public LeanKitAPIException(string message, ResponseCode responseCode, Exception innerException) : base( string.IsNullOrEmpty(message) ? (innerException != null ? innerException.Message : "A problem occurred while communicating with the LeanKit API or during the processing of the data.") : message, innerException) { ResponseCode = responseCode; }
internal Response(Robot robot, ResponseCode code, Byte seqNum, Byte[] data) { Robot = robot; RspCode = code; SeqNum = seqNum; Data = data; }
public CollisionData(Robot robot, ResponseCode code, Byte seqNum, Byte[] data, AsynchronousId asyncCode, Int32 length) : base(robot, code, seqNum, data, asyncCode, length) { if ((Int32)Data.Length == 16) { CollisionAccelerometerReading = new AccelerometerReading((Single)GetFloatFromBytes(0), (Single)GetFloatFromBytes(2), (Single)GetFloatFromBytes(4)); XAxisCollision = (Data[6] & 1) > 0; YAxisCollision = (Data[6] >> 1 & 1) > 0; CollisionPower = new TwoAxisSensor((Single)GetFloatFromBytes(7), (Single)GetFloatFromBytes(9)); SpheroSpeed = (Single)Data[11] / 255f; Timestamp = GetIntFromBytes((Int32)Data[12]); } }
public MessageFlags( bool isResponse, OpCode opCode, bool isAuthorative, bool isTruncated, bool recursionDesired, bool recursionAvailable, ResponseCode responseCode) { int val = 0; val |= isResponse ? 0x8000 : 0x0000; val |= ((int)opCode & 0xF) << 11; val |= isAuthorative ? 0x0400 : 0x0000; val |= isTruncated ? 0x0200 : 0x0000; val |= recursionDesired ? 0x0100 : 0x0000; val |= recursionAvailable ? 0x0080 : 0x0000; val |= (int)responseCode & 0xF; _value = (ushort)val; }
//internal override void InstantiateFromXml(XmlDocument xmlDocument) //{ // /* Expect testing environment response in the form: // * // <response> // <result code=\"1000\"/> // <resdata> // <check> // <domain name=\"example.us\" avail=\"1\"/> // <domain name=\"example.biz\" avail=\"1\"/> // </check> // </resdata> // </response> // */ // XmlNode responseNode = xmlDocument.DocumentElement; // XmlNode resultNode = responseNode["result"]; // this.ResponseCode = (ResponseCode)int.Parse(resultNode.Attributes["code"].Value); // DomainNames = new List<string>(); // Availabilities = new List<Availability>(); // if (responseNode["resdata"] != null && responseNode["resdata"]["check"] != null) // { // foreach (XmlNode domainNode in responseNode["resdata"]["check"].ChildNodes) // { // DomainNames.Add(domainNode.Attributes["name"].Value); // Availabilities.Add(GetAvailability(int.Parse(domainNode.Attributes["avail"].Value))); // } // } //} #endregion internal override void InstantiateFromXml(XmlDocument xmlDocument) { /* Expect production response in the form: * <check> <domain name=\"example.us\" avail=\"1\"/> <domain name=\"example.biz\" avail=\"1\"/> </check> */ XmlNode checkNode = xmlDocument.DocumentElement; DomainNames = new List<string>(); Availabilities = new List<Availability>(); foreach (XmlNode domainNode in checkNode.ChildNodes) { DomainNames.Add(domainNode.Attributes["name"].Value); Availabilities.Add(GetAvailability(int.Parse(domainNode.Attributes["avail"].Value))); } this.ResponseCode = ResponseCode.Success; }
public AsyncSensorData(Robot robot, ResponseCode code, Byte seqNum, Byte[] data, AsynchronousId asyncCode, Int32 length, UInt64 mask) : base(robot, code, seqNum, data, asyncCode, length) { if ((Int32)Data.Length == CountBits(mask) * 2) { Int32 num = 0; if (MaskHasFlag(mask, (DataStreaming)((Int64)458752))) { Attitude = new AttitudeReading((Single)GetFloatFromBytes(num), (Single)GetFloatFromBytes(num + 2), (Single)GetFloatFromBytes(num + 4)); num = num + 6; } if (MaskHasFlag(mask, (DataStreaming)((Int64)57344))) { Accelorometer = new AccelerometerReading((Single)GetFloatFromBytes(num), (Single)GetFloatFromBytes(num + 2), (Single)GetFloatFromBytes(num + 4)); num = num + 6; } if (MaskHasFlag(mask, (DataStreaming)((Int64)7168))) { Gyrometer = new GyrometerReading((Single)GetFloatFromBytes(num), (Single)GetFloatFromBytes(num + 2), (Single)GetFloatFromBytes(num + 4)); num = num + 6; } if (MaskHasFlag(mask, DataStreaming.Quaternion)) { Quaternion = new QuaternionReading((Single)GetFloatFromBytes(num), (Single)GetFloatFromBytes(num + 2), (Single)GetFloatFromBytes(num + 4), (Single)GetFloatFromBytes(num + 6)); num = num + 8; } if (MaskHasFlag(mask, DataStreaming.Location)) { Location = new LocationReading((Single)GetFloatFromBytes(num), (Single)GetFloatFromBytes(num + 2)); num = num + 4; } if (MaskHasFlag(mask, DataStreaming.Velocity)) { Velocity = new VelocityReading((Single)GetFloatFromBytes(num), (Single)GetFloatFromBytes(num + 2)); num = num + 4; } } }
public abstract void Reject(ResponseCode code);
private void OnUnsubscribeCompleted(ResponseCode code, int type, List <string> failedIDList) { NimUtility.Log.Info(string.Format("[OnUnsubscribeCompleted :code = {0},type = {1} failed:{2}]", code, type, failedIDList != null ? failedIDList.Aggregate((a, b) => a + "," + b) : "null")); }
/// <summary> /// Exception constructor. /// </summary> /// <param name="message"> /// A message describing the nature of the problem. /// </param> /// <param name="transaction"> /// The Transaction ID corresponding to the request that failed. /// </param> /// <param name="innerException"> /// Inner exception causing this error, typically reserved for /// fundamental GRPC pipeline exceptions. /// </param> /// <param name="code"> /// The status code returned by the gateway node. /// </param> /// <param name="requiredFee"> /// The cost value returned for insufficient transaction fee errors. /// </param> public PrecheckException(string message, TxId transaction, ResponseCode code, ulong requiredFee, Exception innerException) : base(message, innerException) { Status = code; TxId = transaction; RequiredFee = requiredFee; }
public override void Reject(ResponseCode code) { mMessage.Error(code); Rejected = true; }
/// <summary> /// Convert the responsecode struct defined in adapter to stack /// </summary> /// <param name="responseCode">ResponseCode values.</param> /// <returns>Return the RESPONSE_CODE type defined in stack</returns> private static RESPONSE_CODE ConvertToStackForResponseCode(ResponseCode responseCode) { RESPONSE_CODE responseCodeStack; responseCodeStack = (RESPONSE_CODE)responseCode; return responseCodeStack; }
public void SetResponse(ResponseCode code) => response = new Response(code);
public void Error(ResponseCode code) { Socket.Send(id, "error", JsonTypeConverters.EscapedString(HttpUtils.CodeToString(code))); }
/// <summary> /// 初始化 AirException 类的新实例。 /// </summary> /// <param name="code">异常代码。</param> public AirException(ResponseCode code = ResponseCode.Succeed) : base() { Code = code; }
private Task _listen() { return(Task.Factory.StartNew(() => { try { while (IsListening) { HttpListenerContext ctx = _listener.GetContext(); HttpListenerRequest req = ctx.Request; HttpListenerResponse resp = ctx.Response; try { string accesslog = DateTime.Now.ToString("o"); accesslog += "\t" + string.Format("Request #: {0}", ++_requestCount); accesslog += "\t" + req.Url.ToString(); accesslog += "\t" + req.HttpMethod; accesslog += "\t" + req.UserHostAddress; accesslog += "\t" + req.UserAgent; string origin = _getOrigin(req); accesslog += "\t" + origin; bool forbidden = false; if (config.URL == origin || config.allowedDomains.Contains(origin)) { resp.AppendHeader("Access-Control-Allow-Origin", origin); } else { if (req.Url.AbsolutePath == "/permissions" && req.HttpMethod == "GET") { resp.AppendHeader("Access-Control-Allow-Origin", origin); } else { resp.AppendHeader("Access-Control-Allow-Origin", config.URL); forbidden = true; } } if (req.HttpMethod == "OPTIONS") { resp.AddHeader("Access-Control-Allow-Headers", "*"); resp.StatusCode = (int)HttpStatusCode.OK; resp.StatusDescription = "OK"; resp.Close(); } else { if (forbidden) { accesslog += "\tfailed\tsame origin"; ServerConfig.appendLog(accesslog); responseForbidden(resp); } else { ResponseCode respCode = ResponseCode.OK; if (req.Url.AbsolutePath == "/") { respCode = _home.handle(req, resp, accesslog); } else if (req.Url.AbsolutePath == "/permissions") { respCode = _permissions.handle(req, resp, accesslog, origin); } else if (req.Url.AbsolutePath == "/printers") { respCode = _printers.handle(req, resp, accesslog); } else if (req.Url.AbsolutePath == "/settings") { respCode = _settings.handle(req, resp, accesslog); } else { respCode = ResponseCode.NotFound; } switch (respCode) { case ResponseCode.NotFound: accesslog += "\tfailed\tnot found"; ServerConfig.appendLog(accesslog); resp.StatusCode = (int)HttpStatusCode.NotFound; resp.StatusDescription = "NOT FOUND"; resp.Close(); break; case ResponseCode.Forbidden: responseForbidden(resp); break; } } } } catch (Exception e) { ServerConfig.appendLog("Error: " + e.Message + "\n" + e.StackTrace); resp.StatusCode = (int)HttpStatusCode.InternalServerError; resp.StatusDescription = "INTERNAL SERVER ERROR"; resp.Close(); } } } catch (Exception e) { if (!(e is HttpListenerException && (e as HttpListenerException).ErrorCode == 995)) { ServerConfig.appendLog(e.GetType().Name + ": " + e.Message + "\n" + e.StackTrace); } return false; } return true; })); }
/// <summary> /// Initializes a new instance of the <see cref="MessengerException"/> class. /// </summary> /// <param name="code"> /// The code. /// </param> /// <param name="innerException"> /// The inner exception. /// </param> public MessengerException(ResponseCode code, Exception innerException = null) : base(code.ToString(), innerException) { this.Code = code; }
public ErrorResponse(ResponseCode code, object data) : this((ResponseCode)code) { this.Data = data; }
public ErrorResponse(ResponseCode code) { this.Code = code; }
public ServiceResult(ResponseCode responseCode, string error, T result) { ResponseCode = responseCode; Error = error; Result = result; }
private void OnBatchQueryCompleted(ResponseCode code, List <NIMSubscribeStatus> subscribeList) { NimUtility.Log.Info(string.Format("[OnBatchQueryCompleted :code = {0},subscribe list:{1}", code, subscribeList.Dump())); }
public ResponseData(ResponseCode code, System.Xml.Linq.XDocument result) { Code = code; Result = result; }
public LeanKitAPIException(ResponseCode responseCode, Exception innerException) : this(null, responseCode, innerException) { }
public ResponseData(ResponseCode code, System.Xml.Linq.XDocument result, Exception error) : this(code, result) { this.Error = error; }
public static bool TryParse(string value, out ResponseCode result) { result = default(ResponseCode); if( value=="ok") result = ResponseCode.Ok; else if( value=="error") result = ResponseCode.Error; else if( value=="rejection") result = ResponseCode.Rejection; else if( value=="rules") result = ResponseCode.Rules; else if( value=="undeliverable") result = ResponseCode.Undeliverable; else return false; return true; }
public ResponseDataJson(ResponseCode code, string result) { Code = code; Result = result; }
/// <summary> /// /// </summary> /// <param name="res"></param> /// <param name="ec"></param> /// <param name="msg"></param> public ResultDto(int res, ResponseCode ec, string msg) { Res = res; Ec = ec; Msg = msg; }
public ResponseDataJson(ResponseCode code, string result, Exception error) : this(code, result) { this.Error = error; }
public override int GetHashCode() { int hash = 1; if (StartTime != 0L) { hash ^= StartTime.GetHashCode(); } if (EndTime != 0L) { hash ^= EndTime.GetHashCode(); } if (SourceServiceName.Length != 0) { hash ^= SourceServiceName.GetHashCode(); } if (SourceServiceId != 0) { hash ^= SourceServiceId.GetHashCode(); } if (SourceServiceInstance.Length != 0) { hash ^= SourceServiceInstance.GetHashCode(); } if (SourceServiceInstanceId != 0) { hash ^= SourceServiceInstanceId.GetHashCode(); } if (DestServiceName.Length != 0) { hash ^= DestServiceName.GetHashCode(); } if (DestServiceId != 0) { hash ^= DestServiceId.GetHashCode(); } if (DestServiceInstance.Length != 0) { hash ^= DestServiceInstance.GetHashCode(); } if (DestServiceInstanceId != 0) { hash ^= DestServiceInstanceId.GetHashCode(); } if (Endpoint.Length != 0) { hash ^= Endpoint.GetHashCode(); } if (Latency != 0) { hash ^= Latency.GetHashCode(); } if (ResponseCode != 0) { hash ^= ResponseCode.GetHashCode(); } if (Status != false) { hash ^= Status.GetHashCode(); } if (Protocol != 0) { hash ^= Protocol.GetHashCode(); } if (DetectPoint != 0) { hash ^= DetectPoint.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public SessionChangedEventArgs(ResponseCode code, SessionInfo info, int unreadCount) { ResCode = code; Info = info; TotalUnreadCount = unreadCount; }
internal Response(bool success, ResponseCode statusCode) : this(success) { StatusCode = (int)statusCode; }
//------------------------------------------------------------------------------ public void Response(ResponseCode code, string reason = null) { Code = (int)code; Reason = reason != null ? reason : HttpUtils.CodeToString(code); }
public override void Reject(ResponseCode code) { mCode = code; }
public CustomerException(ResponseCode code) { this.Code = code; }
public override void Reject(ResponseCode code) { mRequest.Reject(code); }
public CustomerException(ResponseCode code, string msg) { this.Code = code; this.Msg = msg; }
private void OnBatchUnsubscribeCompleted(ResponseCode code, int type) { NimUtility.Log.Info(string.Format("[OnBatchUnsubscribeCompleted :code = {0},type = {1}", code, type)); }
internal AsynchronousResponse(Robot robot, ResponseCode code, Byte seqNum, Byte[] data, AsynchronousId asyncId, Int32 length) : base(robot, code, seqNum, data) { AsyncId = asyncId; PacketLength = length; }
public LeanKitAPIException(string message, ResponseCode responseCode) : this(message, responseCode, null) { }
public string ToString(ResponseCode code) { List<string> headers = new List<string>(); foreach (var f in Fields) headers.Add(f.Key + ": " + f.Value); if (!string.IsNullOrWhiteSpace(ContentType)) headers.Add("Content-type: " + ContentType); if (code != ResponseCode.None) for (var i = 0; i < Cookies.Count; i++) headers.Add("Set-Cookie: " + Cookies[i]); else for (var i = 0; i < Cookies.Count; i++) headers.Add("Cookie: " + Cookies[i]); headers.Sort(); StringBuilder res = new StringBuilder(); if (code == ResponseCode.None) res.Append(Method.ToString()).Append(" ").Append(Path).Append(" ").Append(Version).Append("\n").Append("Host: ").Append(Host).Append("\n"); else res.Append(Version).Append(" ").Append((int)code).Append(" ").Append(code.ToString()).Append("\n"); for (int i = 0; i < headers.Count; i++) res.Append(headers[i]).Append("\n"); if (code != ResponseCode.None) res.Append("Content-Length: " + Body.Length); res.Append("\n\n"); res.Append(Body); string ress = res.ToString(); return ress; }
/// <summary> /// Initializes a new instance of the AirException class with /// serialized data. /// </summary> /// <param name="info">保存序列化对象数据的对象。</param> /// <param name="context">有关源或目标的上下文信息。</param> /// <param name="code">异常代码。</param> public AirException(SerializationInfo info, StreamingContext context, ResponseCode code = ResponseCode.Succeed) : base(info, context) { Code = code; }
public Response(int length) { Length = length; Raw = null; Result = ResponseCode.COMMAND_NO_RESPONSE; WaitEvent = new AutoResetEvent(false); Complete = false; }
public AjaxResponse(ResponseCode responseCode) { this.ResponseCode = responseCode; }
public static string ToString(ResponseCode value) { if( value==ResponseCode.Ok ) return "ok"; else if( value==ResponseCode.Error ) return "error"; else if( value==ResponseCode.Rejection ) return "rejection"; else if( value==ResponseCode.Rules ) return "rules"; else if( value==ResponseCode.Undeliverable ) return "undeliverable"; else throw new ArgumentException("Unrecognized ResponseCode value: " + value.ToString()); }
async Task HandleRequest(POSAPIMsg message, Func <PATResponse> func) { _logger.Log($"Processing {message.Header.RequestType} {message.Header.RequestMethod}"); // Get content ResponseCode rc = ResponseCode.Ok; string content = null; try { PATResponse patResponse = func.Invoke(); content = JsonConvert.SerializeObject(patResponse); } catch (InvalidRequestException ex) { _logger.Log(ex.Message, LogType.ERROR); rc = ResponseCode.BadRequest; } catch (ResourceNotFoundException ex) { _logger.Log(ex.Message, LogType.ERROR); rc = ResponseCode.NotFound; } catch (Exception ex) { _logger.Log(ex.Message, LogType.ERROR); rc = ResponseCode.ServerError; } // Build response POSAPIMsg resp = new POSAPIMsg() { Header = new POSAPIMsgHeader() { RequestMethod = message.Header.RequestMethod, RequestType = message.Header.RequestType, ResponseCode = content != null ? ResponseCode.Ok : rc, ContentLength = content?.Length ?? 0 }, Content = content }; var respString = resp.ToString(); _logger.Log(new LogData(respString, $"TX (Building request): {respString}")); try { // build eft request EFTPayAtTableRequest eftRequest = new EFTPayAtTableRequest(); eftRequest.Header = resp.Header.ToString(); eftRequest.Content = resp.Content; await SendRequest(eftRequest); } catch (Exception ex) { _logger.Log(ex.Message, LogType.ERROR); throw; } }
/// <summary> /// Initializes a new instance of the AirException class with /// a specified error message and a reference to the inner exception that is /// the cause of this exception. /// </summary> /// <param name="message">解释异常原因的错误信息。</param> /// <param name="innerException">导致当前异常的异常。如果 innerException 参数不为空引用,则在处理内部异常的 catch 块中引发当前异常。</param> /// <param name="code">异常代码。</param> public AirException(string message, Exception innerException, ResponseCode code = ResponseCode.Succeed) : base(message, innerException) { Code = code; }
public ErrorPage(ResponseCode code, string message) { Code = code; Message = message; }
private byte[] BuildPacket() { byte[] buffer; if (DataBuffer == null) { DataBuffer = new Byte[0]; } if (Version == "1.0") { if ((Method == "") && (ResponseCode == -1)) { return(DataBuffer); } } UTF8Encoding UTF8 = new UTF8Encoding(); String sbuf; IDictionaryEnumerator en = TheHeaders.GetEnumerator(); en.Reset(); if (Method != "") { if (Version != "") { sbuf = Method + " " + EscapeString(MethodData) + " HTTP/" + Version + "\r\n"; } else { sbuf = Method + " " + EscapeString(MethodData) + "\r\n"; } } else { sbuf = "HTTP/" + Version + " " + ResponseCode.ToString() + " " + ResponseData + "\r\n"; } while (en.MoveNext()) { if ((String)en.Key != "CONTENT-LENGTH" || OverrideContentLength) { if (en.Value is string) { sbuf += (String)en.Key + ": " + (String)en.Value + "\r\n"; } else { sbuf += (String)en.Key + ":"; foreach (string v in (ArrayList)en.Value) { sbuf += (" " + v + "\r\n"); } } } } if (StatusCode == -1 && DontShowContentLength == false) { sbuf += "Content-Length: " + DataBuffer.Length.ToString() + "\r\n"; } else if (Version != "1.0" && Version != "0.9" && Version != "" && DontShowContentLength == false) { if (OverrideContentLength == false) { sbuf += "Content-Length: " + DataBuffer.Length.ToString() + "\r\n"; } } sbuf += "\r\n"; buffer = new byte[UTF8.GetByteCount(sbuf) + DataBuffer.Length]; UTF8.GetBytes(sbuf, 0, sbuf.Length, buffer, 0); Array.Copy(DataBuffer, 0, buffer, buffer.Length - DataBuffer.Length, DataBuffer.Length); return(buffer); }
// ----------------------------------------------------------------- /// <summary> /// /// </summary> // ----------------------------------------------------------------- public ResponseBase(ResponseCode result, string msg) { _Success = result; _Message = msg; }
public int HandleResponseMessage(UDPModel uModel) { KevSocketModel <IEnumerable <UserInfoModel> > ksModel = JsonHelper.ParseFromJson <KevSocketModel <IEnumerable <UserInfoModel> > >(uModel); if (ksModel == null) { return(ResponseCode.AnalyticalDataError); } if (ksModel.ResponseCode != ResponseCode.Success) { KevRegister.Get <Dispatcher>(ClientItemsPrimaryKey.Dispatcher_MainThread).Invoke(() => { KevRegister.Get <HomeForm>(ClientItemsPrimaryKey.Form_Home).label_status.Text = ResponseCode.GetDescription(ksModel.ResponseCode); }); return(ResponseCode.Error); } if (ksModel.Data == null) { return(ResponseCode.AnalyticalDataError); } KevRegister.Get <Dispatcher>(ClientItemsPrimaryKey.Dispatcher_MainThread).Invoke(() => { KevRegister.Get <HomeForm>(ClientItemsPrimaryKey.Form_Home).AddUserRange(ksModel.Data); foreach (UserInfoModel item in ksModel.Data) { UserCache.Updata(item); } }); return(ResponseCode.Success); }
/// <summary> /// returns a server side message to client with Json format /// </summary> /// <param name="code"></param> /// <param name="messageList"></param> /// <returns></returns> protected JsonResult GetUserMessageFromResponse(ResponseCode code, IEnumerable<string> messageList) { //Json(new {type=UserMessageType.ErrorMessage,message=filterContext.Exception.Message},JsonRequestBehavior.AllowGet); var type = StaticVariables.UserMessageType.NONE; switch (code) { case ResponseCode.Fail: type = StaticVariables.UserMessageType.ERROR; break; case ResponseCode.Success: type = StaticVariables.UserMessageType.SUCCESS; break; case ResponseCode.Warning: type = StaticVariables.UserMessageType.WARNING; break; case ResponseCode.Info: type = StaticVariables.UserMessageType.INFO; break; default: break; } return Json(new { type = type, messageArray = Newtonsoft.Json.JsonConvert.SerializeObject(messageList) }, JsonRequestBehavior.AllowGet); }
/// <summary> /// /// </summary> /// <param name="code"></param> /// <param name="msg"></param> public ResultDto(ResponseCode code, string msg) { Res = 0; Ec = code; Msg = msg; }