public static object SaveRegion(Region scParam) { object data = new { }; Region item = new Region(); item.RegionID = scParam.RegionID; item.RegionEn = scParam.RegionEn; item.RegionAr = scParam.RegionAr; item.RegionCommissionJor = scParam.RegionCommissionJor; bool status = new RegionsManager().SaveRegion(item); if ((item.RegionEn != null && item.RegionAr != null) || status) { HttpContext.Current.Cache.Remove("Regions"); data = new { Status = true, Message = Resources.AdminResources_ar.SuccessSave }; } else { data = new { Status = false, Message = Resources.AdminResources_ar.ErrorSave } }; return(data); } #endregion }
private void TabEditCustomer_GotFocus(object sender, RoutedEventArgs e) { if (DGCustomerView.SelectedItem == null) { lblCustomerError.Content = "Please select a customer first from above grid"; TabViewCustomer.Focus(); switchCanvas("Active"); return; } lblCustomerError.Content = ""; RegionsManager regionsManager = new RegionsManager(); regions = regionsManager.retrieveAllRegions(); ComboCustomerEditRegionID.Items.Clear(); foreach (var item in regions) { ComboCustomerEditRegionID.Items.Add(item.RegionId); } switchCanvas("Edit"); oldCustomer = (Customer)DGCustomerView.SelectedItem; txtCustomerEditFirstName.Text = oldCustomer.FirstName; txtCustomerEditMIDName.Text = oldCustomer.MiddleName; txtCustomerEditLastName.Text = oldCustomer.LastName; txtCustomerEditPhoneNumber.Text = oldCustomer.PhoneNumber; txtCustomerEditEmail.Text = oldCustomer.Email; txtCustomerEditRegionID.Text = oldCustomer.RegionID; txtCustomerEditAddressLine.Text = oldCustomer.AddressLine; chkCustomerEditActive.IsChecked = oldCustomer.Active; }
//public double GetSumOfAllXCellFuzzyOutputs() //{ // var sum = 0.0; // foreach(var xCellFuzzy in ListOfXCellFuzzy) // { // sum += xCellFuzzy.OutputFuzzyValue; // } // return sum; //} //public override void GetInputData() //Diastole //{ // if(this.ListOfInputChannels.Count>0) // { // IN = ListOfInputChannels[0].Aij; // var lowerLimit = IN - RegionsManager.r; // var upperLimit = IN + RegionsManager.r; // if (RegionsManager.TryToAddANewRegion(lowerLimit, upperLimit))//RegionsManager.CheckIfRegionIsAvailable(lowerLimit, upperLimit)) // { // var xCellFuzzyNew = new XCellFuzzy($"{lowerLimit}<{Id}<{upperLimit}", Layer, RegionsManager.R); // xCellFuzzyNew.ListOfInputChannels.Add(ListOfInputChannels[0]); // //RegionsManager.TryToAddANewRegion(lowerLimit, upperLimit); // ListOfXCellFuzzy.Add(xCellFuzzyNew); // //xCellFuzzyNew.GetInputData(); // //Recalculate_r(); // } // foreach (var xCellFuzzy in ListOfXCellFuzzy) // { // xCellFuzzy.GetInputData(); // xCellFuzzy.SendOutputData(); // } // } //} //public override void SendOutputData() //Systole //{ // //var lowerLimit = IN - RegionsManager.r; // //var upperLimit = IN + RegionsManager.r; // //if (RegionsManager.TryToAddANewRegion(lowerLimit, upperLimit))//RegionsManager.CheckIfRegionIsAvailable(lowerLimit, upperLimit)) // //{ // // var xCellFuzzyNew = new XCellFuzzy($"{lowerLimit}<{Id}<{upperLimit}", Layer, RegionsManager.R); // // xCellFuzzyNew.ListOfInputChannels.Add(ListOfInputChannels[0]); // // //RegionsManager.TryToAddANewRegion(lowerLimit, upperLimit); // // ListOfXCellFuzzy.Add(xCellFuzzyNew); // // //xCellFuzzyNew.GetInputData(); // // //Recalculate_r(); // //} // //foreach (var xCellFuzzy in ListOfXCellFuzzy) // //{ // // xCellFuzzy.GetInputData(); // // xCellFuzzy.SendOutputData(); // //} // XCellFuzzy xCellFuzzyWithGreaterOutput = null; // double greaterOutput = 0; // foreach (var xCellFuzzy in ListOfXCellFuzzy.Where(xCellFuzz => xCellFuzz.ListOfOutputChannels[0].IsActive && xCellFuzz.ListOfOutputChannels[0].Aij > 0)) // { // if (!ORExplodeLayer.ListOfXCellsOrExplode.Any(xCellORExplode => xCellORExplode.Id == xCellFuzzy.Id)) // { // var xCellOrExplode = new XCellORExplode(xCellFuzzy.Id, this.Layer); // ORExplodeLayer.ListOfXCellsOrExplode.Add(xCellOrExplode); // ORExplodeLayer.ListOfInputChannels.Add(xCellFuzzy.ListOfOutputChannels[0]); // } // if (xCellFuzzy.ListOfOutputChannels[0].Aij > greaterOutput) // { // greaterOutput = xCellFuzzy.ListOfOutputChannels[0].Aij; // xCellFuzzyWithGreaterOutput = xCellFuzzy; // } // } // if (xCellFuzzyWithGreaterOutput != null) // { // var outputChannelFound = ListOfOutputChannels.FirstOrDefault(outputChannel => outputChannel.XCellOrigin.Id == xCellFuzzyWithGreaterOutput.Id); // if (outputChannelFound == null) // { // ListOfOutputChannels.Add(xCellFuzzyWithGreaterOutput.ListOfOutputChannels[0]); // } // } //} public override void GetInputData() //Diastole { if (this.ListOfInputChannels.Count > 0) { IN = ListOfInputChannels[0].Aij; var lowerLimit = IN - RegionsManager.r; var upperLimit = IN + RegionsManager.r; if (RegionsManager.TryToAddANewRegion(lowerLimit, upperLimit))//RegionsManager.CheckIfRegionIsAvailable(lowerLimit, upperLimit)) { var xCellFuzzyNew = new XCellFuzzy($"{lowerLimit}<{Id}<{upperLimit}", Layer, RegionsManager.R); xCellFuzzyNew.ListOfInputChannels.Add(ListOfInputChannels[0]); //RegionsManager.TryToAddANewRegion(lowerLimit, upperLimit); ListOfXCellFuzzy.Add(xCellFuzzyNew); //xCellFuzzyNew.GetInputData(); //Recalculate_r(); } foreach (var xCellFuzzy in ListOfXCellFuzzy) { xCellFuzzy.GetInputData(); xCellFuzzy.SendOutputData(); } } }
public void RegionsRedisCache() { var manager = new RegionsManager(new RegionsRedisCache("localhost,abortConnect=false,syncTimeout=3000")); for (var i = 0; i < 10; i++) { Console.WriteLine(manager.GetRegions().Count()); Thread.Sleep(100); } }
public void RegionsMemoryCache() { var manager = new RegionsManager(new RegionsCache()); for (var i = 0; i < 10; i++) { Console.WriteLine(manager.GetRegions().Count()); Thread.Sleep(100); } }
public void RegionsPolicyMemoryCache() { var query = "select * from category"; var regionManager = new RegionsManager(new RegionsMemoryCache(), query); var categCnt = 4; for (var i = 0; i < 10; i++) { Assert.AreEqual(categCnt, regionManager.GetRegions().Count()); Thread.Sleep(100); } }
private void TabAddCustomer_GotFocus(object sender, RoutedEventArgs e) { //we need to retrieve regionsIds. So, the entry can choose the region from //drop list RegionsManagerInterface regionsManager = new RegionsManager(); List <Region> regions = regionsManager.retrieveAllRegions(); foreach (var item in regions) { comboCustomerAddRegionID.Items.Add(item.RegionId); } TabAddCustomer.Focus(); switchCanvas("Add"); }
private void DeleteItem(int _ID) { // Execute delete func. var childIds = new RegionsManager().DeleteRegion(_ID); if (childIds) // deleted. { lblError.Text = Resources.AdminResources_en.SuccessDelete; // success deleted. } else { lblError.Text = Resources.AdminResources_en.ErrorDelete; } }
private void ShowRegionInformation(int Id) { var result = new RegionsManager().GetRegionDetails(Id); if (result != null) { //hfID.Value = result.RegionID.ToString(); txtNameEn.Text = result.RegionEn; txtNameAr.Text = result.RegionAr; cbActive.Checked = (bool)result.Active; ddlAuctions.SelectedValue = result.Auction_ID.ToString(); txtPriority.Text = result.Priority.ToString(); } }
private void updateCustomersLists() { customers.Clear(); activeCustomers.Clear(); deactiveCustomers.Clear(); customers = customersManager.GetAllCustomers(); foreach (Customer customer in customers) { if (customer.Active == true) { activeCustomers.Add(customer); } else { deactiveCustomers.Add(customer); } } RegionsManager regionsManager = new RegionsManager(); regions = regionsManager.retrieveAllRegions(); }
/// <summary> /// on click on Insert buttom, we hid all other canvases and let /// Canvas of customerAdd to pop up /// </summary> /// <remarks> /// created by Awaab Elamin on 5/21/2020 /// </remarks> /// <param name="sender"></param> /// <param name="e"></param> private void btnCustomerInsert_Click(object sender, RoutedEventArgs e) { //we need to retrieve regionsIds. So, the entry can choose the region from //drop list RegionsManagerInterface regionsManager = new RegionsManager(); List <Region> regions = regionsManager.retrieveAllRegions(); foreach (var item in regions) { comboCustomerAddRegionID.Items.Add(item.RegionId); } CanViewAllCustomer.Visibility = Visibility.Hidden; CanCustomerAdd.Visibility = Visibility.Visible; TabAddCustomer.Focus(); //if (DGCustomerView.SelectedItem == null) //{ // lblCustomerError.Content = "AWaab"; // return; //} //Customer customer = (Customer)DGCustomerView.SelectedItem; //lblCustomerError.Content = ""; }
//TODO: remove hack public void SetManager(RegionsManager manager) { _manager = manager; }
public void SetUp() { _mock = new Mock <IRegionsHttpClient>(); _manager = new RegionsManager(_mock.Object); }
public BeginSliceRegionsCommand(RegionsManager manager) { _manager = manager; }
//private uint _lastMappedInputValue; public XCellFuzzyMaster(string id, Layer layer, uint R) : base(id, layer) { RegionsManager = new RegionsManager(R); ListOfXCellFuzzy = new List <XCellFuzzy>(); ORExplodeLayer = new ORExplodeLayer(); }
/// <summary> /// 数据库实例 /// </summary> /// <param name="manager">区域数据库操作实例</param> public RegionsController(RegionsManager manager) { _manager = manager; }
public static object GetRegions() { jQueryDataTableParamModel param = new jQueryDataTableParamModel(); HttpContext Context = HttpContext.Current; param.sEcho = String.IsNullOrEmpty(Context.Request["sEcho"]) ? 0 : Convert.ToInt32(Context.Request["sEcho"]); param.sSearch = String.IsNullOrEmpty(Context.Request["sSearch"]) ? "" : Context.Request["sSearch"]; param.iDisplayStart = String.IsNullOrEmpty(Context.Request["iDisplayStart"]) ? 0 : Convert.ToInt32(Context.Request["iDisplayStart"]); param.iDisplayLength = String.IsNullOrEmpty(Context.Request["iDisplayLength"]) ? 0 : Convert.ToInt32(Context.Request["iDisplayLength"]); var sortColumnIndex = Convert.ToInt32(Context.Request["iSortCol_0"]); var sortDirection = Context.Request["sSortDir_0"]; // asc or desc List <Regions_SelectRowResult> categoryList = new List <Regions_SelectRowResult>(); IEnumerable <Regions_SelectRowResult> filtereRegions; if (HttpContext.Current.Cache["Regions"] == null) { categoryList = new RegionsManager().GetRegions(""); HttpContext.Current.Cache.Insert("Regions", categoryList, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(10)); } else { categoryList = HttpContext.Current.Cache["Regions"] as List <Regions_SelectRowResult>; } // check for search param if (!String.IsNullOrEmpty(param.sSearch)) { filtereRegions = categoryList.Where(c => c.RegionEn.ToLower().Contains(param.sSearch.ToLower()) || c.RegionAr.ToLower().Contains(param.sSearch.ToLower())); } else { filtereRegions = categoryList; } // handle asc and desc operation Func <Regions_SelectRowResult, string> orderingFunction = (c => sortColumnIndex == 1 ? c.RegionEn : sortColumnIndex == 2 ? c.RegionAr.ToString() : ""); if (sortDirection == "asc") { filtereRegions = filtereRegions.OrderBy(orderingFunction); } else { filtereRegions = filtereRegions.OrderByDescending(orderingFunction); } //paginate our result var result = filtereRegions.Select(c => new { RegionID = c.RegionID, RegionEn = c.RegionEn, RegionAr = c.RegionAr, RegionCommissionJor = c.RegionCommissionJor }).Skip(param.iDisplayStart).Take(param.iDisplayLength); // Our last var data = new { sEcho = param.sEcho, iTotalRecords = categoryList.Count(), iTotalDisplayRecords = filtereRegions.Count(), aaData = result }; return(data); }