public BaseReturn Crop(ImageCropDTO dto) { var result = new BaseReturn(); try { using (var image = new MagickImage(dto.Source)) { image.Crop(dto.Width, dto.Height); image.Write(dto.FullDestination); } if (dto.DeleteSource) { File.Delete(dto.Source); } result.Ok(); } catch (Exception ex) { result.AddMessage("[error]", ex.Message); } return(result); }
/// <summary> /// 同步wish订单 /// </summary> /// <param name="filter"></param> /// <returns></returns> public List <SyncWishOrdersReturn> SyncOrders(SyncWishOrdersFilter filter) { using (var client = new WebClient()) { List <SyncWishOrdersReturn> list = new List <SyncWishOrdersReturn>(); string url = "https://china-merchant.wish.com/api/v2/order/multi-get?start={0}&limit={1}&since={2}&access_token={3}&show_original_shipping_detail=True"; url = string.Format(url, filter.start, filter.limit, filter.since, access_token); var responseString = client.DownloadString(url); BaseReturn <List <SyncWishOrdersReturn> > entity = new BaseReturn <List <SyncWishOrdersReturn> >(); entity = JsonConvert.DeserializeObject <BaseReturn <List <SyncWishOrdersReturn> > >(responseString); if (entity.code != 0) { throw new Exception(entity.message); } list.AddRange(entity.data); while (entity.paging != null && entity.paging.next != null) { responseString = client.DownloadString(entity.paging.next); entity = new BaseReturn <List <SyncWishOrdersReturn> >(); entity = JsonConvert.DeserializeObject <BaseReturn <List <SyncWishOrdersReturn> > >(responseString); if (entity.code == 0 && entity.data.Count() > 0) { list.AddRange(entity.data); } else { break; } } list = list.OrderBy(q => q.Order.last_updated).ToList(); return(list); } }
// make method async EAttachment getAttachmentData(Email mail, string attachmentId, string filename) { EAttachment attachment = null; MessagePartBody attachPart = _service.Users.Messages.Attachments.Get("me", mail.MailId, attachmentId).Execute(); byte[] attachmentData = CommonFunctions.FromBase64ForString(attachPart.Data); StorageService.Storage storageService = new StorageService.Storage("Email/" + mail.MailId); EStorageRequest request = new EStorageRequest { FileName = filename, isSaveLocal = true }; BaseReturn <EStorageResponse> storageResponse = storageService.BinaryUpload(request, attachmentData); attachment = new EAttachment { AttachmentId = attachmentId, Filename = filename, localUrl = storageResponse.Data.LocalFilePath, CloudUrl = storageResponse.Data.BucketFilePath, Data = attachPart != null ? attachmentData : null }; return(attachment); }
// protected override bool IsEnblocExists<T>(IEnumerable<T> lstEnblocSnapshot) // { // var enblocData = ((List<EmptyEnblocSnapshot>)lstEnblocSnapshot).First(); // return new EmpezarRepository<EmptyEnbloc>().IsExists(x => x.EnblocNumber == enblocData.EnblocNumber && x.Status != Status.COMPLETED); // } protected override BaseReturn <Dictionary <string, string> > ValidateOtherData <T>(Email email, IEnumerable <T> lstEnblocSnapshot) { BaseReturn <Dictionary <string, string> > baseObject = new BaseReturn <Dictionary <string, string> >(); Dictionary <string, string> obj = new Dictionary <string, string>(); obj.Add("transactionNo", Convert.ToString(email.TransactionId)); var lstenbloc = ((List <EmptyEnblocSnapshot>)lstEnblocSnapshot); var IsEnblocExists = new EmpezarRepository <EmptyEnbloc>().IsExists(x => x.EnblocNumber == lstenbloc.First().EnblocNumber&& x.Status != Status.COMPLETED); if (!IsEnblocExists) { obj.Add("errors" + Guid.NewGuid().ToString(), "Enbloc already exists in the system"); baseObject.Success = false; baseObject.Code = (int)EnumTemplateCode.ErrorOccuredExcel; baseObject.Data = obj; return(baseObject); } if (!(lstenbloc.Select(x => x.ViaNo).Distinct().Count() == lstenbloc.Count)) { obj.Add("errors" + Guid.NewGuid().ToString(), "Duplicate Via No. not allowed."); baseObject.Success = false; baseObject.Code = (int)EnumTemplateCode.ErrorOccuredExcel; baseObject.Data = obj; return(baseObject); } baseObject.Success = true; return(baseObject); }
public BaseReturn <List <EAttachment> > getAttachments(Email mail, List <EAttachmentRequest> attachmentRequest) { List <EAttachment> attachments = null; BaseReturn <List <EAttachment> > baseObject = new BaseReturn <List <EAttachment> >(); try { attachments = new List <EAttachment>(); foreach (EAttachmentRequest attachment in attachmentRequest) { var attachmentData = getAttachmentData(mail, attachment.AttachmentId, attachment.Filename); attachments.Add(attachmentData); } baseObject.Success = true; baseObject.Data = attachments; saveMailAttachments(mail.TransactionId, attachments); } catch (Exception ex) { baseObject.Success = false; baseObject.Message = "Error Occured."; } return(baseObject); }
public BaseReturn Validation(ImageValidationDTO dto) { var result = new BaseReturn(); try { using (var image = new MagickImage(dto.Source)) { if (dto.Type.Equals(ImageValidationDTO.type.absolue) && image.Width.Equals(dto.Width) && image.Height.Equals(dto.Height)) { result.Ok(); } else if (dto.Type.Equals(ImageValidationDTO.type.relative) && image.Width <= dto.Width && image.Height <= dto.Height) { result.Ok(); } } } catch (Exception ex) { result.AddMessage("[error]", ex.Message); } return(result); }
public ActionResult Registrar(FormCollection collection) { BaseReturn retorno = null; var Nome = Convert.ToString(collection["Nome"]); var Email = Convert.ToString(collection["Email"]); var DataNascimento = Convert.ToDateTime(collection["DataNascimento"]); var CPF = Convert.ToString(collection["CPF"]); var Telefone = Convert.ToString(collection["Telefone"]); var Celular = Convert.ToString(collection["Celular"]); var Sexo = (Sexo)Enum.Parse(typeof(Sexo), Convert.ToString(collection["Sexo"])); var Rua = Convert.ToString(collection["Rua"]); var Bairro = Convert.ToString(collection["Bairro"]); var CEP = Convert.ToString(collection["CEP"]); var Cidade = Convert.ToString(collection["Cidade"]); var Numero = Convert.ToInt32(collection["Numero"]); var UF = Convert.ToString(collection["UF"]); var Complemento = Convert.ToString(collection["Complemento"]); var Usuario = Convert.ToString(collection["Usuario"]); var Senha = Convert.ToString(collection["Senha"]); if (ModelState.IsValid) { retorno = _RepositoryControlUsuario.CadastrarUsuarioLogin(Nome, DataNascimento, Email, CPF, Sexo, Telefone, Celular, Rua, Bairro, CEP, Cidade, Numero, UF, Complemento, 2, 1, Usuario, Senha.ConvertToMD5()); return(RedirectToAction("Register", "Home", new { @msg = retorno.Status ? "" : "Erro" + retorno.Propert + " - " + retorno.Message })); } return(RedirectToAction("Register", retorno)); }
/// <summary> /// 审核页面 /// </summary> /// <param name="pageid"></param> /// <param name="version"></param> /// <returns></returns> public async Task <bool> ReviewPage(string pageid, int version) { string apitype = JsonApiType.reviewPage; BaseRequest bj = GetCommonBaseRequest(apitype); ReviewRequest re = new ReviewRequest(version, pageid); bj.api_type = apitype; bj.data = re; try { var result = await Post(bj); BaseReturn brj = JsonController.DeSerializeToClass <BaseReturn>(result); CommonReturn cr = JsonController.DeSerializeToClass <CommonReturn>(brj.data.ToString()); if (cr.error_code.Equals(ReturnConst.right)) { return(true); } else { return(false); } } catch { return(false); } }
private static BaseReturn <Dictionary <string, string> > ProcessEmailAttachments(Mail mailService, Email email, List <EmptyEnblocSnapshot> lstEnblocSnapshot) { BaseReturn <Dictionary <string, string> > baseObject = new BaseReturn <Dictionary <string, string> >(); Dictionary <string, string> obj = new Dictionary <string, string>(); try { FileInfo file = new FileInfo(email.Attachments.First().localUrl); ProcessEnbloc(file, "EM", email.TransactionId, lstEnblocSnapshot); baseObject.Success = true; } catch (Exception ex) { baseObject.Success = false; baseObject.Code = (int)TemplateCodes.NoAttachment; baseObject.Data = obj; } return(baseObject); // SaveEnblocSnapshot(); // SaveEnblocContainerSnapshot(); // SaveEnbloc(); // SaveEnblocContainer(); }
/// <summary> /// 获取最近上传页面 /// </summary> /// <param name="version"></param> /// <returns></returns> public async Task <List <PageGroupDetail> > GetRecentUploadPages() { string apitype = JsonApiType.groupPageGet; BaseRequest bj = GetCommonBaseRequest(apitype); string reviewState = "0"; RecentUploadPageRequest pgd = new RecentUploadPageRequest(reviewState); bj.api_type = apitype; bj.data = pgd; try { var result = await Post(bj); BaseReturn brj = JsonController.DeSerializeToClass <BaseReturn>(result); pageGroupReturnData pgr = JsonController.DeSerializeToClass <pageGroupReturnData>(brj.data.ToString()); if (!object.Equals(pgr.data, null) && pgr.data.Length > 0) { List <PageGroupDetail> listreturn = new List <PageGroupDetail>(); listreturn.AddRange(pgr.data); return(listreturn); } else { return(null); } } catch { return(null); } }
/// <summary> /// 获取页面分组信息 /// </summary> /// <returns></returns> public async Task <List <pageDetailForGroup> > GetPageGroupInfo(string pageid) { string apitype = JsonApiType.groupPageGet; BaseRequest bj = GetCommonBaseRequest(apitype); //string review = "0"; string review = string.Empty; PageGroupData pgd = new PageGroupData(pageid, review); bj.api_type = apitype; bj.data = pgd; try { var result = await Post(bj); BaseReturn brj = JsonController.DeSerializeToClass <BaseReturn>(result); pageGroupReturnData pgr = JsonController.DeSerializeToClass <pageGroupReturnData>(brj.data.ToString()); if (!object.Equals(pgr.data, null) && pgr.data.Length > 0) { List <pageDetailForGroup> listpage = new List <pageDetailForGroup>(); listpage.AddRange(pgr.data[0].page_list); return(listpage); } return(null); } catch (Exception ex) { string test = ex.Message; return(null); } }
public BaseReturn <EStorageResponse> FormDataUpload(EStorageRequest storageRequest, IFormFile file) { BaseReturn <EStorageResponse> baseObject = new BaseReturn <EStorageResponse>(); EStorageResponse objResposne = null; try { if (file != null && file.Length > 0) { string path = getLocalFilePath(storageRequest); using (var stream = new FileStream(path, FileMode.Create)) { file.CopyToAsync(stream); objResposne = PushToCloudStorage(storageRequest, stream, path); } baseObject.Success = true; baseObject.Data = objResposne; } else { baseObject.Success = false; baseObject.Message = "File is empty."; } } catch (Exception ex) { baseObject.Success = false; baseObject.Message = "Error Occured!"; } return(baseObject); }
public IHttpActionResult Create(SaveUserCommand user) { try { var returnModel = new BaseReturn(); if (user == null) { return(NotFound()); } else { var map = Mapper.Map <SaveUserCommand, User>(user); var valid = serviceUser.Query().Any(x => x.Login == map.Login); if (!valid) { serviceUser.Create(map); return(Ok(returnModel)); } return(BadRequest("User already exists.")); } } catch (Exception e) { return(BadRequest(e.Message)); } }
protected override BaseReturn <Dictionary <string, string> > SaveEnblocToDB <T>(Email email, IEnumerable <T> baselstEnblocSnapshot) { BaseReturn <Dictionary <string, string> > baseObject = new BaseReturn <Dictionary <string, string> >(); Dictionary <string, string> obj = new Dictionary <string, string>(); obj.Add("transactionNo", Convert.ToString(email.TransactionId)); try { var lstEnblocSnapshot = (List <EmptyEnblocSnapshot>)baselstEnblocSnapshot; var enblocFromSnapshot = lstEnblocSnapshot.First(); string enblocno = enblocFromSnapshot.Vessel.Replace(" ", "") + enblocFromSnapshot.ViaNo.ToString(); EmptyEnbloc objEnbloc = new EmptyEnbloc() { Vessel = enblocFromSnapshot.Vessel, Voyage = "", EnblocNumber = enblocno, ViaNo = enblocFromSnapshot.ViaNo, TransactionId = enblocFromSnapshot.TransactionId, Status = Status.PENDING, CreatedBy = 0 }; //Save to DB new EmpezarRepository <EmptyEnbloc>().Add(objEnbloc); List <EmptyEnblocContainers> lstEmptyEnblocContainers = new List <EmptyEnblocContainers>(); lstEnblocSnapshot.ForEach(enblocContainer => { lstEmptyEnblocContainers.Add(new EmptyEnblocContainers() { TransactionId = enblocContainer.TransactionId, Vessel = enblocContainer.Vessel, Voyage = "", ViaNo = enblocContainer.ViaNo, EnblocNumber = enblocno, ContainerNo = enblocContainer.ContainerNo, ContainerSize = Convert.ToInt16(enblocContainer.ContainerSize), ContainerType = enblocContainer.ContainerType, IsoCode = enblocContainer.IsoCode, Status = Status.PENDING, CreatedBy = 0 }); }); //Save to DB new EmpezarRepository <EmptyEnblocContainers>().AddRange(lstEmptyEnblocContainers); baseObject.Success = true; baseObject.Code = (int)EnumTemplateCode.EmailProcessed; baseObject.Data = obj; } catch (Exception ex) { baseObject.Success = false; baseObject.Code = (int)EnumTemplateCode.ErrorOccured; baseObject.Data = obj; } return(baseObject); }
/// <summary> /// 上传文件 /// 将返回路径存储到d0字段中 /// </summary> /// <param name="value"></param> public void SetA1(object value) { ControlDetailForPage obj = (this.Tag as ControlDetailForPage); //上传文件 var values = new[] { new KeyValuePair <string, string>("api_type", "upload"), new KeyValuePair <string, string>("sql", /*obj.d5*/ string.Empty), //other values }; OpenFileDialog opf = new OpenFileDialog(); string filter = this.GetFilterType(); if (!string.IsNullOrEmpty(filter)) { opf.Filter = filter; } if (opf.ShowDialog() == DialogResult.OK) { if (IsValidImage(opf.FileName)) { long length = new System.IO.FileInfo(opf.FileName).Length; float lef = length / (1024 * 1024); if (lef > 2.0) { MessageBox.Show("图片大小超过2m!"); return; } } try { bool resultbol = false; //if (CommonFunction.IsFinishLoading) //{ // resultbol = true; // CommonFunction.IsFinishLoading = false; // CommonFunction.ShowWaitingForm(); //} BaseConnection bcc = new BaseConnection(); var result = bcc.PostFile(opf.FileName, values); BaseReturn brj = JsonController.DeSerializeToClass <BaseReturn>(result.Result); FileUploadReturn returnResult = JsonController.DeSerializeToClass <FileUploadReturn>(brj.data.ToString()); obj.d0 = returnResult.data.path; this.Tag = obj; this.SetP9(obj.p9); //if (resultbol) //{ // CommonFunction.IsFinishLoading = true; //} } catch { //调用失败后走这里 this.SetP12(obj.p12); } } }
public BaseReturn <bool> sendMailReply(Email mail, string replymessage) { BaseReturn <bool> baseObject = new BaseReturn <bool>(); try { Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); var enc1252 = Encoding.GetEncoding(1252); mail.To = mail.From; mail.From = Config.serviceMailId; mail.Body = replymessage; var msg = new AE.Net.Mail.MailMessage { Subject = "RE : " + mail.Subject, Body = mail.Body, ContentType = "text/html", From = new MailAddress(mail.From) }; msg.To.Add(new MailAddress(mail.To)); msg.ReplyTo.Add(new MailAddress(mail.From)); mail.CC.Split(',').ToList().ForEach(addr => { if (addr.Trim() != "") { msg.Cc.Add(new MailAddress(addr)); } }); var msgStr = new StringWriter(); msg.Save(msgStr); var result = _service.Users.Messages.Send(new Message { ThreadId = mail.MailId, Id = mail.MailId, Raw = CommonFunctions.Base64UrlEncode(msgStr.ToString()) }, "me").Execute(); saveReplyMailInfo(mail); baseObject.Success = true; baseObject.Data = true; } catch (Exception ex) { baseObject.Success = false; baseObject.Message = "Error Occured."; } return(baseObject); }
private void Send(BaseReturn ret,HttpContext context) { System.Runtime.Serialization.Json.DataContractJsonSerializer serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(BaseReturn)); using (System.IO.MemoryStream ms = new System.IO.MemoryStream()) { serializer.WriteObject(ms, ret); byte[] b = ms.ToArray(); context.Response.OutputStream.Write(b, 0, b.Length); context.Response.Flush(); } }
private BaseReturn <Dictionary <string, string> > GetEmailAttachments(Email email) { BaseReturn <Dictionary <string, string> > baseObject = new BaseReturn <Dictionary <string, string> >(); Dictionary <string, string> obj = new Dictionary <string, string>(); baseObject.Success = true; try { if (!email.Attachments.Any()) { baseObject.Success = false; baseObject.Code = (int)EnumTemplateCode.NoExcelAttachment; baseObject.Data = obj; return(baseObject); } var attachments = email.Attachments.Where(attachment => attachment.Filename.ToLower().EndsWith(FileType.XLSX)).ToList(); if (!attachments.Any()) { baseObject.Success = false; baseObject.Code = (int)EnumTemplateCode.NoExcelAttachment; baseObject.Data = obj; return(baseObject); } if (attachments.Count > 1) // Invalid no. of attachments { baseObject.Success = false; baseObject.Code = (int)EnumTemplateCode.NoExcelAttachment; baseObject.Data = obj; return(baseObject); } List <EAttachmentRequest> attachmentRequest = attachments.Select(attachment => new EAttachmentRequest { AttachmentId = attachment.AttachmentId, Filename = attachment.Filename }).ToList(); email.Attachments = mailService.getAttachments(email.MailId, attachmentRequest).Data; baseObject.Success = true; } catch (Exception ex) { baseObject.Success = false; baseObject.Code = (int)EnumTemplateCode.ErrorOccured; baseObject.Data = obj; } return(baseObject); }
private bool validateMail(Email email) { bool success = false; BaseReturn <Dictionary <string, string> > baseObject = new BaseReturn <Dictionary <string, string> >(); Dictionary <string, string> obj = new Dictionary <string, string>(); //EmailNotWhiteListed, //MaxEmailLimitReached, ReplyToEmail(email, baseObject); success = true; return(success); }
public void processUnreadEmails() { try { //Get All Unread Emails var baseEmails = mailService.getUnreadEmailsByLabel("INBOX"); //Log object baseEmails here -- use async method for logging if (baseEmails.Success) { BaseReturn<Dictionary<string, string>> baseObject = new BaseReturn<Dictionary<string, string>>(); //Parallel.ForEach(baseEmails.Data, email => baseEmails.Data.ForEach(email => { baseObject = validateMail(email); if (baseObject.Success) { switch (email.Subject.Trim().ToLower()) { case "enbloc.empty": baseObject = new Empty(mailService).processEmail(email); break; case "enbloc.loaded": baseObject = new Loaded(mailService).processEmail(email); break; default: Dictionary<string, string> obj = new Dictionary<string, string>(); obj.Add("transactionNo", Convert.ToString(email.TransactionId)); obj.Add("errors", "Email Subject is not recognized."); baseObject.Code = (int)EnumTemplateCode.ErrorOccuredEmail; baseObject.Data = obj; baseObject.Success = false; break; } } ReplyToEmail(email, baseObject); }); } } catch (Exception ex) { //Log exception } finally { mailService.Dispose(); } }
/// <summary> /// 上传图片 /// </summary> /// <param name="filePath"></param> /// <returns></returns> private string UploadImage(string filePath) { try { var result = bcc.PostFile(filePath, values); BaseReturn brj = JsonController.DeSerializeToClass <BaseReturn>(result.Result); FileUploadReturn returnResult = JsonController.DeSerializeToClass <FileUploadReturn>(brj.data.ToString()); string fileUrl = returnResult.data.path; return(fileUrl); } catch { return(string.Empty); } }
public void ReplyToEmail(Email email, BaseReturn<Dictionary<string, string>> baseObject) { string replyMessage = ""; string template = getTemplate(baseObject); StringBuilder result = new StringBuilder(template); if (baseObject.Data != null) { baseObject.Data.ToList().ForEach(obj => { result.Replace(obj.Key, obj.Value); }); } replyMessage = result.ToString(); mailService.sendMailReply(email, replyMessage); }
/// <summary> /// 启动控件 /// </summary> /// <param name="text"></param> public void SetA1(string text) { if (!object.Equals(_allFiles, null) && _allFiles.Count > 0) { try { ControlDetailForPage obj = (this.Tag as ControlDetailForPage); //上传文件 var values = new[] { new KeyValuePair <string, string>("api_type", "upload"), new KeyValuePair <string, string>("sql", string.Empty), }; SqlController slcontroller = new SqlController(); string sqlInsert = obj.d5; //sqlInsert = DecoderAssistant.FormatSql(sqlInsert, this); //bool resultbol = false; //if (CommonFunction.IsFinishLoading) //{ // resultbol = true; // CommonFunction.IsFinishLoading = false; // CommonFunction.ShowWaitingForm(); //} //改为传相对路径 foreach (string file in _allFiles) { var result = slcontroller.PostFile(file, values); BaseReturn brj = JsonController.DeSerializeToClass <BaseReturn>(result.Result); FileUploadReturn returnResult = JsonController.DeSerializeToClass <FileUploadReturn>(brj.data.ToString()); string fileUrl = returnResult.data.path; string filename = this.GetRelativePath(file, _folderPath);; string fileName = @"\" + @filename; fileName = fileName.Replace("\\", "\\\\"); slcontroller.ExcuteSqlWithReturn(string.Format(sqlInsert, fileUrl, fileName)); } //if (resultbol) //{ // CommonFunction.IsFinishLoading = true; //} this.SetP9(obj.p9); } catch { this.SetP9((this.Tag as ControlDetailForPage).p12); } } }
/// <summary> /// 获取页面信息 /// </summary> /// <param name="pageId"></param> /// <returns></returns> public async Task <PageInfoDetail> GetPageInfo(int pageId) { //string pageVersion = string.IsNullOrEmpty(LocalCacher.GetCache("page_version")) ? "0" : LocalCacher.GetCache("page_version"); string pageVersion = "4"; BaseRequest bj = this.GetPageRequest(pageId, pageVersion); try { PageInfoDetail prd; try { var result = await Post(bj); BaseReturn brj = JsonController.DeSerializeToClass <BaseReturn>(result); ReturnCode code = JsonController.DeSerializeToClass <ReturnCode>(brj.data.ToString()); if (code.error_code.Equals("1")) { throw new Exception("获取页面失败"); } prd = JsonController.DeSerializeToClass <PageInfoDetail>(brj.data.ToString()); } catch (Exception ex) { Logging.Error(ex.Message); //这种情况是连不上服务的处理或者调用接口失败 prd = new PageInfoDetail(); prd.data = null; } if (object.Equals(prd.data, null)) { return(_pageCacher.GetPageInfo(pageId)); } else { //获取页面成功后进行缓存 if ("0".Equals(pageVersion)) { _pageCacher.CachePageInfo(prd); } return(prd); } } catch { return(null); } }
private static BaseReturn <Dictionary <string, string> > ValidateEnbloc(List <LoadedEnblocSnapshot> lstEnblocSnapshot) { BaseReturn <Dictionary <string, string> > baseObject = new BaseReturn <Dictionary <string, string> >(); Dictionary <string, string> obj = new Dictionary <string, string>(); try { LoadedEnblocValidatorCollectionValidator validator = new LoadedEnblocValidatorCollectionValidator(); if (lstEnblocSnapshot.Count > 1000) { baseObject.Success = false; baseObject.Code = (int)EnumTemplateCode.ExcelNoRowsLimitReached; baseObject.Data = obj; return(baseObject); } // if vessel voyage no already exists and enbloc in progress then no processing if (IsVesselVoyageExists(lstEnblocSnapshot.First().Vessel, lstEnblocSnapshot.First().Voyage)) { baseObject.Success = false; baseObject.Code = (int)EnumTemplateCode.ErrorOccured; baseObject.Data = obj; return(baseObject); } ValidationResult results = validator.Validate(lstEnblocSnapshot); if (!results.IsValid) { baseObject.Success = false; baseObject.Code = (int)EnumTemplateCode.ErrorOccured; baseObject.Data = obj; return(baseObject); } baseObject.Success = true; } catch (Exception ex) { baseObject.Success = false; baseObject.Code = (int)EnumTemplateCode.ErrorOccured; baseObject.Data = obj; } return(baseObject); }
private BaseReturn<Dictionary<string, string>> validateMail(Email email) { BaseReturn<Dictionary<string, string>> baseObject = new BaseReturn<Dictionary<string, string>>(); Dictionary<string, string> obj = new Dictionary<string, string>(); obj.Add("transactionNo", Convert.ToString(email.TransactionId)); try { MailAddress address = new MailAddress(email.From); if (Config.enblocwhitelistDomains.Split(",").Any(id => id == address.Host)) { obj.Add("errors", "Email Domain Not Listed With Empezar."); baseObject.Success = false; baseObject.Code = (int)EnumTemplateCode.ErrorOccuredEmail; baseObject.Data = obj; return baseObject; } if (Config.enblocwhitelistEmailIds.Split(",").Any(id => id == email.From.ToLower())) { obj.Add("errors", "Email Id Not Listed With Empezar."); baseObject.Success = false; baseObject.Code = (int)EnumTemplateCode.ErrorOccuredEmail; baseObject.Data = obj; return baseObject; } if (new EmailService.MailService().getEmailCountByEmailId(email.From) > 25) { obj.Add("errors", "Email exceeded daily limit."); baseObject.Success = false; baseObject.Code = (int)EnumTemplateCode.ErrorOccuredEmail; baseObject.Data = obj; return baseObject; } baseObject.Success = true; } catch (Exception ex) { baseObject.Success = false; baseObject.Code = (int)EnumTemplateCode.ErrorOccured; baseObject.Data = obj; } return baseObject; }
public async Task <IActionResult> List() { var response = new BaseReturn <object>(); try { var service = await _application.List(); response.Data = service.Data; } catch (Exception ex) { response.Success = false; response.Description = ex.Message; } return(HandleResponse(response)); }
/// <summary> /// 处理短信验证码 /// </summary> /// <param name="type"></param> /// <param name="phonenumber"></param> /// <param name="code"></param> /// <returns></returns> public async Task <bool> DealWithSMS(string type, string phonenumber, string code = "", bool isVerify = false) { string apitype = JsonApiType.sendCode; BaseRequest bj = GetCommonBaseRequest(apitype); bj.api_type = apitype; if (isVerify) { SmsRequest sr = new SmsRequest() { type = type, to = phonenumber, code = code }; bj.data = sr; } else { SmsRequestSend sr = new SmsRequestSend() { type = type, to = phonenumber }; bj.data = sr; } try { string result = await Post(bj); BaseReturn brj = JsonController.DeSerializeToClass <BaseReturn>(result); CommonReturn cr = JsonController.DeSerializeToClass <CommonReturn>(brj.data.ToString()); if (cr.error_code.Equals(ReturnConst.right)) { return(true); } else { return(false); } } catch { return(false); } }
public void ProcessRequest(HttpContext context) { BaseReturn ret = new BaseReturn(); try { Stream s = context.Request.InputStream; using (var streamReader = new StreamReader(s, Encoding.UTF8)) { var json = streamReader.ReadToEnd(); var entity = JSONHelper.ParseFormByJson<Order>(json); string sError = ""; bool isService= DriverBLL.GetDriverStatus(entity.Ucode); if (isService) { bool isInsert = OrderBLL.InsertOrder(entity, out sError); if (isInsert) { ret.Success = true; ret.Message = ""; } else { ret.Message = sError; } } else { ret.Message = "司机在服务中!"; } } } catch (Exception ex) { LogControl.WriteError("catch" + ex.Message); ret.Message = ex.Message; } finally { Send(ret, context); } }
public async Task <BaseReturn <List <ExtractViewModel> > > List() { var response = new BaseReturn <List <ExtractViewModel> >(); try { var model = await _repository.List(); var viewModels = _mapper.ExtractViewModels(model); response.Data = viewModels; } catch (Exception ex) { response.Success = false; response.Description = ex.Message; } return(response); }
private static BaseReturn <Dictionary <string, string> > ProcessEmailAttachments(Email email, List <LoadedEnblocSnapshot> lstEnblocSnapshot) { BaseReturn <Dictionary <string, string> > baseObject = new BaseReturn <Dictionary <string, string> >(); Dictionary <string, string> obj = new Dictionary <string, string>(); try { FileInfo file = new FileInfo(email.Attachments.First().localUrl); ProcessEnbloc(file, "EM", email.TransactionId, lstEnblocSnapshot); baseObject.Success = true; } catch (Exception ex) { baseObject.Success = false; baseObject.Code = (int)EnumTemplateCode.ErrorOccured; baseObject.Data = obj; } return(baseObject); }
public IActionResult HandleResponse(BaseReturn <object> result) { try { return(Ok(new { success = result.Success, data = result.Data, description = result.Description })); } catch (Exception) { return(BadRequest(new { success = false, data = result, description = "Ocorreu uma falha interna no servidor." })); } }