示例#1
0
 public OrderOptionsModel(orderMaster mst)
 {
     // ORD_NO = mst.ORD_NO;
     //DLR_NO = mst.DLR_NO;
     //OPT_NUM = BitConverter.ToInt16(mst.OPT_NUM, 0);
     //DESC = BitConverter.ToString(mst.DESC, 0, fldsz_DESCOrd);
     //CLR = BitConverter.ToString(mst.CLR, 0, fldsz_CLR);
     //WIDTH = BitConverter.ToInt64(mst.WIDTH, 0);
     //HEIGHT = BitConverter.ToInt64(mst.HEIGHT, 0);
     //MDL_CNT = BitConverter.ToInt16(mst.MDL_CNT, 0);
     //WIN_CNT = BitConverter.ToInt16(mst.WIN_CNT, 0);
     //RTE_CDE = mst.RTE_CDE;
 }
示例#2
0
        public OrderMasterData(orderMaster sd, bool isSelected = false)
        {
            Command   = sd.command;
            RequestId = NewGuid(sd.requestId);
            ManId     = sd.ManId;

            ORD_NO    = sd.ORD_NO;
            DLR_NO    = sd.DLR_NO;
            DLR_PO    = sd.DLR_PO;
            ORD_DTE   = sd.ORD_DTE;
            SHP_DTE   = sd.SHP_DTE;
            SHIP_DTE  = sd.SHIP_DTE;
            CMNT1     = sd.CMNT1;
            CMNT2     = sd.CMNT2;
            DLR_NME   = sd.DLR_NME;
            DLR_ADDR  = sd.DLR_ADDR;
            DLR_ADDR2 = sd.DLR_ADDR2;
            SHP_NME   = sd.SHP_NME;
            SHP_ADDR  = sd.SHP_ADDR;
            SHP_ADDR2 = sd.SHP_ADDR2;
            SHP_CSZ   = sd.SHP_CSZ;
            SHP_TEL   = sd.SHP_TEL;
            SHP_CT    = sd.SHP_CT;
            SHP_ZIP   = sd.SHP_ZIP;
            CUS_NME   = sd.CUS_NME;
            CUS_ADDR  = sd.CUS_ADDR;
            CUS_CSZ   = sd.CUS_CSZ;
            CUS_TEL   = sd.CUS_TEL;
            RTE_CDE   = sd.RTE_CDE;
            ENT_BY    = sd.ENT_BY;
            ORD_AMT   = sd.ORD_AMT;
            WIN_QTY   = sd.WIN_QTY;
            STK_QTY   = sd.STK_QTY;
            CMP_QTY   = sd.CMP_QTY;
            SHP_QTY   = sd.SHP_QTY;
            SHP_AMT   = sd.SHP_AMT;
            MISC_TEXT = sd.MISC_TEXT;

            //scanFileData.AddRange(sd.ScanFile.Select(s => new ScanFileData(s)).ToList());
        }
示例#3
0
        void UploadOrderData(OrderData ord)
        {
            Logger.Info($"OrderVM UploadStopOrder: {ord.ToString()}");
            bool bExists     = Orders.Select(a => a).Where(o => o == ord).ToList().Count > 0;
            bool bCompExists = CompletedOrders.Select(a => a).Where(o => o == ord).ToList().Count > 0;

            if (((ord.Status == OrderStatus.Shipped && ord.IsSelected == false) && (bExists && !bCompExists) || dDeliveredRequestPending.Contains(ord.ORD_NO)) || (
                    ord.Status == OrderStatus.Delivered && ord.IsSelected) && (!bExists && bCompExists) || dShippedRequestPending.Contains(ord.ORD_NO))
            {
                return;
            }

            var req = new Request()
            {
                reqGuid = NewGuid(),
                LIds    = new Dictionary <long, status>(),
                LinkMid = new Dictionary <long, List <long> >(),
                ChkIds  = new Dictionary <long, status>()
            };

            dRequests.Add(req.reqGuid, req);
            bool bShipped   = !ord.IsSelected && ord.prevstate;
            bool bDelivered = ord.IsSelected && !ord.prevstate;

            if (bShipped)
            {
                ord.Status = OrderStatus.Shipped;
                ord.status = status.Releasing;
                //ord.IsSelected = false;
            }
            else if (bDelivered)
            {
                ord.Status = OrderStatus.Delivered;
                ord.status = status.Completed;
            }
            orderMaster ordUp = new orderMaster(ord, ord.ManifestId);

            if (bShipped || bDelivered)
            {
                ordUp.command = eCommand.CompleteOrder;

                ProcessMsgDelegateRXRaw pmRx = new ProcessMsgDelegateRXRaw(ProcessMessage);
                Logger.Info($"Upload Sopt Order reqid: {req.reqGuid}");
                orderThread.OnStartProcess((new manifestRequest()
                {
                    requestId = req.reqGuid.ToByteArray(),
                    command = ordUp.command,
                    bData = ordUp.ToArray()
                }), req, pmRx);

                lock (olock)
                {
                    if (bShipped)
                    {
                        dShippedRequestPending.Add(ord.ORD_NO);
                    }
                    else if (bDelivered)
                    {
                        dDeliveredRequestPending.Add(ord.ORD_NO);
                    }
                }
            }
        }
        static Dictionary <short, Dictionary <byte, List <long> > > dTruckCodeToDealerNumbers = new Dictionary <short, Dictionary <byte, List <long> > >();  //TruckCode -> <Seq, List<Orders>>
        public static isaCommand CommandFactory(byte[] cmdBytes)
        {
            isaCommand cmd = new Command().FromArray(cmdBytes);

            switch (cmd.command)
            {
            case eCommand.Broadcast:
                //Broadcast cmdType = Broadcast.FromArray(cmdBytes);
                break;

            case eCommand.DeliveryComplete:
                //Broadcast cmdType = Broadcast.FromArray(cmdBytes);
                break;

            case eCommand.CheckManifest:
            case eCommand.CheckManifestComplete:
                manifestMaster mamr = new manifestMaster();
                cmd = mamr.FromArray(cmdBytes);
                break;

            case eCommand.GenerateManifest:
                manifestRequest mr = new manifestRequest();
                cmd = mr.FromArray(cmdBytes);
                if (cmd == null)
                {
                    manifestMaster mmr = new manifestMaster();
                    cmd = mmr.FromArray(cmdBytes);
                }
                //Call ApplicationServer to return the data requested.
                //UMDManifest.
                break;

            case eCommand.OrdersLoad:
                //orders ords = new orders();
                //cmd = ords.FromArray(cmdBytes);
                orderMaster orm = new orderMaster();
                cmd = orm.FromArray(cmdBytes);
                break;

            case eCommand.Trucks:
                trucks trks = new trucks();
                cmd = trks.FromArray(cmdBytes);
                break;

            case eCommand.Stops:
                stops stps = new stops();
                cmd = stps.FromArray(cmdBytes);
                break;

            case eCommand.OrderDetails:
                orderDetails cmdType = new orderDetails();
                cmd = cmdType.FromArray(cmdBytes);
                break;

            case eCommand.Manifest:
                manifestMaster mm = new manifestMaster();
                cmd = mm.FromArray(cmdBytes);
                break;

            case eCommand.ManifestDetails:
                manifestDetails md = new manifestDetails();
                cmd = md.FromArray(cmdBytes);
                break;

            case eCommand.OrdersUpload:
                orderMaster om = new orderMaster();
                cmd = om.FromArray(cmdBytes);
                OrderMasterData omd = new OrderMasterData(om);
                if (!dStopOrders.ContainsKey(omd.DLR_NO))
                {
                    dStopOrders.Add(omd.DLR_NO, new List <long>()
                    {
                        omd.ORD_NO
                    });
                }
                break;

            case eCommand.ScanFile:
                scanFile sc = new scanFile();
                cmd = sc.FromArray(cmdBytes);
                ScanFileData scd = new ScanFileData(sc);
                break;

            case eCommand.OrderOptions:
                orderOptions oo = new orderOptions();
                cmd = oo.FromArray(cmdBytes);
                //OrderOptionsData ood = new OrderOptionsData(oo);
                break;

            case eCommand.AccountReceivable:
                accountReceivable ar = new accountReceivable();
                cmd = ar.FromArray(cmdBytes);
                // AccountsReceivableData acr = new AccountsReceivableData((accountReceivable)cmd);
                break;

            case eCommand.ManifestLoadComplete:
            case eCommand.TrucksLoadComplete:
            case eCommand.StopsLoadComplete:
            case eCommand.OrdersLoadComplete:
            case eCommand.OrderUpdatesComplete:
            case eCommand.OrderDetailsComplete:
            case eCommand.OrderOptionsComplete:
            case eCommand.ManifestDetailsComplete:
            case eCommand.UploadManifestComplete:
            case eCommand.LoadFilesComplete:
                Logger.Info($"CommandFactory: {Enum.GetName(typeof(eCommand), cmd.command) + Environment.NewLine}");
                manifestRequest req = new manifestRequest();
                Logger.Info($"CommandFactory: {req.ToString()}");
                cmd = req.FromArray(cmdBytes);
                break;

            case eCommand.Ping:
                //Broadcast cmdType = Broadcast.FromArray(cmdBytes);
                //cmd = SendPong();
                break;

            case eCommand.Pong:
                //Broadcast cmdType = Broadcast.FromArray(cmdBytes);
                //Broadcast cmdType = Broadcast.FromArray(cmdBytes);
                break;

            case eCommand.RunQuery:
                //Broadcast cmdType = Broadcast.FromArray(cmdBytes);
                break;

            default:
                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 void HandleClientCmd(byte[] bytes_cmd, Func <byte[], Task> cbsend)
        {
            isaCommand cmd = new Command().FromArray(bytes_cmd);

            switch (cmd.command)
            {
            case eCommand.Ping:
                Logger.Debug("HandleClientCmd -  Received Ping / Replying Pong..");
                cbsend(new Command()
                {
                    command = eCommand.Pong
                }.ToArray());
                break;

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

            case eCommand.GenerateManifest:
                Logger.Info($"HandleClientCmd - Generate Manifest:{cmd.ToString()}");

                manifestMaster mM = (manifestMaster) new manifestMaster().FromArray(bytes_cmd);
                Logger.Info($"HandleClientCmd Generate Manifest from Winsys and SqlServer:{mM.ToString()}");
                if (mM.LINK != 0)
                {
                    ManifestMasterData mmd1 = (ManifestMasterData)UMDServer.QueryData(cbsend, mM);
                    Logger.Info($"API Manager GenerateManifest QueryData Complete. {mmd1.ToString()}");
                }
                else
                {
                    WinSysSM.SendMessage(cmd);
                }

                break;

            case eCommand.CheckManifest:
                Logger.Info($"HandleClientCmd - CheckManifest: {cmd.ToString()}");
                manifestMaster mMst = (manifestMaster) new manifestMaster().FromArray(bytes_cmd);
                Logger.Info($"HandleClientCmd Check Manifest in ManagerAPI/SqlServer: {mMst.ToString()}");
                ManifestMasterData mamd = (ManifestMasterData)UMDServer.QueryData(cbsend, mMst);
                Logger.Info($"API Manager Check Manifest. {mamd.ToString()}");

                break;


            case eCommand.Manifest:
                Logger.Info($"HandleClientCmd - Manifest: {cmd.ToString()}");
                cbsend(cmd.ToArray());

                break;

            case eCommand.OrdersUpload:
                Logger.Info($"HandleClientCmd - Orders: {cmd.ToString()}");
                orderMaster            om      = (orderMaster) new orderMaster().FromArray(bytes_cmd);
                List <OrderMasterData> ordList = new List <OrderMasterData>();
                Logger.Info($"Persist INSERTORDER {om.ToString()}");
//                    om.Status = OrderStatus.Shipped;
                foreach (OrderMasterData omd in UMDServer.Persist(SPCmds.INSERTORDER, new OrderMasterData(om)))
                {
                    ordList.Add(omd);
                    Logger.Info($"Orders - drillDown.GetOrderDetailsData: {omd.ToString()}");
                    omd.Command = eCommand.OrdersLoadComplete;
                }

                //foreach (var ord in ordList)
                //{
                //    drillDown.GetOrderDetailsData(ord);
                //    drillDown.GetOrderOptionsData(ord);
                //}
                drillDown.GetOrderDetailsData(ordList);
                drillDown.GetOrderOptionsData(ordList);

                Logger.Info($"INSERTORDER Complete. OrdersLoadComplete: {om.ToString()}");
                om.command = eCommand.ManifestDetailsComplete;
                cbsend(om.ToArray());

                break;

            case eCommand.CompleteOrder:
                Logger.Info($"HandleClientCmd - Close Order: {cmd.ToString()}");

                manifestRequest mreq = (manifestRequest) new manifestRequest().FromArray(bytes_cmd);

                Logger.Info($"HandleClientCmd - CompleteOrder:  {mreq.ToString()}");

                orderMaster cs = (orderMaster) new orderMaster().FromArray(mreq.bData);

                Logger.Info($"Persist COMPLETEORDER {cs.ToString()}");

                var no = new OrderMasterData(cs);
                foreach (OrderMasterData omd in UMDServer.Persist(SPCmds.COMPLETEORDER, no))
                {
                    Logger.Info($"Persisted COMPLETEORDER {omd.ToString()}");
                    cbsend(new orderMaster(omd).ToArray());
                }

                break;

            case eCommand.CompleteStop:

                Logger.Info($"HandleClientCmd - Close Stop for Orders: {cmd.ToString()}");

                manifestRequest mreqs = (manifestRequest) new manifestRequest().FromArray(bytes_cmd);

                Logger.Info($"HandleClientCmd - CompleteStop:  {mreqs.ToString()}");

                StopData sd = new StopData();
                sd.POD        = mreqs.bData;
                sd.ManifestId = mreqs.id;
                sd.DisplaySeq = (int)mreqs.DATA;
                sd.Orders     = new List <OrderMasterData>();
                //temp - uncomment!
                // mreqs.valist.ForEach(v => sd.Orders.Add(new OrderMasterData() { DSP_SEQ=sd.DisplaySeq, ManifestId=sd.ManifestId, ORD_NO = v }));

                Logger.Info($"Persist COMPLETESTOP {sd.ToString()}");

                foreach (StopData omd in UMDServer.Persist(SPCmds.COMPLETESTOP, sd))
                {
                    Logger.Info($"Persisted COMPLETESTOP {sd.ToString()}");
                    cbsend(new stops(sd).ToArray());
                }

                break;

            case eCommand.OrderOptions:

                //throw new Exception("This should be handled by the Receive Message handler.");
                Logger.Info($"HandleClientCmd - OrderOptions:{cmd.ToString()}");
                manifestRequest mreqoo = (manifestRequest) new manifestRequest().FromArray(bytes_cmd);

                OrderOptionsData ood = (OrderOptionsData)UMDServer.QueryData(cbsend, mreqoo);
                Logger.Info($"API Manager QueryData OrderOptionsData. {ood.ToString()}");

                break;

            case eCommand.OrderDetails:

                Logger.Info($"HandleClientCmd - OrderDetails:{cmd.ToString()}");
                manifestRequest mreqod = (manifestRequest) new manifestRequest().FromArray(bytes_cmd);

                OrderDetailsData odd = (OrderDetailsData)UMDServer.QueryData(cbsend, mreqod);
                Logger.Info($"API Manager OrderDetailsData QueryData. {odd.ToString()}");
                break;

            case eCommand.UploadManifest:

                Logger.Info($"HandleClientCmd - UploadManifest:{cmd.ToString()}");

                mreq = (manifestRequest) new manifestRequest().FromArray(bytes_cmd);

                Logger.Info($"HandleClientCmd - UploadManifest:  {mreq.ToString()}");

                manifestMaster mm = (manifestMaster) new manifestMaster().FromArray(mreq.bData);

                if (!dRetCall.ContainsKey(NewGuid(mm.requestId)))
                {
                    dRetCall.Add(NewGuid(mm.requestId), cbsend);
                }

                Logger.Info($"UploadManifest cb dRetCall:  {mm.ToString()}");

                try
                {
                    foreach (ManifestMasterData mmdit in UMDServer.Persist(SPCmds.INSERTMANIFEST, new ManifestMasterData(mm, mm.id)))
                    {
                        Logger.Info($"HandleClientCmd - UploadManifest Persisted:{mmdit.ToString()}");
                        Logger.Info($"UploadManifest - Get ManifestDetails: {mmdit.ToString()}");

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

                        drillDown.GetManifestDetails(mmdit);
                    }
                    mm.command = eCommand.UploadManifestComplete;
                    Logger.Info($"UploadManifest - ManifestLoadComplete: {mm.ToString()}");
                    cbsend(mm.ToArray());
                }
                catch (Exception e)
                {
                    Logger.Debug("HandleClientCmd - Error exception = " + e.Message);
                    dRetCall.Remove(NewGuid(mm.requestId));
                }
                break;

            case eCommand.Trucks:
                isaCommand req = new manifestRequest().FromArray(bytes_cmd);
                Logger.Info($"HandleClientCmd - Trucks: {req.ToString()}");
                TruckData td = (TruckData)UMDServer.QueryData(cbsend, req);
                Logger.Info($"HandleClientCmd - Trucks:  {td.ToString()}");
                break;

            case eCommand.Drivers:
                req = new manifestRequest().FromArray(bytes_cmd);
                Logger.Info($"HandleClientCmd - Drivers: {req.ToString()}");
                DriverData dd = (DriverData)UMDServer.QueryData(cbsend, req);
                Logger.Info($"HandleClientCmd - Drivers:  {dd.ToString()}");
                break;

            case eCommand.Stops:
                req = new manifestRequest().FromArray(bytes_cmd);
                Logger.Info($"HandleClientCmd Stops:  {req.ToString()}");
                StopData sdt = (StopData)UMDServer.QueryData(cbsend, req);
                Logger.Info($"Stops QueryData:  {sdt.ToString()}");
                break;

            case eCommand.OrdersLoad:
                req = new manifestRequest().FromArray(bytes_cmd);
                Logger.Info($"HandleClientCmd - OrdersLoad (Start QueryData): {req.ToString()}");
                OrderData od = (OrderData)UMDServer.QueryData(cbsend, req);
                Logger.Info($"OrdersLoad QueryData: {od.ToString()}");
                break;

            case eCommand.AccountReceivable:
                req = new manifestRequest().FromArray(bytes_cmd);
                manifestRequest        mr    = (manifestRequest)req;
                accountReceivable      arecv = (accountReceivable) new accountReceivable().FromArray(mr.bData);                    Logger.Info($"HandleClientCmd - AccountRecievable");
                AccountsReceivableData ard   = (AccountsReceivableData)
                                               UMDServer.QueryData(cbsend, arecv);
                Logger.Info($"AccountsReceivables Complete.");
                break;

            default:
                Logger.Error("HandleClientCmd - ERROR Unknown command.  Parse Error MDM-API");
                break;
            }
        }