private bool Validation() { if (string.IsNullOrEmpty(txtName.Text)) { MessageBox.Show("لطفاً نام تيپ را مشخص نمایید", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading); txtName.Focus(); return(false); } if (Atend.Base.Equipment.EGroundCabelTip.SearchByName(txtName.Text) == true && SelectGroundCabelTipXCode == Guid.Empty) { MessageBox.Show("نام قبلا استفاده شده است", "خطا"); txtName.Focus(); return(false); } Atend.Base.Equipment.EGroundCabelTip groundtip = Atend.Base.Equipment.EGroundCabelTip.CheckForExist(Convert.ToInt32(cboPhaseCount.SelectedItem.ToString()), new Guid(cboPhaseProductCode.SelectedValue.ToString()), Convert.ToInt32(cboNeutralCount.SelectedItem.ToString()), new Guid(cboNeutralProductCode.SelectedValue.ToString())); if (groundtip.Code != -1 && SelectGroundCabelTipXCode == Guid.Empty) { if (MessageBox.Show("تیپ بندی با مشخصات داده شده موجود میباشد\n\n تیپ بندی با مشخصات فوق : " + groundtip.Name + "\n\n" + "آیا مایل به ادامه ثبت می باشید؟", "خطا", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { cboPhaseProductCode.Focus(); return(false); } } return(CheckStatuseOfAccessChangeDefault()); // return true; }
private void tsbShare_Click(object sender, EventArgs e) { if (SelectGroundCabelTipXCode != Guid.Empty) { if (Atend.Base.Equipment.EContainerPackage.ShareOnServer(Convert.ToInt32(Atend.Control.Enum.ProductType.GroundCabelTip), SelectGroundCabelTipXCode)) { Atend.Base.Equipment.EGroundCabelTip CabelTip = Atend.Base.Equipment.EGroundCabelTip.SelectByXCode(SelectGroundCabelTipXCode); Code = CabelTip.Code; MessageBox.Show("به اشتراک گذاری با موفقیت انجام شد"); } else { MessageBox.Show("خطا در به اشتراک گذاری ."); } } else { MessageBox.Show("لطفا تجهیز مورد نظر را انتخاب کنید"); } //if (SelectGroundCabelTipXCode != Guid.Empty) //{ // if (Atend.Base.Equipment.EGroundCabelTip.ShareOnServer(SelectGroundCabelTipXCode)) // MessageBox.Show("به اشتراک گذاری با موفقیت انجام شد"); // else // MessageBox.Show("خطا در به اشتراک گذاری . لطفاً دوباره سعی کنید"); //} //else // MessageBox.Show("لطفا تجهیز مورد نظر را انتخاب کنید"); }
private void Delete() { string name = string.Empty; if (!Atend.Global.Utility.UBinding.ExistInSubEquip(SelectedCabelCode, out name)) { MessageBox.Show(string.Format("حذف بدلیل وجود در تجهیزات جانبی امکانپذیر نمی باشد\n تجهیز موردنظر زیر تجهیز '{0}' میباشد ", name), "خطا"); return; } //Atend.Base.Equipment.EProductPackage _ProductPackage = Atend.Base.Equipment.EProductPackage.SelectByXCode(SelectedCabelCode); //if (_ProductPackage.Code != -1) //{ // MessageBox.Show("حذف بدلیل وجود در تجهیزات جانبی امکانپذیر نمی باشد ", "خطا"); // return; //} Atend.Base.Equipment.EGroundCabelTip NeutralProduct = Atend.Base.Equipment.EGroundCabelTip.SelectByNeutralProductXCode(SelectedCabelCode); if (NeutralProduct.Code != -1) { MessageBox.Show("حذف کابل زمینی بدلیل وجود در تیپ بندی امکانپذیر نمی باشد ", "خطا"); return; } Atend.Base.Equipment.EGroundCabelTip PhaseProduct = Atend.Base.Equipment.EGroundCabelTip.SelectByPhaseProductXCode(SelectedCabelCode); if (PhaseProduct.Code != -1) { MessageBox.Show("حذف کابل زمینی بدلیل وجود در تیپ بندی امکانپذیر نمی باشد ", "خطا"); return; } if (MessageBox.Show("آیا از حذف کردن اطلاعات اطمینان دارید؟", "حذف", MessageBoxButtons.YesNo) == DialogResult.Yes) { if (SelectedCabelCode != Guid.Empty) { if (Atend.Base.Equipment.EGroundCabel.DeleteX(SelectedCabelCode)) { Reset(); } else { MessageBox.Show("امکان حذف کردن اطلاعات نمی باشد", "خطا"); } } else { MessageBox.Show("لطفاً گزینه مورد نظر را انتخاب نمایید", "خطا"); } } }
public void BindDataToOwnControl(Guid XCode) { SelectGroundCabelTipXCode = XCode; Atend.Base.Equipment.EGroundCabelTip GroundCabeltip = Atend.Base.Equipment.EGroundCabelTip.SelectByXCode(XCode); txtName.Text = Convert.ToString(GroundCabeltip.Name.ToString()); cboPhaseCount.SelectedIndex = Convert.ToInt32(GroundCabeltip.PhaseCount.ToString()); cboNeutralCount.SelectedIndex = Convert.ToInt32(GroundCabeltip.NeutralCount.ToString()); //cboNightCount.SelectedIndex = Convert.ToInt32(GroundCabeltip.NightCount.ToString()); cboPhaseProductCode.SelectedValue = new Guid(GroundCabeltip.PhaseProductXCode.ToString()); cboNeutralProductCode.SelectedValue = new Guid(GroundCabeltip.NeutralProductXCode.ToString()); //cboNightProductCode.SelectedValue = new Guid(GroundCabeltip.NightProductXCode.ToString()); tsbIsDefault.Checked = GroundCabeltip.IsDefault; Code = GroundCabeltip.Code; }
private void btnOk_Click(object sender, EventArgs e) { Atend.Global.Acad.DrawEquips.AcDrawGroundCabel DrawGroundCabel = new Atend.Global.Acad.DrawEquips.AcDrawGroundCabel(); if (Validation()) { if (Convert.ToBoolean(gvConductor.Rows[gvConductor.CurrentRow.Index].Cells[4].Value) == false) { DrawGroundCabel.UseAccess = true; DrawGroundCabel.eGroundCabelTip = Atend.Base.Equipment.EGroundCabelTip.AccessSelectByCode(Convert.ToInt32(gvConductor.Rows[gvConductor.CurrentRow.Index].Cells[1].Value.ToString())); } else if (Convert.ToBoolean(gvConductor.Rows[gvConductor.CurrentRow.Index].Cells[4].Value)) { DrawGroundCabel.UseAccess = false; Atend.Base.Equipment.EGroundCabelTip GroundCabeltip = new Atend.Base.Equipment.EGroundCabelTip(); ed.WriteMessage("SelectByXCode={0}\n", gvConductor.Rows[gvConductor.CurrentRow.Index].Cells[0].Value.ToString()); GroundCabeltip = Atend.Base.Equipment.EGroundCabelTip.SelectByXCode(new Guid(gvConductor.Rows[gvConductor.CurrentRow.Index].Cells[0].Value.ToString())); DrawGroundCabel.eGroundCabelTip = GroundCabeltip; ed.WriteMessage("GroundCabelTip.XCOde={0}\n", GroundCabeltip.XCode); List <Atend.Base.Equipment.EGroundCabel> list = new List <Atend.Base.Equipment.EGroundCabel>(); list.Add(Atend.Base.Equipment.EGroundCabel.SelectByXCode(GroundCabeltip.PhaseProductXCode)); list.Add(Atend.Base.Equipment.EGroundCabel.SelectByXCode(GroundCabeltip.NeutralProductXCode)); DrawGroundCabel.eGroundCabels = list; } Atend.Base.Base.BEquipStatus status = Atend.Base.Base.BEquipStatus.SelectByCode(Convert.ToInt32(cboIsExist.SelectedValue)); DrawGroundCabel.Existance = status.ACode; if (cboProjCode.Items.Count == 0) { DrawGroundCabel.ProjectCode = 0; } else { DrawGroundCabel.ProjectCode = Convert.ToInt32(cboProjCode.SelectedValue); } DrawGroundCabel.SelectedObjID = BranchObj; DrawGroundCabel.UpdateGroundCabelData(Convert.ToDouble(txtLenght.Text), BranchCode); //if (DrawSelfKeeper.UpdateSelfKeeperData()) // ed.WriteMessage("Update SelfKeeper Success \n"); } }
private bool CheckStatuseOfAccessChangeDefault() { Autodesk.AutoCAD.EditorInput.Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; //ed.WriteMessage("AccessChangeDefault={0}\n", Atend.Control.Common.AccessChangeDefault); if (!Atend.Control.Common.AccessChangeDefault) { if (SelectGroundCabelTipXCode == Guid.Empty && IsDefault) { MessageBox.Show("کاربر گرامی شما اجازه ثبت تجهیز به صورت پیش فرض ندارید", "خطا"); return(false); } else { Atend.Base.Equipment.EGroundCabelTip Equip = Atend.Base.Equipment.EGroundCabelTip.SelectByXCode(SelectGroundCabelTipXCode); if (Equip.IsDefault || IsDefault) { MessageBox.Show("کاربر گرامی شما اجازه ویرایش تجهیز به صورت پیش فرض ندارید", "خطا"); return(false); } } } return(true); }
private void Save() { txtName.Focus(); string cmd = string.Empty; bool sw = false; bool swPhase = false; if (lblPhase.Text != "0") { cmd += string.Format("({0}*{1})", lblPhase.Text, txtPhaseCross.Text); sw = true; swPhase = true; } if (txtNeutralCross.Text != "0") { if (sw) { cmd += " + "; } cmd += string.Format("{0}", txtNeutralCross.Text); sw = true; } if (swPhase) { //if (sw) // cmd += " + "; cmd += " " + string.Format("{0}", txtType.Text); sw = true; } cmd += " Cable Ground"; //if (swPhase) //{ // cmd += " " + lblMaterialCode.Text; //} ed.WriteMessage(cmd + "\n"); Atend.Base.Equipment.EGroundCabelTip GroundCabeltip = new Atend.Base.Equipment.EGroundCabelTip(); GroundCabeltip.Name = txtName.Text; GroundCabeltip.PhaseCount = Convert.ToInt32(cboPhaseCount.SelectedItem.ToString()); GroundCabeltip.NeutralCount = Convert.ToInt32(cboNeutralCount.SelectedItem.ToString()); //GroundCabeltip.NightCount = Convert.ToInt32(cboNightCount.SelectedItem.ToString()); GroundCabeltip.NeutralProductXCode = new Guid(cboNeutralProductCode.SelectedValue.ToString()); GroundCabeltip.PhaseProductXCode = new Guid(cboPhaseProductCode.SelectedValue.ToString()); //GroundCabeltip.NightProductXCode = new Guid(cboNightProductCode.SelectedValue.ToString()); GroundCabeltip.Description = cmd; GroundCabeltip.IsDefault = IsDefault; //ed.WriteMessage("Go To Insert\n"); GroundCabeltip.Code = Code; if (SelectGroundCabelTipXCode == Guid.Empty) { if (GroundCabeltip.InsertX()) { Reset(); } else { MessageBox.Show("امکان ثبت اطلاعات نمی باشد", "خطا"); } } else { GroundCabeltip.XCode = SelectGroundCabelTipXCode; if (GroundCabeltip.UpdateX()) { Reset(); } else { MessageBox.Show("امکان به روز رسانی اطلاعات نمی باشد", "خطا"); } } }
private void btnOk_Click(object sender, EventArgs e) { if (Validation()) { if (Convert.ToBoolean(gvConductor.Rows[gvConductor.CurrentRow.Index].Cells[2].Value) == false)//Access { Atend.Base.Equipment.EGroundCabelTip GroundCabelTip = Atend.Base.Equipment.EGroundCabelTip.AccessSelectByCode(Convert.ToInt32(gvConductor.Rows[gvConductor.CurrentRow.Index].Cells[1].Value.ToString())); if (GroundCabelTip.Code != -1) { Atend.Base.Acad.AcadGlobal.GroundCableData.eGroundCabelTip = GroundCabelTip; Atend.Base.Acad.AcadGlobal.GroundCableData.UseAccess = true; Atend.Base.Equipment.EGroundCabel GroundPhase = Atend.Base.Equipment.EGroundCabel.AccessSelectByCode(GroundCabelTip.PhaseProductCode); if (GroundPhase.Code != -1) { Atend.Base.Acad.AcadGlobal.GroundCableData.eGroundCabels.Add(GroundPhase); Atend.Base.Equipment.EGroundCabel GroundNeutral = Atend.Base.Equipment.EGroundCabel.AccessSelectByCode(GroundCabelTip.NeutralProductCode); if (GroundNeutral.Code != -1) { Atend.Base.Acad.AcadGlobal.GroundCableData.eGroundCabels.Add(GroundNeutral); } else { return; } } else { return; } } else { return; } } else { Atend.Base.Equipment.EGroundCabelTip GroundCabelTip = Atend.Base.Equipment.EGroundCabelTip.SelectByXCode(new Guid(gvConductor.Rows[gvConductor.CurrentRow.Index].Cells[0].Value.ToString())); if (GroundCabelTip.Code != -1) { Atend.Base.Acad.AcadGlobal.GroundCableData.eGroundCabelTip = GroundCabelTip; Atend.Base.Acad.AcadGlobal.GroundCableData.UseAccess = false; Atend.Base.Equipment.EGroundCabel GroundPhase = Atend.Base.Equipment.EGroundCabel.SelectByXCode(GroundCabelTip.PhaseProductXCode); if (GroundPhase.Code != -1) { Atend.Base.Acad.AcadGlobal.GroundCableData.eGroundCabels.Add(GroundPhase); Atend.Base.Equipment.EGroundCabel GroundNeutral = Atend.Base.Equipment.EGroundCabel.SelectByXCode(GroundCabelTip.NeutralProductXCode); if (GroundNeutral.Code != -1) { Atend.Base.Acad.AcadGlobal.GroundCableData.eGroundCabels.Add(GroundNeutral); } else { return; } } else { return; } } else { return; } } Atend.Base.Base.BEquipStatus status = Atend.Base.Base.BEquipStatus.SelectByCode(Convert.ToInt32(cboIsExist.SelectedValue)); Atend.Base.Acad.AcadGlobal.GroundCableData.Existance = status.ACode; if (cboProjCode.Items.Count == 0) { Atend.Base.Acad.AcadGlobal.GroundCableData.ProjectCode = 0; } else { Atend.Base.Acad.AcadGlobal.GroundCableData.ProjectCode = Convert.ToInt32(cboProjCode.SelectedValue); } Atend.Control.Common.IsExist = Convert.ToInt32(cboIsExist.SelectedValue.ToString()); if (cboProjCode.Items.Count != 0) { Atend.Control.Common.ProjectCode = Convert.ToInt32(cboProjCode.SelectedValue.ToString()); } else { Atend.Control.Common.ProjectCode = -1; } AllowClose = true; } else { AllowClose = false; } }
//DataColumn dcSCCurrent = new DataColumn("SCCurrent"); //DataColumn CondMax1sCurrent = new DataColumn("CondMax1sCurrent"); public frmElectericalResult(DataTable dtNodes, DataTable dtBranch) { Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; ed.WriteMessage("\nchecking.....\n"); if (!Atend.Global.Acad.DrawEquips.Dicision.IsHere()) { if (!Atend.Global.Acad.DrawEquips.Dicision.IsThere()) { //System.Diagnostics.Process[] prs = System.Diagnostics.Process.GetProcesses(); //foreach (System.Diagnostics.Process pr in prs) //{ // if (pr.ProcessName == "acad") // { // pr.CloseMainWindow(); // } //} Atend.Global.Acad.Notification notification = new Atend.Global.Acad.Notification(); notification.Title = "شناسایی قفل"; notification.Msg = "لطفا وضعیت قفل را بررسی نمایید "; notification.infoCenterBalloon(); ForceToClose = true; } } InitializeComponent(); dtResultNode.Columns.Add(dcLoadPowerImage); dtResultNode.Columns.Add(dcLoadPowerReal); dtResultNode.Columns.Add(dcVoltAbs); dtResultNode.Columns.Add(dcVoltAng); dtResultNode.Columns.Add(dcVoltDropPer); dtResultNode.Columns.Add(dcLoadCurrentAbs); dtResultNode.Columns.Add(dcLoadCurrentArg); dtResultNode.Columns.Add(dcConsolGuid); dtResultBranch.Columns.Add(dcCode); dtResultBranch.Columns.Add(dcCondUtilization); dtResultBranch.Columns.Add(dcLenght); dtResultBranch.Columns.Add(dcCurrentAbs); dtResultBranch.Columns.Add(dcCurrentAng); dtResultBranch.Columns.Add(dcTotalLoadREal); dtResultBranch.Columns.Add(dcCondCode); dtResultBranch.Columns.Add(dcCondCurrent); dtResultBranch.Columns.Add(dcFrom); dtResultBranch.Columns.Add(dcTo); dtResultBranch.Columns.Add(dcPowerLoss); //dtResultBranch.Columns.Add(dcSCCurrent); //dtResultBranch.Columns.Add(CondMax1sCurrent); //ed.WriteMessage("Print Nodes\n"); Atend.Base.Calculating.CDistributedLoadBranch.AccessDelete(); Atend.Base.Calculating.CDistributedLoadNode.AccessDelete(); foreach (DataRow dr in dtNodes.Rows) { DataRow drNew = dtResultNode.NewRow(); Atend.Base.Calculating.CDistributedLoadNode loadNode = new Atend.Base.Calculating.CDistributedLoadNode(); Atend.Base.Design.DPackage pack = Atend.Base.Design.DPackage.AccessSelectByCode(new Guid(dr["ConsoleGuid"].ToString())); if (pack.Code != Guid.Empty) { drNew["ConsolGuid"] = pack.Number; loadNode.NodeName = pack.Number; drNew["VoltAbs"] = Math.Round(((Complex)dr["Voltage"]).abs, 3); loadNode.VoltAbs = Math.Round(((Complex)dr["Voltage"]).abs, 3); double voltDegree = ConvertToDegree(((Complex)dr["Voltage"]).arg); //drNew["VoltArg"] = Math.Round(((Complex)dr["Voltage"]).arg, 2); //loadNode.VoltArg = Math.Round(((Complex)dr["Voltage"]).arg, 2); drNew["VoltArg"] = Math.Round(voltDegree, 2); loadNode.VoltArg = Math.Round(voltDegree, 2); double voltDropPer = 100 - Convert.ToDouble(dr["VoltageDropPer"].ToString()); drNew["VoltDropPer"] = Math.Round(voltDropPer, 2); loadNode.DropVolt = Convert.ToDouble(Math.Round(voltDropPer, 2)); drNew["LoadPowerReal"] = Math.Round(((Complex)dr["LoadPower"]).imag, 3) / 1000; loadNode.LoadPower = Math.Round(((Complex)dr["LoadPower"]).imag, 3) / 1000; drNew["LoadPowerImg"] = Math.Round(((Complex)dr["LoadPower"]).real, 3) / 1000; loadNode.LoadPowerActive = Math.Round(((Complex)dr["LoadPower"]).real, 3) / 1000; drNew["LoadCurrentAbs"] = Math.Round(((Complex)dr["LoadCurrent"]).abs, 3);//.ToString(); loadNode.LoadCurrentAbs = Math.Round(((Complex)dr["LoadCurrent"]).abs, 3); double LoadCurrentArg = ConvertToDegree(((Complex)dr["LoadCurrent"]).arg); //drNew["LoadCurrentArg"] = Math.Round(((Complex)dr["LoadCurrent"]).arg, 3); //loadNode.LoadCurrentArg = Math.Round(((Complex)dr["LoadCurrent"]).arg, 3); drNew["LoadCurrentArg"] = Math.Round(LoadCurrentArg, 3); loadNode.LoadCurrentArg = Math.Round(LoadCurrentArg, 3); dtResultNode.Rows.Add(drNew); if (!loadNode.AccessInsert()) { ed.WriteMessage("LoadNode Insert Failed\n"); } } } //ed.WriteMessage("Print Branch\n"); double totalLoad = 0; foreach (DataRow dr in dtBranch.Rows) { DataRow drNew = dtResultBranch.NewRow(); Atend.Base.Calculating.CDistributedLoadBranch LoadBranch = new Atend.Base.Calculating.CDistributedLoadBranch(); Atend.Base.Design.DBranch branch = Atend.Base.Design.DBranch.AccessSelectByCode(new Guid(dr["Code"].ToString())); if (branch.Code != Guid.Empty) { drNew["Code"] = branch.Number; LoadBranch.BranchName = branch.Number; drNew["Lenght"] = Math.Round(Convert.ToDouble(dr["Length"].ToString()), 2); LoadBranch.Lenght = Math.Round(Convert.ToDouble(dr["Length"].ToString()), 3); drNew["CondUtilization"] = Math.Round(Convert.ToDouble(dr["CondUtilization"].ToString()), 3); LoadBranch.Condutilization = Math.Round(Convert.ToDouble(dr["CondUtilization"].ToString()), 3); drNew["CurrentAbs"] = Math.Round(((Complex)dr["Current"]).abs, 3);//.ToString(); LoadBranch.CurrentAbs = Math.Round(((Complex)dr["Current"]).abs, 3); double currentArg = ConvertToDegree(((Complex)dr["Current"]).arg); //drNew["CurrentArg"] = Math.Round(((Complex)dr["Current"]).arg, 3); //LoadBranch.CurrentArg = Math.Round(((Complex)dr["Current"]).arg, 3); drNew["CurrentArg"] = Math.Round(currentArg, 3); LoadBranch.CurrentArg = Math.Round(currentArg, 3); //MessageBox.Show(dr["PowerLoss"].ToString()); totalLoad += Math.Round(((Complex)dr["TotalLoad"]).real / 1000 + (Convert.ToDouble(dr["PowerLoss"].ToString()) / 1000), 3); drNew["TotalLoadReal"] = totalLoad; LoadBranch.TotalLoad = totalLoad;//Math.Round(((Complex)dr["TotalLoad"]).real / 1000 + (Convert.ToDouble(dr["PowerLoss"].ToString()) / 1000), 3); ed.WriteMessage("CondCode={0}\n", dr["CondCode"].ToString()); if ((branch.ProductType == Convert.ToInt32(Atend.Control.Enum.ProductType.Conductor)) || (branch.ProductType == Convert.ToInt32(Atend.Control.Enum.ProductType.Jumper)) || (branch.ProductType == Convert.ToInt32(Atend.Control.Enum.ProductType.Terminal))) { Atend.Base.Equipment.EConductorTip econdTip = Atend.Base.Equipment.EConductorTip.AccessSelectByCode(branch.ProductCode); Atend.Base.Equipment.EConductor eCond = Atend.Base.Equipment.EConductor.AccessSelectByCode(econdTip.PhaseProductCode); drNew["CondName"] = eCond.Name; drNew["CondCurrent"] = eCond.MaxCurrent; LoadBranch.CondName = eCond.Name; LoadBranch.CondCurrent = eCond.MaxCurrent; } else if (branch.ProductType == Convert.ToInt32(Atend.Control.Enum.ProductType.SelfKeeper)) { Atend.Base.Equipment.ESelfKeeperTip eSelTip = Atend.Base.Equipment.ESelfKeeperTip.AccessSelectByCode(branch.ProductCode); Atend.Base.Equipment.ESelfKeeper eSelf = Atend.Base.Equipment.ESelfKeeper.AccessSelectByCode(eSelTip.PhaseProductCode); drNew["CondName"] = eSelf.Name; drNew["CondCurrent"] = eSelf.MaxCurrent; LoadBranch.CondName = eSelf.Name; LoadBranch.CondCurrent = eSelf.MaxCurrent; } else if (branch.ProductType == Convert.ToInt32(Atend.Control.Enum.ProductType.GroundCabel)) { Atend.Base.Equipment.EGroundCabelTip egroundTip = Atend.Base.Equipment.EGroundCabelTip.AccessSelectByCode(branch.ProductCode); Atend.Base.Equipment.EGroundCabel eGround = Atend.Base.Equipment.EGroundCabel.AccessSelectByCode(egroundTip.PhaseProductCode); drNew["CondName"] = eGround.Name; drNew["CondCurrent"] = eGround.MaxCurrent; LoadBranch.CondName = eGround.Name; LoadBranch.CondCurrent = eGround.MaxCurrent; } DataRow[] drnodeFrom = dtNodes.Select(string.Format("ConsoleObjID={0}", dr["UpNodeId"].ToString())); if (drnodeFrom.Length > 0) { drNew["From"] = FindNodeComment(new Guid(drnodeFrom[0]["ConsoleGuid"].ToString())); LoadBranch.From = drNew["From"].ToString(); } //به DataRow[] drnodeTo = dtNodes.Select(string.Format("ConsoleObjID={0}", dr["DnNodeId"].ToString())); if (drnodeTo.Length > 0) { //drNew["Volt"] = Math.Round(((Complex)(drnodeTo[0]["Voltage"])).abs, 2).ToString(); drNew["To"] = FindNodeComment(new Guid(drnodeTo[0]["ConsoleGuid"].ToString())); LoadBranch.To = drNew["To"].ToString(); } LoadBranch.PowerLoss = Math.Round(Convert.ToDouble(dr["PowerLoss"]) / 1000, 2); drNew["PowerLoss"] = Math.Round(Convert.ToDouble(dr["PowerLoss"]) / 1000, 2); dtResultBranch.Rows.Add(drNew); if (!LoadBranch.AccessInsert()) { ed.WriteMessage("LoadBranch Inser Failed\n"); } } //drNew["SCCurrent"] = Math.Round(Convert.ToDouble(dr["SCCurrent"].ToString()), 3); //drNew["CondMax1sCurrent"] = Math.Round(Convert.ToDouble(dr["CondMax1sCurrent"].ToString()), 3); } //ed.WriteMessage("BindDAtA\n"); //string Code1 = "00000000-0000-0000-0000-000000000000"; //DataRow[] drs = dtResultBranch.Select(" Code= '" + Code1 + "'"); //drs[0].Delete(); //DataRow[] drs1 = dtResultNode.Select(" ConsolGuid ='" + Code1 + "'"); //drs1[0].Delete(); gvBranch.AutoGenerateColumns = false; gvBranch.DataSource = dtResultBranch; gvNode.AutoGenerateColumns = false; gvNode.DataSource = dtResultNode; }
public frmShortCircuitResult(DataTable dtNodes, DataTable dtBranch, double FalutDuration) { Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; ed.WriteMessage("\nchecking.....\n"); if (!Atend.Global.Acad.DrawEquips.Dicision.IsHere()) { if (!Atend.Global.Acad.DrawEquips.Dicision.IsThere()) { //System.Diagnostics.Process[] prs = System.Diagnostics.Process.GetProcesses(); //foreach (System.Diagnostics.Process pr in prs) //{ // if (pr.ProcessName == "acad") // { // pr.CloseMainWindow(); // } //} Atend.Global.Acad.Notification notification = new Atend.Global.Acad.Notification(); notification.Title = "شناسایی قفل"; notification.Msg = "لطفا وضعیت قفل را بررسی نمایید "; notification.infoCenterBalloon(); ForceToClose = true; } } InitializeComponent(); _FaultDuration = FalutDuration; dtResultNode.Columns.Add(dcLoadPowerImage); dtResultNode.Columns.Add(dcLoadPowerReal); dtResultNode.Columns.Add(dcVoltAbs); dtResultNode.Columns.Add(dcVoltAng); dtResultNode.Columns.Add(dcVoltDropPer); dtResultNode.Columns.Add(dcLoadCurrentAbs); dtResultNode.Columns.Add(dcLoadCurrentArg); dtResultNode.Columns.Add(dcConsolGuid); dtResultBranch.Columns.Add(dcCode); dtResultBranch.Columns.Add(dcCondUtilization); dtResultBranch.Columns.Add(dcLenght); dtResultBranch.Columns.Add(dcCurrentAbs); dtResultBranch.Columns.Add(dcCurrentAng); dtResultBranch.Columns.Add(dcTotalLoadREal); dtResultBranch.Columns.Add(dcSCCurrent); dtResultBranch.Columns.Add(CondMax1sCurrent); dtResultBranch.Columns.Add(dcFrom); dtResultBranch.Columns.Add(dcTo); dtResultBranch.Columns.Add(dcCondName); dtResultBranch.Columns.Add(dcVolt); ed.WriteMessage("Print Nodes\n"); foreach (DataRow dr in dtNodes.Rows) { DataRow drNew = dtResultNode.NewRow(); if (new Guid(dr["ConsoleGuid"].ToString()) != Guid.Empty) { Atend.Base.Design.DPackage dPack = Atend.Base.Design.DPackage.AccessSelectByCode(new Guid(dr["ConsoleGuid"].ToString())); drNew["ConsolGuid"] = dPack.Number; drNew["VoltAbs"] = Math.Round(((Complex)dr["Voltage"]).abs, 3); double voltArg = ConvertToDegree(((Complex)dr["Voltage"]).arg); //drNew["VoltArg"] = Math.Round(((Complex)dr["Voltage"]).arg, 2); drNew["VoltArg"] = Math.Round(voltArg, 2); drNew["VoltDropPer"] = Math.Round(Convert.ToDouble(dr["VoltageDropPer"].ToString())); drNew["LoadPowerReal"] = Math.Round(((Complex)dr["LoadPower"]).real, 3); drNew["LoadPowerImg"] = Math.Round(((Complex)dr["LoadPower"]).imag, 3); drNew["LoadCurrentAbs"] = Math.Round(((Complex)dr["LoadCurrent"]).abs, 3);//.ToString(); double loadcurrentArg = ConvertToDegree(((Complex)dr["LoadCurrent"]).arg); //drNew["LoadCurrentArg"] = Math.Round(((Complex)dr["LoadCurrent"]).arg, 3);//.ToString(); drNew["LoadCurrentArg"] = loadcurrentArg; dtResultNode.Rows.Add(drNew); } } ed.WriteMessage("Print Branch\n"); Atend.Base.Calculating.CShortCircuit.AccessDelete(); foreach (DataRow dr in dtBranch.Rows) { Atend.Base.Calculating.CShortCircuit shortCircuit = new Atend.Base.Calculating.CShortCircuit(); if (new Guid(dr["Code"].ToString()) != Guid.Empty) { DataRow drNew = dtResultBranch.NewRow(); Atend.Base.Design.DBranch branch = Atend.Base.Design.DBranch.AccessSelectByCode(new Guid(dr["Code"].ToString())); //drNew["Code"] = branch.Number; if ((branch.ProductType == Convert.ToInt32(Atend.Control.Enum.ProductType.Conductor)) || (branch.ProductType == Convert.ToInt32(Atend.Control.Enum.ProductType.Jumper)) || (branch.ProductType == Convert.ToInt32(Atend.Control.Enum.ProductType.Terminal))) { Atend.Base.Equipment.EConductorTip ConductorTip = Atend.Base.Equipment.EConductorTip.AccessSelectByCode(branch.ProductCode); Atend.Base.Equipment.EConductor Conductor = Atend.Base.Equipment.EConductor.AccessSelectByCode(ConductorTip.PhaseProductCode); drNew["CondName"] = Conductor.Name; double IbMax = Convert.ToDouble(Conductor.MaxCurrent1Second) / Math.Sqrt(_FaultDuration); drNew["CondMax1sCurrent"] = Math.Round(IbMax, 1); shortCircuit.CondName = Conductor.Name; shortCircuit.CondMax1SCurrent = Math.Round(IbMax, 1); } if (branch.ProductType == Convert.ToInt32(Atend.Control.Enum.ProductType.SelfKeeper)) { Atend.Base.Equipment.ESelfKeeperTip SelfKeeperTip = Atend.Base.Equipment.ESelfKeeperTip.AccessSelectByCode(branch.ProductCode); Atend.Base.Equipment.ESelfKeeper SelfKeeper = Atend.Base.Equipment.ESelfKeeper.AccessSelectByCode(SelfKeeperTip.PhaseProductCode); drNew["CondName"] = SelfKeeper.Name; double IbMax = Convert.ToDouble(SelfKeeper.MaxCurrent1Second) / Math.Sqrt(_FaultDuration); drNew["CondMax1sCurrent"] = Math.Round(IbMax, 1); shortCircuit.CondName = SelfKeeper.Name; shortCircuit.CondMax1SCurrent = Math.Round(IbMax, 1); } if (branch.ProductType == Convert.ToInt32(Atend.Control.Enum.ProductType.GroundCabel)) { Atend.Base.Equipment.EGroundCabelTip GroundTip = Atend.Base.Equipment.EGroundCabelTip.AccessSelectByCode(branch.ProductCode); Atend.Base.Equipment.EGroundCabel Ground = Atend.Base.Equipment.EGroundCabel.AccessSelectByCode(GroundTip.PhaseProductCode); drNew["CondName"] = Ground.Name; double IbMax = Convert.ToDouble(Ground.MaxCurrent1Second) / Math.Sqrt(_FaultDuration); drNew["CondMax1sCurrent"] = Math.Round(IbMax, 1); shortCircuit.CondName = Ground.Name; shortCircuit.CondMax1SCurrent = Math.Round(IbMax, 1); } drNew["Lenght"] = dr["Length"].ToString(); drNew["CondUtilization"] = Math.Round(Convert.ToDouble(dr["CondUtilization"].ToString()), 3); drNew["CurrentAbs"] = Math.Round(((Complex)dr["Current"]).abs, 3);//.ToString(); double currentArg = ConvertToDegree(((Complex)dr["Current"]).arg); //drNew["CurrentArg"] = Math.Round(((Complex)dr["Current"]).arg, 3);//.ToString(); drNew["CurrentArg"] = Math.Round(currentArg, 3); drNew["TotalLoadReal"] = Math.Round(((Complex)dr["TotalLoad"]).arg, 3); drNew["SCCurrent"] = Math.Round(Convert.ToDouble(dr["SCCurrent"].ToString()), 0); ed.WriteMessage("CondCode={0}\n", dr["CondCode"].ToString()); shortCircuit.Lenght = Convert.ToDouble(dr["Length"].ToString()); shortCircuit.Condutilization = Math.Round(Convert.ToDouble(dr["CondUtilization"].ToString()), 3); shortCircuit.CurrentAbs = Math.Round(((Complex)dr["Current"]).abs, 3); //.ToString(); shortCircuit.CurrentArg = Math.Round(currentArg, 3); //.ToString(); shortCircuit.TotalLoad = Math.Round(((Complex)dr["TotalLoad"]).arg, 3); shortCircuit.ScCurrent = Math.Round(Convert.ToDouble(dr["SCCurrent"].ToString()), 0); ed.WriteMessage("Current={0}\n", shortCircuit.ScCurrent); //از DataRow[] drnodeFrom = dtNodes.Select(string.Format("ConsoleObjID={0}", dr["UpNodeId"].ToString())); if (drnodeFrom.Length > 0) { drNew["From"] = FindNodeComment(new Guid(drnodeFrom[0]["ConsoleGuid"].ToString())); shortCircuit.From = drNew["From"].ToString(); } //به DataRow[] drnodeTo = dtNodes.Select(string.Format("ConsoleObjID={0}", dr["DnNodeId"].ToString())); if (drnodeTo.Length > 0) { drNew["Volt"] = Math.Round(((Complex)(drnodeTo[0]["Voltage"])).abs, 2).ToString(); drNew["To"] = FindNodeComment(new Guid(drnodeTo[0]["ConsoleGuid"].ToString())); shortCircuit.To = drNew["To"].ToString(); shortCircuit.Volt = Math.Round(((Complex)(drnodeTo[0]["Voltage"])).abs, 2); } //if (new Guid(dr["Code"].ToString()) != Guid.Empty) //{ ////Atend.Base.Equipment.EConductorTip condTip = Atend.Base.Equipment.EConductorTip.AccessSelectByCode(Convert.ToInt32(dr["CondCode"].ToString())); ////Atend.Base.Equipment.EConductor conductor = Atend.Base.Equipment.EConductor.AccessSelectByCode(condTip.PhaseProductCode); ////ed.WriteMessage("conductor.MaxCurrent1Second={0},SCCurrent={1}\n", conductor.MaxCurrent1Second, dr["SCCurrent"].ToString()); ////ed.WriteMessage("#######\n"); //ed.WriteMessage("&&&&&&={0}\n", dr["CondMax1sCurrent"].ToString()); //} //else //{ // drNew["CondMax1sCurrent"] = dr["CondUtilizationSC"].ToString(); //} dtResultBranch.Rows.Add(drNew); if (!shortCircuit.AccessInsert()) { ed.WriteMessage("Insert Failed\n"); } } } ////foreach (DataRow dr in dtResultBranch.Rows) ////{ //// ed.WriteMessage("dtResultBranch.CondMax1sCurrent={0}\n", dr["CondMax1sCurrent"].ToString()); ////} //string code1 = "00000000-0000-0000-0000-000000000000"; //DataRow[] drs = dtResultBranch.Select(" Code = '"+code1+"'"); //drs[0].Delete(); //DataRow[] drs1 = dtResultNode.Select(" ConsolGuid = '" + code1 + "'"); //drs1[0].Delete(); ed.WriteMessage("BindDAtA\n"); gvBranch.AutoGenerateColumns = false; gvBranch.DataSource = dtResultBranch; //gvNode.AutoGenerateColumns = false; //gvNode.DataSource = dtResultNode; CheckCurrent(); }