Пример #1
0
        private Boolean StartSFC()
        {
            KeyValuePair <string, ShopOrderModel> shopOrder = dictGSFCCache.Where(order => order.Value.sFCState == SFCState.New).FirstOrDefault();

            if (shopOrder.Equals(default(KeyValuePair <string, ShopOrderModel>)))
            {
                return(false);
            }
            //Assumption is there will be no routing steps with status other than "New"
            int         RoutingStepID = Int32.MaxValue;
            XElement    RoutingStep   = null;
            XmlNodeList RoutingSteps  = shopOrder.Value.Routing.SelectNodes("/SFC/RoutingStep");

            foreach (XmlNode RoutingStepNode in RoutingSteps)
            {
                if (RoutingStepID > Convert.ToInt32(RoutingStepNode.Attributes["ID"].Value))
                {
                    RoutingStepID = Convert.ToInt32(RoutingStepNode.Attributes["ID"].Value);
                    RoutingStep   = XElement.Parse(RoutingStepNode.OuterXml);
                }
            }
            ThreadedExecuter <Tuple <XElement, String>, Tuple <XElement, string> > threadedExecuter =
                new ThreadedExecuter <Tuple <XElement, string>, Tuple <XElement, string> >(DelegateWork, null);

            threadedExecuter.Start(new Tuple <XElement, string>(RoutingStep, shopOrder.Value.Product));
            shopOrder.Value.sFCState = SFCState.InProcess;
            shopOrder.Value.Routing.DocumentElement.Attributes["Status"].Value = OperationState.InProcess.ToString();
            //ManageGSFCCache();
            return(true);
        }
Пример #2
0
        private Boolean ManageGSFCCache()
        {
            int InProcessSFCs = this.dictGSFCCache.Values.Where(order => order.sFCState == SFCState.InProcess).Count();

            while (InProcessSFCs <= GlobalVariables.GSFCCacheProcessingSFCSize)
            {
                if (this.dictGSFCCache.Values.Where(order => order.sFCState == SFCState.New).Count()
                    < GlobalVariables.GSFCCacheNewSFCsSizeMinThreshold)
                {
                    //TBD : Make this call generic by passsing parameter types
                    //ThreadedExecuter<Tuple<int, object>, object> GetSFCsExecutor =
                    //    new ThreadedExecuter<Tuple<int, object>, object>
                    //    (GetSFCsCaller, null, true);
                    //GetSFCsExecutor.Start( new Tuple<int, object>(
                    //    ( GlobalVariables.GSFCCacheNewSFCsSize - dictGSFCCache.Count),
                    //    this.perceptionLayer.CreateDynamicClientProxy(GlobalVariables.GSFCUrl)));

                    object GSFCClientProxy = this.perceptionLayer.CreateDynamicClientProxy(GlobalVariables.GSFCUrl);
                    object result          = GSFCClientProxy.GetType().
                                             GetMethod("GSFCCache_GetSFCs").
                                             Invoke(GSFCClientProxy, new object[] { GlobalVariables.GSFCCacheNewSFCsSize - dictGSFCCache.Count });

                    PropertyInfo propertyInfo = result.GetType().GetProperty("outStatus");
                    if (Convert.ToBoolean(propertyInfo.GetValue(result, null)) &&
                        this.dictGSFCCache.Values.Where(order => order.sFCState == SFCState.New).Count() == 0)
                    {
                        return(false);
                    }

                    //Tuple<Dictionary<string, object>, object> result = GetSFCs(GlobalVariables.GSFCCacheNewSFCsSize - dictGSFCCache.Count);

                    //if ((Convert.ToBoolean(result.Item1["outStatus"]) == false)
                    //    && this.dictGSFCCache.Values.Where(order => order.sFCState == SFCState.New).Count() == 0)
                    //    return false;
                }
                if (StartSFC())
                {
                    InProcessSFCs++;
                }
                else
                {
                    break;
                }
            }

            if (this.dictGSFCCache.Values.Where(order => order.sFCState == SFCState.New).Count()
                < GlobalVariables.GSFCCacheNewSFCsSizeMinThreshold)
            {
                //TBD : Make this call generic by passsing parameter types
                ThreadedExecuter <Tuple <int, object>, object> GetSFCsExecutor =
                    new ThreadedExecuter <Tuple <int, object>, object>
                        (GetSFCsCaller, null, true);
                GetSFCsExecutor.Start(new Tuple <int, object>(
                                          (GlobalVariables.GSFCCacheNewSFCsSize - dictGSFCCache.Count),
                                          this.perceptionLayer.CreateDynamicClientProxy(GlobalVariables.GSFCUrl)));
            }
            return(true);
        }
Пример #3
0
        public Tuple <Dictionary <string, object>, object> CallbackDelegateWork(string ResourceUrl, string RoutingStepElement, String Product)
        {
            Dictionary <string, object> Result = new Dictionary <string, object>();

            Result.Add(this.empMetaData.Methods[GlobalVariables.CallbackDelegateWorkMethodID].OutputParameters.ElementAt(0).Key, true);

            ThreadedExecuter <Tuple <XElement, string, string>, object> threadedExecutor = new ThreadedExecuter <Tuple <XElement, string, string>, object>
                                                                                               (AssignNextOperation, null);

            threadedExecutor.Start(new Tuple <XElement, string, string>(XElement.Parse(RoutingStepElement), Product, ResourceUrl));

            //AssignNextOperation( new Tuple<XElement, string, string>(XElement.Parse(RoutingStepElement), Product, ResourceUrl));
            return(new Tuple <Dictionary <string, object>, object>(Result, 202));
        }
Пример #4
0
        private Boolean ManageGSFCCache()
        {
            int InProcessSFCs = this.dictGSFCCache.Values.Where(order => order.sFCState == SFCState.InProcess).Count();

            while (InProcessSFCs <= GlobalVariables.GSFCCacheProcessingSFCSize)
            {
                //if (InProcessSFCs > 0)
                //{
                //    KeyValuePair<string, ShopOrderModel> shopOrder = dictGSFCCache.Where(order => order.Value.sFCState == SFCState.InProcess).FirstOrDefault();
                //    XmlNode RoutingElement = this.dictGSFCCache[shopOrder.Key].Routing.
                //        SelectSingleNode("SFC/RoutingStep[@Status='" + OperationState.Done.ToString("G") + "']");
                //    if (RoutingElement != null)
                //        DelegateWork(new Tuple<XElement, string, string>(RoutingElement.ToXElement(), shopOrder.Value.Product, null));
                //    else
                //    {
                //        //if (shopOrder.Equals(default(KeyValuePair<string, ShopOrderModel>)))
                //        //    return false;
                //        //Assumption is there will be no routing steps with status other than "New"
                //        int RoutingStepID = Int32.MaxValue;
                //        XElement RoutingStep = null;
                //        XmlNodeList RoutingSteps = shopOrder.Value.Routing.SelectNodes("/SFC/RoutingStep");
                //        foreach (XmlNode RoutingStepNode in RoutingSteps)
                //        {
                //            if (RoutingStepID > Convert.ToInt32(RoutingStepNode.Attributes["ID"].Value))
                //            {
                //                RoutingStepID = Convert.ToInt32(RoutingStepNode.Attributes["ID"].Value);
                //                RoutingStep = XElement.Parse(RoutingStepNode.OuterXml);
                //            }
                //        }
                //        DelegateWork(new Tuple<XElement, string, string>(RoutingStep, shopOrder.Value.Product, null));
                //    }
                //}

                if (this.dictGSFCCache.Values.Where(order => order.sFCState == SFCState.New).Count()
                    < GlobalVariables.GSFCCacheNewSFCsSizeMinThreshold)
                {
                    //TBD : Make this call generic by passsing parameter types
                    //ThreadedExecuter<Tuple<int, object>, object> GetSFCsExecutor =
                    //    new ThreadedExecuter<Tuple<int, object>, object>
                    //    (GetSFCsCaller, null, true);
                    //GetSFCsExecutor.Start( new Tuple<int, object>(
                    //    ( GlobalVariables.GSFCCacheNewSFCsSize - dictGSFCCache.Count),
                    //    this.perceptionLayer.CreateDynamicClientProxy(GlobalVariables.GSFCUrl)));

                    object GSFCClientProxy = this.perceptionLayer.CreateDynamicClientProxy(GlobalVariables.GSFCUrl);
                    object result          = GSFCClientProxy.GetType().
                                             GetMethod("GSFCCache_GetSFCs").
                                             Invoke(GSFCClientProxy, new object[] { GlobalVariables.GSFCCacheNewSFCsSize - dictGSFCCache.Count });

                    PropertyInfo propertyInfo = result.GetType().GetProperty("outStatus");
                    if (Convert.ToBoolean(propertyInfo.GetValue(result, null)) &&
                        this.dictGSFCCache.Values.Where(order => order.sFCState == SFCState.New).Count() == 0)
                    {
                        return(false);
                    }

                    //Tuple<Dictionary<string, object>, object> result = GetSFCs(GlobalVariables.GSFCCacheNewSFCsSize - dictGSFCCache.Count);

                    //if ((Convert.ToBoolean(result.Item1["outStatus"]) == false)
                    //    && this.dictGSFCCache.Values.Where(order => order.sFCState == SFCState.New).Count() == 0)
                    //    return false;
                }

                if (StartSFC())
                {
                    InProcessSFCs++;
                }
                else
                {
                    break;
                }
            }

            if (this.dictGSFCCache.Values.Where(order => order.sFCState == SFCState.New).Count()
                < GlobalVariables.GSFCCacheNewSFCsSizeMinThreshold)
            {
                //TBD : Make this call generic by passsing parameter types
                ThreadedExecuter <Tuple <int, object>, object> GetSFCsExecutor =
                    new ThreadedExecuter <Tuple <int, object>, object>
                        (GetSFCsCaller, null, true);
                GetSFCsExecutor.Start(new Tuple <int, object>(
                                          (GlobalVariables.GSFCCacheNewSFCsSize - dictGSFCCache.Count),
                                          this.perceptionLayer.CreateDynamicClientProxy(GlobalVariables.GSFCUrl)));
            }
            return(true);
        }