///
 /// ------------------------------------------------------------------------------------------------
 /// Name		SRiResolution
 ///
 /// <summary>	Creates a new instance of the SRiResolution class.
 /// </summary>
 /// <param name="sent">			The record that was sent to the API.</param>
 /// <param name="returned">		The record that was returned from the API in conflict.</param>
 ///
 /// <remarks>
 /// </remarks>
 /// ------------------------------------------------------------------------------------------------
 ///
 public SRiResolution(SRiRecordMeta sent, SRiRecordMeta returned)
 {
     Title       = sent.RequestTypeDescription;
     Description = sent.Record.Name ?? "No Value";
     Type        = "SRREC";
     Selected    = false;
     CaseID      = returned.Record.RefVal ?? "No Case ID";
     TradeName   = returned.Record.TradeName ?? "No Trading Name";
     //
     if (returned.QueryState.ToUpper().Equals("C"))
     {
         Issue            = SRiResolutionIssue.Conflict;
         m_oResolveAction = () =>
         {
             // Make sure the record stays as changed, but update the UVersion to match the returned.
             sent.Record.Status = SyncStatus.Changed;
             sent.Version       = returned.Version;
             sent.Record.UpdateVersions(returned.Record);
             AppData.PropertyModel.Update(sent, sent);
         };
     }
     else if (returned.QueryState.ToUpper().Equals("D"))
     {
         Issue            = SRiResolutionIssue.Deletion;
         m_oResolveAction = () =>
         {
             AppData.PropertyModel.Delete(sent);
         };
     }
 }
Exemple #2
0
        private async Task SaveExistCase(SRiUtilityAddress uaddress)
        {
            try
            {
                Exception       err;
                SRiRequestGroup s_RequestGroup = AppData.PropertyModel.SelectedProperty.RequestGroups[0];
                SRiRecordMeta   s_Record       = AppData.PropertyModel.SelectedRecord.Record;
                //
                s_Record.Record.Address = EdAddress.Text;
                s_Record.Record.UPRN    = uaddress?.UPRN.ToString() ?? null;

                s_Record.Record.Latitude  = uaddress?.Latitude ?? s_Record.Record.Latitude;
                s_Record.Record.Longitude = uaddress?.Longitude ?? s_Record.Record.Longitude;

                s_Record.Record.TradeName   = TxtTradeName.Text;
                s_Record.Record.Received    = RcvdDueDate.Date + RcvdDueTime.Time;
                s_Record.Record.RequestType = AppData.ConfigModel.AllRequestTypes(
                    AppData.MainModel.CurrentUser.Organisations.Select(x => x.Organisation.Name).FirstOrDefault())
                                              .FirstOrDefault(x => x.Description == PkrRequestType.Items[PkrRequestType.SelectedIndex]).Code;
                s_RequestGroup.Name      = s_Record.RequestTypeDescription;
                s_RequestGroup.GroupType = s_Record.Record.RequestType;
                s_Record.Record.Inspections[0].InspectionType = AppData.ConfigModel.Inspections(
                    AppData.MainModel.CurrentUser.Organisations.Select(x => x.Organisation.Name).FirstOrDefault())
                                                                .FirstOrDefault(x => x.Description == PkrInspectionType.Items[PkrInspectionType.SelectedIndex]).Code;
                s_Record.Record.Details = EdPropertyDetails.Text;
                //
                AppData.PropertyModel.Update(s_Record, s_Record);
                //AppData.PropertyModel.SelectedProperty.UpdateFields();
                await SplitView.HubMaster.ReloadPropertyData();
            }
            catch (Exception ex)
            {
                LogTracking.LogTrace(ex.ToString());
            }
        }
Exemple #3
0
 /// ------------------------------------------------------------------------------------------------
 #region Public Constructor
 /// ------------------------------------------------------------------------------------------------
 ///
 /// ------------------------------------------------------------------------------------------------
 /// Name		SRiRequestGroup
 ///
 /// <summary>	Creates a new instnace of the SRiRequestGroup class using a SRiRecordMeta as
 ///             the starting pram.
 /// </summary>
 /// <param name="record">		The record to create them all.</param>
 ///
 /// <remarks>
 /// </remarks>
 /// ------------------------------------------------------------------------------------------------
 ///
 public SRiRequestGroup(SRiRecordMeta record)
 {
     Name      = record.RequestTypeDescription;
     GroupType = record.Record.RequestType;
     Records   = new List <SRiRecordMeta>()
     {
         record
     };
 }
Exemple #4
0
 public static void SetSavedStatus(this SRiRecordMeta r, SRiRecordMeta r2)
 {
     r.Record.Status = r2.Record.Status;
     //
     foreach (var i in r.Record.Inspections)
     {
         foreach (var i2 in r2.Record.Inspections)
         {
             if (i.KeyVal.Equals(i2.KeyVal))
             {
                 i.SetSavedStatus(i2);
                 break;
             }
         }
     }
 }
        ///
        /// ------------------------------------------------------------------------------------------------
        /// Name		Matches
        ///
        /// <summary>	Checks to see if the record matches the property on various fields.
        /// </summary>
        /// <param name="record">		The record.</param>
        ///
        /// <remarks>
        /// </remarks>
        /// ------------------------------------------------------------------------------------------------
        ///
        public bool Matches(SRiRecordMeta record)
        {
            bool match;

            //
            if (Match(TradeName, record.Record.TradeName))
            {
                match = (Match(UPRN, record.Record.UPRN) ||
                         Match(Address, new OnSiteAddress(record.Record.Address)));
            }
            else
            {
                match = false;
            }
            //
            return(match);
        }
 /// ------------------------------------------------------------------------------------------------
 #region Public Constructors
 /// ------------------------------------------------------------------------------------------------
 ///
 /// ------------------------------------------------------------------------------------------------
 /// Name		SRiProperty
 ///
 /// <summary>	Creates a new instance of the SRIProperty class.
 /// </summary>
 /// <param name="record">		The first record in the record collection.</param>
 ///
 /// <remarks>
 /// </remarks>
 /// ------------------------------------------------------------------------------------------------
 ///
 public SRiProperty(SRiRecordMeta record)
 {
     RequestGroups   = new List <SRiRequestGroup>();
     Documents       = new List <OnSiteDocumentData>();
     PropertyDetails = new List <SRiPropertyDetail>();
     CPInfos         = new List <SRiCPInfoMeta>();
     LICases         = new List <SRiLICaseMeta>();
     //
     Address   = new OnSiteAddress(record.Record.Address);
     Latitude  = record.Record.Latitude;
     Longitude = record.Record.Longitude;
     TradeName = record.Record.TradeName;
     UPRN      = record.Record.UPRN;
     //Added by Gowtham for getting organisation name in the Property field. It has not been in the code given by louis.
     Organisation = record.Organisation;
     RequestGroups.Add(new SRiRequestGroup(record));
 }
Exemple #7
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();
        }
        ///
        /// ------------------------------------------------------------------------------------------------
        /// Name		AddRecord
        ///
        /// <summary>	Adds a record to the request group collection. Putting it in either an existing
        ///             group that has a matching request type or creating a new group.
        /// </summary>
        /// <param name="record">		The record to add.</param>
        ///
        /// <remarks>
        /// </remarks>
        /// ------------------------------------------------------------------------------------------------
        ///
        public void AddRecord(SRiRecordMeta record)
        {
            bool addedToGroup;

            //
            addedToGroup = false;
            foreach (var rg in RequestGroups)
            {
                if (rg.GroupType.Equals(record.Record.RequestType))
                {
                    rg.Records.Add(record);
                    addedToGroup = true;
                    break;
                }
            }
            //
            if (!addedToGroup)
            {
                RequestGroups.Add(new SRiRequestGroup(record));
            }
            //
            // If any of the record fields in the property are missing,
            // take the field from the new record.
            if (string.IsNullOrEmpty(UPRN))
            {
                UPRN = record.Record.UPRN;
            }
            if (string.IsNullOrEmpty(TradeName))
            {
                TradeName = record.Record.TradeName;
            }
            if (string.IsNullOrEmpty(Address.RawAddress))
            {
                Address = new OnSiteAddress(record.Record.Address);
            }
            if (!HasValidCoords)
            {
                Latitude  = record.Record.Latitude;
                Longitude = record.Record.Longitude;
            }
            //Added by Gowtham for getting organisation name in the new property. It has not been in the code given by louis.
            Organisation = record.Organisation;
        }