public ActionResult DeleteMenu(string ids) { string returnValue = string.Empty; int[] deleteId = Array.ConvertAll <string, int>(ids.Split(','), delegate(string s) { return(int.Parse(s)); }); if (ids != null && ids.Length > 0) { if (m_BLL.DeleteMenuCollection(ref validationErrors, deleteId)) { LogClassModels.WriteServiceLog(Suggestion.DeleteSucceed + ",信息的Id为" + string.Join(",", ids), "消息" );//删除成功,写入日志 return(Json(new { Code = "ok", Message = Suggestion.DeleteSucceed })); } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(Suggestion.DeleteFail + ",信息的Id为" + string.Join(",", ids) + "," + returnValue, "消息" );//删除失败,写入日志 return(Json(new { Code = "error", Message = Suggestion.DeleteFail + returnValue })); } } else { return(Json(new { Code = "error", Message = "未选择任何数据" })); } }
/// <summary> /// 停用 /// </summary> /// <param name="id"></param> /// <returns></returns> public Common.ClientResult.Result Stop(string id) { Common.ClientResult.Result result = new Common.ClientResult.Result(); if (ModelState.IsValid) { string returnValue = string.Empty; if (m_BLL.StopPrice(id)) { LogClassModels.WriteServiceLog(Suggestion.UpdateSucceed + ",最低报价信息的Id为" + id, "最低报价信息_停用" );//写入日志 result.Code = Common.ClientCode.Succeed; result.Message = Suggestion.UpdateSucceed; return(result); //提示更新成功 } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(Suggestion.UpdateFail + ",最低报价信息的Id为" + id + "," + returnValue, "最低报价信息_停用" );//写入日志 result.Code = Common.ClientCode.Fail; result.Message = Suggestion.UpdateFail + returnValue; return(result); //提示更新失败 } } result.Code = Common.ClientCode.FindNull; result.Message = Suggestion.UpdateFail + "请核对输入的数据的格式"; return(result); //提示输入的数据的格式不对 }
// DELETE api/<controller>/5 /// <summary> /// 删除 /// </summary> /// <param name="collection"></param> /// <returns></returns> public Common.ClientResult.Result Delete(string query) { Common.ClientResult.Result result = new Common.ClientResult.Result(); string returnValue = string.Empty; string[] deleteId = query.GetString().Split(','); if (deleteId != null && deleteId.Length > 0) { if (m_BLL.DeleteCollection(ref validationErrors, deleteId)) { LogClassModels.WriteServiceLog(Suggestion.DeleteSucceed + ",信息的Id为" + string.Join(",", deleteId), "消息" );//删除成功,写入日志 result.Code = Common.ClientCode.Succeed; result.Message = Suggestion.DeleteSucceed; } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return true; }); } LogClassModels.WriteServiceLog(Suggestion.DeleteFail + ",信息的Id为" + string.Join(",", deleteId)+ "," + returnValue, "消息" );//删除失败,写入日志 result.Code = Common.ClientCode.Fail; result.Message = Suggestion.DeleteFail + returnValue; } } return result; }
public Common.ClientResult.Result DeletePayRecord(int id) { Common.ClientResult.Result result = new Common.ClientResult.Result(); string returnValue = string.Empty; if (m_BLL.DeletePayRecord(ref validationErrors, id)) { LogClassModels.WriteServiceLog(Suggestion.DeleteSucceed + ",信息的Id为" + id, "消息" );//作废成功,写入日志 result.Code = Common.ClientCode.Succeed; result.Message = Suggestion.DeleteSucceed; } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(Suggestion.DeleteFail + ",信息的Id为" + id + "," + returnValue, "消息" );//作废失败,写入日志 result.Code = Common.ClientCode.Fail; result.Message = Suggestion.DeleteFail + returnValue; } return(result); }
/// <summary> /// 添加菜单功能信息 /// </summary> /// <param name="entity"></param> /// <returns></returns> public ActionResult Post(ORG_MenuOp entity) { IBLL.IORG_MenuOpBLL o_bll = new ORG_MenuOpBLL(); Common.ClientResult.Result result = new Common.ClientResult.Result(); if (entity != null && ModelState.IsValid) { entity.ID = entity.ORG_Menu_ID + "-" + entity.ID; entity.Sort = 100; entity.XYBZ = "Y"; #region 添加前进行判断 //编码不为空时,需要对编码唯一性进行判断 if (!string.IsNullOrEmpty(entity.ID.Trim())) { List <ORG_MenuOp> list = o_bll.GetMenuOpId(entity.ID); if (list.Count > 0) { return(Json(new { Code = 0, Message = "此菜单功能ID已被占用" })); } } #endregion string returnValue = string.Empty; if (o_bll.Create(ref validationErrors, entity)) { LogClassModels.WriteServiceLog(Suggestion.InsertSucceed + ",菜单功能的信息的Id为" + entity.ID, "菜单功能" );//写入日志 result.Code = Common.ClientCode.Succeed; result.Message = Suggestion.InsertSucceed; //return result; //提示创建成功 return(Json(new { Code = result.Code, Message = result.Message })); } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(Suggestion.InsertFail + ",菜单功能的信息," + returnValue, "菜单功能" );//写入日志 result.Code = Common.ClientCode.Fail; result.Message = Suggestion.InsertFail + returnValue; //return result; //提示插入失败 return(Json(new { Code = result.Code, Message = result.Message })); } } result.Code = Common.ClientCode.FindNull; result.Message = Suggestion.InsertFail + ",请核对输入的数据的格式"; //提示输入的数据的格式不对 //return result; return(Json(new { Code = result.Code, Message = result.Message })); }
public JsonResult Index(ShenQing entity) { SuggestionRes response = new SuggestionRes(); #region 各种校验 if (string.IsNullOrWhiteSpace(entity.BaoXiuRen)) { response.errorCode = 2; return(Json(response)); } if (string.IsNullOrWhiteSpace(entity.LianXiDianHua)) { response.errorCode = 3; return(Json(response)); } if (string.IsNullOrWhiteSpace(entity.MiaoShu)) { response.errorCode = 4; return(Json(response)); } #endregion Account account = GetCurrentAccount(); entity.HuiYuanId = account.Id; entity.BiaoShi = account.BiaoShi; entity.CreatePerson = account.PersonName; string returnValue = string.Empty; IChuLiBLL m_BLL = new ChuLiBLL(); if (!m_BLL.CreateAndCopy(ref validationErrors, entity)) { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } response.errorCode = 99; response.content = returnValue; return(Json(response)); } response.errorCode = 0; return(Json(response)); }
public ActionResult SetSysMenu(SysOperation entity) { if (entity != null) { string currentPerson = GetCurrentPerson(); //entity.UpdateTime = DateTime.Now; //entity.UpdatePerson = currentPerson; string returnValue = string.Empty; if (m_BLL.SetSysMenu(ref validationErrors, entity)) { LogClassModels.WriteServiceLog(Suggestion.UpdateSucceed + ",菜单信息的Id为" + entity.Id, "消息" ); //写入日志 return(Json(Suggestion.UpdateSucceed)); //提示更新成功 } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(Suggestion.DeleteFail + ",信息的Id为" + entity.Id + "," + returnValue, "消息" );//删除失败,写入日志 return(Json(Suggestion.UpdateFail + returnValue)); } } else { return(Json(Suggestion.UpdateFail + ",请核对输入的数据的格式")); //提示输入的数据的格式不对 } }
public string this[string columnName] { get { string result = null; if (!ValidationOnSaving) { return(result); } result = Validate(columnName); if (string.IsNullOrEmpty(result)) { return(result); } if (ValidationErrors.All(x => x.PropertyName != columnName)) { ValidationErrors.Add(new PropertyValidationError(columnName, result, ErrorType.Error)); } return(result); } }
public ActionResult SetSysMenu(SysRole entity) { if (entity != null) { string currentPerson = GetCurrentPerson(); //entity.UpdateTime = DateTime.Now; //entity.UpdatePerson = currentPerson; string returnValue = string.Empty; if (m_BLL.SetSysMenu(ref validationErrors, entity)) { LogClassModels.WriteServiceLog(LogType.Operation, Suggestion.UpdateSucceed + ",角色信息的Id为" + entity.Id, "消息", Result.Succeed); //写入日志 return(Json(Suggestion.UpdateSucceed)); //提示更新成功 } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(LogType.Operation, Suggestion.DeleteFail + ",信息的Id为" + string.Join(",", entity.Id) + "," + returnValue, "消息", Result.Fail);//删除失败,写入日志 } } else { return(Json(Suggestion.UpdateFail + ",请核对输入的数据的格式")); //提示输入的数据的格式不对 } return(RedirectToAction("Index", "NotFound")); }
/// <summary> /// 加入对比 /// </summary> /// <param name="id">支出费用表ID</param> /// <returns></returns> public Common.ClientResult.Result ContrastedPayRecord(int yearMonth, int costType, string cityId) { Common.ClientResult.Result result = new Common.ClientResult.Result(); string returnValue = string.Empty; if (m_BLL.ContrastedInsurance(ref validationErrors, yearMonth, costType, cityId, LoginInfo.UserName)) { LogClassModels.WriteServiceLog("加入对比成功" + ",信息的险种为" + ((Common.EmployeeAdd_InsuranceKindId)costType).ToString(), ",缴纳地Id为" + cityId + "消息" );//加入对比成功,写入日志 result.Code = Common.ClientCode.Succeed; result.Message = "加入对比成功"; } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog("加入对比失败" + ",信息的险种为" + ((Common.EmployeeAdd_InsuranceKindId)costType).ToString(), ",缴纳地Id为" + cityId + "消息" );//加入对比成功,写入日志 result.Code = Common.ClientCode.Fail; result.Message = "加入对比失败," + returnValue; } return(result); }
public Common.ClientResult.Result SetSuccess(string stopIds, string alltype) { alltype = HttpUtility.HtmlDecode(alltype); IBLL.IEmployeeStopPaymentBLL m_BLL = new BLL.EmployeeStopPaymentBLL(); ValidationErrors validationErrors = new ValidationErrors(); Common.ClientResult.Result result = new Common.ClientResult.Result(); if (!string.IsNullOrEmpty(stopIds)) { string returnValue = string.Empty; SysEntities db = new SysEntities(); List <int> IdList = new List <int>(); string[] strArrayid = stopIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); string[] strArrayType = alltype.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); List <int?> InsuranceKindList = new List <int?>();//险种 foreach (string id in strArrayid) { int idd = int.Parse(id); IdList.Add(idd); } foreach (var a in strArrayType) { int InsuranceKindId = (int)(Common.EmployeeAdd_InsuranceKindId)Enum.Parse(typeof(Common.EmployeeAdd_InsuranceKindId), a); InsuranceKindList.Add(InsuranceKindId); } if (SetStopPaymentSuccess(db, IdList, InsuranceKindList)) { //LogClassModels.WriteServiceLog(Suggestion.InsertSucceed + ",员工停缴的信息的Id为" + entity.Id, "员工停缴");//写入日志 result.Code = Common.ClientCode.Succeed; result.Message = "保存成功!"; return(result); //提示创建成功 } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(Suggestion.UpdateFail + ",报减设置成功," + returnValue, "员工停缴");//写入日志 result.Code = Common.ClientCode.Fail; result.Message = Suggestion.UpdateFail + returnValue; return(result); //提示插入失败 } } result.Code = Common.ClientCode.FindNull; result.Message = Suggestion.UpdateFail + ",请核对输入的数据的格式"; //提示输入的数据的格式不对 return(result); }
/// <summary> /// 创建银行信息 /// </summary> /// <param name="entity">实体对象</param> /// <returns></returns> public Common.ClientResult.Result Post([FromBody] EmployeeBank entity) { IBLL.IEmployeeBankBLL m_BLL = new EmployeeBankBLL(); Common.ClientResult.Result result = new Common.ClientResult.Result(); if (entity != null && ModelState.IsValid) { entity.State = "启用"; entity.CreateTime = DateTime.Now; entity.CreatePerson = LoginInfo.RealName; //entity.EmployeeId = LoginInfo.UserID; string returnValue = string.Empty; if (m_BLL.Create(ref validationErrors, entity)) { LogClassModels.WriteServiceLog(Suggestion.InsertSucceed + ",员工银行的信息的Id为" + entity.Id, "员工银行" );//写入日志 result.Code = Common.ClientCode.Succeed; result.Message = Suggestion.InsertSucceed; return(result); //提示创建成功 } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(Suggestion.InsertFail + ",员工银行的信息," + returnValue, "员工银行" );//写入日志 result.Code = Common.ClientCode.Fail; result.Message = Suggestion.InsertFail + returnValue; return(result); //提示插入失败 } } result.Code = Common.ClientCode.FindNull; result.Message = Suggestion.InsertFail + ",请核对输入的数据的格式"; //提示输入的数据的格式不对 return(result); }
public void All_ReturnsValidationErrorsAtOneLevel() { StringBuilder builder = new StringBuilder(); builder.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); builder.Append("<api-error-response>"); builder.Append(" <errors>"); builder.Append(" <customer>"); builder.Append(" <errors type=\"array\">"); builder.Append(" <error>"); builder.Append(" <code>81608</code>"); builder.Append(" <message>First name is too long.</message>"); builder.Append(" <attribute type=\"symbol\">first_name</attribute>"); builder.Append(" </error>"); builder.Append(" </errors>"); builder.Append(" <credit-card>"); builder.Append(" <errors type=\"array\">"); builder.Append(" <error>"); builder.Append(" <code>81715</code>"); builder.Append(" <message>Credit card number is invalid.</message>"); builder.Append(" <attribute type=\"symbol\">number</attribute>"); builder.Append(" </error>"); builder.Append(" <error>"); builder.Append(" <code>81710</code>"); builder.Append(" <message>Expiration date is invalid.</message>"); builder.Append(" <attribute type=\"symbol\">expiration_date</attribute>"); builder.Append(" </error>"); builder.Append(" </errors>"); builder.Append(" </credit-card>"); builder.Append(" </customer>"); builder.Append(" <errors type=\"array\"/>"); builder.Append(" </errors>"); builder.Append("</api-error-response>"); XmlDocument doc = new XmlDocument(); doc.LoadXml(builder.ToString()); ValidationErrors errors = new ValidationErrors(new NodeWrapper(doc.ChildNodes[1])); Assert.AreEqual(0, errors.All().Count); Assert.AreEqual(1, errors.ForObject("customer").All().Count); Assert.AreEqual("first_name", errors.ForObject("customer").All()[0].Attribute); Assert.AreEqual(ValidationErrorCode.CUSTOMER_FIRST_NAME_IS_TOO_LONG, errors.ForObject("customer").All()[0].Code); Assert.AreEqual(2, errors.ForObject("customer").ForObject("credit-card").All().Count); Assert.AreEqual("number", errors.ForObject("customer").ForObject("credit-card").All()[0].Attribute); Assert.AreEqual(ValidationErrorCode.CREDIT_CARD_NUMBER_IS_INVALID, errors.ForObject("customer").ForObject("credit-card").All()[0].Code); Assert.AreEqual("expiration_date", errors.ForObject("customer").ForObject("credit-card").All()[1].Attribute); Assert.AreEqual(ValidationErrorCode.CREDIT_CARD_EXPIRATION_DATE_IS_INVALID, errors.ForObject("customer").ForObject("credit-card").All()[1].Code); }
/// <summary> /// 停用 /// </summary> /// <param name="id"></param> /// <returns></returns> public Common.ClientResult.Result Stop(string id) { Common.ClientResult.Result result = new Common.ClientResult.Result(); if (ModelState.IsValid) { //数据校验 LadderPrice item = m_BLL.GetById(id); item.Status = Common.Status.停用.ToString();//停用 string returnValue = string.Empty; if (m_BLL.Edit(ref validationErrors, item)) { LogClassModels.WriteServiceLog(Suggestion.UpdateSucceed + ",阶梯报价信息的Id为" + id, "阶梯报价信息_停用" );//写入日志 result.Code = Common.ClientCode.Succeed; result.Message = Suggestion.UpdateSucceed; return(result); //提示更新成功 } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(Suggestion.UpdateFail + ",阶梯报价信息的Id为" + id + "," + returnValue, "阶梯报价信息_停用" );//写入日志 result.Code = Common.ClientCode.Fail; result.Message = Suggestion.UpdateFail + returnValue; return(result); //提示更新失败 } } result.Code = Common.ClientCode.FindNull; result.Message = Suggestion.UpdateFail + "请核对输入的数据的格式"; return(result); //提示输入的数据的格式不对 }
/// <summary> /// 设置报减失败操作 /// </summary> /// <param name="ids"></param> /// <param name="reason">失败原因</param> /// <param name="alltype">报减险种</param> /// <returns></returns> public Common.ClientResult.Result SetFail(string ids, string reason, string alltype) { Common.ClientResult.Result result = new Common.ClientResult.Result(); reason = HttpUtility.HtmlDecode(reason); // 失败原因 alltype = HttpUtility.HtmlDecode(alltype); string[] strArrayall = alltype.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); List <int?> insuranceKindTypes = new List <int?>(); // 失败的险种 foreach (var a in strArrayall) { int insuranceKindId = (int)(Common.EmployeeAdd_InsuranceKindId)Enum.Parse(typeof(Common.EmployeeAdd_InsuranceKindId), a); insuranceKindTypes.Add(insuranceKindId); } if (!string.IsNullOrEmpty(ids)) { string returnValue = string.Empty; if (m_BLL.SetStopPaymentFailByInsuranceKind(ids, reason, insuranceKindTypes)) { LogClassModels.WriteServiceLog(Suggestion.InsertSucceed + ",报减设置成功" + returnValue, "员工停缴");//写入日志 result.Code = Common.ClientCode.Succeed; result.Message = Suggestion.UpdateSucceed; return(result); //提示创建成功 } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(Suggestion.UpdateFail + ",报减设置失败," + returnValue, "员工停缴");//写入日志 result.Code = Common.ClientCode.Fail; result.Message = Suggestion.UpdateFail + returnValue; return(result); //提示插入失败 } } result.Code = Common.ClientCode.FindNull; result.Message = Suggestion.UpdateFail + ",请核对输入的数据的格式"; //提示输入的数据的格式不对 return(result); }
protected override string Validate(string columnName) { var result = base.Validate(columnName); foreach (var ingredient in Ingredients) { ingredient.ValidationErrors.Clear(); ingredient.ValidationOnSaving = true; ingredient.OnPropertyChanged(string.Empty); ingredient.ValidationOnSaving = false; var newErrors = ingredient.ValidationErrors.Where(x => ValidationErrors.All(t => t.PropertyName != x.PropertyName)); ValidationErrors.AddRange(newErrors); } return(result); }
private Dictionary <String, String> CollectResponseErrors(ValidationErrors errors, String message) { var result = new Dictionary <String, String>(); if (errors != null && errors.Count > 0) { foreach (var error in errors.All()) { if (!result.ContainsKey(error.Attribute)) { result[error.Attribute] = $"{error.Code} | {error.Message}"; } } } if (!String.IsNullOrWhiteSpace(message)) { result.Add("_global", message); } return(result); }
/// <summary> /// 创建 /// </summary> /// <param name="entity"></param> /// <returns></returns> public Common.ClientResult.Result Post([FromBody] CRM_CompanyContract_Audit entity) { Common.ClientResult.Result result = new Common.ClientResult.Result(); if (entity != null && ModelState.IsValid) { entity.CreateUserID = LoginInfo.UserID; entity.CreateTime = DateTime.Now; entity.CreateUserName = LoginInfo.RealName; entity.BranchID = 1; entity.OperateStatus = 1; entity.OperateNode = 2; string returnValue = string.Empty; if (m_BLL.Create(ref validationErrors, entity)) { LogClassModels.WriteServiceLog(Suggestion.InsertSucceed + ",客户_合同信息_待审核的信息的Id为" + entity.ID, "客户_合同信息_待审核" );//写入日志 result.Code = Common.ClientCode.Succeed; result.Message = Suggestion.InsertSucceed; return(result); //提示创建成功 } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(Suggestion.InsertFail + ",客户_合同信息_待审核的信息," + returnValue, "客户_合同信息_待审核" );//写入日志 result.Code = Common.ClientCode.Fail; result.Message = Suggestion.InsertFail + returnValue; return(result); //提示插入失败 } } result.Code = Common.ClientCode.FindNull; result.Message = Suggestion.InsertFail + ",请核对输入的数据的格式"; //提示输入的数据的格式不对 return(result); }
public void All_ReturnsValidationErrorsAtOneLevel() { StringBuilder builder = new StringBuilder(); builder.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); builder.Append("<api-error-response>"); builder.Append(" <errors>"); builder.Append(" <customer>"); builder.Append(" <errors type=\"array\">"); builder.Append(" <error>"); builder.Append(" <code>81608</code>"); builder.Append(" <message>First name is too long.</message>"); builder.Append(" <attribute type=\"symbol\">first_name</attribute>"); builder.Append(" </error>"); builder.Append(" </errors>"); builder.Append(" <credit-card>"); builder.Append(" <errors type=\"array\">"); builder.Append(" <error>"); builder.Append(" <code>81715</code>"); builder.Append(" <message>Credit card number is invalid.</message>"); builder.Append(" <attribute type=\"symbol\">number</attribute>"); builder.Append(" </error>"); builder.Append(" <error>"); builder.Append(" <code>81710</code>"); builder.Append(" <message>Expiration date is invalid.</message>"); builder.Append(" <attribute type=\"symbol\">expiration_date</attribute>"); builder.Append(" </error>"); builder.Append(" </errors>"); builder.Append(" </credit-card>"); builder.Append(" </customer>"); builder.Append(" <errors type=\"array\"/>"); builder.Append(" </errors>"); builder.Append("</api-error-response>"); XmlDocument doc = new XmlDocument(); doc.LoadXml(builder.ToString()); ValidationErrors errors = new ValidationErrors(new NodeWrapper(doc.ChildNodes[1])); Assert.AreEqual(0, errors.All().Count); Assert.AreEqual(1, errors.ForObject("customer").All().Count); Assert.AreEqual("first_name", errors.ForObject("customer").All()[0].Attribute); Assert.AreEqual(ValidationErrorCode.CUSTOMER_FIRST_NAME_IS_TOO_LONG, errors.ForObject("customer").All()[0].Code); Assert.AreEqual(2, errors.ForObject("customer").ForObject("credit-card").All().Count); Assert.AreEqual("number", errors.ForObject("customer").ForObject("credit-card").All()[0].Attribute); Assert.AreEqual(ValidationErrorCode.CREDIT_CARD_NUMBER_IS_INVALID, errors.ForObject("customer").ForObject("credit-card").All()[0].Code); Assert.AreEqual("expiration_date", errors.ForObject("customer").ForObject("credit-card").All()[1].Attribute); Assert.AreEqual(ValidationErrorCode.CREDIT_CARD_EXPIRATION_DATE_IS_INVALID, errors.ForObject("customer").ForObject("credit-card").All()[1].Code); }
public ContentResult Upload(HttpPostedFileBase fileData, string folder, string userid) { //HttpContext.Request.ContentType = "text/plain"; //HttpContext.Request.ContentEncoding = System.Text.Encoding.g; //string s = EnCodeCovert("utf-8","utf-8", fileData.FileName); int type = 0; int bid = 0; string username = ""; if (!string.IsNullOrEmpty(userid)) { string[] userarray = userid.Split('!'); type = int.Parse(userarray[0]); bid = int.Parse(userarray[1]); username = userarray[2]; } string result = "0"; string fileName = ""; if (fileData != null) { try { //int UserID = GetCurrentPerson().UserID; //string UserName = GetCurrentPerson().UserName; int Length = fileData.ContentLength; string newFileName = fileData.FileName.Replace(" ", string.Empty); string fileExt = Path.GetExtension(newFileName); if (newFileName.Length > 50) { newFileName = newFileName.Substring(0, 45) + fileExt; } //判断同文件名和大小的文件是否在数据库存在 //bool fileisexist = _IDocumentService.fileisexist(newFileName, fileExt.Trim('.'), Length); //if (fileisexist) //{ // return Content("isexist"); //} //获取文件流的前500个byte 的md5 //Stream get_file = fileData.InputStream; //byte[] data = new byte[8000]; //get_file.Read(data, 0, data.Length); //System.Security.Cryptography.MD5CryptoServiceProvider get_md5 = new System.Security.Cryptography.MD5CryptoServiceProvider(); //byte[] hash_byte = get_md5.ComputeHash(data); //string resule = System.BitConverter.ToString(hash_byte); //resule = resule.Replace("-", ""); //bool fileisexist = _IDocumentService.pdfileisexist(resule); //if (fileisexist) //{ // return Content("isexist"); //} fileName = newFileName.Replace(fileExt, "") + "-" + DateTime.Now.ToString("yyyy-MM-dd-hh-mm-ss") + fileExt; string dir = System.Configuration.ConfigurationManager.AppSettings["DocUploadFolder"]; string ss = "/UploadFiles/" + username + "/"; string newpath = Server.MapPath(ss); //string dir = Request.MapPath("~" + folder + "/"); if (!Directory.Exists(newpath)) { Directory.CreateDirectory(newpath); } fileData.SaveAs(Path.Combine(newpath + "\\" + fileName)); //result = fileName; //如果是商店,则更新里面的图片字段,加上上传的图片地址 //if (type == 0) //{ // shop item = m_shopBLL.GetById(bid); // string imgsUrl = item.home_pic; // imgsUrl = imgsUrl + fileName+";"; // item.home_pic = imgsUrl; // if (m_shopBLL.SaveChange()) // { // LogClassModels.WriteServiceLog(LogType.Operation, Suggestion.UpdateSucceed + ",shop信息的Id为" + bid, "shop", // Result.Succeed);//写入日志 // //return Json(Suggestion.UpdateSucceed); //提示更新成功 // } // else // { // string returnValue = string.Empty; // if (validationErrors != null && validationErrors.Count > 0) // { // validationErrors.All(a => // { // returnValue += a.ErrorMessage; // return true; // }); // } // LogClassModels.WriteServiceLog(LogType.Operation, Suggestion.UpdateFail + ",shop信息的Id为" + bid + "," + returnValue, "shop", // Result.Fail);//写入日志 // //return Json(Suggestion.UpdateFail + returnValue); //提示更新失败 // } //} shop item; activity activity; food_list food_list; youhui youhui; room_price room_price; string imgsUrl = ""; switch (type) { case 0: item = m_shopBLL.GetById(bid); imgsUrl = item.welcome_pic; imgsUrl = imgsUrl + fileName + ";"; item.welcome_pic = imgsUrl; if (m_shopBLL.SaveChange()) { LogClassModels.WriteServiceLog(LogType.Operation, Suggestion.UpdateSucceed + ",shop信息的Id为" + bid, "shop", Result.Succeed);//写入日志 //return Json(Suggestion.UpdateSucceed); //提示更新成功 } else { string returnValue = string.Empty; if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(LogType.Operation, Suggestion.UpdateFail + ",shop信息的Id为" + bid + "," + returnValue, "shop", Result.Fail);//写入日志 //return Json(Suggestion.UpdateFail + returnValue); //提示更新失败 } break; case 1: item = m_shopBLL.GetById(bid); imgsUrl = item.home_pic; imgsUrl = imgsUrl + fileName + ";"; item.home_pic = imgsUrl; if (m_shopBLL.SaveChange()) { LogClassModels.WriteServiceLog(LogType.Operation, Suggestion.UpdateSucceed + ",shop信息的Id为" + bid, "shop", Result.Succeed);//写入日志 //return Json(Suggestion.UpdateSucceed); //提示更新成功 } else { string returnValue = string.Empty; if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(LogType.Operation, Suggestion.UpdateFail + ",shop信息的Id为" + bid + "," + returnValue, "shop", Result.Fail);//写入日志 //return Json(Suggestion.UpdateFail + returnValue); //提示更新失败 } break; case 2: activity = m_activityBLL.GetById(bid); imgsUrl = activity.pic; imgsUrl = imgsUrl + fileName + ";"; activity.pic = imgsUrl; if (m_activityBLL.SaveChange()) { LogClassModels.WriteServiceLog(LogType.Operation, Suggestion.UpdateSucceed + ",activity信息的Id为" + bid, "activity", Result.Succeed);//写入日志 //return Json(Suggestion.UpdateSucceed); //提示更新成功 } else { string returnValue = string.Empty; if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(LogType.Operation, Suggestion.UpdateFail + ",activity信息的Id为" + bid + "," + returnValue, "activity", Result.Fail);//写入日志 //return Json(Suggestion.UpdateFail + returnValue); //提示更新失败 } break; case 3: food_list = m_food_listBLL.GetById(bid); imgsUrl = food_list.pic; imgsUrl = imgsUrl + fileName + ";"; food_list.pic = imgsUrl; if (m_food_listBLL.SaveChange()) { LogClassModels.WriteServiceLog(LogType.Operation, Suggestion.UpdateSucceed + ",food_list信息的Id为" + bid, "food_list", Result.Succeed);//写入日志 //return Json(Suggestion.UpdateSucceed); //提示更新成功 } else { string returnValue = string.Empty; if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(LogType.Operation, Suggestion.UpdateFail + ",food_list信息的Id为" + bid + "," + returnValue, "food_list", Result.Fail);//写入日志 //return Json(Suggestion.UpdateFail + returnValue); //提示更新失败 } break; case 4: youhui = m_youhuiBLL.GetById(bid); imgsUrl = youhui.pic; imgsUrl = imgsUrl + fileName + ";"; youhui.pic = imgsUrl; if (m_food_listBLL.SaveChange()) { LogClassModels.WriteServiceLog(LogType.Operation, Suggestion.UpdateSucceed + ",youhui信息的Id为" + bid, "youhui", Result.Succeed);//写入日志 //return Json(Suggestion.UpdateSucceed); //提示更新成功 } else { string returnValue = string.Empty; if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(LogType.Operation, Suggestion.UpdateFail + ",youhui信息的Id为" + bid + "," + returnValue, "youhui", Result.Fail);//写入日志 //return Json(Suggestion.UpdateFail + returnValue); //提示更新失败 } break; case 5: room_price = m_room_priceBLL.GetById(bid); imgsUrl = room_price.pic; imgsUrl = imgsUrl + fileName + ";"; room_price.pic = imgsUrl; if (m_food_listBLL.SaveChange()) { LogClassModels.WriteServiceLog(LogType.Operation, Suggestion.UpdateSucceed + ",room_price信息的Id为" + bid, "room_price", Result.Succeed);//写入日志 //return Json(Suggestion.UpdateSucceed); //提示更新成功 } else { string returnValue = string.Empty; if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(LogType.Operation, Suggestion.UpdateFail + ",room_price信息的Id为" + bid + "," + returnValue, "room_price", Result.Fail);//写入日志 //return Json(Suggestion.UpdateFail + returnValue); //提示更新失败 } break; default: break; } } catch { } } return(Content(fileName)); }
//public Common.ClientResult.DataResult PostPoliceOperation(int kindId) //{ // IInsuranceKindBLL kindBll = new InsuranceKindBLL(); // List<PoliceOperation> items = kindBll.GetRefPoliceOperationForStop(kindId); // var data = new Common.ClientResult.DataResult // { // rows = items.Select(s => new // { // ID = s.Id, // Name = s.Name // }) // }; // return data; //} /// <summary> /// 创建 /// </summary> /// <param name="entity">实体对象</param> /// <returns></returns> public Common.ClientResult.Result Post(string parameters) { Common.ClientResult.Result result = new Common.ClientResult.Result(); if (!string.IsNullOrEmpty(parameters)) { List <EmployeeStopPaymentSingle> list = new List <EmployeeStopPaymentSingle>(); string[] kinds = parameters.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (string kind in kinds) { string[] param = kind.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);//EmployeeAddID,社保月,报减类型,报减自然月,险种,政策,企业员工关系 EmployeeStopPaymentSingle single = new EmployeeStopPaymentSingle() { InsuranceKindId = Convert.ToInt32(param[4]), PoliceInsuranceId = Convert.ToInt32(param[5]), CompanyEmployeeRelationId = Convert.ToInt32(param[6]), StopPayment = new EmployeeStopPayment() { EmployeeAddId = Convert.ToInt32(param[0]), InsuranceMonth = Convert.ToDateTime(param[1] + "-01"), PoliceOperationId = Convert.ToInt32(param[2]), State = EmployeeStopPayment_State.待员工客服确认.ToString(), YearMonth = Convert.ToInt32(param[3].Replace("-", "")), CreateTime = DateTime.Now, CreatePerson = LoginInfo.UserName, UpdateTime = DateTime.Now, UpdatePerson = LoginInfo.UserName, }, }; list.Add(single); } //string currentPerson = GetCurrentPerson(); //entity.CreateTime = DateTime.Now; //entity.CreatePerson = currentPerson; string returnValue = string.Empty; if (m_BLL.InsertStopPayment(list)) { //LogClassModels.WriteServiceLog(Suggestion.InsertSucceed + ",员工停缴的信息的Id为" + entity.Id, "员工停缴");//写入日志 result.Code = Common.ClientCode.Succeed; result.Message = Suggestion.InsertSucceed; return(result); //提示创建成功 } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(Suggestion.InsertFail + ",员工停缴的信息," + returnValue, "员工停缴");//写入日志 result.Code = Common.ClientCode.Fail; result.Message = Suggestion.InsertFail + returnValue; return(result); //提示插入失败 } } result.Code = Common.ClientCode.FindNull; result.Message = Suggestion.InsertFail + ",请核对输入的数据的格式"; //提示输入的数据的格式不对 return(result); }
public ActionResult Register(RegisterViewModel model) { SuggestionRes response = new SuggestionRes(); #region 各种校验 if (string.IsNullOrWhiteSpace(model.BiaoShi)) {//标识是否存在 response.errorCode = 11; return(Json(response)); } var vali = Validator.IsPassword(model.Password); if (vali != 0) {//标识是否存在 response.errorCode = vali; return(Json(response)); } if (model.Password != model.ConfirmPassword) { response.errorCode = 9; return(Json(response)); } if (string.IsNullOrWhiteSpace(model.UserName)) { response.errorCode = 20; return(Json(response)); } if (model.UserName.Length > 50) { response.errorCode = 21; return(Json(response)); } if (!Validator.IsMobile(model.UserName)) { response.errorCode = 22; return(Json(response)); } #endregion Langben.IBLL.IHuiYuanBLL m_BLL = new HuiYuanBLL(); if (m_BLL.IsPhone(model.UserName, model.BiaoShi)) { response.errorCode = 23; return(Json(response)); } ValidationErrors validationErrors = new ValidationErrors(); HuiYuan entity = new HuiYuan() { Password = model.Password , PhoneNumber = model.UserName , CreateTime = DateTime.Now , BiaoShi = model.BiaoShi , State = "未审核" , LogonIP = Common.IP.GetIP() }; entity.Id = Result.GetNewId(); string returnValue = string.Empty; if (m_BLL.Create(ref validationErrors, entity)) { response.errorCode = 0; return(Json(response)); } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } //LogClassModels.WriteServiceLog(Suggestion.InsertFail + ",注册的信息," + returnValue, "注册" // );//写入日志 response.errorCode = 99; return(Json(response)); //提示插入失败 } }
/// <summary> /// Initializes a new instance of the <see cref="BraintreeApiException"/> class. /// </summary> /// <param name="validationErrors"> /// The validation errors. /// </param> public BraintreeApiException(ValidationErrors validationErrors) : this(validationErrors.All()) { }
/// <summary> /// 编辑 /// </summary> /// <param name="entity"></param> /// <returns></returns> public Common.ClientResult.Result BaseEdit([FromBody] Employee entity) { IBLL.IEmployeeBLL m_BLL = new EmployeeBLL(); Common.ClientResult.Result result = new Common.ClientResult.Result(); #region 验证 if (entity.CertificateType == null) { result.Code = Common.ClientCode.FindNull; result.Message = "请选择证件类型"; return(result); //提示输入的数据的格式不对 } if (entity.Sex == null) { result.Code = Common.ClientCode.FindNull; result.Message = "请选择性别"; return(result); //提示输入的数据的格式不对 } if (entity.AccountType == null) { result.Code = Common.ClientCode.FindNull; result.Message = "请选择户口类型"; return(result); //提示输入的数据的格式不对 } if (entity.CertificateType == "居民身份证") { string number = entity.CertificateNumber; if (Common.CardCommon.CheckCardID18(number) == false) { result.Code = Common.ClientCode.FindNull; result.Message = "证件号不正确请重新输入"; return(result); //提示输入的数据的格式不对 } } #endregion //数据校验 if (entity != null && ModelState.IsValid) { Employee item = m_BLL.GetById(entity.Id); item.Name = entity.Name; item.CertificateNumber = entity.CertificateNumber; item.CertificateType = entity.CertificateType; item.Sex = entity.Sex; item.AccountType = entity.AccountType; item.UpdateTime = DateTime.Now; item.UpdatePerson = LoginInfo.RealName; string returnValue = string.Empty; if (m_BLL.Edit(ref validationErrors, item)) { LogClassModels.WriteServiceLog(Suggestion.UpdateSucceed + ",员工信息的Id为" + entity.Id, "员工" );//写入日志 result.Code = Common.ClientCode.Succeed; result.Message = Suggestion.UpdateSucceed; return(result); //提示更新成功 } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(Suggestion.UpdateFail + ",员工信息的Id为" + entity.Id + "," + returnValue, "员工" );//写入日志 result.Code = Common.ClientCode.Fail; result.Message = Suggestion.UpdateFail + returnValue; return(result); //提示更新失败 } } result.Code = Common.ClientCode.FindNull; result.Message = Suggestion.UpdateFail + "请核对输入的数据的格式"; return(result); //提示输入的数据的格式不对 }
/// <summary> /// Initializes a new instance of the <see cref="BraintreeApiException"/> class. /// </summary> /// <param name="validationErrors"> /// The validation errors. /// </param> /// <param name="message"> /// The message. /// </param> public BraintreeApiException(ValidationErrors validationErrors, string message) : base(string.Format("{0} {1} {2}", message, System.Environment.NewLine, string.Join(" ", validationErrors.All().Select(x => x.Message)))) { }
/// <summary> /// Initializes a new instance of the <see cref="BraintreeApiException"/> class. /// </summary> /// <param name="validationErrors"> /// The validation errors. /// </param> public BraintreeApiException(ValidationErrors validationErrors) : this(validationErrors.All()) { }
public ActionResult Register(RegisterViewModel model) { SuggestionRes response = new SuggestionRes(); #region 各种校验 if (string.IsNullOrWhiteSpace(model.BiaoShi)) {//标识是否存在 response.errorCode = 11; return Json(response); } var vali = Validator.IsPassword(model.Password); if (vali != 0) {//标识是否存在 response.errorCode = vali; return Json(response); } if (model.Password != model.ConfirmPassword) { response.errorCode = 9; return Json(response); } if (string.IsNullOrWhiteSpace(model.UserName)) { response.errorCode = 20; return Json(response); } if (model.UserName.Length > 50) { response.errorCode = 21; return Json(response); } if (!Validator.IsMobile(model.UserName)) { response.errorCode = 22; return Json(response); } #endregion Langben.IBLL.IHuiYuanBLL m_BLL = new HuiYuanBLL(); if (m_BLL.IsPhone(model.UserName, model.BiaoShi)) { response.errorCode = 23; return Json(response); } ValidationErrors validationErrors = new ValidationErrors(); HuiYuan entity = new HuiYuan() { Password = model.Password , PhoneNumber = model.UserName , CreateTime = DateTime.Now , BiaoShi = model.BiaoShi , State = "未审核" , LogonIP = Common.IP.GetIP() }; entity.Id = Result.GetNewId(); string returnValue = string.Empty; if (m_BLL.Create(ref validationErrors, entity)) { response.errorCode = 0; return Json(response); } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return true; }); } //LogClassModels.WriteServiceLog(Suggestion.InsertFail + ",注册的信息," + returnValue, "注册" // );//写入日志 response.errorCode = 99; return Json(response); //提示插入失败 } }
/// <summary> /// Initializes a new instance of the <see cref="BraintreeApiException"/> class. /// </summary> /// <param name="validationErrors"> /// The validation errors. /// </param> /// <param name="message"> /// The message. /// </param> public BraintreeApiException(ValidationErrors validationErrors, string message) : base(string.Format("{0} {1} {2}", message, System.Environment.NewLine, string.Join(" ", validationErrors.All().Select(x => x.Message)))) { }
/// <summary> /// 供应商客服提取报减信息 /// </summary> /// <param name="getParam"></param> /// <returns></returns> public Common.ClientResult.UrlResult SupplierExport([FromBody] GetDataParam getParam) { FileStream file = new FileStream(System.Web.HttpContext.Current.Server.MapPath("../../Template/Excel/供应商客服报减数据提取模版.xls"), FileMode.Open, FileAccess.Read); HSSFWorkbook workbook = new HSSFWorkbook(file); try { string search = getParam.search; int getid = 0; int total = 0; Dictionary <string, string> queryDic = ValueConvert.StringToDictionary(search.GetString()); if (queryDic != null && queryDic.Count > 0) { if (queryDic.ContainsKey("CollectState") && !string.IsNullOrWhiteSpace(queryDic["CollectState"])) { string str = queryDic["CollectState"]; if (str.Contains(Common.CollectState.未提取.ToString())) { string state = Common.EmployeeAdd_State.待供应商客服提取.ToString(); search += "State&" + state + "^"; } else { string state = Common.EmployeeAdd_State.已发送供应商.ToString(); search += "State&" + state + "^"; } } } search += "UserID_Supplier&" + LoginInfo.UserID + "^"; List <SupplierAddView> queryData = m_BLL.GetEmployeeStopExcelListBySupplier(search).OrderBy(c => c.CertificateNumber).ThenBy(c => c.CityID).ThenBy(c => c.OperationTime).ToList(); if (queryData.Count == 0) { var data = new Common.ClientResult.UrlResult { Code = ClientCode.FindNull, Message = "没有符合条件的数据", URL = "" }; return(data); } //string excelName = "供应商导出" + DateTime.Now.ToString(); using (MemoryStream ms = new MemoryStream()) { string ids = string.Empty; int[] intArray = new int[queryData.Count]; //员工社保一览 ISheet sheet = workbook.GetSheetAt(0); sheet.SetActiveCell(0, 0); int rowNum = 0; ICellStyle style = workbook.CreateCellStyle(); style.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Red.Index; style.FillPattern = FillPattern.SolidForeground; string tmpCertificateNumber = ""; string tmpCity = ""; string tmpYearMonth = ""; string strRemark = ""; IRow currentRow = null; #region 数据输出 int i = 0; foreach (var query in queryData) { intArray[i] = query.EmployeeAddId ?? 0; i++; if (tmpCertificateNumber != query.CertificateNumber || tmpCity != query.City || (tmpYearMonth != Convert.ToDateTime(query.OperationTime).ToString("yyyyMM") && query.InsuranceKindId != (int)Common.EmployeeAdd_InsuranceKindId.公积金)) { //保存临时数据 tmpCertificateNumber = query.CertificateNumber; tmpCity = query.City; tmpYearMonth = Convert.ToDateTime(query.OperationTime).ToString("yyyyMM"); if (currentRow != null) { currentRow.GetCell(10).SetCellValue(strRemark); // 备注 strRemark = ""; } rowNum++; currentRow = sheet.CopyRow(rowNum + 1, rowNum); currentRow.GetCell(0).SetCellValue(rowNum); // 序号 currentRow.GetCell(1).SetCellValue(query.CustomerName); // 客服姓名 currentRow.GetCell(2).SetCellValue(query.City); // 缴费地 currentRow.GetCell(3).SetCellValue(query.BranchName); // 分公司名称 currentRow.GetCell(4).SetCellValue(query.CompanyName); // 客户单位名称 currentRow.GetCell(5).SetCellValue(query.EmployeeName); // 员工姓名 currentRow.GetCell(6).SetCellValue(query.CertificateNumber); // 身份证号码 currentRow.GetCell(7).SetCellValue(query.Telephone); // 联系电话 if (query.InsuranceKindId != (int)Common.EmployeeAdd_InsuranceKindId.公积金) { currentRow.GetCell(8).SetCellValue(tmpYearMonth); // 缴费开始时间 } else { currentRow.GetCell(9).SetCellValue(tmpYearMonth); // 缴费开始时间 } } int cellNum = 0; switch (Convert.ToInt32(query.InsuranceKindId)) { case (int)Common.EmployeeAdd_InsuranceKindId.公积金: cellNum = 9; break; case (int)Common.EmployeeAdd_InsuranceKindId.养老: cellNum = 8; break; case (int)Common.EmployeeAdd_InsuranceKindId.医疗: cellNum = 8; break; case (int)Common.EmployeeAdd_InsuranceKindId.失业: cellNum = 8; break; case (int)Common.EmployeeAdd_InsuranceKindId.工伤: cellNum = 8; break; case (int)Common.EmployeeAdd_InsuranceKindId.生育: cellNum = 8; break; case (int)Common.EmployeeAdd_InsuranceKindId.大病: cellNum = 8; break; default: break; } if (query.State == "1") { currentRow.GetCell(cellNum).CellStyle = style; } if (!string.IsNullOrEmpty(query.Remark)) { strRemark += query.Remark + Convert.ToChar(10); } ids += query.EmployeeAddId + ","; } #endregion var results = 0;//返回的结果 if (queryDic["CollectState"].Equals(Common.CollectState.未提取.ToString())) { int[] ApprovedId; string[] strArray = ids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); ApprovedId = Array.ConvertAll <string, int>(strArray, s => int.Parse(s)); string returnValue = string.Empty; if (ApprovedId != null && ApprovedId.Length > 0) { if (m_BLL.EmployeeStopPaymentApproved(ref validationErrors, ApprovedId, Common.EmployeeStopPayment_State.待供应商客服提取.ToString(), Common.EmployeeStopPayment_State.已发送供应商.ToString(), null, LoginInfo.LoginName)) { results = ApprovedId.Count(); LogClassModels.WriteServiceLog("供应商客服已提取" + ",信息的Id为" + string.Join(",", ApprovedId), "消息" );//回退成功,写入日志 } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog("供应商客服提取失败" + ",信息的Id为" + string.Join(",", ApprovedId) + "," + returnValue, "消息" );//回退失败,写入日志 } } } string fileName = "供应商客服导出_" + DateTime.Now.ToString("yyyy-MM-dd") + ".xls"; string urlPath = "DataExport\\" + fileName; // 文件下载的URL地址,供给前台下载 string filePath = System.Web.HttpContext.Current.Server.MapPath("\\") + urlPath; // 文件路径 file = new FileStream(filePath, FileMode.Create); workbook.Write(file); file.Close(); string Message = queryDic["CollectState"].Equals(Common.CollectState.未提取.ToString()) ? "已成功提取报减信息" : "导出成功"; if (queryData.Count == 0) { //ActionResult result = var data = new Common.ClientResult.UrlResult { Code = ClientCode.FindNull, Message = "没有符合条件的数据", URL = urlPath }; return(data); } return(new Common.ClientResult.UrlResult { Code = ClientCode.Succeed, Message = Message, URL = urlPath }); } } catch (Exception e) { file.Close(); return(new Common.ClientResult.UrlResult { Code = ClientCode.Fail, Message = e.Message }); } }