Esempio n. 1
0
 public override void Start()
 {
     base.Start();
     MainProcess.MainForm.PerformInMainThread = GetTask;
     //ShowMessage("6");
     //MainProcess.MainForm.Focus();
     ////ShowMessage("7");
     ShowMessage("ќжидайте получение задани¤!");
     timer = new CallTimer(CheckTaskAvailable, 1000);
 }
Esempio n. 2
0
 public override void Start()
 {
     base.Start();
     MainProcess.MainForm.PerformInMainThread = GetTask;
     //ShowMessage("6");
     //MainProcess.MainForm.Focus();
     ////ShowMessage("7");
     "ќжидайте получение задани¤!".ShowMessage();
     timer = new CallTimer(CheckTaskAvailable, 1000);
 }
Esempio n. 3
0
        private void ReadPackages()
        {
            #region Define local variables

            string StorekeeperQuery = "", StorekeeperQueryHead = "";

            //Byte[] emptyData = System.Text.Encoding.GetEncoding(1251).GetBytes("");

            //int streamLength;

            #endregion

            while (wifiEnabled)
            {
                #region Getting package

                if (PackageViaWireless.isCompletelyPackage(StorekeeperQueryHead))
                {
                    StorekeeperQuery     = StorekeeperQueryHead;
                    StorekeeperQueryHead = "";
                }
                else
                {
                    StorekeeperQuery = ReadStream();
                    WriteToFile(" << ReadStream [" + StorekeeperQuery + "]", false);
                }


                Package = null;
                if (StorekeeperQuery == null)
                {
                    return;
                }

                StorekeeperQuery = StorekeeperQueryHead + StorekeeperQuery;

                if (!PackageViaWireless.isCompletelyPackage(StorekeeperQuery))
                {
                    StorekeeperQueryHead = StorekeeperQuery;
                    continue;
                }

                WriteToFile(" << Read Query [" + StorekeeperQuery + "]", false);
                try
                {
                    Package = new PackageViaWireless(StorekeeperQuery, out StorekeeperQueryHead);
                }
                catch (Exception exp)
                {
                    string.Format("", exp.Message);
                }

                if (PackageConvertation.PACKAGE_CONFIRMATION_NAME.Equals(Package.QueryName))
                {
                    sentDeliveryReport(PackageConvertation.GetPatametersFromStr(Package.Parameters)[0] as string);
                    continue;
                }

                lastPackageId = Package.PackageID;
                sentDeliveryReport(lastPackageId);

                StorekeeperQuery = "";

                #endregion

                #region Pinging server

                Trace.WriteLine(string.Format("Pack id: {0};\tquery = {1};\t{2}", Package.PackageID, Package.QueryName, DateTime.Now.ToString("mm:ss")));

                if (Package.QueryName == "Ping")
                {
                    Package.QueryName = "PingReply";
                    SendPackage(Package.GetPackage());
                    continue;
                }

                if (Package.QueryName == "PingReply")
                {
                    WriteToFile("? ShowPingResult");
                    DataRepresent.ShowPingValue(PackageConvertation.GetPatametersFromStr(Package.Parameters)[0] as string);
                    //Client.MainForm.ShowPingResult(PackageConvertation.GetPatametersFromStr(Package.Parameters)[0] as string);
                    WriteToFile("OK ShowPingResult");

                    continue;
                }

                #endregion

                if (Package.QueryName == "KeyPressing")
                {
                    SendKeyCode = (int)PackageConvertation.GetPatametersFromStr(Package.Parameters)[0];
                    var CallTimer = new CallTimer(SendKey, 1, true);
                    continue;
                }

                if (Package.QueryName == "BarcodeEvent")
                {
                    SendBarcode = PackageConvertation.GetPatametersFromStr(Package.Parameters)[0] as string;
                    var CallTimer = new CallTimer(SendKey, 1, true);
                    continue;
                }

                if (Package.QueryName == "TimeSynchronization")
                {
                    SetTime(PackageConvertation.GetPatametersFromStr(Package.Parameters)[0] as string);
                    continue;
                }

                if (Package.QueryName == "FileTransmit")
                {
                    object[] Params = PackageConvertation.GetPatametersFromStr(Package.Parameters);
                    StorekeeperQueryHead = AcceptFile(Params[0] as string, (int)Params[1], StorekeeperQueryHead, Convert.ToBoolean(Params[2]));
                    continue;
                }

                #region Message handling

                if (Package.QueryName == "Message")
                {
                    object[] Parameters = PackageConvertation.GetPatametersFromStr(Package.Parameters);
                    System.Windows.Forms.MessageBox.Show(Parameters[0] as string);

                    // В параметры записывается только ID, текс сообщения уже не нужен
                    Package.Parameters = ((int)Parameters[1]).ToString();
                    SendPackage(Package.GetPackage());
                    continue;
                }
                #endregion

                #region PackageHandling
                if (Package.PackageID != WaitingPackageID)
                {
                    continue;
                }
                Executed     = true;
                RequestReady = true;
                requestReadyTrigger.Set();
                requestReadyTrigger.WaitOne();

                while (RequestReady)
                {
                    Thread.Sleep(100);
                }
                #endregion
            }
        }
Esempio n. 4
0
        private void ReadPackages()
        {
            #region Define local variables

            string StorekeeperQuery = "", StorekeeperQueryHead = "";

            //Byte[] emptyData = System.Text.Encoding.GetEncoding(1251).GetBytes("");

            //int streamLength;

            #endregion

            while (wifiEnabled)
                {
                #region Getting package

                if (PackageViaWireless.isCompletelyPackage(StorekeeperQueryHead))
                    {
                    StorekeeperQuery = StorekeeperQueryHead;
                    StorekeeperQueryHead = "";
                    }
                else
                    {
                    StorekeeperQuery = ReadStream();
                    }

                Package = null;
                if (StorekeeperQuery == null) return;

                StorekeeperQuery = StorekeeperQueryHead + StorekeeperQuery;
                WriteToFile(" << Read Query [" + StorekeeperQuery + "]", false);

                if (!PackageViaWireless.isCompletelyPackage(StorekeeperQuery)) continue;

                Package = new PackageViaWireless(StorekeeperQuery, out StorekeeperQueryHead);

                StorekeeperQuery = "";

                #endregion

                #region Pinging server

                if (Package.QueryName == "Ping")
                    {
                    Package.QueryName = "PingReply";
                    SendPackage(Package.GetPackage());
                    continue;
                    }

                if (Package.QueryName == "PingReply")
                    {

                    WriteToFile("? ShowPingResult");
                    DataRepresent.ShowPingValue(PackageConvertation.GetPatametersFromStr(Package.Parameters)[0] as string);
                    //Client.MainForm.ShowPingResult(PackageConvertation.GetPatametersFromStr(Package.Parameters)[0] as string);
                    WriteToFile("OK ShowPingResult");

                    continue;
                    }

                #endregion

                if (Package.QueryName == "KeyPressing")
                    {
                    SendKeyCode = (int)PackageConvertation.GetPatametersFromStr(Package.Parameters)[0];
                    var CallTimer = new CallTimer(SendKey, 1, true);
                    continue;
                    }

                if (Package.QueryName == "BarcodeEvent")
                    {
                    SendBarcode = PackageConvertation.GetPatametersFromStr(Package.Parameters)[0] as string;
                    var CallTimer = new CallTimer(SendKey, 1, true);
                    continue;
                    }

                if (Package.QueryName == "TimeSynchronization")
                    {
                    SetTime(PackageConvertation.GetPatametersFromStr(Package.Parameters)[0] as string);
                    continue;
                    }

                if (Package.QueryName == "FileTransmit")
                    {
                    object[] Params = PackageConvertation.GetPatametersFromStr(Package.Parameters);
                    StorekeeperQueryHead = AcceptFile(Params[0] as string, (int)Params[1], StorekeeperQueryHead, Convert.ToBoolean(Params[2]));
                    continue;
                    }

                #region Message handling

                if (Package.QueryName == "Message")
                    {
                    object[] Parameters = PackageConvertation.GetPatametersFromStr(Package.Parameters);
                    System.Windows.Forms.MessageBox.Show(Parameters[0] as string);

                    // В параметры записывается только ID, текс сообщения уже не нужен
                    Package.Parameters = ((int)Parameters[1]).ToString();
                    SendPackage(Package.GetPackage());
                    continue;
                    }
                #endregion

                #region PackageHandling
                if (Package.PackageID != WaitingPackageID) continue;
                Executed = true;
                RequestReady = true;

                while (RequestReady)
                    {
                    Thread.Sleep(100);
                    }
                #endregion
                }
        }