Esempio n. 1
0
        private void button5_Click_1(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();

            frmGHDeviceList frmDevList = new frmGHDeviceList();
            frmDevList.ProjectID = Itop.Client.MIS.ProgUID;
            frmDevList.ProjectSUID = ctrlPSP_GProg1.FocusedObject.UID;
            frmDevList.Init();
            if (frmDevList.ShowDialog() == DialogResult.OK) {
                foreach (DataRow row in frmDevList.DT.Rows) {
                    try {
                        if ((bool)row["C"]) {
                            PSP_GprogElevice elcDevice = new PSP_GprogElevice();
                            elcDevice.DeviceSUID = row["A"].ToString();
                            elcDevice.GprogUID = ctrlPSP_GProg1.FocusedObject.UID;
                            elcDevice = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByKey", elcDevice);
                            if (elcDevice != null) {
                                elcDevice.Type = row["D"].ToString();
                                elcDevice.L2 = "0";
                                Services.BaseService.Update<PSP_GprogElevice>(elcDevice);
                            } else {
                                elcDevice = new PSP_GprogElevice();
                                elcDevice.DeviceSUID = row["A"].ToString();
                                elcDevice.GprogUID = ctrlPSP_GProg1.FocusedObject.UID;
                                elcDevice.Type = row["D"].ToString();
                                elcDevice.L2 = "0";
                                Services.BaseService.Create<PSP_GprogElevice>(elcDevice);
                            }

                        } else {
                            PSP_GprogElevice elcDevice = new PSP_GprogElevice();
                            elcDevice.DeviceSUID = row["A"].ToString();
                            elcDevice.GprogUID = ctrlPSP_GProg1.FocusedObject.UID;

                            Services.BaseService.Delete<PSP_GprogElevice>(elcDevice);
                        }
                    } catch (System.Exception ex) {

                    }
                }
            } else
                return;
            //在此处将其选择的元件设备的属性进行更改

            LayerGrade l1 = new LayerGrade();
            l1.Type = "1";
            l1.SvgDataUid = svguid;
            IList ttlist = Services.BaseService.GetList("SelectLayerGradeList5", l1);
            int yy1 = System.DateTime.Now.Year, yy2 = System.DateTime.Now.Year, yy3 = System.DateTime.Now.Year;
            if (ttlist.Count > 0) {
                LayerGrade n1 = (LayerGrade)ttlist[0];
                yy1 = Convert.ToInt32(n1.Name.Substring(0, 4));
            }
            l1.Type = "2";
            l1.SvgDataUid = svguid;
            ttlist = Services.BaseService.GetList("SelectLayerGradeList5", l1);
            if (ttlist.Count > 0) {
                LayerGrade n1 = (LayerGrade)ttlist[0];
                yy2 = Convert.ToInt32(n1.Name.Substring(0, 4));
            }
            l1.Type = "3";
            l1.SvgDataUid = svguid;
            ttlist = Services.BaseService.GetList("SelectLayerGradeList5", l1);
            if (ttlist.Count > 0) {
                LayerGrade n1 = (LayerGrade)ttlist[0];
                yy3 = Convert.ToInt32(n1.Name.Substring(0, 4));
            }
            string con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '变电站'";

            IList list = Services.BaseService.GetList("SelectPSP_GprogEleviceByCondition", con);
            foreach (PSP_GprogElevice pg in list) {

                PSP_Substation_Info ps = new PSP_Substation_Info();
                ps.UID = pg.DeviceSUID;
                ps = (PSP_Substation_Info)Services.BaseService.GetObject("SelectPSP_Substation_InfoByKey", ps);
                if (ps != null) {
                    int s2 = 0;
                    if (!string.IsNullOrEmpty(ps.S2)) {
                        s2 = Convert.ToInt32(ps.S2);
                    }
                    if (s2 <= System.DateTime.Now.Year) {
                        pg.L1 = "现行";
                    } else if (s2 > System.DateTime.Now.Year && Convert.ToInt32(ps.S2) <= yy1) {
                        pg.L1 = "近期";
                    } else if (s2 > yy1 && Convert.ToInt32(ps.S2) <= yy2) {
                        pg.L1 = "中期";
                    } else if (s2 > yy2 && Convert.ToInt32(ps.S2) <= yy3) {
                        pg.L1 = "远期";
                    }
                    Services.BaseService.Update<PSP_GprogElevice>(pg);
                } else
                    Services.BaseService.Delete<PSP_GprogElevice>(pg);

            }
            con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '电源'";

            list = Services.BaseService.GetList("SelectPSP_GprogEleviceByCondition", con);
            foreach (PSP_GprogElevice pg in list) {
                PSP_PowerSubstation_Info ps = new PSP_PowerSubstation_Info();
                ps.UID = pg.DeviceSUID;
                ps = (PSP_PowerSubstation_Info)Services.BaseService.GetObject("SelectPSP_PowerSubstation_InfoByKey", ps);
                if (ps != null) {
                    int s2 = 0;
                    if (!string.IsNullOrEmpty(ps.S3)) {
                        s2 = Convert.ToInt32(ps.S3);
                    }
                    if (s2 <= System.DateTime.Now.Year) {
                        pg.L1 = "现行";
                    } else if (s2 > System.DateTime.Now.Year && Convert.ToInt32(ps.S3) <= yy1) {
                        pg.L1 = "近期";
                    } else if (s2 > yy1 && Convert.ToInt32(ps.S3) <= yy2) {
                        pg.L1 = "中期";
                    } else if (s2 > yy2 && Convert.ToInt32(ps.S3) <= yy3) {
                        pg.L1 = "远期";
                    }
                    Services.BaseService.Update<PSP_GprogElevice>(pg);
                } else
                    Services.BaseService.Delete<PSP_GprogElevice>(pg);
            }
            //变电站里判断两绕和三绕是哪个时期的

            con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '变电站'";

            list = Services.BaseService.GetList("SelectPSP_GprogEleviceByCondition", con);
            foreach (PSP_GprogElevice pg in list) {
                con = "c.UID='" + pg.DeviceSUID + "'and a.Type='02'and a.ProjectID='" + Itop.Client.MIS.ProgUID + "'";
                IList uidlist = Services.BaseService.GetList("SelectPSPDEV_byqSUID", con);
                foreach (string uid in uidlist) {

                    con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '两绕组变压器'AND DeviceSUID='" + uid + "'";
                    PSP_GprogElevice pglr = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByCondition", con);
                    if (pglr != null) {
                        pglr.L1 = pg.L1;
                        Services.BaseService.Update<PSP_GprogElevice>(pglr);
                    }

                }
                con = "c.UID='" + pg.DeviceSUID + "'and a.Type='03'and a.ProjectID='" + Itop.Client.MIS.ProgUID + "'";
                uidlist = Services.BaseService.GetList("SelectPSPDEV_byqSUID", con);
                foreach (string uid in uidlist) {

                    con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '三绕组变压器'AND DeviceSUID='" + uid + "'";
                    PSP_GprogElevice pglr = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByCondition", con);
                    if (pglr != null) {
                        pglr.L1 = pg.L1;
                        Services.BaseService.Update<PSP_GprogElevice>(pglr);
                    }

                }
            }
            //发电厂里两绕和三绕组是哪个时期的
            con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '电源'";

            list = Services.BaseService.GetList("SelectPSP_GprogEleviceByCondition", con);
            foreach (PSP_GprogElevice pg in list) {
                con = "c.UID='" + pg.DeviceSUID + "'and a.Type='02'and a.ProjectID='" + Itop.Client.MIS.ProgUID + "'";
                IList uidlist = Services.BaseService.GetList("SelectPSPDEV_byqSUID", con);
                foreach (string uid in uidlist) {

                    con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '两绕组变压器'AND DeviceSUID='" + uid + "'";
                    PSP_GprogElevice pglr = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByCondition", con);
                    if (pglr != null) {
                        pglr.L1 = pg.L1;
                        Services.BaseService.Update<PSP_GprogElevice>(pglr);
                    }

                }
                con = "c.UID='" + pg.DeviceSUID + "'and a.Type='03'and a.ProjectID='" + Itop.Client.MIS.ProgUID + "'";
                uidlist = Services.BaseService.GetList("SelectPSPDEV_byqSUID", con);
                foreach (string uid in uidlist) {

                    con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '三绕组变压器'AND DeviceSUID='" + uid + "'";
                    PSP_GprogElevice pglr = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByCondition", con);
                    if (pglr != null) {
                        pglr.L1 = pg.L1;
                        Services.BaseService.Update<PSP_GprogElevice>(pglr);
                    }

                }
            }
            //判断设备参数中有没有在规划设备中的两绕,三绕组变压器,发电机和负荷 如果没有则删掉

            con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND (Type= '两绕组变压器'or Type= '三绕组变压器'or Type= '负荷'or Type= '发电机')";

            list = Services.BaseService.GetList("SelectPSP_GprogEleviceByCondition", con);
            foreach (PSP_GprogElevice pg in list) {
                PSPDEV ps = new PSPDEV();
                ps.SUID = pg.DeviceSUID;
                ps = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", ps);
                if (ps == null) {
                    Services.BaseService.Delete<PSP_GprogElevice>(pg);
                }
            }
            //线路信息
            con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '线路'";

            list = Services.BaseService.GetList("SelectPSP_GprogEleviceByCondition", con);
            foreach (PSP_GprogElevice pg in list) {
                PSPDEV ps = new PSPDEV();
                ps.SUID = pg.DeviceSUID;
                ps = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", ps);
                if (ps != null) {
                    int s2 = 0;
                    if (!string.IsNullOrEmpty(ps.OperationYear)) {
                        s2 = Convert.ToInt32(ps.OperationYear);
                    }
                    if (s2 <= System.DateTime.Now.Year) {
                        pg.L1 = "运行";
                        ps.LineStatus = "运行";
                    } else {
                        pg.L1 = "待选";
                        ps.LineStatus = "待选";

                    }
                    Services.BaseService.Update<PSP_GprogElevice>(pg);
                    Services.BaseService.Update<PSPDEV>(ps);
                } else
                    Services.BaseService.Delete<PSP_GprogElevice>(pg);

            }
        }
        public void Calc(string addConn)
        {
            int x5 = 1, x1 = 1, x1z = 1, x2 = 1, x2z = 1, x35 = 1, x35z = 1, x10 = 1, x10z = 1, x6 = 1, x6z = 1, t5 = 0, t2 = 0, t2z = 0, t1 = 0, t1z = 0, t35 = 0, t35z = 0, t10 = 0, t10z = 0, t6 = 0, t6z = 0;
            double h5 = 0, h1 = 0, h1z = 0, h2 = 0, h2z = 0, h35 = 0, h35z = 0, h10 = 0, h10z = 0, h6 = 0, h6z = 0, z5 = 0, z1 = 0, z1z = 0, z2 = 0, z2z = 0, z35 = 0, z35z = 0, z10 = 0, z10z = 0, z6 = 0, z6z = 0; ;
            int index5 = -1, index2 = -1, index2z = -1, index1 = -1, index1z = -1, index35 = -1, index35z = -1, index10 = -1, index10z = -1, index6 = -1, index6z = -1;
            Hashtable table = new Hashtable();
            Hashtable table_500 = new Hashtable();
            Hashtable table_220 = new Hashtable();
            Hashtable table_220z = new Hashtable();
            Hashtable table_35 = new Hashtable();
            Hashtable table_35z = new Hashtable();
            Hashtable table_10 = new Hashtable();
            Hashtable table_10z = new Hashtable();
            Hashtable table_6 = new Hashtable();
            Hashtable table_6z = new Hashtable();
            IList<string> groupList_500 = new List<string>();
            IList<string> groupList_220 = new List<string>();
            IList<string> groupList_220z = new List<string>();
            IList<string> groupList_35 = new List<string>();
            IList<string> groupList_35z = new List<string>();
            IList<string> groupList_10 = new List<string>();
            IList<string> groupList_10z = new List<string>();
            IList<string> groupList_6 = new List<string>();
            IList<string> groupList_6z = new List<string>();

            bool five = true, one = true, onez = true, two = true, twoz = true, three = true, threez = true, ten = true, tenz = true, six = true, sixz = true;
            string area = "1@3$5q99z99";
            string area_500 = "1@3$5q99z99";
            string area_220 = "1@3$5q99z99";
            string area_220z = "1@3$5q99z99";
            string area_35 = "1@3$5q99z99";
            string area_35z = "1@3$5q99z99";
            string area_10 = "1@3$5q99z99";
            string area_10z = "1@3$5q99z99";
            string area_6 = "1@3$5q99z99";
            string area_6z = "1@3$5q99z99";
            int j = 0;
            int now = 0;
            string con = "AreaID='" + projectid + "'";// +" and Flag='" + Ghflag + "'";
               // con += addConn;
            con += " order by convert(int,S1) desc,S4,AreaName,CreateDate,convert(int,S5)";
            string[] que = new string[60] { "һ", "��", "��", "��", "��", "��", "��", "��", "��", "ʮ",
            "ʮһ","ʮ��","ʮ��","ʮ��","ʮ��","ʮ��","ʮ��","ʮ��","ʮ��","��ʮ","��ʮһ","��ʮ��","��ʮ��","��ʮ��","��ʮ��","��ʮ��","��ʮ��",
            "��ʮ��","��ʮ��","��ʮ","��ʮһ","��ʮ��","��ʮ��","��ʮ��","��ʮ��","��ʮ��","��ʮ��","��ʮ��","��ʮ��","��ʮ","��ʮһ","��ʮ��","��ʮ��","��ʮ��",
            "��ʮ��","��ʮ��","��ʮ��","��ʮ��","��ʮ��","��ʮ","��ʮһ","��ʮ��","��ʮ��","��ʮ��","��ʮ��","��ʮ��","��ʮ��","��ʮ��","��ʮ��","��ʮ"};
            titlestr = que;
            //IList list = Common.Services.BaseService.GetList("SelectPSP_PowerSubstation_InfoByCon", con);
            IList list = Common.Services.BaseService.GetList("SelectPSP_PowerSubstation_InfoListByWhere", con);
            if (!string.IsNullOrEmpty(addConn))
            {
                List<PSP_PowerSubstation_Info> listremove = new List<PSP_PowerSubstation_Info>();
                for (int i = 0; i < list.Count;i++ )
                {
                    if (((PSP_PowerSubstation_Info)list[i]).S3.Length != 4)
                    {
                        listremove.Add((PSP_PowerSubstation_Info)list[i]);
                    }
                    else
                    {
                        if (Convert.ToDouble(((PSP_PowerSubstation_Info)list[i]).S3)>Convert.ToDouble(addConn))
                        {
                            listremove.Add((PSP_PowerSubstation_Info)list[i]);
                        }

                    }
                }
                for (int i = 0; i < listremove.Count;i++ )
                {
                    list.Remove(listremove[i]);
                }
                for (int i = 0; i < list.Count;i++ )
                {
                    double rl=0; int bts=0;
                    string where = "where projectid='" + Itop.Client.MIS.ProgUID + "'and type='04'and SvgUID='" + ((PSP_PowerSubstation_Info)list[i]).UID + "'";
                    IList<PSPDEV> list1 = Services.BaseService.GetList<PSPDEV>("SelectPSPDEVByCondition", where);
                    foreach (PSPDEV pd in list1)
                    {
                        if (!string.IsNullOrEmpty(pd.OperationYear) && Convert.ToInt32(pd.OperationYear) <= Convert.ToDouble(addConn))
                        {
                            if (!string.IsNullOrEmpty(pd.OperationYear) && !string.IsNullOrEmpty(pd.Date2) && pd.Date2.Length == 4 && !string.IsNullOrEmpty(((PSP_PowerSubstation_Info)list[i]).S29) && !string.IsNullOrEmpty(((PSP_PowerSubstation_Info)list[i]).S30))
                            {
                                if (Convert.ToInt32(pd.OperationYear) >= Convert.ToInt32(((PSP_PowerSubstation_Info)list[i]).S29) && Convert.ToInt32(pd.Date2) <= Convert.ToInt32(((PSP_PowerSubstation_Info)list[i]).S30))
                                {
                                    rl += pd.P0;
                                    bts++;
                                }
                            }
                            else
                            {
                                rl += (double)pd.P0;
                                bts++;
                            }
                        }

                    }
                    ((PSP_PowerSubstation_Info)list[i]).S2 = rl.ToString();

                }
            }
            string conn = "L1=110";
            // IList groupList = Common.Services.BaseService.GetList("SelectAreaNameGroupByConn", conn);
            IList<string> groupList = new List<string>();
            Hashtable table2 = new Hashtable();
            IList<string> groupList2 = new List<string>();
            string area2 = "1@3$5q99z99";
            for (int i = 0; i < list.Count; i++)
            {
                if (((PSP_PowerSubstation_Info)list[i]).S1 == "500"  )
                {
                    if (((PSP_PowerSubstation_Info)list[i]).AreaName != area_500)
                    {
                        if (!table_500.Contains(((PSP_PowerSubstation_Info)list[i]).AreaName))
                        {

                            table_500.Add(((PSP_PowerSubstation_Info)list[i]).AreaName, i);
                            groupList_500.Add(((PSP_PowerSubstation_Info)list[i]).AreaName);
                        }
                        area_500 = ((PSP_PowerSubstation_Info)list[i]).AreaName;
                    }
                    if (five)
                    { index5 = i; five = false; }
                    ((PSP_PowerSubstation_Info)list[i]).S3 = x5.ToString();
                    h5 += Convert.ToDouble(((PSP_PowerSubstation_Info)list[i]).S2);
                    //try
                    //{
                    //    z5 += double.Parse(((PSP_PowerSubstation_Info)list[i]).L5);

                    //}
                    //catch { }
                    //try
                    //{

                    //    t5 += (int)((PSP_PowerSubstation_Info)list[i]).L3;
                    //}
                   // catch { }
                    x5++;
                }
                else if (((PSP_PowerSubstation_Info)list[i]).S1 == "220" && ((PSP_PowerSubstation_Info)list[i]).S8 == "ר��")
                {
                    if (((PSP_PowerSubstation_Info)list[i]).AreaName != area_220z)
                    {
                        if (!table_220z.Contains(((PSP_PowerSubstation_Info)list[i]).AreaName))
                        {

                            table_220z.Add(((PSP_PowerSubstation_Info)list[i]).AreaName, i);
                            groupList_220z.Add(((PSP_PowerSubstation_Info)list[i]).AreaName);
                            //  table[((PSP_PowerSubstation_Info)list[i]).AreaName] = i;
                        }
                        area_220z = ((PSP_PowerSubstation_Info)list[i]).AreaName;
                    }
                    if (twoz)
                    { index2z = i; twoz = false; }
                    ((PSP_PowerSubstation_Info)list[i]).S20 = x2z.ToString();
                    h2z +=Convert.ToDouble(((PSP_PowerSubstation_Info)list[i]).S2) ;
                    //try
                    //{
                    //    z2z += double.Parse(((PSP_PowerSubstation_Info)list[i]).L5);

                    //}
                    //catch { }
                    //try
                    //{

                    //    t2z += (int)((PSP_PowerSubstation_Info)list[i]).L3;
                    //}
                    //catch { }
                    x2z++;
                }
                else if (((PSP_PowerSubstation_Info)list[i]).S1 == "220"&& ((PSP_PowerSubstation_Info)list[i]).S8 != "ר��")
                {
                    if (((PSP_PowerSubstation_Info)list[i]).AreaName != area_220)
                    {
                        if (!table_220.Contains(((PSP_PowerSubstation_Info)list[i]).AreaName))
                        {

                            table_220.Add(((PSP_PowerSubstation_Info)list[i]).AreaName, i);
                            groupList_220.Add(((PSP_PowerSubstation_Info)list[i]).AreaName);
                            //  table[((PSP_PowerSubstation_Info)list[i]).AreaName] = i;
                        }
                        area_220 = ((PSP_PowerSubstation_Info)list[i]).AreaName;
                    }
                    if (two)
                    { index2 = i; two = false; }
                    ((PSP_PowerSubstation_Info)list[i]).S20 = x2.ToString();
                    h2 += Convert.ToDouble(((PSP_PowerSubstation_Info)list[i]).S2);
                    //try
                    //{
                    //    z2 += double.Parse(((PSP_PowerSubstation_Info)list[i]).L5);

                    //}
                    //catch { }
                    //try
                    //{

                    //    t2 += (int)((PSP_PowerSubstation_Info)list[i]).L3;
                    //}
                    //catch { }
                    x2++;
                }
                else if (((PSP_PowerSubstation_Info)list[i]).S1 == "110" && ((PSP_PowerSubstation_Info)list[i]).S8 == "ר��")
                {
                    if (((PSP_PowerSubstation_Info)list[i]).AreaName != area2)
                    {
                        if (!table2.Contains(((PSP_PowerSubstation_Info)list[i]).AreaName))
                        {

                            table2.Add(((PSP_PowerSubstation_Info)list[i]).AreaName, i);
                            groupList2.Add(((PSP_PowerSubstation_Info)list[i]).AreaName);
                            //  table[((PSP_PowerSubstation_Info)list[i]).AreaName] = i;
                        }
                        area2 = ((PSP_PowerSubstation_Info)list[i]).AreaName;
                    }
                    if (onez)
                    { index1z = i; onez = false; }
                    ((PSP_PowerSubstation_Info)list[i]).S20 = x1z.ToString();
                    h1z +=Convert.ToDouble(((PSP_PowerSubstation_Info)list[i]).S2) ;
                    //try
                    //{
                    //    z1z += double.Parse(((PSP_PowerSubstation_Info)list[i]).L5);

                    //}
                    //catch { }
                    //try
                    //{

                    //    t1z += (int)((PSP_PowerSubstation_Info)list[i]).L3;
                    //}
                    //catch { }
                    x1z++;
                }
                else if (((PSP_PowerSubstation_Info)list[i]).S1 == "110" && ((PSP_PowerSubstation_Info)list[i]).S8 != "ר��")
                {
                    if (((PSP_PowerSubstation_Info)list[i]).AreaName != area)
                    {
                        if (!table.Contains(((PSP_PowerSubstation_Info)list[i]).AreaName))
                        {

                            table.Add(((PSP_PowerSubstation_Info)list[i]).AreaName, i);
                            groupList.Add(((PSP_PowerSubstation_Info)list[i]).AreaName);
                            //  table[((PSP_PowerSubstation_Info)list[i]).AreaName] = i;
                        }
                        area = ((PSP_PowerSubstation_Info)list[i]).AreaName;
                    }

                    if (one)
                    { index1 = i; one = false; }
                    ((PSP_PowerSubstation_Info)list[i]).S20 = x1.ToString();
                    h1 += Convert.ToDouble(((PSP_PowerSubstation_Info)list[i]).S2);
                    //try
                    //{
                    //    z1 += double.Parse(((PSP_PowerSubstation_Info)list[i]).L5);

                    //}
                    //catch { }
                    //try
                    //{

                    //    t1 += (int)((PSP_PowerSubstation_Info)list[i]).L3;
                    //}
                    //catch { }
                    x1++;
                }
                else if (((PSP_PowerSubstation_Info)list[i]).S1 == "35" && ((PSP_PowerSubstation_Info)list[i]).S8 == "ר��")
                {
                    if (((PSP_PowerSubstation_Info)list[i]).AreaName != area_35z)
                    {
                        if (!table_35z.Contains(((PSP_PowerSubstation_Info)list[i]).AreaName))
                        {

                            table_35z.Add(((PSP_PowerSubstation_Info)list[i]).AreaName, i);
                            groupList_35z.Add(((PSP_PowerSubstation_Info)list[i]).AreaName);
                        }
                        area_35z = ((PSP_PowerSubstation_Info)list[i]).AreaName;
                    }
                    if (threez)
                    { index35z = i; threez = false; }
                    ((PSP_PowerSubstation_Info)list[i]).S20 = x35z.ToString();
                    h35z += Convert.ToDouble(((PSP_PowerSubstation_Info)list[i]).S2);
                    //try
                    //{
                    //    z35z += double.Parse(((PSP_PowerSubstation_Info)list[i]).L5);

                    //}
                    //catch { }
                    //try
                    //{

                    //    t35z += (int)((PSP_PowerSubstation_Info)list[i]).L3;
                    //}
                    //catch { }
                    x35z++;
                }
                else if (((PSP_PowerSubstation_Info)list[i]).S1 == "35" && ((PSP_PowerSubstation_Info)list[i]).S8 != "ר��")
                {
                    if (((PSP_PowerSubstation_Info)list[i]).AreaName != area_35)
                    {
                        if (!table_35.Contains(((PSP_PowerSubstation_Info)list[i]).AreaName))
                        {

                            table_35.Add(((PSP_PowerSubstation_Info)list[i]).AreaName, i);
                            groupList_35.Add(((PSP_PowerSubstation_Info)list[i]).AreaName);
                        }
                        area_35 = ((PSP_PowerSubstation_Info)list[i]).AreaName;
                    }
                    if (three)
                    { index35 = i; three = false; }
                    ((PSP_PowerSubstation_Info)list[i]).S20 = x35.ToString();
                    h35 +=Convert.ToDouble(((PSP_PowerSubstation_Info)list[i]).S2) ;
                    //try
                    //{
                    //    z35 += double.Parse(((PSP_PowerSubstation_Info)list[i]).L5);

                    //}
                    //catch { }
                    //try
                    //{

                    //    t35 += (int)((PSP_PowerSubstation_Info)list[i]).L3;
                    //}
                    //catch { }
                    x35++;
                }
                else if (((PSP_PowerSubstation_Info)list[i]).S1 == "10" && ((PSP_PowerSubstation_Info)list[i]).S8 == "ר��")
                {
                    if (((PSP_PowerSubstation_Info)list[i]).AreaName != area_10z)
                    {
                        if (!table_10z.Contains(((PSP_PowerSubstation_Info)list[i]).AreaName))
                        {

                            table_10z.Add(((PSP_PowerSubstation_Info)list[i]).AreaName, i);
                            groupList_10z.Add(((PSP_PowerSubstation_Info)list[i]).AreaName);
                        }
                        area_10z = ((PSP_PowerSubstation_Info)list[i]).AreaName;
                    }
                    if (tenz)
                    { index10z = i; tenz = false; }
                    ((PSP_PowerSubstation_Info)list[i]).S20= x10z.ToString();
                    h10z += Convert.ToDouble(((PSP_PowerSubstation_Info)list[i]).S2);
                    //try
                    //{
                    //    z10z += double.Parse(((PSP_PowerSubstation_Info)list[i]).L5);

                    //}
                    //catch { }
                    //try
                    //{

                    //    t10z += (int)((PSP_PowerSubstation_Info)list[i]).L3;
                    //}
                    //catch { }
                    x10z++;
                }
                else if (((PSP_PowerSubstation_Info)list[i]).S1 == "10" && ((PSP_PowerSubstation_Info)list[i]).S8 != "ר��")
                {
                    if (((PSP_PowerSubstation_Info)list[i]).AreaName != area_10)
                    {
                        if (!table_10.Contains(((PSP_PowerSubstation_Info)list[i]).AreaName))
                        {

                            table_10.Add(((PSP_PowerSubstation_Info)list[i]).AreaName, i);
                            groupList_10.Add(((PSP_PowerSubstation_Info)list[i]).AreaName);
                        }
                        area_10 = ((PSP_PowerSubstation_Info)list[i]).AreaName;
                    }
                    if (ten)
                    { index10 = i; ten = false; }
                    ((PSP_PowerSubstation_Info)list[i]).S20 = x10.ToString();
                    h10 += Convert.ToDouble(((PSP_PowerSubstation_Info)list[i]).S2);
                    //try
                    //{
                    //    z10 += double.Parse(((PSP_PowerSubstation_Info)list[i]).L5);

                    //}
                    //catch { }
                    //try
                    //{

                    //    t10 += (int)((PSP_PowerSubstation_Info)list[i]).L3;
                    //}
                    //catch { }
                    x10++;
                }
                else if (((PSP_PowerSubstation_Info)list[i]).S1 == "6" && ((PSP_PowerSubstation_Info)list[i]).S8 == "ר��")
                {
                    if (((PSP_PowerSubstation_Info)list[i]).AreaName != area_6z)
                    {
                        if (!table_6z.Contains(((PSP_PowerSubstation_Info)list[i]).AreaName))
                        {

                            table_6z.Add(((PSP_PowerSubstation_Info)list[i]).AreaName, i);
                            groupList_6z.Add(((PSP_PowerSubstation_Info)list[i]).AreaName);
                        }
                        area_6z = ((PSP_PowerSubstation_Info)list[i]).AreaName;
                    }
                    if (sixz)
                    { index6z = i; sixz = false; }
                    ((PSP_PowerSubstation_Info)list[i]).S20 = x6z.ToString();
                    h6z += Convert.ToDouble(((PSP_PowerSubstation_Info)list[i]).S2);
                    //try
                    //{
                    //    z6z += double.Parse(((PSP_PowerSubstation_Info)list[i]).L5);

                    //}
                    //catch { }
                    //try
                    //{

                    //    t6z += (int)((PSP_PowerSubstation_Info)list[i]).L3;
                    //}
                    //catch { }
                    x6z++;
                }
                else if (((PSP_PowerSubstation_Info)list[i]).S1 =="6"  && ((PSP_PowerSubstation_Info)list[i]).S8 != "ר��")
                {
                    if (((PSP_PowerSubstation_Info)list[i]).AreaName != area_6)
                    {
                        if (!table_6.Contains(((PSP_PowerSubstation_Info)list[i]).AreaName))
                        {

                            table_6.Add(((PSP_PowerSubstation_Info)list[i]).AreaName, i);
                            groupList_6.Add(((PSP_PowerSubstation_Info)list[i]).AreaName);
                        }
                        area_6 = ((PSP_PowerSubstation_Info)list[i]).AreaName;
                    }
                    if (six)
                    { index6 = i; six = false; }
                    ((PSP_PowerSubstation_Info)list[i]).S20 = x6.ToString();
                    h6 += Convert.ToDouble(((PSP_PowerSubstation_Info)list[i]).S2);
                    //try
                    //{
                    //    z6 += double.Parse(((PSP_PowerSubstation_Info)list[i]).L5);

                    //}
                    //catch { }
                    //try
                    //{

                    //    t6 += (int)((PSP_PowerSubstation_Info)list[i]).L3;
                    //}
                    //catch { }
                    x6++;
                }
            }
            if (x5 > 1)
            {
                PSP_PowerSubstation_Info info = new PSP_PowerSubstation_Info();
                info.S20 = que[j];
                j++;
                info.Title = "500ǧ��";
                info.S2 = h5.ToString();
                //info.L5 = z5.ToString();
                //info.L3 = t5;
                info.S11 = "500";
                info.S8 = "no";
                list.Insert(index5, info);//.Add(info);
                now++;
                for (int k = 0; k < groupList_500.Count; k++)
                {
                    PSP_PowerSubstation_Info infok = new PSP_PowerSubstation_Info();
                    infok.S20 = Convert.ToChar(k + 65).ToString().ToLower();
                    //infok.Title = groupList[k];
                    infok.AreaName = groupList_500[k];
                    conn = "S1='500' and AreaID='" + projectid + "' and  AreaName='" + groupList_500[k] + "'";
                    IList temList = Common.Services.BaseService.GetList("SelectSumPSP_PowerSubstation_InfoByConn", conn);
                    infok.S2 = ((PSP_PowerSubstation_Info)temList[0]).S2;
                    //infok.L5 = ((PSP_PowerSubstation_Info)temList[0]).L5;
                    infok.S1 = "500";
                    infok.S8 = "no";
                    conn += " and Flag='" + Ghflag + "' order by Title ";
                    temList = Common.Services.BaseService.GetList("SelectPSP_PowerSubstation_InfoListByWhere", conn);

                    list.Insert(int.Parse(table_500[groupList_500[k]].ToString()) + now, infok);
                    now++;
                }
            }
            if (x2 > 1)
            {
                PSP_PowerSubstation_Info info2 = new PSP_PowerSubstation_Info();
                info2.S20 = que[j];
                j++;
                info2.Title = "220ǧ������";
                info2.S2 = h2.ToString();

                info2.S1 = "220";
                info2.S8 = "no";
                list.Insert(index2 + now, info2);
                now++;
                for (int k = 0; k < groupList_220.Count; k++)
                {
                    PSP_PowerSubstation_Info infok = new PSP_PowerSubstation_Info();
                    infok.S20 = Convert.ToChar(k + 65).ToString().ToLower();
                    //infok.Title = groupList[k];
                    infok.AreaName = groupList_220[k];
                    conn = "S1='220' and AreaID='" + projectid + "' and  AreaName='" + groupList_220[k] + "'and S8!='ר��'" ;
                    IList temList = Common.Services.BaseService.GetList("SelectSumPSP_PowerSubstation_InfoByConn", conn);
                    infok.S2 = ((PSP_PowerSubstation_Info)temList[0]).S2;

                    infok.S1 = "220";
                    infok.S4 = "no";
                    conn += " and Flag='" + Ghflag + "' order by Title ";
                    temList = Common.Services.BaseService.GetList("SelectPSP_PowerSubstation_InfoListByWhere", conn);

                    list.Insert(int.Parse(table_220[groupList_220[k]].ToString()) + now, infok);
                    now++;
                }
            }
            if (x2z > 1)
            {
                PSP_PowerSubstation_Info info2z = new PSP_PowerSubstation_Info();
                info2z.S20 = que[j];
                j++;
                info2z.Title = "220ǧ��ר��";
                info2z.S2 = h2z.ToString();

                info2z.S1 = "220";
                info2z.S8 = "no";
                list.Insert(index2z + now, info2z);
                now++;

                for (int k = 0; k < groupList_220z.Count; k++)
                {
                    PSP_PowerSubstation_Info infok = new PSP_PowerSubstation_Info();
                    infok.S20 = Convert.ToChar(k + 65).ToString().ToLower();
                    //infok.Title = groupList2[k];
                    infok.AreaName = groupList_220z[k];
                    conn = "S1='220' and AreaID='" + projectid + "' and  AreaName='" + groupList_220z[k] + "' and S8='ר��'";
                    IList temList = Common.Services.BaseService.GetList("SelectSumPSP_PowerSubstation_InfoByConn", conn);
                    infok.S2 = ((PSP_PowerSubstation_Info)temList[0]).S2;

                    infok.S1 = "220";
                    infok.S4 = "no";
                    conn += " and Flag='" + Ghflag + "' order by Title ";
                    temList = Common.Services.BaseService.GetList("SelectPSP_PowerSubstation_InfoListByWhere", conn);

                    list.Insert(int.Parse(table_220z[groupList_220z[k]].ToString()) + now, infok);
                    now++;
                }
            }
            if (x1 > 1)
            {
                PSP_PowerSubstation_Info info1 = new PSP_PowerSubstation_Info();
                info1.S20 = que[j];
                j++;
                info1.Title = "110ǧ������";
                info1.S2 = h1.ToString();

                info1.S1 = "110";
                info1.S8 = "no";
                list.Insert(index1 + now, info1);
                now++;
                for (int k = 0; k < groupList.Count; k++)
                {
                    PSP_PowerSubstation_Info infok = new PSP_PowerSubstation_Info();
                    infok.S20 = Convert.ToChar(k + 65).ToString().ToLower();
                    //infok.Title = groupList[k];
                    infok.AreaName = groupList[k];
                    conn = "S1='110' and AreaID='" + projectid + "' and  AreaName='" + groupList[k] + "'  and S8!='ר��'" ;
                    IList temList = Common.Services.BaseService.GetList("SelectSumPSP_PowerSubstation_InfoByConn", conn);
                    infok.S2 = ((PSP_PowerSubstation_Info)temList[0]).S2;

                    infok.S1 = "110";
                    infok.S8 = "no";
                    conn += " and Flag='" + Ghflag + "' order by Title ";
                    temList = Common.Services.BaseService.GetList("SelectPSP_PowerSubstation_InfoListByWhere", conn);

                    list.Insert(int.Parse(table[groupList[k]].ToString()) + now, infok);
                    now++;
                }
            }
            if (x1z > 1)
            {
                PSP_PowerSubstation_Info info1z = new PSP_PowerSubstation_Info();
                info1z.S20= que[j];
                j++;
                info1z.Title = "110ǧ��ר��";
                info1z.S2 = h1z.ToString();

                info1z.S1 = "110";
                info1z.S8 = "no";
                list.Insert(index1z + now, info1z);
                now++;

                for (int k = 0; k < groupList2.Count; k++)
                {
                    PSP_PowerSubstation_Info infok = new PSP_PowerSubstation_Info();
                    infok.S20= Convert.ToChar(k + 65).ToString().ToLower();
                    //infok.Title = groupList2[k];
                    infok.AreaName = groupList2[k];
                    conn = "S1='110 'and AreaID='" + projectid + "' and  AreaName='" + groupList2[k] + "' and S8='ר��'";
                    IList temList = Common.Services.BaseService.GetList("SelectSumPSP_PowerSubstation_InfoByConn", conn);
                    infok.S2 = ((PSP_PowerSubstation_Info)temList[0]).S2;

                    infok.S1 = "110";
                    infok.S8 = "no";
                    conn += " and Flag='" + Ghflag + "' order by Title ";
                    temList = Common.Services.BaseService.GetList("SelectPSP_PowerSubstation_InfoListByWhere", conn);

                    list.Insert(int.Parse(table2[groupList2[k]].ToString()) + now, infok);
                    now++;
                }
            }
            if (x35 > 1)
            {
                PSP_PowerSubstation_Info info35 = new PSP_PowerSubstation_Info();
                info35.S20 = que[j];
                j++;
                info35.Title = "35ǧ������";
                info35.S2 = h35.ToString();

                info35.S1 = "35";
                info35.S4 = "no";
                list.Insert(index35 + now, info35);
                now++;
                for (int k = 0; k < groupList_35.Count; k++)
                {
                    PSP_PowerSubstation_Info infok = new PSP_PowerSubstation_Info();
                    infok.S20 = Convert.ToChar(k + 65).ToString().ToLower();
                    //infok.Title = groupList[k];
                    infok.AreaName = groupList_35[k];
                    conn = "S1='35' and AreaID='" + projectid + "' and  AreaName='" + groupList_35[k] + "'  and S8!='ר��' ";
                    IList temList = Common.Services.BaseService.GetList("SelectSumPSP_PowerSubstation_InfoByConn", conn);
                    infok.S2 = ((PSP_PowerSubstation_Info)temList[0]).S2;

                    infok.S1 = "35";
                    infok.S8 = "no";
                    conn += " and Flag='" + Ghflag + "' order by Title ";
                    temList = Common.Services.BaseService.GetList("SelectPSP_PowerSubstation_InfoListByWhere", conn);

                    list.Insert(int.Parse(table_35[groupList_35[k]].ToString()) + now, infok);
                    now++;
                }
            }
            if (x35z > 1)
            {
                PSP_PowerSubstation_Info info35z = new PSP_PowerSubstation_Info();
                info35z.S20 = que[j];
                j++;
                info35z.Title = "35ǧ��ר��";
                info35z.S2 = h35z.ToString();

                info35z.S2 = "35";
                info35z.S4 = "no";
                list.Insert(index35z + now, info35z);
                now++;

                for (int k = 0; k < groupList_35z.Count; k++)
                {
                    PSP_PowerSubstation_Info infok = new PSP_PowerSubstation_Info();
                    infok.S20 = Convert.ToChar(k + 65).ToString().ToLower();
                    //infok.Title = groupList2[k];
                    infok.AreaName = groupList_35z[k];
                    conn = "S1='35' and AreaID='" + projectid + "' and  AreaName='" + groupList_35z[k] + "' and S8='ר��'";
                    IList temList = Common.Services.BaseService.GetList("SelectSumPSP_PowerSubstation_InfoByConn", conn);
                    infok.S2 = ((PSP_PowerSubstation_Info)temList[0]).S2;

                    infok.S1 = "35";
                    infok.S8 = "no";
                    conn += " and Flag='" + Ghflag + "' order by Title ";
                    temList = Common.Services.BaseService.GetList("SelectPSP_PowerSubstation_InfoListByWhere", conn);

                    list.Insert(int.Parse(table_35z[groupList_35z[k]].ToString()) + now, infok);
                    now++;
                }
            }
            if (x10 > 1)
            {
                PSP_PowerSubstation_Info info10 = new PSP_PowerSubstation_Info();
                info10.S20 = que[j];
                j++;
                info10.Title = "10ǧ������";
                info10.S2 = h10.ToString();

                info10.S1 = "10";
                info10.S8 = "no";
                list.Insert(index10 + now, info10);
                now++;
                for (int k = 0; k < groupList_10.Count; k++)
                {
                    PSP_PowerSubstation_Info infok = new PSP_PowerSubstation_Info();
                    infok.S20 = Convert.ToChar(k + 65).ToString().ToLower();
                    //infok.Title = groupList[k];
                    infok.AreaName = groupList_10[k];
                    conn = "S1='10' and AreaID='" + projectid + "' and  AreaName='" + groupList_10[k] + "'  and S8!='ר��'";
                    IList temList = Common.Services.BaseService.GetList("SelectSumPSP_PowerSubstation_InfoByConn", conn);
                    infok.S2 = ((PSP_PowerSubstation_Info)temList[0]).S2;

                    infok.S1 ="10" ;
                    infok.S8 = "no";
                    conn += " and Flag='" + Ghflag + "' order by Title ";
                    temList = Common.Services.BaseService.GetList("SelectPSP_PowerSubstation_InfoListByWhere", conn);

                    list.Insert(int.Parse(table_10[groupList_10[k]].ToString()) + now, infok);
                    now++;
                }
            }
            if (x10z > 1)
            {
                PSP_PowerSubstation_Info info10z = new PSP_PowerSubstation_Info();
                info10z.S20 = que[j];
                j++;
                info10z.Title = "10ǧ��ר��";
                info10z.S2 = h10z.ToString();

                info10z.S1 = "10";
                info10z.S8 = "no";
                list.Insert(index10z + now, info10z);
                now++;

                for (int k = 0; k < groupList_10z.Count; k++)
                {
                    PSP_PowerSubstation_Info infok = new PSP_PowerSubstation_Info();
                    infok.S20 = Convert.ToChar(k + 65).ToString().ToLower();
                    //infok.Title = groupList2[k];
                    infok.AreaName = groupList_10z[k];
                    conn = "S1='10' and AreaID='" + projectid + "' and  AreaName='" + groupList_10z[k] + "' and S8='ר��'";
                    IList temList = Common.Services.BaseService.GetList("SelectSumPSP_PowerSubstation_InfoByConn", conn);
                    infok.S2 = ((PSP_PowerSubstation_Info)temList[0]).S2;

                    infok.S1 = "10";
                    infok.S8 = "no";
                    conn += " and Flag='" + Ghflag + "' order by Title ";
                    temList = Common.Services.BaseService.GetList("SelectPSP_PowerSubstation_InfoListByWhere", conn);

                    list.Insert(int.Parse(table_10z[groupList_10z[k]].ToString()) + now, infok);
                    now++;
                }
            }
            if (x6 > 1)
            {
                PSP_PowerSubstation_Info info6 = new PSP_PowerSubstation_Info();
                info6.S20 = que[j];
                j++;
                info6.Title = "6ǧ������";
                info6.S2 = h6.ToString();

                info6.S1 ="6" ;
                info6.S8 = "no";
                list.Insert(index6 + now, info6);
                now++;
                for (int k = 0; k < groupList_6.Count; k++)
                {
                    PSP_PowerSubstation_Info infok = new PSP_PowerSubstation_Info();
                    infok.S20 = Convert.ToChar(k + 65).ToString().ToLower();
                    //infok.Title = groupList[k];
                    infok.AreaName = groupList_6[k];
                    conn = "S1='6' and AreaID='" + projectid + "' and  AreaName='" + groupList_6[k] + "'  and S8!='ר��'";
                    IList temList = Common.Services.BaseService.GetList("SelectSumPSP_PowerSubstation_InfoByConn", conn);
                    infok.S2 = ((PSP_PowerSubstation_Info)temList[0]).S2;

                    infok.S1 = "6";
                    infok.S4 = "no";
                    conn += " and Flag='" + Ghflag + "' order by Title ";
                    temList = Common.Services.BaseService.GetList("SelectPSP_PowerSubstation_InfoListByWhere", conn);

                    list.Insert(int.Parse(table_6[groupList_6[k]].ToString()) + now, infok);
                    now++;
                }
            }
            if (x6z > 1)
            {
                PSP_PowerSubstation_Info info6z = new PSP_PowerSubstation_Info();
                info6z.S20= que[j];
                j++;
                info6z.Title = "6ǧ��ר��";
                info6z.S2 = h6z.ToString();

                info6z.S1 = "6";
                info6z.S8= "no";
                list.Insert(index6z + now, info6z);
                now++;

                for (int k = 0; k < groupList_6z.Count; k++)
                {
                    PSP_PowerSubstation_Info infok = new PSP_PowerSubstation_Info();
                    infok.S20 = Convert.ToChar(k + 65).ToString().ToLower();
                    //infok.Title = groupList2[k];
                    infok.AreaName = groupList_6z[k];
                    conn = "S1='6' and AreaID='" + projectid + "' and  AreaName='" + groupList_6z[k] + "' and S8='ר��'";
                    IList temList = Common.Services.BaseService.GetList("SelectSumPSP_PowerSubstation_InfoByConn", conn);
                    infok.S2 = ((PSP_PowerSubstation_Info)temList[0]).S2;

                    infok.S1 ="6" ;
                    infok.S8 = "no";
                    conn += " and Flag='" + Ghflag + "' order by Title ";
                    temList = Common.Services.BaseService.GetList("SelectPSP_PowerSubstation_InfoListByWhere", conn);

                    list.Insert(int.Parse(table_6z[groupList_6z[k]].ToString()) + now, infok);
                    now++;
                }
            }
            try
            {
                //for (int i = 0; i < list.Count; i++)
                //{
                //    if (((PSP_PowerSubstation_Info)list[i]).L9 != null && (double)((PSP_PowerSubstation_Info)list[i]).L2 != null)
                //    {
                //        double templ9 = (double)((PSP_PowerSubstation_Info)list[i]).L9;
                //        double templ2 = (double)((PSP_PowerSubstation_Info)list[i]).L2;
                //        ((PSP_PowerSubstation_Info)list[i]).L10 = (templ2 == 0 ? 0 : templ9 / templ2) * 100;
                //        PSP_PowerSubstation_Info tempsub = Common.Services.BaseService.GetOneByKey<PSP_PowerSubstation_Info>(((PSP_PowerSubstation_Info)list[i]).UID);
                //        tempsub.L10 = ((PSP_PowerSubstation_Info)list[i]).L10;
                //        Common.Services.BaseService.Update<PSP_PowerSubstation_Info>(tempsub);
                //    }
                //}
            }
            catch (Exception ew)
            {

                MessageBox.Show("���㸺���ʳ���" + ew.Message);
            }

            this.gridControl1.DataSource = list;
            fu_list = list;

            list_copy(list, fu_list_no);
            att_list(fu_list_no);
        }
Esempio n. 3
0
        private void comboBoxEdit1_SelectedIndexChanged(object sender, EventArgs e)
        {
            //�������˹�ϵ
            vistlineflag.Clear();
            vistbusflag .Clear();
            vistsubstationflag .Clear();
            vistpowerflag.Clear();
            visttrans2flag.Clear();
            visttrans3flag.Clear();
            vistfdjflag.Clear();
            vistfhflag.Clear();
            vistmlflag.Clear();
            vistml2flag.Clear();
            vistcldkflag.Clear();
            vistcldrflag.Clear();
            vistbldkflag.Clear();
            vistbldrflag.Clear();
            vistdlqflag.Clear();
            string con = " AreaID = '" + Itop.Client.MIS.ProgUID + "' AND Title='"+comboBoxEdit1.Text+"'";
            PSP_Substation_Info list =(PSP_Substation_Info) UCDeviceBase.DataService.GetObject("SelectPSP_Substation_InfoListByWhere", con);
            vistsubstationflag.Add(list.Title, list);
            con = "WHERE SvgUID='" + list.UID + "'AND projectid='" + Itop.Client.MIS.ProgUID + "'AND Type='01'";
            IList buslist = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
            if (buslist!=null)
            {
                for (int i = 0; i < buslist.Count;i++ )
                {
                    TopolyCheck(type, (PSPDEV)buslist[i]);
                }
                foreach (KeyValuePair<string, PSPDEV> keyvalue in vistbusflag)
                {
                    if (string.IsNullOrEmpty(keyvalue.Value.SvgUID))
                    {
                        MessageBox.Show(keyvalue.Value.Name + "û�й������վ��", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;

                    }
                    else
                    {
                        if (list == null) return;
                        list.UID = keyvalue.Value.SvgUID;

                    }
                 list.UID=keyvalue.Value.SvgUID;

                 list = (PSP_Substation_Info)UCDeviceBase.DataService.GetObject("SelectPSP_Substation_InfoByKey", list);
                    if (list!=null)
                    {
                        if (!vistsubstationflag.ContainsKey(list.Title))
                            vistsubstationflag.Add(list.Title, list);
                    }

                 PSP_PowerSubstation_Info pp = new PSP_PowerSubstation_Info();
                 pp.UID = keyvalue.Value.SvgUID;
                 pp = (PSP_PowerSubstation_Info)UCDeviceBase.DataService.GetObject("SelectPSP_PowerSubstation_InfoByKey", pp);
                    if (pp!=null)
                    {
                        if (!vistpowerflag.ContainsKey(pp.Title))
                            vistpowerflag.Add(pp.Title, pp);
                    }
                    con = " WHERE IName='" + keyvalue.Value.Name + "' AND ProjectID = '" + Itop.Client.MIS.ProgUID + "'" + "AND Type='11'";
                    IList pspline1 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                    foreach (PSPDEV psp in pspline1)
                    {
                        if (vistbldkflag.ContainsKey(psp.Name))
                        {
                            continue;
                        }
                        else
                        {
                            vistbldkflag.Add(psp.Name, psp);

                        }
                    }
                    con = " WHERE IName='" + keyvalue.Value.Name + "' AND ProjectID = '" + Itop.Client.MIS.ProgUID + "'" + "AND Type='09'";
                    pspline1 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                    foreach (PSPDEV psp in pspline1)
                    {
                        if (vistbldrflag.ContainsKey(psp.Name))
                        {
                            continue;
                        }
                        else
                        {
                            vistbldrflag.Add(psp.Name, psp);

                        }
                    }
                    con = " WHERE IName='" + keyvalue.Value.Name + "' AND ProjectID = '" + Itop.Client.MIS.ProgUID + "'" + "AND Type='12'";
                    pspline1 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                    foreach (PSPDEV psp in pspline1)
                    {
                        if (vistfhflag.ContainsKey(psp.Name))
                        {
                            continue;
                        }
                        else
                        {
                            vistfhflag.Add(psp.Name, psp);

                        }
                    }
                    con = " WHERE IName='" + keyvalue.Value.Name + "' AND ProjectID = '" + Itop.Client.MIS.ProgUID + "'" + "AND Type='04'";
                    pspline1 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                    foreach (PSPDEV psp in pspline1)
                    {
                        if (vistfdjflag.ContainsKey(psp.Name))
                        {
                            continue;
                        }
                        else
                        {
                            vistfdjflag.Add(psp.Name, psp);

                        }
                    }
                    con = " WHERE IName='" + keyvalue.Value.Name + "' AND ProjectID = '" + Itop.Client.MIS.ProgUID + "'" + "AND Type='13'";
                    pspline1 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                    foreach (PSPDEV psp in pspline1)
                    {
                        if (vistmlflag.ContainsKey(psp.Name))
                        {
                            continue;
                        }
                        else
                        {
                            vistmlflag.Add(psp.Name, psp);

                        }
                    }
                    con = " WHERE JName='" + keyvalue.Value.Name + "' AND ProjectID = '" + Itop.Client.MIS.ProgUID + "'" + "AND Type='13'";
                    pspline1 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                    foreach (PSPDEV psp in pspline1)
                    {
                        if (vistmlflag.ContainsKey(psp.Name))
                        {
                            continue;
                        }
                        else
                        {
                            vistmlflag.Add(psp.Name, psp);

                        }
                    }
                    con = " WHERE IName='" + keyvalue.Value.Name + "' AND ProjectID = '" + Itop.Client.MIS.ProgUID + "'" + "AND Type='06'";
                    pspline1 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                    foreach (PSPDEV psp in pspline1)
                    {
                        if (vistdlqflag.ContainsKey(psp.Name))
                        {
                            continue;
                        }
                        else
                        {
                            vistdlqflag.Add(psp.Name, psp);

                        }
                    }
                    con = " WHERE HuganLine1='" + keyvalue.Value.Name + "' AND ProjectID = '" + Itop.Client.MIS.ProgUID + "'" + "AND Type='14'";
                    pspline1 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                    foreach (PSPDEV psp in pspline1)
                    {
                        if (vistml2flag.ContainsKey(psp.Name))
                        {
                            continue;
                        }
                        else
                        {
                            vistml2flag.Add(psp.Name, psp);

                        }
                    }
                    con = " WHERE HuganLine2='" + keyvalue.Value.Name + "' AND ProjectID = '" + Itop.Client.MIS.ProgUID + "'" + "AND Type='14'";
                    pspline1 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                    foreach (PSPDEV psp in pspline1)
                    {
                        if (vistml2flag.ContainsKey(psp.Name))
                        {
                            continue;
                        }
                        else
                        {
                            vistml2flag.Add(psp.Name, psp);

                        }
                    }
                    con = " WHERE IName='" + keyvalue.Value.Name + "' AND ProjectID = '" + Itop.Client.MIS.ProgUID + "'" + "AND Type='02'";
                    pspline1 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                    foreach (PSPDEV psp in pspline1)
                    {
                        if (visttrans2flag.ContainsKey(psp.Name))
                        {
                            continue;
                        }
                        else
                        {
                            visttrans2flag.Add(psp.Name, psp);

                        }
                    }
                    con = " WHERE JName='" + keyvalue.Value.Name + "' AND ProjectID = '" + Itop.Client.MIS.ProgUID + "'" + "AND Type='02'";
                    pspline1 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                    foreach (PSPDEV psp in pspline1)
                    {
                        if (visttrans2flag.ContainsKey(psp.Name))
                        {
                            continue;
                        }
                        else
                        {
                            visttrans2flag.Add(psp.Name, psp);

                        }
                    }
                    con = " WHERE IName='" + keyvalue.Value.Name + "' AND ProjectID = '" + Itop.Client.MIS.ProgUID + "'" + "AND Type='03'";
                    pspline1 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                    foreach (PSPDEV psp in pspline1)
                    {
                        if (visttrans3flag.ContainsKey(psp.Name))
                        {
                            continue;
                        }
                        else
                        {
                            visttrans3flag.Add(psp.Name, psp);

                        }
                    }
                    con = " WHERE JName='" + keyvalue.Value.Name + "' AND ProjectID = '" + Itop.Client.MIS.ProgUID + "'" + "AND Type='03'";
                    pspline1 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                    foreach (PSPDEV psp in pspline1)
                    {
                        if (visttrans3flag.ContainsKey(psp.Name))
                        {
                            continue;
                        }
                        else
                        {
                            visttrans3flag.Add(psp.Name, psp);

                        }
                    }
                    con = " WHERE KName='" + keyvalue.Value.Name + "' AND ProjectID = '" + Itop.Client.MIS.ProgUID + "'" + "AND Type='03'";
                    pspline1 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                    foreach (PSPDEV psp in pspline1)
                    {
                        if (visttrans3flag.ContainsKey(psp.Name))
                        {
                            continue;
                        }
                        else
                        {
                            visttrans3flag.Add(psp.Name, psp);

                        }
                    }
                }
                foreach (KeyValuePair<string, PSPDEV> keyvalue in vistlineflag)
                {
                    con = " WHERE IName='" + keyvalue.Value.Name + "' AND ProjectID = '" + Itop.Client.MIS.ProgUID + "'" + "AND Type='08'";
                    IList pspline1 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                    foreach (PSPDEV psp in pspline1)
                    {
                        if (vistcldrflag.ContainsKey(psp.Name))
                        {
                            continue;
                        }
                        else
                        {
                            vistcldrflag.Add(psp.Name, psp);

                        }
                    }
                    con = " WHERE IName='" + keyvalue.Value.Name + "' AND ProjectID = '" + Itop.Client.MIS.ProgUID + "'" + "AND Type='10'";
                    pspline1 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                    foreach (PSPDEV psp in pspline1)
                    {
                        if (vistcldkflag.ContainsKey(psp.Name))
                        {
                            continue;
                        }
                        else
                        {
                            vistcldkflag.Add(psp.Name, psp);

                        }
                    }
                }

            }

            else
            {
                MessageBox.Show("�˱��վû�����˹�ϵ�����ѯ���ݺ��ٽ��м���!");
            }
        }
        public bool RefreshDataOut(string addConn)
        {
            try
            {
                string filepath = "";
                string con = "AreaID='" + projectid + "'";
                con += addConn;
                IList<PSP_PowerSubstation_Info> list = Services.BaseService.GetList<PSP_PowerSubstation_Info>("SelectSubstation_InfoByCon", con);
                if (xmlflag == "guihua")
                    filepath = Path.GetTempPath() + "\\" + Path.GetFileName("SubstationGuiHua.xml");
                else
                {
                    filepath = Path.GetTempPath() + "\\" + Path.GetFileName("SubstationLayOut11.xml");
                }

                if (File.Exists(filepath))
                {
                    this.gridView1.RestoreLayoutFromXml(filepath);
                }
                PSP_PowerSubstation_Info info = new PSP_PowerSubstation_Info();
                info.Title = "�ϼ�";
                //info.L9 = 0.0;
                //info.L3 = 0;
                //for (int i = 0; i < list.Count; i++)
                //{

                //    info.L5 = Convert.ToString(double.Parse(info.L5 == "" ? "0" : info.L5) + double.Parse((list[i] as Substation_Info).L5 == "" ? "0" : (list[i] as Substation_Info).L5));
                //    info.L6 = Convert.ToString(double.Parse(info.L6 == "" ? "0" : info.L6) + double.Parse((list[i] as Substation_Info).L6 == "" ? "0" : (list[i] as Substation_Info).L6));
                //    info.L3 += ((list[i] as Substation_Info).L3 == null ? 0 : (list[i] as Substation_Info).L3);
                //    info.L2 += (list[i] as Substation_Info).L2;
                //    info.L9 += (list[i] as Substation_Info).L9;
                //    info.L14 = Convert.ToString(double.Parse(info.L14 == "" ? "0" : info.L14) + double.Parse((list[i] as Substation_Info).L14 == "" ? "0" : (list[i] as Substation_Info).L14));
                //    info.L13 = Convert.ToString(double.Parse(info.L13 == "" ? "0" : info.L13) + double.Parse((list[i] as Substation_Info).L13 == "" ? "0" : (list[i] as Substation_Info).L13));
                //    info.S9 = Convert.ToString(double.Parse(info.S9 == "" ? "0" : info.S9) + double.Parse((list[i] as Substation_Info).S9 == "" ? "0" : (list[i] as Substation_Info).S9));
                //    info.S10 = Convert.ToString(double.Parse(info.S10 == "" ? "0" : info.S10) + double.Parse((list[i] as Substation_Info).S10 == "" ? "0" : (list[i] as Substation_Info).S10));
                //}
                //info.L10 = (info.L2 == 0 ? 0 : info.L9 / info.L2)*100;
                //info.S6 = Convert.ToString(double.Parse(info.L13) == 0.0 ? 0 : double.Parse(info.L14 == "" ? "0" : info.L14)*100 / double.Parse(info.L13));
                list.Add(info);
                this.gridControl1.DataSource = list;
            }
            catch (Exception exc)
            {
                Debug.Fail(exc.Message);
                HandleException.TryCatch(exc);
                return false;
            }

            return true;
        }
Esempio n. 5
0
        private void ShowResult(int order, string projectsuid, string FileName, int pspouttype, frnReport wFrom)
        {
            try
            {
                //删除原来的text文本
                //XmlNodeList list = tlVectorControl1.SVGDocument.SelectNodes("svg/*[@flag='" + "1" + "']");

                //foreach (XmlNode node in list)
                //{
                //    SvgElement element = node as SvgElement;
                //    tlVectorControl1.SVGDocument.CurrentElement = element;
                //    tlVectorControl1.Delete();
                //}
                wFrom.ShowText += "\r\n开始显示计算结果\t" + System.DateTime.Now.ToString();
                double yinzi = 0, capability = 0, volt = 0, standvolt = 0, current = 0;
                PSPDEV benchmark = new PSPDEV();
                benchmark.Type = "power";
                benchmark.SvgUID = projectsuid;
                IList list3 = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", benchmark);
                //if (list3 == null)
                //{
                //    MessageBox.Show("请设置基准后再进行计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //    return;
                //}
                foreach (PSPDEV dev in list3)
                {
                    yinzi = Convert.ToDouble(dev.PowerFactor);
                    capability = Convert.ToDouble(dev.StandardCurrent);
                    volt = Convert.ToDouble(dev.StandardVolt);
                    TLPSPVmin = dev.iV;
                    TLPSPVmax = dev.jV;
                    if (dev.PowerFactor == 0)
                    {
                        yinzi = 1;
                    }
                    if (dev.StandardCurrent == 0)
                    {
                        capability = 1;
                    }
                    if (dev.StandardVolt == 0)
                    {
                        volt = 1;
                    }
                    standvolt = volt;
                    current = capability / (Math.Sqrt(3) * volt);
                };
                Layer lar = null;
                if (Layer.CkLayerExist(FileName, tlVectorControl1.SVGDocument))
                {
                    ArrayList layercol = tlVectorControl1.SVGDocument.getLayerList();
                    for (int i = 0; i < layercol.Count; i++)
                    {
                        if (FileName == (layercol[i] as Layer).GetAttribute("label"))
                        {
                            lar = (Layer)layercol[i];
                            break;
                        }
                    }
                }
                else
                {
                    lar = Layer.CreateNew(FileName, tlVectorControl1.SVGDocument);

                    lar.SetAttribute("layerType", progtype);
                    lar.SetAttribute("ParentID", tlVectorControl1.SVGDocument.CurrentLayer.GetAttribute("ParentID"));
                    this.frmlar.checkedListBox1.SelectedIndex = -1;
                    this.frmlar.checkedListBox1.Items.Add(lar, true);
                }
                int size = tlVectorControl1.ScaleRatio > 1 ? 12 : (int)(12 / tlVectorControl1.ScaleRatio);
                XmlNodeList useList = tlVectorControl1.SVGDocument.SelectNodes("svg/use");
                foreach (XmlNode node in useList)
                {
                    XmlElement element = node as XmlElement;
                    string strCon = null;
                    IList listMX = null;
                    if (pspouttype == 0)
                    {
                        strCon = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectsuid + "' AND SvgUID = '" + (element).GetAttribute("Deviceid") + "' AND Type = '01'";
                        listMX = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                    }

                    //XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + element.GetAttribute("id") + "']");
                    if (pspouttype == 1)
                    {
                        bool pspflag = false;
                        PSP_Substation_Info ps = new PSP_Substation_Info();
                        ps.UID = (element).GetAttribute("Deviceid");
                        ps = (PSP_Substation_Info)Services.BaseService.GetObject("SelectPSP_Substation_InfoByKey", ps);
                        if (ps != null)
                        {
                            if (ps.Flag == "2")
                            {
                                strCon = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectsuid + "' AND SvgUID = '" + (element).GetAttribute("Deviceid") + "' AND Type = '01'";
                                listMX = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                            }

                            pspflag = true;
                        }
                        if (!pspflag)
                        {
                            PSP_PowerSubstation_Info ppi = new PSP_PowerSubstation_Info();
                            ppi.UID = (element).GetAttribute("Deviceid");
                            ppi = (PSP_PowerSubstation_Info)Services.BaseService.GetObject("SelectPSP_PowerSubstation_InfoByKey", ppi);
                            if (ppi != null)
                            {
                                if (ppi.Flag == "2")
                                {
                                    strCon = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectsuid + "' AND SvgUID = '" + (element).GetAttribute("Deviceid") + "' AND Type = '01'";
                                    listMX = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                                }

                            }
                        }

                    }

                    if (listMX != null)
                    {
                        for (int i = 0; i < listMX.Count; i++)
                        {
                            PSPDEV elementDEV = (PSPDEV)(listMX[i]);
                            PSP_ElcDevice elcDEV = new PSP_ElcDevice();
                            elcDEV.ProjectSUID = projectsuid;
                            elcDEV.DeviceSUID = ((PSPDEV)listMX[i]).SUID;
                            elcDEV = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDEV);
                            if (elcDEV != null)
                            {
                                XmlElement elementn1 = tlVectorControl1.SVGDocument.SelectSingleNode("svg/text[@ layer='" + lar.ID + "'and @ParentID1='" + ((PSPDEV)listMX[i]).SUID + "']") as XmlElement;
                                XmlElement elementn2 = tlVectorControl1.SVGDocument.SelectSingleNode("svg/text[@ layer='" + lar.ID + "'and @ParentID2='" + ((PSPDEV)listMX[i]).SUID + "']") as XmlElement;
                                if (elementn1 == null)
                                {
                                    //RectangleF bound = ((IGraph)element).GetBounds();
                                    //XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                    //XmlElement n2 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                    //n1.SetAttribute("x", Convert.ToString(bound.X));
                                    //n1.SetAttribute("y", Convert.ToString(bound.Y - i * 20));
                                    //n1.SetAttribute("font-size", size.ToString());//"12");
                                    //n1.InnerText = Convert.ToDouble(GetColValue(elcDEV, order).COL2).ToString("N2");
                                    ////Layer la = tlVectorControl1.SVGDocument.GetLayerByID(element.GetAttribute("layer"));
                                    //n1.SetAttribute("layer", lar.ID);
                                    ////MessageBox.Show(Convert.ToString(n1.InnerText));
                                    //n1.SetAttribute("flag", "1");
                                    //n1.SetAttribute("ParentID1", ((PSPDEV)listMX[i]).SUID);
                                    //if (Convert.ToDouble(GetColValue(elcDEV, order).COL2) > TLPSPVmax * elementDEV.RateVolt / elementDEV.ReferenceVolt || Convert.ToDouble(GetColValue(elcDEV, order).COL2) < TLPSPVmin * elementDEV.RateVolt / elementDEV.ReferenceVolt)//电压越限,需修改
                                    //    n1.SetAttribute("stroke", "#FF0000");
                                    //if (elementDEV.NodeType == "0")
                                    //{

                                    //    n2.SetAttribute("x", Convert.ToString(bound.X));
                                    //    n2.SetAttribute("y", Convert.ToString(bound.Y + bound.Height + 20));
                                    //    if (Convert.ToDouble(elcDEV.COL5) >= 0)
                                    //    {
                                    //        n2.InnerText = Convert.ToDouble(GetColValue(elcDEV, order).COL4).ToString("N2") + "  + " + "j" + Convert.ToDouble(GetColValue(elcDEV, order).COL5).ToString("N2");
                                    //    }
                                    //    else
                                    //    {
                                    //        n2.InnerText = Convert.ToDouble(GetColValue(elcDEV, order).COL4).ToString("N2") + "  - " + "j" + (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL5))).ToString("N2");
                                    //    }
                                    //    n2.SetAttribute("layer", lar.ID);
                                    //    n2.SetAttribute("flag", "1");
                                    //    n2.SetAttribute("ParentID", ((PSPDEV)listMX[i]).SUID);
                                    //    n2.SetAttribute("font-size", size.ToString());//"12");
                                    //    // n2.SetAttribute("limitsize", "true");

                                    //    double tempi = Convert.ToDouble(GetColValue(elcDEV, order).COL4);
                                    //    double tempj = Convert.ToDouble(GetColValue(elcDEV, order).COL5);
                                    //    double temptotal = Math.Sqrt(tempi * tempi + tempj * tempj);
                                    //    if (temptotal > Convert.ToDouble(elementDEV.Burthen))
                                    //    {
                                    //        n2.SetAttribute("stroke", "#FF0000");
                                    //    }
                                    //    tlVectorControl1.SVGDocument.RootElement.AppendChild(n2);

                                    //}
                                    //tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                                    //tlVectorControl1.Operation = ToolOperation.Select;
                                }
                                else
                                {
                                    //elementn1.InnerText = Convert.ToDouble(GetColValue(elcDEV, order).COL2).ToString("N2");
                                    //if (Convert.ToDouble(GetColValue(elcDEV, order).COL2) > TLPSPVmax * elementDEV.RateVolt / elementDEV.ReferenceVolt || Convert.ToDouble(GetColValue(elcDEV, order).COL2) < TLPSPVmin * elementDEV.RateVolt / elementDEV.ReferenceVolt)//电压越限,需修改
                                    //    elementn1.SetAttribute("stroke", "#FF0000");
                                    //if (elementDEV.NodeType == "0")
                                    //{

                                    //    if (Convert.ToDouble(elcDEV.COL5) >= 0)
                                    //    {
                                    //        elementn2.InnerText = Convert.ToDouble(GetColValue(elcDEV, order).COL4).ToString("N2") + "  + " + "j" + Convert.ToDouble(GetColValue(elcDEV, order).COL5).ToString("N2");
                                    //    }
                                    //    else
                                    //    {
                                    //        elementn2.InnerText = Convert.ToDouble(GetColValue(elcDEV, order).COL4).ToString("N2") + "  - " + "j" + (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL5))).ToString("N2");
                                    //    }
                                    //}
                                }

                            } tlVectorControl1.Refresh();
                        }
                    }

                }
                List<PSPDEV> listline = new List<PSPDEV>();
                if (pspouttype==1)
                {
                     SelShowlineform selbusfrm = new SelShowlineform();
                    selbusfrm.ProjectSUID = projectsuid;
                    selbusfrm.ProjectID = Itop.Client.MIS.ProgUID;
                    selbusfrm.ShowDialog();
                    if (selbusfrm.DialogResult == DialogResult.OK)
                    {

                        foreach (DataRow row in selbusfrm.DT.Rows)
                        {
                            try
                            {
                                if ((bool)row["C"])
                                {
                                    PSPDEV psp = new PSPDEV();
                                    psp.SUID = row["A"].ToString();

                                    psp = (PSPDEV)UCDeviceBase.DataService.GetObject("SelectPSPDEVByKey", psp);
                                    if (psp != null)
                                    {
                                        listline.Add(psp);
                                    }
                                }

                            }
                            catch (System.Exception ex)
                            {

                            }
                        }
                        if (listline.Count == 0)
                        {
                            MessageBox.Show("没有选择显示的线路!");
                            return;
                        }
                    }
                }
                wFrom.ShowText += "\r\n正在显示线路信息\t" + System.DateTime.Now.ToString();
                XmlNodeList polyLineList = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline");

                foreach (XmlNode node in polyLineList)
                {
                    XmlElement element = node as XmlElement;
                    PSP_ElcDevice elcDEV = new PSP_ElcDevice();
                    elcDEV.ProjectSUID = projectsuid;
                    elcDEV.DeviceSUID = element.GetAttribute("Deviceid");
                    elcDEV = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDEV);
                    PSPDEV elementDEV = new PSPDEV();
                    if (elcDEV != null)
                    {
                        elementDEV.SUID = elcDEV.DeviceSUID;
                        elementDEV = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", elementDEV);
                        if (pspouttype == 1)                             //如果只显示规划线路的数据
                        {
                            bool flag = false;
                            foreach (PSPDEV showdev in listline)
                            {
                                if (elementDEV.SUID==showdev.SUID)
                                {
                                    flag = true;
                                    break;
                                }
                            }
                            if (!flag)
                            {
                                //删除不是选中的线路的数据

                                XmlElement elementdl = tlVectorControl1.SVGDocument.SelectSingleNode("svg/text[@ layer='" + lar.ID + "'and @ParentID='" + elementDEV.SUID + "']") as XmlElement;
                                if (elementdl != null)
                                {
                                    tlVectorControl1.SVGDocument.RootElement.RemoveChild(elementdl);
                                }
                                tlVectorControl1.Refresh();

                                continue;
                            }
                            //if (Convert.ToInt32(elementDEV.OperationYear) <= DateTime.Now.Year)
                            //{
                            //    continue;
                            //}
                        }
                    }
                    else
                    {
                        continue;
                    }

                    if (elementDEV != null && elementDEV.KSwitchStatus == "0")
                    {
                        XmlElement elementdl = tlVectorControl1.SVGDocument.SelectSingleNode("svg/text[@ layer='" + lar.ID + "'and @ParentID='" + elementDEV.SUID + "']") as XmlElement;

                        if (elementdl == null)
                        {
                            List<PointF> pcol = CheckLenth((Polyline)element);

                            PointF[] t = ((Polyline)element).Points;
                            PointF[] t2 = ((Polyline)element).Points; t = t2;
                            int lastnum = t2.Length - 1;
                            PointF midt = new PointF((float)((pcol[0].X + pcol[1].X) / 2), (float)((pcol[0].Y + pcol[1].Y) / 2));
                            float angel = 0f;
                            angel = (float)(180 * Math.Atan2((pcol[0].Y - pcol[1].Y), (pcol[1].X - pcol[0].X)) / Math.PI);

                            string l3 = Convert.ToString(midt.X);
                            string l4 = Convert.ToString(midt.Y);

                            string tran = ((Polyline)element).Transform.ToString();

                            PointF center = new PointF((float)(pcol[0].X + (pcol[1].X - pcol[0].X) / 2), (float)(pcol[0].Y + (pcol[1].Y - pcol[0].Y) / 2));
                            XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                            // XmlElement n2 = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline;
                            //XmlElement n3 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;

                            PointF pStart = new PointF(center.X + (float)(15 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(15 * Math.Cos((angel) * Math.PI / 180)));
                            PointF pStart2 = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));

                            XmlNode firstNodeElement = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@id='" + element.GetAttribute("FirstNode") + "']");
                            XmlNode lastNodeElement = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@id='" + element.GetAttribute("LastNode") + "']");
                            //if (firstNodeElement != null)
                            {
                                if ((angel > 10 && angel < 90) || (angel < 0 && Math.Abs(angel) < 90) || (angel > 180 && angel < 350))
                                {
                                    //if (t2[0].X > ((IGraph)firstNodeElement).CenterPoint.X)
                                    //{
                                    pStart = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));
                                    pStart2 = new PointF(center.X + (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(23 * Math.Cos((angel) * Math.PI / 180)));
                                    //}
                                }
                                else if ((angel >= 0 && angel <= 10) || (angel >= 350 && angel <= 360) || (angel < 0 && Math.Abs(angel) <= 90))
                                {
                                    //if (t2[0].Y > ((IGraph)firstNodeElement).CenterPoint.Y)
                                    //{
                                    pStart = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));
                                    pStart2 = new PointF(center.X + (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(23 * Math.Cos((angel) * Math.PI / 180)));
                                    //}
                                }
                                else if ((angel < 0 && Math.Abs(angel) > 90) || (angel >= 90 && angel <= 180))
                                {
                                    //if (t2[0].Y > ((IGraph)firstNodeElement).CenterPoint.Y)
                                    //{
                                    pStart = new PointF(center.X - (float)(7 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(7 * Math.Cos((angel) * Math.PI / 180)));
                                    pStart2 = new PointF(center.X + (float)(7 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(7 * Math.Cos((angel) * Math.PI / 180)));
                                    //}
                                }
                                if (Convert.ToDouble(GetColValue(elcDEV, order).COL5) >= 0)
                                {
                                    n1.InnerText = (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL4))).ToString("N2") + " + j" + (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL5))).ToString("N2");
                                }
                                else
                                {
                                    n1.InnerText = (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL4))).ToString("N2") + " - j" + (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL5))).ToString("N2");
                                }
                                Graphics dd = this.CreateGraphics();
                                Font ff = new Font("宋体", 12);
                                SizeF sf = dd.MeasureString(n1.InnerText, ff);
                                double ztlength = Math.Sqrt(sf.Width * sf.Width + sf.Height * sf.Height);
                                PointF newp1 = new PointF(t[0].X + (t[1].X - t[0].X) / 2 - (float)(15 * Math.Sin(angel)), t[0].Y + (t[1].Y - t[0].Y) / 2 - (float)(15 * Math.Cos(angel)));
                                //n1.SetAttribute("x", Convert.ToString(center.X - (float)(Math.Sin((angel) * Math.PI / 180) * ztlength)));
                                //n1.SetAttribute("y", Convert.ToString(center.Y - (float)(Math.Cos((angel) * Math.PI / 180) * ztlength)));

                                n1.SetAttribute("x", Convert.ToString(center.X));
                                n1.SetAttribute("y", Convert.ToString(center.Y));

                                //Layer la = tlVectorControl1.SVGDocument.GetLayerByID(element.GetAttribute("layer"));
                                n1.SetAttribute("layer", lar.ID);
                                n1.SetAttribute("ParentID", elementDEV.SUID);
                                n1.SetAttribute("flag", "1");
                                n1.SetAttribute("Showline", "1");            //为显示哪条线路做标志
                                n1.SetAttribute("font-size", "96");// size.ToString());//"12");
                                // n1.SetAttribute("limitsize", "true");
                                if (Convert.ToDouble(GetColValue(elcDEV, order).COL14) > (elementDEV.LineChange))//电流越限,需修改。

                                    n1.SetAttribute("stroke", "#FF0000");

                                //PointF p1 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 25) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 25) * Math.PI / 180)));
                                //PointF p2 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 335) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 335) * Math.PI / 180)));

                                //if (Convert.ToDouble(elcDEV.COL4) < 0)
                                //{
                                //    p1 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 155) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 155) * Math.PI / 180)));
                                //    p2 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 205) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 205) * Math.PI / 180)));
                                //}

                                //string l1 = Convert.ToString(p1.X);
                                //string l2 = Convert.ToString(p1.Y);
                                //string l5 = Convert.ToString(p2.X);
                                //string l6 = Convert.ToString(p2.Y);

                                //n2.SetAttribute("points", l1 + " " + l2 + "," + l3 + " " + l4 + "," + l5 + " " + l6);
                                //n2.SetAttribute("fill-opacity", "1");
                                //n2.SetAttribute("layer", SvgDocument.currentLayer);
                                //n2.SetAttribute("flag", "1");
                                //n2.SetAttribute("font-size", "6");
                                //tlVectorControl1.SVGDocument.RootElement.AppendChild(n2);
                                //tlVectorControl1.SVGDocument.CurrentElement = n2 as SvgElement;

                                tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                                tlVectorControl1.Operation = ToolOperation.Select;

                                tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement;

                                RectangleF ttt = ((Polyline)element).GetBounds();

                                tlVectorControl1.RotateSelection(angel, pStart);
                                if (Math.Abs(angel) > 90)
                                    tlVectorControl1.RotateSelection(180, pStart);

                            }
                        }
                        else
                        {
                            elementdl.SetAttribute("Showline", "1");            //为显示哪条线路做标志
                            if (Convert.ToDouble(GetColValue(elcDEV, order).COL5) >= 0)
                            {
                                elementdl.InnerText = (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL4))).ToString("N2") + " + j" + (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL5))).ToString("N2");
                            }
                            else
                            {
                                elementdl.InnerText = (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL4))).ToString("N2") + " - j" + (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL5))).ToString("N2");
                            }
                            if (Convert.ToDouble(GetColValue(elcDEV, order).COL14) > (elementDEV.LineChange))//电流越限,需修改。

                                elementdl.SetAttribute("stroke", "#FF0000");
                        }
                        tlVectorControl1.Refresh();
                    }
                    //删除不投入运行的输出结果
                    else if (elementDEV != null && elementDEV.KSwitchStatus == "1")
                    {
                        XmlElement elementdl = tlVectorControl1.SVGDocument.SelectSingleNode("svg/text[@ layer='" + lar.ID + "'and @ParentID='" + elementDEV.SUID + "']") as XmlElement;
                        if (elementdl != null)
                        {
                            tlVectorControl1.SVGDocument.RootElement.RemoveChild(elementdl);
                        }
                        tlVectorControl1.Refresh();
                    }

                }
                //this.frmlar.checkedListBox1.Items.Add(lar, true);
                //this.frmlar.checkedListBox1.SelectedIndex = -1;
                MessageBox.Show("显示完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("参数错误,请调整参数后重新计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
        }
Esempio n. 6
0
        private void checkwjghelement()
        {
            //判断图元有没有

            wjghelement.Clear();
            XmlNodeList useList = tlVectorControl1.SVGDocument.SelectNodes("svg/use");
            XmlNodeList linelist = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline [@IsLead='1']");
            string con = "GprogUID='" + ff.Key + "'";
            IList list = Services.BaseService.GetList("SelectPSP_GprogEleviceByCondition", con);
            try
            {
                foreach (PSP_GprogElevice pg in list)
                {
                    bool flag = false;
                    if (pg.Type == "变电站" || pg.Type == "电源")
                    {
                        foreach (XmlNode element in useList)
                        {
                            if (!string.IsNullOrEmpty((element as XmlElement).GetAttribute("Deviceid")))
                            {
                                if ((element as XmlElement).GetAttribute("Deviceid") == pg.DeviceSUID)
                                {
                                    flag = true;
                                    if (pg.L2 == "0")
                                    {
                                        pg.L2 = "1";
                                        Services.BaseService.Update<PSP_GprogElevice>(pg);
                                    }
                                    break;
                                }
                            }

                        }
                    }
                    else
                    {
                        foreach (XmlNode element in linelist)
                        {
                            if (!string.IsNullOrEmpty((element as XmlElement).GetAttribute("Deviceid")))
                            {
                                if ((element as XmlElement).GetAttribute("Deviceid") == pg.DeviceSUID)
                                {
                                    //显示隐藏的图元

                                    (element as XmlElement).SetAttribute("visibility", "show");
                                    flag = true;
                                    if (pg.L2 == "0")
                                    {
                                        pg.L2 = "1";
                                        Services.BaseService.Update<PSP_GprogElevice>(pg);
                                    }

                                    break;
                                }
                            }

                        }
                    }
                    if (!flag)
                    {
                        if (pg.L2 == "1")
                        {
                            pg.L2 = "0";
                            Services.BaseService.Update<PSP_GprogElevice>(pg);
                        }

                    }
                    if (pg.Type == "变电站")
                    {
                        PSP_Substation_Info sb = new PSP_Substation_Info();
                        sb.UID = pg.DeviceSUID;
                        sb = (PSP_Substation_Info)Services.BaseService.GetObject("SelectPSP_Substation_InfoByKey", sb);
                        eleclass el = new eleclass(sb.Title, sb.UID, "20", flag);
                        wjghelement.Add(el);
                    }
                    if (pg.Type == "电源")
                    {
                        PSP_PowerSubstation_Info sb = new PSP_PowerSubstation_Info();
                        sb.UID = pg.DeviceSUID;
                        sb = (PSP_PowerSubstation_Info)Services.BaseService.GetObject("SelectPSP_PowerSubstation_InfoByKey", sb);
                        eleclass el = new eleclass(sb.Title, sb.UID, "30", flag);
                        wjghelement.Add(el);
                    }
                    if (pg.Type == "线路")
                    {
                        PSPDEV sb = new PSPDEV();
                        sb.SUID = pg.DeviceSUID;
                        sb = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", sb);
                        eleclass el = new eleclass(sb.Name, sb.SUID, "05", flag);
                        wjghelement.Add(el);
                    }
                }

            }
            catch (System.Exception ex)
            {

            }
        }
Esempio n. 7
0
        //�������ڵ�ʱ��ָ�pspdev����·������״̬ ��Ϊ���кʹ�ѡ��״̬
        public void initdat(string GprogUID)
        {
            //�ڴ˴�����ѡ���Ԫ���豸�����Խ��и���
            LayerGrade l1 = new LayerGrade();
            l1.Type = "1";
            l1.SvgDataUid = svguid;
            IList ttlist = Services.BaseService.GetList("SelectLayerGradeList5", l1);
            int yy1 = System.DateTime.Now.Year, yy2 = System.DateTime.Now.Year, yy3 = System.DateTime.Now.Year;
            if (ttlist.Count > 0)
            {
                LayerGrade n1 = (LayerGrade)ttlist[0];
                yy1 = Convert.ToInt32(n1.Name.Substring(0, 4));
            }
            l1.Type = "2";
            l1.SvgDataUid = svguid;
            ttlist = Services.BaseService.GetList("SelectLayerGradeList5", l1);
            if (ttlist.Count > 0)
            {
                LayerGrade n1 = (LayerGrade)ttlist[0];
                yy2 = Convert.ToInt32(n1.Name.Substring(0, 4));
            }
            l1.Type = "3";
            l1.SvgDataUid = svguid;
            ttlist = Services.BaseService.GetList("SelectLayerGradeList5", l1);
            if (ttlist.Count > 0)
            {
                LayerGrade n1 = (LayerGrade)ttlist[0];
                yy3 = Convert.ToInt32(n1.Name.Substring(0, 4));
            }
            string con = "GprogUID = '" + GprogUID + "' AND Type= '���վ'";

            IList list = Services.BaseService.GetList("SelectPSP_GprogEleviceByCondition", con);
            foreach (PSP_GprogElevice pg in list)
            {

                PSP_Substation_Info ps = new PSP_Substation_Info();
                ps.UID = pg.DeviceSUID;
                ps = (PSP_Substation_Info)Services.BaseService.GetObject("SelectPSP_Substation_InfoByKey", ps);
                if (ps != null)
                {
                    int s2 = 0;
                    if (!string.IsNullOrEmpty(ps.S2))
                    {
                        s2 = Convert.ToInt32(ps.S2);
                    }
                    if (s2 <= System.DateTime.Now.Year)
                    {
                        pg.L1 = "����";
                    }
                    else if (s2 > System.DateTime.Now.Year && Convert.ToInt32(ps.S2) <= yy1)
                    {
                        pg.L1 = "����";
                    }
                    else if (s2 > yy1 && Convert.ToInt32(ps.S2) <= yy2)
                    {
                        pg.L1 = "����";
                    }
                    else if (s2 > yy2 && Convert.ToInt32(ps.S2) <= yy3)
                    {
                        pg.L1 = "Զ��";
                    }
                    Services.BaseService.Update<PSP_GprogElevice>(pg);
                }
                else
                    Services.BaseService.Delete<PSP_GprogElevice>(pg);
            }
            con = "GprogUID = '" + GprogUID + "' AND Type= '��Դ'";

            list = Services.BaseService.GetList("SelectPSP_GprogEleviceByCondition", con);
            foreach (PSP_GprogElevice pg in list)
            {
                PSP_PowerSubstation_Info ps = new PSP_PowerSubstation_Info();
                ps.UID = pg.DeviceSUID;
                ps = (PSP_PowerSubstation_Info)Services.BaseService.GetObject("SelectPSP_PowerSubstation_InfoByKey", ps);
                if (ps != null)
                {
                    int s2 = 0;
                    if (!string.IsNullOrEmpty(ps.S3))
                    {
                        s2 = Convert.ToInt32(ps.S3);
                    }
                    if (s2 <= System.DateTime.Now.Year)
                    {
                        pg.L1 = "����";
                    }
                    else if (s2 > System.DateTime.Now.Year && Convert.ToInt32(ps.S3) <= yy1)
                    {
                        pg.L1 = "����";
                    }
                    else if (s2 > yy1 && Convert.ToInt32(ps.S3) <= yy2)
                    {
                        pg.L1 = "����";
                    }
                    else if (s2 >yy2 && Convert.ToInt32(ps.S3) <= yy3)
                    {
                        pg.L1 = "Զ��";
                    }
                    Services.BaseService.Update<PSP_GprogElevice>(pg);
                }
                else
                    Services.BaseService.Delete<PSP_GprogElevice>(pg);
            }
            con = "GprogUID = '" + GprogUID + "' AND Type= '��·'";

            list = Services.BaseService.GetList("SelectPSP_GprogEleviceByCondition", con);
            foreach (PSP_GprogElevice pg in list)
            {
                PSPDEV ps = new PSPDEV();
                ps.SUID = pg.DeviceSUID;
                ps = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", ps);
                if (ps != null)
                {
                    int s2 = 0;
                    if (!string.IsNullOrEmpty(ps.OperationYear))
                    {
                        s2 = Convert.ToInt32(ps.OperationYear);
                    }
                    if (s2 <= System.DateTime.Now.Year)
                    {
                        pg.L1 = "����";
                        ps.LineStatus = "����";
                    }
                    else
                    {
                        pg.L1 = "��ѡ";
                        ps.LineStatus = "��ѡ";
                    }
                    Services.BaseService.Update<PSP_GprogElevice>(pg);
                    Services.BaseService.Update<PSPDEV>(ps);
                }
                else
                    Services.BaseService.Delete<PSP_GprogElevice>(pg);
            }
        }
Esempio n. 8
0
        public override void UpdateIn(DataTable table)
        {
            for (int i = 0; i < table.Rows.Count; i++)
            {
                if (table.Rows[i][0].ToString().IndexOf("�ϼ�") > 0 || table.Rows[i][1].ToString().IndexOf("�ϼ�") > 0)
                    continue;
                PSP_PowerSubstation_Info area = new PSP_PowerSubstation_Info();
                area.UID += "|" + ProjectID;
                area.AreaID = ProjectID;
                area.CreateDate = DateTime.Now;
                foreach (DataColumn col in table.Columns)
                {
                    try
                    {
                        if (table.Rows[i][col] != null)
                        {
                            string inserted = table.Rows[i][col].ToString();
                            if (inserted == "�滮" || inserted == "��״")
                                area.GetType().GetProperty("Flag").SetValue(area, inserted == "�滮" ? "2" : "1", null);
                            else
                            {
                                Type type = area.GetType().GetProperty(col.ColumnName).PropertyType;//.GetValue(area, null).GetType();
                                if (type == typeof(int))
                                    area.GetType().GetProperty(col.ColumnName).SetValue(area, int.Parse(inserted == "" ? "0" : inserted), null);
                                else if (type == typeof(string))
                                    area.GetType().GetProperty(col.ColumnName).SetValue(area, inserted, null);
                                else if (type == typeof(decimal))
                                    area.GetType().GetProperty(col.ColumnName).SetValue(area, decimal.Parse(inserted == "" ? "0" : inserted), null);
                                else if (type == typeof(double))
                                    area.GetType().GetProperty(col.ColumnName).SetValue(area, double.Parse(inserted == "" ? "0.0" : inserted), null);
                                else if (type == typeof(DateTime))
                                {

                                }
                            }
                        }
                    }
                    catch { MessageBox.Show(string.Format("��{0}��{1}���������", i.ToString(), col.Caption)); }
                }
                DataService.Create<PSP_PowerSubstation_Info>(area);

            }
        }