Profilo di Ashish"Getting better never st...FotoBlogElenchiAltro ![]() | Guida |
|
22 novembre Software engineer and the social serviceI have been working as a .NET developer for quite some time now. I always wanted to be a doctor. I thought that is the most nobel profession you can ever have. Because when your loved one is sick you look up to that doctor after you pray to the god. So, if you are a doctor, you have the best opportunity to serve the human kind and the society. Now I could not be a doctor of course :-). Recently I heard Jeffery Ritcher saying that he wanted to write books because he thinks that when he write books/articles, he is helping people. Because he runs into people who say that they got a job when they read his book and they learnt how garbage collector works. So, he feels incredibly awesome that because of his book, somebody got a job and could support family and children and he helped in that. He also comes across some people who say that this software which is running in this hospital, they learnt how to work with virtual memory from his book and they put that in that software and that makes him feel that he is making a massive impact to the society with this little contribution to the hospital helping people's lives. He says that this is the reason he writes books because he is helping the world to be a better place. What a nobel thought and no doubt why he is a hero many developers like me! Now we all know that we all can't be a Jeffery Ritcher. But It gets to me this thinking that you can serve society this way (or can think some other ways), something which I never thought of. hmmm... 02 ottobre Difference between RPC and Document-Centric/Message Oriented applicationWith Document/Literal encoding/ Message oriented application, the payload of a message is an XML fragment that can be validated against the corresponding XML schema, for instance: <?xml version="1.0" encoding="UTF-8"?> RPC (remote procedure call)/Literal more closely corresponds to remote procedure invocations. <?xml version="1.0" encoding="UTF-8"?> One important difference between RPC and Document web services is that with RPC web services, XML schema will only be created for complex type parameters. It is thus not possible to validate the entire XML fragment contained in the SOAP body. 20 settembre SQL Server –Error - The FOR XML clause is not allowed in a INSERT statement. - Returning the result of a FOR XML, ELEMENTS in a dynamic query to a variableProblem :- When you try to execute a dynamic query having the FOR XML AUTO like this (ignore the query itself for now, you can find the complete script at the end of this article):- DECLARE @Data2 TABLE(col xml) You get an error like the following "The FOR XML clause is not allowed in a INSERT statement.” From http://msdn.microsoft.com/en-us/library/aa226520(SQL.80).aspx:- The above is applicable for SQL server 2005 as well. Very annoying… However, if you have something like below, the query would get executed successfully:- SELECT @Query= 'SELECT ( SELECT Customer.CustomerID,Address.FullAddress,Phone.PhoneNumberFROM #tempCustomer Customer JOIN #tempAddress Address ON Address.CustomerID= Customer.CustomerID JOIN #tempPhone Phone ON Phone.CustomerID= Customer.CustomerID FOR XML AUTO, ELEMENTS ) '
Notice that I prefixed the query with ‘SELECT(‘ and suffixed it with ‘)’. This would allow the query to execute but to return the data in text format rather than XML. However, you can have the result stored in a column of XML data type of a temporary table/variable and It would appear as if the result was XML. So we need to stuff the prefix and then the suffix in the query. Here is where the STUFF function would come to rescue. It is different from REPLACE function as it allows you to replace a specific instance of a character for a length. The complete query :- (Just run it) /* Temporary table to hold sample data. Forgive me for not using the table variable as they would be out of scope when I would use them in the dynamic query*/
if OBJECT_ID('tempdb..#tempPhone') is not null /* Insert sample data*/ /* Build the dynamic query*/ /* There can be many 'SELECT' in the query, we need to get the last one as that would be the one 19 settembre Procrastination
The problem This is how I try to overcome this?
06 settembre Programmatically showing only the custom styles in the style pane of a Word 2007 file
The project in which I working nowadays is a content authoring and management system and makes extensive use of Word 2007. The system has two parts in context of the problem I am going to discuss about – One part where the Admin uploads a Word 2003 (.doc) file containing all the custom styles created in there into the system. Let us call this file as a word template. The second part is where the user uploads his own content files Word 2003 (.doc) files in the system. When the user uploads the content in the system, the styles from the word template gets into the to the uploaded content file (more on this later). This facilitated the styles being introduced in the system only once (or whenever the Admin wants) using the template and the same styles getting used in all the content files without having the user to recreate them in each content file. This also offered the consistency in the styles used in the content files used in the system. Problem :- When the user uploads the content and then later opens the content for editing, he was seeing the inbuilt styles as well and they wanted only the custom styles and “Clear Formatting” option to be seen in the content file. Silly , isn’t it. But this is was requirement.:-) Just to make sure we we are all clear on what an in-built and what a custom style is :-
Open Word 2003 and choose Format > Styles and Formatting and what ever styles you see in the style pane are all in-built styles. And you can create a new style by clicking on the “New Style” button. I created one “MyCustomStyle”. So this is the custom style in my file. I need to take the attention back to my following line which I mentioned earlier :- “When the user uploads the content in the system, the styles from the word template gets into the to the uploaded content file (more on this later). “ The way we do this is following :- 1. Convert the template word 2003 file to word 2007 format using a third party component named “Aspose.Words.dll” (www.aspose.com) Just in case you are not aware, a Word 2007 file is an archive/zip file. You can rename any Word file (.docx) to zip file and extracts its contents as if it was a Zip file. When you look into the contents of that zip file, you will see each component of the word 2007 being represented by a file. Read about this here. All the above four steps happen while the user attempts to open the file and when the file was ultimately opened, he sees the inbuilt styles as well along with the custom styles which is the problem. When I started looking into the problem(an you, dear reader must have realized by now for sure), it seemed that user can always filter the custom styles:- However, this is exactly what the users of the application did not want to do. So the effort of convincing them was in vain. So, first I started looking at if Aspose.Words.dll offers any API to change the filter to show only the custom styles in the word 2003 file, when we convert the content 2007 file back to 2003. It turns out that It does not and a request for incorporating that change would take months. I started looking at any other commercial product which would do a better job than Aspose and even the using Office Migration Utility(OFC) and wordconv.exe (comes with the Office compatibility pack). Those did not help either. So then I looked at if we can find something in the files in the content word 2007 archive itself. There must be something in that archive which is telling Microsoft Word 2007 which types of styles to show in the style pane. I came across an article at http://msdn.microsoft.com/en-us/library/documentformat.openxml.wordprocessing.stylepaneformatfilter(office.14).aspxWhich states that For this , the w:stylePaneFormatFilter element in the settings.xml of the docx file can have the following values:- To test this, I created a new file in Word 2007 and created a new style named “MyCustomStyle” in it. Then I rename that .docx file to .zip and then unzipped the same:- and extracted and navigate to Word folder to see the Settings.xml:- Opened that file and see the following structure :- I added the following node right under the root of the xml:- Updated the zip file and renamed the zip file back to docx and opened the docx file and saw only my custom style and “Clear All”! 15 agosto Accessing user control's control from the ASPX page
Ok, I know, I know! ?This is something you must be wondering like "Why this guy is so scre*** up and he had to blog about this". But I got into this problem last week and an realized that I have seen this problem and addressed this ..but just forgot about. So why not just blog about this. At least for myself :-). So, forgive me folks!! Using user control from the ASPX page:-
The goal was to access the user control’s control from the ASPX page. First I started looking into why that control in the user control wont be available in the page load of the ASPX page. I could have debugged it. But I thought enabling tracing in and looking into the traces would be a better idea. So I added the trace switch in the web.config (I could have done this on that page itself, but I just did that in the Web.config.). I use the following tag in the Web.config under <System.Web>:- <trace enabled=”true” pageOutput=”true”/> Then I put the some Trace.Write statement in the Page_Load of the user control. Notice this is the method where the menu control is getting created (getting populated with the child control). I put the Trace.Write statement at the end of the Page_Load event handler. I put the Trace.Write statement in the Page_Load of the ASPX page as well at the end. Now, when I try accessing the aspx page, It would give all the tracing information right from “PreInIt” to “Render” along with all the information on the controls on this page. Notice that the Trace.Write statement from the user control is after the same from the ASPX page which implies that the page load of the user control is fired after the page_load of the ASPX page and hence the user control’s control collection wont be available in the aspx page. Now, there is another event named Page_PreRender which fires after the page load and you can tweak the controls before thry get Rendered to the page. You can override that event handler as given below. Notice that in the below screenshot the user control’s(UserStatus1) control(userMenu) is being accessed and is getting modified. To show that this would work, there is a Trace.Write right at the end of the end of this event handler. See the Trace.Write statement (highlighted) in between the Begin PreRender and End PreRender. 30 giugno The SOAP vs RESTA very interseting comparision of REST vs SOAP :-
An analogy of SOAP and REST is an envelop vs a postcard (which one is bulky..huh..! :-) ) 07 giugno Create a RESTful service using WCF
Ok,so I decided to learn creating the REST services using WCF. a) WCF REST Starter Kit Preview 2 After you have installed the starter kit,you should see a set of templates under “File > New > Project”:- 06 giugno Roadmap to learn REST (Representational State Transfer)1) What is REST? Question :- Are you
Question :- Are you c) How to create a REST ful service? 1) c)High REST and Low REST ful service I started here at 12:33 PM 6/6/2009:- What is a Service ? REST is an architectural style for building resource oriented services by defining the resources that implement uniform interfaces using standard HTTP verb LIKE Get,POST,PUT and DELETE. Tenets of REST ful service:-
Addressing scheme – URI B) Scales best when Stateless C) Hyperlinks!- and right, internet would just suck if there are no links! If you look at how we write web services,you see that we follow SOAP which in no doubt an incredible way of interoperability between the clients and the services.
a) How to map REST verbs with HTTP verbs
28 gennaio Quickly open a file in VS2005/VS2008Just in case you know the name of a file and want to open the among many without finding in the solution explorer,check out the following option in the VS.NET.
Just type "> open" followed by first few characters of the file in the "Find" in the toolbar and it would give you all the matching results(irrespective of the location or extensiton). You just hit enter on the file you want to open. Update :- And how to go to that Find bar in the VS 2008. Just hit Ctrl+/ and you are there! :-)Just hit Ctrl+/ and you are there! :-) 26 gennaio ASP.NET performace tricksPerformance Issues in ADO.NET DataTable Usage - Use Enum to Access Items in DataRow
http://www.knowdotnet.com/articles/adoenums.html
03 gennaio Lyrics - "You had me from hello" - song by Kenny ChesneyIf there is one reason why I started liking country music,it is because of Kenney Chesney. He is an outstanding country singer and following is lyrics of one of the songs I really like. Its "You had me from hello".
One word, that's all you said
Somethin' in your voice caused me to turn my head. Your smile, just captured me And you were in my future as far as I could see And I don't know how it happened, but it happened still You asked me if I love you, if I always will Well you had me from "Hello" I felt love start to grow The moment that I looked into your eyes, you won me It was over from the start You completely stole my heart And now you won't let go I never even had a chance you know You had me from "Hello" Inside, I built a wall So high around my heart, I thought I'd never fall One touch, you brought it down The bricks of my defenses scattered on the ground And I swore to me I wasn't gonna love again The last time was the last time I let someone in But you had me from "Hello" I felt love start to grow The moment that I looked into your eyes, you won me It was over from the start You completely stole my heart And now you won't let go I never even had a chance you know You had me from "Hello" That's all you said Somethin' in your voice caused me to turn my head You had me from "Hello" You had me from "Hello" Girl I've loved you from "Hello" Some of his many gems are-
28 dicembre My introduction to the Assembly LanguageSo,I started studying Assembly Language.It is very silly to say that it is interesting language at the first glance when you look at those hexadecimal codes with some weird command like MOV on the command prompt and also when you are coming from working on all the high level languages like C++,Java and C#.However,there is no denial to the fact that you start to learn a lot about the CPU architecture especially "registers". Most important thing is Assembly language is just one level up from the machine language and hence are bound to be real fast compared to the high level (read "layered/abstract/sugar coated") languages. I would be really cool if I can get my fundamentals straight out here and then get into something real deep. I am sure it would help me in writing efficient code (or better understanding) in the language I speak,C# ! :-) Why Assembly language all of a sudden?? Ok,ok,let me confess,it is one of the papers in my MS (Computer Science) degree. :-). I realized that this subject (which I have never worked on),deserves some time to be understood and and there is an opportunity to learn a new thing. See..I am thinking! :-) I started with real basic introduction and a good place is http://www.swansontec.com/sprogram.htm. Which basically says that the Assembly language is a mnemonic language i.e. a set of instructions mapping to the machine language. It has a pretty small but basic example of creating a assembly language program. I read about the Assemblers and Loaders which,respectively are responsible for converting the Assembly language to the machine language and loading the machine language to the memory. 26 dicembre "kaise Mujhe Tum Mil Gayee" - From GhajiniJust in case you cant see the video above..following is the link:-
Of all the songs from the soundtrack of Ghajini, my favorite is Kaise Mujhe Tu Mil Gayi. A great composition by A R Rehman, the lyrics by Prasoon Joshi,as usual are are really deep and meaningful. Listen to the song at the dead of the night and you'll really like it. Hoo hooo oooo.. Hoo hoo hooo… Oooo..hoo…hooo..oooo Hooo hooo… Kaise mujhe tu mil gayi, Kismat pe aaye naa yaakeen, Utar aayi jheel mein jaise chand utarta hai kabhi, Haule haule dheere se, Gunguni dhoop ki tarah se taranum mein tum, Choo ke mujhe guzari hu yu, Dekhu tumhe ya mein sunu, Tum ho sukoon, tum ho junoon, Kyu pehle naa aayi tum? Kaise mujhe tu mil gayi, hoo hoo.. Kismat pe aaye naa yaakeen, hoo hoo.. Mein to yeh sochta tha ki aaj kal, Upar wale ko fursat nahi, Phir bhi tumhe bana ke woh, Meri nazar mein chadh gaya, Rutbe mein woh aur badh gaya.. Aaaa..aaaaa… Aaaa..aaaa…. Hoo..hoo…hooo.. Badle raaste jharne aur nadi, Badli deep ki timtim, Chedhe zindagi dhun koi nayee, Badli barkha ki rimjhim, Badlengi rituyein adaa, Par mein rahungi sada, Ussi tarah teri bahon mein baahein daalke, Har lamha, har pal.. Aaaa..aaaaa… Aaaa..aaaa…. Zindagi sitar ho gayi, Rimjhim malhaar ho gayi, Mujhe aata nahi kismat pe apni yakeen, Kaise mujhko mili tum 29 novembre Gazal by Jagjit Singh - Hai Lau ZindagiThis is one of the numerous beautiful gazals from Jagjit Singh. I first heard this in a documentary named "Hello Zindagi" on Doordarshan hosted by Nalini Singh. I loved this song and after some searching I got this.
Find the online song at :- http://ishare.rediff.com/filemusic-Hai-Lau-Zindagi-id-58965.php
Lyrics:-
hai lau zindagi...zindagi noor hai
magar isme jalne(?) ka dastoor hai adhoore se rishton me jalte raho adhoori si sasson me pal te raho... magar jiye jaane ka dastoor he... rawayat hai ke zindagi gahana hai If you see a spelling mistake and ,please ldo me a favor to let me know and I would correct the same.. Thanks, 08 agosto Nice add-ins for ReflectorNice add-ins for Reflector:-
(if you dont have reflector,download the same from http://www.aisto.com/roeder/dotnet).
One of the very useful add-in is the "diff" add-in. Which would point out the differences between the two versions of the same assemblies including any added/changed/deleted members/methods.
And also the "File Diassembler" where all you have to do is provide the assembly (with the dependent assemblies) you want to disassemble and it would generate the class library out of the same with all the source code.
Others are code search,Code Metrics and many more.
In order to use an add-in in the Reflector :-
a) Copy the all the binaries for the add-in in the same directory as the Reflector.exe.
b) In the reflector,View > Add-In. In the Add-ins dialog,Add the dll for the Add-in.
c) You should see the added "Add-In" under Tools menu.
23 luglio Gios PDF .NET libraryVery sleek open source PDF creation library built in .NET and its up for commercial use. http://www.codeproject.com/KB/graphics/giospdfnetlibrary.aspx Use sections in the config file and access them...( NameValueCollection)ConfigurationManager.GetSection("applicationSettings/ConnectionStrings");for the following XML fragment in the config file:-
<applicationSettings>
<ConnectionStrings>
<add key="DevConnectionstring" value="server=myserver1;database=mydatabase;uid=ashish;pwd=password"/>
<add key="QAConnectionstring" value="server=myserver2;database=mydatabase;uid=ashish;pwd=password"/>
<add key="ProdConnectionstring" value="server=myserver3;database=mydatabase;uid=ashish;pwd=password"/>
</ConnectionStrings>
</applicationSettings> 02 giugno Visual studio 2005 Build error :- The volume for a file has been externally altered so that the opened file is no longer validJust clean the solution and rebuild.
Just dont have any idea why the above error happened this morning when I tried to add some code to a windows service and tried to build the solution.But it has a simple resolution,just clean the solution. :-) [Solution Explorer > Right click on the Solution> Select "Clean Solution"].
26 maggio Convert string to byte array and viceversa byte[] elementByteContent= contentObject.Content; // this byte array content string elementStringContent = System.Text.Encoding.UTF8.GetString(elementByteContent); elementStringContent = elementStringContent.Replace(" ", ""); if (elementStringContent == string.Empty) { elementStringContent = "<P> </P>"; contentObject.Content = System.Text.Encoding.UTF8.GetBytes(elementStringContent); } |
|
|