public bool Add(BaseVillage model, DbOperator dbOperator) { model.DataStatus = DataStatus.Normal; model.LastUpdateTime = DateTime.Now; model.HaveUpdate = SystemDefaultConfig.DataUpdateFlag; StringBuilder strSql = new StringBuilder(); strSql.Append("insert into BaseVillage(VID,VNo,VName,CPID,LinkMan,Mobile,Address,Coordinate,ProxyNo,LastUpdateTime,HaveUpdate,DataStatus)"); strSql.Append(" values(@VID,@VNo,@VName,@CPID,@LinkMan,@Mobile,@Address,@Coordinate,@ProxyNo,@LastUpdateTime,@HaveUpdate,@DataStatus)"); dbOperator.ClearParameters(); dbOperator.AddParameter("VID", model.VID); dbOperator.AddParameter("VNo", model.VNo); dbOperator.AddParameter("VName", model.VName); dbOperator.AddParameter("CPID", model.CPID); dbOperator.AddParameter("LinkMan", model.LinkMan); dbOperator.AddParameter("Mobile", model.Mobile); dbOperator.AddParameter("Address", model.Address); dbOperator.AddParameter("Coordinate", model.Coordinate); dbOperator.AddParameter("ProxyNo", model.ProxyNo); dbOperator.AddParameter("LastUpdateTime", model.LastUpdateTime); dbOperator.AddParameter("HaveUpdate", model.HaveUpdate); dbOperator.AddParameter("DataStatus", (int)model.DataStatus); return(dbOperator.ExecuteNonQuery(strSql.ToString()) > 0); }
public bool Update(BaseVillage model) { using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { model.DataStatus = DataStatus.Normal; model.LastUpdateTime = DateTime.Now; model.HaveUpdate = SystemDefaultConfig.DataUpdateFlag; StringBuilder strSql = new StringBuilder(); strSql.Append("update BaseVillage set VNo=@VNo,VName=@VName,CPID=@CPID,LinkMan=@LinkMan,Mobile=@Mobile,Address=@Address,Coordinate=@Coordinate,LastUpdateTime=@LastUpdateTime,HaveUpdate=@HaveUpdate"); strSql.Append(" where VID=@VID"); dbOperator.ClearParameters(); dbOperator.AddParameter("VID", model.VID); dbOperator.AddParameter("VNo", model.VNo); dbOperator.AddParameter("VName", model.VName); dbOperator.AddParameter("CPID", model.CPID); dbOperator.AddParameter("LinkMan", model.LinkMan); dbOperator.AddParameter("Mobile", model.Mobile); dbOperator.AddParameter("Address", model.Address); dbOperator.AddParameter("Coordinate", model.Coordinate); dbOperator.AddParameter("LastUpdateTime", model.LastUpdateTime); dbOperator.AddParameter("HaveUpdate", model.HaveUpdate); return(dbOperator.ExecuteNonQuery(strSql.ToString()) > 0); } }
public static bool Update(BaseVillage model) { if (model == null) { throw new ArgumentNullException("model"); } if (string.IsNullOrWhiteSpace(model.VNo)) { throw new ArgumentNullException("小区编号不能为空"); } IVillage factory = VillageFactory.GetFactory(); BaseVillage dbModel = factory.QueryVillageByVillageNo(model.VNo, model.CPID); if (dbModel != null && dbModel.VID != model.VID) { throw new MyException("小区编号已经存在"); } dbModel = factory.QueryVillageByProxyNo(model.ProxyNo); if (dbModel != null && dbModel.VID != model.VID) { throw new MyException("代理编号已存在"); } bool result = factory.Update(model); if (result) { OperateLogServices.AddOperateLog <BaseVillage>(model, OperateType.Update); } return(result); }
public bool Add(BaseVillage model) { using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { return(Add(model, dbOperator)); } }
//根据人员和车场信息 下载二维码 public JsonResult DownloadQRCode(string parkingId, string personId, int size) { try { List <int> dics = new List <int>(); dics.Add(258); dics.Add(344); dics.Add(430); dics.Add(860); dics.Add(1280); List <string> imgs = new List <string>(); //if (string.IsNullOrWhiteSpace(SystemDefaultConfig.SystemDomain)) //{ // throw new MyException("获取系统域名失败"); //} BaseParkinfo parking = ParkingServices.QueryParkingByParkingID(parkingId); if (parking == null) { throw new MyException("获取车场信息失败"); } BaseVillage village = VillageServices.QueryVillageByRecordId(parking.VID); if (village == null) { throw new MyException("获取小区信息失败"); } //string url = SystemDefaultConfig.SystemDomain; string url = "http://spscs.spsing.cn"; string content = string.Format("{0}/qrl/qrp_ix_pid={1}^personId={2}", url, parkingId.Trim(), personId); foreach (var item in dics) { try { string parkingName = string.Format("{0}_{1}", parking.PKName, item); string result = QRCodeServices.GenerateQRCode(village.CPID, content, item, parkingName); imgs.Add(item.ToString() + "|" + result); TxtLogServices.WriteTxtLogEx("DownloadQRCode", item.ToString() + "|" + result); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "生存车场二维码失败"); imgs.Add(item.ToString() + "|"); } } return(Json(MyResult.Success("", imgs))); } catch (MyException ex) { return(Json(MyResult.Error(ex.Message))); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "下载二维码失败"); return(Json(MyResult.Error("下载二维码失败"))); } }
public JsonResult AddIdenticalQRCode(string recordId, string vid, bool isAdd) { try { ParkDerateQRcode derate = ParkDerateQRcodeServices.QueryByRecordId(recordId); if (derate == null) { throw new MyException("获取优免二维码失败"); } if (isAdd) { derate.AlreadyUseTimes = 0; derate.CreateTime = DateTime.Now; derate.OperatorId = GetLoginUser.RecordID; bool result = ParkDerateQRcodeServices.Add(derate); if (!result) { throw new MyException("添加优免二维码失败"); } } if (string.IsNullOrWhiteSpace(SystemDefaultConfig.SystemDomain)) { throw new MyException("获取系统域名失败"); } BaseVillage village = VillageServices.QueryVillageByRecordId(vid); if (village == null) { throw new MyException("获取小区信息失败"); } string content = string.Format("{0}/QRCodeDerate/Index?vid={1}&qid={2}&sign={3}", SystemDefaultConfig.SystemDomain, vid, recordId, GetSignature(vid, recordId)); using (System.Drawing.Image image = QRCodeServices.GenerateQRCode(content, 430)) { ImageFormat format = image.RawFormat; byte[] buffer; using (MemoryStream ms = new MemoryStream()) { image.Save(ms, ImageFormat.Jpeg); buffer = new byte[ms.Length]; ms.Seek(0, SeekOrigin.Begin); ms.Read(buffer, 0, buffer.Length); } return(Json(MyResult.Success("添加二维码成功", System.Convert.ToBase64String(buffer)))); } } catch (MyException ex) { return(Json(MyResult.Error(ex.Message))); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "复制优免二维码失败"); return(Json(MyResult.Error("复制优免二维码失败"))); } }
/// <summary> /// 扫码优免进入 /// </summary> /// <param name="vid">小区编号</param> /// <param name="qid">二维码编号</param> /// <param name="type">0-长久二维码 1-临时二维码</param> /// <param name="sign">签名</param> /// <returns></returns> public ActionResult Index(string vid, string qid, string sign) { TxtLogServices.WriteTxtLogEx("QRCodeDerate", "进入扫码打折:vid={0},qid={1},sign={2}", vid, qid, sign); try { if (SourceClient != RequestSourceClient.WeiXin) { throw new MyException("请在微信中打开"); } if (!CheckSignature(vid, qid, sign)) { throw new MyException("验证签名失败"); } if (SourceClient == RequestSourceClient.WeiXin) { if (string.IsNullOrWhiteSpace(WeiXinOpenId)) { ParkDerate derate = ParkDerateServices.Query(qid); if (derate == null) { throw new MyException("获取优免券信息失败"); } ParkSeller seller = ParkSellerServices.QueryBySellerId(derate.SellerID); if (seller == null) { throw new MyException("获取商家信息失败"); } BaseVillage village = VillageServices.QueryVillageByRecordId(seller.VID); if (village == null) { throw new MyException("获取小区信息失败"); } string id = string.Format("QRCodeDerate_Index_vid={0}^qid={1}^sign={2}^companyId={3}", vid, qid, sign, village.CPID); return(RedirectToAction("Index", "WeiXinAuthorize", new { id = id })); } } ViewBag.PlateNumber = OnlineOrderServices.QueryLastPaymentPlateNumber(PaymentChannel.WeiXinPay, WeiXinOpenId); ViewBag.VillageId = vid; ViewBag.QId = qid; return(View()); } catch (MyException ex) { TxtLogServices.WriteTxtLogEx("QRCodeDerate", "扫码打折异常:描述:{0}", ex.Message); return(RedirectToAction("Index", "ErrorPrompt", new { message = ex.Message })); } catch (Exception ex) { TxtLogServices.WriteTxtLogEx("QRCodeDerate", "扫码打折异常:描述:{0},明细:{1}", ex.Message, ex.StackTrace); return(RedirectToAction("Index", "ErrorPrompt", new { message = "扫码失败,未知异常" })); } }
private void UpdateLoginUserVillageCache(BaseVillage model) { List <BaseVillage> villages = GetLoginUserVillages; if (villages != null && villages.Count(p => p.VID == model.VID) > 0) { villages.Remove(villages.First(p => p.VID == model.VID)); villages.Add(model); Session["SmartSystem_SystemLoginUserRole_Valid_Village"] = villages; } }
public static BaseVillage GetVillage(string CPID) { BaseVillage model = new BaseVillage(); model.VID = GuidGenerator.GetGuidString(); model.ProxyNo = model.VID; model.CPID = CPID; model.VName = "默认小区"; model.VNo = "0001"; return(model); }
public JsonResult DownloadQRCode(string vid, string qid, string sellerName, string derateName) { try { List <int> dics = new List <int>(); dics.Add(258); dics.Add(344); dics.Add(430); dics.Add(860); dics.Add(1280); List <string> imgs = new List <string>(); if (string.IsNullOrWhiteSpace(SystemDefaultConfig.SystemDomain)) { throw new MyException("获取系统域名失败"); } BaseVillage village = VillageServices.QueryVillageByRecordId(vid); if (village == null) { throw new MyException("获取小区信息失败"); } string content = string.Format("{0}/QRCodeDerate/Index?vid={1}&qid={2}&sign={3}", SystemDefaultConfig.SystemDomain, vid, qid, GetSignature(vid, qid)); foreach (var item in dics) { try { string fileName = string.Format("{0}_{1}_{2}_{3}", sellerName, derateName, item, qid); string result = QRCodeServices.GenerateQRCode(village.CPID, content, item, fileName); imgs.Add(item.ToString() + "|" + result); TxtLogServices.WriteTxtLogEx("DownloadQRCode", item.ToString() + "|" + result); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "生存优免二维码失败"); imgs.Add(item.ToString() + "|"); } } return(Json(MyResult.Success("", imgs))); } catch (MyException ex) { return(Json(MyResult.Error(ex.Message))); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "下载优免二维码失败"); return(Json(MyResult.Error("下载优免二维码失败"))); } }
/// <summary> /// 创建默认小区 /// </summary> /// <param name="model"></param> /// <param name="dbOperator"></param> /// <returns></returns> public static bool AddVillageDefaultUser(BaseVillage model, DbOperator dbOperator) { model.DataStatus = DataStatus.Normal; model.LastUpdateTime = DateTime.Now; model.HaveUpdate = SystemDefaultConfig.DataUpdateFlag; IVillage factory = VillageFactory.GetFactory(); bool result = factory.Add(model, dbOperator); if (result) { OperateLogServices.AddOperateLog <BaseVillage>(model, OperateType.Add); } return(result); }
public static List <CarParkingResult> GetParkGrantByPlateNo(string plateNo) { if (plateNo.IsEmpty()) { throw new ArgumentNullException("plateNo"); } List <CarParkingResult> models = new List <CarParkingResult>(); IParkGrant factory = ParkGrantFactory.GetFactory(); List <ParkGrant> grants = factory.GetParkGrantByPlateNo(plateNo); if (grants.Count > 0) { List <ParkCarType> carTypes = ParkCarTypeServices.QueryParkCarTypeByRecordIds(grants.Select(p => p.CarTypeID).ToList()); List <BaseParkinfo> parkings = ParkingServices.QueryParkingByRecordIds(grants.Select(p => p.PKID).ToList()); List <BaseVillage> villages = new List <BaseVillage>(); if (parkings.Count > 0) { IVillage factoryVillage = VillageFactory.GetFactory(); villages = factoryVillage.QueryVillageByRecordIds(parkings.Select(p => p.VID).ToList()); } foreach (var item in grants) { CarParkingResult model = new CarParkingResult(); model.PlateNo = plateNo; BaseParkinfo parking = parkings.FirstOrDefault(p => p.PKID == item.PKID); if (parking != null) { model.ParkingName = parkings != null ? parking.PKName : string.Empty; BaseVillage village = villages.FirstOrDefault(p => p.VID == parking.VID); model.VillageName = village != null ? village.VName : string.Empty; } ParkCarType carType = carTypes.FirstOrDefault(p => p.CarTypeID == item.CarTypeID); if (carType != null) { model.CarTypeName = carType.CarTypeName; } model.StartTime = item.BeginDate; model.EndTime = item.EndDate; models.Add(model); } } return(models); }
public JsonResult EditVillage(BaseVillage model) { try { bool result = false; if (string.IsNullOrWhiteSpace(model.VID)) { model.ProxyNo = GuidGenerator.GetGuidString(); model.VID = GuidGenerator.GetGuidString(); result = VillageServices.Add(model); if (!result) { throw new MyException("添加小区信息失败"); } UpdateLoginUserVillageCache(model); return(Json(MyResult.Success("添加小区信息成功【如需查看或修改该小区信息,请对当前登录账号所在的作用域中勾选该小区】"))); } else { result = VillageServices.Update(model); if (!result) { throw new MyException("修改小区信息失败"); } UpdateLoginUserVillageCache(model); return(Json(MyResult.Success("修改小区信息成功"))); } } catch (MyException ex) { return(Json(MyResult.Error(ex.Message))); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "保存小区失败"); return(Json(MyResult.Error("保存小区失败"))); } }
public ActionResult SaveRecharge(decimal Amount) { try { BaseVillage village = VillageServices.QueryVillageByRecordId(SellerLoginUser.VID); if (village == null) { throw new MyException("获取小区信息失败"); } WX_ApiConfig config = WXApiConfigServices.QueryWXApiConfig(village.CPID); if (config == null) { ExceptionsServices.AddExceptionToDbAndTxt("WeiXin_XFJM", "获取微信配置信息失败", "单位编号:" + village.CPID, LogFrom.WeiXin); return(RedirectToAction("Index", "ErrorPrompt", new { message = "获取微信配置信息失败!" })); } if (!config.Status) { ExceptionsServices.AddExceptionToDbAndTxt("WeiXin_XFJM", "该车场暂停使用微信支付", "单位编号:" + village.CPID, LogFrom.WeiXin); return(RedirectToAction("Index", "ErrorPrompt", new { message = "该车场暂停使用微信支付!" })); } if (config.CompanyID != WeiXinUser.CompanyID) { ExceptionsServices.AddExceptionToDbAndTxt("WeiXin_XFJM", "微信用户所属公众号和当前公众号不匹配,不能支付", string.Format("支付单位:{0},微信用户单位:{1}", config.CompanyID, WeiXinUser.CompanyID), LogFrom.WeiXin); return(RedirectToAction("Index", "ErrorPrompt", new { message = "微信用户所属公众号和当前公众号不匹配,不能支付!" })); } if (CurrLoginWeiXinApiConfig == null || config.CompanyID != CurrLoginWeiXinApiConfig.CompanyID) { string loginCompanyId = CurrLoginWeiXinApiConfig != null ? CurrLoginWeiXinApiConfig.CompanyID : string.Empty; ExceptionsServices.AddExceptionToDbAndTxt("WeiXin_XFJM", "车场所属公众号和当前公众号不匹配,不能支付", string.Format("支付单位:{0},微信用户单位:{1}", config.CompanyID, loginCompanyId), LogFrom.WeiXin); return(RedirectToAction("Index", "ErrorPrompt", new { message = "车场所属公众号和当前公众号不匹配,不能支付!" })); } OnlineOrder order = new OnlineOrder(); order.OrderID = IdGenerator.Instance.GetId(); order.InOutID = SellerLoginUser.SellerID; order.PKID = SellerLoginUser.SellerID; order.Status = OnlineOrderStatus.WaitPay; order.PayAccount = WeiXinUser.OpenID; order.Payer = WeiXinUser.OpenID; order.PKName = SellerLoginUser.SellerName; order.Amount = Amount; order.PayeeUser = config.SystemName; order.PayeeAccount = config.PartnerId; order.OrderType = OnlineOrderType.SellerRecharge; order.PaymentChannel = PaymentChannel.WeiXinPay; order.PayeeChannel = PaymentChannel.WeiXinPay; order.AccountID = WeiXinUser.AccountID; order.Amount = Amount; order.CardId = WeiXinUser.AccountID; order.CompanyID = config.CompanyID; order.OrderTime = DateTime.Now; order.Remark = "商家充值"; bool result = OnlineOrderServices.Create(order); if (!result) { throw new MyException("充值失败[保存订单失败]"); } return(RedirectToAction("SellerRechargePayment", "WeiXinPayment", new { orderId = order.OrderID })); } catch (MyException ex) { return(PageAlert("Index", "SellerRecharge", new { RemindUserContent = ex.Message })); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("WeiXin_XFJM", "提交商家充值信息失败", ex, LogFrom.WeiXin); return(PageAlert("Index", "SellerRecharge", new { RemindUserContent = "提交商家充值信息失败" })); } }
internal static bool AddCompanyDefaultUserCS(BaseCompany company, BaseVillage village, DbOperator dbOperator, string systemmodelpath) { ISysUser factory = SysUserFactory.GetFactory(); if (factory.QuerySysUserByUserAccount(company.UserAccount) != null) { throw new MyException("用户名已存在"); } SysUser user = GetDefaultUserModel(company.CPID, company.UserAccount, company.UserPassword); bool result = factory.Add(user, dbOperator); if (!result) { throw new MyException("添加用户失败"); } //添加默认角色 SysRoles role = GetDefaultSysRolesModel(company.CPID); ISysRoles roleFactory = SysRolesFactory.GetFactory(); result = roleFactory.AddSysRole(role, dbOperator); if (!result) { throw new MyException("添加单位默认角色失败"); } //添加收费员角色 SysRoles role2 = GetDefaultBaRolesModel(company.CPID); ISysRoles roleFactory2 = SysRolesFactory.GetFactory(); result = roleFactory2.AddSysRole(role2, dbOperator); if (!result) { throw new MyException("添加单位收费角色失败"); } //添加默认角色模块授权失败 List <SysRoleAuthorize> roleAuthorizes2 = GetCompanyDefaultSFYRoleAuthorizeCS(role2.RecordID, systemmodelpath); ISysRoleAuthorize roleAuthorizesFactory2 = SysRoleAuthorizeFactory.GetFactory(); result = roleAuthorizesFactory2.Add(roleAuthorizes2, dbOperator); if (!result) { throw new MyException("添加单位收费角色失败"); } //添加默认角色模块授权失败 List <SysRoleAuthorize> roleAuthorizes = GetCompanyDefaultSysRoleAuthorizeCS(role.RecordID, systemmodelpath); ISysRoleAuthorize roleAuthorizesFactory = SysRoleAuthorizeFactory.GetFactory(); result = roleAuthorizesFactory.Add(roleAuthorizes, dbOperator); if (!result) { throw new MyException("添加单位默认角色失败"); } //添加作用域 SysScope scope = GetSystemDefaultSysScope(company.CPID); ISysScope scopeFactory = SysScopeFactory.GetFactory(); result = scopeFactory.Add(scope, dbOperator); if (!result) { throw new MyException("添加系统默认作用域失败"); } SysScopeAuthorize model = new SysScopeAuthorize(); model.ASID = scope.ASID; model.ASType = ASType.Village; model.CPID = company.CPID; model.DataStatus = 0; model.HaveUpdate = 3; model.LastUpdateTime = DateTime.Now; model.TagID = village.VID; model.ASDID = GuidGenerator.GetGuidString(); List <SysScopeAuthorize> list = new List <SysScopeAuthorize>(); list.Add(model); ISysScopeAuthorize scopeauthorize = SysScopeAuthorizeFactory.GetFactory(); result = scopeauthorize.Add(list, dbOperator); if (!result) { throw new MyException("添加默认用户 用户作用域失败"); } ISysUserRolesMapping roleMappingFactory = SysUserRolesMappingFactory.GetFactory(); List <SysUserRolesMapping> roleMapping = GetSysUserRolesMapping(user.RecordID, role.RecordID); result = roleMappingFactory.Add(roleMapping, dbOperator); if (!result) { throw new MyException("添加默认用户 用户授权角色失败"); } ISysUserScopeMapping userMappingFactory = SysUserScopeMappingFactory.GetFactory(); List <SysUserScopeMapping> scopeMapping = GetSysUserScopeMapping(user.RecordID, scope.ASID); result = userMappingFactory.Add(scopeMapping, dbOperator); if (!result) { throw new MyException("添加默认用户 用户授权作用域失败"); } return(result); }
/// <summary> /// 系统初始化默认单位CS /// </summary> public static bool InitSystemDefaultCompanyCS(string VName, string CPName, string userno, string pwd, string systemmodelpath) { try { ICompany factory = CompanyFactory.GetFactory(); using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { try { dbOperator.BeginTransaction(); BaseCompany compamy = GetCompanyModel(); compamy.CPName = CPName; compamy.UserAccount = userno; compamy.UserPassword = pwd; bool result = factory.Add(compamy, dbOperator); if (!result) { throw new MyException("添加默认单位失败"); } BaseVillage village = GetVillage(compamy.CPID); village.VName = VName; result = VillageServices.AddVillageDefaultUser(village, dbOperator); if (!result) { throw new MyException("添加默认小区失败"); } result = SysUserServices.AddCompanyDefaultUserCS(compamy, village, dbOperator, systemmodelpath); if (!result) { throw new MyException("添加默认用户失败"); } BaseParkinfo parkinfo = GetParkinfo(village.VID); result = ParkingServices.AddParkinfoDefault(parkinfo, dbOperator); if (!result) { throw new MyException("添加默认车场失败"); } dbOperator.CommitTransaction(); ParkArea area = GetParkArea(parkinfo.PKID); result = ParkAreaServices.AddDefualt(area); if (result) { ParkBox box = GetParkBox(area.AreaID); result = ParkBoxServices.AddDefault(box); if (result) { result = ParkGateServices.AddDefault(GetParkGate(box.BoxID, 1)); result = ParkGateServices.AddDefault(GetParkGate(box.BoxID, 2)); } } } catch (Exception ex) { dbOperator.RollbackTransaction(); throw; } } } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "添加系统默认单用户失败"); return(false); } return(true); }
public JsonResult GrantCarDerate(string vid, string qid, string sellerName, string derateName, int number) { try { if (number <= 0) { throw new MyException("发放优免券数量不正确"); } if (string.IsNullOrWhiteSpace(SystemDefaultConfig.SystemDomain)) { throw new MyException("获取系统域名失败"); } ParkDerateQRcode qrCode = ParkDerateQRcodeServices.QueryByRecordId(qid); if (qrCode == null) { throw new MyException("优免券规则不存在"); } ParkDerate derate = ParkDerateServices.Query(qrCode.DerateID); if (derate == null) { throw new MyException("获取优免规则失败"); } if (derate.DerateType == DerateType.SpecialTimePeriodPayment) { string errorMsg = string.Empty; ParkSeller seller = ParkSellerServices.GetSeller(derate.SellerID, out errorMsg); if (derate == null) { throw new MyException("获取优免规则失败"); } decimal totalAmount = qrCode.DerateValue * number; if ((seller.Creditline + seller.Balance) < totalAmount) { throw new MyException("商家余额不足"); } } BaseVillage village = VillageServices.QueryVillageByRecordId(vid); if (village == null) { throw new MyException("获取小区信息失败"); } string folderName = string.Format("{0}_{1}_{2}", sellerName, derateName, IdGenerator.Instance.GetId().ToString()); List <string> carDerateIds = new List <string>(); for (int i = 0; i < number; i++) { string carDerateId = GuidGenerator.GetGuidString(); string content = string.Format("{0}/QRCodeDerate/Index?vid={1}&qid={2}&did={3}&sign={4}", SystemDefaultConfig.SystemDomain, vid, qid, carDerateId, GetSignature(vid, qid, carDerateId)); string result = QRCodeServices.GenerateQRCode(village.CPID, content, 430, carDerateId, folderName); if (string.IsNullOrWhiteSpace(result)) { throw new MyException("创建二维码失败"); } carDerateIds.Add(carDerateId); } string filePath = string.Format("/Uploads/{0}", folderName); string zipFilePath = string.Format("{0}/{1}_{2}.zip", filePath, sellerName, derateName); string mapPath = Server.MapPath("~/"); ZipHelper.ZipFiles(string.Format("{0}/{1}", mapPath, filePath), string.Format("{0}/{1}", mapPath, zipFilePath)); if (carDerateIds.Count != number) { throw new MyException("二维码数量与待创建的数量不匹配"); } bool grantResult = ParkDerateQRcodeServices.GrantCarDerate(carDerateIds, zipFilePath, qid); if (!grantResult) { throw new MyException("发放券失败"); } return(Json(MyResult.Success("", zipFilePath))); } catch (MyException ex) { return(Json(MyResult.Error(ex.Message))); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "发放优免券失败"); return(Json(MyResult.Error("发放优免券失败"))); } }
public ActionResult DerateQRCode(string recordId) { try { ParkDerateQRcode derateQRcode = ParkDerateQRcodeServices.QueryByRecordId(recordId); if (derateQRcode == null) { throw new MyException("该二维码不存在"); } ParkDerate derate = ParkDerateServices.Query(derateQRcode.DerateID); if (derate == null) { throw new MyException("优免规则不存在"); } derateQRcode.DerateName = derate.Name; ParkSeller seller = ParkSellerServices.QueryBySellerId(derate.SellerID); if (seller == null) { throw new MyException("商家不存在"); } derateQRcode.SellerName = seller.SellerName; if (string.IsNullOrWhiteSpace(SystemDefaultConfig.SystemDomain)) { throw new MyException("获取系统域名失败"); } BaseVillage village = VillageServices.QueryVillageByRecordId(seller.VID); if (village == null) { throw new MyException("获取小区信息失败"); } string content = string.Format("{0}/QRCodeDerate/Index?vid={1}&qid={2}&sign={3}", SystemDefaultConfig.SystemDomain, seller.VID, recordId, GetSignature(seller.VID, recordId)); using (System.Drawing.Image image = QRCodeServices.GenerateQRCode(content, 430)) { ImageFormat format = image.RawFormat; byte[] buffer; using (MemoryStream ms = new MemoryStream()) { image.Save(ms, ImageFormat.Jpeg); buffer = new byte[ms.Length]; ms.Seek(0, SeekOrigin.Begin); ms.Read(buffer, 0, buffer.Length); } derateQRcode.ImageData = System.Convert.ToBase64String(buffer); } ViewBag.CompanyID = village.CPID; ViewBag.ShareAction = "XFJMDerateQRCode/DerateQRCode?recordId=" + recordId; return(View(derateQRcode)); } catch (MyException ex) { return(RedirectToAction("Index", "XFJMDerateQRCode", new { RemindUserContent = ex.Message })); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "微信获取二维码失败", LogFrom.WeiXin); return(RedirectToAction("Index", "XFJMDerateQRCode", new { RemindUserContent = "获取二维码失败" })); } }
private static void villageTest() { BaseVillage testVillage = new BaseVillage(); testVillage.VillageName = "Test Town"; List <IStar> stars = new List <IStar>(); var david = new BaseStar(); david.Name = "David"; var passionCats = new BasePassion(); passionCats.PassionValue = 10; passionCats.PassionName = "Cats"; passionCats.Thresholds.Add(new BaseThreshold("Cat-like affinity", "Your burgeoning love for cats has allowed for this bonus to manifest.", 10)); passionCats.Thresholds.Add(new BaseThreshold("Cat-like reflexes", "Your reflexes are no longer like that of a dead cat. More like a live one. Or something like that.", 20)); passionCats.Thresholds.Add(new BaseThreshold("Dog-like affinity", "Your burgeoning love for dogs has brough this burden on you.", -10)); passionCats.Likes.Add(PassionValue.Cats); passionCats.Hates.Add(PassionValue.Dogs); david.Passions.Add(passionCats); //-------------------------------untested----------------------------------------------------// var trent = new BaseStar(); trent.Name = "Trent"; var passionNoodles = new BasePassion(); passionNoodles.PassionName = "Noodles"; passionNoodles.PassionValue = 15; passionNoodles.Thresholds.Add(new BaseThreshold("Noodle liker", "Your love of noodles is beginning to become hard to contain", 10)); passionNoodles.Thresholds.Add(new BaseThreshold("Noodle connoisseur", "Only the greatest of noodles can satiate your tastes", 50)); passionNoodles.Thresholds.Add(new BaseThreshold("Rice lover", "Not a sex thing... probably", -25)); trent.Passions.Add(passionNoodles); var testBoy = new BaseStar(); testBoy.Name = "Testy"; var passionTest = new BasePassion(); passionTest.PassionName = "Testing"; passionTest.PassionValue = 10; passionTest.Thresholds.Add(new BaseThreshold("Testing affinity", "You can test like a tester", 5)); passionTest.Thresholds.Add(new BaseThreshold("Testing Mastery", "Testing with the best of them", 50)); testBoy.Passions.Add(passionTest); // actual village testing // PassionManager seems like a good name? var passionManager = new ActionListener(); passionManager.ManagedPassions.Add(passionCats); passionManager.ManagedPassions.Add(passionNoodles); passionManager.ManagedPassions.Add(passionTest); // Add the stars, and shoot for them testVillage.Stars.Add(trent); testVillage.Stars.Add(david); testVillage.Stars.Add(testBoy); Console.WriteLine("Village setup complete"); Console.WriteLine("Village before testing"); Console.WriteLine(testVillage.ToString()); // Now do some stuff to the stars. passionManager.FireEvent(PassionValue.Cats, 20); Console.WriteLine("Village after testing"); Console.WriteLine(testVillage); Console.ReadLine(); }