protected void Page_Load(object sender, EventArgs e) { string CompanyID = Request.QueryString["CompanyID"] == null ? string.Empty : Request.QueryString["CompanyID"].ToString(); string AC_ID = Request.QueryString["AC_ID"] == null ? string.Empty : Request.QueryString["AC_ID"].ToString(); if (AC_ID == "" || CompanyID == "") { Response.Write("<script>alert('参数错误!AC_ID,CompanyID不能为空!')</script>"); return; } ADItem Info = new ADItem(); WCFServiceProxy <IADItemDAL> proxy = null; proxy = new WCFServiceProxy <IADItemDAL>(); //提出显示图片ACID List <ADItem> listView = proxy.getChannel.getListShow(long.Parse(AC_ID)); //把数据写到特定DIV中; for (int i = 0; i < listView.Count; i++) { imgArray += "<img src='ADMPlayShow.aspx?fileLen=" + listView[i].FileLength + "&StoreName=" + listView[i].StoreName + "&CompanyID=" + CompanyID + "' title='" + listView[i].FileName + "' />"; } }
protected void Page_Load(object sender, EventArgs e) { HttpContext context = Context; if (context.Session["LoginCompanyOperator"] != null) { CompanyOperator Loginer = (CompanyOperator)context.Session["LoginCompanyOperator"]; WCFServiceProxy <IAdInfoManage> proxy = new WCFServiceProxy <IAdInfoManage>(); int id = int.Parse(context.Request.QueryString["FileId"]); IoT_AdInfo adInfo = proxy.getChannel.GetAdInfoData(id); byte[] images = adInfo.FileData.ToArray(); MemoryStream ms = new MemoryStream(images); context.Response.ClearContent(); context.Response.ContentType = "image/jpeg"; context.Response.BinaryWrite(ms.ToArray());//这里的Write改成BinaryWrite即可 context.Response.End(); } }
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 { } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["LoginCompanyOperator"] == null) { //向数据中心记录登录信息 try { WCFServiceProxy <ILoginerManage> proxy = new WCFServiceProxy <ILoginerManage>(); string webCookie = Session.SessionID.ToString(); CompanyOperator dCLoginer = proxy.getChannel.GetLoginerByMd5Cookie(Md5.GetMd5(webCookie)); if (dCLoginer != null) { dCLoginer.Pwd = string.Empty; Session["LoginCompanyOperator"] = dCLoginer; } else { Response.Redirect("Login.aspx", true); } } 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()); }
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); } } }
protected void Page_Load(object sender, EventArgs e) { if (Session["LoginCompanyOperator"] == null) { //向数据中心记录登录信息 try { WCFServiceProxy <ILoginerManage> proxy = new WCFServiceProxy <ILoginerManage>(); string webCookie = Session.SessionID.ToString(); CompanyOperator dCLoginer = proxy.getChannel.GetLoginerByMd5Cookie(Md5.GetMd5(webCookie)); if (dCLoginer != null) { dCLoginer.Pwd = string.Empty; Session["LoginCompanyOperator"] = dCLoginer; } } catch (Exception) { return; } } if (Session["LoginCompanyOperator"] != null) { CompanyOperator Loginer = (CompanyOperator)Session["LoginCompanyOperator"]; try { LoadReport(Loginer); } catch { } } else { Response.Write("<script> window.top.location.href = '../Login.aspx';</script>"); } }
public string ReadFileSeg(Stream stream, string companyID, string fileName, int fileLength, int totalSegments, int currentSegmentsIndex, int dataLength) { lock (_readOnly) { string result = ""; if (totalSegments < currentSegmentsIndex) { return("请求当前段号大于文件同段数"); } byte[] buffer = ADFileCached.getInstance().ReadFileSegment(companyID, fileName, fileLength, totalSegments, currentSegmentsIndex); if (buffer == null) { buffer = ADFileCached.getInstance().ReadFile(companyID, fileName); if (buffer == null) { //没有找到缓存文件 WCFServiceProxy <IADFileService> _iTaskManageProxy = new WCFServiceProxy <IADFileService>(); buffer = _iTaskManageProxy.getChannel.DownLoad(companyID, fileName); _iTaskManageProxy.Close(); ADFileCached.getInstance().SaveFile(buffer, companyID, fileName); } MemoryStream ms = new MemoryStream(); int bPos = (currentSegmentsIndex - 1) * 1024; if ((bPos + 1024) > (fileLength - 1)) { dataLength = fileLength - bPos; } else { dataLength = 1024; } ms.Write(buffer, bPos, dataLength); buffer = new byte[dataLength]; ms.Position = 0; ms.Read(buffer, 0, dataLength); ms.Close(); ADFileCached.getInstance().SaveFileSegment(buffer, companyID, fileName, fileLength, totalSegments, currentSegmentsIndex); } if (buffer != null) { stream.Write(buffer, 0, buffer.Length); } else { result = "读取文件段失败"; } return(result); } }
/// <summary> /// 修改 /// </summary> /// <param name="info"></param> /// <returns></returns> public Message UPD(IoT_MeterTopUp info) { // 定义执行结果 Message m; string configName = System.Configuration.ConfigurationManager.AppSettings["defaultDatabase"]; //Linq to SQL 上下文对象 DataContext dd = new DataContext(System.Configuration.ConfigurationManager.ConnectionStrings[configName].ConnectionString); string strMessagge = string.Empty; try { //添加设置上传周期参数任务到通讯队列 //Table<IoT_MeterTopUp> tbl = dd.GetTable<IoT_MeterTopUp>(); //// 调用新增方法 //IoT_MeterTopUp IoT_MeterTopUpDB = tbl.Where(u => u.ID == info.ID).SingleOrDefault(); //IoT_MeterTopUpDB.State = '2'; //IoT_MeterTopUpDB.Oper = info.Oper; //IoT_MeterTopUpDB.Context = info.Context; //// 更新操作 //dd.SubmitChanges(); //调用接口 WCFServiceProxy <IMeterTopUp> proxy1 = null; TopUpType TopUpTypea = (TopUpType)info.TopUpType; proxy1 = new WCFServiceProxy <IMeterTopUp>(); strMessagge = proxy1.getChannel.UnTopUp(info.TaskID, info.Context, info.Oper); if (strMessagge != "") { m = new Message() { Result = false, TxtMessage = strMessagge }; } else { m = new Message() { Result = true, TxtMessage = "撤销成功!" }; } } catch (Exception e) { m = new Message() { Result = false, TxtMessage = "撤销充值失败!" + e.Message }; } return(m); }
/// <summary> /// 新增 /// </summary> /// <param name="info"></param> /// <returns></returns> public Message Add(IoT_MeterTopUp info) { // 定义执行结果 Message m; string configName = System.Configuration.ConfigurationManager.AppSettings["defaultDatabase"]; //Linq to SQL 上下文对象 DataContext dd = new DataContext(System.Configuration.ConfigurationManager.ConnectionStrings[configName].ConnectionString); string strMessagge = string.Empty; try { //添加设置上传周期参数任务到通讯队列 //Table<IoT_MeterTopUp> tbl = dd.GetTable<IoT_MeterTopUp>(); //// 调用新增方法 //tbl.InsertOnSubmit(info); //// 更新操作 //dd.SubmitChanges(); //调用接口 WCFServiceProxy <IMeterTopUp> proxy1 = null; int intTopUpType = int.Parse(info.TopUpType.ToString()); TopUpType TopUpTypea = (TopUpType)intTopUpType; proxy1 = new WCFServiceProxy <IMeterTopUp>(); strMessagge = proxy1.getChannel.Topup(info.MeterNo, decimal.Parse(info.Amount.ToString()), TopUpTypea, info.Oper, info.OrgCode, info); m = JsonConvert.DeserializeObject <Message>(strMessagge); //if (!msg.Result) //{ // m = new Message() // { // Result = false, // TxtMessage = strMessagge // }; //} //else //{ // m = new Message() // { // Result = true, // TxtMessage = "充值成功!" // }; //} } catch (Exception e) { m = new Message() { Result = false, TxtMessage = "充值失败!" + e.Message }; } return(m); }
private void btnPublish_Click(object sender, EventArgs e) { WCFServiceProxy <IADPublishManager> _iTaskManageProxy = new WCFServiceProxy <IADPublishManager>(); string result = _iTaskManageProxy.getChannel.ADPublish(Convert.ToInt64(this.txtAP.Value)); _iTaskManageProxy.Close(); if (result == "") { MessageBox.Show("发布完成"); } else { MessageBox.Show("发布失败,原因:" + result); } }
private bool Register() { try { _iDCSServiceProxy.getChannel.Register(this.serviceNo, this.serviceName, this.serviceIP, this.servicePort); Log.getInstance().Write(MsgType.Information, string.Format("服务器:{0}-{1} 注册成功", serviceNo, serviceName)); return(true); } catch (Exception e) { _iDCSServiceProxy = new WCFServiceProxy <IDCSService>(contxt); Log.getInstance().Write(MsgType.Error, "注册服务失败,原因:" + e.Message); return(false); } }
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); }
/// <summary> /// 构造调度服务器对象 /// </summary> private DDService() { //读取服务器基本配置信息 this.serviceNo = System.Configuration.ConfigurationManager.AppSettings["CJServiceNo"]; //"0001"; this.serviceName = System.Configuration.ConfigurationManager.AppSettings["serviceName"]; // "数据采集服务器"; this.serviceIP = System.Configuration.ConfigurationManager.AppSettings["CJServiceIP"]; //IP this.servicePort = System.Configuration.ConfigurationManager.AppSettings["CJServicePort"]; //Port //向数据中心注册服务器 contxt = new InstanceContext(this); _iDCSServiceProxy = new WCFServiceProxy <IDCSService>(contxt); this.isRegister = Register(); this.myThread = new Thread(Heart); this.myThread.IsBackground = true; this.myThread.Start(); }
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)); }
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)); }
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); } } }
protected void Page_Load(object sender, EventArgs e) { string CompanyID = Request.QueryString["CompanyID"] == null ? string.Empty : Request.QueryString["CompanyID"].ToString(); string StoreName = Request.QueryString["StoreName"] == null ? string.Empty : Request.QueryString["StoreName"].ToString(); string fileLen = Request.QueryString["fileLen"] == null ? string.Empty : Request.QueryString["fileLen"].ToString(); if (CompanyID == "" || StoreName == "") { Response.Write("<script>alert('参数错误!CompanyID,StoreName不能为空!')</script>"); return; } //文件控制接口 WCFServiceProxy <IADFileService> fileContrl = new WCFServiceProxy <IADFileService>(); byte[] Fdata = new byte[int.Parse(fileLen.ToString())]; //调用图片服务器提取图片或文件的二进制串 Fdata = fileContrl.getChannel.DownLoad(CompanyID, StoreName); //判断文件类型,如果是图片格式直接输出,如果是文件进行文本图转换后输出; //取得扩展名 string fileExtendName = StoreName.Substring(StoreName.IndexOf("."), StoreName.Length - StoreName.IndexOf(".")); if (fileExtendName.IndexOf("txt") < 0) { Response.Clear(); Response.ContentType = "image/gif"; Response.BinaryWrite(Fdata); } else { string bstr = System.Text.Encoding.UTF8.GetString(Fdata); //转成文本格式; Font font = new Font("宋体", 10); //字体样式 Color fontcolor = Color.Black; //字段颜色 Color backcolor = Color.White; //背景颜色 Bitmap img = TextToBitmap(bstr, font, Rectangle.Empty, fontcolor, backcolor); //生成图片 //输出图片 MemoryStream ms = new MemoryStream(); img.Save(ms, System.Drawing.Imaging.ImageFormat.Gif); Response.BinaryWrite(ms.ToArray()); } }
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); }
private void Heart() { //调度服务到数据中心的注册维护。 while (isChecked) { Thread.Sleep(1000 * 5); if (this.isRegister) { try { this._iDCSServiceProxy.getChannel.Heart(this.serviceNo); } catch { isRegister = false; contxt = new InstanceContext(this); if (_iDCSServiceProxy != null) { try { if (_iDCSServiceProxy.State != System.ServiceModel.CommunicationState.Faulted) { _iDCSServiceProxy.Close(); } } catch { _iDCSServiceProxy.Abort(); } } _iDCSServiceProxy = new WCFServiceProxy <IDCSService>(contxt); } } else { this.isRegister = Register(); } } }
private void btnUpload_Click(object sender, EventArgs e) { WCFServiceProxy <IADFileService> _iTaskManageProxy = new WCFServiceProxy <IADFileService>(); System.IO.FileStream fs = System.IO.File.OpenRead(this.txtFile.Text); byte[] buffer = new byte[fs.Length]; fs.Read(buffer, 0, buffer.Length); fs.Close(); string fileName = string.Format("{0}{1}{2}{3}", txtCompanyID.Text, txtDate.Text, txtOrder.Value.ToString().PadLeft(5, '0'), System.IO.Path.GetExtension(this.txtFile.Text)); string result = _iTaskManageProxy.getChannel.UpLoad(txtCompanyID.Text, fileName, buffer); _iTaskManageProxy.Close(); if (result == "") { MessageBox.Show("上传完成。"); this.txtOrder.Value++; } else { MessageBox.Show("上传失败,原因:" + result); } }
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 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 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 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 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 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 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_PricePar Info; WCFServiceProxy <IPriceParManage> proxy = null; try { switch (AjaxType) { case "QUERY": CommonSearch <IoT_PricePar> InfoSearch = new CommonSearch <IoT_PricePar>(); 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 = "IoT_PricePar", TFieldKey = "ID", TTotalCount = -1, TPageCurrent = 1, TFieldOrder = "ID ASC", TWhere = Where }; List <IoT_PricePar> list = InfoSearch.GetList(ref sCondition, context); jsonMessage = new Message() { Result = true, TxtMessage = JSon.ListToJson <IoT_PricePar>(list, sCondition.TTotalCount) }; break; case "ADD": if (CommonOperRightHelper.CheckMenuCode(base.loginOperator, "jggl_tjjg")) { Info = new CommonModelFactory <IoT_PricePar>().GetModelFromContext(context); Info.CompanyID = loginOperator.CompanyID; proxy = new WCFServiceProxy <IPriceParManage>(); jsonMessage = proxy.getChannel.Add(Info); } break; case "EDIT": if (CommonOperRightHelper.CheckMenuCode(base.loginOperator, "jggl_bjjg")) { Info = new CommonModelFactory <IoT_PricePar>().GetModelFromContext(context); proxy = new WCFServiceProxy <IPriceParManage>(); jsonMessage = proxy.getChannel.Edit(Info); } break; case "DELETE": if (CommonOperRightHelper.CheckMenuCode(base.loginOperator, "jggl_scjg")) { Info = new CommonModelFactory <IoT_PricePar>().GetModelFromContext(context); proxy = new WCFServiceProxy <IPriceParManage>(); jsonMessage = proxy.getChannel.Delete(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)); }