private void button2_Click(object sender, EventArgs e) { if (this.meter == null) { return; } List <IoT_Meter> list = new List <IoT_Meter>(); FormValveControlcs frm = new FormValveControlcs(); if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { WCFServiceProxy <IValveControl> _valveProxy = new WCFServiceProxy <IValveControl>(); string result = _valveProxy.getChannel.TurnOn(this.meter, frm.Reason, "test"); _valveProxy.CloseChannel(); if (result == "") { MessageBox.Show("开阀阀任务下发成功"); } else { MessageBox.Show("开阀任务下发失败,原因:" + result); } } }
private void btnQuery_Click(object sender, EventArgs e) { WCFServiceProxy <ITaskManage> _iTaskManageProxy = new WCFServiceProxy <ITaskManage>(); try { List <IoT_Meter> list = _iTaskManageProxy.getChannel.getIotMeters(this.textBox1.Text.Trim(), this.textBox2.Text.Trim()); _iTaskManageProxy.CloseChannel(); if (list != null) { foreach (IoT_Meter m in list) { this.Simulatorlist.Add(new Simulator() { 择 = false, 表号 = m.MeterNo.Trim(), 户号 = m.UserID, 表类型 = m.MeterType }); } this.bindingSource1.DataSource = this.Simulatorlist; this.dataGridView1.DataSource = this.bindingSource1; this.dataGridView1.Refresh(); } } catch { } }
public static string GetMenuListToJson(string companyID) { List <DefineMenu> list = new List <DefineMenu>(); WCFServiceProxy <IOperRightManage> proxy = null; try { proxy = new WCFServiceProxy <IOperRightManage>(); list = proxy.getChannel.LoadCompanyDefineMenu(companyID); list = list.Where(p => p.Type == "00" || p.Type == "01" || p.Type == "03").ToList(); } catch { return(string.Empty); } finally { if (proxy != null) { proxy.CloseChannel(); } } StringBuilder Json = new StringBuilder(); if (list != null && list.Count > 0) { foreach (DefineMenu p in list) { Json.Append(","); Json.Append(p.MenuCode); } } Json.Append(","); return(Json.ToString()); }
public void SendMessage(MessageInfo message) { WCFServiceProxy <IOneNetService> proxy = null; try { proxy = new WCFServiceProxy <IOneNetService>(); proxy.getChannel.OutPutLog(message.Mac, message.MsgContent); // raw content as string proxy.CloseChannel(); } catch (Exception e) { Debug.Print(e.Message); } }
public String Charge(string userId, string companyId, decimal money) { string result = ""; WCFServiceProxy <IUserManage> proxyUser = new WCFServiceProxy <IUserManage>(); WCFServiceProxy <IMeterTopUp> _valveProxy = new WCFServiceProxy <IMeterTopUp>(); try { string meterNo = proxyUser.getChannel.GetUserMeterByUserId(userId, companyId); result = _valveProxy.getChannel.Topup(meterNo.Trim(), money, TopUpType.接口, "", "", new IoT_MeterTopUp()); } catch (Exception e) { } finally { proxyUser.CloseChannel(); _valveProxy.CloseChannel(); } return(result); }
public String GetGasUserByUserId(string userId, string companyId) { OlbGasUser userInfo = null; WCFServiceProxy <ICommonSearch <View_UserMeter> > proxy = null; try { proxy = new WCFServiceProxy <ICommonSearch <View_UserMeter> >(); SearchCondition sCondition = new SearchCondition() { TBName = "View_UserMeter", TFieldKey = "UserID", TPageSize = 1, TPageCurrent = 1, TFieldOrder = "UserID ASC", TWhere = " 1=1 AND CompanyID='" + companyId + "' AND UserID='" + userId + "' " }; List <View_UserMeter> list = proxy.getChannel.getListBySearchCondition(ref sCondition); if (list.Count > 0) { userInfo = new OlbGasUser(); userInfo.UserID = list[0].UserID; userInfo.UserName = list[0].UserName; userInfo.Address = list[0].Address; userInfo.CompanyID = list[0].CompanyID; userInfo.Balance = (decimal)list[0].RemainingAmount; userInfo.MeterNo = list[0].MeterNo; userInfo.MeterType = int.Parse(list[0].MeterType); } } catch (Exception ex) { } finally { if (proxy != null) { proxy.CloseChannel(); } } return(JsToJson.SerializeToJsonString(userInfo)); }
public override void DoNoLoginHandlerWork(HttpContext context) { Message jsonMessage = new Message(); //获取操作类型AType:ADD,EDIT,DELETE,QUERY WCFServiceProxy <ILoginerManage> proxyLoginer; string AjaxType = context.Request.QueryString["AType"] == null ? string.Empty : context.Request.QueryString["AType"].ToString().ToUpper(); switch (AjaxType) { case "USERLOGIN": jsonMessage = UserLogin(context); break; case "USERLOGINOUT": proxyLoginer = new WCFServiceProxy <ILoginerManage>(); if (context.Session["LoginCompanyOperator"] != null) { context.Session.Remove("LoginCompanyOperator"); } string webCookie = context.Session.SessionID.ToString(); try { jsonMessage = proxyLoginer.getChannel.UnLRegisterClientByMd5Cookie(Md5.GetMd5(webCookie)); } catch { } finally { proxyLoginer.CloseChannel(); } break; default: jsonMessage = new Message() { Result = false, TxtMessage = "操作未定义。" }; break; } context.Response.Write(JSon.TToJson <Message>(jsonMessage)); }
private void button6_Click(object sender, EventArgs e) { //充值操作 FormTopUp topup = new FormTopUp(); if (topup.ShowDialog() == System.Windows.Forms.DialogResult.OK) { WCFServiceProxy <IMeterTopUp> _valveProxy = new WCFServiceProxy <IMeterTopUp>(); string result = _valveProxy.getChannel.Topup(this.meter.MeterNo.Trim(), topup.topUp, TopUpType.本地营业厅, "", "", new IoT_MeterTopUp()); _valveProxy.CloseChannel(); if (result == "") { MessageBox.Show("充值任务下发成功"); } else { MessageBox.Show("充值任务下发失败,原因:" + result); } } }
void GetLoginer(HttpContext context) { if (context.Session["LoginCompanyOperator"] == null) { //查询数据中心记录的登录者信息 WCFServiceProxy <ILoginerManage> proxy = null; try { proxy = new WCFServiceProxy <ILoginerManage>(); string webCookie = context.Session.SessionID.ToString(); CompanyOperator dCLoginer = null; dCLoginer = proxy.getChannel.GetLoginerByMd5Cookie(Md5.GetMd5(webCookie)); if (dCLoginer != null) { dCLoginer.Pwd = string.Empty; context.Session["LoginCompanyOperator"] = dCLoginer; } else { if (context.Request.Form["NO_COOKIE_SessionId"] != null && context.Request.Form["NO_COOKIE_SessionId"].ToString() != string.Empty) { webCookie = context.Request.Form["NO_COOKIE_SessionId"].ToString(); dCLoginer = proxy.getChannel.GetLoginerByMd5Cookie(webCookie); if (dCLoginer != null) { dCLoginer.Pwd = string.Empty; context.Session["LoginCompanyOperator"] = dCLoginer; } } } } catch { } finally { if (proxy != null) { proxy.CloseChannel(); } } } }
public T GetFirstTModel(ref SearchCondition sCondition) { List <T> list = new List <T>(); WCFServiceProxy <ICommonSearch <T> > proxy = null; try { proxy = new WCFServiceProxy <ICommonSearch <T> >(); list = proxy.getChannel.getListBySearchCondition(ref sCondition); } catch { } finally { if (proxy != null) { proxy.CloseChannel(); } } return(list.Count > 0 ? list[0] : null); }
public static string GetHidMenuCode(CompanyOperator info) { string result = string.Empty; WCFServiceProxy <IOperRightManage> proxy = null; try { proxy = new WCFServiceProxy <IOperRightManage>(); result = proxy.getChannel.LoadHiddenMenuCode(info); } catch { return(string.Empty); } finally { if (proxy != null) { proxy.CloseChannel(); } } return(result); }
public static string GetCompanyRightMenuCode(string companyID, string rightCode) { string result = string.Empty; WCFServiceProxy <IOperRightManage> proxy = null; try { proxy = new WCFServiceProxy <IOperRightManage>(); result = proxy.getChannel.LoadCompanyDefineRightMenu(companyID, rightCode); } catch { return(string.Empty); } finally { if (proxy != null) { proxy.CloseChannel(); } } return(result); }
public static bool CheckMenuCode(CompanyOperator info, string menuCode) { bool result = false; WCFServiceProxy <IOperRightManage> proxy = null; try { proxy = new WCFServiceProxy <IOperRightManage>(); result = proxy.getChannel.CheckMenuCode(info, menuCode); } catch { result = false; } finally { if (proxy != null) { proxy.CloseChannel(); } } return(result); }
public String GetGasUserBill(string userId, string companyId, string month) { OlbGasFeeBill gasFeeBill = null; WCFServiceProxy <IChaoBiao> proxy = null; try { proxy = new WCFServiceProxy <IChaoBiao>(); View_UserMeterHistory thisRecord = proxy.getChannel.GetMonthLastRecord(userId, companyId, month); string thisMonth = month + "-01"; string lastMonth = Convert.ToDateTime(thisMonth).AddMonths(-1).ToString("yyyy-MM"); View_UserMeterHistory lastRecord = proxy.getChannel.GetMonthLastRecord(userId, companyId, lastMonth); if (thisRecord != null && lastRecord != null) { gasFeeBill = new OlbGasFeeBill(); gasFeeBill.ChaoBiaoTime = (DateTime)thisRecord.ReadDate; gasFeeBill.UserID = thisRecord.UserID; gasFeeBill.UserName = thisRecord.UserName; gasFeeBill.LastNum = (decimal)lastRecord.TotalAmount; gasFeeBill.ThisNum = (decimal)thisRecord.TotalAmount; gasFeeBill.GasNum = (decimal)thisRecord.TotalAmount - (decimal)lastRecord.TotalAmount; gasFeeBill.GasFee = (decimal)lastRecord.RemainingAmount - (decimal)thisRecord.RemainingAmount; } } catch (Exception ex) { } finally { if (proxy != null) { proxy.CloseChannel(); } } return(JsToJson.SerializeToJsonString(gasFeeBill)); }
public List <T> GetList(ref SearchCondition sCondition, HttpContext context) { List <T> list = new List <T>(); WCFServiceProxy <ICommonSearch <T> > proxy = null; try { proxy = new WCFServiceProxy <ICommonSearch <T> >(); // 设置分页参数:解析context int Page = 1; int Rows = 100; string Sort = context.Request.Form["sort"] == null ? string.Empty : context.Request.Form["sort"].ToString(); string Order = context.Request.Form["order"] == null ? string.Empty : context.Request.Form["order"].ToString(); int.TryParse(context.Request.Form["page"] == null ? Page.ToString() : context.Request.Form["page"].ToString(), out Page); int.TryParse(context.Request.Form["rows"] == null ? Rows.ToString() : context.Request.Form["rows"].ToString(), out Rows); if (sCondition.TPageSize != 9999) { sCondition.TPageSize = Rows; } sCondition.TPageCurrent = Page; if (Sort != string.Empty) { sCondition.TFieldOrder = Sort == string.Empty ? string.Empty : Sort + " " + Order; } list = proxy.getChannel.getListBySearchCondition(ref sCondition); } catch { } finally { if (proxy != null) { proxy.CloseChannel(); } } return(list); }
public String GetCompanyList() { List <OlbCompany> listOlbCompany = null; WCFServiceProxy <ICommonSearch <CompanyInfo> > proxy = null; try { proxy = new WCFServiceProxy <ICommonSearch <CompanyInfo> >(); SearchCondition sCondition = new SearchCondition() { TBName = "S_CompanyInfo", TFieldKey = "CompanyID", TPageSize = 9999, TPageCurrent = 1, TFieldOrder = "CompanyName ASC" }; List <CompanyInfo> list = proxy.getChannel.getListBySearchCondition(ref sCondition); listOlbCompany = new List <OlbCompany>(); foreach (CompanyInfo c in list) { listOlbCompany.Add(new OlbCompany() { Id = c.CompanyID, Name = c.CompanyName }); } } catch (Exception ex) { } finally { if (proxy != null) { proxy.CloseChannel(); } } return(JsToJson.SerializeToJsonString(listOlbCompany)); }
public string AddIotUser(string account, string pwd, string userInfoJson, string meterInfoJson) { string LoginPsw = pwd; string CompanyID = string.Empty; string OperID = string.Empty; IotUser _iotUser = new IotUser(); try { string[] acc = account.Replace("-", "").Split('@'); if (acc.Length != 2) { return("账号错误"); } //验证账号密码 string result = Login(account, pwd); if (result != "") { return(result); } OperID = acc[0]; CompanyID = acc[1]; IoT_User user = Newtonsoft.Json.JsonConvert.DeserializeObject <IoT_User>(userInfoJson); IoT_Meter meter = Newtonsoft.Json.JsonConvert.DeserializeObject <IoT_Meter>(meterInfoJson); user.CompanyID = CompanyID; meter.CompanyID = CompanyID; meter.UserID = user.UserID; user.State = '1';//设置为等待点火状态 WCFServiceProxy <IUserManage> proxy = new WCFServiceProxy <IUserManage>(); Message jsonMessage = proxy.getChannel.Add(user); if (!jsonMessage.Result) { proxy.CloseChannel(); return(Newtonsoft.Json.JsonConvert.SerializeObject(jsonMessage)); } IoT_User resultUser = Newtonsoft.Json.JsonConvert.DeserializeObject <IoT_User>(jsonMessage.TxtMessage); meter.UserID = resultUser.UserID; meter.MeterType = "00"; _iotUser.User = resultUser; //表安装 WCFServiceProxy <IMeterManage> _proxy = new WCFServiceProxy <IMeterManage>(); jsonMessage = _proxy.getChannel.Add(meter); if (!jsonMessage.Result) { //删除用户档案 proxy.getChannel.Delete(user); proxy.CloseChannel(); _proxy.CloseChannel(); return(Newtonsoft.Json.JsonConvert.SerializeObject(jsonMessage));; } proxy.CloseChannel(); _proxy.CloseChannel(); IoT_Meter resultMeter = Newtonsoft.Json.JsonConvert.DeserializeObject <IoT_Meter>(jsonMessage.TxtMessage); _iotUser.Meter = resultMeter; return(Newtonsoft.Json.JsonConvert.SerializeObject(new Message() { Result = true, TxtMessage = Newtonsoft.Json.JsonConvert.SerializeObject(_iotUser) })); } catch (Exception e) { return(Newtonsoft.Json.JsonConvert.SerializeObject(new Message() { Result = false, TxtMessage = e.Message })); } }
protected void Page_Load(object sender, EventArgs e) { WCFServiceProxy <IChaoBiao> proxy = new WCFServiceProxy <IChaoBiao>(); try { string TimeKind = Request.QueryString["Time"]; string UserKind = Request.QueryString["User"]; string CompanyID = Request.QueryString["CompanyID"]; string Where = "1=1 and CompanyID='" + CompanyID + "'"; if (UserKind != "*" && UserKind != "") { Where += "AND charindex(','+CAST(Community AS NVARCHAR(10))+',',','+'" + UserKind + "'+',')>=1"; } if (TimeKind != "*") { Where += "and CONVERT(varchar(100), ReadDate, 23)='" + TimeKind + "'"; } List <View_UserMeterHistory> listAll = proxy.getChannel.GetModelList(Where); List <View_UserMeterHistory> listEXP = new List <View_UserMeterHistory>(); var newModel = (from n in listAll orderby n.Community, n.ReadDate descending select new { n.UserID }).Distinct().ToList(); if (TimeKind == "*") {//如果汇出说有数据,执行以下(筛选出最新一笔的数据) foreach (var item in newModel) { View_UserMeterHistory Model = new View_UserMeterHistory(); Model = (from n in listAll where n.UserID == item.UserID orderby n.ReadDate descending select n).FirstOrDefault(); listEXP.Add(Model); } } else {//如果汇出指定日期的数据,执行以下(筛选出指定日期下的第一笔数据) //foreach (var item in newModel) //{ //View_UserMeterDayFirstHistory Models = new View_UserMeterDayFirstHistory(); List <View_UserMeterDayFirstHistory> list = proxy.getChannel.GetModelLists(Where); //Model = (from n in list // where n.UserID == item.UserID // orderby n.ReadDate ascending // select n).FirstOrDefault(); foreach (View_UserMeterDayFirstHistory Model in list) { View_UserMeterHistory ModelAdd = new View_UserMeterHistory() { CompanyID = Model.CompanyID, UserID = Model.UserID, UserName = Model.UserName, State = Model.State, Address = Model.Address, Street = Model.Street, Community = Model.Community, Door = Model.Door, MeterNo = Model.MeterNo, MeterType = Model.MeterType, ValveState = Model.ValveState, LastTotal = Model.LastTotal, TotalAmount = Model.TotalAmount, RemainingAmount = Model.RemainingAmount, ReadDate = Model.ReadDate, InstallDate = Model.InstallDate, Gas = Model.Gas, }; listEXP.Add(ModelAdd); } //} } listAll = listEXP; Workbook workbook = new Workbook(); workbook.Worksheets.Add("未下载数据"); Worksheet sheet = (Worksheet)workbook.Worksheets[0]; //Worksheet sheet1 = (Worksheet)workbook.Worksheets[1]; sheet.Cells["A1"].PutValue("户号"); sheet.Cells["B1"].PutValue("户名"); sheet.Cells["C1"].PutValue("地址"); sheet.Cells["D1"].PutValue("表号"); sheet.Cells["E1"].PutValue("阀状态"); sheet.Cells["F1"].PutValue("总用量"); sheet.Cells["G1"].PutValue("余额(元)"); sheet.Cells["H1"].PutValue("抄表时间"); int RowNo = 2; for (int i = 0; i < listAll.Count; i++) { sheet.Cells["A" + RowNo].PutValue(listAll[i].UserID); sheet.Cells["B" + RowNo].PutValue(listAll[i].UserName); sheet.Cells["C" + RowNo].PutValue(listAll[i].Address); sheet.Cells["D" + RowNo].PutValue(listAll[i].MeterNo); if (listAll[i].ValveState == '0') { sheet.Cells["E" + RowNo].PutValue("阀开"); } else { sheet.Cells["E" + RowNo].PutValue("阀关"); } sheet.Cells["F" + RowNo].PutValue(listAll[i].TotalAmount.ToString()); sheet.Cells["G" + RowNo].PutValue(listAll[i].RemainingAmount.ToString()); sheet.Cells["H" + RowNo].PutValue(listAll[i].ReadDate.ToString()); RowNo++; } String filename = string.Format("{0}{1}.xls", "抄表记录", Convert.ToDateTime(DateTime.Now).ToString("yyyyMMdd")); Response.ContentType = "application/ms-excel;charset=utf-8"; Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode(filename, System.Text.Encoding.GetEncoding("utf-8"))); System.IO.MemoryStream memStream = workbook.SaveToStream(); Response.BinaryWrite(memStream.ToArray()); Response.End(); } catch (Exception) { } finally { if (proxy != null) { proxy.CloseChannel(); } } }
public override void DoLoginedHandlerWork(HttpContext context) { Message jsonMessage; jsonMessage = new Message() { Result = false, TxtMessage = "权限验证失败,可能原因:\n1、数据中心通讯失败。\n2、系统管理员未与您分配对应操作权限。" }; //获取操作类型AType:ADD,EDIT,DELETE string AjaxType = context.Request.QueryString["AType"] == null ? string.Empty : context.Request.QueryString["AType"].ToString().ToUpper(); IoT_AdInfo Info; WCFServiceProxy <IAdInfoManage> proxy = null; try { switch (AjaxType) { case "QUERY": CommonSearch <IoT_AdInfo> InfoSearch = new CommonSearch <IoT_AdInfo>(); string Where = "1=1 "; Where += "AND CompanyID='" + loginOperator.CompanyID + "' "; if (context.Request.Form["Date1"] != null && context.Request.Form["Date1"].ToString().Trim() != string.Empty) { Where += " AND StartDate>='" + context.Request.Form["Date1"].ToString() + "'";; } if (context.Request.Form["Date2"] != null && context.Request.Form["Date2"].ToString().Trim() != string.Empty) { Where += " AND EndDate<='" + context.Request.Form["Date2"].ToString() + "'";; } if (context.Request.Form["TWhere"] != null && context.Request.Form["TWhere"].ToString().Trim() != string.Empty) { Where += context.Request.Form["TWhere"].ToString(); } SearchCondition sCondition = new SearchCondition() { TBName = "IoT_AdInfo", TFieldKey = "FileIndex", TTotalCount = -1, TPageCurrent = 1, TFieldOrder = "FileIndex ASC", TWhere = Where }; List <IoT_AdInfo> list = InfoSearch.GetList(ref sCondition, context); jsonMessage = new Message() { Result = true, TxtMessage = JSon.ListToJson <IoT_AdInfo>(list, sCondition.TTotalCount) }; break; case "ADD": { HttpPostedFile postedFile = context.Request.Files[0]; System.IO.Stream stream = postedFile.InputStream; //将流转换为二进制数组 byte[] bytes = new byte[stream.Length]; stream.Read(bytes, 0, bytes.Length); Binary binaryData = new Binary(bytes); IoT_AdInfo adInfo = new IoT_AdInfo(); adInfo.FileData = binaryData; adInfo.CompanyID = base.loginOperator.CompanyID; adInfo.PublishStatus = 0; //未发布 if (context.Request.Form["CycleTime"] != null && context.Request.Form["CycleTime"].ToString().Trim() != string.Empty) { adInfo.CycleTime = int.Parse(context.Request.Form["CycleTime"].ToString()); } if (context.Request.Form["EndDate"] != null && context.Request.Form["EndDate"].ToString().Trim() != string.Empty) { adInfo.EndDate = context.Request.Form["EndDate"].ToString(); } if (context.Request.Form["StartDate"] != null && context.Request.Form["StartDate"].ToString().Trim() != string.Empty) { adInfo.StartDate = context.Request.Form["StartDate"].ToString(); } if (context.Request.Form["ShowStatus"] != null && context.Request.Form["ShowStatus"].ToString().Trim() != string.Empty) { adInfo.ShowStatus = int.Parse(context.Request.Form["ShowStatus"].ToString()); } if (context.Request.Form["PublishStatus"] != null && context.Request.Form["PublishStatus"].ToString().Trim() != string.Empty) { adInfo.PublishStatus = int.Parse(context.Request.Form["PublishStatus"].ToString()); } if (context.Request.Form["FileIndex"] != null && context.Request.Form["FileIndex"].ToString().Trim() != string.Empty) { adInfo.FileIndex = int.Parse(context.Request.Form["FileIndex"].ToString()); } if (context.Request.Form["FileName"] != null && context.Request.Form["FileName"].ToString().Trim() != string.Empty) { adInfo.FileName = context.Request.Form["FileName"].ToString(); } adInfo.FileSize = postedFile.ContentLength; proxy = new WCFServiceProxy <IAdInfoManage>(); jsonMessage = proxy.getChannel.Add(adInfo); } break; case "EDIT": { Info = new CommonModelFactory <IoT_AdInfo>().GetModelFromContext(context); proxy = new WCFServiceProxy <IAdInfoManage>(); jsonMessage = proxy.getChannel.Edit(Info); } break; case "DELETE": { Info = new CommonModelFactory <IoT_AdInfo>().GetModelFromContext(context); proxy = new WCFServiceProxy <IAdInfoManage>(); jsonMessage = proxy.getChannel.Delete(Info); } break; case "PUBLISH": { IoT_SetAdInfo setInfo = new CommonModelFactory <IoT_SetAdInfo>().GetModelFromContext(context); setInfo.SetType = 0; //发布 setInfo.SendTime = DateTime.Now; proxy = new WCFServiceProxy <IAdInfoManage>(); jsonMessage = proxy.getChannel.Publish(setInfo); } break; case "UNPUBLISH": { IoT_SetAdInfo setInfo = new CommonModelFactory <IoT_SetAdInfo>().GetModelFromContext(context); proxy = new WCFServiceProxy <IAdInfoManage>(); jsonMessage = proxy.getChannel.UnPublish(setInfo); } break; case "EDITADINFO": { IoT_SetAdInfo setInfo = new CommonModelFactory <IoT_SetAdInfo>().GetModelFromContext(context); setInfo.SetType = 1; //编辑 setInfo.DeleteStatus = 0; setInfo.SendTime = DateTime.Now; proxy = new WCFServiceProxy <IAdInfoManage>(); jsonMessage = proxy.getChannel.EditAdInfo(setInfo); } break; case "DELETEADINFO": { IoT_SetAdInfo setInfo = new CommonModelFactory <IoT_SetAdInfo>().GetModelFromContext(context); setInfo.SetType = 2; //删除 setInfo.DeleteStatus = 1; setInfo.SendTime = DateTime.Now; proxy = new WCFServiceProxy <IAdInfoManage>(); jsonMessage = proxy.getChannel.EditAdInfo(setInfo); } break; case "QUERYCONTROL": CommonSearch <IoT_SetAdInfo> setAdInfoSearch = new CommonSearch <IoT_SetAdInfo>(); Where = "1=1 "; Where += "AND CompanyID='" + loginOperator.CompanyID + "' "; if (context.Request.Form["TWhere"] != null && context.Request.Form["TWhere"].ToString().Trim() != string.Empty) { Where += context.Request.Form["TWhere"].ToString(); } sCondition = new SearchCondition() { TBName = "IoT_SetAdInfo", TFieldKey = "SendTime", TTotalCount = -1, TPageCurrent = 1, TFieldOrder = "SendTime Desc", TWhere = Where }; List <IoT_SetAdInfo> setAdInfoList = setAdInfoSearch.GetList(ref sCondition, context); jsonMessage = new Message() { Result = true, TxtMessage = JSon.ListToJson <IoT_SetAdInfo>(setAdInfoList, sCondition.TTotalCount) }; break; case "QUERYMETERVIEW": CommonSearch <View_AdInfoMeter> InfoSearch_User = new CommonSearch <View_AdInfoMeter>(); Where = "1=1 "; Where += "AND CompanyID='" + loginOperator.CompanyID + "' "; if (context.Request.Form["TWhere"] != null && context.Request.Form["TWhere"].ToString().Trim() != string.Empty) { Where += context.Request.Form["TWhere"].ToString(); } if (context.Request.Form["ID"] != null && context.Request.Form["ID"].ToString().Trim() != string.Empty) { Where += " AND ID=" + context.Request.Form["ID"].ToString().Trim(); } sCondition = new SearchCondition() { TBName = "View_AdInfoMeter", TFieldKey = "UserID", TTotalCount = -1, TPageCurrent = 1, TFieldOrder = "FinishedDate DESC", TWhere = Where }; List <View_AdInfoMeter> list_User = InfoSearch_User.GetList(ref sCondition, context); jsonMessage = new Message() { Result = true, TxtMessage = JSon.ListToJson <View_AdInfoMeter>(list_User, sCondition.TTotalCount) }; break; default: jsonMessage = new Message() { Result = false, TxtMessage = "操作未定义。" }; break; } } catch (Exception ex) { jsonMessage = new Message() { Result = false, TxtMessage = ex.Message }; } finally { if (proxy != null) { proxy.CloseChannel(); } } context.Response.Write(JSon.TToJson <Message>(jsonMessage)); }
public override void DoLoginedHandlerWork(HttpContext context) { Message jsonMessage; jsonMessage = new Message() { Result = false, TxtMessage = "权限验证失败,可能原因:\n1、数据中心通讯失败。\n2、系统管理员未与您分配对应操作权限。" }; string AjaxType = context.Request.QueryString["AType"] == null ? string.Empty : context.Request.QueryString["AType"].ToString().ToUpper(); ADUser Info = new ADUser(); WCFServiceProxy <IADUserDAL> proxy = null; Info = new CommonModelFactory <ADUser>().GetModelFromContext(context); proxy = new WCFServiceProxy <IADUserDAL>(); try { switch (AjaxType) {//查询用户 case "QUERY": CommonSearch <View_AdUser> InfoSearch = new CommonSearch <View_AdUser>(); string Where = "1=1 "; Where += "AND CompanyID='" + loginOperator.CompanyID + "' "; if (context.Request.Form["TWhere"] != null && context.Request.Form["TWhere"].ToString().Trim() != string.Empty) { Where += context.Request.Form["TWhere"].ToString(); } SearchCondition sCondition = new SearchCondition() { TBName = "View_AdUser", TFieldKey = "UserID", TTotalCount = -1, TPageCurrent = 1, TFieldOrder = "UserID desc", TWhere = Where }; List <View_AdUser> list = InfoSearch.GetList(ref sCondition, context); jsonMessage = new Message() { Result = true, TxtMessage = JSon.ListToJson <View_AdUser>(list, sCondition.TTotalCount) }; break; //广告屏用户列表 case "QUERYVIEW": CommonSearch <View_AdUser> InfoSearchView = new CommonSearch <View_AdUser>(); Where = "1=1 "; Where += "AND CompanyID='" + loginOperator.CompanyID + "' "; if (context.Request.Form["TWhere"] != null && context.Request.Form["TWhere"].ToString().Trim() != string.Empty) { Where += context.Request.Form["TWhere"].ToString(); } sCondition = new SearchCondition() { TBName = "View_AdUser", TFieldKey = "UserID", TTotalCount = -1, TPageCurrent = 1, TFieldOrder = " UserID desc", TWhere = Where }; List <View_AdUser> listView = InfoSearchView.GetList(ref sCondition, context); jsonMessage = new Message() { Result = true, TxtMessage = JSon.ListToJson <View_AdUser>(listView, sCondition.TTotalCount) }; break; //广告主题列表 case "QUERYVIEWSC": List <ADUserSC> listSC = proxy.getChannel.getListSC(); jsonMessage = new Message() { Result = true, TxtMessage = JSon.ListToJson <ADUserSC>(listSC, listSC.Count) }; break; //用户列表 case "QUERYVIEWUSER": CommonSearch <View_UserInfo> InfoSearchViewUser = new CommonSearch <View_UserInfo>(); Where = "1=1 "; Where += "AND CompanyID='" + loginOperator.CompanyID + "' "; if (context.Request.Form["TWhere"] != null && context.Request.Form["TWhere"].ToString().Trim() != string.Empty) { Where += context.Request.Form["TWhere"].ToString(); } sCondition = new SearchCondition() { TBName = "View_UserInfo", TFieldKey = "UserID", TTotalCount = -1, TPageCurrent = 1, TFieldOrder = " UserID desc", TWhere = Where }; List <View_UserInfo> listViewUser = InfoSearchViewUser.GetList(ref sCondition, context); jsonMessage = new Message() { Result = true, TxtMessage = JSon.ListToJson <View_UserInfo>(listViewUser, sCondition.TTotalCount) }; break; //用户列表 case "QUERYVIEWUSERADD": //List<View_UserInfo> listViewUserADD = proxy.getChannel.getUserListShow(loginOperator.CompanyID); CommonSearch <View_UserInfo> InfoSearchViewUserADD = new CommonSearch <View_UserInfo>(); Where = "1=1 "; Where += "AND CompanyID='" + loginOperator.CompanyID + "' "; if (context.Request.Form["TWhere"] != null && context.Request.Form["TWhere"].ToString().Trim() != string.Empty) { Where += context.Request.Form["TWhere"].ToString(); } sCondition = new SearchCondition() { TBName = "View_UserInfoADDC", TFieldKey = "UserID", TTotalCount = -1, TPageCurrent = 1, TFieldOrder = " UserID desc", TWhere = Where }; List <View_UserInfo> listViewUserADD = InfoSearchViewUserADD.GetList(ref sCondition, context); jsonMessage = new Message() { Result = true, TxtMessage = JSon.ListToJson <View_UserInfo>(listViewUserADD, sCondition.TTotalCount) }; break; //添加信息 case "GROUPADD": if (context.Request.Form["strNo"] != null && context.Request.Form["strNo"].ToString().Trim() != string.Empty) { string strNo = context.Request.Form["strNo"]; string[] arrNo = strNo.Split(','); for (int i = 0; i < arrNo.Length; i++) { string[] userInfo = arrNo[i].Split('|'); Info.UserID = userInfo[0].ToString(); Info.CompanyID = userInfo[1].ToString(); Info.Street = userInfo[2].ToString(); Info.Community = userInfo[3].ToString(); Info.Adress = userInfo[4].ToString(); Info.AddTime = DateTime.Now; Info.Ver = "1.0"; jsonMessage = proxy.getChannel.Add(Info); if (!jsonMessage.Result) { break; } } } break; case "DELETE": jsonMessage = proxy.getChannel.Delete(Info.UserID, Info.CompanyID); break; //删除信息 case "GROUPDEL": if (context.Request.Form["strNo"] != null && context.Request.Form["strNo"].ToString().Trim() != string.Empty) { string strNo = context.Request.Form["strNo"]; string[] arrNo = strNo.Split(','); for (int i = 0; i < arrNo.Length; i++) { string[] userInfo = arrNo[i].Split('|'); Info.UserID = userInfo[0].ToString(); Info.CompanyID = userInfo[1].ToString(); jsonMessage = proxy.getChannel.Delete(Info.UserID, Info.CompanyID); if (!jsonMessage.Result) { break; } } } //jsonMessage = proxy.getChannel.Delete(Info.UserID,Info.CompanyID); break; default: jsonMessage = new Message() { Result = false, TxtMessage = "操作未定义!" + AjaxType }; break; } } catch (Exception ex) { jsonMessage = new Message() { Result = false, TxtMessage = ex.Message }; } finally { if (proxy != null) { proxy.CloseChannel(); } } context.Response.Write(JSon.TToJson <Message>(jsonMessage)); }
public void ProcessRequest(HttpContext context) { //获取操作类型AType:list,oneinfo string AjaxType = context.Request.QueryString["AType"] == null ? string.Empty : context.Request.QueryString["AType"].ToString().ToUpper(); Message jsonMessage; jsonMessage = new Message() { Result = false, TxtMessage = "调用失败。" }; WCFServiceProxy <IGetMonitorInfo> proxy = null; try { switch (AjaxType) { case "LIST": //获取采集端服务器列表 proxy = new WCFServiceProxy <IGetMonitorInfo>(); DataArge arglist = proxy.getChannel.GetMonitorInfo(""); List <CJDInfo> list = (List <CJDInfo>)arglist.Data; jsonMessage = new Message() { Result = true, TxtMessage = JSon.ListToJson <CJDInfo>(list, list.Count) }; break; case "ONEINFO": //获取某一台采集服务器 监视信息 proxy = new WCFServiceProxy <IGetMonitorInfo>(); string dscId = context.Request.Form["dscId"] == null ? string.Empty : context.Request.Form["dscId"].ToString(); string mac = context.Request.Form["mac"] == null ? string.Empty : context.Request.Form["mac"].ToString(); string datetime = context.Request.Form["datetime"] == null ? string.Empty : context.Request.Form["datetime"].ToString(); string pageIndex = context.Request.Form["page"] == null ? string.Empty : context.Request.Form["page"].ToString(); string pageSize = context.Request.Form["rows"] == null ? string.Empty : context.Request.Form["rows"].ToString(); //获取日志 LogCollection logCollection = proxy.getChannel.GetDCSLog(dscId, mac, Convert.ToDateTime(datetime), Convert.ToInt32(pageIndex), Convert.ToInt32(pageSize), IoTM.Common.Log.ReadLogDataType.OneMeterData); //LogCollection logCollection = new LogCollection(); //logCollection.Rows = 1; //List<TxtMessage> listTxtMessage = new List<TxtMessage>(); //TxtMessage txtmsg; //for (int j = 0; j < 20; j++) //{ // txtmsg = new TxtMessage(); // txtmsg.Message =DateTime.Now.ToString("j: "+"yyyy-MM-dd HH:mm:ss.fff"); // listTxtMessage.Add(txtmsg); //} //logCollection.ListTxtMessage = listTxtMessage; jsonMessage = new Message() { Result = true, TxtMessage = JSon.ListToJson <TxtMessage>(logCollection.ListTxtMessage, logCollection.Rows) }; //context.Response.Write(JSon.ListToJson<TxtMessage>(logCollection.ListTxtMessage, logCollection.ListTxtMessage.Count)); //return; break; } } catch (Exception ex) { jsonMessage = new Message() { Result = false, TxtMessage = ex.Message }; } finally { if (proxy != null) { proxy.CloseChannel(); } } context.Response.Write(JSon.TToJson <Message>(jsonMessage)); }
public override void DoLoginedHandlerWork(HttpContext context) { Message jsonMessage; //获取操作类型AType:ADD,EDIT,DELETE,QUERY string AjaxType = context.Request.QueryString["AType"] == null ? string.Empty : context.Request.QueryString["AType"].ToString().ToUpper(); DefineRight Info; jsonMessage = new Message() { Result = false, TxtMessage = "权限验证失败,可能原因:\n1、数据中心通讯失败。\n2、系统管理员未与您分配对应操作权限。" }; switch (AjaxType) { case "LOADLEFTMENU": jsonMessage = new Message() { Result = true, TxtMessage = CommonOperRightHelper.MenuListToJson(base.loginOperator) }; break; //新菜单栏加载菜单 case "LOADNEWLEFTMENU": jsonMessage = new Message() { Result = true, TxtMessage = CommonOperRightHelper.GetLeftMenu(base.loginOperator) }; break; case "LOADHIDEMENUCODE": jsonMessage = new Message() { Result = true, TxtMessage = CommonOperRightHelper.GetHidMenuCode(base.loginOperator) }; break; case "LOADCOMPANYRIGHT": List <DefineRight> list = new WCFServiceProxy <IOperRightManage>().getChannel.LoadCompanyDefineRight(base.loginOperator.CompanyID); jsonMessage = new Message() { Result = true, TxtMessage = JSon.ListToJson <DefineRight>(list, list.Count) }; break; case "LOADCOMPANYMENU": jsonMessage = new Message() { Result = true, TxtMessage = CommonOperRightHelper.CompanyMenuListToJson(base.loginOperator.CompanyID) }; break; //加载两级菜单树(zzcy) case "LOADNEWCOMPANYMENU": jsonMessage = new Message() { Result = true, TxtMessage = CommonOperRightHelper.MenuListToJson(base.loginOperator) }; break; //获取公司菜单 case "LOADMENUBYCOMPANY": string companyId = context.Request.Form["CompanyID"] == null ? string.Empty : context.Request.Form["CompanyID"].ToString().Trim(); jsonMessage = new Message() { Result = true, TxtMessage = CommonOperRightHelper.GetMenuListToJson(companyId) }; break; case "LOADRIGHTMENU": string rightCode = context.Request.Form["rightCode"] == null ? string.Empty : context.Request.Form["rightCode"].ToString().Trim(); jsonMessage = new Message() { Result = true, TxtMessage = CommonOperRightHelper.GetCompanyRightMenuCode(base.loginOperator.CompanyID, rightCode) }; break; case "LOADCOMPANYOPERRIGHT": string operID = context.Request.Form["OperID"] == null ? string.Empty : context.Request.Form["OperID"].ToString(); WCFServiceProxy <IOperRightManage> proxy = new WCFServiceProxy <IOperRightManage>(); try { jsonMessage = new Message() { Result = true, TxtMessage = proxy.getChannel.LoadCompanyOperDefineRight(base.loginOperator.CompanyID, operID) }; } catch { } finally { proxy.CloseChannel(); } break; //编辑公司菜单(分配菜单) case "EDITCOMPANYMENU": if (CommonOperRightHelper.CheckMenuCode(base.loginOperator, "fpqycd")) { companyId = context.Request.Form["CompanyID"] == null ? string.Empty : context.Request.Form["CompanyID"].ToString().Trim(); List <String> List = new List <String>(); string CompanyMenuCode = context.Request.Form["CompanyMenuCode"] == null ? string.Empty : context.Request.Form["CompanyMenuCode"].ToString(); foreach (string menu in CompanyMenuCode.Split(',')) { List.Add(menu); } jsonMessage = new WCFServiceProxy <IOperRightManage>().getChannel.EditCompanyMenu(companyId, List); } break; case "ADDQXZ": if (CommonOperRightHelper.CheckMenuCode(base.loginOperator, "tjqxz")) { Info = new CommonModelFactory <DefineRight>().GetModelFromContext(context); Info.CompanyID = base.loginOperator.CompanyID; string RightMenuCode = context.Request.Form["RightMenuCode"] == null ? string.Empty : context.Request.Form["RightMenuCode"].ToString(); List <DefineRightMenu> List = new List <DefineRightMenu>(); foreach (string menu in RightMenuCode.Split(',')) { List.Add(new DefineRightMenu() { CompanyID = base.loginOperator.CompanyID, MenuCode = menu, RightCode = Info.RightCode }); } jsonMessage = new WCFServiceProxy <IOperRightManage>().getChannel.AddCompanyDefineRight(Info, List.Distinct().ToList()); } break; case "EDITQXZ": if (CommonOperRightHelper.CheckMenuCode(base.loginOperator, "bjqxz")) { Info = new CommonModelFactory <DefineRight>().GetModelFromContext(context); Info.CompanyID = base.loginOperator.CompanyID; List <DefineRightMenu> List = new List <DefineRightMenu>(); string RightMenuCode = context.Request.Form["RightMenuCode"] == null ? string.Empty : context.Request.Form["RightMenuCode"].ToString(); foreach (string menu in RightMenuCode.Split(',')) { List.Add(new DefineRightMenu() { CompanyID = base.loginOperator.CompanyID, MenuCode = menu, RightCode = Info.RightCode }); } jsonMessage = new WCFServiceProxy <IOperRightManage>().getChannel.AddCompanyDefineRight(Info, List.Distinct().ToList()); } break; case "DELETEQXZ": if (CommonOperRightHelper.CheckMenuCode(base.loginOperator, "scqxz")) { Info = new CommonModelFactory <DefineRight>().GetModelFromContext(context); Info.CompanyID = base.loginOperator.CompanyID; jsonMessage = new WCFServiceProxy <IOperRightManage>().getChannel.DelCompanyDefineRight(Info); } break; case "EDITOPERRIGHT": if (CommonOperRightHelper.CheckMenuCode(base.loginOperator, "fpqxz")) { string OperID = context.Request.Form["OperID"] == null ? string.Empty : context.Request.Form["OperID"].ToString(); string RightCode = context.Request.Form["RightCode"] == null ? string.Empty : context.Request.Form["RightCode"].ToString(); List <DefineRight> lDefineRight = new List <DefineRight>(); foreach (string tmp in RightCode.Split(',')) { lDefineRight.Add(new DefineRight() { CompanyID = base.loginOperator.CompanyID, RightCode = tmp }); } if (OperID == string.Empty) { jsonMessage = new Message() { Result = false, TxtMessage = "请选择您要分配权限组的操作员。" }; } else { jsonMessage = new WCFServiceProxy <IOperRightManage>().getChannel.EditCompanyOperRight(base.loginOperator.CompanyID, OperID, lDefineRight); } } break; case "REMOVECACHE": jsonMessage = new WCFServiceProxy <IOperRightManage>().getChannel.RemoveCompanyRightCache(base.loginOperator.CompanyID); break; default: jsonMessage = new Message() { Result = false, TxtMessage = "操作未定义。" }; break; } context.Response.Write(JSon.TToJson <Message>(jsonMessage)); }
private Message UserLogin(HttpContext context) { Message jMessage = new Message(); string LoginID = string.Empty; string LoginPsw = string.Empty; string CompanyID = string.Empty; string OperID = string.Empty; bool IsPhoneLogin = false; if (context.Request.Form["LoginID"] != null && context.Request.Form["LoginID"].ToString().Trim() != string.Empty) { LoginID = context.Request.Form["LoginID"].ToString().Trim(); if (LoginID.Split('@').Length == 2) { CompanyID = LoginID.Split('@')[1]; OperID = LoginID.Split('@')[0]; } else { if (LoginID.Length == 11) { IsPhoneLogin = true; } } } if (context.Request.Form["LoginPsw"] != null) { LoginPsw = context.Request.Form["LoginPsw"].ToString().Trim(); } if (LoginID == string.Empty) { jMessage = new Message() { Result = false, TxtMessage = "登录账号格式不正确。" }; } else { CommonSearch <CompanyOperator> userInfoSearch = new CommonSearch <CompanyOperator>(); string Where = "1=1 "; if (IsPhoneLogin) { Where += " AND PhoneLogin=1 and Phone='" + LoginID + "'"; } else { Where += " AND OperID='" + OperID + "' AND CompanyID='" + CompanyID + "'"; } SearchCondition sCondition = new SearchCondition() { TBName = "S_CompanyOperator", TFieldKey = "OperID", TTotalCount = -1, TWhere = Where }; CompanyOperator Loginer = userInfoSearch.GetFirstTModel(ref sCondition); //服务器错误 if (sCondition.TTotalCount == -1) { jMessage = new Message() { Result = false, TxtMessage = "数据中心未返回信息,请稍候再试。" }; } else if (Loginer != null && Loginer.OperID != string.Empty) { if (Loginer.State != null && Loginer.State.ToString() == "1") { jMessage = new Message() { Result = false, TxtMessage = string.Format("账号{0}已停用。", LoginID) }; } else if (Loginer.Pwd == Md5.GetMd5(Loginer.CompanyID + LoginPsw)) { jMessage = new Message() { Result = true, TxtMessage = "登录成功。" }; //向数据中心记录登录信息 WCFServiceProxy <ILoginerManage> proxy = new WCFServiceProxy <ILoginerManage>(); string webCookie = context.Session.SessionID.ToString(); try { proxy.getChannel.RegisterClient(Md5.GetMd5(webCookie), Loginer.OperID, Loginer.CompanyID); } catch { } finally { proxy.CloseChannel(); } Loginer.Pwd = string.Empty; context.Session["LoginCompanyOperator"] = Loginer; } else { jMessage = new Message() { Result = false, TxtMessage = "密码错误。" }; } } else { jMessage = new Message() { Result = false, TxtMessage = IsPhoneLogin ? "该手机号未绑定,请联系管理员操作[系统管理]->[操作员管理]界面进行绑定。" : "登录账号不存在。" }; } } return(jMessage); }
protected void Page_Load(object sender, EventArgs e) { WCFServiceProxy <IMeterGasBill> proxy = null; try { CompanyOperator dCLoginer = null; if (this.Context.Session["LoginCompanyOperator"] != null) { dCLoginer = (CompanyOperator)this.Context.Session["LoginCompanyOperator"]; } else { return; } string month = Request.QueryString["Month"]; string companyId = dCLoginer.CompanyID; Workbook workbook = new Workbook(); workbook.Worksheets.Add("气量表结算数据"); Worksheet sheet = (Worksheet)workbook.Worksheets[0]; sheet.Cells["A1"].PutValue("户号"); sheet.Cells["B1"].PutValue("户名"); sheet.Cells["C1"].PutValue("地址"); sheet.Cells["D1"].PutValue("表号"); sheet.Cells["E1"].PutValue("结算月份"); sheet.Cells["F1"].PutValue("上次表底"); sheet.Cells["G1"].PutValue("本次表底"); sheet.Cells["H1"].PutValue("用气量"); sheet.Cells["I1"].PutValue("气费"); sheet.Cells["J1"].PutValue("抄表时间"); proxy = new WCFServiceProxy <IMeterGasBill>(); List <View_MeterGasBill> listAll = proxy.getChannel.GetGasBillByMonth(month, companyId); int RowNo = 2; for (int i = 0; i < listAll.Count; i++) { sheet.Cells["A" + RowNo].PutValue(listAll[i].UserID); sheet.Cells["B" + RowNo].PutValue(listAll[i].UserName); sheet.Cells["C" + RowNo].PutValue(listAll[i].Address); sheet.Cells["D" + RowNo].PutValue(listAll[i].MeterNo); sheet.Cells["E" + RowNo].PutValue(listAll[i].UseMonth); sheet.Cells["F" + RowNo].PutValue(listAll[i].LastSum.ToString()); sheet.Cells["G" + RowNo].PutValue(listAll[i].ThisSum.ToString()); sheet.Cells["H" + RowNo].PutValue(listAll[i].UseGasSum.ToString()); sheet.Cells["I" + RowNo].PutValue(listAll[i].GasFee.ToString()); sheet.Cells["J" + RowNo].PutValue(listAll[i].ThisReadDate.ToString()); RowNo++; } String filename = string.Format("{0}{1}.xls", "气量表结算数据", month); Response.ContentType = "application/ms-excel;charset=utf-8"; Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode(filename, System.Text.Encoding.GetEncoding("utf-8"))); System.IO.MemoryStream memStream = workbook.SaveToStream(); Response.BinaryWrite(memStream.ToArray()); Response.End(); } catch (Exception) { } finally { if (proxy != null) { proxy.CloseChannel(); } } }
public override void DoLoginedHandlerWork(HttpContext context) { Message jsonMessage; jsonMessage = new Message() { Result = false, TxtMessage = "权限验证失败,可能原因:\n1、数据中心通讯失败。\n2、系统管理员未与您分配对应操作权限。" }; //获取操作类型AType:ADD,EDIT,DELETE string AjaxType = context.Request.QueryString["AType"] == null ? string.Empty : context.Request.QueryString["AType"].ToString().ToUpper(); WCFServiceProxy <ISetUploadCycle> proxy = null; try { switch (AjaxType) { //查询充值的历史资料 case "QUERY": CommonSearch <View_ChongZhi> InfoSearch = new CommonSearch <View_ChongZhi>(); string Where = "1=1 "; Where += "AND CompanyID='" + loginOperator.CompanyID + "' "; if (context.Request.Form["DateS"] != null && context.Request.Form["DateS"].ToString().Trim() != string.Empty) { Where += " AND convert(char(10),TopUpDate,120)>='" + context.Request.Form["DateS"].ToString() + "'";; } if (context.Request.Form["DateE"] != null && context.Request.Form["DateE"].ToString().Trim() != string.Empty) { Where += " AND convert(char(10),TopUpDate,120)<='" + context.Request.Form["DateE"].ToString() + "'";; } if (context.Request.Form["TWhere"] != null && context.Request.Form["TWhere"].ToString().Trim() != string.Empty) { Where += context.Request.Form["TWhere"].ToString(); } SearchCondition sCondition = new SearchCondition() { TBName = "View_ChongZhi", TFieldKey = "AID", TTotalCount = -1, TPageCurrent = 1, TFieldOrder = "TopUpDate DESC", TWhere = Where }; List <View_ChongZhi> list = InfoSearch.GetList(ref sCondition, context); jsonMessage = new Message() { Result = true, TxtMessage = JSon.ListToJson <View_ChongZhi>(list, sCondition.TTotalCount) }; break; //执行充值动作 case "CXCHONGZHI": if (CommonOperRightHelper.CheckMenuCode(base.loginOperator, "CZ_CXCZ")) //营业厅撤销充值 { IoT_MeterTopUp Info; WCFServiceProxy <IChongzhiManage> proxy1 = null; Info = new CommonModelFactory <IoT_MeterTopUp>().GetModelFromContext(context); List <IoT_MeterTopUp> lstIoT_MeterTopUp = new List <IoT_MeterTopUp>(); //表号 string MeterNo = string.IsNullOrEmpty(context.Request["MeterNo"]) == true ? "" : context.Request["MeterNo"].ToString(); //充值金额 string Amount = string.IsNullOrEmpty(context.Request["Amount"]) == true ? "" : context.Request["Amount"].ToString(); //表ID string MeterID = string.IsNullOrEmpty(context.Request["MeterID"]) == true ? "" : context.Request["MeterID"].ToString(); //人员ID string UserID = string.IsNullOrEmpty(context.Request["UserID"]) == true ? "" : context.Request["UserID"].ToString(); //PK string ID = string.IsNullOrEmpty(context.Request["AID"]) == true ? "" : context.Request["AID"].ToString(); //任务编号 string TaskID = string.IsNullOrEmpty(context.Request["TaskID"]) == true ? "" : context.Request["TaskID"].ToString(); string Context = string.IsNullOrEmpty(context.Request["Context"]) == true ? "" : context.Request["Context"].ToString(); Info.Amount = decimal.Parse(Amount); Info.MeterID = int.Parse(MeterID); Info.MeterNo = MeterNo; Info.ID = int.Parse(ID); Info.Context = Context; Info.Oper = base.loginOperator.Name; Info.CompanyID = base.loginOperator.CompanyID; Info.TopUpDate = DateTime.Now; Info.UserID = UserID; Info.TopUpType = '1'; //充值类型目前未知 Info.State = '0'; //等待充值状态 Info.TaskID = TaskID; //等待充值状态 proxy1 = new WCFServiceProxy <IChongzhiManage>(); jsonMessage = proxy1.getChannel.UPD(Info); } break; default: jsonMessage = new Message() { Result = false, TxtMessage = "操作未定义。" }; break; } } catch (Exception ex) { jsonMessage = new Message() { Result = false, TxtMessage = ex.Message }; } finally { if (proxy != null) { proxy.CloseChannel(); } } context.Response.Write(JSon.TToJson <Message>(jsonMessage)); }
public override void DoLoginedHandlerWork(HttpContext context) { Message jsonMessage; jsonMessage = new Message() { Result = false, TxtMessage = "权限验证失败,可能原因:\n1、数据中心通讯失败。\n2、系统管理员未与您分配对应操作权限。" }; string AjaxType = context.Request.QueryString["AType"] == null ? string.Empty : context.Request.QueryString["AType"].ToString().ToUpper(); ADItem Info = new ADItem(); WCFServiceProxy <IADItemDAL> proxy = null; Info = new CommonModelFactory <ADItem>().GetModelFromContext(context); proxy = new WCFServiceProxy <IADItemDAL>(); //文件控制接口 WCFServiceProxy <IADFileService> fileContrl = new WCFServiceProxy <IADFileService>(); try { switch (AjaxType) {//查询用户 case "QUERY": CommonSearch <ADItem> InfoSearch = new CommonSearch <ADItem>(); string Where = "1=1 "; if (context.Request.Form["TWhere"] != null && context.Request.Form["TWhere"].ToString().Trim() != string.Empty) { Where += context.Request.Form["TWhere"].ToString(); } SearchCondition sCondition = new SearchCondition() { TBName = "ADItem", TFieldKey = "AI_ID", TTotalCount = -1, TPageCurrent = 1, TFieldOrder = "OrderID asc", TWhere = Where }; List <ADItem> list = InfoSearch.GetList(ref sCondition, context); jsonMessage = new Message() { Result = true, TxtMessage = JSon.ListToJson <ADItem>(list, sCondition.TTotalCount) }; break; //列表 case "QUERYVIEW": CommonSearch <ADItem> InfoSearchView = new CommonSearch <ADItem>(); Where = "1=1 "; if (context.Request.Form["TWhere"] != null && context.Request.Form["TWhere"].ToString().Trim() != string.Empty) { Where += context.Request.Form["TWhere"].ToString(); } sCondition = new SearchCondition() { TBName = "ADItem", TFieldKey = "AI_ID", TTotalCount = -1, TPageCurrent = 1, TFieldOrder = " OrderID asc", TWhere = Where }; List <ADItem> listView = InfoSearchView.GetList(ref sCondition, context); //SysCookie.UrlParaStr = "InfoCount?" + listView.Count;//取得条数据,方便生成序列号 jsonMessage = new Message() { Result = true, TxtMessage = JSon.ListToJson <ADItem>(listView, sCondition.TTotalCount) }; break; //添加广告内容 case "ADD": //提取上传地址配置值 string ADFilePath = System.Configuration.ConfigurationManager.AppSettings["ADFilePath"].ToString(); HttpPostedFile postedFile = context.Request.Files[0]; //提取扩展名 string fileExtendName = Info.FileName.Substring(Info.FileName.IndexOf("."), Info.FileName.Length - Info.FileName.IndexOf(".")); //将文件存到服务器上 postedFile.SaveAs(ADFilePath + @"\" + Info.FileName); //将生成文件流 System.IO.Stream stream = postedFile.InputStream; //将文件转换成文件流并存入二进制数组 byte[] data = new byte[stream.Length]; stream.Read(data, 0, data.Length); stream.Close(); Info.FileLength = data.Length; Info.StorePath = postedFile.FileName; Info.StoreName = loginOperator.CompanyID + string.Format("{0:yyMMdd}", DateTime.Now) + AdMComm.GetAddZero(proxy.getChannel.userPuFileNum(loginOperator.CompanyID) + 1, 5) + fileExtendName; //调用共用文件上传接口 string fileRetrue = fileContrl.getChannel.UpLoad(loginOperator.CompanyID, Info.StoreName, data); jsonMessage = proxy.getChannel.Add(Info); break; case "EDIT": HttpFileCollection files = HttpContext.Current.Request.Files; if (files.Count > 0) { //提取上传地址配置值 string eADFilePath = System.Configuration.ConfigurationManager.AppSettings["ADFilePath"].ToString(); HttpPostedFile epostedFile = context.Request.Files[0]; //提取扩展名 string efileExtendName = Info.FileName.Substring(Info.FileName.IndexOf("."), Info.FileName.Length - Info.FileName.IndexOf(".")); //将文件存到服务器上 epostedFile.SaveAs(eADFilePath + @"\" + Info.FileName); //将生成文件流 System.IO.Stream estream = epostedFile.InputStream; //将文件转换成文件流并存入二进制数组 byte[] edata = new byte[estream.Length]; estream.Read(edata, 0, edata.Length); estream.Close(); Info.FileLength = edata.Length; Info.StorePath = epostedFile.FileName; Info.StoreName = loginOperator.CompanyID + string.Format("{0:yyMMdd}", DateTime.Now) + AdMComm.GetAddZero(proxy.getChannel.userPuFileNum(loginOperator.CompanyID) + 1, 5) + efileExtendName; //调用共用文件上传接口 string efileRetrue = fileContrl.getChannel.UpLoad(loginOperator.CompanyID, Info.StoreName, edata); } jsonMessage = proxy.getChannel.Edit(Info); break; case "UPORDER": //if (Info.OrderID != null) orderIDre = short.Parse(Info.OrderID.ToString()); jsonMessage = proxy.getChannel.upOrder(Info); break; case "DOWNORDER": //if (Info.OrderID != null) orderIDre = short.Parse(Info.OrderID.ToString()); jsonMessage = proxy.getChannel.downOrder(Info); break; //删除信息 case "DELFILE": jsonMessage = proxy.getChannel.Delete(Info.AI_ID); //调用共用文件接口,删除文件 string dfileRetrue = fileContrl.getChannel.Delete(loginOperator.CompanyID, Info.StoreName); break; default: jsonMessage = new Message() { Result = false, TxtMessage = "1.操作未定义!" }; break; } } catch (Exception ex) { jsonMessage = new Message() { Result = false, TxtMessage = ex.Message }; } finally { if (proxy != null) { proxy.CloseChannel(); } } context.Response.Write(JSon.TToJson <Message>(jsonMessage)); }
public static string MenuListToJson(CompanyOperator info) { List <DefineMenu> list = new List <DefineMenu>(); WCFServiceProxy <IOperRightManage> proxy = null; try { proxy = new WCFServiceProxy <IOperRightManage>(); list = proxy.getChannel.LoadDefineMenuByLoginOper(info, false); } catch { return(string.Empty); } finally { if (proxy != null) { proxy.CloseChannel(); } } List <DefineMenu> tmp = new List <DefineMenu>(); List <DefineMenu> tmp1 = new List <DefineMenu>(); StringBuilder Json = new StringBuilder(); int id = 0; if (list != null && list.Count > 0) { var vList = list.Where(p => p.Type == "00"); if (vList != null) { tmp = vList.OrderBy(p => p.OrderNum).ToList(); } else { tmp = null; } if (tmp != null) { //动态生成菜单:只解析两级菜单 Json.Append("["); for (int i = 0; i < tmp.Count; i++) { Json.Append("{"); Json.Append("\"id\":" + (id++)); Json.Append(","); Json.Append("\"text\":\"" + tmp[i].Name + "\""); //if (tmp[i].UrlClass != string.Empty) //{ Json.Append(","); Json.Append("\"attributes\":{\"url\":\"" + tmp[i].UrlClass + "\""); Json.Append(","); Json.Append("\"type\":\"" + tmp[i].Type + "\""); Json.Append(","); Json.Append("\"menucode\":\"" + tmp[i].MenuCode + "\""); Json.Append("}"); //} var vvList = list.Where(p => (p.Type == "01" || p.Type == "03") && p.FatherCode == tmp[i].MenuCode); if (vvList != null) { tmp1 = vvList.OrderBy(p => p.OrderNum).ToList(); } else { tmp1 = null; } if (tmp1 != null && tmp1.Count > 0) { Json.Append(","); Json.Append("\"children\":["); for (int j = 0; j < tmp1.Count; j++) { Json.Append("{"); Json.Append("\"id\":" + (id++)); Json.Append(","); Json.Append("\"text\":\"" + tmp1[j].Name + "\""); //if (tmp1[j].UrlClass != string.Empty) //{ Json.Append(","); Json.Append("\"attributes\":{\"url\":\"" + tmp1[j].UrlClass + "\""); Json.Append(","); Json.Append("\"type\":\"" + tmp1[j].Type + "\""); Json.Append(","); Json.Append("\"menucode\":\"" + tmp1[j].MenuCode + "\""); Json.Append("}"); //} Json.Append("}"); if (j != tmp1.Count - 1) { Json.Append(","); } } Json.Append("]"); } Json.Append("}"); if (i != tmp.Count - 1) { Json.Append(","); } } Json.Append("]"); } } return(Json.ToString()); }
public override void DoLoginedHandlerWork(HttpContext context) { Message jsonMessage; jsonMessage = new Message() { Result = false, TxtMessage = "权限验证失败,可能原因:\n1、数据中心通讯失败。\n2、系统管理员未与您分配对应操作权限。" }; //获取操作类型AType:ADD,EDIT,DELETE string AjaxType = context.Request.QueryString["AType"] == null ? string.Empty : context.Request.QueryString["AType"].ToString().ToUpper(); //IoT_User Info; View_UserMeter viewInfo; WCFServiceProxy <IUserManage> proxy = null; try { switch (AjaxType) { //查询用户表讯息 case "QUERY": CommonSearch <View_UserMeter> InfoSearch = new CommonSearch <View_UserMeter>(); string Where = "1=1 "; Where += "AND CompanyID='" + loginOperator.CompanyID + "' "; if (context.Request.Form["TWhere"] != null && context.Request.Form["TWhere"].ToString().Trim() != string.Empty) { Where += context.Request.Form["TWhere"].ToString(); } SearchCondition sCondition = new SearchCondition() { TBName = "View_UserMeter", TFieldKey = "UserID", TTotalCount = -1, TPageCurrent = 1, TFieldOrder = "UserID ASC", TWhere = Where }; List <View_UserMeter> list = InfoSearch.GetList(ref sCondition, context); jsonMessage = new Message() { Result = true, TxtMessage = JSon.ListToJson <View_UserMeter>(list, sCondition.TTotalCount) }; break; //实现营业厅充值动作 case "CHONGZHI": if (CommonOperRightHelper.CheckMenuCode(base.loginOperator, "CHONGZHI")) { IoT_MeterTopUp Info; WCFServiceProxy <IChongzhiManage> proxy1 = null; Info = new CommonModelFactory <IoT_MeterTopUp>().GetModelFromContext(context); List <IoT_MeterTopUp> lstIoT_MeterTopUp = new List <IoT_MeterTopUp>(); string MeterNo = string.IsNullOrEmpty(context.Request["MeterNo"]) == true ? "" : context.Request["MeterNo"].ToString(); string Amount = string.IsNullOrEmpty(context.Request["Amount"]) == true ? "0" : context.Request["Amount"].ToString(); string MeterID = string.IsNullOrEmpty(context.Request["MeterID"]) == true ? "" : context.Request["MeterID"].ToString(); string UserID = string.IsNullOrEmpty(context.Request["UserID"]) == true ? "" : context.Request["UserID"].ToString(); string OperID = string.IsNullOrEmpty(context.Request["OperId"]) ? "" : context.Request["OperId"].ToString(); string OperName = string.IsNullOrEmpty(context.Request["OperName"]) ? "" : context.Request["OperName"].ToString(); string PayType = string.IsNullOrEmpty(context.Request["PayType"]) ? "0" : context.Request["PayType"].ToString(); if (Amount == "0") //后台验证输入的金额是否为空 { jsonMessage = new Message() { Result = false, TxtMessage = "请输入正确的充值金额。" }; context.Response.Write(JSon.TToJson <Message>(jsonMessage)); return; } Info.Amount = decimal.Parse(Amount); //充值金额 Info.MeterID = int.Parse(MeterID); //充值的表ID Info.MeterNo = MeterNo; //充值表号 Info.Oper = base.loginOperator.Name; //操作员 Info.CompanyID = base.loginOperator.CompanyID; //公司 Info.TopUpDate = DateTime.Now; //充值时间,后面会被写到表上的时间覆盖,用来表示写到表上的时间 Info.PayDate = DateTime.Now; //充值时间,用户支付完成的时间 Info.UserID = UserID; //充值户号 Info.TopUpType = '0'; //充值类型为"本地营业厅" Info.State = '0'; //等待充值状态 Info.PayType = Convert.ToChar(PayType); //付款类型:0 现金 1 支付宝 2 微信 Info.SFOperID = OperID; Info.SFOperName = OperName; proxy1 = new WCFServiceProxy <IChongzhiManage>(); jsonMessage = proxy1.getChannel.Add(Info); proxy1.CloseChannel(); } break; case "PRINT": //打印票据(修改打印状态为已打印) WCFServiceProxy <IChongzhiManage> proxy2 = new WCFServiceProxy <IChongzhiManage>(); string id = string.IsNullOrEmpty(context.Request["id"]) ? "" : context.Request["id"].ToString(); if (id == "") { jsonMessage = new Message() { Result = false, TxtMessage = "票据不存在" }; } else { string result = proxy2.getChannel.PrintTicket(id); if (result == "") { jsonMessage = new Message() { Result = true, TxtMessage = "" }; } } proxy2.CloseChannel(); break; default: jsonMessage = new Message() { Result = false, TxtMessage = "操作未定义。" }; break; } } catch (Exception ex) { jsonMessage = new Message() { Result = false, TxtMessage = ex.Message }; } finally { if (proxy != null) { proxy.CloseChannel(); } } context.Response.Write(JSon.TToJson <Message>(jsonMessage)); }
public override void DoLoginedHandlerWork(HttpContext context) { Message jsonMessage; jsonMessage = new Message() { Result = false, TxtMessage = "权限验证失败,可能原因:\n1、数据中心通讯失败。\n2、系统管理员未与您分配对应操作权限。" }; //获取操作类型AType:ADD,EDIT,DELETE string AjaxType = context.Request.QueryString["AType"] == null ? string.Empty : context.Request.QueryString["AType"].ToString().ToUpper(); WCFServiceProxy <IUserManage> proxy = null; try { switch (AjaxType) { //查询用户表讯息 case "QUERY": CommonSearch <View_UserMeter> InfoSearch = new CommonSearch <View_UserMeter>(); string Where = "1=1 "; Where += "AND CompanyID='" + loginOperator.CompanyID + "' "; if (context.Request.Form["TWhere"] != null && context.Request.Form["TWhere"].ToString().Trim() != string.Empty) { Where += context.Request.Form["TWhere"].ToString(); } SearchCondition sCondition = new SearchCondition() { TBName = "View_UserMeter", TFieldKey = "UserID", TTotalCount = -1, TPageCurrent = 1, TFieldOrder = "UserID ASC", TWhere = Where }; List <View_UserMeter> list = InfoSearch.GetList(ref sCondition, context); jsonMessage = new Message() { Result = true, TxtMessage = JSon.ListToJson <View_UserMeter>(list, sCondition.TTotalCount) }; break; //查询用户表具视图 case "QUERYHISTORY": CommonSearch <View_UserMeterHistory> InfoSearchView = new CommonSearch <View_UserMeterHistory>(); Where = "1=1 "; Where += "AND CompanyID='" + loginOperator.CompanyID + "' "; if (context.Request["UserID"] != null && context.Request["UserID"].ToString().Trim() != string.Empty) { Where += "and UserID='" + context.Request["UserID"].ToString() + "'"; } sCondition = new SearchCondition() { TBName = "View_UserMeterHistory", TFieldKey = "ReadDate", TTotalCount = -1, TPageCurrent = 1, TFieldOrder = "ReadDate DESC", TWhere = Where }; List <View_UserMeterHistory> listView = InfoSearchView.GetList(ref sCondition, context); jsonMessage = new Message() { Result = true, TxtMessage = JSon.ListToJson <View_UserMeterHistory>(listView, sCondition.TTotalCount) }; break; //查询街道 case "QUERYSTREET": //CommonSearch<IoT_Street> InfoSearch = new CommonSearch<IoT_Street>(); Where = "1=1 "; Where += "AND CompanyID='" + loginOperator.CompanyID + "' "; if (context.Request.Form["TWhere"] != null && context.Request.Form["TWhere"].ToString().Trim() != string.Empty) { Where += context.Request.Form["TWhere"].ToString(); } sCondition = new SearchCondition() { TBName = "View_Community", TFieldKey = "ID", TTotalCount = -1, TPageCurrent = 1, TFieldOrder = "ID ASC", TWhere = Where }; CommonSearch <View_Community> InfoSearchStreet = new CommonSearch <View_Community>(); List <View_Community> listStreet = InfoSearchStreet.GetList(ref sCondition, context); jsonMessage = new Message() { Result = true, TxtMessage = JSon.ListToJson <View_Community>(listStreet, sCondition.TTotalCount) }; break; //查询历史资料笔数 case "GETHISTORYCOUNT": string TimeKind = string.Empty; //按照时间类型 string UserKind = string.Empty; //按照人员类型 string CompanyID = string.Empty; //公司ID Where = "1=1 "; Where += "AND CompanyID='" + loginOperator.CompanyID + "' "; //CommonSearch<IoT_Street> InfoSearch = new CommonSearch<IoT_Street>(); try { if (context.Request["Time"] != null && context.Request["Time"].ToString().Trim() != string.Empty) { TimeKind = context.Request["Time"]; } if (context.Request["User"] != null && context.Request["User"].ToString().Trim() != string.Empty) { UserKind = context.Request["User"]; } if (UserKind != "*" && UserKind != "") { Where += "AND charindex(','+CAST(Community AS NVARCHAR(10))+',',','+'" + UserKind + "'+',')>=1"; } if (TimeKind != "*") { Where += "and CONVERT(varchar(100), ReadDate, 23)='" + TimeKind + "'"; } WCFServiceProxy <IChaoBiao> proxy1 = new WCFServiceProxy <IChaoBiao>(); List <View_UserMeterHistory> listAll = proxy1.getChannel.GetModelList(Where); if (listAll == null || listAll.Count <= 0) { //如果查询出笔数大于0,返回True jsonMessage = new Message() { Result = true, TxtMessage = "" }; } else { //否则返回False jsonMessage = new Message() { Result = false, TxtMessage = "" }; } } catch (Exception) { jsonMessage = new Message() { Result = false, TxtMessage = "" }; } break; //获取当前的公司 case "GETCOMPANY": jsonMessage = new Message() { Result = true, TxtMessage = loginOperator.CompanyID }; break; default: jsonMessage = new Message() { Result = false, TxtMessage = "操作未定义。" }; break; } } catch (Exception ex) { jsonMessage = new Message() { Result = false, TxtMessage = ex.Message }; } finally { if (proxy != null) { proxy.CloseChannel(); } } context.Response.Write(JSon.TToJson <Message>(jsonMessage)); }
public static string GetLeftMenu(CompanyOperator info) { List <DefineMenu> list = new List <DefineMenu>(); WCFServiceProxy <IOperRightManage> proxy = null; try { proxy = new WCFServiceProxy <IOperRightManage>(); list = proxy.getChannel.LoadDefineMenuByLoginOper(info, false); } catch { return(string.Empty); } finally { if (proxy != null) { proxy.CloseChannel(); } } List <DefineMenu> tmp = new List <DefineMenu>(); List <DefineMenu> tmp1 = new List <DefineMenu>(); var vList = list.Where(p => p.Type == "00"); if (vList != null) { tmp = vList.OrderBy(p => p.OrderNum).ToList(); } else { tmp = null; } StringBuilder menuApp = new StringBuilder(); menuApp.Append("["); foreach (DefineMenu node in tmp) { if (menuApp.Length > 1) { menuApp.Append(","); } menuApp.Append("{"); menuApp.Append("No:'" + node.MenuCode + "'"); menuApp.Append(",Name:'" + node.Name + "'"); menuApp.Append(",Img:'" + node.ImageUrl + "'"); menuApp.Append(",Url:'" + node.UrlClass + "'"); menuApp.Append(",Children:["); var vvList = list.Where(p => (p.Type == "01" || p.Type == "03") && p.FatherCode == node.MenuCode); if (vvList != null) { tmp1 = vvList.OrderBy(p => p.OrderNum).ToList(); } else { tmp1 = null; } if (tmp1.Count > 0) { string childrenMenu = ""; foreach (DefineMenu cNode in tmp1) { if (childrenMenu.Length > 0) { childrenMenu += ","; } childrenMenu += "{"; childrenMenu += "No:'" + cNode.MenuCode + "'"; childrenMenu += ",Name:'" + cNode.Name + "'"; childrenMenu += ",Img:'" + cNode.ImageUrl + "'"; childrenMenu += ",Url:'" + cNode.UrlClass + "'"; childrenMenu += ",Children:[]"; childrenMenu += "}"; } menuApp.Append(childrenMenu); } menuApp.Append("]}"); } menuApp.Append("]"); return(menuApp.ToString()); }