private static Dictionary <string, ClassificationItem> ConvertClassification(CostModel model, IEnumerable <TZatrideni> zatrideni, ClassificationItemCollection parent) { var result = new Dictionary <string, ClassificationItem>(); foreach (var zatr in zatrideni) { // classification items model classification hierarchy (breakdown structure) // there might be several classifications in the model var item = new ClassificationItem(model) { Sort = zatr.Typ.ToString(), Name = zatr.Nazev, Identification = zatr.Cislo, Description = zatr.ZPOPIS }; // nested level of classification breakdown if (zatr.ZATRIDENI?.Any() == true) { var children = ConvertClassification(model, zatr.ZATRIDENI, item.Children); foreach (var ch in children) { result.Add(ch.Key, ch.Value); } } // keep key in the lookup for later use if (!string.IsNullOrWhiteSpace(zatr.PolozkaZatrideniUID) && !result.ContainsKey(zatr.PolozkaZatrideniUID)) { result.Add(zatr.PolozkaZatrideniUID, item); } } return(result); }
public IActionResult Sort(string category, DateTime datestart, DateTime dateend) { DateTime correct = new DateTime(2015, 05, 18); db.CostModels.RemoveRange(db.CostModels); db.SaveChanges(); foreach (Cost i in db.Costs) { CostModel p = new CostModel { Name = i.Name, Money = i.Money, Category = db.Categorys.Where(j => j.Id == i.CategoryId).FirstOrDefault().Name, Date = i.Date, User = db.Users.Where(j => j.Id == i.UserId).FirstOrDefault().Login, Count = i.Count, Unit = i.Unit, Cash = i.Cash }; db.CostModels.Add(p); } db.SaveChanges(); if (category != "Все") { db.CostModels.RemoveRange(db.CostModels.Where(i => i.Category != category)); } db.SaveChanges(); db.CostModels.RemoveRange(db.CostModels.Where(i => i.Date < datestart)); db.SaveChanges(); if (dateend > correct) { db.CostModels.RemoveRange(db.CostModels.Where(i => i.Date > dateend)); } db.SaveChanges(); return(View("Index", db)); }
public CostsEntity(int treatmentId, CostModel costModel) { TREATMENTID = treatmentId; COST_ = costModel.Equation; CRITERIA = costModel.Criteria; ISFUNCTION = costModel.IsFunction ?? false; }
public override double ComputeCost() { double newCost = CostModel.GetSyncCost(numberOfWrites, Convert.ToInt32(OldSyncPeriod() * ConstPool.ADJUSTING_SYNC_INTERVAL_MULTIPLIER)); double oldCost = CostModel.GetSyncCost(numberOfWrites, OldSyncPeriod()); return(newCost - oldCost); }
public async Task <ActionResult> UpdateCostAsync(CostModel model) { using (var orderDbContext = Provider.CreateDbContext()) { try { Cost update = await orderDbContext.Costs.Where(a => a.Id == model.Id).FirstOrDefaultAsync(); if (update != null) { update.Cost_Date = model.Cost_Date; update.Cost_Description = model.Cost_Description; update.Cost_Price = model.Cost_Price; } await orderDbContext.SaveChangesAsync(); Log.Info("修改Cost id:" + model.Id + "成功!"); return(new ActionResult() { Status = ActionStatus.OK, Msg = "修改Cost id:" + model.Id + "成功!" }); } catch (Exception ex) { Log.Error(ex.ToString()); return(new ActionResult() { Status = ActionStatus.Failed, Msg = "修改Cost id:" + model.Id + "失败!" }); } } }
public override double ComputeCost() { double result = 0; DowngradePrimary p = new DowngradePrimary(Configuration.Name, ServerName, 0, null, ConfigurationActionSource.Constraint, numberOfReads, numberOfWrites); if (Configuration.SecondaryServers.Contains(ServerName)) { //all primaries will become secondary, result = Configuration.PrimaryServers.Count * p.ComputeCost(); //a secondary will become primary: int secondarySyncPeriod = Configuration.GetSyncPeriod(ServerName); result += CostModel.GetPrimaryTransactionalCost(numberOfReads, numberOfWrites) - (CostModel.GetSecondaryTransactionalCost(numberOfReads) + CostModel.GetSyncCost(numberOfWrites, secondarySyncPeriod)); } else if (Configuration.PrimaryServers.Contains(ServerName)) { //all primaries except one will become secondary result = (Configuration.PrimaryServers.Count - 1) * p.ComputeCost(); } else { // all primaries will become secondary result = Configuration.PrimaryServers.Count * p.ComputeCost(); //one non-replica becomes primary result += CostModel.GetPrimaryTransactionalCost(numberOfReads, numberOfWrites) + CostModel.GetStorageCost(ClientRegistry.GetMainPrimaryContainer(Configuration.Name)); } return(result); }
public async Task <ActionResult> InsertCostAsync(CostModel model) { using (var orderDbContext = Provider.CreateDbContext()) { Cost cost = new Cost() { Cost_Date = model.Cost_Date, Cost_Description = model.Cost_Description, Cost_Price = model.Cost_Price }; try { await orderDbContext.Costs.AddAsync(cost); await orderDbContext.SaveChangesAsync(); Log.Info("成本" + model.Cost_Description + "记录成功!"); return(new ActionResult() { Status = ActionStatus.OK, Msg = "成本" + model.Cost_Description + "记录成功!" }); } catch (Exception ex) { // orderDbContext.Articles.Remove(article); Log.Info("成本记录失败!" + ex.ToString()); return(new ActionResult() { Status = ActionStatus.Failed, Msg = "成本记录失败!" + ex.InnerException.Message }); } } }
public IHttpActionResult Index(HttpRequestMessage requestMessage) { var readRequest = Request.Content.ReadAsStringAsync().Result.ToLower(); //Add a opening and closing tag for the whole string readRequest = "<root>" + readRequest + "</root>"; try { XElement request = XElement.Parse(readRequest); //check if Total is existing if (request != null && request.Element("total") != null) { //build the json response dynamic obj = new ExpandoObject(); obj.discoverySchemaVersion = "1.0.0"; obj.result = new ExpandoObject(); var costModel = CostModel.CalculateExtractedResult(request); var jsonToReturn = JsonConvert.SerializeObject(costModel); if (null != jsonToReturn) { return(Ok(jsonToReturn)); } } return(NotFound()); } catch (Exception ex) { throw new Exception("Invalid message. Please try again." + ex.Message); } }
public override double ComputeCost() { double result = 0; result = CostModel.GetSecondaryTransactionalCost(numberOfReads) + CostModel.GetSyncCost(numberOfWrites, ConstPool.DEFAULT_SYNC_INTERVAL) + CostModel.GetStorageCost(ClientRegistry.GetMainPrimaryContainer(Configuration.Name)); return(result); }
private static Dictionary <string, ClassificationItem> ProcessJKSO(CostModel model, TeSoupis soupis) { var result = new Dictionary <string, ClassificationItem>(); var items = (soupis.STAVBA ?? new List <TStavba>()) .SelectMany(s => s.OBJEKT ?? new List <TObjekt>()) .Where(o => !string.IsNullOrWhiteSpace(o.CisloJKSO)) .Select(o => new { Nazev = o.NazevJKSO, Cislo = o.CisloJKSO }) .ToList(); if (!items.Any()) { return(result); } var jkso = new Classification(model, "JKSO"); items.ForEach(i => { if (result.ContainsKey(i.Cislo)) { return; } var j = new ClassificationItem(model) { Name = i.Nazev, Identification = i.Cislo }; jkso.Children.Add(j); result.Add(i.Cislo, j); }); return(result); }
public IActionResult Costing(int?id, int projectId) { if (id == null) { return(NotFound()); } //var record = (from c in _context.CostModel // where c.Id == id // select c).FirstOrDefault(); var record = from cost in _context.CostModel join proj in _context.Projects on cost.ProjectId equals proj.Id where cost.ProjectId == projectId select new CostProjectViewModel { Projects = proj, CostModel = cost }; if (record == null) { CostModel cm = new CostModel(); return(View(cm)); } return(View(record.FirstOrDefault())); }
private static void ProcessParts(CostModel model, List <TDil> dily, CostItem parent, Dictionary <string, ClassificationItem> map) { if (dily == null) { return; } foreach (var dil in dily) { // grouping level in the cost breakdown hierarchy var item = new CostItem(model) { Name = dil.Nazev, Identifier = dil.Cislo, Description = dil.DPOPIS, Type = dil.Typ.ToString() }; parent.Children.Add(item); // additional properties can be stored in custom property sets // item["CZ_CostItem"] = new PropertySet(model); // leafs in the cost breakdown hierarchy ProcessItems(model, dil.POLOZKA, item, map); } }
public CostViewModel() { Model = new CostModel { Id = SystemUtility.GetGuid() }; IsNew = true; HavePrevCost = false; }
public void RemoveCost(CostModel cost) { using (Context.AppContext dbContext = new Context.AppContext()) { dbContext.Costs.Remove(cost); dbContext.SaveChanges(); } }
public MedicalInfoViewModel(int animalID) { AnimalID = animalID; MedicalRecord = new MedicalRecordModel(); NewMedicalRecord = new MedicalRecordModel(); MedicalCost = new CostModel(); NewMedicalCost = new CostModel(); }
public ActionResult About() { var model = new CostModel { check = false }; return(View(model)); }
internal void UpdateCost(CostModel updateCost) { using (Context.AppContext dbContext = new Context.AppContext()) { CostModel currentCost = dbContext.Costs.FirstOrDefault(c => c.Id == updateCost.Id); dbContext.Entry(currentCost).CurrentValues.SetValues(updateCost); dbContext.SaveChanges(); } }
private CatalogViewModel Catalog() { CatalogViewModel catalog = new CatalogViewModel(); var brands = brandService.GetAllBrands(); for (int i = 0; i < brands.Count(); i++) { BrandModel brand = new BrandModel { Id = brands[i].Id, Name = brands[i].Name, Photo = brands[i].Photo }; var models = modelService.GetAllModels(brands[i].Id); for (int j = 0; j < models.Count(); j++) { ModelModel model = new ModelModel { Id = models[j].Id, Name = models[j].Name, Photo = models[j].PhotoUrl }; var cars = carService.GetAllCars(models[j].Id); for (int k = 0; k < cars.Count(); k++) { CarModel car = new CarModel { Id = cars[k].Id, Color = cars[k].Color, VolumeEngine = cars[k].VolumeEngine, Description = cars[k].Description }; var prices = cars[k].Prices; for (int l = 0; l < prices.Count(); l++) { CostModel cost = new CostModel { Id = prices[l].Id, Date = prices[l].Date, Price = prices[l].Price }; car.Prices.Add(cost); } model.Cars.Add(car); } brand.Models.Add(model); } catalog.Brands.Add(brand); } return(catalog); }
public void ClearNewCost() { NewCost = new CostModel(); NotifyOfPropertyChange(() => NewCost); NotifyOfPropertyChange(() => NewCostName); NotifyOfPropertyChange(() => NewDescription); NotifyOfPropertyChange(() => NewDate); NotifyOfPropertyChange(() => NewPrice); }
public void Initialize(FullyConnectedNeuralNetworkModel model) { population[0] = new CostModel <FullyConnectedNeuralNetworkModel>(model); for (var populationIndex = 1; populationIndex < populationSize; populationIndex++) { var member = modelInitializer.CreateModel(model.ActivationCountsPerLayer, model.ActivationFunction); population[populationIndex] = new CostModel <FullyConnectedNeuralNetworkModel>(member); } }
internal CostModel GetCost(string id) { CostModel result = null; using (Context.AppContext dbContext = new Context.AppContext()) { result = dbContext.Costs.FirstOrDefault(c => c.Id == id); } return(result); }
/// <summary> /// 新增缴费信息 /// </summary> /// <returns></returns> public Result AddCostInfo(CostModel model) { var cost = _mapper.Map <WCostinfo>(model); cost.IsDel = 0; _videoContext.Add(cost); _videoContext.SaveChanges(); return(new Result { msg = "新增成功" }); }
public override double ComputeCost() { double result = 0; double secondaryTransactionalCost = CostModel.GetSecondaryTransactionalCost(numberOfReads); double syncCost = CostModel.GetSyncCost(numberOfWrites, ConstPool.DEFAULT_SYNC_INTERVAL); double primaryTransactionalCost = CostModel.GetPrimaryTransactionalCost(numberOfReads, numberOfWrites); result = (secondaryTransactionalCost + syncCost) - primaryTransactionalCost; return(result); }
public IActionResult AddCostModel([Bind("Id,ProjectId,AveragePerSqFootFinsihed,AvgCostGarage,AvgCostMainLevel, AvgCostUnfinsihedBasement,AvgCostUpperLoft,AvgPerSqFtFinBasement,BasementUnfinishedSqFeet,FinishedBasement,Garage,MainLevelSquareFeet,TotalSquareFtHouse,TotalSquareFtUnderRoof,UpperLevelLoft")] CostModel costModel) { if (ModelState.IsValid) { _context.Add(costModel); _context.SaveChanges(); return(RedirectToAction(nameof(ViewCost), new { })); } return(View(costModel)); }
public async Task <IActionResult> CreateCostModel([Bind("Id,AveragePerSqFootFinished,AvgCostGarage,AvgCostMainLevel,projectValues, AvgCostUnfinsihedBasement,AvgCostUpperLoft,AvgPerSqFtFinBasement,BasementUnfinishedSqFeet,FinishedBasement,Garage,MainLevelSquareFeet,TotalSquareFtHouse,TotalSquareFtUnderRoof,UpperLevelLoft")] CostModel costModel) { if (ModelState.IsValid) { costModel.ProjectId = 1; _context.Add(costModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(costModel)); }
private static void ProcessObjects(CostModel model, CostSchedule schedule, IEnumerable <TObjekt> objekty, Dictionary <string, ClassificationItem> jkso) { if (objekty == null || !objekty.Any()) { return; } foreach (var obj in objekty) { // root element of the cost schedule var rootItem = new CostItem(model) { Name = obj.Nazev, Description = obj.OPOPIS, Identifier = obj.Cislo }; schedule.CostItems.Add(rootItem); // additional properties can be stored in custom property sets rootItem["CZ_CostItem"] = new PropertySet(model); rootItem["CZ_CostItem"]["Charakteristika"] = new IfcText(obj.Charakteristika); rootItem["CZ_CostItem"]["DruhStavebniAkce"] = new IfcText(obj.DruhStavebniAkce); if (!string.IsNullOrWhiteSpace(obj.CisloJKSO)) { var jksoItem = jkso[obj.CisloJKSO]; rootItem.ClassificationItems.Add(jksoItem); } foreach (var soup in obj.SOUPIS) { var item = new CostItem(model) { Name = soup.Nazev, Identifier = soup.Cislo, Description = soup.RPOPIS }; rootItem.Children.Add(item); // classification hierarchy in IFC. Cost Items will be related to Classification Items var classificationMap = new Dictionary <string, ClassificationItem>(); if (soup.ZATRIDENI != null && soup.ZATRIDENI.Any()) { var rootClassificationName = GetClassificationName(soup); var rootClassification = new Classification(model, rootClassificationName); classificationMap = ConvertClassification(model, soup.ZATRIDENI, rootClassification.Children); } // next level of the cost breakdown structure ProcessParts(model, soup.DIL, item, classificationMap); } } }
public void ClearNewMedicalRecord() { NewMedicalRecord = new MedicalRecordModel(); NewMedicalCost = new CostModel(); NotifyOfPropertyChange(() => NewMedicalRecord); NotifyOfPropertyChange(() => NewMedicalCost); NotifyOfPropertyChange(() => NewRecordName); NotifyOfPropertyChange(() => NewDescription); NotifyOfPropertyChange(() => NewVet); NotifyOfPropertyChange(() => NewDate); NotifyOfPropertyChange(() => NewPrice); }
public virtual async Task LoadData() { IsWorking = true; await Task.Delay(150); await Task.Run(() => { AnimalCosts = CostModel.GetAnimalCosts(AnimalID); }); IsWorking = false; }
public override async Task LoadData() { IsWorking = true; await Task.Delay(150); await Task.Run(() => { AnimalCosts = CostModel.GetAllCosts(); }); IsWorking = false; }
public virtual async Task FilterData() { IsWorking = true; await Task.Delay(150); await Task.Run(() => { AnimalCosts = CostModel.GetDatedCosts(Since, To); }); IsWorking = false; }
public void TestComputeOverallCost() { var cost = new MethodCost("a", 0); cost.addCostSource(new CyclomaticCost(0, Cost.Cyclomatic(1))); cost.addCostSource(new GlobalCost(0, null, Cost.Global(1))); var cost3 = new MethodCost("b", 0); cost3.addCostSource(new CyclomaticCost(0, Cost.Cyclomatic(1))); cost3.addCostSource(new CyclomaticCost(0, Cost.Cyclomatic(1))); cost3.addCostSource(new CyclomaticCost(0, Cost.Cyclomatic(1))); cost.addCostSource(new MethodInvokationCost(0, cost3, Reason.IMPLICIT_STATIC_INIT, Cost.Cyclomatic(3))); var costModel = new CostModel(2, 10); cost.link(); Assert.AreEqual((long) 2*(3+1)+10*1, costModel.computeOverall(cost.getTotalCost())); Assert.AreEqual(2, cost.getExplicitViolationCosts().Count); Assert.AreEqual(1, cost.getImplicitViolationCosts().Count); }