///
        /// ------------------------------------------------------------------------------------------------
        /// Name		GetLICases
        ///
        /// <summary>	Downloads LICASE data from the API using the supplied set of KeyVals.
        /// </summary>
        /// <param name="keyVals">		The KeyVals of the records to retreive.</param>
        ///
        /// <remarks>
        /// </remarks>
        /// ------------------------------------------------------------------------------------------------
        ///
        private async Task <SRiLICaseData> GetLICases(string[] keyVals)
        {
            ServiceClient            client;
            RequestResponseEventArgs response;
            SRiLICaseData            data;

            //
            m_oJsonError = null;
            if (AppData.Environment == OnSiteEnvironments.Sales || true)
            {
                data = SRiLICaseData.FromJson(Readfile("ServiceRequest.sr_licase.txt"), out m_oJsonError);
            }
            else
            {
                client = await GetServiceClient();

                response = await client.DownloadStringAsync(GetUrl("licase?keyvals=" + string.Join("/", keyVals)));

                if (HandleError(response))
                {
                    data = SRiLICaseData.FromJson(response.Text, out m_oJsonError);
                }
                else
                {
                    data = null;
                }
            }
            //
            return(data);
        }
        ///
        /// ------------------------------------------------------------------------------------------------
        /// Name		LoadCaseData
        ///
        /// <summary>	Loads the cached property collection from the device.
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// ------------------------------------------------------------------------------------------------
        ///
        public async Task <bool> LoadCaseData()
        {
            try
            {
                OnSiteConfigCache   config;
                SRiCPInfoData       cpinfoData;
                SRiLICaseData       licaseData;
                SRiCNApplPropData   historyData;
                SRiPRNotePadData    notesData;
                SRiRecordData       recordData;
                SRiVisitData        visitData;
                OnSiteDocumentCache docsData;
                FileSystemArgs      response, responseInfo;
                Exception           error;
                List <SRiProperty>  properties;
                //
                // Load the config first and then the data. Return true if both load successfully.
                response = Task.Run(() => FileSystem.ReadText(AppData.CONFIG)).Result;
                //response = await FileSystem.ReadText(AppData.CONFIG).Result;
                if (response.Error == null)
                {
                    config = OnSiteConfigCache.FromJson(response.TextContents, out error);
                    if (error == null && config != null)
                    {
                        AppData.ConfigModel.Add(config.Configs, true);

                        responseInfo = await FileSystem.ReadText(AppData.CPINFO);

                        cpinfoData = SRiCPInfoData.FromJson(responseInfo.TextContents, out error);
                        if (error != null)
                        {
                            return(false);
                        }

                        responseInfo = await FileSystem.ReadText(AppData.LICASE);

                        licaseData = SRiLICaseData.FromJson(responseInfo.TextContents, out error);
                        if (error != null)
                        {
                            return(false);
                        }

                        // licaseData = SRiLICaseData.FromJson(FileSystem.ReadText(AppData.LICASE).TextContents, out error);
                        //if (error != null) return false;

                        responseInfo = await FileSystem.ReadText(AppData.HISTORY);

                        historyData = SRiCNApplPropData.FromJson(responseInfo.TextContents, out error);
                        if (error != null)
                        {
                            return(false);
                        }

                        //historyData = SRiCNApplPropData.FromJson(FileSystem.ReadText(AppData.HISTORY).TextContents, out error);
                        //if (error != null) return false;

                        responseInfo = await FileSystem.ReadText(AppData.NOTES);

                        notesData = SRiPRNotePadData.FromJson(responseInfo.TextContents, out error);
                        if (error != null)
                        {
                            return(false);
                        }

                        //notesData = SRiPRNotePadData.FromJson(FileSystem.ReadText(AppData.NOTES).TextContents, out error);
                        //if (error != null) return false;

                        responseInfo = await FileSystem.ReadText(AppData.RECORDS);

                        recordData = SRiRecordData.FromJson(responseInfo.TextContents, out error);
                        if (error != null)
                        {
                            return(false);
                        }

                        //recordData = SRiRecordData.FromJson(FileSystem.ReadText(AppData.RECORDS).TextContents, out error);
                        //if (error != null) return false;

                        responseInfo = await FileSystem.ReadText(AppData.VISITS);

                        visitData = SRiVisitData.FromJson(responseInfo.TextContents, out error);
                        if (error != null)
                        {
                            return(false);
                        }

                        //visitData = SRiVisitData.FromJson(FileSystem.ReadText(AppData.VISITS).TextContents, out error);
                        //if (error != null) return false;

                        responseInfo = await FileSystem.ReadText(AppData.DOCS);

                        docsData = OnSiteDocumentCache.FromJson(responseInfo.TextContents, out error);
                        if (error != null)
                        {
                            return(false);
                        }

                        //docsData = OnSiteDocumentCache.FromJson(FileSystem.ReadText(AppData.DOCS).TextContents, out error);
                        //if (error != null || docsData == null) return false;
                        //Added to avoid error on no saced content for existing user
                        if (recordData != null && visitData != null)
                        {
                            recordData.AddVisits(visitData.Visits);
                            properties = recordData.CreateProperties(cpinfoData, licaseData, historyData, notesData);
                            if (AppData.Environment != OnSiteEnvironments.Sales)
                            {
                                properties.AddDocumentData(docsData.DocumentData);
                            }
                            AppData.LastSync = recordData.LastSync;
                            AppData.PropertyModel.Update(properties, true);
                        }
                    }
                }
                //
                return(false);
            }
            catch (Exception ex)
            {
                LogTracking.LogTrace(ex.ToString());
                return(false);
            }
        }