Exemple #1
0
 private bool SaveStub(DbContextWrapper ilcdDb, DataTypeEnum dtEnum)
 {
     bool isSaved = false;
     string uuid = GetCommonUUID();
     if (ilcdDb.GetIlcdEntity(GetCommonUUID()) == null)
     {
         ILCDEntity stub = SaveIlcdStub(ilcdDb, dtEnum);
         isSaved = ilcdDb.AddEntity<ILCDEntity>(stub);
     }
     return isSaved;
 }
Exemple #2
0
        private List<Classification> CreateClassificationList(DbContextWrapper ilcdDb, string uuid)
        {
            int ilcdEntityId = ilcdDb.GetIlcdEntity(uuid).ILCDEntityID;
            var catExist = ilcdDb.GetDbSet<Classification>().AsQueryable().Where(c => c.ILCDEntityID == ilcdEntityId)
                .Select(c => c.CategoryID).ToList();
            var classInfo = LoadedDocument.Root.Descendants(ElementName("classificationInformation")).FirstOrDefault();
            var c1 = new List<Classification>();

            c1.AddRange(classInfo.Element(_CommonNamespace + "elementaryFlowCategorization").Elements(_CommonNamespace + "category")
                    .Select(c => new Classification
                    {
                        ILCDEntityID = ilcdEntityId,
                        CategoryID = GetCategoryIdForElementary(ilcdDb, c)
                    }).Where(c => c.CategoryID !=0).ToList());
            if (c1.Count() == 0)
            {
                try
                {
                    c1.AddRange(classInfo.Element(_CommonNamespace + "classification").Elements(_CommonNamespace + "class")
                        .Select(c => new Classification
                    {
                        ILCDEntityID = ilcdEntityId,
                        CategoryID = GetCategoryIdForIntermediate(ilcdDb, c)
                    }).Where(c => c.CategoryID != 0).ToList());
                }
                catch (Exception e)
                    {
                        Program.Logger.ErrorFormat("Something went wrong");
                    }

            }
            return c1.Where(c => !catExist.Contains(c.CategoryID)).ToList();
        }