Ejemplo n.º 1
0
        public void Allshort(string projectSUID, string projectid, int dulutype, double ratecaplity)
        {
            int cishu = 0;           //��¼�ڶ��ٴγ����ڴ�����
            try
            {

                if (!CheckDL(projectSUID, projectid, ratecaplity))
                {
                    return;
                }
                System.Windows.Forms.Clipboard.Clear();
                Dictionary<int, double> nodeshorti = new Dictionary<int, double>();      //��¼ĸ����û�н��й���·
                KeyValuePair<int, double> maxshorti = new KeyValuePair<int, double>(); //ȡ����·������·����

                string con = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='01'AND PSPDEV.KSwitchStatus = '0' order by PSPDEV.number";
                PSPDEV pspDev = new PSPDEV();
                IList list1 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);

                PSPDEV psp = new PSPDEV();

                string data = System.DateTime.Now.ToString("d");
                string time = System.DateTime.Now.ToString("T");
                string duanResult = null;
                duanResult += "��·�������" + "\r\n" + "\r\n";
                duanResult += "��·��ҵ�ţ�1" + "\r\n";
                duanResult += "��·�������ڣ�" + data + " " + "ʱ�䣺" + time + "\r\n";
                duanResult += "���kA" + "\r\n";
                string dianYaResult = null;
                dianYaResult += "ĸ�ߵ�ѹ���" + "\r\n" + "\r\n";
                dianYaResult += "��·��ҵ�ţ�1" + "\r\n";
                dianYaResult += "��·�������ڣ�" + data + " " + "ʱ�䣺" + time + "\r\n";
                dianYaResult += "��λ����ֵ( p.u. )  �Ƕ�(deg.)" + "\r\n";
                string dianLiuResult = null;
                dianLiuResult += "֧·�������" + "\r\n" + "\r\n";
                dianLiuResult += "��·��ҵ�ţ�1" + "\r\n";
                dianLiuResult += "��·�������ڣ�" + data + " " + "ʱ�䣺" + time + "\r\n";
                dianLiuResult += "��λ����ֵ( p.u. )  �Ƕ�(deg.)" + "\r\n";
                int intshorti = 0;        //��һ�м�¼��ΪҪ����·����������˵��
                bool shortiflag = false;
                int muxiannum = 0;         //��¼һ��ĸ�߶�·�� �ж��ٸ���¼ĸ�ߵ�ѹ
                int linenum = 0;           //��¼һ��ĸ�߶�· �ж��ٸ���·����
                shortbuscir shortCutCal = new shortbuscir(Compuflag);
                for (int i = 0; i < list1.Count; i++)
                {
                    cishu++;
                    pspDev = list1[i] as PSPDEV;
                    bool flag = false;
                    string dlr = null;
                    con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='05'AND(PSPDEV.IName='" + pspDev.Name + "'OR PSPDEV.JName='" + pspDev.Name + "') AND PSPDEV.KSwitchStatus = '0'order by PSPDEV.number";
                    IList list2 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                    for (int j = 0; j < list2.Count; j++)
                    {
                        psp = list2[j] as PSPDEV;
                        con = " WHERE Name='" + psp.ISwitch + "' AND ProjectID = '" + projectid + "'" + "AND Type='07'";
                        IList listiswitch = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                        con = " WHERE Name='" + psp.JSwitch + "' AND ProjectID = '" + projectid + "'" + "AND Type='07'";
                        IList listjswitch = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                        PSPDEV pspiswitch = (PSPDEV)listiswitch[0];
                        PSPDEV pspjswitch = (PSPDEV)listjswitch[0];

                        if (pspDev.Number == psp.FirstNode && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0")
                        {

                            flag = true;
                            dlr = "0" + " " + psp.FirstNode + " " + psp.LastNode + " " + psp.Number + " " + "0 " + " " + dulutype;

                        }
                        if (pspDev.Number == psp.LastNode && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0")
                        {
                            flag = true;
                            dlr = "0" + " " + psp.FirstNode + " " + psp.LastNode + " " + psp.Number + " " + "1 " + " " + dulutype;
                        }
                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\fault.txt"))
                        {
                            File.Delete(System.Windows.Forms.Application.StartupPath + "\\fault.txt");
                        }
                        if (flag)
                        {

                            break;                 //������ѭ�� ����ĸ�ߵ�����һ��ĸ�߶�·
                        }
                        if (!flag)
                            continue;
                        //������
                    }
                    //�����һ����·��û�������������н���
                    if (!flag)
                    {
                        con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='02'AND PSPDEV.KSwitchStatus = '0'and (PSPDEV.IName='" + pspDev.Name + "'OR PSPDEV.JName='" + pspDev.Name + "') order by PSPDEV.number";
                        IList list3 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                        for (int j = 0; j < list3.Count; j++)
                        {
                            dlr = null;
                            psp = list3[j] as PSPDEV;
                            //PSPDEV devFirst = new PSPDEV();

                            //con = " WHERE Name='" + psp.IName + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'";
                            //devFirst = (PSPDEV)UCDeviceBase.DataService.GetObject("SelectPSPDEVByCondition", con);
                            //PSPDEV devLast = new PSPDEV();

                            //con = " WHERE Name='" + psp.JName + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'";
                            //devLast = (PSPDEV)UCDeviceBase.DataService.GetObject("SelectPSPDEVByCondition", con);
                            con = " WHERE Name='" + psp.ISwitch + "' AND ProjectID = '" + projectid + "'" + "AND Type='07'";
                            IList listiswitch = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                            con = " WHERE Name='" + psp.JSwitch + "' AND ProjectID = '" + projectid + "'" + "AND Type='07'";
                            IList listjswitch = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                            PSPDEV pspiswitch = (PSPDEV)listiswitch[0];
                            PSPDEV pspjswitch = (PSPDEV)listjswitch[0];
                            if (pspDev.Number == psp.FirstNode && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0")
                            {

                                flag = true;
                                dlr = "0" + " " + psp.FirstNode + " " + psp.LastNode + " " + psp.Number + " " + "0" + " " + dulutype;

                            }
                            if (pspDev.Number == psp.LastNode && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0")
                            {
                                flag = true;
                                dlr = "0" + " " + psp.FirstNode + " " + psp.LastNode + " " + psp.Number + " " + "1" + " " + dulutype;
                            }
                            if (flag)
                            {
                                break;                 //������ѭ�� ����ĸ�ߵ�����һ��ĸ�߶�·
                            }
                            if (!flag)
                                continue;
                            //������
                        }
                    }
                    if (!flag)
                    {
                        con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='03'AND(PSPDEV.IName='" + pspDev.Name + "'OR PSPDEV.JName='" + pspDev.Name + "'OR PSPDEV.KName='" + pspDev.Name + "')AND PSPDEV.KSwitchStatus = '0' order by PSPDEV.number";
                        IList list4 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                        for (int j = 0; j < list4.Count; j++)
                        {
                            dlr = null;
                            psp = list4[j] as PSPDEV;
                            //PSPDEV devINode = new PSPDEV();

                            //con = " WHERE Name='" + psp.IName + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'";
                            //devINode = (PSPDEV)UCDeviceBase.DataService.GetObject("SelectPSPDEVByCondition", con);
                            //PSPDEV devJNode = new PSPDEV();

                            //con = " WHERE Name='" + psp.JName + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'";
                            //devJNode = (PSPDEV)UCDeviceBase.DataService.GetObject("SelectPSPDEVByCondition", con);
                            //PSPDEV devKNode = new PSPDEV();

                            //con = " WHERE Name='" + psp.KName + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'";
                            //devKNode = (PSPDEV)UCDeviceBase.DataService.GetObject("SelectPSPDEVByCondition", con);

                            con = " WHERE Name='" + psp.ISwitch + "' AND ProjectID = '" + projectid + "'" + "AND Type='07'";
                            IList listiswitch = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                            con = " WHERE Name='" + psp.JSwitch + "' AND ProjectID = '" + projectid + "'" + "AND Type='07'";
                            IList listjswitch = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                            con = " WHERE Name='" + psp.HuganLine1 + "' AND ProjectID = '" + projectid + "'" + "AND Type='07'";
                            IList listkswitch = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                            PSPDEV pspiswitch = (PSPDEV)listiswitch[0];
                            PSPDEV pspjswitch = (PSPDEV)listjswitch[0];
                            PSPDEV pspkswitch = (PSPDEV)listkswitch[0];
                            if (pspDev.Number == psp.FirstNode && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0" && pspkswitch.KSwitchStatus == "0")
                            {

                                flag = true;
                                dlr = "0" + " " + psp.FirstNode + " " + psp.LastNode + " " + psp.Number + " " + "0" + " " + dulutype;

                            }
                            if (pspDev.Number == psp.LastNode && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0" && pspkswitch.KSwitchStatus == "0")
                            {
                                flag = true;
                                dlr = "0" + " " + psp.FirstNode + " " + psp.LastNode + " " + psp.Number + " " + "1" + " " + dulutype;
                            }
                            if (pspDev.Number == psp.Flag && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0" && pspkswitch.KSwitchStatus == "0")
                            {
                                flag = true;
                                dlr = "0" + " " + psp.FirstNode + " " + psp.Flag + " " + psp.Number + " " + "1" + " " + dulutype;
                            }

                            if (flag)
                            {
                                break;                 //������ѭ�� ����ĸ�ߵ�����һ��ĸ�߶�·
                            }
                            if (!flag)
                                continue;
                            //������
                        }
                    }
                    if (flag)
                    {
                        FileStream VK = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fault.txt"), FileMode.OpenOrCreate);
                        StreamWriter str11 = new StreamWriter(VK);
                        str11.Write(dlr);
                        str11.Close();
                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt"))
                        {
                            File.Delete(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt");
                        }
                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt"))
                        {
                            File.Delete(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt");
                        }
                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt"))
                        {
                            File.Delete(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt");
                        }

                        shortCutCal.Show_shortcir(Compuflag, OutType, 1);
                        GC.Collect();
                        //bool matrixflag=true;                //�����ж��Ƿ��ɾ����������Ƿ���������
                        string matrixstr = null;
                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Zmatrixcheck.txt"))
                        {
                            matrixstr = "�����ɾ���";
                            // matrixflag = false;
                        }

                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Fmatrixcheck.txt"))
                        {
                            // matrixflag = false;
                            matrixstr += "�����ɾ���";
                        }

                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Lmatrixcheck.txt"))
                        {
                            //matrixflag = false;
                            matrixstr += "�����ɾ���";
                        }
                        if (matrixstr != null)
                        {
                            System.Windows.Forms.MessageBox.Show(matrixstr + "�����������������������ٽ��м��㣡", "��ʾ", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
                            return;
                        }
                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt"))
                        {
                        }
                        else
                        {
                            return;
                        }

                        FileStream shorcuit = new FileStream(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt", FileMode.Open);
                        StreamReader readLineGU = new StreamReader(shorcuit, System.Text.Encoding.Default);
                        string strLineGU;
                        string[] arrayGU;
                        char[] charSplitGU = new char[] { ' ' };
                        intshorti = 0;
                        while ((strLineGU = readLineGU.ReadLine()) != null)
                        {

                            arrayGU = strLineGU.Split(charSplitGU);
                            string[] shorti = new string[4];
                            shorti.Initialize();
                            int m = 0;
                            foreach (string str in arrayGU)
                            {

                                if (str != "")
                                {

                                    shorti[m++] = str.ToString();

                                }
                            }
                            if (intshorti == 0)
                            {
                                if (!shortiflag)
                                {
                                    duanResult += shorti[0] + "," + shorti[1] + "," + shorti[3] + "\r\n";
                                    shortiflag = true;
                                }

                            }
                            else
                                duanResult += shorti[0] + "," + shorti[1] + "," + Convert.ToDouble(shorti[3]) * ratecaplity / (Math.Sqrt(3) * pspDev.ReferenceVolt) + "\r\n";

                            intshorti++;
                        }
                        readLineGU.Close();
                        if (OutType == 0)
                        {
                            //**��ȡ�����ѹ��ֵ
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt"))
                            {
                            }
                            else
                            {
                                return;
                            }
                            FileStream dianYa = new FileStream(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt", FileMode.Open);
                            StreamReader readLineDY = new StreamReader(dianYa, System.Text.Encoding.Default);
                            string strLineDY;
                            string[] arrayDY;
                            char[] charSplitDY = new char[] { ' ' };
                            strLineDY = readLineDY.ReadLine();
                            int j = 0;
                            muxiannum = 0;
                            while (strLineDY != null)
                            {
                                arrayDY = strLineDY.Split(charSplitDY);

                                int m = 0;
                                string[] dev = new string[14];
                                dev.Initialize();
                                foreach (string str in arrayDY)
                                {
                                    if (str != "")
                                    {
                                        dev[m++] = str;
                                    }
                                }
                                if (j == 0)
                                {
                                    dianYaResult += "\r\n" + "����ĸ�ߣ�" + pspDev.Name + "\r\n";
                                    dianYaResult += dev[0] + "," + dev[1] + "," + dev[2] + "," + dev[3] + "," + dev[4] + "," + dev[5] + "," + dev[6] + "," + dev[7] + "," + dev[8] + "," +
             dev[9] + "," + dev[10] + "," + dev[11] + "," + dev[12] + "," + dev[13] + "\r\n";
                                }
                                else
                                {
                                    bool dianyaflag = true;     //�жϴ�ĸ���Ƕ�·��ĸ�߻���һ���ĸ��
                                    PSPDEV CR = new PSPDEV();

                                    if (dev[1] != "du")
                                    {

                                        con = " WHERE Name='" + dev[1] + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'";
                                        CR = (PSPDEV)UCDeviceBase.DataService.GetObject("SelectPSPDEVByCondition", con);
                                        if (CR == null)
                                        {
                                            dianyaflag = false;
                                        }
                                    }
                                    //else
                                    //{
                                    //    dianyaflag = false;
                                    //    CR.Name = duanluname;
                                    //    CR = (PSPDEV)UCDeviceBase.DataService.GetObject("SelectPSPDEVByNameANDSVG", CR);
                                    //}
                                    if (dianyaflag)
                                        dianYaResult += dev[0] + "," + dev[1] + "," + Convert.ToDouble(dev[2]) * CR.ReferenceVolt + "," + dev[3] + "," + Convert.ToDouble(dev[4]) * CR.ReferenceVolt + "," + dev[5] + "," + Convert.ToDouble(dev[6]) * CR.ReferenceVolt + "," + dev[7] + "," + Convert.ToDouble(dev[8]) * CR.ReferenceVolt + "," +
                                            dev[9] + "," + Convert.ToDouble(dev[10]) * CR.ReferenceVolt + "," + dev[11] + "," + Convert.ToDouble(dev[12]) * CR.ReferenceVolt + "," + dev[13] + "\r\n";
                                    //else
                                    //    dianYaResult += dev[0] + "," + duanluname + "�϶�·��" + "," + Convert.ToDouble(dev[2]) * CR.ReferenceVolt + "," + dev[3] + "," + Convert.ToDouble(dev[4]) * CR.ReferenceVolt + "," + dev[5] + "," + Convert.ToDouble(dev[6]) * CR.ReferenceVolt + "," + dev[7] + "," + Convert.ToDouble(dev[8]) * CR.ReferenceVolt + "," +
                                    //       dev[9] + "," + Convert.ToDouble(dev[10]) * CR.ReferenceVolt + "," + dev[11] + Convert.ToDouble(dev[12]) * CR.ReferenceVolt + "," + dev[13] + "\r\n";

                                }
                                strLineDY = readLineDY.ReadLine();
                                muxiannum++;
                                j++;
                            }
                            readLineDY.Close();
                            //**��ȡ���������ֵ
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt"))
                            {
                            }
                            else
                            {
                                return;
                            }
                            FileStream dianLiu = new FileStream(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt", FileMode.Open);
                            StreamReader readLineDL = new StreamReader(dianLiu, System.Text.Encoding.Default);
                            string strLineDL;
                            string[] arrayDL;
                            char[] charSplitDL = new char[] { ' ' };
                            strLineDL = readLineDL.ReadLine();
                            j = 0;
                            linenum = 0;
                            while (strLineDL != null)
                            {
                                arrayDL = strLineDL.Split(charSplitDL);
                                int m = 0;
                                string[] dev = new string[15];
                                dev.Initialize();
                                foreach (string str in arrayDL)
                                {
                                    if (str != "")
                                    {
                                        dev[m++] = str;
                                    }
                                }
                                if (j == 0)
                                {
                                    dianLiuResult += "\r\n" + "����ĸ�ߣ�" + pspDev.Name + "\r\n";
                                    dianLiuResult += dev[0] + "," + dev[1] + "," + dev[2] + "," + dev[3] + "," + dev[4] + "," + dev[5] + "," + dev[6] + "," + dev[7] + "," + dev[8] + "," +
                                                 dev[9] + "," + dev[10] + "," + dev[11] + "," + dev[12] + "," + dev[13] + "," + dev[14] + "\r\n";
                                }
                                else
                                {

                                    //��Ϊ����·�������ʱ����һ����·�ĵ��������������������·�ĵ������нӵص������͵翹���ĵ��������ֻ���������������
                                    PSPDEV CR = new PSPDEV();

                                    if (dev[0] != "du")
                                    {

                                        con = " WHERE Name='" + dev[0] + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'";
                                    }
                                    else
                                        con = " WHERE Name='" + dev[1] + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'";

                                    CR = (PSPDEV)UCDeviceBase.DataService.GetObject("SelectPSPDEVByCondition", con);

                                    dianLiuResult += dev[0] + "," + dev[1] + "," + dev[2] + "," + Convert.ToDouble(dev[3]) * ratecaplity / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[4] + "," + Convert.ToDouble(dev[5]) * ratecaplity / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[6] + "," + Convert.ToDouble(dev[7]) * ratecaplity / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[8] + "," +
                                      Convert.ToDouble(dev[9]) * ratecaplity / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[10] + "," + Convert.ToDouble(dev[11]) * ratecaplity / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[12] + "," + Convert.ToDouble(dev[13]) * ratecaplity / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[14] + "\r\n";
                                }

                                strLineDL = readLineDL.ReadLine();
                                j++;
                                linenum++;
                            }
                            readLineDL.Close();

                        }
                    }

                }
                //д�뱨����
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result.csv"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\result.csv");
                }
                FileStream tempGU = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result.csv"), FileMode.OpenOrCreate);
                StreamWriter strGU = new StreamWriter(tempGU, Encoding.Default);
                strGU.Write(duanResult);
                strGU.Close();
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result1.csv"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\result1.csv");
                }
                FileStream tempDY = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result1.csv"), FileMode.OpenOrCreate);
                StreamWriter strDY = new StreamWriter(tempDY, Encoding.Default);
                strDY.Write(dianYaResult);
                strDY.Close();
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result2.csv"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\result2.csv");
                }
                FileStream tempDL = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result2.csv"), FileMode.OpenOrCreate);
                StreamWriter strDL = new StreamWriter(tempDL, Encoding.Default);
                strDL.Write(dianLiuResult);
                strDL.Close();
                PSP_ELCPROJECT psproject = new PSP_ELCPROJECT();
                psproject.ID = projectSUID;
                psproject = (PSP_ELCPROJECT)UCDeviceBase.DataService.GetObject("SelectPSP_ELCPROJECTByKey", psproject);
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\" + psproject.Name + "ȫ����·������.xls"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\" + psproject.Name + "ȫ����·������.xls");
                }

                Excel.Application ex;
                Excel.Worksheet xSheet;
                Excel.Application result1;
                Excel.Application result2;
                Excel.Worksheet tempSheet;
                Excel.Worksheet tempSheet1;
                Excel.Worksheet newWorksheet;
                Excel.Worksheet newWorkSheet1;

                object oMissing = System.Reflection.Missing.Value;
                ex = new Excel.Application();
                ex.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result.csv");

                xSheet = (Excel.Worksheet)ex.Worksheets[1];
                ex.Worksheets.Add(System.Reflection.Missing.Value, xSheet, 1, System.Reflection.Missing.Value);
                xSheet = (Excel.Worksheet)ex.Worksheets[2];
                ex.Worksheets.Add(System.Reflection.Missing.Value, xSheet, 1, System.Reflection.Missing.Value);
                xSheet = (Excel.Worksheet)ex.Worksheets[1];
                result1 = new Excel.Application();
                result1.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result1.csv");
                result2 = new Excel.Application();
                result2.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result2.csv");
                tempSheet = (Excel.Worksheet)result1.Worksheets.get_Item(1);
                tempSheet1 = (Excel.Worksheet)result2.Worksheets.get_Item(1);
                newWorksheet = (Excel.Worksheet)ex.Worksheets.get_Item(2);
                newWorkSheet1 = (Excel.Worksheet)ex.Worksheets.get_Item(3);
                newWorksheet.Name = "ĸ�ߵ�ѹ";
                newWorkSheet1.Name = "֧·����";
                xSheet.Name = "��·����";
                ex.Visible = true;

                tempSheet.Cells.Select();
                tempSheet.Cells.Copy(System.Reflection.Missing.Value);
                newWorksheet.Paste(System.Reflection.Missing.Value, System.Reflection.Missing.Value);
                tempSheet1.Cells.Select();
                tempSheet1.Cells.Copy(System.Reflection.Missing.Value);
                newWorkSheet1.Paste(System.Reflection.Missing.Value, System.Reflection.Missing.Value);

                xSheet.UsedRange.Font.Name = "����_GB2312";
                newWorksheet.UsedRange.Font.Name = "����_GB2312";
                newWorkSheet1.UsedRange.Font.Name = "����_GB2312";
                //��¼��Ϊ��·������ʽ
                xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 3]).MergeCells = true;
                xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Size = 20;
                xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Name = "����";
                xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                xSheet.get_Range(xSheet.Cells[6, 1], xSheet.Cells[6, 3]).Interior.ColorIndex = 45;
                xSheet.get_Range(xSheet.Cells[7, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6;
                xSheet.get_Range(xSheet.Cells[4, 3], xSheet.Cells[xSheet.UsedRange.Rows.Count, 13]).NumberFormat = "0.0000_ ";
                //ĸ�ߵ�ѹ��ʾ��ʽ
                newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 14]).MergeCells = true;
                newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).Font.Size = 20;
                newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).Font.Name = "����";
                newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                if (OutType == 0)
                {
                    for (int m = 0; m < muxiannum - 1; m++)
                    {
                        newWorksheet.get_Range(newWorksheet.Cells[m * (muxiannum + 2) + 8, 1], newWorksheet.Cells[m * (muxiannum + 2) + 8, 14]).Interior.ColorIndex = 45;
                        newWorksheet.get_Range(newWorksheet.Cells[m * (muxiannum + 2) + 9, 1], newWorksheet.Cells[m * (muxiannum + 2) + 8 + muxiannum - 1, 1]).Interior.ColorIndex = 6;
                        newWorksheet.get_Range(newWorksheet.Cells[m * (muxiannum + 2) + 9, 3], newWorksheet.Cells[m * (muxiannum + 2) + 8 + muxiannum - 1, 13]).NumberFormat = "0.0000_ ";
                    }

                }

                //��·�����������ʾ��ʽ
                newWorkSheet1.get_Range(newWorkSheet1.Cells[1, 1], newWorkSheet1.Cells[1, 15]).MergeCells = true;
                newWorkSheet1.get_Range(newWorkSheet1.Cells[1, 1], newWorkSheet1.Cells[1, 1]).Font.Size = 20;
                newWorkSheet1.get_Range(newWorkSheet1.Cells[1, 1], newWorkSheet1.Cells[1, 1]).Font.Name = "����";
                newWorkSheet1.get_Range(newWorkSheet1.Cells[1, 1], newWorkSheet1.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                if (OutType == 0)
                {
                    for (int m = 0; m < muxiannum - 1; m++)
                    {
                        newWorkSheet1.get_Range(newWorkSheet1.Cells[m * (linenum + 2) + 8, 1], newWorkSheet1.Cells[m * (linenum + 2) + 8, 15]).Interior.ColorIndex = 45;
                        newWorkSheet1.get_Range(newWorkSheet1.Cells[m * (linenum + 2) + 9, 1], newWorkSheet1.Cells[m * (linenum + 2) + 8 + linenum - 1, 1]).Interior.ColorIndex = 6;
                        newWorkSheet1.get_Range(newWorkSheet1.Cells[m * (linenum + 2) + 9, 2], newWorkSheet1.Cells[m * (linenum + 2) + 8 + linenum - 1, 2]).Interior.ColorIndex = 6;
                        newWorkSheet1.get_Range(newWorkSheet1.Cells[m * (linenum + 2) + 9, 3], newWorkSheet1.Cells[m * (linenum + 2) + 8 + linenum - 1, 3]).Interior.ColorIndex = 6;
                        newWorkSheet1.get_Range(newWorkSheet1.Cells[m * (linenum + 2) + 9, 4], newWorkSheet1.Cells[m * (linenum + 2) + 8 + linenum - 1, 14]).NumberFormat = "0.0000_ ";
                    }
                }

                xSheet.Rows.AutoFit();
                xSheet.Columns.AutoFit();
                newWorksheet.Rows.AutoFit();
                newWorksheet.Columns.AutoFit();
                newWorkSheet1.Rows.AutoFit();
                newWorkSheet1.Columns.AutoFit();
                newWorksheet.SaveAs(System.Windows.Forms.Application.StartupPath + "\\" + psproject.Name + "ȫ����·������.xls", Excel.XlFileFormat.xlXMLSpreadsheet, null, null, false, false, false, null, null, null);
                System.Windows.Forms.Clipboard.Clear();
                result1.Workbooks.Close();
                result1.Quit();
                result2.Workbooks.Close();
                result2.Quit();

            }
            catch (System.Exception ex)
            {
                MessageBox.Show("���ݴ���������������ȫ���ٲ���", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
        }
Ejemplo n.º 2
0
        //根据操作的次序依次显示
        private void Allshortcheck(int caozuoi)
        {
            if (!addcheck())
            {
                return;
            }
            ElectricShorti elc = new ElectricShorti();
            if (!elc.CheckDL(tlVectorControl1.SVGDocument.SvgdataUid,this.ProjectUID,100))
            {
                return;
            }
            Dictionary<int, double> nodeshorti = new Dictionary<int, double>();      //记录母线有没有进行过短路
            KeyValuePair<int, double> maxshorti = new KeyValuePair<int, double>(); //取出短路的最大短路电流

            string con = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" +tlVectorControl1.SVGDocument.SvgdataUid + "'AND PSPDEV.type='01'AND PSPDEV.KSwitchStatus = '0' order by PSPDEV.number";
            PSPDEV pspDev = new PSPDEV();
            IList list1 = Services.BaseService.GetList("SelectPSPDEVByCondition", con);

            con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid+ "'AND PSPDEV.type='05'AND PSPDEV.KSwitchStatus = '0'order by PSPDEV.number";
            PSPDEV psp = new PSPDEV();
            IList list2 = Services.BaseService.GetList("SelectPSPDEVByCondition", con);

            shortbuscir shortCutCal = new shortbuscir(0);
            for (int i = 0; i < list1.Count; i++)
            {
                pspDev = list1[i] as PSPDEV;
                bool flag = false;
                string dlr = null;
                for (int j = 0; j < list2.Count; j++)
                {
                    psp = list2[j] as PSPDEV;
                    con = " WHERE Name='" + psp.ISwitch + "' AND ProjectID = '" +this.ProjectUID + "'" + "AND Type='07'";
                    IList listiswitch = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                    con = " WHERE Name='" + psp.JSwitch + "' AND ProjectID = '" + this.ProjectUID + "'" + "AND Type='07'";
                    IList listjswitch = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                    PSPDEV pspiswitch = (PSPDEV)listiswitch[0];
                    PSPDEV pspjswitch = (PSPDEV)listjswitch[0];

                    if (pspDev.Number == psp.FirstNode && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0")
                    {

                        flag = true;
                        dlr = "0" + " " + psp.FirstNode + " " + psp.LastNode + " " + psp.Number + " " + "0 " + " " + "0 ";

                    }
                    if (pspDev.Number == psp.LastNode && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0")
                    {
                        flag = true;
                        dlr = "0" + " " + psp.FirstNode + " " + psp.LastNode + " " + psp.Number + " " + "1 " + " " + "0 ";
                    }
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\fault.txt"))
                    {
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\fault.txt");
                    }
                    if (flag)
                    {
                        FileStream VK = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fault.txt"), FileMode.OpenOrCreate);
                        StreamWriter str11 = new StreamWriter(VK);
                        str11.Write(dlr);
                        str11.Close();
                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt"))
                        {
                            File.Delete(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt");
                        }
                       // shortcir shortCutCal = new shortcir();
                        shortCutCal.Show_shortcir(0,0,1);
                        //bool matrixflag=true;                //用来判断是否导纳矩阵的逆矩阵是否存在逆矩阵

                        string matrixstr = null;
                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Zmatrixcheck.txt"))
                        {
                            matrixstr = "正序导纳矩阵";
                            // matrixflag = false;
                        }

                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Fmatrixcheck.txt"))
                        {
                            // matrixflag = false;
                            matrixstr += "负序导纳矩阵";
                        }

                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Lmatrixcheck.txt"))
                        {
                            //matrixflag = false;
                            matrixstr += "零序导纳矩阵";
                        }
                        if (matrixstr != null)
                        {
                            MessageBox.Show(matrixstr + "不存在逆矩阵,请调整参数后再进行计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt"))
                        {
                        }
                        else
                        {
                            return;
                        }

                        FileStream shorcuit = new FileStream(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt", FileMode.Open);
                        StreamReader readLineGU = new StreamReader(shorcuit, System.Text.Encoding.Default);
                        string strLineGU;
                        string[] arrayGU;
                        char[] charSplitGU = new char[] { ' ' };

                        while ((strLineGU = readLineGU.ReadLine()) != null)
                        {

                            while ((strLineGU = readLineGU.ReadLine()) != null)
                            {
                                arrayGU = strLineGU.Split(charSplitGU);
                                string[] shorti = new string[4];
                                shorti.Initialize();
                                int m = 0;
                                foreach (string str in arrayGU)
                                {

                                    if (str != "")
                                    {

                                        shorti[m++] = str.ToString();

                                    }
                                }

                                nodeshorti[pspDev.Number] = Convert.ToDouble(shorti[3]) * 100 / (Math.Sqrt(3) * pspDev.ReferenceVolt);
                            }
                        }
                        readLineGU.Close();
                        break;                 //跳出本循环 进行母线的另外一个母线短路

                    }
                    if (!flag)
                        continue;
                    //写入错误中

                }
                //如果在一般线路中没有则在两绕组中进行
                if (!flag)
                {
                    con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "'AND PSPDEV.type='02'AND PSPDEV.KSwitchStatus = '0' order by PSPDEV.number";
                    IList list3 = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                    for (int j = 0; j < list3.Count; j++)
                    {
                        dlr = null;
                        psp = list3[j] as PSPDEV;
                        PSPDEV devFirst = new PSPDEV();

                        con = " WHERE Name='" + psp.IName + "' AND ProjectID = '" + this.ProjectUID + "'" + "AND Type='01'";
                        devFirst = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", con);
                        PSPDEV devLast = new PSPDEV();

                        con = " WHERE Name='" + psp.JName + "' AND ProjectID = '" + this.ProjectUID + "'" + "AND Type='01'";
                        devLast = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", con);
                        con = " WHERE Name='" + psp.ISwitch + "' AND ProjectID = '" + this.ProjectUID + "'" + "AND Type='07'";
                        IList listiswitch = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                        con = " WHERE Name='" + psp.JSwitch + "' AND ProjectID = '" + this.ProjectUID + "'" + "AND Type='07'";
                        IList listjswitch = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                        PSPDEV pspiswitch = (PSPDEV)listiswitch[0];
                        PSPDEV pspjswitch = (PSPDEV)listjswitch[0];
                        if (pspDev.Number == devFirst.Number && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0")
                        {

                            flag = true;
                            dlr = "0" + " " + devFirst.Number + " " + devLast.Number + " " + psp.Number + " " + "0" + " " + "0";

                        }
                        if (pspDev.Number == devLast.Number && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0")
                        {
                            flag = true;
                            dlr = "0" + " " + devFirst.Number + " " + devLast.Number + " " + psp.Number + " " + "1" + " " + "0";
                        }
                        if (flag)
                        {
                            FileStream VK = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fault.txt"), FileMode.OpenOrCreate);
                            StreamWriter str11 = new StreamWriter(VK);
                            str11.Write(dlr);
                            str11.Close();
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt"))
                            {
                                File.Delete(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt");
                            }
                           // shortcir shortCutCal = new shortcir();
                            shortCutCal.Show_shortcir(0,0,1);
                            //bool matrixflag=true;                //用来判断是否导纳矩阵的逆矩阵是否存在逆矩阵

                            string matrixstr = null;
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Zmatrixcheck.txt"))
                            {
                                matrixstr = "正序导纳矩阵";
                                // matrixflag = false;
                            }

                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Fmatrixcheck.txt"))
                            {
                                // matrixflag = false;
                                matrixstr += "负序导纳矩阵";
                            }

                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Lmatrixcheck.txt"))
                            {
                                //matrixflag = false;
                                matrixstr += "零序导纳矩阵";
                            }
                            if (matrixstr != null)
                            {
                                MessageBox.Show(matrixstr + "不存在逆矩阵,请调整参数后再进行计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt"))
                            {
                            }
                            else
                            {
                                return;
                            }

                            FileStream shorcuit = new FileStream(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt", FileMode.Open);
                            StreamReader readLineGU = new StreamReader(shorcuit, System.Text.Encoding.Default);
                            string strLineGU;
                            string[] arrayGU;
                            char[] charSplitGU = new char[] { ' ' };

                            while ((strLineGU = readLineGU.ReadLine()) != null)
                            {

                                while ((strLineGU = readLineGU.ReadLine()) != null)
                                {
                                    arrayGU = strLineGU.Split(charSplitGU);
                                    string[] shorti = new string[4];
                                    shorti.Initialize();
                                    int m = 0;
                                    foreach (string str in arrayGU)
                                    {

                                        if (str != "")
                                        {

                                            shorti[m++] = str.ToString();

                                        }
                                    }

                                    nodeshorti[pspDev.Number] = Convert.ToDouble(shorti[3]) * 100 / (Math.Sqrt(3) * pspDev.ReferenceVolt);
                                }
                            }
                            readLineGU.Close();
                            break;                 //跳出本循环 进行母线的另外一个母线短路

                        }
                        if (!flag)
                            continue;
                        //写入错误中

                    }
                }
                if (!flag)
                {
                    con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "'AND PSPDEV.type='03'AND PSPDEV.KSwitchStatus = '0' order by PSPDEV.number";
                    IList list4 = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                    for (int j = 0; j < list4.Count; j++)
                    {
                        dlr = null;
                        psp = list4[j] as PSPDEV;
                        PSPDEV devINode = new PSPDEV();

                        con = " WHERE Name='" + psp.IName + "' AND ProjectID = '" + this.ProjectUID+ "'" + "AND Type='01'";
                        devINode = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", con);
                        PSPDEV devJNode = new PSPDEV();

                        con = " WHERE Name='" + psp.JName + "' AND ProjectID = '" + this.ProjectUID + "'" + "AND Type='01'";
                        devJNode = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", con);
                        PSPDEV devKNode = new PSPDEV();

                        con = " WHERE Name='" + psp.KName + "' AND ProjectID = '" + this.ProjectUID + "'" + "AND Type='01'";
                        devKNode = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", con);

                        con = " WHERE Name='" + psp.ISwitch + "' AND ProjectID = '" + this.ProjectUID + "'" + "AND Type='07'";
                        IList listiswitch = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                        con = " WHERE Name='" + psp.JSwitch + "' AND ProjectID = '" + this.ProjectUID + "'" + "AND Type='07'";
                        IList listjswitch = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                        con = " WHERE Name='" + psp.HuganLine1 + "' AND ProjectID = '" + this.ProjectUID + "'" + "AND Type='07'";
                        IList listkswitch = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                        PSPDEV pspiswitch = (PSPDEV)listiswitch[0];
                        PSPDEV pspjswitch = (PSPDEV)listjswitch[0];
                        PSPDEV pspkswitch = (PSPDEV)listkswitch[0];
                        if (pspDev.Number == devINode.Number && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0" && pspkswitch.KSwitchStatus == "0")
                        {

                            flag = true;
                            dlr = "0" + " " + devINode.Number + " " + devJNode.Number + " " + psp.Number + " " + "0" + " " + "0";

                        }
                        if (pspDev.Number == devJNode.Number && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0" && pspkswitch.KSwitchStatus == "0")
                        {
                            flag = true;
                            dlr = "0" + " " + devINode.Number + " " + devJNode.Number + " " + psp.Number + " " + "1" + " " + "0";
                        }
                        if (pspDev.Number == devKNode.Number && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0" && pspkswitch.KSwitchStatus == "0")
                        {
                            flag = true;
                            dlr = "0" + " " + devINode.Number + " " + devKNode.Number + " " + psp.Number + " " + "1" + " " + "0";
                        }

                        if (flag)
                        {
                            FileStream VK = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fault.txt"), FileMode.OpenOrCreate);
                            StreamWriter str11 = new StreamWriter(VK);
                            str11.Write(dlr);
                            str11.Close();
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt"))
                            {
                                File.Delete(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt");
                            }
                          //  shortcir shortCutCal = new shortcir();
                            shortCutCal.Show_shortcir(0,0,1);
                            //bool matrixflag=true;                //用来判断是否导纳矩阵的逆矩阵是否存在逆矩阵

                            string matrixstr = null;
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Zmatrixcheck.txt"))
                            {
                                matrixstr = "正序导纳矩阵";
                                // matrixflag = false;
                            }

                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Fmatrixcheck.txt"))
                            {
                                // matrixflag = false;
                                matrixstr += "负序导纳矩阵";
                            }

                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Lmatrixcheck.txt"))
                            {
                                //matrixflag = false;
                                matrixstr += "零序导纳矩阵";
                            }
                            if (matrixstr != null)
                            {
                                MessageBox.Show(matrixstr + "不存在逆矩阵,请调整参数后再进行计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt"))
                            {
                            }
                            else
                            {
                                return;
                            }

                            FileStream shorcuit = new FileStream(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt", FileMode.Open);
                            StreamReader readLineGU = new StreamReader(shorcuit, System.Text.Encoding.Default);
                            string strLineGU;
                            string[] arrayGU;
                            char[] charSplitGU = new char[] { ' ' };

                            while ((strLineGU = readLineGU.ReadLine()) != null)
                            {

                                while ((strLineGU = readLineGU.ReadLine()) != null)
                                {
                                    arrayGU = strLineGU.Split(charSplitGU);
                                    string[] shorti = new string[4];
                                    shorti.Initialize();
                                    int m = 0;
                                    foreach (string str in arrayGU)
                                    {

                                        if (str != "")
                                        {

                                            shorti[m++] = str.ToString();

                                        }
                                    }

                                    nodeshorti[pspDev.Number] = Convert.ToDouble(shorti[3]) * 100 / (Math.Sqrt(3) * pspDev.ReferenceVolt);
                                }
                            }
                            readLineGU.Close();
                            break;                 //跳出本循环 进行母线的另外一个母线短路

                        }
                        if (!flag)
                            continue;
                        //写入错误中

                    }
                }
            }
            //找出短路电流最大的值

            //maxshorti.Key = 1;
            //maxshorti.Value = nodeshorti[1];
            foreach (KeyValuePair<int, double> keyvalue in nodeshorti)
            {
                if (keyvalue.Value > maxshorti.Value)
                {
                    maxshorti = keyvalue;
                }
            }

            //首先取出断路器 判断它的母线在不在 如果不在就将其删除 然后与额定电压进行比较
            con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "'AND PSPDEV.type='06'AND PSPDEV.KSwitchStatus = '0' order by PSPDEV.number";
            IList list = Services.BaseService.GetList("SelectPSPDEVByCondition", con);

            for (int i = 0; i < list.Count; i++)
            {
                bool flag = false;
                pspDev = list[i] as PSPDEV;
                for (int j = 0; j < list1.Count; j++)
                {
                    psp = list1[j] as PSPDEV;
                    if (pspDev.IName == psp.Name)
                        flag = true;

                }
                if (!flag)
                {
                    Services.BaseService.Delete<PSPDEV>(pspDev);
                }
            }
            con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "'AND PSPDEV.type='06'AND PSPDEV.KSwitchStatus = '0' order by PSPDEV.number";
            list = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
            for (int i = 0; i < list.Count; i++)
            {
                pspDev = list[i] as PSPDEV;
                pspDev.HuganLine3 = "";
                pspDev.KName = "";
                if (pspDev.KSwitchStatus == "0")
                {
                    pspDev.OutP = maxshorti.Value;
                    if (maxshorti.Value > pspDev.HuganTQ1)
                    {
                        pspDev.HuganLine3 = "不合格";
                    }
                    else
                    {
                        pspDev.HuganLine3 = "合格";
                    }
                    pspDev.HuganLine4 = "";
                    if (pspDev.HuganLine3 == "合格")
                    {
                        pspDev.KName = "合格";
                    }
                    else
                        pspDev.KName = "不合格";
                }

                Services.BaseService.Update<PSPDEV>(pspDev);
            }
            switch (caozuoi)
            {
                case 1:           //全部短路检验

                    {
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                        pspDev.Type = "06";
                         DlqiCheckform dlqicheckform = new DlqiCheckform(pspDev);
                        dlqicheckform.getusercltr.gridView.GroupPanelText = "断路器开断能力评估初步结果表";
                        dlqicheckform.ShowDialog();
                        break;
                    }
                case 2:             //最大短路检验
                    {
                        con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "'AND PSPDEV.type='06'AND PSPDEV.KSwitchStatus = '0' order by PSPDEV.number";
                        list = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                        for (int i = 0; i < list.Count; i++)
                        {
                            pspDev = list[i] as PSPDEV;
                            if (pspDev.KSwitchStatus == "0")
                            {
                               con = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid+ "'AND PSPDEV.type='01'AND PSPDEV.KSwitchStatus = '0'AND PSPDEV.Name='"+pspDev.IName+"'";

                               IList list4 = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                                psp = list4[0] as PSPDEV;
                                try
                                {
                                    pspDev.OutQ = nodeshorti[psp.Number];
                                    if (pspDev.HuganLine3 == "不合格")
                                    {
                                        if (pspDev.OutQ <= pspDev.HuganTQ1)
                                        {
                                            pspDev.HuganLine3 = "合格";
                                        }
                                    }
                                    pspDev.HuganLine4 = "";

                                    if (pspDev.HuganLine3 == "合格")
                                    {
                                        pspDev.KName = "合格";
                                    }
                                    else
                                        pspDev.KName = "不合格";
                                    Services.BaseService.Update<PSPDEV>(pspDev);
                                }
                                catch (System.Exception ex)
                                {
                                    MessageBox.Show("短路数据不完整");
                                }
                            }

                        }
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                        pspDev.Type = "06";
                        DlqiCheckform dlqicheckform = new DlqiCheckform(pspDev);
                        dlqicheckform.getusercltr.gridView.GroupPanelText = "最大短路校核结果表";
                        dlqicheckform.ShowDialog();
                        break;
                    }
                case 3:          //断路器直流检验

                    {
                        con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "'AND PSPDEV.type='06'AND PSPDEV.KSwitchStatus = '0' order by PSPDEV.number";
                        list = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                        for (int i = 0; i < list.Count; i++)
                        {
                            pspDev = list[i] as PSPDEV;
                            if (pspDev.KSwitchStatus == "0")
                            {
                                double tx = 0.0;
                                if (pspDev.HuganLine2 == "自脱扣断路器")
                                {
                                    tx = 0.0;
                                }
                                else if (pspDev.HuganLine2 == "辅助动力脱扣的断路器")
                                {
                                    tx = 10;
                                }
                                pspDev.HuganTQ4 = (pspDev.OutP / pspDev.HuganTQ1) * Math.Exp((-pspDev.HuganTQ2 - tx) / 45) * 100;
                                pspDev.HuganTQ5 = (pspDev.OutQ / pspDev.HuganTQ1) * Math.Exp((-pspDev.HuganTQ2 - tx) / 45) * 100;
                                if (pspDev.HuganTQ3 >= pspDev.HuganTQ4)
                                {
                                    pspDev.HuganLine4 = "合格";
                                }
                                if (pspDev.HuganTQ3 >= pspDev.HuganTQ5)
                                {
                                    pspDev.HuganLine4 = "合格";
                                }
                                else if (pspDev.HuganTQ3 < pspDev.HuganTQ5)
                                {
                                    pspDev.HuganLine4 = "不合格";
                                }
                                if (pspDev.HuganLine3 == "合格" && pspDev.HuganLine4 == "合格")
                                {
                                    pspDev.KName = "合格";
                                }
                                else
                                {
                                    pspDev.KName = "不合格";
                                }

                                Services.BaseService.Update<PSPDEV>(pspDev);
                            }

                        }
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                        pspDev.Type = "06";
                        DlqiCheckform dlqicheckform = new DlqiCheckform(pspDev);
                        dlqicheckform.getusercltr.gridView.GroupPanelText = "断路器开端能力最终评估表";
                        dlqicheckform.ShowDialog();
                        break;
                    }

            }
        }
Ejemplo n.º 3
0
        public void AllShortWJ(string projectSUID, string projectid, int dulutype, double ratecaplity, WaitDialogForm wf)
        {
            try
            {
                OutType = 1;
                if (Compuflag == 1)
                {
                    ElectricLoadCal elcc = new ElectricLoadCal();
                    elcc.LFCS(projectSUID, 1, (float)ratecaplity);
                    if (!CheckDLL(projectSUID, projectid, ratecaplity))
                    {
                        return;
                    }
                }
                else
                {
                    if (!CheckDL(projectSUID, projectid, ratecaplity))
                    {
                        return;
                    }
                }

                System.Windows.Forms.Clipboard.Clear();
                Dictionary<int, double> nodeshorti = new Dictionary<int, double>();      //��¼ĸ����û�н��й���·
                KeyValuePair<int, double> maxshorti = new KeyValuePair<int, double>(); //ȡ����·������·����

                string con = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='01'AND PSPDEV.KSwitchStatus = '0' order by PSPDEV.number";
                PSPDEV pspDev = new PSPDEV();
                IList list1 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type in ('05','03','02') AND PSPDEV.KSwitchStatus = '0'order by PSPDEV.number";
                IList list2 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);

                PSPDEV psp = new PSPDEV();
                psp = list2[0] as PSPDEV;
                string data = System.DateTime.Now.ToString("d");
                string time = System.DateTime.Now.ToString("T");
                StringBuilder duanResult = new StringBuilder();
                duanResult.Append("��·�������" + "\r\n" + "\r\n");
                duanResult.Append("��·��ҵ�ţ�1" + "\r\n");
                duanResult.Append("��·�������ڣ�" + data + " " + "ʱ�䣺" + time + "\r\n");
                duanResult.Append("���kA" + "\r\n");
                StringBuilder dianYaResult = new StringBuilder();
                dianYaResult.Append("ĸ�ߵ�ѹ���" + "\r\n" + "\r\n");
                dianYaResult.Append("��·��ҵ�ţ�1" + "\r\n");
                dianYaResult.Append("��·�������ڣ�" + data + " " + "ʱ�䣺" + time + "\r\n");
                dianYaResult.Append("��λ����ֵ( p.u. )  �Ƕ�(deg.)" + "\r\n");
                StringBuilder dianLiuResult = new StringBuilder();
                dianLiuResult.Append("֧·�������" + "\r\n" + "\r\n");
                dianLiuResult.Append("��·��ҵ�ţ�1" + "\r\n");
                dianLiuResult.Append("��·�������ڣ�" + data + " " + "ʱ�䣺" + time + "\r\n");
                dianLiuResult.Append("��λ����ֵ( p.u. )  �Ƕ�(deg.)" + "\r\n");
                int intshorti = 0;        //��һ�м�¼��ΪҪ����·����������˵��
                bool shortiflag = false;
                int muxiannum = 0;         //��¼һ��ĸ�߶�·�� �ж��ٸ���¼ĸ�ߵ�ѹ
                int linenum = 0;           //��¼һ��ĸ�߶�· �ж��ٸ���·����
                shortbuscir shortCutCal = new shortbuscir(Compuflag);
                string dlr = null;
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\fault.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\fault.txt");
                }
                if (psp != null)
                {
                    dlr = "0" + " " + psp.FirstNode + " " + psp.LastNode + " " + psp.Number + " " + "0 " + " " + dulutype;
                }
                else
                {
                    return;
                }

                FileStream VK = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fault.txt"), FileMode.OpenOrCreate);
                StreamWriter str11 = new StreamWriter(VK);
                str11.Write(dlr);
                str11.Close();
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt");
                }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt");
                }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt");
                }
                shortCutCal.Show_shortcir(Compuflag, OutType, 0);

                string matrixstr = null;
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Zmatrixcheck.txt"))
                {
                    matrixstr = "�����ɾ���";
                    // matrixflag = false;
                }

                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Fmatrixcheck.txt"))
                {
                    // matrixflag = false;
                    matrixstr += "�����ɾ���";
                }

                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Lmatrixcheck.txt"))
                {
                    //matrixflag = false;
                    matrixstr += "�����ɾ���";
                }
                if (matrixstr != null)
                {
                    System.Windows.Forms.MessageBox.Show(matrixstr + "�����������������������ٽ��м��㣡", "��ʾ", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
                    return;
                }
            }
            catch (System.Exception ex)
            {

            }
        }
Ejemplo n.º 4
0
        public void ALLShortThread(string projectSUID, string projectid, int dulutype, double ratecaplity, WaitDialogForm wf)
        {
            try
            {
                if (!CheckDL(projectSUID, projectid, ratecaplity))
                {
                    return;
                }
                System.Windows.Forms.Clipboard.Clear();
                Dictionary<int, double> nodeshorti = new Dictionary<int, double>();      //��¼ĸ����û�н��й���·
                KeyValuePair<int, double> maxshorti = new KeyValuePair<int, double>(); //ȡ����·������·����

                string con = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='01'AND PSPDEV.KSwitchStatus = '0' order by PSPDEV.number";
                PSPDEV pspDev = new PSPDEV();
                IList list1 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type in ('05','03','02') AND PSPDEV.KSwitchStatus = '0'order by PSPDEV.number";
                IList list2 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);

                PSPDEV psp = new PSPDEV();
                psp = list2[0] as PSPDEV;
                string data = System.DateTime.Now.ToString("d");
                string time = System.DateTime.Now.ToString("T");
                string[,] dataDianliu = new string[65536, 15];

                StringBuilder duanResult = new StringBuilder();
                duanResult.Append("��·�������" + "\r\n" + "\r\n");
                duanResult.Append("��·��ҵ�ţ�1" + "\r\n");
                duanResult.Append("��·�������ڣ�" + data + " " + "ʱ�䣺" + time + "\r\n");
                duanResult.Append("���kA" + "\r\n");
                StringBuilder dianYaResult = new StringBuilder();
                dianYaResult.Append("ĸ�ߵ�ѹ���" + "\r\n" + "\r\n");
                dianYaResult.Append("��·��ҵ�ţ�1" + "\r\n");
                dianYaResult.Append("��·�������ڣ�" + data + " " + "ʱ�䣺" + time + "\r\n");
                dianYaResult.Append("��λ����ֵ( p.u. )  �Ƕ�(deg.)" + "\r\n");
                StringBuilder dianLiuResult = new StringBuilder();
                dianLiuResult.Append("֧·�������" + "\r\n" + "\r\n");
                dianLiuResult.Append("��·��ҵ�ţ�1" + "\r\n");
                dianLiuResult.Append("��·�������ڣ�" + data + " " + "ʱ�䣺" + time + "\r\n");
                dianLiuResult.Append("��λ����ֵ( p.u. )  �Ƕ�(deg.)" + "\r\n");
                int intshorti = 0;        //��һ�м�¼��ΪҪ����·����������˵��
                bool shortiflag = false;
                int muxiannum = 0;         //��¼һ��ĸ�߶�·�� �ж��ٸ���¼ĸ�ߵ�ѹ
                int linenum = 0;           //��¼һ��ĸ�߶�· �ж��ٸ���·����
                shortbuscir shortCutCal = new shortbuscir(Compuflag);
                string dlr = null;

                if (psp != null)
                {
                    dlr = "0" + " " + psp.FirstNode + " " + psp.LastNode + " " + psp.Number + " " + "0 " + " " + dulutype;
                }
                else
                {
                    return;
                }

                FileStream VK = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fault.txt"), FileMode.OpenOrCreate);
                StreamWriter str11 = new StreamWriter(VK);
                str11.Write(dlr);
                str11.Close();
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt");
                }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt");
                }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt");
                }
                shortCutCal.Show_shortcir(Compuflag, OutType, 0);

                string matrixstr = null;
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Zmatrixcheck.txt"))
                {
                    matrixstr = "�����ɾ���";
                    // matrixflag = false;
                }

                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Fmatrixcheck.txt"))
                {
                    // matrixflag = false;
                    matrixstr += "�����ɾ���";
                }

                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Lmatrixcheck.txt"))
                {
                    //matrixflag = false;
                    matrixstr += "�����ɾ���";
                }
                if (matrixstr != null)
                {
                    System.Windows.Forms.MessageBox.Show(matrixstr + "�����������������������ٽ��м��㣡", "��ʾ", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
                    return;
                }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt"))
                {
                }
                else
                {
                    return;
                }
                ArrayList al = new ArrayList();
                FileReadV fv = new FileReadV(projectSUID, projectid, dulutype, ratecaplity, wf, shortiflag, duanResult);
                FileReadDLL fdl = new FileReadDLL(projectSUID, projectid, dulutype, ratecaplity, wf, con, dataDianliu);
                FileReadDV fdv = new FileReadDV(projectSUID, projectid, dulutype, ratecaplity, wf, con, dianYaResult);
                Thread shori = new Thread(new ThreadStart(fv.str));
                Thread dianya = new Thread(new ThreadStart(fdv.str));
                Thread dianliu = new Thread(new ThreadStart(fdl.str));
                shori.Start();
                if (OutType == 0)
                {
                    dianya.Start();
                    dianliu.Start();
                }

                //д�뱨����
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result.csv"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\result.csv");
                }
                FileStream tempGU = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result.csv"), FileMode.OpenOrCreate);
                StreamWriter strGU = new StreamWriter(tempGU, Encoding.Default);
                strGU.Write(duanResult.ToString());
                strGU.Close();
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result1.csv"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\result1.csv");
                }
                FileStream tempDY = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result1.csv"), FileMode.OpenOrCreate);
                StreamWriter strDY = new StreamWriter(tempDY, Encoding.Default);
                strDY.Write(dianYaResult.ToString());
                strDY.Close();
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result2.csv"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\result2.csv");
                }
                FileStream tempDL = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result2.csv"), FileMode.OpenOrCreate);
                StreamWriter strDL = new StreamWriter(tempDL, Encoding.Default);
                strDL.Write(dianLiuResult);
                strDL.Close();
                PSP_ELCPROJECT psproject = new PSP_ELCPROJECT();
                psproject.ID = projectSUID;
                psproject = (PSP_ELCPROJECT)UCDeviceBase.DataService.GetObject("SelectPSP_ELCPROJECTByKey", psproject);
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\" + psproject.Name + "ȫ����·������.xls"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\" + psproject.Name + "ȫ����·������.xls");
                }

                Excel.Application ex;
                Excel.Worksheet xSheet;
                Excel.Application result1;
                Excel.Application result2;
                Excel.Worksheet tempSheet;
                Excel.Worksheet tempSheet1;
                Excel.Worksheet newWorksheet;
                Excel.Worksheet newWorkSheet1;

                object oMissing = System.Reflection.Missing.Value;
                ex = new Excel.Application();
                ex.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result.csv");

                xSheet = (Excel.Worksheet)ex.Worksheets[1];
                ex.Worksheets.Add(System.Reflection.Missing.Value, xSheet, 1, System.Reflection.Missing.Value);
                xSheet = (Excel.Worksheet)ex.Worksheets[2];
                ex.Worksheets.Add(System.Reflection.Missing.Value, xSheet, 1, System.Reflection.Missing.Value);
                xSheet = (Excel.Worksheet)ex.Worksheets[1];
                result1 = new Excel.Application();
                result1.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result1.csv");
                result2 = new Excel.Application();
                result2.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result2.csv");
                tempSheet = (Excel.Worksheet)result1.Worksheets.get_Item(1);
                tempSheet1 = (Excel.Worksheet)result2.Worksheets.get_Item(1);
                newWorksheet = (Excel.Worksheet)ex.Worksheets.get_Item(2);
                newWorkSheet1 = (Excel.Worksheet)ex.Worksheets.get_Item(3);
                newWorksheet.Name = "ĸ�ߵ�ѹ";
                newWorkSheet1.Name = "֧·����";
                xSheet.Name = "��·����";
                ex.Visible = true;

                tempSheet.Cells.Select();
                tempSheet.Cells.Copy(System.Reflection.Missing.Value);
                newWorksheet.Paste(System.Reflection.Missing.Value, System.Reflection.Missing.Value);
                tempSheet1.Cells.Select();
                tempSheet1.Cells.Copy(System.Reflection.Missing.Value);
                newWorkSheet1.Paste(System.Reflection.Missing.Value, System.Reflection.Missing.Value);

                while (shori.IsAlive || dianya.IsAlive || dianliu.IsAlive)
                {
                    newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[65536, 20]).Clear();
                    newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[65536, 20]).Value2 = dataDianliu;

                }
                xSheet.UsedRange.Font.Name = "����_GB2312";
                newWorksheet.UsedRange.Font.Name = "����_GB2312";
                newWorkSheet1.UsedRange.Font.Name = "����_GB2312";
                //��¼��Ϊ��·������ʽ
                xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 3]).MergeCells = true;
                xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Size = 20;
                xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Name = "����";
                xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                xSheet.get_Range(xSheet.Cells[6, 1], xSheet.Cells[6, 3]).Interior.ColorIndex = 45;
                xSheet.get_Range(xSheet.Cells[7, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6;
                xSheet.get_Range(xSheet.Cells[4, 3], xSheet.Cells[xSheet.UsedRange.Rows.Count, 13]).NumberFormat = "0.0000_ ";
                //ĸ�ߵ�ѹ��ʾ��ʽ
                newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 14]).MergeCells = true;
                newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).Font.Size = 20;
                newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).Font.Name = "����";
                newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                if (OutType == 0)
                {
                    for (int m = 0; m < muxiannum - 1; m++)
                    {
                        newWorksheet.get_Range(newWorksheet.Cells[m * (muxiannum + 2) + 8, 1], newWorksheet.Cells[m * (muxiannum + 2) + 8, 14]).Interior.ColorIndex = 45;
                        newWorksheet.get_Range(newWorksheet.Cells[m * (muxiannum + 2) + 9, 1], newWorksheet.Cells[m * (muxiannum + 2) + 8 + muxiannum - 1, 1]).Interior.ColorIndex = 6;
                        newWorksheet.get_Range(newWorksheet.Cells[m * (muxiannum + 2) + 9, 3], newWorksheet.Cells[m * (muxiannum + 2) + 8 + muxiannum - 1, 13]).NumberFormat = "0.0000_ ";
                    }

                }

                //��·�����������ʾ��ʽ
                newWorkSheet1.get_Range(newWorkSheet1.Cells[1, 1], newWorkSheet1.Cells[1, 15]).MergeCells = true;
                newWorkSheet1.get_Range(newWorkSheet1.Cells[1, 1], newWorkSheet1.Cells[1, 1]).Font.Size = 20;
                newWorkSheet1.get_Range(newWorkSheet1.Cells[1, 1], newWorkSheet1.Cells[1, 1]).Font.Name = "����";
                newWorkSheet1.get_Range(newWorkSheet1.Cells[1, 1], newWorkSheet1.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                if (OutType == 0)
                {
                    for (int m = 0; m < muxiannum - 1; m++)
                    {
                        newWorkSheet1.get_Range(newWorkSheet1.Cells[m * (linenum + 2) + 8, 1], newWorkSheet1.Cells[m * (linenum + 2) + 8, 15]).Interior.ColorIndex = 45;
                        newWorkSheet1.get_Range(newWorkSheet1.Cells[m * (linenum + 2) + 9, 1], newWorkSheet1.Cells[m * (linenum + 2) + 8 + linenum - 1, 1]).Interior.ColorIndex = 6;
                        newWorkSheet1.get_Range(newWorkSheet1.Cells[m * (linenum + 2) + 9, 2], newWorkSheet1.Cells[m * (linenum + 2) + 8 + linenum - 1, 2]).Interior.ColorIndex = 6;
                        newWorkSheet1.get_Range(newWorkSheet1.Cells[m * (linenum + 2) + 9, 3], newWorkSheet1.Cells[m * (linenum + 2) + 8 + linenum - 1, 3]).Interior.ColorIndex = 6;
                        newWorkSheet1.get_Range(newWorkSheet1.Cells[m * (linenum + 2) + 9, 4], newWorkSheet1.Cells[m * (linenum + 2) + 8 + linenum - 1, 14]).NumberFormat = "0.0000_ ";
                    }
                }

                xSheet.Rows.AutoFit();
                xSheet.Columns.AutoFit();
                newWorksheet.Rows.AutoFit();
                newWorksheet.Columns.AutoFit();
                newWorkSheet1.Rows.AutoFit();
                newWorkSheet1.Columns.AutoFit();
                newWorksheet.SaveAs(System.Windows.Forms.Application.StartupPath + "\\" + psproject.Name + "ȫ����·������.xls", Excel.XlFileFormat.xlXMLSpreadsheet, null, null, false, false, false, null, null, null);
                System.Windows.Forms.Clipboard.Clear();

                result1.Workbooks.Close();
                result1.Quit();
                result2.Workbooks.Close();
                result2.Quit();
                GC.Collect();
            }
            catch (System.Exception ex)
            {

            }
        }
Ejemplo n.º 5
0
        //�����еĶ�·�������в���
        public void AllShorti(string projectSUID, string projectid, int dulutype, double ratecaplity, Dictionary<string, double> shortcap)
        {
            try
            {

                //OutType = 1;
                if (Compuflag == 1)
                {
                    ElectricLoadCal elcc = new ElectricLoadCal();
                    elcc.LFCS(projectSUID, 1, (float)ratecaplity);
                    if (!CheckDLL(projectSUID, projectid, ratecaplity))
                    {
                        return;
                    }
                }
                else
                {
                    if (!CheckDL(projectSUID, projectid, ratecaplity))
                    {
                        return;
                    }
                }

                System.Windows.Forms.Clipboard.Clear();
                Dictionary<int, double> nodeshorti = new Dictionary<int, double>();      //��¼ĸ����û�н��й���·
                KeyValuePair<int, double> maxshorti = new KeyValuePair<int, double>(); //ȡ����·������·����

                string con = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='01'AND PSPDEV.KSwitchStatus = '0' order by PSPDEV.number";
                PSPDEV pspDev = new PSPDEV();
                IList list1 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type in ('05','03','02') AND PSPDEV.KSwitchStatus = '0'order by PSPDEV.number";
                IList list2 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);

                PSPDEV psp = new PSPDEV();
                psp = list2[0] as PSPDEV;
                string data = System.DateTime.Now.ToString("d");
                string time = System.DateTime.Now.ToString("T");

                int intshorti = 0;        //��һ�м�¼��ΪҪ����·����������˵��
                bool shortiflag = false;
                int muxiannum = 0;         //��¼һ��ĸ�߶�·�� �ж��ٸ���¼ĸ�ߵ�ѹ
                int linenum = 0;           //��¼һ��ĸ�߶�· �ж��ٸ���·����
                shortbuscir shortCutCal = new shortbuscir(Compuflag);
                string dlr = null;

                if (psp != null)
                {
                    dlr = "0" + " " + psp.FirstNode + " " + psp.LastNode + " " + psp.Number + " " + "0 " + " " + dulutype;
                }
                else
                {
                    return;
                }

                FileStream VK = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fault.txt"), FileMode.OpenOrCreate);
                StreamWriter str11 = new StreamWriter(VK);
                str11.Write(dlr);
                str11.Close();
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt");
                }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt");
                }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt");
                }
                shortCutCal.Show_shortcir(Compuflag, OutType, 0);

                string matrixstr = null;
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Zmatrixcheck.txt"))
                {
                    matrixstr = "�����ɾ���";
                    // matrixflag = false;
                }

                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Fmatrixcheck.txt"))
                {
                    // matrixflag = false;
                    matrixstr += "�����ɾ���";
                }

                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Lmatrixcheck.txt"))
                {
                    //matrixflag = false;
                    matrixstr += "�����ɾ���";
                }
                if (matrixstr != null)
                {
                    System.Windows.Forms.MessageBox.Show(matrixstr + "�����������������������ٽ��м��㣡", "��ʾ", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
                    return;
                }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt"))
                {
                }
                else
                {
                    return;
                }

                FileStream shorcuit = new FileStream(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt", FileMode.Open);
                StreamReader readLineGU = new StreamReader(shorcuit, System.Text.Encoding.Default);
                string strLineGU;
                string[] arrayGU;
                char[] charSplitGU = new char[] { ' ' };
                intshorti = 0;
                while ((strLineGU = readLineGU.ReadLine()) != null)
                {

                    arrayGU = strLineGU.Split(charSplitGU, StringSplitOptions.RemoveEmptyEntries);
                    string[] shorti = arrayGU;
                    shorti.Initialize();
                    //int m = 0;
                    //foreach (string str in arrayGU)
                    //{

                    //    if (str != "")
                    //    {

                    //        shorti[m++] = str.ToString();

                    //    }
                    //}
                    if (intshorti == 0)
                    {
                        if (!shortiflag)
                        {
                            //duanResult.Append(shorti[0] + "," + shorti[1] + "," + shorti[3] + "\r\n");
                            shortiflag = true;
                        }

                    }
                    else
                        shortcap[shorti[1]] = Convert.ToDouble(shorti[3]);

                    intshorti++;
                    //wf.SetCaption(intshorti.ToString());
                }
                readLineGU.Close();

            }
            catch (System.Exception ex)
            {
                MessageBox.Show("��·���ݴ������⣬�迹���󲻴��ڻ��ߴ��ڹ����ڵ㣬���֤���ٽ��У�");
            }
        }
Ejemplo n.º 6
0
        //���ݲ����Ĵ���������ʾ
        public void AllshortcheckYL(string projectSUID, string projectid, double ratecaplity, int caozuoi)
        {
            try
            {
                if (!CheckDL(projectSUID, projectid, ratecaplity))
                {
                    return;
                }
                Dictionary<int, double> nodeshorti = new Dictionary<int, double>();      //��¼ĸ����û�н��й���·
                KeyValuePair<int, double> maxshorti = new KeyValuePair<int, double>(); //ȡ����·������·����
                string con = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='01'AND PSPDEV.KSwitchStatus = '0' order by PSPDEV.number";
                PSPDEV pspDev = new PSPDEV();
                IList list1 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);

                PSPDEV psp = new PSPDEV();
                shortbuscir shortCutCal = new shortbuscir(Compuflag);
                for (int i = 0; i < list1.Count; i++)
                {
                    pspDev = list1[i] as PSPDEV;
                    bool flag = false;
                    string dlr = null;
                    con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='05'AND PSPDEV.KSwitchStatus = '0'AND (PSPDEV.IName='" + pspDev.Name + "'OR PSPDEV.JName='" + pspDev.Name + "')order by PSPDEV.number";

                    IList list2 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);

                    for (int j = 0; j < list2.Count; j++)
                    {
                        psp = list2[j] as PSPDEV;
                        con = " WHERE Name='" + psp.ISwitch + "' AND ProjectID = '" + projectid + "'" + "AND Type='07'";
                        IList listiswitch = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                        con = " WHERE Name='" + psp.JSwitch + "' AND ProjectID = '" + projectid + "'" + "AND Type='07'";
                        IList listjswitch = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                        PSPDEV pspiswitch = (PSPDEV)listiswitch[0];
                        PSPDEV pspjswitch = (PSPDEV)listjswitch[0];

                        if (pspDev.Number == psp.FirstNode && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0")
                        {

                            flag = true;
                            dlr = "0" + " " + psp.FirstNode + " " + psp.LastNode + " " + psp.Number + " " + "0 " + " " + "0 ";

                        }
                        if (pspDev.Number == psp.LastNode && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0")
                        {
                            flag = true;
                            dlr = "0" + " " + psp.FirstNode + " " + psp.LastNode + " " + psp.Number + " " + "1 " + " " + "0 ";
                        }
                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\fault.txt"))
                        {
                            File.Delete(System.Windows.Forms.Application.StartupPath + "\\fault.txt");
                        }
                        if (flag)
                        {
                            FileStream VK = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fault.txt"), FileMode.OpenOrCreate);
                            StreamWriter str11 = new StreamWriter(VK);
                            str11.Write(dlr);
                            str11.Close();
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt"))
                            {
                                File.Delete(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt");
                            }
                            //shortcir shortCutCal = new shortcir();
                            shortCutCal.Show_shortcir(0, 0, 1);
                            //bool matrixflag=true;                //�����ж��Ƿ��ɾ����������Ƿ���������
                            string matrixstr = null;
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Zmatrixcheck.txt"))
                            {
                                matrixstr = "�����ɾ���";
                                // matrixflag = false;
                            }

                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Fmatrixcheck.txt"))
                            {
                                // matrixflag = false;
                                matrixstr += "�����ɾ���";
                            }

                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Lmatrixcheck.txt"))
                            {
                                //matrixflag = false;
                                matrixstr += "�����ɾ���";
                            }
                            if (matrixstr != null)
                            {
                                MessageBox.Show(matrixstr + "�����������������������ٽ��м��㣡", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt"))
                            {
                            }
                            else
                            {
                                return;
                            }

                            FileStream shorcuit = new FileStream(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt", FileMode.Open);
                            StreamReader readLineGU = new StreamReader(shorcuit, System.Text.Encoding.Default);
                            string strLineGU;
                            string[] arrayGU;
                            char[] charSplitGU = new char[] { ' ' };

                            while ((strLineGU = readLineGU.ReadLine()) != null)
                            {

                                while ((strLineGU = readLineGU.ReadLine()) != null)
                                {
                                    arrayGU = strLineGU.Split(charSplitGU);
                                    string[] shorti = new string[4];
                                    shorti.Initialize();
                                    int m = 0;
                                    foreach (string str in arrayGU)
                                    {

                                        if (str != "")
                                        {

                                            shorti[m++] = str.ToString();

                                        }
                                    }

                                    nodeshorti[pspDev.Number] = Convert.ToDouble(shorti[3]) * 100 / (Math.Sqrt(3) * pspDev.ReferenceVolt);
                                }
                            }
                            readLineGU.Close();
                            break;                 //������ѭ�� ����ĸ�ߵ�����һ��ĸ�߶�·
                        }
                        if (!flag)
                            continue;
                        //������
                    }
                    //�����һ����·��û�������������н���
                    if (!flag)
                    {
                        con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='02'AND PSPDEV.KSwitchStatus = '0'AND(PSPDEV.IName='" + pspDev.Name + "'OR PSPDEV.JName='" + pspDev.Name + "') order by PSPDEV.number";
                        IList list3 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                        for (int j = 0; j < list3.Count; j++)
                        {
                            dlr = null;
                            psp = list3[j] as PSPDEV;
                            //PSPDEV devFirst = new PSPDEV();

                            //con = " WHERE Name='" + psp.IName + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'";
                            //devFirst = (PSPDEV)UCDeviceBase.DataService.GetObject("SelectPSPDEVByCondition", con);
                            //PSPDEV devLast = new PSPDEV();

                            //con = " WHERE Name='" + psp.JName + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'";
                            //devLast = (PSPDEV)UCDeviceBase.DataService.GetObject("SelectPSPDEVByCondition", con);
                            con = " WHERE Name='" + psp.ISwitch + "' AND ProjectID = '" + projectid + "'" + "AND Type='07'";
                            IList listiswitch = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                            con = " WHERE Name='" + psp.JSwitch + "' AND ProjectID = '" + projectid + "'" + "AND Type='07'";
                            IList listjswitch = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                            PSPDEV pspiswitch = (PSPDEV)listiswitch[0];
                            PSPDEV pspjswitch = (PSPDEV)listjswitch[0];
                            if (pspDev.Number == psp.FirstNode && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0")
                            {

                                flag = true;
                                dlr = "0" + " " + psp.FirstNode + " " + psp.LastNode + " " + psp.Number + " " + "0" + " " + "0";

                            }
                            if (pspDev.Number == psp.LastNode && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0")
                            {
                                flag = true;
                                dlr = "0" + " " + psp.FirstNode + " " + psp.LastNode + " " + psp.Number + " " + "1" + " " + "0";
                            }
                            if (flag)
                            {
                                FileStream VK = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fault.txt"), FileMode.OpenOrCreate);
                                StreamWriter str11 = new StreamWriter(VK);
                                str11.Write(dlr);
                                str11.Close();
                                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt"))
                                {
                                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt");
                                }
                                // shortcir shortCutCal = new shortcir();
                                shortCutCal.Show_shortcir(0, 0, 1);
                                //bool matrixflag=true;                //�����ж��Ƿ��ɾ����������Ƿ���������
                                string matrixstr = null;
                                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Zmatrixcheck.txt"))
                                {
                                    matrixstr = "�����ɾ���";
                                    // matrixflag = false;
                                }

                                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Fmatrixcheck.txt"))
                                {
                                    // matrixflag = false;
                                    matrixstr += "�����ɾ���";
                                }

                                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Lmatrixcheck.txt"))
                                {
                                    //matrixflag = false;
                                    matrixstr += "�����ɾ���";
                                }
                                if (matrixstr != null)
                                {
                                    MessageBox.Show(matrixstr + "�����������������������ٽ��м��㣡", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    return;
                                }
                                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt"))
                                {
                                }
                                else
                                {
                                    return;
                                }

                                FileStream shorcuit = new FileStream(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt", FileMode.Open);
                                StreamReader readLineGU = new StreamReader(shorcuit, System.Text.Encoding.Default);
                                string strLineGU;
                                string[] arrayGU;
                                char[] charSplitGU = new char[] { ' ' };

                                while ((strLineGU = readLineGU.ReadLine()) != null)
                                {

                                    while ((strLineGU = readLineGU.ReadLine()) != null)
                                    {
                                        arrayGU = strLineGU.Split(charSplitGU);
                                        string[] shorti = new string[4];
                                        shorti.Initialize();
                                        int m = 0;
                                        foreach (string str in arrayGU)
                                        {

                                            if (str != "")
                                            {

                                                shorti[m++] = str.ToString();

                                            }
                                        }

                                        nodeshorti[pspDev.Number] = Convert.ToDouble(shorti[3]) * 100 / (Math.Sqrt(3) * pspDev.ReferenceVolt);
                                    }
                                }
                                readLineGU.Close();
                                break;                 //������ѭ�� ����ĸ�ߵ�����һ��ĸ�߶�·
                            }
                            if (!flag)
                                continue;
                            //������
                        }
                    }
                    if (!flag)
                    {
                        con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='03'AND PSPDEV.KSwitchStatus = '0' AND(PSPDEV.IName='" + pspDev.Name + "'OR PSPDEV.JName='" + pspDev.Name + "'OR PSPDEV.KName='" + pspDev.Name + "') order by PSPDEV.number";
                        IList list4 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                        for (int j = 0; j < list4.Count; j++)
                        {
                            dlr = null;
                            psp = list4[j] as PSPDEV;
                            //PSPDEV devINode = new PSPDEV();

                            //con = " WHERE Name='" + psp.IName + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'";
                            //devINode = (PSPDEV)UCDeviceBase.DataService.GetObject("SelectPSPDEVByCondition", con);
                            //PSPDEV devJNode = new PSPDEV();

                            //con = " WHERE Name='" + psp.JName + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'";
                            //devJNode = (PSPDEV)UCDeviceBase.DataService.GetObject("SelectPSPDEVByCondition", con);
                            //PSPDEV devKNode = new PSPDEV();

                            //con = " WHERE Name='" + psp.KName + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'";
                            //devKNode = (PSPDEV)UCDeviceBase.DataService.GetObject("SelectPSPDEVByCondition", con);

                            con = " WHERE Name='" + psp.ISwitch + "' AND ProjectID = '" + projectid + "'" + "AND Type='07'";
                            IList listiswitch = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                            con = " WHERE Name='" + psp.JSwitch + "' AND ProjectID = '" + projectid + "'" + "AND Type='07'";
                            IList listjswitch = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                            con = " WHERE Name='" + psp.HuganLine1 + "' AND ProjectID = '" + projectid + "'" + "AND Type='07'";
                            IList listkswitch = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                            PSPDEV pspiswitch = (PSPDEV)listiswitch[0];
                            PSPDEV pspjswitch = (PSPDEV)listjswitch[0];
                            PSPDEV pspkswitch = (PSPDEV)listkswitch[0];
                            if (pspDev.Number == psp.FirstNode & pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0" && pspkswitch.KSwitchStatus == "0")
                            {

                                flag = true;
                                dlr = "0" + " " + psp.FirstNode + " " + psp.LastNode + " " + psp.Number + " " + "0" + " " + "0";

                            }
                            if (pspDev.Number == psp.LastNode && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0" && pspkswitch.KSwitchStatus == "0")
                            {
                                flag = true;
                                dlr = "0" + " " + psp.FirstNode + " " + psp.LastNode + " " + psp.Number + " " + "1" + " " + "0";
                            }
                            if (pspDev.Number == psp.Flag && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0" && pspkswitch.KSwitchStatus == "0")
                            {
                                flag = true;
                                dlr = "0" + " " + psp.FirstNode + " " + psp.Flag + " " + psp.Number + " " + "1" + " " + "0";
                            }

                            if (flag)
                            {
                                FileStream VK = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fault.txt"), FileMode.OpenOrCreate);
                                StreamWriter str11 = new StreamWriter(VK);
                                str11.Write(dlr);
                                str11.Close();
                                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt"))
                                {
                                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt");
                                }
                                //shortcir shortCutCal = new shortcir();
                                shortCutCal.Show_shortcir(0, 0, 1);
                                //bool matrixflag=true;                //�����ж��Ƿ��ɾ����������Ƿ���������
                                string matrixstr = null;
                                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Zmatrixcheck.txt"))
                                {
                                    matrixstr = "�����ɾ���";
                                    // matrixflag = false;
                                }

                                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Fmatrixcheck.txt"))
                                {
                                    // matrixflag = false;
                                    matrixstr += "�����ɾ���";
                                }

                                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Lmatrixcheck.txt"))
                                {
                                    //matrixflag = false;
                                    matrixstr += "�����ɾ���";
                                }
                                if (matrixstr != null)
                                {
                                    MessageBox.Show(matrixstr + "�����������������������ٽ��м��㣡", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    return;
                                }
                                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt"))
                                {
                                }
                                else
                                {
                                    return;
                                }

                                FileStream shorcuit = new FileStream(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt", FileMode.Open);
                                StreamReader readLineGU = new StreamReader(shorcuit, System.Text.Encoding.Default);
                                string strLineGU;
                                string[] arrayGU;
                                char[] charSplitGU = new char[] { ' ' };

                                while ((strLineGU = readLineGU.ReadLine()) != null)
                                {

                                    while ((strLineGU = readLineGU.ReadLine()) != null)
                                    {
                                        arrayGU = strLineGU.Split(charSplitGU);
                                        string[] shorti = new string[4];
                                        shorti.Initialize();
                                        int m = 0;
                                        foreach (string str in arrayGU)
                                        {

                                            if (str != "")
                                            {

                                                shorti[m++] = str.ToString();

                                            }
                                        }

                                        nodeshorti[pspDev.Number] = Convert.ToDouble(shorti[3]) * 100 / (Math.Sqrt(3) * pspDev.ReferenceVolt);
                                    }
                                }
                                readLineGU.Close();
                                break;                 //������ѭ�� ����ĸ�ߵ�����һ��ĸ�߶�·
                            }
                            if (!flag)
                                continue;
                            //������
                        }
                    }
                }
                //�ҳ���·��������ֵ
                //maxshorti.Key = 1;
                //maxshorti.Value = nodeshorti[1];
                foreach (KeyValuePair<int, double> keyvalue in nodeshorti)
                {
                    if (keyvalue.Value > maxshorti.Value)
                    {
                        maxshorti = keyvalue;
                    }
                }

                //����ȡ����·�� �ж�����ĸ���ڲ��� ������ھͽ���ɾ�� Ȼ������ѹ���бȽ�
                con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='06'AND PSPDEV.KSwitchStatus = '0' order by PSPDEV.number";
                IList list = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);

                for (int i = 0; i < list.Count; i++)
                {
                    bool flag = false;
                    pspDev = list[i] as PSPDEV;
                    for (int j = 0; j < list1.Count; j++)
                    {
                        psp = list1[j] as PSPDEV;
                        if (pspDev.IName == psp.Name)
                            flag = true;

                    }
                    if (!flag)
                    {
                        UCDeviceBase.DataService.Delete<PSPDEV>(pspDev);
                    }
                }
                con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='06'AND PSPDEV.KSwitchStatus = '0' order by PSPDEV.number";
                list = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                for (int i = 0; i < list.Count; i++)
                {
                    pspDev = list[i] as PSPDEV;
                    pspDev.HuganLine3 = "";
                    pspDev.KName = "";
                    if (pspDev.KSwitchStatus == "0")
                    {
                        pspDev.OutP = maxshorti.Value;
                        if (maxshorti.Value > pspDev.HuganTQ1)
                        {
                            pspDev.HuganLine3 = "���ϸ�";
                        }
                        else
                        {
                            pspDev.HuganLine3 = "�ϸ�";
                        }
                        pspDev.HuganLine4 = "";
                        if (pspDev.HuganLine3 == "�ϸ�")
                        {
                            pspDev.KName = "�ϸ�";
                        }
                        else
                            pspDev.KName = "���ϸ�";
                    }

                    UCDeviceBase.DataService.Update<PSPDEV>(pspDev);
                }
                switch (caozuoi)
                {
                    case 1:           //ȫ����·����
                        {
                            pspDev.SvgUID = projectSUID;
                            pspDev.Type = "06";
                            DlqiCheckform dlqicheckform = new DlqiCheckform(pspDev);
                            dlqicheckform.getusercltr.gridView.GroupPanelText = "��·�����������������������";
                            dlqicheckform.ShowDialog();
                            break;
                        }
                    case 2:             //����·����
                        {
                            con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='06'AND PSPDEV.KSwitchStatus = '0' order by PSPDEV.number";
                            list = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                            for (int i = 0; i < list.Count; i++)
                            {
                                pspDev = list[i] as PSPDEV;
                                if (pspDev.KSwitchStatus == "0")
                                {
                                    con = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='01'AND PSPDEV.KSwitchStatus = '0'AND PSPDEV.Name='" + pspDev.IName + "'";

                                    IList list4 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                                    psp = list4[0] as PSPDEV;
                                    try
                                    {
                                        pspDev.OutQ = nodeshorti[psp.Number];
                                        if (pspDev.HuganLine3 == "���ϸ�")
                                        {
                                            if (pspDev.OutQ <= pspDev.HuganTQ1)
                                            {
                                                pspDev.HuganLine3 = "�ϸ�";
                                            }
                                        }
                                        pspDev.HuganLine4 = "";

                                        if (pspDev.HuganLine3 == "�ϸ�")
                                        {
                                            pspDev.KName = "�ϸ�";
                                        }
                                        else
                                            pspDev.KName = "���ϸ�";
                                        UCDeviceBase.DataService.Update<PSPDEV>(pspDev);
                                    }
                                    catch (System.Exception ex)
                                    {
                                        MessageBox.Show("��·���ݲ�����");
                                    }
                                }

                            }
                            pspDev.SvgUID = projectSUID;
                            pspDev.Type = "06";
                            DlqiCheckform dlqicheckform = new DlqiCheckform(pspDev);
                            dlqicheckform.getusercltr.gridView.GroupPanelText = "����·У�˽����";
                            dlqicheckform.ShowDialog();
                            break;
                        }
                    case 3:          //��·��ֱ������
                        {
                            con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='06'AND PSPDEV.KSwitchStatus = '0' order by PSPDEV.number";
                            list = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                            for (int i = 0; i < list.Count; i++)
                            {
                                pspDev = list[i] as PSPDEV;
                                if (pspDev.KSwitchStatus == "0")
                                {
                                    double tx = 0.0;
                                    if (pspDev.HuganLine2 == "���ѿ۶�·��")
                                    {
                                        tx = 0.0;
                                    }
                                    else if (pspDev.HuganLine2 == "���������ѿ۵Ķ�·��")
                                    {
                                        tx = 10;
                                    }
                                    pspDev.HuganTQ4 = (pspDev.OutP / pspDev.HuganTQ1) * Math.Exp((-pspDev.HuganTQ2 - tx) / 45) * 100;
                                    pspDev.HuganTQ5 = (pspDev.OutQ / pspDev.HuganTQ1) * Math.Exp((-pspDev.HuganTQ2 - tx) / 45) * 100;
                                    if (pspDev.HuganTQ3 >= pspDev.HuganTQ4)
                                    {
                                        pspDev.HuganLine4 = "�ϸ�";
                                    }
                                    if (pspDev.HuganTQ3 >= pspDev.HuganTQ5)
                                    {
                                        pspDev.HuganLine4 = "�ϸ�";
                                    }
                                    else if (pspDev.HuganTQ3 < pspDev.HuganTQ5)
                                    {
                                        pspDev.HuganLine4 = "���ϸ�";
                                    }
                                    if (pspDev.HuganLine3 == "�ϸ�" && pspDev.HuganLine4 == "�ϸ�")
                                    {
                                        pspDev.KName = "�ϸ�";
                                    }
                                    else
                                    {
                                        pspDev.KName = "���ϸ�";
                                    }

                                    UCDeviceBase.DataService.Update<PSPDEV>(pspDev);
                                }

                            }
                            pspDev.SvgUID = projectSUID;
                            pspDev.Type = "06";
                            DlqiCheckform dlqicheckform = new DlqiCheckform(pspDev);
                            dlqicheckform.getusercltr.gridView.GroupPanelText = "��·��������������������";
                            dlqicheckform.ShowDialog();
                            break;
                        }

                }

            }
            catch (System.Exception ex)
            {
                MessageBox.Show("��·����������������·�����Ƿ��ܽ��У�");
            }
        }
Ejemplo n.º 7
0
        public void AllShort(string projectSUID, string projectid, int dulutype, double ratecaplity, frnReport wFrom)
        {
            try
            {
                wFrom.ShowText += "\r\n��ʼ׼����·��������\t" + System.DateTime.Now.ToString();
                //OutType = 1;
                if (Compuflag == 1)
                {
                    ElectricLoadCal elcc = new ElectricLoadCal();
                    elcc.LFCS(projectSUID, 1, (float)ratecaplity);
                    if (!CheckDLL(projectSUID, projectid, ratecaplity))
                    {
                        return;
                    }
                }
                else
                {
                    if (!CheckDL(projectSUID, projectid, ratecaplity))
                    {
                        return;
                    }
                }

                System.Windows.Forms.Clipboard.Clear();
                Dictionary<int, double> nodeshorti = new Dictionary<int, double>();      //��¼ĸ����û�н��й���·
                KeyValuePair<int, double> maxshorti = new KeyValuePair<int, double>(); //ȡ����·������·����

                string con = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='01'AND PSPDEV.KSwitchStatus = '0' order by PSPDEV.number";
                PSPDEV pspDev = new PSPDEV();
                IList list1 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type in ('05','03','02') AND PSPDEV.KSwitchStatus = '0'order by PSPDEV.number";
                IList list2 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);

                PSPDEV psp = new PSPDEV();
                psp = list2[0] as PSPDEV;
                string data = System.DateTime.Now.ToString("d");
                string time = System.DateTime.Now.ToString("T");
                StringBuilder duanResult = new StringBuilder();
                duanResult.Append("��·�������" + "\r\n" + "\r\n");
                duanResult.Append("��·��ҵ�ţ�1" + "\r\n");
                duanResult.Append("��·�������ڣ�" + data + " " + "ʱ�䣺" + time + "\r\n");
                duanResult.Append("���kA" + "\r\n");
                StringBuilder dianYaResult = new StringBuilder();
                dianYaResult.Append("ĸ�ߵ�ѹ���" + "\r\n" + "\r\n");
                dianYaResult.Append("��·��ҵ�ţ�1" + "\r\n");
                dianYaResult.Append("��·�������ڣ�" + data + " " + "ʱ�䣺" + time + "\r\n");
                dianYaResult.Append("��λ����ֵ( p.u. )  �Ƕ�(deg.)" + "\r\n");
                StringBuilder dianLiuResult = new StringBuilder();
                dianLiuResult.Append("֧·�������" + "\r\n" + "\r\n");
                dianLiuResult.Append("��·��ҵ�ţ�1" + "\r\n");
                dianLiuResult.Append("��·�������ڣ�" + data + " " + "ʱ�䣺" + time + "\r\n");
                dianLiuResult.Append("��λ����ֵ( p.u. )  �Ƕ�(deg.)" + "\r\n");
                int intshorti = 0;        //��һ�м�¼��ΪҪ����·����������˵��
                bool shortiflag = false;
                int muxiannum = 0;         //��¼һ��ĸ�߶�·�� �ж��ٸ���¼ĸ�ߵ�ѹ
                int linenum = 0;           //��¼һ��ĸ�߶�· �ж��ٸ���·����
                shortbuscir shortCutCal = new shortbuscir(Compuflag);
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\fault.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\fault.txt");
                }
                string dlr = null;

                if (psp != null)
                {
                    dlr = "0" + " " + psp.FirstNode + " " + psp.LastNode + " " + psp.Number + " " + "0 " + " " + dulutype;
                }
                else
                {
                    return;
                }

                FileStream VK = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fault.txt"), FileMode.OpenOrCreate);
                StreamWriter str11 = new StreamWriter(VK);
                str11.Write(dlr);
                str11.Close();
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt");
                }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt");
                }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt");
                }
                wFrom.ShowText += "\r\n��ʼ���ж�·����\t" + System.DateTime.Now.ToString();
                shortCutCal.Show_shortcir(Compuflag, OutType, 0);

                string matrixstr = null;
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Zmatrixcheck.txt"))
                {
                    matrixstr = "�����ɾ���";
                    // matrixflag = false;
                }

                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Fmatrixcheck.txt"))
                {
                    // matrixflag = false;
                    matrixstr += "�����ɾ���";
                }

                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Lmatrixcheck.txt"))
                {
                    //matrixflag = false;
                    matrixstr += "�����ɾ���";
                }
                if (matrixstr != null)
                {
                    System.Windows.Forms.MessageBox.Show(matrixstr + "�����������������������ٽ��м��㣡", "��ʾ", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
                    return;
                }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt"))
                {
                }
                else
                {
                    wFrom.ShowText += "\r\n��·����ʧ��\t" + System.DateTime.Now.ToString();
                    return;
                }
                wFrom.ShowText += "\r\n��ʼ�����·������\t" + System.DateTime.Now.ToString();
                FileStream shorcuit = new FileStream(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt", FileMode.Open);
                StreamReader readLineGU = new StreamReader(shorcuit, System.Text.Encoding.Default);
                string strLineGU;
                string[] arrayGU;
                char[] charSplitGU = new char[] { ' ' };
                intshorti = 0;
                while ((strLineGU = readLineGU.ReadLine()) != null)
                {

                    arrayGU = strLineGU.Split(charSplitGU, StringSplitOptions.RemoveEmptyEntries);
                    string[] shorti = arrayGU;
                    shorti.Initialize();
                    //int m = 0;
                    //foreach (string str in arrayGU)
                    //{

                    //    if (str != "")
                    //    {

                    //        shorti[m++] = str.ToString();

                    //    }
                    //}
                    if (intshorti == 0)
                    {
                        if (!shortiflag)
                        {
                            duanResult.Append(shorti[0] + "," + shorti[1] + "," + shorti[3] + "\r\n");
                            shortiflag = true;
                        }

                    }
                    else
                        duanResult.Append(shorti[0] + "," + shorti[1] + "," + Convert.ToDouble(shorti[3]) + "\r\n");

                    intshorti++;
                   // wf.SetCaption(intshorti.ToString());
                }
                readLineGU.Close();
                if (OutType == 0)
                {
                    //**��ȡ�����ѹ��ֵ
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt"))
                    {
                    }
                    else
                    {
                        wFrom.ShowText += "\r\n��·����ʧ��\t" + System.DateTime.Now.ToString();
                        return;
                    }
                    FileStream dianYa = new FileStream(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt", FileMode.Open);
                    StreamReader readLineDY = new StreamReader(dianYa, System.Text.Encoding.Default);
                    string strLineDY;
                    string[] arrayDY;
                    char[] charSplitDY = new char[] { ' ' };
                    strLineDY = readLineDY.ReadLine();
                    int j = 0;
                    muxiannum = 0;
                    while (strLineDY != null)
                    {
                        arrayDY = strLineDY.Split(charSplitDY, StringSplitOptions.RemoveEmptyEntries);

                        //int m = 0;
                        string[] dev = arrayDY;
                        //dev.Initialize();
                        //foreach (string str in arrayDY)
                        //{
                        //    if (str != "")
                        //    {
                        //        dev[m++] = str;
                        //    }
                        //}
                        if (j == 0)
                        {
                            //dianYaResult += "\r\n" + "����ĸ�ߣ�" + pspDev.Name + "\r\n";
                            dianYaResult.Append(dev[0] + "," + dev[1] + "," + dev[2] + "," + dev[3] + "," + dev[4] + "," + dev[5] + "," + dev[6] + "," + dev[7] + "," + dev[8] + "," +
             dev[9] + "," + dev[10] + "," + dev[11] + "," + dev[12] + "," + dev[13] + "\r\n");
                        }
                        else
                        {
                            if (dev[0] == "����ĸ��")
                            {
                                dianYaResult.Append("\r\n" + "����ĸ�ߣ�" + dev[1] + "\r\n");
                                muxiannum++;
                            }
                            else
                            {
                                bool dianyaflag = true;     //�жϴ�ĸ���Ƕ�·��ĸ�߻���һ���ĸ��
                                PSPDEV CR = new PSPDEV();

                                if (dev[1] != "du")
                                {
                                    con = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='01'AND PSPDEV.Name='" + dev[1] + "'";
                                    //con = " WHERE Name='" + dev[1] + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'";
                                    CR = (PSPDEV)UCDeviceBase.DataService.GetObject("SelectPSPDEVByCondition", con);
                                    if (CR == null)
                                    {
                                        dianyaflag = false;
                                    }
                                }
                                //else
                                //{
                                //    dianyaflag = false;
                                //    CR.Name = duanluname;
                                //    CR = (PSPDEV)UCDeviceBase.DataService.GetObject("SelectPSPDEVByNameANDSVG", CR);
                                //}
                                if (dianyaflag)
                                    dianYaResult.Append(dev[0] + "," + dev[1] + "," + Convert.ToDouble(dev[2]) * CR.ReferenceVolt + "," + dev[3] + "," + Convert.ToDouble(dev[4]) * CR.ReferenceVolt + "," + dev[5] + "," + Convert.ToDouble(dev[6]) * CR.ReferenceVolt + "," + dev[7] + "," + Convert.ToDouble(dev[8]) * CR.ReferenceVolt + "," +
                                        dev[9] + "," + Convert.ToDouble(dev[10]) * CR.ReferenceVolt + "," + dev[11] + "," + Convert.ToDouble(dev[12]) * CR.ReferenceVolt + "," + dev[13] + "\r\n");
                                //else
                                //    dianYaResult.Append( dev[0] + "," + duanluname + "�϶�·��" + "," + Convert.ToDouble(dev[2]) * CR.ReferenceVolt + "," + dev[3] + "," + Convert.ToDouble(dev[4]) * CR.ReferenceVolt + "," + dev[5] + "," + Convert.ToDouble(dev[6]) * CR.ReferenceVolt + "," + dev[7] + "," + Convert.ToDouble(dev[8]) * CR.ReferenceVolt + "," +
                                //       dev[9] + "," + Convert.ToDouble(dev[10]) * CR.ReferenceVolt + "," + dev[11] + Convert.ToDouble(dev[12]) * CR.ReferenceVolt + "," + dev[13] + "\r\n";
                            }

                        }
                        strLineDY = readLineDY.ReadLine();

                        j++;
                        //wf.SetCaption(muxiannum.ToString());
                    }
                    readLineDY.Close();
                    //**��ȡ���������ֵ
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt"))
                    {
                    }
                    else
                    {
                        wFrom.ShowText += "\r\n��·����ʧ��\t" + System.DateTime.Now.ToString();
                        return;
                    }
                    FileStream dianLiu = new FileStream(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt", FileMode.Open);
                    StreamReader readLineDL = new StreamReader(dianLiu, System.Text.Encoding.Default);
                    string strLineDL;
                    string[] arrayDL;
                    char[] charSplitDL = new char[] { ' ' };
                    strLineDL = readLineDL.ReadLine();
                    j = 0;
                    int jxflag = 0;   //��¼��һ��ĸ�߶�·ʱ����·����
                    linenum = 0;
                    while (strLineDL != null)
                    {
                        arrayDL = strLineDL.Split(charSplitDL, StringSplitOptions.RemoveEmptyEntries);
                        int m = 0;
                        string[] dev = arrayDL;
                        //dev.Initialize();
                        //foreach (string str in arrayDL)
                        //{
                        //    if (str != "")
                        //    {
                        //        dev[m++] = str;
                        //    }
                        //}
                        if (j == 0)
                        {
                            //dianLiuResult.Append( "\r\n" + "����ĸ�ߣ�" + pspDev.Name + "\r\n";
                            dianLiuResult.Append(dev[0] + "," + dev[1] + "," + dev[2] + "," + dev[3] + "," + dev[4] + "," + dev[5] + "," + dev[6] + "," + dev[7] + "," + dev[8] + "," +
                                         dev[9] + "," + dev[10] + "," + dev[11] + "," + dev[12] + "," + dev[13] + "," + dev[14] + "\r\n");
                        }
                        else
                        {
                            if (dev[0] == "����ĸ��")
                            {
                                dianLiuResult.Append("\r\n" + "����ĸ�ߣ�" + dev[1] + "\r\n");
                                jxflag++;
                            }
                            else
                            {
                                PSPDEV CR = new PSPDEV();

                                if (dev[0] != "du")
                                {
                                    con = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='01'AND PSPDEV.Name='" + dev[0] + "'";
                                    //con = " WHERE Name='" + dev[0] + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'";
                                }
                                else
                                    con = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='01'AND PSPDEV.Name='" + dev[1] + "'";
                                    //con = " WHERE Name='" + dev[1] + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'";

                                CR = (PSPDEV)UCDeviceBase.DataService.GetObject("SelectPSPDEVByCondition", con);

                                dianLiuResult.Append(dev[0] + "," + dev[1] + "," + dev[2] + "," + Convert.ToDouble(dev[3]) * ratecaplity / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[4] + "," + Convert.ToDouble(dev[5]) * ratecaplity / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[6] + "," + Convert.ToDouble(dev[7]) * ratecaplity / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[8] + "," +
                                  Convert.ToDouble(dev[9]) * ratecaplity / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[10] + "," + Convert.ToDouble(dev[11]) * ratecaplity / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[12] + "," + Convert.ToDouble(dev[13]) * ratecaplity / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[14] + "\r\n");
                            }
                            //��Ϊ����·�������ʱ����һ����·�ĵ��������������������·�ĵ������нӵص������͵翹���ĵ��������ֻ���������������

                        }

                        strLineDL = readLineDL.ReadLine();
                        j++;
                        if (jxflag==1)
                        {
                            linenum++;
                        }

                       // wf.SetCaption(linenum.ToString());
                    }
                    readLineDL.Close();

                }
                wFrom.ShowText += "\r\n��ʼ���ɱ���\t" + System.DateTime.Now.ToString();
                //д�뱨����
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result.csv"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\result.csv");
                }
                FileStream tempGU = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result.csv"), FileMode.OpenOrCreate);
                StreamWriter strGU = new StreamWriter(tempGU, Encoding.Default);
                strGU.Write(duanResult.ToString());
                strGU.Close();
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result1.csv"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\result1.csv");
                }
                FileStream tempDY = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result1.csv"), FileMode.OpenOrCreate);
                StreamWriter strDY = new StreamWriter(tempDY, Encoding.Default);
                strDY.Write(dianYaResult.ToString());
                strDY.Close();
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result2.csv"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\result2.csv");
                }
                FileStream tempDL = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result2.csv"), FileMode.OpenOrCreate);
                StreamWriter strDL = new StreamWriter(tempDL, Encoding.Default);
                strDL.Write(dianLiuResult);
                strDL.Close();
                PSP_ELCPROJECT psproject = new PSP_ELCPROJECT();
                psproject.ID = projectSUID;
                psproject = (PSP_ELCPROJECT)UCDeviceBase.DataService.GetObject("SelectPSP_ELCPROJECTByKey", psproject);
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\" + psproject.Name + "ȫ����·������.xls"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\" + psproject.Name + "ȫ����·������.xls");
                }

                Excel.Application ex;
                Excel.Worksheet xSheet;
                Excel.Application result1;
                Excel.Application result2;
                Excel.Worksheet tempSheet;
                Excel.Worksheet tempSheet1;
                Excel.Worksheet newWorksheet;
                Excel.Worksheet newWorkSheet1;

                object oMissing = System.Reflection.Missing.Value;
                ex = new Excel.Application();
                ex.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result.csv");

                xSheet = (Excel.Worksheet)ex.Worksheets[1];

                xSheet.Name = "��·����";
                ex.Visible = true;

                xSheet.UsedRange.Font.Name = "����_GB2312";

                //��¼��Ϊ��·������ʽ
                xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 3]).MergeCells = true;
                xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Size = 20;
                xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Name = "����";
                xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                xSheet.get_Range(xSheet.Cells[6, 1], xSheet.Cells[6, 3]).Interior.ColorIndex = 45;
                xSheet.get_Range(xSheet.Cells[7, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6;
                xSheet.get_Range(xSheet.Cells[4, 3], xSheet.Cells[xSheet.UsedRange.Rows.Count, 13]).NumberFormat = "0.0000_ ";
                if (muxiannum>50)
                {
                    if (OutType == 0)
                    {
                         if (MessageBox.Show("����ʾ�����ѹʱ���ܵ����ݳ����˱���ij��ܷ�Χ��ѡ���Ƿ����?", "��ʾ", MessageBoxButtons.YesNo, MessageBoxIcon.Information) != DialogResult.Yes)
                     {
                         OutType=1;
                     }
                    }

                }
                if (OutType == 0)
                {
                    ex.Worksheets.Add(System.Reflection.Missing.Value, xSheet, 1, System.Reflection.Missing.Value);
                    xSheet = (Excel.Worksheet)ex.Worksheets[2];
                    ex.Worksheets.Add(System.Reflection.Missing.Value, xSheet, 1, System.Reflection.Missing.Value);
                    xSheet = (Excel.Worksheet)ex.Worksheets[1];
                    result1 = new Excel.Application();
                    result1.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result1.csv");
                    result2 = new Excel.Application();
                    result2.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result2.csv");
                    tempSheet = (Excel.Worksheet)result1.Worksheets.get_Item(1);
                    tempSheet1 = (Excel.Worksheet)result2.Worksheets.get_Item(1);
                    newWorksheet = (Excel.Worksheet)ex.Worksheets.get_Item(2);
                    newWorkSheet1 = (Excel.Worksheet)ex.Worksheets.get_Item(3);
                    newWorksheet.Name = "ĸ�ߵ�ѹ";
                    newWorkSheet1.Name = "֧·����";
                    tempSheet.Cells.Select();
                    tempSheet.Cells.Copy(System.Reflection.Missing.Value);
                    newWorksheet.Paste(System.Reflection.Missing.Value, System.Reflection.Missing.Value);
                    tempSheet1.Cells.Select();
                    tempSheet1.Cells.Copy(System.Reflection.Missing.Value);
                    newWorkSheet1.Paste(System.Reflection.Missing.Value, System.Reflection.Missing.Value);
                    newWorksheet.UsedRange.Font.Name = "����_GB2312";
                    newWorkSheet1.UsedRange.Font.Name = "����_GB2312";
                    //ĸ�ߵ�ѹ��ʾ��ʽ
                    newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 14]).MergeCells = true;
                    newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).Font.Size = 20;
                    newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).Font.Name = "����";
                    newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                    if (OutType == 0)
                    {
                        for (int m = 0; m < muxiannum ; m++)
                        {
                            newWorksheet.get_Range(newWorksheet.Cells[m * (muxiannum + 2) + 8, 1], newWorksheet.Cells[m * (muxiannum + 2) + 8, 14]).Interior.ColorIndex = 45;
                            newWorksheet.get_Range(newWorksheet.Cells[m * (muxiannum + 2) + 9, 1], newWorksheet.Cells[m * (muxiannum + 2) + 8 + muxiannum, 1]).Interior.ColorIndex = 6;
                            newWorksheet.get_Range(newWorksheet.Cells[m * (muxiannum + 2) + 9, 3], newWorksheet.Cells[m * (muxiannum + 2) + 8 + muxiannum - 1, 13]).NumberFormat = "0.0000_ ";
                        }

                    }

                    ////��·�����������ʾ��ʽ
                    newWorkSheet1.get_Range(newWorkSheet1.Cells[1, 1], newWorkSheet1.Cells[1, 15]).MergeCells = true;
                    newWorkSheet1.get_Range(newWorkSheet1.Cells[1, 1], newWorkSheet1.Cells[1, 1]).Font.Size = 20;
                    newWorkSheet1.get_Range(newWorkSheet1.Cells[1, 1], newWorkSheet1.Cells[1, 1]).Font.Name = "����";
                    newWorkSheet1.get_Range(newWorkSheet1.Cells[1, 1], newWorkSheet1.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                    if (OutType == 0)
                    {
                        for (int m = 0; m < muxiannum; m++)
                        {
                            newWorkSheet1.get_Range(newWorkSheet1.Cells[m * (linenum-1 + 2) + 8, 1], newWorkSheet1.Cells[m * (linenum-1 + 2) + 8, 15]).Interior.ColorIndex = 45;
                            newWorkSheet1.get_Range(newWorkSheet1.Cells[m * (linenum - 1 + 2) + 9, 1], newWorkSheet1.Cells[m * (linenum - 1 + 2) + 8 + linenum - 1, 1]).Interior.ColorIndex = 6;
                            newWorkSheet1.get_Range(newWorkSheet1.Cells[m * (linenum - 1 + 2) + 9, 2], newWorkSheet1.Cells[m * (linenum - 1 + 2) + 8 + linenum - 1, 2]).Interior.ColorIndex = 6;
                            newWorkSheet1.get_Range(newWorkSheet1.Cells[m * (linenum - 1 + 2) + 9, 3], newWorkSheet1.Cells[m * (linenum - 1 + 2) + 8 + linenum - 1, 3]).Interior.ColorIndex = 6;
                            newWorkSheet1.get_Range(newWorkSheet1.Cells[m * (linenum - 1 + 2) + 9, 4], newWorkSheet1.Cells[m * (linenum - 1 + 2) + 8 + linenum - 1, 14]).NumberFormat = "0.0000_ ";
                        }
                    }
                    System.Windows.Forms.Clipboard.Clear();
                    newWorksheet.Rows.AutoFit();
                    newWorksheet.Columns.AutoFit();
                    newWorkSheet1.Rows.AutoFit();
                    newWorkSheet1.Columns.AutoFit();
                    newWorksheet.SaveAs(System.Windows.Forms.Application.StartupPath + "\\" + psproject.Name + "ȫ����·������.xls", Excel.XlFileFormat.xlXMLSpreadsheet, null, null, false, false, false, null, null, null);
                    result1.Workbooks.Close();
                    result1.Quit();
                    result2.Workbooks.Close();
                    result2.Quit();
                }

                xSheet.Rows.AutoFit();
                xSheet.Columns.AutoFit();

                System.Windows.Forms.Clipboard.Clear();
                ex.DisplayAlerts = false;

                wFrom.ShowText += "\r\n��·�������\t" + System.DateTime.Now.ToString();
            }
            catch (System.Exception ex)
            {
                wFrom.ShowText += "\r\n��·����ʧ��\t" + System.DateTime.Now.ToString();
                MessageBox.Show("��·���ݴ������⣬�迹���󲻴��ڻ��ߴ��ڹ����ڵ㣬���֤���ٽ��У�");
            }
        }