示例#1
0
 public IHttpActionResult Create([FromBody] MaterialRequestModel model)
 {
     try
     {
         var materialRequest = new MaterialRequest();
         Mapper.Map(model, materialRequest);
         var user = GetCurrentUser();
         materialRequest.SubmittedBy = user.Id;
         _materialRequestsService.Create(materialRequest);
         model.Id       = materialRequest.Id;
         model.StatusId = model.StatusId;
         return(Ok(model));
     }
     catch (DbEntityValidationException ex)
     {
         foreach (var entityValidationErrors in ex.EntityValidationErrors)
         {
             foreach (var validationError in entityValidationErrors.ValidationErrors)
             {
                 model.SetError(validationError.PropertyName, validationError.ErrorMessage);
             }
         }
         return(Ok(model));
     }
     catch (Exception)
     {
         return(InternalServerError());
     }
 }
示例#2
0
        public IEnumerator InitIterativ(GraphicRequest req, int n, int points)
        {
            var data = GraphicsDatabase.GetColorData(req.path + directions[n], bodyColor, true);

            yield return(null);

            while (points > 0)
            {
                var stain = ZombieStains.GetRandom(points, req.path.Contains("Naked"));
                var it    = data.ApplyStainsIterativ(stain.Key, Rand.Bool, Rand.Bool);
                while (it.MoveNext())
                {
                    yield return(null);
                }
                points -= stain.Value;

                hash = Gen.HashCombine(hash, stain);
                yield return(null);
            }

            var request = new MaterialRequest
            {
                mainTex  = null,                // will be calculated lazy from 'data'
                shader   = req.shader,
                color    = color,
                colorTwo = colorTwo,
                maskTex  = null
            };

            mats[n] = new VariableMaterial(request, data);
        }
 /// <summary>
 /// Add a new array of Materials with a priority (materials with higher priorities are shown first).
 /// </summary>
 /// <param name="mats">The materials</param>
 /// <param name="priority">The priority</param>
 public void Add(Material[] mats, int priority)
 {
     var mr = new MaterialRequest();
     mr.mats = mats;
     mr.priority = priority;
     Add(mr);
 }
        public static Material[] GetMatsFrom(GraphicRequest req, Texture2D[] inputTextureArray, Texture2D[] inputMaskArray)
        {
            Material[] matArray = new Material[inputTextureArray.Length];

            for (int i = 0; i < inputTextureArray.Length; i++)
            {
                if (inputTextureArray[i] != null)
                {
                    Texture2D mask;
                    if (inputMaskArray[i] != null)
                    {
                        mask = inputMaskArray[i];
                    }
                    else
                    {
                        mask = HairMasker.GetDefaultMask(inputTextureArray[i].width, inputTextureArray[i].height);
                    }

                    MaterialRequest tempMatReq = default(MaterialRequest);
                    tempMatReq.mainTex          = inputTextureArray[i];
                    tempMatReq.shader           = req.shader;
                    tempMatReq.color            = req.color;
                    tempMatReq.colorTwo         = req.colorTwo;
                    tempMatReq.maskTex          = mask;
                    tempMatReq.shaderParameters = req.shaderParameters;

                    matArray[i] = MaterialPool.MatFrom(tempMatReq);
                }
            }

            return(matArray);
        }
 /// <summary>
 /// Add a new Material with a priority (materials with higher priorities are shown first).
 /// </summary>
 /// <param name="mat">The material</param>
 /// <param name="priority">The priority</param>
 public void Add(Material mat, int priority)
 {
     var mr = new MaterialRequest();
     mr.mat = mat;
     mr.priority = priority;
     Add(mr);
 }
        public async Task HandleAsync(CreateMaterialRequest command)
        {
            var supplier = await _repository.GetAsync <Supplier>(command.SupplierId);

            var requestedItems = new List <InventoryItem>();

            foreach (var(articleId, amount) in command.Items)
            {
                if (supplier.SuppliableArticles.All(a => a.Id != articleId))
                {
                    throw new DomainException(RequestingUnregisteredArticle(supplier, articleId));
                }
                var article = await _repository.LoadAsync <Article>(articleId);

                requestedItems.Add(new InventoryItem(article, amount));
            }

            var name    = $"To {supplier.Name} from {DateTimeOffset.Now}";
            var request = new MaterialRequest(command.Id, name)
            {
                Supplier       = supplier,
                Status         = MaterialRequestStatus.Submitted,
                ItemsRequested = requestedItems,
                CreatedAt      = DateTimeOffset.Now
            };

            supplier.MaterialRequests.Add(request);

            await _repository.AddAsync(request);

            await _eventTransmitter.BroadcastAsync(new DomainEvent <MaterialRequest>(request, Trigger.Added,
                                                                                     command.InitiatorId));
        }
示例#7
0
        /// <summary>
        /// solve Tree
        /// </summary>
        /// <param name="request"></param>
        private void MaterialRequest(object o)
        {
            var p       = o as ProductionOrder;
            var request = p.Message as MaterialRequest;

            if (request.Material.Materials != null)
            {
                foreach (var child in request.Material.Materials)
                {
                    for (int i = 0; i < child.Quantity; i++)
                    {
                        var childRequest = new MaterialRequest(material: child,
                                                               childRequests: null,
                                                               parrent: request.Id,
                                                               due: request.Due - request.Material.AssemblyDuration - child.AssemblyDuration,
                                                               isHead: false);
                        request.ChildRequests.Add(childRequest.Id, false);
                        var po = new ProductionOrder(childRequest, Self);
                        _SimulationContext.Tell(po, Self);
                    }
                }
            }
            if (request.Material.IsReady)
            {
                ReadyItems.Enqueue(request);
            }
            else
            {
                WaitingItems.Add(request);
            }

            PushWork();
        }
示例#8
0
 public void Update(MaterialRequest materialRequest)
 {
     materialRequest.Status = null;
     _db.SetEntityStateModified(materialRequest);
     _db.DeleteOrphans();
     _db.SaveChanges();
 }
        public Material getShellMat()
        {
            // Material result = MaterialPool.MatFrom(path + "0");
            if (ticktime < 34910 && !canFire)
            {
                return(oldt);
            }

            if (!hasPower())
            {
                return(oldt);
            }

            if (ticktime % 4 != 0 && oldt != null)
            {
                return(oldt);
            }

            var req    = new MaterialRequest(list.RandomElement());
            var result = MaterialPool.MatFrom(req);

            oldt = result;
            return(result);

            // result = MaterialPool.MatFrom(path + index);
        }
示例#10
0
        public int CreateRequest(MaterialRequest materialRequest)
        {
            using (SqlConnection connGetDistrict = ConnectionProvider.GetConnection())
            {
                int Result = 0;
                try
                {
                    SqlCommand cmdDistrict = new SqlCommand("SP_Request", connGetDistrict);
                    cmdDistrict.CommandType    = CommandType.StoredProcedure;
                    cmdDistrict.CommandTimeout = 250;
                    cmdDistrict.Parameters.Add("@flag", SqlDbType.Char).Value               = "CreateRequestHdr";
                    cmdDistrict.Parameters.Add("@DATE", SqlDbType.Date).Value               = materialRequest.Date;
                    cmdDistrict.Parameters.Add("@TIME", SqlDbType.NVarChar).Value           = materialRequest.Time;
                    cmdDistrict.Parameters.Add("@REQUESTER_NAME", SqlDbType.NVarChar).Value = materialRequest.Requester_Name;
                    cmdDistrict.Parameters.Add("@DEPARTMENT_ID", SqlDbType.Int).Value       = materialRequest.Department_Id;
                    cmdDistrict.Parameters.Add("@DESCRIPTION", SqlDbType.NVarChar).Value    = materialRequest.Description;
                    cmdDistrict.Parameters.Add("@COMMENTS", SqlDbType.NVarChar).Value       = materialRequest.Comment;
                    cmdDistrict.Parameters.Add("@OutID", SqlDbType.Int).Direction           = ParameterDirection.Output;

                    cmdDistrict.ExecuteNonQuery();
                    int    ID        = Convert.ToInt32(cmdDistrict.Parameters["@OutID"].Value);
                    string ReqNumber = "MRI" + ID;
                    cmdDistrict.Parameters.Clear();
                    cmdDistrict.Parameters.Add("@flag", SqlDbType.Char).Value           = "UpdateReqNo";
                    cmdDistrict.Parameters.Add("@REQUEST_NO", SqlDbType.NVarChar).Value = ReqNumber;
                    cmdDistrict.Parameters.Add("@REQUEST_HDR_ID", SqlDbType.Int).Value  = ID;
                    cmdDistrict.Parameters.Add("@OutID", SqlDbType.Int).Direction       = ParameterDirection.Output;
                    Result = cmdDistrict.ExecuteNonQuery();
                    if (Result > 0)
                    {
                        foreach (var Items in materialRequest.RequestItemsList)
                        {
                            cmdDistrict.Parameters.Clear();
                            cmdDistrict.Parameters.Add("@flag", SqlDbType.Char).Value                = "CreateRequestDtl";
                            cmdDistrict.Parameters.Add("@REQUEST_HDR_ID", SqlDbType.Int).Value       = ID;
                            cmdDistrict.Parameters.Add("@ITEM_ID", SqlDbType.Int).Value              = Items.Item_Id;
                            cmdDistrict.Parameters.Add("@UOM_ID", SqlDbType.Int).Value               = Items.Uom_Id;
                            cmdDistrict.Parameters.Add("@TO_LOCATION", SqlDbType.Int).Value          = Items.To_Location;
                            cmdDistrict.Parameters.Add("@REQUEST_QUANTITY", SqlDbType.Decimal).Value = Items.Request_Quantity;
                            cmdDistrict.Parameters.Add("@COMMENTS", SqlDbType.NVarChar).Value        = Items.Comment;
                            cmdDistrict.Parameters.Add("@OutID", SqlDbType.Int).Direction            = ParameterDirection.Output;
                            Result = cmdDistrict.ExecuteNonQuery();
                        }
                    }
                    return(Result);
                }
                catch (Exception ex)
                {
                    return(0);
                }
                finally
                {
                    if (connGetDistrict.State == ConnectionState.Open)
                    {
                        connGetDistrict.Close();
                    }
                }
            }
        }
        static bool Prefix(MaterialRequest req)
        {
            if (!Active)
            {
                return(true);
            }

            req.mainTex.wrapMode = TextureWrapMode.Clamp;
            return(true);
        }
示例#12
0
        public virtual async Task <IActionResult> Create(MaterialRequest materialData)
        {
            var category = categoriesCache.GetCategory(materialData.CategoryName);

            if (category == null)
            {
                return(BadRequest());
            }

            if (!materialsAuthorization.CanCreate(User.Roles, category))
            {
                return(Unauthorized());
            }

            var now = DateTime.UtcNow;

            var material = new Material
            {
                Title        = materialData.Title,
                Text         = materialData.text,
                PublishDate  = now,
                LastActivity = now,
                CategoryId   = category.Id,
                AuthorId     = User.UserId
            };

            await SetNameAsync(material, materialData.Name);

            if (category.IsMaterialsSubTitleEditable)
            {
                material.SubTitle = materialData.SubTitle;
            }

            if (materialData.IsHidden && materialsAuthorization.CanHide(User.Roles, category))
            {
                material.IsHidden = true;
            }

            if (materialData.IsHidden && materialsAuthorization.CanBlockComments(User.Roles, category))
            {
                material.IsCommentsBlocked = true;
            }

            if (materialsAuthorization.CanEditSettingsJson(User.Roles, category))
            {
                material.SettingsJson = materialData.SettingsJson;
            }

            await materialsManager.CreateAsync(material, materialData.Tags, category, User.Roles);

            contentCache.InvalidateCache(category.Id);

            return(Ok());
        }
示例#13
0
 public static bool MatFrom(ref Material __result, MaterialRequest req)
 {
     if (allThreads2.TryGetValue(CurrentThread, out ThreadInfo threadInfo))
     {
         threadInfo.safeFunctionRequest = new object[] { safeFunction, new object[] { req } };
         mainThreadWaitHandle.Set();
         threadInfo.eventWaitStart.WaitOne();
         __result = (Material)threadInfo.safeFunctionResult;
         return(false);
     }
     return(true);
 }
        private static Material MatFrom(string texPath, Shader shader, Color color, Color colorTwo, int renderQueue)
        {
            var materialRequest = new MaterialRequest(ContentFinder <Texture2D> .Get(texPath), shader)
            {
                renderQueue = renderQueue,
                color       = colorTwo,
                colorTwo    = color,
                maskTex     = ContentFinder <Texture2D> .Get(texPath + Graphic_Single.MaskSuffix, false)
            };

            return(MaterialPool.MatFrom(materialRequest));
        }
示例#15
0
        private static void RunSimulation()
        {
            LogConfiguration.LogTo(TargetTypes.File, TargetNames.LOG_AGENTS, LogLevel.Info, LogLevel.Warn);
            LogConfiguration.LogTo(TargetTypes.Console, TargetNames.LOG_AGENTS, LogLevel.Info);
            LogConfiguration.LogTo(TargetTypes.Console, TargetNames.LOG_AKKA, LogLevel.Warn);
            LogConfiguration.LogTo(TargetTypes.File, TargetNames.LOG_AKKA, LogLevel.Trace);
            //InternalLogger.LogToConsole = true;
            //InternalLogger.LogLevel = LogLevel.Trace;

            SimulationConfig simConfig = new SimulationConfig(debugAkka: false
                                                              , debugAkkaSim: true
                                                              , interruptInterval: 120
                                                              , timeToAdvance: TimeSpan.FromSeconds(0));
            var sim = new Simulation(simConfig);
            var r   = new Random();

            Console.ReadKey();

            var jobDistributor =
                sim.ActorSystem.ActorOf(MachineJobDistributor.Props(sim.ActorSystem.EventStream, sim.SimulationContext, 0),
                                        "JobDistributor");

            // Tell all Machines
            for (int i = 0; i < 3; i++)
            {
                // Create a message
                var createMachines = new MachineJobDistributor.AddMachine(null, jobDistributor);
                sim.SimulationContext.Tell(createMachines, null);
            }

            for (int i = 0; i < 300; i++)
            {
                var materialRequest = new MaterialRequest(CreateBOM(), new Dictionary <int, bool>(), 0, r.Next(50, 500), true);
                var request         = new MachineJobDistributor.ProductionOrder(materialRequest, jobDistributor);
                sim.SimulationContext.Tell(request, null);
            }

            // example to monitor for FinishWork Messages.

            var monitor = sim.ActorSystem.ActorOf(props: Monitoring.WorkTimeMonitor
                                                  .Props(time: 0),
                                                  name: "SimulationMonitor");

            if (sim.IsReady())
            {
                var terminated = sim.RunAsync();
                new StateManager().Continuation(simConfig.Inbox, sim);
                terminated.Wait();
            }

            Console.WriteLine("Systen is shutdown!");
            Console.WriteLine("System Runtime " + sim.ActorSystem.Uptime);
        }
示例#16
0
        public void Create(MaterialRequest materialRequest)
        {
            var status = _db.Status.FirstOrDefault(s => s.Description.Equals("Submitted"));

            if (status != null)
            {
                materialRequest.StatusId    = status.Id;
                materialRequest.RequestDate = DateTime.Now;
                _db.SetEntityStateAdded(materialRequest);
                _db.SaveChanges();
            }
        }
示例#17
0
 public static bool MatFrom(ref Material __result, MaterialRequest req)
 {
     if (!CurrentThread.IsBackground || !allWorkerThreads.TryGetValue(CurrentThread, out ThreadInfo threadInfo))
     {
         return(true);
     }
     threadInfo.safeFunctionRequest = new object[] { FuncMatFrom, new object[] { req } };
     mainThreadWaitHandle.Set();
     threadInfo.eventWaitStart.WaitOne();
     __result = (Material)threadInfo.safeFunctionResult;
     return(false);
 }
        private static Material MatFrom(string texPath, Shader shader, Color color, Color colorTwo, int renderQueue)
        {
            MaterialRequest materialRequest = new MaterialRequest(tex: ContentFinder <Texture2D> .Get(itemPath: texPath), shader: shader)
            {
                renderQueue = renderQueue,
                color       = colorTwo,
                colorTwo    = color,
                maskTex     = ContentFinder <Texture2D> .Get(itemPath : texPath + Graphic_Single.MaskSuffix, reportFailure : false),
            };

            return(MaterialPool.MatFrom(req: materialRequest));
        }
示例#19
0
        /// <summary>
        /// A small helper function to load materials (based on Tynans code)
        /// </summary>
        /// <param name="texturePath"></param>
        /// <returns></returns>
        public static Material LoadMaterial(string texturePath, ShaderType shaderType = ShaderType.Transparent, bool throwError = true)
        {
            Texture2D texture2D = ContentFinder <Texture2D> .Get(texturePath, throwError);

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

            MaterialRequest materialRequest = new MaterialRequest(texture2D, ShaderDatabase.ShaderFromType(shaderType));

            return(MaterialPool.MatFrom(materialRequest));
        }
示例#20
0
        public IEnumerable <Material> GetMaterialList(MaterialRequest request = null)
        {
            request = request ?? new MaterialRequest();
            using (var dbContext = new BasedataDbContext())
            {
                IQueryable <Material> materials = dbContext.Materials;
                if (!string.IsNullOrEmpty(request.MaterialName))
                {
                    materials = materials.Where(u => u.MaterialName.Contains(request.MaterialName));
                }

                return(materials.OrderByDescending(u => u.ID).ToPagedList(request.PageIndex, request.PageSize));
            }
        }
示例#21
0
        private static void Run()
        {
            Console.WriteLine("Simulation world of Akka!");

            SimulationConfig simConfig = new SimulationConfig(false, 480);
            var sim = new Simulation(simConfig);
            var r   = new Random();

            Console.ReadKey();

            var jobDistributor = sim.ActorSystem.ActorOf(MachineJobDistributor.Props(sim.ActorSystem.EventStream, sim.SimulationContext, 0), "JobDistributor");
            // Create a message
            var createMachines = new MachineJobDistributor.AddMachine(null, jobDistributor);

            // Tell all Machines
            for (int i = 0; i < 10; i++)
            {
                sim.SimulationContext.Tell(createMachines, null);
            }

            for (int i = 0; i < 3000; i++)
            {
                var materialRequest = new MaterialRequest(CreateBOM(), new Dictionary <int, bool>(), 0, r.Next(50, 500), true);
                var request         = new MachineJobDistributor.ProductionOrder(materialRequest, jobDistributor);
                sim.SimulationContext.Tell(request, null);
            }

            // example to monitor for FinishWork Messages.

            var monitor = sim.ActorSystem.ActorOf(props: Monitoring.WorkTimeMonitor
                                                  .Props(time: 0),
                                                  name: "SimulationMonitor");
            var stw = new Stopwatch();

            stw.Start();

            if (sim.IsReady())
            {
                sim.RunAsync();
                //Continuation(simConfig.Inbox, sim);
            }



            Console.WriteLine("Systen shutdown. . . ");
            Console.WriteLine("System Runtime " + sim.ActorSystem.Uptime);

            Console.ReadLine();
        }
示例#22
0
        public Material getMat()
        {
            // int speed = this.Props.speed;
            //int index = ((this.ticktime)/speed) %4 ;
            //if (this.ticktime>=(4* speed) -1) { this.ticktime = 0; }
            if (ticktime % 4 != 0 && oldt != null)
            {
                return(oldt);
            }

            var req    = new MaterialRequest(list.RandomElement());
            var result = MaterialPool.MatFrom(req);

            oldt = result;
            return(result);
        }
示例#23
0
 public MaterialRequestRGB(MaterialRequest req, Texture2D patternTex, PatternProperties properties, bool isSkin)
 {
     shader           = req.shader;
     mainTex          = req.mainTex;
     maskTex          = req.maskTex;
     this.properties  = properties;
     color            = properties.colorOne ?? Color.white;
     colorTwo         = properties.colorTwo ?? Color.white;
     colorThree       = properties.colorThree ?? Color.white;
     tiles            = properties.tiles.TryGetValue("All", 1);
     displacement     = Vector2.zero;
     this.patternTex  = patternTex;
     renderQueue      = req.renderQueue;
     shaderParameters = req.shaderParameters;
     this.isSkin      = isSkin;
 }
        public override void SpawnSetup(Map map, bool respawningAfterLoad)
        {
            base.SpawnSetup(map, respawningAfterLoad);
            GraphicRequest req = new GraphicRequest(this.def.graphicData.graphicClass, this.def.graphicData.texPath + "_Ground", this.def.graphicData.shaderType.Shader,
                                                    this.def.graphicData.drawSize, this.def.graphicData.color, this.def.graphicData.colorTwo, this.def.graphicData, 0, null);

            MaterialRequest req2 = default(MaterialRequest);

            req2.mainTex = ContentFinder <Texture2D> .Get(req.path);

            req2.shader           = req.shader;
            req2.color            = req.color;
            req2.colorTwo         = req.colorTwo;
            req2.renderQueue      = req.renderQueue;
            req2.shaderParameters = req.shaderParameters;
            groundMat             = MaterialPool.MatFrom(req2);
        }
示例#25
0
 public ActionResult Index(MaterialRequest request, int?id)
 {
     this.ViewData["BasisDataService"] = this.BasisDataService;
     if (id > 0)
     {
         return(View(this.BasisDataService.GetMaterialList(new MaterialRequest()
         {
             ClassificationID = id
         })));
     }
     else
     {
         //var materialList = this.BasisDataService.GetMaterialList(new MaterialRequest());
         //this.ViewBag.ChannelId = new SelectList(classList, "ID", "Name");
         var result = this.BasisDataService.GetMaterialList(request);
         return(View(result));
     }
 }
示例#26
0
        public Material getMat()
        {
            // int speed = this.Props.speed;
            //int index = ((this.ticktime)/speed) %4 ;
            //if (this.ticktime>=(4* speed) -1) { this.ticktime = 0; }
            if (this.ticktime % 4 == 0 || oldt == null)
            {
                MaterialRequest req    = new MaterialRequest(list.RandomElement <Texture2D>());
                Material        result = MaterialPool.MatFrom(req);

                oldt = result;
                return(result);
            }



            return(oldt);
        }
示例#27
0
        public override void Init(GraphicRequest req)
        {
            data     = req.graphicData;
            path     = req.path;
            color    = req.color;
            colorTwo = req.colorTwo;
            drawSize = req.drawSize;

            hash = Gen.HashCombine(hash, path);
            hash = Gen.HashCombineStruct(hash, color);
            hash = Gen.HashCombineStruct(hash, colorTwo);

            var bodyColor = GraphicToolbox.RandomSkinColorString();

            mats = new ColorData[]
            {
                GraphicsDatabase.GetColorData(req.path + "_back", bodyColor, true),
                GraphicsDatabase.GetColorData(req.path + "_side", bodyColor, true),
                GraphicsDatabase.GetColorData(req.path + "_front", bodyColor, true)
            }
            .Select(data =>
            {
                var points = ZombieStains.maxStainPoints;
                while (points > 0)
                {
                    var stain = ZombieStains.GetRandom(points, req.path.Contains("Naked"));
                    data.ApplyStains(stain.Key, Rand.Bool, Rand.Bool);
                    points -= stain.Value;

                    hash = Gen.HashCombine(hash, stain);
                }

                var request = new MaterialRequest
                {
                    mainTex  = null,                    // will be calculated lazy from 'data'
                    shader   = req.shader,
                    color    = color,
                    colorTwo = colorTwo,
                    maskTex  = null
                };
                return(new PreparedMaterial(request, data));
            })
            .ToArray();
        }
示例#28
0
        public static bool MatFrom(ref Material __result, MaterialRequest req)
        {
            int tID = Thread.CurrentThread.ManagedThreadId;

            if (RimThreaded.mainRequestWaits.TryGetValue(tID, out EventWaitHandle eventWaitStart))
            {
                object[] functionAndParameters = new object[] { safeFunction, new object[] { req } };
                lock (RimThreaded.safeFunctionRequests)
                {
                    RimThreaded.safeFunctionRequests[tID] = functionAndParameters;
                }
                RimThreaded.mainThreadWaitHandle.Set();
                eventWaitStart.WaitOne();
                RimThreaded.safeFunctionResults.TryGetValue(tID, out object safeFunctionResult);
                __result = (Material)safeFunctionResult;
                return(false);
            }
            return(true);
        }
        public async Task <IActionResult> Update([FromRoute] Guid materialId, [FromBody] MaterialRequest request)
        {
            var material = await _materialsService.GetByIdAsync(materialId);

            material.Category     = request.Category;
            material.HouseSection = HouseSectionStringToEnum(request.HouseSection);
            material.Name         = request.Name;
            material.PricePerUnit = request.PricePerUnit;
            material.Supplier     = request.Supplier;
            material.Units        = request.Units;

            var updated = await _materialsService.UpdateAsync(material);

            if (updated)
            {
                return(Ok(MaterialToMaterialResponse(material)));
            }
            return(NotFound());
        }
示例#30
0
        public void Delete(MaterialRequest materialRequest)
        {
            var listDuplexes = materialRequest.RequestedDuplexes.ToList();

            foreach (var requestedDuplex in listDuplexes)
            {
                _db.SetEntityStateDeleted(requestedDuplex);
            }

            var listStrands = materialRequest.RequestedStrands.ToList();

            foreach (var requestedStrand in listStrands)
            {
                _db.SetEntityStateDeleted(requestedStrand);
            }

            _db.SetEntityStateDeleted(materialRequest);
            _db.SaveChanges();
        }
示例#31
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Simulation world of Akka!");

            var sim = new Simulation(false);
            var r   = new Random();

            Console.ReadKey();

            var jobDistributor = sim.ActorSystem.ActorOf(MachineJobDistributor.Props(sim.ActorSystem.EventStream, sim.SimulationContext, 0), "JobDistributor");
            // Create a message
            var createMachines = new MachineJobDistributor.AddMachine(null, jobDistributor);

            // Tell all Machines
            for (int i = 0; i < 10; i++)
            {
                sim.SimulationContext.Tell(createMachines, null);
            }

            for (int i = 0; i < 200; i++)
            {
                var materialRequest = new MaterialRequest(CreateBOM(), new Dictionary <int, bool>(), 0, r.Next(50, 500), true);
                var request         = new MachineJobDistributor.ProductionOrder(materialRequest, jobDistributor);
                sim.SimulationContext.Tell(request, null);
            }

            // example to monitor for FinishWork Messages.

            var monitor = sim.ActorSystem.ActorOf(props: Monitoring.WorkTimeMonitor
                                                  .Props(time: 0),
                                                  name: "SimulationMonitor");
            var stw = new Stopwatch();

            stw.Start();


            sim.RunAsync().Wait();

            Console.WriteLine("System Runtime " + sim.ActorSystem.Uptime);
            Console.WriteLine("Final Call Finisch Done Forever Together And So On");
            Console.ReadLine();
        }
示例#32
0
        public Material getShellMat()
        {
            // Material result = MaterialPool.MatFrom(path + "0");
            if (this.ticktime >= 34910 || canFire)
            {
                if (hasPower())
                {
                    if (this.ticktime % 4 == 0 || oldt == null)
                    {
                        MaterialRequest req    = new MaterialRequest(list.RandomElement <Texture2D>());
                        Material        result = MaterialPool.MatFrom(req);

                        oldt = result;
                        return(result);
                    }
                }
                // result = MaterialPool.MatFrom(path + index);
            }

            return(oldt);
        }
 /// <summary>
 /// Add a new MaterialRequest
 /// </summary>
 /// <param name="mr">The MaterialRequest to add</param>
 void Add(MaterialRequest mr)
 {
     for (int i = 0; i < materialRequests.Count; i++)
         if (mr.priority < materialRequests[i].priority)
         {
             materialRequests.Insert(i, mr);
             break;
         }
     if (!materialRequests.Contains(mr)) materialRequests.Add(mr); // At the end if not added already
     UpdateMaterial();
 }