Exemple #1
0
 private int GetCategoryIdForIntermediate(DbContextWrapper ilcdDb, XElement c)
 {
     string externalClassId = c.Attribute("classId").Value;
     return ilcdDb.GetDbSet<Category>().AsQueryable().Where(a => a.ExternalClassID == externalClassId)
         .Select(a => a.CategoryID).FirstOrDefault();
 }
Exemple #2
0
 /// <summary>
 /// Create a list of FlowFlowProperty entities from elements under flowProperties.
 /// This will only add entries that do not exist, but will not update entries that do exist.
 /// </summary>
 /// <param name="ilcdDb">Database context wrapper object</param>
 /// <param name="flow">Flow parent entity</param>
 private List<FlowFlowProperty> CreateFFPList(DbContextWrapper ilcdDb, int flowId)
 {
     var ffpExist = ilcdDb.GetDbSet<FlowFlowProperty>().AsQueryable().Where(k => k.FlowID == flowId).Select(k => k.FlowPropertyID).ToList();
     return LoadedDocument.Root.Descendants(ElementName("flowProperties")).Elements(ElementName("flowProperty"))
         .Select(fp =>
             new FlowFlowProperty {
                 FlowID = flowId,
                 FlowPropertyID = GetFlowPropertyID(ilcdDb, fp),
                 MeanValue = (double)fp.Element(ElementName("meanValue")),
                 StDev = (double?)fp.Element(ElementName("relativeStandardDeviation95In"))
             }).Where(fp => !ffpExist.Contains(fp.FlowPropertyID)).ToList();
 }
Exemple #3
0
 private int GetCategoryIdForElementary(DbContextWrapper ilcdDb, XElement c)
 {
     string name = c.Value;
     return ilcdDb.GetDbSet<Category>().AsQueryable().Where(a => a.Name == name && a.CategorySystem.Name == "ILCDEflow")
         .Select(a => a.CategoryID).FirstOrDefault();
 }
Exemple #4
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();
        }