Пример #1
0
        /// <summary>
        /// Construit les objets de domaine.
        /// </summary>
        /// <param name="domainsDefinition">Le noeud XML de définition des domaines.</param>
        /// <param name="elementsExtension">Le noeud XML contenant les extentions d'éléments.</param>
        /// <param name="modelFile">Fichier modèle.</param>
        private void BuildModelDomains(XmlNode domainsDefinition, XmlNode elementsExtension, string modelFile)
        {
            foreach (XmlNode domainNode in domainsDefinition.ChildNodes)
            {
                string  id = domainNode.Attributes[PropertyId].Value;
                XmlNode domaineExtensionNode = elementsExtension.SelectSingleNode(string.Format(NodeElementByIdRef, id), _currentNsManager);

                string persistentDataType = domaineExtensionNode.SelectSingleNode(NodeProperties, _currentNsManager).Attributes[PropertyAlias].Value;
                int?   persistentLength   = null;
                if (_regexPersistentLength.IsMatch(persistentDataType))
                {
                    persistentLength = int.Parse(_regexPersistentLength.Replace(persistentDataType, "$1"));
                }

                int?persistentPrecision = null;
                if (_regexPersistentPrecision.IsMatch(persistentDataType))
                {
                    persistentPrecision = int.Parse(_regexPersistentPrecision.Replace(persistentDataType, "$1"));
                }

                ModelDomain domaine = new ModelDomain()
                {
                    Name                = domainNode.Attributes[PropertyName].Value,
                    ModelFile           = modelFile,
                    Code                = domainNode.Attributes[PropertyName].Value,
                    DataType            = domaineExtensionNode.SelectSingleNode(NodeProperties, _currentNsManager).Attributes[PropertyStereotype].Value,
                    PersistentDataType  = persistentDataType,
                    PersistentLength    = persistentLength,
                    PersistentPrecision = persistentPrecision,
                    Model               = _currentModelRoot
                };
                _currentModelRoot.AddDomain(id, domaine);
                CheckDomain(domaine);
            }
        }
Пример #2
0
 /// <summary>
 /// Create general unit movement iterator for an existing or hypothetical unit.
 /// </summary>
 /// <param name="empire">empire</param>
 /// <param name="nation">nation of the unit</param>
 /// <param name="origin">initial unit location</param>
 /// <param name="domain">unit domain</param>
 /// <param name="unitSpeed">speed of the unit</param>
 /// <param name="initialMovementLeft">initial movement points left</param>
 /// <param name="options">options</param>
 public TravelSprawl(AEmpire empire, Nation nation, Location origin, ModelDomain domain, int unitSpeed, int initialMovementLeft, Options options)
     : base(empire, origin, unitSpeed - initialMovementLeft)
 {
     this.domain  = domain;
     this.speed   = unitSpeed;
     this.options = options;
     if (nation != empire.Us)
     {
         options |= Options.EmptyPlanet;                 // default location info relates to own nation, so it can't be considered then
     }
     if (nation.HasWonder(Building.ShinkansenExpress))
     {
         options |= Options.ZeroCostRailroad;
     }
     if (nation.HasWonder(Building.HangingGardens))
     {
         options |= Options.TerrainResistant;
     }
     baseDifficultMoveCost = 100 + (unitSpeed - 150) / 5;
     if ((options & Options.ZeroCostRailroad) != 0)
     {
         baseRailroadMoveCost = 0;
     }
     else
     {
         baseRailroadMoveCost = (unitSpeed / 50) * 4;
     }
 }
Пример #3
0
        /// <summary>
        /// Effectue les vérifications de cohérence sur les domaines.
        /// </summary>
        /// <param name="item">L'élément testé.</param>
        protected void CheckDomain(ModelDomain item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            bool found = false;

            foreach (IDomain domain in DomainList)
            {
                if (domain.Name == item.Code)
                {
                    found = true;
                    if (item.PersistentLength != null && domain.Length > item.PersistentLength)
                    {
                        AddLengthDomainError(item, domain);
                    }

                    if (!ParserHelper.IsSameDataType(domain.DataType, item.DataType))
                    {
                        AddDataTypeDomainError(item, domain);
                    }
                }
            }

            if (!found && item.Code != DomainManager.AliasDomain)
            {
                AddUnknownDomainError(item);
            }
        }
Пример #4
0
        /// <summary>
        /// Enregistre le dommaine.
        /// </summary>
        /// <param name="domaine">Le domaine a enregistrer.</param>
        /// <returns>Retourne <code>false</code> si le domaine est déja enregistré.</returns>
        public bool RegisterDomain(ModelDomain domaine)
        {
            if (DomainList.ContainsKey(domaine.Code))
            {
                return(false);
            }

            DomainList.Add(domaine.Code, domaine);
            return(true);
        }
Пример #5
0
 /// <summary>
 /// Get the model mapped to by the given ModelDomain key.
 /// </summary>
 /// <param name="domain">
 ///          The ModelDomain object which keys to the desired model. </param>
 /// <returns> The MaxentModel corresponding to the given domain. </returns>
 public virtual MaxentModel getModel(ModelDomain domain)
 {
     if (map.ContainsKey(domain))
     {
         return(map[domain]);
     }
     else
     {
         throw new NoSuchElementException("No model has been created for " + "domain: " + domain);
     }
 }
Пример #6
0
 /// <summary>
 /// Set domain of model. Do this before setting properties.
 /// </summary>
 /// <param name="domain">the domain</param>
 /// <returns>result of operation</returns>
 public PlayResult SetDomain__Turn(ModelDomain domain)
 {
     if (theEmpire.Researching == Advance.MilitaryResearch)
     {
         return(new PlayResult(PlayError.ResearchInProgress));
     }
     else
     {
         return(theEmpire.Play(Protocol.sCreateDevModel, (int)domain));
     }
 }
Пример #7
0
 protected void AddLengthDomainError(ModelDomain item, IDomain domain)
 {
     ErrorList.Add(new NVortexMessage()
     {
         Category    = Category.Error,
         IsError     = true,
         Description = "Le domain " + item.Code + " définit une longueur différente (" + item.PersistentLength + " < " + domain.Length + ") de celle de la factory.",
         FileName    = item.Model.ModelFile,
         Code        = "LENGTH_DIVERGENT_DOMAIN"
     });
 }
Пример #8
0
 protected void AddUnknownDomainError(ModelDomain item)
 {
     ErrorList.Add(new NVortexMessage()
     {
         Category    = Category.Error,
         IsError     = true,
         Description = "Le domaine " + item.Code + " n'existe pas dans la Factory.",
         FileName    = item.Model.ModelFile,
         Code        = "UNKNOWN_DOMAIN"
     });
 }
Пример #9
0
        public MainForm()
        {
            InitializeComponent();
            _cargoDomain = this.Get <ModelDomain <Cargo> >();
            _vagaDomain  = this.Get <ModelDomain <VagaRemocao> >();

            foreach (var cargo in _cargoDomain.Get())
            {
                addCargo(cargo.Id, cargo.Abreviacao);
            }
        }
Пример #10
0
 protected void AddDataTypeDomainError(ModelDomain item, IDomain domain)
 {
     ErrorList.Add(new NVortexMessage()
     {
         Category    = Category.Error,
         IsError     = true,
         Description = "Le domaine " + item.Code + " définit un type " + item.DataType + " différent de la Factory (" + domain.DataType.ToString() + ")",
         FileName    = item.Model.ModelFile,
         Code        = "DATA_TYPE_DIVERGENT_DOMAIN"
     });
 }
Пример #11
0
        }                                           //Unidades que já tem vagas no banco

        public UnidadesForm()
        {
            InitializeComponent();
            _unidadeDomain = this.Get <ModelDomain <Unidade> >();

            if (_unidades == null || _unidades.Count == 0)
            {
                var ano = DateTime.Now.Year;
                var mes = DateTime.Now.Month;

                _unidades = _unidadeDomain.Get().Where(a => !a.Vagas.Any(b => b.Data.Year == ano && b.Data.Month == mes))
                            .ToDictionary(a => a.Id, a => a.Id + " - " + a.TipoUnidade.Tipo + " - " + a.Nome);
            }

            Listar();
        }
Пример #12
0
        static void Main(string[] args)
        {
            _unidadeDomain = _lifeTimeScope.Resolve <ModelDomain <Unidade> >();
            _vagaDomain    = _lifeTimeScope.Resolve <ModelDomain <VagaRemocao> >();
            _cargoDomain   = _lifeTimeScope.Resolve <ModelDomain <Cargo> >();

            _cargos              = _cargoDomain.Get().ToArray();
            _unidadeDictionary   = _unidadeDomain.Get().ToDictionary(a => a.Id, a => a.Nome.ReplaceDiacritics().ToUpper());
            _unidadeDoDictionary = _unidadeDomain.Get().Where(a => a.NomeDiarioOficial != null).ToDictionary(a => a.Id, a => a.NomeDiarioOficial.ReplaceDiacritics().ToUpper());

            //Passo 1: Analisar unidades e cargos extraidos
            ExecutarAnalise(false, true);
            //Passo 2: Testar TXT e checar pendencias negativas
            //var vagas = TestarTxtFinal();
            //Passo 3: Salvar vagas - ATENÇÃO: Só executar esse passo se tiver certeza que a analise e testes estão corretos
            //Processar(vagas);
        }
Пример #13
0
        /// <summary>
        /// Vérifie l'intégrité du domaine.
        /// </summary>
        /// <param name="objet">Le domaine à vérifier.</param>
        public override void Check(IModelObject objet)
        {
            ModelDomain domaine = objet as ModelDomain;

            Debug.Assert(domaine != null, "Le domaine est null.");
            if (string.IsNullOrEmpty(domaine.Code))
            {
                RegisterBug(domaine, "Le code du domaine n'est pas renseigné.");
            }

            if (!IsDomaineNameValid(domaine.Code))
            {
                RegisterCodeStyle(domaine, "Le code de la classe est mal formaté.");
            }

            if (!RegisterDomain(domaine))
            {
                RegisterBug(domaine, "Le domaine existe déjà.");
            }
        }
Пример #14
0
 /// <summary>
 /// Vérifie le domaine de la propriété.
 /// </summary>
 /// <param name="property">La propriété en question.</param>
 private static void CheckDomain(ModelProperty property)
 {
     if (property.DataDescription.Domain == null && property.IsPrimitive)
     {
         RegisterBug(property.Class, "La propriété [" + property.Name + "] est de type primitif et n'a pas de domaine.");
     }
     else if (property.DataDescription.Domain != null)
     {
         if (!ModelDomainChecker.Instance.DomainList.ContainsKey(property.DataDescription.Domain.Code))
         {
             RegisterBug(property.Class, "Le domaine de la propriété [" + property.Name + "] n'existe pas.");
         }
         else
         {
             ModelDomain domaine = ModelDomainChecker.Instance.DomainList[property.DataDescription.Domain.Code];
             if (!domaine.DataType.Equals(property.DataType) && !("ICollection<" + domaine.DataType + ">").Equals(property.DataType))
             {
                 RegisterBug(property.Class, "Le datatype de la propriété [" + property.Name + "] ne correspond pas au datatype du domaine [" + domaine.Code + "].");
             }
         }
     }
 }
Пример #15
0
        /// <summary>
        /// Adds Data to a collection with a supplied domain
        /// </summary>
        /// <param name="collectionName">Name of the collection to add data too</param>
        /// <param name="labeledData">list of labeled data points</param>
        /// <param name="domain">the model domain to be used</param>
        /// <returns>True if successful</returns>
        public async Task <bool> AddData(string collectionName, List <CollectionData> labeledData, ModelDomain domain)
        {
            AddDataRequest requestBody = new AddDataRequest(APIKey, collectionName, domain, labeledData);

            return(await PerformAddData(requestBody));
        }
Пример #16
0
 public AddDataRequest(string apiKey, string collectionName, ModelDomain domain, List <CollectionData> data) : base(apiKey, collectionName)
 {
     Domain      = domain;
     LabeledData = data;
 }
Пример #17
0
 public async Task <bool> AddCustomCollectionData(string collectionName, List <CollectionData> labeledData, ModelDomain collectionDomain = ModelDomain.Standard)
 {
     return(await customApiClient.AddData(collectionName, labeledData, collectionDomain));
 }
Пример #18
0
        private void BuildClassProperties(ModelClass classe, XmlNode classNode, XmlNode classExtensionNode, string modelFile)
        {
            ICollection <string> pkRefList = GetClassPrimaryKeysIdList(classExtensionNode);
            XmlNode attributesNode         = classExtensionNode.SelectSingleNode(NodeAttributes, _currentNsManager);

            if (attributesNode != null)
            {
                foreach (XmlNode propertyNode in attributesNode.ChildNodes)
                {
                    string propertyId        = propertyNode.Attributes[PropertyIdRef].Value;
                    string styleEx           = propertyNode.SelectSingleNode(PropertyStyleEx, _currentNsManager).Attributes[PropertyValue].Value;
                    bool   isPersistent      = "0".Equals(_regexPropertyPersistance.Replace(styleEx, "$1"));
                    string multiplicityLower = propertyNode.SelectSingleNode(NodeBounds, _currentNsManager).Attributes[PropertyMultiplicityLower].Value;
                    string multiplicityUpper = propertyNode.SelectSingleNode(NodeBounds, _currentNsManager).Attributes[PropertyMultiplicityUpper].Value;
                    if ("-1".Equals(multiplicityUpper))
                    {
                        multiplicityUpper = "*";
                    }

                    string      multiplicity = multiplicityLower + ".." + multiplicityUpper;
                    ModelDomain domain       = GetDomainByCode(propertyNode.SelectSingleNode(NodeProperties, _currentNsManager).Attributes[PropertyType].Value);

                    XmlAttribute stereotypeAttribute = propertyNode.SelectSingleNode(NodeStereotype, _currentNsManager).Attributes[PropertyStereotype];
                    XmlNode      uniqueNode          = propertyNode.SelectSingleNode(NodeTagUnique, _currentNsManager);

                    ModelProperty property = new ModelProperty()
                    {
                        Name            = propertyNode.SelectSingleNode(NodeStyle, _currentNsManager).Attributes[PropertyValue].Value,
                        Comment         = propertyNode.SelectSingleNode(NodeComment, _currentNsManager).Attributes[PropertyValue].Value,
                        IsPersistent    = isPersistent,
                        IsUnique        = uniqueNode != null,
                        DataType        = domain.DataType,
                        Stereotype      = (stereotypeAttribute == null) ? string.Empty : stereotypeAttribute.Value,
                        Class           = classe,
                        ModelFile       = modelFile,
                        DataDescription = new ModelDataDescription()
                        {
                            Libelle      = propertyNode.Attributes[PropertyName].Value,
                            Domain       = domain,
                            IsPrimaryKey = pkRefList.Contains(propertyId)
                        }
                    };

                    if (!ParserHelper.IsPrimitiveType(property.DataType))
                    {
                        RegisterError(Category.Error, "Propriété " + classe.Name + "." + property.Name + " : le type de la propriété " + property.DataType + " n'est pas primitif, il faut utiliser les liens de composition.");
                        continue;
                    }

                    string dataMemberName = string.Empty;
                    if (property.IsPersistent)
                    {
                        if (property.DataDescription.IsPrimaryKey)
                        {
                            classe.Trigram = property.DataDescription.Libelle;
                        }

                        string  columnName     = null;
                        XmlNode columnNameNode = propertyNode.SelectSingleNode(NodeTagColumnName, _currentNsManager);
                        if (columnNameNode != null)
                        {
                            columnName = columnNameNode.Attributes[PropertyValue].Value;
                        }

                        if (string.IsNullOrEmpty(columnName))
                        {
                            XmlNode columnTypeNode = propertyNode.SelectSingleNode(NodeTagColumnType, _currentNsManager);
                            string  columnType     = string.Empty;
                            if (columnTypeNode != null)
                            {
                                columnType = columnTypeNode.Attributes[PropertyValue].Value;
                            }

                            if (property.DataDescription.IsPrimaryKey)
                            {
                                columnName = columnType + classe.Name;
                            }
                            else
                            {
                                columnName = columnType + property.Name;
                            }
                        }

                        dataMemberName = columnName;
                    }

                    property.DataMember = new ModelDataMember()
                    {
                        Name       = dataMemberName,
                        IsRequired = multiplicity != null && Multiplicity11.Equals(multiplicity)
                    };
                    if (property.DataDescription.IsPrimaryKey || !string.IsNullOrEmpty(property.DataDescription.ReferenceType))
                    {
                        property.DataDescription.Libelle = property.Name;
                    }

                    classe.AddProperty(property);

                    if (!string.IsNullOrEmpty(property.Stereotype) && property.Stereotype != StereotypeDefaultProperty && property.Stereotype != StereotypePrimaryKey)
                    {
                        RegisterError(Category.Error, "Propriété " + classe.Name + "." + property.Name + " : seul les stéréotypes '" + StereotypeDefaultProperty + "' et '" + StereotypePrimaryKey + "' sont acceptés.");
                    }
                }
            }
        }
Пример #19
0
 /// <summary>
 /// Sets the model for the given domain.
 /// </summary>
 /// <param name="domain">
 ///          The ModelDomain object which keys to the model. </param>
 /// <param name="model">
 ///          The MaxentModel trained for the domain. </param>
 public virtual void setModelForDomain(ModelDomain domain, MaxentModel model)
 {
     map[domain] = model;
 }
Пример #20
0
 /// <summary>
 /// Removes the mapping for this ModelDomain key from this map if present.
 /// </summary>
 /// <param name="domain">
 ///          The ModelDomain key whose mapping is to be removed from the map. </param>
 public virtual void removeDomain(ModelDomain domain)
 {
     map.Remove(domain);
 }