コード例 #1
0
        /// ------------------------------------------------------------------------------------------------
        #region Public Constructor
        /// ------------------------------------------------------------------------------------------------
        ///
        /// ------------------------------------------------------------------------------------------------
        /// Name		SelectedTreatment
        ///
        /// <summary>	Creates a new instance of the SelectedTreatment class.
        /// </summary>
        /// <param name="visit">		The treatment being selected.</param>
        /// <param name="iMap">			The index mapping of the treatment selection.</param>
        /// <param name="isNew">		Whethher the entity is a new creation.</param>
        ///
        /// <remarks>
        /// </remarks>
        /// ------------------------------------------------------------------------------------------------
        ///
        public SelectedTreatment(SRiTreatment treatment, IndexMapping iMap, bool isNew)
            : base(iMap, isNew)
        {
            Exception error;

            //
            OnSiteSettings.ShouldSerialize = ShouldSerializeRule.Full;
            Treatment        = SRiTreatment.FromJson(treatment.ToJson(), out error);
            Treatment.Status = Treatment.Status.SetNewOrChanged(isNew ? SyncStatus.New : SyncStatus.Changed);
            if (error != null)
            {
                throw error;
            }
        }
コード例 #2
0
        /// ------------------------------------------------------------------------------------------------
        #region Public Constructor
        /// ------------------------------------------------------------------------------------------------
        ///
        /// ------------------------------------------------------------------------------------------------
        /// Name		SelectedAction
        ///
        /// <summary>	Creates a new instance of the SelectedAction class.
        /// </summary>
        /// <param name="action">		The action being selected.</param>
        /// <param name="iMap">			The index mapping of the action selection.</param>
        /// <param name="isNew">		Whethher the entity is a new creation.</param>
        ///
        /// <remarks>
        /// </remarks>
        /// ------------------------------------------------------------------------------------------------
        ///
        public SelectedAction(SRiAction action, IndexMapping iMap, bool isNew)
            : base(iMap, isNew)
        {
            Exception error;

            //
            OnSiteSettings.ShouldSerialize = ShouldSerializeRule.Full;
            Action        = SRiAction.FromJson(action.ToJson(), out error);
            Action.Status = Action.Status.SetNewOrChanged(isNew ? SyncStatus.New : SyncStatus.Changed);
            if (error != null)
            {
                throw error;
            }
        }
コード例 #3
0
        /// ------------------------------------------------------------------------------------------------
        #region Public Constructor
        /// ------------------------------------------------------------------------------------------------
        ///
        /// ------------------------------------------------------------------------------------------------
        /// Name		SelectedVisit
        ///
        /// <summary>	Creates a new instance of the SelectedVisit class.
        /// </summary>
        /// <param name="visit">		The visit being selected.</param>
        /// <param name="iMap">			The index mapping of the visit selection.</param>
        /// <param name="isNew">		Whether the entity is a new creation.</param>
        ///
        /// <remarks>
        /// </remarks>
        /// ------------------------------------------------------------------------------------------------
        ///
        public SelectedVisit(SRiVisitMeta visit, IndexMapping iMap, bool isNew)
            : base(iMap, isNew)
        {
            Exception error;

            //
            OnSiteSettings.ShouldSerialize = ShouldSerializeRule.Full;
            Visit        = SRiVisitMeta.FromJson(visit.ToJson(), out error);
            Visit.Status = Visit.Status.SetNewOrChanged(isNew ? SyncStatus.New : SyncStatus.Changed);
            if (error != null)
            {
                throw error;
            }
            SetGroupMod();
        }
コード例 #4
0
        ///
        #endregion
        /// ------------------------------------------------------------------------------------------------
        #region Public Cosntructor
        /// ------------------------------------------------------------------------------------------------
        ///
        /// ------------------------------------------------------------------------------------------------
        /// Name		SelectedRecord
        ///
        /// <summary>	Creates a new instance of the SelectedRecord class, using json serialisation to
        ///             copy the record data from the original source.
        /// </summary>
        /// <param name="record">		The record selected.</param>
        /// <param name="iMap">			The index mapping of the record.</param>
        ///
        /// <remarks>
        /// </remarks>
        /// ------------------------------------------------------------------------------------------------
        ///
        public SelectedRecord(SRiRecordMeta record, IndexMapping iMap, bool isNew)
            : base(iMap, false)
        {
            Exception error;

            //
            OnSiteSettings.ShouldSerialize = ShouldSerializeRule.Full;
            Record = SRiRecordMeta.FromJson(record.ToJson(), out error);
            Record.Record.Status = Record.Record.Status.SetNewOrChanged(isNew ? SyncStatus.New : SyncStatus.Changed);
            Record.Record.UpdateForSelection();
            if (error != null)
            {
                throw error;
            }
            //
            CreateMappings();
            CreateRisks();
        }
コード例 #5
0
        ///
        #endregion
        /// ------------------------------------------------------------------------------------------------
        #region Private Functions, Properties and Methods
        /// ------------------------------------------------------------------------------------------------
        ///
        /// ------------------------------------------------------------------------------------------------
        /// Name		SetGroupMod
        ///
        /// <summary>	Gets the instance of the Inspection that contains this visit and extracts the
        ///             GroupMod code from the Inspection for future use. If the Inspection cannot be
        ///             found then a blank string is used as the GroupMod.
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// ------------------------------------------------------------------------------------------------
        ///
        private void SetGroupMod()
        {
            IndexMapping  iMap;
            SRiInspection inspection;

            //
            iMap = new IndexMapping(IndexMap.Property,
                                    IndexMap.RequestGroup.Value,
                                    IndexMap.Record.Value,
                                    IndexMap.Inspection.Value);
            inspection = AppData.PropertyModel.EntityFromMapping(iMap) as SRiInspection;
            if (inspection != null)
            {
                GroupMod = inspection.GroupMod;
            }
            else
            {
                GroupMod = "";
            }
        }
コード例 #6
0
        ///
        /// ------------------------------------------------------------------------------------------------
        /// Name		InspectionTypeDescription
        ///
        /// <summary>	Gets the InspectionTypeDescription of the Inspection that contains the entity
        ///             that is mapped.
        /// </summary>
        /// <param name="iMap">		The entity mapping. Can be Visit, Action or Treatment.</param>
        ///
        /// <remarks>
        /// </remarks>
        /// ------------------------------------------------------------------------------------------------
        ///
        public string InspectionTypeDescription(IndexMapping iMap)
        {
            SRiInspection inspection;

            //
            if (iMap.RequestGroup.HasValue &&
                iMap.Record.HasValue &&
                iMap.Inspection.HasValue)
            {
                inspection = AppData.PropertyModel.EntityFromMapping(new IndexMapping(iMap.Property,
                                                                                      iMap.RequestGroup.Value,
                                                                                      iMap.Record.Value,
                                                                                      iMap.Inspection.Value)) as SRiInspection;
                if (inspection != null)
                {
                    return(inspection.InspectionTypeDescription);
                }
            }
            //
            return("No inspection type");
        }
コード例 #7
0
        ///
        /// ------------------------------------------------------------------------------------------------
        /// Name		EntityFromMapping
        ///
        /// <summary>	Tries to retreive the OnSiteEntity identified by the IndexMapping. If the mapping
        ///             is incorrect then null is returned.
        /// </summary>
        /// <param name="iMap">			The index mapping for the OnSiteEntity required.</param>
        ///
        /// <remarks>
        /// </remarks>
        /// ------------------------------------------------------------------------------------------------
        ///
        public OnSiteEntity EntityFromMapping(IndexMapping iMap)
        {
            try
            {
                // TODO
                switch (iMap.Type)
                {
                case MappingType.Record:
                    return(m_oRecordList[iMap.Record.Value]);

                case MappingType.Inspection:
                    return(m_oRecordList[iMap.Record.Value].Inspections[iMap.Inspection.Value]);

                case MappingType.Visit:
                    return(m_oRecordList[iMap.Record.Value].Inspections[iMap.Inspection.Value].Visits[iMap.Visit.Value]);

                default:
                    return(null);
                }
            }
            catch { return(null); }
        }
コード例 #8
0
 ///
 /// ------------------------------------------------------------------------------------------------
 /// Name		Matches
 ///
 /// <summary>	Checks if another IndexMapping instance matches the current one.
 /// </summary>
 /// <param name="map">		The other IndexMapping instance.</param>
 ///
 /// <remarks>
 /// </remarks>
 /// ------------------------------------------------------------------------------------------------
 ///
 public bool Matches(IndexMapping map)
 {
     return(map.Property == Property &&
            map.RequestGroup == RequestGroup &&
            map.Record == Record);
 }
コード例 #9
0
 /// ------------------------------------------------------------------------------------------------
 #region Public Constructor
 /// ------------------------------------------------------------------------------------------------
 ///
 /// ------------------------------------------------------------------------------------------------
 /// Name		SelectedBase
 ///
 /// <summary>	Creates a new instance of the SelectedBase class.
 /// </summary>
 /// <param name="iMap">		The index mapping of the selected entity.</param>
 /// <param name="isNew">	Whether the entity is a new creation.</param>
 ///
 /// <remarks>
 /// </remarks>
 /// ------------------------------------------------------------------------------------------------
 ///
 public SelectedBase(IndexMapping iMap, bool isNew)
 {
     IndexMap = iMap;
     IsNew    = isNew;
     Edited   = false;
 }