public void Current_CurrentHttpContextIsNull_ReturnsNull() { HttpContext.Current = null; var httpContextHandler = new HttpContextHandler(); Assert.IsNull(httpContextHandler.Current); }
public void Current_HandlerCreatedWithDefaultConstructor_CurrentRequestStoresCurrentContext() { HttpContext.Current = new HttpContext(new HttpRequest(string.Empty, "http://anyuri.org/", string.Empty), new HttpResponse(null)); var httpContextHandler = new HttpContextHandler(); Assert.AreEqual(httpContextHandler.Current, HttpContext.Current.Items[httpContextHandler]); }
public int UpdateData(AdModel adInfo) { try { GenerateDal.BeginTransaction(); string userClientId = HttpContextHandler.GetHeaderObj("UserClientId").ToString(); if (string.IsNullOrEmpty(userClientId)) { return(0); } adInfo.ClientId = userClientId; GenerateDal.Update(CommonSqlKey.UpdateAd, adInfo); new AdRelationService().DeleteData(adInfo.Id.ToString()); if (adInfo.Reources != null && adInfo.Reources.Count > 0) { foreach (var item in adInfo.Reources) { var tmpInfo = new AdRelationModel(); tmpInfo.AdId = adInfo.Id; tmpInfo.SourceId = item.PicId; new AdRelationService().PostAdRelationData(tmpInfo); } } GenerateDal.CommitTransaction(); return(1); } catch (Exception e) { GenerateDal.RollBack(); return(0); } }
public void Current_HandlerCreatedWithDefaultConstructor_CurrentIsAHttpContextWrapper() { HttpContext.Current = new HttpContext(new HttpRequest(string.Empty, "http://anyuri.org/", string.Empty), new HttpResponse(null)); var httpContextHandler = new HttpContextHandler(); Assert.IsInstanceOf<HttpContextWrapper>(httpContextHandler.Current); }
//取客户等级 public List <DicModel> GetRank(string id) { string sts = HttpContextHandler.GetHeaderObj("Sts").ToString(); if (string.IsNullOrEmpty(sts)) { return(null); } if (string.IsNullOrEmpty(sts)) { return(null); } if (sts == "100") { var rankList = GetDic(id); var result = from m in rankList where m.Value != "0" select m; return(result.ToList <DicModel>()); } else { string userAccessId = HttpContextHandler.GetHeaderObj("UerAccessId").ToString(); var dic = new Dictionary <string, object>(); dic.Add("Id", id); dic.Add("DmsId", id); return(GenerateDal.Load <DicModel>(CommonSqlKey.GetRank, dic)); } }
public List <WebSettingModel> GetAll(WebSettingModel webSettingInfo) { string userClientId = string.Empty; if (string.IsNullOrEmpty(webSettingInfo.ClientId)) { userClientId = HttpContextHandler.GetHeaderObj("UserClientId").ToString(); } else { userClientId = webSettingInfo.ClientId; } if (string.IsNullOrEmpty(userClientId)) { return(null); } var conditions = new List <Condition>(); conditions.Add(new Condition { LeftBrace = " AND ", ParamName = "ClientId", DbColumnName = "client_id", ParamValue = userClientId, Operation = ConditionOperate.Equal, RightBrace = " ", Logic = "" }); return(GenerateDal.LoadByConditions <WebSettingModel>(CommonSqlKey.GetWechatInfo, conditions)); }
public int GetCount(CashEquipmentModel cashEquipmentInfo) { var result = 0; string userClientId = HttpContextHandler.GetHeaderObj("UserClientId").ToString(); if (string.IsNullOrEmpty(userClientId)) { return(0); } var conditions = new List <Condition>(); string clientIds = new CommonService().GetClientIds(userClientId); if (clientIds.Contains("self")) { clientIds = "'" + clientIds.Replace(",", "','") + "'"; } conditions.Add(new Condition { LeftBrace = " AND ", ParamName = "ClientId", DbColumnName = "b.client_id", ParamValue = clientIds, Operation = ConditionOperate.INWithNoPara, RightBrace = "", Logic = "" }); result = GenerateDal.CountByConditions(CommonSqlKey.GetCashEquipmentCount, conditions); return(result); }
public int UpdateData(ActivityModel activityInfo) { try { GenerateDal.BeginTransaction(); activityInfo.CreateDate = DateTime.Now; string userClientId = activityInfo.ClientId; if (string.IsNullOrEmpty(userClientId)) { userClientId = HttpContextHandler.GetHeaderObj("UserClientId").ToString(); } string userAccount = HttpContextHandler.GetHeaderObj("UserAccount").ToString(); activityInfo.ClientId = userClientId; activityInfo.Creator = userAccount; new ActivityRelationService().DeleteData(activityInfo.Id); if (activityInfo.listActivityPrivilege != null && activityInfo.listActivityPrivilege.Count > 0) { foreach (ActivityPrivilegeRelationModel relationInfo in activityInfo.listActivityPrivilege) { relationInfo.ActivityId = activityInfo.Id; new ActivityRelationService().PostData(relationInfo); } } GenerateDal.Update(CommonSqlKey.UpdateActivity, activityInfo); GenerateDal.CommitTransaction(); return(1); } catch (Exception ex) { GenerateDal.RollBack(); return(0); } }
public List <TotalMoneyModel> GetAll(TotalMoneyModel totalMoneyInfo) { string userClientId = HttpContextHandler.GetHeaderObj("UserClientId").ToString(); if (string.IsNullOrEmpty(userClientId)) { return(null); } var userStatus = HttpContextHandler.GetHeaderObj("Sts").ToString(); if (string.IsNullOrEmpty(userStatus)) { return(null); } var dics = new Dictionary <string, object>(); if (userStatus == "100" || userStatus == "99") { dics.Add("ClientId", "self"); } else { dics.Add("ClientId", userClientId); } return(GenerateDal.Load <TotalMoneyModel>(CommonSqlKey.GetTotalMoneyByClient, dics)); }
public List <CashEquipmentModel> GetAll(CashEquipmentModel cashEquipmentInfo) { string userClientId = HttpContextHandler.GetHeaderObj("UserClientId").ToString(); if (string.IsNullOrEmpty(userClientId)) { return(null); } var conditions = new List <Condition>(); string clientIds = new CommonService().GetClientIds(userClientId); if (clientIds.Contains("self")) { clientIds = "'" + clientIds.Replace(",", "','") + "'"; } conditions.Add(new Condition { LeftBrace = " AND ", ParamName = "ClientId", DbColumnName = "b.client_id", ParamValue = clientIds, Operation = ConditionOperate.INWithNoPara, RightBrace = "", Logic = "" }); conditions.AddRange(CreatePaginConditions(cashEquipmentInfo.PageIndex, cashEquipmentInfo.PageSize)); return(GenerateDal.LoadByConditions <CashEquipmentModel>(CommonSqlKey.GetCashEquipmentList, conditions)); }
public void Current_HandlerCreatedWithDefaultConstructor_WrapperCreatedWithCurrentContext() { HttpContext.Current = new HttpContext(new HttpRequest(string.Empty, "http://anyuri.org/", string.Empty), new HttpResponse(null)); var httpContextHandler = new HttpContextHandler(); Assert.AreEqual("http://anyuri.org/", httpContextHandler.Current.Request.Url.OriginalString); }
/// <summary> /// 取机器各个状态数 /// </summary> /// <returns></returns> public DataTable GetTotalMachineCount() { var clientId = HttpContextHandler.GetHeaderObj("UserClientId").ToString(); if (string.IsNullOrEmpty(clientId)) { return(null); } var conditions = new List <Condition>(); if (string.IsNullOrEmpty(clientId.ToString())) { return(new DataTable()); } conditions.Add(new Condition { LeftBrace = "", ParamName = "ClientId", DbColumnName = "", ParamValue = clientId, Operation = ConditionOperate.None, RightBrace = "", Logic = "" }); // 返回的三个数字按顺序分别代表未启用 离线 在线 return(GenerateDal.LoadDataTableByConditions(CommonSqlKey.GetMachineCountWithStatus, conditions)); }
public int GetCount(CustomerModel customerInfo) { var result = 0; string userStatus = HttpContextHandler.GetHeaderObj("Sts").ToString(); if (string.IsNullOrEmpty(userStatus)) { return(0); } var userClientId = HttpContextHandler.GetHeaderObj("UserClientId").ToString(); if (string.IsNullOrEmpty(userClientId)) { return(0); } var dics = new Dictionary <string, object>(); dics.Add("ClientName", customerInfo.ClientName + "%"); if (userStatus == "100" || userStatus == "99") { dics.Add("ClientId", "self"); } else { dics.Add("ClientId", userClientId); } result = GenerateDal.CountByDictionary <CustomerModel>(CommonSqlKey.GetCustomerCount, dics); return(result); }
/// <summary> /// 新增/修改会员信息 /// </summary> /// <param name="memberInfo"></param> /// <returns></returns> public int PostData(MachineConfigModel machineConfigInfo) { try { GenerateDal.BeginTransaction(); if (!string.IsNullOrEmpty(machineConfigInfo.MachineId)) { DeleteData(machineConfigInfo.MachineId); } string userAccount = HttpContextHandler.GetHeaderObj("UserAccount").ToString(); machineConfigInfo.UpdateDate = DateTime.Now; machineConfigInfo.Updater = userAccount; GenerateDal.Create(machineConfigInfo); //需要插入机器下行表中待机器取 MachineService mc = new MachineService(); mc.PostToMachine(machineConfigInfo.MachineId, "t"); GenerateDal.CommitTransaction(); //操作日志 OperationLogService operationService = new OperationLogService(); operationService.PostData(new OperationLogModel() { MachineId = machineConfigInfo.MachineId, OptContent = "机器配置添加" }); return(1); } catch (Exception e) { GenerateDal.RollBack(); return(0); } }
public int GetCount(ProductListModel productListInfo) { var result = 0; string userClientId = HttpContextHandler.GetHeaderObj("UserClientId").ToString(); if (string.IsNullOrEmpty(userClientId)) { return(0); } string clientIds = new CommonService().GetClientIds(userClientId); if (clientIds.Contains("self")) { clientIds = "'" + clientIds.Replace(",", "','") + "'"; } var conditions = new List <Condition>(); conditions.Add(new Condition { LeftBrace = " AND ", ParamName = "ClientId", DbColumnName = "client_id", ParamValue = clientIds, Operation = ConditionOperate.INWithNoPara, RightBrace = " ", Logic = "" }); if (!string.IsNullOrEmpty(productListInfo.WaresName)) { conditions.Add(new Condition { LeftBrace = " AND ", ParamName = "WaresName", DbColumnName = "wares_name", ParamValue = "%" + productListInfo.WaresName + "%", Operation = ConditionOperate.Like, RightBrace = "", Logic = "" }); } if (!string.IsNullOrEmpty(productListInfo.WaresTypeId)) { conditions.Add(new Condition { LeftBrace = " AND ", ParamName = "WaresTypeId", DbColumnName = "wares_type_id", ParamValue = productListInfo.WaresTypeId, Operation = ConditionOperate.Equal, RightBrace = "", Logic = "" }); } result = GenerateDal.CountByConditions(CommonSqlKey.GetProductListAllCount, conditions); return(result); }
// 取用户树形结构当字典 public List <CommonDic> GetUserDic() { string userStatus = HttpContextHandler.GetHeaderObj("Sts").ToString(); if (string.IsNullOrEmpty(userStatus)) { return(null); } var clientId = HttpContextHandler.GetHeaderObj("UserClientId").ToString(); if (string.IsNullOrEmpty(clientId)) { return(null); } var conditions = new List <Condition>(); if (userStatus == "100" || userStatus == "99") { } else { conditions.Add(new Condition { LeftBrace = " AND ", ParamName = "ClientFatherId", DbColumnName = "client_father_id", ParamValue = clientId, Operation = ConditionOperate.Equal, RightBrace = "", Logic = "" }); } return(GenerateDal.LoadByConditions <CommonDic>(CommonSqlKey.GetClientDic, conditions)); }
/// <summary> /// 新增/修改会员信息 /// </summary> /// <param name="memberInfo"></param> /// <returns></returns> public int PostData(ConfigModel configInfo) { int result; string userClientId = HttpContextHandler.GetHeaderObj("UserClientId").ToString(); if (string.IsNullOrEmpty(userClientId)) { return(0); } if (string.IsNullOrEmpty(configInfo.ClientId)) { configInfo.ClientId = userClientId; } //configInfo.WxSslcertPath = "cert/"+configInfo.WxMchId+"/apiclient_cert.p12"; //configInfo.WxSslcertPassword = configInfo.WxMchId; configInfo.WxMchId = configInfo.WxMchId.Trim(); result = GenerateDal.Create(configInfo); //操作日志 OperationLogService operationService = new OperationLogService(); operationService.PostData(new OperationLogModel() { Remark = configInfo.ClientId, OptContent = "添加支付配置" }); return(result); }
public void Current_HandlerCreatedWithDefaultConstructor_CurrentIsAHttpContextWrapper() { HttpContext.Current = new HttpContext(new HttpRequest(string.Empty, "http://anyuri.org/", string.Empty), new HttpResponse(null)); var httpContextHandler = new HttpContextHandler(); Assert.IsInstanceOf <HttpContextWrapper>(httpContextHandler.Current); }
public int UpdateData(WebSettingModel webSettingInfo) { if (string.IsNullOrEmpty(webSettingInfo.ClientId)) { webSettingInfo.ClientId = HttpContextHandler.GetHeaderObj("UserClientId").ToString(); } return(GenerateDal.Update(CommonSqlKey.UpdateWechatInfo, webSettingInfo)); }
public void Constructor_SendInAHttpContextFactoryMethod_CurrentContextCreatedByFactoryMethod() { HttpContext.Current = new HttpContext(new HttpRequest(string.Empty, "http://anyuri.org/", string.Empty), new HttpResponse(null)); var context = A.Fake<HttpContextBase>(); var httpContextHandler = new HttpContextHandler(() => context); Assert.AreSame(context, httpContextHandler.Current); }
public int PostData(WebSettingModel webSettingInfo) { if (string.IsNullOrEmpty(webSettingInfo.ClientId)) { webSettingInfo.ClientId = HttpContextHandler.GetHeaderObj("UserClientId").ToString(); } webSettingInfo.Id = Guid.NewGuid().ToString(); return(GenerateDal.Create <WebSettingModel>(webSettingInfo)); }
public void Constructor_SendInAHttpContextFactoryMethod_CurrentContextCreatedByFactoryMethod() { HttpContext.Current = new HttpContext(new HttpRequest(string.Empty, "http://anyuri.org/", string.Empty), new HttpResponse(null)); var context = A.Fake <HttpContextBase>(); var httpContextHandler = new HttpContextHandler(() => context); Assert.AreSame(context, httpContextHandler.Current); }
public int UpdateData(ProductListModel productListInfo) { productListInfo.UpdateDate = DateTime.Now; string userAccount = HttpContextHandler.GetHeaderObj("UserAccount").ToString(); productListInfo.Creator = userAccount; productListInfo.UpdateDate = DateTime.Now; return(GenerateDal.Update(CommonSqlKey.UpdateProductList, productListInfo)); }
public List <CommonDic> GetMachines(CommonDic commonDic, int pageIndex, int pageSize) { string clientId = HttpContextHandler.GetHeaderObj("UserClientId").ToString(); if (string.IsNullOrEmpty(clientId)) { return(null); } var conditions = new List <Condition>(); string clientIds = new CommonService().GetClientIds(clientId); if (clientIds.Contains("self")) { clientIds = "'" + clientIds.Replace(",", "','") + "'"; } conditions.Add(new Condition { LeftBrace = " AND ", ParamName = "ClientId", DbColumnName = "client_id", ParamValue = clientIds, Operation = ConditionOperate.INWithNoPara, RightBrace = "", Logic = "" }); if (!string.IsNullOrEmpty(commonDic.Name)) { conditions.Add(new Condition { LeftBrace = " AND ", ParamName = "MachineId", DbColumnName = " machine_id ", ParamValue = "%" + commonDic.Name + "%", Operation = ConditionOperate.Like, RightBrace = "", Logic = "" }); conditions.Add(new Condition { LeftBrace = " Or ", ParamName = "Remark", DbColumnName = " remark ", ParamValue = "%" + commonDic.Name + "%", Operation = ConditionOperate.Like, RightBrace = "", Logic = "" }); } conditions.AddRange(CreatePaginConditions(pageIndex, pageSize)); List <CommonDic> machines = GenerateDal.LoadByConditions <CommonDic>(CommonSqlKey.GetMachineDic, conditions); return(machines); }
/// <summary> /// 取支付笔数 /// </summary> /// <returns></returns> public List <ClassModel> GetPayNumbers(string clientId) { string userClientId = clientId; if (string.IsNullOrEmpty(userClientId)) { userClientId = HttpContextHandler.GetHeaderObj("UserClientId").ToString(); } if (string.IsNullOrEmpty(userClientId)) { return(null); } var result = new List <ClassModel>(); var conditions = new List <Condition>(); string clientIds = new CommonService().GetClientIds(userClientId); if (clientIds.Contains("self")) { clientIds = "'" + clientIds.Replace(",", "','") + "'"; } conditions.Add(new Condition { LeftBrace = " AND (", ParamName = "ClientIdA", DbColumnName = "b.client_id", ParamValue = userClientId, Operation = ConditionOperate.Equal, RightBrace = "", Logic = "" }); conditions.Add(new Condition { LeftBrace = " OR ", ParamName = "ClientIdB", DbColumnName = "b.client_id", ParamValue = clientIds, Operation = ConditionOperate.INWithNoPara, RightBrace = " ) ", Logic = "" }); conditions.Add(new Condition { LeftBrace = " ", ParamName = "", DbColumnName = "", ParamValue = "a.trade_status", Operation = ConditionOperate.GroupBy, RightBrace = "", Logic = "" }); result = GenerateDal.LoadByConditions <ClassModel>(CommonSqlKey.GetPayNumbers, conditions); return(result); }
public ResultObj <int> ClearLoginCache() { string userClientId = HttpContextHandler.GetHeaderObj("UserClientId").ToString(); if (string.IsNullOrEmpty(userClientId)) { return(Content(0)); } WebCacheHelper.ClearIds(userClientId); return(Content(1)); }
public int UpdateData(PictureModel pictureInfo) { string userClientId = HttpContextHandler.GetHeaderObj("UserClientId").ToString(); if (string.IsNullOrEmpty(userClientId)) { return(0); } pictureInfo.ClientId = userClientId; return(GenerateDal.Update(CommonSqlKey.UpdatePictureList, pictureInfo)); }
/// <summary> /// 新增/修改会员信息 /// </summary> /// <param name="memberInfo"></param> /// <returns></returns> public int PostData(ProductTypeModel productTypeInfo) { int result; string userClientId = HttpContextHandler.GetHeaderObj("UserClientId").ToString(); productTypeInfo.WaresTypeId = Guid.NewGuid().ToString(); productTypeInfo.ClientId = userClientId; result = GenerateDal.Create(productTypeInfo); return(result); }
//取不过期的优惠券作为字典 public List <CommonDic> GetNotExpirePrivilegeDic(string clientId) { if (string.IsNullOrEmpty(clientId)) { clientId = HttpContextHandler.GetHeaderObj("UserClientId").ToString(); } var conditions = new List <Condition>(); conditions.Add(new Condition { LeftBrace = " AND ", ParamName = "ClientId", DbColumnName = "client_id", ParamValue = clientId, Operation = ConditionOperate.Equal, RightBrace = "", Logic = "" }); conditions.Add(new Condition { LeftBrace = " AND (", ParamName = "ExpireTime", DbColumnName = "expire_time", ParamValue = DateTime.Now, Operation = ConditionOperate.GreaterThan, RightBrace = "", Logic = " OR " }); conditions.Add(new Condition { LeftBrace = "", ParamName = "TimeRule", DbColumnName = "time_rule", ParamValue = "", Operation = ConditionOperate.NotNull, RightBrace = "", Logic = " OR " }); conditions.Add(new Condition { LeftBrace = "", ParamName = "ExpireTime1", DbColumnName = "expire_time", ParamValue = "", Operation = ConditionOperate.Null, RightBrace = ")", Logic = "" }); return(GenerateDal.LoadByConditions <CommonDic>(CommonSqlKey.GetNotExpirePrivilegeDic, conditions)); }
/// <summary> /// 新增/修改会员信息 /// </summary> /// <param name="memberInfo"></param> /// <returns></returns> public int PostData(PrivilegeModel privilegeInfo) { int result; string userClientId = HttpContextHandler.GetHeaderObj("UserClientId").ToString(); privilegeInfo.ClientId = userClientId; privilegeInfo.CreateDate = DateTime.Now; privilegeInfo.PrivilegeId = Guid.NewGuid().ToString(); result = GenerateDal.Create(privilegeInfo); return(result); }
/// <summary> /// 删除用户 /// </summary> /// <returns></returns> public int DeleteData(string id) { string userClientId = HttpContextHandler.GetHeaderObj("UserClientId").ToString(); if (string.IsNullOrEmpty(userClientId)) { return(0); } try { GenerateDal.BeginTransaction(); // 删除有子客户的客户 将子客户父级更新为删除对象的父级 string fatherId = string.Empty; var fatherClientInfo = GenerateDal.Get <CustomerModel>(id); if (fatherClientInfo != null) { fatherId = fatherClientInfo.ClientFatherId; } CustomerModel customerInfo = new CustomerModel(); customerInfo.Id = id; int delResult = GenerateDal.Delete <CustomerModel>(CommonSqlKey.DeleteCustomer, customerInfo); if (delResult > 0) { CustomerModel updInfo = new CustomerModel(); updInfo.ClientFatherId = fatherId; updInfo.Id = id; string userAccount = HttpContextHandler.GetHeaderObj("UserAccount").ToString(); if (!string.IsNullOrEmpty(userAccount)) { updInfo.Updater = userAccount; } GenerateDal.Update(CommonSqlKey.UpdateChildCustomer, updInfo); } //操作日志 OperationLogService operationService = new OperationLogService(); operationService.PostData(new OperationLogModel() { Remark = customerInfo.Id, OptContent = "删除客户" }); GenerateDal.CommitTransaction(); WebCacheHelper.ClearIds(userClientId); return(1); } catch (Exception ee) { GenerateDal.RollBack(); return(0); } }
public int UpdateData(MachineListModel machineListInfo) { machineListInfo.UpdateDate = DateTime.Now; string userAccount = HttpContextHandler.GetHeaderObj("UserAccount").ToString(); machineListInfo.Updater = userAccount; //操作日志 OperationLogService operationService = new OperationLogService(); operationService.PostData(new OperationLogModel() { MachineId = machineListInfo.MachineId, OptContent = "更新机器" }); return(GenerateDal.Update(CommonSqlKey.UpdateMachineList, machineListInfo)); }