Esempio n. 1
0
 public object[] DownloadProjectITPSection10(string sSessionId, string sUser, string sId)
 {
     try
     {
         clsLocalUtils util = new clsLocalUtils();
         string sURL = util.GetEnvironment_wbsURL("wbsITP_External");
         wbsITP_External ws = new wbsITP_External();
         ws.Url = sURL;
         object[] objListITPs = ws.GetITPProjectSection10Info(sSessionId, sUser, sId);
         return objListITPs;
     }
     catch (Exception ex)
     {
         object[] objListITPs = new object[2];
         objListITPs[0] = "Failure";
         objListITPs[1] = ex.Message.ToString();
         return objListITPs;
     }
 }
Esempio n. 2
0
        public bool FillITPValidHierarchyTable(string sSessionId, string sUser, ref string sRtnMsg)
        {
            try
            {
                clsTabletDB.ITPStaticTable Static = new clsTabletDB.ITPStaticTable();
                clsTabletDB.ITPValidHierarchy ITPValidHierarchy = new clsTabletDB.ITPValidHierarchy();
                LocalDB DB = new LocalDB();
                double dNewVersionNumber = 0.0;
                DateTime dtLastVersionDate;
                string sITPValidHierarchyTableName = ITPValidHierarchy.sITPValidHierarchyTableName;

                //Only do all of this if the version has changed. So get the local version number 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, sITPValidHierarchyTableName, ref dNewVersionNumber, ref dtLastVersionDate);

                if (!DB.TableExists(sITPValidHierarchyTableName) || bNewVersion)
                {
                    clsLocalUtils util = new clsLocalUtils();
                    string sURL = util.GetEnvironment_wbsURL("wbsITP_External");
                    wbsITP_External ws = new wbsITP_External();
                    ws.Url = sURL;
                    object[] objValidHierarchy = ws.GetITPValidHierarchyInfo(sSessionId, sUser);
                    if (objValidHierarchy[0].ToString() == "Success")
                    {
                        if (ITPValidHierarchy.TableITPValidHierarchyDeleteAllRecords(ref sRtnMsg))
                        {
                            string sITPValidHierarchyInfo = objValidHierarchy[1].ToString();
                            string[] sHeaderInfo = sITPValidHierarchyInfo.Split('~');
                            if (sHeaderInfo[0] == "ITPValidHierarchyInfo")
                            {
                                string[] delimiters = new string[] { "||" };
                                string[] sITPValidHierarchyItems = sHeaderInfo[1].Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
                                int iValidHierarchyCount = sITPValidHierarchyItems.Length;
                                if (iValidHierarchyCount > 0)
                                {
                                    this.InvokeOnMainThread(() => { progBarValidHierarchyVw.ShowProgressBar(iValidHierarchyCount); });
                                    //First check if the ITPValidHierarchy table exists and if not create it
                                    if (ITPValidHierarchy.CheckFullITPValidHierarchyTable())
                                    {
                                        SqliteConnection conn = DB.OpenConnection();
                                        for (int i = 0; i < iValidHierarchyCount; i++)
                                        {
                                            string[] delimiters2 = new string[] { "^" };
                                            string[] sValidHierarchyItems = sITPValidHierarchyItems[i].Split(delimiters2, StringSplitOptions.None);
                                            string sFieldValue = sValidHierarchyItems[0];
                                            string sFieldType = sValidHierarchyItems[1];
                                            Array.Resize<string>(ref sValidHierarchyItems, sValidHierarchyItems.Length + 1);
                                            sValidHierarchyItems[sValidHierarchyItems.Length - 1] = sFieldType;
                                            sValidHierarchyItems[sValidHierarchyItems.Length - 2] = sFieldValue;
                                            sValidHierarchyItems[0] = i.ToString();
                                            ITPValidHierarchy.TableITPValidHierarchyAddRecord(sValidHierarchyItems, conn);
                                            this.InvokeOnMainThread(() => { progBarValidHierarchyVw.UpdateProgressBar(i + 1); });
                                        }
                                        DB.CloseConnection(conn);

                                    }
                                }
                            }
                        }
                        //Update the version number locally
                        Static.UpdateVersionNumber(sITPValidHierarchyTableName, dNewVersionNumber);
                        this.InvokeOnMainThread(() => { progBarValidHierarchyVw.CloseProgressBar(); });
                        return true;
                    }
                    else
                    {
                        sRtnMsg = objValidHierarchy[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;
            }
        }
Esempio n. 3
0
        public bool FillITPInventoryMainTable(string sSessionId, string sUser, ref string sRtnMsg)
        {
            try
            {
                clsTabletDB.ITPStaticTable Static = new clsTabletDB.ITPStaticTable();
                clsTabletDB.ITPInventory ITPInventory = new clsTabletDB.ITPInventory();
                LocalDB DB = new LocalDB();
                double dNewVersionNumber = 0.0;
                DateTime dtLastVersionDate;
                DateTime dtToday = DateTime.Now;
                string sITPInventoryTableName = ITPInventory.sITPInventoryTableName;

                //Only do all of this if the version has changed. So get the local version number 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, sITPInventoryTableName, ref dNewVersionNumber, ref dtLastVersionDate);
                TimeSpan ts = dtToday - dtLastVersionDate;
                int iDaysSinceUpdate = ts.Days;

                if (!DB.TableExists(sITPInventoryTableName) || bNewVersion || iDaysSinceUpdate >= 30)
                {
                    clsLocalUtils util = new clsLocalUtils();
                    string sURL = util.GetEnvironment_wbsURL("wbsITP_External");
                    wbsITP_External ws = new wbsITP_External();
                    ws.Url = sURL;
                    object[] objInventory = ws.GetITPInventoryInfo(sSessionId, sUser);
                    if (objInventory[0].ToString() == "Success")
                    {
                        if (ITPInventory.TableITPInventoryDeleteAllRecords(ref sRtnMsg))
                        {
                            string sITPInventoryInfo = objInventory[1].ToString();
                            string[] sHeaderInfo = sITPInventoryInfo.Split('~');
                            if (sHeaderInfo[0] == "ITPInventoryMakeAndModelInfo")
                            {
                                string[] delimiters = new string[] { "||" };
                                string[] sITPInventoryItems = sHeaderInfo[1].Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
                                int iInventoryCount = sITPInventoryItems.Length;
                                if (iInventoryCount > 0)
                                {
                                    this.InvokeOnMainThread(() => { progBarInventoryVw.ShowProgressBar(iInventoryCount); });
                                    //First check if the ITPInventory table exists and if not create it
                                    if (ITPInventory.CheckFullITPInventoryTable())
                                    {
                                        for (int i = 0; i < iInventoryCount; i++)
                                        {
                                            string[] delimiters2 = new string[] { "^" };
                                            string[] sInventoryItems = sITPInventoryItems[i].Split(delimiters2, StringSplitOptions.None);
                                            ITPInventory.TableITPInventoryAddRecord(sInventoryItems);
                                            this.InvokeOnMainThread(() => { progBarInventoryVw.UpdateProgressBar(i + 1); });
                                        }
                                    }
                                }
                            }
                        }
                        //Update the version number locally
                        Static.UpdateVersionNumber(sITPInventoryTableName, dNewVersionNumber);
                        this.InvokeOnMainThread(() => { progBarInventoryVw.CloseProgressBar(); });
                        return true;
                    }
                    else
                    {
                        sRtnMsg = objInventory[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;
            }
        }
Esempio n. 4
0
        public void LogintoSCMS(object sender, EventArgs e)
        {
            var txtName = (UITextField)View.ViewWithTag (1000);
            string sName = txtName.Text;

            var txtPass = (UITextField)View.ViewWithTag (2000);
            string sPass = txtPass.Text;

            try{
            clsLocalUtils util = new clsLocalUtils ();
            string sURL = util.GetEnvironment_wbsURL ("wbsITP_Exernal");
            wbsITP_External ws = new wbsITP_External ();
            ws.Url = sURL;
            ws.CookieContainer = new CookieContainer ();
            //                object[] sTest = ws.GetITPBatteryFuseTypeInfo("","gmorris");
            string sSessionId = ws.CookieLogin (sName, sPass);

            HomeScreen homeScreen = (HomeScreen)NavigationController.ViewControllers [0];
            if (sSessionId != "") {
                var hfLoggedIn = (UILabel)View.ViewWithTag (3000);
                hfLoggedIn.Text = "1";
                homeScreen.SetLoginName (sName);
                homeScreen.SetSessionId (sSessionId);
                homeScreen.SetLoggedInStatus("1");
                NavigationController.PopToViewController (homeScreen, true);
                //this.Dispose();

            }
            else
            {
                iUtils.AlertBox alert = new iUtils.AlertBox();
                alert.CreateErrorAlertDialog("Incorrect username and/or password");
                homeScreen.SetLoginName ("Not logged in to SCMS");
                homeScreen.SetSessionId ("");
                homeScreen.SetLoggedInStatus("0");
            }
            }
            catch(Exception ex)
            {
                string sRtn = ex.Message.ToString();
                iUtils.AlertBox alert = new iUtils.AlertBox();
                alert.CreateErrorAlertDialog(sRtn);
            }
        }
Esempio n. 5
0
            public bool IsNewVersionOfTable(string sSessionId, string sUser, string sTableName, ref double dNewVersionNumber)
            {
                string sSQLLocal = "Select VersionNumber from " + sDocITPStaticTableName + " where TableName = '" + sTableName + "'";
                string sRtnMsg = "";
                double dLocalVersion = -1.0;
                string[] colNameLocal = new string[1];

                colNameLocal[0] = "VersionNumber";

                dLocalVersion = DB.GetSQLValue(sSQLLocal, 0, ref sRtnMsg);
                DataSet ds = DB.ReadSQLDataSet(sSQLLocal, colNameLocal, ref sRtnMsg);
                wbsITP_External ws = new wbsITP_External();
                object[] objRemote = ws.GetITPStaticTableVersionNumber(sSessionId, sUser, sTableName);
                double dRemoteVersion = 0.0;

                if ((bool)objRemote[0])
                {
                    dRemoteVersion = Convert.ToDouble(objRemote[1]);
                }

                if (dLocalVersion < dRemoteVersion)
                {
                    dNewVersionNumber = dRemoteVersion;
                    return true;
                }
                else
                {
                    return false;
                }
            }
Esempio n. 6
0
        public bool UploadITPInfo(string sSessionId, string sUser, string sId, ref string sRtnMsg)
        {
            try
            {
                clsTabletDB.ITPDocumentSection ITP = new clsTabletDB.ITPDocumentSection();
                clsTabletDB.ITPHeaderTable ITPHdr = new clsTabletDB.ITPHeaderTable();
                DataSet ds = ITP.GetAllLocalITPSectionQuestions(sId);
                string sSendString = "ITPUploadQuestionnaireInfo~";
                int i;
                int iRows = ds.Tables[0].Rows.Count;
                int iCol;
                int iAutoId;
                string sProjId;
                int iSectionId;
                string sQuestion;
                int iYes;
                int iNo;
                int iNA;
                bool bYes;
                bool bNo;
                bool bNA;
                string sComments;
                string sAudit_DateStamp;

                for (i = 0; i < iRows; i++)
                {
                    iCol = ds.Tables[0].Columns["AutoId"].Ordinal;
                    iAutoId = Convert.ToInt32(ds.Tables[0].Rows[i].ItemArray[iCol]);

                    iCol = ds.Tables[0].Columns["Id"].Ordinal;
                    sProjId = ds.Tables[0].Rows[i].ItemArray[iCol].ToString();

                    iCol = ds.Tables[0].Columns["SectionId"].Ordinal;
                    iSectionId = Convert.ToInt32(ds.Tables[0].Rows[i].ItemArray[iCol]);

                    iCol = ds.Tables[0].Columns["Question"].Ordinal;
                    sQuestion = ds.Tables[0].Rows[i].ItemArray[iCol].ToString();

                    iCol = ds.Tables[0].Columns["Yes"].Ordinal;
                    bYes = Convert.ToBoolean(ds.Tables[0].Rows[i].ItemArray[iCol]);
                    if (bYes)
                    {
                        iYes = 1;
                    }
                    else
                    {
                        iYes = 0;
                    }

                    iCol = ds.Tables[0].Columns["No"].Ordinal;
                    bNo = Convert.ToBoolean(ds.Tables[0].Rows[i].ItemArray[iCol]);
                    if (bNo)
                    {
                        iNo = 1;
                    }
                    else
                    {
                        iNo = 0;
                    }

                    iCol = ds.Tables[0].Columns["NA"].Ordinal;
                    bNA = Convert.ToBoolean(ds.Tables[0].Rows[i].ItemArray[iCol]);
                    if (bNA)
                    {
                        iNA = 1;
                    }
                    else
                    {
                        iNA = 0;
                    }

                    iCol = ds.Tables[0].Columns["Comments"].Ordinal;
                    sComments = ds.Tables[0].Rows[i].ItemArray[iCol].ToString();

                    iCol = ds.Tables[0].Columns["Audit_DateStamp"].Ordinal;
                    sAudit_DateStamp = ds.Tables[0].Rows[i].ItemArray[iCol].ToString();

                    sSendString += iAutoId + "^" + sProjId + "^" + iSectionId + "^" + sQuestion + "^" + iYes + "^" + iNo + "^" + iNA + "^" + sComments + "^" + sAudit_DateStamp + "||";
                }

                if (sSendString.Length > 2)
                {
                    sSendString = sSendString.Substring(0, sSendString.Length - 2);
                }

                clsLocalUtils util = new clsLocalUtils();
                string sURL = util.GetEnvironment_wbsURL("wbsITP_External");
                wbsITP_External ws = new wbsITP_External();
                ws.Url = sURL;
                object[] objListITP = ws.SetITPUploadInfo(sSessionId, sUser, sSendString);
                if (objListITP[0].ToString() == "Success")
                {
                    object[] objListITPStatus = ws.SetITPStatus(sSessionId, sUser, sId, 0);
                    if (objListITPStatus[0].ToString() == "Success")
                    {
                        //Now also mark them the same locally
                        if (!ITPHdr.MarkLocalITPDownloaded(sId, 1, ref sRtnMsg))
                        {
                            return false;
                        }
                        else
                        {
                            return true;
                        }
                    }
                    else
                    {
                        sRtnMsg = objListITPStatus[1].ToString();
                        return false;
                    }
                }
                else
                {
                    sRtnMsg = objListITP[1].ToString();
                    return false;
                }
            }
            catch (Exception ex)
            {
                sRtnMsg = ex.Message.ToString();
                return false;
            }
        }
Esempio n. 7
0
 public bool MarkITPDownloaded(string sSessionId, string sUser, string sId, ref string sRtnMsg)
 {
     try
     {
         clsTabletDB.ITPHeaderTable ITP = new clsTabletDB.ITPHeaderTable();
         clsLocalUtils util = new clsLocalUtils();
         string sURL = util.GetEnvironment_wbsURL("wbsITP_External");
         wbsITP_External ws = new wbsITP_External();
         ws.Url = sURL;
         object[] objListITP = ws.SetITPStatus(sSessionId, sUser, sId, 1);
         if (objListITP[0].ToString() == "Success")
         {
             //Now also mark them the same locally
             if (!ITP.MarkLocalITPDownloaded(sId, 0, ref sRtnMsg))
             {
                 return false;
             }
             else
             {
                 return true;
             }
         }
         else
         {
             sRtnMsg = objListITP[1].ToString();
             return false;
         }
     }
     catch (Exception ex)
     {
         sRtnMsg = ex.Message.ToString();
         return false;
     }
 }
Esempio n. 8
0
 public object[] GetITPsForDownload(string sSessionId, string sUser)
 {
     try
     {
         clsLocalUtils util = new clsLocalUtils();
         string sURL = util.GetEnvironment_wbsURL("wbsITP_External");
         wbsITP_External ws = new wbsITP_External();
         ws.Url = sURL;
         object[] objListITPs = ws.GetSubcontractorITPsForDownload(sSessionId, sUser);
         return objListITPs;
     }
     catch (Exception ex)
     {
         object[] objListITPs = new object[2];
         objListITPs[0] = "Failure";
         objListITPs[1] = ex.Message.ToString();
         return objListITPs;
     }
 }
Esempio n. 9
0
 public bool FillITPTypeMainTable(string sSessionId, string sUser, ref string sRtnMsg)
 {
     try
     {
         ITPStaticTable Static = new ITPStaticTable();
         double dNewVersionNumber = 0.0;
         //Only do all of this if the version has changed. So get the local versoin 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, sITPTypeTableName, ref dNewVersionNumber);
         if (!DB.TableExists(sITPTypeTableName) || bNewVersion)
         {
             clsLocalUtils util = new clsLocalUtils();
             string sURL = util.GetEnvironment_wbsURL("wbsITP_External");
             wbsITP_External ws = new wbsITP_External();
             ws.Url = sURL;
             object[] objQuestions = ws.GetITPFullITPTypeInfo(sSessionId, sUser);
             if (objQuestions[0].ToString() == "Success")
             {
                 if (TableITPTypeDeleteAllRecords(ref sRtnMsg))
                 {
                     string sITPDocumentQuestionnaireInfo = objQuestions[1].ToString();
                     string[] sHeaderInfo = sITPDocumentQuestionnaireInfo.Split('~');
                     if (sHeaderInfo[0] == "ITPTypeInfo")
                     {
                         string[] delimiters = new string[] { "||" };
                         string[] sQuestionnaireItems = sHeaderInfo[1].Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
                         int iQuestionCount = sQuestionnaireItems.Length;
                         if (iQuestionCount > 0)
                         {
                             //First check if the ITPType table exists and if not create it
                             if (CheckFullITPTypeTable())
                             {
                                 for (int i = 0; i < iQuestionCount; i++)
                                 {
                                     string[] delimiters2 = new string[] { "^" };
                                     string[] sQuestionItems = sQuestionnaireItems[i].Split(delimiters2, StringSplitOptions.None);
                                     TableITPTypeAddRecord(sQuestionItems);
                                 }
                             }
                         }
                     }
                 }
                 //Update the version number locally
                 Static.UpdateVersionNumber(sITPTypeTableName, dNewVersionNumber);
                 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;
     }
 }