Blogs
-
How to Print using Acrobat Reader X by Command Line Arguments
by Damian Sinay on 12/19/2011 – 0 comments
In this post I will cover how to print a PDF document with Acrobat Reader X using Command Line Arguments in Visual Studio 2010.
Using C# - WPF
Common Declarations:
public string PrintPdf(string FilePath)
{
//The name of the Printer we are going to use
//This name is taken from App.Config for after deployment edit
string printerName = ConfigurationManager.AppSettings["PrinterName"];
//Path to Acrobat Reader X
//This path is taken from App.Config for after deployment edit
String pathToExecutable = ConfigurationManager.AppSettings["AcrobatExePath"];
//Now we pass the arguments For Printing to the ProcessStartInfo Constructor
//We are using the Parameter /t <filename> <printername> <drivername> <portname>
//To Print the file the specified printer
ProcessStartInfo myProcessStartInfo= new ProcessStartInfo(pathToExecutable, @"/t """ + FilePath + @""" xps """+ printerName + @"""");
//Open the process and set the StartInfo to myProcessStartInfo
Process myProcess = new Process();
myProcess.StartInfo = myProcessStartInfo;
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.CreateNoWindow = true;
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
myProcess.Start();
System.Threading.Thread.Sleep(2000);
}
Now if we want to use the Microsoft XPS Document Writer and don't want user interaction we should do the following:
public string PrintPdf(string FilePath)
{
//Set the Output File Path
string outputFilePath = FilePath.Replace(".pdf", ".xps");
//The name of the Printer we are going to use
//This name is taken from App.Config for after deployment edit
string printerName ="Microsoft XPS Document Writer";
//Path to Acrobat Reader X
//This path is taken from App.Config for after deployment edit
String pathToExecutable = ConfigurationManager.AppSettings["AcrobatExePath"];
//Now we pass the arguments For Printing to the ProcessStartInfo Constructor
//We are using the Parameter /t <filename> <printername> <drivername> <portname>
//To Print the file the specified printer
ProcessStartInfo myProcessStartInfo= new ProcessStartInfo(pathToExecutable, @"/t """ + FilePath
+ @""" """ + printerName+ @""" /t """ + outputFilePath + @"""");
//Open the process and set the StartInfo to myProcessStartInfo
Process myProcess = new Process();
myProcess.StartInfo = myProcessStartInfo;
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.CreateNoWindow = true;
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
myProcess.Start();
System.Threading.Thread.Sleep(2000);
}
This Method will print an XPS document using Microsoft XPS Document Writer without user interaction at all.
I got some references from here:http://stackoverflow.com/questions/619158/adobe-reader-command-line-reference
http://bytes.com/topic/c-sharp/answers/256956-printing-pdf-process-start-without-user-prompt
-
New CRM 2011 SDK available for download
by Damian Sinay on 12/19/2011 – 0 comments
On December 12 Microsoft released a new version of the Microsoft Dynamics CRM 2011 SDK
You can download it from this link
http://www.microsoft.com/download/en/details.aspx?id=24004
The new features that this version of the SDK comes are the following
- There is a new version of the metadata browser 1.0.3. It is no longer added in the sitemap as before and now you can launch it and use it directly from the solution in the Configuration page.
- There is a new version of the metadata browser 1.0.3. It is no longer added in the sitemap as before and now you can launch it and use it directly from the solution in the Configuration page.
-
How to change the product key on a Windows 2008 R2 Server Core
by Damian Sinay on 12/14/2011 – 0 comments
By default the windows server 2008 core comes with a dummy product key that you must change before 28 days or so.
To change the product key run this command
start /w slmgr.vbs -ipk ABCDE-FGHIJ-KLMNO-PQRST-UVWXY
where ABCDE-FGHIJ-KLMNO-PQRST-UVWXY is your product key
To activate the product key run
start /w slmgr.vbs -ato
to check the license and the activation state you have run this
start /w slmgr.vbs -dli
found this useful information in this site:
http://blogs.dirteam.com/blogs/sanderberkouwer/archive/2008/04/01/activating-server-core.aspx
-
How to deactivate ValidateRequest
by Damian Sinay on 12/12/2011 – 0 comments
Microsoft offers by default a way to prevent any person entering in our input box some weird character that causes harm to our website, for example any script:
When you click the button we'll have this:
This is good to avoid some scripts entry in a blog for example, but this is not good when you have to save in the database an auto generated password (p<!kj1fg) with this rare characters. In this case you don't need this. To deactivate this you have two ways:
-If you need it in certain pages, add ValidateRequest="false" in the Page section:
-If you need it in all pages, add in the web.config pages section this:
In any of these options you need to add this in the web.config httRuntime section:
Enjoy it!
Original source:
http://stackoverflow.com/questions/2673850/validaterequest-false-doesnt-work-in-asp-net-4
-
Word Automation in ASP.NET
by Damian Sinay on 12/09/2011 – 0 comments
Automating Microsoft Office Word 2010 is very easy and very detailed for any windows application or even when running an ASP.NET application inside the Web Server that comes with Visual Studio 2010 looks to be easy. However when we deploy our solution to a windows server 2003 or 2008 nothing works. The tweak is to touch some registry values and configure some DCOMs as explained on this post
http://forums.asp.net/t/1358207.aspx/1
- First, use regedit (from the SysWOW64 folder) to search the registryfor the CLSID(s) related to the command "WINWORD.EXE /Automation" , you might find more than one of them.
(in my case this was: {000209FE-0000-0000-C000-000000000046} and {000209FF-0000-0000-C000-000000000046})
Under those keys in HKEY_CLASSES_ROOT\CLSID\, add a string value AppID = {same value as the IDs}
Then under HKEY_CLASSES_ROOT\AppID\ create a new key (folder) for each of these IDs, and inside each of them add a string value: RunAs = Interactive UserNext go to Dcomcnfg (from the SysWOW64 folder) and search for those IDs. (there might be a third ID related to Winword.exe), in my case this was {00020906-0000-0000-C000-000000000046}.
Note all those IDs, then right click on each of them, Properties, Security, and edit both the launch & access permissions to add and give Network Service and Interactive full permissions.
- First, use regedit (from the SysWOW64 folder) to search the registryfor the CLSID(s) related to the command "WINWORD.EXE /Automation" , you might find more than one of them.
-
Redirect To A Custom Page After Completing A List Form
by Damian Sinay on 12/05/2011 – 0 comments
As we know, Sharepoint make us easy let the end user populate a list with data though List Forms.
These are out-of-the-box features that Sharepoint design for us.
Well, using these Forms I came across with the fact that after submit the form, Sharepoint redirect you to the List that the form belongs to.
This is a problem. Generally we don't want the user read the information on this list.
So, how can we avoid it and redirect the user to a custom page?.
Go to the page where you have placed the List Form.
At the end of the Url you will have to add the following Query String.
• ?Source=%2F Containing Folder%2FPageName%2Easpx&RootFolder=
Note that the query string is basically the url of our custom page, using '%2F' instead '/' and '%2E' instead of '.' .
You will se that after submit this form you will be redirected to you custom page.
So, what remains for us to do is add the query string to the link that calls the page. For example:
NOTE: You will find on internet different solutions to do this same thing, for example, replacing the 'save' button with this Input control:
<input type="button" value="submit" name="btnSave" onclick="javascript: {ddwrt:GenFireServerEvent('__commit;__redirect={}')}" />
This input seems to work, but when you add validators to the fields, it fails to check the conditions before to redirect you to the custom page.
-
Simple Column Validation in Sharepoint 2010
by Damian Sinay on 12/05/2011 – 0 comments
In Sharepoint 2010 we can easily validate the column values entered into list items.
We have two levels of validation:
- Column level
- List level
and the description of each of them:
http://officebeta.microsoft.com/en-us/sharepoint-foundation-help/CH010372694.aspx
I will show two simple examples of how to use column validation, at column level and at list level.
Example 1 : Column Level Validation.
- Create a new column on a list, click 'column validation':
- Into the 'Formula' text area add a validation Formula. For example, I'll add a very simple E-mail format validation:
Note that into 'User message' text area you can enter the message you want the user see when the validation is not passed.
Example 2 : List Level Validation.
- In the List Settings, click on 'Validation Settings'.
- Into the 'Formula' text area add a validation Formula. For example, this formula check that Value3 is the biggest and Value2 is bigger than Value1*.
About Conflicts:
We have to take into account that Sharepoint evaluate firstly the 'Column Level' Formulas and then the 'List Formulas'.
So, what if List and Column level validations are in conflict?.
For example:
•On the one hand we have the following List level Validation:
[Column1]>[Column2]
•On the other hand we have the following Column level Validation:
[Column1]=100
[Column2]=200
As a result of the conflict, in this case, it will impossible to submit a list item.
References:
http://officebeta.microsoft.com/en-us/sharepoint-foundation-help/CH010372694.aspx
http://blogs.pointbridge.com/Blogs/2010wave/Pages/Post.aspx?_ID=5
-
Using Forms To Fill In A List
by Damian Sinay on 12/05/2011 – 0 comments
Using Forms To Fill In A ListAs we know, Sharepoint 2010 offers us many out-of-the-box features that make us easier the development of our web site.
One of this features are the Forms that Sharepoint design for us to populate a list with data.
Suppose you want to add a form in your site so the people can leave you a message. Well, this is what you have to do:
1 - Create a list with the columns you want the user complete.
2 – Right, at this point we will need to use the Sharepoint Designer. You have to open the page you want to place the Form and insert a 'Custom List Form'.
To do this follow these steps:
• Go to 'Insert Tab' at the Ribbon.
•Under Control Section select 'Sharepoint'.
•Select 'Custom List Form…' , at the bottom of the window.
•Select the list you want to the user fill in.
• Sharepoint will insert into your page the same form that it is used to add an item to the list. This form can be customized.
•After this you are done. The user can complete the form and submit it directly to your Sharepoint list!
-
Redirect To A Custom Page After Completing A List Form
by Damian Sinay on 12/05/2011 – 0 comments
Redirect To A Custom Page After Completing A List FormAs we know, Sharepoint make us easy let the end user populate a list with data though List Forms.
These are out-of-the-box features that Sharepoint design for us.
Well, using these Forms I came across with the fact that after submit the form, Sharepoint redirect you to the List that the form belongs to.
This is a problem. Generally we don't want the user read the information on this list.
So, how can we avoid it and redirect the user to a custom page?.
- Go to the page where you have placed the List Form.
- At the end of the Url you will have to add the following Query String.
• ?Source=%2F Containing Folder%2FPageName%2Easpx&RootFolder=
Note that the query string is basically the url of our custom page, using '%2F' instead '/' and '%2E' instead of '.' .
You will se that after submit this form you will be redirected to you custom page.
So, what remains for us to do is add the query string to the link that calls the page. For example:
NOTE: You will find on internet different solutions to do this same thing, for example, replacing the 'save' button with this Input control:
<input type="button" value="submit" name="btnSave" onclick="javascript: {ddwrt:GenFireServerEvent('__commit;__redirect={}')}" />
This input seems to work, but when you add validators to the fields, it fails to check the conditions before to redirect you to the custom page.
References : http://www.graphicalwonder.com/?p=666
-
Installing Hyper-V in a windows 2008 R2 Server Core Setup
by Damian Sinay on 12/02/2011 – 0 comments
Ok, so I have a goal to install a new server with only the Hyper-V role on windows 2008 server core setup which is the best recommended way to take all the advantages of the Server resources and hardware.
My surprise was that after installing the Windows 2008 R2 Core server I only got a command prompt window!!!
So, how do I enable Hyper-V, looking at different blogs I found this one which told me the right steps.
Thanks John!
Basically the command to run at the command prompt is
ocsetup Microsoft-Hyper-V
Ok, so after restarting the server I got the same command prompt back again, how do I open the Hyper-V manager?
You will need to use another client computer with for example windows 7 and download and install the Remote Server Administration Tools for Windows 7 with Service Pack 1 (SP1)http://www.microsoft.com/download/en/details.aspx?id=7887