Beispiel #1
0
        /// <summary>
        /// 添加,编辑设备和点检项关联信息
        /// </summary>
        /// <param name="nodeKey"></param>
        /// <param name="oArea">删除的纪录</param>
        /// <param name="iArea">添加的纪录</param>
        /// <param name="errMsg"></param>
        /// <returns></returns>
        public bool AddDeviceAndItemRealtion(string nodeKey, string[] oArea, string[] iArea, out string errMsg)
        {
            int    oCou  = 0;
            int    iCou  = 0;
            int    count = 0;
            bool   flag  = false;
            object obj   = null;

            DataRow drRou  = null;
            DataRow drDev  = null;
            DataRow drArea = null;

            errMsg = "";

            //查询线路区域设备ID
            PlanDAL pd = new PlanDAL();

            sql = "SELECT T_NODEID,T_PARAENTID FROM T_INFO_ROUTE where T_NODEKEY='" + nodeKey + "'";

            drDev = DBdb2.RunDataRow(sql, out errMsg);

            if (drDev != null)
            {
                sql = "SELECT T_NODEID,T_PARAENTID FROM T_INFO_ROUTE where T_NODEKEY='" + drDev["T_PARAENTID"] + "'";

                drArea = DBdb2.RunDataRow(sql, out errMsg);

                if (drArea != null)
                {
                    sql = "SELECT T_NODEID,T_PARAENTID FROM T_INFO_ROUTE where T_NODEKEY='" + drArea["T_PARAENTID"] + "' and T_DESC='XL'";

                    drRou = DBdb2.RunDataRow(sql, out errMsg);

                    #region  除点检项关系
                    if (oArea != null)
                    {
                        string[] route    = new string[oArea.Length];
                        string[] area     = new string[oArea.Length];
                        string[] device   = new string[oArea.Length];
                        string[] item     = new string[oArea.Length];
                        int[]    judge    = new int[oArea.Length]; //操作类型:创建点检项关系 删除点检项关系 编辑点检项  编辑设备状态
                        string[] sTimes   = new string[oArea.Length];
                        string[] type     = new string[oArea.Length];
                        string[] count1   = new string[oArea.Length];
                        string[] devState = new string[oArea.Length];
                        string[] state    = new string[oArea.Length];

                        for (int i = 0; i < oArea.Length; i++)
                        {
                            route[i]  = drRou["T_NODEID"].ToString();
                            area[i]   = drArea["T_NODEID"].ToString();
                            device[i] = drDev["T_NODEID"].ToString();

                            sql = "select * from T_BASE_ITEM where ID_KEY=" + oArea[i];

                            DataRow drItem = DBdb2.RunDataRow(sql, out errMsg);

                            if (drItem != null)
                            {
                                item[i]     = drItem["T_ITEMID"].ToString();
                                judge[i]    = 1;                                  //操作类型:创建点检项关系 0 删除点检项关系 1 编辑点检项 2  编辑设备状态3
                                sTimes[i]   = drItem["T_STARTTIME"].ToString();   // itemStartTime; //T_STARTTIME
                                type[i]     = drItem["T_PERIODTYPE"].ToString();  //itemPerType;  //T_PERIODTYPE
                                count1[i]   = drItem["T_PERIODVALUE"].ToString(); // itemPerValue;//T_PERIODVALUE
                                devState[i] = drItem["I_STATUS"].ToString();      // itemStatus;//I_STATUS
                                state[i]    = drItem["T_STATUS"].ToString();      // itemStatusQJ;//T_STATUS

                                sql = "delete from T_INFO_ROUTE where T_PARAENTID='" + nodeKey + "' and T_NODEID='" + drItem["T_ITEMID"].ToString() + "' and T_DESC='DJX'";

                                int j = DBdb2.RunCommand(sql, out errMsg);

                                if (j > 0)
                                {
                                    oCou = 1;
                                }
                            }
                        }

                        flag = pd.EditRelation(route[0], area[0], device[0], item, judge);// qc.ManageQuestcomplete(route, area, device, item, judge, sTimes, type, count1, devState, state);

                        //public bool EditRelation(string routeID, string areaID, string deviceID, string[] items, int[] judge)
                    }
                    else
                    {
                        oCou = 1;
                    }
                    #endregion

                    #region 添加点检项关系
                    if (iArea != null)
                    {
                        string[] route    = new string[iArea.Length];
                        string[] area     = new string[iArea.Length];
                        string[] device   = new string[iArea.Length];
                        string[] item     = new string[iArea.Length];
                        int[]    judge    = new int[iArea.Length]; //操作类型:创建点检项关系 删除点检项关系 编辑点检项  编辑设备状态
                        string[] sTimes   = new string[iArea.Length];
                        string[] type     = new string[iArea.Length];
                        string[] count1   = new string[iArea.Length];
                        string[] devState = new string[iArea.Length];
                        string[] state    = new string[iArea.Length];

                        for (int i = 0; i < iArea.Length; i++)
                        {
                            route[i]  = drRou["T_NODEID"].ToString();
                            area[i]   = drArea["T_NODEID"].ToString();
                            device[i] = drDev["T_NODEID"].ToString();

                            sql = "select * from T_BASE_ITEM where ID_KEY=" + iArea[i];

                            DataRow drItem = DBdb2.RunDataRow(sql, out errMsg);

                            if (drItem != null)
                            {
                                item[i]     = drItem["T_ITEMID"].ToString();
                                judge[i]    = 0;                                  //操作类型:创建点检项关系 0 删除点检项关系 1 编辑点检项 2  编辑设备状态3
                                sTimes[i]   = drItem["T_STARTTIME"].ToString();   // itemStartTime; //T_STARTTIME
                                type[i]     = drItem["T_PERIODTYPE"].ToString();  //itemPerType;  //T_PERIODTYPE
                                count1[i]   = drItem["T_PERIODVALUE"].ToString(); // itemPerValue;//T_PERIODVALUE
                                devState[i] = drItem["I_STATUS"].ToString();      // itemStatus;//I_STATUS
                                state[i]    = drItem["T_STATUS"].ToString();      // itemStatusQJ;//T_STATUS

                                sql = "select T_NODEKEY from T_INFO_ROUTE order by ID_KEY DESC fetch first 1 rows only ";

                                obj = DBdb2.GetSingle(sql);

                                if (obj != null && obj.ToString() != "")
                                {
                                    count = int.Parse(obj.ToString()) + 1;
                                }

                                sql = "insert into T_INFO_ROUTE (T_NODEID,T_NODEKEY,T_PARAENTID,T_DESC) values ('" + drItem["T_ITEMID"].ToString() + "','" + count + "','" + nodeKey + "','DJX')";

                                int j = DBdb2.RunCommand(sql, out errMsg);

                                if (j > 0)
                                {
                                    iCou = 1;
                                }
                            }
                        }

                        flag = pd.EditRelation(route[0], area[0], device[0], item, judge);
                        //flag = qc.ManageQuestcomplete(route, area, device, item, judge, sTimes, type, count1, devState, state);
                    }
                    else
                    {
                        iCou = 1;
                    }

                    #endregion

                    if (iCou == 1 && oCou == 1)
                    {
                    }
                    else
                    {
                        errMsg = "无论新增或删除设备和点检项关系,有一项失败!";
                    }
                }
            }
            return(flag);
        }
Beispiel #2
0
        /// <summary>
        /// 添加线路区域关联信息
        /// </summary>
        /// <param name="nodeKey"></param>
        /// <param name="oArea">删除</param>
        /// <param name="iArea">添加</param>
        /// <returns></returns>
        public bool AddLineAndAreaRealtion(string nodeKey, string[] oArea, string[] iArea, string type, out string errMsg)
        {
            int    oCou  = 0;
            int    iCou  = 0;
            int    count = 0;
            bool   flag  = false;
            object obj   = null;

            errMsg = "";

            if (oArea != null)
            {
                for (int i = 0; i < oArea.Length; i++)
                {
                    sql = "delete from T_INFO_ROUTE where T_PARAENTID='" + nodeKey + "' and T_NODEID='" + oArea[i] + "' and T_DESC='" + type + "'"; //不需要再这里删除区域下的设备

                    int j = DBdb2.RunCommand(sql, out errMsg);

                    if (j > 0)
                    {
                        oCou = 1;
                    }
                }
            }
            else
            {
                oCou = 1;
            }

            if (iArea != null)
            {
                for (int i = 0; i < iArea.Length; i++)
                {
                    sql = "select T_NODEKEY from T_INFO_ROUTE order by ID_KEY DESC fetch first 1 rows only ";

                    obj = DBdb2.GetSingle(sql);

                    if (obj != null && obj.ToString() != "")
                    {
                        count = int.Parse(obj.ToString()) + 1;
                    }

                    sql = "insert into T_INFO_ROUTE (T_NODEID,T_NODEKEY,T_PARAENTID,T_DESC) values ('" + iArea[i] + "','" + count + "','" + nodeKey + "','" + type + "')";

                    int j = DBdb2.RunCommand(sql, out errMsg);

                    if (j > 0)
                    {
                        iCou = 1;
                    }
                }
            }
            else
            {
                iCou = 1;
            }

            if (iCou == 1 && oCou == 1)
            {
                flag = true;
            }
            else
            {
                errMsg = "无论新增或者删除区域,有一项失败!";
            }

            return(flag);
        }