Using an editor like FckEditor in a form application - c#

I am working on a contract management system on c# form application, one of the main parts of the project is to create a letter.
In this part of the application a user can send a letter with in the shape he or she wants, so I need an editor like FCK in html, because my users should be able to insert table insert image and etc.
Any idea how to get this working? Any concerns?

You could indeed use a HTML WYSIWYG editor, but depending on the quality of it, it might raise problems when converting the output of it to print. This may also depend on the framework used to generate the Word document.
In one of our environments, we use CKEditor and JasperReports. That combination is suitable to export to Word, since JasperReports supports reading HTML and convert that to Word.
However, the best solution may depend on your business requirements and personal preferences.
If the application is a business application, another option is to let them edit the document in Word. Our company (disclaimer: I am biased) has build a product that supports editing a Word document from a template loaded and filled from a database (or multiple databases). However, if it is useful to you depends on your business requirements.

FCK is history now and as mentioned by others CKEditor is the successor. TinyMCE would be another alternative, or any other might be..
But what I want to mention is along with possible printing issues (that I have never dealt with) I want to underline another aspect:
my users should be able to insert table insert image and etc.
uploading and inserting images might be another issue...they don't come with a built in uploader, they sell it. you have the option to buy CKFinder along with CKEditor and Moxiemanager along with TinyMCE unless you choose to handle upload and insert into the editor process yourself.

Related

Yet another .net custom cms

I'm trying to switch my custom cms written in php into .net c#. I was thinking to use cms as a learning project. I'm going to use C#, NHibernate ORM layer, mssql, mvc3 and jquery.
I'm aware there are plenty of commercials or open source cms, but still I'm going to spend some of my free time trying to learn new technology working on project like this.
So, is there anyone out there who is willing to share some ideas on creating cms domain model, usefull link, ideas, etc.
Thanks
A really basic CMS consist of 3 elements:
one database table to hold your "pages". The table structure is "name" and "content"
a route to transform requests of type /cms/pagename to a fixed controller, the method called cms and pagename as a parameter
a embeddable html editor
Now, there are two ways your "page" can be invoked. It is either create mode or view/edit mode.
In "create" mode, the page is requested but it is not in the database yet (e.g. cms/announcement1). In this mode you create a view consisting of a html editor and upon submit, you persist the page to the database.
In "view" mode, the page is requested and is IS in the database. You perform any necessary rewriting (for example you rewrite internal links of the form [cms/pagename] to a fully routable http address) and render the content.
If the user is authorized to edit the page, you also show a "edit" button which then invokes the html editor with the page loaded and ready to be edited.
And that's it.
There are tons of additional elements (caching, different built-in page types, embedding images, youtubes, preformatted texts) etc. but all of them are optional and you can introduce new features when you have the core already implemented.
Once I wrote a simple CMS following the structure above, it was a part of a bigger solution and till now it's been sucesfully deployed several hundred times. An advantage of a custom CMS is that it can be really simple and easily maintanable.

Preset html files built into program?

I'm trying to create a very basic web site creator in C#. I already created the templates but have no idea how to get them in the program so the user can pick one and customize it. Is there a certain library I should look into? I've bee told this can be easily created in php but I'd rather not go down that route.
If using .NET you can use WebControl controls to display a preview of your templates and make the user decide which one he wants.
Or a list of templates and single WebControl that parse and display the HTML of the current selected list item (template) and then make the user select.
To edit, just a bunch of controls (one for each template placeholder) that updates the view of the WebControl.
In the top link you found how to do it.
P.S. Templates can be stored on XML, Plain Text, DB or any other mean.
Either store the templates as files on the web-side and use them as templates, or store them in a DB. Unless your app is not web-based, in which case the same advice pretty much applies.

How to write a simple designer for printed reports

I'm currently having a couple of reports which I print from my Forms applications.
However building printed reports only with the built-in .NET printing methods is very tedious. Even just printing a simple table on a couple of pages with a little bit of formatting is a task for a couple of hours (if it should look nice).
What I need is a WYSIWYG-Designer for the layouts, so I'd like to write one.
It shouldn't be for End-Users, but for me as a developer, it's just about to create the layout what the report will look like with various arrangements/fonts/images/formats and so on and not have to do that by trial & error in code (and restart the app a zillion times).
So my specific questions:
What would I use as a canvas for editing and display of the report? An image-control/bitmap which I draw upon like on the printed document? Is there a better way?
Is drawing on a form comparable to drawing on a printed page? What about differences in resolution printer vs. screen?
How to get real WYSIWYG? Should I get the printer settings and create my canvas with the same resolution? Is there something else to consider?
I know that there are report designers around but I think it's sometimes good to understand the basic working principles of what you use and implementing them is for me the best way to do that.
I'm aware that this is not a specific question A to which the answer is always B, but if it were that way I would find an answer in Google pretty quickly.
Thanks in advance!
I can't say much about designing a WYSIWYG editor, but I have written a few custom in-house reporting engines for use by our development team.
There's two main ways I've created reports. The first is using PDFsharp (MIT-licensed) to manually layout pages which isn't for the faint-of-heart.
The second is using Winnovative's HTML to PDF library (not free, but royalty-free) which uses the current installed version of IE to do the layout and spit out a PDF. It looks like they've recently released a new version called EVO PDF which I have never used before.*
For the HTML to PDF solution, it supports JavaScript so you can add in charts from JavaScript libraries like flot or jqplot.
*I'm not affiliated with Winnovative.
You might want to save time and use Visual Studio HTML designer as your WYSIWYG editor.
What I'm currently doing is using ASP.NET MVC 3 as a simple reporting engine. You can use the MVC pattern to really separate your reporting data source (Model) and the rendering (View) while using Visual Studio as your report designer.
From your application you can easily call your actions with the report optional parameters. For example:
http://localhost/Report/Customer/Orders/1
You simply get the returning string from a WebClient's DownloadString method and you have your report generated.
There is some down side using HTML, mainly the difficulties to know when a page would break, but by using code in your View you can calculate the amount of repeating items and add a CSS break-page and re-starting your table's header on the next page.
You can achieve anything from graphics, to table, you can even generate link to other reports.
HTH.
Printing Reports in Windows Forms
http://msdn.microsoft.com/en-us/library/ms996472.aspx

Searching the name of web pages according to the word entered in a textbox

I have a textbox and a button in one page.I want to enter a word in the textbox and click the button. After clicking the button I want to display the name of the web pages containing the word entered in the textbox. So please tell me how to do it? I am using C#.
So you want to create a search engine internal to your website. There are a couple of different options
You can use something like google custom search which requires no coding and uses the google technology which I think we all agree does a pretty good job compared to other search engines. More information at http://www.google.com/cse/
Or you can implement it in .net which I will try to give some pointers about below.
A search engine in general exists out of (some of) the following parts:
a index which is searched against
a query system which allows searches to be specified and results shown
a way to get documents into the index like a crawler or some event thats handled when the documents are created/published/updated.
These are non trivial things to create especially if you want a rich feature set like stemming (returning documents containing plural forms of search terms), highlighting results, indexing different document formats like pdf, rtf, html etc... so you want to use something already made for this purpose. This would only leave the task of connecting and orchestrating the different parts, writing the flow control logic.
You could use Lucene.net a opensource project with a lot of features. http://usoniandream.blogspot.com/2007/10/tutorial-implementing-lucenenet-search.html explains how to get started with it.
The other option is Microsoft indexing service which comes with windows but I would advice against it since it's difficult to tweak to work like you want and the results are sub-optimal in my opinion.
You are going to need some sort of backing store, and full text indexing. To the best of my knowledge, C# alone is not enough.

How to restrict download options on a single report in SSRS?

This question asks how to restrict for a whole server. I just want to do so for a single report. I found a code snippet but it doesn't provide any clues on how to implement:
foreach (RenderingExtension extension in this.reportViewer.LocalReport.ListRenderingExtensions()) {
if (extension.Name == "PDF") {
((Extension)(extension.GetType().GetField("m_serverExtension", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(extension))).Visible = false;
}
I can't see how to make the report reference this code upon loading. Does anyone know how I am supposed to make the report execute this code?
EDIT: Incidentally report access is through the SSRS Report Manager web app. We are, in the main, delighted with this product so wouldn't consider reinventing the wheel in order to implement a hack to produce what is, essentially a "would be nice" feature.
It still boggles the mind slightly that the report's available rendering options are not controllable at the report level. Ho hum.
Incidentally I found this blog entry which clarifies the above code a little. Turns out we're talking about using a reportviewer component to limit the export options. Apparently this requires a dirty, dirty hack and besides it's not how we want to run our reporting function.
So unless anyone has a better idea than this within the next fortnight I'll mark this as the answer which basically sums up to:
You can only restrict functionality like this under certain conditions and by no means easily even when you do.
This seems like a clear failure in the wider fitness of SSRS for purpose as we have users who require Excel export functionality and users who need to be limited to PDF only. Oh well.
Does it matter?
Once they've downloaded the data and taken it offsite, you've lost it anyway.
You haven't really described how you are calling the reports - have you created some kind of application? Are you actually using the report viewer control?
You can generate a report in a specific format using the report URL and including the rs:Format parameter, e.g.
http://SERVER/reportserver?%2fSomeFolder%2fSomeReport&rs:Command=Render&rs:Format=PDF
The above URL generates the report as a PDF. You can also use the URL to hide the report toolbar etc. so you could create these URLs as links in your application, maybe one using just rs:Command=Render as a "View Report" link and one link that includes rs:Format=PDF as an "Export to PDF" link.
More on Reporting Services URL access.

Categories