Exemplo n.º 1
0
        public static void AddOrdQ()
        {
            while (!AddOrdQStop)
            {
                if (OrdersQuery.Count() > 0)
                {
                    Utils.ToLog("get from query");
                    int Chid = 0;
                    int Tid  = 0;
                    DataReciver.STCommand InCommand         = OrdersQuery[0];
                    DataReciver.SendOrderToAlohaRequest req = InCommand.sendOrderToAlohaRequest;

                    SendOrderToAloha(req.OrderId, req.Items, req.CompanyId, req.CompanyName, req.BortName, req.DiscountId, req.Margin, req.TimeOfShipping, req.FreeDisc, out Chid, out Tid);
                    Thread.Sleep(5000);
                    Utils.ToLog("start RC.SendData ");
                    req.AlohaCheckId   = 1;
                    req.AlohaTableNum  = 1;
                    InCommand.Result   = true;
                    InCommand.ResultId = 1;
                    InCommand.Ansver   = true;

                    //  DataTCPSender RC = new DataTCPSender();
                    //  bool r = RC.SendData(InCommand.Sender, InCommand.SenderPort, InCommand);
                    //    Utils.ToLog("RC.SendData end" + r.ToString());
                    OrdersQuery.Remove(InCommand);
                }
                else
                {
                    Thread.Sleep(1000);
                }
            }
        }
Exemplo n.º 2
0
        public static void SendOrderToAloha(DataReciver.STCommand req)
        {
            OrdersQuery.Add(req);
            Utils.ToLog("Add req to query " + req.sendOrderToAlohaRequest.OrderId);

            foreach (OrderToAloha.Item itm in req.sendOrderToAlohaRequest.Items)
            {
                Utils.ToLog(string.Format("itm: {0}; Name: {1}", itm.BarCode, itm.Name));
            }
        }
Exemplo n.º 3
0
 public void SendOrderToAloha(DataReciver.SendOrderToAlohaRequest args)
 {
     DataReciver.STCommand SC = new DataReciver.STCommand()
     {
         Ansver                  = false,
         CommandType             = DataReciver.STCommandType.AddOrder,
         Id                      = new Guid(),
         Sender                  = Environment.MachineName,
         SenderPort              = innerPort,
         sendOrderToAlohaRequest = args
     };
     if (args.port == 0)
     {
         args.port = outerPort;
     }
     RemoteConnection.SendData(args.RemoteCompName, args.port, SC);
 }
Exemplo n.º 4
0
        public void DeleteOrder(DataReciver.DeleteOrderRequest args)
        {
            DataReciver.STCommand SC = new DataReciver.STCommand()
            {
                Ansver             = false,
                CommandType        = DataReciver.STCommandType.DeleteOrder,
                Id                 = new Guid(),
                Sender             = Environment.MachineName,
                SenderPort         = innerPort,
                deleteOrderRequest = args
            };
            if (args.port == 0)
            {
                args.port = outerPort;
            }
            RemoteConnection.SendData(args.RemoteCompName, args.port, SC);


            //  return AlohaTS.DeleteOrder(OrderId);
        }
        void RC_DataRecive(object Fi)
        {
            try
            {
                DataReciver.STCommand InCommand = (DataReciver.STCommand)Fi;


                //Utils.ToCardLog("RC_DataRecive тип " + InCommand.CommandType);
                if (InCommand.Ansver)
                {
                    DataReciver.AlohaResponse resp = new DataReciver.AlohaResponse();
                    resp.OrderId     = InCommand.sendOrderToAlohaRequest.OrderId;
                    resp.CommandType = InCommand.CommandType;
                    resp.Err         = InCommand.ExeptionMessage;
                    resp.port        = InCommand.SenderPort;
                    resp.ResultId    = InCommand.ResultId;
                    if (InCommand.CommandType == DataReciver.STCommandType.AddOrder)
                    {
                        resp.AlohaCheckId  = InCommand.sendOrderToAlohaRequest.AlohaCheckId;
                        resp.AlohaTableNum = InCommand.sendOrderToAlohaRequest.AlohaTableNum;
                    }
                    else if (InCommand.CommandType == DataReciver.STCommandType.DeleteOrder)
                    {
                    }



                    RaiseResponseEvent(resp);
                }
                else
                {
                }
            }
            catch (Exception e)
            {
                Utils.ToLog(e.Message);
            }
        }
        void RC_DataRecive(object Fi)
        {
            /*
             * try
             * {
             *  Utils.ToLog("StopServerLisenter");
             *  RC.StopServerLisenter();
             *  RC.
             * }
             * catch(Exception e)
             * { }
             */

            try
            {
                Utils.ToLog("RC_DataRecive InCommand");
                DataReciver.STCommand InCommand = (DataReciver.STCommand)Fi;

                Utils.ToLog("RC_DataRecive тип " + InCommand.CommandType);

                if (InCommand.Ansver)
                {
                }
                else
                {
                    switch (InCommand.CommandType)
                    {
                    case DataReciver.STCommandType.AddOrder:
                        try
                        {
                            DataReciver.SendOrderToAlohaRequest req = InCommand.sendOrderToAlohaRequest;

                            /*
                             * int Chid = 0;
                             * int Tid = 0;
                             *
                             * SendFromNetToAloha.SendOrderToAloha(req.OrderId, req.Items, req.CompanyId, req.CompanyName, req.BortName, req.DiscountId, req.Margin, req.TimeOfShipping, req.FreeDisc, out Chid, out Tid);
                             * */
                            int Chid = 1;
                            int Tid  = 1;
                            SendFromNetToAloha.SendOrderToAloha(InCommand);
                            Utils.ToLog("SendFromNetToAloha.SendOrderToAloha");
                            req.AlohaCheckId  = Chid;
                            req.AlohaTableNum = Tid;

                            InCommand.Result   = true;
                            InCommand.ResultId = 1;
                        }
                        catch (Exception e)
                        {
                            InCommand.Result          = false;
                            InCommand.ResultId        = 0;
                            InCommand.ExeptionMessage = e.Message;
                            //InCommand.e
                        }


                        break;

                    case DataReciver.STCommandType.DeleteOrder:

                        try
                        {
                            DataReciver.DeleteOrderRequest req = InCommand.deleteOrderRequest;


                            SendFromNetToAloha.DeleteOrder(req.OrderId);
                            InCommand.Result   = true;
                            InCommand.ResultId = 1;
                        }
                        catch (Exception e)
                        {
                            InCommand.Result          = false;
                            InCommand.ResultId        = 0;
                            InCommand.ExeptionMessage = e.Message;
                            //InCommand.e
                        }
                        break;

                    default:
                        break;
                    }
                    InCommand.Ansver = true;
                    //Thread.Sleep(2000);
                    //bool r = RC.SendData(InCommand.Sender, InCommand.SenderPort, InCommand);
                    // Utils.ToLog("RC.SendData " + r.ToString());

                    /*
                     * switch (InCommand.CommandType)
                     * {
                     *  case DataReciver.PDiscountCommandType.OrderItems:
                     *      {
                     *          InCommand.Result = AlohaTSClass.OrderItems(InCommand.EntIds, InCommand.CheckId, InCommand.TableId, out InCommand.ExeptionMessage);
                     *          break;
                     *      }
                     *  case DataReciver.PDiscountCommandType.OrderAllItems:
                     *      {
                     *          InCommand.Result = AlohaTSClass.OrderAllItems(InCommand.CheckId, InCommand.TableId, out InCommand.ExeptionMessage);
                     *          break;
                     *      }
                     *  case DataReciver.PDiscountCommandType.GetStopList:
                     *      {
                     *          //InCommand.Result = AlohaTSClass.OrderAllItems(InCommand.CheckId, InCommand.TableId, out InCommand.ExeptionMessage);
                     *          InCommand.EntIds = AlohaTSClass.GetStopList2();
                     *          InCommand.Result = true;
                     *
                     *          break;
                     *      }
                     *  case DataReciver.PDiscountCommandType.AddRemoteOrder:
                     *      {
                     *
                     *          RemoteOrderSrv.OrderInfoForAloha OI = new RemoteOrderSrv.OrderInfoForAloha();
                     *
                     *          List<RemoteOrderSrv.Item> Tmpit = new List<RemoteOrderSrv.Item>();
                     *
                     *          OI.OrderID = "0";
                     *
                     *          foreach (DataReciver.Item it in InCommand.OrderBody)
                     *          {
                     *
                     *              RemoteOrderSrv.Item IT = new RemoteOrderSrv.Item
                     *              {
                     *                  ItemID = it.Barcode,
                     *                  ItemSpecialMessage = ""
                     *
                     *              };
                     *
                     *              Tmpit.Add(IT);
                     *              List<RemoteOrderSrv.Modifier> TmpMods = new List<RemoteOrderSrv.Modifier>();
                     *
                     *              foreach (DataReciver.Item mod in it.Mods)
                     *              {
                     *                  RemoteOrderSrv.Modifier md = new RemoteOrderSrv.Modifier
                     *                  {
                     *                      ItemModifierID = mod.Barcode
                     *
                     *                  };
                     *                  TmpMods.Add(md);
                     *              }
                     *
                     *              IT.Modifiers = TmpMods.ToArray();
                     *
                     *
                     *          }
                     *          OI.Items = Tmpit.ToArray();
                     *
                     *
                     *
                     *          InCommand.ResultId = MainClass.CTG.AddRemoteOrderFromTCPCommand(OI, out InCommand.ExeptionMessage);
                     *          break;
                     *      }
                     *  default:
                     *      {
                     *          break;
                     *      }
                     * }
                     * InCommand.Ansver = true;
                     *
                     * //   Utils.ToLog("RC.SendData port: " + iniFile.RemoteSenderPort + " CompName: " + InCommand.Sender);
                     * RC.SendData(InCommand.Sender, iniFile.RemoteSenderPort, InCommand);
                     * * */
                }
            }
            catch (Exception e)
            {
                //Utils.ToLog(e.Message);
                Utils.ToLog("Error RC_DataRecive InCommand");
            }
            Utils.ToLog("Recive End");
        }