WebDAV Date Range query - c#

Im trying to access and extract message from Exchange Server 2003. I need to get them by dates but im having problem with it.
Here's the code lsQuery = "<?xml version=\"1.0\"?>"
+ "<D:searchrequest xmlns:D = \"DAV:\" xmlns:m=\"urn:schemas:httpmail:\">"
+ "<D:sql>SELECT \"urn:schemas:httpmail:hasattachment\", \"DAV:displayname\", "
+ "\"urn:schemas:httpmail:from\", \"urn:schemas:httpmail:subject\", "
+ "\"urn:schemas:httpmail:htmldescription\" FROM \"" + lsRootUri
+ "\" WHERE \"DAV:ishidden\" = false "
+ "AND \"DAV:isfolder\" = false "
+ "AND \"urn:schemas:httpmail:hasattachment\" = true "
+ "AND \"urn:schemas:httpmail:read\" = false "
+ "AND \"urn:schemas:httpmail:date \" \">=\" CAST(\"2009/11/17\" as 'dateTime') "
+ "AND \"urn:schemas:httpmail:date \" \"<=\" CAST(\"2009/11/19\" as 'dateTime') "
+ "</D:sql></D:searchrequest>";

http://msdn.microsoft.com/en-us/library/aa123600%28EXCHG.65%29.aspx

Related

2 lines in the Debug.Log result C#

How can I show the Debug.Log in 2 lines (like adding an enter or <br>) in C#?
I have lots of info to show and compare, yet it is not convenient to read it in one line.
Current result: Debug.Log("Pointer:" + " " + pointerPosX + " " + pointerPosY + " " + "target" + " " + targetPosX + " " + targetPosY);
Expected result:
Pointer: pointerPosX + " " + pointerPosY
Target: targetPosX " " " + targetPosY
P.S. This is my first question in StackOverflow - so, please, let me know if I did something wrong.
Option 1 (\n):
Debug.Log("Pointer:" + " " + pointerPosX + " "
+ pointerPosY + "\n" + "Target:" + " " + targetPosX + " " + targetPosY);
Option 2 (System.Environment.NewLine):
Debug.Log("Pointer:" + " " + pointerPosX + " " + pointerPosY +
System.Environment.NewLine + "Target:" + " " + targetPosX + " " + targetPosY);
Using $ - string interpolation
Option 1:
Debug.Log($"Pointer: {pointerPosX} {pointerPosY}\nTarget: {targetPosX} {targetPosY}");
Option 2:
Debug.Log($"Pointer: {pointerPosX} {pointerPosY}{System.Environment.NewLine}Target: {targetPosX} {targetPosY}");
Difference between "\n" and Environment.NewLine

display the text on 2 different lines

listBox2.Items.Add(c[n].nume_proprietar + ", " + c[n].nume_catel + ", " + c[n].varsta + " ani , " + c[n].data_vaccin + " " + c[n].tip_vaccin);
Hi, I was wandering if i could insert a line in between " ani , " and c[n].data_vaccin so that my code will display on 2 different lines, obviously with the vallues i insert when i will run the program:
c[n].nume_proprietar ", " c[n].nume_catel ", " c[n].varsta + " ani , " and on another line
c[n].data_vaccin " " c[n].tip_vaccin
Insert Environment.NewLine where you want to breakline. It is environment specific and provides clarity over "\r\n" hence it's preferred to use.
listBox2.Items.Add(c[n].nume_proprietar + ", " + c[n].nume_catel + ", " + c[n].varsta + " ani ," + Environment.NewLine + c[n].data_vaccin + " " + c[n].tip_vaccin);

Using string SQL queries

I am getting the following error.
Message = "Incorrect syntax near the keyword 'AS'.\r\nIncorrect syntax near the keyword 'AS'."
I have the following sql string query.
private const string QueryString =
"SELECT DISTINCT "
+ " Person.[PersObjId]"
+ ",Person.[PtObjId]"
+ ",MSN.[PersObjId]"
+ ",MSN.[ExtrnId] AS '" + MSNumber + "'"
+ ",HlthProfMstrV.[RptName] AS '" + ItemName + "'"
+ ",HlthProfMstrV.[ItemStsId] AS '" + ItemId + "'"
+ "FROM [dbt1].[Person]"
+ "join"
+ " ( "
+ " SELECT "
+ " PersIdRptV.PersObjId"
+ " , PersIdRptV.ExtrnId"
+ " FROM"
+ " dbt1.PersIdRptV"
+ " join dbt1.IdIssMstrV on PersIdRptV.IdIssObjId = IdIssMstrV.IdIssObjId"
+ " WHERE"
+ " PersIdRptV.TypeId = 5"
+ " and"
+ " PersIdRptV.StpDate is NULL"
+ " ) AS MSN on dbt1.Person.PersObjId = MSN.PersObjId"
+ "left join dbt1.HlthProfMstrV on Person.PCPHlthProfObjId = HlthProfMstrV.HlthProfObjId"
+ " " + "WHERE" + " "
+ "Person.[ExpressId] =12"
+ " and" + " "
+ "Person.[StnTst] = 'Actv' "
+ " and" + " "
+ "MSN.[ExtrnId] = #MSN ";
I think this error is occuring when I am getting the first join result where I assign the result set to "MSN". I tried taking out the AS from AS MSN and I get another error saying the following:
Message = "Incorrect syntax near the keyword 'MSN'.\r\nIncorrect
syntax near the keyword 'MSN'."
I been looking at this for few hours. I am sure its something simple I am missing. Help appreciated!
You're missing a space between last column alias and From keyword:
+ ",HlthProfMstrV.[ItemStsId] AS '" + ItemId + "'"
+ " FROM [dbt1].[Person]"
Space missing before person and join
+ "FROM [dbt1].[Person]"
+ " join" --> Added space before join
+ "MSN.[ExtrnID] = '" + #MSN + "'"

Browser History -> Database

I want to fetch history from browser as soon as a web site is loaded in the browser. It should fetch clients' browser info and save it in a database so that admin may check out the website that is frequently opened and can do survey on the data.
System.Web.HttpBrowserCapabilities browser = Request.Browser;
string s = "Browser Capabilities\n"
+ "Type = " + browser.Type + "\n"
+ "Name = " + browser.Browser + "\n"
+ "Version = " + browser.Version + "\n"
+ "Major Version = " + browser.MajorVersion + "\n"
+ "Minor Version = " + browser.MinorVersion + "\n"
+ "Platform = " + browser.Platform + "\n"
+ "Is Beta = " + browser.Beta + "\n"
+ "Is Crawler = " + browser.Crawler + "\n"
+ "Is AOL = " + browser.AOL + "\n"
+ "Is Win16 = " + browser.Win16 + "\n"
+ "Is Win32 = " + browser.Win32 + "\n"
+ "Supports Frames = " + browser.Frames + "\n"
+ "Supports Tables = " + browser.Tables + "\n"
+ "Supports Cookies = " + browser.Cookies + "\n"
+ "Supports VBScript = " + browser.VBScript + "\n"
+ "Supports JavaScript = " +
browser.EcmaScriptVersion.ToString() + "\n"
+ "Supports Java Applets = " + browser.JavaApplets + "\n"
+ "Supports ActiveX Controls = " + browser.ActiveXControls
+ "\n";
Request.Browser is used to identify the browser info . Using this you can get all info of browser
IIS is already storing this information for you. See: http://msdn.microsoft.com/en-us/library/ms525410%28v=vs.90%29.aspx
To make that data useful you will then need to use a Log Analyzer tool.
Google this term for some options to use: iis log analyzer

AppendAllLines alternative solution

I am trying to write a txt file from C# as follows:
File.WriteAllText("important.txt", Convert.ToString(c));
File.AppendAllLines("important.txt", (from r in rec
select r.name + " " + r.num1 + " " + r.num2 + " " + r.mult + " " + r.rel).ToArray());
I am getting error AppendAllLInes not found for system.IO.File any alternative approach or how can I include AppendAllLInes
Write all at once.
var part1 = Convert.ToString(c);
var part2 = String.Join(Environment.NewLine,
rec.Select(r => r.name + " " + r.num1 + " " + r.num2 + " " + r.mult + " " + r.rel)
.ToArray());
System.IO.File.WriteAllText("important.txt", part1 + part2);
You could also use WriteAllLines in 3.5:
var allLines = new []{Convert.ToString(c)}
.Concat(rec.Select(r => r.name + " " + r.num1 + " " + r.num2 + " " + r.mult + " " + r.rel))
.ToArray();
System.IO.File.WriteAllLines("important.txt", allLines);

Categories

Resources