Ejemplo n.º 1
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;
            }
        }
Ejemplo 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;
            }
        }
Ejemplo n.º 3
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);
            }
        }