public string CreateInquiry() { ResultObj result = new ResultObj(); int _pdid = FormString.IntSafeQ("pdid"); string memphone = FormString.SafeQ("memphone"); string remark = FormString.SafeQ("remark", 500); InquiryRecordsEntity inquiry = new InquiryRecordsEntity(); inquiry.MobilePhone = memphone; inquiry.Remark = remark; inquiry.ProductDetailId = _pdid; inquiry.CreatTime = DateTime.Now; inquiry.Status = (int)InquiryStatus.WaitDeal; int inid = InquiryRecordsBLL.Instance.AddInquiryRecords(inquiry); if (inid > 0) { result.Status = (int)CommonStatus.Success; result.Obj = inid; } else { result.Status = (int)CommonStatus.Fail; } string liststr = JsonJC.ObjectToJson(result); return(liststr); }
public ResultObj LoginByTempCode(string tempcode, string unionid, int clienttype, string ipaddress) { ResultObj _returnentity = new ResultObj(); MemberLoginEntity _entity = null; _entity = MemberBLL.Instance.GetLoginMemByMethod(tempcode, LoginMethodEnum.TempCode); if (_entity.Status == (int)MemberStatus.IsLock) { _returnentity.Status = (int)CommonStatus.LoginStatusLock; return(_returnentity); } if (_entity.Status == (int)MemberStatus.WaitCheck) { _returnentity.Status = (int)CommonStatus.Success; _returnentity.Obj = _entity; return(_returnentity); } _returnentity.Obj = _entity; _returnentity.Status = (int)CommonStatus.Success; if (_entity.MemId > 0 && string.IsNullOrEmpty(_entity.WeChat) && !string.IsNullOrEmpty(unionid)) { MemberBLL.Instance.BindMemWeChat(_entity.MemId, unionid, _entity.TimeStampTab); } //此处可以异步 AddLoginLog(_entity.MemId, 0, ""); return(_returnentity); }
public async void PostObject(IPostServiceDelegate <object> handler, PostObject <object> postObject) { ResultObj <object> result = new ResultObj <object>(); try { var uri = new Uri(String.Format(Config.BASE_SERVICE_URL + postObject.PostAction.Url)); var json = JsonConvert.SerializeObject(postObject); var content = new StringContent(json, Encoding.UTF8, "application/json"); responseMessage = await httpClient.PostAsync(uri, content); if (responseMessage.IsSuccessStatusCode) { JsonSerializerSettings serSettings = new JsonSerializerSettings(); serSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); var data = responseMessage.Content.ReadAsStringAsync().Result; result = JsonConvert.DeserializeObject <ResultObj <object> >(data.ToString()); handler.HandlePostResults(result); } else { result.Error = responseMessage.StatusCode.ToString(); handler.HandlePostResults(result); } } catch (Exception ex) { result.isSuccessful = false; result.Error = ex.Message; handler.HandlePostResults(result); } }
/// <summary> /// 选择供应商 /// </summary> /// <returns></returns> public string SelectCGMemSubmit() { ResultObj result = new ResultObj(); string ordercode = FormString.SafeQ("ordercode"); int memid = FormString.IntSafeQ("memid"); InquiryOrderEntity order = InquiryOrderBLL.Instance.GetInquiryOrderByCode(ordercode); if (order.Status == (int)OrderInquiryStatusEnum.Quoting || order.Status == (int)OrderInquiryStatusEnum.WaitAccept || order.Status == (int)OrderInquiryStatusEnum.HasAccept) { int resultrowi = CGMemQuotedBLL.Instance.SelectInquiryOrderCGMem(ordercode, memid); if (resultrowi > 0) { result.Status = (int)CommonStatus.Success; result.Obj = resultrowi; } else { result.Status = (int)CommonStatus.Fail; } } else { result.Status = (int)CommonStatus.OrderCanNotDo; } return(JsonJC.ObjectToJson(result)); }
public string SelectCGMemPriceSubmit() { ResultObj result = new ResultObj(); string ordercode = FormString.SafeQ("ordercode"); string memprices = FormString.SafeQ("memprices", 8000); memprices = memprices.Trim('|'); InquiryOrderEntity order = InquiryOrderBLL.Instance.GetInquiryOrderByCode(ordercode); if (order.Status == (int)OrderInquiryStatusEnum.Quoting || order.Status == (int)OrderInquiryStatusEnum.WaitAccept || order.Status == (int)OrderInquiryStatusEnum.HasAccept) { int resultrowi = CGQuotedPriceBLL.Instance.InquirySelectQuote(ordercode, memprices); if (resultrowi > 0) { result.Status = (int)CommonStatus.Success; result.Obj = resultrowi; } else { result.Status = (int)CommonStatus.Fail; } } else { result.Status = (int)CommonStatus.OrderCanNotDo; } return(JsonJC.ObjectToJson(result)); }
private static async Task <bool> RememberCodeAsync(string email) { ResultObj result = await Task.Run(() => Users.GetFromPhoneOrMail(email)); if (result.User != null) { Storage.temporaryData = result.User; Storage.IsEntering = true; MailAddress from = new MailAddress(Storage.Email, "DonorPlus"); MailAddress to = new MailAddress(result.User.Email); MailMessage message = new MailMessage(from, to) { Subject = "Восстановление пароля", Body = $"Здравствуйте, {result.User.Name} {result.User.SecondName}!\n" + $"Подтвердите ваш аккаунт в Donor+\n" + $"Код для потверждения: {Storage.ConfirmCode}.\n" + $"Если это не Вы, напишите в нашу поддержку '{Storage.Email}'\n\n" + $"С уважением,\nКоманда Donor+" }; SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587) { Credentials = new NetworkCredential(Storage.Email, Storage.MailPasswd), EnableSsl = true }; await smtp.SendMailAsync(message); } else { return(false); } return(true); }
/// <summary> /// 确认收货 /// </summary> /// <returns></returns> public string OrderRecived() { ResultObj _result = new ResultObj(); long _code = FormString.LongIntSafeQ("code"); if (OrderBLL.Instance.OrderRecived(_code, memid) > 0) { //采购系统接口 if (CGOrderBLL.Instance.CGOrderRecived(_code) == 0) { LogUtil.Log("采购系统数据同步出错", "订单确认收货同步,订单号" + _code); } //优惠券发放 int num = MemCouponsBLL.Instance.ProvideCouponsByOrder(_code); if (num > 0) { OrderBLL.Instance.EditOrderCouponsNum(_code, num); } _result.Status = (int)CommonStatus.Success; _result.Obj = OrderBLL.Instance.GetVWOrderByCode(_code); } else { _result.Status = (int)CommonStatus.Fail; } return(JsonJC.ObjectToJson(_result)); }
/// <summary> /// 注册第一步 /// </summary> /// <param name="_mem"></param> /// <returns></returns> public ResultObj Register1(MemberEntity _mem) { ResultObj _returnentity = new ResultObj(); if (string.IsNullOrEmpty(_mem.PassWord)) { _returnentity.Status = (int)CommonStatus.RegisterEmpty; return(_returnentity); } MemberEntity mem1 = MemberBLL.Instance.GetLoginMemByMobile(_mem.MobilePhone); if (mem1 != null && !string.IsNullOrEmpty(mem1.MobilePhone) && mem1.Id > 0) { _returnentity.Status = (int)CommonStatus.RegisterHasMember; return(_returnentity); } _mem.Id = MemberBLL.Instance.AddMember(_mem); if (_mem.Id > 0) { _returnentity.Status = (int)CommonStatus.Success; _returnentity.Obj = MemberBLL.Instance.GetMember(_mem.Id); } else { _returnentity.Status = (int)CommonStatus.Fail; } return(_returnentity); }
public static async void LogIn(bool IsEnter) { if (IsEnter) { DataAlreadyLoaded?.Invoke(); Storage.DataLoaded = true; } else { if (Current.Properties.TryGetValue("user", out object id)) { try { ResultObj result = await Task.Run(() => Users.GetInfoAboutUser((int)id)); Storage.User = result.User; Storage.User.AddPhoto(Photo.Get(Storage.User.Id).Image); ResultObj blood = BloodData.Get(result.User.Id); Storage.User.AddBloodGroup(blood.BloodGroup); Storage.User.AddRFactor(blood.RFactor); DataAlreadyLoaded?.Invoke(); Storage.DataLoaded = true; } catch (System.Exception ex) { string str = ex.Message; Current.MainPage = new NavigationPage(new EnterPage()); } } } }
//public string GetWeiXinAccessToken() //{ // return WeiXinBLL.GetWeiXinAccessToken(); //} //public string GetWeiXinJsticket() //{ // return WeiXinBLL.GetWeiXinJsticket(); //} //public string GetWeiXinGetSignature() //{ // string ticket = FormString.SafeQ("ticket", 200); // string noncestr = FormString.SafeQ("noncestr", 200); // long times = FormString.LongIntSafeQ("timestamp"); // string url = FormString.SafeQ("url",200 ); // return WeiXinBLL.GetSignature(ticket, noncestr, times, url); //} //public string GetWeiXinAPPId() //{ // return WeiXinBLL.APPId; //} #endregion #region 询价 public string GetXunJiaMsg() { ResultObj result = new ResultObj(); int _pdid = FormString.IntSafeQ("pdid"); MemberLoginEntity member = CookieBLL.GetLoginCookie(); if (member != null && member.MemId > 0) { VWXunJiaObj _obj = new VWXunJiaObj(); VWProductEntity vwp = ProductBLL.Instance.GetProVWByDetailId(_pdid); VWProductNomalParamEntity vwpa = ProductExtBLL.Instance.GetProductNormalParamById(vwp.ProductId); MemStoreEntity store = StoreBLL.Instance.GetStoreByMemId(member.MemId); _obj.Product = vwp; _obj.ProductExt = vwpa; _obj.MobilePhone = store.MobilePhone; _obj.MemId = store.MemId; result.Status = (int)CommonStatus.Success; result.Obj = _obj; } else { result.Status = (int)CommonStatus.NeedLogin; } string liststr = JsonJC.ObjectToJson(result); return(liststr); }
public string SaveLicense() { ResultObj _loginentity = new ResultObj(); int memid = CookieBLL.GetRegisterCookie(); string path = FormString.SafeQ("licensepath"); if (memid > 0) { MemberEntity _mem = new MemberEntity(); _mem = MemberBLL.Instance.GetMember(memid); if (_mem != null && _mem.Status == (int)MemberStatus.WaitCheck) { MemberBLL.Instance.RegisterCompanyLicense(memid, path); _loginentity.Status = (int)CommonStatus.Success; } else { _loginentity.Status = (int)CommonStatus.Fail; } } else { _loginentity.Status = (int)CommonStatus.Fail; } return(JsonJC.ObjectToJson(_loginentity)); }
/// <summary> /// 确认个人信息,忘记密码 /// </summary> /// <returns></returns> public string ConfirmPersonalInfo() { ResultObj result = new ResultObj(); string _mobile = FormString.SafeQ("mobile"); string _vCode = FormString.SafeQ("vCode"); if (System.Web.HttpContext.Current.Session[CommonKey.MobileNo] != null && System.Web.HttpContext.Current.Session[CommonKey.MobileNo].ToString() == _mobile && System.Web.HttpContext.Current.Session[CommonKey.MobileYZCode] != null && System.Web.HttpContext.Current.Session[CommonKey.MobileYZCode].ToString() == _vCode) { MemberEntity _entity = MemberBLL.Instance.GetMemByMobile(_mobile); if (_entity.Id > 0) { if (MemberBLL.Instance.UpdateMember(_entity) > 0) { MemberEntity _memnew = MemberBLL.Instance.GetMember(_entity.Id); System.Web.HttpContext.Current.Session.Add(CommonKey.FindPwdID, _entity.Id); result.Status = (int)CommonStatus.Success; result.Obj = _memnew.TimeStampTab; } else { result.Status = (int)CommonStatus.Fail; } } else { result.Status = (int)CommonStatus.PhoneNotExist; } } else { result.Status = (int)CommonStatus.VerCodeIsError; } return(JsonJC.ObjectToJson(result)); }
public ResultObj Update(InspectLine newObj) { ResultObj resultObj = new ResultObj(); var obj = _context.InspectLine.Find(newObj.GId); if (obj == null) { resultObj.IsSuccess = false; resultObj.ErrMsg = "修改对象不存在。"; return(resultObj); } if (IsExistSameName(newObj)) { resultObj.IsSuccess = false; resultObj.ErrMsg = "名称已存在。"; return(resultObj); } obj.LineName = newObj.LineName; obj.DeviceInspectItems = newObj.DeviceInspectItems; obj.DeviceInspectItemsName = newObj.DeviceInspectItemsName; obj.Remark = newObj.Remark; obj.LastUpdateTime = DateTime.Now; obj.LastUpdateUser = newObj.LastUpdateUser; _context.InspectLine.Update(obj); _context.SaveChanges(); resultObj.IsSuccess = true; return(resultObj); }
public string UserLogin() { ResultObj _result = new ResultObj(); _result.Status = (int)CommonStatus.Fail; string useraccount = StringUtils.SafeStr(Request.Form["useraccount"]); string password = StringUtils.SafeStr(Request.Form["password"]); string VerCode = StringUtils.SafeStr(FormString.SafeQ("verCode")); int autologin = FormString.IntSafeQ("autologin"); //if (VerCode.Length == 4) //{ // //string svercode = StringUtils.GetDbString(System.Web.HttpContext.Current.Session["verify_login"]); // HttpCookie cookie = Request.Cookies["verify_login"]; // string svercode = ""; // if (cookie != null) // { // svercode = CryptDES.DESDecrypt(cookie.Value); // } // if (svercode != "") // { // if (VerCode.ToLower() != svercode.ToLower()) // { // return "验证码输入错误"; // } // } //} MemberLoginEntity _loginmodel = new MemberLoginEntity(); _result = MemberLoginBLL.Instance.Login("", useraccount, password, (int)ClientTypeEnum.PC, IPAddress.IP); if (_result != null && _result.Obj != null) { _loginmodel = (MemberLoginEntity)_result.Obj; try { if (_result.Status == (int)CommonStatus.Success) { if (_loginmodel.Status == (int)MemberStatus.WaitCheck) { CookieBLL.SetRegisterCookie(_loginmodel.MemId); } else { CookieBLL.SetLoginCookie(_loginmodel, autologin == 1); CookieBLL.ComBineCart(1); CookieBLL.ComBineCartXuQiu(1); } } } catch (Exception ex) { LogUtil.Log(ex); _result.Status = (int)CommonStatus.ServerError; } } return(JsonJC.ObjectToJson(_result)); }
/// <summary> /// 用户选择产品 /// </summary> /// <returns></returns> public string OrderProductSelect() { ResultObj result = new ResultObj(); string _ordercode = FormString.SafeQ("code"); string _producselect = FormString.SafeQ("producselect"); VWInquiryOrderEntity order = InquiryOrderBLL.Instance.GetVWInquiryOrderByCode(_ordercode); if (order != null && (order.Status == (int)OrderInquiryStatusEnum.WaitAccept) && order.MemId == memid) { Random rd = new Random(); string confirmcode = XTCodeBLL.Instance.GetCodeFromProc(XTCodeType.OrderDayNo) + rd.Next(100, 999).ToString(); int resulrow = CGQuotedPriceBLL.Instance.UserSelectQuote(_ordercode, confirmcode, _producselect); if (resulrow > 0) { result.Status = (int)CommonStatus.Success; result.Obj = confirmcode; return(JsonJC.ObjectToJson(result)); } } else { result.Status = (int)CommonStatus.Fail; result.Obj = _ordercode; } result.Status = (int)CommonStatus.Fail; result.Obj = _ordercode; return(JsonJC.ObjectToJson(result)); }
public ResultObj Update(InspectItems newObj) { ResultObj resultObj = new ResultObj(); var obj = _context.InspectItems.Find(newObj.GId); if (obj == null) { resultObj.IsSuccess = false; resultObj.ErrMsg = "修改对象不存在。"; return(resultObj); } if (IsExistSameNo(newObj)) { resultObj.IsSuccess = false; resultObj.ErrMsg = "编号已存在。"; return(resultObj); } obj.InspectItemName = newObj.InspectItemName; obj.InspectItemNo = newObj.InspectItemNo; obj.ValueType = newObj.ValueType; obj.Unit = newObj.Unit; obj.Remark = newObj.Remark; obj.LastUpdateTime = DateTime.Now; obj.LastUpdateUser = newObj.LastUpdateUser; _context.InspectItems.Update(obj); _context.SaveChanges(); resultObj.IsSuccess = true; return(resultObj); }
public string PaySelectSubmit() { ResultObj _result = new ResultObj(); long _syscode = FormString.LongIntSafeQ("syscode"); int _paytype = FormString.IntSafeQ("paytype"); int _systype = FormString.IntSafeQ("systype"); if (_systype == 0) { _systype = (int)SystemType.B2B; } OrderEntity order = OrderBLL.Instance.GetOrderByCode(_syscode); string payconfirm = ""; if (_paytype == (int)PayType.OutLine) { payconfirm = StringUtils.GetRandomString(12); } PayOrderEntity payen = PayOrderBLL.Instance.GetPayOrderBySysCode(_systype, _syscode.ToString(), _paytype); if (payen.Id > 0 && payen.Status == 1) { _result.Status = (int)CommonStatus.HasPayed; _result.Obj = payen; } else { payen = PayOrderBLL.Instance.CreatePayOrder(_systype, _syscode.ToString(), order.ActPrice, _paytype, memid, payconfirm); _result.Status = (int)CommonStatus.Success; _result.Obj = payen; } return(JsonJC.ObjectToJson(_result)); }
public async Task <ResultObj <int> > save(DtoSave <SysQueryEntity> inEnt) { ResultObj <int> reObj = new ResultObj <int>(); try { if (string.IsNullOrEmpty(inEnt.data.queryCfgJson)) { inEnt.data.queryCfgJson = TypeChange.ObjectToStr((await _query.MakeQueryCfg(inEnt.data.code)).data); } if (string.IsNullOrEmpty(inEnt.data.rowsBtn)) { inEnt.data.rowsBtn = @" [{ ""title"": ""修改"", ""class"": ""nb-edit"", ""readUrl"": ""user/*/singleByKey"", ""apiUrl"": ""user/*/save"" }, { ""title"": ""删除"", ""class"": ""nb-trash"", ""apiUrl"": ""user/*/delete"", ""confirmTip"": ""确定要删除吗?"" } ]"; } if (string.IsNullOrEmpty(inEnt.data.heardBtn)) { inEnt.data.heardBtn = @" [{ ""title"": ""添加"", ""class"": ""nb-plus"", ""click"": ""nowThis.Add('user/*/save')"" }, { ""title"": ""批量删除"", ""class"": ""ion-delete"", ""click"": ""nowThis.Exec('user/*/delete','id','删除要删除吗?')"" } ] "; } if (inEnt.data.id == 0) { reObj.data = await _query.Save(inEnt); } else { reObj.data = await _query.Update(inEnt); } } catch (Exception ex) { LogHelper.WriteErrorLog(typeof(QueryController), ex.ToString()); reObj.msg = ex.Message; reObj.success = false; } return(reObj); }
public ResultObj Add(OilStation obj) { // 获取当前登录用户名 string _currentUserName = CommonService.GetCurrentUser(HttpContext).UserName; ResultObj resultObj = new ResultObj(); if (IsExistSame(obj)) { resultObj.IsSuccess = false; resultObj.ErrMsg = "该站名已存在。"; return(resultObj); } obj.CreateUser = _currentUserName; obj.CreateTime = DateTime.Now; obj.LastUpdateUser = _currentUserName; obj.LastUpdateTime = DateTime.Now; _context.OilStation.Add(obj); _context.SaveChanges(); resultObj.IsSuccess = true; return(resultObj); }
public ResultObj tovoid(WorkTicket newObj) { // 获取当前登录用户名 string _currentUserName = CommonService.GetCurrentUser(HttpContext).UserName; ResultObj resultObj = new ResultObj(); var obj = _context.WorkTicket.Find(newObj.PK); if (obj == null) { resultObj.IsSuccess = false; resultObj.ErrMsg = "修改对象不存在。"; return(resultObj); } obj.Status = WorkTicketStatus.已作废.ToString(); obj.Description = obj.Description + "\n【作废】操作人:" + _currentUserName + ",时间:" + DateTime.Now; obj.LastUpdateTime = DateTime.Now; obj.LastUpdateUser = _currentUserName; _context.WorkTicket.Update(obj); _context.SaveChanges(); resultObj.IsSuccess = true; return(resultObj); }
public ResultObj Add(WorkTicket obj) { // 获取当前登录用户名 string _currentUserName = CommonService.GetCurrentUser(HttpContext).UserName; ResultObj resultObj = new ResultObj(); if (IsExistSame(obj)) { resultObj.IsSuccess = false; resultObj.ErrMsg = "该工单编号已存在。"; return(resultObj); } //obj.Status = WorkTicketStatus.待接单.ToString(); obj.Status = WorkTicketStatus.待拉油.ToString(); obj.IsDeleted = false; obj.Description = obj.Description + "【创建工单】操作人:" + _currentUserName + ",时间:" + DateTime.Now; obj.CreateUser = _currentUserName; obj.CreateTime = DateTime.Now; obj.LastUpdateUser = _currentUserName; obj.LastUpdateTime = DateTime.Now; _context.WorkTicket.Add(obj); _context.SaveChanges(); resultObj.IsSuccess = true; return(resultObj); }
public ResultObj BackReduceDrugStock(List <InpChargeItemViewModel> modelList, DateTime prescDate, int prescNo, string storage) { ResultObj result = new ResultObj(); if (modelList == null) { result.code = (int)HttpStatusCode.LengthRequired; result.isSuccess = false; result.massage = "参数为空"; return(result); } //组建传递dal中的药品表List List <DRUG_STOCK> drugList = new List <DRUG_STOCK>(); foreach (var model in modelList) { //获取药品库存基本信息 DRUG_STOCK drugModel = _repository.FindByClause(m => m.DRUG_CODE == model.DRUG_CODE && m.STORAGE == storage); int quantity = drugModel.QUANTITY + model.QUANTITY; drugModel.QUANTITY = quantity; drugList.Add(drugModel); } List <DRUG_PRESC_DETAIL> detailList = detailRepository.FindListByClause(m => m.PRESC_DATE == prescDate && m.PRESC_NO == prescNo).ToList(); DRUG_PRESC_MASTER master = masterRepository.FindByClause(m => m.PRESC_DATE == prescDate && m.PRESC_NO == prescNo); bool detailFalg = false; if (detailList.Count > 0) { detailFalg = true; } bool masterFalg = false; if (master != null) { masterFalg = true; } var flag = _repository.BackReduceDrugStock(drugList, prescDate, prescNo, detailFalg, masterFalg); if (flag) { result.code = (int)HttpStatusCode.OK; result.isSuccess = true; } else { result.code = (int)HttpStatusCode.InternalServerError; result.isSuccess = false; result.massage = "服务器处理出错"; } return(result); }
public async Task <IHttpActionResult> PostQuery(JObject jsonData) { TransferObj <PagedObj <NvCongNoVm.Dto> > result = new TransferObj <PagedObj <NvCongNoVm.Dto> >(); dynamic postData = ((dynamic)jsonData); FilterObj <NvCongNoVm.Search> filtered = ((JObject)postData.filtered).ToObject <FilterObj <NvCongNoVm.Search> >(); PagedObj <NvCongNo> paged = ((JObject)postData.paged).ToObject <PagedObj <NvCongNo> >(); string unitCode = _service.GetCurrentUnitCode(); QueryBuilder query = new QueryBuilder { Take = paged.ItemsPerPage, Skip = paged.FromItem - 1, Filter = new QueryFilterLinQ() { SubFilters = new List <IQueryFilter>() { new QueryFilterLinQ() { Property = ClassHelper.GetProperty(() => new NvCongNo().LoaiChungTu), Method = FilterMethod.EqualTo, Value = filtered.AdvanceData.LoaiChungTu }, new QueryFilterLinQ() { Property = ClassHelper.GetProperty(() => new NvCongNo().UnitCode), Method = FilterMethod.EqualTo, Value = unitCode } }, Method = FilterMethod.And }, Orders = new List <IQueryOrder>() { new QueryOrder() { Field = ClassHelper.GetPropertyName(() => new NvCongNo().ICreateDate), Method = OrderMethod.DESC } } }; try { ResultObj <PagedObj <NvCongNo> > filterResult = _service.Filter(filtered, query); if (!filterResult.WasSuccessful) { return(NotFound()); } result.Data = Mapper.Map <PagedObj <NvCongNo>, PagedObj <NvCongNoVm.Dto> >(filterResult.Value); result.Status = true; return(Ok(result)); } catch (Exception e) { WriteLogs.LogError(e); result.Status = false; result.Message = e.Message.ToString(); return(Ok(result)); } }
public List <ResultObj> ExecuteProcedure(string sqlText, List <ParamObj> param) { List <ResultObj> result = new List <ResultObj>(); DbConnection connection = null; DbCommand cmd = null; try { connection = _context.Database.GetDbConnection(); connection.Open(); cmd = connection.CreateCommand(); cmd.CommandText = sqlText; foreach (var data in param) { var pr = cmd.CreateParameter(); pr.ParameterName = "@" + data.Name; if (data.Direction == ParameterDirection.Input) { pr.Value = data.Value; } pr.DbType = data.Type; pr.Direction = data.Direction; cmd.Parameters.Add(pr); } Console.WriteLine("Call procedure"); cmd.CommandType = CommandType.StoredProcedure; cmd.ExecuteNonQuery(); Console.WriteLine("Execute DONE"); foreach (var data in param) { if (data.Direction == ParameterDirection.Output) { var val = Convert.ToString(cmd.Parameters["@" + data.Name].Value); ResultObj rs = new ResultObj(data.Name, val); result.Add(rs); } } } catch (Exception e) { Console.WriteLine("Exception: " + e.Message); //_logger.LogError(e.Message); } finally{ try { if (cmd != null) { cmd.Dispose(); } connection.Close(); } catch (Exception e) { Console.WriteLine("Exception: " + e.Message); } } return(result); }
public async Task <ResultObj <int> > Save(DtoSave <SysRoleEntity> inEnt) { ResultObj <int> reObj = new ResultObj <int>(); try { dbHelper.TranscationBegin(); DapperHelper <SysModuleEntity> moduleDapper = new DapperHelper <SysModuleEntity>(dbHelper.GetConnection(), dbHelper.GetTransaction()); if (inEnt.data.id == 0) { inEnt.data.id = await SequenceRepository.GetNextID <SysRoleEntity>(); reObj.data = await dbHelper.Save(inEnt); } else { reObj.data = await dbHelper.Update(inEnt); } reObj.success = reObj.data > 0; if (!reObj.success) { reObj.msg = "保存角色失败"; dbHelper.TranscationRollback(); } else { var allModule = await moduleDapper.FindAll(string.Format("ID in ({0})", string.Join(",", inEnt.data.moduleIdStr))); var moduleIdList = allModule.Select(i => i.id).ToList(); var parent = allModule.GroupBy(i => i.parentId).Select(x => x.Key).Where(x => x != 0).Select(x => x).ToList(); moduleIdList = moduleIdList.Concat(parent).ToList(); moduleIdList = moduleIdList.GroupBy(i => i).Select(i => i.Key).ToList(); await dbHelper.Exec("delete from sys_role_module where role_id = " + inEnt.data.id); var opNum = await dbHelper.Exec(string.Format("insert into sys_role_module(role_id,module_id) select {0} role_id,id module_id from sys_module where id in ({1}) ", inEnt.data.id, string.Join(",", moduleIdList))); if (opNum != moduleIdList.Count()) { reObj.success = false; reObj.msg = "保存角色模块失败"; dbHelper.TranscationRollback(); } else { reObj.success = true; dbHelper.TranscationCommit(); } } } catch (Exception e) { reObj.success = false; reObj.msg = "保存角色失败"; LogHelper.WriteErrorLog(this.GetType(), reObj.msg, e); dbHelper.TranscationRollback(); } return(reObj); }
/// <summary> /// 查找所有 /// </summary> /// <param name="inParm"></param> /// <returns></returns> public async Task <ResultObj <SysModuleEntity> > GetMenu(Expression <Func <SysModuleEntity, bool> > where) { ResultObj <SysModuleEntity> reObj = new ResultObj <SysModuleEntity>(); var allModel = await dbHelper.FindAll(where); reObj.dataList = GetChildItems(allModel, 0); return(reObj); }
public async Task <IHttpActionResult> PostQuerySummary(JObject jsonData) { TransferObj <PagedObj <NvPhieuDatHangNCCVm.Dto> > result = new TransferObj <PagedObj <NvPhieuDatHangNCCVm.Dto> >(); dynamic postData = ((dynamic)jsonData); FilterObj <NvPhieuDatHangNCCVm.Search> filtered = ((JObject)postData.filtered).ToObject <FilterObj <NvPhieuDatHangNCCVm.Search> >(); filtered.OrderType = "DESC"; filtered.OrderBy = "Ngay"; PagedObj <NvDatHang> paged = ((JObject)postData.paged).ToObject <PagedObj <NvDatHang> >(); string unitCode = _service.GetCurrentUnitCode(); QueryBuilder query = new QueryBuilder { Take = paged.ItemsPerPage, Skip = paged.FromItem - 1, Filter = new QueryFilterLinQ() { SubFilters = new List <IQueryFilter>() { new QueryFilterLinQ() { Property = ClassHelper.GetProperty(() => new NvDatHang().SoPhieuCon), Method = FilterMethod.NotNull, }, new QueryFilterLinQ() { Property = ClassHelper.GetProperty(() => new NvDatHang().Loai), Method = FilterMethod.EqualTo, Value = (int)LoaiDatHang.NHACUNGCAP }, new QueryFilterLinQ() { Property = ClassHelper.GetProperty(() => new NvVatTuChungTu().UnitCode), Method = FilterMethod.EqualTo, Value = unitCode } }, Method = FilterMethod.And }, }; try { ResultObj <PagedObj <NvDatHang> > filterResult = _service.Filter(filtered, query); if (!filterResult.WasSuccessful) { return(NotFound()); } result.Data = Mapper.Map <PagedObj <NvDatHang>, PagedObj <NvPhieuDatHangNCCVm.Dto> >(filterResult.Value); result.Status = true; return(Ok(result)); } catch (Exception) { return(InternalServerError()); } }
public static UserDtoResult ConvertTo(this ResultObj <UserDto> internalModel) { var outputRootModel = new UserDtoResult(); outputRootModel.Success = internalModel.Success; outputRootModel.Data = internalModel.Data; outputRootModel.Messages = internalModel.Messages; return(outputRootModel); }
public async Task <ResultObj <int> > Delete(int key) { ResultObj <int> reObj = new ResultObj <int>(); reObj.data = await dbHelper.Delete(i => i.id == key); reObj.success = reObj.data > 0; return(reObj); }
/// <summary> /// 删除 /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <ResultObj <int> > Delete(int id) { var reObj = new ResultObj <int>(); reObj.data = await dbHelper.Delete(x => x.id == id); reObj.success = reObj.data > 0; return(reObj); }