private void btnSave_Click(object sender, EventArgs e) { try { var tickValue = dtpApplyDate.Value.Ticks; SystemConfigService systemConfigService = new SystemConfigService(); var sc = systemConfigService.GetByName("ApplyPricingDate"); if (sc != null) { sc.ValueNumber = tickValue; systemConfigService.EditSystemConfig(sc); } sc = systemConfigService.GetByName("DirectorName"); if (sc != null) { sc.ValueString = txtDirectorName.Text; systemConfigService.EditSystemConfig(sc); } Utilities.ShowMessage("Lưu thành công"); } catch (Exception) { throw; } }
public void GetByKey_Anykey_CallsQueryMethodOfRepository() { // Setup dependency var settingsMock = new Mock<ISettings>(); var uoMock = new Mock<IUnitOfWork>(); var repositoryMock = new Mock<IRepository>(); var serviceLocatorMock = new Mock<IServiceLocator>(); serviceLocatorMock.Setup(x => x.GetInstance<IRepository>()) .Returns(repositoryMock.Object); ServiceLocator.SetLocatorProvider(() => serviceLocatorMock.Object); // Arrange Guid id = Guid.NewGuid(); var key = "MARK_UP_ON_PLATFORM"; SystemConfig system = new SystemConfig() { Id=id, Name = key, Value = "1234" }; SystemConfig[] systems = new SystemConfig[] { system }; repositoryMock.Setup(e => e.Query<SystemConfig>()).Returns(systems.AsQueryable()); // Act var systemConfigService = new SystemConfigService(uoMock.Object, repositoryMock.Object, settingsMock.Object); SystemConfigDto actualSystemconfig = systemConfigService.GetByKey(key); // Assert Assert.AreEqual(id, actualSystemconfig.Id); }
private void btnSaveEmailInfo_Click(object sender, EventArgs e) { SystemConfigService systemConfigService = null; try { systemConfigService = new SystemConfigService(); var fromEmail = systemConfigService.GetByName("FromEmail"); var toEmail = systemConfigService.GetByName("ToEmail"); if (fromEmail != null) { fromEmail.ValueString = txtFromEmail.Text.Trim(); systemConfigService.EditSystemConfig(fromEmail); } if (toEmail != null) { toEmail.ValueString = txtToEmail.Text.Trim(); systemConfigService.EditSystemConfig(toEmail); } } catch (Exception) { throw; } finally { systemConfigService = null; } }
private void LoadEmails() { SystemConfigService systemConfigService = null; try { systemConfigService = new SystemConfigService(); var fromMail = systemConfigService.GetByName("FromEmail"); var toMail = systemConfigService.GetByName("ToEmail"); if (fromMail != null) { txtFromEmail.Text = fromMail.ValueString; } if (toMail != null) { txtToEmail.Text = toMail.ValueString; } } catch (Exception) { throw; } finally { systemConfigService = null; } }
public void GetGST_GSTRATE_GetByKey() { // Setup dependency var settingsMock = new Mock<ISettings>(); var repositoryMock = new Mock<IRepository>(); var uoMock = new Mock<IUnitOfWork>(); var serviceLocatorMock = new Mock<IServiceLocator>(); serviceLocatorMock.Setup(x => x.GetInstance<IRepository>()) .Returns(repositoryMock.Object); ServiceLocator.SetLocatorProvider(() => serviceLocatorMock.Object); // Arrange Guid id = Guid.NewGuid(); SystemConfig sys = new SystemConfig() { Name = "GST_RATE", Value ="1234" }; SystemConfig [] systems = new SystemConfig[] {sys}; repositoryMock.Setup(e => e.Query<SystemConfig>()).Returns(systems.AsQueryable()); // Act var systemConfigService = new SystemConfigService(uoMock.Object, repositoryMock.Object, settingsMock.Object); decimal actulvalue = systemConfigService.GetGST(); // Assert Assert.AreEqual(decimal.Parse(sys.Value, CultureInfo.InvariantCulture), actulvalue); }
public ConfigFormPresenter(ConfigForm view) { logger = log4net.LogManager.GetLogger(typeof(ConfigFormPresenter)); this.view = view; this.configService = new SystemConfigService(); init(); }
//[BindProperty] //private FullSystemConfig FullSystemConfig { get; set; } public SystemConfig_IndexModel(SystemConfigService systemConfigService, TenantInfoService tenantInfoService, FullSystemConfigCache fullSystemConfigCache) { this._systemConfigService = systemConfigService; this._tenantInfoService = tenantInfoService; this._fullSystemConfigCache = fullSystemConfigCache; //FullSystemConfig = _fullSystemConfigCache.Data; }
public IndexModel(IServiceProvider serviceProvider, XncfModuleServiceExtension xncfModuleService, AdminUserInfoService accountService, SystemConfigService systemConfigService, SysMenuService sysMenuService) { _xncfModuleService = xncfModuleService; _accountInfoService = accountService; _sysMenuService = sysMenuService; _systemConfigService = systemConfigService; _serviceProvider = serviceProvider; }
/// <summary> /// 获取用户密钥 /// </summary> /// <returns></returns> public static string GetEncryptKey() { SystemConfigEntity systemConfig = new SystemConfigService().FindSystemConfig((int)SystemConfigs.EncryptKey); if (systemConfig != null) { return(systemConfig.ExSetting01); } else { throw new Exception("未设置开卷分配的密钥"); } }
public override bool VerifyChanges() { var value = SystemConfigService.GetCurrentValue(this.Name); if (!this.Value.Equals(value)) { this.LastValue = this.Value; this.Value = value; this.MonitoredAt = DateTime.Now; return(true); } return(false); }
public IndexModel(IServiceProvider serviceProvider, XncfModuleServiceExtension xncfModuleService, AdminUserInfoService accountService, SystemConfigService systemConfigService, SysMenuService sysMenuService, TenantInfoService tenantInfoService, Lazy <IHttpContextAccessor> httpContextAccessor) { _xncfModuleService = xncfModuleService; _accountInfoService = accountService; _sysMenuService = sysMenuService; _tenantInfoService = tenantInfoService; this._httpContextAccessor = httpContextAccessor; _systemConfigService = systemConfigService; _serviceProvider = serviceProvider; MultiTenantEnable = SiteConfig.SenparcCoreSetting.EnableMultiTenant; TenantRule = SiteConfig.SenparcCoreSetting.TenantRule; }
private void LoadDApplyDate() { try { SystemConfigService systemConfigService = new SystemConfigService(); var sc = systemConfigService.GetByName("ApplyPricingDate"); if (sc != null) { dtpApplyDate.Value = new DateTime((long)sc.ValueNumber.Value); } } catch (Exception ex) { throw; } }
private void LoadDirectorName() { try { SystemConfigService systemConfigService = new SystemConfigService(); var sc = systemConfigService.GetByName("DirectorName"); if (sc != null) { txtDirectorName.Text = sc.ValueString; } } catch (Exception ex) { throw; } }
public static MQHelper getInstance() { SystemConfigService service = new SystemConfigService(); Dictionary <String, Object> configs = service.getConfigs(); try { String shopcode = configs["shopcode"].ToString(); String poscode = configs["poscode"].ToString(); String queues = configs["queues"].ToString(); String mqaddr = configs["mqaddr"].ToString(); return(getInstance(shopcode, poscode, mqaddr, queues)); }catch (Exception e) { Console.WriteLine(e); return(null); } }
/// <summary> /// Gets the system rules /// </summary> /// <returns></returns> public static bool SetRules() { SystemRules = ( SystemConfig )ContextExtensions.GetCachedData("SR_ca"); if (SystemRules != null) { return(true); } using (SystemConfigService service = new SystemConfigService()) { SystemRules = @service.List()[0] ?? new SystemConfig(); ContextExtensions.CacheData("SR_ca", SystemRules); } return(true); }
public static MQCustomer getInstance() { SystemConfigService service = new SystemConfigService(); Dictionary <String, Object> configs = service.getConfigs(); try { String shopcode = configs["shopcode"].ToString(); String poscode = configs["poscode"].ToString(); String mqaddr = configs["mqaddr"].ToString(); return(getInstance(shopcode, poscode, mqaddr)); } catch (Exception e) { logger.Debug("Get MQCustomer error:" + e); return(null); } }
public HttpResponseMessage Update(HttpRequestMessage request, SystemConfigModel SystemConfigModel) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; if (!ModelState.IsValid) { request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } else { var SystemConfigService = new SystemConfigService(); SystemConfigService.Update(SystemConfigModel); response = request.CreateResponse(HttpStatusCode.OK); } return response; })); }
private static SystemConfig SetRules(bool set) { SystemConfig sr = ( SystemConfig )ContextExtensions.GetCachedData("SR_ca"); if (sr != null) { return(sr); } using (SystemConfigService service = new SystemConfigService()) { sr = service.List().FirstOrDefault() ?? new SystemConfig(); ContextExtensions.CacheData("SR_ca", sr); } return(sr); }
public HttpResponseMessage DeleteMulti(HttpRequestMessage request, int[] id) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; if (!ModelState.IsValid) { response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState); } else { var SystemConfigService = new SystemConfigService(); SystemConfigService.DeleteAll(id); response = request.CreateResponse(HttpStatusCode.OK); } return response; })); }
private string GetLastedContractCode() { string result = ""; try { _systemConfigService = new SystemConfigService(); txtCode.Text = _systemConfigService.GetLastContractNumberAsString(); return(result); } catch (Exception) { throw; } finally { _systemConfigService = null; } }
private bool SystemConfigSave() { var result = true; var message = SettingChecking(); try { if (string.IsNullOrEmpty(message)) { var config = new Models.Entity.SystemConfig(); config.Code = (int)Enums.Entity.SystemConfigType.COMPort; config.Value = comboBoxCOMPort.SelectedValue.ToString(); SystemConfigService.SaveSystemConfig(config); config.Code = (int)Enums.Entity.SystemConfigType.科別代碼; config.Value = comboBoxClinic.SelectedValue.ToString(); SystemConfigService.SaveSystemConfig(config); config.Code = (int)Enums.Entity.SystemConfigType.醫師代碼; config.Value = comboBoxClinic.SelectedValue.ToString(); SystemConfigService.SaveSystemConfig(config); return(result); } else { result = false; var caption = "警告"; var button = MessageBoxButtons.OK; var icon = MessageBoxIcon.Error; Dialog(message, caption, button, icon); return(result); } } catch (Exception ex) { log.Error(ex.ToString()); result = false; return(result); } }
/// <summary> /// Runs all the operations of this monitor /// </summary> /// <param name="writer"></param> /// <returns></returns> public static bool Run(StreamWriter writer) { if (IsRunning) { return(false); } IsRunning = true; // 1. Excute CheckClientContracts Info(writer, ":: ClientMonitor :: CheckClientContracts() :: Executed"); CheckClientContracts(writer); // 2. .... IsRunning = false; #region Update Last Run using (SystemConfigService service = new SystemConfigService()) { SystemConfig rules = service.GetById(ConfigSettings.SystemRules.Id); if (rules != null) { rules.LastClientMonitorRun = DateTime.Now; rules.LastClientMonitorCount = ClientMonitorCount; service.Update(rules); } } #endregion return(true); }
/// <summary> /// 获取当前可执行产品构造器 /// </summary> /// <returns></returns> public static ADbFileProductBuilder GetDbFileProductBuilder() { SystemConfigService service = new SystemConfigService(); SystemConfigEntity systemConfig = service.FindSystemConfig((int)SystemConfigs.OpenbookSysType); if (systemConfig.Status == 0) { throw new Exception($"系统未配置开卷系统类型"); } ADbFileProductBuilder productBuilder = null; if (systemConfig.Status == 1) { productBuilder = new DbFileProductBuilder(); } else { productBuilder = new T8DbFileProductBuilder(); } return(productBuilder); }
/// <summary> /// 呼叫 初始化DB 的method /// </summary> private void DBInitial() { log.Info($"資料庫初始化..."); try { var apiResult = new DataServices.DataServices().GetDataFromAPI(); ClinicRoomService.ClearClinic(); DoctorService.ClearDoctor(); SystemConfigService.Init(); ClinicRoomService.Init(apiResult.Result.ClinicRoom); DoctorService.Init(apiResult.Result.Doctor); } catch (Exception ex) { log.Error(ex.ToString()); } log.Info($"資料庫初始化完成..."); }
public static Boolean Init() { SystemConfigService service = new SystemConfigService(); Dictionary <String, Object> con = service.getConfigs(); try { con[SHOP_CODE].ToString(); con[SHOP_NAME].ToString(); con[POS_CODE].ToString(); con[POS_NAME].ToString(); con[SERVER_ADDRESS].ToString(); con[MQ_ADDRESS].ToString(); con[ORDER_QUEUE].ToString(); con[POS_ID].ToString(); configs = con; } catch (Exception e) { return(false); } return(true); }
/// <summary> /// Create a consultation invoice /// </summary> /// <param name="minimumCharge">true if apply minimum charge</param> /// <returns></returns> public InvoiceDto CreateConsultationInvoice(decimal amount, Guid bookingId, bool minimumCharge, bool isCustomer, string transactionId) { var SystemConfig = new SystemConfigService(UnitOfWork, Repository, Settings); string emailAddress = string.Empty; Invoice invoice = new Invoice(amount, InvoiceType.Consultation, Currency.AUD.ToString(), string.Empty, true, null, DateTime.UtcNow, DateTime.UtcNow); invoice.InvoiceNumber = GetInvoiceNumber(); Booking booking = Repository.FindById<Booking>(bookingId); invoice.User = isCustomer ? booking.Customer : booking.Specialist; emailAddress = invoice.User.Email; invoice.Description = string.Format(InvoiceConst.InvoiceNormalDescription, booking.ReferenceNo, invoice.User.ExposedAs<UserDto>().Name); Log.Debug("CreateConsultationInvoice - before calculate GST - Customer:" + booking.Customer.UserName + " - specialist:" + booking.Specialist.UserName + " - Amount: " + amount + " - GSTRegistered:" + booking.Specialist.Profile.GstRegistered + " - SpecializationGST:" + booking.Specialization.GST); invoice.GST = booking.Specialist.Profile.GstRegistered ? booking.Specialization.GST ? SubtractGSTCalculator(amount) : 0 : 0; Log.Debug("CreateConsultationInvoice - after calculate GST - Customer:" + booking.Customer.UserName + " - specialist:" + booking.Specialist.UserName + " - Amount: " + amount + " - Invoice Calculated GST:" + invoice.GST + " - function calculate GST return:" + SubtractGSTCalculator(amount)); invoice.TransactionId = transactionId; if (minimumCharge) // minimum charge invoice { invoice.Description = string.Format(InvoiceConst.InvoiceCancelDescription, booking.ReferenceNo) + InvoiceConst.InvoiceApplyMinimumDescription; invoice.Duration = 0; invoice.RatePerMinute = booking.RatePerMinute; invoice.ConsultationType = ConsultationType.MinimumCharge; invoice.Booking = booking; invoice.DeclineBookingRate = isCustomer ? booking.CustomerMinCharge : booking.SpecialistMinCharge; invoice.Amount = invoice.DeclineBookingRate; } else // normal consultation invoice { var call = Repository.Query<Call>().FirstOrDefault(x => x.Booking.Id.Equals(bookingId)); if (call == null) { throw new ArgumentException("Generate consulation invoice with booking Id: " + bookingId); } ConsultationType consultType; if (call.Booking.Type == BookingType.ASAP) { consultType = ConsultationType.StandardHour; } else { Enum.TryParse(call.Booking.Type.ToString(), out consultType); } invoice.Booking = call.Booking; invoice.Duration = call.Duration; invoice.RatePerMinute = isCustomer ? call.Booking.CostPerMinute : call.Booking.RatePerMinute; invoice.ConsultationType = consultType; if (call.Duration < Convert.ToInt32(SystemConfig.GetByKey(ParamatricBusinessRules.STARTING_TIME.ToString()).Value)) { invoice.Description += InvoiceConst.InvoiceApplyMinimumDescription; } } Repository.Insert<Invoice>(invoice); UnitOfWork.Save(); Log.Debug("CreateConsultationInvoice - after insert invoice - Customer:" + booking.Customer.UserName + " - specialist:" + booking.Specialist.UserName + " - Amount: " + invoice.Amount + " - Invoice Calculated GST:" + invoice.GST); if (invoice.Id.Equals(Guid.Empty)) { throw new ArgumentException("Cannot save consultation invoice to database"); } return invoice.ExposedAs<InvoiceDto>(); }
private void btnSave_Click(object sender, EventArgs e) { try { Contract result = null; int editResult = CRUDStatusCode.ERROR; _contractService = new ContractService(); _systemConfigService = new SystemConfigService(); if (model == null) { //Add model = new Contract() { Code = txtCode.Text, CustomerCode = txtCustomerCode.Text, //ContractTypeId = (int)cboContractType.SelectedValue, StartDate = dtpStartDate.Value, EndDate = dtpEndDate.Value, SumCost = Utilities.GetDoubleFromTextBox(txtCost), Discount = Utilities.GetDoubleFromTextBox(txtDiscount), Cost = Utilities.GetDoubleFromTextBox(txtTotalCost) }; result = _contractService.AddContract(model); if (result != null) { model = result; gbContractDetail.Visible = true; _systemConfigService.UseLastContractNumber(); contractDetail = new ContractItem() { ContractCode = model.Code }; txtCustomerCode.ReadOnly = true; Utilities.ShowMessage(CommonMessage.ADD_SUCESSFULLY); Logging.LogBusiness(string.Format("{0} {1} {2}", Common.Session.GetUserName(), Common.Constants.LogAction.Create, "hợp đồng mã " + model.Code), Common.Constants.BusinessLogType.Create); } } else { //Edit model.CustomerCode = txtCustomerCode.Text; //model.ContractTypeId = (int)cboContractType.SelectedValue; model.StartDate = dtpStartDate.Value; model.EndDate = dtpEndDate.Value; model.SumCost = Utilities.GetDoubleFromTextBox(txtCost); model.Cost = Utilities.GetDoubleFromTextBox(txtTotalCost); model.Discount = Utilities.GetDoubleFromTextBox(txtDiscount); editResult = _contractService.EditContract(model); if (editResult == CRUDStatusCode.SUCCESS) { gbContractDetail.Visible = true; Utilities.ShowMessage(CommonMessage.EDIT_SUCESSFULLY); Logging.LogBusiness(string.Format("{0} {1} {2}", Common.Session.GetUserName(), Common.Constants.LogAction.Update, "hợp đồng mã " + model.Code), Common.Constants.BusinessLogType.Update); } } } catch (Exception ex) { throw; } finally { _contractService = null; _systemConfigService = null; } }
/// <summary> /// (the specialists rate + TeleConsult mark up) + (virtual consultation cost + TeleConsult mark up) + Sales Tax if applicable /// </summary> /// <param name="specRate"></param> /// <param name="gstOnSpecRate"> = 1 if this specialization doesnot apply gst</param> /// <param name="platformCost"></param> /// <param name="gstOnPlatformCost"></param> /// <returns>customer rate - already has money rounding</returns> public decimal GetCustomerRate(decimal specRate, bool appliedGST) { SystemConfigService systemConfig = new SystemConfigService(UnitOfWork, Repository, Settings); //default tax = 0.1 (10%) decimal tax = systemConfig.GetGST() + 1; // commission = 2% = 0.02 decimal commission = systemConfig.GetValueByKey(ParamatricBusinessRules.COMMISSION_LEVELS.ToString()) / 100; decimal basicFee = systemConfig.GetValueByKey(ParamatricBusinessRules.BASIC_FEE.ToString()); if (!appliedGST) { tax = 1; } decimal rate = (specRate * (1 + commission) + basicFee) * tax; return Utilities.RoundMoney(rate); }
public LoginPresenter(LoginInitForm view) { this.view = view; this.service = new CashierService(); this.configService = new SystemConfigService(); }
static AutoUploadFtpJob() { ftpService = new FtpService(); sysConfigService = new SystemConfigService(); }
public ServiceManagerFrm() { InitializeComponent(); systemConfigBll = new SystemConfigService(); ftpBll = new FtpService(); }
public IndexModel(AdminUserInfoService accountService, SystemConfigService systemConfigService) { _accountInfoService = accountService; _systemConfigService = systemConfigService; }
public InstallController(AdminUserInfoService accountService, SystemConfigService systemConfigService) { _accountInfoService = accountService; _systemConfigService = systemConfigService; }
static BaseFrm() { taskManagerService = new TaskManagerService(); systemConfigService = new SystemConfigService(); ftpService = new FtpService(); }
// Subtract GST public Decimal SubtractGSTCalculator(decimal price) { SystemConfigService sysConfig = new SystemConfigService(UnitOfWork, Repository, Settings); decimal gst = sysConfig.GetGST(); decimal gstAmount = price - (price / (gst + 1)); return decimal.Round(gstAmount, 2, MidpointRounding.AwayFromZero); }