public GetSCADAStatusBySCADAPointIDResponse GetSCADAStatusBySCADAPointID(GetSCADAStatusBySCADAPointIDRequest request) { Random r = new Random(); GetSCADAStatusBySCADAPointIDResponse response = new GetSCADAStatusBySCADAPointIDResponse(); try { response.MultiSpeakMsgHeader = new MultiSpeakMsgHeader(); response.MultiSpeakMsgHeader.TimeStampSpecified = true; response.MultiSpeakMsgHeader.TimeStamp = DateTime.Now; response.GetSCADAStatusBySCADAPointIDResult = new scadaStatus(); response.GetSCADAStatusBySCADAPointIDResult.objectID = request.scadaPointID; response.GetSCADAStatusBySCADAPointIDResult.status = statusIdentifiers.Closed; response.GetSCADAStatusBySCADAPointIDResult.timeStamp = DateTime.Now; response.GetSCADAStatusBySCADAPointIDResult.timeStampSpecified = true; return(response); } catch (Exception ex) { errorObject[] eObject = new errorObject[1]; eObject[0] = new errorObject(); eObject[0].Value = ex.Message; return(response); } }
public GetMethodsResponse GetMethods(GetMethodsRequest request) { GetMethodsResponse response = null; try { response = new GetMethodsResponse(); response.MultiSpeakMsgHeader = new MultiSpeakMsgHeader(); response.MultiSpeakMsgHeader.TimeStampSpecified = true; response.MultiSpeakMsgHeader.TimeStamp = DateTime.Now; response.GetMethodsResult = new string[5]; response.GetMethodsResult[0] = "GetMethods"; response.GetMethodsResult[1] = "PingURL"; response.GetMethodsResult[2] = "GetAllSCADAPoints"; response.GetMethodsResult[3] = "GetSCADAAnalogBySCADAPointID"; response.GetMethodsResult[4] = "GetSCADAStatusBySCADAPointID"; return(response); } catch (Exception ex) { response.GetMethodsResult = new string[1]; errorObject[] eObject = new errorObject[1]; eObject[0] = new errorObject(); eObject[0].Value = ex.Message; response.GetMethodsResult[0] = ex.Message; return(response); } }
public static void InitiatePingMeterRequest(List <string> meterList) { try { if (meterList != null) { if (meterList.Count > 0) { _log.Debug("Sending ping request..."); //Send meters to OD Web services to request ping action MultiSpeakMsgHeader multispeakHeader = new MultiSpeakMsgHeader(); multispeakHeader.UserID = userName; multispeakHeader.Pwd = password; MultiSpeakService multiSpeakService = new MultiSpeakService(); multiSpeakService.MultiSpeakMsgHeaderValue = multispeakHeader; errorObject[] errors = new errorObject[0]; //Send ping request errors = multiSpeakService.InitiateOutageDetectionEventRequest(meterList, System.DateTime.Now, url, "InitiateOutageDetectionEventRequest"); } } } catch (Exception e) { _log.Error("Failed to initiate a request to ping meters. The error message : " + e.Message + " OD_Server_Client::InitiatePingMeterRequest"); } }
public GetSCADAAnalogBySCADAPointIDResponse GetSCADAAnalogBySCADAPointID(GetSCADAAnalogBySCADAPointIDRequest request) { Random r = new Random(); GetSCADAAnalogBySCADAPointIDResponse response = new GetSCADAAnalogBySCADAPointIDResponse(); try { response.MultiSpeakMsgHeader = new MultiSpeakMsgHeader(); response.MultiSpeakMsgHeader.TimeStampSpecified = true; response.MultiSpeakMsgHeader.TimeStamp = DateTime.Now; response.GetSCADAAnalogBySCADAPointIDResult = new scadaAnalog(); response.GetSCADAAnalogBySCADAPointIDResult.objectID = request.scadaPointID; response.GetSCADAAnalogBySCADAPointIDResult.value = new value(); response.GetSCADAAnalogBySCADAPointIDResult.value.units = uom.V; response.GetSCADAAnalogBySCADAPointIDResult.value.unitsSpecified = true; response.GetSCADAAnalogBySCADAPointIDResult.value.Value = (float)r.NextDouble(); return(response); } catch (Exception ex) { errorObject[] eObject = new errorObject[1]; eObject[0] = new errorObject(); eObject[0].Value = ex.Message; return(response); } }
protected void btnSubmit_Click(object sender, EventArgs e) { bool success = false; //simply because we cannot transfer within a catch block if(Page.IsValid) { try { shipIt(); success = true; } catch(Exception ex) { errorObject eo = new errorObject(ex, true); string errorEmailTo = ConfigurationManager.AppSettings.Get("error-email-to"); string errorEmailFrom = ConfigurationManager.AppSettings.Get("error-email-from"); eo.sendAdminEmail(errorEmailTo, errorEmailFrom, siteName); } } if(success) { contactForm.InnerHtml = "<h2>thanks,</h2><p>I will be in touch shortly.</p>"; ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "postback();", true); } else { contactForm.InnerHtml = "<h2>dang...</h2><p style='margin:.3em;'>Something didn't work. If you want, you can just email me: <a href='mailto:[email protected]'>[email protected]</a>.</p>"; } }
private static errorObject[] ErrorArrayFromException(Exception ex) { errorObject theError = new errorObject(); theError.errorString = ex.Message; theError.eventTime = DateTime.Now; return(new errorObject[] { theError }); }
public void InitiatePingMeterRequest(List <string> meterList, bool bWriteData, string sPath, bool windowsServiceCall, string days, bool ignoreError) { try { if (meterList != null) { if (meterList.Count > 0) { // Check if user likes to write the data to a xml file. if (bWriteData && sPath.Length > 0) { // Save the data to a xml file. // Use serializer to write out to the file. StringBuilder file = new StringBuilder(sPath); if (sPath.LastIndexOf(@"\") != (sPath.Length - 1)) { file.Append(@"\"); } file.Append("InitiateOutageDetectionEventRequest_OD_Server_Client_"); file.Append(String.Format("{0:s}", DateTime.Now).Replace(":", "-")); file.Append(".xml"); // Delete older files. //UtilityMS30.DeleteXMLFiles(days, "InitiateOutageDetectionEventRequest_OD_Server_Client_", sPath); XmlSerializer aSerializer = new XmlSerializer(typeof(string[]), "http://www.multispeak.org/Version_3.0"); TextWriter aWriter = new StreamWriter(file.ToString()); // Write each transformer bank. aSerializer.Serialize(aWriter, meterList.ToArray()); aWriter.Close(); } // Send meters to OD Web services to request ping action. MultiSpeakService multispeak = new MultiSpeakService(); errorObject[] errorObj = new errorObject[0]; //multispeak.MultiSpeakMsgHeaderValue = msgHeader; //errorObj = multispeak.InitiateOutageDetectionEventRequest(meterList.ToArray(), System.DateTime.Now, this.OA_Server_URL, "InitiateOutageDetectionEventRequest"); //multispeak.MultiSpeakMsgHeaderValue = msgHeader; //errorObj = this.InitiateOutageDetectionEventRequest(meterList.ToArray(), System.DateTime.Now, this.OA_Server_URL, "InitiateOutageDetectionEventRequest"); } } } catch (Exception e) { //_log.Error("Failed to initiate a request to ping meters. The error message : " + e.Message + " OD_Server_Client::InitiatePingMeterRequest"); throw e; } }
public errorObject[] InitiateOutageDetectionEventRequest(List <string> meterList, DateTime currentDate, string url, string methodName) { try { errorObject theError = new errorObject(); theError.errorString = "test"; theError.eventTime = DateTime.Now; return(new errorObject[] { theError }); } catch (Exception e) { _log.ErrorFormat("Exception caught in InitiateOutageDetectionEventRequest(). Message: {0}", e.Message); } return(_noError); }
public GetMethodsResponse GetMethods(GetMethodsRequest request) { LogInfo("GetMethods() Entered"); GetMethodsResponse response = null; try { if (_UdpClient == null) { String path = @"C:\\DCSystems\Logs\"; ConfigurationList cl = new ConfigurationList(); cl.Add("Process Name", "MockNotServerService"); cl.Add("Log Output Directory", path); _Logger = new Logger(cl); LogInfo("()"); _UdpClient = new UdpClient(); _UdpClient.Connect(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 7373)); } Byte[] sendBytes = Encoding.ASCII.GetBytes("GetURL,OK"); _UdpClient.Send(sendBytes, sendBytes.Length); response = new GetMethodsResponse(); response.MultiSpeakMsgHeader = new MultiSpeakMsgHeader(); response.MultiSpeakMsgHeader.TimeStampSpecified = true; response.MultiSpeakMsgHeader.TimeStamp = DateTime.Now; response.GetMethodsResult = new string[4]; response.GetMethodsResult[0] = "GetMethods"; response.GetMethodsResult[1] = "PingURL"; response.GetMethodsResult[2] = "SCADAAnalogChangedNotification"; response.GetMethodsResult[3] = "SCADAStatusChangedNotification"; return(response); } catch (Exception ex) { LogError(String.Format("GetMethods() ex:{0}", ex)); response.GetMethodsResult = new string[1]; errorObject[] eObject = new errorObject[1]; eObject[0] = new errorObject(); eObject[0].Value = ex.Message; response.GetMethodsResult[0] = ex.Message; return(response); } }
public GetAllSCADAPointsResponse GetAllSCADAPoints(GetAllSCADAPointsRequest request) { const int NUM_POINTS = 2048; GetAllSCADAPointsResponse response = new GetAllSCADAPointsResponse(); try { response.MultiSpeakMsgHeader = new MultiSpeakMsgHeader(); response.MultiSpeakMsgHeader.TimeStampSpecified = true; response.MultiSpeakMsgHeader.TimeStamp = DateTime.Now; response.MultiSpeakMsgHeader.ObjectsRemaining = "0"; // ??????????????????????????? response.GetAllSCADAPointsResult = new scadaPoint[NUM_POINTS]; bool analog = true; for (int i = 0; i < NUM_POINTS; i++) { response.GetAllSCADAPointsResult[i] = new scadaPoint(); if (analog) { response.GetAllSCADAPointsResult[i].objectName = string.Format("Analog{0:0000}", i); response.GetAllSCADAPointsResult[i].scadaPointType = scadaPointType.analog; } else { response.GetAllSCADAPointsResult[i].objectName = string.Format("Status{0:0000}", i); response.GetAllSCADAPointsResult[i].scadaPointType = scadaPointType.status; } response.GetAllSCADAPointsResult[i].scadaPointTypeSpecified = true; analog = !analog; } return(response); } catch (Exception ex) { errorObject[] eObject = new errorObject[1]; eObject[0] = new errorObject(); eObject[0].Value = ex.Message; return(response); } }
public static SynoException FromJson(string json, ExceptionType type) { errorObject results = JsonConvert.DeserializeObject <errorObject>(JObject.Parse(json)["error"].ToString()); return(new SynoException($"{results.code} : {errorDescription(results.code, type)}")); }