public ResponseBuilder([NotNull] JsonResponses jsonResponses, ResponseStatus status) { this.jsonResponses = jsonResponses; this.status = status; message = string.Empty; links = new List<Link>(); }
public void DecodeResponse(StreamReader xmlResponse) { _ResponseStatus = new ResponseStatus(); _ResponseData = new DataFields(); string xmlData = xmlResponse.ReadToEnd(); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(xmlData); XmlNodeList nodeList = xmlDocument.SelectNodes("/response"); foreach (XmlNode xmlNode in nodeList[0].ChildNodes) { switch (xmlNode.Name) { case "status": _ResponseStatus.Code = xmlNode.InnerText; _ResponseStatus.Text = getResponseText(xmlNode.InnerText); break; case "token": _ResponseStatus.Token = xmlNode.InnerText; break; case "error": _ResponseStatus.Error = xmlNode.InnerText; break; case "data": _ResponseData = NodeToDataFields(xmlNode.ChildNodes); break; default: break; } } }
public void Receive() { Reader = new BinaryReader(Connection.GetNetworkStream()); var reader = Reader; Status = (ResponseStatus)reader.ReadByte(); SessionId = reader.ReadInt32EndianAware(); if (Status == ResponseStatus.ERROR) { string exceptionString = ""; byte followByte = reader.ReadByte(); while (followByte == 1) { int exceptionClassLength = reader.ReadInt32EndianAware(); exceptionString += System.Text.Encoding.Default.GetString(reader.ReadBytes(exceptionClassLength)) + ": "; int exceptionMessageLength = reader.ReadInt32EndianAware(); // don't read exception message string if it's null if (exceptionMessageLength != -1) { exceptionString += System.Text.Encoding.Default.GetString(reader.ReadBytes(exceptionMessageLength)) + "\n"; } followByte = reader.ReadByte(); } if (OClient.ProtocolVersion >= 19) { int serializedVersionLength = reader.ReadInt32EndianAware(); var buffer = reader.ReadBytes(serializedVersionLength); } throw new OException(OExceptionType.Operation, exceptionString); } }
public void StatusElse(ResponseStatus status) { var response = new SagePay.Response.RefundResponse(); response.Status = status; Assert.False(response.IsValid()); }
public JsonResponse(string sessionId, ResponseStatus responseCode, object value) { this.SessionId = sessionId; this.Status = responseCode; this.Value = responseCode == ResponseStatus.Success ? value : this.PrepareErrorResponse(value); }
/// <summary> /// Constructor with parameters. /// </summary> /// <param name="version">The API version of the response.</param> /// <param name="status">The response status.</param> public ServiceResponse(string version, ResponseStatus status) : base() { this.Version = version; this.Status = status.ToString(); this.EndPoint = this.ResolveEndpoint(); }
public ResponseJson(ResponseStatus status) { this.status = status; data = "{}"; message = ""; time = DateTime.Now; remark = ""; }
public ResponseJson(ResponseStatus status, String message) { this.status = status; data = "{}"; this.message = message; time = DateTime.Now; remark = ""; }
public void AddErrorMessage(string errorMessage, bool setStatusToFailed = true) { _errorMessages.Add(errorMessage); if (setStatusToFailed) { _responseStatus = ResponseStatus.Failure; } }
public ResponseJson(ResponseStatus status, DateTime time) { this.status = status; data = "{}"; message = ""; this.time = time; remark = ""; }
public ActionResult Delete(int curPage) { resp = familyService.DeleteFamily(Request); return this.JudgeResult(resp, () => RedirectToAction("Details", new { curpage = curPage, msg = "删除成员完成" })); }
public virtual void Parse( ResponseStatus responseStatus, ArraySegment<byte> bodyData, ArraySegment<byte> extras, ArraySegment<byte> key, int bytesOfBodyPreviouslyRead, int totalBodyLength) { }
public void Log(ResponseStatus responseStatus, string resourceUrl) { Console.WriteLine("Console and file loger URL: {1} | Status: {0}", responseStatus, resourceUrl); using (var stWr = new StreamWriter(@"../log.txt",true)) { var sb = new StringBuilder(String.Format("{0} | {1} | {2}", DateTime.Now.ToString(), resourceUrl, responseStatus)); stWr.WriteLine(sb); } }
/// <summary> /// Gets the URL for the Response detail page of a given Response instance. /// </summary> /// <param name="eventId">The event ID.</param> /// <param name="eventStart">The date for which this response was made.</param> /// <param name="status">The status.</param> /// <param name="count">The number of Responses for this event and status.</param> /// <returns> /// A URL for the Response detail page of a given Response instance /// </returns> private string GetDetailUrl(int eventId, DateTime eventStart, ResponseStatus status, int count) { return count > 0 ? this.BuildLinkUrl( this.ModuleId, "ResponseDetail", Utility.GetEventParameters(eventId, eventStart, "status=" + status)) : string.Empty; }
protected string JsonResponse(ResponseStatus status, object value) { if (status != ResponseStatus.Success && value == null) { value = string.Format("WebDriverException {0}", Enum.GetName(typeof(ResponseStatus), status)); } return JsonConvert.SerializeObject(new JsonResponse(this.Session, status, value)); }
public ActionResult Delete(int curPage) { resp = importantEventService.DeleteImportantEvent(Request); return this.JudgeResult(resp, () => RedirectToAction("Details", new { curpage = curPage, msg = "删除事项完成" })); }
public PingResult(int pingResultId, int statusCode, string statusDescription, string server, Uri responseUri, ResponseStatus responseStatus, DateTime dateCreated) { this.PingResultId = pingResultId; this.StatusCode = statusCode; this.StatusDescription = statusDescription; this.Server = server; this.ResponseUri = responseUri.ToString(); this.ResponseStatus = responseStatus.ToString(); this.DateCreated = dateCreated; }
public ActionResult Delete(NoticeType ntype, int curPage) { resp = noticeService.DeleteNotice(Request); return this.JudgeResult(resp, () => RedirectToAction("Details", new { ntype = NoticeType.ASSOCIATION, curpage = curPage, msg = string.Format("删除公告完成") })); }
public ActionResult Add() { if (Request.Form != null && Request.Form.Count > 0) { resp = departmentService.AddDepartment(Request); return this.JudgeResult(resp, () => RedirectToAction("Details", new { msg = string.Format("添加了'{0}'部门", Request.Form["name"].ToString()) })); } conta_Department = new Container_Department(); return View(conta_Department); }
public void Can_serialize_ResponseStats() { var dto = new ResponseStatus { ErrorCode = null }; var dtoString = TypeSerializer.SerializeToString(dto); Assert.That(dtoString, Is.EqualTo("{Errors:[]}")); Console.WriteLine(dtoString); }
public void Log(ResponseStatus responseStatus, string resourceUrl) { Console.WriteLine("File loger"); using (Stream st = File.Open("../log.txt",FileMode.OpenOrCreate, FileAccess.Write)) { var stWr =new StreamWriter(st); var sb = new StringBuilder(String.Format("{0} | {1}\n", resourceUrl, responseStatus)); stWr.WriteLine(sb); stWr.Flush(); } }
public static Mock<IRestClient> SetupIRestClientMock(ResponseStatus responsesStatus, string filename) { var moqRestClient = new Mock<IRestClient>(); moqRestClient.Setup(x => x.Execute(It.Is<IRestRequest> (p => p.Parameters.Exists(y => y.Name == "user") && p.Parameters.Exists(y => y.Name == "file") && p.Parameters.Exists(y => y.Value == "matt") && p.Parameters.Exists(y => y.Value == filename)) )) .Returns(new RestResponse() { ResponseStatus = responsesStatus }); return moqRestClient; }
/// <summary> /// HandleError /// </summary> /// <param name="responseStatus"></param> protected void HandleError(ResponseStatus responseStatus, ServiceResponseMessage responseMessage) { if (responseStatus == ResponseStatus.BusinessException) { throw new BusinessException(responseMessage.Message, responseMessage.MessageCode, responseMessage.Overridable); } else if (responseStatus == ResponseStatus.Exception) { throw new SysException(responseMessage.Message); } }
public void Only_Serializes_DataMember_fields_for_DataContracts() { var dto = new ResponseStatus { ErrorCode = "ErrorCode", Message = "Message", StackTrace = "StackTrace", Errors = new List<ResponseError>(), }; Serialize(dto); }
public void Load_WhenNotSuccess_ReturnNull(ResponseStatus status) { //arrange var result = new Mock<IOperationResult<byte[]>>(); result.Setup(x => x.Status).Returns(status); var bucket = new Mock<IBucket>(); bucket.Setup(x => x.Get<byte[]>(It.IsAny<string>())).Returns(result.Object); //act var item = SessionStateItem.Load(bucket.Object, "thekey", false); //assert Assert.IsNull(item); }
public ActionResult Update(int id, string message) { if (Request.Form != null && Request.Form.Count > 0) { resp = departmentService.UpdateDepartment(Request); return this.JudgeResult(resp, () => RedirectToAction("Details", new { msg = string.Format("'{0}'部门已经更新", message) })); } else { conta_Department = new Container_Department(); conta_Department.dep = new Department(); resp = departmentService.GetDepartment(id, conta_Department.dep); return this.JudgeResult(resp, () => View(conta_Department)); } }
public ActionResult Add(int curPage) { if (Request.Form != null && Request.Form.Count > 0) { resp = noticeService.AddNotice(Request); return this.JudgeResult(resp, () => RedirectToAction("Details", new{ ntype = Convert.ToByte(Request.Form["ntype"]) == 1 ? NoticeType.All_MEMBER : NoticeType.ASSOCIATION, curpage = curPage, msg = string.Format("添加了公告:{0}", Request.Form["content"]) })); } ViewData["curPage"] = curPage; return View(); }
public override void Parse( ResponseStatus responseStatus, ArraySegment<byte> bodyData, ArraySegment<byte> extras, ArraySegment<byte> key, int bytesOfBodyPreviouslyRead, int totalBodyLength) { if (bytesOfBodyPreviouslyRead == 0) { _decoder = new StringDecoder(); } _decoder.Decode(bodyData); }
public ActionResult Add(int curPage) { if (Request.Form != null && Request.Form.Count > 0) { resp = importantEventService.AddImportantEvent(Request); return this.JudgeResult(resp, () => RedirectToAction("Details", new { curpage = curPage, msg = string.Format("添加了事项:{0}", Request.Form["content"]) })); } ViewData["curPage"] = curPage; return View(); }
public ActionResult Details(string msg) { conta_List_Department = new Container_List_Department(); conta_List_Department.message = msg; conta_List_Department.List_Dep = new List<Department>(); resp = departmentService.GetDepartments(Request, conta_List_Department); Container_Authority_Msg auth = new Container_Authority_Msg(); ResponseStatus resp1 = ServiceBuilder.BuildAuthService().GetSecondAuth(Request.Cookies, auth); if (resp1 == ResponseStatus.FAILED) resp = resp1; return this.JudgeResult(resp, () => { conta_List_Department.isAdd = auth.isAdd; conta_List_Department.isDelete = auth.isDelete; conta_List_Department.isUpdate = auth.isUpdate; conta_List_Department.isVisit = auth.isVisit; return View(conta_List_Department); }); }
public Response(ResponseStatus status, T body) : base(status) { _responseBody = body; }
public ErrorResponse(Error result) { Result = result; ResponseStatus = new ResponseStatus(); }
/// <summary> /// 返回异常信息 /// </summary> public static Result FromError(string message, ResponseStatus code = ResponseStatus.Fail) { return(new Result(code, message)); }
protected sealed override void setValue(object value) { var response = value as IRestResponse; if (Request != null) { Request.SetValue(response.Request); } if (ErrorMessage != null) { ErrorMessage.SetValue(response.ErrorMessage); } if (ResponseStatus != null) { ResponseStatus.SetValue(response.ResponseStatus); } if (Headers != null) { foreach (var header in Headers) { var headerValue = response.Headers.FirstOrDefault(h => h.Name == header.Key); if (headerValue != null) { header.Value.SetValue(headerValue.Value); } } } if (Cookies != null) { foreach (var cookie in Cookies) { var cookieValue = response.Cookies.FirstOrDefault(c => c.Name == cookie.Key); if (cookieValue != null) { cookie.Value.SetValue(cookieValue.Value); } } } if (Server != null) { Server.SetValue(response.Server); } if (ResponseUri != null) { ResponseUri.SetValue(response.ResponseUri); } if (ErrorException != null) { ErrorException.SetValue(response.ErrorException); } if (RawBytes != null) { RawBytes.SetValue(response.RawBytes); } if (IsSuccessful != null) { IsSuccessful.SetValue(response.IsSuccessful); } if (StatusCode != null) { StatusCode.SetValue(response.StatusCode); } if (Content != null) { Content.SetValue(response.Content); } if (ContentEncoding != null) { ContentEncoding.SetValue(response.ContentEncoding); } if (ContentLength != null) { ContentLength.SetValue(response.ContentLength); } if (ContentType != null) { ContentType.SetValue(response.ContentType); } if (StatusDescription != null) { StatusDescription.SetValue(response.StatusDescription); } if (ProtocolVersion != null) { ProtocolVersion.SetValue(response.ProtocolVersion); } setExtraValues(response); }
public ResponseInfo(ResponseStatus status, bool hasData) { Status = status; HasData = hasData; }
public ResponseModel(ResponseStatus status, T data) : this(status, data, status.GetEnumDescription()) { }
protected string JsonResponse(ResponseStatus status = ResponseStatus.Success, object value = null) { return(JsonConvert.SerializeObject( new JsonResponse(this.Automator.Session, status, value), Formatting.Indented)); }
public static Response Of(ResponseStatus statusCode, string entity) => new Response(Version.Http1_1, statusCode, Http.Headers.Empty <ResponseHeader>(), Body.From(entity));
public static Response Of(Version version, ResponseStatus statusCode, byte[] entity) => new Response(version, statusCode, Http.Headers.Empty <ResponseHeader>(), Body.From(entity));
public PostBitmapResponse(Image <Rgba32> img, ResponseStatus status) { Image = img; Status = status; }
public static Response Of(Version version, ResponseStatus statusCode) => new Response(version, statusCode, Http.Headers.Empty <ResponseHeader>(), Body.Empty);
public ConceptoDeleteResponse() { ResponseStatus = new ResponseStatus(); ResponseStatus.Message = "OK"; Success = false; }
public ErrorResponse(ResponseStatus status, string errorMessage = null) { Status = status; StatusMessage = status.ToString(); ErrorMessage = errorMessage; }
/// <summary> /// 返回结果 /// </summary> /// <param name="code">状态码</param> /// <param name="message">提示信息</param> public Result(ResponseStatus code, string message = null) { Code = code; Message = message; }
public override void OnExceptionTypeFilter(Exception ex, ResponseStatus responseStatus) { "In OnExceptionTypeFilter...".Print(); base.OnExceptionTypeFilter(ex, responseStatus); }
public static Response Of(Version version, ResponseStatus statusCode, Headers <ResponseHeader> headers) => new Response(version, statusCode, headers, Body.Empty);
public ResponseModel(ResponseStatus status, T data, string message) { Status = status; Data = data; Message = message; }
public static Response Of(Version version, ResponseStatus statusCode, Headers <ResponseHeader> headers, byte[] entity) => new Response(version, statusCode, headers, Body.From(entity));
public CurrentSongNameResponse() { ResponseStatus = new ResponseStatus(); }
public static Response Of(ResponseStatus statusCode, Body body) => new Response(Version.Http1_1, statusCode, Http.Headers.Empty <ResponseHeader>(), body);
public static bool StatusIsSuccess(ResponseStatus status) { return(((int)status) > 0); }
public static Response Of(ResponseStatus statusCode, Headers <ResponseHeader> headers, Body entity) => new Response(Version.Http1_1, statusCode, headers, entity);
/// <summary> /// Generate register of systems document using existing file. /// </summary> /// <param name="tv"></param> /// <param name="clientFolder"></param> /// <param name="fileName"></param> /// <returns></returns> public ResponseStatus RegisterOfSytemDocuments2(TreeView tv, string clientFolder, string fileName, string processName, string userID) { uioutput.AddOutputMessage("Starting Register of Systems Documents generation...", processName, userID); uioutput.AddOutputMessage(clientFolder, processName, userID); uioutput.AddOutputMessage(fileName, processName, userID); ResponseStatus ret = new ResponseStatus(); object oMissing = System.Reflection.Missing.Value; object vkMissing = System.Reflection.Missing.Value; object vkReadOnly = false; object vkVisiblefalse = false; object vkFalse = false; var pastPlannedActivities = string.Empty; //Start Word and open the document. //WordNet._Application oApplication = new Application { Visible = false }; // string clientDestinationFileLocation = document.clientDocument.Location.Trim(); string clientDestinationFileLocation = clientFolder; //string clientDestinationFileLocationName = Utils.getFilePathName( // clientDestinationFileLocation, document.clientDocument.FileName.Trim() ); string clientDestinationFileLocationName = Utils.getFilePathName(clientDestinationFileLocation, fileName.Trim()); object destinationFileName = clientDestinationFileLocationName; if (!File.Exists(clientDestinationFileLocationName)) { uioutput.AddOutputMessage("File doesn't exist " + destinationFileName, processName: processName, userID: userID); uioutput.AddErrorMessage("File doesn't exist " + destinationFileName, processName: processName, userID: userID); var responseerror = new ResponseStatus(MessageType.Error); responseerror.Message = "File doesn't exist " + destinationFileName; return(responseerror); } WordNet._Document oDoc; try { uioutput.AddOutputMessage("Opening document in Word... " + destinationFileName, processName: processName, userID: userID); oDoc = oApplication.Documents.Open( ref destinationFileName, ref vkMissing, ref vkFalse, ref vkMissing, ref vkMissing, ref vkMissing, ref vkMissing, ref vkMissing, ref vkMissing, ref vkMissing, ref vkMissing, ref vkVisiblefalse); } catch (Exception ex) { var responseerror = new ResponseStatus(MessageType.Error); responseerror.ReturnCode = -1; responseerror.ReasonCode = 1000; responseerror.Message = "Error copying file."; responseerror.Contents = ex; return(responseerror); } if (oDoc.ReadOnly) { if (uioutput != null) { uioutput.AddOutputMessage("(Word) File is Read-only contact support: " + destinationFileName, processName, userID); } oDoc.Close(); System.Runtime.InteropServices.Marshal.ReleaseComObject(oDoc); var responseerror = new ResponseStatus(MessageType.Error); responseerror.Message = "(Word) File is Read-only contact support: " + destinationFileName; return(responseerror); } try { if (uioutput != null) { uioutput.AddOutputMessage("Saving document in Word... " + destinationFileName, processName, userID); } oDoc.Save(); } catch (Exception ex) { if (uioutput != null) { uioutput.AddOutputMessage("Error saving file " + clientDestinationFileLocationName, processName, userID); } var responseerror = new ResponseStatus(MessageType.Error); responseerror.Message = "Error saving file " + clientDestinationFileLocationName; return(responseerror); } string msg = ">>> Opening file... " + destinationFileName; if (uioutput != null) { uioutput.AddOutputMessage(msg, processName, userID); } PrintToWord(oDoc, " ", 8, 1); WordNet.Range wrdRng; WordNet.Table oTable; wrdRng = oDoc.Bookmarks.get_Item(oEndOfDoc).Range; int rowCount = 30; // Get number of rows for a client document, client document set // // var cds = new BUSClientDocumentSet( Utils.ClientID, Utils.ClientSetID XXXXXXXXXXXXXXX ); var cds = new BUSClientDocumentSet(clientID, clientDocSetID); rowCount = cds.DocumentCount; if (rowCount < 1) { return(new ResponseStatus(MessageType.Error)); } oTable = oDoc.Tables.Add(wrdRng, rowCount, 8, ref vkFalse, ref vkFalse); oTable.Borders.OutsideColor = WordNet.WdColor.wdColorBlack; oTable.Borders.InsideLineStyle = WordNet.WdLineStyle.wdLineStyleDouble; oTable.Borders.OutsideColor = WordNet.WdColor.wdColorBlueGray; oTable.Borders.OutsideLineStyle = WordNet.WdLineStyle.wdLineStyleEmboss3D; oTable.Rows [1].HeadingFormat = -1; WordNet.Row headingRow = oTable.Rows [1]; ApplyHeadingStyle(headingRow.Cells [1], 200); headingRow.Cells [1].Range.Text = "Directory"; ApplyHeadingStyle(headingRow.Cells [2], 60); headingRow.Cells [2].Range.Text = "Sub Directory"; ApplyHeadingStyle(headingRow.Cells [3], 80); headingRow.Cells [3].Range.Text = "Document Number"; ApplyHeadingStyle(headingRow.Cells [4], 30); headingRow.Cells [4].Range.Text = "Sml"; ApplyHeadingStyle(headingRow.Cells [5], 40); headingRow.Cells [5].Range.Text = "Med"; ApplyHeadingStyle(headingRow.Cells [6], 30); headingRow.Cells [6].Range.Text = "Lrg"; ApplyHeadingStyle(headingRow.Cells [7], 50); headingRow.Cells [7].Range.Text = "Version"; ApplyHeadingStyle(headingRow.Cells [8], 200); headingRow.Cells [8].Range.Text = "Document Name"; int line = 0; foreach (var treeNode in tv.Nodes) { line++; WriteLineToRoSD(tv.Nodes [0], oDoc, oTable, prefix: "", parent: "", seqnum: line); } msg = ">>> End "; if (uioutput != null) { uioutput.AddOutputMessage(msg, processName, userID); } PrintToWord(oDoc, " ", 12, 1); try { oDoc.Save(); } catch (Exception ex) { if (uioutput != null) { uioutput.AddOutputMessage("Error saving file again... " + clientDestinationFileLocationName, processName, userID); } var responseerror = new ResponseStatus(MessageType.Error); responseerror.Message = "Error saving file again... " + clientDestinationFileLocationName; return(responseerror); } oDoc.Close(); ResponseStatus goodresponse = new ResponseStatus(MessageType.Informational); goodresponse.Message = "Document SRG-01 generated successfully."; return(goodresponse); }
public static Response Of(Version?version, ResponseStatus statusCode, Headers <ResponseHeader> headers, Body?entity) => new Response(version, statusCode, headers, entity);
public static Exception CreateException(this ResponseStatus status, KeyValueErrorContext ctx) { switch (status) { case ResponseStatus.KeyNotFound: return(new DocumentNotFoundException { Context = ctx }); case ResponseStatus.KeyExists: if (ctx.OpCode != OpCode.Add) { return(new CasMismatchException { Context = ctx }); } return(new DocumentExistsException { Context = ctx }); case ResponseStatus.ValueTooLarge: return(new ValueToolargeException { Context = ctx }); case ResponseStatus.InvalidArguments: return(new InvalidArgumentException { Context = ctx }); case ResponseStatus.TemporaryFailure: case ResponseStatus.OutOfMemory: case ResponseStatus.Busy: case ResponseStatus.NotInitialized: return(new TemporaryFailureException { Context = ctx }); case ResponseStatus.OperationTimeout: return(new AmbiguousTimeoutException { Context = ctx }); case ResponseStatus.Locked: return(new DocumentLockedException { Context = ctx }); case ResponseStatus.DocumentMutationLost: return(new MutationLostException { Context = ctx }); case ResponseStatus.DurabilityInvalidLevel: return(new DurabilityLevelNotAvailableException { Context = ctx }); case ResponseStatus.DurabilityImpossible: return(new DurabilityImpossibleException { Context = ctx }); case ResponseStatus.SyncWriteInProgress: return(new DurableWriteInProgressException { Context = ctx }); case ResponseStatus.SyncWriteReCommitInProgress: return(new DurableWriteReCommitInProgressException { Context = ctx }); case ResponseStatus.SyncWriteAmbiguous: return(new DurabilityAmbiguousException { Context = ctx }); case ResponseStatus.Eaccess: case ResponseStatus.AuthenticationError: case ResponseStatus.AuthenticationContinue: //likely remove case ResponseStatus.AuthStale: return(new AuthenticationFailureException { Context = ctx }); case ResponseStatus.VBucketBelongsToAnotherServer: return(new NotMyVBucketException { Context = ctx }); case ResponseStatus.SubdocXattrUnknownVattr: return(new XattrException { Context = ctx }); case ResponseStatus.SubdocXattrUnknownMacro: case ResponseStatus.SubDocXattrInvalidFlagCombo: case ResponseStatus.SubDocXattrInvalidKeyCombo: case ResponseStatus.SubdocXattrCantModifyVattr: case ResponseStatus.SubdocInvalidXattrOrder: return(new XattrException { Context = ctx }); //sub doc errors case ResponseStatus.SubdocMultiPathFailureDeleted: case ResponseStatus.SubDocMultiPathFailure: case ResponseStatus.SubDocPathNotFound: case ResponseStatus.SubDocPathMismatch: case ResponseStatus.SubDocPathInvalid: return(new PathInvalidException { Context = ctx }); case ResponseStatus.SubDocPathTooBig: return(new PathTooDeepException { Context = ctx }); case ResponseStatus.SubDocDocTooDeep: return(new DocumentTooDeepException { Context = ctx }); case ResponseStatus.SubDocCannotInsert: return(new ValueNotJsonException { Context = ctx }); case ResponseStatus.SubDocDocNotJson: return(new DocumentNotJsonException { Context = ctx }); case ResponseStatus.SubDocNumRange: return(new NumberTooBigException { Context = ctx }); case ResponseStatus.SubDocDeltaRange: return(new DeltaInvalidException { Context = ctx }); case ResponseStatus.SubDocPathExists: return(new PathExistsException { Context = ctx }); case ResponseStatus.SubDocValueTooDeep: return(new DocumentTooDeepException { Context = ctx }); case ResponseStatus.SubDocInvalidCombo: return(new InvalidArgumentException { Context = ctx }); case ResponseStatus.DocumentMutationDetected: //maps to nothing case ResponseStatus.NoReplicasFound: //maps to nothing case ResponseStatus.InvalidRange: //maps to nothing case ResponseStatus.ItemNotStored: //maps to nothing case ResponseStatus.IncrDecrOnNonNumericValue: //maps to nothing case ResponseStatus.Rollback: //maps to nothing case ResponseStatus.InternalError: //maps to nothing case ResponseStatus.UnknownCommand: //maps to nothing case ResponseStatus.BucketNotConnected: //maps to nothing case ResponseStatus.NotSupported: //maps to nothing return(new CouchbaseException { Context = ctx }); case ResponseStatus.UnknownCollection: return(new CollectionOutdatedException { Context = ctx }); case ResponseStatus.TransportFailure: return(new RequestCanceledException { Context = ctx }); default: return(new CouchbaseException { Context = ctx }); } }
public Response(ResponseStatus status) : base(status) { }
public async Task <ResponseStatus> Upload() { ResponseStatus status = new ResponseStatus(); try { //var file = Request.Form.Files[0]; // var file = Request.Form.Files[0]; //var fileuploadPath = HttpContext.Current.Server.MapPath("~/Images"); ; //var provider = new MultipartFormDataStreamProvider(fileuploadPath); //var content = new StreamContent(HttpContext.Current.Request.GetBufferlessInputStream(true)); //foreach (var header in Request.Content.Headers) //{ // content.Headers.TryAddWithoutValidation(header.Key, header.Value); //} //await content.ReadAsMultipartAsync(provider); //string uploadingFileName = provider.FileData.Select(x => x.LocalFileName).FirstOrDefault(); //var guId = Guid.NewGuid(); //var type = provider.FormData["type"]; //var name = provider.FormData["name"]; //// string pid = Convert.ToString(provider.FormData["SId"]); //string id = Convert.ToString(provider.FormData["SId"]); //if (!string.IsNullOrEmpty(id)) //{ // id = Convert.ToString(provider.FormData["SId"]); //} //else //{ // id = guId.ToString(); //} //// string cid = Convert.ToString(provider.FormData["PId"]); //string filename = String.Concat(type, name, RandomNumber(1000, 50000) + ".jpg"); //string originalFileName = String.Concat(fileuploadPath, "\\" + (filename).Trim(new Char[] { '"' })); //if (File.Exists(originalFileName)) //{ // File.Delete(originalFileName); //} //File.Move(uploadingFileName, originalFileName); // productimages productimages = appDbContex.Productimages.Where(a => a.id == id).SingleOrDefault(); var httpRequest = HttpContext.Current.Request; if (httpRequest.Files.Count > 0) { var docfiles = new List <string>(); foreach (string file in httpRequest.Files) { var postedFile = httpRequest.Files[file]; var guId = Guid.NewGuid(); string id = Convert.ToString(httpRequest.Form["SId"]); if (!string.IsNullOrEmpty(id)) { id = Convert.ToString(httpRequest.Form["SId"]); } else { id = guId.ToString(); } string filename = RandomNumber(1000, 50000) + postedFile.FileName; var filePath1 = HttpContext.Current.Server.MapPath("~/Images/" + filename); Stream strm = postedFile.InputStream; Compressimage(strm, filePath1, postedFile.FileName); slider slider = appDbContex.Sliders.Where(a => a.id == id).SingleOrDefault(); if (slider != null) { slider.image = "http://api.greenshops.in/Images/" + filename; // memoryCache.Remove("bannerlist"); await appDbContex.SaveChangesAsync(); } else { slider slider1 = new slider { id = id, image = "http://api.greenshops.in/Images/" + filename, deleted = false, active = false, createAt = DateTime.Now }; appDbContex.Sliders.Add(slider); // memoryCache.Remove("bannerlist"); await appDbContex.SaveChangesAsync(); } } } status.status = true; status.message = "uploaded"; // status.filePath = "http://api.clickperfect.me/Images/" + filename; } catch (Exception ex) { status.status = false; status.message = ex.ToString(); } return(status); }
/// <summary> /// 返回指定 Code /// </summary> public static Result FromCode(ResponseStatus code, string message = null) { return(new Result(code, message)); }
/// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <param name="code"></param> /// <param name="message"></param> /// <param name="data"></param> /// <returns></returns> public static Result <T> FromCode <T>(ResponseStatus code, T data, string message = null) { return(new Result <T>(code, message, data)); }
public void SetException_Sets_TemporaryLockFailureException_Only_When_LOCK_ERROR(ResponseStatus responseStatus, string message) { var result = new OperationResult { Status = responseStatus, Message = message }; result.SetException(); if (message == null) { Assert.IsNull(result.Exception); } else { Assert.IsInstanceOf <TemporaryLockFailureException>(result.Exception); } }