Beispiel #1
0
        public async Task <string> InsertAdress(Adress adress)
        {
            await Collection.InsertOneAsync(adress);

            var coord = new Coordinates();
            var Uid   = Guid.NewGuid();

            coord.IdOperacion  = Uid.ToString();
            coord.Latitud      = "";
            coord.Longitud     = "";
            coord.Estado       = "PROCESANDO";
            adress.IdOperacion = coord.IdOperacion;
            await CollectionCD.InsertOneAsync(coord);

            _send = new SendMessages();
            _send.SendMessage(adress);

            return(Uid.ToString());
        }
        public isaCommand ReceiveMessage(isaCommand cmd)
        {
            switch (cmd.command)
            {
            case eCommand.Ping:
                Logger.Debug($"ReceiveMessage - Received Ping / Replying Pong..");
                WinSysSM.SendMessage(new Command()
                {
                    command = eCommand.Pong
                });
                break;

            case eCommand.Pong:
                Logger.Debug($"ReceiveMessage - Received Pong");
                break;

            case eCommand.GetNewHeads:
                Logger.Debug("GetNewHeads");
                manifestRequest req = (manifestRequest)cmd;
                dRetCall[NewGuid(cmd.requestId)](req.ToArray());
//                    cbsend(new Command() { command = eCommand.GetNewHeads }.ToArray());
                break;

            case eCommand.CreateCustomerAccount:
                Logger.Debug("CreateCustomerAccount");
                dRetCall[NewGuid(cmd.requestId)](cmd.ToArray());
                // cbsend(new Command() { command = eCommand.CreateCustomerAccount }.ToArray());
                break;

            case eCommand.GetCustomerBalance:
                Logger.Debug("GetCustomerBalance");
                dRetCall[NewGuid(cmd.requestId)](cmd.ToArray());
                break;

            case eCommand.CreateOrder:
                Logger.Debug("CreateOrder");
                dRetCall[NewGuid(cmd.requestId)](cmd.ToArray());
                break;

            case eCommand.ConfirmDelivery:
                Logger.Debug("ConfirmDelivery");
                dRetCall[NewGuid(cmd.requestId)](cmd.ToArray());
                break;

            case eCommand.Withdraw:
                Logger.Debug("Withdraw");
                dRetCall[NewGuid(cmd.requestId)](cmd.ToArray());
                break;

            case eCommand.SweepToCold:
                Logger.Debug("SweepToCold");
                dRetCall[NewGuid(cmd.requestId)](cmd.ToArray());
                break;

            case eCommand.TransferToHot:
                Logger.Debug("TransferToHot");
                dRetCall[NewGuid(cmd.requestId)](cmd.ToArray());
                break;

            default:
                Logger.Error("ReceiveMessage - ERROR Unknown command.  Parse Error MDM-API");
                break;
            }
            return(cmd);
        }
Beispiel #3
0
        public isaCommand ReceiveMessage(isaCommand cmd)
        {
            switch (cmd.command)
            {
            case eCommand.Ping:
                Logger.Debug($"ReceiveMessage - Received Ping / Replying Pong..");
                WinSysSM.SendMessage(new Command()
                {
                    command = eCommand.Pong
                });
                break;

            case eCommand.Pong:
                Logger.Debug($"ReceiveMessage - Received Pong");
                break;

            case eCommand.LoadFiles:
                Logger.Info($"ReceiveMessage - Copy Files from Winsys Server Paths top App Server Paths:{cmd.ToString()}");
                //CopyFilesToServer(DateTime.Today);
                Logger.Info($"ReceiveMessage - Replying LoadFilesComplete...");
                WinSysSM.SendMessage(new Command()
                {
                    command = eCommand.LoadFilesComplete
                });
                //cbsend(new Command() { command = eCommand.LoadFilesComplete }.ToArray());
                break;

            case eCommand.GenerateManifest:
                Logger.Info($"ReceiveMessage - Generate Manifest from Winsys and SqlServer:{cmd.ToString()}");
                manifestRequest req = (manifestRequest)cmd;
                WinSysSM.SendMessage(req);
                break;

            case eCommand.ManifestDetails:
                Logger.Info($"ReceiveMessage - Generate Manifest Details from Winsys - API Drill Down:{cmd.ToString()}");
                //drillDown.reportMDProgressChanged(50, cmd );
                foreach (var mmd in UMDServer.Persist(SPCmds.INSERTMANIFESTDETAILS, new ManifestDetailsData((manifestDetails)cmd)))
                {
                    drillDown.GetOrderMasterData((ManifestDetailsData)mmd);
                }
                break;

            case eCommand.ManifestDetailsComplete:
                Logger.Info($"ReceiveMessage - ManifestDetailsComplete:{cmd.ToString()}");
                //drillDown.reportMDProgressChanged(100, cmd);
                break;

            case eCommand.Orders:
                Logger.Info($"ReceiveMessage - Orders  reqId: {cmd.requestId}");
                foreach (var omd in UMDServer.Persist(SPCmds.INSERTORDER, new OrderMasterData((orderMaster)cmd)))
                {
                    drillDown.GetOrderDetailsData((OrderMasterData)omd);
                    drillDown.GetOrderOptionsData((OrderMasterData)omd);
                }
                break;

            case eCommand.OrderOptions:
                Logger.Info($"ReceiveMessage - OrderOptions  reqId:{cmd.ToString()}");
                UMDServer.Persist(SPCmds.INSERTORDEROPTIONS, new OrderOptionsData((orderOptions)cmd));

                break;

            case eCommand.OrderDetails:
                Logger.Info($"ReceiveMessage - OrderDetails:{cmd.ToString()}");
                UMDServer.Persist(SPCmds.INSERTORDERDETAILS, new OrderDetailsData((orderDetails)cmd));
                //  drillDown.GetOrderMasterData((ManifestDetailsData)mmd);
                break;

            case eCommand.RunQuery:
                //DriverData dd = (DriverData)GetDrivers(cbsend);
                break;

            case eCommand.Drivers:
                Logger.Info($"ReceiveMessage - Drivers:{cmd.ToString()}");
                break;

            case eCommand.OrderDetailsComplete:
                Logger.Info($"ReceiveMessage - OrderDetailsComplete:{cmd.ToString()}");
                break;

            case eCommand.OrderOptionsComplete:
                Logger.Info($"ReceiveMessage - OrderOptionsComplete:{cmd.ToString()}");
                break;

            case eCommand.OrderUpdatesComplete:
                Logger.Info($"ReceiveMessage - OrderUpdatesComplete:{cmd.ToString()}");
                break;

            default:
                Logger.Error("ReceiveMessage - ERROR Unknown command.  Parse Error MDM-API");
                break;
            }
            return(cmd);
        }
        public isaCommand ReceiveMessage(isaCommand cmd)
        {
            switch (cmd.command)
            {
            case eCommand.Ping:
                Logger.Debug($"ReceiveMessage - Received Ping / Replying Pong..");
                WinSysSM.SendMessage(new Command()
                {
                    command = eCommand.Pong
                });
                break;

            case eCommand.Pong:
                Logger.Debug($"ReceiveMessage - Received Pong");
                break;

            case eCommand.LoadFiles:
                Logger.Info($"ReceiveMessage - Copy Files from Winsys Server Paths top App Server Paths:{cmd.ToString()}");
                //CopyFilesToServer(DateTime.Today);
                Logger.Info($"ReceiveMessage - Replying LoadFilesComplete...");
                WinSysSM.SendMessage(new Command()
                {
                    command = eCommand.LoadFilesComplete
                });
                //cbsend(new Command() { command = eCommand.LoadFilesComplete }.ToArray());
                break;

            case eCommand.GenerateManifest:
                Logger.Info($"ReceiveMessage - Generate Manifest from Winsys and SqlServer:{cmd.ToString()}");
                manifestRequest req = (manifestRequest)cmd;
                WinSysSM.SendMessage(req);
                break;

            case eCommand.ManifestDetails:
                Logger.Info($"ReceiveMessage - Generate Manifest Details from Winsys - API Drill Down:{cmd.ToString()}");
                manifestDetails manDet = (manifestDetails)cmd;

                ManifestDetailsData manDetData = new ManifestDetailsData(manDet);
                Logger.Info($"INSERTMANIFESTDETAILS (Persist): {manDetData.ToString()}");

                if (!dManDetails.ContainsKey(manDetData.RequestId.ToString() + manDetData.ManId.ToString()))
                {
                    dManDetails.Add(manDetData.RequestId.ToString() + manDetData.ManId.ToString(), new List <ManifestDetailsData>());
                }

                foreach (var omdit in UMDServer.Persist(SPCmds.INSERTMANIFESTDETAILS, manDetData))
                {
                    dManDetails[manDetData.RequestId.ToString() + manDetData.ManId.ToString()].Add(manDetData);
                }

                Logger.Info($"ManifestDetails Complete: {manDet.ToString()}");
                break;

            case eCommand.ManifestDetailsComplete:
                Logger.Info($"ReceiveMessage - ManifestDetailsComplete:{cmd.ToString()}");
                req = (manifestRequest)cmd;
                List <ManifestDetailsData> mdd = null;
                if (dManDetails.ContainsKey(NewGuid(req.requestId).ToString() + req.id.ToString()))
                {
                    mdd = dManDetails[NewGuid(req.requestId).ToString() + req.id.ToString()];
                    dManDetails.Remove(NewGuid(req.requestId).ToString() + req.id.ToString());
                }
                if (!dManDetails.ContainsKey(NewGuid(req.requestId).ToString()) && mdd != null && mdd.Count > 0)
                {
                    drillDown.GetOrderMasterData(new manifestRequest()
                    {
                        valist = req.valist, requestId = req.requestId, date = req.date, id = req.id
                    });
                }

                dRetCall[NewGuid(cmd.requestId)](req.ToArray());
                //drillDown.reportMDProgressChanged(100, cmd);
                break;

            case eCommand.OrdersUpload:
                Logger.Info($"ReceiveMessage - Orders  reqId: {cmd.requestId}");
                List <IMDMMessage> lstOrd = new List <IMDMMessage>();

                OrderMasterData omd = new OrderMasterData(((orderMaster)cmd));
                orderMaster     om  = new orderMaster(omd);
                //omd.Status = OrderStatus.Shipped;

                lock (dOrdLock)
                {
                    if (!dOrdersMaster.ContainsKey(omd.RequestId.ToString() + omd.ManId.ToString()))
                    {
                        dOrdersMaster.Add(omd.RequestId.ToString() + omd.ManId.ToString(), new List <OrderMasterData>());
                    }
                }
                if (!dOrdersMaster[omd.RequestId.ToString() + omd.ManId.ToString()].Contains(omd))
                {
                    foreach (var omdit in UMDServer.Persist(SPCmds.INSERTORDER, omd))
                    {
                        lock (dOrdLock)
                            dOrdersMaster[omd.RequestId.ToString() + omd.ManId.ToString()].Add((OrderMasterData)omdit);
                    }
                }

                break;

            case eCommand.OrdersLoad:
                Logger.Info($"ReceiveMessage - OrdersLoad  reqId: {cmd.requestId}");
                orderMaster     ord    = (orderMaster)cmd;
                OrderMasterData omdata = new OrderMasterData(ord);

                lock (dOrdLock)
                {
                    if (!dOrdersMaster.ContainsKey(NewGuid(ord.requestId).ToString() + ord.ManId.ToString()))
                    {
                        dOrdersMaster.Add(NewGuid(ord.requestId).ToString() + ord.ManId.ToString(), new List <OrderMasterData>());
                    }
                }
                if (!dOrdersMaster[omdata.RequestId.ToString() + omdata.ManId.ToString()].Contains(omdata))
                {
                    foreach (var omdit in UMDServer.Persist(SPCmds.INSERTORDER, omdata))
                    {
                        lock (dOrdLock)
                            dOrdersMaster[omdata.RequestId.ToString() + omdata.ManId.ToString()].Add((OrderMasterData)omdit);
                    }
                }

                break;

            case eCommand.OrdersLoadComplete:
                Logger.Info($"ReceiveMessage - OrdersLoadComplete:{cmd.ToString()}");
                req = (manifestRequest)cmd;

                if (dOrdersMaster.ContainsKey(NewGuid(cmd.requestId).ToString() + req.id))
                {
                    List <OrderMasterData> lMOrd = dOrdersMaster[NewGuid(cmd.requestId).ToString() + req.id.ToString()].Distinct().ToList();
                    lMOrd.ForEach(x => Logger.Info($"ordldcmp{x.ORD_NO}"));
                    drillDown.GetDrillDownData(req.valist, eCommand.OrderDetails, req.requestId, 1);
                    drillDown.GetDrillDownData(req.valist, eCommand.OrderOptions, req.requestId);
                    lock (dOrdLock)
                        dOrdersMaster.Remove(NewGuid(cmd.requestId).ToString() + req.id);
                }
                else
                {
                    Logger.Info($"No Orders for {cmd.ToString()}");
                }
//                        throw new Exception("OrdersLoadComplete - response not mapped in dOrderMaster.  " +
//                          "Request Id: {NewGuid(cmd.requestId).ToString()} , id: {req.id}. ");
                dRetCall[NewGuid(cmd.requestId)](req.ToArray());

                break;

            case eCommand.OrderDetails:
                Logger.Info($"ReceiveMessage - OrderDetails:{cmd.ToString()}");
                try
                {
                    orderDetails     od  = (orderDetails)cmd;
                    OrderDetailsData odd = new OrderDetailsData(od);

                    lock (dOrdLock)
                    {
                        if (!dOrdersDetails.ContainsKey(odd.RequestId))
                        {
                            dOrdersDetails.Add(odd.RequestId, new List <OrderDetailsData>());
                        }
                    }
                    foreach (var odit in UMDServer.Persist(SPCmds.INSERTORDERDETAILS, odd))
                    {
                        Logger.Info($"INSERTORDERDETAILS Complete: {odit.ToString()}");
                    }

                    //dRetCall[NewGuid(od.requestId)](cmd.ToArray());
                }
                catch (Exception ex) { Logger.Error($"eCommand.OrderDetails {ex.Message}"); }

                break;

            case eCommand.OrderDetailsComplete:
                Logger.Info($"ReceiveMessage - OrderDetailsComplete:{cmd.ToString()}");
                // Can we detrmine the completed transaction at this point from the cmd in order to clean the completed tx for dRetCall
                req = (manifestRequest)cmd;

                lock (dOrdLock)
                {
                    if (dOrdersDetails.ContainsKey(NewGuid(cmd.requestId)))
                    {
                        //                        drillDown.GetOrderOptionsData(dOrdersDetails[NewGuid(cmd.requestId)].Distinct().ToList());
                        //drillDown.GetOrderOptionsData(ordersToRequestDetails[NewGuid(cmd.requestId)]);
                        dOrdersDetails.Remove(NewGuid(cmd.requestId));
                    }
                }

                //dRetCall[NewGuid(cmd.requestId)](req.ToArray());

                break;

            case eCommand.OrderOptions:
                Logger.Info($"ReceiveMessage - OrderOptions  reqId:{cmd.ToString()}");
                try
                {
                    orderOptions     oo  = (orderOptions)cmd;
                    OrderOptionsData ood = new OrderOptionsData(oo);

                    foreach (var oodit in UMDServer.Persist(SPCmds.INSERTORDEROPTIONS, ood))
                    {
                        Logger.Info($"INSERTORDEROPTIONS Complete: {oodit.ToString()}");
                    }

                    //oo.command = eCommand.OrderOptionsComplete;
                    //dRetCall[NewGuid(oo.requestId)](cmd.ToArray());
                }
                catch (Exception ex) { Logger.Error($"eCommand.OrderOptions {ex.Message}"); }

                break;

            case eCommand.OrderOptionsComplete:

                Logger.Info($"ReceiveMessage - OrderOptionsComplete:{cmd.ToString()}");
                // Can we detrmine the completed transaction at this point from the cmd in order to clean the completed tx for dRetCall
                req = (manifestRequest)cmd;
                dRetCall[NewGuid(cmd.requestId)](req.ToArray());

                break;

            case eCommand.OrderUpdatesComplete:
                Logger.Info($"ReceiveMessage - OrderUpdatesComplete:{cmd.ToString()}");

                req = (manifestRequest)cmd;
                dRetCall[NewGuid(cmd.requestId)](req.ToArray());
                break;

            case eCommand.ManifestLoadComplete:
                Logger.Info($"ReceiveMessage - OrdersLoadComplete:{cmd.ToString()}");
                Logger.Info($"ReceiveMessage - OrderDetailsComplete:{cmd.ToString()}");

                req = (manifestRequest)cmd;
                dRetCall[NewGuid(cmd.requestId)](req.ToArray());
                break;

            case eCommand.ScanFile:
                Logger.Info($"ReceiveMessage Cached Success - ScanFile:{cmd.ToString()}");
                scanFile     sf  = (scanFile)cmd;
                ScanFileData sfd = new ScanFileData(sf);

                foreach (var scnfle in UMDServer.Persist(SPCmds.INSERTSCANFILE, sfd))
                {
                    Logger.Info($"INSERTSCNFLE Complete: {scnfle.ToString()}");
                }

                //if(cmd.requestId==null)
                //    dRetCall.FirstOrDefault().Value(sf.ToArray());
                //else
                //    dRetCall[NewGuid(cmd.requestId)](sf.ToArray());

                break;

            default:
                Logger.Error("ReceiveMessage - ERROR Unknown command.  Parse Error MDM-API");
                break;
            }
            return(cmd);
        }
 public bool SendMessage(isaCommand cmd)
 {
     return(smsg.SendMessage(cmd));
 }