public ActionResult EditCustomerActivity(int activityId, int customerId) { ActivityManagement activityMgr = new ActivityManagement(User.Identity.GetUserId <int>()); List <BActivity> activities = activityMgr.FindActivities(activityId, User.Identity.GetUserId <int>(), customerId, out total, true, 1, 1); CustomerActivityModel model = new CustomerActivityModel(); if (activities.Count == 1) { BActivity activity = activities[0]; model.Id = activity.Activity.Id; model.CustomerId = customerId; model.Description = activity.Activity.Description; model.Enable = activity.Activity.Enabled; model.ExpiredTime = activity.Activity.ExpiredTime > 0 ? DateTimeUtil.ConvertToDateTime(activity.Activity.ExpiredTime).ToString("yyyy-M-dd") : ""; model.Name = activity.Activity.Name; model.ScanType = activity.Activity.ScanType; model.StartTime = activity.Activity.ExpiredTime > 0 ? DateTimeUtil.ConvertToDateTime(activity.Activity.StartedTime).ToString("yyyy-M-dd") : ""; } else { ViewBag.Message = "不能修改不属于自己客户的活动"; return(View("Error")); } List <DictionaryTemplate> scanTypes = StaticDictionary.GetScanTypeList(); ViewBag.ScanTypes = new SelectList(from st in scanTypes select new { Id = st.Id, Name = st.Value }, "Id", "Name"); return(View("CreateCustomerActivity", model)); }
public SeedBuildingData() { Buildings = new StaticDictionary <StaticBuilding>(); SeedInfrastructureData(); SeedDefensiveData(); }
/// <summary> /// Builds the data. /// </summary> /// <param name="interpreter"></param> /// <param name="embeddedString"></param> /// <returns></returns> public override IRoutingAlgorithmData <CHEdgeData> BuildData(IOsmRoutingInterpreter interpreter, string embeddedString) { string key = string.Format("CHEdgeDifference.Routing.IRoutingAlgorithmData<CHEdgeData>.OSM.{0}", embeddedString); var data = StaticDictionary.Get <IRoutingAlgorithmData <CHEdgeData> >( key); if (data == null) { var tagsIndex = new TagsIndex(); // do the data processing. var memoryData = new RouterDataSource <CHEdgeData>(new DirectedGraph <CHEdgeData>(), tagsIndex); var targetData = new CHEdgeGraphOsmStreamTarget( memoryData, interpreter, tagsIndex, Vehicle.Car); var dataProcessorSource = new XmlOsmStreamSource( Assembly.GetExecutingAssembly().GetManifestResourceStream(embeddedString)); var sorter = new OsmStreamFilterSort(); sorter.RegisterSource(dataProcessorSource); targetData.RegisterSource(sorter); targetData.Pull(); data = memoryData; StaticDictionary.Add <IRoutingAlgorithmData <CHEdgeData> >(key, data); } return(data); }
/// <summary> /// Builds data source. /// </summary> /// <param name="interpreter"></param> /// <param name="embeddedString"></param> /// <returns></returns> public override IBasicRouterDataSource <LiveEdge> BuildData(IOsmRoutingInterpreter interpreter, string embeddedString) { string key = string.Format("Dykstra.Routing.IBasicRouterDataSource<SimpleWeighedEdge>.OSM.{0}", embeddedString); var data = StaticDictionary.Get <IBasicRouterDataSource <LiveEdge> >( key); if (data == null) { var tagsIndex = new TagsTableCollectionIndex(); // do the data processing. var memoryData = new DynamicGraphRouterDataSource <LiveEdge>(tagsIndex); var targetData = new LiveGraphOsmStreamTarget(memoryData, interpreter, tagsIndex); var dataProcessorSource = new XmlOsmStreamSource( Assembly.GetExecutingAssembly().GetManifestResourceStream(embeddedString)); var sorter = new OsmStreamFilterSort(); sorter.RegisterSource(dataProcessorSource); targetData.RegisterSource(sorter); targetData.Pull(); data = memoryData; StaticDictionary.Add <IBasicRouterDataSource <LiveEdge> >(key, data); } return(data); }
public ActionResult EditCustomer(int customerId) { CustomerManagement customerMgr = new CustomerManagement(User.Identity.GetUserId <int>()); List <BCustomer> customers = customerMgr.FindCustomers(User.Identity.GetUserId <int>(), customerId, out total); if (customers == null || customers.Count <= 0) { ViewBag.Message = string.Format("编号为{0}的客户不存在", customerId); return(View("Error")); } BCustomer customer = customers[0]; CreateCustomerModel model = new CreateCustomerModel() { Amount = customer.RemainingAmount, ContactAddress = customer.ContactAddress, ContactEmail = customer.ContactEmail, ContactPeople = customer.ContactPeople, ContactPhone = customer.ContactPhone, CreditAmount = customer.CreditAmount, Description = customer.Description, Id = customer.Id, Name = customer.Name, OpenAccount = customer.OpenId, OpenType = customer.OpenType }; List <DictionaryTemplate> types = StaticDictionary.GetOpenTypeList(); ViewBag.OpenTypes = new SelectList(types, "Id", "Value"); return(View("CreateCustomer", model)); }
/// <summary> /// Builds the data. /// </summary> /// <param name="interpreter"></param> /// <param name="embeddedString"></param> /// <returns></returns> public override IBasicRouterDataSource <CHEdgeData> BuildData(IOsmRoutingInterpreter interpreter, string embeddedString) { string key = string.Format("CHEdgeDifference.Routing.IBasicRouterDataSource<CHEdgeData>.OSM.{0}", embeddedString); var data = StaticDictionary.Get <IBasicRouterDataSource <CHEdgeData> >( key); if (data == null) { var tagsIndex = new TagsTableCollectionIndex(); // do the data processing. var memoryData = new DynamicGraphRouterDataSource <CHEdgeData>(tagsIndex); var targetData = new CHEdgeGraphOsmStreamTarget( memoryData, interpreter, tagsIndex, Vehicle.Car); var dataProcessorSource = new XmlOsmStreamSource( Assembly.GetExecutingAssembly().GetManifestResourceStream(embeddedString)); var sorter = new OsmStreamFilterSort(); sorter.RegisterSource(dataProcessorSource); targetData.RegisterSource(sorter); targetData.Pull(); // do the pre-processing part. var witnessCalculator = new DykstraWitnessCalculator(); var preProcessor = new CHPreProcessor(memoryData, new EdgeDifference(memoryData, witnessCalculator), witnessCalculator); preProcessor.Start(); data = memoryData; StaticDictionary.Add <IBasicRouterDataSource <CHEdgeData> >(key, data); } return(data); }
public ActionResult CreateCustomerActivity(int customerId) { CustomerManagement customerMgr = new CustomerManagement(User.Identity.GetUserId <int>()); List <BCustomer> customers = customerMgr.FindCustomers(User.Identity.GetUserId <int>(), customerId, out total); if (customers.Count == 0) { ViewBag.Message = string.Format("编号为:{0}的客户不是你的客户"); return(View("Error")); } AgentManagement agentMgr = new AgentManagement(customerMgr.CurrentLoginUser); List <BAgentRoute> routes = agentMgr.FindTaocans(0, true); ViewBag.Customer = customers[0]; ViewBag.Routes = new SelectList((from r in routes select new { Id = r.Route.Id, Name = r.Taocan.Taocan2.Name + " - " + (r.Taocan.Taocan.Sale_price * r.Route.Discount).ToString("0.00") + "元" }), "Id", "Name"); List <DictionaryTemplate> scanTypes = StaticDictionary.GetScanTypeList(); ViewBag.ScanTypes = new SelectList(from st in scanTypes select new { Id = st.Id, Name = st.Value }, "Id", "Name"); CustomerActivityModel model = new CustomerActivityModel() { Id = 0, CustomerId = customerId, Enable = true }; return(View(model)); }
public SeedBuildingData() { Buildings = new StaticDictionary<StaticBuilding>(); SeedInfrastructureData(); SeedDefensiveData(); }
public ActionResult ChargeOrders(OrderSearchModel searchModel) { OrderManagement orderMgt = new OrderManagement(User.Identity.GetUserId <int>()); int pageSize = 30; DateTime sDate = DateTime.MinValue; DateTime eDate = DateTime.MinValue; if (!string.IsNullOrEmpty(searchModel.StartTime)) { DateTime.TryParse(searchModel.StartTime, out sDate); } if (!string.IsNullOrEmpty(searchModel.EndTime)) { DateTime.TryParse(searchModel.EndTime, out eDate); } long sintDate = sDate != DateTime.MinValue ? DateTimeUtil.ConvertDateTimeToInt(sDate) : 0; long eintDate = eDate != DateTime.MinValue ? DateTimeUtil.ConvertDateTimeToInt(eDate) : 0; int page = 1; if (Request["page"] != null) { int.TryParse(Request["page"], out page); } searchModel.Page = page; searchModel.AgencyId = User.Identity.GetUserId <int>(); List <BOrder> orders = orderMgt.FindOrders(searchModel.OrderId != null ? (int)searchModel.OrderId : 0, searchModel.AgencyId != null ? (int)searchModel.AgencyId : 0, searchModel.ResourceId != null ? (int)searchModel.ResourceId : 0, searchModel.ResourceTaocanId != null ? (int)searchModel.ResourceTaocanId : 0, searchModel.RuoteId != null ? (int)searchModel.RuoteId : 0, searchModel.SPName, searchModel.MobileNumber, searchModel.Status, sintDate, eintDate, out total, pageSize, searchModel.Page, true); PageItemsResult <BOrder> result = new PageItemsResult <BOrder>() { CurrentPage = searchModel.Page, Items = orders, PageSize = pageSize, TotalRecords = total, EnablePaging = true }; KMBit.Grids.KMGrid <BOrder> grid = new Grids.KMGrid <BOrder>(result); BigOrderSearchModel model = new BigOrderSearchModel() { SearchModel = searchModel, OrderGrid = grid }; List <BResourceTaocan> taocans = new List <BResourceTaocan>(); agentMgt = new AgentManagement(orderMgt.CurrentLoginUser); List <BAgentRoute> routes = agentMgt.FindTaocans(0); taocans = (from r in routes select r.Taocan).ToList <BResourceTaocan>(); ViewBag.Taocans = new SelectList((from t in taocans select new { Id = t.Taocan.Id, Name = t.Taocan2.Name }), "Id", "Name"); ViewBag.StatusList = new SelectList((from s in StaticDictionary.GetChargeStatusList() select new { Id = s.Id, Name = s.Value }), "Id", "Name"); return(View(model)); }
public SeedProvinceData() { Provinces = new StaticDictionary<StaticProvince>(); StaticProvince province; province = AddProvince("Italia", "province_italia"); Provinces.Add(province.TagName, province); }
public SeedProvinceData() { Provinces = new StaticDictionary <StaticProvince>(); StaticProvince province; province = AddProvince("Italia", "province_italia"); Provinces.Add(province.TagName, province); }
public void _01_Bools() { var dic = new StaticDictionary<bool, bool>(new[] {new KeyValuePair<bool, bool>(false, true), new KeyValuePair<bool, bool>(true, false)}); Assert.AreEqual(2, dic.Count); Assert.AreEqual(false, dic[true]); Assert.AreEqual(true, dic[false]); }
public SeedCountryData() { Countries = new StaticDictionary <StaticCountry>(); StaticCountry country; country = AddCountry("Rome", "country_rome"); country = AddCountryProvinces(country, "province_italia"); Countries.Add(country.TagName, country); }
public SeedCountryData() { Countries = new StaticDictionary<StaticCountry>(); StaticCountry country; country = AddCountry("Rome", "country_rome"); country = AddCountryProvinces(country, "province_italia"); Countries.Add(country.TagName, country); }
public ActionResult CreateCustomer() { CreateCustomerModel model = new CreateCustomerModel(); model.Id = 0; List <DictionaryTemplate> types = StaticDictionary.GetOpenTypeList(); ViewBag.OpenTypes = new SelectList(types, "Id", "Value"); model.OpenType = 1; return(View(model)); }
///<summary> /// Обновление информации в выпадающем списке ///</summary> private void UpdateInformation() { if (_typeItemsCollection != null) { _typeItemsCollection.CollectionChanged -= DictionaryCollectionChanged; } if (_type.IsSubclassOf(typeof(AbstractDictionary))) { try { if (GlobalObjects.CasEnvironment != null) { _typeItemsCollection = GlobalObjects.CasEnvironment.GetDictionary(_type); } else { _typeItemsCollection = GlobalObjects.CaaEnvironment.GetDictionary(_type); } } catch (Exception) { _typeItemsCollection = null; } } if (_type.IsSubclassOf(typeof(StaticDictionary))) { try { PropertyInfo p = _type.GetProperty("Items"); ConstructorInfo ci = _type.GetConstructor(new Type[0]); StaticDictionary instance = (StaticDictionary)ci.Invoke(null); _typeItemsCollection = (IDictionaryCollection)p.GetValue(instance, null); } catch (Exception) { _typeItemsCollection = null; } } UpdateItems(); LostFocus += ComboBoxLostFocus; GotFocus += ATAChapterComboBoxGotFocus; if (_typeItemsCollection != null) { _typeItemsCollection.CollectionChanged += DictionaryCollectionChanged; } }
void TestStaticDictionary(ICollection<KeyValuePair<int, int>> data) { var sw = new Stopwatch(); sw.Start(); var dic = new StaticDictionary<int, int>(data); sw.Stop(); Assert.AreEqual(data.Count, dic.Count); var sw2 = new Stopwatch(); sw2.Start(); foreach (var d in data) Assert.AreEqual(d.Value, dic[d.Key]); sw2.Stop(); Console.WriteLine("StaticDictionary: creation=" + sw.Elapsed + ", search=" + sw2.Elapsed); }
public SeedIndustryData() { Industrys = new StaticDictionary <StaticIndustry>(); StaticIndustry industry; industry = AddIndustry("Roma Industry", "industry_roma"); Industrys.Add(industry.TagName, industry); industry = AddIndustry("Velathri Industry", "industry_velathri"); Industrys.Add(industry.TagName, industry); industry = AddIndustry("Ariminum Industry", "industry_ariminum"); Industrys.Add(industry.TagName, industry); }
public SeedPortData() { Ports = new StaticDictionary<StaticPort>(); StaticPort port; port = AddPort("Roma Port", "port_roma"); Ports.Add(port.TagName, port); port = AddPort("Velathri Port", "port_velathri"); Ports.Add(port.TagName, port); port = AddPort("Ariminum Port", "port_ariminum"); Ports.Add(port.TagName, port); }
public SeedFarmData() { Farms = new StaticDictionary<StaticFarm>(); StaticFarm farm; farm = AddFarm("Roma Farm", "farm_roma"); Farms.Add(farm.TagName, farm); farm = AddFarm("Velathri Farm", "farm_velathri"); Farms.Add(farm.TagName, farm); farm = AddFarm("Ariminum Farm", "farm_ariminum"); Farms.Add(farm.TagName, farm); }
public SeedPortData() { Ports = new StaticDictionary <StaticPort>(); StaticPort port; port = AddPort("Roma Port", "port_roma"); Ports.Add(port.TagName, port); port = AddPort("Velathri Port", "port_velathri"); Ports.Add(port.TagName, port); port = AddPort("Ariminum Port", "port_ariminum"); Ports.Add(port.TagName, port); }
public SeedIndustryData() { Industrys = new StaticDictionary<StaticIndustry>(); StaticIndustry industry; industry = AddIndustry("Roma Industry", "industry_roma"); Industrys.Add(industry.TagName, industry); industry = AddIndustry("Velathri Industry", "industry_velathri"); Industrys.Add(industry.TagName, industry); industry = AddIndustry("Ariminum Industry", "industry_ariminum"); Industrys.Add(industry.TagName, industry); }
public SeedFarmData() { Farms = new StaticDictionary <StaticFarm>(); StaticFarm farm; farm = AddFarm("Roma Farm", "farm_roma"); Farms.Add(farm.TagName, farm); farm = AddFarm("Velathri Farm", "farm_velathri"); Farms.Add(farm.TagName, farm); farm = AddFarm("Ariminum Farm", "farm_ariminum"); Farms.Add(farm.TagName, farm); }
public SeedCityData() { Citys = new StaticDictionary <StaticCity>(); StaticCity city; city = AddCity("Roma City", "city_roma"); city = AddBuildingsToCity(city, "building_woodenpalisade"); Citys.Add(city.TagName, city); city = AddCity("Velathri City", "city_velathri"); Citys.Add(city.TagName, city); city = AddCity("Ariminum City", "city_ariminum"); Citys.Add(city.TagName, city); }
public SeedCityData() { Citys = new StaticDictionary<StaticCity>(); StaticCity city; city = AddCity("Roma City", "city_roma"); city = AddBuildingsToCity(city, "building_woodenpalisade"); Citys.Add(city.TagName, city); city = AddCity("Velathri City", "city_velathri"); Citys.Add(city.TagName, city); city = AddCity("Ariminum City", "city_ariminum"); Citys.Add(city.TagName, city); }
protected override void AnimatedThreadWorkerDoWork(object sender, DoWorkEventArgs e) { #region Загрузка элементов InitialDirectiveArray.Clear(); if (ResultDirectiveArray != null) { ResultDirectiveArray.Clear(); } AnimatedThreadWorker.ReportProgress(0, "load directives"); if (ViewedType.IsSubclassOf(typeof(StaticDictionary))) { PropertyInfo p = ViewedType.GetProperty("Items"); ConstructorInfo ci = ViewedType.GetConstructor(new Type[0]); StaticDictionary instance = (StaticDictionary)ci.Invoke(null); InitialDirectiveArray.AddRange((IDictionaryCollection)p.GetValue(instance, null)); InitialDirectiveArray.RemoveById(-1); } else { var dto = (CAADtoAttribute)ViewedType.GetCustomAttributes(typeof(CAADtoAttribute), false).FirstOrDefault(); var res = GlobalObjects.CaaEnvironment.NewLoader.GetObjectList(dto.Type, ViewedType, loadChild: true, filter: _filters); InitialDirectiveArray.AddRange((IEnumerable <IBaseEntityObject>)res); } AnimatedThreadWorker.ReportProgress(40, "filter directives"); #region Фильтрация директив AnimatedThreadWorker.ReportProgress(70, "filter directives"); FilterItems(InitialDirectiveArray, ResultDirectiveArray); if (AnimatedThreadWorker.CancellationPending) { e.Cancel = true; return; } #endregion AnimatedThreadWorker.ReportProgress(100, "Complete"); #endregion }
public SeedInfrastructureData() { Infrastructures = new StaticDictionary <StaticInfrastructure>(); StaticInfrastructure industry; industry = AddInfrastructure("Infra Roma", "infrastructure_roma"); industry = AddInfrastructureBuildings(industry, "building_path", "building_road"); Infrastructures.Add(industry.TagName, industry); industry = AddInfrastructure("Infra Velathri", "infrastructure_velathri"); industry = AddInfrastructureBuildings(industry, "building_path"); Infrastructures.Add(industry.TagName, industry); industry = AddInfrastructure("Infra Ariminum", "infrastructure_ariminum"); industry = AddInfrastructureBuildings(industry, "building_path", "building_road"); Infrastructures.Add(industry.TagName, industry); }
public SeedRegionData() { Regions = new StaticDictionary<StaticRegion>(); StaticRegion region; region = AddRegion("Roma Region", "region_roma", true, "country_rome"); region = AddRegionLocations(region, "city_roma", "farm_roma", "port_roma", "industry_roma", "infrastructure_roma", "province_italia"); Regions.Add(region.TagName, region); region = AddRegion("Velathri Region", "region_velathri", true, "country_rome"); region = AddRegionLocations(region, "city_velathri", "farm_velathri", "port_velathri", "industry_velathri", "infrastructure_velathri", "province_italia"); Regions.Add(region.TagName, region); region = AddRegion("Ariminum Region", "region_ariminum", true, "country_rome"); region = AddRegionLocations(region, "city_ariminum", "farm_ariminum", "port_ariminum", "industry_ariminum", "infrastructure_ariminum", "province_italia"); Regions.Add(region.TagName, region); }
public SeedRegionData() { Regions = new StaticDictionary <StaticRegion>(); StaticRegion region; region = AddRegion("Roma Region", "region_roma", true, "country_rome"); region = AddRegionLocations(region, "city_roma", "farm_roma", "port_roma", "industry_roma", "infrastructure_roma", "province_italia"); Regions.Add(region.TagName, region); region = AddRegion("Velathri Region", "region_velathri", true, "country_rome"); region = AddRegionLocations(region, "city_velathri", "farm_velathri", "port_velathri", "industry_velathri", "infrastructure_velathri", "province_italia"); Regions.Add(region.TagName, region); region = AddRegion("Ariminum Region", "region_ariminum", true, "country_rome"); region = AddRegionLocations(region, "city_ariminum", "farm_ariminum", "port_ariminum", "industry_ariminum", "infrastructure_ariminum", "province_italia"); Regions.Add(region.TagName, region); }
public SeedInfrastructureData() { Infrastructures = new StaticDictionary<StaticInfrastructure>(); StaticInfrastructure industry; industry = AddInfrastructure("Infra Roma", "infrastructure_roma"); industry = AddInfrastructureBuildings(industry, "building_path", "building_road"); Infrastructures.Add(industry.TagName, industry); industry = AddInfrastructure("Infra Velathri", "infrastructure_velathri"); industry = AddInfrastructureBuildings(industry, "building_path"); Infrastructures.Add(industry.TagName, industry); industry = AddInfrastructure("Infra Ariminum", "infrastructure_ariminum"); industry = AddInfrastructureBuildings(industry, "building_path", "building_road"); Infrastructures.Add(industry.TagName, industry); }
protected override void OnParametersSet() { base.OnParametersSet(); if (StaticList is object) { things = StaticList .Select(s => new Tag <T>(s, RemoveItem)) .ToList(); } else if (StaticDictionary is object) { things = StaticDictionary .Select(kvp => new Tag <T>(kvp.Value, RemoveItem) { Label = kvp.Key }) .ToList(); } }
///<summary> /// Обновление информации в выпадающем списке ///</summary> private void UpdateInformation() { if (_typeItemsCollection != null) { _typeItemsCollection.CollectionChanged -= DictionaryCollectionChanged; } buttonEdit.Visible = !_type.IsSubclassOf(typeof(StaticDictionary)); AdjustSizes(); try { if (_type.IsSubclassOf(typeof(StaticDictionary))) { //поиск своиства Items у типа StaticDictionary PropertyInfo p = _type.GetProperty("Items"); ConstructorInfo ci = _type.GetConstructor(new Type[0]); StaticDictionary instance = (StaticDictionary)ci.Invoke(null); _typeItemsCollection = (IDictionaryCollection)p.GetValue(instance, null); } if (_type.IsSubclassOf(typeof(AbstractDictionary))) { _typeItemsCollection = GlobalObjects.CasEnvironment.GetDictionary(_type); } } catch (Exception) { _typeItemsCollection = null; } UpdateItems(); LostFocus += ComboBoxLostFocus; GotFocus += ATAChapterComboBoxGotFocus; if (_typeItemsCollection != null) { _typeItemsCollection.CollectionChanged += DictionaryCollectionChanged; } }
public void Load() { DataDictionary = DataManager.Load <StaticDictionary <T> >(FileName, Application.dataPath); if (DataDictionary == null) { DataDictionary = new StaticDictionary <T>(); } PopupDataList.Add(new PopupData { Id = 0, Name = "Empty", TagName = "empty" }); int count = 1; foreach (var data in DataDictionary.Data) { PopupDataList.Add(new PopupData { Id = count, Name = ((IData)data.Value).Name, TagName = ((IData)data.Value).TagName }); count++; } }
public ActionResult SaveCustomer(CreateCustomerModel model) { if (ModelState.IsValid) { CustomerManagement customerMgr = new CustomerManagement(User.Identity.GetUserId <int>()); BCustomer customer = new BCustomer() { AgentId = User.Identity.GetUserId <int>(), ContactAddress = model.ContactAddress, ContactEmail = model.ContactEmail, ContactPeople = model.ContactPeople, ContactPhone = model.ContactPhone, CreatedTime = DateTimeUtil.ConvertDateTimeToInt(DateTime.Now), CreditAmount = model.CreditAmount, Description = model.Description, Id = model.Id, Name = model.Name, OpenId = model.OpenAccount, OpenType = model.OpenType, RemainingAmount = model.Amount }; try { if (customerMgr.SaveCustomer(customer)) { return(RedirectToAction("Customers")); } }catch (KMBitException ex) { ViewBag.Message = ex.Message; } } List <DictionaryTemplate> types = StaticDictionary.GetOpenTypeList(); ViewBag.OpenTypes = new SelectList(types, "Id", "Value"); return(View("CreateCustomer", model)); }
internal ArmorComponent(Template template) { var d = new Dictionary <string, Part>(); foreach (var locationProtected in template.Defenses) { var resistances = new StaticDictionary <DamageType, int>(locationProtected.Resistances); // check for missing resistances and throws errors foreach (var value in Combat.DamageTypes.Values) { if (!resistances.ContainsKey(value)) { throw new ArgumentException("Resistances is missing a damage type"); } } d.Add(locationProtected.BodyPart, new Part(locationProtected.BodyPart, locationProtected.Coverage, resistances)); } Defenses = new StaticDictionary <string, Part>(d); DonTime = template.DonTime; }
public ActionResult CreateCustomerActivity(CustomerActivityModel model) { if (ModelState.IsValid) { ActivityManagement activityMgr = new ActivityManagement(User.Identity.GetUserId <int>()); Marketing_Activities activity = new Marketing_Activities() { AgentId = User.Identity.GetUserId <int>(), CreatedTime = DateTimeUtil.ConvertDateTimeToInt(DateTime.Now), CustomerId = model.CustomerId, Description = model.Description, ScanType = model.ScanType, Enabled = model.Enable, Name = model.Name, Id = model.Id }; if (model.Id == 0) { activity = activityMgr.CreateNewActivity(activity); if (activity.Id > 0) { return(Redirect("/Agent/CustomerAcivities?customerId=" + model.CustomerId)); } } else { activityMgr.UpdateActivity(activity); return(Redirect("/Agent/CustomerAcivities?customerId=" + model.CustomerId)); } } List <DictionaryTemplate> scanTypes = StaticDictionary.GetScanTypeList(); ViewBag.ScanTypes = new SelectList(from st in scanTypes select new { Id = st.Id, Name = st.Value }, "Id", "Name"); return(View(model)); }
protected override void SetRowCellsValues(DataGridViewRow row, BaseEntityObject item) { AtaChapter ataChapter = null; string title = ""; string description = ""; //string zone = ""; //string access = ""; string taskType = ""; MaintenanceDirectiveProgramType program = MaintenanceDirectiveProgramType.Unknown; StaticDictionary workType = null; //string phase = ""; double manHours = 0; int mans = 0; string categories = ""; double cost = 0; string kits = ""; //Lifelength performance = Lifelength.Null; //Lifelength repeat = Lifelength.Null; //Lifelength remain = Lifelength.Null; //DateTime? performanceDate = null; if (item is NextPerformance) { NextPerformance np = (NextPerformance)item; IEngineeringDirective engineeringDirective = np.Parent as IEngineeringDirective; if (engineeringDirective != null) { ataChapter = engineeringDirective.ATAChapter; //zone = engineeringDirective.Zone; //access = engineeringDirective.Access; program = engineeringDirective.Program; workType = engineeringDirective.WorkType; //phase = engineeringDirective.Phase; manHours = engineeringDirective.ManHours; mans = engineeringDirective.Mans; categories = engineeringDirective.CategoriesRecords.Aggregate("", (current, i) => current + (i.AircraftWorkerCategory + "; ")); cost = engineeringDirective.Cost; } title = np.Title; description = np.Description; taskType = np.Parent.SmartCoreObjectType.ToString(); kits = np.KitsToString; //performance = np.PerformanceSource; //repeat = np.Parent.Threshold != null ? np.Parent.Threshold.RepeatInterval : Lifelength.Null; //remain = np.Remains; //performanceDate = np.PerformanceDate; } else if (item is AbstractPerformanceRecord) { //DirectiveRecord directiveRecord = (DirectiveRecord)item; AbstractPerformanceRecord apr = (AbstractPerformanceRecord)item; IEngineeringDirective engineeringDirective = apr.Parent as IEngineeringDirective; if (engineeringDirective != null) { ataChapter = engineeringDirective.ATAChapter; //zone = engineeringDirective.Zone; //access = engineeringDirective.Access; program = engineeringDirective.Program; workType = engineeringDirective.WorkType; //phase = engineeringDirective.Phase; manHours = engineeringDirective.ManHours; mans = engineeringDirective.Mans; categories = engineeringDirective.CategoriesRecords.Aggregate("", (current, i) => current + (i.AircraftWorkerCategory + "; ")); cost = engineeringDirective.Cost; } title = apr.Title; description = apr.Description; taskType = apr.Parent.SmartCoreObjectType.ToString(); kits = apr.KitsToString; //performance = apr.OnLifelength; //repeat = apr.Parent.Threshold != null ? apr.Parent.Threshold.RepeatInterval : Lifelength.Null; //performanceDate = apr.RecordDate; } else if (item is IEngineeringDirective) { IEngineeringDirective engineeringDirective = item as IEngineeringDirective; ataChapter = engineeringDirective.ATAChapter; //zone = engineeringDirective.Zone; //access = engineeringDirective.Access; program = engineeringDirective.Program; workType = engineeringDirective.WorkType; //phase = engineeringDirective.Phase; manHours = engineeringDirective.ManHours; mans = engineeringDirective.Mans; categories = engineeringDirective.CategoriesRecords.Aggregate("", (current, i) => current + (i.AircraftWorkerCategory + "; ")); cost = engineeringDirective.Cost; title = engineeringDirective.Title; description = engineeringDirective.Description; taskType = engineeringDirective.SmartCoreObjectType.ToString(); kits = engineeringDirective is IKitRequired ? ((IKitRequired)engineeringDirective).Kits.ToString() : ""; //performance = engineeringDirective.NextPerformanceSource; //repeat = engineeringDirective.Threshold != null ? engineeringDirective.Threshold.RepeatInterval : Lifelength.Null; //performanceDate = engineeringDirective.NextPerformanceDate; } //if (performance == null) // performance = Lifelength.Null; //if (repeat == null) // repeat = Lifelength.Null; //if (remain == null) // remain = Lifelength.Null; row.Cells[0].Value = ataChapter != null?ataChapter.ToString() : ""; row.Cells[0].Tag = ataChapter; row.Cells[1].Value = title; row.Cells[1].Tag = title; row.Cells[2].Value = description; row.Cells[2].Tag = description; //row.Cells[3].Value = zone; //row.Cells[3].Tag = zone; //row.Cells[4].Value = access; //row.Cells[4].Tag = access; row.Cells[3].Value = taskType; row.Cells[3].Tag = taskType; row.Cells[4].Value = program.ToString(); row.Cells[4].Tag = program; row.Cells[5].Value = workType != null?workType.ToString() : DirectiveType.Unknown.ToString(); row.Cells[5].Tag = workType != null?workType.ToString() : DirectiveType.Unknown.ToString(); //row.Cells[8].Value = phase; //row.Cells[8].Tag = phase; row.Cells[6].Value = manHours.ToString(); row.Cells[6].Tag = manHours; row.Cells[7].Value = mans.ToString(); row.Cells[7].Tag = mans; row.Cells[8].Value = categories; row.Cells[8].Tag = categories; row.Cells[9].Value = cost.ToString(); row.Cells[9].Tag = cost; row.Cells[10].Value = kits; row.Cells[10].Tag = kits; //row.Cells[14].Value = performance.ToString(); //row.Cells[14].Tag = performance; //row.Cells[15].Value = repeat.ToString(); //row.Cells[15].Tag = repeat; //row.Cells[16].Value = remain.ToString(); //row.Cells[16].Tag = remain.ToString(); //row.Cells[17].Value = performanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)performanceDate); //row.Cells[17].Tag = performanceDate; }
/// <summary> /// Обновляет значения полей /// </summary> public override void FillControls() { BeginUpdate(); if (_typeItemsCollection != null) { _typeItemsCollection.CollectionChanged -= DictionaryCollectionChanged; } checkedListBoxItems.Items.Clear(); checkedListBoxItems.SelectedIndexChanged -= CheckedListBoxItemsSelectedIndexChanged; checkBoxSelectAll.CheckedChanged -= CheckBoxSelectAllCheckedChanged; if (Filter != null) { Type filterType = Filter.GetType(); if (filterType.IsGenericType) { Type genericArgumentType = filterType.GetGenericArguments().FirstOrDefault(); if (genericArgumentType.IsSubclassOf(typeof(AbstractDictionary))) { try { if (GlobalObjects.CasEnvironment != null) { _typeItemsCollection = GlobalObjects.CasEnvironment.GetDictionary(genericArgumentType); } else { _typeItemsCollection = GlobalObjects.CaaEnvironment.GetDictionary(genericArgumentType); } } catch (Exception) { _typeItemsCollection = null; } } if (genericArgumentType.IsSubclassOf(typeof(StaticDictionary))) { try { PropertyInfo p = genericArgumentType.GetProperty("Items"); ConstructorInfo ci = genericArgumentType.GetConstructor(new Type[0]); StaticDictionary instance = (StaticDictionary)ci.Invoke(null); _typeItemsCollection = (IDictionaryCollection)p.GetValue(instance, null); } catch (Exception) { _typeItemsCollection = null; } } } if (_typeItemsCollection != null) { //в CheckListBox добавляются только элементы используемые в фильтруемых //объектах if (_filterValues != null && _filterValues.Length > 0) { foreach (IDictionaryItem dic in _typeItemsCollection.OfType <IDictionaryItem>().Where(i => _filterValues.Contains(i))) { checkedListBoxItems.Items.Add(dic, Filter.Values.Contains(dic)); } int countValidItems = Filter.GetValidValuesCount(); if (countValidItems == 0) { checkBoxSelectAll.CheckState = CheckState.Unchecked; } else if (countValidItems == _filterValues.Length) { checkBoxSelectAll.CheckState = CheckState.Checked; } else { checkBoxSelectAll.CheckState = CheckState.Indeterminate; } } } } checkedListBoxItems.SelectedIndexChanged += CheckedListBoxItemsSelectedIndexChanged; checkBoxSelectAll.CheckedChanged += CheckBoxSelectAllCheckedChanged; if (_typeItemsCollection != null) { _typeItemsCollection.CollectionChanged += DictionaryCollectionChanged; } EndUpdate(); }
public void GetDictionaries() { _casEnvironment.ClearDictionaries(); var assembly = Assembly.GetAssembly(typeof(BaseEntityObject)); var types = assembly.GetTypes() .Where(t => t.Namespace != null && t.IsClass && t.Namespace.StartsWith("SmartCore.Entities.Dictionaries")); var staticDictionaryType = types.Where(t => t.IsSubclassOf(typeof(StaticDictionary)) && t.GetCustomAttributes(typeof(TableAttribute), false).Length > 0).ToList(); foreach (var type in staticDictionaryType) { try { string qr = BaseQueries.GetSelectQueryWithWhere(type, loadChild: true); DataSet ds = _casEnvironment.Execute(qr); //поиск в типе своиства Items PropertyInfo itemsProp = type.GetProperty("Items"); //поиск у типа конструктора беза параметров ConstructorInfo ci = type.GetConstructor(new Type[0]); //создание экземпляра статического словаря //(при этом будут созданы все его статические элементы, // которые будут доступны через статическое своиство Items) StaticDictionary instance = (StaticDictionary)ci.Invoke(null); //Получение элементов статического своиства Items IEnumerable staticList = (IEnumerable)itemsProp.GetValue(instance, null); BaseQueries.SetFields(staticList, ds); } catch (Exception) { continue; //throw ex; } } var abstractDictionaryTypes = types.Where(t => t.IsSubclassOf(typeof(AbstractDictionary)) && !t.IsAbstract) .ToList(); //коллекция дл типов, которые не удалось загрузить сразу //по причине отсутствия другого словаря в коллекции словарей ядра var defferedTypes = new List <Type>(); foreach (var type in abstractDictionaryTypes) { try { var dca = (DictionaryCollectionAttribute)type.GetCustomAttributes(typeof(DictionaryCollectionAttribute), false).FirstOrDefault(); var bl = (DtoAttribute)type.GetCustomAttributes(typeof(DtoAttribute), false).FirstOrDefault(); var typeDict = dca == null ? new CommonDictionaryCollection <AbstractDictionary>() : dca.GetInstance(); IEnumerable items = GetObjectList(bl.Type, type, true); typeDict.AddRange((IEnumerable <IDictionaryItem>)items); _casEnvironment.AddDictionary(type, typeDict); } catch (KeyNotFoundException) { defferedTypes.Add(type); continue; } catch (Exception) { continue; //throw ex; } } //Повторная попытка загрузить типы данных, которые не удалось загрузить с первого раза foreach (var type in defferedTypes) { try { var dca = (DictionaryCollectionAttribute)type.GetCustomAttributes(typeof(DictionaryCollectionAttribute), false).FirstOrDefault(); var bl = (DtoAttribute)type.GetCustomAttributes(typeof(DtoAttribute), false).FirstOrDefault(); var typeDict = dca == null ? new CommonDictionaryCollection <AbstractDictionary>() : dca.GetInstance(); IEnumerable items = GetObjectList(bl.Type, type, true); typeDict.AddRange((IEnumerable <IDictionaryItem>)items); _casEnvironment.AddDictionary(type, typeDict); } catch (Exception) { continue; //throw ex; } } }
/// <summary> /// Устанавливает заголовки /// </summary> protected virtual void SetHeaders() { if (!(itemsListView.View is GridView)) { itemsListView.View = new GridView(); } ColumnHeaderList.Clear(); try { List <PropertyInfo> properties = GetTypeProperties(); GridViewColumn columnHeader; foreach (PropertyInfo propertyInfo in properties) { ListViewDataAttribute attr = (ListViewDataAttribute)propertyInfo.GetCustomAttributes(typeof(ListViewDataAttribute), false)[0]; #region Определение ЭУ if (propertyInfo.PropertyType.IsSubclassOf(typeof(StaticDictionary))) { //object val = propertyInfo.GetValue(obj, null); //if (propertyInfo.PropertyType.GetCustomAttributes(typeof(TableAttribute), false).Length > 0) //{ // DictionaryComboBox dc = new DictionaryComboBox // { // Enabled = controlEnabled, // Name = propertyInfo.Name, // SelectedItem = (StaticDictionary)val, // Tag = propertyInfo, // Type = propertyInfo.PropertyType, // }; // //для возможности вызова новой вкладки // Program.MainDispatcher.ProcessControl(dc); // // // return dc; //} Type t = propertyInfo.PropertyType; PropertyInfo p = t.GetProperty("Items"); ConstructorInfo ci = t.GetConstructor(new Type[0]); StaticDictionary instance = (StaticDictionary)ci.Invoke(null); IEnumerable staticList = (IEnumerable)p.GetValue(instance, null); DataTemplate template = new DataTemplate(); FrameworkElementFactory factory = new FrameworkElementFactory(typeof(System.Windows.Controls.ComboBox)); template.VisualTree = factory; //System.Windows.Data.Binding sourceBinding = new System.Windows.Data.Binding(); //sourceBinding.Source = staticList; //BindingOperations.SetBinding(taskItemListView, ListView.ItemsSourceProperty, sourceBinding ); factory.SetBinding(ItemsControl.ItemsSourceProperty, new System.Windows.Data.Binding { Source = staticList }); //childFactory = new FrameworkElementFactory(typeof(Label)); //childFactory.SetBinding(Label.ContentProperty, new Binding("Machine.Descriiption")); //childFactory.SetValue(Label.WidthProperty, 170.0); //childFactory.SetValue(Label.HorizontalAlignmentProperty, HorizontalAlignment.Center); //factory.AppendChild(childFactory); columnHeader = new GridViewColumn { CellTemplate = template }; } else if (propertyInfo.PropertyType.IsSubclassOf(typeof(AbstractDictionary))) { IDictionaryCollection dc; try { dc = GlobalObjects.CasEnvironment.Dictionaries[propertyInfo.PropertyType]; } catch (Exception) { dc = null; } DataTemplate template = new DataTemplate(); FrameworkElementFactory factory = new FrameworkElementFactory(typeof(System.Windows.Controls.ComboBox)); template.VisualTree = factory; //System.Windows.Data.Binding sourceBinding = new System.Windows.Data.Binding(); //sourceBinding.Source = staticList; //BindingOperations.SetBinding(taskItemListView, ListView.ItemsSourceProperty, sourceBinding ); if (dc != null) { List <KeyValuePair <string, IDictionaryItem> > list = new List <KeyValuePair <string, IDictionaryItem> >(); foreach (IDictionaryItem item in dc) { list.Add(new KeyValuePair <string, IDictionaryItem>(item.ToString(), item)); } factory.SetBinding(ItemsControl.ItemsSourceProperty, new System.Windows.Data.Binding { Source = list }); factory.SetBinding(ItemsControl.DisplayMemberPathProperty, new System.Windows.Data.Binding("Key")); factory.SetBinding(ItemsControl.ItemsSourceProperty, new System.Windows.Data.Binding("Value")); } columnHeader = new GridViewColumn { CellTemplate = template }; //AbstractDictionary val = (AbstractDictionary)propertyInfo.GetValue(obj, null); //DictionaryComboBox dc = new DictionaryComboBox //{ // Enabled = controlEnabled, // SelectedItem = val, // Tag = propertyInfo, // Type = propertyInfo.PropertyType, //}; //для возможности вызова новой вкладки //Program.MainDispatcher.ProcessControl(dc); // //return dc; } else if (propertyInfo.PropertyType.IsSubclassOf(typeof(BaseEntityObject))) { DataTemplate template = new DataTemplate(); FrameworkElementFactory factory = new FrameworkElementFactory(typeof(System.Windows.Controls.TextBox)); factory.SetValue(System.Windows.Controls.TextBox.TextWrappingProperty, TextWrapping.Wrap); factory.SetValue(TextBoxBase.IsReadOnlyProperty, true); factory.SetBinding(System.Windows.Controls.TextBox.TextProperty, new System.Windows.Data.Binding { Source = list }); template.VisualTree = factory; columnHeader = new GridViewColumn { CellTemplate = template }; } else if (propertyInfo.PropertyType.IsEnum) { DataTemplate template = new DataTemplate(); FrameworkElementFactory factory = new FrameworkElementFactory(typeof(System.Windows.Controls.ComboBox)); template.VisualTree = factory; List <KeyValuePair <string, object> > list = new List <KeyValuePair <string, object> >(); foreach (object o in Enum.GetValues(propertyInfo.PropertyType)) { string name = Enum.GetName(propertyInfo.PropertyType, o); string desc = name; FieldInfo fi = propertyInfo.PropertyType.GetField(name); DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false); if (attributes.Length > 0) { string s = attributes[0].Description; if (!string.IsNullOrEmpty(s)) { desc = s; } } list.Add(new KeyValuePair <string, object>(desc, o)); } factory.SetBinding(ItemsControl.ItemsSourceProperty, new System.Windows.Data.Binding { Source = list }); factory.SetBinding(ItemsControl.DisplayMemberPathProperty, new System.Windows.Data.Binding("Key")); factory.SetBinding(ItemsControl.ItemsSourceProperty, new System.Windows.Data.Binding("Value")); columnHeader = new GridViewColumn { CellTemplate = template }; } else { #region ЭУ для базовых типов string typeName = propertyInfo.PropertyType.Name.ToLower(); switch (typeName) { case "string": { DataTemplate template = new DataTemplate(); FrameworkElementFactory factory = new FrameworkElementFactory(typeof(System.Windows.Controls.TextBox)); factory.SetValue(System.Windows.Controls.TextBox.TextWrappingProperty, TextWrapping.Wrap); factory.SetValue(TextBoxBase.IsReadOnlyProperty, true); template.VisualTree = factory; columnHeader = new GridViewColumn { CellTemplate = template }; break; } case "int32": case "int16": { DataTemplate template = new DataTemplate(); FrameworkElementFactory factory = new FrameworkElementFactory(typeof(System.Windows.Controls.TextBox)); factory.SetValue(System.Windows.Controls.TextBox.TextWrappingProperty, TextWrapping.Wrap); factory.SetValue(TextBoxBase.IsReadOnlyProperty, true); template.VisualTree = factory; columnHeader = new GridViewColumn { CellTemplate = template }; break; } case "datetime": { DataTemplate template = new DataTemplate(); FrameworkElementFactory factory = new FrameworkElementFactory(typeof(System.Windows.Controls.TextBox)); factory.SetValue(System.Windows.Controls.TextBox.TextWrappingProperty, TextWrapping.Wrap); factory.SetValue(TextBoxBase.IsReadOnlyProperty, true); template.VisualTree = factory; columnHeader = new GridViewColumn { CellTemplate = template }; break; } case "bool": case "boolean": { DataTemplate template = new DataTemplate(); FrameworkElementFactory factory = new FrameworkElementFactory(typeof(System.Windows.Controls.CheckBox)); template.VisualTree = factory; columnHeader = new GridViewColumn { CellTemplate = template }; break; } case "double": { DataTemplate template = new DataTemplate(); FrameworkElementFactory factory = new FrameworkElementFactory(typeof(System.Windows.Controls.TextBox)); factory.SetValue(System.Windows.Controls.TextBox.TextWrappingProperty, TextWrapping.Wrap); factory.SetValue(TextBoxBase.IsReadOnlyProperty, true); template.VisualTree = factory; columnHeader = new GridViewColumn { CellTemplate = template }; break; } //case "directivethreshold": // { // object val = propertyInfo.GetValue(obj, null); // return new DirectiveThresholdControl { Enabled = controlEnabled, Threshold = (DirectiveThreshold)val, Tag = propertyInfo }; // } //case "detaildirectivethreshold": // { // object val = propertyInfo.GetValue(obj, null); // return new DetailDirectiveThresholdControl { Enabled = controlEnabled, Threshold = (DetailDirectiveThreshold)val, Tag = propertyInfo }; // } //case "lifelength": // { // object val = propertyInfo.GetValue(obj, null); // return new LifelengthViewer // { // Enabled = controlEnabled, // Lifelength = (Lifelength)val, // MinimumSize = new Size(20, 17), // Tag = propertyInfo // }; // } default: columnHeader = null; break; } #endregion } #endregion if (columnHeader == null) { continue; } columnHeader.Width = (int)(attr.HeaderWidth < 1 ? itemsListView.Width * attr.HeaderWidth : attr.HeaderWidth); columnHeader.Header = attr.Title; //columnHeader.Tag = propertyInfo; //Поиск NotNullAttribute для определения возможности задавать пустые значения в колонке //NotNullAttribute notNullAttribute = // (NotNullAttribute)propertyInfo.GetCustomAttributes(typeof(NotNullAttribute), false).FirstOrDefault(); //if (notNullAttribute != null) //{ // //Если имеется атрибут NotNullAttribute то шрифт заголовка задается Жирным // columnHeader.HeaderCell.Style.Font = new Font(dataGridView.ColumnHeadersDefaultCellStyle.Font, FontStyle.Bold); // columnHeader.HeaderCell.ToolTipText = // string.Format("The cells in column {0} should be filled", columnHeader.HeaderText); //} ColumnHeaderList.Add(columnHeader); } } catch (Exception ex) { Program.Provider.Logger.Log("Error while building list headers", ex); return; } }
private Equipable(StaticDictionary <string, IEnumerable <string> > slotsOccupied) { SlotsOccupied = slotsOccupied; }