Esempio n. 1
0
        private void ModifySwitch_Click(object sender, EventArgs e)
        {
            if (lbSwitchCabinetcol.Items.Count <= 0)
            {
                return;
            }
            int index = lbSwitchCabinetcol.SelectedIndex;

            if (index < 0)
            {
                return;
            }
            if (!DBEntityFinder.Instance.VerifyLTTID(dfG3eFid))
            {
                PublicMethod.Instance.Editor.WriteMessage("\n电房未在工单锁定范围之内,禁止编辑!!!\n");
                return;
            }
            try
            {
                var values = DevEventHandler.GetDevTables(198, dict[index]);
                GenerateHelper.SetAllBrowsable(values.DevObj, true);
                pgSwitchCabinet.SelectedObject = values.DevObj;
                pgSwitchCabinet.Enabled        = true;
                isModify = true;
                isAdd    = false;
            }
            catch (Exception ex)
            {
                LogManager.Instance.Error(ex);
            }
            finally
            {
                ResetSwitch(false);
            }
        }
Esempio n. 2
0
        public bool AddDevAttribute()
        {
            long fid = 0, fno = 0, id = 0;

            if (!DBEntityFinder.Instance.GetG3EIds(objId, ref id, ref fid, ref fno))
            {
                return(false);
            }
            Fno = (int)fno;
            Fid = fid;
            rdt = DevEventHandler.GetDevTables(Fno, Fid);
            if (rdt == null)
            {
                return(false);
            }
            if (!DBEntityFinder.Instance.VerifyLTTID(objId))
            {
                PublicMethod.Instance.ShowMessage("\n当前设备未在工单锁定范围,禁止编辑...");
                GenerateHelper.SetAllReadOnly(rdt.DevObj, true);
            }
            GenerateHelper.SetAllBrowsable(rdt.DevObj, true);
            GenerateHelper.GenerateXPropsByAzwz(rdt.DevObj, Fno, false);
            AutoGenerationHelper.Instance.AddUITypeEditor(rdt.DevObj, Fno);
            pgDev.SelectedObject = rdt.DevObj;
            CurPropertyObj       = rdt.DevObj;
            pgDev.Refresh();
            // var simpleSymbolConfigEntry = SimpleSymbolConfig.Instance.Symbols.SingleOrDefault(o => o.Fno == Fno);
            //if (simpleSymbolConfigEntry != null)
            //    WindowManager.ChangeDevAttributePsText(simpleSymbolConfigEntry.LayerName + "(*表示必填项)-" +
            //                                           Fid.ToString(CultureInfo.InvariantCulture));
            //this.Refresh();
            //CommonHelp.Instance.RestoreValue(rdt.GnwzObj);
            return(true);
        }
Esempio n. 3
0
 private void lbSwitchCabinetcol_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         int index = lbSwitchCabinetcol.SelectedIndex;
         if (index < 0)
         {
             return;
         }
         var values = DevEventHandler.GetDevTables(198, dict[index]);
         GenerateHelper.SetAllBrowsable(values.DevObj, true);
         GenerateHelper.SetAllReadOnly(values.DevObj, true);
         pgSwitchCabinet.SelectedObject = values.DevObj;
         g3eFid   = dict[index];
         devIndex = index;
         if (isAdd || isModify)
         {
             AddSwitch.Enabled    = true;
             ModifySwitch.Enabled = true;
             DelSwitch.Enabled    = true;
         }
     }
     catch (Exception ex)
     {
         LogManager.Instance.Equals(ex);
     }
     finally
     {
         ResetSwitch(true);
     }
 }
Esempio n. 4
0
        /// <summary>
        /// 按FID查找设备属性
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FIDQuery_Click(object sender, EventArgs e)
        {
            long g3eFid = 0;

            if (!string.IsNullOrEmpty(FID_textBox.Text.Trim()) && (long.TryParse(FID_textBox.Text.Trim(), NumberStyles.Integer, null, out g3eFid)))
            {
                ;
            }
            {
                var ent = DBEntityFinder.Instance.GetDBSymbolFinderByFid(g3eFid);
                if (ent == null || !ent.Any())
                {
                    Fidlable.Text = "请您输入有效的FID";
                }
                else
                {
                    Fidlable.Text = "";
                    List <QueryRes> fidList = new List <QueryRes>();
                    var             common  = DBManager.Instance.GetEntity <Common_n>(g3eFid);
                    if (common != null)
                    {
                        var qr = FillQueryResObj(g3eFid, common.G3E_FNO, common.CD_SSXL, common.CD_SMZQ, common.SBMC);
                        fidList.Add(qr);
                    }
                    else
                    {
                        var cbx = DevEventHandler.GetDevTables(159, g3eFid);
                        if (cbx == null)
                        {
                            var cbxSelf = cbx.SelfObj as Gg_pd_cbx_n;
                            if (cbxSelf != null)
                            {
                                fidList.Add(FillQueryResObj(g3eFid, 159, cbxSelf.CD_SSXL, cbxSelf.CD_SMZQ, cbxSelf.HH));
                            }
                        }
                        else
                        {
                            var shb = DevEventHandler.GetDevTables(159, g3eFid);
                            if (shb != null)
                            {
                                var shbSelf = shb.SelfObj as Gg_pd_dyshb_n;
                                if (shbSelf != null)
                                {
                                    fidList.Add(FillQueryResObj(g3eFid, 160, shbSelf.CD_SSXL, shbSelf.SMZQ, shbSelf.HH));
                                }
                            }
                        }
                    }
                    if (fidList.Count <= 0)
                    {
                        Fidlable.Text = "当前沿布图查询不到该FID对应的设备";
                    }
                    else
                    {
                        AddColumnData(fidList, "根据FID查询设备", lvFidQuery);
                        FixEntity.Instance.Fix(g3eFid);
                    }
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 更新选择的同类设备自身属性
        /// </summary>
        public UpdataResult UpdataSelfAttribute(ref List <BulkChangeEnt> Current, XProps objDev)
        {
            UpdataResult ur = new UpdataResult();

            try
            {
                DCadApi.isModifySymbol = true;
                foreach (var ent in Current)
                {
                    try
                    {
                        var value = DevEventHandler.GetDevTables(ent.SingleG3EObject.G3E_FNO, ent.SingleG3EObject.G3E_FID);
                        if (value.DevObj != null)
                        {
                            PartialCopy(objDev, value.DevObj);
                            //查找看看该设备是否有符号,有的就要根据属性更新符号
                            ObjectId objId = DBEntityFinder.Instance.GetObjectIdByFid(ent.SingleG3EObject.G3E_FID);
                            if (objId.IsNull)
                            {
                                UpdateAttribute(value, value.DevObj, false);
                                ur.UpdataSucceedNum++;
                            }
                            else
                            {
                                ObjectId newObjId = ObjectId.Null;
                                bool     isUpdate = DCadApi.UpdateSymbol(objId, value.DevObj, out newObjId);
                                if (isUpdate)
                                {
                                    UpdateAttribute(value, value.DevObj, false);
                                    ur.UpdataSucceedNum++;
                                }
                                else
                                {
                                    //存放更新失败的设备
                                    ur.UpdataFailedNum++;
                                    ur.UpdataErrorLog.AppendLine("Fid=" + ent.SingleG3EObject.G3E_FID + "的设备更新失败");
                                }
                            }
                        }
                        PublicMethod.Instance._isSelectedEntityChoice = false;
                    }
                    catch (Exception)
                    {
                        ur.UpdataFailedNum++;
                        ur.UpdataErrorLog.AppendLine("Fid=" + ent.SingleG3EObject.G3E_FID + "的设备更新失败");
                    }
                }
            }
            catch (Exception ex)
            {
                LogManager.Instance.Error(ex);
            }
            finally
            {
                DCadApi.isModifySymbol = false;
            }
            return(ur);
        }
Esempio n. 6
0
        /// <summary>
        /// 更新属性面板
        /// </summary>
        /// <param name="isSyncTz">是否是同步台帐调用次方法</param>
        private void SelectDevAttribute(bool isSyncTz)
        {
            var value = DevEventHandler.GetDevTables(CurrentFno, CurrentFid);

            if (value == null)
            {
                return;
            }
            if (value.DevObj == null)
            {
                return;
            }
            GenerateHelper.SetAllBrowsable(value.DevObj, true);

            isLTTID = DBEntityFinder.Instance.VerifyLTTID(CurrentFid);
            if (!isLTTID)
            {
                PublicMethod.Instance.ShowMessage("\n当前设备未被锁定,禁止编辑...");
                GenerateHelper.SetAllReadOnly(value.DevObj, true);
            }
            else
            {
                if (isSyncTz)
                {
                    GenerateHelper.SetAllReadOnly(value.DevObj, false);
                }
                DevPropertyGrid.Enabled = true;
            }
            AutoGenerationHelper.Instance.AddUITypeEditor(value.DevObj, CurrentFno);
            GenerateHelper.GenerateXPropsByAzwz(value.DevObj, CurrentFno, false);
            DevPropertyGrid.SelectedObject = value.DevObj;
            CurPropertyObj = value.DevObj;

            if (!DBEntityFinder.Instance.MemoryDevice.Keys.Contains(CurrentFno))
            {
                DBEntityFinder.Instance.MemoryDevice.Add(CurrentFno, CurPropertyObj);
            }
            else
            {
                DBEntityFinder.Instance.MemoryDevice[CurrentFno] = CurPropertyObj;
            }

            DevPropertyGrid.Refresh();
            var simpleSymbolConfigEntry = SimpleDBSymbolsConfig.Instance.DBSymbol.SingleOrDefault(o => o.G3E_FNO == CurrentFno);

            if (simpleSymbolConfigEntry != null)
            {
                DevNameGroup.Text = simpleSymbolConfigEntry.OtherProperty.LayerName + "(*表示必填项)-" + CurrentFid.ToString(CultureInfo.InvariantCulture);
            }
            //保证面板属性和点击设备对应
            isclickDev = true;
            oldFno     = 0;

            //绑定受电馈线
            GetSDKXBEntity();
        }
Esempio n. 7
0
        private void AddSwitch_Click(object sender, EventArgs e)
        {
            if (!DBEntityFinder.Instance.VerifyLTTID(dfG3eFid))
            {
                PublicMethod.Instance.Editor.WriteMessage("\n电房未在工单锁定范围之内,禁止编辑!!!\n");
                return;
            }
            try
            {
                if (lbSwitchCabinetcol.Items.Count > 0)
                {
                    lbSwitchCabinetcol.SetSelected(lbSwitchCabinetcol.SelectedIndex, false);
                }
                isModify = false;
                isAdd    = true;

                XProps kgg = GenerateObj.Instance.GenderObjByFno(198);
                GenerateHelper.SetAllBrowsable(kgg, true);
                if (dict.Count > 0)
                {
                    var oldkgg = DevEventHandler.GetDevTables(198, dict[0]);
                    if (oldkgg.DevObj != null)
                    {
                        DBEntityFinder.Instance.CopyValueFromOldDev(kgg, oldkgg.DevObj);
                    }
                }
                else
                {
                    var dfCom = DBManager.Instance.GetEntity <Common_n>(dfG3eFid);
                    if (dfCom != null)
                    {
                        GenerateHelper.SetPropertyValue(kgg, "Common_n", "CD_SSDW", dfCom.CD_SSDW);
                        GenerateHelper.SetPropertyValue(kgg, "Common_n", "CD_SSBDZ", dfCom.CD_SSBDZ);
                        GenerateHelper.SetPropertyValue(kgg, "Common_n", "CD_SSXL", dfCom.CD_SSXL);
                        GenerateHelper.SetPropertyValue(kgg, "Common_n", "WHBS", dfCom.WHBS);
                        //GenerateHelper.SetPropertyValue(kgg, "Common_n", "GNWZ_SSGDS", dfCom.GNWZ_SSGDS);
                    }
                }
                pgSwitchCabinet.SelectedObject = kgg;
                pgSwitchCabinet.Enabled        = true;
            }
            catch (Exception ex)
            {
                LogManager.Instance.Error(ex);
            }
            finally
            {
                ResetSwitch(false);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// 获取父设备的所属单位
        /// </summary>
        /// <returns></returns>
        private string GetCD_SSDW()
        {
            var ssdw  = string.Empty;
            var value = DevEventHandler.GetDevTables(entityArgs.g3eObject.G3E_FNO, entityArgs.g3eObject.G3E_FID);

            if (value != null)
            {
                var ssgdj = GenerateHelper.GetPropertyValue(value.DevObj, "Common_n", "CD_SSDW");
                if (ssgdj != null && !string.IsNullOrEmpty(ssgdj.ToString()))
                {
                    ssdw = ssgdj.ToString();
                }
            }
            return(ssdw);
        }
Esempio n. 9
0
 private void btSave_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("确定要新增或修改吗!!!", "提示", MessageBoxButtons.OKCancel) != DialogResult.OK)
     {
         btSave.Enabled = true;
         return;
     }
     try
     {
         if (isModify)
         {
             var value = DevEventHandler.GetDevTables(198, g3eFid);
             UpdateAttribute((XProps)pgSwitchCabinet.SelectedObject, value.ComObj, value.SelfObj, value.GnwzObj, false);
             //DBSymbolLTTIDFinder.Instance[g3eFid].SBMC = value.ComObj.SBMC;
             int idx = dict.SingleOrDefault(o => o.Value == g3eFid).Key;
             lbSwitchCabinetcol.Items[idx] = string.IsNullOrEmpty(value.ComObj.SBMC)?value.ComObj.G3E_FID.ToString():value.ComObj.SBMC;
             //lbSwitchCabinetcol.SetSelected(devIndex, true);
         }
         if (isBulkModify)
         {
             foreach (var item in dict)
             {
                 var value = DevEventHandler.GetDevTables(198, item.Value);
                 UpdateAttribute((XProps)pgSwitchCabinet.SelectedObject, value.ComObj, value.SelfObj, value.GnwzObj, true);
             }
         }
         if (isAdd)
         {
             var kggRes  = DCadApi.AddAttribute((XProps)pgSwitchCabinet.SelectedObject, 198, dfG3eFid);
             var prevCur = kggRes;
             dict.Add(lbSwitchCabinetcol.Items.Count, long.Parse(prevCur.G3eFid));
             lbSwitchCabinetcol.Items.Add(string.IsNullOrEmpty(prevCur.DeviceSbmc)?prevCur.G3eFid.ToString():prevCur.DeviceSbmc);
             g3eFid = long.Parse(prevCur.G3eFid);
             lbSwitchCabinetcol.SetSelected(lbSwitchCabinetcol.Items.Count - 1, true);
         }
         isModify = false;
         isAdd    = false;
     }
     catch (Exception ex)
     {
         LogManager.Instance.Error(ex);
     }
     finally
     {
         ResetSwitch(true);
         pgSwitchCabinet.Enabled = false;
     }
 }
Esempio n. 10
0
        /// <summary>
        /// 判断指定设备是否是插入的新设备
        /// </summary>
        /// <param name="fno"></param>
        /// <param name="fid"></param>
        /// <returns></returns>
        public bool IsInsertDevice(int fno, long fid)
        {
            var tables = DevEventHandler.GetDevTables(fno, fid);

            if (tables != null)
            {
                if ((tables.ComObj != null && tables.ComObj.EntityState == EntityState.Insert) ||
                    (tables.SelfObj != null && tables.SelfObj.EntityState == EntityState.Insert) ||
                    (tables.ConnectObj != null && tables.ConnectObj.EntityState == EntityState.Insert) ||
                    (tables.GnwzObj != null && tables.GnwzObj.EntityState == EntityState.Insert)
                    )
                {
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 11
0
 private void AddWorkOrderOfDev(ObjectId objectId, long g3e_fno, long g3e_fid, int index)
 {
     try
     {
         var tables = DevEventHandler.GetDevTables(g3e_fno, g3e_fid);
         if (tables == null)
         {
             return;
         }
         //更新的情况比较特殊,可能只更新一个表
         string sbmc = string.Empty;
         if (tables.ComObj == null)
         {
             if (g3e_fno == 159 || g3e_fno == 160) //集中抄表箱//散户表
             {
                 sbmc = tables.SelfObj.GetAttribute("HH");
             }
             else if (g3e_fno == 188) //负控
             {
                 sbmc = tables.GnwzObj.GetAttribute("MC");
             }
         }
         else
         {
             sbmc = tables.ComObj.SBMC;
         }
         var vc = new WorkOrder
         {
             SerialNum = index,
             G3E_FID   = g3e_fid,
             DevType   = PublicMethod.Instance.GetDeviceType(Convert.ToInt32(g3e_fno)),
             SSXL      = tables.ComObj != null ? tables.ComObj.CD_SSXL : string.Empty,
             SBMC      = sbmc,
             DevState  = GetDeviceState(tables),
             objId     = objectId
         };
         objList.Add(vc);
     }
     catch (Exception ex)
     {
         PublicMethod.Instance.ShowMessage(ex.Message);
         LogManager.Instance.Error(ex);
     }
 }
Esempio n. 12
0
 private void DevPropertyGrid_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
 {
     ConnectManager.CleanSelcol();
     CommonHelp.Instance.ChangeAttributeRunTime(CurPropertyObj, CurrentFno, new List <long> {
         CurrentFid
     },
                                                e.ChangedItem.PropertyDescriptor.Name, e.ChangedItem.Value != null?e.ChangedItem.Value.ToString():null, e.OldValue);
     DevPropertyGrid.SelectedObject = CurPropertyObj;
     DevPropertyGrid.Refresh();
     //点击了设备但是没有点击图元面板才更新
     if (isclickDev)
     {
         try
         {
             var            rdt       = DevEventHandler.GetDevTables(CurrentFno, CurrentFid);
             cadDS.ObjectId tempObjId = CurrentObjId;
             CommonHelp.Instance.UpdateAttribute(CurPropertyObj, ref tempObjId, rdt);
             if (tempObjId != CurrentObjId)
             {
                 CurrentObjId = tempObjId;
             }
         }
         catch (UpdataArgumentException ee)
         {
             CommonHelp.Instance.ShowErrorMsg();
             if (e.ChangedItem.PropertyDescriptor != null)
             {
                 GenerateHelper.SetPropertyValue(CurPropertyObj, ee.TableName, ee.FieldName, e.OldValue);
             }
         }
         catch (Exception ex)
         {
             LogManager.Instance.Error(ex.Message);
         }
         finally
         {
             //RefPaletteSet();
             EventTriggerFunc();
             GenerateHelper.EmptyFidRecord();
         }
     }
 }
Esempio n. 13
0
        /// <summary>
        /// 开关柜台账信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TZInfo_Click(object sender, EventArgs e)
        {
            try
            {
                pgSwitchCabinet.Enabled = false;
                int index = lbSwitchCabinetcol.SelectedIndex;
                if (index < 0)
                {
                    return;
                }
                var    values = DevEventHandler.GetDevTables(198, dict[index]);
                string g3efid = values.Fid.ToString();
                string g3efno = "198";
                var    kgg    = DBManager.Instance.GetEntity <Gg_pd_kgg_n>(dict[index]);
                if (kgg.EntityState == EntityState.Insert)
                {
                    g3efid = "a" + g3efid;
                }
                string gisid = MapConfig.Instance.LTTID.ToString();
                string sbmc  = values.ComObj.SBMC;
                string s     = "";
                if (!string.IsNullOrEmpty(sbmc))
                {
                    s = BitConverter.ToString(System.Text.Encoding.UTF8.GetBytes(sbmc)).Replace("-", "<M>");
                }

                string UrlStr = @"http://localhost:9090/emmis/equipGisMappingTemp/getInstallEquipments.gis?g3e_fid=" +
                                g3efid + "&jobId=" + gisid + "&g3e_fno=" + g3efno + "&editAble=Y&funcplaceName=" + s +
                                "&jgdh=009";

                if (string.IsNullOrEmpty(UrlStr))
                {
                    return;
                }
                ViewHelper.LoadTZPalette(UrlStr);
            }catch (Exception ex)
            {
                LogManager.Instance.Error(ex);
            }
        }
Esempio n. 14
0
 /// <summary>
 /// 属性查询
 /// </summary>
 /// <param name="fno">设备fno</param>
 /// <param name="fid">设备fid</param>
 /// <returns></returns>
 public static RetureValueCheck AttributeQuery(long fno, long fid)
 {
     try
     {
         var value = DevEventHandler.GetDevTables(fno, fid);
         if (value == null)
         {
             return(RetureValueCheck.LoadNoFound);
         }
         //这里表示已经找到了该FID+FNO对应的设备
         if (value.DevObj != null)
         {
             //如果这四张表有一张被删除了,就表示该设备已经被删除
             if ((value.ComObj != null && value.ComObj.EntityState == EntityState.Delete) ||
                 (value.SelfObj != null && value.SelfObj.EntityState == EntityState.Delete) ||
                 (value.ConnectObj != null && value.ConnectObj.EntityState == EntityState.Delete) ||
                 (value.GnwzObj != null && value.GnwzObj.EntityState == EntityState.Delete))
             {
                 MessageBox.Show("抱歉,您要查找的设备已被删除咯!!!", "CAD警告", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                 return(RetureValueCheck.LoadDialogFalied);
             }
             ObjectId    objId = DBEntityFinder.Instance.GetObjectIdByFid(fid);
             DevAttrArgs ee    = new DevAttrArgs
             {
                 devObjId = objId
             };
             ViewHelper.AddDevAttribute(ee);
             return(RetureValueCheck.LoadDialogSuccess);
         }
     }
     catch (Autodesk.AutoCAD.Runtime.Exception ex)
     {
         LogManager.Instance.Error(ex.Message);
     }
     return(RetureValueCheck.LoadNoFound);
 }
Esempio n. 15
0
        private void DelSwitch_Click(object sender, EventArgs e)
        {
            if (lbSwitchCabinetcol.Items.Count <= 0)
            {
                return;
            }
            int index = lbSwitchCabinetcol.SelectedIndex;

            if (index < 0)
            {
                return;
            }
            if (!DBEntityFinder.Instance.VerifyLTTID(dfG3eFid))
            {
                PublicMethod.Instance.Editor.WriteMessage("\n电房未在工单锁定范围之内,禁止编辑!!!\n");
                return;
            }
            try
            {
                string prompt;
                g3eFid = dict[index];
                var entitys = DBEntityFinder.Instance.GetSSKGG(g3eFid);
                if (entitys != null)
                {
                    prompt = entitys.Any() ? "当前开关柜下已挂有开关,确定要删除该开关柜!" : "确定要删除该开关柜!";
                }
                else
                {
                    prompt = "确定要删除该开关柜!";
                }
                if (MessageBox.Show(prompt, "温馨提示", MessageBoxButtons.OKCancel) != DialogResult.OK)
                {
                    return;
                }
                var values = DevEventHandler.GetDevTables(198, g3eFid);
                if (values.ComObj != null)
                {
                    if (values.ComObj.EntityState == EntityState.None)
                    {
                        values.ComObj.EntityState = EntityState.Delete;
                    }
                    DBManager.Instance.Delete(values.ComObj);
                }
                if (values.SelfObj != null)
                {
                    if (values.SelfObj.EntityState == EntityState.None)
                    {
                        values.SelfObj.EntityState = EntityState.Delete;
                    }
                    DBManager.Instance.Delete(values.SelfObj);
                }
                if (values.GnwzObj != null)
                {
                    if (values.GnwzObj.EntityState == EntityState.None)
                    {
                        values.GnwzObj.EntityState = EntityState.Delete;
                    }
                    DBManager.Instance.Delete(values.GnwzObj);
                }
                int indexDel = dict.SingleOrDefault(o => o.Value == g3eFid).Key;
                for (int i = indexDel; i < dict.Count - 1; i++)
                {
                    dict[i] = dict[i + 1];
                }
                dict.Remove(dict.Count - 1);
                lbSwitchCabinetcol.Items.RemoveAt(indexDel);

                if (index != 0)
                {
                    lbSwitchCabinetcol.SetSelected(index - 1, true);
                    //var kgg = DevEventHandler.GetDevTables(198, dict[index - 1]);

                    //pgSwitchCabinet.SelectedObject = kgg.DevObj;
                }
                else if (index == 0 && lbSwitchCabinetcol.Items.Count > 0)
                {
                    lbSwitchCabinetcol.SetSelected(0, true);
                    //var kgg = DevEventHandler.GetDevTables(198, dict[0]);
                    //GenerateHelper.SetAllReadOnly(kgg.DevObj,true);
                    //pgSwitchCabinet.SelectedObject = kgg.DevObj;
                }
                else
                {
                    AddSwitch_Click(null, null);
                }
                pgSwitchCabinet.Refresh();
                //更新开关柜里的开关状态
                UpdateDBEntity.UpdateSSKGG(entitys);
            }
            catch (Exception ex)
            {
                LogManager.Instance.Error(ex);
            }
            //finally
            //{
            //    //删除完成后清空填写了所属开关柜字段为当前开关柜的设备字段值
            //    var entities = DBManager.Instance.GetEntities<Gg_pd_gnwzmc_n>(o=>o.GNWZ_SSKGG==deleteFid.ToString());
            //    if (entities.Any())
            //    {
            //        foreach (var item in entities)
            //        {
            //            item.GNWZ_SSKGG = null;
            //            if (item.EntityState == EntityState.None)
            //                item.EntityState = EntityState.Update;
            //            DBManager.Instance.Update(item);
            //        }
            //    }
            //}
        }
Esempio n. 16
0
 private void treeViewDevLayer_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
 {
     if (e.Button != MouseButtons.Left)
     {
         return;
     }
     if (e.Node.Parent != null)
     {
         if (!String.IsNullOrEmpty(e.Node.Text))
         {
             LvEntity.Items.Clear();
             //搜索出符合当前层的所有设备
             var entInCurLayer = entities.Where(o => o.Value.Layer.Equals(e.Node.Text)).Select(o => o.Key);
             int index         = 1;
             CurrentLayerFeatures.Clear();
             foreach (var item in entInCurLayer)
             {
                 G3EObject objIds = new G3EObject();
                 if (DBEntityFinder.Instance.GetG3EIds(item, ref objIds))
                 {
                     var tables = DevEventHandler.GetDevTables(objIds.G3E_FNO, objIds.G3E_FID);
                     if (tables != null)
                     {
                         //更新的情况比较特殊,可能只更新一个表
                         string sbmc = string.Empty;
                         string ssdw = string.Empty;
                         string ssxl = string.Empty;
                         if (tables.ComObj == null)
                         {
                             if (objIds.G3E_FNO == 159) //集中抄表箱//散户表
                             {
                                 if (tables.SelfObj != null)
                                 {
                                     if (tables.SelfObj.HasAttribute("HH") &&
                                         tables.SelfObj.GetAttribute("HH") != null)
                                     {
                                         sbmc = tables.SelfObj.GetAttribute("HH");
                                     }
                                     if (tables.SelfObj.HasAttribute("CD_SSXL") &&
                                         tables.SelfObj.GetAttribute("CD_SSXL") != null)
                                     {
                                         ssxl = tables.SelfObj.GetAttribute("CD_SSXL");
                                     }
                                     if (tables.SelfObj.HasAttribute("CD_SSDW") &&
                                         tables.SelfObj.GetAttribute("CD_SSDW") != null)
                                     {
                                         ssdw = tables.SelfObj.GetAttribute("CD_SSDW");
                                     }
                                 }
                             }
                             else if (objIds.G3E_FNO == 188) //负控
                             {
                                 if (tables.GnwzObj != null && tables.GnwzObj.HasAttribute("MC") && tables.GnwzObj.GetAttribute("MC") != null)
                                 {
                                     sbmc = tables.GnwzObj.GetAttribute("MC");
                                 }
                                 if (tables.SelfObj != null && tables.SelfObj.HasAttribute("CD_SSDW") && tables.SelfObj.GetAttribute("CD_SSDW") != null)
                                 {
                                     ssdw = tables.SelfObj.GetAttribute("CD_SSDW");
                                 }
                             }
                         }
                         else
                         {
                             sbmc = tables.ComObj.SBMC;
                             ssxl = tables.ComObj.CD_SSXL;
                             ssdw = tables.ComObj.CD_SSDW;
                         }
                         var featureItem = new FeatureFixedItem
                         {
                             BH    = index.ToString(),
                             FID   = objIds.G3E_FID.ToString(),
                             SBMC  = sbmc,
                             SDKX  = ssxl,
                             SSGDJ = ssdw
                         };
                         if (CurrentLayerFeatures.Any())
                         {
                             var value = CurrentLayerFeatures.Where(o => o.FID == featureItem.FID);
                             if (!value.Any())
                             {
                                 CurrentLayerFeatures.Add(featureItem);
                             }
                         }
                         else
                         {
                             CurrentLayerFeatures.Add(featureItem);
                         }
                     }
                 }
             }
             AddListViewItem();
         }
     }
 }
Esempio n. 17
0
        /// <summary>
        /// 更新指定的实体属性
        /// </summary>
        /// <param name="values"></param>
        /// <param name="objDev"></param>
        /// <param name="flag">是否是批量修改公共表</param>
        private void UpdateAttribute(RequiredDevTables values, XProps objDev, bool flag)
        {
            try
            {
                DCadApi.isModifySymbol = true;

                #region

                if (values.Fno == 148)
                {
                    var    currentAzwz = GenerateHelper.GetPropertyValue(objDev, GenerateHelper.GetGnwzTableNameByFno(148), "GNWZ_FL2");
                    string oldAzwz     = string.Empty;
                    if (values.GnwzObj != null)
                    {
                        oldAzwz = values.GnwzObj.GNWZ_FL2;
                    }
                    //安装位置由非台架变成台架
                    if (currentAzwz != null && currentAzwz.ToString().Equals("台架"))
                    {
//以前是台架只需更新
                        if (oldAzwz.Equals("台架"))
                        {
                            RefAttribute(objDev, values, 148, flag);
                            //因为都是台架所以更新完148后还要更新199,
                            long tjFid = 0;
                            if (values.GnwzObj != null && long.TryParse(values.GnwzObj.GNWZ_SSTJ, out tjFid))
                            {
                                var tjTables = DevEventHandler.GetDevTables(199, tjFid);
                                RefAttribute(objDev, tjTables, 199, flag);
                            }
                        }
                        else //以前为空或不是台架
                        {
                            //先添加一条台架记录
                            //注意在添加新的台架数据之前先看看有没有对应的原始的台架数据(即被标记为Delete的数据)
                            try
                            {
                                var tj =
                                    DBManager.Instance.GetEntity <Gg_gz_tj_n>(o => o.HasAttribute("GNWZ_FID") && o.GNWZ_FID != null && o.GNWZ_FID.Equals(values.Fid.ToString()));
                                if (tj != null)
                                {
                                    tj.EntityState = EntityState.Update;
                                    tj.IsErased    = false;
                                    DBManager.Instance.Update(tj);
                                    var tjcom = DBManager.Instance.GetEntity <Common_n>(tj.G3E_FID);
                                    if (tjcom != null)
                                    {
                                        tjcom.EntityState = EntityState.Update;
                                        tjcom.IsErased    = false;
                                        DBManager.Instance.Update(tjcom);
                                    }
                                    var tjGnwz = DBManager.Instance.GetEntity <Gg_pd_gnwzmc_n>(tj.G3E_FID);
                                    if (tjGnwz != null)
                                    {
                                        tjGnwz.EntityState = EntityState.Update;
                                        tjGnwz.IsErased    = false;
                                        DBManager.Instance.Update(tjGnwz);
                                    }
                                    GenerateHelper.Unrf.tjFid = tj.G3E_FID.ToString();
                                    var tjTables = DevEventHandler.GetDevTables(199, tj.G3E_FID);
                                    RefAttribute(objDev, tjTables, 199, flag);
                                }
                                else
                                {
                                    var tjRes = DCadApi.AddAttribute(objDev, 199, values.Fid);
                                    GenerateHelper.Unrf.tjFid = tjRes.G3eFid;
                                }
                            }
                            catch (NotExistException ex)
                            {
                                var tjRes = DCadApi.AddAttribute(objDev, 199, values.Fid);
                                GenerateHelper.Unrf.tjFid = tjRes.G3eFid;
                            }
                            RefAttribute(objDev, values, 148, flag);
                        }
                    } //安装位置由台架变成非台架
                    else if (currentAzwz == null || !currentAzwz.ToString().Equals("台架"))
                    {
                        //以前是台架只需删除
                        if (oldAzwz.Equals("台架"))
                        {
                            //先删除台架数据
                            DBEntityErased.Instance.ErasedTjDBEntity(values.ComObj.G3E_FID, new List <DBEntity>());
                            //把变压器的GNWZ_SSTJ变成null
                            GenerateHelper.Unrf.tjFid = null;
                            //GenerateHelper.SetPropertyValue(objDev, "GNWZ_SSTJ", null);
                            if (values.GnwzObj != null)
                            {
                                values.GnwzObj.GNWZ_SSTJ = null;
                            }
                            RefAttribute(objDev, values, 148, flag);
                        }
                        else
                        {
                            RefAttribute(objDev, values, 148, flag);
                        }
                    }
                }
                else
                {
                    RefAttribute(objDev, values, values.Fno, flag);
                }
                UpdataShbAdnJlbValue(values.Fno, values.Fid);
                #endregion
            }
            catch (Exception ex)
            {
                LogManager.Instance.Error(ex);
            }
            finally
            {
                DCadApi.isModifySymbol = false;
            }
        }
Esempio n. 18
0
        /// <summary>
        /// 更新公共属性
        /// </summary>
        public UpdataResult UpdataCommonAttribute(ref List <BulkChangeEnt> Current, XProps objDev)
        {
            UpdataResult ur = new UpdataResult();

            try
            {
                DCadApi.isModifySymbol = true;

                foreach (var ent in Current)
                {
                    try
                    {
                        //查看是否有没有公共属性表
                        var simpleEntry = DeviceAttributeConfig.Instance.Attributes.SingleOrDefault(o => o.Fno == ent.SingleG3EObject.G3E_FNO);
                        if (simpleEntry != null)
                        {
                            if (!simpleEntry.Common.PropertiesFromTable.Any())
                            {
                                ur.UpdataFailedNum++;
                                ur.UpdataErrorLog.AppendLine(ent.SingleG3EObject.G3E_FID.ToString() + "没有公共属性表");
                                continue;
                            }
                        }
                    }
                    catch (Exception)
                    {
                        ur.UpdataFailedNum++;
                        //ur.UpdataErrorLog.AppendLine("CAD实体查找错误,ObjectID="+ent.SingleG3EObject.G3E_FID);
                    }

                    #region
                    try
                    {
                        var value = DevEventHandler.GetDevTables(ent.SingleG3EObject.G3E_FNO, ent.SingleG3EObject.G3E_FID);
                        if (value.DevObj != null)
                        {
                            PartialCopy(objDev, value.DevObj);

                            //查找看看该设备是否有符号,有的就要根据属性更新符号
                            ObjectId objId = DBEntityFinder.Instance.GetObjectIdByFid(ent.SingleG3EObject.G3E_FID);
                            if (objId.IsNull)
                            {
                                UpdateAttribute(value, value.DevObj, true);
                                ur.UpdataSucceedNum++;
                            }
                            else
                            {
                                ObjectId newObjId = ObjectId.Null;
                                bool     isUpdate = DCadApi.UpdateSymbol(objId, value.DevObj, out newObjId);
                                if (isUpdate)
                                {
                                    UpdateAttribute(value, value.DevObj, true);
                                    ur.UpdataSucceedNum++;
                                }
                                else
                                {
                                    //存放更新失败的设备
                                    ur.UpdataFailedNum++;
                                    ur.UpdataErrorLog.AppendLine("Fid=" + ent.SingleG3EObject.G3E_FID + "的设备更新失败 ");
                                }
                            }
                        }
                    }
                    catch (Exception)
                    {
                        ur.UpdataFailedNum++;
                        ur.UpdataErrorLog.AppendLine("Fid=" + ent.SingleG3EObject.G3E_FID + "的设备更新失败 ");
                    }
                    PublicMethod.Instance._isSelectedEntityChoice = false;
                    #endregion
                }
            }
            catch (Exception ex)
            {
                LogManager.Instance.Error(ex);
            }
            finally
            {
                DCadApi.isModifySymbol = false;
            }
            return(ur);
        }
Esempio n. 19
0
        private void btSync_Click(object sender, EventArgs e)
        {
            btSync.Enabled = false;
            lbShowSyncData.Refresh();
            LoadNecessarySyncDev();
            if (lbShowSyncData.Items.Count > 0)
            {
                lbShowSyncData.Items.Clear();
            }
            lbShowSyncData.Items.Add("开始同步");
            lbShowSyncData.Refresh();
            WebClient webClient = new WebClient();
            int       index     = 1;//上面已经占用了一个位置

            foreach (var item in recordSyncData)
            {
                try
                {
                    string syncDataUrl    = string.Empty;
                    var    syncDataTables = DevEventHandler.GetDevTables(item.G3E_FNO, item.G3E_FID);
                    if (syncDataTables == null)
                    {
                        var str = string.Format("FID={0}的设备数据获取失败", item.G3E_FID);
                        recorDictionary.Add(index, new ItemOfData()
                        {
                            Fid = item.G3E_FID, Index = index, SyncResult = str, RDT = null
                        });
                        lbShowSyncData.Items.Add(str);
                        continue;
                    }
                    if (CommonHelp.Instance.IsInsertDevice(item.G3E_FNO, item.G3E_FID))
                    {
                        syncDataUrl =
                            string.Format(
                                " http://localhost:9090/emmis/equipGisMappingTemp/cadRestful/synchAttributeToCAD.gis?g3e_fid=a{0}&g3e_fno={1}",
                                item.G3E_FID, item.G3E_FNO);
                    }
                    else
                    {
                        syncDataUrl =
                            string.Format(
                                " http://localhost:9090/emmis/equipGisMappingTemp/cadRestful/synchAttributeToCAD.gis?g3e_fid={0}&g3e_fno={1}",
                                item.G3E_FID, item.G3E_FNO);
                    }
                    byte[] redata = new byte[] { };
                    try
                    {
                        redata = webClient.DownloadData(syncDataUrl);
                    }
                    catch (WebException ex)
                    {
                        lbShowSyncData.Items.Add("下载台账数据失败");
                        return;
                    }
                    string syncRes = System.Text.Encoding.UTF8.GetString(redata);
                    if (string.IsNullOrEmpty(syncRes.Trim()))
                    {
                        var str = string.Format("FID={0}的设备缺少台账录入...", item.G3E_FID);
                        recorDictionary.Add(index, new ItemOfData()
                        {
                            Fid = item.G3E_FID, Index = index, SyncResult = str, RDT = syncDataTables
                        });
                        lbShowSyncData.Items.Add(str);
                        continue;
                    }
                    var tzValues = GetSyncData(syncRes);
                    //开始同步数据
                    if (tzValues.Any())
                    {
                        ShowSyncResultToListBox(index, tzValues, syncDataTables);
                        if (item.G3E_FNO == 148 && syncDataTables.GnwzObj != null)
                        {
                            var azwzValue = GenerateHelper.GetCurrentEntityAzwzByFidAndFno(syncDataTables.Fid, syncDataTables.Fno);
                            if (azwzValue != null && azwzValue.ToString().Equals("台架"))
                            {
                                if (syncDataTables.GnwzObj.HasAttribute("GNWZ_SSTJ"))
                                {
                                    var  tj    = syncDataTables.GnwzObj.GNWZ_SSTJ;
                                    long tjFid = 0;
                                    if (long.TryParse(tj, out tjFid))
                                    {
                                        var value = DevEventHandler.GetDevTables(199, tjFid);
                                        ShowSyncResultToListBox(index, tzValues, value);
                                    }
                                }
                            }
                        }
                    }
                    //更新标注
                    SymbolLabel.ShowSymbolLabel(item.G3E_FNO, item.G3E_FID);
                }
                catch
                {
                }
                finally
                {
                    index++;
                    lbShowSyncData.Refresh();
                }
            }
            lbShowSyncData.Items.Add("同步完成.");
        }