public string updateCustomObjPropbyPropName(VDF.Vault.Currency.Connections.Connection connection, string PropName, long entID, string ObjType, object value) //CUSTENT
        {
            try
            {
                using (WebServiceManager serviceManager = connection.WebServiceManager) //using will log out after usage
                {
                    var propDefs = getPropertyDefDetails(connection, ObjType, PropName);
                    CES = connection.WebServiceManager.CustomEntityService;
                    //check value format
                    List <long> entitiesList = new List <long>();
                    entitiesList.Clear();
                    entitiesList.Add(entID);
                    CES.UpdateCustomEntityProperties(entitiesList.ToArray(), new PropInstParamArray[] { new PropInstParamArray()
                                                                                                        {
                                                                                                            Items = new PropInstParam[] { new PropInstParam()
                                                                                                                                          {
                                                                                                                                              PropDefId = propDefs.Id, Val = value
                                                                                                                                          } }
                                                                                                        } });
                    result = propDefs.DispName + " | " + propDefs.IsSys + " | " + propDefs.Typ + " | " + propDefs.Id;
                }
            }
            catch (SystemException ex)
            {
                result = ex.ToString();
            }

            return(result);
        }
        public static CustEntDef getCustomObjDefbyName(VDF.Vault.Currency.Connections.Connection connection, string custObjDefName)
        {
            CustEntDef cDef = new CustEntDef();

            try
            {
                CES = connection.WebServiceManager.CustomEntityService;
                CustEntDef[] ceDefs = CES.GetAllCustomEntityDefinitions();
                //MessageBox.Show("inside,," + ceDefs.ToList().Count);
                foreach (var ceDef in ceDefs)
                {
                    //MessageBox.Show(custObjDefName + " --" + ceDef.Id.ToString() + " | " + ceDef.DispName);
                    if (ceDef.DispName.Equals(custObjDefName))
                    {
                        //MessageBox.Show(ceDef.Id.ToString() + " | | ||" + ceDef.DispName);
                        cDef = ceDef;
                    }
                }
            }
            catch (SystemException ex)
            {
                MessageBox.Show(ex.ToString());
            }
            return(cDef);
        }
 public Dictionary <long, string> getCustomObjDefs(VDF.Vault.Currency.Connections.Connection connection)
 {
     CES = connection.WebServiceManager.CustomEntityService;
     CustEntDef[] ceDefs = CES.GetAllCustomEntityDefinitions();
     foreach (var ceDef in ceDefs)
     {
         cDefDict.Add(ceDef.Id, ceDef.DispName.ToString());
     }
     return(cDefDict);
 }
        public static Dictionary <string, CustEntDef> getCustomObjDefs(VDF.Vault.Currency.Connections.Connection connection)
        {
            Dictionary <string, CustEntDef> cDefDictColl = new Dictionary <string, CustEntDef>();

            try
            {
                CES = connection.WebServiceManager.CustomEntityService;
                CustEntDef[] ceDefs = CES.GetAllCustomEntityDefinitions();
                foreach (var ceDef in ceDefs)
                {
                    cDefDictColl.Add(ceDef.DispName.ToString(), ceDef);
                }
            }
            catch (SystemException ex)
            {
            }
            return(cDefDictColl);
        }
Exemple #5
0
        public void CreateABlock()
        {
            try
            {
                var pdo = new PromptDoubleOptions("Informe a altura da parede: ")
                {
                    AllowNegative = false,
                    AllowNone     = false,
                    AllowZero     = false,
                    DefaultValue  = 2.80
                };

                PromptDoubleResult pdr;

                do
                {
                    pdr = _editor.GetDouble(pdo);

                    if (pdr.Status == PromptStatus.Cancel)
                    {
                        return;
                    }

                    if (pdr.Status == PromptStatus.OK)
                    {
                        var altura        = pdr.Value;
                        var namesOfBlocks = Enum.GetNames(typeof(TipoBloco));
                        var pko           = new PromptKeywordOptions("")
                        {
                            AllowNone = false,
                            Message   = "Enter an option "
                        };

                        foreach (var name in namesOfBlocks)
                        {
                            pko.Keywords.Add(name);
                        }

                        var pr = _editor.GetKeywords(pko);

                        if (pr.Status == PromptStatus.OK)
                        {
                            var blk     = new BlockRepository <Entity, AttributeDefinition>();
                            var tipBloc = (TipoBloco)Enum.Parse(typeof(TipoBloco), pr.StringResult, true);
                            using (var ces = new CustomEntityService())
                            {
                                var blockId = blk.Get(tipBloc.ToString());
                                if (blockId == ObjectId.Null)
                                {
                                    _editor.WriteMessage(
                                        $"\nBloco não existente.\nCriando bloco {tipBloc.ToString()}.");
                                    var(entities, attributes) = ces.GetEntitiesToBlock(tipBloc);
                                    blockId = blk.CreatingABlock(tipBloc.ToString(), entities, attributes,
                                                                 new Point3d(0, 0.07, 0));
                                }

                                if (blockId != ObjectId.Null)
                                {
                                    var pio = new PromptIntegerOptions("");
                                    pio.Keywords.Add("1 - Inserir um bloco");
                                    pio.Keywords.Add("2 - Inserir multiplos blocos");
                                    var op = _editor.GetInteger(pio);
                                    if (op.Status == PromptStatus.Cancel)
                                    {
                                        return;
                                    }
                                    if (op.Status == PromptStatus.OK)
                                    {
                                        PromptPointResult pPtRes;
                                        var pPtOpts = new PromptPointOptions("");
                                        switch (op.Value)
                                        {
                                        case 1:
                                            pPtOpts.Message = "\nInforme o ponto de inserção: ";
                                            pPtRes          = _editor.GetPoint(pPtOpts);
                                            if (pPtRes.Status == PromptStatus.Cancel)
                                            {
                                                return;
                                            }
                                            blk.InsertBlock(tipBloc.ToString(), pPtRes.Value, 0, altura);
                                            break;

                                        case 2:
                                            pPtOpts.Message = "\nInforme o ponto inicial: ";
                                            pPtRes          = _editor.GetPoint(pPtOpts);

                                            if (pPtRes.Status == PromptStatus.Cancel)
                                            {
                                                return;
                                            }
                                            var ptStart = pPtRes.Value;

                                            pPtOpts.Message      = "\nInforme o ponto final: ";
                                            pPtOpts.UseBasePoint = true;
                                            pPtOpts.BasePoint    = ptStart;
                                            pPtRes = _editor.GetPoint(pPtOpts);

                                            if (pPtRes.Status == PromptStatus.Cancel)
                                            {
                                                return;
                                            }

                                            var ptEnd          = pPtRes.Value;
                                            var tamanho        = CustomEntityService.GetDistanceBetweenTwoPoints(ptStart, ptEnd);
                                            var angulo         = CustomEntityService.GetAngleBetweenTwoPoints(ptStart, ptEnd);
                                            var blkComprimento = (double.Parse(tipBloc.ToString()
                                                                               .Split(new[] { "x" },
                                                                                      StringSplitOptions.RemoveEmptyEntries)
                                                                               .LastOrDefault() ??
                                                                               throw new InvalidOperationException(
                                                                                   "Operação de conversão inválida.")) + 1) /
                                                                 100;

                                            var dist = 0.0;
                                            do
                                            {
                                                var pointInsert = CustomEntityService.GetPolarPoints(ptStart, angulo, dist);
                                                blk.InsertBlock(tipBloc.ToString(), pointInsert, angulo, altura);
                                                dist += blkComprimento;
                                            } while (dist < tamanho);
                                            break;

                                        default:
                                            _editor.WriteMessage("Opção inválida.");
                                            return;
                                        }
                                    }
                                }
                            }
                        }
                    }
                } while (pdr.Status != PromptStatus.OK);
            }
            catch (ArgumentNullException ex)
            {
                _editor.WriteMessage(ex.Message);
            }
            catch (System.Exception ex)
            {
                _editor.WriteMessage(ex.Message);
            }
        }