public void StopSupplyItem(List<Item> itemList)
        {
            try
            {
                //save record to database

                ItemDao.StopSupplyItem(itemList);
                List<RequestHandleInfo> requestList = new List<RequestHandleInfo>();
                foreach (Item item in itemList)
                {
                    RequestHandleInfo info = new RequestHandleInfo();
                    info.RequestType = RequestType.DeorderItem;
                    info.SourceId = item.Id;
                    requestList.Add(info);
                }
                //HandleEventHandler(StopSupplyItemEvent, new HandleEventArgs("stop supply item", requestList));
            }
            catch (HCSMSException ex)
            {
                raiseError(ex);
                throw new FaultException<HCSMSException>(ex);
            }
            catch (Exception ex)
            {
                raiseError(ex);
            }
        }
Ejemplo n.º 2
0
 public void HandleRequest(RequestHandleInfo aRequest)
 {
     throw new NotImplementedException();
 }
        public void ChangeItem(string tableNumber, Dictionary<Item, Item> itemPair)
        {
            FrontDeskRequest frontdesk = null;
            try
            {
                HCSMSLog.OnWarningLog(this, new NotifyEventArgs("Recieve change order Request"));

                //check if this table is really in use
                DinningTable table = TableDao.GetDinningTable(tableNumber);
                if (table == null)
                {
                    throw new HCSMSException("餐桌是空的 !");
                }

                // constructing request list
                List<RequestHandleInfo> requestList = new List<RequestHandleInfo>();
                foreach (KeyValuePair<Item, Item> ite in itemPair)
                {
                    RequestHandleInfo info = new RequestHandleInfo();
                    info.EntityId = tableNumber;
                    info.IsHandled = false;
                    info.RequestType = RequestType.ChangeItem;
                    info.SourceId = ite.Key.Id;
                    info.TargetId = ite.Value.Id;

                    requestList.Add(info);
                }

                //check for response of cook at the kitchen
                KitchenRequest handler = KitchenRequestControl.GetService();
                if (handler == null)
                {
                    requestList.Clear();
                }
                else
                {
                    requestList = handler.OnChangeItem(requestList);
                }
                HCSMSLog.OnWarningLog(this, new NotifyEventArgs("Recieve Result order item"));

                List<RequestHandleInfo> denyList = new List<RequestHandleInfo>();
                foreach (RequestHandleInfo ite in requestList)
                {
                    if (!ite.IsHandled)
                        denyList.Add(ite);
                }
                if (denyList.Count == 0 && requestList.Count > 0)
                {
                    //build data for calling data access servcie
                    Dictionary<string, string> itemIdList = new Dictionary<string, string>();
                    foreach (var ite in itemPair)
                    {
                        itemIdList.Add(ite.Key.Id, ite.Value.Id);
                    }
                    //save data to database
                    ItemDao.ChangeItem(table.Id, itemIdList);
                }
                else
                {
                    frontdesk = FrontDeskRequestControl.GetService(callBackId);
                    if (frontdesk != null)
                    {
                        //means kitchen service is not up
                        if (requestList.Count == 0)
                        {
                            frontdesk.InformationMessage( new NotifyEventArgs("不存在厨房处理服务!"));
                        }
                        // notify front desk, the request is not satisfied
                        else
                        {
                            frontdesk.RequestDeny(denyList);
                        }
                    }
                }
            }
            catch (HCSMSException ex)
            {
                raiseError(ex);
                if (frontdesk != null)
                {
                   frontdesk.ErrorMessage(new ErrorEventArgs("", ex));
                }
            }
            catch (Exception ex)
            {
                raiseError(ex);
            }
        }