Example #1
0
        private void GetAreaTreeList(int parent_id, ref Treeview pTr, ref DataTable dtSource)
        {
            DataRow[] pArr  = dtSource.Select("Parent_id=" + parent_id, "Co_id");
            int       pRows = pArr.Count();

            if (pRows > 0)
            {
                pTr.nodes = new List <Treeview>();
            }
            foreach (DataRow dr in pArr)
            {
                int      co_id = CommFunc.ConvertDBNullToInt32(dr["Co_id"]);
                Treeview cTr   = new Treeview();
                cTr.id         = co_id.ToString();
                cTr.text       = CommFunc.ConvertDBNullToString(dr["CoName"]);
                cTr.attributes = parent_id; // new { areaId = co_id, attrib = CoAttrib.Area, parent_id = parent_id };
                pTr.nodes.Add(cTr);
                this.GetAreaTreeList(co_id, ref cTr, ref dtSource);
            }
        }
Example #2
0
        /// <summary>
        /// 硬删除角色信息
        /// </summary>
        /// <param name="Uid"></param>
        public void DelRole(int Role_id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Clear();
            strSql.Append("SELECT UserType FROM sys_role WHERE Ledger=@Ledger and Role_id=@Role_id and UserType=0;");
            DataTable obj = SQLHelper.Query(strSql.ToString(), new { Ledger = this.Ledger, Role_id = Role_id });

            if (CommFunc.ConvertDBNullToInt32(obj.Rows[0]["UserType"]) > 0)
            {
                throw new Exception("此用户为厂家角色,不可删除");
            }
            strSql.Clear();
            strSql.Append(" delete from sys_role  where Ledger=@Ledger");
            if (Role_id != 0)
            {
                strSql.Append(" and Role_id=@Role_id");
            }
            SQLHelper.Execute(strSql.ToString(), new { Ledger = this.Ledger, Role_id = Role_id });
        }
Example #3
0
        /// <summary>
        /// 设置物业收费-单价详情
        /// </summary>
        /// <param name="Rate_id">费率ID号</param>
        /// <param name="CsId">单价ID号</param>
        /// <param name="Price">单价</param>
        /// <param name="pStart">开始区间</param>
        /// <param name="pEnd">结束区间</param>
        /// <returns></returns>
        public int SetSaveYdRateNewCs(int Rate_id, int CsId, decimal Price, string pStart, string pEnd)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Clear();
            DataTable obj = null;

            if (CsId == 0)
            {
                strSql.Clear();
                strSql.Append("select max(CsId) as Id from v1_rate_cs where Ledger=@Ledger and Rate_id=@Rate_id");
                obj  = SQLHelper.Query(strSql.ToString(), new { Ledger = this.Ledger, Rate_id = Rate_id });
                CsId = obj.Rows.Count > 0 ? CommFunc.ConvertDBNullToInt32(obj.Rows[0]["Id"]) + 1 : 1;
                //CsId = CommFunc.ConvertDBNullToInt32(obj.Rows[0]["Id"]) + 1;
            }
            strSql.Clear();
            strSql.Append("insert into v1_rate_cs(Ledger,Rate_id,CsId,Price,PStart,PEnd,Update_by,Update_dt)values(@Ledger,@Rate_id,@CsId,@Price,@PStart,@PEnd,@SysUid,now())");
            strSql.Append(" ON DUPLICATE KEY UPDATE Price=@Price,PStart=@PStart,PEnd=@PEnd,Update_by=@SysUid,Update_dt=now()");
            return(SQLHelper.Execute(strSql.ToString(), new { Ledger = this.Ledger, Rate_id = Rate_id, CsId = CsId, Price = Price, PStart = pStart, PEnd = pEnd, SysUid = this.SysUid }));
        }
Example #4
0
        /// <summary>
        /// 设置邮件接口信息
        /// </summary>
        /// <param name="MailFrom">邮件发送人</param>
        /// <param name="MailSmtpHost">邮件服务器地址</param>
        /// <param name="MailSmtpPassword">邮件登陆密码</param>
        /// <param name="MailSmtpUser">邮件登陆名</param>
        /// <returns></returns>
        public int SetMailConfig(string MailFrom, string MailSmtpHost, string MailSmtpPassword, string MailSmtpUser)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Clear();
            strSql.Append("insert into sys_config(Ledger,CfKey,CfType,CfValue,Rule)values(@Ledger,'MailFrom','Email',@MailFrom,'')");
            strSql.Append("ON DUPLICATE KEY UPDATE CfValue=@MailFrom;");
            //
            strSql.Append("insert into sys_config(Ledger,CfKey,CfType,CfValue,Rule)values(@Ledger,'MailSmtpHost','Email',@MailSmtpHost,'')");
            strSql.Append("ON DUPLICATE KEY UPDATE CfValue=@MailSmtpHost;");
            //
            strSql.Append("insert into sys_config(Ledger,CfKey,CfType,CfValue,Rule)values(@Ledger,'MailSmtpPassword','Email',@MailSmtpPassword,'')");
            strSql.Append("ON DUPLICATE KEY UPDATE CfValue=@MailSmtpPassword;");
            //
            strSql.Append("insert into sys_config(Ledger,CfKey,CfType,CfValue,Rule)values(@Ledger,'MailSmtpUser','Email',@MailSmtpUser,'')");
            strSql.Append("ON DUPLICATE KEY UPDATE CfValue=@MailSmtpUser;");
            object obj = SQLHelper.Execute(strSql.ToString(), new { Ledger = this.Ledger, MailFrom = MailFrom, MailSmtpHost = MailSmtpHost, MailSmtpPassword = MailSmtpPassword, MailSmtpUser = MailSmtpUser });

            return(CommFunc.ConvertDBNullToInt32(obj));
        }
Example #5
0
        public DataTable GetYdAlarmOfChargeList(string CoStrcName, string CoName, string IsPay, DateTime Start, DateTime End)
        {
            DataTable dtSource = dal.GetYdAlarmOfChargeList(CoStrcName, CoName, IsPay, Start, End);

            dtSource.Columns.Add("RowId", typeof(System.Int32));
            dtSource.Columns.Add("PayTypeS", typeof(System.String));
            dtSource.Columns.Add("IsPayS", typeof(System.String));
            int RowId = 0;

            foreach (DataRow dr in dtSource.Rows)
            {
                dr["RowId"] = ++RowId;
                int payType = CommFunc.ConvertDBNullToInt32(dr["PayType"]);
                int ispay   = CommFunc.ConvertDBNullToInt32(dr["IsPay"]);
                if (payType == (int)PayType.pay)
                {
                    dr["PayTypeS"] = "充值";
                }
                if (payType == (int)PayType.refund)
                {
                    dr["PayTypeS"] = "退费";
                }
                if (payType == (int)PayType.present)
                {
                    dr["PayTypeS"] = "赠电";
                }
                if (payType == (int)PayType.reback)
                {
                    dr["PayTypeS"] = "退赠电";
                }
                if (ispay == 0)
                {
                    dr["IsPayS"] = "现金支付";
                }
                if ((ispay >= 10 && ispay < 20) || ispay == 1)
                {
                    dr["IsPayS"] = "微信支付";
                }
            }
            return(dtSource);
        }
Example #6
0
        //缴费总列表
        public APIRst GetYdPrePayInMdOnList(string strcName, string coName, int co_id)
        {
            APIRst rst = new APIRst();

            try
            {
                DataTable dtSource = bll.GetYdPrePayInMdOnList(strcName, coName, co_id);
                int       total    = dtSource.Rows.Count;
                int       RowId    = 0;
                var       res1     = from s1 in dtSource.AsEnumerable()
                                     select new
                {
                    RowId      = ++RowId,
                    Co_id      = CommFunc.ConvertDBNullToInt32(s1["Co_id"]),
                    CoStrcName = CommFunc.ConvertDBNullToString(s1["CoStrcName"]),
                    CoName     = CommFunc.ConvertDBNullToString(s1["CoName"]),
                    Module_id  = CommFunc.ConvertDBNullToInt32(s1["Module_id"]),
                    MeterName  = CommFunc.ConvertDBNullToString(s1["MeterName"]),
                    Fun_id     = CommFunc.ConvertDBNullToInt32(s1["Fun_id"]),
                    ModuleAddr = CommFunc.ConvertDBNullToString(s1["ModuleAddr"]),
                    ChrgVal    = CommFunc.ConvertDBNullToDecimal(s1["ChrgVal"]).ToString("f2"),
                    UseVal     = CommFunc.ConvertDBNullToDecimal(s1["UseVal"]).ToString("f2"),
                    RdVal      = CommFunc.ConvertDBNullToDecimal(s1["RdVal"]).ToString("f2"),
                    RdAmt      = (CommFunc.ConvertDBNullToDecimal(s1["RdVal"]) * CommFunc.ConvertDBNullToDecimal(s1["Price"])).ToString("f2"),
                    Price      = CommFunc.ConvertDBNullToDecimal(s1["Price"]).ToString("f3"),
                    ZsVal      = CommFunc.ConvertDBNullToDecimal(s1["ZsVal"]).ToString("f2"),
                    SyZsVal    = CommFunc.ConvertDBNullToDecimal(s1["SyZsVal"]).ToString("f2"),
                    SyVal      = (CommFunc.ConvertDBNullToDecimal(s1["RdVal"]) - CommFunc.ConvertDBNullToDecimal(s1["SyZsVal"])).ToString("f2")
                };
                object obj = new { total = total, rows = res1.ToList() };
                rst.data = obj;
            }
            catch (Exception ex)
            {
                rst.rst      = false;
                rst.err.code = (int)ResultCodeDefine.Error;
                rst.err.msg  = ex.Message;
                FileLog.WriteLog("获取预付费页面错误:(GetYdPrePayInMdOnList)", ex.Message + ex.StackTrace);
            }
            return(rst);
        }
Example #7
0
        /// <summary>
        /// 获取用能小时数据
        /// </summary>
        /// <param name="Module_ids">回路</param>
        /// <returns></returns>
        private Dictionary <DateTime, decimal> GetDayEnergyUseValList(string Module_ids, DateTime date)
        {
            DataRow[] rows = DT_USE_HOUR.Select(string.Format("Module_id in({0})", Module_ids));
            Dictionary <DateTime, decimal> dic = new Dictionary <DateTime, decimal>();

            for (int i = 0; i < 72; i++)
            {
                dic.Add(date.AddHours(i), 0);
            }
            //List<decimal> todayList = new List<decimal>();
            //int nn = DateTime.Now.Hour;
            //while (nn-- >= 0)
            //{
            //    todayList.Add(0);
            //}
            foreach (DataRow dr in rows)
            {
                DataRow curDr = DT_SOURCE.Rows.Find(new object[] { dr["Module_id"], dr["Fun_id"] });
                if (curDr == null)
                {
                    continue;
                }
                int     scale    = CommFunc.ConvertDBNullToInt32(curDr["Scale"]);
                decimal multiply = CommFunc.ConvertDBNullToDecimal(curDr["Multiply"]);
                scale = scale == 0 ? 2 : scale;

                DateTime tagTime  = CommFunc.ConvertDBNullToDateTime(dr["TagTime"]);
                decimal  firstVal = CommFunc.ConvertDBNullToDecimal(dr["FirstVal"]);
                decimal  lastVal  = CommFunc.ConvertDBNullToDecimal(dr["LastVal"]);
                decimal  useVal   = lastVal - firstVal;
                useVal = Math.Round(useVal * multiply, scale, MidpointRounding.AwayFromZero);

                if (dic.ContainsKey(tagTime))
                {
                    dic[tagTime] = CommFunc.ConvertDBNullToDecimal(dic[tagTime]) + useVal;
                }

                //todayList[tagTime.Hour] = CommFunc.ConvertDBNullToDecimal(todayList[tagTime.Hour]) + useVal;
            }
            return(dic);
        }
Example #8
0
        /// <summary>
        /// 获取充值明细列表
        /// </summary>
        /// <param name="StrcName">建筑名称</param>
        /// <param name="CoName">房间名称</param>
        /// <param name="d_ways">缴费类型:0=全部,1=充值,2=退费,3=赠送电,4=退赠送电</param>
        /// <param name="Create_by">操作员</param>
        /// <param name="StartTime">缴费日期开始</param>
        /// <param name="EndTime">缴费日期结束</param>
        /// <returns></returns>
        public APIRst GetYdPayLogOnList(string StrcName, string CoName, int d_ways, string Create_by, DateTime StartTime, DateTime EndTime)
        {
            APIRst rst = new APIRst();

            try
            {
                DataTable dtSource = bll.GetYdPayLogOnList(StrcName, CoName, d_ways, Create_by, StartTime, EndTime);
                var       res1     = from s1 in dtSource.AsEnumerable()
                                     select new
                {
                    RowId      = CommFunc.ConvertDBNullToInt32(s1["RowId"]),
                    Co_id      = CommFunc.ConvertDBNullToInt32(s1["Co_id"]),
                    CoStrcName = CommFunc.ConvertDBNullToString(s1["CoStrcName"]),
                    CoName     = CommFunc.ConvertDBNullToString(s1["CoName"]),
                    Module_id  = CommFunc.ConvertDBNullToInt32(s1["Module_id"]),
                    ModuleName = CommFunc.ConvertDBNullToString(s1["ModuleName"]),
                    ModuleAddr = CommFunc.ConvertDBNullToString(s1["ModuleAddr"]),
                    IsPay      = CommFunc.ConvertDBNullToInt32(s1["IsPay"]),
                    IsPayS     = CommFunc.ConvertDBNullToString(s1["IsPayS"]),
                    Trade_no   = CommFunc.ConvertDBNullToString(s1["Trade_no"]),
                    PayAmt     = CommFunc.ConvertDBNullToDecimal(s1["PayAmt"]).ToString("f2"),
                    PayVal     = CommFunc.ConvertDBNullToDecimal(s1["PayVal"]).ToString("f2"),
                    ErrCode    = CommFunc.ConvertDBNullToInt32(s1["ErrCode"]),
                    ErrTxt     = (CommFunc.ConvertDBNullToInt32(s1["IsPay"]) == 1 && CommFunc.ConvertDBNullToInt32(s1["ErrCode"]) == -2) ? "用户取消" : CommFunc.ConvertDBNullToString(s1["ErrTxt"]),
                    Create_by  = CommFunc.ConvertDBNullToString(s1["Create_by"]),
                    Create_dt  = CommFunc.ConvertDBNullToDateTime(s1["Create_dt"]).ToString("yyyy-MM-dd HH:mm:ss"),
                    PayType    = CommFunc.ConvertDBNullToInt32(s1["PayType"]),
                    PayTypeS   = CommFunc.ConvertDBNullToString(s1["PayTypeS"]),
                };
                object obj = new { total = dtSource.Rows.Count, rows = res1.ToList() };
                rst.data = obj;
            }
            catch (Exception ex)
            {
                rst.rst      = false;
                rst.err.code = (int)ResultCodeDefine.Error;
                rst.err.msg  = ex.Message;
                FileLog.WriteLog("获取充值用电信息错误(GetYdPayLogOnList):" + ex.Message + ex.StackTrace);
            }
            return(rst);
        }
Example #9
0
        private object GetYdRateList(int rate_id, string descr)
        {
            DataTable dtSource = bll.GetYdRateList(rate_id, descr);
            var       res1     = from s1 in dtSource.AsEnumerable()
                                 select new
            {
                Rate_id = CommFunc.ConvertDBNullToInt32(s1["Rate_id"]),
                Descr   = CommFunc.ConvertDBNullToString(s1["Descr"]),
                Pri1st  = CommFunc.ConvertDBNullToDecimal(s1["Pri1st"]),
                Pri2nd  = CommFunc.ConvertDBNullToDecimal(s1["Pri2nd"]),
                Pri3rd  = CommFunc.ConvertDBNullToDecimal(s1["Pri3rd"]),
                Pri4th  = CommFunc.ConvertDBNullToDecimal(s1["Pri4th"]),
                T1st    = CommFunc.ConvertDBNullToString(s1["T1st"]),
                T2nd    = CommFunc.ConvertDBNullToString(s1["T2nd"]),
                T3rd    = CommFunc.ConvertDBNullToString(s1["T3rd"]),
                T4th    = CommFunc.ConvertDBNullToString(s1["T4th"]),
            };
            object obj = new { total = dtSource.Rows.Count, rows = res1.ToList() };

            return(obj);
        }
Example #10
0
        public DataTable GetDk_buy()
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Clear();
            strSql.Append("SELECT count(*)as cnt FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'dk_buy' LIMIT 1");
            object obj = SQLHelper.ExecuteScalar(strSql.ToString(), null);

            if (CommFunc.ConvertDBNullToInt32(obj) > 0)
            {
                strSql.Clear();
                strSql.Append("select a.recno,a.FJID,a.tranamt,a.endatatime,a.custsn,a.TBID");
                strSql.Append(" from dk_buy as a");
                strSql.Append(" where a.endatatime>=@Endatatime "); //and CAST(a.TBID AS SIGNED)=0
                //strSql.Append(" and not exists(select m.Ledger from v4_pay_log as m where m.Ledger=@Ledger and m.CDate>=@Endatatime and m.Co_id=a.FJID and m.ErrCode=1 and m.Month=UNIX_TIMESTAMP(a.endatatime))");
                strSql.Append(" and not exists(select m.Ledger from v4_pay_log as m where m.Ledger=@Ledger and m.CDate>=@Endatatime and m.Co_id=a.FJID and m.ErrCode=1 and m.Recno=a.recno)");
                return(SQLHelper.Query(strSql.ToString(), new { Ledger = this.Ledger, Endatatime = DateTime.Now.AddDays(-2) }));
                //return SQLHelper.Query(strSql.ToString(), new { Ledger = this.Ledger, Endatatime = new DateTime(2019, 5, 27) });
            }
            return(null);
        }
Example #11
0
        /// <summary>
        /// 设置保存物业收费
        /// </summary>
        /// <param name="Rate_id">费率ID号</param>
        /// <param name="Descr">描述</param>
        /// <param name="Rule">计算规则: 0=正常,1=时间范围,2=数量范围</param>
        /// <param name="Unit">单位: Area=平方米,Bank=户数</param>
        /// <param name="UnitBase">单位基数</param>
        /// <param name="Disabled">是否弃用:0=否,1=是</param>
        /// <returns></returns>
        public int SaveYdRateNew(v1_rateVModel rv)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Clear();
            DataTable obj = null;

            if (rv.Rate_id == 0)
            {
                strSql.Clear();
                strSql.Append("select max(Rate_id) as id from v1_rate where Ledger=@Ledger");
                obj        = SQLHelper.Query(strSql.ToString(), new { Ledger = this.Ledger });
                rv.Rate_id = obj.Rows.Count > 0 ? CommFunc.ConvertDBNullToInt32(obj.Rows[0]["id"]) + 1 : 1;
                //rv.Rate_id = CommFunc.ConvertDBNullToInt32(obj.Rows[0]["id"]) + 1;
            }
            strSql.Clear();
            strSql.Append("insert into v1_rate(Ledger,Rate_id,Descr,Attrib,Rule,Unit,UnitBase,Disabled,Create_by,Create_dt,Update_by,Update_dt)values");
            strSql.Append("(@Ledger,@Rate_id,@Descr,@Attrib,@Rule,@Unit,@UnitBase,@Disabled,@SysUid,now(),@SysUid,now())");
            strSql.Append("ON DUPLICATE KEY UPDATE Descr=@Descr,Rule=@Rule,Unit=@Unit,UnitBase=@UnitBase,Disabled=@Disabled,Update_by=@SysUid,Update_dt=now()");
            return(SQLHelper.Execute(strSql.ToString(), new { Ledger = this.Ledger, Rate_id = rv.Rate_id, Descr = rv.Descr, Attrib = rv.Attrib, Rule = rv.Rule, Unit = rv.Unit, UnitBase = rv.UnitBase, Disabled = rv.Disabled, SysUid = this.SysUid }));
        }
Example #12
0
        private List <Treeview> GetMenuTreeList(DataTable dtSource)
        {
            List <Treeview> rst = new List <Treeview>();

            DataRow[] pArr = dtSource.Select("(parent_no='0' or parent_no='') and attrib=0", "ordno,menu_no");
            foreach (DataRow dr in pArr)
            {
                Treeview pTr = new Treeview();
                pTr.id   = CommFunc.ConvertDBNullToString(dr["menu_no"]);
                pTr.text = CommFunc.ConvertDBNullToString(dr["descr"]);
                pTr.icon = CommFunc.ConvertDBNullToString(dr["icon"]);
                string child  = this.GetPower(pTr.id, ref dtSource);
                int    isShow = (CommFunc.ConvertDBNullToInt32(dr["pass"]) > 0 ? 1 : 0);
                pTr.nodes = new List <Treeview>();
                int cc = this.GetMenuTreeList(ref dtSource, ref pTr);
                isShow         = cc == 1 ? 1 : isShow;
                pTr.attributes = new { path = CommFunc.ConvertDBNullToString(dr["path"]), power = CommFunc.ConvertDBNullToString(dr["Power"]), show = isShow, child = child };
                rst.Add(pTr);
            }
            return(rst);
        }
Example #13
0
        /// <summary>
        /// 删除设备
        /// </summary>
        /// <param name="meter_id"></param>
        /// <returns></returns>
        public int DelMdInfo(int meter_id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Clear();
            strSql.Append("select count(a.Ledger)as cnt from vp_mdinfo as a inner join v2_info as b");
            strSql.Append(" on a.Ledger=b.Ledger and a.Module_id=b.Module_id and a.ModuleAddr=b.ModuleAddr");
            strSql.Append(" where a.Ledger=@Ledger and a.Meter_id=@Meter_id  limit 1");
            Object obj = SQLHelper.ExecuteScalar(strSql.ToString(), new { Ledger = this.Ledger, Meter_id = meter_id });

            if (CommFunc.ConvertDBNullToInt32(obj) > 0)
            {
                throw new Exception("此设备已经有采集数据不能删除");
            }
            strSql.Clear();
            strSql.Append("delete d,c,b,a from v1_gateway_esp_meter as a left join v1_gateway_esp_module as b on a.Ledger=b.Ledger and a.Meter_id=b.Meter_id");
            strSql.Append(" left join v1_gateway_esp_module_info as c on b.Ledger=c.Ledger and b.Module_id=c.Module_id");
            strSql.Append(" left join v1_map as d on b.Ledger=d.Ledger and b.Module_id=d.Module_id");
            strSql.Append(" where a.Ledger=@Ledger and a.Meter_id=@Meter_id");
            return(SQLHelper.Execute(strSql.ToString(), new { Ledger = this.Ledger, Meter_id = meter_id }));
        }
Example #14
0
        /// <summary>
        /// 获取传感器数据列表
        /// </summary>
        /// <returns></returns>
        public APIRst GetMonitorSensor200(int co_id)
        {
            APIRst rst = new APIRst();

            try
            {
                List <object> rb       = new List <object>();
                DataTable     dtSource = bll.GetMonitorSensor200(user.CacheKey, co_id);
                foreach (DataRow s1 in dtSource.Rows)
                {
                    object list = new
                    {
                        Val_Tag = new
                        {
                            name = "缓存key",
                            tag  = CommFunc.ConvertDBNullToString(s1["Val_Tag"]),
                            unit = CommFunc.ConvertDBNullToString(s1["Val_Unit"]),
                        }
                    };
                    object obj = new
                    {
                        RowId      = dtSource.Rows.IndexOf(s1) + 1,
                        Module_id  = CommFunc.ConvertDBNullToInt32(s1["Module_id"]),
                        ModuleName = CommFunc.ConvertDBNullToString(s1["ModuleName"]),
                        //FrMd = CommFunc.ConvertDBNullToInt32(s1["FrMd"]),
                        List = list,
                    };
                    rb.Add(obj);
                }
                rst.data = rb; // res1.ToList();
            }
            catch (Exception ex)
            {
                rst.rst      = false;
                rst.err.code = (int)ResultCodeDefine.Error;
                rst.err.msg  = ex.Message;
                FileLog.WriteLog("获取监测数据信息错误:" + ex.Message + ex.StackTrace);
            }
            return(rst);
        }
Example #15
0
        /// <summary>
        /// 上载建筑信息
        /// </summary>
        /// <param name="dtSource"></param>
        private void UpdateCoList(DataTable dtSource)
        {
            StringBuilder coSplit = new StringBuilder();
            var           res1    = (from s1 in dtSource.AsEnumerable()
                                     select new
            {
                CoFullName = CommFunc.ConvertDBNullToString(s1["CoFullName"])
            }).Distinct();

            foreach (var obj in res1)
            {
                string[] str = obj.CoFullName.Split(new string[] { "->" }, StringSplitOptions.RemoveEmptyEntries);
                if (str.Count() == 0)
                {
                    continue;
                }
                DataTable dtCoInfo = dal.GetCoInfo(str[0]);//获取全部建筑信息
                coSplit.Clear();
                int pid = 0, layer = 0;
                foreach (string name in str)
                {
                    if (!string.IsNullOrEmpty(coSplit.ToString()))
                    {
                        coSplit.Append("->");
                    }
                    coSplit.Append(CommFunc.ConvertDBNullToString(name));
                    DataRow[] arr = dtCoInfo.Select("CoFullName='" + coSplit.ToString() + "'");
                    int       co_id = 0, dbLayer = 0;
                    string    coName = "";
                    if (arr.Count() > 0)
                    {
                        co_id   = CommFunc.ConvertDBNullToInt32(arr[0]["Co_id"]);
                        dbLayer = CommFunc.ConvertDBNullToInt32(arr[0]["Layer"]);
                        coName  = CommFunc.ConvertDBNullToString(arr[0]["CoName"]);
                    }
                    pid   = dal.UpdateCoList(co_id, name.Trim(), pid, layer);/*更新建筑*/
                    layer = layer + 1;
                }
            }
        }
Example #16
0
        public int UpdateEspInfo(v1_gateway_espVModel Esp, out string msg)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Clear();
            DataTable obj = new DataTable();

            msg = "";
            if (Esp.Esp_id == 0)
            {
                strSql.Clear();
                strSql.Append("select max(Esp_id) as cnt from v1_gateway_esp where Ledger=@Ledger");
                obj        = SQLHelper.Query(strSql.ToString(), new { Ledger = this.Ledger });
                Esp.Esp_id = obj.Rows.Count > 0 ? CommFunc.ConvertDBNullToInt32(obj.Rows[0]["cnt"]) + 1 : 1;
            }
            obj = null;
            strSql.Clear();
            strSql.Append("select count(*) as cnt from v1_gateway_esp where Ledger=@Ledger and Esp_id!=@Esp_id and Gw_id=@Gw_id and (EspName=@EspName or EspAddr=@EspAddr)");
            obj = SQLHelper.Query(strSql.ToString(), new { Ledger = this.Ledger, Esp_id = Esp.Esp_id, Gw_id = Esp.Gw_id, EspName = Esp.EspName, EspAddr = Esp.EspAddr });
            if (CommFunc.ConvertDBNullToInt32(obj.Rows[0]["cnt"]) > 0)
            {
                msg = "采集器名称" + Esp.EspName + "或地址" + Esp.EspAddr + "重复";
                throw new Exception("采集器名称" + Esp.EspName + "或地址" + Esp.EspAddr + "重复");
            }

            obj = null;
            strSql.Clear();
            strSql.Append("select GwIp from v1_gateway where Ledger=@Ledger and Gw_id=@Gw_id");
            obj = SQLHelper.Query(strSql.ToString(), new { Ledger = this.Ledger, Gw_id = Esp.Gw_id });
            string EspIp = CommFunc.ConvertDBNullToString(obj.Rows[0]["GwIp"]);

            strSql.Clear();
            strSql.Append("insert into v1_gateway_esp(");
            strSql.Append("Ledger,Esp_id,Gw_id,EspName,EspAddr,TransferType,EspIp,EspPort,Timeout,EspType,ComPort,Baud,DataBit,StopBit,Parity,Inst_loc,Remark,Create_by,Create_dt,Update_by,Update_dt)");
            strSql.Append(" values (");
            strSql.Append("@Ledger,@Esp_id,@Gw_id,@EspName,@EspAddr,@TransferType,@EspIp,@EspPort,1000,'',@ComPort,@Baud,@DataBit,@StopBit,@Parity,'','',@SysUid,now(),@SysUid,now())");
            strSql.Append(" ON DUPLICATE KEY UPDATE EspAddr=@EspAddr,TransferType=@TransferType,EspIp=@EspIp,EspPort=@EspPort,ComPort=@ComPort,Baud=@Baud,DataBit=@DataBit,StopBit=@StopBit,Parity=@Parity,Update_by=@SysUid,Update_dt=now();");
            SQLHelper.Execute(strSql.ToString(), new { Ledger = this.Ledger, Esp_id = Esp.Esp_id, Gw_id = Esp.Gw_id, EspName = Esp.EspName, EspAddr = Esp.EspAddr, TransferType = Esp.TransferType, EspIp = EspIp, EspPort = Esp.EspPort, ComPort = Esp.ComPort, Baud = Esp.Baud, DataBit = Esp.DataBit, StopBit = Esp.StopBit, Parity = Esp.Parity, SysUid = this.SysUid });
            return(Esp.Esp_id);
        }
Example #17
0
        /// <summary>
        /// 保存修改错误时间
        /// </summary>
        /// <returns></returns>
        public APIRst SaveTime(int RowId, int Co_id, int Log_id, int Module_id, int Fun_id, string ModuleAddr, string LastTime)
        {
            APIRst rst = new APIRst();

            try
            {
                int total = 0;
                bll.SetV2_infoInTime(Log_id, Co_id, Module_id, ModuleAddr, Fun_id, CommFunc.ConvertDBNullToDateTime(LastTime));

                DataTable dtSource = bll.GetTabVal(Co_id, ModuleAddr);
                total = dtSource.Rows.Count;
                var res1 = from s1 in dtSource.AsEnumerable()
                           select new
                {
                    RowId       = RowId,
                    Co_id       = CommFunc.ConvertDBNullToInt32(s1["Co_id"]),
                    Log_id      = CommFunc.ConvertDBNullToInt32(s1["Log_id"]),
                    CoStrcName  = CommFunc.ConvertDBNullToString(s1["CoStrcName"]),
                    CoName      = CommFunc.ConvertDBNullToString(s1["CoName"]),
                    ModuleAddr  = CommFunc.ConvertDBNullToString(s1["ModuleAddr"]),
                    AType       = CommFunc.ConvertDBNullToString(s1["AType"]),
                    Content     = CommFunc.ConvertDBNullToString(s1["Content"]),
                    ErrCode     = CommFunc.ConvertDBNullToString(s1["ErrCode"]),
                    CollectTime = CommFunc.ConvertDBNullToDateTime(s1["CollectTime"]).ToString("yyyy-MM-dd HH:mm:ss"),
                    FirstVal    = CommFunc.ConvertDBNullToDecimal(s1["FirstVal"]),
                    LastVal     = CommFunc.ConvertDBNullToDecimal(s1["LastVal"]),
                    LastValOld  = CommFunc.ConvertDBNullToDecimal(s1["LastVal"]),
                    LastTime    = CommFunc.ConvertDBNullToDateTime(s1["LastTime"]).ToString("yyyy-MM-dd HH:mm:ss"),
                };
                rst.data = res1.ToList();
            }
            catch (Exception ex)
            {
                rst.rst      = false;
                rst.err.code = (int)ResultCodeDefine.Error;
                rst.err.msg  = ex.Message;
                FileLog.WriteLog("保存修改错误时间错误:" + ex.Message + ex.StackTrace);
            }
            return(rst);
        }
Example #18
0
        /// <summary>
        /// 赠送总电度(每月未用完电的不累计值)
        /// </summary>
        /// <param name="dbConnection"></param>
        /// <param name="trans"></param>
        /// <param name="month"></param>
        /// <param name="module_id"></param>
        /// <param name="fun_id"></param>
        /// <param name="moduleAddr"></param>
        /// <param name="co_id"></param>
        /// <param name="subTab"></param>
        private void AddRaValStep1(IDbConnection dbConnection, DateTime month, int module_id, int fun_id, string moduleAddr, int co_id, string subTab)
        {
            StringBuilder strSql = new StringBuilder();
            int           i = 0;
            decimal       mthUseVal = 0, mthRaVal = 0;

            while (i <= 6)
            {
                DateTime tagTime = month.AddMonths(0 - (++i));
                strSql.Clear();
                strSql.Append(string.Format("select count(*) from information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = @TabName LIMIT 1", tagTime.Year));
                object obj = dbConnection.ExecuteScalar(strSql.ToString(), new { TabName = "v9_month_" + subTab + tagTime.Year });
                if (CommFunc.ConvertDBNullToInt32(obj) == 0)
                {
                    continue;
                }
                DataTable dtRst = new DataTable();
                /*电表上月使用电量情况*/
                strSql.Clear();
                strSql.Append(string.Format("select sum(LastVal-FirstVal)as UseVal,sum(RaVal)as RaVal from v9_month_{0}{1}", subTab, tagTime.Year));
                strSql.Append(" where TagTime=UNIX_TIMESTAMP(@TagTime) and Ledger=@Ledger and Module_id=@Module_id and Fun_id=@Fun_id and ModuleAddr=@ModuleAddr and Co_id=@Co_id");
                var reader = dbConnection.ExecuteReader(strSql.ToString(), new { Ledger = this.Ledger, TagTime = tagTime, Module_id = module_id, Fun_id = fun_id, ModuleAddr = moduleAddr, Co_id = co_id });
                dtRst.Load(reader);
                if (dtRst.Rows.Count > 0)
                {
                    mthUseVal = CommFunc.ConvertDBNullToDecimal(dtRst.Rows[0]["UseVal"]);
                    mthRaVal  = CommFunc.ConvertDBNullToDecimal(dtRst.Rows[0]["RaVal"]);
                }
                /*电表的建筑上月使用电量情况*/
                break;
            }
            decimal mthRealVal = mthUseVal >= mthRaVal ? mthRaVal : mthUseVal;

            strSql.Clear();
            strSql.Append("update v2_info set RaVal = case when RaVal - @MthRaVal +  @MthRealVal < 0 then 0 else RaVal - @MthRaVal +  @MthRealVal end");
            strSql.Append(" where Ledger=@Ledger and Co_id=@Co_id and Module_id=@Module_id and ModuleAddr=@ModuleAddr and Fun_id=@Fun_id;");
            strSql.Append("update v4_bill set RaVal = case when RaVal - @MthRaVal +  @MthRealVal < 0 then 0 else RaVal - @MthRaVal +  @MthRealVal end ");
            strSql.Append(" where Ledger=@Ledger and Co_id=@Co_id and Fun_id=@Fun_id;");
            dbConnection.Execute(strSql.ToString(), new { Ledger = this.Ledger, Module_id = module_id, Fun_id = fun_id, ModuleAddr = moduleAddr, Co_id = co_id, MthRaVal = mthRaVal, MthRealVal = mthRealVal });
        }
Example #19
0
        /// <summary>
        /// 设置采集点信息
        /// </summary>
        /// <param name="fun"></param>
        /// <returns></returns>
        public int SetModuleFun(ModuleFunVModel fun)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Clear();
            strSql.Append("select count(*) from v0_fun where Ledger=@Ledger and Fun_id!=@Fun_id and FunType=@FunType");
            object obj = SQLHelper.ExecuteScalar(strSql.ToString(), new { Ledger = this.Ledger, Fun_id = fun.Fun_id, FunType = fun.FunType });

            if (CommFunc.ConvertDBNullToInt32(obj) > 0)
            {
                throw new Exception("已存在此采集点型号:" + fun.FunType);
            }
            if (fun.ModuleTypeId == 0)
            {
                throw new Exception("已存在此采集类型ID号为空");
            }
            if (fun.Fun_id == 0)
            {
                strSql.Clear();
                strSql.Append("select max(Fun_id)as cnt from v0_fun where Ledger=@Ledger");
                fun.Fun_id = CommFunc.ConvertDBNullToInt32(SQLHelper.ExecuteScalar(strSql.ToString(), new { Ledger = this.Ledger })) + 1;
            }
            //
            strSql.Clear();
            strSql.Append("select count(a.Ledger)as cnt from v0_fun as a inner join v2_info as b on a.Ledger=b.Ledger and a.Fun_id=b.Fun_id");
            strSql.Append(" where a.Ledger=@Ledger and a.Mm_id=@Mm_id and a.Fun_id=@Fun_id limit 1");
            obj = SQLHelper.ExecuteScalar(strSql.ToString(), new { Ledger = this.Ledger, Mm_id = fun.ModuleTypeId, Fun_id = fun.Fun_id });
            if (CommFunc.ConvertDBNullToInt32(obj) > 0)
            {
                throw new Exception("此采集点型号:" + fun.FunType + "已经有采集数据不能修改");
            }
            //
            object params01 = new { Ledger = this.Ledger, Mm_id = fun.ModuleTypeId, Fun_id = fun.Fun_id, FunType = fun.FunType, FunName = fun.FunName, Disabled = 0 };

            strSql.Clear();
            strSql.Append("insert into v0_fun(Ledger,Fun_id,Mm_id,FunName,FunType,Action,Scale,Disabled,SubTab)");
            strSql.Append(" values (@Ledger, @Fun_id, @Mm_id, @FunName, @FunType, 0, 2, 0, @FunType)");
            strSql.Append("ON DUPLICATE KEY UPDATE FunType=@FunType,FunName=@FunName,SubTab=@FunType;");
            return(SQLHelper.Execute(strSql.ToString(), params01));
        }
Example #20
0
        private int UpdatePayEst(DataRow dr, DateTime month, DateTime payStartTime, DateTime payEndTime)
        {
            object params01 = new
            {
                Ledger       = this.Ledger,
                Month        = month,
                Co_id        = CommFunc.ConvertDBNullToInt32(dr["Co_id"]),
                Cic_id       = CommFunc.ConvertDBNullToInt32(dr["Cic_id"]),
                UseVal       = CommFunc.ConvertDBNullToDecimal(dr["UseVal"]),
                UseAmt       = CommFunc.ConvertDBNullToDecimal(dr["UseAmt"]),
                PayStartTime = payStartTime,
                PayEndTime   = payEndTime,
                SysUid       = this.SysUid,
            };
            StringBuilder strSql = new StringBuilder();

            strSql.Clear();
            strSql.Append("insert into v4_pay_est(Ledger,Month,Co_id,Cic_id,UseVal,UseAmt,PayAmt,Status,PayStartTime,PayEndTime,Disabled,Create_by,Create_dt,Update_by,Update_dt)values");
            strSql.Append("(@Ledger,UNIX_TIMESTAMP(@Month),@Co_id,@Cic_id,@UseVal,@UseAmt,0,0,@PayStartTime,@PayEndTime,0,@SysUid,now(),@SysUid,now())");
            strSql.Append(" ON DUPLICATE KEY UPDATE UseVal=@UseVal,UseAmt=@UseAmt,PayStartTime=@PayStartTime,PayEndTime=@PayEndTime,Disabled=0,Update_by=@SysUid,Update_dt=now()");
            return(SQLHelper.Execute(strSql.ToString(), params01));
        }
Example #21
0
 public object GetRoomToList(DataTable dtSource, int pageIndex, int pageSize)
 {
     if (pageIndex != 0 && pageSize != 0)
     {
         var res1 = from s1 in dtSource.AsEnumerable().Skip((pageIndex - 1) * pageSize).Take(pageSize)
                    select new
         {
             RowId      = dtSource.Rows.IndexOf(s1) + 1,
             Co_id      = CommFunc.ConvertDBNullToInt32(s1["Co_id"]),
             Parent_id  = CommFunc.ConvertDBNullToInt32(s1["Parent_id"]),
             CoName     = CommFunc.ConvertDBNullToString(s1["CoName"]),
             StrcName   = CommFunc.ConvertDBNullToString(s1["CoStrcName"]),
             IsDefineS  = GetRoomType(s1["IsDefine"]),
             IsDefine   = CommFunc.ConvertDBNullToInt32(s1["IsDefine"]),
             CoNo       = CommFunc.ConvertDBNullToString(s1["CoNo"]),
             Price      = CommFunc.ConvertDBNullToString(s1["CdrPrice"]),
             CoFullName = CommFunc.ConvertDBNullToString(s1["CoFullName"])
         };
         return(res1.ToList());
     }
     else
     {
         var res1 = from s1 in dtSource.AsEnumerable()
                    select new
         {
             RowId      = dtSource.Rows.IndexOf(s1) + 1,
             Co_id      = CommFunc.ConvertDBNullToInt32(s1["Co_id"]),
             Parent_id  = CommFunc.ConvertDBNullToInt32(s1["Parent_id"]),
             CoName     = CommFunc.ConvertDBNullToString(s1["CoName"]),
             StrcName   = CommFunc.ConvertDBNullToString(s1["CoStrcName"]),
             IsDefineS  = GetRoomType(s1["IsDefine"]),
             IsDefine   = CommFunc.ConvertDBNullToInt32(s1["IsDefine"]),
             CoNo       = CommFunc.ConvertDBNullToString(s1["CoNo"]),
             Price      = CommFunc.ConvertDBNullToString(s1["CdrPrice"]),
             CoFullName = CommFunc.ConvertDBNullToString(s1["CoFullName"])
         };
         return(res1.ToList());
     }
 }
Example #22
0
        /// <summary>
        /// 下发控制
        /// </summary>
        /// <param name="pStr">module_id</param>
        /// <param name="fun_id"></param>
        /// <returns></returns>
        public APIRst SendCtrl(string pStr, int fun_id)
        {
            APIRst rst = new APIRst();
            YdToGw gw  = new YdToGw(user.Ledger, user.Uid);

            try
            {
                foreach (string s in pStr.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    gw.YdToGwCmd(CommFunc.ConvertDBNullToInt32(s), fun_id);
                }
                rst.data = "";
            }
            catch (Exception ex)
            {
                rst.rst      = false;
                rst.err.code = (int)ResultCodeDefine.Error;
                rst.err.msg  = ex.Message;
                FileLog.WriteLog("批量下发命令错误(SendCtrl)", ex.Message + ex.StackTrace);
            }
            return(rst);
        }
Example #23
0
        /// <summary>
        /// 获取区域权限信息
        /// </summary>
        /// <param name="id">权限ID</param>
        /// <returns></returns>
        public APIRst GetAreaById(int id)
        {
            APIRst rst = new APIRst();

            try
            {
                int total   = 0;
                int role_id = CommFunc.ConvertDBNullToInt32(id);
                //var dt2 = bll.GetAreaById2();
                List <Treeview> dt  = bll.GetAreaById(role_id, WebConfig.SysProject, out total);
                object          obj = new { total = total, rows = dt };
                rst.data = obj;
            }
            catch (Exception ex)
            {
                rst.rst      = false;
                rst.err.code = (int)ResultCodeDefine.Error;
                rst.err.msg  = ex.Message;
                FileLog.WriteLog("获取区域树形列表错误(GetAreaById):" + ex.Message + ex.StackTrace);
            }
            return(rst);
        }
Example #24
0
        /// <summary>
        /// 获取站点列表
        /// </summary>
        public APIResult GetRoomList(int roomId, string roomName)
        {
            APIResult rst = new APIResult();

            try
            {
                DataTable dtSource = bll.GetRoomList(roomId, roomName);
                var       res1     = from s1 in dtSource.AsEnumerable()
                                     select new
                {
                    RowId         = dtSource.Rows.IndexOf(s1) + 1,
                    RoomId        = CommFunc.ConvertDBNullToInt32(s1["Co_id"]),
                    RoomName      = CommFunc.ConvertDBNullToString(s1["CoName"]),
                    RoomNo        = CommFunc.ConvertDBNullToString(s1["CoNo"]),
                    Address       = CommFunc.ConvertDBNullToString(s1["CustAddr"]),
                    RoomSight     = CommFunc.ConvertDBNullToInt32(s1["Cic_id"]),     //站点类型(场景)
                    Switch        = CommFunc.ConvertDBNullToString(s1["Switch"]),    //供电类型ID(区分转供电,直供电)
                    RoomType      = CommFunc.ConvertDBNullToString(s1["CoType"]),    //站点类型(区分宏站和室分)
                    Remark        = CommFunc.ConvertDBNullToString(s1["Remark"]),
                    Disabled      = CommFunc.ConvertDBNullToInt32(s1["Disabled"]),
                    StationId     = CommFunc.ConvertDBNullToInt32(s1["Parent_id"]),
                    StationName   = CommFunc.ConvertDBNullToString(s1["StationName"]),
                    RoomSightName = CommFunc.ConvertDBNullToString(s1["CicName"]),                                         //站点类型名称
                    SwitchName    = CommFunc.GetEnumDisplay(typeof(Switch), CommFunc.ConvertDBNullToString(s1["Switch"])), //供电类型(区分转供电,直供电)
                    RoomTypeName  = CommFunc.GetEnumDisplay(typeof(CoType), CommFunc.ConvertDBNullToString(s1["CoType"])), //站点类型(区分宏站和室分)
                    MeterCnt      = 0,                                                                                     //下挂(直连站点)电表总数
                };
                rst.Code = 0;
                rst.Msg  = "";
                rst.Data = new { total = dtSource.Rows.Count, rows = res1.ToList() };
            }
            catch (Exception ex)
            {
                rst.Code = -1;
                rst.Msg  = ex.Message;
                FileLog.WriteLog("获取站点列表错误(GetRoomList):" + ex.Message + ex.StackTrace);
            }
            return(rst);
        }
Example #25
0
        public APIRst GetYdAlarmOfCmdList(string strcName, string coName, string startTime, string endTime)
        {
            APIRst rst = new APIRst();

            try
            {
                DataTable dtSource = bll.GetYdAlarmOfCmdList(strcName, coName, CommFunc.ConvertDBNullToDateTime(startTime), CommFunc.ConvertDBNullToDateTime(endTime));
                int       total    = dtSource.Rows.Count;
                var       res1     = from s1 in dtSource.AsEnumerable()
                                     select new
                {
                    RowId      = CommFunc.ConvertDBNullToInt32(s1["RowId"]),
                    Log_id     = CommFunc.ConvertDBNullToLong(s1["Log_id"]),
                    Co_id      = CommFunc.ConvertDBNullToInt32(s1["Co_id"]),
                    CoStrcName = CommFunc.ConvertDBNullToString(s1["CoStrcName"]),
                    CoName     = CommFunc.ConvertDBNullToString(s1["CoName"]),
                    Module_id  = CommFunc.ConvertDBNullToInt32(s1["Module_id"]),
                    ModuleName = CommFunc.ConvertDBNullToString(s1["ModuleName"]),
                    ModuleAddr = CommFunc.ConvertDBNullToString(s1["ModuleAddr"]),
                    FunType    = CommFunc.ConvertDBNullToString(s1["FunType"]),
                    FunTypeS   = CommFunc.ConvertDBNullToString(s1["FunTypeS"]),
                    ErrTxt     = CommFunc.ConvertDBNullToString(s1["ErrTxt"]),
                    DataValue  = CommFunc.ConvertDBNullToString(s1["DataValue"]),
                    Create_by  = CommFunc.ConvertDBNullToString(s1["Create_by"]),
                    Create_dt  = CommFunc.ConvertDBNullToDateTime(s1["Create_dt"]).ToString("yyyy-MM-dd HH:mm:ss"),
                };
                object obj = new { total = total, rows = res1.ToList() };
                rst.data = obj;
            }
            catch (Exception ex)
            {
                rst.rst      = false;
                rst.err.code = (int)ResultCodeDefine.Error;
                rst.err.msg  = ex.Message;
                FileLog.WriteLog("获取远程控制内容错误(GetYdAlarmOfCmdList)", ex.Message + ex.StackTrace);
            }
            return(rst);
        }
Example #26
0
        static Config()
        {
            if (string.IsNullOrEmpty(Config.lpFileName))
            {
                string   path = AppDomain.CurrentDomain.BaseDirectory;
                string[] aa   = path.Split(new Char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries);
                string   tt   = aa[aa.Length - 1];
                if (tt.ToLower().Equals("Automatic".ToLower()))
                {
                    Config.lpFileName = path.Substring(0, path.Length - (tt.Length + 1)) + "Web.ini";
                }
                else
                {
                    Config.lpFileName = path + "Web.ini";
                }
            }
            string port = IniHepler.GetConfig(lpFileName, "Automatic", "Port");

            if (!string.IsNullOrEmpty(port))
            {
                Config.ListenPort = CommFunc.ConvertDBNullToInt32(port);
            }
            Config.Ledger     = CommFunc.ConvertDBNullToInt32(IniHepler.GetConfig(lpFileName, "Automatic", "Ledger"));
            Config.Uid        = CommFunc.ConvertDBNullToInt32(IniHepler.GetConfig(lpFileName, "Automatic", "Uid"));
            Config.Project    = IniHepler.GetConfig(lpFileName, "Automatic", "Project");
            Config.Log_levenl = CommFunc.ConvertDBNullToInt32(IniHepler.GetConfig(lpFileName, "Automatic", "Log_levenl"));
            //
            string connect = ConfigHelper.GetConnectionStrings("DefaultConnection");
            string dbHost  = IniHepler.GetConfig(lpFileName, "Db", "DbHost");
            string dbName  = IniHepler.GetConfig(lpFileName, "Db", "DbName");
            string dbUid   = IniHepler.GetConfig(lpFileName, "Db", "DbUid");
            string dbPwd   = IniHepler.GetConfig(lpFileName, "Db", "DBPwd");

            dbPwd = ConfigHelper.Decrypt(dbPwd);
            //
            connect = string.Format(connect, dbHost, dbName, dbUid, dbPwd);
            YDS6000.BLL.WholeBLL.ConnectionString(connect);
        }
Example #27
0
        /// <summary>
        /// 设备属性下拉数据
        /// </summary>
        /// <returns></returns>
        public APIRst GetAttribCombox()
        {
            APIRst rst = new APIRst();

            try
            {
                DataTable dtSource = new DataTable();
                dtSource.Columns.Add("Id", typeof(System.Int32));
                dtSource.Columns.Add("Text", typeof(System.String));
                System.Reflection.FieldInfo[] fields = typeof(MdAttrib).GetFields(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
                foreach (System.Reflection.FieldInfo field in fields)
                {
                    MdAttrib aa  = (MdAttrib)Enum.Parse(typeof(MdAttrib), field.Name);
                    var      obj = field.GetCustomAttributes(typeof(System.ComponentModel.DataAnnotations.DisplayAttribute), false);
                    if (obj != null && obj.Count() != 0)
                    {
                        System.ComponentModel.DataAnnotations.DisplayAttribute md = obj[0] as System.ComponentModel.DataAnnotations.DisplayAttribute;
                        dtSource.Rows.Add(new object[] { (int)aa, md.Name });
                    }
                }

                var res1 = from s1 in dtSource.AsEnumerable()
                           select new
                {
                    Id   = CommFunc.ConvertDBNullToInt32(s1["Id"]),
                    Text = CommFunc.ConvertDBNullToString(s1["Text"]),
                };
                rst.data = res1.ToList();
            }
            catch (Exception ex)
            {
                rst.rst      = false;
                rst.err.code = (int)ResultCodeDefine.Error;
                rst.err.msg  = ex.Message;
                FileLog.WriteLog("设备属性下拉数据错误:" + ex.Message + ex.StackTrace);
            }
            return(rst);
        }
Example #28
0
        /// <summary>
        /// 获取集中器信息
        /// </summary>
        /// <returns></returns>
        public APIResult GetEspList(int esp_id, string espName)
        {
            APIResult rst = new APIResult();

            try
            {
                DataTable dtSource = bll.GetEspList(esp_id, espName);
                var       res1     = from s1 in dtSource.AsEnumerable()
                                     select new
                {
                    RowId   = dtSource.Rows.IndexOf(s1) + 1,
                    Esp_id  = CommFunc.ConvertDBNullToInt32(s1["Esp_id"]),
                    EspName = CommFunc.ConvertDBNullToString(s1["EspName"]),
                    EspAddr = CommFunc.ConvertDBNullToString(s1["EspAddr"]),
                    //EspIp = CommFunc.ConvertDBNullToString(s1["EspIp"]),
                    //EspPort = CommFunc.ConvertDBNullToInt32(s1["EspPort"]),
                    //TransferType = CommFunc.ConvertDBNullToInt32(s1["TransferType"]),
                    //TransferTypeName = CommFunc.GetEnumDisplay(typeof(TfAttrib), CommFunc.ConvertDBNullToInt32(s1["TransferType"]))
                    EspType    = CommFunc.ConvertDBNullToString(s1["EspType"]),
                    Inst_loc   = CommFunc.ConvertDBNullToString(s1["Inst_loc"]),
                    Remark     = CommFunc.ConvertDBNullToString(s1["Remark"]),
                    Disabled   = CommFunc.ConvertDBNullToInt32(s1["Disabled"]),
                    Supplier   = CommFunc.ConvertDBNullToString(s1["Supplier"]),
                    ActiveTime = CommFunc.ConvertDBNullToDateTime(s1["ActiveTime"]).ToString("yyyy-MM-dd HH:mm:ss")
                };
                object obj = new { total = dtSource.Rows.Count, rows = res1.ToList() };
                rst.Code = 0;
                rst.Msg  = "";
                rst.Data = obj;
            }
            catch (Exception ex)
            {
                rst.Code = -1;
                rst.Msg  = ex.Message;
                FileLog.WriteLog("获取获取集中器信息错误(GetEspList):" + ex.Message + ex.StackTrace);
            }
            return(rst);
        }
Example #29
0
        private v2_alarm_logVModel AlarmInfo(DataRow dr, decimal cfValue, decimal cfRule)
        {
            int      co_id      = CommFunc.ConvertDBNullToInt32(dr["Co_id"]);
            string   coName     = CommFunc.ConvertDBNullToString(dr["CoName"]);
            int      chrgType   = CommFunc.ConvertDBNullToInt32(dr["ChrgType"]);
            DateTime lastTime   = CommFunc.ConvertDBNullToDateTime(dr["LastTime"]);
            decimal  rdVal      = CommFunc.ConvertDBNullToDecimal(dr["RdVal"]);
            decimal  price      = CommFunc.ConvertDBNullToDecimal(dr["Price"]);
            decimal  rdAmt      = Math.Round(rdVal * price, 2, MidpointRounding.AwayFromZero);
            int      module_id  = 0;
            string   moduleAddr = "";
            string   moduleName = CommFunc.ConvertDBNullToString(dr["ModuleName"]);

            if (chrgType >= 2)
            {
                module_id  = CommFunc.ConvertDBNullToInt32(dr["Module_id"]);
                moduleAddr = CommFunc.ConvertDBNullToString(dr["ModuleAddr"]);
            }
            string             ss  = "你好当前设备:" + moduleName + "余额:" + rdAmt.ToString("f2");
            v2_alarm_logVModel ems = bll.GetAlarmModel(co_id, module_id, moduleAddr, AlarmType.Alarm.ToString(), cfRule);

            if (ems == null)
            {
                ems            = new v2_alarm_logVModel();
                ems.Log_id     = 0;
                ems.Co_id      = co_id;
                ems.Module_id  = module_id;
                ems.ModuleAddr = moduleAddr;
                ems.AType      = AlarmType.Alarm.ToString();
            }
            ems.Content = ss;
            ems.ErrTxt  = "";
            if (ems.Log_id == 0)
            {
                bll.AddAlarm(ems);//增加log
            }
            return(ems);
        }
Example #30
0
        private int GetSelectObject(int parent_id, ref Treeview pTr, ref DataTable dtSource, ref DataTable dtMeter)
        {
            DataRow[] pArr  = dtSource.Select("Parent_id=" + parent_id, "Co_id");
            int       pRows = pArr.Count();

            pTr.nodes = new List <Treeview>();
            int meterCnt = 0;

            foreach (DataRow dr in pArr)
            {
                int      co_id  = CommFunc.ConvertDBNullToInt32(dr["Co_id"]);
                int      attrib = CommFunc.ConvertDBNullToInt32(dr["Attrib"]);
                string   type   = attrib == (int)CoAttrib.Area ? "A" : attrib == (int)CoAttrib.Station ? "S" : "R";
                Treeview cTr    = new Treeview();
                cTr.id         = type + "-" + co_id.ToString();
                cTr.text       = CommFunc.ConvertDBNullToString(dr["CoName"]);
                cTr.attributes = type;
                pTr.nodes.Add(cTr);
                this.GetSelectObject(co_id, ref cTr, ref dtSource, ref dtMeter);
                if (attrib == (int)CoAttrib.Room)
                {
                    #region 增加站点
                    DataRow[] meterArr = dtMeter.Select("Co_id=" + co_id, "Meter_id");
                    meterCnt  = meterArr.Count();
                    cTr.nodes = new List <Treeview>();
                    foreach (DataRow drMeter in meterArr)
                    {
                        int      mid = CommFunc.ConvertDBNullToInt32(drMeter["Meter_id"]);
                        Treeview mTr = new Treeview();
                        mTr.id         = "M-" + mid;
                        mTr.text       = CommFunc.ConvertDBNullToString(drMeter["MeterName"]);
                        mTr.attributes = "M";
                    }
                    #endregion
                }
            }
            return(meterCnt);
        }