|
What are you talking about?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Ay caramba!
A message in a bottle.
|
|
|
|
|
How best can I create a Windows Form Application that regulates temperature and humidity for a green house using C#? I would want the inputs of humidity and temperature to be continuously generated. Please assist.
|
|
|
|
|
|
So you want experts to create that application completely for you? Have you tried anything? If not , i suggest you to go any freelancer website and post your need.
So much complexity in software comes from trying to make one thing do two things.
Sibeesh
|
|
|
|
|
i wanna to get text : فروش_آپارتمان-تهران-اسلام شهر-OQA2ADEAMAAwADUA.aspx
from string :
string s=@"href=\"فروش_آپارتمان-تهران-اسلام شهر-OQA2ADEAMAAwADUA.aspx\"\u003e\r\n \u003c";
I have tried this but not use :
string _conD="href\\s*=\\s*(?:\"(?<1>[^\"]*)\"|(?<1>\\S+))";
MatchCollection _mat = Regex.Matches(s, _conD, RegexOptions.None);
|
|
|
|
|
Depending on the variance of the line you are extracting from, perhaps you could use a non-regex approach. Personally I would go down this route as RegEx syntax is tricky, but each to their own.
In you example you could do something like:
string x = s.Replace("href=\"", string.Empty);
x = x.Substring(0, x.IndexOf('\\');
.. or something like that, no visual studio to hand.
Regards,
Rob Philpott.
|
|
|
|
|
Thanks in advanced!
How to do that in regex(Only cause the string has a lot of this href)...
|
|
|
|
|
Are you trying to parse an HTML document for its links?
Then: no, do not use regex. There are libraries which can do that.
|
|
|
|
|
For another alternative to Regex for your case, see my StringParser[^] article.
/ravi
|
|
|
|
|
I have created an application to encrypt selected files with password protection, it will accept files like word and pdf, everything work perfect and i ma finished with its development.
And now i have to add functionality to add an entry to system explorer context menu (right click menu) to have my application icon and menu entry on it. as user select multiple files and right click on them, my application icon and menu entry will appear over then and by selecting that, i need to select all that files to my main application for encryption process.
I have searched over Google and found some solutions but its only show some registry key to enter, but there is nothing to show how to handle all event, how to add icon to menu. i have also found one article over code project but its written in c++, and i need in c#.
So can any body has any idea or example using c#, or any wrapper or helper class to register/unregistered context menu entry for my application etc.
I want to do same as winzip or winrar or notepad++ application add their entry to system context menu with the icon on menu as well.
|
|
|
|
|
You are looking to write an Explorer/Shell extension.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Sounds tricky in .NET.
Regards,
Rob Philpott.
|
|
|
|
|
Yes, I am looking for that.
|
|
|
|
|
|
|
You're welcome
|
|
|
|
|
I have an small issue of adding an XML nodelist to a datagrid. It is as follows:
I have a few code blocks that read in the nodelist from an XML file that I was able to find in several forums starting with this one which I have tweaked to suit. I am grabbing the proper nodelist (ServiceHistory) and all works well unti I try and add custom columns etc.
public static DataTable ConvertXmlNodeListToDataTable(XmlNodeList xnl)
{
DataTable dt = new DataTable();
string strOpCode, strDescription; //set up error code vars
//String OpCode;
//String Description;
int TempColumn = 0;
foreach (XmlNode node in xnl.Item(0).ChildNodes)
{
DataColumn dc = new DataColumn(node.Name, System.Type.GetType("System.String"));
if (node.Name == "Operation") //Need to get the OpCode and Descriptions out
{
CodesDesc(node.InnerText, out strOpCode, out strDescription);
dt.Columns.Add("OpCode");
dt.Columns.Add("Description");
}
TempColumn++;
if (dt.Columns.Contains(node.Name))
{
dt.Columns.Add(dc.ColumnName = dc.ColumnName + TempColumn.ToString());
}
else
{
dt.Columns.Add(dc);
}
}
int ColumnsCount = dt.Columns.Count;
for (int i = 0; i < xnl.Count; i++)
{
DataRow dr = dt.NewRow();
for (int j = 0; j < ColumnsCount; j++)
{
dr[j] = xnl.Item(i).ChildNodes[j].InnerText;
}
dt.Rows.Add(dr);
}
return dt;
}
The CodeDesc void is used to break strings out one of the nodes(<operation>) and into 2 new data columns. I am having trouble figuring out just how to go about adding the columns I want(the OpCode and Description columns) and get the strings from the Operations.Innertext into those.
public static void CodesDesc(string OpsText, out string strOpCode, out string strDescription)
{
int Lpos = OpsText.IndexOf("*");
int Rpos = OpsText.LastIndexOf("*") +1;
strOpCode = OpsText.Substring(0, Lpos);
strDescription = OpsText.Substring(Rpos);
}
The Sample XML is as follows:
="1.0"="UTF-8"
<api:reply xmlns:api="http://www.site.com/api" version="1.0">
<Session>
<Reply type="Connection">
<ErrorMessage />
<ErrorCode>0</ErrorCode>
</Reply>
<Reply group="T1G1" object="ServiceHistory" type="Get">
<ServiceHistory>
<RecordID>XF301274*9929</RecordID>
<SWR>661</SWR>
<Operation>BSRS*IBN****REPAIR RIGHT SIDE DAMAGE</Operation>
<PartsAmount>31.20</PartsAmount>
<LaborAmount>543.00</LaborAmount>
</ServiceHistory>
<ServiceHistory>
<RecordID>XF301274*9929</RecordID>
<SWR>661</SWR>
<Operation>RP*IBN****REFINISH & PAINT DAMAGED AREA</Operation>
<PartsAmount>0.00</PartsAmount>
<LaborAmount>351.00</LaborAmount>
</ServiceHistory>
<ServiceHistory>
<RecordID>XF301274*9929</RecordID>
<SWR>661</SWR>
<Operation>PM*IPM****PAINT & MATERIAL</Operation>
<PartsAmount>0.00</PartsAmount>
<LaborAmount>198.90</LaborAmount>
</ServiceHistory>
<ErrorMessage />
<ErrorCode>0</ErrorCode>
</Reply>
</Session>
</api:reply>
Any help is greatly appreciated...
|
|
|
|
|
I cannot really follow your description. What do you want to achieve?
Do you talk about splitting an entry like
<Operation>BSRS*IBN****REPAIR RIGHT SIDE DAMAGE</Operation>
into several fields, with * being the saparator?
But then it is (at least) three field, not two!
|
|
|
|
|
I apologize. Let me try an explain further. I need to split the Operation Element innertext which is being done. The issue is trying to get that text into the datatable row properly. I have modified the function some to add columns as I know what those are going to be. It is the childnode values that change and I need to take Operation childnode and change the loop to add the OpCode and Description strings rather than the Operation childnode innertext.
public static DataTable ConvertXmlNodeListToDataTable(XmlNodeList xnl)
{
DataTable dt = new DataTable();
string strOpCode, strDescription;
dt.Columns.Add("RecordID");
dt.Columns.Add("SWR");
dt.Columns.Add("OpCode");
dt.Columns.Add("Description");
dt.Columns.Add("PartsAmount");
dt.Columns.Add("LaborAmount");
int ColumnsCount = dt.Columns.Count;
for (int i = 0; i < xnl.Count; i++)
{
DataRow dr = dt.NewRow();
for (int j = 0; j < ColumnsCount; j++)
{
if (xnl.Item(i).ChildNodes[j].Name == "Operation")
{
CodesDesc(xnl.Item(i).ChildNodes[j].InnerText, out strOpCode, out strDescription);
dr[j] = strOpCode.ToString();
dr[j+1] = strDescription.ToString();
j++;
}
else
{
dr[j] = xnl.Item(i).ChildNodes[j].InnerText;
}
}
dt.Rows.Add(dr);
}
return dt;
}
Does this help clear things up? I amnot able to insert the text into the datarow properly during the for loop which is where my headaches are coming from..
modified 27-Aug-14 14:44pm.
|
|
|
|
|
|
You can't.
The problem is that the remaining HTML is generated by javascript code at "run-time" of the HTML page, using data retrieved over separate HTTP requests. Unless you're code can execute the javascript itself and figure out what it's outputting, you'll never get this to work.
I don't know of any implementations that can scrape this.
|
|
|
|
|
Thanks all
I have done that
|
|
|
|
|
Hi All,
Can anyone help, I am getting an object reference error in my code. All I am doing is adding two tables to one table, the tables that are being added are Genealogy Table and Relationship Table to Details Table.
The error is below:
An object reference is required for the non-static field, method, or property 'MvcGenealogy.Models.GRHolding.GetDetailID(System.Web.HttpContextBase)'
The error is part of a holding model, the code that is causing the error is below:
public static GRHolding GetDetail(HttpContextBase context)
{
var detail = new GRHolding();
detail.GRHoldingID = GRHolding.GetDetailID(context);
return detail;
}
It references the GetDetailID, the code is below and come from the same Model.GRHolding:
public string GetDetailID(HttpContextBase context)
{
if (context.Session[DetailsSessionKey] == null)
{
if (!string.IsNullOrWhiteSpace(context.User.Identity.Name))
{
context.Session[DetailsSessionKey] = context.User.Identity.Name;
}
else
{
Guid tempDetailsID = Guid.NewGuid();
context.Session[DetailsSessionKey] = tempDetailsID.ToString();
}
}
return context.Session[DetailsSessionKey].ToString();
}
I do have a Session in my Model call DetailsSessionKey which is a string and identifies with the DetailsID. The code that declares this is here:
public const string DetailsSessionKey = "DetailsID";
I think the problem is in my session because the error is with this line of code "detail.GRHoldingID = GRHolding.GetDetailID(context);", which under the GetDetail in my GRHolding.cs model. It is not converting it to a string properly. I think it is something minor in the session, can anyone help? All I am to doing is associating two tables, (Genealogy table and Relationship table), with one table, (Details table).
|
|
|
|
|
Best guess? Check the GetDetail method parameter: I'd start by looking to see if context is null in the debugger.
You looking for sympathy?
You'll find it in the dictionary, between sympathomimetic and sympatric
(Page 1788, if it helps)
|
|
|
|