I'm having a problem with this query below. I'm connecting to OrientDB using the C# driver and running the query in my c# code. All this code is in a loop and the queries in the try block works for a number of iterations and afterwards fails throwing a FormatException. At the point it fails I copy out the query and run it in the orientDB web interface and it returns the expect records so I'm sure it's not the input. So I'm so confused as to why it succeeds sometimes and fails at other times even when the input string is correct. Has anyone encountered a similar problem? Someone please help.
string origin = route[i].Trim();
string destination = route[i + 1].Trim();
List<ODocument> document = new List<ODocument>();
try
{
document = database.Query("select from (traverse out_Connects from " + origin + ") where in = " + destination);
//document = database.Query("select from Connects where (out = " + origin + " and in = " + destination + ")");
}
catch (Exception e)
{
//document = database.Query("select from Connects where (out = " + origin + " and in = " + destination + ")");
}
Related
I'm attempting to monitor multiple SNMP agents (timeticks) with SnmpSharpNet across separate networks. The code below works with a single IP address, but when I try and connect to a second IP address the code fails, I'm trying to run this asynchronously but it appears that SnmpSharpNet won't allow me to receive data from more than one agent.
Is this the right way to approach this problem? Is there a better alternative to SmnpSharpNet?
community = new OctetString("public");
// Define agent parameters class
param = new AgentParameters(community);
// Set SNMP version to 1 (or 2)
param.Version = SnmpVersion.Ver1;
for (int i = 0; i < sendsqldatalist.Count(); i++)
{
agent = new IpAddress(sendsqldatalist[i].ip);
target = new UdpTarget((IPAddress)agent, 161, 2000, 1);
// Make SNMP request
resultlist.Add(result = (SnmpV1Packet)target.Request(pdu, param));
// If result is null then agent didn't reply or we couldn't parse the reply.r
if (resultlist[i] != null)
{
// ErrorStatus other then 0 is an error returned by
// the Agent - see SnmpConstants for error definitions
if (resultlist[i].Pdu.ErrorStatus != 0)
{
Console.WriteLine("error on - " + sendsqldatalist[i].oid + " " + sendsqldatalist[i].ip);
// agent reported an error with the request
//- Error status found here http://www.docs.snmpsharpnet.com/docs-0-9-1/
MessageBox.Show("Error in SNMP reply from " + target.Address.ToString() + Environment.NewLine + "Error status " + result.Pdu.ErrorStatus.GetType() + Environment.NewLine + "Error Index " + result.Pdu.ErrorIndex.ToString(), "WARNING!");
}
else
{
Console.WriteLine("ConnectSNMP() CONNECTED - " + sendsqldatalist[i].oid + " - " + sendsqldatalist[i].ip);
}
}
}
Thanks in advance!
Developing a winforms C# 4.5 on Win10 that creates multiple AxWindowsMediaPlayer control objects dynamically on Form1 (the only form). Relative code segments look like this:
axWMPn[zi] = new AxWindowsMediaPlayer();
((ISupportInitialize)(axWMPn[zi])).BeginInit();
axWMPn[zi].Name = "Zone " + zi; //Zone name + index
axWMPn[zi].Tag = "Z" + zi; // "Z" + Zone index
axWMPn[zi].Location = loc;
axWMPn[zi].Size = sz;
Controls.Add(axWMPn[zi]);
((ISupportInitialize)(axWMPn[zi])).EndInit();
axWMPn[zi].uiMode = "none";
axWmpDisplayZones.Add(axWMPn[zi].Tag.ToString(), axWMPn[zi]);
axWMPn[zi].StatusChange += axWMPx_StatusChange;
axWMPn[zi].PlayStateChange += axWMPx_PlayStateChange;
I create 6 zones - 3 are assigned static JPEG images and the other 3 are used for video (*.avi and *.mov). The video files are assigned like this:
private void playVideo(string file)
{
int tc6 = 0;
axWMPn[0].URL = file;
axWMPn[4].URL = file;
axWMPn[5].URL = file;
axWMPn[6].URL = "C:/test/AmexDonut.mov";
}
This all works - playVideo is called from another process and the first time all videos run without errors; however when I call playVideo a second time I intermittently get a COMException error:
Exception thrown: 'System.Runtime.InteropServices.COMException' in AxInterop.WMPLib.dll -- Message: The message filter indicated that the application is busy. (Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER)).
Notes:
1. If I just do 2 axWMPn[x].URL=file it always works no COMException; if I had a third axWMPn[x].URL=file it mostly works with a COMException once every few dozen calls to playVideo. Adding the 4th awWMPn[x].URL=file almost always causes the COMException but not every single time.
So I did following to see more about what was going on:
private void playVideo(string file)
{
int tc6 = 0;
try
{
axWMPn[0].URL = file;
}
catch (System.Runtime.InteropServices.COMException comEx)
{
Console.WriteLine("playVideo COMException 0: " + comEx.Source + " -- " + comEx.Message);
}
try
{
axWMPn[4].URL = file;
}
catch (System.Runtime.InteropServices.COMException comEx)
{
Console.WriteLine("playVideo COMException 4: " + comEx.Source + " -- " + comEx.Message);
}
try
{
axWMPn[5].URL = file;
}
catch (System.Runtime.InteropServices.COMException comEx)
{
Console.WriteLine("playVideo COMException 5: " + comEx.Source + " -- " + comEx.Message);
}
Again:
try
{
axWMPn[6].URL = "C:/test/AmexDonut.mov";
}
catch (System.Runtime.InteropServices.COMException comEx)
{
tc6++;
Console.WriteLine("playVideo COMException 6: try again count = " + tc6 + " - " + comEx.Source + " -- " + comEx.Message);
goto Again;
}
The COMException "busy" when it occurs always occurs in axWMPn[6].URL=file and putting the goto Again in works - tc6 will always just be 1. So merely trying one more time to assign axWMPn[6].URL=file always works. It never takes more than 1 additional try (tc6 never goes beyond 1).
I could leave it this way - I have run it dozens of times and it works just fine; but it sure seems like a bad hack. Does anybody have any thoughts or ideas?
Thanks for any input
I made script task that's downloading and saving on disk two spreadsheets from Google Drive using file ID and prepared URL address.
This is main() from my C# code, there are no things outside of it:
public void Main()
{
string m_FileId = Dts.Variables["User::varFileId"].Value.ToString();
string m_RemoteUrl = "https://docs.google.com/spreadsheets/d/" + m_FileId + "/export?format=xlsx";
string m_FilePath = null;
WebClient client = new WebClient();
try
{
m_FilePath = Dts.Variables["User::varFilePath"].Value.ToString() + Dts.Variables["User::varFileName"].Value.ToString();
client.DownloadFile(new System.Uri(m_RemoteUrl), m_FilePath);
m_FilePath = "";
m_FileId = Dts.Variables["User::varFileId2"].Value.ToString();
m_RemoteUrl = "https://docs.google.com/spreadsheets/d/" + m_FileId + "/export?format=xlsx";
m_FilePath = Dts.Variables["User::varFilePath"].Value.ToString() + Dts.Variables["User::varFileName2"].Value.ToString();
client.DownloadFile(new System.Uri(m_RemoteUrl), m_FilePath);
}
catch(Exception e)
{
Dts.Events.FireError(0, "FileDownload", e.Message
+ "\r" + e.StackTrace
+ " \rUrl: " + m_RemoteUrl
+ " \rFilePath: " + m_FilePath
+ " \rPath: " + Dts.Variables["User::varFilePath"].Value.ToString()
+ " \rFileName2: " + Dts.Variables["User::varFileName2"].Value.ToString()
, string.Empty, 0);
Dts.TaskResult = (int)ScriptResults.Failure;
}
Dts.TaskResult = (int)ScriptResults.Success;
}
Problem occurs exactly on every second time I run this code and I don't know how to get rid of it. There's just exception in my script task. I'm printing all variables that are used in this code, and as you can see there's something wrong with m_FilePath, it's like multiplied despite of being printed just once.
[FileDownload] Error: An exception occurred during a WebClient request.
at System.Net.WebClient.DownloadFile(Uri address, String fileName)
at ST_84b63d1593dd449886eb2b32dff40b2d.ScriptMain.Main()
Url: https://docs.google.com/spreadsheets/d/----------/export?format=xlsx
FilePath: C:\Google Drive extract\ga_manual_cost_file.xlsxC:\Google Drive extract\ga_manual_cost_file.xlsx
Path: C:\Google Drive extract\ga_manual_cost_file.xlsx
FileName2: ga_manual_cost_file.xlsx
SSIS variables that I'm using are ReadOnly, and are used only in this script task(I tried running only this part of control flow), and their values are as follows:
Error parsing query: The specified FROM-ENTITY "<1>" is invalid [The filename, directory name, or volume label syntax is incorrect.]
<1> is working when use in sql in Log Parser 2.2, the folder is exist.
Query is working if i following article - LogParser DataProvider for ADO.NE
try
{
ILogRecord rowLP = null;
ILogRecordset rsLP = null;
LogQueryClass logQuery = new LogQueryClass();
COMW3CInputContextClass comW3CInputContext = new COMW3CInputContextClass();
string strSQL = #"SELECT " +
#"COUNT(*) AS [Requests], " +
#"DIV(DIV(SUM(cs-bytes), 1024), 1024) AS [MBytes received], " +
#"DIV(DIV(SUM(sc-bytes), 1024), 1024) AS [MBytes sent], " +
#"c-ip AS [IP Address], cs(User-Agent) AS [User agent], " +
#"MAX(date) AS [Last visit] " +
#"FROM <1> " +
#"GROUP BY [IP Address], [User agent] " +
#"ORDER BY [Requests] DESC";
// run the query against W3C log
rsLP = logQuery.Execute(strSQL, comW3CInputContext);
rowLP = rsLP.getRecord();
}
catch (System.Runtime.InteropServices.COMException exc)
{
Console.WriteLine("Unexpected error: " + exc.Message);
}
The <1> "magic shortcut" only works with the IISW3C input format, which is the format that parses the W3C log files generated by IIS. In your code, you are using the W3C input format, which parses generic W3C-formatted logs and thus knows nothing about <1>.
I found they is not working by follow this http://www.codeproject.com/Articles/13504/Simple-log-parsing-using-MS-Log-Parser-2-2-in-C-NE which is the line
COMW3CInputContextClass comW3CInputContext = new COMW3CInputContextClass();
rsLP = logQuery.Execute(strSQL, comW3CInputContext);
By make change as below than the query can be work
rsLP = logQuery.Execute(strSQL, null);
I am trying to see what exception is happening on my dev clients devserver (our servers are fine) and I have an TestException.cs class that handles the most of my exceptions from my sql statement class.
I have a method like so:
StringBuilder errorMessages = new StringBuilder();
for (int i = 0; i < innerException.Errors.Count; i++)
{
errorMessages.Append("Index #" + i + "\n" +
"Message: " + innerException.Errors[i].Message + "\n" +
"LineNumber: " + innerException.Errors[i].LineNumber + "\n" +
"Source: " + innerException.Errors[i].Source + "\n" +
"Procedure: " + innerException.Errors[i].Procedure + "\n");
}
//Console.WriteLine(errorMessages.ToString());
Response.Clear();
Response.Write("FAILURE");
Response.End();
But the Response.XX won't compile and if I use console.writeline when it hits it on the client server, the browser gets a connection lost webpage.
Is there a better way to do this?
You could try using the Trace class. If you link with a tracewriter in web.config pointing to a text file you can generate logging with Trace.WriteLine. Then you would just need the file uploaded to your network for reviewing.