Beispiel #1
0
        /// <summary>
        /// 获取设备编码
        /// </summary>
        /// <param name="codetype">设备类型 1是站 2是设备 3是传感器</param>
        public static long GetEquipmentCode(int codetype)
        {
            //最大范围值
            long maxtemp = 0;

            if (codetype == 1)
            {
                maxtemp = 2000000000;
            }
            else if (codetype == 2)
            {
                maxtemp = 3000000000;
            }
            else if (codetype == 3)
            {
                maxtemp = 9000000000;
            }

            long code = 0;
            pdermsWebEntities          bll  = new pdermsWebEntities();
            List <t_Sys_EquipmentCode> list = bll.t_Sys_EquipmentCode.Where(d => d.EquipmentCode < maxtemp).ToList();

            if (list.Count > 0)
            {
                // 最大设备编码加上1
                string equipmentcode = list.Max(m => m.EquipmentCode).ToString();
                long   ecode         = Convert.ToInt64(equipmentcode.Substring(1, 9)) + 1;
                code = Convert.ToInt64(codetype.ToString() + ecode.ToString("000000000"));
            }
            return(code);
        }
Beispiel #2
0
 public static Result smsOrderAdd(string handler, string OrderName, pdermsWebEntities bll)
 {
     try
     {
         string sql = "SELECT * FROM t_CM_UserInfo WHERE UserName='******'";
         List <t_CM_UserInfo> listUsers = bll.ExecuteStoreQuery <t_CM_UserInfo>(sql).ToList();
         if (listUsers != null && listUsers.Count > 0)
         {
             string mobile = listUsers.First().Mobilephone;
             Config config = new Config(key);
             Dictionary <string, string> data = new Dictionary <string, string>();
             Result      result = null;
             SmsOperator sms    = new SmsOperator(config);
             data.Clear();
             data.Add("mobile", mobile);
             data.Add("text", "【" + company + "】您有一个工单名称为[" + subString(OrderName) + "]的待处理工单,请及时处理!");
             return(sms.singleSend(data));
         }
         else
         {
             string rm = "{\"code\":2,\"msg\":\"" + "查找不到" + handler + "的手机号" + "\",\"count\":1,\"fee\":0.05,\"unit\":\"RMB\",\"mobile\":\"13681206520\",\"sid\":22927664130}";
             return(new Result(-1, rm));
         }
     }
     catch (Exception e)
     {
         string rm = "{\"code\":2,\"msg\":\"" + "发送短信出错:" + e.Message + "\",\"count\":1,\"fee\":0.05,\"unit\":\"RMB\",\"mobile\":\"13681206520\",\"sid\":22927664130}";
         return(new Result(-1, rm));
     }
 }
Beispiel #3
0
        // 递归树形
        public static string ComboPdrList(t_CM_PDRInfo model)
        {
            pdermsWebEntities bll   = new pdermsWebEntities();
            string            res_s = "";

            //你想要在视图中得到的值
            res_s += "{\"id\":\"" + model.PID + "\",\"text\":\"" + model.Name + "\"";

            IList <t_CM_PDRInfo> list = bll.t_CM_PDRInfo.Where(c => c.ParentID == model.PID).ToList();

            if (list != null && list.Count > 0)
            {
                res_s += "," + "\"children\":[";
                for (int i = 0; i < list.Count; i++)
                {
                    if (i > 0)
                    {
                        res_s += ",";
                    }
                    res_s += ComboPdrList(list[i]);
                }
                res_s += "]";
            }
            ;
            res_s += "}";
            return(res_s);
        }
Beispiel #4
0
        // 递归树形
        public static string ComboRecursion(t_CM_Module model)
        {
            pdermsWebEntities bll   = new pdermsWebEntities();
            string            res_s = "";

            //你想要在视图中得到的值
            res_s += "{\"id\":\"" + model.ModuleID + "\",\"text\":\"" + model.ModuleName + "\"";

            IList <t_CM_Module> list = bll.t_CM_Module.Where(c => c.ParentID == model.ModuleID && c.ModuleType != 3).ToList();

            if (list != null && list.Count > 0)
            {
                res_s += "," + "\"children\":[";
                for (int i = 0; i < list.Count; i++)
                {
                    if (i > 0)
                    {
                        res_s += ",";
                    }
                    res_s += ComboRecursion(list[i]);
                }
                res_s += "]";
            }
            ;
            res_s += "}";
            return(res_s);
        }
Beispiel #5
0
        // 递归树形
        public static string Recursion(t_CM_Module model)
        {
            pdermsWebEntities bll   = new pdermsWebEntities();
            string            res_s = "";
            //你想要在视图中得到的值
            string icon = "book_open.png";

            if (!string.IsNullOrEmpty(model.Icon))
            {
                icon = model.Icon;
            }
            res_s += "{\"ModuleID\":\"" + model.ModuleID + "\",\"ModuleName\":\"" + model.ModuleName + "\",\"ParentID\":\"" + model.ParentID + "\",\"Icon\":\"" + icon + "\",\"Location\":\"" + model.Location + "\"";

            IList <t_CM_Module> list = bll.t_CM_Module.Where(c => c.ParentID == model.ModuleID && c.ModuleType != 3).ToList();

            list = list.OrderBy(m => m.SN).ToList();
            if (list != null && list.Count > 0)
            {
                res_s += "," + "\"children\":[";
                for (int i = 0; i < list.Count; i++)
                {
                    if (i > 0)
                    {
                        res_s += ",";
                    }
                    res_s += Recursion(list[i]);
                }
                res_s += "]";
            }
            ;
            res_s += "}";
            return(res_s);
        }
Beispiel #6
0
        public static string List2Json <T>(IList <T> list, int total, List <t_CM_PointsInfo> listPar)
        {
            pdermsWebEntities b    = new pdermsWebEntities();
            StringBuilder     json = new StringBuilder();

            //{"total":5,"rows":[
            //int total = list.Count;
            json.Append("{\"total\":");
            json.Append(total);
            json.Append(",\"rows\":[");
            for (int i = 0; i < list.Count; i++)
            {
                T              obj  = Activator.CreateInstance <T>();
                Type           type = obj.GetType();
                PropertyInfo[] pis  = type.GetProperties();
                json.Append("{");

                for (int j = 0; j < pis.Length; j++)
                {
                    json.Append("\"" + pis[j].Name.ToString() + "\":\"" + pis[j].GetValue(list[i], null) + "\"");
                    if ("TagID" == pis[j].Name.ToString())
                    {
                        int tagid    = Convert.ToInt32(pis[j].GetValue(list[i], null));
                        var pointInf = listPar.Where(o => o.TagID == tagid);
                        if (pointInf.Count() > 0)
                        {
                            t_CM_PointsInfo poinf = pointInf.First();
                            json.Append(",");
                            json.Append("\"" + "TagName" + "\":\"" + poinf.TagName + "\"");
                            json.Append(",");
                            json.Append("\"" + "Remarks" + "\":\"" + poinf.Remarks + "\"");
                            b.t_DM_CircuitInfo.Where(p => p.CID == poinf.CID).FirstOrDefault();
                            if (b.t_DM_CircuitInfo.Where(p => p.CID == poinf.CID).FirstOrDefault() != null)
                            {
                                json.Append(",");
                                json.Append("\"" + "CName" + "\":\"" + b.t_DM_CircuitInfo.Where(p => p.CID == poinf.CID && p.PID == poinf.PID).FirstOrDefault().CName + "\"");
                            }
                            else
                            {
                                json.Append(",");
                                json.Append("\"" + "CName" + "\":\"--\"");
                            }
                        }
                    }
                    if (j < pis.Length - 1)
                    {
                        json.Append(",");
                    }
                }
                json.Append("}");
                if (i < list.Count - 1)
                {
                    json.Append(",");
                }
            }
            json.Append("]}");
            return(json.ToString());
        }
Beispiel #7
0
        //获取事项列表
        public ActionResult GetDefaultTemp(int type)
        {
            List <t_ES_DefaultTemplet> list = new List <t_ES_DefaultTemplet>();

            using (var bll = new pdermsWebEntities())
            {
                list = bll.t_ES_DefaultTemplet.Where(p => p.Type == type).ToList();
            }
            return(Json(list));
        }
Beispiel #8
0
        /// <summary>
        /// 记录日志
        /// </summary>
        /// <param name="logType">日志类型</param>
        /// <param name="username">操作人</param>
        /// <param name="contents">日志描述</param>
        public static void InsertLog(string logType, string username, string contents)
        {
            pdermsWebEntities bll = new pdermsWebEntities();
            t_CM_Log          log = new t_CM_Log();

            log.LogDate   = DateTime.Now;
            log.LogType   = logType;
            log.UserName  = username;
            log.Contents  = contents;
            log.IPAddress = "";// GetIPAddress();
            bll.t_CM_Log.AddObject(log);
            bll.SaveChanges();
        }
Beispiel #9
0
 public static void smsOrderCancel(string handler, string OrderName, pdermsWebEntities bll)
 {
     try
     {
         string sql = "SELECT * FROM t_CM_UserInfo WHERE UserName='******'";
         List <t_CM_UserInfo> listUsers = bll.ExecuteStoreQuery <t_CM_UserInfo>(sql).ToList();
         if (listUsers != null && listUsers.Count > 0)
         {
             string mobile = listUsers.First().Mobilephone;
             Config config = new Config(key);
             Dictionary <string, string> data = new Dictionary <string, string>();
             SmsOperator sms = new SmsOperator(config);
             data.Clear();
             data.Add("mobile", mobile);
             data.Add("text", "【" + company + "】您的一个待处理工单[" + subString(OrderName) + "],已取消!");
             sms.singleSend(data);
         }
     }catch (Exception e) {
     }
 }
Beispiel #10
0
        public static List <T> SelectPageList <T>(string tbName, int pageIndex, int pagesize, string orderByField, ref int totalCount, int orderby, string strWhere, string SelectFieldName) where T : class
        {
            pdermsWebEntities bll = new pdermsWebEntities();

            SqlParameter[] spm = new SqlParameter[5];
            spm[0] = new SqlParameter("@tblName", tbName);
            spm[1] = new SqlParameter("@SelectFieldName", SelectFieldName);
            spm[2] = new SqlParameter("@strWhere", strWhere);
            spm[3] = new SqlParameter("@OrderFieldName", orderByField);
            spm[4] = new SqlParameter("@PageSize", pagesize);
            spm[5] = new SqlParameter("@PageIndex", pageIndex);
            spm[6] = new SqlParameter("@iRowCount", totalCount);
            spm[7] = new SqlParameter("@OrderType", orderby);

            spm[7].Direction = ParameterDirection.Output;
            var data = bll.ExecuteStoreQuery <T>("exec AspNetPage @tblName,@SelectFieldName,@strWhere,@OrderByField,@PageSize,@PageIndex,@iRowCount out,@OrderType", spm).ToList();

            totalCount = Convert.ToInt32(spm[4].Value.ToString());
            return(data);
        }
Beispiel #11
0
        public static string doImport2003(DataSet tDS, int Mode)
        {
            StringBuilder Result     = new StringBuilder();
            string        TagIDs     = "";
            int           errorCount = 0;

            try
            {
                pdermsWebEntities bll = new pdermsWebEntities();

                //检验excel表格中的数据是否符合格式
                //检查列数是否与数据库一致
                if (tDS.Tables[0].Columns.Count == 42)
                {
                    for (int i = 0; i < tDS.Tables[0].Rows.Count; i++)
                    {
                        string MDate = tDS.Tables[0].Rows[i][1].ToString();
                        string Val   = tDS.Tables[0].Rows[i][2].ToString();
                        for (int j = 0; j < tDS.Tables[0].Columns.Count; j++)
                        {
                            //检查TagID
                            if (tDS.Tables[0].Rows[i][0].ToString() == "")
                            {
                                Result.Append("错误:第" + i + "列,缺少TagID。<br>");
                                errorCount++;
                            }
                            else
                            {
                                TagIDs += tDS.Tables[0].Rows[i][0].ToString() + ",";
                            }
                            //检查DID
                            if (tDS.Tables[0].Rows[i][2].ToString() == "")
                            {
                                Result.Append("错误:第" + i + "列,缺少DID。<br>");
                                errorCount++;
                            }

                            //检查实时库索引
                            if (tDS.Tables[0].Rows[i][14].ToString() == "")
                            {
                                Result.Append("错误:第" + i + "列,缺少实时库索引。<br>");
                                errorCount++;
                            }

                            //检查PID
                            if (tDS.Tables[0].Rows[i][15].ToString() == "")
                            {
                                Result.Append("错误:第" + i + "列,缺少PID。<br>");
                                errorCount++;
                            }
                        }
                    }
                }
                else
                {
                    Result.Append("错误:列数错误。\r");
                    errorCount++;
                }
                string pointSQL             = "SELECT * FROM t_CM_PointsInfo WHERE TagID in (" + TagIDs.TrimEnd(',') + ")";
                List <t_CM_PointsInfo> list = bll.ExecuteStoreQuery <t_CM_PointsInfo>(pointSQL).ToList();
                if (list.Count > 0)
                {
                    //覆盖模式下删除重复数据
                    if (Mode > 0)
                    {
                        list.ForEach(i =>
                        {
                            bll.AttachTo("t_CM_PointsInfo", i);
                            bll.t_CM_PointsInfo.DeleteObject(i);
                        });
                        bll.SaveChanges();
                    }
                    else
                    {
                        foreach (t_CM_PointsInfo p in list)
                        {
                            Result.Append("错误:数据库中已经存在 TagID = " + p.TagID + "的行。<br>");
                            errorCount++;
                        }
                    }
                }
                StringBuilder strSQL = new StringBuilder();
                if (errorCount < 1)
                {
                    //关闭标识
                    strSQL.Append("set IDENTITY_INSERT t_CM_PointsInfo ON ");
                    //插入数据库
                    for (int i = 0; i < tDS.Tables[0].Rows.Count; i++)
                    {
                        strSQL.Append("insert into t_CM_PointsInfo (TagID,TagName,DID,DataTypeID,Position,MPID,UseState,PIOID,ABCID,Remarks,数据类型,设备点名,中文描述,站内点号,实时库索引,PID,通信地址,例外报告死区,工程下限,工程上限,码值下限,码值上限,远动数据类型,报警下限1,报警上限1,报警定义,置0说明,置1说明,单位,分组,最大间隔时间,小信号切除值,报警下限2,报警上限2,报警下限3,报警上限3,报警死区,报警级别,报警方式,速率报警限制,初始值,传感器SN编码) ");
                        strSQL.Append("values ("
                                      + "" + tDS.Tables[0].Rows[i][0] + ","
                                      + "'" + tDS.Tables[0].Rows[i][1] + "',"
                                      + "" + tDS.Tables[0].Rows[i][2] + ","
                                      + "" + tDS.Tables[0].Rows[i][3] + ","
                                      + "'" + tDS.Tables[0].Rows[i][4] + "',"
                                      + "" + tDS.Tables[0].Rows[i][5] + ","
                                      + "" + tDS.Tables[0].Rows[i][6] + ","
                                      + "" + tDS.Tables[0].Rows[i][7] + ","
                                      + "" + tDS.Tables[0].Rows[i][8] + ","
                                      + "'" + tDS.Tables[0].Rows[i][9] + "',"
                                      + "'" + tDS.Tables[0].Rows[i][10] + "',"
                                      + "'" + tDS.Tables[0].Rows[i][11] + "',"
                                      + "'" + tDS.Tables[0].Rows[i][12] + "',"
                                      + "'" + tDS.Tables[0].Rows[i][13] + "',"
                                      + "" + tDS.Tables[0].Rows[i][14] + ","
                                      + "" + tDS.Tables[0].Rows[i][15] + ","
                                      + "" + tDS.Tables[0].Rows[i][16] + ","
                                      + "" + tDS.Tables[0].Rows[i][17] + ","
                                      + "" + tDS.Tables[0].Rows[i][18] + ","
                                      + "" + tDS.Tables[0].Rows[i][19] + ","
                                      + "" + tDS.Tables[0].Rows[i][20] + ","
                                      + "" + tDS.Tables[0].Rows[i][21] + ","
                                      + "'" + tDS.Tables[0].Rows[i][22] + "',"
                                      + "" + tDS.Tables[0].Rows[i][23] + ","
                                      + "" + tDS.Tables[0].Rows[i][24] + ","
                                      + "" + tDS.Tables[0].Rows[i][25] + ","
                                      + "'" + tDS.Tables[0].Rows[i][26] + "',"
                                      + "'" + tDS.Tables[0].Rows[i][27] + "',"
                                      + "'" + tDS.Tables[0].Rows[i][28] + "',"
                                      + "" + tDS.Tables[0].Rows[i][29] + ","
                                      + "" + tDS.Tables[0].Rows[i][30] + ","
                                      + "" + tDS.Tables[0].Rows[i][31] + ","
                                      + "" + tDS.Tables[0].Rows[i][32] + ","
                                      + "" + tDS.Tables[0].Rows[i][33] + ","
                                      + "" + tDS.Tables[0].Rows[i][34] + ","
                                      + "" + tDS.Tables[0].Rows[i][35] + ","
                                      + "" + tDS.Tables[0].Rows[i][36] + ","
                                      + "" + tDS.Tables[0].Rows[i][37] + ","
                                      + "" + tDS.Tables[0].Rows[i][38] + ","
                                      + "" + tDS.Tables[0].Rows[i][39] + ","
                                      + "" + tDS.Tables[0].Rows[i][40] + ","
                                      + "'" + tDS.Tables[0].Rows[i][41] + "')");
                    }
                    strSQL.Append("set IDENTITY_INSERT t_CM_PointsInfo OFF");
                    bll.ExecuteStoreCommand(strSQL.ToString());
                    Result.Append("OK");
                }
                return(Result.ToString());
            }
            catch (Exception e)
            {
                string a = e.ToString();
                return(a);
            }
        }