예제 #1
0
        public void BizAction(ProjectSubSystemDto inputData)
        {
            var pSystem = _dbAccess.GetSubSystme(inputData.Id);

            if (pSystem == null)
            {
                AddError("Could not find the Subsystem. Someone entering illegal ids?");
                return;
            }


            var status = pSystem.UpdateProjectSubSystem(inputData.Code, inputData.Description,
                                                        inputData.PriorityNo, inputData.SubPriorityNo);

            CombineErrors(status);

            Message = $"Subsystem is update: {pSystem.ToString()}.";
        }
        private void calculateBySubSystem(ActivityPlaneDto inputData, Project project)
        {
            var workPackages = _workPackageDbAccess.GetRoadMap(inputData.WorkPackageId);

            if (workPackages == null)
            {
                AddError("Not available WorkPackage!!!", "activity");
            }

            var location = _locationDbAccess.GetLocationType(inputData.LocationId);

            if (location == null)
            {
                AddError("Not available location!!!", "activity");
            }

            var subSystem = _subsystemDbAccess.GetSubSystme(inputData.SubSystemId);

            if (subSystem == null)
            {
                AddError("Not available subSystem!!!", "activity");
            }

            var descipline = _desciplineDbAccess.GetDescipline(inputData.DesciplineId);

            if (subSystem == null)
            {
                AddError("Not available descipline!!!", "activity");
            }

            if (inputData.StartDate > inputData.EndDate)
            {
                AddError("Inserted Start Date is greater of End Date!!!", "activity");
            }

            if (inputData.StartDate < project.StartDate)
            {
                AddError("Start Date must be greater of project start date!!!", "activity");
            }

            if (inputData.EndDate > project.EndDate)
            {
                AddError("End Date must be lowest of project end date!!!", "activity");
            }

            if (!this.HasErrors)
            {
                var items = _dbAccess.GetActivityForConfigPlan(inputData.WorkPackageId, inputData.LocationId, inputData.SubSystemId, inputData.DesciplineId)
                            .ToList();

                float  formMh     = items.Sum(s => s.FormDictionary.ManHours);
                double totalHours = (inputData.EndDate - inputData.StartDate).TotalHours;

                if (totalHours < formMh)
                {
                    AddError("Total hours for claculate date is Smaller than sum of Tasks's form Mh", "activity");
                    return;
                }

                double fac = 0;

                if (totalHours > formMh)
                {
                    double dif = (totalHours - formMh);
                    fac = Math.Floor(dif / items.Count);
                }

                var groupItems = items
                                 .OrderBy(s => s.FormDictionary.Priority).GroupBy(s => s.FormDictionary.Id);

                DateTime startDate = inputData.StartDate;
                DateTime endDate   = inputData.StartDate;

                foreach (var g in groupItems)
                {
                    var orderbySubSystem = g.OrderBy(o => o.SubSystem.PriorityNo).ThenBy(o => o.SubSystem.SubPriorityNo);
                    foreach (var ac in orderbySubSystem)
                    {
                        var fmh = ac.FormDictionary.ManHours;
                        fmh = (float)(fmh + fac);

                        endDate = startDate.AddHours(fmh);
                        ac.UpdateActivityPlane(startDate, endDate);
                        startDate = endDate;
                    }
                }

                _dbAccess.UpdateActivityPlane(items);
            }
        }
예제 #3
0
        public void BizAction(ActivityDto inputData)
        {
            var workPackage = _workPackageDbAccess.GetRoadMap(inputData.WorkPackageId);

            if (workPackage == null)
            {
                AddError("WorkPackage is Not Valid.");
            }

            var location = _locationDbAccess.GetLocationType(inputData.LocationId);

            if (location == null)
            {
                AddError("Location is Not Valid.");
            }

            var descipline = _desciplineDbAccess.GetDescipline(inputData.DesciplineId);

            if (descipline == null)
            {
                AddError("Descipline is Not Valid.");
            }

            var form = _formDicDbAccess.GetFormDictionary(inputData.FormDictionaryId);

            if (form == null)
            {
                AddError("Form is Not Valid.");
            }

            var system = _systemDbAccess.GetSystme(inputData.SystemdId);

            if (system == null)
            {
                AddError("System is Not Valid.");
            }

            var subSystem = _subSystemDbAccess.GetSubSystme(inputData.SubsytemId);

            if (subSystem == null)
            {
                AddError("Subsystem is Not Valid.");
            }
            var workStep = _workStepDbAccess.GetWorkPackageStep(inputData.WorkPackageStepId);

            if (workStep == null)
            {
                AddError("WorkPackage Step is Not Valid.");
            }

            var activity = _dbAccess.GetActivity(inputData.Id);

            if (activity == null)
            {
                AddError("Could not find the Activity. Someone entering illegal ids?");
                return;
            }

            var status = activity.UpdateActivity(inputData.TagNumber, inputData.TagDescription
                                                 , inputData.ValueUnitNum, inputData.EstimateMh, inputData.ActualMh, inputData.ActualStartDate,
                                                 inputData.ActualEndDate, inputData.Condition, inputData.Status);

            CombineErrors(status);

            Message = $"activity is update: {activity.ToString()}.";
        }
예제 #4
0
        public Activity BizAction(ActivityDto inputData)
        {
            var workPackage = _workPackageDbAccess.GetRoadMap(inputData.WorkPackageId);

            if (workPackage == null)
            {
                AddError("WorkPackage is Not Valid.");
            }

            var location = _locationDbAccess.GetLocationType(inputData.LocationId);

            if (location == null)
            {
                AddError("Location is Not Valid.");
            }

            var descipline = _desciplineDbAccess.GetDescipline(inputData.DesciplineId);

            if (descipline == null)
            {
                AddError("Descipline is Not Valid.");
            }

            var form = _formDicDbAccess.GetFormDictionary(inputData.FormDictionaryId);

            if (form == null)
            {
                AddError("Form is Not Valid.");
            }

            var system = _systemDbAccess.GetSystme(inputData.SystemdId);

            if (system == null)
            {
                AddError("System is Not Valid.");
            }

            var subSystem = _subSystemDbAccess.GetSubSystme(inputData.SubsytemId);

            if (subSystem == null)
            {
                AddError("Subsystem is Not Valid.");
            }
            var workStep = _workStepDbAccess.GetWorkPackageStep(inputData.WorkPackageStepId);

            if (workStep == null)
            {
                AddError("WorkPackage Step is Not Valid.");
            }

            if (inputData.WeightFactor < 0)
            {
                AddError("WeightFactor is Not Valid.");
            }

            if (string.IsNullOrWhiteSpace(inputData.TagNumber))
            {
                AddError("TagNumber is Not Valid.");
            }

            var desStatus = Activity.CreateActivity(inputData.TagNumber, inputData.TagDescription, inputData.Progress,
                                                    inputData.WeightFactor, inputData.ValueUnitNum, inputData.EstimateMh, inputData.ActualMh, inputData.Status, inputData.ActualStartDate, inputData.ActualEndDate
                                                    , inputData.PlanStartDate, inputData.PlanEndDate, inputData.FormDictionaryId, inputData.ValueUnitId
                                                    , inputData.WorkPackageId, inputData.LocationId, inputData.SubsytemId,
                                                    inputData.Condition, inputData.ActivityCode, inputData.DesciplineId, inputData.WorkPackageStepId);

            CombineErrors(desStatus);

            if (!HasErrors)
            {
                _dbAccess.Add(desStatus.Result);
            }

            return(HasErrors ? null : desStatus.Result);
        }