Ejemplo n.º 1
0
        public bool AddResource(ResourceDetails resourceDetails)
        {
            if (!resourceDetails.IsOnline)
            {
                KeyValuePair <string, ResourceDetails> Resource = dictRegisteredResources.
                                                                  Where(resource => resource.Value.ResourceUrl.Equals(resourceDetails.ResourceUrl)).
                                                                  FirstOrDefault();

                if (!Resource.Equals(default(KeyValuePair <string, ResourceDetails>)))
                {
                    Resource.Value.IsOnline = false;
                }
                return(false);
            }

            if (!dictRegisteredResources.ContainsKey(resourceDetails.Name))
            {
                dictRegisteredResources.Add(resourceDetails.Name, resourceDetails);
                return(true);
            }
            else
            {
                dictRegisteredResources[resourceDetails.Name] = resourceDetails;
            }
            return(false);
        }
Ejemplo n.º 2
0
        public ResourceDetails BrowseMachine(string ResourceUrl)
        {
            ResourceDetails resourceDetails = new ResourceDetails();

            resourceDetails.ResourceUrl = ResourceUrl;
            object DynamicClientProxy = null;

            try
            {
                DynamicClientProxy = CreateDynamicClientProxy(ResourceUrl);
            }
            catch (Exception exception)
            {
                resourceDetails.IsOnline = false;
                return(resourceDetails);
            }

            resourceDetails.Name = DynamicClientProxy.GetType().GetMethod(GlobalVariables.GetResourceNameMethod).
                                   Invoke(DynamicClientProxy, new object[] { }).ToString();

            resourceDetails.Capability = DynamicClientProxy.GetType().GetMethod(GlobalVariables.GetCapabilityMethod).
                                         Invoke(DynamicClientProxy, new object[] { }).ToString();

            resourceDetails.QueueLength = Int32.Parse(DynamicClientProxy.GetType().GetMethod(GlobalVariables.GetQueueLengthMethod).
                                                      Invoke(DynamicClientProxy, new object[] { }).ToString());

            resourceDetails.State = (ResourceState)Enum.Parse(typeof(ResourceState),
                                                              DynamicClientProxy.GetType().GetMethod(GlobalVariables.GetStateMethod).
                                                              Invoke(DynamicClientProxy, new object[] { }).ToString());

            resourceDetails.ClientProxy = DynamicClientProxy;
            resourceDetails.IsOnline    = true;

            return(resourceDetails);
        }
Ejemplo n.º 3
0
        private Tuple <XElement, String, String> DelegateWork(Tuple <XElement, String, String> RoutingStepElement_Product)
        {
            string Capability    = RoutingStepElement_Product.Item1.Attribute("Operation").Value;
            int    RoutingStepID = Convert.ToInt32(RoutingStepElement_Product.Item1.Attribute("ID").Value);
            string ShopOrder     = RoutingStepElement_Product.Item1.Attribute("ShopOrder").Value;

            foreach (string ResourceUrl in this.decentralizationFacilitator.GetRegisteredResourceUrls(Capability))
            {
                this.decentralizationFacilitator.AddResource(this.perceptionLayer.BrowseMachine(ResourceUrl));
            }
            ResourceDetails resourceDetails = this.decentralizationFacilitator.ResourceDetermination(Capability);

            if (resourceDetails == null)
            {
                return(null);
            }

            this.perceptionLayer.AssignWorkToResource(resourceDetails, RoutingStepElement_Product.Item1, this.dictGSFCCache[ShopOrder].Product);

            dictGSFCCache[RoutingStepElement_Product.Item1.Attribute("ShopOrder").Value].RoutingSteps[RoutingStepID].StepState = OperationState.InProcess;
            dictGSFCCache[RoutingStepElement_Product.Item1.Attribute("ShopOrder").Value].RoutingSteps[RoutingStepID].Resource  = resourceDetails.Name;

            this.dictGSFCCache[RoutingStepElement_Product.Item1.Attribute("ShopOrder").Value].Routing.
            SelectSingleNode("SFC/RoutingStep[@ID=" + RoutingStepID + "]").Attributes["Resource"].Value = resourceDetails.ResourceUrl;
            this.dictGSFCCache[RoutingStepElement_Product.Item1.Attribute("ShopOrder").Value].Routing.
            SelectSingleNode("SFC/RoutingStep[@ID=" + RoutingStepID + "]").Attributes["Status"].Value = OperationState.InProcess.ToString();

            return(null);
        }
Ejemplo n.º 4
0
        public bool SetResourceDetails(string ResourceUrl, ResourceState resourceState)
        {
            ResourceDetails resourceDetails = this.dictRegisteredResources.Values.
                                              Where(resource => resource.ResourceUrl.Equals(ResourceUrl)).
                                              FirstOrDefault();

            if (resourceDetails != null)
            {
                resourceDetails.State = resourceState;
                return(true);
            }
            return(false);
        }
Ejemplo n.º 5
0
 private void CallbackDecentralizationFacilitator(ResourceDetails resourceDetails)
 {
     decentralizationFacilitator.AddResource(resourceDetails);
     return;
 }
Ejemplo n.º 6
0
 public bool AssignWorkToResource(ResourceDetails resourceDetails, XElement RoutingStep, string Product)
 {
     return(Convert.ToBoolean(resourceDetails.ClientProxy.GetType().GetMethod(GlobalVariables.DoWorkMethod).
                              Invoke(resourceDetails.ClientProxy, new object[] { RoutingStep.ToXmlNode(), Product })));
 }