public ISOGuidanceShift ExportGuidanceShift(GuidanceShift adaptGuidanceShift)
        {
            ISOGuidanceShift gst = new ISOGuidanceShift();

            //Group ID
            gst.GuidanceGroupIdRef = TaskDataMapper.InstanceIDMap.GetISOID(adaptGuidanceShift.GuidanceGroupId);

            //Pattern ID
            gst.GuidancePatternIdRef = TaskDataMapper.InstanceIDMap.GetISOID(adaptGuidanceShift.GuidancePatterId);

            //Shifts
            gst.GuidanceEastShift  = adaptGuidanceShift.EastShift.AsConvertedInt("mm");
            gst.GuidanceNorthShift = adaptGuidanceShift.NorthShift.AsConvertedInt("mm");
            gst.PropagationOffset  = adaptGuidanceShift.PropagationOffset.AsConvertedInt("mm");

            //Allocation Stamp
            if (adaptGuidanceShift.TimeScopeIds.Any())
            {
                TimeScope scope = DataModel.Catalog.TimeScopes.FirstOrDefault(t => t.Id.ReferenceId == adaptGuidanceShift.TimeScopeIds.First()); //Mapping first timescope only
                if (scope != null)
                {
                    gst.AllocationStamp = AllocationStampMapper.ExportAllocationStamp(scope);
                }
            }

            return(gst);
        }
        public PersonRole ImportWorkerAllocation(ISOWorkerAllocation isoWorkerAllocation)
        {
            int?personID = TaskDataMapper.InstanceIDMap.GetADAPTID(isoWorkerAllocation.WorkerIdRef);

            if (personID.HasValue)
            {
                PersonRole adaptWorkerAllocation = new PersonRole();

                //Worker ID
                adaptWorkerAllocation.PersonId = personID.Value;

                //Allocation Stamps
                if (isoWorkerAllocation.AllocationStamp != null)
                {
                    adaptWorkerAllocation.TimeScopes = AllocationStampMapper.ImportAllocationStamps(new List <ISOAllocationStamp>()
                    {
                        isoWorkerAllocation.AllocationStamp
                    }).ToList();
                }

                return(adaptWorkerAllocation);
            }

            //If we can't map to a Person, no sense including a PersonRole
            return(null);
        }
        public GuidanceAllocation ImportGuidanceAllocation(ISOGuidanceAllocation isoGuidanceAllocation)
        {
            GuidanceAllocation adaptGuidanceAllocation = new GuidanceAllocation();

            //Group ID
            int?groupID = TaskDataMapper.InstanceIDMap.GetADAPTID(isoGuidanceAllocation.GuidanceGroupIdRef);

            if (groupID.HasValue)
            {
                adaptGuidanceAllocation.GuidanceGroupId = groupID.Value;
            }

            //Allocation Stamps
            if (isoGuidanceAllocation.AllocationStamp != null)
            {
                adaptGuidanceAllocation.TimeScopes = AllocationStampMapper.ImportAllocationStamps(new List <ISOAllocationStamp>()
                {
                    isoGuidanceAllocation.AllocationStamp
                }).ToList();
            }

            //Guidance Shift
            if (isoGuidanceAllocation.GuidanceShifts.Any())
            {
                GuidanceShiftMapper gstMapper = new GuidanceShiftMapper(TaskDataMapper);
                adaptGuidanceAllocation.GuidanceShift = gstMapper.ImportGuidanceShift(isoGuidanceAllocation.GuidanceShifts.First()); //Using first item only
            }

            return(adaptGuidanceAllocation);
        }
        public ISOGuidanceAllocation ExportGuidanceAllocation(GuidanceAllocation adaptGuidanceAllocation)
        {
            ISOGuidanceAllocation gan = new ISOGuidanceAllocation();

            //Group ID
            gan.GuidanceGroupIdRef = TaskDataMapper.InstanceIDMap.GetISOID(adaptGuidanceAllocation.GuidanceGroupId);

            //Allocation Stamps
            if (adaptGuidanceAllocation.TimeScopes.Any())
            {
                gan.AllocationStamp = AllocationStampMapper.ExportAllocationStamps(adaptGuidanceAllocation.TimeScopes).FirstOrDefault();
            }

            //Guidance Shift
            if (adaptGuidanceAllocation.GuidanceShift != null)
            {
                GuidanceShiftMapper gstMapper = new GuidanceShiftMapper(TaskDataMapper);
                gan.GuidanceShifts = new List <ISOGuidanceShift>()
                {
                    gstMapper.ExportGuidanceShift(adaptGuidanceAllocation.GuidanceShift)
                };
            }

            return(gan);
        }
        public Note ImportCommentAllocation(ISOCommentAllocation isoCommentAllocation)
        {
            Note adaptNote = new Note();

            //Allocation Stamps
            if (isoCommentAllocation.AllocationStamp != null && isoCommentAllocation.AllocationStamp.Start != null)
            {
                adaptNote.TimeStamps = AllocationStampMapper.ImportAllocationStamps(new List <ISOAllocationStamp>()
                {
                    isoCommentAllocation.AllocationStamp
                }).ToList();
            }

            //Coded Comment
            if (!string.IsNullOrEmpty(isoCommentAllocation.CodedCommentIdRef) && !string.IsNullOrEmpty(isoCommentAllocation.CodedCommentListValueIdRef))
            {
                ISOCodedComment          comment = ISOTaskData.ChildElements.OfType <ISOCodedComment>().FirstOrDefault(c => c.CodedCommentID == isoCommentAllocation.CodedCommentIdRef);
                ISOCodedCommentListValue value   = comment.CodedCommentListValues.FirstOrDefault(l => l.CodedCommentListValueId == isoCommentAllocation.CodedCommentListValueIdRef);
                if (comment != null)
                {
                    adaptNote.Description = comment.CodedCommentDesignator;
                    adaptNote.Value       = TaskDataMapper.CommentMapper.ImportCodedComment(comment);
                    adaptNote.Value.Value = adaptNote.Value.Representation.EnumeratedMembers.FirstOrDefault(m => m.Value == value.CodedCommentListValueDesignator);
                }
            }
            else
            {
                adaptNote.Description = isoCommentAllocation.FreeCommentText;
            }


            return(adaptNote);
        }
        public ISOCommentAllocation ExportCommentAllocation(Note note)
        {
            ISOCommentAllocation commentAllocation = new ISOCommentAllocation();

            if (note.Value == null)
            {
                commentAllocation.FreeCommentText = note.Description;
            }
            else
            {
                if (note.Value.Representation != null)
                {
                    ISOCodedComment          comment = TaskDataMapper.CommentMapper.ExportCodedComment(note.Value);
                    ISOCodedCommentListValue value   = comment.CodedCommentListValues.FirstOrDefault(c => c.CodedCommentListValueDesignator == note.Value.Value.Value);
                    if (value != null)
                    {
                        commentAllocation.CodedCommentListValueIdRef = value.CodedCommentListValueId;
                    }
                }
            }

            //Allocation Stamps
            if (note.TimeStamps.Any())
            {
                commentAllocation.AllocationStamp = AllocationStampMapper.ExportAllocationStamps(note.TimeStamps).FirstOrDefault();
            }

            return(commentAllocation);
        }
        public GuidanceShift ImportGuidanceShift(ISOGuidanceShift isoGuidanceShift)
        {
            GuidanceShift adaptShift = new GuidanceShift();

            //Group ID
            int?groupID = TaskDataMapper.InstanceIDMap.GetADAPTID(isoGuidanceShift.GuidanceGroupIdRef);

            if (groupID.HasValue)
            {
                adaptShift.GuidanceGroupId = groupID.Value;
            }

            //Pattern ID
            int?patternID = TaskDataMapper.InstanceIDMap.GetADAPTID(isoGuidanceShift.GuidancePatternIdRef);

            if (patternID.HasValue)
            {
                adaptShift.GuidancePatterId = patternID.Value;
            }

            //Shifts
            if (isoGuidanceShift.GuidanceEastShift.HasValue)
            {
                adaptShift.EastShift = isoGuidanceShift.GuidanceEastShift.Value.AsNumericRepresentationValue("mm");
            }

            if (isoGuidanceShift.GuidanceNorthShift.HasValue)
            {
                adaptShift.NorthShift = isoGuidanceShift.GuidanceNorthShift.Value.AsNumericRepresentationValue("mm");
            }

            if (isoGuidanceShift.PropagationOffset.HasValue)
            {
                adaptShift.PropagationOffset = isoGuidanceShift.PropagationOffset.Value.AsNumericRepresentationValue("mm");
            }

            //Allocation Stamp
            if (isoGuidanceShift.AllocationStamp != null)
            {
                TimeScope scope = AllocationStampMapper.ImportAllocationStamp(isoGuidanceShift.AllocationStamp);
                DataModel.Catalog.TimeScopes.Add(scope);
                adaptShift.TimeScopeIds = new List <int>()
                {
                    scope.Id.ReferenceId
                };
            }

            return(adaptShift);
        }
        public ISOWorkerAllocation ExportWorkerAllocation(PersonRole adaptWorkerAllocation)
        {
            ISOWorkerAllocation wan = new ISOWorkerAllocation();

            //Worker ID
            wan.WorkerIdRef = TaskDataMapper.InstanceIDMap.GetISOID(adaptWorkerAllocation.PersonId);

            //Allocation Stamps
            if (adaptWorkerAllocation.TimeScopes.Any())
            {
                wan.AllocationStamp = AllocationStampMapper.ExportAllocationStamps(adaptWorkerAllocation.TimeScopes).FirstOrDefault();
            }

            return(wan);
        }
Beispiel #9
0
        private List <ISOProductAllocation> GetProductAllocationsForSummary(Summary summary)
        {
            List <ISOProductAllocation> productAllocations = null;

            if (summary.OperationSummaries != null && summary.OperationSummaries.Any())
            {
                productAllocations = new List <ISOProductAllocation>();
                foreach (OperationSummary operationSummary in summary.OperationSummaries)
                {
                    foreach (StampedMeteredValues values in operationSummary.Data)
                    {
                        ISOProductAllocation pan = new ISOProductAllocation();
                        pan.AllocationStamp = AllocationStampMapper.ExportAllocationStamp(values.Stamp);
                        pan.ProductIdRef    = TaskDataMapper.InstanceIDMap.GetISOID(operationSummary.ProductId);
                        productAllocations.Add(pan);
                    }
                }
            }
            return(productAllocations);
        }