Example #1
0
        /// <summary>
        /// 删除用户档案
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public Message DeleteUserMeter(View_UserMeter info)
        {
            // 定义执行结果
            Message m;
            string  configName = System.Configuration.ConfigurationManager.AppSettings["defaultDatabase"];
            //Linq to SQL 上下文对象
            DataContext dd = new DataContext(System.Configuration.ConfigurationManager.ConnectionStrings[configName].ConnectionString);

            try
            {
                // 获得上下文对象中的表信息
                Table <IoT_Meter> tbl = dd.GetTable <IoT_Meter>();

                var s = tbl.Where(p => p.CompanyID == info.CompanyID && p.UserID == info.UserID).Single();
                tbl.DeleteOnSubmit(s as IoT_Meter);

                Table <IoT_MeterDataHistory> dhTbl = dd.GetTable <IoT_MeterDataHistory>();

                var data = dhTbl.Where(p => p.MeterNo == info.MeterNo);
                dhTbl.DeleteAllOnSubmit(data);

                Table <IoT_ValveControl> valTB = dd.GetTable <IoT_ValveControl>();
                var vavData = valTB.Where(p => p.CompanyID == info.CompanyID && p.MeterNo == info.MeterNo);

                valTB.DeleteAllOnSubmit(vavData);

                Table <IoT_AlarmInfo> alertTb = dd.GetTable <IoT_AlarmInfo>();
                var alertData = alertTb.Where(p => p.MeterNo == info.MeterNo);
                alertTb.DeleteAllOnSubmit(alertData);

                Table <Iot_MeterAlarmPara> mapTb = dd.GetTable <Iot_MeterAlarmPara>();
                var meterAlertData = mapTb.Where(p => p.MeterNo == info.MeterNo);
                mapTb.DeleteAllOnSubmit(meterAlertData);

                Table <IoT_User> tbl_user = dd.GetTable <IoT_User>();
                var u = tbl_user.Where(p => p.CompanyID == info.CompanyID && p.UserID == info.UserID).Single();
                tbl_user.DeleteOnSubmit(u as IoT_User);

                // 更新操作
                dd.SubmitChanges();
                new MongoDataHelper.TaskManageDA().DeleteMeter(info.MeterNo);
                m = new Message()
                {
                    Result     = true,
                    TxtMessage = "删除用户成功!"
                };
            }
            catch (Exception e)
            {
                m = new Message()
                {
                    Result     = false,
                    TxtMessage = "删除用户失败!" + e.Message
                };
            }
            return(m);
        }
Example #2
0
        /// <summary>
        /// 获取表号根据户号
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public string GetUserMeterByUserId(string userId, string companyId)
        {
            string      meterNo;
            string      configName = System.Configuration.ConfigurationManager.AppSettings["defaultDatabase"];
            DataContext dd         = new DataContext(System.Configuration.ConfigurationManager.ConnectionStrings[configName].ConnectionString);

            try
            {
                View_UserMeter m = dd.GetTable <View_UserMeter>().Where(p => p.CompanyID == companyId && p.UserID == userId).SingleOrDefault();
                meterNo = m.MeterNo;
            }
            catch (Exception e) {
                meterNo = "";
            }
            return(meterNo);
        }
Example #3
0
        public View_UserMeter getView_UserMeterList(string UserID, string MeterNo, string CompanyID)
        {
            View_UserMeter m;
            string         configName = System.Configuration.ConfigurationManager.AppSettings["defaultDatabase"];
            DataContext    dd         = new DataContext(System.Configuration.ConfigurationManager.ConnectionStrings[configName].ConnectionString);

            try
            {
                View_UserMeter meterTempList = dd.GetTable <View_UserMeter>().Where(p => p.CompanyID == CompanyID & p.MeterNo == MeterNo & p.UserID == UserID).FirstOrDefault();
                m = meterTempList;
            }
            catch (Exception e)
            {
                m = null;
            }
            return(m);
        }
Example #4
0
        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_ChangeMeter             Info;
            WCFServiceProxy <IHuanBiao> Iproxy = null;

            try
            {
                switch (AjaxType)
                {
                //查询换标记录
                case "QUERY":
                    CommonSearch <View_HuanBiao> InfoSearch = new CommonSearch <View_HuanBiao>();
                    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_HuanBiao", TFieldKey = "HID", TTotalCount = -1, TPageCurrent = 1, TFieldOrder = "FinishedDate DESC", TWhere = Where
                    };
                    List <View_HuanBiao> list = InfoSearch.GetList(ref sCondition, context);

                    jsonMessage = new Message()
                    {
                        Result     = true,
                        TxtMessage = JSon.ListToJson <View_HuanBiao>(list, sCondition.TTotalCount)
                    };
                    break;

                //查询换标历史记录
                case "HISTORYMETER":
                    CommonSearch <View_HistoryUserMeter> InfoSearch1 = new CommonSearch <View_HistoryUserMeter>();

                    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_HistoryUserMeter", TFieldKey = "MeterNo", TTotalCount = -1, TPageCurrent = 1, TFieldOrder = "MeterNo DESC", TWhere = Where
                    };
                    List <View_HistoryUserMeter> list1 = InfoSearch1.GetList(ref sCondition, context);

                    jsonMessage = new Message()
                    {
                        Result     = true,
                        TxtMessage = JSon.ListToJson <View_HistoryUserMeter>(list1, sCondition.TTotalCount)
                    };
                    break;

                //新增换标申请
                case "ADD":
                    if (CommonOperRightHelper.CheckMenuCode(base.loginOperator, "szbjcs"))
                    {
                        Info = new CommonModelFactory <IoT_ChangeMeter>().GetModelFromContext(context);
                        List <IoT_ChangeMeter> lstIoT_ChangeMeter = new List <IoT_ChangeMeter>();
                        View_UserMeter         View_UserMeters    = new View_UserMeter();
                        string MeterNo = string.IsNullOrEmpty(context.Request["MeterNo"]) == true ? "" : context.Request["MeterNo"].ToString();
                        string UserID  = string.IsNullOrEmpty(context.Request["UserID"]) == true ? "" : context.Request["UserID"].ToString();
                        string Reason  = string.IsNullOrEmpty(context.Request["Reason"]) == true ? "" : context.Request["Reason"].ToString();
                        Iproxy          = new WCFServiceProxy <IHuanBiao>();
                        View_UserMeters = Iproxy.getChannel.getView_UserMeterList(UserID, MeterNo, loginOperator.CompanyID);
                        Info.CompanyID  = View_UserMeters.CompanyID;
                        //Info.OldGasSum = View_UserMeters.LastTotal;这里不太清楚
                        Info.OldMeterNo = View_UserMeters.MeterNo;
                        Info.Reason     = Reason;
                        Info.State      = '1';
                        Info.UserID     = View_UserMeters.UserID;
                        //Info.ChangeUseSum = View_UserMeters.CompanyID;
                        //Info.ChangeGasSum = View_UserMeters.CompanyID;
                        //Info.p = View_UserMeters.CompanyID;
                        Info.RegisterDate = DateTime.Now;
                        jsonMessage       = Iproxy.getChannel.AddShenQing(Info);
                    }
                    break;

                //修改换标申请
                case "EDIT":
                    if (CommonOperRightHelper.CheckMenuCode(base.loginOperator, "szbjcs"))
                    {
                        Info = new CommonModelFactory <IoT_ChangeMeter>().GetModelFromContext(context);
                        string Reason = string.IsNullOrEmpty(context.Request["Reason"]) == true ? "" : context.Request["Reason"].ToString();
                        string HID    = string.IsNullOrEmpty(context.Request["HID"]) == true ? "" : context.Request["HID"].ToString();
                        Info.ID        = int.Parse(HID);
                        Info.Reason    = Reason;
                        Info.CompanyID = loginOperator.CompanyID;
                        Iproxy         = new WCFServiceProxy <IHuanBiao>();
                        jsonMessage    = Iproxy.getChannel.Edit(Info);
                    }
                    break;

                //撤销换表申请
                case "REVOKE":
                    if (CommonOperRightHelper.CheckMenuCode(base.loginOperator, "SQREVOKE"))
                    {
                        Iproxy = new WCFServiceProxy <IHuanBiao>();
                        string ID = string.Empty;
                        if (context.Request["HID"] != null && context.Request["HID"].ToString().Trim() != string.Empty)
                        {
                            ID = context.Request["HID"].ToString() == "" ? "0" : context.Request["HID"].ToString();
                        }
                        jsonMessage = Iproxy.getChannel.revoke(ID, loginOperator.CompanyID);
                    }
                    break;

                //换表登记
                case "DENGJI":
                    if (CommonOperRightHelper.CheckMenuCode(base.loginOperator, "DENGJI"))
                    {
                        string dayGas          = string.Empty; //上期结算底数
                        string NewMeterType_DJ = string.Empty; //新表类型
                        string TotalAmountS    = string.Empty; //本期用量
                        string MeterType_DJ    = string.Empty; //原表类型
                        string Direction_DJ    = string.Empty; //原表进气方向
                        string ID = string.Empty;              //原表进气方向
                        if (context.Request.Form["dayGas"] != null && context.Request.Form["dayGas"].ToString().Trim() != string.Empty)
                        {
                            dayGas = context.Request.Form["dayGas"].ToString() == "" ? "0" : context.Request.Form["dayGas"].ToString();
                        }
                        if (context.Request.Form["NewMeterType_DJ"] != null && context.Request.Form["dayGas"].ToString().Trim() != string.Empty)
                        {
                            NewMeterType_DJ = context.Request.Form["NewMeterType_DJ"].ToString() == "" ? "" : context.Request.Form["NewMeterType_DJ"].ToString();
                        }
                        if (context.Request.Form["TotalAmountS"] != null && context.Request.Form["TotalAmountS"].ToString().Trim() != string.Empty)
                        {
                            TotalAmountS = context.Request.Form["TotalAmountS"].ToString() == "" ? "0" : context.Request.Form["TotalAmountS"].ToString();
                        }
                        if (context.Request.Form["MeterType_DJ"] != null && context.Request.Form["MeterType_DJ"].ToString().Trim() != string.Empty)
                        {
                            MeterType_DJ = context.Request.Form["MeterType_DJ"].ToString() == "" ? "" : context.Request.Form["MeterType_DJ"].ToString();
                        }
                        if (context.Request.Form["Direction_DJ"] != null && context.Request.Form["Direction_DJ"].ToString().Trim() != string.Empty)
                        {
                            Direction_DJ = context.Request.Form["Direction_DJ"].ToString() == "" ? "" : context.Request.Form["Direction_DJ"].ToString();
                        }
                        if (context.Request.Form["ID"] != null && context.Request.Form["ID"].ToString().Trim() != string.Empty)
                        {
                            ID = context.Request.Form["ID"].ToString() == "" ? "0" : context.Request.Form["ID"].ToString();
                        }
                        Info           = new CommonModelFactory <IoT_ChangeMeter>().GetModelFromContext(context);
                        Info.CompanyID = loginOperator.CompanyID;
                        Info.State     = '2';
                        Info.ID        = int.Parse(ID);
                        Iproxy         = new WCFServiceProxy <IHuanBiao>();
                        if (MeterType_DJ != "01")  //不是金额表则将换表时剩余金额改为0
                        {
                            Info.RemainingAmount = 0;
                        }
                        //注意换表时剩余金额(仅针对金额表)
                        jsonMessage = Iproxy.getChannel.Dengji(Info);
                    }
                    break;

                default:
                    jsonMessage = new Message()
                    {
                        Result     = false,
                        TxtMessage = "操作未定义。"
                    };
                    break;
                }
            }
            catch (Exception ex)
            {
                jsonMessage = new Message()
                {
                    Result     = false,
                    TxtMessage = ex.Message
                };
            }
            finally
            {
                if (Iproxy != null)
                {
                    Iproxy.CloseChannel();
                }
            }
            context.Response.Write(JSon.TToJson <Message>(jsonMessage));
        }
Example #5
0
        public string UpdateIotUser(string account, string pwd, string userInfoJson, string meterInfoJson)
        {
            string LoginPsw  = pwd;
            string CompanyID = string.Empty;
            string OperID    = string.Empty;

            try
            {
                string[] acc = account.Replace("-", "").Split('@');
                if (acc.Length != 2)
                {
                    return("账号错误");
                }
                OperID    = acc[0];
                CompanyID = acc[1];

                //验证账号密码
                string result = Login(account, pwd);
                if (result != "")
                {
                    return(result);
                }
                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;

                View_UserMeter viewInfo = new View_UserMeter()
                {
                    CompanyID = user.CompanyID,
                    Address   = user.Address,
                    Community = user.Community,
                    Door      = user.Door,
                    BGL       = user.BGL,
                    BWGCD     = user.BWGCD,
                    BXGMRQ    = user.BXGMRQ,
                    BXGMRSFZ  = user.BXGMRSFZ,
                    BXYXQ     = user.BXYXQ,
                    BZCZYBH   = user.BZCZYBH,
                    BZFY      = user.BZFY,
                    BZRQ      = user.BZRQ,
                    DY        = user.DY,
                    LD        = user.LD,
                    Phone     = user.Phone,
                    FYQHTR    = user.FYQHTR,
                    UserID    = user.UserID,
                    UserName  = user.UserName,
                    UserType  = user.UserType,
                    SFZH      = user.SFZH,
                    Street    = user.Street,
                    SYBWG     = user.SYBWG,
                    YGBX      = user.YGBX,
                    QYQHTR    = user.QYQHTR,
                    YJBZFY    = user.YJBZFY,
                    YQHTBH    = user.YQHTBH,
                    YQHTQD    = user.YQHTQD,
                    YQHTQDRQ  = user.YQHTQDRQ,
                    ZCZJE     = user.ZCZJE,
                    ZQF       = user.ZQF,
                    ZS        = user.ZS,
                    ZYQL      = user.ZYQL,

                    MeterID      = meter.ID,
                    Direction    = meter.Direction,
                    Installer    = meter.Installer,
                    MeterNo      = meter.MeterNo,
                    IotPhone     = meter.IotPhone,
                    FDKH1        = meter.FDKH1,
                    InstallDate  = meter.InstallDate,
                    InstallPlace = meter.InstallPlace,
                    InstallType  = meter.InstallType,
                    MeterRange   = meter.MeterRange
                };

                WCFServiceProxy <IUserManage> proxy = new WCFServiceProxy <IUserManage>();
                Message jsonMessage = proxy.getChannel.EditUserMeter(viewInfo);
                if (!jsonMessage.Result)
                {
                    return(jsonMessage.TxtMessage);
                }
            }
            catch (Exception e)
            {
            }

            return("");
        }
Example #6
0
        /// <summary>
        /// 编辑用户档案
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public Message EditUserMeter(View_UserMeter info)
        {
            // 定义执行结果
            Message m;
            string  configName = System.Configuration.ConfigurationManager.AppSettings["defaultDatabase"];
            //Linq to SQL 上下文对象
            DataContext dd = new DataContext(System.Configuration.ConfigurationManager.ConnectionStrings[configName].ConnectionString);

            try
            {
                IoT_User dbinfo = dd.GetTable <IoT_User>().Where(p => p.CompanyID == info.CompanyID && p.UserID == info.UserID).SingleOrDefault();

                //dbinfo.UserID = info.UserID;
                dbinfo.UserName  = info.UserName;
                dbinfo.Street    = info.Street;
                dbinfo.Community = info.Community;
                dbinfo.Door      = info.Door;
                dbinfo.Address   = info.Address;
                dbinfo.Phone     = info.Phone;
                dbinfo.LD        = info.LD;
                dbinfo.DY        = info.DY;
                dbinfo.BGL       = info.BGL;
                dbinfo.BWGCD     = info.BWGCD;
                dbinfo.YGBX      = info.YGBX;
                dbinfo.BXGMRQ    = info.BXGMRQ;
                dbinfo.BXGMRSFZ  = info.BXGMRSFZ;
                dbinfo.BXYXQ     = info.BXYXQ;
                dbinfo.BZCZYBH   = info.BZCZYBH;
                dbinfo.BZFY      = info.BZFY;
                dbinfo.BZRQ      = info.BZRQ;
                dbinfo.FYQHTR    = info.FYQHTR;
                dbinfo.QYQHTR    = info.QYQHTR;
                dbinfo.SFZH      = info.SFZH;
                dbinfo.SYBWG     = info.SYBWG;
                dbinfo.UserType  = info.UserType;
                dbinfo.ZS        = info.ZS;
                dbinfo.YQHTQD    = info.YQHTQD;
                dbinfo.YQHTQDRQ  = info.YQHTQDRQ;
                dbinfo.YQHTBH    = info.YQHTBH;

                IoT_Meter dbMeterinfo = dd.GetTable <IoT_Meter>().Where(p =>
                                                                        p.CompanyID == info.CompanyID && p.UserID == info.UserID).SingleOrDefault();

                if (dbMeterinfo.MeterNo.Trim() != info.MeterNo.Trim())
                {
                    UpadteMeterNo(dbMeterinfo.MeterNo, info.MeterNo);
                }
                dbMeterinfo.FDKH1        = info.FDKH1;
                dbMeterinfo.FDKH2        = info.FDKH2;
                dbMeterinfo.InstallDate  = info.InstallDate;
                dbMeterinfo.Installer    = info.Installer;
                dbMeterinfo.InstallPlace = info.InstallPlace;
                dbMeterinfo.InstallType  = info.InstallType;
                dbMeterinfo.IotPhone     = info.IotPhone;
                dbMeterinfo.MeterRange   = info.MeterRange;
                dbMeterinfo.Direction    = info.Direction;
                dbMeterinfo.MeterModel   = info.MeterModel;



                // 更新操作
                dd.SubmitChanges();

                View_UserMeter viewInfo = dd.GetTable <View_UserMeter>().Where(p =>
                                                                               p.CompanyID == info.CompanyID && p.UserID == info.UserID).SingleOrDefault();

                m = new Message()
                {
                    Result     = true,
                    TxtMessage = JSon.TToJson <View_UserMeter>(viewInfo)
                };
            }
            catch (Exception e)
            {
                m = new Message()
                {
                    Result     = false,
                    TxtMessage = "编辑用户失败!" + e.Message
                };
            }
            return(m);
        }