Ejemplo n.º 1
0
    public override void OnCompleteProductionImmediately()
    {
        foreach (var productionItem in ProductionItems)
        {
            DataCenter.Instance.AddSkill(new SkillVO()
            {
                cid = productionItem.cid, amount = productionItem.count
            });
        }
        ProductionItems.Clear();
        int diamond = GameDataAlgorithm.TimeToGem(TotalTimeLeft);

        EndTime = System.DateTime.MinValue;
        new ProductionRequestCommand(ProductionReq.ProductionRequestType.CompleteImmediately, Entity.buildingVO, null, diamond).ExecuteAndSend();
    }
Ejemplo n.º 2
0
    /// <summary>
    /// 添加入生产队列
    /// </summary>
    /// <param name="productionItem"></param>
    private void AddToQueue(ProductionItemVO productionItem)
    {
        var model = DataCenter.Instance.FindEntityModelById(productionItem.cid);

        CurrentQueueSize += GetProductionUseQueueSize(model) * productionItem.count;
        totalTime        += GetProductionTime(model) * productionItem.count;
        for (int i = 0; i < ProductionItems.Count; i++)
        {
            if (ProductionItems[i].cid == productionItem.cid)
            {
                ProductionItems[i].count += productionItem.count;
                return;
            }
        }
        ProductionItems.Add(productionItem);
    }
Ejemplo n.º 3
0
    /// <summary>
    /// 从队列中移除
    /// </summary>
    /// <param name="productionItem"></param>
    private void RemoveFromQueue(ProductionItemVO productionItem)
    {
        var model = DataCenter.Instance.FindEntityModelById(productionItem.cid);

        CurrentQueueSize -= GetProductionUseQueueSize(model) * productionItem.count;
        totalTime        -= GetProductionTime(model) * productionItem.count;

        for (int i = 0; i < ProductionItems.Count; i++)
        {
            if (ProductionItems[i].cid == productionItem.cid)
            {
                ProductionItems[i].count -= productionItem.count;
                if (ProductionItems[i].count <= 0)
                {
                    ProductionItems.RemoveAt(i);
                }
                return;
            }
        }
        Assert.Fail("Should not reach here");
    }
Ejemplo n.º 4
0
    public override void OnCompleteProductionImmediately()
    {
        DataCenter.Instance.SpaceUsed += CurrentQueueSize;
        var newViewActors = new List <ArmyVO>();

        foreach (var productionItem in ProductionItems)
        {
            var army = new ArmyVO()
            {
                amount = productionItem.count, cid = productionItem.cid
            };
            DataCenter.Instance.AddArmy(army);
            newViewActors.Add(army);
        }
        ProductionItems.Clear();
        int diamond = GameDataAlgorithm.TimeToGem(TotalTimeLeft);

        EndTime = System.DateTime.MinValue;
        CoroutineHelper.Run(CreateViewActors(newViewActors));
        new ProductionRequestCommand(ProductionReq.ProductionRequestType.CompleteImmediately, Entity.buildingVO, null, diamond).ExecuteAndSend();
    }
Ejemplo n.º 5
0
 public bool TryDoCommand(Players.Player player, string chat, List <string> splits)
 {
     if (player.Equals(null))
     {
         return(false);
     }
     chat.ToLower();
     if (chat.StartsWith("/production"))
     {
         string typeName = ItemTypes.GetType(player.Inventory.Items[0].Type).Name;
         chat = chat.Remove(0, 12);
         if (!ProductionItems.ContainsKey(player.ActiveColony.ColonyID))
         {
             ProductionItems[player.ActiveColony.ColonyID] = new Dictionary <string, int[]>();
         }
         if (chat.StartsWith("add"))
         {
             if (!ProductionItems[player.ActiveColony.ColonyID].ContainsKey(typeName))
             {
                 ProductionItems[player.ActiveColony.ColonyID][typeName] = new int[10];
                 Chat.Send(player, "<color=yellow>Added " + typeName + " to production chain will take 5 ingame days to see all data</color>");
                 return(true);
             }
             Chat.Send(player, "<color=yellow>" + typeName + " is already being recorded</color>");
             return(true);
         }
         else if (chat.StartsWith("remove"))
         {
             if (ProductionItems[player.ActiveColony.ColonyID].ContainsKey(typeName))
             {
                 ProductionItems[player.ActiveColony.ColonyID].Remove(typeName);
                 Chat.Send(player, "<color=yellow>" + typeName + " has been removed</color>");
                 return(true);
             }
             Chat.Send(player, "<color=yellow>" + typeName + " was not being recorded, could not remove</color>");
             return(true);
         }
     }
     return(false);
 }
        private List <ProductionItems> ListProductionItems(DataTable dta)

        {
            List <ProductionItems> list = new List <ProductionItems>();

            listSummary = new List <ProductionSummary>();
            for (int i = 0; i < dta.Rows.Count; i++)
            {
                object item9  = dta.Rows[i][9];  //Create_date
                object item10 = dta.Rows[i][10]; //Create_date
                object item6  = dta.Rows[i][6];  //Create_date
                object item11 = dta.Rows[i][11]; //Create_date
                object item12 = dta.Rows[i][12]; //Create_date

                ProductionItems items = new ProductionItems();
                items.Date            = (DateTime)item9;
                items.Time            = (TimeSpan)item10;
                items.Dept            = (string)dta.Rows[i][14];
                items.ProductionCode  = (string)dta.Rows[i][4];
                items.ActualOutput    = double.Parse(dta.Rows[i][11].ToString());
                items.ActualDefectQty = double.Parse(dta.Rows[i][12].ToString());
                double[] target = new double[2];
                if (rd_Monthly.Checked)
                {
                    target = GetTargetfromDatabase("Monthly", items.ProductionCode, new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1));
                }
                else if (rd_daily.Checked)
                {
                    target = GetTargetfromDatabase("Daily", items.ProductionCode, DateTime.Now.Date);
                }
                if (target[0] == 0 && target[1] == 0)
                {
                    target[0] = 1000; target[1] = 0.3;
                }
                items.OutputTarget    = target[0];
                items.ScrapTargetRate = target[1];
                list.Add(items);
            }

            var groupedListItems = list
                                   .GroupBy(u => u.ProductionCode)
                                   .Select(grp => grp.ToList())
                                   .ToList();

            foreach (var item in groupedListItems)
            {
                ProductionSummary production = new ProductionSummary();
                var SumOutput = item.Sum(a => a.ActualOutput);
                var SumScrap  = item.Sum(a => a.ActualDefectQty);

                production.Dept            = item[0].Dept;
                production.ProductionCode  = item[0].ProductionCode;
                production.OutputTarget    = item[0].OutputTarget;
                production.ScrapTargetRate = item[0].ScrapTargetRate;

                production.ActualOutput     = SumOutput;
                production.ActualDefectQty  = SumScrap;
                production.ScrapActualtRate = Math.Round(SumScrap / (SumOutput + SumScrap), 2);

                if (production.ActualOutput >= production.OutputTarget)
                {
                    production.QuantityEvaluation = "Good";
                }
                else if (production.ActualOutput < production.OutputTarget)
                {
                    production.QuantityEvaluation = "Not Good";
                }
                if (production.ScrapActualtRate < production.ScrapTargetRate)
                {
                    production.QualityEvaluation = "Good";
                }
                else if (production.ScrapActualtRate >= production.ScrapTargetRate)
                {
                    production.QualityEvaluation = "Not Good";
                }
                listSummary.Add(production);
            }


            return(list);
        }
        private void Dgv_show_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dgv_show.RowCount == 0)
            {
                return;
            }
            int    i         = e.RowIndex;
            int    j         = e.ColumnIndex;
            string OrderCode = dgv_show.Rows[i].Cells["ProductionCode"].Value.ToString();

            dtDisplay = new DataTable();
            if (dgv_show.Rows[i].Cells["ProductionCode"].Selected)
            {
                var dr = ListproductionItems.Where(d => d.ProductionCode == OrderCode).ToList();
                if (rd_Monthly.Checked)
                {
                    var groupedListItems = dr
                                           .GroupBy(u => u.Date)
                                           .Select(grp => grp.ToList())
                                           .ToList();
                    listSort = new List <ProductionItems>();
                    foreach (var item in groupedListItems)
                    {
                        ProductionItems production = new ProductionItems();
                        var             SumOutput  = item.Sum(a => a.ActualOutput);
                        var             SumScrap   = item.Sum(a => a.ActualDefectQty);
                        production.Date             = item[0].Date;
                        production.Dept             = item[0].Dept;
                        production.OutputTarget     = item[0].OutputTarget;
                        production.ScrapTargetRate  = item[0].ScrapTargetRate;
                        production.ProductionCode   = item[0].ProductionCode;
                        production.ActualOutput     = SumOutput;
                        production.ActualDefectQty  = SumScrap;
                        production.ScrapActualtRate = Math.Round(SumScrap / (SumOutput + SumScrap), 2);

                        listSort.Add(production);
                    }
                    dtDisplay = ConvertToDataTable(listSort);
                    double[] target = new double[2];
                    target[0] = (double)listSort[0].OutputTarget;
                    target[1] = (double)listSort[0].ScrapTargetRate;
                    CrisisReport.DiplayChartDatagrid display = new CrisisReport.DiplayChartDatagrid(dtDisplay, "Monthly", target);

                    display.ShowDialog();
                }
                if (rd_daily.Checked)
                {
                    var groupedListItems = dr
                                           .GroupBy(u => u.Time)
                                           .Select(grp => grp.ToList())
                                           .ToList();
                    listSort = new List <ProductionItems>();
                    foreach (var item in groupedListItems)
                    {
                        ProductionItems production = new ProductionItems();
                        var             SumOutput  = item.Sum(a => a.ActualOutput);
                        var             SumScrap   = item.Sum(a => a.ActualDefectQty);
                        production.Date             = item[0].Date;
                        production.Dept             = item[0].Dept;
                        production.Time             = item[0].Time;
                        production.OutputTarget     = item[0].OutputTarget;
                        production.ScrapTargetRate  = item[0].ScrapTargetRate;
                        production.ProductionCode   = item[0].ProductionCode;
                        production.ActualOutput     = SumOutput;
                        production.ActualDefectQty  = SumScrap;
                        production.ScrapActualtRate = Math.Round(SumScrap / (SumOutput + SumScrap), 1);

                        listSort.Add(production);
                    }

                    dtDisplay = ConvertToDataTable(listSort);

                    double[] target = new double[2];
                    target[0] = (double)listSort[0].OutputTarget;
                    target[1] = (double)listSort[0].ScrapTargetRate;
                    CrisisReport.DiplayChartDatagrid display = new CrisisReport.DiplayChartDatagrid(dtDisplay, "Daily", target);

                    display.ShowDialog();
                }
            }
        }