private void FindPropertyModelCode(ModelCode property)
        {
            string[] props = (property.ToString()).Split('_');

            props[1] = props[1].TrimEnd('S');
            DMSType propertyCode = ModelResourcesDesc.GetTypeFromModelCode(property);
            // DMSType propertyCode = ModelCodeHelper.GetDMSTypeFromString(property);

            ModelCode mc;

            ModelCodeHelper.GetModelCodeFromString(propertyCode.ToString(), out mc);

            foreach (ModelCode modelCode in Enum.GetValues(typeof(ModelCode)))
            {
                if ((String.Compare(modelCode.ToString(), mc.ToString()) != 0) && (String.Compare(property.ToString(), modelCode.ToString()) != 0) && (String.Compare(props[1], modelCode.ToString())) == 0)
                {
                    DMSType type = ModelCodeHelper.GetTypeFromModelCode(modelCode);
                    if (type == 0)
                    {
                        FindChildren(modelCode);
                    }
                    else
                    {
                        childrenType = new List <ModelCode>();
                        childrenType.Add(modelCode);
                    }
                }
            }
        }
Esempio n. 2
0
        private List <ModelCode> NadjiTipove(ModelCode kodProp)
        {
            ModelResourcesDesc modResDes = new ModelResourcesDesc();

            //List<DMSType> tip = new List<DMSType>();

            string[] props = (kodProp.ToString()).Split('_');
            props[1] = props[1].TrimEnd('S');

            DMSType propertyCode = ModelResourcesDesc.GetTypeFromModelCode(kodProp);


            ModelCode mc;

            ModelCodeHelper.GetModelCodeFromString(propertyCode.ToString(), out mc);

            foreach (ModelCode modelCode in Enum.GetValues(typeof(ModelCode)))
            {
                if (String.Compare(props[1], modelCode.ToString()) == 0)
                {
                    DMSType type = ModelCodeHelper.GetTypeFromModelCode(modelCode);
                    if (type == 0)
                    {
                        tipovi = new List <ModelCode>();
                        List <DMSType> r = modResDes.GetLeaves(modelCode);
                        foreach (DMSType ff in r)
                        {
                            tipovi.Add(modResDes.GetModelCodeFromType(ff));
                        }
                    }
                    else
                    {
                        tipovi = new List <ModelCode>();
                        tipovi.Add(modelCode);
                    }
                }
            }


            return(new List <ModelCode>());
        }
Esempio n. 3
0
        public void SortOperations()
        {
            string message = String.Format("Sorting delta operations for delta with ID: {0}.", GetCompositeId(id));

            Logger.LogDebug(message);

            List <ResourceDescription> insertOpsOrdered = new List <ResourceDescription>();
            List <ResourceDescription> deleteOpsOrdered = new List <ResourceDescription>();
            int insertOpsOrderedNo = 0;
            int deleteOpsOrderedNo = 0;
            int indexOp            = 0;

            // pass through all given types
            for (int indexType = 0; indexType < Delta.ResourceDescs.TypeIdsInInsertOrder.Count; indexType++)
            {
                DMSType type = ModelResourcesDesc.GetTypeFromModelCode(Delta.ResourceDescs.TypeIdsInInsertOrder[indexType]);

                // pass through all insert operations
                // move operations with current type to list of ordered insert operations
                indexOp = 0;
                for (indexOp = 0; indexOp < insertOps.Count; indexOp++)
                {
                    if (insertOps[indexOp] != null && type == (DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(insertOps[indexOp].Id))
                    {
                        // add at the end of list of ordered insert operations
                        insertOpsOrdered.Add(insertOps[indexOp]);
                        insertOps[indexOp] = null;
                        insertOpsOrderedNo++;

                        // remove from the old non sorted list - ATTENTION: this turns to be VERY SLOW operation in case delta is BIG
                        ////insertOps.RemoveAt(indexOp);
                    }
                }

                // pass through all delete operations
                // move operations with current type to list of ordered delete operations
                indexOp = 0;
                for (indexOp = 0; indexOp < deleteOps.Count; indexOp++)
                {
                    if (deleteOps[indexOp] != null && type == (DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(deleteOps[indexOp].Id))
                    {
                        // add at the end of list of ordered delete operations
                        deleteOpsOrdered.Add(deleteOps[indexOp]);
                        deleteOps[indexOp] = null;
                        deleteOpsOrderedNo++;

                        // remove from the old non sorted list - ATTENTION: this turns to be VERY SLOW operation in case delta is BIG
                        ////deleteOps.RemoveAt(indexOp);
                    }
                }
            }

            // check if there are insert operations not covered by given data model types
            if (insertOps.Count != insertOpsOrderedNo)
            {
                // find type that is not specified in given list of types
                short typeNotDefined = 0;
                for (indexOp = 0; indexOp < insertOps.Count; indexOp++)
                {
                    if (insertOps[indexOp] != null)
                    {
                        typeNotDefined = (short)ModelCodeHelper.ExtractTypeFromGlobalId(insertOps[indexOp].Id);
                    }
                }

                message = String.Format("Failed to sort delta operations because there are some insert operations (count = {0}) whose type (e.g {1}) is not specified in the given list of types.", insertOps.Count - insertOpsOrderedNo, typeNotDefined);
                Logger.LogError(message);

                string exceptionMessage = String.Format("Invalid delta. Some insert operations (count = {0}) whose type (e.g {1}) is not correct.", insertOps.Count - insertOpsOrderedNo, typeNotDefined);
                throw new ModelException(ErrorCode.InvalidDelta, exceptionMessage);
            }

            // remember ordered insert operations
            insertOps = insertOpsOrdered;

            // check if there are delete operations not covered by given data model types
            if (deleteOps.Count != deleteOpsOrderedNo)
            {
                // find type that is not specified in given list of types
                short typeNotDefined = 0;
                for (indexOp = 0; indexOp < deleteOps.Count; indexOp++)
                {
                    if (deleteOps[indexOp] != null)
                    {
                        typeNotDefined = ModelCodeHelper.ExtractTypeFromGlobalId(deleteOps[indexOp].Id);
                    }
                }
                message = String.Format("Failed to sort delta operations because there are some delete operations (count = {0}) which type (e.g. {1}) is not specified in given list of types.", deleteOps.Count, typeNotDefined);
                Logger.LogError(message);

                string exceptionMessage = String.Format("Invalid delta. Some delete operations (count = {0}) which type (e.g. {1}) is not correct.", deleteOps.Count, typeNotDefined);
                throw new ModelException(ErrorCode.InvalidDelta, exceptionMessage);
            }

            // remember ordered delete operations
            deleteOpsOrdered.Reverse();
            deleteOps = deleteOpsOrdered;

            message = String.Format("Sorting delta operations for delta with ID: {0} completed successfully.", GetCompositeId(id));
            Logger.LogDebug(message);
        }