public async Task <(bool, string)> WriteOrder(ProductionOrder productionOrder)
        {
            try{
                bool returnBool;

                switch (productionOrder.typeDescription.ToString().ToLower())
                {
                case "tira":
                    Console.WriteLine("Começou");
                    Console.WriteLine("");
                    Console.WriteLine("");
                    Console.WriteLine("");
                    Console.WriteLine("Era de tira");
                    returnBool = await OpTypeTira(productionOrder);

                    break;

                case "liga":
                    returnBool = true;
                    break;

                default:
                    returnBool = false;
                    break;
                }

                return(returnBool, string.Empty);
            }
            catch (Exception ex)
            {
                return(false, ex.ToString());
            }
        }
Beispiel #2
0
        public string GetGraphizString(ProductionOrder productionOrder)
        {
            // Demand(CustomerOrder);20;Truck
            string graphizString = $"P: ProductionOrder;{ToGraphizString(productionOrder)}";

            return(graphizString);
        }
        internal static ProductionOrder GetById(int id)
        {
            var productionOrder = new ProductionOrder();

            try
            {
                using (var connection = SqlServer.OpenConnection())
                {
                    var strSql = "SELECT Id, PalletId, MoldId, PartId, Status FROM ProductionOrders WHERE Id=@Id";

                    using (var command = new SqlCommand(strSql, connection))
                    {
                        command.Parameters.AddWithValue("@Id", id);

                        using (var reader = command.ExecuteReader())
                        {
                            if (reader.Read())
                            {
                                productionOrder.Id         = int.Parse(reader["Id"].ToString());
                                productionOrder.Pallet     = PalletRepository.GetById(int.Parse(reader["PalletId"].ToString()));
                                productionOrder.Mold       = MoldRepository.GetById(int.Parse(reader["MoldId"].ToString()));
                                productionOrder.ActivePart = PartRepository.GetById(int.Parse(reader["PartId"].ToString()));
                                productionOrder.Status     = (ProductionOrderStatus)int.Parse(reader["Status"].ToString());
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //Introducir en el futuro codigo para NLog.
            }

            return(productionOrder);
        }
        public async Task <IActionResult> Edit(int id, [Bind("ProductionOrderId,ArticleId,Quantity,Name")] ProductionOrder productionOrder)
        {
            if (id != productionOrder.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(productionOrder);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductionOrderExists(productionOrder.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            ViewData["ArticleId"] = new SelectList(_context.Articles, "ArticleId", "ArticleId", productionOrder.ArticleId);
            return(View(productionOrder));
        }
Beispiel #5
0
        private void CreateGraph2(ProductionOrder productionOrder)
        {
            IDbTransactionData dbTransactionData =
                ZppConfiguration.CacheManager.GetDbTransactionData();
            IEnumerable <ProductionOrderOperation> productionOrderOperations = dbTransactionData
                                                                               .ProductionOrderOperationGetAll().GetAll().Where(x =>
                                                                                                                                x.GetValue().ProductionOrderId.Equals(productionOrder.GetId().GetValue()))
                                                                               .OrderByDescending(x => x.GetHierarchyNumber().GetValue());

            ;
            if (productionOrderOperations.Any() == false)
            {
                Clear();
                return;
            }

            // root is always the productionOrder
            INode predecessor = new Node(productionOrder);

            foreach (var operation in productionOrderOperations)
            {
                INode operationNode = new Node(operation);
                AddEdge(new Edge(predecessor, operationNode));
                predecessor = operationNode;
            }
        }
Beispiel #6
0
        /// <summary>
        ///     A mock for BabyDiaperRetentionBll for Save methods
        /// </summary>
        /// <param name="testSheet">testSheet data which would be in the db</param>
        /// <param name="productionOrder">testSheet data which would be in the db</param>
        /// <param name="testValue">testValue data which would be in the db</param>
        /// <returns>a ITestBll moq</returns>
        public static ITestBll GetTestBllForSavingAndUpdating(TestSheet testSheet, ProductionOrder productionOrder, TestValue testValue)
        {
            var mock = new Mock <ITestBll>
            {
                Name         = "MockHelper.GetTestBllForSavingAndUpdating",
                DefaultValue = DefaultValue.Mock
            };

            mock.Setup(x => x.SaveNewTestValue(It.IsAny <TestValue>()))
            .Returns(( TestValue tValue ) => tValue);
            mock.Setup(x => x.UpdateTestValue(It.IsAny <TestValue>()))
            .Returns(( TestValue tValue ) => tValue);
            mock.Setup(x => x.GetTestSheetInfo(It.IsAny <Int32>()))
            .Returns(testSheet);
            mock.Setup(x => x.GetProductionOrder(It.IsAny <String>()))
            .Returns(productionOrder);
            mock.Setup(x => x.GetTestValue(It.IsAny <Int32>()))
            .Returns(testValue);
            mock.Setup(x => x.UpdateTestSheet())
            .Returns(0);
            mock.Setup(x => x.DeleteNote(It.IsAny <Int32>()))
            .Returns(new TestValueNote());

            return(mock.Object);
        }
Beispiel #7
0
        void selRow()
        {
            if (dgvData.CurrentCell != null && dgvData.CurrentCell.RowIndex >= 0)
            {
                var rowe = dgvData.CurrentCell.RowInfo;
                idCustomerPO = rowe.Cells["idCustomerPO"].Value.ToInt();

                if (dgvData.CurrentCell.ColumnInfo.Name.Equals("JobNo"))
                {
                    string jobNo = rowe.Cells["JobNo"].Value.ToSt();
                    if (!baseClass.Question("Do you want to open 'Job Order sheet' ?"))
                    {
                        return;
                    }
                    var m = new ProductionOrder(jobNo);
                    m.ShowDialog();
                    DataLoad();
                }
                else
                {
                    if (sType == 1)
                    {
                        var p = new CustomerPO(idCustomerPO);
                        p.ShowDialog();
                        DataLoad();
                    }
                    else
                    {
                        this.Close();
                    }
                }
            }
        }
Beispiel #8
0
 public ProductionCommand(CommandMode mode, ProductionOrder productionOrder, string starKey, int index = 0)
 {
     Mode            = mode;
     ProductionOrder = productionOrder;
     StarKey         = starKey;
     Index           = index;
 }
        public static bool Cancel(ProductionOrder po)
        {
            MySqlTransaction tr = null;

            try
            {
                using (var conn = new MySqlConnection(Globals.CONN_STR))
                {
                    conn.Open();
                    tr = conn.BeginTransaction();
                    var sql = "";

                    sql = @"UPDATE production_order
								SET  active=@active 
								WHERE po_no=@po_no"                                ;
                    var cmd = new MySqlCommand(sql, conn)
                    {
                        Transaction = tr
                    };
                    cmd.Parameters.AddWithValue("po_no", po.PoNo);
                    cmd.Parameters.AddWithValue("active", po.Active);
                    var affRow = cmd.ExecuteNonQuery();

                    tr.Commit();
                }
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
        /// <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();
        }
        public async Task <(ProductionOrder, HttpStatusCode)> getProductionOrderId(int id)
        {
            ProductionOrder returnProductionOrder = null;

            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            var    builder = new UriBuilder(_configuration["ProductionOrderApi"]);
            string url     = builder.ToString() + id;

            var result = await client.GetAsync(url);

            switch (result.StatusCode)
            {
            case HttpStatusCode.OK:
            {
                var returnAPI = await client.GetStringAsync(url);

                returnProductionOrder = JsonConvert.DeserializeObject <ProductionOrder>(returnAPI);
                return(returnProductionOrder, HttpStatusCode.OK);
            }

            case HttpStatusCode.NotFound:
                return(returnProductionOrder, HttpStatusCode.NotFound);

            case HttpStatusCode.InternalServerError:
                return(returnProductionOrder, HttpStatusCode.InternalServerError);
            }
            return(returnProductionOrder, HttpStatusCode.NotFound);
        }
Beispiel #12
0
        public ProductionOrderOperation GetHighestPriorityOperation(DueTime now,
                                                                    List <ProductionOrderOperation> productionOrderOperations)
        {
            IDbTransactionData dbTransactionData =
                ZppConfiguration.CacheManager.GetDbTransactionData();

            if (productionOrderOperations.Any() == false)
            {
                return(null);
            }

            foreach (var productionOrderOperation in productionOrderOperations)
            {
                ProductionOrder productionOrder =
                    dbTransactionData.ProductionOrderGetById(productionOrderOperation
                                                             .GetProductionOrderId());
                // TODO: This is this correct ?
                DueTime minStartNextOfParentProvider = productionOrder.GetStartTimeBackward();

                Priority priority = GetPriorityOfProductionOrderOperation(now,
                                                                          productionOrderOperation, minStartNextOfParentProvider);
                productionOrderOperation.SetPriority(priority);
            }

            return(productionOrderOperations.OrderBy(x => x.GetPriority().GetValue()).ToList()[0]);
        }
        public async Task <IActionResult> Post([FromBody] ProductionOrder productionOrder)
        {
            productionOrder.productionOrderId = 0;
            if (ModelState.IsValid)
            {
                bool pOExists = await _productionOrderService.checkProductionOrderNumber(productionOrder.productionOrderNumber);

                if (pOExists)
                {
                    ModelState.AddModelError("productionOrderNumber", "This Production Order Number already exists.");
                    return(BadRequest(ModelState));
                }
                bool pOTypeExists = await _productionOrderService.checkProductionOrderType(productionOrder.productionOrderTypeId.Value);

                if (!pOTypeExists)
                {
                    ModelState.AddModelError("productionOrderTypeId", "This Production Order Type Doesn't exists.");
                    return(BadRequest(ModelState));
                }

                productionOrder = await _productionOrderService.addProductionOrder(productionOrder);

                if (productionOrder == null)
                {
                    return(BadRequest());
                }
                return(Created($"api/phases/{productionOrder.productionOrderId}", productionOrder));
            }
            return(BadRequest(ModelState));
        }
        private static void HandleProductionOrderIsInStateCreated(ProductionOrder productionOrder,
                                                                  IAggregator aggregator, IDbTransactionData dbTransactionData)
        {
            // delete all operations
            List <ProductionOrderOperation> operations =
                aggregator.GetProductionOrderOperationsOfProductionOrder(productionOrder);

            dbTransactionData.ProductionOrderOperationDeleteAll(operations);

            // collect entities and demandToProviders/providerToDemands to delete
            List <IDemandOrProvider> demandOrProvidersToDelete =
                CreateProductionOrderSubGraph(true, productionOrder, aggregator);

            // delete all collected entities
            IOpenDemandManager openDemandManager =
                ZppConfiguration.CacheManager.GetOpenDemandManager();

            foreach (var demandOrProvider in demandOrProvidersToDelete)
            {
                // don't forget to delete it from openDemands
                if (demandOrProvider.GetType() == typeof(StockExchangeDemand))
                {
                    if (openDemandManager.Contains((Demand)demandOrProvider))
                    {
                        openDemandManager.RemoveDemand((Demand)demandOrProvider);
                    }
                }

                List <ILinkDemandAndProvider> demandAndProviderLinks =
                    aggregator.GetArrowsToAndFrom(demandOrProvider);
                dbTransactionData.DeleteAllFrom(demandAndProviderLinks);

                dbTransactionData.DeleteA(demandOrProvider);
            }
        }
        public async Task <ProductionOrderQuality> AddProductionOrderQuality(ProductionOrder productionOrder)
        {
            ProductionOrderQuality productionOrderQuality = new ProductionOrderQuality();

            var tool = await GetToolApi(productionOrder.currentThing.thingId);

            // if(tool == null)//if(tool == null || tool.Count == 0)
            // {
            //     Console.WriteLine("Ferramenta nula");
            //     return null;
            // }


            productionOrderQuality.productionOrderNumber = productionOrder.productionOrderNumber;
            productionOrderQuality.productionOrderId     = productionOrder.productionOrderId;
            productionOrderQuality.forno    = "Nome da Ferramenta"; //tool.FirstOrDefault().name;
            productionOrderQuality.corrida  = 0;                    //Convert.ToInt32(tool.FirstOrDefault().currentLife);
            productionOrderQuality.posicao  = productionOrder.currentThing.thingName;
            productionOrderQuality.status   = "create";
            productionOrderQuality.qntForno = productionOrder.quantForno;

            _context.ProductionOrderQualities.Add(productionOrderQuality);
            await _context.SaveChangesAsync();

            return(productionOrderQuality);
        }
        public async Task <(ProductionOrder, string)> DisassociateProductionOrder(ProductionOrder productionOrder)
        {
            var PODB = await _productionOrderService.getProductionOrder(productionOrder.productionOrderId);

            if (PODB == null)
            {
                return(null, "Production Order Not Found");
            }
            if (PODB.currentStatus != stateEnum.ended.ToString())
            {
                return(null, "Production Order Not Ended");
            }
            var POType = await _productionOrderTypeService.getProductionOrderType(productionOrder.productionOrderTypeId.Value);

            if (POType == null)
            {
                return(null, "Production Order Type Not Found");
            }
            UpdateStatusAPI(POType.typeScope, POType.typeDescription, "productionOrderNumber", "", PODB.currentThingId.Value);
            await _productionOrderService.setProductionOrderToThing(PODB, null);

            Trigger(PODB);
            PODB = await _productionOrderService.getProductionOrder(productionOrder.productionOrderId);

            return(PODB, "Production Order Disassociated");
        }
        public void tempNextTick(DateTime currentTime)
        {
            foreach (Tool tool in ToolsList.toolList)
            {
                tool.TimeTick();

                if (tool.CurrentStatus == Tool.ToolStatuses.Idle)
                {
                    ProductionOrder productionOrder = ProductionQueue[tool.ToolType].getTopOrder();
                    if (productionOrder != null)
                    {
                        tool.StartProduction(productionOrder);
                    }
                }

                string info = tool.ToolName + "\n" +
                              tool.CurrentStatus.ToString() + "\n" +
                              tool.ProcessingTimeRemaining.ToString() + "\n";
                if (tool.CurrentProductionOrder != null)
                {
                    info = info + tool.CurrentProductionOrder.OrderID + "\n";
                }
                else
                {
                    info = info + "no order";
                }

                MessageBox.Show(info);
            }
        }
Beispiel #18
0
        /// <summary>
        /// Load from XML: Initializing constructor from an XML node.
        /// </summary>
        /// <param name="node">An <see cref="XmlNode"/> within
        /// a Nova component definition file (xml document).
        /// </param>
        public ProductionCommand(XmlNode node)
        {
            XmlNode mainNode = node.FirstChild;

            while (mainNode != null)
            {
                switch (mainNode.Name.ToLower())
                {
                case "mode":
                    Mode = (CommandMode)Enum.Parse(typeof(CommandMode), mainNode.FirstChild.Value);
                    break;

                case "productionorder":
                    ProductionOrder = new ProductionOrder(mainNode);
                    break;

                case "index":
                    Index = int.Parse(mainNode.FirstChild.Value, System.Globalization.CultureInfo.InvariantCulture);
                    break;

                case "starkey":
                    StarKey = mainNode.FirstChild.Value;
                    break;
                }

                mainNode = mainNode.NextSibling;
            }
        }
Beispiel #19
0
        private void PostProduction(ProductionOrder dbOrder)
        {
            CWInvPosting invpostingDialog = new CWInvPosting(api, "ReportAsFinished", true);

#if !SILVERLIGHT
            invpostingDialog.DialogTableId = 2000000041;
#endif
            invpostingDialog.Closed += async delegate
            {
                if (invpostingDialog.DialogResult == true)
                {
                    busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("SendingWait");
                    busyIndicator.IsBusy      = true;
                    var papi          = new Uniconta.API.Inventory.ProductionAPI(api);
                    var postingResult = await papi.ReportAsFinished(dbOrder, invpostingDialog.Date, invpostingDialog.Text, invpostingDialog.TransType,
                                                                    invpostingDialog.Comment, invpostingDialog.FixedVoucher, invpostingDialog.Simulation, new GLTransClientTotal(), 0, invpostingDialog.NumberSeries);

                    busyIndicator.IsBusy      = false;
                    busyIndicator.BusyContent = Uniconta.ClientTools.Localization.lookup("LoadingMsg");
                    if (postingResult == null)
                    {
                        return;
                    }
                    if (postingResult.Err != ErrorCodes.Succes)
                    {
                        Utility.ShowJournalError(postingResult, dgProductionOrders);
                    }
                    else if (invpostingDialog.Simulation)
                    {
                        if (postingResult.SimulatedTrans != null)
                        {
                            AddDockItem(TabControls.SimulatedTransactions, postingResult.SimulatedTrans, Uniconta.ClientTools.Localization.lookup("SimulatedTransactions"), null, true);
                        }
                        else
                        {
                            var msg = string.Format(Uniconta.ClientTools.Localization.lookup("OBJisEmpty"), Uniconta.ClientTools.Localization.lookup("LedgerTransList"));
                            msg = Uniconta.ClientTools.Localization.lookup("JournalOK") + Environment.NewLine + msg;
                            UnicontaMessageBox.Show(msg, Uniconta.ClientTools.Localization.lookup("Message"));
                        }
                    }
                    else
                    {
                        dgProductionOrders.UpdateItemSource(3, dbOrder);

                        string msg;
                        if (postingResult.JournalPostedlId != 0)
                        {
                            msg = string.Format("{0} {1}={2}", Uniconta.ClientTools.Localization.lookup("JournalHasBeenPosted"), Uniconta.ClientTools.Localization.lookup("JournalPostedId"), postingResult.JournalPostedlId);
                        }
                        else
                        {
                            msg = Uniconta.ClientTools.Localization.lookup("JournalHasBeenPosted");
                        }
                        UnicontaMessageBox.Show(msg, Uniconta.ClientTools.Localization.lookup("Message"));
                    }
                }
            };
            invpostingDialog.Show();
        }
 /// <summary>
 ///     returns the RwType for the BabyDiaperRetention test
 /// </summary>
 /// <param name="value">the tested Value</param>
 /// <param name="productOrder">the Production order</param>
 /// <returns></returns>
 private static RwType GetRetentionRwType(Double value, ProductionOrder productOrder)
 {
     if (value <= productOrder.Article.MinRetention)
     {
         return(RwType.Worse);
     }
     return(value >= productOrder.Article.MaxRetention ? RwType.Better : RwType.Ok);
 }
Beispiel #21
0
 public int GetAvailableAmountFromProductionOrder(ProductionOrder productionOrder)
 {
     if (productionOrder.DemandProviderProductionOrders == null)
     {
         return((int)productionOrder.Quantity);
     }
     return((int)productionOrder.Quantity - productionOrder.DemandProviderProductionOrders.Sum(provider => (int)provider.Quantity));
 }
Beispiel #22
0
 public object InsertUpdateProductionOrder(ProductionOrder productionOrder)
 {
     if (productionOrder.ProductionOrderDetailList.Count > 0)
     {
         productionOrder.DetailXML = _commonBusiness.GetXMLfromProductionOrderObject(productionOrder.ProductionOrderDetailList, "ProductID,ProductModelID,ProductSpec,UnitCode");
     }
     return(_productionOrderRepository.InsertUpdateProductionOrder(productionOrder));
 }
Beispiel #23
0
        public void RemoveProductionOrder(Team team, ProductionOrder order, User user)
        {
            CheckPossibilityToRemoveProductionOrder(team, user);

            team.RemoveProductionOrder(order);

            teamRepository.Save(team);
        }
Beispiel #24
0
        public ActionResult GenerateProductionOrder(Guid id)
        {
            ProductionOrderDataSet ds = new ProductionOrderDataSet();

            ProductionOrderDataSet.ProductionOrderRow poRow = ds.ProductionOrder.NewProductionOrderRow();
            ProductionOrder po            = db.ProductionOrders.SingleOrDefault(s => s.Id == id);
            ConfigSetting   configSetting = db.ConfigSettings.FirstOrDefault();

            if (configSetting == null)
            {
                configSetting = new ConfigSetting();
            }
            if (po == null)
            {
                return(null);
            }
            poRow.PONumber        = po.PONumber;
            poRow.Name            = po.Name;
            poRow.PhoneNumber     = po.PhoneNumber;
            poRow.Email           = po.Email;
            poRow.Note            = po.Note;
            poRow.Address         = po.Address;
            poRow.CreatedDate     = po.CreatedDate;
            poRow.CreatedBy       = po.CreatedBy;
            poRow.Total           = po.Total;
            poRow.Quantity        = po.Quantity;
            poRow.ShopName        = configSetting.AppName;
            poRow.ShopAddress     = configSetting.Address;
            poRow.ShopPhoneNumber = configSetting.PhoneNumber + (!string.IsNullOrEmpty(configSetting.MobilePhone) ? " - " + configSetting.MobilePhone : "");
            poRow.PaymentMethod   = "Thanh toán khi nhận hàng (COD)";

            poRow.USER_DEFINE = "";

            poRow.PrintedBy   = User.Identity.GetUserName();
            poRow.PrintedDate = DateTime.Now;

            ds.ProductionOrder.AddProductionOrderRow(poRow);

            int counter = 1;

            foreach (var item in po.CartItems)
            {
                ProductionOrderDataSet.CartItemRow itemRow = ds.CartItem.NewCartItemRow();
                itemRow.OrderNo     = counter++;
                itemRow.ProductName = item.ProductName;
                itemRow.Quantity    = item.Quantity;
                itemRow.Price       = item.Price;
                itemRow.Total       = item.Total;
                ds.CartItem.AddCartItemRow(itemRow);
            }
            rptProductionOrder report = new rptProductionOrder();

            report.SetDataSource((DataTable)ds.ProductionOrder);
            report.Subreports["rptCartItem"].SetDataSource((DataTable)ds.CartItem);
            Stream stream = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            return(File(stream, "application/pdf"));
        }
        public static void ApplyConfirmations()
        {
            IDbTransactionData dbTransactionData =
                ZppConfiguration.CacheManager.GetDbTransactionData();
            IAggregator aggregator = ZppConfiguration.CacheManager.GetAggregator();

            // ProductionOrder: 3 Zustände siehe DA
            Providers copyOfProductionOrders = new Providers();

            copyOfProductionOrders.AddAll(dbTransactionData.ProductionOrderGetAll());

            foreach (var provider in copyOfProductionOrders)
            {
                ProductionOrder productionOrder = (ProductionOrder)provider;
                State           state           = productionOrder.DetermineProductionOrderState();
                switch (state)
                {
                case State.Created:
                    HandleProductionOrderIsInStateCreated(productionOrder, aggregator,
                                                          dbTransactionData);
                    break;

                case State.InProgress:
                    HandleProductionOrderIsInProgress();
                    break;

                case State.Finished:
                    HandleProductionOrderIsFinished(productionOrder, aggregator,
                                                    dbTransactionData);
                    break;

                default: throw new MrpRunException("This state is not expected.");
                }
            }


            // Entferne alle Pfeile auf StockExchangeProvider zeigend
            // Entferne alle Pfeile von StockExchangeDemands weg zeigend
            //  --> übrig beleiben Pfeile zwischen StockExchangeProvider und StockExchangeDemands
            RemoveArrowsBelowStockExchangeDemandsAndAboveStockExchangeProviders(dbTransactionData,
                                                                                aggregator);

            /*
             *  foreach sed in beendeten und geschlossenen StockExchangeDemands
             *      Archiviere sed und seine parents (StockExchangeProvider)
             *        und die Pfeile dazwischen
             */
            ArchiveClosedStockExchangeDemandsAndItsParents(dbTransactionData, aggregator);

            // this can be the case of stockExchangeProvider had multiple child stockExchangeDemands
            ArchiveStockExchangeProvidersWithoutChilds(dbTransactionData, aggregator);

            ArchiveFinishedCustomerOrderPartsAndDeleteTheirArrows(dbTransactionData, aggregator);
            ArchiveFinishedPurchaseOrderPartsAndDeleteTheirArrows(dbTransactionData, aggregator);

            ArchivedCustomerOrdersWithoutCustomerOrderParts();
            ArchivedPurchaseOrdersWithoutPurchaseOrderParts();
        }
Beispiel #26
0
        // TODO: перенести в сервис заказов или удалить
        public decimal?CalculateSumInBaseCurrency(ProductionOrder productionOrder, decimal sumInCurrency)
        {
            Currency     currency;
            CurrencyRate currencyRate;

            GetCurrencyAndCurrencyRate(productionOrder, out currency, out currencyRate);

            return(CalculateSumInBaseCurrency(currency, currencyRate, sumInCurrency));
        }
Beispiel #27
0
        public async Task <bool> ProductionOrderEmailPush(ProductionOrder productionOrder)
        {
            bool sendsuccess = false;

            try
            {
                if (!string.IsNullOrEmpty(productionOrder.EmailSentTo))
                {
                    string[] BccList   = null;
                    string[] CcList    = null;
                    string[] EmailList = productionOrder.EmailSentTo.Split(',');
                    if (productionOrder.Cc != null)
                    {
                        CcList = productionOrder.Cc.Split(',');
                    }
                    if (productionOrder.Bcc != null)
                    {
                        BccList = productionOrder.Bcc.Split(',');
                    }
                    string      mailBody = File.ReadAllText(HttpContext.Current.Server.MapPath("~/Content/MailTemplate/DocumentEmailBody.html"));
                    MailMessage _mail    = new MailMessage();
                    PDFTools    pDFTools = new PDFTools();
                    string      link     = WebConfigurationManager.AppSettings["AppURL"] + "/Content/images/Pilot1.png";
                    _mail.Body               = mailBody.Replace("$Customer$", productionOrder.Customer.ContactPerson).Replace("$Document$", "Production Order").Replace("$DocumentNo$", productionOrder.ProdOrderNo).Replace("$DocumentDate$", productionOrder.ProdOrderDateFormatted).Replace("$Logo$", link);
                    pDFTools.Content         = productionOrder.MailContant;
                    pDFTools.ContentFileName = "ProductionOrder";
                    pDFTools.IsWithWaterMark = productionOrder.LatestApprovalStatus == 0 ? true : false;
                    _mail.Attachments.Add(new Attachment(new MemoryStream(_pDFGeneratorBusiness.GetPdfAttachment(pDFTools)), productionOrder.ProdOrderNo + ".pdf"));
                    _mail.Subject    = productionOrder.Subject;
                    _mail.IsBodyHtml = true;
                    foreach (string email in EmailList)
                    {
                        _mail.To.Add(email);
                    }
                    if (productionOrder.Cc != null)
                    {
                        foreach (string email in CcList)
                        {
                            _mail.CC.Add(email);
                        }
                    }
                    if (productionOrder.Bcc != null)
                    {
                        foreach (string email in BccList)
                        {
                            _mail.Bcc.Add(email);
                        }
                    }
                    sendsuccess = await _mailBusiness.MailMessageSendAsync(_mail);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(sendsuccess);
        }
Beispiel #28
0
        public async Task <IActionResult> PrintProductionOrder(string id)
        {
            ProductionOrder obj = await _context.ProductionOrder
                                  .Include(x => x.branch)
                                  .Include(x => x.ProductionOrderLine).ThenInclude(x => x.Product)
                                  .SingleOrDefaultAsync(x => x.ProductionOrderId.Equals(id));

            return(View(obj));
        }
Beispiel #29
0
        // GET: ProductionOrder/Create
        public IActionResult Create()
        {
            ProductionOrder po            = new ProductionOrder();
            Branch          defaultBranch = _context.Branch.Where(x => x.isDefaultBranch.Equals(true)).FirstOrDefault();

            ViewData["branchId"] = new SelectList(_context.Branch, "branchId", "branchName", defaultBranch != null ? defaultBranch.branchId : null);

            return(View(po));
        }
Beispiel #30
0
        /// <summary>
        /// Удаление заказа на производство из команды
        /// </summary>
        /// <param name="deal">Заказ на производство</param>
        public virtual void RemoveProductionOrder(ProductionOrder order)
        {
            if (!productionOrders.Any(x => x.Id == order.Id))
            {
                throw new Exception("Заказ на производство не входит в область видимости данной команды.");
            }

            productionOrders.Remove(order);
        }
        public static StationDto Create(Station s, ProductionOrder order = null, DvseMeter meter = null)
        {
            var dto = new StationDto()
            {
                ComPort = s.ComPort,
                ComParamStatus = s.ComParamStatus,
                ScanMatrixStatus = s.ScanMatrixStatus,
                ScanPcbStatus = s.ScanPcbStatus,
                OrderUniqueId = s.OrderUniqueId,
                Order = order,
                ConfigurationOptions = s.ConfigurationOptions,
                MeterNo = s.MeterNo,
                Meter = meter,
                Number = s.Number,
                ParameterInfoSetName = order != null ? order.ParameterInfoSetName : string.Empty
            };

            return dto;
        }
Beispiel #32
0
 public void placeOrder(ProductionOrder o)
 {
     activeOrders.Add(o);
 }
Beispiel #33
0
    void productionWindow(int windowID)
    {
        float margin = 15;
        int space = 10;
        float selectionAreaWidth = 7*Screen.width/12;
        float weaponInfoHeight = 2*(Screen.height-topMenuHeight)/3;
        float itemColWidth = 250;
        float producedColWidth = 100;
        float limitColWidth = 100;
        float buttonSize = 15;
        float itemHeight = 30;

        List<Weapon> weapons = manager.getAvailableWeapons();

        string[] names = new string[weapons.Count];
        for (int i = 0; i < weapons.Count; i++) {
            names[i] = weapons[i].getName();
        }

        GUIStyle centeredLabelStyle = new GUIStyle();
        centeredLabelStyle.normal = GUI.skin.label.normal;
        centeredLabelStyle.alignment = TextAnchor.MiddleCenter;
        centeredLabelStyle.margin = GUI.skin.label.margin;

        showTopMenu();

        #region Weapon Selection
        GUILayout.BeginArea(new Rect(margin
                                    ,topMenuHeight+margin
                                    ,selectionAreaWidth
                                    ,Screen.height-topMenuHeight-2*margin)
                            ,GUI.skin.box);

        GUILayout.BeginVertical ();

        // First row
        GUILayout.BeginHorizontal();
        GUILayout.Space(margin);
        GUILayout.Label("Item Name", centeredLabelStyle, GUILayout.Width(itemColWidth));
        GUILayout.Space(space);
        GUILayout.Label ("Produced", centeredLabelStyle, GUILayout.Width(producedColWidth));
        GUILayout.Space(space);
        GUILayout.Label ("Item Limit", centeredLabelStyle, GUILayout.Width(limitColWidth));
        GUILayout.EndHorizontal ();

        GUILayout.Space(margin);

        if (weapons != null && weapons.Count > 0)
        {
            // Scrollable section
            scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.ExpandHeight(true), GUILayout.Width (selectionAreaWidth));

            GUILayout.BeginHorizontal();
            GUILayout.Space(margin);
            // First column -- item name
            int previousItem = productionSelected;
            productionSelected = GUILayout.SelectionGrid(productionSelected, names, 1, GUILayout.Width (itemColWidth),
                                                        GUILayout.Height(weapons.Count*(space+itemHeight)));
            if (previousItem != productionSelected)
            {
                // On change, instantiate new order
                order = new ProductionOrder(weapons[productionSelected]);
                if (currentBase.orderInProgress(order.getWeapon()))
                    productionMessage = "Order in progress";
                else
                    productionMessage = "";
            }
            GUILayout.Space(space);

            // Next two columns -- Produced, Production Limit
            GUILayout.BeginVertical();
            // Changing the alignment -- workaround
            TextAnchor oldLabel = GUI.skin.label.alignment;
            GUI.skin.label.alignment = TextAnchor.MiddleCenter;
            foreach (Weapon w in weapons) {
                GUILayout.BeginHorizontal(GUILayout.Height(itemHeight));
                //Produced
                GUILayout.Label ("" + currentBase.getAmountManufactured(w), GUILayout.Width (producedColWidth));
                GUILayout.Space(space);
                // Limit
                GUILayout.Label ("" + w.getProductionLimit(), GUILayout.Width(limitColWidth));
                GUILayout.Space(space);
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
                GUILayout.Space(space);
            }
            //GUI.skin.button.alignment = oldButton;
            GUI.skin.label.alignment = oldLabel;
            GUILayout.EndVertical();
            GUILayout.Space(margin);
            GUILayout.EndHorizontal();
            GUILayout.EndScrollView();
        }
        else
        {
            GUILayout.Label ("No Items available for production!\nResearch some first.", centeredLabelStyle);
        }
        GUILayout.EndVertical();

        GUILayout.EndArea();
        #endregion

        #region Workshop Info
        GUILayout.BeginArea(new Rect(selectionAreaWidth+2*margin
                                    ,topMenuHeight+margin
                                    ,Screen.width-selectionAreaWidth-3*margin
                                    ,Screen.height-weaponInfoHeight-topMenuHeight-3*margin)
                            ,GUI.skin.box);
        GUILayout.BeginVertical();
        GUILayout.Space(margin);

        GUILayout.BeginHorizontal();
        GUILayout.Space(margin);
        GUILayout.Label ("Workers\n(Ready/all)", centeredLabelStyle, GUILayout.ExpandHeight (true), GUILayout.Width(itemColWidth));
        GUILayout.Label ((currentBase.getNumbWorkers()-currentBase.getOccupiedWorkers())
                            + "/" + currentBase.getNumbWorkers(), centeredLabelStyle, GUILayout.ExpandHeight (true));
        GUILayout.Space(margin);
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Space(margin);
        GUILayout.Label ("Workshop Capacity\n(Used/total)", centeredLabelStyle, GUILayout.ExpandHeight (true), GUILayout.Width(itemColWidth));
        GUILayout.Label (currentBase.getOccupiedWorkers() + "/" + currentBase.getTotalWorkshopSpace(), centeredLabelStyle, GUILayout.ExpandHeight (true));
        GUILayout.Space(margin);
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Space(margin);
        GUILayout.Label ("Storage Capacity\n(Used/total)", centeredLabelStyle, GUILayout.ExpandHeight (true), GUILayout.Width(itemColWidth));
        GUILayout.Label (currentBase.getUsedStorage() + "/" + currentBase.getTotalStorageSpace(), centeredLabelStyle, GUILayout.ExpandHeight (true));
        GUILayout.Space(margin);
        GUILayout.EndHorizontal();

        GUILayout.Space(margin);
        GUILayout.EndVertical();
        GUILayout.EndArea();
        #endregion

        #region Weapon Info
        GUILayout.BeginArea(new Rect(selectionAreaWidth+2*margin
                                    ,Screen.height-margin-weaponInfoHeight
                                    ,Screen.width-selectionAreaWidth-3*margin
                                    ,weaponInfoHeight)
                            ,GUI.skin.box);
        GUILayout.BeginHorizontal();
        GUILayout.Space(margin);
        if (weapons != null && weapons.Count > 0)
        {
            GUILayout.BeginVertical();
            GUILayout.Space(margin);
            GUILayout.Label(names[productionSelected], centeredLabelStyle, GUILayout.ExpandHeight(true));
            GUILayout.Space(space);
            if (!showWeaponInfo)
            {
                GUILayout.Label ("Production Days: " + weapons[productionSelected].getProductionTime()/24, centeredLabelStyle, GUILayout.ExpandHeight(true));
                GUILayout.Space(space);

                //Choose Quantity
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUILayout.Label ("Quantity: " + order.getQuantity(), centeredLabelStyle, GUILayout.Height(2*buttonSize));
                GUILayout.Space(space);
                GUILayout.BeginVertical();
                // Buttons
                if (GUILayout.Button ("", increaseSkin.button, GUILayout.Width (buttonSize), GUILayout.Height (buttonSize)))
                {
                    order.increaseQuantity();
                }
                if (GUILayout.Button ("", decreaseSkin.button, GUILayout.Width (buttonSize), GUILayout.Height (buttonSize)))
                {
                    order.decreaseQuantity();
                }
                GUILayout.EndVertical();
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();

                GUILayout.Space(margin);

                // Choose workers
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUILayout.Label ("Workers: " + order.getWorkers(), centeredLabelStyle, GUILayout.Height(2*buttonSize));
                GUILayout.Space(space);
                GUILayout.BeginVertical();
                // Buttons
                if (GUILayout.Button ("", increaseSkin.button, GUILayout.Width (buttonSize), GUILayout.Height (buttonSize)))
                {
                    if (order.getWorkers() < currentBase.getNumbWorkers() - currentBase.getOccupiedWorkers())
                        order.increaseWorkers();
                }
                if (GUILayout.Button ("", decreaseSkin.button, GUILayout.Width (buttonSize), GUILayout.Height (buttonSize)))
                {
                    order.decreaseWorkers();
                }
                GUILayout.EndVertical();
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();

                GUILayout.Space(margin);

                if (GUILayout.Button("Place Order"))
                {
                    // Check weapon isn't already in an order
                    if (currentBase.orderInProgress(order.getWeapon()))
                    {
                        productionMessage = "Error: Order is already in progress";
                    }
                    // Check quantity/workers > 0
                    else if (order.getQuantity() <= 0 || order.getWorkers() <= 0)
                    {
                        productionMessage = "Error: Must assign quantity and workers";
                    }
                    // Check production limit
                    else if (currentBase.getAmountManufactured(order.getWeapon()) + order.getQuantity() > order.getWeapon().getProductionLimit())
                    {
                        productionMessage = "Error: exceeds item's production limit";
                    }
                    // Check that there are enough free workers
                    else if (currentBase.getNumbWorkers() - currentBase.getOccupiedWorkers() < order.getWorkers())
                    {
                        productionMessage = "Error: not enough free workers to process request";
                    }
                    // Check that there is enough workshop space
                    else if (order.getWorkers() > currentBase.getTotalWorkshopSpace() - currentBase.getOccupiedWorkers())
                    {
                        productionMessage = "Error: not enough workshop space";
                    }
                    else
                    {
                        order.placeOrder();

                        productionMessage = "Order placed!\nDays until completion: " + (double)(order.getTimeRemaining()/order.getWorkers())/24.0;

                        // Occupy workers
                        for (int i = 0; i < order.getWorkers(); i++)
                            currentBase.occupyWorker();

                        // Add to list of active orders
                        currentBase.placeOrder(order);

                        order = new ProductionOrder(weapons[productionSelected]);
                    }
                }

                GUILayout.Space(margin);

                if (GUILayout.Button("Additional Info"))
                {
                    showWeaponInfo = true;
                }

                GUILayout.Space(margin);

                GUILayout.Label (productionMessage, centeredLabelStyle);
            }
            else
            {
                space = 7;
                Weapon w = order.getWeapon();
                // Show weapon details
                GUILayout.Label (w.getImage (), centeredLabelStyle, GUILayout.Height (weaponInfoHeight/4));
                GUILayout.Space(space);
                GUILayout.Label ("Storage: " + w.getStorageSpace()
                                ,centeredLabelStyle, GUILayout.ExpandHeight(true));
                GUILayout.Space(space);
                GUILayout.Label ("Cost: " + w.getCost(), centeredLabelStyle, GUILayout.ExpandHeight(true));
                GUILayout.Space(space);

                if (w.isArmourType())
                {
                    GUILayout.Label ("Protection: " + w.getProtection()*100 + "%", centeredLabelStyle, GUILayout.ExpandHeight(true));
                }
                else
                {
                    GUILayout.Label ("Damage: " + w.getDamage(), centeredLabelStyle, GUILayout.ExpandHeight(true));
                    GUILayout.Space(space);
                    GUILayout.Label ("Range: " + w.getRange(), centeredLabelStyle, GUILayout.ExpandHeight(true));
                    GUILayout.Space(space);
                    GUILayout.Label ("Max Ammo: " + w.getMaxAmmo(), centeredLabelStyle, GUILayout.ExpandHeight(true));
                    GUILayout.Space(space);
                    GUILayout.Label ("Action Points: " + w.getActionPoints(), centeredLabelStyle, GUILayout.ExpandHeight(true));
                    //TODO -- accuracy = (angle/10)*100?
                }

                if (GUILayout.Button("Back"))
                {
                    showWeaponInfo = false;
                }
            }

            GUILayout.Space(margin);
            GUILayout.EndVertical();

        }
        else
        {
            GUILayout.Label ("No Weapons Available", centeredLabelStyle, GUILayout.ExpandHeight(true));
        }
        GUILayout.Space(margin);
        GUILayout.EndHorizontal();
        GUILayout.EndArea();
        #endregion
    }
Beispiel #34
0
    // Use this for initialization
    void Start()
    {
        manager = gameManager.Instance;

        // THIS SECTION IS FOR TESTING PURPOSES
        /*
        if (!manager.baseExist("Base 1")) {
            manager.startState();
            manager.addBase("Base 1");
            manager.addBase("Base 2");
            manager.addBase("Base 3");
            manager.createInitialBase ();
            DontDestroyOnLoad(manager);
        }
        */
        //END OF SECTION

        currentBase = manager.getCurrentBase();
        menuShown = BASE_MAIN;

        order = new ProductionOrder(manager.getAvailableWeapons()[0]);

        destBase = manager.getBaseAfter(currentBase);
    }
Beispiel #35
0
 public void removeOrder(ProductionOrder order)
 {
     activeOrders.Remove(order);
 }