WordprocessingDocument.Close() throwing IsolatedStorageException - openxml

I am building up a chart with 582 literal data points. When I call WordprocessingDocument.Close() I get an IsolatedStorageException.
This doesn't make sense to me because the OpenXML SDK, as I understand it, is totally self contained writing data to a stream. There's no calls to Office or anything else that could hit this issue.
Be that as it may, is there anything I can do to avoid this issue?
thanks - dave

I did some research into the IsolatedStorageException related to large XLSX files and found solutions to your problem.
According to Eric White's blog, when legacy OpenXml generates a file larger than 10M it needs to take advantage of Isolated Storage. If mulitple threads access the Isolated Storage during report generation System.IO.Packaging will throw the IsolatedStorageException.
This is because the System.IO.Packaging that is baked into .NET was not written well enough to handle these scenarios. That System.IO.Packaging can't be changed.
To remedy this issue, you can try one of these solutions:
Refactor your code to use a new OpenXml built on a System.IO.Packaging that Eric White refactored to remove the Isolated Storage depedency. Check this chart for reference and use the correct NuGet command to bring in the new version without the WindowsBase dependency.
Don't refactor your OpenXml code, but change your report generation user interface to prohibit (if possible) or discourage generating files larger than 10M.
If your OpenXml code is embedded inside an IIS based web solution and refactoring your code is not feasible, try one of the solutions provided by this blog. These techniques aim to provide permissions needed by IIS to try and get around this exception and might not be related to Eric White's concern.
Without more information about your solution architecture, these are the solutions I can recommend at this time. Hope they help.

Related

MIT-Scratch adding/removing language features

I am seeking a way to allow my non-tech users to specify a workflow and execute it (if anyone is interested, I want them to specify and execute test cases). Visual programming seems a good way to go.
Can I modify the Scratch IDE to remove some categories (such as sound, motion, etc), and add some of my own? Ditto for individual keywords (obviously, I then need to handle new keywords).
I have Googled, but the answer is not immediately apparent.
[Update] I have just found Google's Blockly
Blockly was influenced by App Inventor, which in turn was influenced
by Scratch, which in turn was influenced by StarLogo.
It looks very promising. Especially when it says
Exportable code. Users can extract their programs as JavaScript, Python, PHP, Dart or other language so that when they outgrow Blockly
they can keep learning.
Open source. Everything about Blockly is open: you can fork it, hack it, and use it in your own websites.
Extensible. Make Blockly fit with your application by adding custom blocks for your API and remove unneeded blocks and
functionality.
One possible snag is that it is browser based, but if my management don't like that, then I can create a dummy Windows based app consisting of little but a TWebBrowser component.
I will investigate and report back - unless someone else posts an acceptable answer first.
The short answer to your initial question is: no. You can't customize Scratch, or not to the extent that you seem to ask/want.
That said, look at:
custom blocks.
scratch extensions.
variants like snap
using scratch's source code in squeak to make your own variant.
other systems inspired from scratch, like appinventor and blockly.
Only the first two are compatible with the scratch web site.
A word on the site: depending on your purpose with Scratch, the exchange between users is a powerful part of scratch. Check how cooperation is supported, like the backpack. There's also a good wiki that documents much of the above.

WF4 Custom Persistence Examples

I am writing my own custom persistence instance store for WF4, based on the XmlWorkflowInstanceStore found in the .NET 4 WF and WCF samples. This sample is quite simplistic and the xml is produces is quite verbose. I have issues with how some of the objects are serialized.
I have tried using Red Gate Reflector to understand the Sql implementation used, but it is quite complex and difficult to learn from. The MS documentation for this is rather limited - often giving one sentence descriptions for complex methods.
Please could you point me at other examples of WF4 persistence (or proper documentation) around on the web that are not copy and paste versions of XmlWorkflowInstanceStore? Maybe someone else on StackOverflow has written their own?
You are completely correct that the docs are very much lacking here and the sample is of very limited use. I have started work on a custom instance store using the entity framework but, much like you discovered, found it slow going and am nowhere near anything I could use myself, let alone release onto CodePlex.
I am not aware of any blog posts or other information that help solve this.
You've probably seen this already, but I've found the code quite easy to understand: http://xhinker.com/post/WF4Xml-persistence-store.aspx
Ron Jacobs wrote an in memory persistence store for WF unit testing. Check out http://wf.codeplex.com/releases/view/73842

How can I avoid having to write boilerplate code?

Well, I've been following the NerdDinner tutorial online and I've completed it to a T.
Now I've implemented a project of my own using pretty much the same architecture.
I notice my process is:
Create database.
Create DBML.
Create |TableName|Repository.cs class with data access methods.
Create partial |TableName| class to handle validation.
Rinse and repeat for all tables.
By the time I'm done I'm exhausted and I haven't really done anything except drag and copypaste code and change variable names.
What am I missing here. Where can I improve this boilerplate haze I'm in?
Edit: Sans creating my own T4 template, is there a tool that will help me?
See Visual Studio Templates.
I haven't used them, but I assume if you take the time to customize them, you'll be able to make Visual Studio generate a lot of what you already do instantly specifically using the T4 template language/interpreter thats embedded in Visual Studio.
I haven't used it much but perhaps you could create a codesmith template to handle this. http://www.codesmithtools.com/
I have seen it used to good effect with Nettiers and in some other scenarios.
Have a look at this for ideas. It uses a generic repository and the unit of work pattern.
http://elegantcode.com/2009/12/15/entity-framework-ef4-generic-repository-and-unit-of-work-prototype/
Also here.
Advantage of creating a generic repository vs. specific repository for each object?
I've implemented something based on these ideas. You may also want to look at using a service layer more interfaces etc than the nerd dinner example shows.
As good as the tutorial is, it isn't IMO really fit for use in an enterprise application as it is still quite tightly coupled.
Hope this helps.
I use my own tool for that: http://github.com/Necroskillz/NecroNetToolkit
It basically bypasses all the steps that u mentioned (except validation, because I have validation on my view models).
While its not directly MVC focused, I've enjoyed using NetTiers http://nettiers.com for this kind of foundation. We start with the Db tables and indexing and then generate the stored procedures and their related data and service layer code. After that we add our own custom stored procedures, creating a rich (and easily understood) foundation. Future changes are easily accommodated through this mechanism.
We also bolt the code generation into our Nant build procedures, providing a very quick way of updating all of the mundane 'plumbing' code, allowing us to concentrate on the interesting stuff.
We've just started working with MVC and have found the netTiers service layer works nicely with it - time will tell as our MVC experience grows. I hope that helps!
Create a framework!

Is there any reasons to prefer SparkViewEngine over XSLT (or vice versa) for a standalone email generation?

I have a service that receives an object containing all the data needed to build a newsletter. I need to be able to generate the email using different templates.
I don't want to involve the whole ASP.NET stack for that, so I want a separate templating engine.
Reading a lot of opinions, I have found that XSLT was not getting very much love when it comes to templating engines. Why?
SparkViewEngine is a "new cool toy", but it seems mature enough considering the number of projects that have been built with it. What do you think?
Did you used those 2 engines? in which situation, and what strength/pain did you enjoy/endure
XSLT is much more verbose, especially when it comes to tricks like conditional attributes. I used it a lot (even to generate C#/C++ source code) but I don't remember that time to be a joy. Spark is.
I used a Spark template to generate an email on my last project, it was a fairly straight forward experience.
As you mentioned you have an object containing all the data needed to build a newsletter. To use XSLT wouldn't you need to serialize to to XML first? Using Spark skips the serialization step and gets you directly to the output you want, and as queen3 mentioned, creating conditional attributes is quite easy.
In case you need it, there's a post on how to use Spark as a general purpose templating engine here.
Also if you have to work with any graphics designers it may be easier to take an HTML mockup and turn it into a spark template than it would be taking an HTML mockup and turning into an XSLT.

Looking how to Implement Document Conversion in MOSS 2007

We've been tasked with creating a MOSS workflow that on it's final step will convert a document (most likely from word 2003 or 2007) to PDF and watermark it with the current date.
So far I haven't seen a definitive way to do this. Have looked at using the MS Word Interop dlls, but we will not be installing Word (or Office) onto the server - so that's really not doable. Another option I've looked at is using Aspose dll libraries for conversion.
From a topology standpoint, wondering if using one server exclusively for document conversion is a good way to implement this. (I've read some info that recommends this approach for larger organizations).
If anyone - who has preferable done this sort of thing, can give me some pointers or best practices on this I'd really appreciate it.
Thanks
I would think that starting with one server is the best way to go. Then, just monitor the workload on the machine and if it gets to be too much for one, pop another in there. That's the beauty of MOSS.