Esempio n. 1
0
        public string GetCurrentVersion()
        {
            frmStart myStart = new frmStart();

            string      result   = "";
            XmlDocument oXML     = new XmlDocument();
            string      sVersion = "";

            // Create the web request
            RETRIES = 6;

            for (int i = 1; i <= RETRIES; i++)
            {
                if (sVersion != "")
                {
                    return(sVersion);
                }

                try
                {
                    WebRequest  request  = WebRequest.Create(VERSION_URL);
                    WebResponse response = request.GetResponse();

                    using (response)
                    {
                        // Get the response stream
                        StreamReader reader = new StreamReader(response.GetResponseStream());

                        // Read the whole contents and return as a string
                        result = reader.ReadToEnd();

                        oXML.LoadXml(result);
                        XmlNodeList oList = oXML.GetElementsByTagName("version");
                        sVersion = oList.Item(0).InnerText;
                    }
                }
                catch (Exception ex)
                {
                    logger mylog = new logger();
                    mylog.makelog("Exception:" + i.ToString());
                    if (i == 5)
                    {
                        frmStart.HandleException(ex, false);
                    }
                    return(sVersion);
                }
            }


            return(sVersion);
        }
Esempio n. 2
0
        private frmShowLog ShowLog;                         //Debug logging

        public frmSearch()
        {
            #region Start Logger
            logger mylog = new logger();

            //kill log
            if (File.Exists("logfile.txt"))
            {
                File.Delete("logfile.txt");
            }

            mylog.makelog("Starting PO Search");
            #endregion

            InitializeComponent();
        }
Esempio n. 3
0
        public frmStockCountStart(frmStockMenu pfrmParent)
        {
            #region Start Logger
            logger mylog = new logger();

            mylog.makelog("Starting Stock Count");
            #endregion

            InitializeComponent();
            this.button1.BackColor  = System.Drawing.Color.LightGreen;
            this.textBox1.BackColor = System.Drawing.Color.Beige;
            this.textBox2.BackColor = System.Drawing.Color.Beige;
            this.frmParent          = pfrmParent;
            this.RefreshSAPGateway();
            this.comboBox1.Focus();
        }
Esempio n. 4
0
        private void cmdLogon_Click(object sender, System.EventArgs e)
        {
            logger mylog = new logger();

            mylog.makelog("Login");

            HTTPSAPGateway SAPGateway = new HTTPSAPGateway();
            string         sMessage   = "";

            Cursor.Current = Cursors.WaitCursor;
            Cursor.Show();

            if (SAPGateway.CheckLogin(this.txtUname.Text, this.txtPword.Text, out sMessage))
            {
                frmStart frmMain = (frmStart)this.Parent;
                this.frmParent.SAPUname = this.txtUname.Text;
                this.frmParent.SAPPword = this.txtPword.Text;

                this.frmParent.SAPUname = this.txtUname.Text;
                this.frmParent.SAPPword = this.txtPword.Text;

                try
                {
                    this.frmParent.SAPlogontime = new DateTime(DateTime.UtcNow.Ticks);
                    this.Close();
                }
                catch (Exception ex)
                {
                    frmStart.HandleException(ex, true);
                }
            }
            else
            {
                //MessageBox.Show(sMessage, frmStart.MESSAGE_BOX_TITLE);
                if (sMessage == "")
                {
                    this.lblStatusBar.Text = "Cannot Connect";
                }
                else
                {
                    this.lblStatusBar.Text = sMessage;
                }
            }

            SAPGateway     = null;
            Cursor.Current = Cursors.Default;
        }
Esempio n. 5
0
        public bool CheckLogin(string sUname, string sPassword, out string sMessage)
        {
            //check the wifi status


            int WIFISTATE = (int)Registry.GetValue("HKEY_LOCAL_MACHINE\\System\\State\\Hardware", "WiFi", -1);

            logger mylog = new logger();

            sMessage = "WIFI:" + WIFISTATE;

            mylog.makelog(sMessage);

            string sPOST = BASE_URL + "?FUNCTION=LOGIN&UNAME=" + sUname + "&PWORD=" + sPassword;

            if (frmStart.debug != true)
            {
                mylog.makelog(sPOST);
            }

            string sXML = RunQuery(sPOST);


            XmlDocument xml = new XmlDocument();

            xml.LoadXml(sXML);
            XmlNodeList nodeResult = xml.GetElementsByTagName("result");
            bool        bOK        = false;

            sMessage = "";
            if (nodeResult.Count > 0)
            {
                if (nodeResult.Item(0).InnerText.Trim() == "OK")
                {
                    bOK      = true;
                    sMessage = "";
                }
                else
                {
                    sMessage = "Check Account (Locked?)";
                }
            }
            return(bOK);
        }
Esempio n. 6
0
        /// <summary>
        /// Warns the user if the version in the assembly file does not match
        /// the version on the web servers' CurrentVersionXML
        /// </summary>
        private void CheckVersion()
        {
            logger mylog = new logger();

            mylog.makelog("Calling CheckVersion");

            this.lblStatusBar.Text = "Checking Version..";
            this.lblStatusBar.Update();

            Type           t        = typeof(ce5b.frmStart);
            HTTPSAPGateway oGateway = new HTTPSAPGateway();

            this.sCurrent = oGateway.GetCurrentVersion().Trim();
            this.sRunning = t.Assembly.GetName().Version.ToString().Trim();

            //if (this.sCurrent != this.sRunning)
            //{

            //    if (Program.PlatformType == "SYMBOL WinCE")
            //    {
            //        string sWarn = "The application is not the current version.\n " +
            //            "Please Close Application and Download latest version via link";
            //        MessageBox.Show(sWarn, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
            //        this.lblStatusBar.Text = "Incorrect Version :" + sCurrent;
            //    }
            //    else
            //    {
            //        string sWarn = "The application is not the current version.\n " +
            //            "Please Close Application and Download latest version via link";
            //        MessageBox.Show(sWarn, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
            //        this.lblStatusBar.Text = "Incorrect Version :" + sCurrent;
            //    }
            //}
            //else
            //{
            //    this.lblStatusBar.Text = "Checked Version :" + sCurrent;
            //}

            this.lblStatusBar.Update();

            mylog.makelog("Exit Check Version");
            mylog.makelog(this.sCurrent);
        }
Esempio n. 7
0
        private void SetSystem(string SystemName)
        {
            logger mylog = new logger();

            mylog.makelog("SetSystem:" + SystemName);

            if (SystemName == "Debug")
            {
                cmdPMGI.Enabled = false;
            }
            cmdPMGR.Enabled       = false;
            cmdStockCount.Enabled = false;

            Cursor.Current = Cursors.WaitCursor;
            Cursor.Show();

            this.Refresh();

            if (SystemName != "LIVE")
            {
//go to DEV, TEST etc
                SERVICE_URL = "http://nisapwireless/PMWebServices" + SystemName + "/POFunctions.asmx";
            }
            else
//go to LIVE
            {
                SERVICE_URL = "http://nisapwireless/PMWebServices/POFunctions.asmx";
            }

            this.sSystemText = SystemName + " SYSTEM ";
            RUNNING_SYSTEM   = SystemName;;
            LogoffSAP();
            this.Refresh();

            Cursor.Current = Cursors.Default;

            cmdPMGI.Enabled       = true;
            cmdPMGR.Enabled       = true;
            cmdStockCount.Enabled = true;
        }
Esempio n. 8
0
        public static void HandleException(Exception ex, string sBoxTitle, bool bIgnore)
        {
            if (!bIgnore)
            {
                logger mylog = new logger();

                mylog.makelog(ex.Message);

                string sMess = ex.Message;
                if (IsConnectionError(ex))
                {
                    sMess += "\nPlease try again as the network connection may have been temporarily lost.";
                    //MessageBox.Show(sMess, sBoxTitle);
                    mylog.makelog(ex.Message);
                    mylog.makelog(sMess);
                }
                else
                {
                    mylog.makelog(ex.Message);
                }
            }
        }
Esempio n. 9
0
        public frmStockCountMain(string sDoc, string sXML, string sPlantName, string psPlant, frmCountByDocument pfrmParent)
        {
            #region Start Logger
            logger mylog = new logger();

            mylog.makelog("Starting Stock Count Main");
            #endregion
            InitializeComponent();

            this.sIBLNR            = sDoc;
            this.frmParent         = pfrmParent;
            this.txtEdit.Font      = this.dgOverview.Font;
            this.txtSernrEdit.Font = this.dgSerial.Font;
            this.txtPlant.Text     = sPlantName;
            this.sPlant            = psPlant;
            this.cmdPost.BackColor = System.Drawing.Color.LightGreen;
            this.BuildGrid();
            this.BuildVarianceGrid();
            this.BuildSernrTab();
            this.LoadData(sXML);
            this.RefreshSAPGateway();
        }
Esempio n. 10
0
        public static void HandleException(Exception ex, bool bIgnore)
        {
            if (!bIgnore)
            {
                logger mylog = new logger();

                mylog.makelog(ex.Message);

                string sMess = ex.Message;
                if (IsConnectionError(ex))
                {
                    sMess += "\nPlease try again as the network connection may have been temporarily lost.";
                    //MessageBox.Show(sMess, MESSAGE_BOX_TITLE);
                    mylog.makelog(ex.Message);
                    mylog.makelog(sMess);
                }
                else
                {
                    sMess = "Unknown Error-See Log";
                    mylog.makelog(ex.Message);
                }
            }
        }
Esempio n. 11
0
        public frmSearch(frmPOGR lfrmParent)
        {
            #region Start Logger
            logger mylog = new logger();

            //kill log
            if (File.Exists("logfile.txt"))
            {
                File.Delete("logfile.txt");
            }

            mylog.makelog("Starting PMGM");
            #endregion

            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();
            //
            // TODO: Add any constructor code after InitializeComponent call
            //
            this.frmParent = lfrmParent;
        }
Esempio n. 12
0
        //      public frmCountByDocument(frmStockCountStart pfrmParent)
        public frmCountByDocument(frmStockMenu pfrmParent)

        {
            #region Start Logger
            logger mylog = new logger();

            //kill log
            if (File.Exists("logfile.txt"))
            {
                File.Delete("logfile.txt");
            }

            mylog.makelog("Starting CountByDocument");
            #endregion

            InitializeComponent();

            this.frmParent = pfrmParent;
            this.RefreshSAPGateway();

            this.lblStatusBar.Text = this.frmParent.frmParent.lblStatusBar.Text;
            this.lblStatusBar.Update();
        }
Esempio n. 13
0
        private void frmStart_Load(object sender, System.EventArgs e)
        {
            #region Start Logger
            logger mylog = new logger();

            //kill log
            if (File.Exists("logfile.txt"))
            {
                File.Delete("logfile.txt");
            }

            mylog.makelog("Starting Application");

            mylog.makelog("VersionDate:28.07.10:12:00");

//            if (Program.PlatformType == "SYMBOL WinCE")
//            {
//                mylog.makelog("CE5 Device");
//            }
//            else
//            {
////At the moment the CE5 guns will be updated manually so the version check is temporarily disabled
//                this.CheckVersion();
//                mylog.makelog("PPC Device");
//            }

            #endregion

            this.cmdExit.BackColor       = System.Drawing.Color.Red;
            this.cmdPMGI.BackColor       = System.Drawing.Color.LightGreen;
            this.cmdPMGR.BackColor       = System.Drawing.Color.LightGreen;
            this.cmdStockCount.BackColor = System.Drawing.Color.LightGreen;


            //define the default starting system
            SetSystem("LIVE");
        }
Esempio n. 14
0
        //Call Inventory functions via Login
        private void cmdStockCount_Click(object sender, System.EventArgs e)
        {
            logger mylog = new logger();

            mylog.makelog("Calling INV");

            frmStock = new frmStockMenu(this);

            frmStock.SetParent(this);

            UpdateLastDidSomethingAt();
            try
            {
                frmStock.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                HandleException(ex, true);
            }

            frmStock = null;
            this.Refresh();
        }
Esempio n. 15
0
        private string RunQuery(string sPOST)
        {
            logger mylog = new logger();

            mylog.makelog("RunQuery");

            string       sXML = "<result></result>";
            WebRequest   oReq;
            WebResponse  oRes = null;
            Encoding     encode;
            StreamReader sr;
            Stream       ReceiveStream = null;


            //      sPOST = "http://10.194.9.22/FSGWireless/XMLInterface.aspx";

            byte[] requestBytes = Encoding.ASCII.GetBytes(sPOST);

            RETRIES = 6;

            try
            {
                for (int i = 1; i <= RETRIES; i++)
                {
                    try
                    {
                        mylog.makelog("RunQuery:" + i.ToString());



                        oReq = WebRequest.Create(sPOST);

                        //// If required by the server, set the credentials.
                        oReq.Credentials = CredentialCache.DefaultCredentials;

                        //// Check for aproxy server
                        //if (oReq.DefaultWebProxy.GetProxy(new System.Uri (sPOST)).ToString() ==sPOST)
                        //{
                        //    //is a proxy
                        //}
                        //else
                        //{
                        //    //is not a proxy
                        //}


                        //// If required by the server, set the credentials.
                        //request.Credentials = CredentialCache.DefaultCredentials;

                        //// Get the response.
                        //HttpWebResponse response = (HttpWebResponse)request.GetResponse();

                        //// Get the stream containing content returned by the server.
                        //Stream dataStream = response.GetResponseStream();

                        //// Open the stream using a StreamReader for easy access.
                        //StreamReader reader = new StreamReader(dataStream);

                        //// Read the content.
                        //string responseFromServer = reader.ReadToEnd();

                        //reader.Close();

                        oReq.Timeout       = TIMEOUT;
                        oReq.ContentLength = requestBytes.Length;
                        oReq.ContentType   = "appliication/x-www-form-urlencoded";
                        oReq.Method        = "POST";
                        Stream requestStream = oReq.GetRequestStream();
                        requestStream.Write(requestBytes, 0, requestBytes.Length);
                        requestStream.Close();

                        // oReq.Proxy = null;



                        oRes = oReq.GetResponse();


                        break;
                    }
                    catch (Exception ex)
                    {
                        //frmStart myStart = new frmStart();
                        mylog.makelog("Exception:" + i.ToString() + ":" + ex.Message);
                        //myStart.lblStatusBar.Text = ex.Message;

                        if (i == 5)
                        {
                            frmStart.HandleException(ex, false);
                        }
                    }
                }
                ReceiveStream = oRes.GetResponseStream();

                if (ReceiveStream != null)
                {
                    encode = System.Text.Encoding.GetEncoding("utf-8");
                    sr     = new StreamReader(ReceiveStream, encode);
                    sXML   = sr.ReadToEnd();

                    mylog.makelog(sXML);

                    ReceiveStream.Close();
                    oRes.Close();
                }
                ReceiveStream = null;
                encode        = null;
                sr            = null;
                oRes          = null;
                oReq          = null;
            }
            catch (Exception ex) { frmStart.HandleException(ex, false); }

            return(sXML);
        }
Esempio n. 16
0
        public frmLogon(frmStart frmParent)
        {
            string WifiString, HoldString;

            #region Start Logger
            logger mylog = new logger();

            mylog.makelog("Starting Login");
            #endregion

            InitializeComponent();
            this.frmParent = frmParent;

            //save the orinal message
            HoldString = this.frmParent.lblStatusBar.Text;

            //check wifi
            int WIFISTATE = (int)Registry.GetValue("HKEY_LOCAL_MACHINE\\System\\State\\Hardware", "WiFi", -1);

            switch (WIFISTATE)
            {
            case 1:
                WifiString = "WIFI:" + "Off";
                break;

            case 3:
                WifiString = "WIFI:" + "Medium";
                break;

            case 13:
                WifiString = "WIFI:" + "Good";
                break;

            default:
                WifiString = "WIFI:" + "Unknown:" + WIFISTATE;
                break;
            }

            //display wifi state
            this.frmParent.lblStatusBar.Text = WifiString;
            this.frmParent.lblStatusBar.Update();

            //wait
            System.Threading.Thread.Sleep(4000);

            //replace original message
            this.frmParent.lblStatusBar.Text = HoldString;
            lblStatusBar.Text = this.frmParent.lblStatusBar.Text;
            this.frmParent.lblStatusBar.Update();

            #region Set Debuuger
            if (frmStart.debug != false)//TRUE
            {
                this.mnuiDebugOn.Enabled = true;
                this.mnuiDebugOn.Text    = "Debug Off";
            }
            else
            {
                this.mnuiDebugOn.Enabled = true;
                this.mnuiDebugOn.Text    = "Debug On";
            }
            #endregion
        }