public bool FillITPDocumentSectionMainTable(string sSessionId, string sUser, ref string sRtnMsg) { try { clsTabletDB.ITPStaticTable Static = new clsTabletDB.ITPStaticTable(); clsTabletDB.ITPDocumentSection ITPDocSection = new clsTabletDB.ITPDocumentSection(); LocalDB DB = new LocalDB(); string sITPDocumentSectionTableName = ITPDocSection.sITPDocumentSectionTableName; double dNewVersionNumber = 0.0; DateTime dtLastVersionDate; //Only do all of this if the version has changed. So get the local version umber and compare to that on the DB. If different do all of this. - WRITE LATER as a general function bool bNewVersion = Static.IsNewVersionOfTable(sSessionId, sUser, sITPDocumentSectionTableName, ref dNewVersionNumber, ref dtLastVersionDate); if (!DB.TableExists(sITPDocumentSectionTableName) || bNewVersion) { clsLocalUtils util = new clsLocalUtils(); string sURL = util.GetEnvironment_wbsURL("wbsITP_External"); wbsITP_External ws = new wbsITP_External(); ws.Url = sURL; object[] objQuestions = ws.GetITPFullDocumentSectionInfo(sSessionId, sUser); if (objQuestions[0].ToString() == "Success") { if (ITPDocSection.TableITPDocumentSectionDeleteAllRecords(ref sRtnMsg)) { string sITPDocumentQuestionnaireInfo = objQuestions[1].ToString(); string[] sHeaderInfo = sITPDocumentQuestionnaireInfo.Split('~'); if (sHeaderInfo[0] == "ITPDocumentSectionInfo") { string[] delimiters = new string[] { "||" }; string[] sDocSectionItems = sHeaderInfo[1].Split(delimiters, StringSplitOptions.RemoveEmptyEntries); int iQuestionCount = sDocSectionItems.Length; if (iQuestionCount > 0) { this.InvokeOnMainThread(() => { progBarSectionsVw.ShowProgressBar(iQuestionCount); }); //First check if the ITPType table exists and if not create it if (ITPDocSection.CheckFullDocumentSectionTable()) { for (int i = 0; i < iQuestionCount; i++) { string[] delimiters2 = new string[] { "^" }; string[] sQuestionItems = sDocSectionItems[i].Split(delimiters2, StringSplitOptions.None); ITPDocSection.TableITPDocumentSectionAddRecord(sQuestionItems); this.InvokeOnMainThread(() => { progBarSectionsVw.UpdateProgressBar(i + 1); }); } } } } } //Update the version number locally Static.UpdateVersionNumber(sITPDocumentSectionTableName, dNewVersionNumber); this.InvokeOnMainThread(() => { progBarSectionsVw.CloseProgressBar(); }); return true; } else { sRtnMsg = objQuestions[1].ToString(); return false; } } else { //This means you don't have to fill this static table return true; } } catch (Exception ex) { sRtnMsg = "Failure" + ex.Message.ToString(); return false; } }