static void Main(string[] args) { string db_filename = string.Empty; if (args.Length >= 1) { db_filename = args[0]; } if (string.IsNullOrEmpty(db_filename)) { ShowUsage(); return; } else { Context.SpecifyFilename(db_filename); Database db = new Database(); using (SQLiteConnection conn = db.Connection) { conn.Open(); SystemConfiguration config = SystemConfigurationStore.Get(false, conn); foreach (DeviceInfo device in config.devices) { PruneDevice(device, conn); } Vaccuum(conn); } } }
/// <summary> /// Обновление настройки системы /// </summary> /// <param name="systemConfiguration">Редактируемая настройка системы</param> /// <returns>Отредактированная настройка системы</returns> public SystemConfiguration UpdateSystemConfiguration(SystemConfiguration systemConfiguration) { logger.Trace("Попытка подключения к источнику данных."); logger.Trace("Подготовка к обновлению настройки системы."); try { var systemConfigurationToUpdate = context.SystemConfiguration.FirstOrDefault(sc => sc.Name == systemConfiguration.Name); logger.Debug($"Текущая запись {systemConfigurationToUpdate.ToString()}"); systemConfigurationToUpdate.Title = systemConfiguration.Title; systemConfigurationToUpdate.Value = systemConfiguration.Value; context.SaveChanges(); logger.Debug($"Новая запись {systemConfigurationToUpdate.ToString()}"); return(systemConfigurationToUpdate); } catch (SqlException sqlEx) { logger.Error("Ошибка редактирования настройки системы."); logger.Error($"Ошибка SQL Server — {sqlEx.Number}."); logger.Error($"Сообщение об ошибке: {sqlEx.Message}."); return(null); } catch (Exception ex) { logger.Error("Ошибка редактирования настройки системы."); logger.Error($"Ошибка — {ex.Message}."); return(null); } }
public MDINSites_VUI() { InitializeComponent(); loUserGroup = new UserGroup(); ldtUserGroup = new DataTable(); loSystemConfiguration = new SystemConfiguration(); }
public SystemConfigurationUI() { InitializeComponent(); lSystemConfigHash = new Hashtable(); loSystemConfiguration = new SystemConfiguration(); loCryptorEngine = new CryptorEngine(); }
public int Create(int companyId, Format_Create parseData) { using (CDStudioEntities dbEntity = new CDStudioEntities()) { SystemConfiguration newData = new SystemConfiguration() { Group = parseData.Group ?? "", Key = parseData.Key, Value = parseData.Value }; dbEntity.SystemConfiguration.Add(newData); try { dbEntity.SaveChanges(); } catch (DbUpdateException ex) { if (ex.InnerException.InnerException.Message.Contains("Cannot insert duplicate key")) { throw new CDSException(11902); } else { throw ex; } } return(newData.Id); } }
// // GET: /Configurations/ public ActionResult Index() { IEnumerable <Interblocks.CProperty> prop = new List <CProperty>(); var config = SystemConfiguration.GetProperties(); return(View(config)); }
private void CheckForConfigurationChanges(DataStorage storage, SQLiteConnection conn) { Database db = new Database(); DateTimeOffset?configuration_update = db.GetLastConfigurationUpdateAttribute(conn); if (m_last_configuration_update == DateTimeOffset.MinValue || (configuration_update.HasValue && configuration_update.Value != m_last_configuration_update)) { if (configuration_update.HasValue) { m_last_configuration_update = configuration_update.Value; } logging.EventLog elog = new ApplicationEventLog(); elog.LogInformation("Loading configuration from database"); //db.Initialize(); SystemConfiguration config = SystemConfigurationStore.Get(false, conn); m_system_device = new SystemDevice(config, storage); DeleteDays delete_days = new DeleteDays(); int? days = delete_days.GetValueAsInt(conn); m_days_to_keep = days ?? 180; m_daily_file_cleaner.DaysToKeep = m_days_to_keep; } }
public void SendEmailVerificationMail(string subject, string body, string fullname) { DBEntities db = new DBEntities(); SystemConfiguration toMailObj = db.SystemConfigurations.FirstOrDefault(x => x.Key == "Event Email Address"); SystemConfiguration fromMailObj = db.SystemConfigurations.FirstOrDefault(x => x.Key == "Support Email Address"); var fromEmail = new MailAddress(fromMailObj.Value, "Darsh Sharma"); var toMail = new MailAddress(toMailObj.Value); var fromEmailPassword = "******"; string emailSubject = subject; string emailBody = "Hello, <br><br> " + body + "<br><br>Regards,<br>" + fullname; var smtp = new SmtpClient { Host = "smtp.gmail.com", Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new NetworkCredential(fromEmail.Address, fromEmailPassword) }; using (var message = new MailMessage(fromEmail, toMail) { Subject = emailSubject, Body = emailBody, IsBodyHtml = true }) smtp.Send(message); }
public void ConfigureServices(IServiceCollection services) { services.AddControllers(); sysConfig = new SystemConfiguration(); Configuration.Bind(sysConfig); services.AddSingleton(sysConfig); }
public static List <Switch> GetAvSwitch(SystemConfiguration configObject, CrestronControlSystem master) { List <Switch> switchers = new List <Switch>(); try { Assembly switchAssembly = Assembly.LoadFrom(configObject.AvSwitchers.LibraryPath); foreach (AvSwitch sw in configObject.AvSwitchers.AvSwitch) { CType swt = switchAssembly.GetType(sw.ClassName); ConstructorInfo ci = swt.GetConstructor(new CType[] { typeof(UInt32), typeof(CrestronControlSystem) }); object swObject = ci.Invoke(new object[] { Convert.ToUInt32(sw.IpId), master }); Switch swCasted = (Switch)swObject; switchers.Add(swCasted); } //TODO Instantiate the AV Switch //TODO Get all Input cards //TODO Get all Output cards //TODO Get frame object //TODO add input cards to frame //TODO add output cards to frame } catch (Exception e) { ErrorLog.Error("Failed to retreive switcher data:\n{0} -- {1}\n", e.Message, e.StackTrace); } return(switchers); }
public SystemDevice(SystemConfiguration config, DataStorage storage) : base("System", storage) { m_log = LogManager.GetLogger(typeof(SystemDevice)); Devices = new List <Device>(); config.devices.ForEach(m => { if (m.type != EDeviceType.System) { Devices.Add(new Device(m, this, Storage)); } }); DeviceInfo system = config.devices.Find(d => d.type == EDeviceType.System); CollectorInfo ping = null; if (system != null) { ping = system.collectors.Find(c => c.collectorType == ECollectorType.Ping); } if (ping != null && ping.isEnabled) { Collect(new PingCollector(new CollectorID(ping.id, Name))); } }
public static void AddBme680Config(this SystemConfiguration config) { var bme680Config = new Bme680Configuration { FilteringMode = Bme680FilteringMode.C3, GasConversionIsEnabled = true, HeaterIsEnabled = true, HeaterProfiles = new List <Bme680HeaterConfiguration> { new Bme680HeaterConfiguration { HeaterProfile = Bme680HeaterProfile.Profile1, Duration = 150, TargetTemperature = 320 } }, HumiditySampling = Sampling.HighResolution, PressureSampling = Sampling.HighResolution, TemperatureSampling = Sampling.HighResolution, ActiveProfile = Bme680HeaterProfile.Profile1, I2CAddress = Bme680.SecondaryI2cAddress }; var bme680DeviceConfig = new DeviceConfig { Name = "Bme680", Configuration = JsonSerializer.Serialize(bme680Config) }; config.DeviceConfig.Add(bme680DeviceConfig); }
public void Update(List <SystemConfigOutput> requestDto, string username) { if (requestDto != null && requestDto.Count > 0) { foreach (var item in requestDto) { var obj = GetSystemConfig(item.Key); if (obj == null) { obj = new SystemConfiguration { KeyStr = item.Key, ValueUnit = item.ValueUnit, Value = item.Value, CreatedBy = username, CreatedDate = Clock.Now }; _systemConfigRepository.Insert(obj); } else { obj.Value = item.Value; obj.ValueUnit = item.ValueUnit; obj.LastUpdateDate = Clock.Now; obj.LastUpdatedBy = username; _systemConfigRepository.Update(obj); _unitOfWork.Commit(); } } } }
/// <summary> /// Добавление настройки системы /// </summary> /// <param name="systemConfiguration">Новая настройка системы</param> /// <returns>Новая запись</returns> public SystemConfiguration InsertSystemConfiguration(SystemConfiguration systemConfiguration) { logger.Trace("Попытка подключения к источнику данных."); logger.Trace("Подготовка к добавлению настройки системы"); try { logger.Debug($"Добавляемая запись {systemConfiguration.ToString()}"); context.SystemConfiguration.Add(systemConfiguration); context.SaveChanges(); logger.Debug($"Новая запись успешно добавлена."); return(systemConfiguration); } catch (SqlException sqlEx) { logger.Error("Ошибка добавления настройки системы."); logger.Error($"Ошибка SQL Server — {sqlEx.Number}."); logger.Error($"Сообщение об ошибке: {sqlEx.Message}."); return(null); } catch (Exception ex) { logger.Error("Ошибка добавления настройки системы."); logger.Error($"Ошибка — {ex.Message}."); return(null); } }
public int CaculateDayOfConfig(SystemConfiguration obj) { try { if (obj == null) { return(1); } if (obj.ValueUnit.Equals(Unit.days.ToString())) { return(Int32.Parse(obj.Value)); } if (obj.ValueUnit.Equals(Unit.weeks.ToString())) { return(Int32.Parse(obj.Value) * 7); } if (obj.ValueUnit.Equals(Unit.months.ToString())) { var totals = 0; var value = Int32.Parse(obj.Value); var current = Clock.Now; for (int i = 0; i < value; i++) { int days = DateTime.DaysInMonth(current.Year, current.Month + i); totals = totals + days; } return(totals); } } catch (Exception e) { Log.Error("Something wrong when get system config {e}", e); } return(1); }
public static string get_database_name() { if (_config == null) { _config = initialize_config_to_dotnetconfig(); } string database_name = string.Empty; string connection_string = _config.get_connection_string("db"); if (!string.IsNullOrEmpty(connection_string)) { string[] parts = connection_string.Split(';'); foreach (string part in parts) { if ((part.to_lower().Contains("initial catalog") || part.to_lower().Contains("database"))) { database_name = part.Substring(part.IndexOf("=") + 1); break; } } } return database_name; }
public void SendNotifications(string SearchName, Boolean consumersearch) { var defaultCultureCode = SystemConfiguration.GetConfigValueByKey("DefaultCultureCode"); List <string> NameList = null; string currCulture = System.Threading.Thread.CurrentThread.CurrentCulture.Name; if (consumersearch) { if (currCulture.ToUpper().Equals(defaultCultureCode.ToUpper())) { NameList = SearchNameListConfig.ConsumerNameListEN; } else { NameList = SearchNameListConfig.ConsumerNameListAR; } } else { if (currCulture.ToUpper().Equals(defaultCultureCode.ToUpper())) { NameList = SearchNameListConfig.CommercialNameListEN; } else { NameList = SearchNameListConfig.CommercialNameListAR; } } var MatchingNames = NameList.Where(stringToCheck => stringToCheck.StartsWith(SearchName.ToUpper())); var TopNames = (from Name in MatchingNames select Name).Take(MaxItemsDisplay); Clients.Client(Context.ConnectionId).receiveNotification(TopNames); }
private void btnOk_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.OK; SystemConfiguration.SaveConfig(); this.Close(); }
public LogInUI() { InitializeComponent(); loSystemConfiguration = new SystemConfiguration(); loUser = new User(); loCryptorEngine = new CryptorEngine(); }
public void GenerateSystemConfiguration() { SystemConfiguration configuration = new SystemConfiguration(); EmailTemplate template = new EmailTemplate() { BodyTemplate = "body", ItemTemplate = "item", RowTemplate = "row" }; configuration.EmailConfiguration = new EmailConfiguration() { ApiKey = "key", Login = "******", Password = "******", SmtpServer = "smtp", UseSendGrid = true }; configuration.EmailMessage = new EmailMessage(template) { From = "from", Recipients = new string[] { "rec1", "rec2" }, Subject = "subject" }; var sConfiguration = Newtonsoft.Json.JsonConvert.SerializeObject(configuration); Assert.IsNotNull(sConfiguration); }
public SearchOutput Search(SearchFromTo <TypeLogEnum> requestDto, string username) { SystemConfiguration config = _configService.GetSystemConfig(SystemConfigEnum.ArchiveLogData.ToString()); var day = CaculateDayOfConfig(config); var begin = Clock.Now.Date.AddDays(-day); if (requestDto.From != null && requestDto.From.Value > begin) { begin = requestDto.From.Value; } requestDto.From = new DateTime(begin.Year, begin.Month, begin.Day, 0, 0, 0); if (requestDto.To != null) { var to = requestDto.To.Value.AddDays(1); requestDto.To = new DateTime(to.Year, to.Month, to.Day, 0, 0, 0); } User user = _userRepository.GetAll().FirstOrDefault(x => x.Username.Equals(username)); switch (requestDto.Property) { case TypeLogEnum.SystemLog: return(GetAllSystemLog(requestDto, user)); case TypeLogEnum.SynchronizationLog: return(GetAllSynchronizationLog(requestDto, user)); case TypeLogEnum.TransactionLog: return(GetAllTransactionLog(requestDto, user)); default: return(null); } }
private static Dictionary <string, DataCollectorContext> GetCollectorIDCache(SystemConfiguration config) { Dictionary <string, DataCollectorContext> collector_id_cache = new Dictionary <string, DataCollectorContext>(); config.devices.ForEach(d => { d.collectors.ForEach(c => { collector_id_cache[c.name] = c.DCContext; }); }); return(collector_id_cache); }
private static (GeneralLedgerTransaction debit, GeneralLedgerTransaction credit) NewGeneralJournalTransactions( WineMsGeneralLedgerJournalTransaction wineMsGeneralLedgerJournalTransaction) { var debit = NewGeneralJournalTransaction(); debit.Transaction.Account = new GLAccount(wineMsGeneralLedgerJournalTransaction.DebitGeneralLedgerAccountCode); debit.Transaction.Debit = (double)wineMsGeneralLedgerJournalTransaction.TransactionAmountExVat; var credit = NewGeneralJournalTransaction(); credit.Transaction.Account = new GLAccount(wineMsGeneralLedgerJournalTransaction.CreditGeneralLedgerAccountCode); credit.Transaction.Credit = (double)wineMsGeneralLedgerJournalTransaction.TransactionAmountExVat; return(debit : debit, credit : credit); GeneralLedgerTransaction NewGeneralJournalTransaction() => new GeneralLedgerTransaction( wineMsGeneralLedgerJournalTransaction.Guid, new GLTransaction { Date = wineMsGeneralLedgerJournalTransaction.TransactionDate, Description = wineMsGeneralLedgerJournalTransaction.Description1, Reference = wineMsGeneralLedgerJournalTransaction.DocumentNumber, Reference2 = wineMsGeneralLedgerJournalTransaction.Guid.ToString(), TransactionCode = new TransactionCode(Module.GL, SystemConfiguration.GetJournalTransactionCode()) }); }
/// <summary> /// Удаление настройки системы /// </summary> /// <param name="systemConfiguration">Удаляемая настройка системы</param> public void DeleteSystemConfiguration(SystemConfiguration systemConfiguration) { logger.Trace("Попытка подключения к источнику данных."); logger.Trace("Подготовка к удалению настройки системы."); try { var systemConfigurationToDelete = context.SystemConfiguration.FirstOrDefault(sc => sc.Name == systemConfiguration.Name); if (systemConfigurationToDelete != null) { context.SystemConfiguration.Remove(systemConfigurationToDelete); context.SaveChanges(); logger.Debug("Удаление успешно завершено."); } } catch (SqlException sqlEx) { logger.Error("Ошибка удаления записи настройки системы."); logger.Error($"Ошибка SQL Server — {sqlEx.Number}."); logger.Error($"Сообщение об ошибке: {sqlEx.Message}."); } catch (Exception ex) { logger.Error("Ошибка удаления записи настройки системы."); logger.Error($"Ошибка — {ex.Message}."); } }
public bool Initialize(SystemConfiguration configuration, IntPtr windowHandle) { try { // Create the Direct3D object. D3D = new DX11(); // Initialize the Direct3D object. if (!D3D.Initialize(configuration, windowHandle)) { return(false); } // Create the camera object Camera = new Camera(); // Initialize a base view matrix the camera for 2D user interface rendering. Camera.SetPosition(0, 0, -1); Camera.Render(); var baseViewMatrix = Camera.ViewMatrix; // Create the text object. Text = new Text(); if (!Text.Initialize(D3D.Device, D3D.DeviceContext, windowHandle, configuration.Width, configuration.Height, baseViewMatrix)) { return(false); } return(true); } catch (Exception ex) { MessageBox.Show("Could not initialize Direct3D\nError is '" + ex.Message + "'"); return(false); } }
public ShopController(DBConnection context, IDetectionService detectionService, IHttpContextAccessor accessor, IOptions <SystemConfiguration> systemConfiguration) { _accessor = accessor; _context = context; _detectionService = detectionService; _systemConfiguration = systemConfiguration.Value; }
public void deleteSystemConfiguration(int id) { DBHelper.APIService dbhelp = new DBHelper.APIService(); SystemConfiguration existingSystemConfiguration = dbhelp.GetSystemConfigurationById(id); dbhelp.DeleteSystemConfiguration(existingSystemConfiguration); }
private Actor.ActorSystemState LoadSystem(IDocumentSession session) { using (session.Advanced.DocumentStore.AggressivelyCacheFor(TimeSpan.FromDays(CacheDays))) { var system = session .Include <SystemConfiguration>(x => x.ManagedConventionId) .Include <SystemConfiguration>(x => x.DisplayConventionId) .Load <SystemConfiguration>(SystemConfiguration.Id); var activities = session.Query <Activity>().ToList() .Where(x => x.IsSubActivity == false).ToList(); var ageGroups = session.Query <AgeGroup>().ToList(); if (system == null) { system = new SystemConfiguration(); } return(new Actor.ActorSystemState { ManagersConventionId = system.ManagedConventionId, DisplayConventionId = system.DisplayConventionId, Activities = activities, AgeGroups = ageGroups }); } }
public ResponseInfoModel EditInfo([FromBody] SystemConfiguration input) { ResponseInfoModel json = new ResponseInfoModel() { Success = 1, Result = new object() }; try { CheckModelState(); if (!_systemConfigurationService.Update(input)) { json.Success = 0; json.Result = LocalizationConst.UpdateFail; } else { _logService.Insert(new Log() { ActionContent = LocalizationConst.Update, SourceType = _moduleName, SourceID = input.ID, LogTime = DateTime.Now, LogIPAddress = IPHelper.GetIPAddress, }); } } catch (Exception e) { DisposeUserFriendlyException(e, ref json, "api/sysconfig/editInfo", LocalizationConst.UpdateFail); } return(json); }
public List <SystemConfiguration> getSystemConfiguration() { List <SystemConfiguration> lsSystemConfiguration = new List <SystemConfiguration>(); CommonData commonData = new CommonData(); DataSet dataset = new DataSet(); try { dataset = commonData.getSystemConfiguration(); if (dataset.Tables["SYSTEMSETTING"].Rows.Count > 0) { for (int i = 0; i < dataset.Tables["SYSTEMSETTING"].Rows.Count; i++) { SystemConfiguration localSC = new SystemConfiguration(); localSC.SystemSettingID = Convert.ToInt32(dataset.Tables["SYSTEMSETTING"].Rows[i]["SYSTEMSETTINGID"]); localSC.Property = dataset.Tables["SYSTEMSETTING"].Rows[i]["PROPERTY"].ToString(); localSC.Value = dataset.Tables["SYSTEMSETTING"].Rows[i]["VALUE"].ToString(); localSC.DisplayText = dataset.Tables["SYSTEMSETTING"].Rows[i]["DISPLAYTEXT"].ToString(); lsSystemConfiguration.Add(localSC); } } } catch (Exception ex) { LoggerHelper.WriteToLog(ex); } return(lsSystemConfiguration); }
public SystemConfigurationUI() { InitializeComponent(); lSystemConfigHash = new Hashtable(); loSystemConfiguration = new SystemConfiguration(); loLookupValue = new LookUpValueUI(); }
public D3DGraphic(SystemConfiguration windowConfig) { this.windowConfig = windowConfig; ShaderName shaderName = ShaderName.Texture; IShape shape = new Box2(); ModelShader.Get(shaderName, shape); d3d = new D3D11(windowConfig); camera = new Camera(); model = new Bitmap(d3d.Device, ModelShader.GetShaderEffect, shaderName, this.windowConfig, new Vector2(256, 256)); //model = new D3DModel(d3d.Device, ModelShader.GetModelForRender, ModelShader.GetIndexes); shader = new D3DShader(d3d.Device, ModelShader.GetShaderEffect, shaderName); graph.Add(d3d); graph.Add(model); graph.Add(shader); //camera.Position = new Vector3(-2, 1, -3); camera.Position = new Vector3(0.0f, 0.0f, -10.0f); }
private void SendErrorEmail(CreateCouponViewModel createCouponVm, string description) { var adminEmail = new SystemConfiguration().AdminEmergencyEmail; var mailTemplate = new MailTemplate(Language.CurrentCulture); var username = Session.GetLoggedInUser().Username; var errorEmail = mailTemplate.GetCouponErrorEmail(description, createCouponVm.EventId, createCouponVm.PaymentId, username); var subject = string.Format(MyMentorResources.errorCreatingCoupon,username,createCouponVm.EventId); Mailer.SendMail(adminEmail, errorEmail, subject); }