I got an email from one of workmate to show me that the french characters are valid in the CSV file.
However those customer anmes with French accents had been screwed up with one example
the name is ANDRÉ in the CSV file. the user queried the database but return
ANDRÉ
the root cause of this issue stems from the character set in the connection string configuration.
you can view my previous posting about the character set setting in the connection string
how-to-import-unicode-characters-from Excel to SQL
I can quickly fix the package to support the french accents in the customer name by setting
the code page to be 65001(UTF-8)
a blog to share Microsoft technologies Azure, DotNet, SharePoint, SQL Server,JavaScript Framework: Node.JS, Angular, React
Friday, June 13, 2014
Wednesday, May 14, 2014
FTPWebRequest TimeOut Issue
I am doing an upgrade on the app host on ASP.Net 2.0 and running on .Net framework 2.0 to
host in windows server 2012 running ASP.Net 4.0 engine and 4.5 .Net Framework
however one of the upload page was hanged for period time, then throw an exception
Exception information:
Exception type: WebException
Exception message: The operation has timed out.
at ASP.fileupload_aspx.submit(Object Sender, EventArgs e) in C:\MyAppFolder\FileUpload.aspx:line 129
at System.Web.UI.HtmlControls.HtmlInputButton.OnServerClick(EventArgs e)
at System.Web.UI.HtmlControls.HtmlInputButton.RaisePostBackEvent(String eventArgument)
at System.Web.UI.HtmlControls.HtmlInputButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
I went back to the old server to run the same application. the upload process was completed very quick.
the root cause of this issue is that connection can't be established
http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.usepassive.aspx
stated that "Setting the UsePassive property to true sends the "PASV" command to the server. This command requests the server to listen on a data port and to wait for a connection rather than initiate one upon receipt of a transfer command."
My old code that caused the upload in long run
ftp.UsePassive = false
my fix to allow the client initiates the connection
ftp.UsePassive =true
host in windows server 2012 running ASP.Net 4.0 engine and 4.5 .Net Framework
however one of the upload page was hanged for period time, then throw an exception
Exception information:
Exception type: WebException
Exception message: The operation has timed out.
at ASP.fileupload_aspx.submit(Object Sender, EventArgs e) in C:\MyAppFolder\FileUpload.aspx:line 129
at System.Web.UI.HtmlControls.HtmlInputButton.OnServerClick(EventArgs e)
at System.Web.UI.HtmlControls.HtmlInputButton.RaisePostBackEvent(String eventArgument)
at System.Web.UI.HtmlControls.HtmlInputButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
I went back to the old server to run the same application. the upload process was completed very quick.
the root cause of this issue is that connection can't be established
http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.usepassive.aspx
stated that "Setting the UsePassive property to true sends the "PASV" command to the server. This command requests the server to listen on a data port and to wait for a connection rather than initiate one upon receipt of a transfer command."
My old code that caused the upload in long run
ftp.UsePassive = false
my fix to allow the client initiates the connection
ftp.UsePassive =true
Tuesday, April 29, 2014
How to fix Sharepoint 2013 pre-requisite configuration Error with AutoSPInstaller
when I installed the SharePoint 2013 with AutoSPInstaller today.
I always get the failed message after I run the install bat file
the error indicated that some sharepoint 2013 pre requisite is not found
when I manually run the prerequisite installer exe file, the process completed with error.
here is the picture of installation result.
after I google a bit. I found that here is very helpful solution
SharePoint 2013 Pre-Requisites Configuration Error on Server 2012
I need to copy the files inside the SXS folder of Windows Server 2012 Setup ISO and put it under the Folder
C:\SP\2013\SharePoint\PrerequisiteInstallerFiles\sxs
then the setup process is running
I can fold my hand and wait for the process to complete.
cheers
Update:
i can not fold my hand and relax.. actually i still have to run this line CMD windows
C:\Windows\Microsoft.NET\Framework64\v4.0.30319>aspnet_regiis -enable -i
after another auto installation failed.
I always get the failed message after I run the install bat file
the error indicated that some sharepoint 2013 pre requisite is not found
when I manually run the prerequisite installer exe file, the process completed with error.
here is the picture of installation result.
after I google a bit. I found that here is very helpful solution
SharePoint 2013 Pre-Requisites Configuration Error on Server 2012
I need to copy the files inside the SXS folder of Windows Server 2012 Setup ISO and put it under the Folder
C:\SP\2013\SharePoint\PrerequisiteInstallerFiles\sxs
then the setup process is running
I can fold my hand and wait for the process to complete.
cheers
Update:
i can not fold my hand and relax.. actually i still have to run this line CMD windows
C:\Windows\Microsoft.NET\Framework64\v4.0.30319>aspnet_regiis -enable -i
after another auto installation failed.
Wednesday, January 15, 2014
How to improve the performance of Linq IEnumerable to Object List
I found an issue with the my linq code. it is straight forward code.
it simply call a Ienumerable object to list
List<myObject>=myIenumerable.ToList<myObject>();
as the number of objects in the Ienumerable Increases. the app take noticeable time to load the data.
the good search return the following will provide a great help to solve the issue.
http://msmvps.com/blogs/jon_skeet/archive/2011/01/01/reimplementing-linq-to-objects-part-20-tolist.aspx
I changed my code to
List<myObject>=new List<myObject>(myIenumerable);
the performance take a big jump.
List<myObject>=myIenumerable.ToList<myObject>();
List<myObject>=new List<myObject>(myIenumerable);
the performance take a big jump.
Tuesday, December 17, 2013
How to Convert JSON XML string representation to Object in C#
my workmate had asked me this question for while.. I gave him the solution is that he did not need to convert the JSon object to C#object. he can create a new store procedure to load the data into the C# object.
currently i worked on a project that i need to consume the JSon object via the WCF (Windows communication foundation). Since I did not have the control on the data source, it means that i can call the store procedure to load those data into the C# object.
JSON.Net is the solution to deserialzie the json object back to .net object.
http://james.newtonking.com/json
http://json.codeplex.com/
First we will define C# object with Properties matching to the json object.
here is the json sample object from
http://adobe.github.io/Spry/samples/data_region/JSONDataSetSample.html
public class MyJson {
[JsonProperty("id")]
public string id
{
get;
set;
}
[JsonProperty("type")]
public string type
{
get;
set;
}
[JsonProperty("name")]
public string name
{
get;
set;
}
[JsonProperty("Pricing")]
public Pricing Pricing
{
get;
set;
}
[JsonProperty("ppu")]
public string ppu
{
get;
set;
}
[JsonProperty("batters")]
public batters batters
{
get;
set;
}
[JsonProperty("topping")]
public topping[] topping
{
get;
set;
}
}
public class batters
{
[JsonProperty("batter")]
public batter[] batter
{
get;
set;
}
}
public class batter
{
[JsonProperty("id")]
public string id
{
get;
set;
}
[JsonProperty("type")]
public string type
{
get;
set;
}
}
public class topping
{
[JsonProperty("id")]
public string id
{
get;
set;
}
[JsonProperty("type")]
public string type
{
get;
set;
}
}
in my sample i will convert the json object in my page load event
protected void Page_Load(object sender, EventArgs e)
{
using (var webClient = new System.Net.WebClient())
{
try
{
var jsonString = webClient.DownloadString("Your WCF Url with paramter input options");
// if you need to remove any string that did not need in the json xml string.
jsonString = jsonString.Replace("{\"MyJSonOjects\":", "").TrimEnd('}');
//use JsonConvert object in Json.Net to deserialize the json to .net Object.
List<MyJson> MyJsonList= JsonConvert.DeserializeObject<List<MyJson >(jsonString) as List<MyJson>;
}
catch (Exception ex)
{
throw ex;
}
}
}
currently i worked on a project that i need to consume the JSon object via the WCF (Windows communication foundation). Since I did not have the control on the data source, it means that i can call the store procedure to load those data into the C# object.
JSON.Net is the solution to deserialzie the json object back to .net object.
http://james.newtonking.com/json
http://json.codeplex.com/
First we will define C# object with Properties matching to the json object.
here is the json sample object from
http://adobe.github.io/Spry/samples/data_region/JSONDataSetSample.html
{ "id": "0001", "type": "donut", "name": "Cake", "ppu": 0.55, "batters": { "batter": [ { "id": "1001", "type": "Regular" }, { "id": "1002", "type": "Chocolate" }, { "id": "1003", "type": "Blueberry" }, { "id": "1004", "type": "Devil's Food" } ] }, "topping": [ { "id": "5001", "type": "None" }, { "id": "5002", "type": "Glazed" }, { "id": "5005", "type": "Sugar" }, { "id": "5007", "type": "Powdered Sugar" }, { "id": "5006", "type": "Chocolate with Sprinkles" }, { "id": "5003", "type": "Chocolate" }, { "id": "5004", "type": "Maple" } ] }
we define the c# object MyJson based on the JSon xml Schema
public class MyJson {
[JsonProperty("id")]
public string id
{
get;
set;
}
[JsonProperty("type")]
public string type
{
get;
set;
}
[JsonProperty("name")]
public string name
{
get;
set;
}
[JsonProperty("Pricing")]
public Pricing Pricing
{
get;
set;
}
[JsonProperty("ppu")]
public string ppu
{
get;
set;
}
[JsonProperty("batters")]
public batters batters
{
get;
set;
}
[JsonProperty("topping")]
public topping[] topping
{
get;
set;
}
}
public class batters
{
[JsonProperty("batter")]
public batter[] batter
{
get;
set;
}
}
public class batter
{
[JsonProperty("id")]
public string id
{
get;
set;
}
[JsonProperty("type")]
public string type
{
get;
set;
}
}
public class topping
{
[JsonProperty("id")]
public string id
{
get;
set;
}
[JsonProperty("type")]
public string type
{
get;
set;
}
}
in my sample i will convert the json object in my page load event
protected void Page_Load(object sender, EventArgs e)
{
using (var webClient = new System.Net.WebClient())
{
try
{
var jsonString = webClient.DownloadString("Your WCF Url with paramter input options");
// if you need to remove any string that did not need in the json xml string.
jsonString = jsonString.Replace("{\"MyJSonOjects\":", "").TrimEnd('}');
//use JsonConvert object in Json.Net to deserialize the json to .net Object.
List<MyJson> MyJsonList= JsonConvert.DeserializeObject<List<MyJson >(jsonString) as List<MyJson>;
}
catch (Exception ex)
{
throw ex;
}
}
}
Monday, November 18, 2013
How to use regular expression to trim leading and trailing characters of a specific character in C#
After i enabled filter on the Telerik Grid, the grid filter was not function property, when i copied and paste those search criteria into the filter textbox.
the root cause of this issue is that when i highlight and copy the context in the grid. the context was copied with space in the front and end. I must trim those leading and trailing space
the following is the filter syntax that i grab via the visual studio debugger
MyColumnName.Contains(" MySearchCriteria ")
so I need to clear the space before and after double quotation mark.
the regular expression is the good fit for this issue.
first i will define the regular expression pattern to represent the issue.
s*: space appears 0 or more in the string.
\s*\""\*: space before and after the double quotation mark.
the root cause of this issue is that when i highlight and copy the context in the grid. the context was copied with space in the front and end. I must trim those leading and trailing space
the following is the filter syntax that i grab via the visual studio debugger
MyColumnName.Contains(" MySearchCriteria ")
so I need to clear the space before and after double quotation mark.
the regular expression is the good fit for this issue.
first i will define the regular expression pattern to represent the issue.
s*: space appears 0 or more in the string.
\s*\""\*: space before and after the double quotation mark.
var slashRegex = new Regex(@"(?:\s*\""\s*)+");
var filterExpression=MyColumnName.Contains(" MySearchCriteria ");
filterExpression = slashRegex.Replace(filterExpression, "\"");
after i apply the regular expression.
MyColumnName.Contains("MySearchCriteria")
Thursday, September 26, 2013
How to qucikly launch Task Managment Window
it should be hard to launch the CMD command window after i accidently close it in windows Server 2008 Core.
since the administrator had setup my profit to have CMD prompt since i log into the server with Remote access. i do not have access CMD Prompte after i close it. we should be able to access the
task window by using Ctrl-Alt-Del command to launch the login screen. However this command always trigger the login screen of host window.
here is the quickly solution to access the Task Manager Window in the remote server.
Ctrl+Shift+Esc will work to start Task Manager.
since the administrator had setup my profit to have CMD prompt since i log into the server with Remote access. i do not have access CMD Prompte after i close it. we should be able to access the
task window by using Ctrl-Alt-Del command to launch the login screen. However this command always trigger the login screen of host window.
here is the quickly solution to access the Task Manager Window in the remote server.
Ctrl+Shift+Esc will work to start Task Manager.
Subscribe to:
Posts (Atom)