コード例 #1
0
        public void Load()
        {
            // Explicitly loads a Project and all related entities

            using (LabDbEntities entities = new LabDbEntities())
            {
                entities.Configuration.LazyLoadingEnabled = false;

                Project tempEntry = entities.Projects.Include(prj => prj.ExternalReports
                                                              .Select(extr => extr.ExternalLab))
                                    .Include(prj => prj.Leader)
                                    .Include(prj => prj.Oem)
                                    .First(prj => prj.ID == ID);

                Description         = tempEntry.Description;
                ExternalReports     = tempEntry.ExternalReports;
                Leader              = tempEntry.Leader;
                Name                = tempEntry.Name;
                Oem                 = tempEntry.Oem;
                OemID               = tempEntry.OemID;
                ProjectLeaderID     = tempEntry.ProjectLeaderID;
                TotalExternalCost   = tempEntry.TotalExternalCost;
                TotalReportDuration = tempEntry.TotalReportDuration;
            }
        }
コード例 #2
0
ファイル: TaskExtension.cs プロジェクト: PiSim/LDb2
        /// <summary>
        /// Generates a list of tests based on the taskItems loading all values from the DB
        /// </summary>
        /// <param name="includeMethods">If true the related Method entities are loaded</param>
        /// <returns>An IList containing the generated test entitites</returns>
        public IList <Test> GenerateTests(bool includeMethods = false)
        {
            List <Test> output = new List <Test>();

            using (LabDbEntities entities = new LabDbEntities())
            {
                entities.Configuration.LazyLoadingEnabled = false;

                IEnumerable <TaskItem> _itemList;

                if (includeMethods)
                {
                    _itemList = entities.TaskItems
                                .Include(tski => tski.Method.Property)
                                .Include(tski => tski.Method.Standard)
                                .Include(tski => tski.SubTaskItems)
                                .Where(tski => tski.TaskID == ID)
                                .ToList();
                }
                else
                {
                    _itemList = entities.TaskItems
                                .Include(tski => tski.SubTaskItems)
                                .Where(tski => tski.TaskID == ID)
                                .ToList();
                }

                foreach (TaskItem currentItem in _itemList)
                {
                    output.Add(currentItem.GetTest());
                }

                return(output);
            }
        }
コード例 #3
0
        /// <summary>
        /// Deletes the entry from the database if no Test or requirement is associated with it, otherwise sets it as obsolete
        /// </summary>
        public void RemoveOrSetObsolete()
        {
            using (LabDbEntities entities = new LabDbEntities())
            {
                MethodVariant attachedInstance = entities.MethodVariants.FirstOrDefault(mtdvar => mtdvar.ID == ID);
                if (attachedInstance == null)
                {
                    return;
                }

                if (attachedInstance.Requirements.Count == 0 &&
                    attachedInstance.Tests.Count == 0)
                {
                    entities.Entry(attachedInstance)
                    .State = EntityState.Deleted;
                }
                else
                {
                    attachedInstance.IsOld = true;
                    IsOld = true;
                }

                entities.SaveChanges();
            }
        }
コード例 #4
0
ファイル: TestRecordExtension.cs プロジェクト: PiSim/LDb2
        /// <summary>
        /// Returns the report which uses this TestRecord
        /// </summary>
        /// <returns></returns>
        public object GetReport()
        {
            using (LabDbEntities entities = new LabDbEntities())
            {
                entities.Configuration.LazyLoadingEnabled = false;

                if (RecordTypeID == 1)
                {
                    return(entities.TestRecords
                           .Include(tstr => tstr.Reports).First(tsr => tsr.ID == ID)
                           .Reports
                           .FirstOrDefault());
                }
                else if (RecordTypeID == 2)
                {
                    return(entities.TestRecords
                           .Include(tstr => tstr.ExternalReports)
                           .First(tsr => tsr.ID == ID)
                           .ExternalReports
                           .FirstOrDefault());
                }
                else
                {
                    return(null);
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// Returns all Task entities in the DB
        /// </summary>
        /// <param name="includeComplete">If true complete tasks will be included</param>
        /// <param name="includeAssigned">If true assigned tasks will be included</param>
        /// <returns>IEnumerable containing all the found entries</returns>
        public IEnumerable <Task> GetTasks(bool includeComplete = true,
                                           bool includeAssigned = true)
        {
            using (LabDbEntities entities = _dbContextFactory.Create())
            {
                entities.Configuration.LazyLoadingEnabled = false;

                IQueryable <Task> queryBase = entities.Tasks.Include(tsk => tsk.Batch.Material.Aspect)
                                              .Include(tsk => tsk.Batch.Material.Project)
                                              .Include(tsk => tsk.Batch.Material.MaterialLine)
                                              .Include(tsk => tsk.Batch.Material.MaterialType)
                                              .Include(tsk => tsk.Batch.Material.Recipe.Colour)
                                              .Include(tsk => tsk.Requester)
                                              .Include(tsk => tsk.SpecificationVersion.Specification.Standard);

                if (includeComplete)
                {
                    return(queryBase.ToList());
                }

                if (includeAssigned)
                {
                    return(queryBase.Where(tsk => tsk.Report == null || !tsk.Report.IsComplete)
                           .ToList());
                }
                else
                {
                    return(queryBase.Where(tsk => tsk.Report == null)
                           .ToList());
                }
            }
        }
コード例 #6
0
ファイル: TaskExtension.cs プロジェクト: PiSim/LDb2
        /// <summary>
        /// Reads and stores the entity property values from the DB
        /// Children collections are not loaded
        /// </summary>
        public void Load()
        {
            using (LabDbEntities entities = new LabDbEntities())
            {
                entities.Configuration.LazyLoadingEnabled = false;

                Task tempEntry = entities.Tasks.Include(tsk => tsk.Batch.Material.Aspect)
                                 .Include(tsk => tsk.Batch.Material.ExternalConstruction)
                                 .Include(tsk => tsk.Batch.Material.MaterialLine)
                                 .Include(tsk => tsk.Batch.Material.MaterialType)
                                 .Include(tsk => tsk.Batch.Material.Project.Oem)
                                 .Include(tsk => tsk.Batch.Material.Recipe.Colour)
                                 .Include(tsk => tsk.Batch.Material.Recipe.Master)
                                 .Include(tsk => tsk.Report)
                                 .Include(tsk => tsk.Requester)
                                 .Include(tsk => tsk.SpecificationVersion.Specification.Standard.Organization)
                                 .First(tsk => tsk.ID == ID);

                Batch                  = tempEntry.Batch;
                BatchID                = tempEntry.BatchID;
                EndDate                = tempEntry.EndDate;
                Notes                  = tempEntry.Notes;
                PipelineOrder          = tempEntry.PipelineOrder;
                PriorityModifier       = tempEntry.PriorityModifier;
                Progress               = tempEntry.Progress;
                Report                 = tempEntry.Report;
                Requester              = tempEntry.Requester;
                RequesterID            = tempEntry.RequesterID;
                SpecificationVersion   = tempEntry.SpecificationVersion;
                SpecificationVersionID = tempEntry.SpecificationVersionID;
                StartDate              = tempEntry.StartDate;
            }
        }
コード例 #7
0
        public static void Load(this SpecificationVersion entry)
        {
            // Loads relevant RelatedEntities for given SpecificationVersion entry

            if (entry == null)
            {
                return;
            }

            using (LabDbEntities entities = new LabDbEntities())
            {
                entities.Configuration.LazyLoadingEnabled = false;

                SpecificationVersion tempEntry = entities.SpecificationVersions.Include(specv => specv.ExternalConstructions)
                                                 .Include(specv => specv.Requirements
                                                          .Select(req => req.SubRequirements))
                                                 .Include(specv => specv.Requirements
                                                          .Select(req => req.Overridden))
                                                 .Include(specv => specv.Requirements
                                                          .Select(req => req.MethodVariant.Method.Property))
                                                 .Include(specv => specv.Requirements
                                                          .Select(req => req.MethodVariant.Method.Standard.Organization))
                                                 .Include(req => req.Specification.Standard.Organization)
                                                 .First(specv => specv.ID == entry.ID);

                entry.ExternalConstructions = tempEntry.ExternalConstructions;
                entry.IsMain          = tempEntry.IsMain;
                entry.Name            = tempEntry.Name;
                entry.Reports         = tempEntry.Reports;
                entry.Requirements    = tempEntry.Requirements;
                entry.Specification   = tempEntry.Specification;
                entry.SpecificationID = tempEntry.SpecificationID;
                entry.Tasks           = tempEntry.Tasks;
            }
        }
コード例 #8
0
ファイル: MethodExtension.cs プロジェクト: PiSim/LDb2
 public static void Create(this Method entry)
 {
     using (LabDbEntities entities = new LabDbEntities())
     {
         entities.Methods.Add(entry);
         entities.SaveChanges();
     }
 }
コード例 #9
0
 public void Create()
 {
     using (LabDbEntities entities = new LabDbEntities())
     {
         entities.ControlPlans.Add(this);
         entities.SaveChanges();
     }
 }
コード例 #10
0
 public void Create()
 {
     using (LabDbEntities entities = new LabDbEntities())
     {
         entities.Projects.Add(this);
         entities.SaveChanges();
     }
 }
コード例 #11
0
 public static void CreateTests(this IEnumerable <Test> testList)
 {
     using (LabDbEntities entities = new LabDbEntities())
     {
         entities.Tests.AddRange(testList);
         entities.SaveChanges();
     }
 }
コード例 #12
0
 /// <summary>
 /// Inserts the entity in the database
 /// </summary>
 public void Create()
 {
     using (LabDbEntities entities = new LabDbEntities())
     {
         entities.MethodVariants.Add(this);
         entities.SaveChanges();
     }
 }
コード例 #13
0
ファイル: ReportExtension.cs プロジェクト: PiSim/LDb2
 public static void Update(this Report entry)
 {
     using (LabDbEntities entities = new LabDbEntities())
     {
         entities.Reports.AddOrUpdate(entry);
         entities.SaveChanges();
     }
 }
コード例 #14
0
 public static void Create(this Batch entry)
 {
     using (LabDbEntities entities = new LabDbEntities())
     {
         entities.Batches.Add(entry);
         entities.SaveChanges();
     }
 }
コード例 #15
0
 public static void Update(this Specification entry)
 {
     using (LabDbEntities entities = new LabDbEntities())
     {
         entities.Specifications.AddOrUpdate(entry);
         entities.SaveChanges();
     }
 }
コード例 #16
0
 public static void Delete(this Specification entry)
 {
     using (LabDbEntities entities = new LabDbEntities())
     {
         entities.Entry(entities.Specifications.First(spec => spec.ID == entry.ID))
         .State = EntityState.Deleted;
         entities.SaveChanges();
     }
 }
コード例 #17
0
        public Requirement GetRequirement(int ID)
        {
            using (LabDbEntities entities = _dbContextFactory.Create())
            {
                entities.Configuration.LazyLoadingEnabled = false;

                return(entities.Requirements.First(req => req.ID == ID));
            }
        }
コード例 #18
0
ファイル: MethodExtension.cs プロジェクト: PiSim/LDb2
 public static void Delete(this Method entry)
 {
     using (LabDbEntities entities = new LabDbEntities())
     {
         entities.Methods.Attach(entry);
         entities.Entry(entry).State = System.Data.Entity.EntityState.Deleted;
         entities.SaveChanges();
     }
 }
コード例 #19
0
        /// <summary>
        /// Returns all PersonRole Entities
        /// </summary>
        /// <returns>An IEnumerable containing all PersonRole entities</returns>
        public IEnumerable <PersonRole> GetPersonRoles()
        {
            using (LabDbEntities entities = _dbContextFactory.Create())
            {
                entities.Configuration.LazyLoadingEnabled = false;

                return(entities.PersonRoles.ToList());
            }
        }
コード例 #20
0
ファイル: TaskExtension.cs プロジェクト: PiSim/LDb2
        public static void Update(this Task entry)
        {
            // Updates the DB values of a Task entry

            using (LabDbEntities entities = new LabDbEntities())
            {
                entities.Tasks.AddOrUpdate(entry);
                entities.SaveChanges();
            }
        }
コード例 #21
0
ファイル: ReportExtension.cs プロジェクト: PiSim/LDb2
        public static void Delete(this Report entry)
        {
            using (LabDbEntities entities = new LabDbEntities())
            {
                entities.Entry(entities.Reports.First(rep => rep.ID == entry.ID)).State = EntityState.Deleted;
                entities.SaveChanges();

                entry.ID = 0;
            }
        }
コード例 #22
0
ファイル: ReportExtension.cs プロジェクト: PiSim/LDb2
        public static void Create(this Report entry)
        {
            using (LabDbEntities entities = new LabDbEntities())
            {
                entities.Configuration.LazyLoadingEnabled = false;

                entities.Reports.Add(entry);
                entities.SaveChanges();
            }
        }
コード例 #23
0
ファイル: ExternalReportExtension.cs プロジェクト: PiSim/LDb2
        public void Create()
        {
            // Inserts the report in the DB

            using (LabDbEntities entities = new LabDbEntities())
            {
                entities.ExternalReports.Add(this);
                entities.SaveChanges();
            }
        }
コード例 #24
0
ファイル: RequirementExtension.cs プロジェクト: PiSim/LDb2
        public static void Create(this Requirement entry)
        {
            // Insert new Requirement entry in the DB

            using (LabDbEntities entities = new LabDbEntities())
            {
                entities.Requirements.Add(entry);
                entities.SaveChanges();
            }
        }
コード例 #25
0
ファイル: TaskExtension.cs プロジェクト: PiSim/LDb2
        public static void Create(this Task entry)
        {
            // Deletes given task instance

            using (LabDbEntities entities = new LabDbEntities())
            {
                entities.Tasks.Add(entry);
                entities.SaveChanges();
            }
        }
コード例 #26
0
        /// <summary>
        /// Calculates the total external cost of the project and stores the result in the
        /// TotalExternalCost field
        /// </summary>
        /// <returns>The calculated value</returns>
        public double GetExternalReportCost()
        {
            using (LabDbEntities entities = new LabDbEntities())
            {
                IQueryable <ExternalReport> externalReportList = entities.ExternalReports
                                                                 .Where(extr => extr.ProjectID == ID);

                return((externalReportList.Count() == 0) ? 0 : externalReportList.Sum(extr => extr.OrderTotal));
            }
        }
コード例 #27
0
        public IEnumerable <MeasurementUnit> GetMeasurementUnits()
        {
            // Returns all measurement units

            using (LabDbEntities entities = _dbContextFactory.Create())
            {
                entities.Configuration.LazyLoadingEnabled = false;

                return(entities.MeasurementUnits.ToList());
            }
        }
コード例 #28
0
        public CalibrationReport GetCalibrationReport(int ID)
        {
            // Returns a calibration report with the given ID, or null if none is found

            using (LabDbEntities entities = _dbContextFactory.Create())
            {
                entities.Configuration.LazyLoadingEnabled = false;

                return(entities.CalibrationReports.FirstOrDefault(calrep => calrep.ID == ID));
            }
        }
コード例 #29
0
        /// <summary>
        /// Removes the ExternalConstruction Association from the material
        /// </summary>
        public void UnsetConstruction()
        {
            using (LabDbEntities entities = new LabDbEntities())
            {
                Material attachedEntry = entities.Materials.First(mat => mat.ID == ID);

                attachedEntry.ExternalConstruction.Materials.Remove(attachedEntry);

                entities.SaveChanges();
            }
        }
コード例 #30
0
        /// <summary>
        /// Returns all the StandardFiles related to this standard
        /// </summary>
        /// <returns>An IEnumerable of StandardFiles entities</returns>
        public IEnumerable <StandardFile> GetFiles()
        {
            using (LabDbEntities entities = new LabDbEntities())
            {
                entities.Configuration.LazyLoadingEnabled = false;

                return(entities.StandardFiles
                       .Where(stf => stf.StandardID == ID)
                       .ToList());
            }
        }