示例#1
0
        public ViewResult Detail(DNRUplandRegionPrimaryKey dnrUplandRegionPrimaryKey)
        {
            var region   = dnrUplandRegionPrimaryKey.EntityObject;
            var mapDivID = $"region_{region.DNRUplandRegionID}_Map";

            var associatedProjects = region.GetAssociatedProjects(CurrentPerson);
            var layers             = DNRUplandRegion.GetRegionAndAssociatedProjectLayers(region, associatedProjects);
            var mapInitJson        = new MapInitJson(mapDivID, 10, layers, new BoundingBox(region.DNRUplandRegionLocation));

            var grantAllocationExpenditures = new List <GrantAllocationExpenditure>();

            region.GrantAllocations.ForEach(x => grantAllocationExpenditures.AddRange(x.GrantAllocationExpenditures));
            var costTypes = CostType.GetLineItemCostTypes();

            const string chartTitle       = "Grant Allocation Expenditures By Cost Type";
            var          chartContainerID = chartTitle.Replace(" ", "");
            var          googleChart      = grantAllocationExpenditures.ToGoogleChart(x => x.CostType?.CostTypeDisplayName,
                                                                                      costTypes.Select(ct => ct.CostTypeDisplayName).ToList(),
                                                                                      x => x.CostType?.CostTypeDisplayName,
                                                                                      chartContainerID,
                                                                                      chartTitle);

            var viewGoogleChartViewData = new ViewGoogleChartViewData(googleChart, chartTitle, 405, true);

            var performanceMeasures = associatedProjects
                                      .SelectMany(x => x.PerformanceMeasureActuals)
                                      .Select(x => x.PerformanceMeasure).Distinct()
                                      .OrderBy(x => x.PerformanceMeasureDisplayName)
                                      .ToList();

            var viewData = new DetailViewData(CurrentPerson, region, mapInitJson, viewGoogleChartViewData, performanceMeasures);

            return(RazorView <Detail, DetailViewData>(viewData));
        }
示例#2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Defenition")] CostType costType)
        {
            if (id != costType.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(costType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CostTypeExists(costType.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(costType));
        }
示例#3
0
        public ActionResult EditCostType([FromBody] CostType[] costTypes)
        {
            if (_context.CostType.Where(c => c.Defenition == costTypes[0].Defenition).Count() > 0)
            {
                return(Json("Bu məxaric növü mövcuddur"));
            }
            string result = "Sistem xətası";

            try
            {
                CostType costType = new CostType();
                costType.Id         = costTypes[0].Id;
                costType.Defenition = costTypes[0].Defenition;

                _context.Update(costType);
                _context.SaveChanges();
                result = "Əməliyyat uğurla tamamlandı!";
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }


            return(Json(result));
        }
示例#4
0
    /// <summary>
    /// 播放特效
    /// </summary>
    /// <param name="type"></param>
    /// <param name="tt"></param>
    /// <param name="count"></param>
    /// <param name="_type"></param>
    public void ShowLottryAnimaEffect(PosType type, LotteryType tt, int count, CostType _type)
    {
        switch (type)
        {
        case PosType.Lorry:
            ty         = type;
            typ        = tt;
            this.count = count;
            t          = _type;
            if (!Chouxiangzi.gameObject.activeInHierarchy)
            {
                Chouxiangzi.gameObject.SetActive(true);
            }
            UI_KaiBaoXiang_01.gameObject.SetActive(true); break;

        case PosType.heroEffect:
            if (!Chouxiangzi.gameObject.activeInHierarchy)
            {
                Chouxiangzi.gameObject.SetActive(true);
            }
            UI_KaiBaoXiang_Hero_01.gameObject.SetActive(true);
            break;
        }
        this.type = AnimType.None;
    }
示例#5
0
        public JsonResult SaveDataInDatabase(CostType model)
        {
            var result = false;

            try
            {
                if (model.Id > 0)
                {
                    _context.Update(model);
                    _context.SaveChanges();
                    result = true;
                }
                else
                {
                    _context.Add(model);
                    _context.SaveChanges();
                    result = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(Json(result));
        }
        /// <summary>
        /// Increments a specified cost by the specified amount.
        /// </summary>
        /// <param name="type"> The type of cost being incremented.</param>
        /// <param name="amount">The amount the cost is beinf incremented by.</param>
        /// <exception cref="System.ComponentModel.InvalidEnumArgumentException">When the cost type is an invalid argument.</exception>
        /// <exception cref="ArgumentOutOfRangeException">When the amount is less than or equal to 0. </exception>
        public void AddCost(CostType type, decimal amount)
        {
            if (!Enum.IsDefined(typeof(CostType), type))
            {
                throw new System.ComponentModel.InvalidEnumArgumentException("The value is an invalid enumeration value.");
            }
            ;

            if (amount <= 0)
            {
                throw new ArgumentOutOfRangeException("amount", "The argument cannot be less than or equal to 0.");
            }

            switch (type)
            {
            case CostType.Labour:
            {
                LabourCost += amount;
                break;
            }

            case CostType.Material:
            {
                MaterialCost += amount;
                break;
            }

            case CostType.Part:
            {
                PartsCost += amount;
                break;
            }
            }
        }
示例#7
0
 private void RemoveCost(IBosServiceCollection services, CostType type, double cost)
 {
     if (currencyRemovers.ContainsKey(type))
     {
         currencyRemovers[type](services, cost);
     }
 }
示例#8
0
 public BudgetVsActualLineItem(CostType costType, Money budget, Money expendituresFromDatamart, Money invoicedToDate)
 {
     CostType = costType;
     Budget   = budget;
     ExpendituresFromDatamart = expendituresFromDatamart;
     InvoicedToDate           = invoicedToDate;
 }
示例#9
0
        public static Interaction GetInteraction(decimal amount, decimal fee)
        {
            string parm1             = amount.ToString("0.00000000").Split('.')[1];
            int    costTypeInt       = int.Parse(parm1.Substring(0, 2));
            int    interactionTypInt = int.Parse(parm1.Substring(2, 2));

            if (Enum.IsDefined(typeof(CostType), costTypeInt) &&
                Enum.IsDefined(typeof(InteractionType), interactionTypInt))
            {
                CostType        costType        = (CostType)costTypeInt;
                InteractionType interactionType = (InteractionType)interactionTypInt;
                int             addParam1       = int.Parse(parm1.Substring(4, 4));
                int             addParam2       = int.Parse(fee.ToString("0.00000000").Split('.')[1].Substring(4, 4));

                switch (interactionType)
                {
                case InteractionType.ADVENTURE:
                    if (AdventureAction.TryGetAdventure(addParam1, addParam2, out AdventureAction adventure))
                    {
                        return(adventure);
                    }
                    break;

                case InteractionType.LEVELING:
                    if (LevelingAction.TryGetAdventure(addParam1, addParam2, out LevelingAction leveling))
                    {
                        return(leveling);
                    }
                    break;
                }
            }

            return(new Unknown());
        }
示例#10
0
    public static double getCost(CostType costType, double cardPoints)
    {
        double blueCardEffect = System.Math.Round(cardPoints / (requiredPointsForExtraCardLast(cardPoints) * 0.75f));

        int blueCardExponent = 0;

        switch (costType)
        {
        case CostType.NONE:
            return(0);

        case CostType.LOW:
            blueCardExponent = 2;
            break;

        case CostType.MEDIUM:
            blueCardExponent = 3;
            break;

        case CostType.HIGH:
            blueCardExponent = 5;
            break;

        case CostType.ABSURD:
            blueCardExponent = 7;
            break;
        }
        double cardPointsPower = System.Math.Pow(blueCardEffect, blueCardExponent);
        int    exponent        = (int)System.Math.Floor(System.Math.Log10(cardPointsPower));

        return(System.Math.Pow(10, exponent));
    }
        /// <summary>
        /// Increments a specified cost by the specified amount.
        /// </summary>
        /// <param name="type">The type of cost being incremented.</param>
        /// <param name="amount">The amount the cost is being incremented by.</param>
        /// <exception cref="InvalidEnumArgumentException">Throw when the cost type is an invalid argument.</exception>
        /// <exception cref="ArgumentOutOfRangeException">Throw when the amount is less than or equal to 0.</exception>
        public void AddCost(CostType type, decimal amount)
        {
            if (!Enum.IsDefined(typeof(CostType), type))
            {
                throw new InvalidEnumArgumentException("The argument is an invalid enumeration value.");
            }
            else if (amount <= 0)
            {
                throw new ArgumentOutOfRangeException("amount", "The argument cannot be less than or equal to 0.");
            }
            else
            {
                switch (type)
                {
                case CostType.Labour:
                    LabourCost += amount;
                    break;

                case CostType.Material:
                    MaterialCost += amount;
                    break;

                case CostType.Part:
                    PartsCost += amount;
                    break;
                }
            }
        }
示例#12
0
    public static Card generateRandomCardImprove(double cardPoints)
    {
        CostType costType = getRandomCostType(cardPoints);
        double   cost     = getCost(costType, cardPoints);

        return(generateRandomCardImprove(cardPoints, costType, cost));
    }
示例#13
0
        public void SetCostEntry(ProjectType projectType, CostType costTye, int month, string costValue)
        {
            var cost = 0L;

            long.TryParse(costValue, out cost);
            this.SetCostEntry(projectType, costTye, month, cost);
        }
示例#14
0
        public async Task <IActionResult> Post([FromBody] CostType newCostType)
        {
            if (newCostType == null)
            {
                return(BadRequest());
            }

            if (FindCostTypesByName(newCostType.Name).Any())
            {
                return(Conflict());
            }

            await _dataContext.CostTypes.AddAsync(newCostType);

            try
            {
                await _dataContext.SaveChangesAsync();

                return(Ok());
            }
            catch (DbUpdateException)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
            catch (DBConcurrencyException)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
示例#15
0
        /// <summary>
        /// Increments a specified cosst by the specified amount.
        /// </summary>
        /// <param name="costType">
        /// The type of cost being incremented.
        /// </param>
        /// <param name="amount">
        /// The amount the cost is bein incremented by.
        /// </param>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// Thrown when the amount is less than 0.
        /// </exception>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// Thrown when the amount is equal to 0.
        /// </exception>
        public void AddCost(CostType costType, decimal amount)
        {
            if (amount < 0)
            {
                throw new ArgumentOutOfRangeException("amount",
                                                      "Argument cannot be less than 0.");
            }

            if (amount == 0)
            {
                throw new ArgumentOutOfRangeException("amount",
                                                      "Argument cannot be equal to 0.");
            }

            switch (costType)
            {
            case CostType.Labour:
                LabourCost += amount;
                break;

            case CostType.Material:
                MaterialCost += amount;
                break;

            case CostType.Part:
                PartCost += amount;
                break;
            }
            OnCostAdded();
        }
        /// <summary>
        /// Khi ấn nút Save, lưu Service nếu đang edit, insert nếu đang thêm mới
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            ActiveCost.Name         = txtServiceName.Text;
            ActiveCost.GroupName    = txtGroupName.Text;
            ActiveCost.IsDailyInput = chkIsDailyInput.Checked;
            ActiveCost.IsCustomType = chkIsCustomType.Checked;
            ActiveCost.IsSupplier   = chkIsSupplier.Checked;
            ActiveCost.IsMonthly    = chkIsMonthly.Checked;
            ActiveCost.IsDaily      = chkIsDaily.Checked;
            ActiveCost.IsYearly     = chkIsYearly.Checked;
            if (ddlSuppliers.SelectedIndex > 0)
            {
                ActiveCost.DefaultAgency = Module.AgencyGetById(Convert.ToInt32(ddlSuppliers.SelectedValue));
            }
            else
            {
                ActiveCost.DefaultAgency = null;
            }

            if (ddlServices.SelectedIndex > 0)
            {
                ActiveCost.Service = Module.ExtraOptionGetById(Convert.ToInt32(ddlServices.SelectedValue));
            }
            else
            {
                ActiveCost.Service = null;
            }

            // Kiểm tra trong View State
            Module.SaveOrUpdate(ActiveCost);
            ActiveCost             = ActiveCost;
            labelFormTitle.Text    = ActiveCost.Name;
            rptServices.DataSource = Module.CostTypeGetAll();
            rptServices.DataBind();
        }
示例#17
0
        protected IStageDetails BuildStageDetails(string contentType, string region, CostType costType, string productionType, bool?isUsage = null)
        {
            var result = new StageDetails
            {
                Data = new Dictionary <string, dynamic>()
            };

            result.Data.Add("budgetRegion", new AbstractTypeValue {
                Key = region
            });
            result.Data.Add("contentType", JObject.Parse("{\"id\":\"b4a1bb22-90ab-4e37-82bd-494e512827da\",\"value\":\"" + contentType + "\",\"key\":\"" + contentType + "\"}"));
            if (costType == CostType.Production)
            {
                result.Data.Add("productionType",
                                JObject.Parse("{\"id\":\"b4a1bb22-90ab-4e37-82bd-494e512827dd\",\"value\":\"" + productionType + "\",\"key\":\"" + productionType + "\"}"));
            }

            result.Data.Add("costType", costType);
            if (isUsage.HasValue)
            {
                result.Data.Add("isUsage", isUsage.Value);
                result.Data.Add("usageBuyoutType", new DictionaryValue {
                    Key = contentType
                });
            }
            return(result);
        }
        public void Load_Templates_MiscCost()
        {
            //Arrange
            Guid     expectedGuid     = new Guid("5df99701-1d7b-4fbe-843d-40793f4145a8");
            string   expectedName     = "Bid Misc";
            double   expectedCost     = 1298;
            double   expectedLabor    = 8921;
            double   expectedQuantity = 2;
            CostType expectedType     = CostType.Electrical;
            TECMisc  actualMisc       = null;

            foreach (TECMisc misc in actualTemplates.Templates.MiscCostTemplates)
            {
                if (misc.Guid == expectedGuid)
                {
                    actualMisc = misc;
                    break;
                }
            }

            //Assert
            Assert.AreEqual(expectedName, actualMisc.Name);
            Assert.AreEqual(expectedQuantity, actualMisc.Quantity);
            Assert.AreEqual(expectedCost, actualMisc.Cost);
            Assert.AreEqual(expectedLabor, actualMisc.Labor);
            Assert.AreEqual(expectedType, actualMisc.Type);
        }
示例#19
0
    public SkillBase Init(string itemName, Sprite skillIcon, SkillBaseConfig config)
    {
        SkillName = itemName;
        Icon      = skillIcon;

        CostType = CostType.ActionPoint;

        Cost           = config.Cost;
        Cooldown       = config.Cooldown;
        UsePerTurn     = config.UsePerTurn;
        CriticalChance = config.CriticalChance;
        SkillEffects   = config.SkillEffects;

        //if (config.SkillEffects != null) {
        //    SkillEffects = new List<SkillEffect>();
        //    for (int i = 0; i < config.SkillEffects.Count; i++)
        //        SkillEffects.Add(Damage.Create(config.SkillEffects[i]));
        //}

        RangeType        = config.RangeType;
        MinRange         = config.MinRange;
        MaxRange         = config.MaxRange;
        NeedLineOfSight  = config.NeedLineOfSight;
        NeedPathToTarget = config.NeedPathToTarget;
        AreaOfEffect     = config.AreaOfEffect;
        Animations       = config.Animations;

        return(this);
    }
        public async Task GetPurchaseOrder_whenCostSubmittedAndNonProductionCostType_LongText_mapping()
        {
            // Arrange
            var costSubmitted          = GetCostRevisionStatusChanged(CostStageRevisionStatus.PendingBrandApproval);
            var costId                 = costSubmitted.AggregateId;
            const CostStages costStage = CostStages.FirstPresentation;
            const CostType   costType  = CostType.Buyout;

            const string expectedVNLine1 = "Purchase order does not authorize committing funds without approved EPCAT sheet.";
            const string expectedVNLine2 = "The services within this Purchase Order can only be ordered from 3rd parties after EPCAT approval.";
            var          expectedBN      = $"{costStage} APPROVED {costType}";
            var          expectedAN      = $"{FrontEndUrl.TrimEnd('/')}/#/cost/{costId}/review";

            SetupPurchaseOrderView(costId,
                                   costStage: costStage,
                                   costType: costType
                                   );

            // Act
            var purchase = await PgPurchaseOrderService.GetPurchaseOrder(costSubmitted);

            // Assert
            purchase.LongText.Should().NotBeNull();
            purchase.LongText.VN.Should().Contain(expectedVNLine1);
            purchase.LongText.VN.Should().Contain(expectedVNLine2);
            purchase.LongText.BN.Should().Contain(expectedBN);
            purchase.LongText.AN.Should().Contain(expectedAN);
        }
        public void Load_Templates_SystemMiscCost()
        {
            //Arrange
            Guid     expectedGuid     = new Guid("e3ecee54-1f90-415a-b493-90a78f618476");
            string   expectedName     = "System Misc";
            double   expectedCost     = 1492;
            double   expectedLabor    = 2941;
            double   expectedQuantity = 3;
            CostType expectedType     = CostType.TEC;
            TECMisc  actualMisc       = null;

            foreach (TECSystem system in actualTemplates.Templates.SystemTemplates)
            {
                foreach (TECMisc misc in system.MiscCosts)
                {
                    if (misc.Guid == expectedGuid)
                    {
                        actualMisc = misc;
                        break;
                    }
                }
            }

            //Assert
            Assert.AreEqual(expectedName, actualMisc.Name);
            Assert.AreEqual(expectedQuantity, actualMisc.Quantity);
            Assert.AreEqual(expectedCost, actualMisc.Cost);
            Assert.AreEqual(expectedLabor, actualMisc.Labor);
            Assert.AreEqual(expectedType, actualMisc.Type);
        }
示例#22
0
 public virtual void Initialize(CostType type, Card card, Game game, TargetValidator validator = null)
 {
     Game      = game;
     Card      = card;
     Validator = validator;
     Type      = type;
 }
示例#23
0
        private AnnualPlanCostTypeModel GetAnnualPlanCostTypeModel(CostType costType,
                                                                   IList <CostPlanDto> previousMarketingYearCostPlans, IList <CostPlanDto> currentMarketingYearCostPlans)
        {
            var annualPlanCostTypeModel = new AnnualPlanCostTypeModel
            {
                CostType     = costType,
                CostTypeName = TypeName.GetFodderTypeName((int)costType),
                PreviousPlan = previousMarketingYearCostPlans.FirstOrDefault(x => x.Type == (int)costType)?.Cost / 1000.0 ?? 0,
                CurrentState = 0, // TODO: How to determine it?
                FutureState  = currentMarketingYearCostPlans.FirstOrDefault(x => x.Type == (int)costType)?.Cost / 1000.0 ?? 0
            };

            switch (costType)
            {
            case CostType.Cost:
                IList <ExpenseDto> previousMarketingYearExpenses = _expenseDao.GetByMarketingYear(PreviousMarketingYearId);
                annualPlanCostTypeModel.Execution = previousMarketingYearExpenses.Sum(x => x.Cost) / 1000.0;
                break;

            case CostType.Revenue:
                IList <CarcassRevenueDto> previousMarketingYearCarcassRevenues = _carcassRevenueDao.GetByMarketingYear(PreviousMarketingYearId);
                annualPlanCostTypeModel.Execution = previousMarketingYearCarcassRevenues.Sum(x => x.Revenue) / 1000.0;
                break;

            default:
                break;
            }

            return(annualPlanCostTypeModel);
        }
示例#24
0
 protected void copyPropertiesFromCost(TECCost cost)
 {
     copyPropertiesFromScope(cost);
     _cost  = cost.Cost;
     _labor = cost.Labor;
     _type  = cost.Type;
 }
示例#25
0
 /// <summary>
 /// This checks if a node has been seen by the other iterator/traverser
 /// as well. In that case a path has been found. In that case, the total
 /// cost for the path is calculated and compared to previously found
 /// paths.
 /// </summary>
 /// <param name="currentNode"> The node to be examined. </param>
 /// <param name="currentCost"> The cost from the start node to this node. </param>
 /// <param name="otherSideDistances"> Map over distances from other side. A path
 ///            is found and examined if this contains currentNode. </param>
 protected internal virtual void CheckForPath(Node currentNode, CostType currentCost, Dictionary <Node, CostType> otherSideDistances)
 {
     // Found a path?
     if (otherSideDistances.ContainsKey(currentNode))
     {
         // Is it better than previously found paths?
         CostType otherCost    = otherSideDistances[currentNode];
         CostType newTotalCost = outerInstance.CostAccumulator.addCosts(currentCost, otherCost);
         if (outerInstance.FoundPathsMiddleNodes == null)
         {
             outerInstance.FoundPathsMiddleNodes = new HashSet <Node>();
         }
         // No previous path found, or equally good one found?
         if (outerInstance.FoundPathsMiddleNodes.Count == 0 || outerInstance.CostComparator.Compare(outerInstance.FoundPathsCost, newTotalCost) == 0)
         {
             outerInstance.FoundPathsCost = newTotalCost;                                   // in case we had no
             // previous path
             outerInstance.FoundPathsMiddleNodes.Add(currentNode);
         }
         // New better path found?
         else if (outerInstance.CostComparator.Compare(outerInstance.FoundPathsCost, newTotalCost) > 0)
         {
             outerInstance.FoundPathsMiddleNodes.Clear();
             outerInstance.FoundPathsCost = newTotalCost;
             outerInstance.FoundPathsMiddleNodes.Add(currentNode);
         }
     }
 }
示例#26
0
        public void SetData(LottoItemProto itemProto, CostType costType, float costValue)
        {
            this.m_normalEffect.Visible = !itemProto.Special;
            this.m_effect.Visible       = itemProto.Special;
            if (itemProto.Special)
            {
            }

            ConfProp prop = ConfProp.Get(itemProto.PropId);

            if (prop == null)
            {
                return;
            }
            m_icon_img.Sprite    = prop.icon;
            m_itemCount_lab.Text = string.Format("x{0}", itemProto.Count);
            m_itemName_lab.Text  = LocalizeModule.Instance.GetString(prop.name);
            if (costType == CostType.CostCash)
            {
                m_costType_img.Sprite = "icon_mainpanel_cash_2.png";
            }
            else if (costType == CostType.CostCoin)
            {
                m_costType_img.Sprite = "icon_mainpanel_coin_2.png";
            }
            m_costValue_lab.Text = costValue.ToString();
            GlobalInfo.MY_PLAYER_INFO.AddSingleBagInfo(itemProto.PropId, itemProto.Count);

            GameEvents.UIEvents.UI_GameEntry_Event.Listen_OnCombinePropCollected.SafeInvoke();
        }
示例#27
0
 public SportsGameDto(int id, DateTimeOffset date, string name, EventType eventType, string venue,
                      CostType venueCostType, CostType marketingCostType, int capacity, int sold, int numberOfPlayers,
                      int costsPerPlayer) : base(id,
                                                 date, name, eventType, venue, venueCostType, marketingCostType, capacity, sold)
 {
     NumberOfPlayers = numberOfPlayers;
     CostsPerPlayer  = costsPerPlayer;
 }
示例#28
0
 public ConferenceDto(int id, DateTimeOffset date, string name, EventType eventType, string venue,
                      CostType venueCostType, CostType marketingCostType, int capacity, int sold, int badgeCosts,
                      int cateringCosts) : base(id, date,
                                                name, eventType, venue, venueCostType, marketingCostType, capacity, sold)
 {
     BadgeCosts    = badgeCosts;
     CateringCosts = cateringCosts;
 }
示例#29
0
 CostTypeViewModel ConvertEntityToViewModel(CostType model)
 {
     return(new CostTypeViewModel
     {
         CostTypeId = model.CostTypeId,
         CostTypeName = model.CostTypeName
     });
 }
示例#30
0
 public static CostTypeModel ToModel(this CostType costType)
 {
     return(new CostTypeModel
     {
         CostTypeDescription = costType.CostTypeDescription,
         CostTypeId = costType.CostTypeId
     });
 }
示例#31
0
        /// <summary>
        /// Gets the actual or target cost entry for the given project type and the month.
        /// </summary>
        /// <param name="projectType">Type of project.</param>
        /// <param name="costType">The actual or target cost indicator.</param>
        /// <param name="month">Month for the calculation.</param>
        /// <returns>The cost value.</returns>
        public long GetCostEntry(ProjectType projectType, CostType costType, int month)
        {
            var key = ProjectCostEntry.ToString(projectType, costType, month);
            if (this.costEntries.ContainsKey(key))
            {
                return this.costEntries[key].Cost;
            }

            return 0;
        }
        public IList<Record> GetInRange(CostType type, DateTimeIntervals intervalType, CostBarInfo barInfo, int startIdx, int count)
        {
            switch (intervalType)
            {
                case DateTimeIntervals.None:
                    return GetCostsByProducts(barInfo, startIdx, count);
                default:
                    return GetCostsByDate(intervalType, barInfo, startIdx, count);

            }
        }
 public double GetMax(CostType type, DateTimeIntervals intervalType, CostBarInfo barInfo, int count)
 {
     switch (barInfo.Level)
     {
         case 0:
             return GetMaxCostByDate(intervalType, type, count);
         case 1:
             return GetMaxCostByCostCenters(barInfo, type, count);
         default:
             return 0;
     }
 }
示例#34
0
        public IList<Record> GetInRange(CostType type, DateTimeIntervals intervalType, CostBarInfo barInfo, int startIdx, int count)
        {

            switch (barInfo.Level)
            {
                case 0:
                    return GetCostsByDate(intervalType, type, startIdx, count);
                case 1:
                    return GetCostsByCostCenters(barInfo, type, startIdx, count);
                case 2:
                    return GetCostsByType(barInfo, type, startIdx, count);
            }
            return new List<Record>();
        }
示例#35
0
        private IList<Record> GetCostsByDate(DateTimeIntervals intervalType, CostType type, int startIdx, int count)
        {
            IList<Record> records = new List<Record>();
            int currentYear = DateTime.Now.Year;
            var startDate = new DateTime(currentYear, 1, 1);
            startDate = AddInterval(startDate, startIdx, intervalType);
            var currentInterval = startDate;

            using (var context = new SoheilEdmContext())
            {
                var costRepository = new Repository<Cost>(context);

                var costList = costRepository.GetAll();

                var indexList = new List<KeyValuePair<int, double>>();

                for (int i = startIdx; i < count; i++)
                {
                    indexList.AddRange(from cost in costList
                                      where cost.Date >= currentInterval
                                      && cost.Date < AddInterval(currentInterval, 1, intervalType)
                                      && (type == CostType.All || cost.CostType == (decimal) type)
                                      select new KeyValuePair<int, double>(i, cost.CostValue?? 0));
                    indexList.Add(new KeyValuePair<int, double>(i, 0));
                    currentInterval = AddInterval(currentInterval, 1, intervalType);
                }

                var query = from index in indexList
                            group index by index.Key into g
                            let total = g.Sum(item => item.Value)
                            select new { interval = g.Key, value = total};

                for (int i = startIdx; i < count; i++)
                {
                    var newRecord = new Record { Header = i.ToString(CultureInfo.InvariantCulture) };
                    foreach (var line in query)
                    {
                        if (line.interval == i)
                        {
                            newRecord.Id = line.interval;
                            newRecord.Value = line.value;
                            newRecord.StartDate = AddInterval(startDate, i - startIdx, intervalType);
                            newRecord.EndDate = AddInterval(startDate, i - startIdx + 1, intervalType);
                        }
                    }
                    records.Add(newRecord);
                }
            }
            return records;
        }
示例#36
0
        private IList<Record> GetCostsByCostCenters(CostBarInfo indexInfo, CostType type, int startIdx, int count)
        {
            IList<Record> records = new List<Record>();

            using (var context = new SoheilEdmContext())
            {
                var costRepository = new Repository<Cost>(context);
                var costCenterRepository = new Repository<CostCenter>(context);

                var costList = costRepository.GetAll();
                var costCenterList = costCenterRepository.GetAll();

                var indexList = costCenterList.Skip(startIdx).Take(count).Select((cc, index) => new { interval = index, cc.Id, cc.Name });

                var ccQuery = from index in indexList
                            from cost in costList.Where(c => c.CostCenter != null && c.CostCenter.Id == index.Id
                                && c.Date >= indexInfo.StartDate && c.Date < indexInfo.EndDate
                                && (type == (decimal)CostType.All || c.CostType == (decimal)type)).DefaultIfEmpty()
                            select new {index.interval, index.Id, index.Name , Value = cost == null ? 0 : cost.CostValue?? 0 };

                var query = from costCenter in ccQuery
                            group costCenter by new {costCenter.interval, costCenter.Id, costCenter.Name } into g
                            let total = g.Sum(item => item.Value)
                            select new {g.Key.interval, g.Key.Id, g.Key.Name, value = total };

                for (int i = startIdx; i < count; i++)
                {
                    var newRecord = new Record { Header = i.ToString(CultureInfo.InvariantCulture) };
                    foreach (var line in query)
                    {
                        if (line.interval + startIdx == i)
                        {
                            newRecord.Id = line.Id;
                            newRecord.Value = line.value;
                            newRecord.StartDate = indexInfo.StartDate;
                            newRecord.EndDate = indexInfo.EndDate;
                            newRecord.Header = line.Name;
                        }
                    }
                    records.Add(newRecord);
                }
            }
            return records;
        }
示例#37
0
        private IList<Record> GetCostsByType(CostBarInfo indexInfo, CostType type, int startIdx, int count)
        {
            IList<Record> records = new List<Record>();

            using (var context = new SoheilEdmContext())
            {
                var costRepository = new Repository<Cost>(context);
                var costList = costRepository.Find(c=> c.CostCenter != null && c.CostCenter.Id == indexInfo.Id);

                var indexList = costList.Skip(startIdx).Take(count).Select((c, index) => new { interval = index, c.Id, c.CostType, c.Description, c.Date, c.CostValue });

                var query = from index in indexList.Where(idx => idx.Date >= indexInfo.StartDate && idx.Date < indexInfo.EndDate
                                && (type == CostType.All || idx.CostType == (decimal)type))
                            select new {index.interval, index.Id, index.CostValue, index.Description };

                var results = query.ToList();

                for (int i = startIdx; i < count; i++)
                {
                    if (i - startIdx >= results.Count)
                    {
                        records.Add(new Record());
                    }
                    else
                    {
                        var newRecord = new Record
                            {
                                Id = results[i - startIdx].Id,
                                Header = results[i - startIdx].Description,
                                Value = results[i - startIdx].CostValue ?? 0,
                                StartDate = indexInfo.StartDate,
                                EndDate = indexInfo.EndDate
                            };
                        records.Add(newRecord);
                    }
                }
                //foreach (var result in results)
                //{
                //    var newRecord = new Record
                //    {
                //        Id = result.Id,
                //        Header = result.Description,
                //        Value = result.CostValue ?? 0,
                //        StartDate = indexInfo.StartDate,
                //        EndDate = indexInfo.EndDate
                //    };
                //    records.Add(newRecord);
                //}
            }
            return records;
        }
        private double GetMaxCostByCostCenters(CostBarInfo indexInfo, CostType type, int count)
        {
            using (var context = new SoheilEdmContext())
            {
                var costRepository = new Repository<Cost>(context);
                var costCenterRepository = new Repository<CostCenter>(context);

                var costList = costRepository.GetAll().ToList();
                var costCenterList = costCenterRepository.GetAll().ToList();

                var indexList = costCenterList.Select((cc, index) => new { interval = index, cc.Id, cc.Name });

                var ccQuery = from index in indexList
                              from cost in costList.Where(c => c.CostCenter != null && c.CostCenter.Id == index.Id
                                  && c.Date >= indexInfo.StartDate && c.Date < indexInfo.EndDate
                                  && (type == (decimal)CostType.All || c.CostType == (decimal)type)).DefaultIfEmpty()
                              select new { index.interval, index.Id, index.Name, Value = cost == null ? 0 : cost.CostValue ?? 0 };

                var query = from costCenter in ccQuery
                            group costCenter by new { costCenter.interval, costCenter.Id, costCenter.Name } into g
                            let total = g.Sum(item => item.Value)
                            select new { g.Key.interval, g.Key.Id, g.Key.Name, value = total };

                return query.Max(item => item.value);
            }
        }
        private double GetMaxCostByDate(DateTimeIntervals intervalType, CostType type, int count)
        {
            int currentYear = DateTime.Now.Year;
            var startDate = new DateTime(currentYear, 1, 1);
            startDate = AddInterval(startDate, 0, intervalType);
            var currentInterval = startDate;

            using (var context = new SoheilEdmContext())
            {
                var costRepository = new Repository<Cost>(context);

                var costList = costRepository.GetAll().ToList();

                var indexList = new List<KeyValuePair<int, double>>();

                for (int i = 0; i < count; i++)
                {
                    indexList.AddRange(from cost in costList
                                       where cost.Date >= currentInterval
                                       && cost.Date < AddInterval(currentInterval, 1, intervalType)
                                       && (type == CostType.All || cost.CostType == (decimal)type)
                                       select new KeyValuePair<int, double>(i, cost.CostValue ?? 0));
                    indexList.Add(new KeyValuePair<int, double>(i, 0));
                    currentInterval = AddInterval(currentInterval, 1, intervalType);
                }

                var query = from index in indexList
                            group index by index.Key into g
                            let total = g.Sum(item => item.Value)
                            select new { interval = g.Key, value = total };

                return query.Max(item => item.value);
            }
        }
示例#40
0
 /// <summary>
 /// Provide the string representation of the <see cref="ProjectCostEntry"/> with the provided input values.
 /// </summary>
 /// <param name="projectType">Type of project.</param>
 /// <param name="costType">The actual or target cost indicator.</param>
 /// <param name="month">Month for the calculation.</param>
 /// <returns>The string representation of the <see cref="ProjectCostEntry"/></returns>
 public static string ToString(ProjectType projectType, CostType costType, int month)
 {
     return string.Format("{0}_{1}_{2}", projectType, costType, FormatMonth(month));
 }
示例#41
0
 /// <summary>
 /// Provide the string representation of the <see cref="ProjectCostEntry"/> with the provided input values.
 /// </summary>
 /// <param name="projectType">Type of project.</param>
 /// <param name="costType">The actual or target cost indicator.</param>
 /// <returns>The string representation of the <see cref="ProjectCostEntry"/></returns>
 public static string ToString(ProjectType projectType, CostType costType)
 {
     return string.Format("{0}_{1}", projectType, costType);
 }
示例#42
0
        /// <summary>
        /// Provide the string representation of the <see cref="ProjectCostEntry"/> with the provided input values.
        /// </summary>
        /// <param name="costType">The actual or target cost indicator.</param>
        /// <param name="month">Month for the calculation.</param>
        /// <returns>The string representation of the <see cref="ProjectCostEntry"/></returns>
        public static string ToString(CostType costType, int month)
        {

            return string.Format("{0}_{1}", costType, FormatMonth(month));
        }
示例#43
0
 public void SetCostEntry(ProjectType projectType, CostType costTye, int month, string costValue)
 {
     var cost = 0L;
     long.TryParse(costValue, out cost);
     this.SetCostEntry(projectType, costTye, month, cost);
 }
示例#44
0
        private double GetMaxCostByType(CostBarInfo indexInfo, CostType type, int count)
        {
            using (var context = new SoheilEdmContext())
            {
                var costRepository = new Repository<Cost>(context);
                var costList = costRepository.Find(c => c.CostCenter != null && c.CostCenter.Id == indexInfo.Id);

                var indexList = costList.Select((c, index) => new { interval = index, c.Id, c.CostType, c.Description, c.Date, c.CostValue });

                var query = from index in indexList.Where(idx => idx.Date >= indexInfo.StartDate && idx.Date < indexInfo.EndDate
                                && (type == CostType.All || idx.CostType == (decimal)type))
                            select new { index.interval, index.Id, index.CostValue, index.Description };

                var max = query.Max(item => item.CostValue);
                if (max != null) return (double) max;
            }
            return 0;
        }
示例#45
0
 public void SetCostEntry(ProjectType projectType, CostType costTye, int month, long cost)
 {
     var projectCostEntry = new ProjectCostEntry();
     projectCostEntry.ProjectType = projectType;
     projectCostEntry.CostType = costTye;
     projectCostEntry.Month = month;
     projectCostEntry.Cost = cost;
     this.SetCostEntry(projectCostEntry);
 }