// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { CustomerCache.Initialize(); //initializes the Solana customer databases RegisterDependencies(services); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "Solana Web API Documentation", Version = "v1" }); var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); c.CustomSchemaIds(x => x.FullName); c.IncludeXmlComments(xmlPath); c.OperationFilter <SolanaHeadersOperationFilter>(); }); services.AddAutoMapper( config => config.ValidateInlineMaps = false, //this disables Destination members validation (i.e. Destination members do not all have to be mapped from Source) Assembly.GetAssembly(typeof(AdmUserMappingProfile))); ConfigureJwtAuth(services); }
public void Save() { System.Diagnostics.Trace.WriteLine("Starting to save New Customer"); //foreach (Customer c in this.context.Customers) //{ // this.context.Customers.Remove(c); //} foreach (Customer c in CustomerCache) { if (this.context.Customers.Find(c.ID) == null) { this.context.Customers.Add(c); } } foreach (Customer c in this.context.Customers) { if (CustomerCache.Find(Customer => Customer.ID == c.ID) == null) { this.context.Customers.Remove(c); } } this.context.SaveChanges(); }
public JobUnitAppService(JobUnitManager jobUnitManager, IRepository <JobUnit> jobUnitRepository, IRepository <JobCommercialUnit> jobDetailUnitRepository, IRepository <EmployeeUnit> employeeUnitRepository, IRepository <CustomerUnit> customerUnitRepository, IJobCommercialAppService jobCommercialAppService, IRepository <OrganizationUnit, long> organizationUnitRepository, IRepository <JobAccountUnit, long> jobAccountUnitRepository, IRepository <CoaUnit> coaUnitRepository, IRepository <AccountUnit, long> accountUnitRepository, IRepository <ValueAddedTaxRecoveryUnit> valueAddedTaxRecoveryUnitRepository, IRepository <ValueAddedTaxTypeUnit> valueAddedTaxTypeUnitRepository, IRepository <TypeOfCountryUnit, short> typeOfCountryUnitRepository, IRepository <CountryUnit> countryUnitRepository, IJobAccountUnitAppService jobAccountUnitAppService, IRepository <TaxCreditUnit> taxCreditUnitRepository, ICacheManager cacheManager, CustomAppSession customAppSession, IUnitOfWorkManager unitOfWorkManager, IRepository <JobLocationUnit> jobLocationRepository, DivisionCache divisioncache, AccountCache accountcache, CustomerCache customercache, ICustomJobAccountRepository jobAccountRepository) { _jobUnitManager = jobUnitManager; _jobUnitRepository = jobUnitRepository; _jobDetailUnitRepository = jobDetailUnitRepository; _employeeUnitRepository = employeeUnitRepository; _customerUnitRepository = customerUnitRepository; _jobCommercialAppService = jobCommercialAppService; _organizationUnitRepository = organizationUnitRepository; _coaUnitRepository = coaUnitRepository; _accountUnitRepository = accountUnitRepository; _jobAccountUnitRepository = jobAccountUnitRepository; _valueAddedTaxRecoveryUnitRepository = valueAddedTaxRecoveryUnitRepository; _valueAddedTaxTypeUnitRepository = valueAddedTaxTypeUnitRepository; _typeOfCountryUnitRepository = typeOfCountryUnitRepository; _countryUnitRepository = countryUnitRepository; _jobAccountUnitAppService = jobAccountUnitAppService; _taxCreditUnitRepository = taxCreditUnitRepository; _cacheManager = cacheManager; _customAppSession = customAppSession; _unitOfWorkManager = unitOfWorkManager; _jobLocationRepository = jobLocationRepository; _divisioncache = divisioncache; _accountcache = accountcache; _customercache = customercache; _jobAccountRepository = jobAccountRepository; }
private void printCustomerInformation(PrintPageEventArgs e) { CustomerCache cache = null; Dictionary<CustomerCacheSearchKey, string> searchParam = new Dictionary<CustomerCacheSearchKey, string>(); if (!string.IsNullOrEmpty(currVehicle.GetValue(PropertyId.SaleCustomerId))) { searchParam.Add(CustomerCacheSearchKey.Id, currVehicle.GetValue(PropertyId.SaleCustomerId)); cache = new CustomerCache(searchParam); } if (cache == null || cache.Count <= 0) return; using (Font font = new Font("Calibri (Body)", 10)) { CustomerAdminObject customer = cache[0]; e.Graphics.DrawString(customer.FirstName, font, Brushes.Black, backgroundXPos + 90, backgroundYPos + 115); e.Graphics.DrawString(customer.LastName, font, Brushes.Black, backgroundXPos + 280, backgroundYPos + 115); string address = ""; if (string.IsNullOrEmpty(customer.GetValue(PropertyId.HomeUnitNumber))) { address = string.Format("{0} {1}", customer.GetValue(PropertyId.HomeStreetNumber), customer.GetValue(PropertyId.HomeStreet)); } else { address = string.Format("{0} - {1} {2}", customer.GetValue(PropertyId.HomeUnitNumber), customer.GetValue(PropertyId.HomeStreetNumber), customer.GetValue(PropertyId.HomeStreet)); } e.Graphics.DrawString(address, font, Brushes.Black, backgroundXPos + 30, backgroundYPos + 145); e.Graphics.DrawString(customer.GetValue(PropertyId.HomeCity), font, Brushes.Black, backgroundXPos + 30, backgroundYPos + 170); e.Graphics.DrawString(customer.GetValue(PropertyId.HomeProvince), font, Brushes.Black, backgroundXPos + 220, backgroundYPos + 170); e.Graphics.DrawString(customer.GetValue(PropertyId.HomePostalCode), font, Brushes.Black, backgroundXPos + 330, backgroundYPos + 170); //Print phone number if (string.IsNullOrEmpty(customer.GetValue(PropertyId.MobilePhone))) { e.Graphics.DrawString(customer.GetValue(PropertyId.HomePhone), font, Brushes.Black, backgroundXPos + 30, backgroundYPos + 200); } else { e.Graphics.DrawString(customer.GetValue(PropertyId.MobilePhone) + " (cell)", font, Brushes.Black, backgroundXPos + 30, backgroundYPos + 200); } e.Graphics.DrawString(customer.GetValue(PropertyId.DriversLicense), font, Brushes.Black, backgroundXPos + 65, backgroundYPos + 225); e.Graphics.DrawString(customer.GetValue(PropertyId.LicenseExpiry), font, Brushes.Black, backgroundXPos + 315, backgroundYPos + 225); } }
private void ProjectViewNewProjectClickHandler(ProjectsViewModel viewModel) { TextblockPanelName.Text = "Create New Project"; RoleCache.GetInstance().Clear(); EmployeeCache.GetInstance().Clear(); ResourceCache.GetInstance().Clear(); CustomerCache.GetInstance().Clear(); ProcessCache.GetInstance().Clear(); ProjectCache.GetInstance().Clear(); var resources = ResourceCache.GetInstance().Resources; resources = ResourceCache.GetInstance().UpdateAllQSizes(); DataContext = new AddEditProjectViewModel { Project = new Project { Id = 0, Processes = new List <Process>(), StartDate = DateTimeOffset.UtcNow, PoDate = DateTimeOffset.UtcNow, Quantity = 1, OrderStatus = Project.ProjectOrderStatus.WaitingQuote, }, BackClickedHandler = AddEditProjectViewBackClickHandler, Customers = CustomerCache.GetInstance().Customers, Processes = new ObservableCollection <Process>(new List <Process>()), Resources = resources.OrderByDescending(r => r.QSize).ToList <Resource>(), Employees = EmployeeCache.GetInstance().Employees }; }
private void ButtonDashboard_Click(object sender, RoutedEventArgs e) { TextblockPanelName.Text = "Dashboard"; RoleCache.GetInstance().Clear(); EmployeeCache.GetInstance().Clear(); ResourceCache.GetInstance().Clear(); CustomerCache.GetInstance().Clear(); ProcessCache.GetInstance().Clear(); ProjectCache.GetInstance().Clear(); List <Resource> recs = ResourceCache.GetInstance().Resources; recs = ResourceCache.GetInstance().UpdateAllQSizes(); recs = recs.OrderByDescending(r => r.QSize).ToList <Resource>(); var emps = EmployeeCache.GetInstance().Employees; emps = EmployeeCache.GetInstance().UpdateAllQSizes(); emps = emps.OrderByDescending(e => e.QSize).ToList <Employee>(); DataContext = new DashboardViewModel { Resources = new ObservableCollection <Resource>(recs), SelectedResource = recs[0], Employees = new ObservableCollection <Employee>(emps), SelectedEmployee = emps[0] }; }
public static void PrototypePatternDemo() { ICache <Customer> customerCache = new CustomerCache(); Customer c1 = customerCache.GetFromCache(1); Customer c2 = customerCache.GetFromCache(1); }
public void Delete(int id) { var customer = CustomerCache.Find(Customer => Customer.ID == id); CustomerCache.Remove(customer); //this.context.Customers.Remove(customer); }
public Customer SyncCustomer(Customer customer) { if (GetCustomerByName(customer.Name) == null) { CustomerCache.GetInstance().InsertNewCustomer(customer); } return(GetCustomerByName(customer.Name)); }
public string[] GetNamesOfCustomers() { List <string> nameList = new List <string>(); foreach (Customer customer in CustomerCache.GetInstance().Customers) { nameList.Add(customer.Name); } return(nameList.ToArray()); }
public void Refresh() { CustomerCache.GetInstance().Clear(); EmployeeCache.GetInstance().Clear(); Customers = new ObservableCollection <Customer>(CustomerCache.GetInstance().Customers); Employees = new ObservableCollection <Employee>(EmployeeCache.GetInstance().Employees); ListViewCustomers.ItemsSource = Customers; ComboboxCustomerManager.ItemsSource = Employees; ListViewCustomers.SelectedItem = GetFirstCustomer(); }
private void SaveCustomer(Customer itemToSave) { if (itemToSave.Id > 0) { CustomerCache.GetInstance().Update(itemToSave); } else { CustomerCache.GetInstance().Insert(itemToSave); } Customers = new ObservableCollection <Customer>(CustomerCache.GetInstance().Customers); }
public void InsertOrUpdate(Customer customer) { if (customer.ID == default(int)) { CustomerCache.Add(customer); //this.context.Customers.Add(customer); } else { this.context.Entry(customer).State = EntityState.Modified; } }
private void EnsureCacheInitialized() { System.Diagnostics.Trace.WriteLine("Listing Customers"); if (CustomerCache == null) { CustomerCache = new List <Customer>(); } foreach (var c in this.context.Customers) { CustomerCache.Add(c); } }
private void btnSearch_Click(object sender, RoutedEventArgs e) { Dictionary<CustomerCacheSearchKey, string> searchParam = new Dictionary<CustomerCacheSearchKey, string>(); searchParam.Add(CustomerCacheSearchKey.FirstName, txtFirstName.Text.Trim()); searchParam.Add(CustomerCacheSearchKey.LastName, txtLastName.Text.Trim()); searchParam.Add(CustomerCacheSearchKey.PhoneNumber, txtPhoneNumber.Text.Trim()); cache = new CustomerCache(searchParam); cache.ItemUpdate += cache_ItemUpdate; UpdateUI(); }
public void UpdateCustomerByID(Customer changedCustomer) { if (changedCustomer.ID < 0) { CustomerCache.GetInstance().InsertNewCustomer(changedCustomer); } else { CustomerCache.GetInstance().UpdateCustomer(changedCustomer); //force cache reload on next access CustomerCache.GetInstance().Clear(); } }
public static T GetData <T>(string key, Func <T> func) { T result = default(T); if (CustomerCache.Contains(key)) { result = CustomerCache.Get <T>(key); } else { result = func.Invoke(); CustomerCache.Add(key, result); } return(result); }
public void DeleteCustomer(int selectedCustomerID) { CustomerCache.GetInstance().DeleteCustomer(selectedCustomerID); //>>replace the deleted customer's id with empty customer id //1. find the empty customer Customer defaultCustomer = GetCustomerByName(string.Empty); if (defaultCustomer != null) { //use the id to replace deleted Customer's ID in all transactions. (new TransactionManager()).ReplaceCustomer(selectedCustomerID, defaultCustomer.ID); } //force cache reload on next access CustomerCache.GetInstance().Clear(); }
static void Main(string[] args) { string key = $"this_is_key_123"; /* * int result = 0; * if (CustomerCache.Contains(key)) * { * result = CustomerCache.Get<int>(key); * } * else * { * result = DataSource.Count(123); * CustomerCache.Add(key, result); * * }*/ int result = CustomerCache.GetData <int>(key, () => CustomerCache.Get <int>(key)); }
private void ProjectViewOpenProectClickHandler(ProjectsViewModel viewModel) { TextblockPanelName.Text = "Project Details"; RoleCache.GetInstance().Clear(); EmployeeCache.GetInstance().Clear(); ResourceCache.GetInstance().Clear(); CustomerCache.GetInstance().Clear(); ProcessCache.GetInstance().Clear(); ProjectCache.GetInstance().Clear(); var resources = ResourceCache.GetInstance().Resources; resources = ResourceCache.GetInstance().UpdateAllQSizes(); DataContext = new AddEditProjectViewModel { Project = viewModel.SelectedProject, BackClickedHandler = AddEditProjectViewBackClickHandler, Customers = CustomerCache.GetInstance().Customers, Processes = new ObservableCollection <Process>(viewModel.SelectedProject.Processes), Resources = resources.OrderByDescending(r => r.QSize).ToList <Resource>(), Employees = EmployeeCache.GetInstance().Employees }; }
public Customer GetCustomerByID(int ID) { return(CustomerCache.GetInstance().GetCustomerById(ID)); }
public List <Customer> GetAllCustomers() { return(CustomerCache.GetInstance().Customers); }
internal void RefreshCache() { CustomerCache.GetInstance().Clear(); CustomerCache.GetInstance(); }
public Customer GetCustomerByName(string name) { return(CustomerCache.GetInstance().GetCustomerByName(name.Trim().ToLower())); }
public double GetPendingAmountTill(int customerID, DateTime tillDate) { return(CustomerCache.GetInstance().GetPendingAmountBefore(customerID, tillDate)); }
public SelectCustomerForm() { InitializeComponent(); _customerCache = new CustomerCache(); }
public ManageCustomersForm() { InitializeComponent(); _customerCache = new CustomerCache(); InitHiddenColumns(); }
private void TxtCustomerId_TextChanged(object sender, TextChangedEventArgs e) { Dictionary<CustomerCacheSearchKey, string> searchParam = new Dictionary<CustomerCacheSearchKey, string>(); CustomerCache cache = null; if (!string.IsNullOrEmpty(TxtCustomerId.Text)) { searchParam.Add(CustomerCacheSearchKey.Id, TxtCustomerId.Text); cache = new CustomerCache(searchParam); } if (_vehicle != null) { _vehicle.SetValue(PropertyId.SaleCustomerId, TxtCustomerId.Text); } if (cache != null && cache.Count > 0) { CustomerAdminObject customer = cache[0]; lblCustomerFound.Content = customer.FirstName + " " + customer.LastName; } else { lblCustomerFound.Content = ""; } }
private void lblCustomerFound_MouseDoubleClick(object sender, MouseButtonEventArgs e) { Dictionary<CustomerCacheSearchKey, string> searchParam = new Dictionary<CustomerCacheSearchKey, string>(); CustomerCache cache = null; CustomerAdminObject customer = null; if (!string.IsNullOrEmpty(TxtCustomerId.Text)) { searchParam.Add(CustomerCacheSearchKey.Id, TxtCustomerId.Text); cache = new CustomerCache(searchParam); } if (cache != null && cache.Count > 0) { customer = cache[0]; } else { return; } CustomerInfoPage customerInfo = new CustomerInfoPage(customer); if (CacheManager.MainTabControl == null) { throw new NotImplementedException("MainTabControl == null"); } ClosableTab tabItem = new ClosableTab(); tabItem.BackGroundColor = LookAndFeel.CustomerTabColor; customerInfo.SetParentTabControl(tabItem); tabItem.Height = LookAndFeel.TabItemHeight; tabItem.Title = "Customer: " + customer.LastName + ", " + customer.FirstName; tabItem.Content = customerInfo; CacheManager.MainTabControl.Items.Add(tabItem); tabItem.Focus(); }
public Customer GetCustomerByName(string name) { return(CustomerCache.GetInstance().GetCustomerByName(name)); }
public static void UpdateAllVehicleCache() { VehicleCache vehicleTemplCache = new VehicleCache(Settings.VehiclePath, new Dictionary<VehicleCacheSearchKey, string>(), true); _allVehicleCache = vehicleTemplCache; CustomerCache customerTempCache = new CustomerCache(); _allCustomerCache = customerTempCache; _updateingCache = false; }
private static void LoadCache() { try { _userCache = new UserCache(); _allVehicleCache = new VehicleCache(Settings.VehiclePath, new Dictionary<VehicleCacheSearchKey, string>()); _allCustomerCache = new CustomerCache(); } catch (Exception ex) { MessageBox.Show("ERROR: CacheManager: LoadCache\n" + ex.StackTrace); } }
public CustomerFacts() { cache = new CustomerCache(); }
private void DeleteSelectedCustomer() { CustomerCache.GetInstance().Delete(ListViewCustomers.SelectedItem as Customer); Customers = new ObservableCollection <Customer>(CustomerCache.GetInstance().Customers); }