Entries:
Comments:
Posts:

Loading User Information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading User Information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Discussions

itsnotabug itsnotabug
  • Are emoticons racist?

    , wkempf wrote

    Seeking greater racial diversity != Apple thinks emoticons are racist.

     

    true. this is a non-story.

  • Is Microsoft Halting Development on WCF Data Services

    that's unfortunate if true. imo, wcf data services is very flexible and easier to bolt onto legacy asp.net than webapi.

  • Report: Microsoft In Talks To Acquire Xamarin

    the biggest obstacle with ios development on windows is the requirement to build against apple binaries. if they remove that obstacle by either providing a "macbook-in-the-cloud" or a totally hands-off compilation step, i would be on that in a second... seems like a great way to get more people into azure hosted services. imagine tight VS integration with 3 or 4 different project target types with seemless cloud-build functionality for windows phone, android, ios, etc... PCL for business logic, platform-specific project templates for ui bindings... the number and quality of windows phone apps would increase as the marginal cost of developing a windows phone app in addition to ios/android would be small. this would be my dream scenario, but then again, this is all rumor at this point.

  • Should Node.js replace Web API?

    webforms is still very big in enterprise and i don't see that changing any time soon. there are too many old vb6 guys who migrated to webforms who would be lost doing anything else. webforms are also a little easier to secure "out-of-the-box" than a bunch of http endpoints if you don't know what you're doing. if you do know what you're doing, then yes, you can do anything on a webform, especially if you use the webform as simply an html/js delivery mechanism. if you remove all unnecessary httpmodules, turn off viewstate, ignore the Page event model, and enable static ids (or better yet, don't use any server controls at all), you can get excellent performance/throughput. this is a trend i've noticed as business users are asking for modern js/css ui features but the business unit cannot get away from webforms for whatever reason.

  • multi-​channel sample step ​sequencer/t​racker in c#

    @dentaku: well, there are people who care about music and dsp on windows but they're all doing it native. it's funny, i see a lot of libraries in java for midi and audio, just not a lot out there for c#. last i read, java vm performance is close to c# vm performance so i don't know why that is... could it be the people who would be most interested in doing foss midi/audio tend to favor the platform less bound to a specific ecosystem? i know mono eliminates that argument, but maybe the perception is still out there.

  • Microsoft want to "win back our game developers" with something ...

    metro was purposefully forced were it didn't belong in order to leverage the desktop's popularity into wider adoption of windows on a tablet. this was a gamble and i think they lost, but instead of going back, it seems like they're doubling down.

    i wish it would just boot into whatever expected UI for whichever form factor the OS is running on and kept polishing the desktop as the excellent productivity tool it is.

  • Should Node.js replace Web API?

    , RealBboy360 wrote

    *snip*

    Yes, but that goes back to my initial point.  If Node.js can't do it, then Web API probably can't so use WCF.

    MVC has some nice things that adds to HTML5/Javascript, but MVC is still just HTML5/Javascript.  For somethings, it might take a little longer to code, but everything can be done and plug-ins can be added.

    If you're going for speed to develop a LOB application, nothing beats ASP.NET with something like Telerik controls.  Also, I'd see the MVC crowd abandoning MVC for something new before the webforms people.

    As for ORMs, who cares, you're passing back json anyway.   Well I'm an ORM hater anyway.  I like to actually write my queries in sql to see what's going on and make sure i don't get an surprises.

    ...well there is that whole decade + worth of mature .Net code you'd have access to ;)

    i kinda get what you're saying about writing raw sql. i don't like too much magic either. check out some of the micro-orms like petapoco or dapper. with the use of t4 templates, they give you the rich statically typed experience of an orm with the ability to extend your entities (using partial classes). Zero magic.

    I'd rather write something like DB.Save<MyNicelyTypedClass>(MyNicelyTpedObject) than the dozens of lines to figure out upsert logic from your primary keys.

  • Should Node.js replace Web API?

    wcf is much bigger than the web. you can do .net remoting, com interop, lot's of different types of endpoints with rich meta-descriptions of interfaces so clients can easily get what they need to know about a service. i think mvc was a reaction to the rapid rest-like development that was hot with ruby on rails at the time, so they bolted a framework onto existing asp.net/iis. i think webapi represents a ground-up approach on how ms SHOULD do rest-like development. whether you like it or not, node.js is hot right now, so the decision to go with it for azure is likely a marketing thing. if you're already bought into the ms stack, chances are you're going to use azure anyway if you needed cloud, so the marketing right now is focused on getting those other guys who wouldn't otherwise be considering azure. if i had the luxury to start a brand new project with my choice of tech, i would go mvc/iis (webapi is just too different for me to learn it all right now), but enterprise developers rarely have that luxury. i might even go with wcf data services. you get odata and other nice rest-like features, but it's still on the back on the familiar asp.net iis stack.

  • Xbox One/Windows 8.1 Project Spark Game Development

    wow, where did this come from? there are some impressive looking demos people have created with it already out there. i know the visual programming paradigm is always an inch deep, mile wide, but i really like the ui they've created for the object "brain". if they open up some real scripting abilities, something like this could be really cool to prototype on.

  • ASP.NET Create Word.Docx file?

    a cheap way to go about it is to use a simple find/replace pattern with well-defined {MERGE} fields embedded in the regular docx instead of using real mail merge (literally just type unique "{FIELDTOREPLACE}")

    you can use the openxml sdk 2.0 to work with the xml based file instead of the real mail merge functionality in the word application. do not try automating the word application on the server.

    i think you'd need windowsbase and openxmlpackaging referenced at the very least for this to work, something like...

     

    public string MergeDoc(string wordTemplatePath, string wordOutputPath, List<KeyValuePair<string, string>> MergeFields)
    {
    try
    {
    
    //Create instance of our template in the output location
    File.Copy(wordTemplatePath, wordOutputPath, true); //overwrite = true
    
    using (WordprocessingDocument wordOutputDoc = WordprocessingDocument.Open(wordOutputPath, true))
    {
    string docText = null;
    using (StreamReader sr = new StreamReader(wordOutputDoc.MainDocumentPart.GetStream()))
    {
    docText = sr.ReadToEnd();
    }
    
    foreach (var kv in MergeFields)
    {
    //Swap the text out, key is something like {PLACEHOLDER}, value is "My new text" 
    docText = docText.Replace(kv.Key, kv.Value);
    }
    
    using (StreamWriter sw = new StreamWriter(wordOutputDoc.MainDocumentPart.GetStream(FileMode.Create)))
    {
    sw.Write(docText);
    }
    
    
    }
    
    return wordOutputPath;
    }
    catch (Exception ex)
    {
    
    // logit
    return "";
    }
    }

    then you can test for the returned merged path and serve it up in the response stream ala...

    var MyNewlyMergedFile = MergeDoc(Path.Combine(TemplateFolderName, filename), Path.Combine(OutputFolderName, filename), MergeFields);
    
    byte[] byteArray = File.ReadAllBytes(MyNewlyMergedFile);
    
    Response.Clear();
    
    Response.ContentType = "Application/msword";
    Response.AddHeader("Content-Disposition", String.Format("attachment;filename={0}", filename));
    Response.BinaryWrite(byteArray);
    Response.Flush();
    Response.Close();
    Response.End();

    this works with formatted text too. the only quirky thing is line breaks in address blocks if you don't need Address2. Environment.NewLine doesn't work so you'd need to add the literal xml tags that define a line break if you want to replace the merge field with a block that contains a line break ("<w:br />")

     

    **** edit **** it just occurred to me that docx files are just zip files containing xml. if you change the docx extension to zip, then drill down to \word\document.xml, you can probably get away with just replacing your merge fields in there. you probably don't even need to use openxml sdk or windowsbase for that. i'm too lazy to test for performance differences between using the sdk or manually unzipping, but i'd bet the sdk is faster. just an option if you feel you cannot use the sdk or other 3rd party libraries.