Пример #1
0
        public bool LFCER(string projectSUID, int type, float ratedCapacity)
        {
            frnReport wForm = new frnReport();
            switch(type)
            {
                case 1:
                    wForm.Text = "牛拉法潮流计算";
                    break;
                case 2:
                    wForm.Text = "PQ分解法潮流计算";
                    break;
                case 3:
                    wForm.Text = "高斯—赛德尔法计算潮流计算";
                    break;
                case 4:
                    wForm.Text = "最优乘子法潮流计算";
                    break;
                default:
                    wForm.Text = "潮流计算";
                    break;
            }
            wForm.Show();
            wForm.ShowText += "选择结果输出方式\t" + System.DateTime.Now.ToString();
            bool flag = false;
            int iResult = 0;
            frmSelectSub frmSub = new frmSelectSub();
            frmSub.ShowDialog();
            if (frmSub.DialogResult==DialogResult.OK)
            {
                iResult = frmSub.SelectSub;
            }
            else if (frmSub.DialogResult== DialogResult.Cancel)
            {
                wForm.Close();
                return false;
            }
            System.Windows.Forms.Clipboard.Clear();
            flag = LFC(projectSUID, type, ratedCapacity,wForm);
            if (flag == false)
            {
                wForm.ShowText += "\r\n潮流计算结果不收敛,请检查数据\t" + System.DateTime.Now.ToString();
                wForm.ShowText += "\r\n计算失败\t" + System.DateTime.Now.ToString();
                return false;
            }
            try
            {
                if (type == 1)
                {
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\" + projectSUID + "牛拉法计算结果.xls"))
                    {
                        //System.Diagnostics.Process.Start(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "线损计算结果.xls");
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\" + projectSUID + "牛拉法计算结果.xls");
                        //OpenRead(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + ".xls");
                    }
                }
                else if (type == 2)
                {
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\" + projectSUID + "PQ分解法计算结果.xls"))
                    {
                        //System.Diagnostics.Process.Start(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "线损计算结果.xls");
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\" + projectSUID + "PQ分解法计算结果.xls");
                        //OpenRead(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + ".xls");
                    }

                }
                else if (type == 3)
                {
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\" + projectSUID + "高斯—赛德尔法计算结果.xls"))
                    {
                        //System.Diagnostics.Process.Start(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "线损计算结果.xls");
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\" + projectSUID + "高斯—赛德尔法计算结果.xls");
                        //OpenRead(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + ".xls");
                    }

                }
                else if (type == 4)
                {
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\" + projectSUID + "最优乘子法计算结果.xls"))
                    {
                        //System.Diagnostics.Process.Start(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "线损计算结果.xls");
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\" + projectSUID + "最优乘子法计算结果.xls");
                        //OpenRead(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + ".xls");
                    }
                }
                else if (type == 5)
                {
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\" + projectSUID + "配网潮流计算结果.xls"))
                    {
                        //System.Diagnostics.Process.Start(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "线损计算结果.xls");
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\" + projectSUID + "配网潮流计算结果.xls");
                        //OpenRead(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + ".xls");
                    }
                }

                wForm.ShowText += "\r\n正在形成报表\t" + System.DateTime.Now.ToString();

                string output = null;
                output += ("全网母线(发电、负荷)结果报表 " + "\r\n" + "\r\n");
                output += ("单位:kA\\kV\\MW\\Mvar" + "\r\n" + "\r\n");
                output += ("计算日期:" + System.DateTime.Now.ToString() + "\r\n" + "\r\n");
                output += ("母线名" + "," + "电压幅值" + "," + "电压相角" + "," + "有功发电" + "," + "无功发电" + "," + "有功负荷" + "," + "无功负荷" + "," + "越限标志" + "," + "过载标志" + "\r\n");
                string strCon = ",PSPDEV WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'" + " AND PSPDEV.Type = '01' order by PSPDEV.RateVolt,PSPDEV.Name";
                IList list = Services.BaseService.GetList("SelectPSP_ElcDeviceByCondition", strCon);
                foreach (PSP_ElcDevice elcDEV in list)
                {
                    PSPDEV dev = new PSPDEV();
                    dev.SUID = elcDEV.DeviceSUID;
                    dev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", dev);
                    //double vTemp = Convert.ToDouble(GetColValue(elcDEV,type-1));
                    //double vTemp1 =  TLPSPVmin * dev.RateVolt;
                    //double vTemp2 =  TLPSPVmax * dev.RateVolt;
                    string voltF = "否";
                    string pF = "否";
                    if (dev.KSwitchStatus=="1")
                    {
                        continue;
                    }
                    if (Convert.ToDouble(GetColValue(elcDEV, type - 1).COL2) < dev.iV || Convert.ToDouble(GetColValue(elcDEV, type - 1).COL2) > dev.jV)
                    {
                        voltF = "是";
                    }
                    double tempi = Convert.ToDouble(GetColValue(elcDEV, type - 1).COL4);
                    double tempj = Convert.ToDouble(GetColValue(elcDEV, type - 1).COL5);
                    double temptotal = Math.Sqrt(tempi * tempi + tempj * tempj);
                    if (temptotal > (double)dev.Burthen)
                    {
                        pF = "是";
                    }

                    if (Convert.ToDouble(GetColValue(elcDEV, type - 1).COL4) > 0)
                    {
                        if (iResult == 0)
                        {
                            output += dev.Name + "," + Convert.ToDouble(GetColValue(elcDEV, type - 1).COL2).ToString() + "," + Convert.ToDouble(GetColValue(elcDEV, type - 1).COL3).ToString() + "," + Convert.ToDouble(GetColValue(elcDEV, type - 1).COL4).ToString() + "," + Convert.ToDouble(GetColValue(elcDEV, type - 1).COL5).ToString() + "," + "0" + "," + "0" + "," + voltF + "," + pF + "\r\n";
                        }
                        else
                        {
                            object obj = DeviceHelper.GetDevice<PSP_Substation_Info>(dev.SvgUID);

                            if (obj != null)
                            {
                                output += ((PSP_Substation_Info)obj).Title + "," + Convert.ToDouble(GetColValue(elcDEV, type - 1).COL2).ToString() + "," + Convert.ToDouble(GetColValue(elcDEV, type - 1).COL3).ToString() + "," + Convert.ToDouble(GetColValue(elcDEV, type - 1).COL4).ToString() + "," + Convert.ToDouble(GetColValue(elcDEV, type - 1).COL5).ToString() + "," + "0" + "," + "0" + "," + voltF + "," + pF + "\r\n";

                            }
                            else
                            {
                                obj = DeviceHelper.GetDevice<PSP_PowerSubstation_Info>(dev.SvgUID);
                                if (obj != null)
                                {
                                    output += ((PSP_PowerSubstation_Info)obj).Title + "," + Convert.ToDouble(GetColValue(elcDEV, type - 1).COL2).ToString() + "," + Convert.ToDouble(GetColValue(elcDEV, type - 1).COL3).ToString() + "," + Convert.ToDouble(GetColValue(elcDEV, type - 1).COL4).ToString() + "," + Convert.ToDouble(GetColValue(elcDEV, type - 1).COL5).ToString() + "," + "0" + "," + "0" + "," + voltF + "," + pF + "\r\n";

                                }
                            }

                        }
                    }
                    else
                    {
                        if (iResult == 0)
                        {
                            output += dev.Name + "," + Convert.ToDouble(GetColValue(elcDEV, type - 1).COL2).ToString() + "," + Convert.ToDouble(GetColValue(elcDEV, type - 1).COL3).ToString() + "," + "0" + "," + "0" + "," + Convert.ToDouble(GetColValue(elcDEV, type - 1).COL4).ToString() + "," + Convert.ToDouble(GetColValue(elcDEV, type - 1).COL5).ToString() + "," + voltF + "," + pF + "\r\n";
                        }
                        else
                        {
                            object obj = DeviceHelper.GetDevice<PSP_Substation_Info>(dev.SvgUID);

                            if (obj != null)
                            {
                                output += ((PSP_Substation_Info)obj).Title + "," + Convert.ToDouble(GetColValue(elcDEV, type - 1).COL2).ToString() + "," + Convert.ToDouble(GetColValue(elcDEV, type - 1).COL3).ToString() + "," + "0" + "," + "0" + "," + Convert.ToDouble(GetColValue(elcDEV, type - 1).COL4).ToString() + "," + Convert.ToDouble(GetColValue(elcDEV, type - 1).COL5).ToString() + "," + voltF + "," + pF + "\r\n";

                            }
                            else
                            {
                                obj = DeviceHelper.GetDevice<PSP_PowerSubstation_Info>(dev.SvgUID);
                                if (obj != null)
                                {
                                    output += ((PSP_PowerSubstation_Info)obj).Title + "," + Convert.ToDouble(GetColValue(elcDEV, type - 1).COL2).ToString() + "," + Convert.ToDouble(GetColValue(elcDEV, type - 1).COL3).ToString() + "," + "0" + "," + "0" + "," + Convert.ToDouble(GetColValue(elcDEV, type - 1).COL4).ToString() + "," + Convert.ToDouble(GetColValue(elcDEV, type - 1).COL5).ToString() + "," + voltF + "," + pF + "\r\n";

                                }
                            }

                        }
                    }
                }

                try
                {
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result.csv"))
                    {
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\result.csv");
                    }
                }
                catch (System.Exception ex2)
                {
                    MessageBox.Show("请关闭相关Excel后再查看结果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                FileStream op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result.csv"), FileMode.OpenOrCreate);
                StreamWriter str1 = new StreamWriter(op, Encoding.Default);
                str1.Write(output);
                str1.Close();

                output = null;

                output += ("全网交流线结果报表" + "\r\n" + "\r\n");
                output += ("单位:kA\\kV\\MW\\Mvar" + "\r\n" + "\r\n");
                output += ("计算日期:" + System.DateTime.Now.ToString() + "\r\n" + "\r\n");
                output += ("支路名称" + "," + "支路有功" + "," + "支路无功" + "," + "有功损耗" + "," + "无功损耗" + "," + "电流幅值" + "," + "电流相角" + "," + "越限标志" + "," + "\r\n");

                string strCon1 = ",PSPDEV WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'" + " AND PSPDEV.Type = '05'  order by PSPDEV.RateVolt,PSPDEV.Name";
                IList list1 = Services.BaseService.GetList("SelectPSP_ElcDeviceByCondition", strCon1);

                foreach (PSP_ElcDevice elcDEV in list1)
                {
                    PSPDEV dev = new PSPDEV();
                    dev.SUID = elcDEV.DeviceSUID;
                    dev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", dev);
                    string lineF = "否";
                    if (dev.KSwitchStatus == "1")
                    {
                        continue;
                    }
                    if (Convert.ToDouble(GetColValue(elcDEV, type - 1).COL14)*1000 > (double)dev.Burthen)
                    {
                        lineF = "是";
                    }
                    //double vTemp = Convert.ToDouble(GetColValue(elcDEV,type-1));
                    //double vTemp1 =  TLPSPVmin * dev.RateVolt;
                    //double vTemp2 =  TLPSPVmax * dev.RateVolt;
                    output += dev.Name.ToString() + "," + Convert.ToDouble(GetColValue(elcDEV, type - 1).COL4).ToString() + "," + Convert.ToDouble(GetColValue(elcDEV, type - 1).COL5).ToString() + "," + Convert.ToDouble(GetColValue(elcDEV, type - 1).COL6).ToString() + "," + Convert.ToDouble(GetColValue(elcDEV, type - 1).COL7).ToString() + "," + Convert.ToDouble(GetColValue(elcDEV, type - 1).COL14).ToString() + "," + Convert.ToDouble(GetColValue(elcDEV, type - 1).COL15).ToString() + "," + lineF + "," + "\r\n";
                }
                try
                {
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result1.csv"))
                    {
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\result1.csv");
                    }
                }
                catch (System.Exception ex3)
                {
                    MessageBox.Show("请关闭相关Excel后再查看结果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result1.csv"), FileMode.OpenOrCreate);
                str1 = new StreamWriter(op, Encoding.Default);
                str1.Write(output);
                str1.Close();
                Excel.Application ex;
                Excel.Worksheet xSheet;
                Excel.Application result1;
                Excel.Worksheet tempSheet;
                Excel.Worksheet newWorksheet;
                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);

                result1 = new Excel.Application();
                result1.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result1.csv");
                tempSheet = (Excel.Worksheet)result1.Worksheets.get_Item(1);
                newWorksheet = (Excel.Worksheet)ex.Worksheets.get_Item(2);
                newWorksheet.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);

                xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 9]).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[7, 1], xSheet.Cells[7, 9]).Interior.ColorIndex = 45;
                xSheet.get_Range(xSheet.Cells[8, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6;
                xSheet.get_Range(xSheet.Cells[8, 2], xSheet.Cells[xSheet.UsedRange.Rows.Count, 9]).NumberFormat = "0.0000_ ";
                xSheet.get_Range(xSheet.Cells[3, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 9]).Font.Name = "楷体_GB2312";
                //xSheet.get_Range(xSheet.Cells[3, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 1]).NumberFormatLocal = "@";

                newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 9]).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;
                newWorksheet.get_Range(newWorksheet.Cells[7, 1], newWorksheet.Cells[7, 8]).Interior.ColorIndex = 45;
                newWorksheet.get_Range(newWorksheet.Cells[8, 1], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6;
                // newWorksheet.get_Range(newWorksheet.Cells[6, 1], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 1]).NumberFormatLocal = "@";
                newWorksheet.get_Range(newWorksheet.Cells[8, 2], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 9]).NumberFormat = "0.0000_ ";
                newWorksheet.get_Range(newWorksheet.Cells[3, 1], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 9]).Font.Name = "楷体_GB2312";

                //op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fck.excel"), FileMode.OpenOrCreate);
                //str1 = new StreamWriter(op, Encoding.Default);
                xSheet.Rows.AutoFit();
                xSheet.Columns.AutoFit();
                newWorksheet.Rows.AutoFit();
                newWorksheet.Columns.AutoFit();

                //result1.Save(System.Windows.Forms.Application.StartupPath + "\\fck.xls");

                if (type == 1)
                {
                    newWorksheet.SaveAs(System.Windows.Forms.Application.StartupPath + "\\" + projectSUID + "牛拉法计算结果.xls", Excel.XlFileFormat.xlXMLSpreadsheet, null, null, false, false, false, null, null, null);
                }
                else if (type == 2)
                {
                    newWorksheet.SaveAs(System.Windows.Forms.Application.StartupPath + "\\" + projectSUID + "PQ分解法计算结果.xls", Excel.XlFileFormat.xlXMLSpreadsheet, null, null, false, false, false, null, null, null);
                }
                else if (type == 3)
                {
                    newWorksheet.SaveAs(System.Windows.Forms.Application.StartupPath + "\\" + projectSUID + "高斯—赛德尔法计算结果.xls", Excel.XlFileFormat.xlXMLSpreadsheet, null, null, false, false, false, null, null, null);
                }
                else if (type == 4)
                {
                    newWorksheet.SaveAs(System.Windows.Forms.Application.StartupPath + "\\" + projectSUID + "最优乘子法计算结果.xls", Excel.XlFileFormat.xlXMLSpreadsheet, null, null, false, false, false, null, null, null);
                }
                else if (type == 5)
                {
                    newWorksheet.SaveAs(System.Windows.Forms.Application.StartupPath + "\\" + projectSUID + "配网潮流计算结果.xls", Excel.XlFileFormat.xlXMLSpreadsheet, null, null, false, false, false, null, null, null);
                }
                System.Windows.Forms.Clipboard.Clear();
                result1.Workbooks.Close();
                result1.Quit();

            }
            catch (System.Exception ex)
            {
                wForm.ShowText += "\r\n计算失败\t" + System.DateTime.Now.ToString();
                return false;
            }
            wForm.ShowText += "\r\n计算成功\t" + System.DateTime.Now.ToString();
            return flag;
        }
Пример #2
0
        public bool ORP(string projectSUID, float ratedCapacity)
        {
            frnReport wFrom = new frnReport();
            try
            {

                wFrom.Text = "无功优化";
                wFrom.Show();
                string strCon1 = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "' AND KSwitchStatus ='0'";
                string strCon2 = null;
                string strCon = null;
                string strData = null;
                string strBus = null;
                string strBranch = null;
                wFrom.ShowText += "正在准备数据\t" + System.DateTime.Now.ToString();
                double Rad_to_Deg = 180 / Math.PI;
                {
                    strCon2 = " AND Type = '01'";
                    strCon = strCon1 + strCon2;
                    IList listMX = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                    strCon2 = " AND Type = '05'";
                    strCon = strCon1 + strCon2;
                    IList listXL = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                    strCon2 = " AND Type = '02'";
                    strCon = strCon1 + strCon2;
                    IList listBYQ2 = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                    strCon2 = " AND Type = '03'";
                    strCon = strCon1 + strCon2;
                    IList listBYQ3 = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                    strData += (listXL.Count + listBYQ2.Count + listBYQ3.Count * 3).ToString() + " " + listMX.Count.ToString() + " " + listMX.Count.ToString() + " " + "0.00001" + " " + "100" + " " + "0" + " " + "0";
                    foreach (PSPDEV dev in listXL)
                    {
                        if (dev.KSwitchStatus == "0")
                        {
                            if (strBranch != null)
                            {
                                strBranch += "\r\n";
                            }
                            if (dev.FirstNode == dev.LastNode)
                            {
                                if (dev.UnitFlag == "0")
                                {
                                    strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "3" + " " + dev.LineR.ToString() + " " + dev.LineTQ.ToString() + " " + (dev.LineGNDC * 2).ToString() + " " + "0" + " " + "0" + " " + dev.iV.ToString() + " " + dev.jV.ToString();

                                }
                                else
                                {
                                    strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "3" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineGNDC * 2 * dev.ReferenceVolt * dev.ReferenceVolt / (ratedCapacity * 1000000)).ToString() + " " + "0" + " " + "0" + " " + (dev.iV / ratedCapacity).ToString() + " " + (dev.jV / ratedCapacity).ToString();

                                }
                            }
                            else
                            {
                                if (dev.UnitFlag == "0")
                                {
                                    strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "1" + " " + dev.LineR.ToString() + " " + dev.LineTQ.ToString() + " " + (dev.LineGNDC * 2).ToString() + " " + "0" + " " + "0" + " " + "0" + " " + "0";

                                }
                                else
                                {
                                    strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "1" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineGNDC * 2 * dev.ReferenceVolt * dev.ReferenceVolt / (ratedCapacity * 1000000)).ToString() + " " + "0" + " " + "0" + " " + "0" + " " + "0";

                                }
                            }
                        }
                    }
                    foreach (PSPDEV dev in listBYQ2)
                    {
                        if (dev.KSwitchStatus == "0")
                        {
                            if (strBranch != null)
                            {
                                strBranch += "\r\n";
                            }
                            if (dev.UnitFlag == "0")
                            {
                                strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + dev.LineR.ToString() + " " + dev.LineTQ.ToString() + " " + (dev.LineGNDC * 2).ToString() + " " + dev.K.ToString() + " " + dev.G.ToString() + " " + dev.iV.ToString() + " " + dev.jV.ToString();

                            }
                            else
                            {
                                strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineGNDC * 2 * dev.ReferenceVolt * dev.ReferenceVolt / (ratedCapacity * 1000000)).ToString() + " " + dev.K.ToString() + " " + dev.G.ToString() + " " + dev.iV.ToString() + " " + dev.jV.ToString();

                            }
                        }
                    }
                    foreach (PSPDEV dev in listBYQ3)
                    {
                        if (dev.KSwitchStatus == "0")
                        {

                            if (dev.UnitFlag == "0")
                            {
                                if (strBranch != null)
                                {
                                    strBranch += "\r\n";
                                }
                                strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + dev.HuganTQ1.ToString() + " " + dev.HuganTQ4.ToString() + " " + "0" + " " + dev.K.ToString() + " " + dev.G.ToString() + " " + dev.iV.ToString() + " " + dev.jV.ToString();
                                if (strBranch != null)
                                {
                                    strBranch += "\r\n";
                                }
                                strBranch += dev.LastNode.ToString() + " " + dev.Flag.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + dev.HuganTQ2.ToString() + " " + dev.HuganTQ5.ToString() + " " + "0" + " " + dev.StandardCurrent.ToString() + " " + dev.G.ToString() + " " + dev.iV.ToString() + " " + dev.jV.ToString();
                                if (strBranch != null)
                                {
                                    strBranch += "\r\n";
                                }
                                strBranch += dev.FirstNode.ToString() + " " + dev.Flag.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + dev.HuganTQ3.ToString() + " " + dev.ZeroTQ.ToString() + " " + "0" + " " + dev.BigP.ToString() + " " + dev.G.ToString() + " " + dev.iV.ToString() + " " + dev.jV.ToString();

                            }
                            else
                            {
                                if (strBranch != null)
                                {
                                    strBranch += "\r\n";
                                }
                                strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + (dev.HuganTQ1 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.HuganTQ4 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + "0" + " " + dev.K.ToString() + " " + dev.G.ToString() + " " + dev.iV.ToString() + " " + dev.jV.ToString();
                                if (strBranch != null)
                                {
                                    strBranch += "\r\n";
                                }
                                strBranch += dev.LastNode.ToString() + " " + dev.Flag.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + (dev.HuganTQ2 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.HuganTQ5 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + "0" + " " + dev.StandardCurrent.ToString() + " " + dev.G.ToString() + " " + dev.iV.ToString() + " " + dev.jV.ToString();
                                if (strBranch != null)
                                {
                                    strBranch += "\r\n";
                                }
                                strBranch += dev.FirstNode.ToString() + " " + dev.Flag.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + (dev.HuganTQ3 * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.ZeroTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + "0" + " " + dev.BigP.ToString() + " " + dev.G.ToString() + " " + dev.iV.ToString() + " " + dev.jV.ToString();

                            }
                        }
                    }
                    foreach (PSPDEV dev in listMX)
                    {
                        if (dev.KSwitchStatus == "0")
                        {
                            if (strBus != null)
                            {
                                strBus += "\r\n";
                            }
                                                        double outP = 0;
                            double outQ = 0;
                            double inputP = 0;
                            double inputQ = 0;
                            string strCon3 = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "' AND Type = '04' AND IName = '" + dev.Name + "'";
                            IList listFDJ = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon3);
                            string strCon4 = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "' AND Type = '12' AND IName = '" + dev.Name + "'";
                            IList listFH = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon4);
                            foreach (PSPDEV devFDJ in listFDJ)
                            {
                                if (devFDJ.UnitFlag == "0")
                                {
                                    outP += devFDJ.OutP;
                                    outQ += devFDJ.OutQ;
                                }
                                else
                                {
                                    outP += devFDJ.OutP / ratedCapacity;
                                    outQ += devFDJ.OutQ / ratedCapacity;
                                }
                            }
                            foreach (PSPDEV devFH in listFH)
                            {
                                if (devFH.UnitFlag == "0")
                                {
                                    inputP += devFH.InPutP;
                                    inputQ += devFH.InPutQ;
                                }
                                else
                                {
                                    inputP += devFH.InPutP / ratedCapacity;
                                    inputQ += devFH.InPutQ / ratedCapacity;
                                }
                            }
                            //if (mxflag.ContainsKey(dev.SUID))
                            //{
                            //    gltj tj = mxflag[dev.SUID];
                            //    outP += tj.outP;
                            //    outQ += tj.outQ;
                            //    inputP += tj.inputP;
                            //    inputQ += tj.inputQ;
                            //}

                            if (dev.UnitFlag == "0")
                            {
                                outP += dev.OutP;
                                outQ += dev.OutQ;
                                inputP += dev.InPutP;
                                inputQ += dev.InPutQ;
                                strBus += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + MXNodeType(dev.NodeType) + " " + (dev.VoltR).ToString() + " " + dev.VoltV.ToString() + " " + ((outP)).ToString() + " " + ((outQ)).ToString() + " " + ((inputP)).ToString() + " " + ((inputQ)).ToString() + " " + dev.LineLevel.ToString() + " " + dev.LineType.ToString() + " " + ((dev.Vjmin)).ToString() + " " + ((dev.Vjmax)).ToString() + " " + ((dev.iV)).ToString() + " " + ((dev.jV)).ToString() + " " + ((dev.Vimin)).ToString() + " " + ((dev.Vimax)).ToString() + " " + ((dev.Vk0)).ToString());
                                //strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "0" + " " + (dev.LineR).ToString() + " " + (dev.LineTQ).ToString() + " " + (dev.LineGNDC).ToString() + " " + "0" + " " + dev.Name.ToString());

                            }
                            else
                            {
                                outP += dev.OutP/ratedCapacity;
                                outQ += dev.OutQ / ratedCapacity;
                                inputP += dev.InPutP / ratedCapacity;
                                inputQ += dev.InPutQ / ratedCapacity;
                                strBus += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + MXNodeType(dev.NodeType) + " " + (dev.VoltR / dev.ReferenceVolt).ToString() + " " + dev.VoltV.ToString() + " " + (outP).ToString() + " " + (outQ).ToString() + " " + (inputP).ToString() + " " + (inputQ).ToString() + " " + dev.LineLevel.ToString() + " " + dev.LineType.ToString() + " " + ((dev.Vjmin) / ratedCapacity).ToString() + " " + ((dev.Vjmax) / ratedCapacity).ToString() + " " + ((dev.iV) / dev.ReferenceVolt).ToString() + " " + ((dev.jV) / dev.ReferenceVolt).ToString() + " " + ((dev.Vimin) / ratedCapacity).ToString() + " " + ((dev.Vimax) / ratedCapacity).ToString() + " " + ((dev.Vk0) / ratedCapacity).ToString());
                                //strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "0" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + ((dev.LineGNDC) * dev.ReferenceVolt * dev.ReferenceVolt / (ratedCapacity * 1000000)).ToString() + " " + "0" + " " + dev.Name.ToString());

                            }
                        }
                    }
                }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\data.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\data.txt");
                }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\branch.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\branch.txt");
                }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\bus.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\bus.txt");
                }
                FileStream VK = new FileStream((System.Windows.Forms.Application.StartupPath + "\\data.txt"), FileMode.OpenOrCreate);
                StreamWriter strVK = new StreamWriter(VK, Encoding.Default);
                strVK.Write(strData);
                strVK.Close();

                FileStream VK1 = new FileStream((System.Windows.Forms.Application.StartupPath + "\\branch.txt"), FileMode.OpenOrCreate);
                StreamWriter strVK1 = new StreamWriter(VK1, Encoding.Default);
                strVK1.Write(strBranch);
                strVK1.Close();
                FileStream L = new FileStream((System.Windows.Forms.Application.StartupPath + "\\bus.txt"), FileMode.OpenOrCreate);
                StreamWriter strL = new StreamWriter(L, Encoding.Default);
                strL.Write(strBus);
                strL.Close();

                if (strBus.Contains("非数字") || strBus.Contains("正无穷大") || strBranch.Contains("非数字") || strBranch.Contains("正无穷大"))
                {
                    wFrom.ShowText += "\r\n缺少参数,计算失败\t" + System.DateTime.Now.ToString();
                    MessageBox.Show("缺少参数,请检查输入参数!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return false;
                }

                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Volt.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\Volt.txt");
                }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Transformer.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\Transformer.txt");
                }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Generator.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\Generator.txt");
                }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\GND.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\GND.txt");
                }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\busidle.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\busidle.txt");
                }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\branchidle.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\branchidle.txt");
                }
                wFrom.ShowText += "\r\n开始潮流计算\t" + System.DateTime.Now.ToString();
                NiuLaIdle niulaidle = new NiuLaIdle();
                niulaidle.CurrentCal();
                wFrom.ShowText += "\r\n根据潮流计算结果,开始进行无功优化计算\t" + System.DateTime.Now.ToString();
                IdleOptimize idlOptimize = new IdleOptimize();
                idlOptimize.Optimize();
                wFrom.ShowText += "\r\n开始处理计算结果,形成报表\t" + System.DateTime.Now.ToString();
                string outV = null;
                string outT = null;
                string outG = null;
                string outQC = null;
                FileStream dhoutV = new FileStream(System.Windows.Forms.Application.StartupPath + "\\Volt.txt", FileMode.Open);
                StreamReader readLineoutV = new StreamReader(dhoutV, Encoding.Default);

                FileStream dhoutT = new FileStream(System.Windows.Forms.Application.StartupPath + "\\Transformer.txt", FileMode.Open);
                StreamReader readLineoutT = new StreamReader(dhoutT, Encoding.Default);

                FileStream dhoutG = new FileStream(System.Windows.Forms.Application.StartupPath + "\\Generator.txt", FileMode.Open);
                StreamReader readLineoutG = new StreamReader(dhoutG, Encoding.Default);

                FileStream dhoutQC = new FileStream(System.Windows.Forms.Application.StartupPath + "\\GND.txt", FileMode.Open);
                StreamReader readLineoutQC = new StreamReader(dhoutQC, Encoding.Default);

                FileStream dhoutPQ = new FileStream(System.Windows.Forms.Application.StartupPath + "\\busidle.txt", FileMode.Open);
                StreamReader readLineoutPQ = new StreamReader(dhoutPQ, Encoding.Default);
                IList listGEN = new List<object>();
                IList listBUS = new List<object>();
                char[] charSplit = new char[] { ' ' };
                string strLine = readLineoutV.ReadLine();
                string[] arry;
                outV += ("电压调整表" + "\r\n" + "\r\n");
                outV += ("计算日期:" + System.DateTime.Now.ToString() + "\r\n" + "\r\n");
                outV += ("单位:KV" + "\r\n" + "\r\n");
                outV += ("母线名" + "," + "调整后电压" + "," + "调整前电压" + "," + "电压下限" + "," + "电压上限" + "\r\n");
                PSPDEV CR;
                double voltExcursion = 0;
                int numFlag = 0, numVolt = 0;
                int num = 0;
                string flag;
                while (strLine != null)
                {
                    arry = strLine.Split(charSplit);
                    strCon2 = " AND Type= '01' AND Name = '" + arry[0] + "'";
                    strCon = strCon1 + strCon2;
                    CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                    outV += arry[0] + "," + Convert.ToDouble(arry[1]) * CR.ReferenceVolt + "," + Convert.ToDouble(arry[2]) * CR.ReferenceVolt + "," + Convert.ToDouble(arry[3]) * CR.ReferenceVolt + "," + Convert.ToDouble(arry[4]) * CR.ReferenceVolt + "\r\n";

                    //voltExcursion = (Convert.ToDouble(arry[1]) * CR.ReferenceVolt - CR.RateVolt) / CR.RateVolt;
                    //flag = voltFlag(voltExcursion, CR.RateVolt);
                    if (Convert.ToDouble(arry[1]) >= Convert.ToDouble(arry[3]) && Convert.ToDouble(arry[1]) <= Convert.ToDouble(arry[4]))
                    {
                        numFlag++;
                    }
                    //voltExcursion = (Convert.ToDouble(arry[2]) * CR.ReferenceVolt - CR.RateVolt) / CR.RateVolt;
                    //flag = voltFlag(voltExcursion, CR.RateVolt);
                    if (Convert.ToDouble(arry[2]) >= Convert.ToDouble(arry[3]) && Convert.ToDouble(arry[2]) <= Convert.ToDouble(arry[4]))
                    {
                        numVolt++;
                    }
                    num++;
                    strLine = readLineoutV.ReadLine();
                }
                readLineoutV.Close();
                outV += "优化前电压合格率" + "," + (float)((float)numVolt / (float)num) + "\r\n";
                outV += "优化后电压合格率" + "," + (float)((float)numFlag / (float)num) + "\r\n";
                string strLineT = readLineoutT.ReadLine();
                string[] arryT;
                outT += ("变压器调整表" + "\r\n" + "\r\n");
                outT += ("计算日期:" + System.DateTime.Now.ToString() + "\r\n" + "\r\n");
                outT += ("单位:p.u." + "\r\n" + "\r\n");
                outT += ("I侧母线" + "," + "J侧母线" + "," + "支路名" + "," + "调整后变比" + "," + "调整前变比" + "," + "变比下限" + "," + "变比上限" + "\r\n");

                while (strLineT != null)
                {
                    arryT = strLineT.Split(charSplit);
                    outT += arryT[0] + "," + arryT[1] + "," + arryT[2] + "," + arryT[3] + "," + arryT[4] + "," + arryT[5] + "," + arryT[6] + "\r\n";
                    strLineT = readLineoutT.ReadLine();
                }
                readLineoutT.Close();

                string strLineG = readLineoutG.ReadLine();
                string[] arryG;
                outG += ("发电调整表" + "\r\n" + "\r\n");
                outG += ("计算日期:" + System.DateTime.Now.ToString() + "\r\n" + "\r\n");
                outG += ("单位:KV/MW/Mvar" + "\r\n" + "\r\n");
                outG += ("母线名" + "," + "控制类型" + "," + "调整后电压" + "," + "调整后有功" + "," + "调整后无功" + "," + "调整前电压" + "," + "调整前有功" + "," + "调整前无功" + "\r\n");

                while (strLineG != null)
                {
                    arryG = strLineG.Split(charSplit);
                    //arry = strLine.Split(charSplit);
                    strCon2 = " AND Type= '01' AND Name = '" + arryG[0] + "'";
                    strCon = strCon1 + strCon2;
                    CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                    outG += arryG[0] + "," + arryG[1] + "," + Convert.ToDouble(arryG[2]) * CR.ReferenceVolt + "," + Convert.ToDouble(arryG[3]) * ratedCapacity + "," + Convert.ToDouble(arryG[4]) * ratedCapacity + "," + Convert.ToDouble(arryG[5]) * CR.ReferenceVolt + "," + Convert.ToDouble(arryG[6]) * ratedCapacity + "," + Convert.ToDouble(arryG[7]) * ratedCapacity + "\r\n";
                    strLineG = readLineoutG.ReadLine();
                    listGEN.Add(arryG);
                }
                readLineoutG.Close();

                string strBUS = readLineoutPQ.ReadLine();
                string[] arryBUS;
                double OUTP = 0;
                double OUTQ = 0;
                double OUTP1 = 0;
                double OUTQ1 = 0;
                while (strBUS != null)
                {
                    arryBUS = strBUS.Split(charSplit, StringSplitOptions.RemoveEmptyEntries);
                    OUTP1 += Convert.ToDouble(arryBUS[7]) - Convert.ToDouble(arryBUS[5]);
                    OUTQ1 += Convert.ToDouble(arryBUS[8]) - Convert.ToDouble(arryBUS[6]);
                    strBUS = readLineoutPQ.ReadLine();
                }
                foreach (string[] ab in listGEN)
                {
                    OUTP += Convert.ToDouble(ab[3]) - Convert.ToDouble(ab[6]);
                    OUTQ += Convert.ToDouble(ab[4]) - Convert.ToDouble(ab[7]);
                }
                OUTP = Math.Abs(OUTP);
                OUTQ = Math.Abs(OUTQ);
                readLineoutPQ.Close();
               // outG += "优化前功率因数" + "," + OUTP1 / Math.Sqrt(OUTP1 * OUTP1 + OUTQ1 * OUTQ1) + "\r\n";
              //  outG += "优化后功率因数" + "," + (Math.Abs(OUTP1) + OUTP) / Math.Sqrt((Math.Abs(OUTP1) + OUTP) * (OUTP1 + OUTP) + (Math.Abs(OUTQ1) - OUTQ) * (Math.Abs(OUTQ1) - OUTQ)) + "\r\n";

                string strLineQC = readLineoutQC.ReadLine();
                string[] arryQC;
                outQC += ("无功补偿调整表" + "\r\n" + "\r\n");
                outQC += ("计算日期:" + System.DateTime.Now.ToString() + "\r\n" + "\r\n");
                outQC += ("单位:KV/Mvar" + "\r\n" + "\r\n");
                outQC += ("母线名" + "," + "支路名" + "," + "调整后电压" + "," + "补偿的电容" + "," + "补偿的电抗" + "," + "调整前电压" + "\r\n");

                while (strLineQC != null)
                {
                    arryQC = strLineQC.Split(charSplit);
                   // arry = strLine.Split(charSplit);
                    strCon2 = " AND Type= '01' AND Name = '" + arryQC[0] + "'";
                    strCon = strCon1 + strCon2;
                    CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                    outQC += arryQC[0] + "," + arryQC[1] + "," + Convert.ToDouble(arryQC[2]) * CR.ReferenceVolt + "," + Convert.ToDouble(arryQC[3]) * ratedCapacity + "," + Convert.ToDouble(arryQC[4]) * ratedCapacity + "," + Convert.ToDouble(arryQC[5]) * CR.ReferenceVolt + "\r\n";
                    strLineQC = readLineoutQC.ReadLine();
                }
                readLineoutQC.Close();

                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result1.csv"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\result1.csv");
                }
                FileStream temp1 = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result1.csv"), FileMode.OpenOrCreate);
                StreamWriter str1 = new StreamWriter(temp1, Encoding.Default);
                str1.Write(outV);
                str1.Close();

                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result2.csv"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\result2.csv");
                }
                FileStream temp2 = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result2.csv"), FileMode.OpenOrCreate);
                StreamWriter str2 = new StreamWriter(temp2, Encoding.Default);
                str2.Write(outT);
                str2.Close();
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result3.csv"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\result3.csv");
                }
                FileStream temp3 = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result3.csv"), FileMode.OpenOrCreate);
                StreamWriter str3 = new StreamWriter(temp3, Encoding.Default);
                str3.Write(outG);
                str3.Close();

                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result4.csv"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\result4.csv");
                }
                FileStream temp4 = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result4.csv"), FileMode.OpenOrCreate);
                StreamWriter str4 = new StreamWriter(temp4, Encoding.Default);
                str4.Write(outQC);
                str4.Close();

                Excel.Application result1 = new Excel.Application();
                result1.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result1.csv");
                Excel.Worksheet xSheet1 = (Excel.Worksheet)result1.Worksheets[1];
                result1.Worksheets.Add(System.Reflection.Missing.Value, xSheet1, 3, System.Reflection.Missing.Value);

                Excel.Application result2 = new Excel.Application();
                result2.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result2.csv");
                Excel.Worksheet tempSheet2 = (Excel.Worksheet)result2.Worksheets.get_Item(1);
                Excel.Application result3 = new Excel.Application();
                result3.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result3.csv");
                Excel.Worksheet tempSheet3 = (Excel.Worksheet)result3.Worksheets.get_Item(1);
                Excel.Application result4 = new Excel.Application();
                result4.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result4.csv");
                Excel.Worksheet tempSheet4 = (Excel.Worksheet)result4.Worksheets.get_Item(1);
                Excel.Worksheet newWorksheet2 = (Excel.Worksheet)result1.Worksheets.get_Item(2);
                Excel.Worksheet newWorksheet3 = (Excel.Worksheet)result1.Worksheets.get_Item(3);
                Excel.Worksheet newWorksheet4 = (Excel.Worksheet)result1.Worksheets.get_Item(4);
                newWorksheet2.Name = "变压器调整表";
                newWorksheet3.Name = "发电机调整表";
                newWorksheet4.Name = "无功补偿调整表";
                xSheet1.Name = "电压调整表";
                result1.Visible = true;

                tempSheet2.Cells.Select();
                tempSheet2.Cells.Copy(System.Reflection.Missing.Value);
                newWorksheet2.Paste(System.Reflection.Missing.Value, System.Reflection.Missing.Value);
                tempSheet3.Cells.Select();
                tempSheet3.Cells.Copy(System.Reflection.Missing.Value);
                newWorksheet3.Paste(System.Reflection.Missing.Value, System.Reflection.Missing.Value);
                tempSheet4.Cells.Select();
                tempSheet4.Cells.Copy(System.Reflection.Missing.Value);
                newWorksheet4.Paste(System.Reflection.Missing.Value, System.Reflection.Missing.Value);

                System.Windows.Forms.Clipboard.Clear();

                xSheet1.get_Range(xSheet1.Cells[1, 1], xSheet1.Cells[1, 5]).MergeCells = true;
                xSheet1.get_Range(xSheet1.Cells[3, 1], xSheet1.Cells[3, 5]).MergeCells = true;
                xSheet1.get_Range(xSheet1.Cells[5, 1], xSheet1.Cells[5, 5]).MergeCells = true;
                xSheet1.get_Range(xSheet1.Cells[1, 1], xSheet1.Cells[1, 1]).Font.Size = 16;
                xSheet1.get_Range(xSheet1.Cells[1, 1], xSheet1.Cells[7, 5]).Font.Name = "黑体";
                xSheet1.get_Range(xSheet1.Cells[1, 1], xSheet1.Cells[1, 1]).Font.ColorIndex = 3;
                xSheet1.get_Range(xSheet1.Cells[6, 1], xSheet1.Cells[xSheet1.UsedRange.Rows.Count, 5]).NumberFormat = "0.00_ ";
                xSheet1.get_Range(xSheet1.Cells[xSheet1.UsedRange.Rows.Count - 1, 2], xSheet1.Cells[xSheet1.UsedRange.Rows.Count - 1, 2]).NumberFormatLocal = "0.00%";
                xSheet1.get_Range(xSheet1.Cells[xSheet1.UsedRange.Rows.Count, 2], xSheet1.Cells[xSheet1.UsedRange.Rows.Count, 2]).NumberFormatLocal = "0.00%";
                //xSheet1.get_Range(xSheet1.Cells[1, 1], xSheet1.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                //xSheet1.get_Range(xSheet1.Cells[1, 1], xSheet1.Cells[1, 1]).Interior.ColorIndex = 3;
                //xSheet1.get_Range(xSheet1.Cells[6, 1], xSheet1.Cells[xSheet1.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6;

                newWorksheet2.get_Range(newWorksheet2.Cells[1, 1], newWorksheet2.Cells[1, 7]).MergeCells = true;
                newWorksheet2.get_Range(newWorksheet2.Cells[3, 1], newWorksheet2.Cells[3, 7]).MergeCells = true;
                newWorksheet2.get_Range(newWorksheet2.Cells[5, 1], newWorksheet2.Cells[5, 7]).MergeCells = true;
                newWorksheet2.get_Range(newWorksheet2.Cells[1, 1], newWorksheet2.Cells[1, 1]).Font.Size = 16;
                newWorksheet2.get_Range(newWorksheet2.Cells[1, 1], newWorksheet2.Cells[7, 7]).Font.Name = "黑体";
                newWorksheet2.get_Range(newWorksheet2.Cells[1, 1], newWorksheet2.Cells[1, 1]).Font.ColorIndex = 3;
                newWorksheet2.get_Range(newWorksheet2.Cells[6, 1], newWorksheet2.Cells[newWorksheet2.UsedRange.Rows.Count, 7]).NumberFormat = "0.00_ ";

                newWorksheet3.get_Range(newWorksheet3.Cells[1, 1], newWorksheet3.Cells[1, 8]).MergeCells = true;
                newWorksheet3.get_Range(newWorksheet3.Cells[3, 1], newWorksheet3.Cells[3, 8]).MergeCells = true;
                newWorksheet3.get_Range(newWorksheet3.Cells[5, 1], newWorksheet3.Cells[5, 8]).MergeCells = true;
                newWorksheet3.get_Range(newWorksheet3.Cells[1, 1], newWorksheet3.Cells[1, 1]).Font.Size = 16;
                newWorksheet3.get_Range(newWorksheet3.Cells[1, 1], newWorksheet3.Cells[7, 8]).Font.Name = "黑体";
                newWorksheet3.get_Range(newWorksheet3.Cells[1, 1], newWorksheet3.Cells[1, 1]).Font.ColorIndex = 3;
                newWorksheet3.get_Range(newWorksheet3.Cells[6, 1], newWorksheet3.Cells[newWorksheet3.UsedRange.Rows.Count, 8]).NumberFormat = "0.00_ ";
                newWorksheet4.get_Range(newWorksheet4.Cells[1, 1], newWorksheet4.Cells[1, 6]).MergeCells = true;
                newWorksheet4.get_Range(newWorksheet4.Cells[3, 1], newWorksheet4.Cells[3, 6]).MergeCells = true;
                newWorksheet4.get_Range(newWorksheet4.Cells[5, 1], newWorksheet4.Cells[5, 6]).MergeCells = true;
                newWorksheet4.get_Range(newWorksheet4.Cells[1, 1], newWorksheet4.Cells[1, 1]).Font.Size = 16;
                newWorksheet4.get_Range(newWorksheet4.Cells[1, 1], newWorksheet4.Cells[7, 6]).Font.Name = "黑体";
                newWorksheet4.get_Range(newWorksheet4.Cells[1, 1], newWorksheet4.Cells[1, 1]).Font.ColorIndex = 3;
                newWorksheet4.get_Range(newWorksheet4.Cells[6, 1], newWorksheet4.Cells[newWorksheet4.UsedRange.Rows.Count, 6]).NumberFormat = "0.00_ ";

                xSheet1.Rows.AutoFit();
                xSheet1.Columns.AutoFit();
                newWorksheet2.Rows.AutoFit();
                newWorksheet2.Columns.AutoFit();
                newWorksheet3.Rows.AutoFit();
                newWorksheet3.Columns.AutoFit();
                newWorksheet4.Rows.AutoFit();
                newWorksheet4.Columns.AutoFit();

               // xSheet1.SaveAs(System.Windows.Forms.Application.StartupPath + "\\" + projectSUID + "无功优化.xls", Excel.XlFileFormat.xlXMLSpreadsheet, null, null, false, false, false, null, null, null);
                result1.DisplayAlerts = false;
                result2.DisplayAlerts = false;
                result3.DisplayAlerts = false;
                result4.DisplayAlerts = false;
                result2.Workbooks.Close();
                result2.Quit();
                result3.Workbooks.Close();
                result3.Quit();
                result4.Workbooks.Close();
                result4.Quit();
                wFrom.ShowText += "\r\n计算成功\t" + System.DateTime.Now.ToString();
                GC.Collect();
                return true;
            }
            catch (System.Exception ex)
            {
                wFrom.ShowText += "\r\n计算失败\t" + System.DateTime.Now.ToString();
                return false;
            }
        }
Пример #3
0
        private bool addcheck(frnReport wForm)
        {
            bool flag = true;
               foreach (eleclass el in buscol)
               {
               if (el.selectflag == false)
               {
                   wForm.ShowText += "\r\n还有母线节点没有添加,请继续添加!" + System.DateTime.Now.ToString();
                  // MessageBox.Show("还有母线节点没有添加,请继续添加!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                   flag = false;
                   return false;
               }
               }
               flag = true;
               foreach (eleclass el in loadcol)
               {
               if (el.selectflag == false)
               {
                   wForm.ShowText += "\r\n还有负荷没有添加,请继续添加!" + System.DateTime.Now.ToString();
                   //MessageBox.Show("还有负荷没有添加,请继续添加!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                   flag = false;
                   return false;
               }
               }

               flag = true;
               foreach (eleclass el in trans2col)
               {
               if (el.selectflag == false)
               {
                   wForm.ShowText += "\r\n还有两绕组变压器没有添加,请继续添加!" + System.DateTime.Now.ToString();
                  // MessageBox.Show("还有两绕组变压器没有添加,请继续添加!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                   flag = false;
                   return false;
               }
               }

               flag = true;
               foreach (eleclass el in trans3col)
               {
               if (el.selectflag == false)
               {
                   wForm.ShowText += "\r\n还有三绕组变压器没有添加,请继续添加!" + System.DateTime.Now.ToString();
                   //MessageBox.Show("还有三绕组变压器没有添加,请继续添加!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                   flag = false;
                   return false;
               }
               }
               flag = true;
               foreach (eleclass el in cldkcol)
               {
               if (el.selectflag == false)
               {
                   MessageBox.Show("还有串联电抗器没有添加,请继续添加!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                   flag = false;
                   return false;
               }
               }
               flag = true;
               foreach (eleclass el in cldrcol)
               {
               if (el.selectflag == false)
               {
                   wForm.ShowText += "\r\n还有串联电容器没有添加,请继续添加!" + System.DateTime.Now.ToString();
                   //MessageBox.Show("还有串联电容器没有添加,请继续添加!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                   flag = false;
                   return false;
               }
               }

               flag = true;
               foreach (eleclass el in bldrcol)
               {
               if (el.selectflag == false)
               {
                   wForm.ShowText += "\r\n还有并联电容器没有添加,请继续添加!" + System.DateTime.Now.ToString();
                   //MessageBox.Show("还有并联电容器没有添加,请继续添加!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                   flag = false;
                   return false;
               }
               }

               flag = true;
               foreach (eleclass el in bldkcol)
               {
               if (el.selectflag == false)
               {
                   wForm.ShowText += "\r\n还有并联电抗器没有添加,请继续添加!" + System.DateTime.Now.ToString();
                   //MessageBox.Show("还有并联电抗器没有添加,请继续添加!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                   flag = false;
                   return false;
               }
               }

               flag = true;
               foreach (eleclass el in gencol)
               {
               if (el.selectflag == false)
               {
                   wForm.ShowText += "\r\n还有发电机没有添加,请继续添加!" + System.DateTime.Now.ToString();
                  // MessageBox.Show("还有发电机没有添加,请继续添加!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                   flag = false;
                   return false;
               }
               }

               flag = true;
               foreach (eleclass el in MLcol)
               {
               if (el.selectflag == false)
               {
                   wForm.ShowText += "\r\n还有1/2母联开关没有添加,请继续添加!" + System.DateTime.Now.ToString();
                   //MessageBox.Show("还有1/2母联开关没有添加,请继续添加!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                   flag = false;
                   return false;
               }
               }

               flag = true;
               foreach (eleclass el in ML2col)
               {
               if (el.selectflag == false)
               {
                   wForm.ShowText += "\r\n还有2/3母联开关没有添加,请继续添加!" + System.DateTime.Now.ToString();
                   //MessageBox.Show("还有2/3母联开关没有添加,请继续添加!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                   flag = false;
                   return false;
               }
               }

               flag = true;
               foreach (eleclass el in HGcol)
               {
               if (el.selectflag == false)
               {
                   wForm.ShowText += "\r\n还有线路互感没有添加,请继续添加!" + System.DateTime.Now.ToString();
                   //MessageBox.Show("还有线路互感没有添加,请继续添加!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                   flag = false;
                   return false;
               }
               }

               return true;
        }
Пример #4
0
        public bool LFC(string projectSUID, int type, float ratedCapacity,frnReport wForm)
        {
            //WaitDialogForm wait = new WaitDialogForm("","正在进行计算,请等待!");
            //wait.SetCaption("正在处理数据。。。");
            try
            {
                wForm.ShowText += "\r\n正在准备潮流计算数据\t" + System.DateTime.Now.ToString();
                string strCon1 = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "' AND KSwitchStatus ='0'";
                string strCon2 = null;
                string strCon = null;
                string strData = null;
                string strBus = null;
                string strBranch = null;
                double Rad_to_Deg = Math.PI / 180;
                {
                    strCon2 = " AND Type = '01'";
                    strCon = strCon1 + strCon2;
                    IList listMX = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                    strCon2 = " AND Type = '05'";
                    strCon = strCon1 + strCon2;
                    IList listXL = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                    strCon2 = " AND Type = '02'";
                    strCon = strCon1 + strCon2;
                    IList listBYQ2 = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                    strCon2 = " AND Type = '03'";
                    strCon = strCon1 + strCon2;
                    IList listBYQ3 = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                    strData += (listXL.Count + listBYQ2.Count + listBYQ3.Count * 3).ToString() + " " + listMX.Count.ToString() + " " + listMX.Count.ToString() + " " + "0.00001" + " " + "100" + " " + "0" + " " + "0";
                    foreach (PSPDEV dev in listXL)
                    {
                        if (dev.KSwitchStatus == "0")
                        {
                            if (strBranch != null)
                            {
                                strBranch += "\r\n";
                            }
                            if (strData != null)
                            {
                                strData += "\r\n";
                            }
                            if (dev.FirstNode == dev.LastNode)
                            {
                                if (dev.UnitFlag == "0")
                                {
                                    strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "3" + " " + dev.LineR.ToString() + " " + dev.LineTQ.ToString() + " " + (dev.LineGNDC * 2).ToString() + " " + "0" + " " + "0";
                                    strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "0" + " " + (dev.LineR).ToString() + " " + (dev.LineTQ).ToString() + " " + (dev.LineGNDC).ToString() + " " + "0" + " " + dev.Name.ToString());
                                }
                                else
                                {
                                    strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "3" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineGNDC * 2 * dev.ReferenceVolt * dev.ReferenceVolt / (ratedCapacity * 1000000)).ToString() + " " + "0" + " " + "0";
                                    strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "0" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + ((dev.LineGNDC) * dev.ReferenceVolt * dev.ReferenceVolt / (ratedCapacity * 1000000)).ToString() + " " + "0" + " " + dev.Name.ToString());
                                }
                            }
                            else
                            {
                                if (dev.UnitFlag == "0")
                                {
                                    strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "1" + " " + dev.LineR.ToString() + " " + dev.LineTQ.ToString() + " " + (dev.LineGNDC * 2).ToString() + " " + "0" + " " + "0";
                                    strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "0" + " " + (dev.LineR).ToString() + " " + (dev.LineTQ).ToString() + " " + (dev.LineGNDC).ToString() + " " + "0" + " " + dev.Name.ToString());
                                }
                                else
                                {
                                    strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "1" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineGNDC * 2 * dev.ReferenceVolt * dev.ReferenceVolt / (ratedCapacity * 1000000)).ToString() + " " + "0" + " " + "0";
                                    strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "0" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + ((dev.LineGNDC) * dev.ReferenceVolt * dev.ReferenceVolt / (ratedCapacity * 1000000)).ToString() + " " + "0" + " " + dev.Name.ToString());
                                }
                            }

                        }
                    }
                    foreach (PSPDEV dev in listBYQ2)
                    {
                        if (dev.KSwitchStatus == "0")
                        {
                            if (strBranch != null)
                            {
                                strBranch += "\r\n";
                            }
                            if (strData != null)
                            {
                                strData += "\r\n";
                            }
                            if (dev.UnitFlag == "0")
                            {
                                strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + dev.LineR.ToString() + " " + dev.LineTQ.ToString() + " " + (dev.LineGNDC * 2).ToString() + " " + dev.K.ToString() + " " + dev.G.ToString();
                                strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "1" + " " + (dev.LineR).ToString() + " " + (dev.LineTQ).ToString() + " " + (dev.K).ToString() + " " + dev.G.ToString() + " " + dev.Name.ToString());
                            }
                            else
                            {
                                strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + (dev.LineR * ratedCapacity / (dev.Vib * dev.Vib)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.Vib * dev.Vib)).ToString() + " " + (dev.LineGNDC * 2 * dev.Vib * dev.Vib / (ratedCapacity * 1000000)).ToString() + " " + dev.K.ToString() + " " + dev.G.ToString();
                                strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "1" + " " + (dev.LineR * ratedCapacity / (dev.Vib * dev.Vib)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.Vib * dev.Vib)).ToString() + " " + (dev.K.ToString()).ToString() + " " + dev.G.ToString() + " " + dev.Name.ToString());
                            }
                        }
                    }
                    foreach (PSPDEV dev in listBYQ3)
                    {
                        if (dev.KSwitchStatus == "0")
                        {

                            if (dev.UnitFlag == "0")
                            {
                                if (strBranch != null)
                                {
                                    strBranch += "\r\n";
                                }
                                if (strData != null)
                                {
                                    strData += "\r\n";
                                }
                                strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + dev.HuganTQ1.ToString() + " " + dev.HuganTQ4.ToString() + " " + "0" + " " + dev.K.ToString() + " " + "0";
                                strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "1" + " " + (dev.HuganTQ1).ToString() + " " + (dev.HuganTQ4).ToString() + " " + (dev.K).ToString() + " " + "0" + " " + dev.Name.ToString());
                                if (strBranch != null)
                                {
                                    strBranch += "\r\n";
                                }
                                if (strData != null)
                                {
                                    strData += "\r\n";
                                }
                                strBranch += dev.LastNode.ToString() + " " + dev.Flag.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + dev.HuganTQ2.ToString() + " " + dev.HuganTQ5.ToString() + " " + "0" + " " + dev.StandardCurrent.ToString() + " " + "0";

                                strData += (dev.LastNode.ToString() + " " + dev.Flag.ToString() + " " + "1" + " " + (dev.HuganTQ2).ToString() + " " + (dev.HuganTQ5).ToString() + " " + (dev.StandardCurrent).ToString() + " " + "0" + " " + dev.Name.ToString());
                                if (strBranch != null)
                                {
                                    strBranch += "\r\n";
                                }
                                if (strData != null)
                                {
                                    strData += "\r\n";
                                }
                                strBranch += dev.FirstNode.ToString() + " " + dev.Flag.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + dev.HuganTQ3.ToString() + " " + dev.ZeroTQ.ToString() + " " + "0" + " " + dev.BigP.ToString() + " " + "0";
                                strData += (dev.FirstNode.ToString() + " " + dev.Flag.ToString() + " " + "1" + " " + (dev.HuganTQ3).ToString() + " " + (dev.ZeroTQ).ToString() + " " + (dev.BigP).ToString() + " " + "0" + " " + dev.Name.ToString());

                            }
                            else
                            {
                                if (strBranch != null)
                                {
                                    strBranch += "\r\n";
                                }
                                if (strData != null)
                                {
                                    strData += "\r\n";
                                }
                                strBranch += dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + (dev.HuganTQ1 * ratedCapacity / (dev.Vib * dev.Vib)).ToString() + " " + (dev.HuganTQ4 * ratedCapacity / (dev.Vib * dev.Vib)).ToString() + " " + "0" + " " + dev.K.ToString() + " " + "0";
                                strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "1" + " " + (dev.HuganTQ1 * ratedCapacity / (dev.Vib * dev.Vib)).ToString() + " " + (dev.HuganTQ4 * ratedCapacity / (dev.Vib * dev.Vib)).ToString() + " " + (dev.K).ToString() + " " + "0" + " " + dev.Name.ToString());
                                if (strBranch != null)
                                {
                                    strBranch += "\r\n";
                                }
                                if (strData != null)
                                {
                                    strData += "\r\n";
                                }
                                strBranch += dev.LastNode.ToString() + " " + dev.Flag.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + (dev.HuganTQ2 * ratedCapacity / (dev.Vjb * dev.Vjb)).ToString() + " " + (dev.HuganTQ5 * ratedCapacity / (dev.Vjb * dev.Vjb)).ToString() + " " + "0" + " " + dev.StandardCurrent.ToString() + " " + "0";
                                strData += (dev.LastNode.ToString() + " " + dev.Flag.ToString() + " " + "1" + " " + (dev.HuganTQ2 * ratedCapacity / (dev.Vjb * dev.Vjb)).ToString() + " " + (dev.HuganTQ5 * ratedCapacity / (dev.Vjb * dev.Vjb)).ToString() + " " + (dev.StandardCurrent).ToString() + " " + "0" + " " + dev.Name.ToString());
                                if (strBranch != null)
                                {
                                    strBranch += "\r\n";
                                }
                                if (strData != null)
                                {
                                    strData += "\r\n";
                                }
                                strBranch += dev.FirstNode.ToString() + " " + dev.Flag.ToString() + " " + dev.Name.ToString() + " " + "2" + " " + (dev.HuganTQ3 * ratedCapacity / (dev.Vkb * dev.Vkb)).ToString() + " " + (dev.ZeroTQ * ratedCapacity / (dev.Vkb * dev.Vkb)).ToString() + " " + "0" + " " + dev.BigP.ToString() + " " + "0";
                                strData += (dev.FirstNode.ToString() + " " + dev.Flag.ToString() + " " + "1" + " " + (dev.HuganTQ3 * ratedCapacity / (dev.Vkb * dev.Vkb)).ToString() + " " + (dev.ZeroTQ * ratedCapacity / (dev.Vkb * dev.Vkb)).ToString() + " " + (dev.BigP).ToString() + " " + "0" + " " + dev.Name.ToString());
                            }
                        }
                    }
                    //foreach (PSPDEV dev in listMX)
                    //{
                    //    if (dev.KSwitchStatus == "0")
                    //    {
                    //        if (strBus != null)
                    //        {
                    //            strBus += "\r\n";
                    //        }
                    //        if (strData != null)
                    //        {
                    //            strData += "\r\n";
                    //        }
                    //        if (dev.UnitFlag == "0")
                    //        {
                    //            strBus += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + MXNodeType(dev.NodeType) + " " + (dev.VoltR).ToString() + " " + (dev.VoltV*Rad_to_Deg).ToString() + " " + ((dev.InPutP - dev.OutP)).ToString() + " " + ((dev.InPutQ - dev.OutQ)).ToString());
                    //            //strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "0" + " " + (dev.LineR).ToString() + " " + (dev.LineTQ).ToString() + " " + (dev.LineGNDC).ToString() + " " + "0" + " " + dev.Name.ToString());
                    //            if (dev.NodeType == "1")
                    //            {
                    //                strData += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + dev.NodeType + " " + ((dev.OutP)).ToString() + " " + ((dev.OutQ)).ToString());
                    //            }
                    //            else if (dev.NodeType == "2")
                    //            {
                    //                strData += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + dev.NodeType + " " + ((dev.OutP)).ToString() + " " + (dev.VoltR).ToString());
                    //            }
                    //            else if (dev.NodeType == "0")
                    //            {
                    //                strData += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + dev.NodeType + " " + (dev.VoltR).ToString() + " " + "0");
                    //            }
                    //        }
                    //        else
                    //        {
                    //            strBus += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + MXNodeType(dev.NodeType) + " " + (dev.VoltR / dev.ReferenceVolt).ToString() + " " + (dev.VoltV * Rad_to_Deg).ToString() + " " + ((dev.InPutP - dev.OutP) / ratedCapacity).ToString() + " " + ((dev.InPutQ - dev.OutQ) / ratedCapacity).ToString());
                    //            //strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "0" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + ((dev.LineGNDC) * dev.ReferenceVolt * dev.ReferenceVolt / (ratedCapacity * 1000000)).ToString() + " " + "0" + " " + dev.Name.ToString());
                    //            if (dev.NodeType == "1")
                    //            {
                    //                strData += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + dev.NodeType + " " + ((dev.OutP) / ratedCapacity).ToString() + " " + ((dev.OutQ) / ratedCapacity).ToString());
                    //            }
                    //            else if (dev.NodeType == "2")
                    //            {
                    //                strData += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + dev.NodeType + " " + ((dev.OutP) / ratedCapacity).ToString() + " " + (dev.VoltR / dev.ReferenceVolt).ToString());
                    //            }
                    //            else if (dev.NodeType == "0")
                    //            {
                    //                strData += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + dev.NodeType + " " + (dev.VoltR / dev.ReferenceVolt).ToString() + " " + "0");
                    //            }
                    //        }
                    //    }
                    //}
                    //foreach (PSPDEV dev in listMX)
                    //{
                    //    if (dev.KSwitchStatus == "0")
                    //    {
                    //        if (strData != null)
                    //        {
                    //            strData += "\r\n";
                    //        }
                    //        if (dev.UnitFlag == "0")
                    //        {
                    //            strData += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + "0" + " " + "0" + " " + "0" + " " + "0" + " " + "0" + " " + ((dev.InPutP)).ToString() + " " + ((dev.InPutQ)).ToString());
                    //        }
                    //        else
                    //        {
                    //            strData += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + "0" + " " + "0" + " " + "0" + " " + "0" + " " + "0" + " " + ((dev.InPutP) / ratedCapacity).ToString() + " " + ((dev.InPutQ) / ratedCapacity).ToString());
                    //        }
                    //    }
                    //}
                    foreach (PSPDEV dev in listMX)
                    {
                        if (dev.KSwitchStatus == "0")
                        {
                            if (strBus != null)
                            {
                                strBus += "\r\n";
                            }
                            if (strData != null)
                            {
                                strData += "\r\n";
                            }
                            double outP = 0;
                            double outQ = 0;
                            double inputP = 0;
                            double inputQ = 0;
                            string strCon3 = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "' AND Type = '04' AND IName = '" + dev.Name + "'";
                            IList listFDJ = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon3);
                            string strCon4 = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "' AND Type = '12' AND IName = '" + dev.Name + "'";
                            IList listFH = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon4);
                            foreach (PSPDEV devFDJ in listFDJ)
                            {
                                if (devFDJ.UnitFlag == "0")
                                {
                                    outP += devFDJ.OutP;
                                    outQ += devFDJ.OutQ;
                                }
                                else
                                {
                                    outP += devFDJ.OutP / ratedCapacity;
                                    outQ += devFDJ.OutQ / ratedCapacity;
                                }
                            }
                            foreach (PSPDEV devFH in listFH)
                            {
                                if (devFH.UnitFlag == "0")
                                {
                                    inputP += devFH.InPutP;
                                    inputQ += devFH.InPutQ;
                                    //上海新加
                                    if (devFH.OutP!=0)
                                    {
                                        inputP += devFH.OutP;
                                    }
                                    if (devFH.OutQ != 0)
                                    {
                                        inputQ += devFH.OutQ;
                                    }
                                }
                                else
                                {
                                    inputP += devFH.InPutP / ratedCapacity;
                                    inputQ += devFH.InPutQ / ratedCapacity;
                                    //上海新加
                                    if (devFH.OutP != 0)
                                    {
                                        inputP += devFH.OutP / ratedCapacity;
                                    }
                                    if (devFH.OutQ != 0)
                                    {
                                        inputQ += devFH.OutQ / ratedCapacity;
                                    }
                                }
                            }
                            //if (mxflag.ContainsKey(dev.SUID))
                            //{
                            //    gltj tj = mxflag[dev.SUID];
                            //    outP += tj.outP;
                            //    outQ += tj.outQ;
                            //    inputP += tj.inputP;
                            //    inputQ += tj.inputQ;
                            //}

                            if (dev.UnitFlag == "0")
                            {
                                outP += dev.OutP;
                                outQ += dev.OutQ;
                                inputP += dev.InPutP;
                                inputQ += dev.InPutQ;
                                strBus += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + MXNodeType(dev.NodeType) + " " + (dev.VoltR).ToString() + " " + (dev.VoltV * Rad_to_Deg).ToString() + " " + ((inputP - outP)).ToString() + " " + ((inputQ - outQ)).ToString());
                                //strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "0" + " " + (dev.LineR).ToString() + " " + (dev.LineTQ).ToString() + " " + (dev.LineGNDC).ToString() + " " + "0" + " " + dev.Name.ToString());
                                if (dev.NodeType == "1")
                                {
                                    strData += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + dev.NodeType + " " + ((outP)).ToString() + " " + ((outQ)).ToString());
                                }
                                else if (dev.NodeType == "2")
                                {
                                    strData += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + dev.NodeType + " " + ((outP)).ToString() + " " + (dev.VoltR).ToString());
                                }
                                else if (dev.NodeType == "0")
                                {
                                    strData += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + dev.NodeType + " " + (dev.VoltR).ToString() + " " + "0");
                                }
                            }
                            else
                            {
                                outP += dev.OutP / ratedCapacity;
                                outQ += dev.OutQ / ratedCapacity;
                                inputP += dev.InPutP / ratedCapacity;
                                inputQ += dev.InPutQ / ratedCapacity;
                                strBus += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + MXNodeType(dev.NodeType) + " " + (dev.VoltR / dev.ReferenceVolt).ToString() + " " + (dev.VoltV * Rad_to_Deg).ToString() + " " + ((inputP - outP)).ToString() + " " + ((inputQ - outQ)).ToString());
                                //strData += (dev.FirstNode.ToString() + " " + dev.LastNode.ToString() + " " + "0" + " " + (dev.LineR * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + (dev.LineTQ * ratedCapacity / (dev.ReferenceVolt * dev.ReferenceVolt)).ToString() + " " + ((dev.LineGNDC) * dev.ReferenceVolt * dev.ReferenceVolt / (ratedCapacity * 1000000)).ToString() + " " + "0" + " " + dev.Name.ToString());
                                if (dev.NodeType == "1")
                                {
                                    strData += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + dev.NodeType + " " + (outP).ToString() + " " + (outQ).ToString());
                                }
                                else if (dev.NodeType == "2")
                                {
                                    strData += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + dev.NodeType + " " + (outP).ToString() + " " + (dev.VoltR / dev.ReferenceVolt).ToString());
                                }
                                else if (dev.NodeType == "0")
                                {
                                    strData += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + dev.NodeType + " " + (dev.VoltR / dev.ReferenceVolt).ToString() + " " + "0");
                                }
                            }
                        }
                    }
                    foreach (PSPDEV dev in listMX)
                    {
                        if (dev.KSwitchStatus == "0")
                        {
                            if (strData != null)
                            {
                                strData += "\r\n";
                            }
                            double outP = 0;
                            double outQ = 0;
                            double inputP = 0;
                            double inputQ = 0;
                            string strCon3 = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "' AND Type = '04' AND IName = '" + dev.Name + "'";
                            IList listFDJ = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon3);
                            string strCon4 = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "' AND Type = '12' AND IName = '" + dev.Name + "'";
                            IList listFH = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon4);
                            foreach (PSPDEV devFDJ in listFDJ)
                            {
                                if (devFDJ.UnitFlag == "0")
                                {
                                    outP += devFDJ.OutP;
                                    outQ += devFDJ.OutQ;
                                }
                                else
                                {
                                    outP += devFDJ.OutP / ratedCapacity;
                                    outQ += devFDJ.OutQ / ratedCapacity;
                                }
                            }
                            foreach (PSPDEV devFH in listFH)
                            {
                                if (devFH.UnitFlag == "0")
                                {
                                    inputP += devFH.InPutP;
                                    inputQ += devFH.InPutQ;
                                    //上海新加
                                    if (devFH.OutP != 0)
                                    {
                                        inputP += devFH.OutP;
                                    }
                                    if (devFH.OutQ != 0)
                                    {
                                        inputQ += devFH.OutQ;
                                    }
                                }
                                else
                                {
                                    inputP += devFH.InPutP / ratedCapacity;
                                    inputQ += devFH.InPutQ / ratedCapacity;
                                    //上海新加
                                    if (devFH.OutP != 0)
                                    {
                                        inputP += devFH.OutP / ratedCapacity;
                                    }
                                    if (devFH.OutQ != 0)
                                    {
                                        inputQ += devFH.OutQ / ratedCapacity;
                                    }
                                }
                            }
                            if (dev.UnitFlag == "0")
                            {
                                outP += dev.OutP;
                                outQ += dev.OutQ;
                                inputP += dev.InPutP;
                                inputQ += dev.InPutQ;
                            }
                            else
                            {
                                outP += dev.OutP / ratedCapacity;
                                outQ += dev.OutQ / ratedCapacity;
                                inputP += dev.InPutP / ratedCapacity;
                                inputQ += dev.InPutQ / ratedCapacity;
                            }
                            strData += (dev.Number.ToString() + " " + dev.Name.ToString() + " " + "0" + " " + "0" + " " + "0" + " " + "0" + " " + "0" + " " + ((inputP)).ToString() + " " + ((inputQ)).ToString());

                        }
                    }
                }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\data.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\data.txt");
                }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\branch.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\branch.txt");
                }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\bus.txt"))
                {
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\bus.txt");
                }
                FileStream VK = new FileStream((System.Windows.Forms.Application.StartupPath + "\\data.txt"), FileMode.OpenOrCreate);
                StreamWriter str1 = new StreamWriter(VK, Encoding.Default);
                str1.Write(strData);
                str1.Close();

                FileStream VK1 = new FileStream((System.Windows.Forms.Application.StartupPath + "\\branch.txt"), FileMode.OpenOrCreate);
                StreamWriter str3 = new StreamWriter(VK1, Encoding.Default);
                str3.Write(strBranch);
                str3.Close();
                FileStream L = new FileStream((System.Windows.Forms.Application.StartupPath + "\\bus.txt"), FileMode.OpenOrCreate);
                StreamWriter str2 = new StreamWriter(L, Encoding.Default);
                str2.Write(strBus);
                str2.Close();
                if (strData.Contains("非数字") || strData.Contains("正无穷大") || strBus.Contains("非数字") || strBus.Contains("正无穷大") || strBranch.Contains("非数字") || strBranch.Contains("正无穷大"))
                {
                    //wait.Close();
                    MessageBox.Show("缺少参数,请检查输入参数!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return false;
                }
                //wait.SetCaption("正在进行计算。。。");
                if (type == 1)
                {
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\PF1.txt"))
                    {
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\PF1.txt");
                    }
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH1.txt"))
                    {
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\DH1.txt");
                    }
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\IH1.txt"))
                    {
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\IH1.txt");
                    }
                    wForm.ShowText += "\r\n正在进行迭代\t" + System.DateTime.Now.ToString();
                    NIULA nr = new NIULA();
                    nr.CurrentCal();
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\PF1.txt"))
                    {
                    }
                    else
                    {
                        //wait.Close();
                        return false;
                    }
                    FileStream pf = new FileStream(System.Windows.Forms.Application.StartupPath + "\\PF1.txt", FileMode.Open);
                    StreamReader readLine = new StreamReader(pf, Encoding.Default);
                    char[] charSplit = new char[] { ' ' };
                    string strLine = readLine.ReadLine();
                    while (strLine != null && strLine != "")
                    {
                        string[] array1 = strLine.Split(charSplit);
                        strCon2 = " AND Type= '01' AND Number = " + array1[0];
                        strCon = strCon1 + strCon2;
                        PSPDEV devMX = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                        if (devMX != null)
                        {
                            PSP_ElcDevice elcDev = new PSP_ElcDevice();
                            elcDev.ProjectSUID = projectSUID;
                            elcDev.DeviceSUID = devMX.SUID;
                            elcDev = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);
                            if (elcDev != null)
                            {
                                elcDev.COL1 = devMX.Name;
                                elcDev.COL19 = devMX.ReferenceVolt.ToString();
                                elcDev.COL20 = ratedCapacity.ToString();
                                double temp = 0.0;
                                double.TryParse(array1[1], out temp);
                                elcDev.COL2 = (temp * (devMX.ReferenceVolt)).ToString();
                                temp = 0.0;
                                double.TryParse(array1[2], out temp);
                                elcDev.COL3 = (temp * Rad_to_Deg).ToString();
                                temp = 0.0;
                                double.TryParse(array1[3], out temp);
                                elcDev.COL4 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[4], out temp);
                                elcDev.COL5 = (temp * ratedCapacity).ToString();

                                Services.BaseService.Update<PSP_ElcDevice>(elcDev);
                            }
                        }
                        strLine = readLine.ReadLine();
                    }
                    readLine.Close();
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH1.txt"))
                    {
                    }
                    else
                    {
                        //wait.Close();
                        return false;
                    }
                    FileStream dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DH1.txt", FileMode.Open);
                    readLine = new StreamReader(dh, Encoding.Default);
                    strLine = readLine.ReadLine();
                    while (strLine != null && strLine != "")
                    {
                        string[] array1 = strLine.Split(charSplit);
                        strCon2 = " AND Type= '05' AND Name = '" + array1[0] + "' AND FirstNode = " + array1[1] + " AND LastNode = " + array1[2];
                        strCon = strCon1 + strCon2;
                        PSPDEV devMX = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                        if (devMX != null)
                        {
                            PSP_ElcDevice elcDev = new PSP_ElcDevice();
                            elcDev.ProjectSUID = projectSUID;
                            elcDev.DeviceSUID = devMX.SUID;
                            elcDev = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);
                            if (elcDev != null)
                            {
                                elcDev.COL1 = devMX.Name;
                                elcDev.COL2 = devMX.FirstNode.ToString();
                                elcDev.COL3 = devMX.LastNode.ToString();
                                elcDev.COL19 = devMX.ReferenceVolt.ToString();
                                if (Convert.ToDouble(devMX.Burthen) == 0.0)
                                {
                                    elcDev.COL20 = ratedCapacity.ToString();
                                }
                                else
                                    elcDev.COL20 = devMX.Burthen.ToString();
                                double temp = 0.0;
                                double.TryParse(array1[3], out temp);
                                elcDev.COL4 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[4], out temp);
                                elcDev.COL5 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[5], out temp);
                                elcDev.COL6 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[6], out temp);
                                elcDev.COL7 = (temp * ratedCapacity).ToString();

                                temp = 0.0;
                                double.TryParse(array1[7], out temp);
                                elcDev.COL8 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[8], out temp);
                                elcDev.COL9 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[9], out temp);
                                elcDev.COL10 = (temp * ratedCapacity / (Math.Sqrt(3) * devMX.ReferenceVolt)).ToString();

                                temp = 0.0;
                                double.TryParse(array1[10], out temp);
                                elcDev.COL11 = (temp * Rad_to_Deg).ToString();
                                temp = 0.0;
                                double.TryParse(array1[11], out temp);
                                elcDev.COL12 = (temp * (devMX.ReferenceVolt)).ToString();
                                temp = 0.0;
                                double.TryParse(array1[12], out temp);
                                elcDev.COL13 = (temp * (devMX.ReferenceVolt)).ToString();
                                PSP_ElcDevice elcTemp = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);

                                Services.BaseService.Update<PSP_ElcDevice>(elcDev);
                            }
                        }
                        strLine = readLine.ReadLine();
                    }
                    readLine.Close();
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\IH1.txt"))
                    {
                    }
                    else
                    {
                        //wait.Close();
                        return false;
                    }
                    FileStream ih = new FileStream(System.Windows.Forms.Application.StartupPath + "\\IH1.txt", FileMode.Open);
                    readLine = new StreamReader(ih, Encoding.Default);
                    strLine = readLine.ReadLine();
                    while (strLine != null && strLine != "")
                    {
                        string[] array1 = strLine.Split(charSplit);
                        strCon2 = " AND Type= '05' AND Name = '" + array1[0] + "' AND FirstNode = " + array1[1] + " AND LastNode = " + array1[2];
                        strCon = strCon1 + strCon2;
                        PSPDEV devMX = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                        if (devMX != null)
                        {
                            PSP_ElcDevice elcDev = new PSP_ElcDevice();
                            elcDev.ProjectSUID = projectSUID;
                            elcDev.DeviceSUID = devMX.SUID;
                            elcDev = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);
                            if (elcDev != null)
                            {
                                elcDev.COL1 = devMX.Name;
                                elcDev.COL2 = devMX.FirstNode.ToString();
                                elcDev.COL3 = devMX.LastNode.ToString();
                                elcDev.COL19 = devMX.ReferenceVolt.ToString();
                                if (Convert.ToDouble(devMX.Burthen) == 0.0)
                                {
                                    elcDev.COL20 = ratedCapacity.ToString();
                                }
                                else
                                    elcDev.COL20 = devMX.Burthen.ToString();
                                double temp = 0.0;
                                double.TryParse(array1[3], out temp);
                                elcDev.COL14 = (temp * ratedCapacity / (Math.Sqrt(3) * devMX.ReferenceVolt)).ToString();
                                temp = 0.0;
                                double.TryParse(array1[4], out temp);
                                elcDev.COL15 = (temp * Rad_to_Deg).ToString();
                                PSP_ElcDevice elcTemp = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);

                                Services.BaseService.Update<PSP_ElcDevice>(elcDev);
                            }
                        }
                        strLine = readLine.ReadLine();
                    }
                    readLine.Close();
                }
                else if (type == 2)
                {
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\PF2.txt"))
                    {
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\PF2.txt");
                    }
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH2.txt"))
                    {
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\DH2.txt");
                    }
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\IH2.txt"))
                    {
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\IH2.txt");
                    }
                    wForm.ShowText += "\r\n正在进行迭代\t" + System.DateTime.Now.ToString();

                    PQ_PowerFlowCalClass pq = new PQ_PowerFlowCalClass();
                    pq.CurrentCal();
                    GC.Collect();
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\PF2.txt"))
                    {
                    }
                    else
                    {
                        //wait.Close();
                        return false;
                    }
                    FileStream pf = new FileStream(System.Windows.Forms.Application.StartupPath + "\\PF2.txt", FileMode.Open);
                    StreamReader readLine = new StreamReader(pf, Encoding.Default);
                    char[] charSplit = new char[] { ' ' };
                    string strLine = readLine.ReadLine();
                    while (strLine != null && strLine != "")
                    {
                        string[] array1 = strLine.Split(charSplit);
                        strCon2 = " AND Type= '01' AND Number = " + array1[0];
                        strCon = strCon1 + strCon2;
                        PSPDEV devMX = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                        if (devMX != null)
                        {
                            PSP_ElcDevice elcDev = new PSP_ElcDevice();
                            elcDev.ProjectSUID = projectSUID;
                            elcDev.DeviceSUID = devMX.SUID;
                            elcDev = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);
                            if (elcDev != null)
                            {
                                elcDev.COL21 = devMX.Name;
                                elcDev.COL39 = devMX.ReferenceVolt.ToString();
                                elcDev.COL40 = ratedCapacity.ToString();
                                double temp = 0.0;
                                double.TryParse(array1[1], out temp);
                                elcDev.COL22 = (temp * (devMX.ReferenceVolt)).ToString();
                                temp = 0.0;
                                double.TryParse(array1[2], out temp);
                                elcDev.COL23 = (temp * Rad_to_Deg).ToString();
                                temp = 0.0;
                                double.TryParse(array1[3], out temp);
                                elcDev.COL24 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[4], out temp);
                                elcDev.COL25 = (temp * ratedCapacity).ToString();
                                PSP_ElcDevice elcTemp = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);

                                Services.BaseService.Update<PSP_ElcDevice>(elcDev);
                            }
                        }
                        strLine = readLine.ReadLine();
                    }
                    readLine.Close();
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH2.txt"))
                    {
                    }
                    else
                    {
                        //wait.Close();
                        return false;
                    }
                    FileStream dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DH2.txt", FileMode.Open);
                    readLine = new StreamReader(dh, Encoding.Default);
                    strLine = readLine.ReadLine();
                    while (strLine != null && strLine != "")
                    {
                        string[] array1 = strLine.Split(charSplit);
                        strCon2 = " AND Type= '05' AND Name = '" + array1[0] + "' AND FirstNode = " + array1[1] + " AND LastNode = " + array1[2];
                        strCon = strCon1 + strCon2;
                        PSPDEV devMX = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                        if (devMX != null)
                        {
                            PSP_ElcDevice elcDev = new PSP_ElcDevice();
                            elcDev.ProjectSUID = projectSUID;
                            elcDev.DeviceSUID = devMX.SUID;
                            elcDev = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);
                            if (elcDev != null)
                            {
                                elcDev.COL21 = devMX.Name;
                                elcDev.COL22 = devMX.FirstNode.ToString();
                                elcDev.COL23 = devMX.LastNode.ToString();
                                elcDev.COL39 = devMX.ReferenceVolt.ToString();
                                elcDev.COL40 = ratedCapacity.ToString();
                                double temp = 0.0;
                                double.TryParse(array1[3], out temp);
                                elcDev.COL24 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[4], out temp);
                                elcDev.COL25 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[5], out temp);
                                elcDev.COL26 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[6], out temp);
                                elcDev.COL27 = (temp * ratedCapacity).ToString();

                                temp = 0.0;
                                double.TryParse(array1[7], out temp);
                                elcDev.COL28 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[8], out temp);
                                elcDev.COL29 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[9], out temp);
                                elcDev.COL30 = (temp * ratedCapacity / (Math.Sqrt(3) * devMX.ReferenceVolt)).ToString();

                                temp = 0.0;
                                double.TryParse(array1[10], out temp);
                                elcDev.COL31 = (temp * Rad_to_Deg).ToString();
                                temp = 0.0;
                                double.TryParse(array1[11], out temp);
                                elcDev.COL32 = (temp * (devMX.ReferenceVolt)).ToString();
                                temp = 0.0;
                                double.TryParse(array1[12], out temp);
                                elcDev.COL33 = (temp * (devMX.ReferenceVolt)).ToString();
                                PSP_ElcDevice elcTemp = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);

                                Services.BaseService.Update<PSP_ElcDevice>(elcDev);
                            }
                        }
                        strLine = readLine.ReadLine();
                    }
                    readLine.Close();
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\IH2.txt"))
                    {
                    }
                    else
                    {
                        //wait.Close();
                        return false;
                    }
                    FileStream ih = new FileStream(System.Windows.Forms.Application.StartupPath + "\\IH2.txt", FileMode.Open);
                    readLine = new StreamReader(ih, Encoding.Default);
                    strLine = readLine.ReadLine();
                    while (strLine != null && strLine != "")
                    {
                        string[] array1 = strLine.Split(charSplit);
                        strCon2 = " AND Type= '05' AND Name = '" + array1[0] + "' AND FirstNode = " + array1[1] + " AND LastNode = " + array1[2];
                        strCon = strCon1 + strCon2;
                        PSPDEV devMX = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                        if (devMX != null)
                        {
                            PSP_ElcDevice elcDev = new PSP_ElcDevice();
                            elcDev.ProjectSUID = projectSUID;
                            elcDev.DeviceSUID = devMX.SUID;
                            elcDev = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);
                            if (elcDev != null)
                            {
                                elcDev.COL21 = devMX.Name;
                                elcDev.COL22 = devMX.FirstNode.ToString();
                                elcDev.COL23 = devMX.LastNode.ToString();
                                elcDev.COL39 = devMX.ReferenceVolt.ToString();
                                elcDev.COL40 = ratedCapacity.ToString();
                                double temp = 0.0;
                                double.TryParse(array1[3], out temp);
                                elcDev.COL34 = (temp * ratedCapacity / (Math.Sqrt(3) * devMX.ReferenceVolt)).ToString();
                                temp = 0.0;
                                double.TryParse(array1[4], out temp);
                                elcDev.COL35 = (temp * Rad_to_Deg).ToString();
                                PSP_ElcDevice elcTemp = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);

                                Services.BaseService.Update<PSP_ElcDevice>(elcDev);
                            }
                        }
                        strLine = readLine.ReadLine();
                    }
                    readLine.Close();
                }
                else if (type == 3)
                {
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\PF3.txt"))
                    {
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\PF3.txt");
                    }
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH3.txt"))
                    {
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\DH3.txt");
                    }
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\IH3.txt"))
                    {
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\IH3.txt");
                    }
                    wForm.ShowText += "\r\n正在进行迭代\t" + System.DateTime.Now.ToString();
                    Gauss gs = new Gauss();
                    gs.CurrentCal();

                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\PF3.txt"))
                    {
                    }
                    else
                    {
                        //wait.Close();
                        return false;
                    }
                    FileStream pf = new FileStream(System.Windows.Forms.Application.StartupPath + "\\PF3.txt", FileMode.Open);
                    StreamReader readLine = new StreamReader(pf, Encoding.Default);
                    char[] charSplit = new char[] { ' ' };
                    string strLine = readLine.ReadLine();
                    while (strLine != null && strLine != "")
                    {
                        string[] array1 = strLine.Split(charSplit);
                        strCon2 = " AND Type= '01' AND Number = " + array1[0];
                        strCon = strCon1 + strCon2;
                        PSPDEV devMX = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                        if (devMX != null)
                        {
                            PSP_ElcDevice elcDev = new PSP_ElcDevice();
                            elcDev.ProjectSUID = projectSUID;
                            elcDev.DeviceSUID = devMX.SUID;
                            elcDev = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);
                            if (elcDev != null)
                            {
                                elcDev.COL41 = devMX.Name;
                                elcDev.COL59 = devMX.ReferenceVolt.ToString();
                                elcDev.COL60 = ratedCapacity.ToString();
                                double temp = 0.0;
                                double.TryParse(array1[1], out temp);
                                elcDev.COL42 = (temp * (devMX.ReferenceVolt)).ToString();
                                temp = 0.0;
                                double.TryParse(array1[2], out temp);
                                elcDev.COL43 = (temp * Rad_to_Deg).ToString();
                                temp = 0.0;
                                double.TryParse(array1[3], out temp);
                                elcDev.COL44 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[4], out temp);
                                elcDev.COL45 = (temp * ratedCapacity).ToString();
                                PSP_ElcDevice elcTemp = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);

                                Services.BaseService.Update<PSP_ElcDevice>(elcDev);
                            }
                        }
                        strLine = readLine.ReadLine();
                    }
                    readLine.Close();
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH3.txt"))
                    {
                    }
                    else
                    {
                        // wait.Close();
                        return false;
                    }
                    FileStream dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DH3.txt", FileMode.Open);
                    readLine = new StreamReader(dh, Encoding.Default);
                    strLine = readLine.ReadLine();
                    while (strLine != null && strLine != "")
                    {
                        string[] array1 = strLine.Split(charSplit);
                        strCon2 = " AND Type= '05' AND Name = '" + array1[0] + "' AND FirstNode = " + array1[1] + " AND LastNode = " + array1[2];
                        strCon = strCon1 + strCon2;
                        PSPDEV devMX = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                        if (devMX != null)
                        {
                            PSP_ElcDevice elcDev = new PSP_ElcDevice();
                            elcDev.ProjectSUID = projectSUID;
                            elcDev.DeviceSUID = devMX.SUID;
                            elcDev = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);
                            if (elcDev != null)
                            {
                                elcDev.COL41 = devMX.Name;
                                elcDev.COL42 = devMX.FirstNode.ToString();
                                elcDev.COL43 = devMX.LastNode.ToString();
                                elcDev.COL59 = devMX.ReferenceVolt.ToString();
                                elcDev.COL60 = ratedCapacity.ToString();
                                double temp = 0.0;
                                double.TryParse(array1[3], out temp);
                                elcDev.COL44 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[4], out temp);
                                elcDev.COL45 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[5], out temp);
                                elcDev.COL46 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[6], out temp);
                                elcDev.COL47 = (temp * ratedCapacity).ToString();

                                temp = 0.0;
                                double.TryParse(array1[7], out temp);
                                elcDev.COL48 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[8], out temp);
                                elcDev.COL49 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[9], out temp);
                                elcDev.COL50 = (temp * ratedCapacity / (Math.Sqrt(3) * devMX.ReferenceVolt)).ToString();

                                temp = 0.0;
                                double.TryParse(array1[10], out temp);
                                elcDev.COL51 = (temp * Rad_to_Deg).ToString();
                                temp = 0.0;
                                double.TryParse(array1[11], out temp);
                                elcDev.COL52 = (temp * (devMX.ReferenceVolt)).ToString();
                                temp = 0.0;
                                double.TryParse(array1[12], out temp);
                                elcDev.COL53 = (temp * (devMX.ReferenceVolt)).ToString();
                                PSP_ElcDevice elcTemp = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);

                                Services.BaseService.Update<PSP_ElcDevice>(elcDev);
                            }
                        }
                        strLine = readLine.ReadLine();
                    }
                    readLine.Close();
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\IH3.txt"))
                    {
                    }
                    else
                    {
                        //wait.Close();
                        return false;
                    }
                    FileStream ih = new FileStream(System.Windows.Forms.Application.StartupPath + "\\IH3.txt", FileMode.Open);
                    readLine = new StreamReader(ih, Encoding.Default);
                    strLine = readLine.ReadLine();
                    while (strLine != null && strLine != "")
                    {
                        string[] array1 = strLine.Split(charSplit);
                        strCon2 = " AND Type= '05' AND Name = '" + array1[0] + "' AND FirstNode = " + array1[1] + " AND LastNode = " + array1[2];
                        strCon = strCon1 + strCon2;
                        PSPDEV devMX = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                        if (devMX != null)
                        {
                            PSP_ElcDevice elcDev = new PSP_ElcDevice();
                            elcDev.ProjectSUID = projectSUID;
                            elcDev.DeviceSUID = devMX.SUID;
                            elcDev = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);
                            if (elcDev != null)
                            {
                                elcDev.COL41 = devMX.Name;
                                elcDev.COL42 = devMX.FirstNode.ToString();
                                elcDev.COL43 = devMX.LastNode.ToString();
                                elcDev.COL59 = devMX.ReferenceVolt.ToString();
                                elcDev.COL60 = ratedCapacity.ToString();
                                double temp = 0.0;
                                double.TryParse(array1[3], out temp);
                                elcDev.COL54 = (temp * ratedCapacity / (Math.Sqrt(3) * devMX.ReferenceVolt)).ToString();
                                temp = 0.0;
                                double.TryParse(array1[4], out temp);
                                elcDev.COL55 = (temp * Rad_to_Deg).ToString();
                                PSP_ElcDevice elcTemp = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);

                                Services.BaseService.Update<PSP_ElcDevice>(elcDev);
                            }
                        }
                        strLine = readLine.ReadLine();
                    }
                    readLine.Close();
                }
                else if (type == 4)
                {
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\PF4.txt"))
                    {
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\PF4.txt");
                    }
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH4.txt"))
                    {
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\DH4.txt");
                    }
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\IH4.txt"))
                    {
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\IH4.txt");
                    }
                    wForm.ShowText += "\r\n正在进行迭代\t" + System.DateTime.Now.ToString();
                    ZYZ zy = new ZYZ();
                    zy.CurrentCal();

                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\PF4.txt"))
                    {
                    }
                    else
                    {
                        //wait.Close();
                        return false;
                    }
                    FileStream pf = new FileStream(System.Windows.Forms.Application.StartupPath + "\\PF4.txt", FileMode.Open);
                    StreamReader readLine = new StreamReader(pf, Encoding.Default);
                    char[] charSplit = new char[] { ' ' };
                    string strLine = readLine.ReadLine();
                    while (strLine != null && strLine != "")
                    {
                        string[] array1 = strLine.Split(charSplit);
                        strCon2 = " AND Type= '01' AND Number = " + array1[0];
                        strCon = strCon1 + strCon2;
                        PSPDEV devMX = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                        if (devMX != null)
                        {
                            PSP_ElcDevice elcDev = new PSP_ElcDevice();
                            elcDev.ProjectSUID = projectSUID;
                            elcDev.DeviceSUID = devMX.SUID;
                            elcDev = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);
                            if (elcDev != null)
                            {
                                elcDev.COL61 = devMX.Name;
                                elcDev.COL79 = devMX.ReferenceVolt.ToString();
                                elcDev.COL80 = ratedCapacity.ToString();
                                double temp = 0.0;
                                double.TryParse(array1[1], out temp);
                                elcDev.COL62 = (temp * (devMX.ReferenceVolt)).ToString();
                                temp = 0.0;
                                double.TryParse(array1[2], out temp);
                                elcDev.COL63 = (temp * Rad_to_Deg).ToString();
                                temp = 0.0;
                                double.TryParse(array1[3], out temp);
                                elcDev.COL64 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[4], out temp);
                                elcDev.COL65 = (temp * ratedCapacity).ToString();
                                PSP_ElcDevice elcTemp = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);

                                Services.BaseService.Update<PSP_ElcDevice>(elcDev);
                            }
                        }
                        strLine = readLine.ReadLine();
                    }
                    readLine.Close();
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH4.txt"))
                    {
                    }
                    else
                    {
                        //wait.Close();
                        return false;
                    }
                    FileStream dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DH4.txt", FileMode.Open);
                    readLine = new StreamReader(dh, Encoding.Default);
                    strLine = readLine.ReadLine();
                    while (strLine != null && strLine != "")
                    {
                        string[] array1 = strLine.Split(charSplit);
                        strCon2 = " AND Type= '05' AND Name = '" + array1[0] + "' AND FirstNode = " + array1[1] + " AND LastNode = " + array1[2];
                        strCon = strCon1 + strCon2;
                        PSPDEV devMX = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                        if (devMX != null)
                        {
                            PSP_ElcDevice elcDev = new PSP_ElcDevice();
                            elcDev.ProjectSUID = projectSUID;
                            elcDev.DeviceSUID = devMX.SUID;
                            elcDev = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);
                            if (elcDev != null)
                            {
                                elcDev.COL61 = devMX.Name;
                                elcDev.COL62 = devMX.FirstNode.ToString();
                                elcDev.COL63 = devMX.LastNode.ToString();
                                elcDev.COL79 = devMX.ReferenceVolt.ToString();
                                elcDev.COL80 = ratedCapacity.ToString();
                                double temp = 0.0;
                                double.TryParse(array1[3], out temp);
                                elcDev.COL64 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[4], out temp);
                                elcDev.COL65 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[5], out temp);
                                elcDev.COL66 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[6], out temp);
                                elcDev.COL67 = (temp * ratedCapacity).ToString();

                                temp = 0.0;
                                double.TryParse(array1[7], out temp);
                                elcDev.COL68 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[8], out temp);
                                elcDev.COL69 = (temp * ratedCapacity).ToString();
                                temp = 0.0;
                                double.TryParse(array1[9], out temp);
                                elcDev.COL70 = (temp * ratedCapacity / (Math.Sqrt(3) * devMX.ReferenceVolt)).ToString();

                                temp = 0.0;
                                double.TryParse(array1[10], out temp);
                                elcDev.COL71 = (temp * Rad_to_Deg).ToString();
                                temp = 0.0;
                                double.TryParse(array1[11], out temp);
                                elcDev.COL72 = (temp * (devMX.ReferenceVolt)).ToString();
                                temp = 0.0;
                                double.TryParse(array1[12], out temp);
                                elcDev.COL73 = (temp * (devMX.ReferenceVolt)).ToString();
                                PSP_ElcDevice elcTemp = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);

                                Services.BaseService.Update<PSP_ElcDevice>(elcDev);
                            }
                        }
                        strLine = readLine.ReadLine();
                    }
                    readLine.Close();
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\IH4.txt"))
                    {
                    }
                    else
                    {
                        //wait.Close();
                        return false;
                    }
                    FileStream ih = new FileStream(System.Windows.Forms.Application.StartupPath + "\\IH4.txt", FileMode.Open);
                    readLine = new StreamReader(ih, Encoding.Default);
                    strLine = readLine.ReadLine();
                    while (strLine != null && strLine != "")
                    {
                        string[] array1 = strLine.Split(charSplit);
                        strCon2 = " AND Type= '05' AND Name = '" + array1[0] + "' AND FirstNode = " + array1[1] + " AND LastNode = " + array1[2];
                        strCon = strCon1 + strCon2;
                        PSPDEV devMX = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                        if (devMX != null)
                        {
                            PSP_ElcDevice elcDev = new PSP_ElcDevice();
                            elcDev.ProjectSUID = projectSUID;
                            elcDev.DeviceSUID = devMX.SUID;
                            elcDev = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);
                            if (elcDev != null)
                            {
                                elcDev.COL61 = devMX.Name;
                                elcDev.COL62 = devMX.FirstNode.ToString();
                                elcDev.COL63 = devMX.LastNode.ToString();
                                elcDev.COL79 = devMX.ReferenceVolt.ToString();
                                elcDev.COL80 = ratedCapacity.ToString();
                                double temp = 0.0;
                                double.TryParse(array1[3], out temp);
                                elcDev.COL74 = (temp * ratedCapacity / (Math.Sqrt(3) * devMX.ReferenceVolt)).ToString();
                                temp = 0.0;
                                double.TryParse(array1[4], out temp);
                                elcDev.COL75 = (temp * Rad_to_Deg).ToString();
                                PSP_ElcDevice elcTemp = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev);

                                Services.BaseService.Update<PSP_ElcDevice>(elcDev);
                            }
                        }
                        strLine = readLine.ReadLine();
                    }
                    readLine.Close();
                }
                //wait.Close();
            }
            catch (System.Exception ex)
            {
                //wait.Close();
                MessageBox.Show("潮流计算结果不收敛,请检查输入参数!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return false;
            }
            return true;
        }
Пример #5
0
        private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            frnReport wFrom = new frnReport();
            if (e.ClickedItem.Text == "属性")
            {
                elementProperty();
            }
            tlVectorControl1.Operation = ToolOperation.Select;
            if (e.ClickedItem.Text == "短路计算")
            {

                wFrom.Owner = this;
                wFrom.Show();
                wFrom.Text = this.Text + "短路计算";
                wFrom.ShowText += "正在收集信息\t" + System.DateTime.Now.ToString();
                if (!addcheck(wFrom))
                {

                    return;
                }
                string duanluname = null;        //记录短路点的名字 如果是发生在支路上短路点的名字为线路连接的第一个母线名
                int tuxing = 0;
                int baobiao = 0;
                PSPDEV pspDuanlu = new PSPDEV();
                XmlElement element = tlVectorControl1.SVGDocument.CurrentElement;
                pspDuanlu.SUID = element.GetAttribute("Deviceid");
                pspDuanlu = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", pspDuanlu);
                if (pspDuanlu == null)
                    return;
                if (pspDuanlu.Type != "05" && pspDuanlu.Type != "01")
                    return;
                frmDuanlu dudu = new frmDuanlu(pspDuanlu);
                dudu.projectsuid = tlVectorControl1.SVGDocument.SvgdataUid;
                ElectricShorti lec = new ElectricShorti();
                int n11 = 0, n2 = 0, n3 = 0;
                double n4 = 0;

                if (dudu.ShowDialog() == DialogResult.OK)
                {
                    //int bigsmall=Convert.ToInt32(dudu.DuanluBigsmall);
                    try
                    {
                        if (!lec.CheckDL(tlVectorControl1.SVGDocument.SvgdataUid, this.ProjectUID, 100))
                            return;
                        string nodeType;
                        if (dudu.DuanluBaobiao == "是")
                            baobiao = 1;
                        if (dudu.DuanluTuxing == "图形输出节点电压")
                            tuxing = 1;
                        if (dudu.DuanluTuxing == "图形输出短路电流")
                            tuxing = 2;
                        //Duanlu.Name = dudu.DuanluPoint;
                        //Duanlu = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", Duanlu);
                        n4 = (double)Convert.ToInt32(dudu.hscool) / 100;
                        nodeType = pspDuanlu.Type;
                        if (pspDuanlu.Type == "01")
                        {
                            n11 = 0;
                            n2 = pspDuanlu.Number;
                            switch (dudu.DuanluType)
                            {
                                case "单相接地":
                                    n3 = 1;
                                    break;

                                case "两相接地":
                                    n3 = 3;
                                    break;
                                case "两相故障":
                                    n3 = 2;
                                    break;
                                case "三相故障":
                                    n3 = 0;
                                    break;
                                default:
                                    n3 = 1;
                                    break;
                            }

                            string 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); ;
                            string dlr = null;
                            bool flag = false;             //记录读的是一般线路还是两绕组变压器上的母线还是三绕组上面的

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

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

                                    flag = true;
                                    dlr = "0" + " " + psp.FirstNode + " " + psp.LastNode + " " + psp.Number + " " + "0 " + " " + n3.ToString();

                                }
                                if (pspDuanlu.Number == psp.LastNode && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0")
                                {
                                    flag = true;
                                    dlr = "0" + " " + psp.FirstNode + " " + psp.LastNode + " " + psp.Number + " " + "1 " + " " + n3.ToString();
                                }
                                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 = '" + tlVectorControl1.SVGDocument.SvgdataUid + "'AND PSPDEV.type='02'AND PSPDEV.KSwitchStatus = '0' order by PSPDEV.number";
                                IList list3 = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                                for (int i = 0; i < list3.Count; i++)
                                {
                                    dlr = null;
                                    psp = list3[i] as PSPDEV;
                                    PSPDEV devFirst = new PSPDEV();

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

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

                                        flag = true;
                                        dlr = "0" + " " + devFirst.Number + " " + devLast.Number + " " + psp.Number + " " + "0" + " " + n3.ToString();

                                    }
                                    if (pspDuanlu.Number == devLast.Number && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0")
                                    {
                                        flag = true;
                                        dlr = "0" + " " + devFirst.Number + " " + devLast.Number + " " + psp.Number + " " + "1" + " " + n3.ToString();
                                    }
                                    if (flag)
                                    {
                                        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 i = 0; i < list4.Count; i++)
                                {
                                    dlr = null;
                                    psp = list4[i] as PSPDEV;
                                    PSPDEV devINode = new PSPDEV();

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

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

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

                                    con = " WHERE Name='" + psp.ISwitch + "' AND ProjectID = '" + projectid + "'" + "AND Type='07'";
                                    IList listiswitch = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                                    con = " WHERE Name='" + psp.JSwitch + "' AND ProjectID = '" + projectid + "'" + "AND Type='07'";
                                    IList listjswitch = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                                    con = " WHERE Name='" + psp.HuganLine1 + "' AND ProjectID = '" + projectid + "'" + "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 (pspDuanlu.Number == devINode.Number && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0" && pspkswitch.KSwitchStatus == "0")
                                    {

                                        flag = true;
                                        dlr = "0" + " " + devINode.Number + " " + devJNode.Number + " " + psp.Number + " " + "0" + " " + n3.ToString();

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

                                    if (flag)
                                    {
                                        break;                 //跳出本循环 进行母线的另外一个母线短路

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

                                }
                            }
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\fault.txt"))
                            {
                                File.Delete(System.Windows.Forms.Application.StartupPath + "\\fault.txt");
                            }

                            FileStream VK = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fault.txt"), FileMode.OpenOrCreate);
                            StreamWriter str11 = new StreamWriter(VK);
                            str11.Write(dlr);
                            str11.Close();
                            n4 = 0;

                        }
                        else if (pspDuanlu.Type == "05")
                        {
                            //n11 = pspDuanlu.FirstNode;
                            //n2 = pspDuanlu.LastNode;
                            n11 = pspDuanlu.Number;
                            n2 = n11;
                            switch (dudu.DuanluType)
                            {
                                case "单相接地":
                                    n3 = 1;
                                    break;

                                case "两相接地":
                                    n3 = 3;
                                    break;
                                case "两相故障":
                                    n3 = 2;
                                    break;
                                case "三相故障":
                                    n3 = 0;
                                    break;
                                default:
                                    n3 = 0;
                                    break;
                            }
                            string dlr = null;
                            if (n4 < 1 && n4 > 0)
                            {
                                duanluname = pspDuanlu.Name;
                            }
                            dlr = "0" + " " + pspDuanlu.FirstNode + " " + pspDuanlu.LastNode + " " + pspDuanlu.Number + " " + n4 + " " + n3.ToString();

                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\fault.txt"))
                            {
                                File.Delete(System.Windows.Forms.Application.StartupPath + "\\fault.txt");
                            }

                            FileStream VK = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fault.txt"), FileMode.OpenOrCreate);
                            StreamWriter str11 = new StreamWriter(VK);
                            str11.Write(dlr);
                            str11.Close();
                        }
                        else
                        {
                            return;
                        }
                        XmlNodeList list = tlVectorControl1.SVGDocument.SelectNodes("svg/*[@flag='" + "1" + "']");
                        foreach (XmlNode node in list)
                        {
                            SvgElement elementde = node as SvgElement;
                            tlVectorControl1.SVGDocument.CurrentElement = elementde;
                            tlVectorControl1.Delete();
                        }
                        wFrom.ShowText += "\r\n进行短路计算!" + System.DateTime.Now.ToString();
                        shortcir shortCutCal = new shortcir();
                        shortCutCal.Show_shortcir(0,0);
                        //bool matrixflag=true;                //用来判断是否导纳矩阵的逆矩阵是否存在逆矩阵

                        string matrixstr = null;
                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Zmatrixcheck.txt"))
                        {
                            matrixstr = "正序导纳矩阵";
                            // matrixflag = false;
                        }
                        if (matrixstr != null)
                        {
                            matrixstr += ",";
                        }
                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Fmatrixcheck.txt"))
                        {
                            // matrixflag = false;
                            matrixstr += "负序导纳矩阵";
                        }
                        if (matrixstr != null)
                        {
                            matrixstr += ",";
                        }
                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Lmatrixcheck.txt"))
                        {
                            //matrixflag = false;
                            matrixstr += "零序导纳矩阵";
                        }
                        if (matrixstr != null)
                        {
                            wFrom.ShowText += "\r\n" + matrixstr + "不存在逆矩阵,请调整参数后再进行计算!" + System.DateTime.Now.ToString();
                            //MessageBox.Show(matrixstr + "不存在逆矩阵,请调整参数后再进行计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        string duanResult = null;
                        duanResult += "短路电流简表" + "\r\n" + "\r\n";
                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt"))
                        {
                        }
                        else
                        {
                            return;
                        }
                         wFrom.ShowText += "\r\n结果显示!" + 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[] { ' ' };
                        strLineGU = readLineGU.ReadLine();
                         int j = 0;
                        while (strLineGU != null)
                        {
                            arrayGU = strLineGU.Split(charSplitGU);
                            int i = 0;
                            string[] dev = new string[9];
                            dev.Initialize();
                            foreach (string str in arrayGU)
                            {
                                if (str != "")
                                {
                                    dev[i++] = str;
                                }
                            }
                            if (tuxing == 2 && j != 0)
                            {
                                PSPDEV CR = new PSPDEV();

                                if (dev[1] != "du")
                                {
                                   string con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "'AND PSPDEV.Name='" + dev[1] + "'";
                                    CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", con);
                                }
                                else
                                {
                                    string con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "'AND PSPDEV.Name='" + duanluname + "'AND PSPDEV.Type='05'";
                                    CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", con);
                                }

                                if (CR != null)
                                {
                                    if (CR.Type != "05")
                                    {
                                        XmlElement elementdl = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@Deviceid='" + CR.SUID + "']") as XmlElement;

                                        if (elementdl != null)
                                        {
                                            RectangleF bound = ((IGraph)elementdl).GetBounds();
                                            XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                            n1.SetAttribute("x", Convert.ToString(bound.X));
                                            n1.SetAttribute("y", Convert.ToString(bound.Y - 20));
                                            n1.InnerText = (Convert.ToDouble(dev[3]) * 100 / (Math.Sqrt(3) * CR.ReferenceVolt)).ToString("N4");
                                            n1.SetAttribute("layer", SvgDocument.currentLayer);
                                            n1.SetAttribute("flag", "1");
                                            n1.SetAttribute("stroke", "#FF0000");
                                            tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                                            tlVectorControl1.Operation = ToolOperation.Select;
                                            tlVectorControl1.Refresh();
                                        }
                                    }
                                    else
                                    {
                                        XmlElement elementdl = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@Deviceid='" + CR.SUID + "']") as XmlElement;

                                        if (elementdl != null)
                                        {
                                            PointF[] t = ((Polyline)elementdl).Points;

                                            PointF[] t2 = ((Polyline)elementdl).FirstTwoPoint;
                                            t = t2;
                                            PointF midt = new PointF((float)((t2[0].X + t2[1].X) / 2), (float)((t2[0].Y + t2[1].Y) / 2));
                                            float angel = 0f;
                                            angel = (float)(180 * Math.Atan2((t2[1].Y - t2[0].Y), (t2[1].X - t2[0].X)) / Math.PI);

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

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

                                            PointF center = new PointF((float)(t[0].X + (t[1].X - t[0].X) / 2), (float)(t[0].Y + (t[1].Y - t[0].Y) / 2));
                                            XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                            XmlElement n2dl = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline;
                                            PointF pStart = new PointF(center.X + (float)(15 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(15 * Math.Cos((angel) * Math.PI / 180)));
                                            PSPDEV psp = new PSPDEV();
                                            psp.FirstNode = CR.FirstNode;
                                            psp.LastNode = CR.LastNode;
                                            string con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "'AND PSPDEV.FirstNode='" + CR.FirstNode + "'AND PSPDEV.LastNode='"+CR.LastNode+"'";
                                            IList listParallel = Services.BaseService.GetList("SelectPSPDEVByCondition", con);

                                            PSPDEV tempss = new PSPDEV();

                                            foreach (PSPDEV devP in listParallel)
                                            {
                                                if ((angel > 10 && angel < 90) || (angel < 0 && Math.Abs(angel) < 90) || (angel > 180 && angel < 350))
                                                {
                                                    if (((devP.X1) > (CR.X1)))
                                                    {
                                                        pStart = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));

                                                    }
                                                }
                                                else if ((angel >= 0 && angel <= 10) || (angel >= 350 && angel <= 360) || (angel < 0 && Math.Abs(angel) <= 90))
                                                {
                                                    if (((devP.Y1) > (CR.Y1)))
                                                    {
                                                        pStart = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));

                                                    }
                                                }
                                                else if ((angel < 0 && Math.Abs(angel) > 90) || (angel >= 90 && angel <= 180))
                                                {
                                                    if (((devP.Y1) > (CR.Y1)))
                                                    {
                                                        pStart = new PointF(center.X - (float)(7 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(7 * Math.Cos((angel) * Math.PI / 180)));

                                                    }
                                                }
                                            }

                                            PointF newp1 = new PointF(t[0].X + (t[1].X - t[0].X) / 2 - (float)(15 * Math.Sin(angel)), t[0].Y + (t[1].Y - t[0].Y) / 2 - (float)(15 * Math.Cos(angel)));

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

                                            //if (Convert.ToDouble(dev[4]) >= 0)
                                            //{
                                            n1.InnerText = (Math.Abs(Convert.ToDouble(dev[3]) * 100 / (Math.Sqrt(3) * CR.ReferenceVolt))).ToString("N4");
                                            //}
                                            //else
                                            //{
                                            //    n1.InnerText = (Math.Abs(Convert.ToDouble(dev[3]))).ToString("N4");
                                            //}
                                            n1.SetAttribute("layer", SvgDocument.currentLayer);
                                            n1.SetAttribute("flag", "1");

                                            //if (Convert.ToDouble(dev[5]) == 1)
                                            //    n1.SetAttribute("stroke", "#FF0000");

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

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

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

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

                                            tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement;

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

                                            tlVectorControl1.RotateSelection(angel, pStart);
                                            if (Math.Abs(angel) > 90)
                                                tlVectorControl1.RotateSelection(180, pStart);
                                            PointF newp = new PointF(center.X + 10, center.Y + 10);

                                            tlVectorControl1.Refresh();

                                        }
                                    }
                                }
                                if (CR.NodeType == "05")
                                {
                                    PSPDEV fl = new PSPDEV();
                                    string con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "'AND PSPDEV.Number='" + CR.FirstNode +"'";
                                    fl = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", con);
                                    duanResult += dev[0] + "," + dev[1] + "," + Convert.ToDouble(dev[3]) * 100 / (Math.Sqrt(3) * fl.ReferenceVolt) + "\r\n";
                                }
                                else
                                {
                                    duanResult += dev[0] + "," + dev[1] + "," + Convert.ToDouble(dev[3]) * 100 / (Math.Sqrt(3) * CR.ReferenceVolt) + "\r\n";
                                }

                            }
                            else if (tuxing==1&&j!=0)
                            {
                                PSPDEV CR = new PSPDEV();

                                if (dev[1] != "du")
                                {
                                    string con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "'AND PSPDEV.Name='" + dev[1] + "'";
                                    CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", con);
                                }
                                else
                                {
                                    string con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "'AND PSPDEV.Name='" + duanluname + "'AND PSPDEV.Type='05'";
                                    CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", con);
                                }

                                if (CR.NodeType == "05")
                                {
                                    PSPDEV fl = new PSPDEV();
                                    string con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "'AND PSPDEV.Number='" + CR.FirstNode + "'";
                                    fl = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", con);
                                    duanResult += dev[0] + "," + dev[1] + "," + Convert.ToDouble(dev[3]) * 100 / (Math.Sqrt(3) * fl.ReferenceVolt) + "\r\n";
                                }
                                else
                                {
                                    duanResult += dev[0] + "," + dev[1] + "," + Convert.ToDouble(dev[3]) * 100 / (Math.Sqrt(3) * CR.ReferenceVolt) + "\r\n";
                                }
                            }
                            else if (j==0)
                            {
                                duanResult += dev[0] + "," + dev[1] + "," + dev[3]+ "\r\n";
                            }
                            strLineGU = readLineGU.ReadLine();
                            j++;
                        }
                        readLineGU.Close();
                        string dianYaResult = null;
                        dianYaResult += "母线电压结果" + "\r\n" + "\r\n";
                        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();
                        j = 0;
                        while (strLineDY != null)
                        {
                            arrayDY = strLineDY.Split(charSplitDY);
                            int i = 0;
                            string[] dev = new string[14];
                            dev.Initialize();
                            foreach (string str in arrayDY)
                            {
                                if (str != "")
                                {
                                    dev[i++] = str;
                                }
                            }
                            if (j == 0)
                            {
                                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 flag = true;     //判断此母线是短路点母线还是一般的母线
                                PSPDEV CR = new PSPDEV();

                                if (dev[1] != "du")
                                {
                                    string con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "'AND PSPDEV.Name='" + dev[1] + "'";
                                    CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", con); ;
                                }
                                else
                                {
                                    flag = false;
                                    string con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "'AND PSPDEV.Name='" + duanluname + "'AND PSPDEV.Type='05'";
                                    CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", con);
                                }

                                //CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByNameANDSVG", CR);
                                if (tuxing == 1)
                                {
                                    XmlElement elementdl = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@Deviceid='" + CR.SUID + "']") as XmlElement;

                                    if (elementdl != null)
                                    {
                                        RectangleF bound = ((IGraph)elementdl).GetBounds();
                                        XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                        XmlElement n22 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                        XmlElement n33 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                        n1.SetAttribute("x", Convert.ToString(bound.X));
                                        n1.SetAttribute("y", Convert.ToString(bound.Y - 60));
                                        n1.InnerText = "A相:" + (Convert.ToDouble(dev[2]) * CR.ReferenceVolt).ToString("N4") + "kV/" + (Convert.ToDouble(dev[3])).ToString("N4") + "°";
                                        n1.SetAttribute("layer", SvgDocument.currentLayer);
                                        n1.SetAttribute("flag", "1");
                                        tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                                        tlVectorControl1.Operation = ToolOperation.Select;
                                        tlVectorControl1.Refresh();
                                        n22.SetAttribute("x", Convert.ToString(bound.X));
                                        n22.SetAttribute("y", Convert.ToString(bound.Y - 40));
                                        n22.InnerText = "B相:" + (Convert.ToDouble(dev[4]) * CR.ReferenceVolt).ToString("N4") + "kV/" + (Convert.ToDouble(dev[5])).ToString("N4") + "°";
                                        n22.SetAttribute("layer", SvgDocument.currentLayer);
                                        n22.SetAttribute("flag", "1");
                                        tlVectorControl1.SVGDocument.RootElement.AppendChild(n22);
                                        tlVectorControl1.Operation = ToolOperation.Select;
                                        tlVectorControl1.Refresh();
                                        n33.SetAttribute("x", Convert.ToString(bound.X));
                                        n33.SetAttribute("y", Convert.ToString(bound.Y - 20));
                                        n33.InnerText = "C相:" + (Convert.ToDouble(dev[6]) * CR.ReferenceVolt).ToString("N4") + "kV/" + (Convert.ToDouble(dev[7])).ToString("N4") + "°";
                                        n33.SetAttribute("layer", SvgDocument.currentLayer);
                                        n33.SetAttribute("flag", "1");
                                        tlVectorControl1.SVGDocument.RootElement.AppendChild(n33);
                                        tlVectorControl1.Operation = ToolOperation.Select;
                                        tlVectorControl1.Refresh();
                                    }
                                }
                                if (flag)
                                    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();
                            j++;
                        }
                        readLineDY.Close();
                        string dianLiuResult = null;
                        dianLiuResult += "支路电流结果" + "\r\n" + "\r\n";
                        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;
                        while (strLineDL != null)
                        {
                            arrayDL = strLineDL.Split(charSplitDL);
                            int i = 0;
                            string[] dev = new string[15];
                            dev.Initialize();
                            foreach (string str in arrayDL)
                            {
                                if (str != "")
                                {
                                    dev[i++] = str;
                                }
                            }
                            if (j == 0)
                            {
                                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();
                                //CR.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                //CR.Number = Convert.ToInt32(dev[2]);
                                //CR.Type = "Polyline";
                                //CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByNumberAndSvgUIDAndType", CR);

                                //因为在线路电流输出时既有一般线路的电流、两绕组和三绕组线路的电流还有接地电容器和电抗器的电流,因此只将电流输出就行了

                                PSPDEV CR = new PSPDEV();
                               // CR.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;

                                if (dev[0] != "du")
                                {
                                    CR.Name = dev[0];
                                }
                                else
                                    CR.Name = dev[1];
                                string con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "'AND PSPDEV.Name='" + CR.Name + "'AND PSPDEV.Type='01'";
                                CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", con);
                                if (tuxing == 1)
                                {
                                    //    XmlElement elementdl = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@id='" + CR.EleID + "']") as XmlElement;

                                    //    if (elementdl != null)
                                    //    {
                                    //        PointF[] t = ((Polyline)elementdl).Points;

                                    //        PointF[] t2 = ((Polyline)elementdl).FirstTwoPoint;
                                    //        t = t2;
                                    //        PointF midt = new PointF((float)((t2[0].X + t2[1].X) / 2), (float)((t2[0].Y + t2[1].Y) / 2));
                                    //        float angel = 0f;
                                    //        angel = (float)(180 * Math.Atan2((t2[1].Y - t2[0].Y), (t2[1].X - t2[0].X)) / Math.PI);

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

                                    //        string tran = ((Polyline)elementdl).Transform.ToString();

                                    //        PointF center = new PointF((float)(t[0].X + (t[1].X - t[0].X) / 2), (float)(t[0].Y + (t[1].Y - t[0].Y) / 2));
                                    //        XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                    //        XmlElement n2dl = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline;
                                    //        PointF pStart = new PointF(center.X + (float)(15 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(15 * Math.Cos((angel) * Math.PI / 180)));
                                    //        PSPDEV psp = new PSPDEV();
                                    //        psp.FirstNode = CR.FirstNode;
                                    //        psp.LastNode = CR.LastNode;
                                    //        psp.SvgUID = CR.SvgUID;
                                    //        PSPDEV tempss = new PSPDEV();
                                    //        IList listParallel = Services.BaseService.GetList("SelectPSPDEVBySvgUIDandFirstOrLastNode", psp);
                                    //        foreach (PSPDEV devP in listParallel)
                                    //        {
                                    //            if ((angel > 10 && angel < 90) || (angel < 0 && Math.Abs(angel) < 90) || (angel > 180 && angel < 350))
                                    //            {
                                    //                if (((devP.X1) > (CR.X1)))
                                    //                {
                                    //                    pStart = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));

                                    //                }
                                    //            }
                                    //            else if ((angel >= 0 && angel <= 10) || (angel >= 350 && angel <= 360) || (angel < 0 && Math.Abs(angel) <= 90))
                                    //            {
                                    //                if (((devP.Y1) > (CR.Y1)))
                                    //                {
                                    //                    pStart = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));

                                    //                }
                                    //            }
                                    //            else if ((angel < 0 && Math.Abs(angel) > 90) || (angel >= 90 && angel <= 180))
                                    //            {
                                    //                if (((devP.Y1) > (CR.Y1)))
                                    //                {
                                    //                    pStart = new PointF(center.X - (float)(7 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(7 * Math.Cos((angel) * Math.PI / 180)));

                                    //                }
                                    //            }
                                    //        }

                                    //        PointF newp1 = new PointF(t[0].X + (t[1].X - t[0].X) / 2 - (float)(15 * Math.Sin(angel)), t[0].Y + (t[1].Y - t[0].Y) / 2 - (float)(15 * Math.Cos(angel)));

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

                                    //        //if (Convert.ToDouble(dev[4]) >= 0)
                                    //        //{
                                    //        n1.InnerText = (Math.Abs(Convert.ToDouble(dev[3]) * 100 / (Math.Sqrt(3) * CR.ReferenceVolt))).ToString("N4");
                                    //        //}
                                    //        //else
                                    //        //{
                                    //        //    n1.InnerText = (Math.Abs(Convert.ToDouble(dev[3]))).ToString("N4");
                                    //        //}
                                    //        n1.SetAttribute("layer", SvgDocument.currentLayer);
                                    //        n1.SetAttribute("flag", "1");

                                    //        //if (Convert.ToDouble(dev[3]) == 1)
                                    //        //    n1.SetAttribute("stroke", "#FF0000");

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

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

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

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

                                    //        tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement;

                                    //        RectangleF ttt = ((Polyline)elementdl).GetBounds();

                                    //        tlVectorControl1.RotateSelection(angel, pStart);
                                    //        if (Math.Abs(angel) > 90)
                                    //            tlVectorControl1.RotateSelection(180, pStart);
                                    //        PointF newp = new PointF(center.X + 10, center.Y + 10);

                                    //        tlVectorControl1.Refresh();

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

                                //if (CR.NodeType == "Polyline")
                                //{
                                //    PSPDEV fl = new PSPDEV();
                                //    fl.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                //    fl.Number = CR.FirstNode;
                                //    fl.Type = nodeType;
                                //    fl = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByNumberAndSvgUIDAndType", CR);
                                //    dianLiuResult += dev[0] + "," + dev[1] + "," + dev[2] + "," + Convert.ToDouble(dev[3]) * 100 / (Math.Sqrt(3) * fl.ReferenceVolt) + "," + dev[4] + "," + Convert.ToDouble(dev[5]) * 100 / (Math.Sqrt(3) * fl.ReferenceVolt) + "," + dev[6] + "," + Convert.ToDouble(dev[7]) * 100 / (Math.Sqrt(3) * fl.ReferenceVolt) + "," + dev[8] + "," +
                                //    Convert.ToDouble(dev[9]) * 100 / (Math.Sqrt(3) * fl.ReferenceVolt) + "," + dev[10] + "," + Convert.ToDouble(dev[11]) * 100 / (Math.Sqrt(3) * fl.ReferenceVolt) + dev[12] + "," + Convert.ToDouble(dev[13]) * 100 / (Math.Sqrt(3) * fl.ReferenceVolt) + "," + dev[14] + "\r\n";
                                //}
                                //else
                                //{
                                //    dianLiuResult += dev[0] + "," + dev[1] + "," + dev[2] + "," + Convert.ToDouble(dev[3]) * 100 / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[4] + "," + Convert.ToDouble(dev[5]) * 100 / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[6] + "," + Convert.ToDouble(dev[7]) * 100 / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[8] + "," +
                                //    Convert.ToDouble(dev[9]) * 100 / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[10] + "," + Convert.ToDouble(dev[11]) * 100 / (Math.Sqrt(3) * CR.ReferenceVolt) + dev[12] + "," + Convert.ToDouble(dev[13]) * 100 / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[14] + "\r\n";
                                //}

                            }

                            strLineDL = readLineDL.ReadLine();
                            j++;
                        }
                        readLineDL.Close();
                        if (baobiao == 1)
                        {
                             wFrom.ShowText += "\r\n形成报表!" + 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.GetEncoding("GB2312"));
                            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.GetEncoding("GB2312"));
                            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.GetEncoding("GB2312"));
                            strDL.Write(dianLiuResult);
                            strDL.Close();
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "短路计算结果.xls"))
                            {
                                File.Delete(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "短路计算结果.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[3, 1], xSheet.Cells[3, 3]).Interior.ColorIndex = 45;
                            xSheet.get_Range(xSheet.Cells[4, 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;
                            newWorksheet.get_Range(newWorksheet.Cells[3, 1], newWorksheet.Cells[3, 14]).Interior.ColorIndex = 45;
                            newWorksheet.get_Range(newWorksheet.Cells[4, 1], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6;
                            newWorksheet.get_Range(newWorksheet.Cells[4, 3], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 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;
                            newWorkSheet1.get_Range(newWorkSheet1.Cells[3, 1], newWorkSheet1.Cells[3, 15]).Interior.ColorIndex = 45;
                            newWorkSheet1.get_Range(newWorkSheet1.Cells[4, 1], newWorkSheet1.Cells[newWorkSheet1.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6;
                            newWorkSheet1.get_Range(newWorkSheet1.Cells[4, 2], newWorkSheet1.Cells[newWorkSheet1.UsedRange.Rows.Count, 2]).Interior.ColorIndex = 6;
                            newWorkSheet1.get_Range(newWorkSheet1.Cells[4, 4], newWorkSheet1.Cells[newWorkSheet1.UsedRange.Rows.Count, 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 + "\\" + tlVectorControl1.SVGDocument.FileName + "短路计算结果.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();
                             wFrom.ShowText += "\r\n结果成功!" + System.DateTime.Now.ToString();
                        }

                    }
                    catch (Exception e1)
                    {
                         wFrom.ShowText += "\r\n计算失败,短路数据有问题,请调整后再计算!" + System.DateTime.Now.ToString();
                       // MessageBox.Show("短路数据有问题,请调整后再计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            else if (e.ClickedItem.Text == "区域打印")
            {
                setTJhide();
                PrintHelper ph = new PrintHelper(tlVectorControl1, mapview);
                ph.blshowflag = false;
                frmPrinter dlg = new frmPrinter();
                dlg.printHelper = ph;
                dlg.ShowDialog();
                setTJshow();
                return;
            }
        }
Пример #6
0
        private void dotNetBarManager1_ItemClick(object sender, EventArgs e)
        {
            DevComponents.DotNetBar.ButtonItem btItem = sender as DevComponents.DotNetBar.ButtonItem;
            //Layer layer1 = (Layer)LayerBox.ComboBoxEx.SelectedItem;
            if (btItem != null)
            {
                switch (btItem.Name)
                {
                    #region 文件操作
                    case "mNew":

                        //NewFile(fileType, this.Text);
                        frmNewProject frmprojectDLG = new frmNewProject();
                        frmprojectDLG.Name = "";
                        frmprojectDLG.FileType = "短路";
                        if (frmprojectDLG.ShowDialog() == DialogResult.OK)
                        {
                            tlVectorControl1.NewFile();
                            PSP_ELCPROJECT pd = new PSP_ELCPROJECT();
                            pd.Name = frmprojectDLG.Name;
                            pd.FileType = frmprojectDLG.FileType;
                            pd.Class = System.DateTime.Now.ToString();
                            pd.ProjectID = this.ProjectUID;
                            tlVectorControl1.SVGDocument.SvgdataUid = pd.ID;
                            SvgDocument.currentLayer = Layer.CreateNew("默认层", tlVectorControl1.SVGDocument).ID;
                            Layer la = tlVectorControl1.SVGDocument.GetLayerByID(SvgDocument.currentLayer);
                            la.SetAttribute("layerType", "电网规划层");
                            Services.BaseService.Create<PSP_ELCPROJECT>(pd);
                            if (pd.ID != null)
                            {
                                Open(pd.ID);
                                intdata(pd.ID);
                                this.Text = frmname + "-" + pd.Name;
                            }
                            this.Show();
                            jxtbar2(2);
                            LoadShape("symbol23.xml");
                        }
                        break;
                    case "mOpen":
                        if (tlVectorControl1.IsModified == true)
                        {
                            DialogResult a;
                            a = MessageBox.Show("图形已修改,是否保存?", "提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);

                            if (a == DialogResult.Yes)
                            {
                                Save();
                            }
                            else if (a == DialogResult.No)
                            {
                            }
                            else if (a == DialogResult.Cancel)
                            {
                                return;
                            }

                        }
                        OpenProject op = new OpenProject();
                        op.ProjectID = this.ProjectUID;
                        op.Initdata(true);
                        if (op.ShowDialog() == DialogResult.OK)
                        {
                            if (op.FileSUID != null)
                            {
                                Open(op.FileSUID);
                                intdata(op.FileSUID);
                                this.Text = frmname + "-" + op.FileName;
                            }
                            this.Show();
                            jxtbar2(2);
                            LoadShape("symbol23.xml");
                        }
                        break;
                    case "btExSymbol":
                        tlVectorControl1.ExportSymbol();
                        break;
                    case "mjxt"://导入接线图

                        break;
                    case "mSave":
                        Save();
                        //tlVectorControl1.Save();
                        //frmElementName dlg = new frmElementName();
                        //dlg.TextInput = tlVectorControl1.SVGDocument.FileName;
                        //if (dlg.ShowDialog() == DialogResult.OK)
                        //{
                        //    tlVectorControl1.SVGDocument.FileName = dlg.TextInput;
                        //    Save();
                        //}
                        break;
                    case "mExit":
                        this.Close();
                        break;
                    case "bt1":
                        //InitTK();
                        break;
                    case "bt2":
                        break;
                    case "mPriSet":
                        this.tlVectorControl1.Operation = ToolOperation.InterEnclosurePrint;
                        printToolStripMenuItem.Visible = true;
                        break;
                    case "mPrint":
                        tlVectorControl1.Print();

                        break;
                    case "mImport":
                        ExportImage();
                        break;
                    case "mView":
                        //frmSvgView fView = new frmSvgView();
                        //fView.Open(tlVectorControl1.SVGDocument.SvgdataUid);
                        //fView.Show();

                        break;

                    case "deviceparam":
                        frmProjectManager frmPdlg = new frmProjectManager();
                        frmPdlg.SetMode(tlVectorControl1.SVGDocument.SvgdataUid);
                        frmPdlg.ShowDialog();
                        break;
                    //case "mIncreaseView":
                    //    tlVectorControl1.Operation = ToolOperation.IncreaseView;
                    //    break;
                    case "mRzb":
                        frmRatio fRat = new frmRatio();
                        string viewRat = tlVectorControl1.SVGDocument.getRZBRatio();
                        if (viewRat != "")
                        {
                            fRat.InitData(viewRat);
                        }
                        if (fRat.ShowDialog() == DialogResult.OK)
                        {
                            viewRat = fRat.ViewScale;
                            tlVectorControl1.SVGDocument.setRZBRatio(viewRat);
                        }
                        break;

                    case "mAbout":

                        frmAbout frma = new frmAbout();
                        frma.ShowDialog();
                        break;

                    case "ButtonItem10":

                        break;
                    case "Dlqibutt":
                        break;
                    //MessageBox.Show("请选中母线点,然后点击右键输入断路器属性" "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //duluqiflag=true;
                    //基础操作
                    case "mFreeTransform":
                        tlVectorControl1.Operation = ToolOperation.FreeTransform;

                        break;
                    case "mCJ":
                        tlVectorControl1.Operation = ToolOperation.PolyLine;
                        csOperation = CustomOperation.OP_MeasureDistance;
                        break;
                    //case "ButtonItem2":
                    //    break;
                    #endregion
                    #region 无功优化参数维护
                    case "VoltLimit":
                        break;
                    case "GeneratorLimit":
                        break;
                    case "TransformLimit":
                        break;
                    case "SVC":
                        break;
                    #endregion
                    #region 基础图元
                    case "mLayer":
                        tlVectorControl1.LayerManager();
                        break;
                    case "mDecreaseView":
                        tlVectorControl1.Operation = ToolOperation.DecreaseView;

                        break;
                    case "mIncreaseView":

                        tlVectorControl1.Operation = ToolOperation.IncreaseView;
                        break;
                    case "mRoam":
                        tlVectorControl1.Operation = ToolOperation.Roam;

                        break;
                    case "mSelect":
                        tlVectorControl1.Operation = ToolOperation.Select;
                        break;
                    case "mSel":

                        tlVectorControl1.Operation = ToolOperation.FreeTransform;
                        break;
                    //case "mFreeTransform":
                    //    tlVectorControl1.Operation = ToolOperation.FreeTransform;

                    //    break;
                    case "mFreeLines"://锁套
                        tlVectorControl1.Operation = ToolOperation.FreeLines;

                        break;
                    case "mFreePath":
                        tlVectorControl1.Operation = ToolOperation.FreePath;

                        break;
                    case "mShapeTransform":
                        tlVectorControl1.Operation = ToolOperation.ShapeTransform;

                        break;
                    case "mAngleRectangle":
                        tlVectorControl1.Operation = ToolOperation.AngleRectangle;

                        break;
                    case "mEllipse":
                        tlVectorControl1.Operation = ToolOperation.Ellipse;

                        break;
                    case "mLine":
                        tlVectorControl1.Operation = ToolOperation.ConnectLine_Polyline;

                        break;
                    case "mPolyline":
                        tlVectorControl1.Operation = ToolOperation.PolyLine;

                        break;
                    case "mConnectLine":
                      tlVectorControl1.Operation = ToolOperation.ConnectLine;
                        //tlVectorControl1.Operation = ToolOperation.ConnectLine_Polyline;
                        break;

                    case "mPolygon":
                        tlVectorControl1.Operation = ToolOperation.Polygon;

                        break;
                    case "mImage":
                        tlVectorControl1.Operation = ToolOperation.Image;
                        break;
                    case "mText":
                        tlVectorControl1.Operation = ToolOperation.Text;
                        break;
                    case "mBezier":
                        tlVectorControl1.Operation = ToolOperation.Bezier;

                        break;
                    case "ButtonItem2":

                        break;
                    case "ButtonItem8":

                        break;
                    case "mCheck":
                        break;
                    case "niula":
                        break;
                    case "pq":

                        break;

                    case "GaussSeidel":

                        break;
                    case "PowerLossCal":

                        break;
                    case "N_RZYz":

                        break;
                    case "WebRela":                        //进行网络N-1检验

                        break;
                    case "TransRela":                       //进行变压器N-1检验

                        break;
                    case "Shortibut":
                        if (!addcheck())  //检验是不是还有元件需要添加

                            return;
                        ElectricShorti elc = new ElectricShorti();
                       string strID =tlVectorControl1.SVGDocument.SvgdataUid;
                        //elc.CheckDL(strID, 100);
                        int n3 = 0;
                        ShortTform shorttype = new ShortTform();
                        frnReport wduanlu = new frnReport();
                        wduanlu.Owner = this;
                        wduanlu.Text = this.Text;
                        wduanlu.Show();
                        wduanlu.ShowText += "进行相关设置\t" + System.DateTime.Now.ToString();
                        shorttype.ShowDialog();
                        if (shorttype.DialogResult == DialogResult.OK)
                        {
                            switch (shorttype.DuanluType)
                            {
                                case "单相接地":
                                    n3 = 1;
                                    break;

                                case "两相接地":
                                    n3 = 3;
                                    break;
                                case "两相故障":
                                    n3 = 2;
                                    break;
                                case "三相故障":
                                    n3 = 0;
                                    break;

                            }
                            elc.OutType = shorttype.Mathindex;
                        }
                        //elc.P1 = strID; elc.P2 = this.ProjectUID; elc.P3 = n3; elc.P4 = 100;
                        //Thread wait = new Thread(new ThreadStart(elc.temp));
                        //wait.Start();
                       // WaitDialogForm wait = null;
                        try
                        {
                            //wait = new WaitDialogForm("", "正在处理数据, 请稍候...");
                            elc.AllShort(strID, this.ProjectUID, n3, 100,wduanlu);
                           // wait.Close();
                        }
                        catch (Exception exc)
                        {
                            Debug.Fail(exc.Message);
                            HandleException.TryCatch(exc);
                            //wait.Close();
                            wduanlu.ShowText += "\r\n短路计算失败" + System.DateTime.Now.ToString();
                            return;
                        }

                        break;
                    case "ZLcheck":

                       elc = new ElectricShorti();

                        strID = tlVectorControl1.SVGDocument.SvgdataUid;
                        WaitDialogForm wait = null;
                        try
                        {
                            wait = new WaitDialogForm("", "正在处理数据, 请稍候...");
                            wait.Close();
                            elc.Allshortcheck(strID, this.ProjectUID, 100, 3);

                        }
                        catch (Exception exc)
                        {
                            Debug.Fail(exc.Message);
                            Itop.Client.Common.HandleException.TryCatch(exc);
                            wait.Close();
                            return;
                        }

                       // Allshortcheck(3);
                        dotNetBarManager1.Bars["bar2"].GetItem("ZLcheck").Enabled = false;
                        dotNetBarManager1.Bars["bar2"].GetItem("Jiaoliucheck").Enabled = true;
                        //dotNetBarManager1.Bars["bar2"].GetItem("DLqiOutResult").Enabled =true;
                        break;
                    case "Jiaoliucheck":
                       elc = new ElectricShorti();

                        strID = tlVectorControl1.SVGDocument.SvgdataUid;
                     wait = null;
                        try
                        {
                            wait = new WaitDialogForm("", "正在处理数据, 请稍候...");
                            wait.Close();
                            elc.Allshortcheck(strID, this.ProjectUID, 100, 2);

                        }
                        catch (Exception exc)
                        {
                            Debug.Fail(exc.Message);
                            Itop.Client.Common.HandleException.TryCatch(exc);
                            wait.Close();
                            return;

                        }
                       // Allshortcheck(2);
                        dotNetBarManager1.Bars["bar2"].GetItem("Jiaoliucheck").Enabled = false;
                        dotNetBarManager1.Bars["bar2"].GetItem("ZLcheck").Enabled = true;
                        break;
                    case "dd":
                        //SubPrint = true;
                        tlVectorControl1.Operation = ToolOperation.InterEnclosurePrint;
                        break;

                    case "NiulaResult":

                        break;
                    case "GaussSeidelResult":

                        break;
                    case "N_RZYzResult":

                        break;
                    case "VoltEvaluation":
                        break;
                    case "PowerLoss":

                        break;
                    case "ZLPResult1":

                        break;

                    case "mDLR":

                        break;

                    case "mEnclosure":
                        tlVectorControl1.Operation = ToolOperation.Enclosure;

                        break;

                    case "mGroup":
                        tlVectorControl1.Group();
                        break;
                    case "mUnGroup":
                        tlVectorControl1.UnGroup();
                        break;
                    case "mlinelx":
                        tlVectorControl1.Operation = ToolOperation.ConnectLine_Line;
                        break;
                    case "mzxlx":
                        tlVectorControl1.Operation = ToolOperation.ConnectLine_Rightangle;
                        break;
                    case "mqxlx":
                        tlVectorControl1.Operation = ToolOperation.ConnectLine_Spline;
                        break;
                    case "mqzlx":
                        tlVectorControl1.Operation = ToolOperation.ConnectLine_Polyline;
                        break;
                    case "mCJ1":
                        tlVectorControl1.Operation = ToolOperation.PolyLine;
                        csOperation = CustomOperation.OP_MeasureDistance;
                        break;
                    case "powerFactor":

                        break;
                    #endregion

                    #region 视图
                    case "mOption":
                        tlVectorControl1.SetOption();
                        break;
                    case "mAirscape":
                        frmAirscape fAir = new frmAirscape();
                        fAir.InitData(tlVectorControl1);
                        fAir.Owner = this;
                        fAir.ShowInTaskbar = false;
                        fAir.Top = Screen.PrimaryScreen.WorkingArea.Height - 250;
                        fAir.Left = Screen.PrimaryScreen.WorkingArea.Width - 300;
                        fAir.Show();
                        break;
                    case "btTL":
                        frmGlebeTypeList fgle = new frmGlebeTypeList();
                        fgle.Show();
                        break;
                    #endregion

                    #region 布局,对齐,顺序
                    case "mRotate":
                        if (btItem.Tag is ButtonItem)
                        {
                            btItem = btItem.Tag as ButtonItem;
                            tlVectorControl1.FlipX();

                        }
                        else
                        {
                            tlVectorControl1.FlipX();
                        }
                        break;
                    case "mToH":

                        tlVectorControl1.FlipX();
                        //this.rotateButton.Tag = btItem;
                        //this.rotateButton.ImageIndex = btItem.ImageIndex;
                        break;
                    case "mToV":
                        tlVectorControl1.FlipY();
                        //this.rotateButton.Tag = btItem;
                        //this.rotateButton.ImageIndex = btItem.ImageIndex;
                        break;
                    case "mToLeft":
                        tlVectorControl1.RotateSelection(-90f);
                        ////this.rotateButton.Tag = btItem;
                        ////this.rotateButton.ImageIndex = btItem.ImageIndex;
                        break;
                    case "mToRight":
                        tlVectorControl1.RotateSelection(90f);
                        //this.rotateButton.Tag = btItem;
                        //this.rotateButton.ImageIndex = btItem.ImageIndex;
                        break;
                    case "mAlign":
                        if (btItem.Tag is ButtonItem)
                        {
                            btItem = btItem.Tag as ButtonItem;
                            tlVectorControl1.Align(AlignType.Left);

                        }
                        else
                        {
                            tlVectorControl1.Align(AlignType.Left);

                        }
                        tlVectorControl1.Refresh();
                        break;
                    case "mAlignLeft":
                        tlVectorControl1.Align(AlignType.Left);
                        this.alignButton.ImageIndex = btItem.ImageIndex;
                        this.alignButton.Tag = btItem;
                        tlVectorControl1.Refresh();
                        break;
                    case "mAlignRight":
                        tlVectorControl1.Align(AlignType.Right);
                        this.alignButton.ImageIndex = btItem.ImageIndex;
                        this.alignButton.Tag = btItem;
                        tlVectorControl1.Refresh();
                        break;
                    case "mAlignTop":
                        tlVectorControl1.Align(AlignType.Top);
                        this.alignButton.ImageIndex = btItem.ImageIndex;
                        this.alignButton.Tag = btItem;
                        tlVectorControl1.Refresh();
                        break;
                    case "mAlignBottom":
                        tlVectorControl1.Align(AlignType.Bottom);
                        this.alignButton.ImageIndex = btItem.ImageIndex;
                        this.alignButton.Tag = btItem;
                        tlVectorControl1.Refresh();
                        break;
                    case "mAlignHorizontalCenter":
                        tlVectorControl1.Align(AlignType.HorizontalCenter);
                        this.alignButton.ImageIndex = btItem.ImageIndex;
                        this.alignButton.Tag = btItem;
                        tlVectorControl1.Refresh();
                        break;
                    case "mAlignVerticalCenter":
                        tlVectorControl1.Align(AlignType.VerticalCenter);
                        this.alignButton.ImageIndex = btItem.ImageIndex;
                        this.alignButton.Tag = btItem;
                        tlVectorControl1.Refresh();
                        break;
                    case "mOrder":
                        if (btItem.Tag is ButtonItem)
                        {
                            btItem = btItem.Tag as ButtonItem;
                            tlVectorControl1.ChangeLevel(LevelType.Top);

                        }
                        else
                        {
                            tlVectorControl1.ChangeLevel(LevelType.Top);
                        }

                        break;
                    case "mGoTop":
                        tlVectorControl1.ChangeLevel(LevelType.Top);
                        this.orderButton.Tag = btItem;
                        this.orderButton.ImageIndex = btItem.ImageIndex;
                        break;
                    case "mGoUp":
                        tlVectorControl1.ChangeLevel(LevelType.Up);
                        this.orderButton.Tag = btItem;
                        this.orderButton.ImageIndex = btItem.ImageIndex;
                        break;
                    case "mGoDown":
                        tlVectorControl1.ChangeLevel(LevelType.Down);
                        this.orderButton.Tag = btItem;
                        this.orderButton.ImageIndex = btItem.ImageIndex;
                        break;
                    case "mGoBottom":
                        tlVectorControl1.ChangeLevel(LevelType.Bottom);
                        this.orderButton.Tag = btItem;
                        this.orderButton.ImageIndex = btItem.ImageIndex;
                        break;
                    #endregion
                    #region 图元操作
                    case "mCopy":
                        tlVectorControl1.Copy();
                        break;
                    case "mCut":
                        tlVectorControl1.Cut();
                        break;
                    case "mPaste":
                        tlVectorControl1.Paste();
                        break;
                    case "mDelete":
                        if (tlVectorControl1.SVGDocument.CurrentElement is SVG)
                        {
                        }
                        else
                        {
                            if (MessageBox.Show("确定要删除么?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                            {
                                SvgElementCollection collection = tlVectorControl1.SVGDocument.SelectCollection;
                                foreach (XmlElement element in collection)
                                {
                                    PSPDEV pspDev = new PSPDEV();
                                    pspDev.EleID = element.GetAttribute("id");
                                    pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                    pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                                    Services.BaseService.Delete<PSPDEV>(pspDev);
                                }
                                tlVectorControl1.Delete();
                            }

                        }
                        break;
                    case "mUodo":
                        tlVectorControl1.Undo();
                        break;
                    case "mRedo":
                        tlVectorControl1.Redo();
                        break;
                    #endregion
                    #region 业务操作

                    case "mXLine":
                        tlVectorControl1.Operation = ToolOperation.Select;
                        tlVectorControl1.Operation = ToolOperation.XPolyLine;
                        break;
                    case "mYLine":
                        tlVectorControl1.Operation = ToolOperation.Select;
                        tlVectorControl1.Operation = ToolOperation.YPolyLine;
                        break;

                    case "mSaveGroup":
                        if (tlVectorControl1.SVGDocument.SelectCollection.Count > 1)
                        {
                            string content = "<svg>";
                            SvgElementCollection col = tlVectorControl1.SVGDocument.SelectCollection;
                            for (int i = 0; i < col.Count; i++)
                            {
                                SvgElement _e = (SvgElement)col[i];
                                if (_e.ID != "svg")
                                {
                                    content = content + _e.OuterXml;
                                }
                            }
                            RectangleF rect = tlVectorControl1.DrawArea.viewer.SelectedViewRectangle;

                            content = content + "</svg>";
                            frmSaveGroup fm = new frmSaveGroup();
                            fm.rect = rect;
                            fm.Content = content;
                            fm.ShowDialog();
                        }
                        else
                        {
                            MessageBox.Show("请至少选择2个图元。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        break;

                    case "mInsert":
                        frmUseGroup fg = new frmUseGroup();
                        if (fg.ShowDialog() == DialogResult.OK)
                        {
                            UseGroup u = fg.SelectedUseGroup;
                            if (u != null)
                            {
                                frmXY xy = new frmXY();
                                if (xy.ShowDialog() == DialogResult.OK)
                                {
                                    decimal x = xy.GetX();
                                    decimal y = xy.GetY();
                                    string content = u.Content;
                                    XmlDocument doc = new XmlDocument();
                                    doc.LoadXml(u.Content);
                                    XmlNodeList list = doc.ChildNodes;
                                    XmlNode _node = list[0];
                                    XmlNodeList sonlist = _node.ChildNodes;
                                    XmlElement ele = tlVectorControl1.SVGDocument.CreateElement("g");
                                    ele.SetAttribute("layer", SvgDocument.currentLayer);
                                    for (int i = 0; i < sonlist.Count; i++)
                                    {
                                        XmlNode _sonnode = sonlist[i];
                                        //string str = _sonnode.OuterXml;
                                        if (_sonnode.Name == "use")
                                        {
                                            string sid = ((XmlElement)_sonnode).GetAttribute("xlink:href");
                                            XmlNode _snode = symbolSelector.SymbolDoc.SelectSingleNode("//*[@id='" + sid.Substring(1) + "']");
                                            tlVectorControl1.SVGDocument.AddDefsElement((SvgElement)_snode);
                                        }
                                        ele.AppendChild(_sonnode);
                                        string ss = ele.OuterXml;
                                    }
                                    //RectangleF r=((Group)ele).GetBounds();
                                    string tr = "matrix(1,0,0,1,";

                                    tr = tr + Convert.ToString(x - Convert.ToDecimal(u.X)) + ",";
                                    tr = tr + Convert.ToString(y - Convert.ToDecimal(u.Y)) + ")";

                                    ele.SetAttribute("transform", tr);
                                    // transform="matrix(1,0,0,1,2558.82,-352.94)"
                                    tlVectorControl1.SVGDocument.RootElement.AppendChild(ele);
                                    tlVectorControl1.SVGDocument.SelectCollection.Clear();
                                    tlVectorControl1.SVGDocument.SelectCollection.Add((SvgElement)ele);
                                    tlVectorControl1.UnGroup();
                                    // tlVectorControl1.Refresh();
                                }
                            }
                        }
                        break;
                    case "PSPIdleOptimize":
                        break;
                    #endregion
                    #region 参数维护
                    case "mNodeParam":

                        break;
                    case "mLineParam":

                        break;
                    case "mWire":

                        break;
                    case "nTransformLineParam":

                        break;
                    case "nGNDLineParam":

                        break;
                    case "mLineDL":

                        break;
                    case "mFadianDL":

                        break;
                    case "mConvert":

                        break;

                    #endregion
                }
            }
        }
Пример #7
0
        private void ShowResult(int order, frnReport wFrom)
        {
            wFrom.ShowText += "\r\n开始显示计算结果\t" + System.DateTime.Now.ToString();
            try {
                XmlNodeList list = tlVectorControl1.SVGDocument.SelectNodes("svg/*[@flag='" + "1" + "']");

                foreach (XmlNode node in list) {
                    SvgElement element = node as SvgElement;
                    if ((element.GetAttribute("textn1id") == null || element.GetAttribute("textn1id") == "") && (element.GetAttribute("textn2id") == null || element.GetAttribute("textn2id") == "")) {
                        tlVectorControl1.SVGDocument.CurrentElement = element;
                        tlVectorControl1.Delete();
                    }
                }
                double yinzi = 0, capability = 0, volt = 0, standvolt = 0, current = 0;
                //PSPDEV benchmark = new PSPDEV();
                //benchmark.Type = "power";
                //benchmark.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                //IList list3 = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", benchmark);
                //if (list3 == null)
                //{
                //    MessageBox.Show("请设置基准后再进行计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //    return;
                //}
                //foreach (PSPDEV dev in list3)
                //{
                //    yinzi = Convert.ToDouble(dev.PowerFactor);
                //    capability = Convert.ToDouble(dev.StandardCurrent);
                //    volt = Convert.ToDouble(dev.StandardVolt);
                //    TLPSPVmin = dev.iV;
                //    TLPSPVmax = dev.jV;
                //    if (dev.PowerFactor == 0)
                //    {
                //        yinzi = 1;
                //    }
                //    if (dev.StandardCurrent == 0)
                //    {
                //        capability = 1;
                //    }
                //    if (dev.StandardVolt == 0)
                //    {
                //        volt = 1;
                //    }
                //    standvolt = volt;
                //    current = capability / (Math.Sqrt(3) * volt);
                //};

                //SvgDocument.currentLayer = Layer.CreateNew("结果显示", tlVectorControl1.SVGDocument).ID;
                tlVectorControl1.SVGDocument.AcceptChanges = true;
                XmlNodeList useList = tlVectorControl1.SVGDocument.SelectNodes("svg/use");
                XmlNodeList layerlist = tlVectorControl1.SVGDocument.GetElementsByTagName("layer");
                Layer layResult;
                bool lb = true;
                foreach (Layer lay in layerlist) {
                    if (lay.GetAttribute("label") == "结果显示") {
                        SvgDocument.currentLayer = lay.ID;
                        lb = false;
                    }
                }
                if (lb) {
                    SvgDocument.currentLayer = Layer.CreateNew("结果显示", tlVectorControl1.SVGDocument).ID;
                }
                wFrom.ShowText += "\r\n正在显示变电站信息\t" + System.DateTime.Now.ToString();
                int count = 0;
                foreach (XmlNode node in useList) {
                    count++;
                    XmlElement element = node as XmlElement;
                    string strCon = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "' AND SvgUID = '" + (element).GetAttribute("Deviceid") + "' AND Type = '01' order by ratevolt desc,referencevolt desc,col2 desc,col22 desc,col42 desc,col62 desc";
                    switch (order) {
                        case 0:
                            strCon = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "' AND SvgUID = '" + (element).GetAttribute("Deviceid") + "' AND Type = '01' order by ratevolt desc,referencevolt desc,col2 desc";
                            break;
                        case 1:
                            strCon = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "' AND SvgUID = '" + (element).GetAttribute("Deviceid") + "' AND Type = '01' order by ratevolt desc,referencevolt desc,col22 desc";
                            break;
                        case 2:
                            strCon = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "' AND SvgUID = '" + (element).GetAttribute("Deviceid") + "' AND Type = '01' order by ratevolt desc,referencevolt desc,col42 desc";
                            break;
                        case 3:
                            strCon = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "' AND SvgUID = '" + (element).GetAttribute("Deviceid") + "' AND Type = '01' order by ratevolt desc,referencevolt desc,col62 desc";
                            break;
                        default:
                            strCon = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "' AND SvgUID = '" + (element).GetAttribute("Deviceid") + "' AND Type = '01' order by ratevolt desc,referencevolt desc,col2 desc,col22 desc,col42 desc,col62 desc";
                            break;
                    }
                    //XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + element.GetAttribute("id") + "']");
                    //string strCon = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "' AND SvgUID = '" + (element).GetAttribute("Deviceid") + "' AND Type = '01' order by ratevolt desc,referencevolt desc,col2 desc,col22 desc,col42 desc,col62 desc";
                    IList listMX = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                    if (listMX.Count <= 0)
                        continue;

                    if ((PSPDEV)(listMX[0]) != null) {
                        PSPDEV elementDEV = (PSPDEV)(listMX[0]);
                        PSP_ElcDevice elcDEV = new PSP_ElcDevice();
                        elcDEV.ProjectSUID = tlVectorControl1.SVGDocument.SvgdataUid;
                        elcDEV.DeviceSUID = ((PSPDEV)listMX[0]).SUID;
                        elcDEV = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDEV);
                        if (elcDEV != null) {
                            RectangleF bound = ((IGraph)element).GetBounds();
                            XmlElement n1 = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@textn1id='" + element.GetAttribute("Deviceid") + "']") as XmlElement;
                            XmlElement n2 = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@textn2id='" + element.GetAttribute("Deviceid") + "']") as XmlElement;
                            Layer la = tlVectorControl1.SVGDocument.GetLayerByID(element.GetAttribute("layer"));

                            if (n1 == null) {
                                n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                n1.SetAttribute("x", Convert.ToString(bound.X));
                                n1.SetAttribute("y", Convert.ToString(bound.Y - (0 + 1) * 10 * tlVectorControl1.ScaleRatio));
                                n1.SetAttribute("font-size", "10");
                                n1.SetAttribute("font-family", "楷体_GB2312");
                                n1.SetAttribute("layer", SvgDocument.currentLayer);
                                //MessageBox.Show(Convert.ToString(n1.InnerText));

                                //n1.SetAttribute("layer", la.ID);
                                //MessageBox.Show(Convert.ToString(n1.InnerText));
                                n1.SetAttribute("flag", "1");
                                n1.SetAttribute("textn1id", element.GetAttribute("Deviceid"));
                                tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                            }

                            if (elementDEV.KSwitchStatus == "1") {
                                n1.InnerText = "0";
                            } else {
                                n1.InnerText = Convert.ToDouble(GetColValue(elcDEV, order).COL2).ToString("N2");
                            }

                            if (elementDEV.KSwitchStatus == "0") {
                                if (Convert.ToDouble(GetColValue(elcDEV, order).COL2 == "" ? "0" : GetColValue(elcDEV, order).COL2) > elementDEV.jV || Convert.ToDouble(GetColValue(elcDEV, order).COL2 == "" ? "0" : GetColValue(elcDEV, order).COL2) < elementDEV.iV)//电压越限,需修改
                                    n1.SetAttribute("stroke", "#FF0000");

                            }
                            if (elementDEV.NodeType == "0") {

                                if (n2 == null) {
                                    n2 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                    n2.SetAttribute("x", Convert.ToString(bound.X));
                                    n2.SetAttribute("y", Convert.ToString(bound.Y + bound.Height + 20));
                                    n2.SetAttribute("layer", SvgDocument.currentLayer);
                                    n2.SetAttribute("flag", "1");
                                    n2.SetAttribute("font-size", "10");
                                    n2.SetAttribute("font-family", "楷体_GB2312");
                                    n2.SetAttribute("textn2id", element.GetAttribute("Deviceid"));
                                    tlVectorControl1.SVGDocument.RootElement.AppendChild(n2);
                                }
                                if (elementDEV.KSwitchStatus == "1") {
                                    n2.InnerText = "0" + "j" + "0";
                                } else {
                                    if (Convert.ToDouble(GetColValue(elcDEV, order).COL5) >= 0) {
                                        n2.InnerText = Convert.ToDouble(GetColValue(elcDEV, order).COL4).ToString("N2") + "  + " + "j" + Convert.ToDouble(GetColValue(elcDEV, order).COL5).ToString("N2");
                                    } else {
                                        n2.InnerText = Convert.ToDouble(GetColValue(elcDEV, order).COL4).ToString("N2") + "  - " + "j" + (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL5))).ToString("N2");
                                    }
                                }

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

                            }
                            //tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                            //tlVectorControl1.Operation = ToolOperation.Select;
                            tlVectorControl1.Refresh();
                        }
                    }
                }
                XmlNodeList polyLineList = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline");
                wFrom.ShowText += "\r\n正在显示线路信息\t" + System.DateTime.Now.ToString();
                foreach (XmlNode node in polyLineList) {

                    XmlElement element = node as XmlElement;
                    PSP_ElcDevice elcDEV = new PSP_ElcDevice();
                    elcDEV.ProjectSUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    elcDEV.DeviceSUID = element.GetAttribute("Deviceid");
                    elcDEV = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDEV);
                    PSPDEV elementDEV = new PSPDEV();
                    Layer la = tlVectorControl1.SVGDocument.GetLayerByID(element.GetAttribute("layer"));
                    if (elcDEV != null) {
                        elementDEV.SUID = elcDEV.DeviceSUID;
                        elementDEV = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", elementDEV);

                    } else {
                        continue;
                    }

                    if (elementDEV != null) {
                        PointF[] t = ((Polyline)element).Points;
                        PointF[] t2 = ((Polyline)element).FirstTwoPoint;
                        t = t2;
                        PointF midt = new PointF((float)((t2[0].X + t2[1].X) / 2), (float)((t2[0].Y + t2[1].Y) / 2));
                        float angel = 0f;
                        angel = (float)(180 * Math.Atan2((t2[1].Y - t2[0].Y), (t2[1].X - t2[0].X)) / Math.PI);

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

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

                        PointF center = new PointF((float)(t[0].X + (t[1].X - t[0].X) / 2), (float)(t[0].Y + (t[1].Y - t[0].Y) / 2));
                        XmlElement n1 = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@textn1id='" + element.GetAttribute("Deviceid") + "']") as XmlElement;
                        //XmlElement n2 = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline;
                        //XmlElement n3 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;

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

                        XmlNode firstNodeElement = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@id='" + element.GetAttribute("FirstNode") + "']");
                        XmlNode lastNodeElement = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@id='" + element.GetAttribute("LastNode") + "']");
                        if (firstNodeElement != null && lastNodeElement != null) {
                            if ((angel > 10 && angel < 90) || (angel < 0 && Math.Abs(angel) < 90) || (angel > 180 && angel < 350)) {
                                if (t2[0].X > ((IGraph)firstNodeElement).CenterPoint.X) {
                                    pStart = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));
                                    pStart2 = new PointF(center.X + (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(23 * Math.Cos((angel) * Math.PI / 180)));
                                }
                            } else if ((angel >= 0 && angel <= 10) || (angel >= 350 && angel <= 360) || (angel < 0 && Math.Abs(angel) <= 90)) {
                                if (t2[0].Y > ((IGraph)firstNodeElement).CenterPoint.Y) {
                                    pStart = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));
                                    pStart2 = new PointF(center.X + (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(23 * Math.Cos((angel) * Math.PI / 180)));
                                }
                            } else if ((angel < 0 && Math.Abs(angel) > 90) || (angel >= 90 && angel <= 180)) {
                                if (t2[0].Y > ((IGraph)firstNodeElement).CenterPoint.Y) {
                                    pStart = new PointF(center.X - (float)(7 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(7 * Math.Cos((angel) * Math.PI / 180)));
                                    pStart2 = new PointF(center.X + (float)(7 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(7 * Math.Cos((angel) * Math.PI / 180)));
                                }
                            }
                        }

                        //if (t2[0].X > ((IGraph)firstNodeElement).CenterPoint.X || t2[0].Y < ((IGraph)firstNodeElement).CenterPoint.Y)
                        //{
                        //    pStart = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));
                        //    pStart2 = new PointF(center.X + (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(23 * Math.Cos((angel) * Math.PI / 180)));
                        //}
                        //else
                        //{
                        //    pStart = new PointF(center.X - (float)(7 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(7 * Math.Cos((angel) * Math.PI / 180)));
                        //    pStart2 = new PointF(center.X + (float)(7 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(7 * Math.Cos((angel) * Math.PI / 180)));
                        //}

                        PointF newp1 = new PointF(t[0].X + (t[1].X - t[0].X) / 2 - (float)(15 * Math.Sin(angel)), t[0].Y + (t[1].Y - t[0].Y) / 2 - (float)(15 * Math.Cos(angel)));

                        if (n1 == null) {
                            n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                            n1.SetAttribute("x", Convert.ToString(pStart.X));
                            n1.SetAttribute("y", Convert.ToString(pStart.Y));
                            n1.SetAttribute("layer", SvgDocument.currentLayer);
                            n1.SetAttribute("flag", "1");
                            n1.SetAttribute("font-size", "10");
                            n1.SetAttribute("font-family", "楷体_GB2312");
                            n1.SetAttribute("textn1id", element.GetAttribute("Deviceid"));
                            tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                            tlVectorControl1.Operation = ToolOperation.Select;

                            tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement;

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

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

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

                            if (Convert.ToDouble(GetColValue(elcDEV, order).COL14) > (double)(elementDEV.Burthen))//电流越限,需修改。
                                n1.SetAttribute("stroke", "#FF0000");
                            PointF p1 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 10) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 10) * Math.PI / 180)));
                            PointF p2 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 350) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 350) * Math.PI / 180)));

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

                            string l1 = Convert.ToString(p1.X);
                            string l2 = Convert.ToString(p1.Y);
                            string l5 = Convert.ToString(p2.X);
                            string l6 = Convert.ToString(p2.Y);
                            XmlElement n2 = tlVectorControl1.SVGDocument.CreateElement("polygon") as Polygon;
                            n2.SetAttribute("points", l1 + " " + l2 + "," + l3 + " " + l4 + "," + l5 + " " + l6);
                            n2.SetAttribute("fill-opacity", "1");
                            n2.SetAttribute("layer", la.ID);
                            n2.SetAttribute("flag", "1");
                            n2.SetAttribute("font-size", "10");
                            n2.SetAttribute("style", "fill:#000000");
                            tlVectorControl1.SVGDocument.RootElement.AppendChild(n2);
                            tlVectorControl1.SVGDocument.CurrentElement = n2 as SvgElement;

                        }

                        n1.SetAttribute("font-family", "楷体_GB2312");

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

                        //tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement;

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

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

                        tlVectorControl1.Refresh();
                    }
                }
            } catch (System.Exception ex) {
                wFrom.ShowText += "\r\n结果显示出错,请检查数据和图形是否一致\t" + System.DateTime.Now.ToString();
                MessageBox.Show("参数错误,请调整参数后重新计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            wFrom.ShowText += "\r\n结果显示完毕\t " + System.DateTime.Now.ToString();
            tlVectorControl1.SVGDocument.CurrentLayer = (Layer)tlVectorControl1.SVGDocument.Layers[0];
        }
Пример #8
0
        public void Partshort(string projectSUID, string projectid, int dulutype, double ratecaplity, List<PSPDEV> list1,frnReport wFrom)
        {
            int cishu = 0;           //��¼�ڶ��ٴγ����ڴ�����
            try
            {
                wFrom.ShowText += "\r\n��ʼ׼����·��������\t" + System.DateTime.Now.ToString();
                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;
                    }
                }

                //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 = null;
                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.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 " + " " + 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.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" + " " + 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(, FileMode.OpenOrCreate);

                        StreamWriter str11 = new StreamWriter((System.Windows.Forms.Application.StartupPath + "\\fault.txt"),false);
                        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();
                        //shortcir shortCutCal = new shortcir();
                        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)
                        {
                            wFrom.ShowText += "\r\n��·����ʧ��\t" + System.DateTime.Now.ToString();
                            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);
                            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
                            {
                                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);

                                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
                            {
                                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;
                            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();

                        }
                    }

                }
                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);
                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 < cishu; 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 < cishu; 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();
                wFrom.ShowText += "\r\n��·�������\t" + System.DateTime.Now.ToString();
            }
            catch (System.Exception ex)
            {
                wFrom.ShowText += "\r\n��·����ʧ��\t" + System.DateTime.Now.ToString();
                MessageBox.Show("���ݴ���������������ȫ���ٲ���", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
        }
Пример #9
0
        private void ShowResult(int order, string projectsuid, string FileName, int pspouttype, frnReport wFrom)
        {
            try
            {
                //删除原来的text文本
                //XmlNodeList list = tlVectorControl1.SVGDocument.SelectNodes("svg/*[@flag='" + "1" + "']");

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

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

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

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

                            }
                        }

                    }

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

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

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

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

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

                            } tlVectorControl1.Refresh();
                        }
                    }

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

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

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

                            }
                            catch (System.Exception ex)
                            {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement;

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

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

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

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

                }
                //this.frmlar.checkedListBox1.Items.Add(lar, true);
                //this.frmlar.checkedListBox1.SelectedIndex = -1;
                MessageBox.Show("显示完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("参数错误,请调整参数后重新计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
        }
Пример #10
0
        private void AllshortItem_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            ElectricShorti elc = new ElectricShorti();
            //TreeListNode node = treeList1.FocusedNode;
            if (strID == null) {
                MessageBox.Show("����ѡ��������㷽����", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            //strID = node["ID"].ToString();
            //elc.CheckDL(strID, 100);
            int n3 = 0;
            ShorttypeForm shortfangshi = new ShorttypeForm();
            ShortTform shorttype = new ShortTform();
            frnReport wFrom = new frnReport();
            wFrom.Text = "��·����";
            wFrom.Show();
            wFrom.ShowText += "�����������\t" + System.DateTime.Now.ToString();
            if (shortfangshi.ShowDialog() == DialogResult.OK) {
                if (shortfangshi.Mathindex == 0) {
                    shorttype.ShowDialog();
                    if (shorttype.DialogResult == DialogResult.OK) {
                        switch (shorttype.DuanluType) {
                            case "����ӵ�":
                                n3 = 1;
                                break;

                            case "����ӵ�":
                                n3 = 3;
                                break;
                            case "�������":
                                n3 = 2;
                                break;
                            case "�������":
                                n3 = 0;
                                break;

                        }
                        elc.OutType = shorttype.Mathindex;
                        elc.Compuflag = shorttype.Compuflag;
                    } else
                        return;
                    //WaitDialogForm wait = null;
                    try {

                        // wait = new WaitDialogForm("", "���ڴ�������, ���Ժ�...");

                        elc.AllShort(strID, this.ProjectUID, n3, 100, wFrom);
                        //elc.ALLShortThread(strID, this.ProjectUID, n3, 100, wait);
                        //wait.Close();
                    } catch (Exception exc) {
                        wFrom.ShowText += "\r\n��·����ʧ��\t" + System.DateTime.Now.ToString();
                        Debug.Fail(exc.Message);
                        Itop.Client.Common.HandleException.TryCatch(exc);
                        // wait.Close();
                        return;

                    }

                }
                if (shortfangshi.Mathindex == 1) {
                    SelshortbusForm1 selbusfrm = new SelshortbusForm1();
                    selbusfrm.ProjectSUID = strID;
                    selbusfrm.ProjectID = Itop.Client.MIS.ProgUID;
                    selbusfrm.ShowDialog();
                    if (selbusfrm.DialogResult == DialogResult.OK) {
                        List<PSPDEV> list = new List<PSPDEV>();
                        foreach (DataRow row in selbusfrm.DT.Rows) {
                            try {
                                if ((bool)row["C"]) {
                                    PSPDEV psp = new PSPDEV();
                                    psp.SUID = row["A"].ToString();

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

                            } catch (System.Exception ex) {

                            }
                        }
                        if (list.Count == 0) {
                            MessageBox.Show("û��ѡ���·��ĸ�ߣ�");
                            return;
                        }
                        shorttype.ShowDialog();
                        if (shorttype.DialogResult == DialogResult.OK) {
                            switch (shorttype.DuanluType) {
                                case "����ӵ�":
                                    n3 = 1;
                                    break;

                                case "����ӵ�":
                                    n3 = 3;
                                    break;
                                case "�������":
                                    n3 = 2;
                                    break;
                                case "�������":
                                    n3 = 0;
                                    break;

                            }
                            elc.OutType = shorttype.Mathindex;
                            elc.Compuflag = shorttype.Compuflag;
                        } else
                            return;
                        // WaitDialogForm wait = null;
                        try {
                            //wait = new WaitDialogForm("", "���ڴ�������, ���Ժ�...");
                            elc.Partshort(strID, this.ProjectUID, n3, 100, list, wFrom);
                            //wait.Close();
                        } catch (Exception exc) {
                            wFrom.ShowText += "\r\n��·����ʧ��\t" + System.DateTime.Now.ToString();
                            Debug.Fail(exc.Message);
                            Itop.Client.Common.HandleException.TryCatch(exc);
                            //wait.Close();
                            return;

                        }

                    }
                }

            }
        }
Пример #11
0
        private void dotNetBarManager1_ItemClick(object sender, EventArgs e)
        {
            DevComponents.DotNetBar.ButtonItem btItem = sender as DevComponents.DotNetBar.ButtonItem;
            //Layer layer1 = (Layer)LayerBox.ComboBoxEx.SelectedItem;
            if (btItem != null)
            {
                if (btItem.Name == "mRoam")
                {
                    frmlar.Hide();
                }
                else
                {
                    frmlar.Show();
                }
                switch (btItem.Name)
                {
                    #region 文件操作
                    case "mNew":
                        tlVectorControl1.NewFile();

                        break;
                    case "mOpen":

                        break;
                    case "mImport":
                        ExportImage();
                        //ImportDxf();
                        break;
                    case "ImportDxf":
                        ImportDxf();
                        break;
                    case "btExSymbol":
                        tlVectorControl1.ExportSymbol();
                        break;
                    case "mSave":
                        SaveButton();
                        break;
                    case "mSaveSVG":
                        tlVectorControl1.SaveAs();
                        break;
                    case "mExit":
                        this.Close();

                        //System.Data.OleDb.OleDbConnection c = new OleDbConnection("Provider=SQLOLEDB;Data source=192.168.0.30;initial catalog=tlpsp_tzkq;user id=sa;password=sa");
                        //OleDbCommand cmd = c.CreateCommand();
                        break;
                    case "bt1":
                        InitTK();
                        break;
                    case "callCAD":
                        try
                        {
                            //Autodesk.AutoCAD.Interop.
                            if (MessageBox.Show("此操作需要花费较长时间,确认导出么?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                            {
                                CAD cad = new CAD();
                                cad.tlVectorControl1 = tlVectorControl1;
                                cad.WriteDwg("ALL");
                            }

                        }
                        catch
                        {
                            MessageBox.Show("请安装AutoCAD2006或以上版本。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        break;
                    case "callCADSub":
                        try
                        {
                            //Autodesk.AutoCAD.Interop.AcadApplicationClass a = new Autodesk.AutoCAD.Interop.AcadApplicationClass();
                            if (MessageBox.Show("此操作需要花费较长时间,确认导出么?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                            {
                                CAD cad = new CAD();
                                cad.tlVectorControl1 = tlVectorControl1;
                                string strlar = frmlar.getSelectedLayer();
                                cad.WriteDwg(strlar);
                            }

                        }
                        catch
                        {
                            MessageBox.Show("请安装AutoCAD2006或以上版本。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        break;
                    case "mPriSet":
                        tlVectorControl1.PaperSetup();
                        break;
                    case "mPrint":
                        tlVectorControl1.Print();
                        break;
                    case "mView":
                        //frmSvgView fView = new frmSvgView();
                        //fView.Open(tlVectorControl1.SVGDocument.SvgdataUid);
                        //fView.Show();

                        break;

                    case "mViewScale":
                        if (img != null)
                        {
                            frmtempViewScale fscale1 = new frmtempViewScale();
                            fscale1.ShowDialog();
                        }
                        else
                        {
                            frmViewScale fScale = new frmViewScale();
                            string viewScale = tlVectorControl1.SVGDocument.getViewScale();
                            if (viewScale != "")
                            {
                                fScale.InitData(viewScale);
                            }
                            if (fScale.ShowDialog() == DialogResult.OK)
                            {

                                //viewScale = fScale.ViewScale;
                                string _viewScale = fScale.ViewScale;
                                tlVectorControl1.SVGDocument.setViewScale(_viewScale);
                                if (viewScale == "")
                                {
                                    viewScale = "1";
                                }
                                Recalculate(Convert.ToDecimal(_viewScale) / Convert.ToDecimal(viewScale));
                            }
                        }
                        break;
                    //case "mIncreaseView":
                    //    tlVectorControl1.Operation = ToolOperation.IncreaseView;
                    //    break;
                    case "mRzb":
                        frmRatio fRat = new frmRatio();
                        string viewRat = tlVectorControl1.SVGDocument.getRZBRatio();
                        if (viewRat != "")
                        {
                            fRat.InitData(viewRat);
                        }
                        if (fRat.ShowDialog() == DialogResult.OK)
                        {
                            viewRat = fRat.ViewScale;
                            tlVectorControl1.SVGDocument.setRZBRatio(viewRat);
                        }
                        break;
                    case "mEdit":
                        if (MapType == "所内接线图")
                        {
                            Save();
                            dotNetBarManager1.Bars["mainmenu"].GetItem("ImportDxf").Visible = false;
                            svg.SUID = ParentUID;
                            IList svglist = Services.BaseService.GetList("SelectSVGFILEByKey", svg);
                            svg = (SVGFILE)svglist[0];
                            sdoc = null;
                            sdoc = new SvgDocument();
                            sdoc.LoadXml(svg.SVGDATA);
                            tlVectorControl1.SVGDocument = sdoc;
                            tlVectorControl1.SVGDocument.SvgdataUid = svg.SUID;
                            MapType = "接线图";
                            CtrlSvgView.MapType = "接线图";
                            LoadShape("symbol_3.xml");
                            Init(progtype);
                            //ButtonEnb(true);
                            frmlar.SymbolDoc = tlVectorControl1.SVGDocument;
                            frmlar.Progtype = progtype;
                            frmlar.InitData();
                            dotNetBarManager1.Bars["mainmenu"].GetItem("ButtonItem2").Enabled = true;
                            dotNetBarManager1.Bars["mainmenu"].GetItem("ButtonItem7").Enabled = true;
                            bk1.Enabled = true;
                            LoadImage = true;
                            tlVectorControl1.Refresh();
                        }
                        tlVectorControl1.ContextMenuStrip = contextMenuStrip1;
                        MapType = "接线图";
                        break;

                    case "mAbout":

                        frmAbout frma = new frmAbout();
                        frma.ShowDialog();
                        break;

                    //基础操作
                    case "mFreeTransform":
                        tlVectorControl1.Operation = ToolOperation.FreeTransform;

                        break;
                    case "mRoam1":
                        tlVectorControl1.Operation = ToolOperation.Roam;

                        break;
                    case "mShapeTransform1":
                        tlVectorControl1.Operation = ToolOperation.Custom11;

                        break;
                    case "mShapeTransform2":
                        tlVectorControl1.Operation = ToolOperation.Custom12;
                        break;
                    case "mShapeTransform3":
                        tlVectorControl1.Operation = ToolOperation.Custom13;
                        break;
                    case "mShapeTransform4":
                        tlVectorControl1.Operation = ToolOperation.Custom15;
                        break;
                    case "mShapeTransform5":
                        tlVectorControl1.Operation = ToolOperation.Custom14;
                        break;
                    case "m_ljxl":
                        ConnLine();
                        break;
                    case "mAngleRectangle1":
                        tlVectorControl1.Operation = ToolOperation.AngleRectangle;

                        break;
                    case "mSelect1":
                    case "mSel1":
                        //tlVectorControl1.Operation = ToolOperation.Select;
                        tlVectorControl1.Operation = ToolOperation.FreeTransform;
                        break;
                    case "mLine1":
                        tlVectorControl1.Operation = ToolOperation.Line;

                        break;
                    case "mPolyline1":
                        tlVectorControl1.Operation = ToolOperation.PolyLine;

                        break;
                    case "mImage1":
                        tlVectorControl1.Operation = ToolOperation.Image;

                        break;
                    case "mText1":
                        tlVectorControl1.Operation = ToolOperation.Text;

                        break;
                    case "mEllipse1":
                        tlVectorControl1.Operation = ToolOperation.Ellipse;

                        break;
                    case "mBezier1":
                        tlVectorControl1.Operation = ToolOperation.Bezier;

                        break;

                    //图元操作
                    case "mCopy1":
                        tlVectorControl1.Copy();
                        break;
                    case "mCut1":
                        tlVectorControl1.Cut();
                        break;
                    case "mPaste1":
                        PasteWithProperty();
                        break;
                    case "mDelete1":
                        if (tlVectorControl1.SVGDocument.CurrentElement != null && tlVectorControl1.SVGDocument.CurrentElement.ID != "svg")
                        {
                            frmMessageBox msg = new frmMessageBox();
                            if (msg.ShowDialog() == DialogResult.OK)
                            {

                                if (msg.ck)
                                {
                                    // if(MessageBox.Show("确认删除么?","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Information)==DialogResult.Yes){
                                    for (int i = 0; i < tlVectorControl1.SVGDocument.SelectCollection.Count; i++)
                                    {
                                        if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Polygon")
                                        {
                                            glebeProperty gle = new glebeProperty();
                                            gle.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                            gle.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID;
                                            Services.BaseService.Update("DeleteglebePropertyByEleID", gle);
                                        }
                                        if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Polyline" || tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Line")
                                        {
                                            LineInfo _line = new LineInfo();
                                            _line.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                            _line.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID;
                                            LineInfo temp = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByEleID", _line);
                                            if (temp != null)
                                            {
                                                Services.BaseService.Update("DeleteLinePropertyByEleID", _line);

                                                Services.BaseService.Update("DeleteLine_InfoByCode", temp.UID);
                                            }
                                        }
                                        if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Use")
                                        {
                                            string str_name = ((XmlElement)(tlVectorControl1.SVGDocument.SelectCollection[i])).GetAttribute("xlink:href");
                                            if (str_name.Contains("Substation"))
                                            {
                                                substation _sub = new substation();
                                                _sub.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                                _sub.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID;

                                                substation temp = (substation)Services.BaseService.GetObject("SelectsubstationByEleID", _sub);

                                                if (temp != null)
                                                {
                                                    Services.BaseService.Update("DeletesubstationByEleID", _sub);

                                                    Services.BaseService.Update("DeleteSubstation_InfoByCode", temp.UID);
                                                }
                                            }
                                        }
                                        if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.ConnectLine")
                                        {
                                            ConnectLine cline = (ConnectLine)tlVectorControl1.SVGDocument.SelectCollection[i];
                                            if (cline.StartGraph != null)
                                            {
                                                SvgElement ele = (SvgElement)cline.StartGraph;
                                                if (!ele.GetAttribute("xlink:href").Contains("Substation"))
                                                {
                                                    tlVectorControl1.SVGDocument.SelectCollection.Add(cline.StartGraph);
                                                }
                                            }
                                            if (cline.EndGraph != null)
                                            {
                                                tlVectorControl1.SVGDocument.SelectCollection.Add(cline.EndGraph);
                                            }
                                        }

                                    }
                                }
                                else
                                {
                                    for (int i = 0; i < tlVectorControl1.SVGDocument.SelectCollection.Count; i++)
                                    {
                                        if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Polyline" || tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Line")
                                        {
                                            LineInfo _line = new LineInfo();
                                            _line.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                            _line.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID;

                                            LineInfo linetemp = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByEleID", _line);
                                            if (linetemp != null)
                                            {
                                                PowerProTypes temp = (PowerProTypes)Services.BaseService.GetObject("SelectPowerProTypesByCode", linetemp.UID);
                                                if (temp != null)
                                                {
                                                    linetemp.EleID = "";
                                                    Services.BaseService.Update<LineInfo>(linetemp);
                                                }
                                                else
                                                {
                                                    Services.BaseService.Update("DeleteLineInfo", linetemp);
                                                }
                                            }

                                        }
                                        if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Use")
                                        {
                                            string str_name = ((XmlElement)(tlVectorControl1.SVGDocument.SelectCollection[i])).GetAttribute("xlink:href");
                                            if (str_name.Contains("Substation"))
                                            {
                                                substation _sub = new substation();
                                                _sub.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                                _sub.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID;

                                                substation subtemp = (substation)Services.BaseService.GetObject("SelectsubstationByEleID", _sub);
                                                if (subtemp != null)
                                                {
                                                    PowerProTypes temp = (PowerProTypes)Services.BaseService.GetObject("SelectPowerProTypesByCode", subtemp.UID);
                                                    if (temp != null)
                                                    {
                                                        subtemp.EleID = "";
                                                        Services.BaseService.Update<substation>(subtemp);
                                                    }
                                                    else
                                                    {
                                                        Services.BaseService.Update("Deletesubstation", subtemp);
                                                    }
                                                }
                                            }
                                        }
                                        if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.ConnectLine")
                                        {
                                            ConnectLine cline = (ConnectLine)tlVectorControl1.SVGDocument.SelectCollection[i];
                                            if (cline.StartGraph != null)
                                            {
                                                SvgElement ele = (SvgElement)cline.StartGraph;
                                                if (!ele.GetAttribute("xlink:href").Contains("Substation"))
                                                {
                                                    tlVectorControl1.SVGDocument.SelectCollection.Add(cline.StartGraph);
                                                }
                                            }
                                            if (cline.EndGraph != null)
                                            {
                                                tlVectorControl1.SVGDocument.SelectCollection.Add(cline.EndGraph);
                                            }
                                        }
                                    }

                                }

                                tlVectorControl1.Delete();
                            }
                        }
                        //tlVectorControl1.Operation = ToolOperation.Select;
                        break;
                    case "mUodo1":
                        tlVectorControl1.Undo();
                        break;
                    case "mRedo1":
                        tlVectorControl1.Redo();
                        break;
                    case "mAlign1":
                        if (btItem.Tag is ButtonItem)
                        {
                            btItem = btItem.Tag as ButtonItem;
                            tlVectorControl1.Align(AlignType.Left);

                        }
                        else
                        {
                            tlVectorControl1.Align(AlignType.Left);

                        }
                        tlVectorControl1.Refresh();
                        break;
                    case "mAlignLeft1":
                        tlVectorControl1.Align(AlignType.Left);
                        this.alignButton.ImageIndex = btItem.ImageIndex;
                        this.alignButton.Tag = btItem;
                        tlVectorControl1.Refresh();
                        break;
                    case "mAlignRight1":
                        tlVectorControl1.Align(AlignType.Right);
                        this.alignButton.ImageIndex = btItem.ImageIndex;
                        this.alignButton.Tag = btItem;
                        tlVectorControl1.Refresh();
                        break;
                    case "mAlignTop1":
                        tlVectorControl1.Align(AlignType.Top);
                        this.alignButton.ImageIndex = btItem.ImageIndex;
                        this.alignButton.Tag = btItem;
                        tlVectorControl1.Refresh();
                        break;
                    case "mAlignBottom1":
                        tlVectorControl1.Align(AlignType.Bottom);
                        this.alignButton.ImageIndex = btItem.ImageIndex;
                        this.alignButton.Tag = btItem;
                        tlVectorControl1.Refresh();
                        break;
                    case "mAlignHorizontalCenter1":
                        tlVectorControl1.Align(AlignType.HorizontalCenter);
                        this.alignButton.ImageIndex = btItem.ImageIndex;
                        this.alignButton.Tag = btItem;
                        tlVectorControl1.Refresh();
                        break;
                    case "mAlignVerticalCenter1":
                        tlVectorControl1.Align(AlignType.VerticalCenter);
                        this.alignButton.ImageIndex = btItem.ImageIndex;
                        this.alignButton.Tag = btItem;
                        tlVectorControl1.Refresh();
                        break;
                    case "mOrder1":
                        if (btItem.Tag is ButtonItem)
                        {
                            btItem = btItem.Tag as ButtonItem;
                            tlVectorControl1.ChangeLevel(LevelType.Top);

                        }
                        else
                        {
                            tlVectorControl1.ChangeLevel(LevelType.Top);
                        }

                        break;
                    case "mGoTop1":
                        tlVectorControl1.ChangeLevel(LevelType.Top);
                        this.orderButton.Tag = btItem;
                        this.orderButton.ImageIndex = btItem.ImageIndex;
                        break;
                    case "mGoUp1":
                        tlVectorControl1.ChangeLevel(LevelType.Up);
                        this.orderButton.Tag = btItem;
                        this.orderButton.ImageIndex = btItem.ImageIndex;
                        break;
                    case "mGoDown1":
                        tlVectorControl1.ChangeLevel(LevelType.Down);
                        this.orderButton.Tag = btItem;
                        this.orderButton.ImageIndex = btItem.ImageIndex;
                        break;
                    case "mGoBottom1":
                        tlVectorControl1.ChangeLevel(LevelType.Bottom);
                        this.orderButton.Tag = btItem;
                        this.orderButton.ImageIndex = btItem.ImageIndex;
                        break;
                    case "mRotate1":
                        if (btItem.Tag is ButtonItem)
                        {
                            btItem = btItem.Tag as ButtonItem;
                            tlVectorControl1.FlipX();

                        }
                        else
                        {
                            tlVectorControl1.FlipX();
                        }
                        break;
                    case "mToH1":

                        tlVectorControl1.FlipX();
                        this.rotateButton.Tag = btItem;
                        this.rotateButton.ImageIndex = btItem.ImageIndex;
                        break;
                    case "mToV1":
                        tlVectorControl1.FlipY();
                        this.rotateButton.Tag = btItem;
                        this.rotateButton.ImageIndex = btItem.ImageIndex;
                        break;
                    case "mToLeft1":
                        tlVectorControl1.RotateSelection(-90f);
                        this.rotateButton.Tag = btItem;
                        this.rotateButton.ImageIndex = btItem.ImageIndex;
                        break;
                    case "mToRight1":
                        tlVectorControl1.RotateSelection(90f);
                        this.rotateButton.Tag = btItem;
                        this.rotateButton.ImageIndex = btItem.ImageIndex;
                        break;

                    //图形操作

                    case "mLeadLine1":

                        if (!getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList()))
                        //if (!layer1.Label.Contains("电网规划层"))
                        {
                            MessageBox.Show("请选择电网规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        // sgt1.Visible = true;
                        tlVectorControl1.Operation = ToolOperation.Select;
                        tlVectorControl1.Operation = ToolOperation.LeadLine;
                        break;
                    case "mAreaPoly1":
                        if (!getlayer(SvgDocument.currentLayer, "城市规划层", tlVectorControl1.SVGDocument.getLayerList()))
                        //if (!layer1.Label.Contains("城市规划层"))
                        {
                            MessageBox.Show("请选择城市规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        tlVectorControl1.Operation = ToolOperation.Select;
                        tlVectorControl1.Operation = ToolOperation.AreaPolygon;

                        break;

                    case "mFzzj1": //放置注记
                        if (!getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList()))
                        //if (!layer1.Label.Contains("供电区域层"))
                        {
                            MessageBox.Show("请选择电网规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        //LayerBox.ComboBoxEx.SelectedIndex = 2;
                        tlVectorControl1.Operation = ToolOperation.Select;
                        MapType = "规划统计";
                        break;

                    case "mPriQu1":
                        SubPrint = true;
                        tlVectorControl1.Operation = ToolOperation.InterEnclosurePrint;
                        break;

                    case "mReCompute1":
                        if (MessageBox.Show("确认要重新计算全图的电量和负荷么?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            string scale = tlVectorControl1.SVGDocument.getViewScale();
                            if (scale != "")
                            {
                                Recalculate(Convert.ToDecimal(scale));
                            }
                            else
                            {
                                Recalculate(1);
                            }

                            MessageBox.Show("重新计算完成", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        break;

                    case "mFhbz1":
                        if (MessageBox.Show("是否生成负荷标注?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                        {
                            Fhbz();
                        }
                        break;
                    case "mCJ":
                        tlVectorControl1.Operation = ToolOperation.PolyLine;
                        csOperation = CustomOperation.OP_MeasureDistance;
                        break;
                    #endregion
                    #region 基础图元
                    case "mDecreaseView":
                        tlVectorControl1.Operation = ToolOperation.DecreaseView;

                        break;
                    case "mIncreaseView":

                        tlVectorControl1.Operation = ToolOperation.IncreaseView;
                        break;
                    case "mRoam":
                        tlVectorControl1.Operation = ToolOperation.Roam;

                        break;
                    case "mSelect":
                    case "mSel":
                        //tlVectorControl1.Operation = ToolOperation.Select;
                        tlVectorControl1.Operation = ToolOperation.FreeTransform;
                        sel_sym = "";
                        sel_start_point = "";
                        break;
                    //case "mFreeTransform":
                    //    tlVectorControl1.Operation = ToolOperation.FreeTransform;

                    //    break;
                    case "mFreeLines"://锁套
                        tlVectorControl1.Operation = ToolOperation.FreeLines;

                        break;
                    case "mFreePath":
                        tlVectorControl1.Operation = ToolOperation.FreePath;

                        break;
                    case "mShapeTransform":
                        tlVectorControl1.Operation = ToolOperation.ShapeTransform;

                        break;
                    case "mAngleRectangle":
                        tlVectorControl1.Operation = ToolOperation.AngleRectangle;

                        break;
                    case "mEllipse":
                        tlVectorControl1.Operation = ToolOperation.Ellipse;

                        break;
                    case "mLine":
                        tlVectorControl1.Operation = ToolOperation.Line;

                        break;
                    case "mPolyline":
                        tlVectorControl1.Operation = ToolOperation.PolyLine;

                        break;
                    case "mPolygon":
                        tlVectorControl1.Operation = ToolOperation.Polygon;

                        break;
                    case "mImage":
                        tlVectorControl1.Operation = ToolOperation.Image;

                        break;
                    case "mText":
                        tlVectorControl1.Operation = ToolOperation.Text;

                        break;
                    case "mBezier":
                        tlVectorControl1.Operation = ToolOperation.Bezier;

                        break;
                    case "mEnclosure":
                        tlVectorControl1.Operation = ToolOperation.Enclosure;

                        break;

                    case "mGroup":
                        tlVectorControl1.Group();
                        break;
                    case "mUnGroup":
                        tlVectorControl1.UnGroup();
                        break;
                    case "mlinelx":
                        tlVectorControl1.Operation = ToolOperation.ConnectLine_Line;
                        break;
                    case "mzxlx":
                        tlVectorControl1.Operation = ToolOperation.ConnectLine_Rightangle;
                        break;
                    case "mqxlx":
                        tlVectorControl1.Operation = ToolOperation.ConnectLine_Spline;
                        break;
                    case "mqzlx":
                        tlVectorControl1.Operation = ToolOperation.ConnectLine_Polyline;
                        break;
                    case "mCJ1":
                        tlVectorControl1.Operation = ToolOperation.PolyLine;
                        csOperation = CustomOperation.OP_MeasureDistance;
                        break;
                    #endregion

                    #region 视图
                    case "mOption":
                        tlVectorControl1.SetOption();
                        break;
                    case "mLayer":
                        LayerManagerShow();
                        //tlVectorControl1.LayerManager();
                        break;
                    case "mAirscape":
                        frmAirscape fAir = new frmAirscape();
                        fAir.InitData(tlVectorControl1);
                        fAir.Owner = this;
                        fAir.ShowInTaskbar = false;
                        fAir.Top = Screen.PrimaryScreen.WorkingArea.Height - 250;
                        fAir.Left = Screen.PrimaryScreen.WorkingArea.Width - 300;
                        fAir.Show();
                        break;
                    case "btTL":
                        frmGlebeTypeList fgle = new frmGlebeTypeList();
                        fgle.Show();
                        break;
                    case "mMapOpacity"://地图透明度

                        frmMapSetup dlg = new frmMapSetup();
                        dlg.MapOpacity = this.MapOpacity;
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            this.MapOpacity = dlg.MapOpacity;
                        }
                        break;
                    #endregion
                    #region 查看
                    case "mDklb":
                        //SaveAllLayer();
                        frmLayerList lay = new frmLayerList();
                        lay.InitData(tlVectorControl1.SVGDocument.getLayerList(), "1");
                        if (lay.ShowDialog() == DialogResult.OK)
                        {
                            frmglebePropertyList flist1 = new frmglebePropertyList();
                            flist1.InitDataSub(tlVectorControl1.SVGDocument.SvgdataUid, lay.str_sid);
                            flist1.Show();
                        }
                        break;
                    case "m_dktj":
                        frmLayerList layn = new frmLayerList();
                        layn.InitData(tlVectorControl1.SVGDocument.getLayerList(), "1");
                        if (layn.ShowDialog() == DialogResult.OK)
                        {
                            frmglebePropertyZHList flist1 = new frmglebePropertyZHList();
                            flist1.InitDataSub(tlVectorControl1.SVGDocument.SvgdataUid, layn.str_sid);
                            flist1.Show();
                        }
                        break;
                    case "mGhlb":
                        frmLayerList lay2 = new frmLayerList();
                        lay2.InitData(tlVectorControl1.SVGDocument.getLayerList(), "2");
                        if (lay2.ShowDialog() == DialogResult.OK)
                        {
                            frmglebePropertyList flist2 = new frmglebePropertyList();
                            flist2.InitData(tlVectorControl1.SVGDocument.SvgdataUid, lay2.str_sid);
                            flist2.Show();
                        }
                        break;
                    case "mLineList":
                        frmLayerList lay3 = new frmLayerList();
                        lay3.InitData(tlVectorControl1.SVGDocument.getLayerList(), "2");
                        if (lay3.ShowDialog() == DialogResult.OK)
                        {
                            frmLinePropertyList flist3 = new frmLinePropertyList();
                            flist3.InitData(tlVectorControl1.SVGDocument.SvgdataUid, lay3.str_sid);
                            flist3.Show();
                        }
                        break;
                    case "mDlph":
                        frmLayerList lay4 = new frmLayerList();
                        lay4.InitData(tlVectorControl1.SVGDocument.getLayerList(), "3");
                        if (lay4.ShowDialog() == DialogResult.OK)
                        {
                            frmSubstationPropertyList fSub = new frmSubstationPropertyList();
                            fSub.InitData(tlVectorControl1.SVGDocument.SvgdataUid, lay4.str_sid);
                            fSub.Show();
                        }
                        break;
                    case "ButtonJXT":
                        if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg" || (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString()) != "ItopVector.Core.Figure.Use")
                        {
                            MessageBox.Show("没有选择变电站!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        ParentUID = tlVectorControl1.SVGDocument.SvgdataUid;
                        Save();
                        ParentUID = tlVectorControl1.SVGDocument.SvgdataUid;
                        SVGFILE svg_temp = new SVGFILE();
                        svg_temp.SUID = ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("id");
                        svg_temp.FILENAME = getBdzName(svg_temp.SUID);//
                        IList svglist1 = Services.BaseService.GetList("SelectSVGFILEByKey", svg_temp);
                        OpenJXT(svglist1, svg_temp);

                        break;
                    #endregion
                    #region 布局,对齐,顺序
                    case "mRotate":
                        if (btItem.Tag is ButtonItem)
                        {
                            btItem = btItem.Tag as ButtonItem;
                            tlVectorControl1.FlipX();

                        }
                        else
                        {
                            tlVectorControl1.FlipX();
                        }
                        break;
                    case "mToH":

                        tlVectorControl1.FlipX();
                        this.rotateButton.Tag = btItem;
                        this.rotateButton.ImageIndex = btItem.ImageIndex;
                        break;
                    case "mToV":
                        tlVectorControl1.FlipY();
                        this.rotateButton.Tag = btItem;
                        this.rotateButton.ImageIndex = btItem.ImageIndex;
                        break;
                    case "mToLeft":
                        tlVectorControl1.RotateSelection(-90f);
                        this.rotateButton.Tag = btItem;
                        this.rotateButton.ImageIndex = btItem.ImageIndex;
                        break;
                    case "mToRight":
                        tlVectorControl1.RotateSelection(90f);
                        this.rotateButton.Tag = btItem;
                        this.rotateButton.ImageIndex = btItem.ImageIndex;
                        break;
                    case "mAlign":
                        if (btItem.Tag is ButtonItem)
                        {
                            btItem = btItem.Tag as ButtonItem;
                            tlVectorControl1.Align(AlignType.Left);

                        }
                        else
                        {
                            tlVectorControl1.Align(AlignType.Left);

                        }
                        tlVectorControl1.Refresh();
                        break;
                    case "mAlignLeft":
                        tlVectorControl1.Align(AlignType.Left);
                        this.alignButton.ImageIndex = btItem.ImageIndex;
                        this.alignButton.Tag = btItem;
                        tlVectorControl1.Refresh();
                        break;
                    case "mAlignRight":
                        tlVectorControl1.Align(AlignType.Right);
                        this.alignButton.ImageIndex = btItem.ImageIndex;
                        this.alignButton.Tag = btItem;
                        tlVectorControl1.Refresh();
                        break;
                    case "mAlignTop":
                        tlVectorControl1.Align(AlignType.Top);
                        this.alignButton.ImageIndex = btItem.ImageIndex;
                        this.alignButton.Tag = btItem;
                        tlVectorControl1.Refresh();
                        break;
                    case "mAlignBottom":
                        tlVectorControl1.Align(AlignType.Bottom);
                        this.alignButton.ImageIndex = btItem.ImageIndex;
                        this.alignButton.Tag = btItem;
                        tlVectorControl1.Refresh();
                        break;
                    case "mAlignHorizontalCenter":
                        tlVectorControl1.Align(AlignType.HorizontalCenter);
                        this.alignButton.ImageIndex = btItem.ImageIndex;
                        this.alignButton.Tag = btItem;
                        tlVectorControl1.Refresh();
                        break;
                    case "mAlignVerticalCenter":
                        tlVectorControl1.Align(AlignType.VerticalCenter);
                        this.alignButton.ImageIndex = btItem.ImageIndex;
                        this.alignButton.Tag = btItem;
                        tlVectorControl1.Refresh();
                        break;
                    case "mOrder":
                        if (btItem.Tag is ButtonItem)
                        {
                            btItem = btItem.Tag as ButtonItem;
                            tlVectorControl1.ChangeLevel(LevelType.Top);

                        }
                        else
                        {
                            tlVectorControl1.ChangeLevel(LevelType.Top);
                        }

                        break;
                    case "mGoTop":
                        tlVectorControl1.ChangeLevel(LevelType.Top);
                        this.orderButton.Tag = btItem;
                        this.orderButton.ImageIndex = btItem.ImageIndex;
                        break;
                    case "mGoUp":
                        tlVectorControl1.ChangeLevel(LevelType.Up);
                        this.orderButton.Tag = btItem;
                        this.orderButton.ImageIndex = btItem.ImageIndex;
                        break;
                    case "mGoDown":
                        tlVectorControl1.ChangeLevel(LevelType.Down);
                        this.orderButton.Tag = btItem;
                        this.orderButton.ImageIndex = btItem.ImageIndex;
                        break;
                    case "mGoBottom":
                        tlVectorControl1.ChangeLevel(LevelType.Bottom);
                        this.orderButton.Tag = btItem;
                        this.orderButton.ImageIndex = btItem.ImageIndex;
                        break;
                    #endregion
                    #region 图元操作
                    case "mCopy":
                        tlVectorControl1.Copy();
                        break;
                    case "mCut":
                        tlVectorControl1.Cut();
                        break;
                    case "mPaste":
                        //tlVectorControl1.Paste();
                        PasteWithProperty();
                        break;
                    case "mDelete":
                        Delete();
                        //tlVectorControl1.Operation = ToolOperation.Select;
                        break;
                    case "mUodo":
                        tlVectorControl1.Undo();
                        break;
                    case "mRedo":
                        tlVectorControl1.Redo();
                        break;
                    #endregion
                    #region 业务操作

                    case "m_line1": //线路走廊优化
                        Wjghboolflag = false;
                        frmPlanList f = new frmPlanList();
                        if (f.ShowDialog() == DialogResult.Yes)
                        {
                            linekey = f.Key;
                            tlVectorControl1.Operation = ToolOperation.Select;
                            //tlVectorControl1.Operation = ToolOperation.LeadLine;

                        }
                        break;
                    case "m_subxz": //变电站选址
                        Wjghboolflag = false;
                        Services.BaseService.GetList<PSP_SubstationSelect>();

                        frmSubstationManager mng = new frmSubstationManager();
                        mng.OnOpen += new OnOpenSubhandler(mng_OnOpen);
                        DialogResult dia = mng.ShowDialog();
                        if (dia == DialogResult.OK)
                        {
                            XZ_bdz = mng.code;
                            MessageBox.Show("请选择变电站拖放置到希望的位置或者进行变电站自动选址。");
                            PSP_SubstationSelect sel = new PSP_SubstationSelect();
                            sel.col2 = XZ_bdz;
                            IList<PSP_SubstationSelect> _plist = Services.BaseService.GetList<PSP_SubstationSelect>("SelectPSP_SubstationSelectList", sel);
                            for (int n = 0; n < _plist.Count; n++)
                            {
                                XmlNodeList _nlist = tlVectorControl1.SVGDocument.SelectNodes("svg/use [@id='" + _plist[n].EleID + "']");
                                if (_nlist.Count < 1)
                                {
                                    Services.BaseService.Delete<PSP_SubstationSelect>(_plist[n]);
                                }
                            }

                        }
                        if (dia == DialogResult.Ignore)
                        {
                            string keyid = mng.KeyID;
                            string suid = mng.SUID;
                            PSP_SubstationUserNum n1 = new PSP_SubstationUserNum();
                            n1.col2 = keyid;
                            IList<PSP_SubstationUserNum> list1 = Services.BaseService.GetList<PSP_SubstationUserNum>("SelectPSP_SubstationNum2", n1);
                            for (int i = 0; i < list1.Count; i++)
                            {
                                if (suid == list1[i].SubStationID)
                                {
                                    PSP_SubstationSelect s = new PSP_SubstationSelect();
                                    s.UID = list1[i].SubStationID;
                                    s.EleID = list1[i].userID;
                                    XmlNodeList nnn1 = tlVectorControl1.SVGDocument.SelectNodes("//* [@id='" + s.EleID + "']");
                                    foreach (XmlNode node1 in nnn1)
                                    {
                                        tlVectorControl1.SVGDocument.RootElement.RemoveChild(node1);
                                    }
                                    Services.BaseService.Update("DeletePSP_SubstationSelect", s);

                                }
                            }
                            tlVectorControl1.Refresh();

                        }
                        break;
                    case "mSubPrint":

                        Hashtable HashTable1 = new Hashtable();
                        HashTable1.Add("SUID", tlVectorControl1.SVGDocument.SvgdataUid);
                        Services.BaseService.Update("UpdateGlebePropertyAll", HashTable1);
                        break;
                    case "mJQLeadLine":
                        tlVectorControl1.Operation = ToolOperation.Select;
                        frmAddLine aLine = new frmAddLine();
                        if (aLine.ShowDialog() == DialogResult.OK)
                        {
                            string points = "";
                            StringBuilder bpts = new StringBuilder();
                            ArrayList list = aLine.list;
                            LineInfo line = aLine.line;
                            string lineWidth = aLine.LineWidth;
                            //ICollection Ilist = list.Values;
                            //IEnumerator IEnum=Ilist.GetEnumerator();
                            for (int n = 0; n < list.Count; n++)
                            {
                                //while (IEnum.MoveNext())
                                //{
                                string[] str = ((string)list[n]).Split(',');
                                //string[] str = ((string)IEnum.Current).Split(',');
                                string[] JWD1 = str[0].Split(' ');
                                double J1 = Convert.ToDouble(JWD1[0]);
                                Double W1 = Convert.ToDouble(JWD1[1]);
                                Double D1 = Convert.ToDouble(JWD1[2]);
                                string[] JWD2 = str[1].Split(' ');
                                Double J2 = Convert.ToDouble(JWD2[0]);
                                Double W2 = Convert.ToDouble(JWD2[1]);
                                Double D2 = Convert.ToDouble(JWD2[2]);

                                Double JD = J1 + W1 / 60 + D1 / 3600;
                                Double WD = J2 + W2 / 60 + D2 / 3600;
                                IntXY xy = mapview.getXY(JD, WD);
                                if (mapview is MapViewGoogle)
                                    bpts.Append(xy.X + " " + xy.Y + ",");
                                else
                                    bpts.Append((-xy.X / (double)tlVectorControl1.ScaleRatio) + " " + (-xy.Y / (double)tlVectorControl1.ScaleRatio) + ",");
                                //}
                            }
                            if (bpts.Length > 0)
                                points = bpts.ToString(0, bpts.Length - 1);

                            XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline;
                            n1.SetAttribute("IsLead", "1");
                            n1.SetAttribute("points", points);
                            n1.SetAttribute("layer", SvgDocument.currentLayer);
                            // n1.SetAttribute("style", styleValue);
                            tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                            line.UID = Guid.NewGuid().ToString();
                            line.EleID = n1.GetAttribute("id");
                            line.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                            Services.BaseService.Create<LineInfo>(line);

                        }
                        break;
                    case "mLeadLine":

                        if (!getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList()))
                        //if (!layer1.Label.Contains("电网规划层"))
                        {
                            MessageBox.Show("请选择电网规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        // sgt1.Visible = true;
                        tlVectorControl1.Operation = ToolOperation.Select;
                        tlVectorControl1.Operation = ToolOperation.LeadLine;
                        break;
                    case "m_dhx":
                        if (!getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList()))
                        //if (!layer1.Label.Contains("电网规划层"))
                        {
                            MessageBox.Show("请选择电网规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }

                        // sgt1.Visible = true;
                        str_dhx = "1";
                        tlVectorControl1.Operation = ToolOperation.Select;
                        tlVectorControl1.Operation = ToolOperation.LeadLine;
                        break;
                    case "mAreaPoly":
            #if(!CITY)
                        if (!getlayer(SvgDocument.currentLayer, "城市规划层", tlVectorControl1.SVGDocument.getLayerList()))
                        //if (!layer1.Label.Contains("城市规划层"))
                        {
                            MessageBox.Show("请选择城市规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
            #endif

                        tlVectorControl1.Operation = ToolOperation.Select;
                        tlVectorControl1.Operation = ToolOperation.AreaPolygon;

                        break;
                    case "sjsz":
                        frmCS cs = new frmCS();
                        cs.ShowDialog();
                        break;
                    case "shjg":
                        GHWPG();
                        break;
                    case "mFx":
                        SubPrint = false;
                        bool ck = false;
                        ArrayList listlayers = frmlar.GetSelectLayers();
                        //CheckedListBox.CheckedItemCollection ckcol = frmlar.checkedListBox1.CheckedItems;
                        for (int i = 0; i < listlayers.Count; i++)
                        {
                            Layer _lar = listlayers[i] as Layer;
                            if (_lar.GetAttribute("layerType") == "城市规划层")
                            {
                                ck = true;
                            }
                        }
                        if (!ck)
                        {
                            MessageBox.Show("请打开城市规划层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        if (!getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList()))
                        //if (!layer1.Label.Contains("供电区域层"))
                        {
                            MessageBox.Show("请选择电网规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        tlVectorControl1.Operation = ToolOperation.Select;
                        tlVectorControl1.Operation = ToolOperation.InterEnclosure;
                        MapType = "接线图";
                        break;
                    case "mGhfx":
                        if (!getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList()))
                        //if (!layer1.Label.Contains("供电区域层"))
                        {
                            MessageBox.Show("请选择电网规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        tlVectorControl1.Operation = ToolOperation.Enclosure;
                        // SvgDocument.currentLayer = getlayer("供电区域层", tlVectorControl1.SVGDocument.getLayerList()).ID;
                        MapType = "接线图";
                        //bar2.Visible = false;
                        break;
                    //case "mEdit":
                    //    //bar2.Visible = true;
                    //    SvgDocument.currentLayer = "layer97052";
                    //    MapType = "接线图";
                    //    break;
                    case "mFzzj": //放置注记
                        if (!getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList()))
                        //if (!layer1.Label.Contains("供电区域层"))
                        {
                            MessageBox.Show("请选择电网规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        //LayerBox.ComboBoxEx.SelectedIndex = 2;
                        tlVectorControl1.Operation = ToolOperation.Select;
                        MapType = "规划统计";
                        break;
                    case "mDkwh": //地块维护
                        frmPropertyClass frmProp = new frmPropertyClass();
                        frmProp.ShowDialog();
                        break;
                    case "mDkfl": //地块分类
                        if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg")
                        {
                            MessageBox.Show("请选择地块。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            break;
                        }
                        frmUsePropertySelect frmUseSel = new frmUsePropertySelect();
                        frmUseSel.InitData(tlVectorControl1.SVGDocument.CurrentElement.ID, tlVectorControl1.SVGDocument.SvgdataUid);
                        frmUseSel.ShowDialog();
                        break;
                    case "mGldt": //关联地图
                        if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg")
                        {
                            MessageBox.Show("请选择地块。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            break;
                        }
                        frmFileSelect frmSel = new frmFileSelect();
                        frmSel.InitData(tlVectorControl1.SVGDocument.CurrentElement.ID, tlVectorControl1.SVGDocument.SvgdataUid, true);
                        frmSel.ShowDialog();
                        break;
                    case "mPriQu":
                        SubPrint = true;
                        tlVectorControl1.Operation = ToolOperation.InterEnclosurePrint;
                        break;
                    case "m_djcl":
                        tlVectorControl1.Operation = ToolOperation.Select;
                        str_djcl = "1";
                        MessageBox.Show("请选择线路进行档距测量。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        break;
                    case "m_inxljwd":
                        frmInJWD f_in = new frmInJWD();
                        if (f_in.ShowDialog() == DialogResult.OK)
                        {

                            InputFile(f_in.GetFileName(), f_in.GetCheck());
                        }
                        break;
                    case "m_inbdzjwd":
                        frmInJWD f_in2 = new frmInJWD();
                        if (f_in2.ShowDialog() == DialogResult.OK)
                        {

                            InputBDZFile(f_in2.GetFileName(), f_in2.GetCheck());
                        }
                        break;
                    case "m_outsubjwd":

                        if (MessageBox.Show("确定要导出当前图层所有变电站坐标吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                        {
                            string str_dy = "";
                            XmlNodeList nn0 = tlVectorControl1.SVGDocument.SelectNodes("svg/use [@layer='" + SvgDocument.currentLayer + "']");
                            string lab = tlVectorControl1.SVGDocument.CurrentLayer.Label;

                            Excel.Application ex = new Excel.Application();
                            Excel.Workbook workBook = ex.Workbooks.Add(Microsoft.Office.Interop.Excel.XlWBATemplate.xlWBATWorksheet);
                            //workBook.Worksheets.Add(Type.Missing, workBook.ActiveSheet, 1, Type.Missing);
                            Excel.Worksheet xSheet1 = (Excel.Worksheet)ex.Worksheets[1];
                            int c = xSheet1.Columns.Count;
                            int r = xSheet1.Rows.Count;
                            ((Excel.Range)xSheet1.Cells[1, 1]).Value2 = "序号";
                            ((Excel.Range)xSheet1.Cells[1, 2]).Value2 = "变电站名称";
                            ((Excel.Range)xSheet1.Cells[1, 3]).Value2 = "电压等级";
                            ((Excel.Range)xSheet1.Cells[1, 4]).Value2 = "经度";
                            ((Excel.Range)xSheet1.Cells[1, 5]).Value2 = "纬度";
                            for (int n = 0; n < nn0.Count; n++)
                            {
                                XmlElement _xele = (XmlElement)nn0[n];

                                string jwd_info = _xele.GetAttribute("jwd-info");
                                string infoname = _xele.GetAttribute("info-name");
                                string dyinfo = _xele.GetAttribute("xlink:href");
                                dyinfo = getDY(dyinfo);
                                if (jwd_info != "")
                                {
                                    string[] jwd = jwd_info.Split(",".ToCharArray());

                                    ((Excel.Range)xSheet1.Cells[n + 2, 1]).Value2 = n + 1;
                                    ((Excel.Range)xSheet1.Cells[n + 2, 2]).Value2 = infoname;
                                    ((Excel.Range)xSheet1.Cells[n + 2, 3]).Value2 = dyinfo;
                                    ((Excel.Range)xSheet1.Cells[n + 2, 4]).Value2 = jwd[0].Trim();
                                    ((Excel.Range)xSheet1.Cells[n + 2, 5]).Value2 = jwd[1].Trim();

                                }
                                else
                                {

                                    // LongLat lat = mapview.ParseToLongLat(((Use)_xele).CenterPoint.X, ((Use)_xele).CenterPoint.Y);
                                    LongLat lat = mapview.OffSetZero(-(int)(Convert.ToInt32(((Use)_xele).CenterPoint.X) * tlVectorControl1.ScaleRatio), -(int)(Convert.ToInt32(((Use)_xele).CenterPoint.Y) * tlVectorControl1.ScaleRatio));
                                    ((Excel.Range)xSheet1.Cells[n + 2, 1]).Value2 = n + 1;
                                    ((Excel.Range)xSheet1.Cells[n + 2, 2]).Value2 = infoname;
                                    ((Excel.Range)xSheet1.Cells[n + 2, 3]).Value2 = dyinfo;
                                    ((Excel.Range)xSheet1.Cells[n + 2, 4]).Value2 = lat.Longitude;
                                    ((Excel.Range)xSheet1.Cells[n + 2, 5]).Value2 = lat.Latitude;

                                }

                            }

                            ex.Visible = true;
                        }
                        break;
                    case "m_outxljwd":
                        tlVectorControl1.Operation = ToolOperation.Select;

                        bool ckright = true;
                        if (MessageBox.Show("确定要导出当前图层所有线路坐标吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                        {
                            string str_dy = "";
                            XmlNodeList nn0 = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline [@IsLead='1'] [@layer='" + SvgDocument.currentLayer + "']");
                            string lab = tlVectorControl1.SVGDocument.CurrentLayer.Label;
                            for (int n = 0; n < nn0.Count; n++)
                            {
                                str_dy = "";
                                XmlElement x = nn0[n] as XmlElement;
                                str_dy = x.GetAttribute("dy-info");
                                string devid = x.GetAttribute("Deviceid");
                                if (str_dy == "")
                                {
                                    if (devid != "")
                                    {
                                        PSPDEV dev = Services.BaseService.GetOneByKey<PSPDEV>(devid);
                                        if (dev != null)
                                        {
                                            if (dev.RateVolt != 0)
                                            {
                                                str_dy = dev.RateVolt.ToString("###");
                                                ckright = true;
                                                break;
                                            }
                                        }
                                    }
                                }
                            }

                            if (str_dy == "")
                            {
                                if (MessageBox.Show("选择图层线路不包含电压等级信息,是否继续导出?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                                {
                                    ckright = true;
                                }
                                else
                                {
                                    ckright = false;
                                }
                            }
                            if (ckright)
                            {
                                Excel.Application ex = new Excel.Application();
                                Excel.Workbook workBook = ex.Workbooks.Add(Microsoft.Office.Interop.Excel.XlWBATemplate.xlWBATWorksheet);
                                for (int n = 0; n < nn0.Count; n++)
                                {
                                    XmlElement _xele = (XmlElement)nn0[n];
                                    workBook.Worksheets.Add(Type.Missing, workBook.ActiveSheet, 1, Type.Missing);
                                    Excel.Worksheet xSheet1 = (Excel.Worksheet)ex.Worksheets[n + 1];
                                    int c = xSheet1.Columns.Count;
                                    int r = xSheet1.Rows.Count;
                                    ((Excel.Range)xSheet1.Cells[1, 1]).Value2 = "杆塔号";
                                    ((Excel.Range)xSheet1.Cells[1, 2]).Value2 = "电压等级";
                                    ((Excel.Range)xSheet1.Cells[1, 3]).Value2 = "经度";
                                    ((Excel.Range)xSheet1.Cells[1, 4]).Value2 = "纬度";
                                    string jwd_info = _xele.GetAttribute("jwd-info");
                                    string gt_info = _xele.GetAttribute("gt-info");
                                    if (jwd_info != "")
                                    {
                                        string[] gt = gt_info.Split(",".ToCharArray());
                                        string[] jwd = jwd_info.Split(";".ToCharArray());
                                        for (int m = 0; m < jwd.Length; m++)
                                        {
                                            string[] jw_str = jwd[m].Split(",".ToCharArray());
                                            ((Excel.Range)xSheet1.Cells[m + 2, 1]).Value2 = gt[m];
                                            ((Excel.Range)xSheet1.Cells[m + 2, 2]).Value2 = str_dy;
                                            ((Excel.Range)xSheet1.Cells[m + 2, 3]).Value2 = jw_str[0].Trim();
                                            ((Excel.Range)xSheet1.Cells[m + 2, 4]).Value2 = jw_str[1].Trim();
                                        }
                                    }
                                    else
                                    {
                                        PointF[] pt = TLMath.getPolygonPoints(_xele);
                                        for (int k = 0; k < pt.Length; k++)
                                        {
                                            LongLat lat = mapview.OffSetZero(-(int)(Convert.ToInt32(pt[k].X) * tlVectorControl1.ScaleRatio), -(int)(Convert.ToInt32(pt[k].Y) * tlVectorControl1.ScaleRatio));
                                            //LongLat lat= mapview.ParseToLongLat(pt[k].X, pt[k].Y);
                                            ((Excel.Range)xSheet1.Cells[k + 2, 1]).Value2 = Convert.ToString(k + 1);
                                            ((Excel.Range)xSheet1.Cells[k + 2, 2]).Value2 = str_dy;
                                            ((Excel.Range)xSheet1.Cells[k + 2, 3]).Value2 = lat.Longitude;
                                            ((Excel.Range)xSheet1.Cells[k + 2, 4]).Value2 = lat.Latitude;
                                        }
                                    }
                                    string info_name = _xele.GetAttribute("info-name");
                                    if (info_name != "")
                                    {
                                        for (int k = 1; k < workBook.Worksheets.Count; k++)
                                        {
                                            if (((Excel.Worksheet)workBook.Worksheets[k]).Name == info_name)
                                            {
                                                info_name = info_name + k.ToString();
                                                break;
                                            }
                                        }
                                        xSheet1.Name = info_name;
                                    }

                                }
                                Excel.Worksheet xSheett = (Excel.Worksheet)ex.Worksheets[ex.Worksheets.Count];
                                xSheett.Activate();
                                xSheett.Delete();

                                ex.Visible = true;
                            }
                        }
                        break;
                    case "m_unsel":
                        string bdzwhere = " UID not in (";
                        string xlwhere = " where SUID not in (";
                        PSPDEV obj = new PSPDEV();
                        DeviceHelper.pspflag = false;
                        DeviceHelper.Wjghflag = false;
                        string[] deviceType = new string[] { "05", "20" };
                        XmlNodeList lslist = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline [@IsLead='1'] [@Deviceid!='']");
                        XmlNodeList useList = tlVectorControl1.SVGDocument.SelectNodes("svg/use [@Deviceid!='']");
                        //XmlNodeList useList = tlVectorControl1.SVGDocument.SelectNodes("svg/use [contains(use,'Sub')]");
                        for (int x1 = 0; x1 < lslist.Count; x1++)
                        {
                            XmlElement _node = lslist[x1] as XmlElement;
                            xlwhere = xlwhere + "'" + _node.GetAttribute("Deviceid") + "',";
                        }
                        for (int x2 = 0; x2 < useList.Count; x2++)
                        {
                            XmlElement _node = useList[x2] as XmlElement;
                            bdzwhere = bdzwhere + "'" + _node.GetAttribute("Deviceid") + "',";
                        }
                        if (bdzwhere.Length > 15)
                        {
                            bdzwhere = bdzwhere.Substring(0, bdzwhere.Length - 1);
                        }
                        if (xlwhere.Length > 15)
                        {
                            xlwhere = xlwhere.Substring(0, xlwhere.Length - 1);
                        }
                        bdzwhere = bdzwhere + ") and ";
                        xlwhere = xlwhere + ") and ";

                        DeviceHelper.bdzwhere = bdzwhere;
                        DeviceHelper.xlwhere = xlwhere;
                        DeviceHelper.SelectDeviceDLG(Itop.Client.MIS.ProgUID, deviceType);
                        DeviceHelper.bdzwhere = "";
                        DeviceHelper.xlwhere = "";
                        break;
                    case "ORP":
                        OpenProject orp = new OpenProject();
                        orp.ProjectID = Itop.Client.MIS.ProgUID;
                        orp.Initdata(false);
                        if (orp.ShowDialog() == DialogResult.OK)
                        {
                            if (orp.FileSUID != null)
                            {
                                ElectricLoadCal elcORP = new ElectricLoadCal();
                                elcORP.ORP(orp.FileSUID, 100);
                            }

                        }

                        break;
                    case "mReCompute":
                        if (MessageBox.Show("确认要重新计算全图的电量和负荷么?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            string scale = tlVectorControl1.SVGDocument.getViewScale();
                            if (scale != "")
                            {
                                Recalculate(Convert.ToDecimal(scale));
                            }
                            else
                            {
                                Recalculate(1);
                            }

                            MessageBox.Show("重新计算完成", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        break;

                    case "mXLine":
                        tlVectorControl1.Operation = ToolOperation.Select;
                        tlVectorControl1.Operation = ToolOperation.XPolyLine;
                        break;
                    case "mYLine":
                        tlVectorControl1.Operation = ToolOperation.Select;
                        tlVectorControl1.Operation = ToolOperation.YPolyLine;
                        break;

                    case "mFhbz":
                        //if (MessageBox.Show("是否生成负荷标注?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                        //{
                        //    Fhbz();
                        //}

                        //FrmSet f_set = new FrmSet();
                        //if (f_set.ShowDialog()==DialogResult.OK)
                        //{
                        if (XZ_bdz == "")
                        {
                            MessageBox.Show("请选择一个变电站选址方案。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        tlVectorControl1.Operation = ToolOperation.Select;
                        tlVectorControl1.Operation = ToolOperation.InterEnclosure;
                        bdz_xz = "yes";
                        //    str_dy = f_set.Str_dj;
                        //    str_num = f_set.Str_num;
                        //    str_jj = f_set.Str_jj;
                        //}
                        break;
                    case "mSaveGroup":
                        if (tlVectorControl1.SVGDocument.SelectCollection.Count > 1)
                        {
                            string content = "<svg>";
                            SvgElementCollection col = tlVectorControl1.SVGDocument.SelectCollection;
                            for (int i = 0; i < col.Count; i++)
                            {
                                SvgElement _e = (SvgElement)col[i];
                                if (_e.ID != "svg")
                                {
                                    content = content + _e.OuterXml;
                                }
                            }
                            RectangleF rect = tlVectorControl1.DrawArea.viewer.SelectedViewRectangle;

                            content = content + "</svg>";
                            frmSaveGroup fm = new frmSaveGroup();
                            fm.rect = rect;
                            fm.Content = content;
                            fm.ShowDialog();
                        }
                        else
                        {
                            MessageBox.Show("请至少选择2个图元。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        break;

                    case "mInsert":
                        frmUseGroup fg = new frmUseGroup();
                        if (fg.ShowDialog() == DialogResult.OK)
                        {
                            UseGroup u = fg.SelectedUseGroup;
                            if (u != null)
                            {
                                frmXY xy = new frmXY();
                                if (xy.ShowDialog() == DialogResult.OK)
                                {
                                    decimal x = xy.GetX();
                                    decimal y = xy.GetY();
                                    string content = u.Content;
                                    XmlDocument doc = new XmlDocument();
                                    doc.LoadXml(u.Content);
                                    XmlNodeList list = doc.ChildNodes;
                                    XmlNode _node = list[0];
                                    XmlNodeList sonlist = _node.ChildNodes;
                                    XmlElement ele = tlVectorControl1.SVGDocument.CreateElement("g");
                                    ele.SetAttribute("layer", SvgDocument.currentLayer);
                                    for (int i = 0; i < sonlist.Count; i++)
                                    {
                                        XmlNode _sonnode = sonlist[i];
                                        //string str = _sonnode.OuterXml;
                                        if (_sonnode.Name == "use")
                                        {
                                            string sid = ((XmlElement)_sonnode).GetAttribute("xlink:href");
                                            XmlNode _snode = symbolSelector.SymbolDoc.SelectSingleNode("//*[@id='" + sid.Substring(1) + "']");
                                            tlVectorControl1.SVGDocument.AddDefsElement((SvgElement)_snode);
                                        }
                                        ele.AppendChild(_sonnode);
                                        string ss = ele.OuterXml;
                                    }
                                    //RectangleF r=((Group)ele).GetBounds();
                                    string tr = "matrix(1,0,0,1,";

                                    tr = tr + Convert.ToString(x - Convert.ToDecimal(u.X)) + ",";
                                    tr = tr + Convert.ToString(y - Convert.ToDecimal(u.Y)) + ")";

                                    ele.SetAttribute("transform", tr);
                                    // transform="matrix(1,0,0,1,2558.82,-352.94)"
                                    tlVectorControl1.SVGDocument.RootElement.AppendChild(ele);
                                    tlVectorControl1.SVGDocument.SelectCollection.Clear();
                                    tlVectorControl1.SVGDocument.SelectCollection.Add((SvgElement)ele);
                                    tlVectorControl1.UnGroup();
                                    // tlVectorControl1.Refresh();
                                }
                            }
                        }
                        break;
                    case "m_tp":
                        frmImgManager frm = new frmImgManager();
                        frm.StrName = "";
                        frm.StrRemark = "";

                        frm.ShowDialog();
                        break;
                    case "m_reDraw":
                        string svguid = tlVectorControl1.SVGDocument.SvgdataUid;
                        XmlNodeList nn1 = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline [@IsLead='1']");
                        LineType lt = new LineType();
                        IList tpList = Services.BaseService.GetList("SelectLineTypeList", lt);
                        Hashtable dkHs = new Hashtable();

                        for (int i = 0; i < tpList.Count; i++)
                        {
                            LineType _gle = (LineType)tpList[i];
                            dkHs.Add(_gle.TypeName, _gle.Color);
                        }
                        bool bo = tlVectorControl1.SVGDocument.Update;
                        tlVectorControl1.SVGDocument.Update = false;
                        for (int j = 0; j < nn1.Count; j++)
                        {
                            XmlElement _node1 = (XmlElement)nn1.Item(j);
                            LineInfo line = new LineInfo();
                            line.SvgUID = svguid;
                            line.EleID = _node1.GetAttribute("id");
                            line = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByEleID", line);
                            if (line != null)
                            {
                                string t = (string)dkHs[line.Voltage + "kV"];
                                string color1 = ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(t)));
                                ItopVector.Core.Func.AttributeFunc.SetAttributeValue(_node1, "stroke", color1);
                            }
                        }
                        tlVectorControl1.SVGDocument.Update = bo;
                        break;
                    case "m_subColor":
                        string svguid1 = tlVectorControl1.SVGDocument.SvgdataUid;
                        XmlNodeList nn2 = tlVectorControl1.SVGDocument.SelectNodes("svg/defs/symbol");
                        LineType lt1 = new LineType();
                        IList tpList1 = Services.BaseService.GetList("SelectLineTypeList", lt1);
                        Hashtable dkHs1 = new Hashtable();
                        for (int i = 0; i < tpList1.Count; i++)
                        {
                            LineType _gle = (LineType)tpList1[i];
                            dkHs1.Add(_gle.TypeName.ToLower(), _gle.Color);
                        }
                        bool bo1 = tlVectorControl1.SVGDocument.Update;
                        tlVectorControl1.SVGDocument.Update = false;
                        Regex regex = new Regex(@"\d{2,3}(?=kv)");
                        foreach (Symbol _node1 in nn2)
                        {
                            string subName = _node1.GetAttribute("label").ToLower();

                            Match match1 = regex.Match(subName);
                            if (match1.Success)
                            {
                                try
                                {
                                    string t = (string)dkHs1[match1.Value + "kv"];
                                    //if (match1.Value == "220")
                                    //{
                                    //    t = t;
                                    //}
                                    string color1 = ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(t)));
                                    foreach (SvgElement element in _node1.GraphList)
                                    {

                                        if (element.SvgAttributes.ContainsKey("stroke") && element.SvgAttributes["stroke"].ToString() != "#FFFFFF")
                                        {
                                            ItopVector.Core.Func.AttributeFunc.SetAttributeValue(element, "stroke", color1);
                                        }
                                        if (element.SvgAttributes.ContainsKey("fill") && element.SvgAttributes["fill"].ToString() != "#FFFFFF")
                                        {
                                            ItopVector.Core.Func.AttributeFunc.SetAttributeValue(element, "fill", color1);
                                        }
                                        if (element.SvgAttributes.ContainsKey("hatch-color") && element.SvgAttributes["hatch-color"].ToString() != "#FFFFFF")
                                        {
                                            ItopVector.Core.Func.AttributeFunc.SetAttributeValue(element, "hatch-color", color1);
                                        }

                                    }
                                }
                                catch { }
                            }

                        }
                        tlVectorControl1.SVGDocument.Update = bo1;
                        break;
                    #endregion
                    #region 图层操作
                    case "layerImport":
                        tlVectorControl1.Operation = ToolOperation.FreePath;
                        layerImport();
                        break;
                    case "layerExport":
                        layerExport();
                        break;
                    case "m_kbsText":
                        openFileDialog1 = new OpenFileDialog();
                        openFileDialog1.Filter = "Excel文件(*.xls)|*.xls";
                        if (openFileDialog1.ShowDialog() == DialogResult.OK)
                        {
                            DataSet ds = ImportExcel(openFileDialog1.FileName);
                            DataTable dt1 = ds.Tables[0];
                            foreach (DataRow r1 in dt1.Rows)
                            {
                                if (r1[0].ToString() != "")
                                {
                                    SvgElement ele = null;
                                    decimal JD = 0;
                                    decimal WD = 0;
                                    JD = Convert.ToDecimal(r1[12]);
                                    WD = Convert.ToDecimal(r1[13]);
                                    PointF fnt = mapview.ParseToPoint(JD, WD);
                                    XmlElement t1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                    t1.SetAttribute("x", Convert.ToString(fnt.X / (float)tlVectorControl1.ScaleRatio + 8));
                                    t1.SetAttribute("y", Convert.ToString(fnt.Y / (float)tlVectorControl1.ScaleRatio));

                                    t1.SetAttribute("layer", SvgDocument.currentLayer);
                                    t1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                                    t1.SetAttribute("font-famliy", "宋体");
                                    t1.SetAttribute("font-size", "6");
                                    t1.InnerText = r1[2].ToString();
                                    tlVectorControl1.SVGDocument.RootElement.AppendChild(t1);
                                }
                            }
                            tlVectorControl1.Refresh();
                        }
                        break;
                    case "m_fText":
                        openFileDialog1 = new OpenFileDialog();
                        openFileDialog1.Filter = "Excel文件(*.xls)|*.xls";
                        if (openFileDialog1.ShowDialog() == DialogResult.OK)
                        {
                            DataSet ds = ImportExcel(openFileDialog1.FileName);
                            DataTable dt1 = ds.Tables[0];
                            foreach (DataRow r1 in dt1.Rows)
                            {
                                if (r1[0].ToString() != "")
                                {
                                    SvgElement ele = null;
                                    decimal JD = 0;
                                    decimal WD = 0;
                                    JD = Convert.ToDecimal(r1[9]);
                                    WD = Convert.ToDecimal(r1[10]);
                                    PointF fnt = mapview.ParseToPoint(JD, WD);
                                    XmlElement t1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                    t1.SetAttribute("x", Convert.ToString(fnt.X / (float)tlVectorControl1.ScaleRatio + 8));
                                    t1.SetAttribute("y", Convert.ToString(fnt.Y / (float)tlVectorControl1.ScaleRatio));

                                    t1.SetAttribute("layer", SvgDocument.currentLayer);
                                    t1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                                    t1.SetAttribute("font-famliy", "宋体");
                                    t1.SetAttribute("font-size", "6");
                                    t1.InnerText = r1[1].ToString();
                                    tlVectorControl1.SVGDocument.RootElement.AppendChild(t1);
                                }
                            }
                            tlVectorControl1.Refresh();
                        }
                        break;
                    case "m_inkbs":
                        openFileDialog1 = new OpenFileDialog();
                        openFileDialog1.Filter = "Excel文件(*.xls)|*.xls";
                        if (openFileDialog1.ShowDialog() == DialogResult.OK)
                        {
                            DataSet ds = ImportExcel(openFileDialog1.FileName);
                            DataTable dt1 = ds.Tables[0];
                            foreach (DataRow r1 in dt1.Rows)
                            {
                                if (r1[0].ToString() != "")
                                {
                                    SvgElement ele = null;
                                    decimal JD = 0;
                                    decimal WD = 0;
                                    JD = Convert.ToDecimal(r1[12]);
                                    WD = Convert.ToDecimal(r1[13]);
                                    //IntXY xy = mapview.getXY(JD, WD);
                                    PointF fnt = mapview.ParseToPoint(JD, WD);
                                    if (r1[7].ToString() == "运行")
                                    {
                                        ele = tlVectorControl1.CreateBySymbolID("kbs-111", new PointF((float)(fnt.X / (float)tlVectorControl1.ScaleRatio), (float)(fnt.Y / (float)tlVectorControl1.ScaleRatio)));

                                    }
                                    else
                                    {
                                        ele = tlVectorControl1.CreateBySymbolID("kbs-112", new PointF((float)(fnt.X / (float)tlVectorControl1.ScaleRatio), (float)(fnt.Y / (float)tlVectorControl1.ScaleRatio)));
                                    }
                                    ele = tlVectorControl1.AddShape(ele, Point.Empty);
                                    ele.SetAttribute("layer", tlVectorControl1.SVGDocument.CurrentLayer.ID);

                                    //points = points + (-xy.X / (decimal)tlVectorControl1.ScaleRatio) + " " + (-xy.Y / (decimal)tlVectorControl1.ScaleRatio) + ",";
                                    PSP_Gra_item item = new PSP_Gra_item();
                                    item.UID = Guid.NewGuid().ToString();
                                    item.EleKeyID = r1[1].ToString();
                                    item.EleName = r1[2].ToString();
                                    item.EleID = ele.ID;
                                    item.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    item.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;

                                    item.col1 = r1[7].ToString();
                                    item.col2 = r1[3].ToString();
                                    item.col3 = r1[4].ToString();
                                    item.col4 = r1[5].ToString();
                                    item.col5 = r1[6].ToString();
                                    item.col6 = r1[8].ToString();
                                    item.col7 = r1[9].ToString();
                                    item.col8 = "kbs";
                                    Services.BaseService.Create<PSP_Gra_item>(item);
                                }
                            }
                        }
                        break;
                    case "m_infjx":
                        openFileDialog1 = new OpenFileDialog();
                        openFileDialog1.Filter = "Excel文件(*.xls)|*.xls";
                        if (openFileDialog1.ShowDialog() == DialogResult.OK)
                        {
                            DataSet ds = ImportExcel(openFileDialog1.FileName);
                            DataTable dt1 = ds.Tables[0];
                            foreach (DataRow r1 in dt1.Rows)
                            {
                                if (r1[0].ToString() != "")
                                {
                                    SvgElement ele = null;
                                    decimal JD = 0;
                                    decimal WD = 0;
                                    JD = Convert.ToDecimal(r1[9]);
                                    WD = Convert.ToDecimal(r1[10]);
                                    //IntXY xy = mapview.getXY(JD, WD);
                                    PointF fnt = mapview.ParseToPoint(JD, WD);
                                    if (r1[4].ToString() == "运行")
                                    {
                                        ele = tlVectorControl1.CreateBySymbolID("fjx-111", new PointF((float)(fnt.X / (float)tlVectorControl1.ScaleRatio), (float)(fnt.Y / (float)tlVectorControl1.ScaleRatio)));

                                    }
                                    else
                                    {
                                        ele = tlVectorControl1.CreateBySymbolID("fjx-112", new PointF((float)(fnt.X / (float)tlVectorControl1.ScaleRatio), (float)(fnt.Y / (float)tlVectorControl1.ScaleRatio)));
                                    }
                                    ele = tlVectorControl1.AddShape(ele, Point.Empty);
                                    ele.SetAttribute("layer", tlVectorControl1.SVGDocument.CurrentLayer.ID);

                                    //points = points + (-xy.X / (decimal)tlVectorControl1.ScaleRatio) + " " + (-xy.Y / (decimal)tlVectorControl1.ScaleRatio) + ",";
                                    PSP_Gra_item item = new PSP_Gra_item();
                                    item.UID = Guid.NewGuid().ToString();
                                    item.EleKeyID = r1[2].ToString();
                                    item.EleName = r1[1].ToString();
                                    item.EleID = ele.ID;
                                    item.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    item.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;

                                    item.col1 = r1[4].ToString();
                                    item.col2 = r1[3].ToString();
                                    item.col3 = r1[5].ToString();
                                    item.col4 = r1[6].ToString();
                                    //item.col5 = r1[6].ToString();
                                    //item.col6 = r1[8].ToString();
                                    //item.col7 = r1[9].ToString();
                                    item.col8 = "fjx";
                                    Services.BaseService.Create<PSP_Gra_item>(item);
                                }
                            }
                        }
                        break;
                    case "m_inbyq":
                        openFileDialog1 = new OpenFileDialog();
                        openFileDialog1.Filter = "Excel文件(*.xls)|*.xls";
                        if (openFileDialog1.ShowDialog() == DialogResult.OK)
                        {
                            DataSet ds = ImportExcel(openFileDialog1.FileName);
                            DataTable dt1 = ds.Tables[0];
                            foreach (DataRow r1 in dt1.Rows)
                            {
                                if (r1[0].ToString() != "")
                                {
                                    SvgElement ele = null;
                                    decimal JD = 0;
                                    decimal WD = 0;
                                    JD = Convert.ToDecimal(r1[9]);
                                    WD = Convert.ToDecimal(r1[10]);
                                    //IntXY xy = mapview.getXY(JD, WD);
                                    PointF fnt = mapview.ParseToPoint(JD, WD);
                                    if (r1[4].ToString() == "运行")
                                    {
                                        ele = tlVectorControl1.CreateBySymbolID("byq-111", new PointF((float)(fnt.X / (float)tlVectorControl1.ScaleRatio), (float)(fnt.Y / (float)tlVectorControl1.ScaleRatio)));

                                    }
                                    else
                                    {
                                        ele = tlVectorControl1.CreateBySymbolID("byq-112", new PointF((float)(fnt.X / (float)tlVectorControl1.ScaleRatio), (float)(fnt.Y / (float)tlVectorControl1.ScaleRatio)));
                                    }
                                    ele = tlVectorControl1.AddShape(ele, Point.Empty);
                                    ele.SetAttribute("layer", tlVectorControl1.SVGDocument.CurrentLayer.ID);

                                    //points = points + (-xy.X / (decimal)tlVectorControl1.ScaleRatio) + " " + (-xy.Y / (decimal)tlVectorControl1.ScaleRatio) + ",";
                                    PSP_Gra_item item = new PSP_Gra_item();
                                    item.UID = Guid.NewGuid().ToString();
                                    item.EleKeyID = r1[2].ToString();
                                    item.EleName = r1[1].ToString();
                                    item.EleID = ele.ID;
                                    item.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    item.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;

                                    item.col1 = r1[4].ToString();
                                    item.col2 = r1[3].ToString();
                                    item.col3 = r1[5].ToString();
                                    item.col4 = r1[6].ToString();
                                    item.col8 = "byq";
                                    Services.BaseService.Create<PSP_Gra_item>(item);
                                }
                            }
                        }
                        break;
                    #endregion
                    #region 未来联动
                    case "m_bxz":

                        //tlVectorControl1.GoLocation();
                        Gh_BXZ();
                        break;
                    case "m_jp":
                        tlVectorControl1.ClipScreen(true);
                        break;
                    case "m_ld":
                        if (SvgDocument.currentLayer == "")
                        {
                            MessageBox.Show("请选择图层", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }

                        if (MessageBox.Show("确认要以当前选中年份为准调整以后年度的变电站及线路位置么?", "请确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            Linkage();
                        }
                        break;
                    case "m_fz":
                        if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg")
                        {
                            MessageBox.Show("请选择图元", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        CopyEle();
                        break;
                    case "m_cx":

                        xltProcessor.GoLocation(tlVectorControl1.SVGDocument.SvgdataUid, frmlar.getSelectedLayer());
                        //XmlNodeList n1111 = tlVectorControl1.SVGDocument.SelectNodes("svg/polygon [@IsArea='1']");
                        //string a = "1";
                        break;
                    #endregion
                    #region  网架优化
                    case "OpenWJ":
                        ff = new frmGProg();
                        if (ff.ShowDialog() == DialogResult.OK)
                        {
                            Wjghboolflag = true;
                            checkwjghelement();
                            dotNetBarManager1.Bars["mainmenu"].GetItem("YHoperator").Enabled = true;
                            dotNetBarManager1.Bars["mainmenu"].GetItem("YHresult").Enabled = true;
                            dotNetBarManager1.Bars["mainmenu"].GetItem("ZTBut").Enabled = true;
                            dotNetBarManager1.Bars["mainmenu"].GetItem("JQBut").Enabled = false;
                            dotNetBarManager1.Bars["mainmenu"].GetItem("ZQBut").Enabled = false;
                            dotNetBarManager1.Bars["mainmenu"].GetItem("YQBut").Enabled = false;
                        }
                        else
                        {
                            Wjghboolflag = false;

                        }
                        break;
                    case "YHoperator":

                        break;
                    case "ghwj":
                        GHWPG();
                        break;
                    case "ZTBut":
                        dotNetBarManager1.Bars["mainmenu"].GetItem("ZTBut").Enabled = false;
                        dotNetBarManager1.Bars["mainmenu"].GetItem("JQBut").Enabled = true;
                        ElectricWjgh wjgh = new ElectricWjgh();
                        wjgh.initdat(ff.Key);             //恢复数据的原来面貌

                        WaitDialogForm wait = null;
                        try
                        {
                            wait = new WaitDialogForm("", "正在处理数据, 请稍候...");
                            wjgh.jianxiancheck(ff.Key, 1, 100);
                            wait.Close();
                            MessageBox.Show("整体数据优化成功。");
                            string con = "WHERE Type='05' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + ff.Key + "'and type='线路')";
                            IList list1 = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                            foreach (PSPDEV dev in list1)
                            {
                                PSP_GprogElevice pg = new PSP_GprogElevice();
                                pg.GprogUID = ff.Key;
                                pg.DeviceSUID = dev.SUID;
                                //先找到再修改
                                pg = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByKey", pg);
                                if (pg != null)
                                {
                                    if (dev.LineStatus == "运行")
                                    {

                                        pg.ZTstatus = "运行";
                                        pg.JQstatus = "运行";
                                        pg.ZQstatus = "运行";
                                        pg.YQstatus = "运行";
                                        Services.BaseService.Update<PSP_GprogElevice>(pg);

                                    }
                                    else if (dev.LineStatus == "等待")
                                    {

                                        pg.ZTstatus = "等待";
                                        pg.JQstatus = "等待";
                                        pg.ZQstatus = "等待";
                                        pg.YQstatus = "等待";

                                        Services.BaseService.Update<PSP_GprogElevice>(pg);
                                    }
                                    else if (dev.LineStatus == "待选")
                                    {

                                        pg.ZTstatus = "待选";
                                        Services.BaseService.Update<PSP_GprogElevice>(pg);
                                    }
                                }
                            }

                            wjghmapview(1);
                        }
                        catch (Exception exc)
                        {
                            MessageBox.Show("数据存在问题,请检查后再继续!");
                            wait.Close();
                            return;
                        }
                        break;
                    case "JQBut":
                        dotNetBarManager1.Bars["mainmenu"].GetItem("JQBut").Enabled = false;
                        dotNetBarManager1.Bars["mainmenu"].GetItem("ZQBut").Enabled = true;
                        wjgh = new ElectricWjgh();
                        wjgh.JDlinecheck(ff.Key, 2);
                        JorJform selectmethod = new JorJform();
                        selectmethod.Text = "近期网架优化方法";
                        if (selectmethod.ShowDialog() == DialogResult.OK)
                        {
                            wait = new WaitDialogForm("", "正在处理数据, 请稍候...");
                            if (selectmethod.Mathindex == 0)
                            {

                                wjgh.jianxiancheck(ff.Key, 2, 100);

                                MessageBox.Show("近期数据减线优化成功。");
                            }
                            else if (selectmethod.Mathindex == 1)
                            {
                                wjgh.addlinecheck(ff.Key, 2, 100);
                                wjgh.addrightcheck(ff.Key, 2, 100);
                                for (int i = 0; i < wjgh.ercilinedengdai.Count; i++)
                                {
                                    wjgh.ercilinedengdai[i].LineStatus = "运行";
                                    Services.BaseService.Update<PSPDEV>(wjgh.ercilinedengdai[i]);
                                }
                                for (int i = 0; i < wjgh.lineyiyou.Count; i++)
                                {
                                    wjgh.lineyiyou[i].LineStatus = "待选";
                                    Services.BaseService.Update<PSPDEV>(wjgh.lineyiyou[i]);
                                }

                                MessageBox.Show("近期数据加线成功。");
                            }
                            wait.Close();
                            //此处写项目jq变化状况
                            string conjq = "WHERE Type='05' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + ff.Key + "'and type='线路'and ZTstatus in('待选'))";
                            IList list1jq = Services.BaseService.GetList("SelectPSPDEVByCondition", conjq);

                            foreach (PSPDEV dev in list1jq)
                            {
                                PSP_GprogElevice pg = new PSP_GprogElevice();
                                pg.GprogUID = ff.Key;
                                pg.DeviceSUID = dev.SUID;
                                //先找到再修改
                                pg = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByKey", pg);
                                if (pg != null)
                                {
                                    if (dev.LineStatus == "等待")
                                    {

                                        pg.JQstatus = "待选";
                                        Services.BaseService.Update<PSP_GprogElevice>(pg);
                                        //dev.LineStatus = "待选";
                                        //Services.BaseService.Update<PSPDEV>(dev);
                                    }
                                    else if (dev.LineStatus == "待选")
                                    {
                                        bool flag = false;
                                        foreach (eleclass el in wjgh.JDlinecol)
                                        {
                                            if (dev.SUID == el.suid)
                                            {
                                                flag = true;
                                                dev.LineStatus = "运行";
                                                Services.BaseService.Update<PSPDEV>(dev);
                                            }

                                        }
                                        if (flag)
                                        {
                                            pg.JQstatus = "投放";
                                            pg.ZQstatus = "运行";
                                            pg.YQstatus = "运行";
                                        }
                                        else
                                        {
                                            pg.JQstatus = "待选";
                                        }
                                        Services.BaseService.Update<PSP_GprogElevice>(pg);
                                    }
                                }

                            }
                            wjghmapview(2);
                        }
                        break;
                    case "ZQBut":
                        dotNetBarManager1.Bars["mainmenu"].GetItem("ZQBut").Enabled = false;
                        dotNetBarManager1.Bars["mainmenu"].GetItem("YQBut").Enabled = true;
                        wjgh = new ElectricWjgh();
                        wjgh.JDlinecheck(ff.Key, 3);
                        selectmethod = new JorJform();
                        selectmethod.Text = "中期网架优化方法";
                        if (selectmethod.ShowDialog() == DialogResult.OK)
                        {
                            wjghmapview(5);
                            wait = new WaitDialogForm("", "正在处理数据, 请稍候...");
                            if (selectmethod.Mathindex == 0)
                            {
                                wjgh.jianxiancheck(ff.Key, 3, 100);

                                MessageBox.Show("中期数据减线优化成功。");

                            }
                            else if (selectmethod.Mathindex == 1)
                            {
                                wjgh.addlinecheck(ff.Key, 3, 100);
                                wjgh.addrightcheck(ff.Key, 3, 100);
                                for (int i = 0; i < wjgh.ercilinedengdai.Count; i++)
                                {
                                    wjgh.ercilinedengdai[i].LineStatus = "运行";
                                    Services.BaseService.Update<PSPDEV>(wjgh.ercilinedengdai[i]);
                                }
                                for (int i = 0; i < wjgh.lineyiyou.Count; i++)
                                {
                                    wjgh.lineyiyou[i].LineStatus = "待选";
                                    Services.BaseService.Update<PSPDEV>(wjgh.lineyiyou[i]);
                                }

                                MessageBox.Show("中期数据加线成功。");
                            }
                            wait.Close();
                            //此处写项目jq变化状况
                            string conzq = "WHERE Type='05' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + ff.Key + "'and type='线路'and JQstatus in('待选'))";
                            IList list1zq = Services.BaseService.GetList("SelectPSPDEVByCondition", conzq);
                            foreach (PSPDEV dev in list1zq)
                            {
                                PSP_GprogElevice pg = new PSP_GprogElevice();
                                pg.GprogUID = ff.Key;
                                pg.DeviceSUID = dev.SUID;
                                //先找到再修改
                                pg = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByKey", pg);
                                if (pg != null)
                                {
                                    if (dev.LineStatus == "等待")
                                    {

                                        pg.ZQstatus = "待选";
                                        Services.BaseService.Update<PSP_GprogElevice>(pg);
                                        //dev.LineStatus = "待选";
                                        //Services.BaseService.Update<PSPDEV>(dev);
                                    }
                                    else if (dev.LineStatus == "待选")
                                    {
                                        bool flag = false;
                                        foreach (eleclass el in wjgh.JDlinecol)
                                        {
                                            if (el.suid == dev.SUID)
                                            {
                                                flag = true;
                                                dev.LineStatus = "运行";
                                                Services.BaseService.Update<PSPDEV>(dev);
                                            }

                                        }
                                        if (flag)
                                        {
                                            pg.ZQstatus = "投放";
                                            pg.YQstatus = "运行";
                                        }
                                        else
                                            pg.ZQstatus = "待选";
                                        Services.BaseService.Update<PSP_GprogElevice>(pg);
                                    }
                                }

                            }
                            wjghmapview(3);
                        }

                        break;
                    case "YQBut":
                        dotNetBarManager1.Bars["mainmenu"].GetItem("YQBut").Enabled = false;
                        dotNetBarManager1.Bars["mainmenu"].GetItem("ZTBut").Enabled = true;
                        wjgh = new ElectricWjgh();
                        wjgh.JDlinecheck(ff.Key, 4);
                        wjghmapview(6);
                        selectmethod = new JorJform();
                        selectmethod.Text = "远期网架优化方法";
                        if (selectmethod.ShowDialog() == DialogResult.OK)
                        {
                            wait = new WaitDialogForm("", "正在处理数据, 请稍候...");
                            if (selectmethod.Mathindex == 0)
                            {

                                wjgh.jianxiancheck(ff.Key, 4, 100);

                                MessageBox.Show("远期数据减线优化成功。");
                            }
                            else if (selectmethod.Mathindex == 1)
                            {
                                wjgh.addlinecheck(ff.Key, 4, 100);
                                wjgh.addrightcheck(ff.Key, 4, 100);
                                for (int i = 0; i < wjgh.ercilinedengdai.Count; i++)
                                {
                                    wjgh.ercilinedengdai[i].LineStatus = "运行";
                                    Services.BaseService.Update<PSPDEV>(wjgh.ercilinedengdai[i]);
                                }
                                for (int i = 0; i < wjgh.lineyiyou.Count; i++)
                                {
                                    wjgh.lineyiyou[i].LineStatus = "待选";
                                    Services.BaseService.Update<PSPDEV>(wjgh.lineyiyou[i]);
                                }

                                MessageBox.Show("远期数据加线成功。");
                            }
                            wait.Close();
                            //此处写项目jq变化状况
                            string conyq = "WHERE Type='05' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + ff.Key + "'and type='线路'and ZQstatus in('待选'))";
                            IList list1yq = Services.BaseService.GetList("SelectPSPDEVByCondition", conyq);
                            // wjgh = new ElectricWjgh();
                            foreach (PSPDEV dev in list1yq)
                            {
                                PSP_GprogElevice pg = new PSP_GprogElevice();
                                pg.GprogUID = ff.Key;
                                pg.DeviceSUID = dev.SUID;
                                //先找到再修改
                                pg = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByKey", pg);
                                if (pg != null)
                                {
                                    if (dev.LineStatus == "等待")
                                    {
                                        bool flag = false;
                                        foreach (eleclass el in wjgh.JDlinecol)
                                        {
                                            if (el.suid == dev.SUID)
                                            {
                                                flag = true;
                                                dev.LineStatus = "运行";
                                                Services.BaseService.Update<PSPDEV>(dev);
                                            }
                                        }
                                        if (flag)
                                            pg.YQstatus = "投放";
                                        else
                                            pg.YQstatus = "待选";
                                        Services.BaseService.Update<PSP_GprogElevice>(pg);
                                        //pg.YQstatus = "待选";
                                        //Services.BaseService.Update<PSP_GprogElevice>(pg);
                                    }
                                    else if (dev.LineStatus == "待选")
                                    {
                                        bool flag = false;
                                        foreach (eleclass el in wjgh.JDlinecol)
                                        {
                                            if (el.suid == dev.SUID)
                                            {
                                                flag = true;
                                                dev.LineStatus = "运行";
                                                Services.BaseService.Update<PSPDEV>(dev);
                                            }
                                        }
                                        if (flag)
                                            pg.YQstatus = "投放";
                                        else
                                            pg.YQstatus = "待选";
                                        Services.BaseService.Update<PSP_GprogElevice>(pg);
                                    }
                                }

                            }
                            wjghmapview(4);
                        }
                        break;
                    case "YHresult":
                        wjgh = new ElectricWjgh();
                        frmGProList p1 = new frmGProList();
                        p1.Show();
                        p1.LoadData(wjgh.LoadData(ff.Key));
                        break;
                    #endregion
                    #region 线路优选

                    case "bt_edit":

                        break;
                    case "bt_start":
                        if (linekey == "")
                        {
                            MessageBox.Show("请选择线路所属的方案。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }

                        sel_sym = "bt_start";
                        tlVectorControl1.Operation = ToolOperation.Symbol;
                        break;
                    case "bt_end":
                        if (sel_start_point == "")
                        {
                            MessageBox.Show("请选择线路起点。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        sel_sym = "bt_end";
                        tlVectorControl1.Operation = ToolOperation.Symbol;
                        break;
                    case "bt_must":
                        if (sel_start_point == "")
                        {
                            MessageBox.Show("请选择线路起点。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        sel_sym = "bt_must";
                        tlVectorControl1.Operation = ToolOperation.Symbol;
                        break;
                    case "bt_point":
                        if (sel_start_point == "")
                        {
                            MessageBox.Show("请选择线路起点。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        sel_sym = "bt_point";
                        tlVectorControl1.Operation = ToolOperation.Symbol;
                        break;
                    case "bt_make":
                        if (sel_start_point == "")
                        {
                            MessageBox.Show("请选择线路起点。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }

                        frmInputDialog frm_input = new frmInputDialog();
                        if (frm_input.ShowDialog() == DialogResult.OK)
                        {

                            SortedList orderlist = new SortedList();

                            XmlNodeList XLlist = tlVectorControl1.SVGDocument.SelectNodes("//*[@start_point=\"" + sel_start_point + "\"]");
                            try
                            {
                                for (int i = 0; i < XLlist.Count; i++)
                                {
                                    XmlElement node = (XmlElement)XLlist[i];
                                    orderlist.Add(Convert.ToInt32(node.GetAttribute("order")), node);
                                }
                            }
                            catch (Exception ex1)
                            {
                                MessageBox.Show("存在相同的节点顺序号,请修改。\n\r" + ex1.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PointF[] _points = new PointF[XLlist.Count];
                            for (int i = 0; i < orderlist.Count; i++)
                            {
                                PointF[] f1 = new PointF[1] { new PointF(((Use)orderlist.GetByIndex(i)).X + 6, ((Use)orderlist.GetByIndex(i)).Y + 6) };
                                ((Use)orderlist.GetByIndex(i)).Transform.Matrix.TransformPoints(f1);
                                _points[i] = f1[0];
                            }
                            string str_points = "";
                            for (int i = 0; i < _points.Length; i++)
                            {
                                str_points = str_points + _points[i].X + " " + _points[i].Y + ",";
                            }
                            if (str_points.Length > 1)
                            {
                                str_points = str_points.Substring(0, str_points.Length - 1);
                            }

                            XmlElement _templine = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline;
                            _templine.SetAttribute("IsLead", "1");
                            _templine.SetAttribute("points", str_points);
                            _templine.SetAttribute("layer", SvgDocument.currentLayer);
                            Random dom = new Random();
                            int int_d = dom.Next(99999);
                            string styleValue = "stroke:" + ColorTranslator.ToHtml(Color.FromArgb(int_d));
                            _templine.SetAttribute("style", styleValue);
                            XmlNode tt_node = tlVectorControl1.SVGDocument.RootElement.AppendChild(_templine);
                            LineInfo gh_line = new LineInfo();
                            gh_line.UID = Guid.NewGuid().ToString();
                            gh_line.EleID = _templine.GetAttribute("id");
                            gh_line.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                            Services.BaseService.Create<LineInfo>(gh_line);
                            tlVectorControl1.Refresh();
                            if (MessageBox.Show("是否删除该线路的参考点?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                            {
                                tlVectorControl1.SVGDocument.SelectCollection.Clear();
                                for (int i = 0; i < XLlist.Count; i++)
                                {
                                    if (((SvgElement)XLlist[i]).GetAttribute("xlink:href").Contains("XL_GT_4") || ((SvgElement)XLlist[i]).GetAttribute("xlink:href").Contains("XL_GT_3"))
                                    {
                                        tlVectorControl1.SVGDocument.SelectCollection.Add((SvgElement)XLlist[i]);
                                    }

                                }
                                tlVectorControl1.Delete();
                            }
                            string str = "";
                            LineList1 line1 = new LineList1();
                            line1.UID = Guid.NewGuid().ToString();
                            //line1.LineEleID = tlVectorControl1.SVGDocument.CurrentElement.ID;
                            line1.PointNum = ((Polyline)(tt_node)).Points.Length - 2;
                            line1.Coefficient = (decimal)(1.02);
                            line1.Length = TLMath.getPolylineLength(((Polyline)(tt_node)), Convert.ToDecimal(tlVectorControl1.ScaleRatio));
                            line1.Length2 = TLMath.getPolylineLength(((Polyline)(tt_node)), Convert.ToDecimal(tlVectorControl1.ScaleRatio)) * Convert.ToDecimal(1.02);
                            PointF[] pnt = ((Polyline)(tt_node)).Points;
                            if (pnt.Length < 3) return;
                            for (int i = 0; i < pnt.Length; i++)
                            {
                                double ang = TLMath.getLineAngle(pnt[i], pnt[i + 1], pnt[i + 2]);
                                if (ang * 57.3 > 60)
                                {
                                    MessageBox.Show("线路转角不能大于60度。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    tlVectorControl1.Delete();
                                    return;
                                }
                                str = str + "第" + (i + 1) + "转角:" + Convert.ToDouble(ang * 57.3).ToString("##.##") + "度。\r\n";
                                if (i == pnt.Length - 3)
                                {
                                    break;
                                }
                            }
                            line1.TurnAngle = str;
                            line1.col1 = linekey;

                            line1.LineName = frm_input.InputStr;
                            line1.LineEleID = ((SvgElement)tt_node).ID;
                            Services.BaseService.Create<LineList1>(line1);
                            sel_start_point = "";
                            tlVectorControl1.Operation = ToolOperation.Select;
                        }
                        break;
                    case "Niula":
                        Wjghboolflag = false;
                        OpenProject op = new OpenProject();
                        op.ProjectID = Itop.Client.MIS.ProgUID;
                        op.Initdata(false);
                        if (op.ShowDialog() == DialogResult.OK)
                        {
                            if (op.FileSUID != null)
                            {

                                Psptypeform pt = new Psptypeform();
                                if (pt.ShowDialog() == DialogResult.OK)
                                {
                                    frnReport wFrom = new frnReport();
                                    wFrom.Owner = this;
                                    wFrom.Show();
                                    wFrom.Text = this.Text + "—牛拉法潮流计算";
                                    wFrom.ShowText += "正在收集信息\t" + System.DateTime.Now.ToString();
                                    ElectricLoadCal elc = new ElectricLoadCal();
                                    elc.LFC(op.FileSUID, 1, 100, wFrom);
                                    ShowResult(0, op.FileSUID, op.FileName, pt.PspOuttype, wFrom);
                                }

                            }

                        }

                        break;
                    case "pq":
                        Wjghboolflag = false;
                        op = new OpenProject();
                        op.ProjectID = Itop.Client.MIS.ProgUID;
                        op.Initdata(false);
                        if (op.ShowDialog() == DialogResult.OK)
                        {
                            if (op.FileSUID != null)
                            {
                                Psptypeform pt = new Psptypeform();
                                if (pt.ShowDialog() == DialogResult.OK)
                                {
                                    frnReport wFrom = new frnReport();
                                    wFrom.Owner = this;
                                    wFrom.Show();
                                    wFrom.Text = this.Text + "—PQ法潮流计算";
                                    wFrom.ShowText += "正在收集信息\t" + System.DateTime.Now.ToString();
                                    ElectricLoadCal elc = new ElectricLoadCal();
                                    ElectricLoadCal elcPQ = new ElectricLoadCal();
                                    elcPQ.LFC(op.FileSUID, 2, 100, wFrom);
                                    // elcPQ.LFCER(op.FileSUID, 2, 100);
                                    ShowResult(1, op.FileSUID, op.FileName, pt.PspOuttype, wFrom);
                                }
                            }

                        }

                        break;

                    case "GausSeidel":
                        Wjghboolflag = false;
                        op = new OpenProject();
                        op.ProjectID = Itop.Client.MIS.ProgUID;
                        op.Initdata(false);
                        if (op.ShowDialog() == DialogResult.OK)
                        {
                            if (op.FileSUID != null)
                            {
                                Psptypeform pt = new Psptypeform();
                                if (pt.ShowDialog() == DialogResult.OK)
                                {
                                    frnReport wFrom = new frnReport();
                                    wFrom.Owner = this;
                                    wFrom.Show();
                                    wFrom.Text = this.Text + "—高斯赛德尔迭代法潮流计算";
                                    wFrom.ShowText += "正在收集信息\t" + System.DateTime.Now.ToString();
                                    ElectricLoadCal elc = new ElectricLoadCal();
                                    ElectricLoadCal elcGS = new ElectricLoadCal();
                                    elcGS.LFC(op.FileSUID, 3, 100, wFrom);
                                    ShowResult(2, op.FileSUID, op.FileName, pt.PspOuttype, wFrom);
                                }
                            }

                        }

                        break;
                    case "N_RZYz":
                        Wjghboolflag = false;
                        op = new OpenProject();
                        op.ProjectID = Itop.Client.MIS.ProgUID;
                        op.Initdata(false);
                        if (op.ShowDialog() == DialogResult.OK)
                        {
                            if (op.FileSUID != null)
                            {
                                Psptypeform pt = new Psptypeform();
                                if (pt.ShowDialog() == DialogResult.OK)
                                {
                                    frnReport wFromZYZ = new frnReport();
                                    wFromZYZ.Owner = this;
                                    wFromZYZ.Show();
                                    wFromZYZ.Text = this.Text + "—最有乘子法潮流计算";
                                    wFromZYZ.ShowText += "正在收集信息\t" + System.DateTime.Now.ToString();
                                    ElectricLoadCal elcN_RZYz = new ElectricLoadCal();
                                    elcN_RZYz.LFC(op.FileSUID, 4, 100, wFromZYZ);
                                    ShowResult(3, op.FileSUID, op.FileName, pt.PspOuttype, wFromZYZ);
                                }
                            }

                        }

                        break;
                    case "NLnFH":
                        Wjghboolflag = false;
                        op = new OpenProject();
                        op.ProjectID = Itop.Client.MIS.ProgUID;
                        op.Initdata(false);
                        if (op.ShowDialog() == DialogResult.OK)
                        {
                            if (op.FileSUID != null)
                            {
                                Psptypeform pt = new Psptypeform();
                                if (pt.ShowDialog() == DialogResult.OK)
                                {
                                    frnReport wFromZYZ = new frnReport();
                                    wFromZYZ.Owner = this;
                                    wFromZYZ.Show();
                                    wFromZYZ.Text = this.Text + "—最有乘子法潮流计算";
                                    wFromZYZ.ShowText += "正在收集信息\t" + System.DateTime.Now.ToString();
                                    ElectricLoadCal elcN_RZYz = new ElectricLoadCal();
                                    elcN_RZYz.LFCS(op.FileSUID, 4, 100);
                                    ShowResult(3, op.FileSUID, op.FileName, pt.PspOuttype, wFromZYZ);
                                }
                            }

                        }

                        break;
                    #endregion
                }
            }
        }
Пример #12
0
        public void GHWPG()
        {
            string output = null;
            frnReport wForm = new frnReport(); ;
            wForm.Owner = this;
            FileStream rs1;
            StreamWriter strRS1;
            Excel.Application mx = new Excel.Application(); ;
            Excel.Application xl = new Excel.Application(); ;
            StringBuilder stResult = new StringBuilder();
            bool N1 = false;
            String chaoliuSUID = null;
            try
            {
                frmOpenProject fop = new frmOpenProject();
                fop.ProjectID = Itop.Client.MIS.ProgUID;
                fop.Initdata();
                String strr = chaoliuSUID;
                stResult.Append("规划网架评估结果" + "\r\n" + "\r\n");
                //OpenProject op = new OpenProject();
                //op.ProjectID = Itop.Client.MIS.ProgUID;
                //op.Initdata();

                if (fop.ShowDialog() == DialogResult.OK)
                {
                    wForm.Text = this.Text + "—规划网评估";
                    wForm.Show();
                    Application.DoEvents();
                    if (fop.ChaoLiuSUID == null)
                    {
                        chaoliuSUID = fop.DuanLuSUID;
                    }
                    else
                    {
                        chaoliuSUID = fop.ChaoLiuSUID;
                    }
                    if (chaoliuSUID == null)
                    {
                        return;
                    }
                    if (chaoliuSUID != null)
                    {
                        wForm.ShowText = "正在进行潮流计算\t" + System.DateTime.Now.ToString();
                        ElectricLoadCal elc = new ElectricLoadCal();
                        bool flag = elc.LFC(chaoliuSUID, 1, 100, wForm);
                        if (flag == true)
                        {
                            wForm.ShowText += "\r\n正在处理潮流计算结果\t" + System.DateTime.Now.ToString();
                            // WaitDialogForm wf = new WaitDialogForm("", "正在处理数据, 请稍候...");
                            stResult.Append("1 潮流计算评价指标" + "\r\n");
                            stResult.Append("1.1 线路负载率" + "\r\n");
                            output = null;

                            output += ("全网交流线结果报表" + "\r\n" + "\r\n");
                            output += ("单位:kA\\kV\\MW\\Mvar" + "\r\n" + "\r\n");
                            output += ("计算日期:" + System.DateTime.Now.ToString() + "\r\n" + "\r\n");
                            output += ("支路名称" + "," + "支路有功" + "," + "支路无功" + "," + "有功损耗" + "," + "无功损耗" + "," + "电流幅值" + "," + "电流相角" + "," + "越限标志" + "," + "\r\n");
                            string strCon1 = ",PSPDEV WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + chaoliuSUID + "'" + " AND PSPDEV.Type = '05' order by PSPDEV.RateVolt,PSPDEV.Name";
                            IList list1 = Services.BaseService.GetList("SelectPSP_ElcDeviceByCondition", strCon1);
                            double fuzail = 0.0;
                            double Amax = 0;
                            double Amin = 0;
                            int i = 0, j = 0;
                            StringBuilder gfzlline = new StringBuilder();
                            foreach (PSP_ElcDevice elcDEV in list1)
                            {
                                PSPDEV dev = new PSPDEV();
                                dev.SUID = elcDEV.DeviceSUID;
                                dev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", dev);
                                string lineF = "否";
                                if (dev.KSwitchStatus == "1")
                                {
                                    continue;
                                }
                                if (Convert.ToDouble(GetColValue(elcDEV, 0).COL14) * 1000 > (double)dev.Burthen)
                                {
                                    lineF = "是";
                                }
                                //double vTemp = Convert.ToDouble(GetColValue(elcDEV,type-1));
                                //double vTemp1 =  TLPSPVmin * dev.RateVolt;
                                //double vTemp2 =  TLPSPVmax * dev.RateVolt;
                                output += dev.Name.ToString() + "," + Convert.ToDouble(GetColValue(elcDEV, 0).COL4).ToString() + "," + Convert.ToDouble(GetColValue(elcDEV, 0).COL5).ToString() + "," + Convert.ToDouble(GetColValue(elcDEV, 0).COL6).ToString() + "," + Convert.ToDouble(GetColValue(elcDEV, 0).COL7).ToString() + "," + Convert.ToDouble(GetColValue(elcDEV, 0).COL14).ToString() + "," + Convert.ToDouble(GetColValue(elcDEV, 0).COL15).ToString() + "," + lineF + "," + "\r\n";
                                double A = 0;
                                if (elcDEV.COL14 != "" || elcDEV.COL20 != "")
                                {
                                    A = (Convert.ToDouble(elcDEV.COL14) * 1000) / Convert.ToDouble(elcDEV.COL20);
                                }

                                if (i == 0)
                                {
                                    Amax = A;
                                    Amin = A;
                                    i++;
                                }
                                fuzail += A;
                                if (A > 1)
                                {
                                    j++;
                                    gfzlline.Append(dev.Name + "负载率" + A.ToString("#####.##") + ",");

                                }
                                if (Amin >= A)
                                {
                                    Amin = A;
                                }
                                else if (Amax < A)
                                {
                                    Amax = A;
                                }
                            }
                            try
                            {
                                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result1.csv"))
                                {
                                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\result1.csv");
                                }
                            }
                            catch (System.Exception ex3)
                            {
                                MessageBox.Show("请关闭相关Excel后再查看结果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }

                            rs1 = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result1.csv"), FileMode.OpenOrCreate);
                            strRS1 = new StreamWriter(rs1, Encoding.Default);
                            strRS1.Write(output);
                            strRS1.Close();
                            xl.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result1.csv");
                            fuzail = fuzail / list1.Count;
                            stResult.Append("平均负载率:," + fuzail.ToString() + ",");
                            stResult.Append("最小负载率:," + Amin.ToString() + ",");
                            stResult.Append("最大负载率:," + Amax.ToString() + ",");
                            stResult.Append("过载线路条数:," + j.ToString() + "\r\n");
                            if (j > 0)
                            {
                                stResult.Append("过载的线路为:" + gfzlline.ToString() + "\r\n");
                            }

                            strCon1 = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + chaoliuSUID + "'" + " AND PSPDEV.Type = '02' order by PSPDEV.RateVolt,PSPDEV.Name";
                            IList list2 = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon1);
                            strCon1 = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + chaoliuSUID + "'" + " AND PSPDEV.Type = '03' order by PSPDEV.RateVolt,PSPDEV.Name";
                            IList list3 = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon1);
                            if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH1.txt"))
                            {
                            }
                            else
                            {
                                return;
                            }
                            FileStream ih = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DH1.txt", FileMode.Open);
                            StreamReader readLine = new StreamReader(ih, Encoding.Default);
                            string strLine = readLine.ReadLine();
                            char[] charSplit = new char[] { ' ' };
                            double byqFuZaiLv = 0.0;
                            double Bmax = 0;
                            double Bmin = 0;
                            int bi = 0, bj = 0;
                            gfzlline = new StringBuilder();
                            IList listobject = new List<object>();
                            while (strLine != null && strLine != "")
                            {
                                string[] array1 = strLine.Split(charSplit, StringSplitOptions.RemoveEmptyEntries);
                                listobject.Add(array1);
                                foreach (PSPDEV byq in list2)
                                {
                                    if (byq.Name == array1[0])
                                    {
                                        double tempA = Math.Sqrt(Convert.ToDouble(array1[3]) * Convert.ToDouble(array1[3]) + Convert.ToDouble(array1[4]) * Convert.ToDouble(array1[4])) / ((double)byq.Burthen);
                                        byqFuZaiLv += tempA;
                                        if (bi == 0)
                                        {
                                            Bmax = tempA;
                                            Bmin = tempA;
                                            bi++;
                                        }
                                        if (tempA > 1)
                                        {
                                            bj++;
                                            gfzlline.Append(byq.Name + "负载率" + tempA.ToString("#####.##") + ",");
                                        }
                                        if (Bmin >= tempA)
                                        {
                                            Bmin = tempA;
                                        }
                                        else if (Bmax < tempA)
                                        {
                                            Bmax = tempA;
                                        }
                                    }
                                }
                                strLine = readLine.ReadLine();
                            }
                            readLine.Close();
                            foreach (PSPDEV byq3 in list3)
                            {
                                double p = 0;
                                double q = 0;
                                foreach (string[] obj in listobject)
                                {
                                    if (obj[0] == byq3.Name && (obj[1] == byq3.KName || obj[2] == byq3.KName))
                                    {
                                        p += Convert.ToDouble(obj[3]);
                                        q += Convert.ToDouble(obj[4]);
                                    }
                                }
                                double tempA = Math.Sqrt(p * p + q * q) / byq3.SiN;
                                byqFuZaiLv += tempA;
                                if (bi == 0)
                                {
                                    Bmax = tempA;
                                    Bmin = tempA;
                                    bi++;
                                }
                                if (tempA > 1)
                                {
                                    bj++;
                                    gfzlline.Append(byq3.Name + "负载率" + tempA.ToString("#####.##") + ",");
                                }
                                if (Bmin >= tempA)
                                {
                                    Bmin = tempA;
                                }
                                else if (Bmax < tempA)
                                {
                                    Bmax = tempA;
                                }
                            }
                            if (list2.Count + list3.Count == 0)
                            {
                                byqFuZaiLv = 0;
                            }
                            else
                            {
                                byqFuZaiLv = byqFuZaiLv / (list2.Count + list3.Count);
                            }

                            stResult.Append("1.2 变压器负载率" + "\r\n");
                            stResult.Append("平均负载率:," + byqFuZaiLv.ToString() + ",");
                            stResult.Append("最小负载率:," + Bmin.ToString() + ",");
                            stResult.Append("最大负载率:," + Bmax.ToString() + ",");
                            stResult.Append("过载变压器台数:," + bj.ToString() + "\r\n");
                            if (bj > 0)
                            {
                                stResult.Append("过载变压器为:" + gfzlline.ToString() + "\r\n");
                            }
                            string strCon = ",PSPDEV WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + chaoliuSUID + "'" + " AND PSPDEV.Type = '01' order by PSPDEV.RateVolt,PSPDEV.Name";
                            IList list4 = Services.BaseService.GetList("SelectPSP_ElcDeviceByCondition", strCon);
                            double voltP = 0;
                            double Vmax = 0, Vmin = 0;
                            int vi = 0, vj = 0;
                            output = null;
                            gfzlline = new StringBuilder();
                            output += ("全网母线(发电、负荷)结果报表 " + "\r\n" + "\r\n");
                            output += ("单位:kA\\kV\\MW\\Mvar" + "\r\n" + "\r\n");
                            output += ("计算日期:" + System.DateTime.Now.ToString() + "\r\n" + "\r\n");
                            output += ("母线名" + "," + "电压幅值" + "," + "电压相角" + "," + "有功发电" + "," + "无功发电" + "," + "有功负荷" + "," + "无功负荷" + "," + "越限标志" + "," + "过载标志" + "\r\n");
                            foreach (PSP_ElcDevice busDEV in list4)
                            {
                                string voltF = "否";
                                string pF = "否";
                                PSPDEV dev = new PSPDEV();
                                dev.SUID = busDEV.DeviceSUID;
                                dev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", dev);
                                //double vTemp = Convert.ToDouble(GetColValue(elcDEV,type-1));
                                //double vTemp1 =  TLPSPVmin * dev.RateVolt;
                                //double vTemp2 =  TLPSPVmax * dev.RateVolt;
                                if (dev == null)
                                {
                                    continue;
                                }
                                double voltExcursion = 0.0;
                                voltExcursion = (Convert.ToDouble(busDEV.COL2) - dev.RateVolt) / dev.RateVolt;
                                voltP += Math.Abs(voltExcursion);
                                if (vi == 0)
                                {
                                    Vmax = voltExcursion;
                                    Vmin = voltExcursion;
                                    vi++;
                                }
                                if (voltFlag(voltExcursion, dev.RateVolt) == "不合格")
                                {
                                    vj++;
                                    gfzlline.Append(dev.Name + ",");
                                }
                                if (Vmin >= voltExcursion)
                                {
                                    Vmin = voltExcursion;
                                }
                                else if (Vmax < voltExcursion)
                                {
                                    Vmax = voltExcursion;
                                }
                                if (dev.KSwitchStatus == "1")
                                {
                                    continue;
                                }
                                if (Convert.ToDouble(GetColValue(busDEV, 0).COL2) < dev.iV || Convert.ToDouble(GetColValue(busDEV, 0).COL2) > dev.jV)
                                {
                                    voltF = "是";
                                }
                                if (Convert.ToDouble(GetColValue(busDEV, 0).COL2) > (double)dev.Burthen)
                                {
                                    pF = "是";
                                }

                                if (Convert.ToDouble(GetColValue(busDEV, 0).COL4) > 0)
                                {

                                    output += dev.Name + "," + Convert.ToDouble(GetColValue(busDEV, 0).COL2).ToString() + "," + Convert.ToDouble(GetColValue(busDEV, 0).COL3).ToString() + "," + Convert.ToDouble(GetColValue(busDEV, 0).COL4).ToString() + "," + Convert.ToDouble(GetColValue(busDEV, 0).COL5).ToString() + "," + "0" + "," + "0" + "," + voltF + "," + pF + "\r\n";

                                }
                                else
                                {

                                    output += dev.Name + "," + Convert.ToDouble(GetColValue(busDEV, 0).COL2).ToString() + "," + Convert.ToDouble(GetColValue(busDEV, 0).COL3).ToString() + "," + "0" + "," + "0" + "," + Convert.ToDouble(GetColValue(busDEV, 0).COL4).ToString() + "," + Convert.ToDouble(GetColValue(busDEV, 0).COL5).ToString() + "," + voltF + "," + pF + "\r\n";

                                }
                            }
                            try
                            {
                                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result.csv"))
                                {
                                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\result.csv");
                                }
                            }
                            catch (System.Exception ex2)
                            {
                                MessageBox.Show("请关闭相关Excel后再查看结果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }

                            rs1 = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result.csv"), FileMode.OpenOrCreate);
                            strRS1 = new StreamWriter(rs1, Encoding.Default);
                            strRS1.Write(output);
                            strRS1.Close();
                            mx.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result.csv"); ;
                            voltP = voltP / list4.Count;
                            stResult.Append("1.3 节点电压偏移" + "\r\n");
                            stResult.Append("平均节点电压偏移:," + voltP.ToString() + ",");
                            stResult.Append("最大下偏移:," + Vmin.ToString() + ",");
                            stResult.Append("最大上偏移:," + Vmax.ToString() + ",");
                            stResult.Append("电压越限节点数:," + vj.ToString() + "\r\n");
                            if (vj > 0)
                            {
                                stResult.Append("电压越限的节点为:" + gfzlline.ToString() + "\r\n");
                            }
                            {
                                string strCon11 = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + chaoliuSUID + "'";
                                string strCon22 = null;
                                string strCon33 = null;
                                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH1.txt"))
                                {
                                }
                                else
                                {
                                    return;
                                }
                                FileStream dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DH1.txt", FileMode.Open);
                                StreamReader readLine1 = new StreamReader(dh, Encoding.Default);
                                char[] charSplit1 = new char[] { ' ' };
                                string strLine1 = readLine1.ReadLine();
                                double temp1 = 0;
                                double temp2 = 0;
                                double temp3 = 0; ;
                                double temp4 = 0;
                                double temp5 = 0, temp6 = 0, temp7 = 0, temp8 = 0;
                                string[] array1 = strLine.Split(charSplit);

                                string strCon3 = ",PSPDEV WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + chaoliuSUID + "'" + " AND PSPDEV.Type = '01' order by PSPDEV.RateVolt,PSPDEV.Name";
                                IList list = Services.BaseService.GetList("SelectPSP_ElcDeviceByCondition", strCon3);
                                double tempAD = 0;
                                foreach (PSP_ElcDevice elcDEV in list)
                                {
                                    PSPDEV dev = new PSPDEV();
                                    dev.SUID = elcDEV.DeviceSUID;
                                    dev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", dev);
                                    tempAD += dev.OutP;
                                    if (Convert.ToDouble(GetColValue(elcDEV, 0).COL4) < 0 && dev.NodeType == "0")
                                    {
                                        tempAD += Convert.ToDouble(GetColValue(elcDEV, 0).COL4);
                                    }
                                }
                                if (tempAD == 0)
                                {
                                    tempAD = 1;
                                }
                                while (strLine1 != null && strLine1 != "")
                                {
                                    array1 = strLine1.Split(charSplit);

                                    string[] dev = new string[20];
                                    dev.Initialize();
                                    int ii = 0;

                                    foreach (string str in array1)
                                    {
                                        if (str != "")
                                        {
                                            if (ii == 0)
                                            {
                                                dev[ii++] = str.ToString();
                                            }
                                            else
                                            {
                                                if (str != "NaN")
                                                {
                                                    dev[ii++] = Convert.ToDouble(str).ToString();
                                                }
                                                else
                                                {
                                                    dev[ii++] = str;
                                                }

                                            }
                                        }

                                    }
                                    strCon22 = " AND Type= '05' AND Name = '" + array1[0] + "' AND FirstNode = " + array1[1] + " AND LastNode = " + array1[2];
                                    strCon33 = strCon11 + strCon22;
                                    PSPDEV CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon33);

                                    if (CR != null)
                                    {
                                        temp1 += Math.Abs(Convert.ToDouble(dev[5]) * 100);
                                        temp2 += Math.Abs(Convert.ToDouble(dev[6]) * 100);
                                        temp5 += Math.Abs(Convert.ToDouble(dev[3]) * 100);
                                        temp6 += Math.Abs(Convert.ToDouble(dev[4]) * 100);
                                    }
                                    else
                                    {
                                        strCon22 = " AND Type= '02' AND Name = '" + array1[0] + "'";
                                        strCon33 = strCon11 + strCon22;
                                        CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon33);
                                        if (CR == null)
                                        {
                                            strCon22 = " AND Type= '03' AND Name = '" + array1[0] + "'";
                                            strCon33 = strCon11 + strCon22;
                                            CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon33);
                                        }
                                        if (CR != null)
                                        {
                                            temp3 += Math.Abs(Convert.ToDouble(dev[5]) * 100);
                                            temp4 += Math.Abs(Convert.ToDouble(dev[6]) * 100);
                                            temp7 += Math.Abs(Convert.ToDouble(dev[3]) * 100);
                                            temp8 += Math.Abs(Convert.ToDouble(dev[4]) * 100);
                                        }
                                    }
                                    strLine1 = readLine1.ReadLine();
                                }
                                double lineLoss = temp1 / temp5;
                                double bLoss = temp3 / temp7;
                                if (temp5 == 0)
                                {
                                    lineLoss = 0;
                                }
                                if (temp7 == 0)
                                {
                                    bLoss = 0;
                                }
                                readLine1.Close();
                                stResult.Append("2 线损率" + "\r\n");
                                stResult.Append("线路有功损耗:," + lineLoss.ToString() + ",");
                                stResult.Append("变压器有功损耗:," + bLoss.ToString() + "\r\n");
                            }
                            wForm.ShowText += "\r\n正在进行N-1校验\t" + System.DateTime.Now.ToString();
                            ElcRel er = new ElcRel();
                            N1 = er.WebCalAndPrint(chaoliuSUID, Itop.Client.MIS.ProgUID, 100);
                            // wf.Close();
                        }
                        else
                        {
                            wForm.ShowText += "\r\n计算失败\t" + System.DateTime.Now.ToString();
                            MessageBox.Show("数据不收敛,请检查数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        }
                    }

                    {
                        if (fop.DuanLuSUID != null)
                        {
                            Application.DoEvents();
                            //WaitDialogForm wait = null;
                            //wait = new WaitDialogForm("", "正在处理数据, 请稍候...");
                            wForm.ShowText += "\r\n正在进行短路计算\t" + System.DateTime.Now.ToString();
                            ElectricShorti esc = new ElectricShorti();
                            esc.AllShortWJ(fop.DuanLuSUID, fop.ProjectID, 0, 100, null);
                            wForm.ShowText += "\r\n正在处理短路计算结果\t" + System.DateTime.Now.ToString();
                        }
                        else
                        {
                            Application.DoEvents();
                            //WaitDialogForm wait = null;
                            //wait = new WaitDialogForm("", "正在处理数据, 请稍候...");
                            wForm.ShowText += "\r\n正在进行短路计算\t" + System.DateTime.Now.ToString();
                            ElectricShorti esc = new ElectricShorti();
                            esc.AllShortWJ(chaoliuSUID, fop.ProjectID, 0, 100, null);
                            wForm.ShowText += "\r\n正在处理短路计算结果\t" + System.DateTime.Now.ToString();
                        }
                        // wait.Close();
                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt"))
                        {
                            StringBuilder dlrl = new StringBuilder();
                            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[] { ' ' };
                            string strCon1 = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + chaoliuSUID + "'";
                            string strCon2 = null;
                            string strCon = null;
                            double Ik = 0;
                            double Imax = 0;
                            double Imin = 0;
                            int ii = 0, ij = 0;
                            int num = 0;
                            strLineGU = readLineGU.ReadLine();
                            while ((strLineGU = readLineGU.ReadLine()) != null)
                            {
                                arrayGU = strLineGU.Split(charSplitGU, StringSplitOptions.RemoveEmptyEntries);
                                strCon2 = " AND Type= '01' AND Number = " + arrayGU[2] + " AND Name = '" + arrayGU[1] + "'";
                                strCon = strCon1 + strCon2;
                                PSPDEV devMX = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                                if (devMX != null)
                                {
                                    double tempI = Convert.ToDouble(arrayGU[3]);
                                    Ik += tempI;
                                    num++;
                                    if (ii == 0)
                                    {
                                        Imax = tempI;
                                        Imin = tempI;
                                        ii++;
                                    }
                                    if (!shortI(tempI, (int)devMX.RateVolt))
                                    {
                                        ij++;
                                        dlrl.Append(devMX.Name + ",");
                                    }
                                    if (Imin >= tempI)
                                    {
                                        Imin = tempI;
                                    }
                                    else if (Imax < tempI)
                                    {
                                        Imax = tempI;
                                    }

                                }
                                else
                                {
                                    continue;
                                }

                            }
                            readLineGU.Close();
                            Ik = Ik / num;
                            stResult.Append("3 短路电流计算评价指标" + "\r\n");
                            stResult.Append("平均短路电流:," + Ik.ToString() + ",");
                            stResult.Append("最小短路电流:," + Imin.ToString() + ",");
                            stResult.Append("最大短路电流:," + Imax.ToString() + ",");
                            stResult.Append("短路电流超标母线数:," + ij.ToString() + "\r\n");
                            if (ij > 0)
                            {
                                stResult.Append("短路电流超标的母线为:" + dlrl.ToString() + "\r\n");
                            }
                        }
                        else
                        {
                            wForm.ShowText += "\r\n短路计算失败!\t" + System.DateTime.Now.ToString();
                        }

                    }

                    stResult.Append("4 N-1校核" + "\r\n");
                    if (N1)
                    {
                        stResult.Append("通过或不通过:," + "通过");
                    }
                    else
                    {
                        stResult.Append("通过或不通过:," + "不通过");
                    }
                    wForm.ShowText += "\r\n正在形成报表\t" + System.DateTime.Now.ToString();
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\" + "result2.csv"))
                    {
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\" + "result2.csv");
                    }
                    FileStream re = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result2.csv"), FileMode.OpenOrCreate);
                    StreamWriter str1 = new StreamWriter(re, Encoding.Default);
                    str1.Write(stResult);
                    str1.Close();

                    Excel.Application ex = new Excel.Application();
                    ex.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result2.csv");
                    Excel.Worksheet xSheet1 = (Excel.Worksheet)ex.Worksheets[1];
                    ex.Worksheets.Add(System.Reflection.Missing.Value, xSheet1, 2, System.Reflection.Missing.Value);

                    xSheet1.Name = "规划网评估";
                    xSheet1.get_Range(xSheet1.Cells[1, 1], xSheet1.Cells[1, 8]).MergeCells = true;
                    xSheet1.get_Range(xSheet1.Cells[1, 1], xSheet1.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                    xSheet1.get_Range(xSheet1.Cells[1, 1], xSheet1.Cells[1, 1]).Font.Size = 16;
                    xSheet1.get_Range(xSheet1.Cells[1, 1], xSheet1.Cells[1, 1]).Font.Name = "黑体";
                    xSheet1.get_Range(xSheet1.Cells[5, 2], xSheet1.Cells[5, 6]).NumberFormatLocal = "0.000%";
                    xSheet1.get_Range(xSheet1.Cells[8, 2], xSheet1.Cells[8, 6]).NumberFormatLocal = "0.000%";
                    xSheet1.get_Range(xSheet1.Cells[12, 2], xSheet1.Cells[12, 6]).NumberFormatLocal = "0.000%";
                    xSheet1.Rows.AutoFit();
                    xSheet1.Columns.AutoFit();

                    Excel.Worksheet xSheet = (Excel.Worksheet)ex.Worksheets.get_Item(2);
                    //ex.Worksheets.Add(System.Reflection.Missing.Value, xSheet, 1, System.Reflection.Missing.Value);
                    Excel.Worksheet newWorksheet = (Excel.Worksheet)ex.Worksheets.get_Item(3);
                    // ex.Worksheets.Add(System.Reflection.Missing.Value, newWorksheet, 3, System.Reflection.Missing.Value);
                    Excel.Worksheet tempSheet = (Excel.Worksheet)mx.Worksheets.get_Item(1);
                    tempSheet.Cells.Select();
                    tempSheet.Cells.Copy(System.Reflection.Missing.Value);
                    xSheet.Paste(System.Reflection.Missing.Value, System.Reflection.Missing.Value);

                    System.Windows.Forms.Clipboard.Clear();
                    tempSheet = (Excel.Worksheet)xl.Worksheets.get_Item(1);
                    tempSheet.Cells.Select();
                    tempSheet.Cells.Copy(System.Reflection.Missing.Value);
                    newWorksheet.Paste(System.Reflection.Missing.Value, System.Reflection.Missing.Value);
                    newWorksheet.Name = "线路电流";
                    xSheet.Name = "母线潮流";

                    xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 9]).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[7, 1], xSheet.Cells[7, 9]).Interior.ColorIndex = 45;
                    xSheet.get_Range(xSheet.Cells[8, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6;
                    xSheet.get_Range(xSheet.Cells[8, 2], xSheet.Cells[xSheet.UsedRange.Rows.Count, 9]).NumberFormat = "0.0000_ ";
                    xSheet.get_Range(xSheet.Cells[3, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 9]).Font.Name = "楷体_GB2312";
                    //xSheet.get_Range(xSheet.Cells[3, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 1]).NumberFormatLocal = "@";

                    newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 9]).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;
                    newWorksheet.get_Range(newWorksheet.Cells[7, 1], newWorksheet.Cells[7, 8]).Interior.ColorIndex = 45;
                    newWorksheet.get_Range(newWorksheet.Cells[8, 1], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6;
                    // newWorksheet.get_Range(newWorksheet.Cells[6, 1], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 1]).NumberFormatLocal = "@";
                    newWorksheet.get_Range(newWorksheet.Cells[8, 2], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 9]).NumberFormat = "0.0000_ ";
                    newWorksheet.get_Range(newWorksheet.Cells[3, 1], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 9]).Font.Name = "楷体_GB2312";

                    //op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fck.excel"), FileMode.OpenOrCreate);
                    //str1 = new StreamWriter(op, Encoding.Default);
                    xSheet.Rows.AutoFit();
                    xSheet.Columns.AutoFit();
                    newWorksheet.Rows.AutoFit();
                    newWorksheet.Columns.AutoFit();
                    System.Windows.Forms.Clipboard.Clear();
                    ex.DisplayAlerts = false;
                    ex.Visible = true;
                    wForm.ShowText += "\r\n网架评估结束\t" + System.DateTime.Now.ToString();
                }
                //op.Initdata();  //临时修改
                //if (op.ShowDialog() == DialogResult.OK)
                //{

                //}

            }
            catch
            {
                wForm.ShowText += "\r\n网架评估失败\t" + System.DateTime.Now.ToString();
            }
            //wForm.Close();
        }
Пример #13
0
        private void AllshortItem_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            ElectricShorti elc = new ElectricShorti();

            //TreeListNode node = treeList1.FocusedNode;
            if (strID == null)
            {
                MessageBox.Show("请先选择电气计算方案!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            //strID = node["ID"].ToString();
            //elc.CheckDL(strID, 100);
            int           n3           = 0;
            ShorttypeForm shortfangshi = new ShorttypeForm();
            ShortTform    shorttype    = new ShortTform();
            frnReport     wFrom        = new frnReport();

            wFrom.Text = "短路计算";
            wFrom.Show();
            wFrom.ShowText += "进行相关设置\t" + System.DateTime.Now.ToString();
            if (shortfangshi.ShowDialog() == DialogResult.OK)
            {
                if (shortfangshi.Mathindex == 0)
                {
                    shorttype.ShowDialog();
                    if (shorttype.DialogResult == DialogResult.OK)
                    {
                        switch (shorttype.DuanluType)
                        {
                        case "单相接地":
                            n3 = 1;
                            break;

                        case "两相接地":
                            n3 = 3;
                            break;

                        case "两相故障":
                            n3 = 2;
                            break;

                        case "三相故障":
                            n3 = 0;
                            break;
                        }
                        elc.OutType   = shorttype.Mathindex;
                        elc.Compuflag = shorttype.Compuflag;
                    }
                    else
                    {
                        return;
                    }
                    //WaitDialogForm wait = null;
                    try {
                        // wait = new WaitDialogForm("", "正在处理数据, 请稍候...");

                        elc.AllShort(strID, this.ProjectUID, n3, 100, wFrom);
                        //elc.ALLShortThread(strID, this.ProjectUID, n3, 100, wait);
                        //wait.Close();
                    } catch (Exception exc) {
                        wFrom.ShowText += "\r\n短路计算失败\t" + System.DateTime.Now.ToString();
                        Debug.Fail(exc.Message);
                        Itop.Client.Common.HandleException.TryCatch(exc);
                        // wait.Close();
                        return;
                    }
                }
                if (shortfangshi.Mathindex == 1)
                {
                    SelshortbusForm1 selbusfrm = new SelshortbusForm1();
                    selbusfrm.ProjectSUID = strID;
                    selbusfrm.ProjectID   = Itop.Client.MIS.ProgUID;
                    selbusfrm.ShowDialog();
                    if (selbusfrm.DialogResult == DialogResult.OK)
                    {
                        List <PSPDEV> list = new List <PSPDEV>();
                        foreach (DataRow row in selbusfrm.DT.Rows)
                        {
                            try {
                                if ((bool)row["C"])
                                {
                                    PSPDEV psp = new PSPDEV();
                                    psp.SUID = row["A"].ToString();

                                    psp = (PSPDEV)UCDeviceBase.DataService.GetObject("SelectPSPDEVByKey", psp);
                                    if (psp != null)
                                    {
                                        list.Add(psp);
                                    }
                                }
                            } catch (System.Exception ex) {
                            }
                        }
                        if (list.Count == 0)
                        {
                            MessageBox.Show("没有选择短路的母线!");
                            return;
                        }
                        shorttype.ShowDialog();
                        if (shorttype.DialogResult == DialogResult.OK)
                        {
                            switch (shorttype.DuanluType)
                            {
                            case "单相接地":
                                n3 = 1;
                                break;

                            case "两相接地":
                                n3 = 3;
                                break;

                            case "两相故障":
                                n3 = 2;
                                break;

                            case "三相故障":
                                n3 = 0;
                                break;
                            }
                            elc.OutType   = shorttype.Mathindex;
                            elc.Compuflag = shorttype.Compuflag;
                        }
                        else
                        {
                            return;
                        }
                        // WaitDialogForm wait = null;
                        try {
                            //wait = new WaitDialogForm("", "正在处理数据, 请稍候...");
                            elc.Partshort(strID, this.ProjectUID, n3, 100, list, wFrom);
                            //wait.Close();
                        } catch (Exception exc) {
                            wFrom.ShowText += "\r\n短路计算失败\t" + System.DateTime.Now.ToString();
                            Debug.Fail(exc.Message);
                            Itop.Client.Common.HandleException.TryCatch(exc);
                            //wait.Close();
                            return;
                        }
                    }
                }
            }
        }
Пример #14
0
        public void PLE(string projectSUID, int type, float ratedCapacity)
        {
            dydir.Clear();
            string strCon1 = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'";
            string strCon2 = null;
            string strCon = null;
            frnReport wFrom = new frnReport();
            wFrom.Text = "线损计算";
            wFrom.Show();
            wFrom.ShowText += "正在收集信息\t" + System.DateTime.Now.ToString();
            try
            {
                LFC(projectSUID, type, ratedCapacity,wFrom);
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\" + projectSUID + "线损计算结果.xls"))
                {
                    //System.Diagnostics.Process.Start(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "线损计算结果.xls");
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\" + projectSUID + "线损计算结果.xls");
                    //OpenRead(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + ".xls");
                }
                //else
                //{

                double yinzi = 0, capability = 0, volt = 0, standvolt = 0, current = 0, Rad_to_Deg = 57.29577951;
                //PSPDEV benchmark = new PSPDEV();
                //benchmark.Type = "power";
                //benchmark.ProjectID = Itop.Client.MIS.ProgUID;
                //IList list3 = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", benchmark);
                //if (list3 == null)
                //{
                //    MessageBox.Show("请设置基准后再进行计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //    return;
                //}
                //foreach (PSPDEV dev in list3)
                //{
                //    yinzi = Convert.ToDouble(dev.PowerFactor);
                //    capability = Convert.ToDouble(dev.StandardCurrent);
                //    volt = Convert.ToDouble(dev.StandardVolt);
                //    if (dev.PowerFactor == 0)
                //    {
                //        yinzi = 1;
                //    }
                //    if (dev.StandardCurrent == 0)
                //    {
                //        capability = 1;
                //    }
                //    if (dev.StandardVolt == 0)
                //    {
                //        volt = 1;
                //    }
                //    volt = standvolt;
                //    current = capability / (Math.Sqrt(3) * volt);

                //}
                //capability = 100;

                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH2.txt"))
                {
                }
                else
                {
                    wFrom.ShowText += "\r\n计算失败\t" + System.DateTime.Now.ToString();
                    return;
                }
                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\IH2.txt"))
                {
                }
                else
                {
                    wFrom.ShowText += "\r\n计算失败\t" + System.DateTime.Now.ToString();
                    return;
                }
                FileStream dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DH2.txt", FileMode.Open);
                StreamReader readLine = new StreamReader(dh, Encoding.Default);
                char[] charSplit = new char[] { ' ' };
                string strLine = readLine.ReadLine();
                double temp1 = 0;
                double temp2 = 0;
                string output = null;
                string[] array1 = strLine.Split(charSplit);
                wFrom.ShowText += "\r\n正在形成报表\t" + System.DateTime.Now.ToString();
                string strCon13 = ",PSPDEV WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'" + " AND PSPDEV.Type = '01'  order by PSPDEV.RateVolt,PSPDEV.Name";
                IList list = Services.BaseService.GetList("SelectPSP_ElcDeviceByCondition", strCon13);
                double tempAD = 0;
                //int count = 0;
                foreach (PSP_ElcDevice elcDEV in list)
                {

                    PSPDEV dev = new PSPDEV();
                    dev.SUID = elcDEV.DeviceSUID;
                    dev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", dev);

                    string strCon3 = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "' AND Type = '04' AND IName = '" + dev.Name + "'";
                    IList listFDJ = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon3);
                    string strCon4 = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "' AND Type = '12' AND IName = '" + dev.Name + "'";
                    IList listFH = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon4);
                    foreach (PSPDEV devFDJ in listFDJ)
                    {
                        if (devFDJ.UnitFlag == "0")
                        {
                            tempAD += devFDJ.OutP;
                            //outQ += devFDJ.OutQ;
                        }
                        else
                        {
                            tempAD += devFDJ.OutP / ratedCapacity;
                            //outQ += devFDJ.OutQ / ratedCapacity;
                        }
                    }
                    foreach (PSPDEV devFH in listFH)
                    {
                        if (devFH.UnitFlag == "0")
                        {
                            if(devFH.InPutP<0)
                            {
                                tempAD += Math.Abs(devFH.InPutP);
                            }
                        }
                        else
                        {
                            if (devFH.InPutP < 0)
                            {
                                tempAD += Math.Abs(devFH.InPutP / ratedCapacity);
                            }
                        }
                    }
                    if (dev.OutP>0)
                    {
                        if (dev.UnitFlag == "0")
                        {
                            if (dev.OutP>0)
                            {
                                tempAD += dev.OutP;
                            }
                            //outQ += devFDJ.OutQ;
                        }
                        else
                        {
                            if (dev.OutP>0)
                            {
                                tempAD += dev.OutP / ratedCapacity;
                            }
                            //outQ += devFDJ.OutQ / ratedCapacity;
                        }
                    }
                    else if (dev.InPutP<0)
                    {
                        if (dev.UnitFlag == "0")
                        {
                            if (dev.InPutP < 0)
                            {
                                tempAD += Math.Abs(dev.InPutP);
                            }
                        }
                        else
                        {
                            if (dev.InPutP < 0)
                            {
                                tempAD += Math.Abs(dev.InPutP / ratedCapacity);
                            }
                        }
                    }
                    if (Convert.ToDouble(GetColValue(elcDEV, 1).COL4) < 0 && dev.NodeType == "0")
                    {
                        tempAD += Convert.ToDouble(GetColValue(elcDEV, 1).COL4)/ratedCapacity;
                    }
                }
                if (tempAD == 0)
                {
                    tempAD = 1;
                }
                output += ("全网线损结果报表" + "\r\n" + "\r\n");
                output += ("单位:MW" + "\r\n" + "\r\n");
                output += ("计算日期:" + System.DateTime.Now.ToString() + "\r\n" + "\r\n");
                output += ("支路名称" + "," + "支路类型" + "," + "导线型号" + "," + "导线长度" + "," + "有功损耗" + "," + "无功损耗" + "," + "线损率" + "\r\n");

                while (strLine != null && strLine != "")
                {
                    array1 = strLine.Split(charSplit);
                    //count++;

                    string[] dev = new string[20];
                    dev.Initialize();
                    int i = 0;

                    foreach (string str in array1)
                    {
                        if (str != "")
                        {
                            if (i == 0)
                            {
                                dev[i++] = str.ToString();
                            }
                            else
                            {
                                if (!str.Contains("NAN") && !str.Contains("IND"))//!= "NaN"
                                {
                                    dev[i++] = Convert.ToDouble(str).ToString();
                                }
                                else
                                {
                                    //dev[i++] = str;
                                    dev[i++] = "0";
                                }

                            }
                        }

                    }
                    strCon2 = " AND Type= '05' AND Name = '" + array1[0] + "' AND FirstNode = " + array1[1] + " AND LastNode = " + array1[2];
                    strCon = strCon1 + strCon2;
                    PSPDEV CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);

                    if (CR != null)
                    {
                        //if (Math.Abs(Convert.ToDouble(dev[5]))>Math.Abs(Convert.ToDouble(dev[3])))
                        //{
                        //    dev[3] = dev[7];
                        //}
                        if (Math.Abs(Convert.ToDouble(dev[3]))==0)
                        {
                            output += CR.Name + "," + "普通线路" + "," + CR.LineType + "," + CR.LineLength + "," + (Convert.ToDouble(dev[5]) * 100 + Convert.ToDouble(dev[9]) * CR.ReferenceVolt * CR.ReferenceVolt * 100 / 1000000).ToString() + "," + (Convert.ToDouble(dev[6]) * 100 + Convert.ToDouble(dev[10]) * CR.ReferenceVolt * CR.ReferenceVolt * 100 / 1000000).ToString() + "," + "0" + "\r\n";
                        }
                        else
                        {
                            output += CR.Name + "," + "普通线路" + "," + CR.LineType + "," + CR.LineLength + "," + (Convert.ToDouble(dev[5]) * 100 + Convert.ToDouble(dev[9]) * CR.ReferenceVolt * CR.ReferenceVolt * 100 / 1000000).ToString() + "," + (Convert.ToDouble(dev[6]) * 100 + Convert.ToDouble(dev[10]) * CR.ReferenceVolt * CR.ReferenceVolt * 100 / 1000000).ToString() + "," + Math.Abs(((Convert.ToDouble(dev[5]) * 100 + (Convert.ToDouble(dev[9]) * CR.ReferenceVolt * CR.ReferenceVolt * 100) / 1000000) / (Convert.ToDouble(dev[3]) * 100))).ToString() + "\r\n";
                        }

                        temp1 += Convert.ToDouble(dev[5]) * 100 + Convert.ToDouble(dev[9]) * CR.ReferenceVolt * CR.ReferenceVolt * 100 / 1000000;
                        temp2 += Convert.ToDouble(dev[6]) * 100 + Convert.ToDouble(dev[10]) * CR.ReferenceVolt * CR.ReferenceVolt * 100 / 1000000;
                        getyg(CR.ReferenceVolt, Convert.ToDouble(dev[5]) * 100 + Convert.ToDouble(dev[9]) * CR.ReferenceVolt * CR.ReferenceVolt * 100 / 1000000, Convert.ToDouble(dev[6]) * 100 + Convert.ToDouble(dev[10]) * CR.ReferenceVolt * CR.ReferenceVolt * 100 / 1000000);
                    }
                    else
                    {
                        strCon2 = " AND Type= '02' AND Name = '" + array1[0] + "'";
                        strCon = strCon1 + strCon2;
                        CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                        if (CR == null)
                        {
                            strCon2 = " AND Type= '03' AND Name = '" + array1[0] + "'";
                            strCon = strCon1 + strCon2;
                            CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByCondition", strCon);
                        }
                        if (CR != null)
                        {
                            if (Math.Abs(Convert.ToDouble(dev[5])) > Math.Abs(Convert.ToDouble(dev[3])))
                            {
                                dev[3] = dev[7];
                            }
                            output += CR.Name + "," + "变压器支路" + "," + CR.LineType + "," + CR.LineLength + "," + (Convert.ToDouble(dev[5]) * 100 + Convert.ToDouble(dev[9]) * CR.ReferenceVolt * CR.ReferenceVolt * 100 / 1000000).ToString() + "," + (Convert.ToDouble(dev[6]) * 100 + Convert.ToDouble(dev[10]) * CR.ReferenceVolt * CR.ReferenceVolt * 100 / 1000000).ToString() + "," + Math.Abs(((Convert.ToDouble(dev[5]) * 100 + Convert.ToDouble(dev[9]) * CR.ReferenceVolt * CR.ReferenceVolt * 100 / 1000000) / (Convert.ToDouble(dev[3]) * 100))).ToString() + "\r\n";
                            temp1 += Convert.ToDouble(dev[5]) * 100 + Convert.ToDouble(dev[9]) * CR.ReferenceVolt * CR.ReferenceVolt * 100 / 1000000;
                            temp2 += Convert.ToDouble(dev[6]) * 100 + Convert.ToDouble(dev[10]) * CR.ReferenceVolt * CR.ReferenceVolt * 100 / 1000000;
                            getyg(CR.ReferenceVolt, Convert.ToDouble(dev[5]) * 100 + Convert.ToDouble(dev[9]) * CR.ReferenceVolt * CR.ReferenceVolt * 100 / 1000000, Convert.ToDouble(dev[6]) * 100 + Convert.ToDouble(dev[10]) * CR.ReferenceVolt * CR.ReferenceVolt * 100 / 1000000);
                        }
                    }

                    strLine = readLine.ReadLine();
                }
                readLine.Close();

                output += ("总损耗" + "," + "线路 " + "," + "" + "," + "" + "," + temp1 + "," + temp2 + "," + temp1 / (tempAD * ratedCapacity)+ "\r\n");
                if (dydir.Keys.Count>1)
                {
                    foreach (KeyValuePair<double, lossyw> keyvalue in dydir)
                    {
                        output += ("电压等级为" + keyvalue.Key.ToString() + "," + "线路" + "," + "" + "," + "" + "," + keyvalue.Value.tempyg + "," + keyvalue.Value.tempwg + "," + keyvalue.Value.tempyg / (tempAD * ratedCapacity) + "\r\n");
                    }

                }
                try
                {
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result1.csv"))
                    {
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\result1.csv");
                    }
                }
                catch (System.Exception ex10)
                {
                    MessageBox.Show("请关闭相关Excel后再查看结果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                FileStream op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result1.csv"), FileMode.OpenOrCreate);
                StreamWriter str1 = new StreamWriter(op, Encoding.Default);
                str1.Write(output);
                str1.Close();

                Excel.Application ex = new Excel.Application();
                ex.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result1.csv");
                Excel.Worksheet xSheet = (Excel.Worksheet)ex.Worksheets[1];
                //ex.Worksheets.Add(System.Reflection.Missing.Value, xSheet, 1, System.Reflection.Missing.Value);

                //result1 = new Excel.Application();
                //result1.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result1.csv");
                //tempSheet = (Excel.Worksheet)result1.Worksheets.get_Item(1);
                //newWorksheet = (Excel.Worksheet)ex.Worksheets.get_Item(1);
                //newWorksheet.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);

                xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 7]).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[7, 1], xSheet.Cells[7, 7]).Interior.ColorIndex = 45;
                xSheet.get_Range(xSheet.Cells[8, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6;
                //xSheet.get_Range(xSheet.Cells[6, 2], xSheet.Cells[xSheet.UsedRange.Rows.Count, 2]).ColumnWidth = 12;
                xSheet.get_Range(xSheet.Cells[8, 2], xSheet.Cells[xSheet.UsedRange.Rows.Count, 2]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                xSheet.get_Range(xSheet.Cells[8, 2], xSheet.Cells[xSheet.UsedRange.Rows.Count, 7]).NumberFormat = "0.0000_ ";
                xSheet.get_Range(xSheet.Cells[3, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 7]).Font.Name = "楷体_GB2312";
                xSheet.get_Range(xSheet.Cells[8, 7], xSheet.Cells[xSheet.UsedRange.Rows.Count, 7]).NumberFormatLocal = "0.0000%";
                //newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 9]).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;
                //newWorksheet.get_Range(newWorksheet.Cells[5, 1], newWorksheet.Cells[5, 8]).Interior.ColorIndex = 45;
                //newWorksheet.get_Range(newWorksheet.Cells[6, 1], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6;
                //newWorksheet.get_Range(newWorksheet.Cells[6, 2], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 9]).NumberFormat = "0.0000_ ";
                //newWorksheet.get_Range(newWorksheet.Cells[3, 1], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 9]).Font.Name = "楷体_GB2312";

                //op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fck.excel"), FileMode.OpenOrCreate);
                //str1 = new StreamWriter(op, Encoding.Default);
                xSheet.Rows.AutoFit();
                xSheet.Columns.AutoFit();

                //result1.Save(System.Windows.Forms.Application.StartupPath + "\\fck.xls");

                //newWorksheet.SaveAs(System.Windows.Forms.Application.StartupPath + "\\" + fn + "线损计算结果.xls", Excel.XlFileFormat.xlXMLSpreadsheet, null, null, false, false, false, null, null, null);

                //str1.Write();
                //op.Close();

                xSheet.SaveAs(System.Windows.Forms.Application.StartupPath + "\\" + projectSUID + "线损计算结果.xls", Excel.XlFileFormat.xlXMLSpreadsheet, null, null, false, false, false, null, null, null);

                System.Windows.Forms.Clipboard.Clear();
                //result1.Workbooks.Close();
                //result1.Quit();
                //ex.Workbooks.Close();
                //ex.Quit();
            }
            //}
            catch (System.Exception e1)
            {
                wFrom.ShowText += "\r\n报表生成失败\t" + System.DateTime.Now.ToString();
                MessageBox.Show("请进行潮流计算后再查看结果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            wFrom.ShowText += "\r\n线损计算结束\t" + System.DateTime.Now.ToString();
        }
Пример #15
0
        private void dotNetBarManager1_ItemClick(object sender, EventArgs e)
        {
            DevComponents.DotNetBar.ButtonItem btItem = sender as DevComponents.DotNetBar.ButtonItem;
            //Layer layer1 = (Layer)LayerBox.ComboBoxEx.SelectedItem;
            if (btItem != null) {
                switch (btItem.Name) {
                    #region 文件操作
                    case "mNew":
                        frmNewProject frmprojectDLG = new frmNewProject();
                        frmprojectDLG.Name = "";
                        if (frmprojectDLG.ShowDialog() == DialogResult.OK) {
                            tlVectorControl1.NewFile();
                            PSP_ELCPROJECT pd = new PSP_ELCPROJECT();
                            pd.Name = frmprojectDLG.Name;
                            pd.FileType = frmprojectDLG.FileType;
                            pd.Class = System.DateTime.Now.ToString();
                            pd.ProjectID = this.ProjectUID;
                            tlVectorControl1.SVGDocument.SvgdataUid = pd.ID;
                            SvgDocument.currentLayer = Layer.CreateNew("默认层", tlVectorControl1.SVGDocument).ID;
                            Layer la = tlVectorControl1.SVGDocument.GetLayerByID(SvgDocument.currentLayer);
                            la.SetAttribute("layerType", "电网规划层");
                            Services.BaseService.Create<PSP_ELCPROJECT>(pd);
                            if (pd.ID != null) {
                                Open(pd.ID);
                                intdata(pd.ID);
                                //if (this.Text.Contains())
                                //{
                                //}
                                this.Text = frmname + "-" + pd.Name;
                            }
                            this.Show();
                            jxtbar(1);
                            LoadShape("symbol20.xml");
                        }
                        break;
                    case "mOpen":
                        //if (tlVectorControl1.IsModified == true)
                        //{
                        //DialogResult a;
                        //a = MessageBox.Show("图形已修改,是否保存?", "提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);

                        //if (a == DialogResult.Yes)
                        //{
                        Save();
                        //    }
                        //    else if (a == DialogResult.No)
                        //    {
                        //    }
                        //    else if (a == DialogResult.Cancel)
                        //    {
                        //        return;
                        //    }

                        //}
                        OpenProject op = new OpenProject();
                        op.ProjectID = this.ProjectUID;
                        op.Initdata(false);
                        if (op.ShowDialog() == DialogResult.OK) {
                            if (op.FileSUID != null) {
                                Open(op.FileSUID);
                                intdata(op.FileSUID);
                                //if (this.Text.Contains())
                                //{
                                //}
                                this.Text = frmname + "-" + op.FileName;
                            }
                            this.Show();
                            jxtbar(1);
                            LoadShape("symbol20.xml");

                        }
                        break;
                    case "barDeviceData":
                        frmProjectManager frmPdlg = new frmProjectManager();
                        frmPdlg.SetMode(tlVectorControl1.SVGDocument.SvgdataUid);
                        frmPdlg.ShowDialog();
                        break;
                    case "btExSymbol":
                        tlVectorControl1.ExportSymbol();
                        break;
                    case "mjxt"://导入接线图
                        ImportJxt2 jxt = new ImportJxt2(tlVectorControl1);
                        jxt.Import();
                        break;
                    case "mSave":
                        Save();
                        //tlVectorControl1.Save();
                        //frmElementName dlg = new frmElementName();
                        //dlg.TextInput = tlVectorControl1.SVGDocument.FileName;
                        //if (dlg.ShowDialog() == DialogResult.OK)
                        //{
                        //    tlVectorControl1.SVGDocument.FileName = dlg.TextInput;
                        //    Save();
                        //}
                        break;
                    case "mSaveAs":
                        tlVectorControl1.SaveAs();
                        break;
                    case "mExit":
                        this.Close();
                        break;
                    case "bt1":
                        //InitTK();
                        break;
                    case "bt2":
                        break;
                    case "mPriSet":
                        this.tlVectorControl1.Operation = ToolOperation.InterEnclosurePrint;
                        break;
                    case "mPrint":
                        tlVectorControl1.Print();
                        break;
                    case "mImport":
                        ExportImage();
                        break;
                    case "mView":
                        //frmSvgView fView = new frmSvgView();
                        //fView.Open(tlVectorControl1.SVGDocument.SvgdataUid);
                        //fView.Show();

                        break;

                    //case "mIncreaseView":
                    //    tlVectorControl1.Operation = ToolOperation.IncreaseView;
                    //    break;
                    case "mRzb":
                        frmRatio fRat = new frmRatio();
                        string viewRat = tlVectorControl1.SVGDocument.getRZBRatio();
                        if (viewRat != "") {
                            fRat.InitData(viewRat);
                        }
                        if (fRat.ShowDialog() == DialogResult.OK) {
                            viewRat = fRat.ViewScale;
                            tlVectorControl1.SVGDocument.setRZBRatio(viewRat);
                        }
                        break;

                    case "mAbout":

                        frmAbout frma = new frmAbout();
                        frma.ShowDialog();
                        break;

                    case "ButtonItem10":

                        break;
                    case "Dlqibutt":
                        break;
                    //MessageBox.Show("请选中母线点,然后点击右键输入断路器属性" "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //duluqiflag=true;
                    //基础操作
                    case "mFreeTransform":
                        tlVectorControl1.Operation = ToolOperation.FreeTransform;

                        break;
                    case "mCJ":
                        tlVectorControl1.Operation = ToolOperation.PolyLine;
                        csOperation = CustomOperation.OP_MeasureDistance;
                        break;
                    //case "ButtonItem2":
                    //    break;
                    #endregion
                    #region 无功优化参数维护
                    case "VoltLimit":
                        break;
                    case "GeneratorLimit":
                        break;
                    case "TransformLimit":
                        break;
                    case "SVC":
                        break;
                    #endregion
                    #region 基础图元
                    case "mLayer":
                        tlVectorControl1.LayerManager();
                        break;
                    case "mDecreaseView":
                        tlVectorControl1.Operation = ToolOperation.DecreaseView;

                        break;
                    case "mIncreaseView":

                        tlVectorControl1.Operation = ToolOperation.IncreaseView;
                        break;
                    case "mRoam":
                        tlVectorControl1.Operation = ToolOperation.Roam;

                        break;
                    case "mSelect":
                        tlVectorControl1.Operation = ToolOperation.Select;
                        break;
                    case "mSel":

                        tlVectorControl1.Operation = ToolOperation.FreeTransform;
                        break;
                    //case "mFreeTransform":
                    //    tlVectorControl1.Operation = ToolOperation.FreeTransform;

                    //    break;
                    case "mFreeLines"://锁套
                        tlVectorControl1.Operation = ToolOperation.FreeLines;

                        break;
                    case "mFreePath":
                        tlVectorControl1.Operation = ToolOperation.FreePath;

                        break;
                    case "mShapeTransform":
                        tlVectorControl1.Operation = ToolOperation.ShapeTransform;

                        break;
                    case "mAngleRectangle":
                        tlVectorControl1.Operation = ToolOperation.AngleRectangle;

                        break;
                    case "mEllipse":
                        tlVectorControl1.Operation = ToolOperation.Ellipse;

                        break;
                    case "mLine":
                        tlVectorControl1.Operation = ToolOperation.ConnectLine_Polyline;

                        break;
                    case "butRef":
                        Ref();
                        break;
                    case "mPolyline":
                        tlVectorControl1.Operation = ToolOperation.PolyLine;

                        break;
                    case "mConnectLine":
                        tlVectorControl1.Operation = ToolOperation.ConnectLine;
                        break;

                    case "mPolygon":
                        tlVectorControl1.Operation = ToolOperation.Polygon;

                        break;
                    case "mImage":
                        tlVectorControl1.Operation = ToolOperation.Image;
                        break;
                    case "mText":
                        tlVectorControl1.Operation = ToolOperation.Text;
                        break;
                    case "mBezier":
                        tlVectorControl1.Operation = ToolOperation.Bezier;

                        break;
                    case "ButtonItem2":

                        break;
                    case "ButtonItem8":

                        break;
                    case "mCheck":
                        break;
                    case "DFSResult":
                        frmSetPower frmSPR = new frmSetPower();
                        frmSPR.ProjectID = this.tlVectorControl1.SVGDocument.SvgdataUid;
                        if (frmSPR.ShowDialog() == DialogResult.OK) {
                            ElectricLoadCal elcDFS = new ElectricLoadCal();
                            //string strCon1 = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "'";
                            //string strCon2 = null;
                            //string strCon = null;
                            //strCon2 = " AND Type = '05'";
                            //strCon = strCon1 + strCon2;
                            //IList listXL = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                            //strCon2 = " AND Type = '01'";
                            //strCon = strCon1 + strCon2;
                            //IList listMX = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                            IList branchList = new List<PSPDEV>();
                            IList busList = new List<PSPDEV>();
                            //foreach (PSPDEV dev in listXL)
                            //{
                            //    if (dev.Number>=14)
                            //    {
                            //        branchList.Add(dev);
                            //    }
                            //}
                            //foreach (PSPDEV dev in listMX)
                            //{
                            //    if (dev.Number<=3)
                            //    {
                            //        busList.Add(dev);
                            //    }
                            //}
                            busList = frmSPR.ListPower;
                            branchList = frmSPR.ListBranch;
                            if (busList != null) {
                                elcDFS.DFSER(branchList, busList, tlVectorControl1.SVGDocument.SvgdataUid, 100, 1);
                            }
                        }
                        break;
                    case "DFS":
                        frmSetPower frmSP = new frmSetPower();
                        frmSP.ProjectID = this.tlVectorControl1.SVGDocument.SvgdataUid;
                        if (frmSP.ShowDialog() == DialogResult.OK) {
                            ElectricLoadCal elcDFS = new ElectricLoadCal();
                            //string strCon1 = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "'";
                            //string strCon2 = null;
                            //string strCon = null;
                            //strCon2 = " AND Type = '05'";
                            //strCon = strCon1 + strCon2;
                            //IList listXL = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                            //strCon2 = " AND Type = '01'";
                            //strCon = strCon1 + strCon2;
                            //IList listMX = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                            IList branchList = new List<PSPDEV>();
                            IList busList = new List<PSPDEV>();
                            //foreach (PSPDEV dev in listXL)
                            //{
                            //    if (dev.Number>=14)
                            //    {
                            //        branchList.Add(dev);
                            //    }
                            //}
                            //foreach (PSPDEV dev in listMX)
                            //{
                            //    if (dev.Number<=3)
                            //    {
                            //        busList.Add(dev);
                            //    }
                            //}
                            busList = frmSP.ListPower;
                            branchList = frmSP.ListBranch;
                            if (busList != null) {
                                elcDFS.DFS(branchList, busList, tlVectorControl1.SVGDocument.SvgdataUid, 100);
                                ShowResult(0);
                            }
                        }

                        break;
                    case "niula":
                        frnReport wFrom = new frnReport();
                        wFrom.Owner = this;
                        wFrom.Show();
                        wFrom.Text = this.Text + "—牛拉法潮流计算";
                        wFrom.ShowText += "正在收集信息\t" + System.DateTime.Now.ToString();
                        ElectricLoadCal elc = new ElectricLoadCal();
                        elc.LFC(tlVectorControl1.SVGDocument.SvgdataUid, 1, 100, wFrom);
                        ShowResult(0, wFrom);
                        break;
                    case "pq":
                        frnReport wFromPQ = new frnReport();
                        wFromPQ.Owner = this;
                        wFromPQ.Show();
                        wFromPQ.Text = this.Text + "—PQ分解法潮流计算";
                        wFromPQ.ShowText += "正在收集信息\t" + System.DateTime.Now.ToString();
                        ElectricLoadCal elcPQ = new ElectricLoadCal();
                        elcPQ.LFC(tlVectorControl1.SVGDocument.SvgdataUid, 2, 100, wFromPQ);
                        ShowResult(1, wFromPQ);
                        break;

                    case "GaussSeidel":
                        frnReport wFromGS = new frnReport();
                        wFromGS.Owner = this;
                        wFromGS.Show();
                        wFromGS.Text = this.Text + "—高斯赛德尔迭代法潮流计算";
                        wFromGS.ShowText += "正在收集信息\t" + System.DateTime.Now.ToString();
                        ElectricLoadCal elcGS = new ElectricLoadCal();
                        elcGS.LFC(tlVectorControl1.SVGDocument.SvgdataUid, 3, 100, wFromGS);
                        ShowResult(2, wFromGS);
                        break;
                    case "N_RZYz":
                        frnReport wFromZYZ = new frnReport();
                        wFromZYZ.Owner = this;
                        wFromZYZ.Show();
                        wFromZYZ.Text = this.Text + "—最有乘子法潮流计算";
                        wFromZYZ.ShowText += "正在收集信息\t" + System.DateTime.Now.ToString();
                        ElectricLoadCal elcN_RZYz = new ElectricLoadCal();
                        elcN_RZYz.LFC(tlVectorControl1.SVGDocument.SvgdataUid, 4, 100, wFromZYZ);
                        ShowResult(3, wFromZYZ);
                        break;
                    case "niulaNfh":
                        elc = new ElectricLoadCal();
                        elc.LFCS(tlVectorControl1.SVGDocument.SvgdataUid, 4, 100);
                        ShowResult(3);
                        break;
                    case "WebRela":                        //进行网络N-1检验

                        ElectricRelcheck elcRela = new ElectricRelcheck();
                        elcRela.WebCalAndPrint(tlVectorControl1.SVGDocument.SvgdataUid, this.ProjectUID, 100);
                        break;
                    case "TransRela":                       //进行变压器N-1检验

                        break;
                    case "Shortibut":

                        break;
                    case "dd":
                        //SubPrint = true;
                        tlVectorControl1.Operation = ToolOperation.InterEnclosurePrint;
                        break;

                    case "NiulaResult":
                        ElectricLoadCal elcResult = new ElectricLoadCal();
                        elcResult.LFCER(tlVectorControl1.SVGDocument.SvgdataUid, 1, 100);
                        break;
                    case "PQResult":
                        ElectricLoadCal elcPQResult = new ElectricLoadCal();
                        elcPQResult.LFCER(tlVectorControl1.SVGDocument.SvgdataUid, 2, 100);
                        break;
                    case "GaussSeidelResult":
                        ElectricLoadCal elcGSResult = new ElectricLoadCal();
                        elcGSResult.LFCER(tlVectorControl1.SVGDocument.SvgdataUid, 3, 100);
                        break;
                    case "N_RZYzResult":
                        ElectricLoadCal elcNZResult = new ElectricLoadCal();
                        elcNZResult.LFCER(tlVectorControl1.SVGDocument.SvgdataUid, 4, 100);
                        break;
                    case "NLnFHresult":
                        elc = new ElectricLoadCal();
                        elc.LFCERS(tlVectorControl1.SVGDocument.SvgdataUid, 4, 100);
                        break;
                    case "VoltEvaluation":
                        ElectricLoadCal elcVE = new ElectricLoadCal();
                        elcVE.VE(tlVectorControl1.SVGDocument.SvgdataUid, 100);
                        break;
                    case "PowerLossCal":
                        ElectricLoadCal elcPLResult = new ElectricLoadCal();
                        elcPLResult.PLE(tlVectorControl1.SVGDocument.SvgdataUid, 2, 100);
                        ShowPowerLoss();
                        break;
                    case "PowerLoss":
                        ElectricLoadCal elcPLE = new ElectricLoadCal();
                        elcPLE.PLE(tlVectorControl1.SVGDocument.SvgdataUid, 2, 100);
                        break;
                    case "ZLPResult1":

                        break;

                    case "mDLR":

                        break;
                    case "clearResult":
                        try {
                            XmlNodeList list = tlVectorControl1.SVGDocument.SelectNodes("svg/*[@flag='" + "1" + "']");

                            foreach (XmlNode node in list) {
                                SvgElement element = node as SvgElement;

                                tlVectorControl1.SVGDocument.CurrentElement = element;
                                tlVectorControl1.Delete();

                            }
                        } catch (System.Exception ex) {

                        }
                        break;
                    case "mEnclosure":
                        tlVectorControl1.Operation = ToolOperation.Enclosure;

                        break;

                    case "mGroup":
                        tlVectorControl1.Group();
                        break;
                    case "mUnGroup":
                        tlVectorControl1.UnGroup();
                        break;
                    case "mlinelx":
                        tlVectorControl1.Operation = ToolOperation.ConnectLine_Line;
                        break;
                    case "mzxlx":
                        tlVectorControl1.Operation = ToolOperation.ConnectLine_Rightangle;
                        break;
                    case "mqxlx":
                        tlVectorControl1.Operation = ToolOperation.ConnectLine_Spline;
                        break;
                    case "mqzlx":
                        tlVectorControl1.Operation = ToolOperation.ConnectLine_Polyline;
                        break;
                    case "mCJ1":
                        tlVectorControl1.Operation = ToolOperation.PolyLine;
                        csOperation = CustomOperation.OP_MeasureDistance;
                        break;
                    case "powerFactor":

                        break;
                    #endregion

                    #region 视图
                    case "mOption":
                        tlVectorControl1.SetOption();
                        break;
                    case "mAirscape":
                        frmAirscape fAir = new frmAirscape();
                        fAir.InitData(tlVectorControl1);
                        fAir.Owner = this;
                        fAir.ShowInTaskbar = false;
                        fAir.Top = Screen.PrimaryScreen.WorkingArea.Height - 250;
                        fAir.Left = Screen.PrimaryScreen.WorkingArea.Width - 300;
                        fAir.Show();
                        break;
                    case "btTL":
                        frmGlebeTypeList fgle = new frmGlebeTypeList();
                        fgle.Show();
                        break;
                    #endregion

                    #region 布局,对齐,顺序
                    case "mRotate":
                        if (btItem.Tag is ButtonItem) {
                            btItem = btItem.Tag as ButtonItem;
                            tlVectorControl1.FlipX();

                        } else {
                            tlVectorControl1.FlipX();
                        }
                        break;
                    case "mToH":

                        tlVectorControl1.FlipX();
                        //this.rotateButton.Tag = btItem;
                        //this.rotateButton.ImageIndex = btItem.ImageIndex;
                        break;
                    case "mToV":
                        tlVectorControl1.FlipY();
                        //this.rotateButton.Tag = btItem;
                        //this.rotateButton.ImageIndex = btItem.ImageIndex;
                        break;
                    case "mToLeft":
                        tlVectorControl1.RotateSelection(-90f);
                        ////this.rotateButton.Tag = btItem;
                        ////this.rotateButton.ImageIndex = btItem.ImageIndex;
                        break;
                    case "mToRight":
                        tlVectorControl1.RotateSelection(90f);
                        //this.rotateButton.Tag = btItem;
                        //this.rotateButton.ImageIndex = btItem.ImageIndex;
                        break;
                    case "mAlign":
                        if (btItem.Tag is ButtonItem) {
                            btItem = btItem.Tag as ButtonItem;
                            tlVectorControl1.Align(AlignType.Left);

                        } else {
                            tlVectorControl1.Align(AlignType.Left);

                        }
                        tlVectorControl1.Refresh();
                        break;
                    case "mAlignLeft":
                        tlVectorControl1.Align(AlignType.Left);
                        this.alignButton.ImageIndex = btItem.ImageIndex;
                        this.alignButton.Tag = btItem;
                        tlVectorControl1.Refresh();
                        break;
                    case "mAlignRight":
                        tlVectorControl1.Align(AlignType.Right);
                        this.alignButton.ImageIndex = btItem.ImageIndex;
                        this.alignButton.Tag = btItem;
                        tlVectorControl1.Refresh();
                        break;
                    case "mAlignTop":
                        tlVectorControl1.Align(AlignType.Top);
                        this.alignButton.ImageIndex = btItem.ImageIndex;
                        this.alignButton.Tag = btItem;
                        tlVectorControl1.Refresh();
                        break;
                    case "mAlignBottom":
                        tlVectorControl1.Align(AlignType.Bottom);
                        this.alignButton.ImageIndex = btItem.ImageIndex;
                        this.alignButton.Tag = btItem;
                        tlVectorControl1.Refresh();
                        break;
                    case "mAlignHorizontalCenter":
                        tlVectorControl1.Align(AlignType.HorizontalCenter);
                        this.alignButton.ImageIndex = btItem.ImageIndex;
                        this.alignButton.Tag = btItem;
                        tlVectorControl1.Refresh();
                        break;
                    case "mAlignVerticalCenter":
                        tlVectorControl1.Align(AlignType.VerticalCenter);
                        this.alignButton.ImageIndex = btItem.ImageIndex;
                        this.alignButton.Tag = btItem;
                        tlVectorControl1.Refresh();
                        break;
                    case "mOrder":
                        if (btItem.Tag is ButtonItem) {
                            btItem = btItem.Tag as ButtonItem;
                            tlVectorControl1.ChangeLevel(LevelType.Top);

                        } else {
                            tlVectorControl1.ChangeLevel(LevelType.Top);
                        }

                        break;
                    case "mGoTop":
                        tlVectorControl1.ChangeLevel(LevelType.Top);
                        this.orderButton.Tag = btItem;
                        this.orderButton.ImageIndex = btItem.ImageIndex;
                        break;
                    case "mGoUp":
                        tlVectorControl1.ChangeLevel(LevelType.Up);
                        this.orderButton.Tag = btItem;
                        this.orderButton.ImageIndex = btItem.ImageIndex;
                        break;
                    case "mGoDown":
                        tlVectorControl1.ChangeLevel(LevelType.Down);
                        this.orderButton.Tag = btItem;
                        this.orderButton.ImageIndex = btItem.ImageIndex;
                        break;
                    case "mGoBottom":
                        tlVectorControl1.ChangeLevel(LevelType.Bottom);
                        this.orderButton.Tag = btItem;
                        this.orderButton.ImageIndex = btItem.ImageIndex;
                        break;
                    #endregion
                    #region 图元操作
                    case "mCopy":
                        tlVectorControl1.Copy();
                        break;
                    case "mCut":
                        tlVectorControl1.Cut();
                        break;
                    case "mPaste":
                        tlVectorControl1.Paste();
                        break;
                    case "mDelete":
                        if (tlVectorControl1.SVGDocument.CurrentElement is SVG) {
                        } else {
                            if (MessageBox.Show("确定要删除么?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) {
                                SvgElementCollection collection = tlVectorControl1.SVGDocument.SelectCollection;
                                foreach (XmlElement element in collection) {
                                    if (element is Text) {
                                        PSP_ElcDevice elcDEV = new PSP_ElcDevice();
                                        elcDEV.ProjectSUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        elcDEV.DeviceSUID = element.GetAttribute("Deviceid");
                                        Services.BaseService.Delete<PSP_ElcDevice>(elcDEV);
                                    }
                                }
                                tlVectorControl1.Delete();
                            }

                        }
                        break;
                    case "mUodo":
                        tlVectorControl1.Undo();
                        break;
                    case "mRedo":
                        tlVectorControl1.Redo();
                        break;
                    #endregion
                    #region 业务操作

                    case "mXLine":
                        tlVectorControl1.Operation = ToolOperation.Select;
                        tlVectorControl1.Operation = ToolOperation.XPolyLine;
                        break;
                    case "mYLine":
                        tlVectorControl1.Operation = ToolOperation.Select;
                        tlVectorControl1.Operation = ToolOperation.YPolyLine;
                        break;

                    case "mSaveGroup":
                        if (tlVectorControl1.SVGDocument.SelectCollection.Count > 1) {
                            string content = "<svg>";
                            SvgElementCollection col = tlVectorControl1.SVGDocument.SelectCollection;
                            for (int i = 0; i < col.Count; i++) {
                                SvgElement _e = (SvgElement)col[i];
                                if (_e.ID != "svg") {
                                    content = content + _e.OuterXml;
                                }
                            }
                            RectangleF rect = tlVectorControl1.DrawArea.viewer.SelectedViewRectangle;

                            content = content + "</svg>";
                            frmSaveGroup fm = new frmSaveGroup();
                            fm.rect = rect;
                            fm.Content = content;
                            fm.ShowDialog();
                        } else {
                            MessageBox.Show("请至少选择2个图元。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        break;

                    case "mInsert":
                        frmUseGroup fg = new frmUseGroup();
                        if (fg.ShowDialog() == DialogResult.OK) {
                            UseGroup u = fg.SelectedUseGroup;
                            if (u != null) {
                                frmXY xy = new frmXY();
                                if (xy.ShowDialog() == DialogResult.OK) {
                                    decimal x = xy.GetX();
                                    decimal y = xy.GetY();
                                    string content = u.Content;
                                    XmlDocument doc = new XmlDocument();
                                    doc.LoadXml(u.Content);
                                    XmlNodeList list = doc.ChildNodes;
                                    XmlNode _node = list[0];
                                    XmlNodeList sonlist = _node.ChildNodes;
                                    XmlElement ele = tlVectorControl1.SVGDocument.CreateElement("g");
                                    ele.SetAttribute("layer", SvgDocument.currentLayer);
                                    for (int i = 0; i < sonlist.Count; i++) {
                                        XmlNode _sonnode = sonlist[i];
                                        //string str = _sonnode.OuterXml;
                                        if (_sonnode.Name == "use") {
                                            string sid = ((XmlElement)_sonnode).GetAttribute("xlink:href");
                                            XmlNode _snode = symbolSelector.SymbolDoc.SelectSingleNode("//*[@id='" + sid.Substring(1) + "']");
                                            tlVectorControl1.SVGDocument.AddDefsElement((SvgElement)_snode);
                                        }
                                        ele.AppendChild(_sonnode);
                                        string ss = ele.OuterXml;
                                    }
                                    //RectangleF r=((Group)ele).GetBounds();
                                    string tr = "matrix(1,0,0,1,";

                                    tr = tr + Convert.ToString(x - Convert.ToDecimal(u.X)) + ",";
                                    tr = tr + Convert.ToString(y - Convert.ToDecimal(u.Y)) + ")";

                                    ele.SetAttribute("transform", tr);
                                    // transform="matrix(1,0,0,1,2558.82,-352.94)"
                                    tlVectorControl1.SVGDocument.RootElement.AppendChild(ele);
                                    tlVectorControl1.SVGDocument.SelectCollection.Clear();
                                    tlVectorControl1.SVGDocument.SelectCollection.Add((SvgElement)ele);
                                    tlVectorControl1.UnGroup();
                                    // tlVectorControl1.Refresh();
                                }
                            }
                        }
                        break;
                    case "PSPIdleOptimize":
                        ElectricLoadCal elcORP = new ElectricLoadCal();
                        elcORP.ORP(tlVectorControl1.SVGDocument.SvgdataUid, 100);
                        break;
                    #endregion
                    #region 参数维护
                    case "mNodeParam":

                        break;
                    case "mLineParam":

                        break;
                    case "mWire":

                        break;
                    case "nTransformLineParam":

                        break;
                    case "nGNDLineParam":

                        break;
                    case "mLineDL":

                        break;
                    case "mFadianDL":

                        break;
                    case "mConvert":

                        break;

                    #endregion
                }
            }
        }
Пример #16
0
        public void VE(string projectSUID, float ratedCapacity)
        {
            int type = 2;
            frnReport wFrom = new frnReport();
            wFrom.Text = "电压质量评估";
            wFrom.Show();
            wFrom.ShowText += "正在收集信息\t" + System.DateTime.Now.ToString();
            try
            {
                LFC(projectSUID, type, ratedCapacity,wFrom);

                if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\" + projectSUID + "电压质量评估.xls"))
                {
                    //System.Diagnostics.Process.Start(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "线损计算结果.xls");
                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\" + projectSUID + "电压质量评估.xls");
                    //OpenRead(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + ".xls");
                }

                wFrom.ShowText += "\r\n正在生成报表\t" + System.DateTime.Now.ToString();

                string output = null;
                output += ("全网母线(发电、负荷)电压质量评估 " + "\r\n" + "\r\n");
                output += ("单位:kA\\kV\\MW\\Mvar" + "\r\n" + "\r\n");
                output += ("计算日期:" + System.DateTime.Now.ToString() + "\r\n" + "\r\n");
                output += ("母线名" + "," + "电压偏移" + "," + "是否合格" + "\r\n");
                string strCon = ",PSPDEV WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'" + " AND PSPDEV.Type = '01'  order by PSPDEV.RateVolt,PSPDEV.Name";
                IList list = Services.BaseService.GetList("SelectPSP_ElcDeviceByCondition", strCon);
                double numFlag = 0, num = 0; ;
                foreach (PSP_ElcDevice elcDEV in list)
                {
                    PSPDEV dev = new PSPDEV();
                    dev.SUID = elcDEV.DeviceSUID;
                    dev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", dev);
                    //double vTemp = Convert.ToDouble(GetColValue(elcDEV,type-1));
                    //double vTemp1 =  TLPSPVmin * dev.RateVolt;
                    //double vTemp2 =  TLPSPVmax * dev.RateVolt;
                    if (dev == null)
                    {
                        continue;
                    }
                    double voltExcursion = 0.0;
                    string flag = "";
                    voltExcursion = (Convert.ToDouble(GetColValue(elcDEV, type - 1).COL2) - dev.RateVolt) / dev.RateVolt;
                    flag = voltFlag(voltExcursion, dev.RateVolt);
                    if (flag == "合格")
                    {
                        numFlag++;
                    }
                    num++;
                    output += dev.Name + "," + voltExcursion.ToString() + "," + flag + "\r\n";
                }
                if (num == 0)
                {
                    num = 1;
                }
                output += "电压合格率" + "," + (double)(numFlag / num) + "\r\n";
                try
                {
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result.csv"))
                    {
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\result.csv");
                    }
                }
                catch (System.Exception ex2)
                {
                    MessageBox.Show("请关闭相关Excel后再查看结果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                FileStream op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result.csv"), FileMode.OpenOrCreate);
                StreamWriter str1 = new StreamWriter(op, Encoding.Default);
                str1.Write(output);
                str1.Close();

                output = null;

                output += ("全网交流线电压质量评估" + "\r\n" + "\r\n");
                output += ("单位:kA\\kV\\MW\\Mvar" + "\r\n" + "\r\n");
                output += ("计算日期:" + System.DateTime.Now.ToString() + "\r\n" + "\r\n");
                output += ("支路名称" + "," + "电压损失" + "," + "是否合格" + "\r\n");

                string strCon1 = ",PSPDEV WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'" + " AND PSPDEV.Type = '05'  order by PSPDEV.RateVolt,PSPDEV.Name";
                IList list1 = Services.BaseService.GetList("SelectPSP_ElcDeviceByCondition", strCon1);

                foreach (PSP_ElcDevice elcDEV in list1)
                {
                    PSPDEV dev = new PSPDEV();
                    dev.SUID = elcDEV.DeviceSUID;
                    dev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", dev);
                    //double vTemp = Convert.ToDouble(GetColValue(elcDEV,type-1));
                    //double vTemp1 =  TLPSPVmin * dev.RateVolt;
                    //double vTemp2 =  TLPSPVmax * dev.RateVolt;
                    double voltLoss = 0.0;
                    string lineFlag = "";
                    voltLoss = (Convert.ToDouble(GetColValue(elcDEV, type - 1).COL12) - Convert.ToDouble(GetColValue(elcDEV, type - 1).COL13)) / dev.RateVolt;
                    lineFlag = voltLineLoss(voltLoss, dev.RateVolt, dev.Type);
                    output += dev.Name + "," + voltLoss.ToString() + "," + lineFlag + "\r\n";
                }
                try
                {
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result1.csv"))
                    {
                        File.Delete(System.Windows.Forms.Application.StartupPath + "\\result1.csv");
                    }
                }
                catch (System.Exception ex3)
                {
                    MessageBox.Show("请关闭相关Excel后再查看结果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result1.csv"), FileMode.OpenOrCreate);
                str1 = new StreamWriter(op, Encoding.Default);
                str1.Write(output);
                str1.Close();
                Excel.Application ex;
                Excel.Worksheet xSheet;
                Excel.Application result1;
                Excel.Worksheet tempSheet;
                Excel.Worksheet newWorksheet;
                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);

                result1 = new Excel.Application();
                result1.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result1.csv");
                tempSheet = (Excel.Worksheet)result1.Worksheets.get_Item(1);
                newWorksheet = (Excel.Worksheet)ex.Worksheets.get_Item(2);
                newWorksheet.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);

                xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 3]).MergeCells = true;
                xSheet.get_Range(xSheet.Cells[3, 1], xSheet.Cells[3, 2]).MergeCells = true;
                xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Size = 16;
                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[7, 1], xSheet.Cells[7, 3]).Interior.ColorIndex = 45;
                xSheet.get_Range(xSheet.Cells[8, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6;

                xSheet.get_Range(xSheet.Cells[6, 2], xSheet.Cells[xSheet.UsedRange.Rows.Count, 3]).NumberFormat = "0.0000_ ";
                xSheet.get_Range(xSheet.Cells[3, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 3]).Font.Name = "楷体_GB2312";
                xSheet.get_Range(xSheet.Cells[6, 2], xSheet.Cells[xSheet.UsedRange.Rows.Count, 2]).NumberFormatLocal = "0.0000%";

                newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 3]).MergeCells = true;
                newWorksheet.get_Range(newWorksheet.Cells[3, 1], newWorksheet.Cells[3, 2]).MergeCells = true;
                newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).Font.Size = 16;
                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;
                newWorksheet.get_Range(newWorksheet.Cells[7, 1], newWorksheet.Cells[7, 3]).Interior.ColorIndex = 45;
                newWorksheet.get_Range(newWorksheet.Cells[8, 1], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6;

                newWorksheet.get_Range(newWorksheet.Cells[6, 2], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 3]).NumberFormat = "0.0000_ ";
                newWorksheet.get_Range(newWorksheet.Cells[3, 1], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 3]).Font.Name = "楷体_GB2312";
                newWorksheet.get_Range(newWorksheet.Cells[6, 2], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 2]).NumberFormatLocal = "0.0000%";
                //op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fck.excel"), FileMode.OpenOrCreate);
                //str1 = new StreamWriter(op, Encoding.Default);
                newWorksheet.Columns.AutoFit();
                newWorksheet.Rows.AutoFit();
                xSheet.Rows.AutoFit();
                xSheet.Columns.AutoFit();

                newWorksheet.SaveAs(System.Windows.Forms.Application.StartupPath + "\\" + projectSUID + "电压质量评估.xls", Excel.XlFileFormat.xlXMLSpreadsheet, null, null, false, false, false, null, null, null);

                ex.DisplayAlerts = false;
                System.Windows.Forms.Clipboard.Clear();
                result1.Workbooks.Close();
                result1.Quit();
            }
            catch (System.Exception ex)
            {
                wFrom.ShowText += "\r\n报表生成失败\t" + System.DateTime.Now.ToString();
            }
            wFrom.ShowText += "\r\n电压质量评估结束\t" + System.DateTime.Now.ToString();
        }
Пример #17
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("��·���ݴ������⣬�迹���󲻴��ڻ��ߴ��ڹ����ڵ㣬���֤���ٽ��У�");
            }
        }