automated document creation - c#

Are there any existing solutions to create documents in Silverlight? Looking to create purchase orders, contracts, etc.
Printing is a desired feature.

Consider sourcing from your customer, the template of those purchase orders, contracts, etc. Keep those documents on the server, and save their names/filepaths in the database.
Determine which fields need to be filled by the user, and create form elements (textbox, radio, image upload) for each of those document fields.
When the user has finished entering their data, save the data to a DB, and then programmatically insert their data into the document. You could manipulate a Word document/ text file, and then perhaps use a PDF generator to save in the user's 'inbox' on the server.
This likely is very business specific, so you'll have a lot of customization. Sounds like you were looking for an existing open source solution. Would be interesting to see if your solution ended up as a blogpost or open-source project at CodePlex or SourceForge. It really could be handy for others down the road!

Related

How to persist data in Excel (VSTO) shared among few users?

I have to load huge amount of data, pre-process it, share it among few users and finally gather updates back from users.
This is what I did in my previous project -
Created an excel add-in using C++. Loaded the data in memory using the add-in code and processed it. For each type of data I have sent the processed data to a sheet and saved a new excel file. That way, if I have three types of data, I have created three new excel workbooks. My users then opened those new workbooks, made their changes and dropped a text file that contains their changes (through a button). The main excel keeps polling for those updates (text files) and loads them as soon as they are found. That's the way I get the updates back from my users.
I am not a fan of what I did in my previous project, it produces too many temporary files (of course I can delete those). In my current project I want to use C# VSTO Workbook so I can have more control over excel. I was hoping once I load the data, I will ask my users to open the same excel in Read-Only mode and they will make changes. While testing this, I realized user's excel (opened in read-only) mode does not see the loaded data. And their changes do not update the data held in memory. This probably means I have no idea what I am doing.
Do you guys have any idea how to achieve this? I will really appreciate any help/hint.
Excel supports so-called "co-authoring" mode, when many people can edit the same document at the same time. But there is might be a catch: afaik, you need a Share Point/Office Online server/OneDrive Business to support this scenario (you need a non-free office document server product).
Using VSTO, you can do just the same you have done with C++ add-in, but in C# (means, the set of capabilities is 1:1 - it basically just wraps C++ COM Excel API for .NET)
But for online version of Excel, there may be yet another alternative - javascript addins (now that's called "Office Addins", afaik). But I doubt you'd want to process your "huge amounts of data" with javascript.
So I would say, there is a good rule: Don't fix something that isn't broken :)
If the problem is the number of temporary files, these files is not the only option to transfer data between applications. You know, you can connect two applications directly (so that they can exchange data with messages/updates). Use network, Luke :)
Of course if your 3 users live on 3 deserted islands, totally disconnected from anything, exchanging with text files on USB stick may still be the only viable option...
I think the "web" solution could be: store your file in some "co-authoring"-capable service (sharepoint, google shees, onedrive, officeonline, whatever). Make some web job to update that file in that storage automatically. Just like a "fourth" user would do.

Document search and add engine web application

I want to develop a asp.net web application which should do the following task
a) user should be able to add content to the document. Content to be added can include text as well as image, screen shots etc.
b) user should be able to search based on some keywords. when searching with the keyword appropriate content along with images(if any) should be shown to user.
I am not sure what should be the proper approach for this. One way i think is to store text content in some xml file and later search for keywords by going though each node of xml and displaying. but i am not sure how to attach image content with xml. Also this method doesn't seem to be nice and efficient if with time document size increases a lot.
Anyone please suggest some proper way to do above requirement. Any hint would be appreciated.
Split it to two tasks. Editation and search.
Full text search is solved problem. Simply use Sphinx Search and you are done. Sphinx is simple to use and can do everything you will need. It has MySQL interface (your app connects to sphinx the same way as to second MySQL database).
Editation is a bit more complicated. If I understand correctly, you want multiple users to edit single document concurrently.
I recommend using websockets to notify other clients about changes in document. Long-polling and Server Sent Events have ugly side effects, like stopping browser from making another requests to server. To implement client side in Javascript, I would use React, Angular or similar framework to make updates as easy as possible.
Server side requires modification-friendly representation of a document, so if one user changes one part, and another user another part, your app should be able to merge changes. Changing completely different parts is easy, but it may be tricky to change the same paragraph or document node. Exact representation of each change depends on format of your document.
I do not see much benefits of using XML rather than any other format. It may be practical for document representation, but it will not help with merging of colliding modifications. I would start with plain array of strings, each representing a single paragraph. Extending it to full XML document is the easy part, once two users can edit the same paragraph.
To store images in XML, simply store files using their hash as a file name and then use such name to link the file in XML. Git does the same thing and it works nicely. You may want to count references to identify unused files.

Creating a Save-able "Project" for C#

I am working on a project for visualizing large specialized datasets.
A "Project" consists of two large datasets (that are imported from XLS or CSV) and several other settings and smaller tables. We were planning to store those tables in SQLite (for ease of access).
We would like to allow the users to save a "Project" so they do not need to load the CSV and XLS files again. We would also like to prevent users who get the project file later from tampering with the data. We want managers to be able to create a "Project" file and pass it to other employees (so they can use the visualized data in presentations, but they can not modify it). The program already has the access control built in.
What suggestions do people have about creating this type of "Project" file, preferably based around a SQLite database.
Note: I am asking for advice here because it is impossible to Google for C# and Project. You get Visual Studio how-to results.
Clarification: Imagine this a if you opened Microsoft Word (or OpenOffice Write if your prefer). You can create open and save a "project". You can send a "project" to someone else who has the program. I would like the "project" file not to be usable in a different SQLite client (for data security).
I would not say there is a any kind of template or common structure for those kind of things. Your structure is already good by itself. You may have not only data information, but also meta-information inside database file, specifying (say) user name, data last changed, comments, whatever to make your project/doc file more comprehencive and full of information, keeping constant attention on memory footprint, cause it would be very nice to have a possibility to pass that file to someone by key-drive or send by e-mail.
Good luck.
Could you not create a table that has a series of BLOB data types (for documents) and a read_only boolean field. If you don't know how many docs there will be you need to enter another table called document that links to the project table!

How to read metadata information from docx documents?

what I need to achieve is to have a word document template(docx), which will contain Title, Author name, Date, etc.
This template then will be used by users to complete it. I need to create a c# program, that will take in the docx file and read all the information of interest(title, name, date, ..).
So my questions are:
How do I put the metadata into the template saying: this is Title, this is Date, this is Name, etc? (not programatically)
How do I programmatically read that information?
One way to approach this would be to use Content Controls. In Office, you can create your template, and then for each of your respective inputs of interest you can place one of these controls. They're under the Developer tab in Office.
After inserting your controls you'll need for each of them to have a unique name. Office will let them all have the same name, but you'll need to uniquely identify all of them in your template document.
You now need to get the data that's input in to these controls. Again, there's likely to be some better solutions but Eric White has all kinds of great OpenXML stuff, and so here's one of his: Iterating over Content Controls
I think there's problems with finding content controls nested within a table. So, if you do that, then I think you have to specifically loop over the elements of the table to find content controls within.
Also, you're probably going to want to save a .docx from your .doct file, which I don't think there's any built-in "one-liner" method in OpenXML; however, you can create a new Word document, and then write the file stream of the template in to the newly created docx file. Again, of course, there may be better solutions out there.
Have you been here? There's lots of good stuff:
Introduction to OpenXML
Additionally, Eric has been releasing more and more videos on the OpenXML YouTube channel
1) how do I put the metadata into the template saying: this is Title,
this is Date, this is Name, etc? (not programatically)
You could do that on Info tab in MS Word 2010 as shown below:
2) how do I programmatically read that information?
Once you created your document (or template) you could always look inside it with Open XML SDK 2.0 Productivity Tool (wich is installed with OpenXML SDK) to see where (what classes to use) to get/set some information from/to document.
Also I think this post might help you to solve your task:
Add and update custom document properties in a docx
UPDATE:
Hi Dave,
Please have a look at this MSDN Article - Retrieving Application Properties from Word 2010 Documents by Using the Open XML SDK 2.0
Hope this is exactly what you are looking for.
All OpenXML documents have built in core Metadata that will do what you need through System.IO.Packaging. Once you open the word file using the open xml sdk in c#, you can get to these values via the PackageProperties class. There are 11 Properties you can use.
You "encourage" your user to enter the metadata using Word's Document Information Panel (DIP).
You can force this on by default when they open your template, by a setting in the Developer Toolbar for the template. See the following article on how to set this in your template.
I wrote a quick Windows Form app that displays this information using open xml sdk call to the PackageProperties of the Word file that is displayed above.
Here is the full solution with the sample word file included.
Hope this helps.

CRM 2011: How to programmatic create document using mail merge template?

I created some mail merge template. It should create some email and sent to some contact. Template is using 'contact' entity.
How to create document from code using that template?
And, for example, send mail to specified contact.
MailMerge in CRM is a bit of a funny one. You upload a Word template (using a wizard) to create the MailMergeTemplate entity, during this process CRM will then inject a little macro into the document.
Downloading the document merged with data, actually just pushes the data into an HTML table that is placed as a comment in the word document, when you open the document (and go through the Word Mail-merge wizard again) the data is moved by the macro from the comment into the form fields.
So if you wan't to complete your mailmerge, you need both the template (stored as an xml blob in CRM), at this point I chose to insert the data manually (so I can't help you getting the sdk to inject the HTML table) by manually creating my own html table of data in a separate file (you need the entity data stored against display name and the calling user entity also against display name but prefixed with User_), you can then simply use the Word SDK to start and finish the mail merge in an automated way.
FYI the technique I used isn't supported by microsoft because Word churns out too many error messages to be automated so I got around this by installing a ClickOnce app on clients that did the merge so there would always be a user present. If you wan't to merge on a server, prepare to wage battle with DCOM also.
I've come across this a few times. When you say document, do you mean a Word attachment?
If so, this isn't a CRM thing, its a Word thing.
Similar Stackoverflow questions are a good place to start.
To get it working is complicated. Once you have populated your Word document, you have to get it back into CRM. It's messy...

Categories

Resources