//获取并设置当前服务链接 private void BtnSaveHostAddress_Click(object sender, RoutedEventArgs e) { AppConfigs ac = new AppConfigs(); ac.updateAppSettings("ServiceHostAddress", ServiceHostAddressText.Text.Trim()); GlobalObjects.ServiceHostAddress = ServiceHostAddressText.Text.Trim(); }
public FrmSettings() { InitializeComponent(); AppConfigs conf = AppConfigs.Load(); if (conf != null) { ValidUsers_bindingList = new BindingList <Employee>(conf.Employees); var sourceUsers = new BindingSource(ValidUsers_bindingList, null); grdValidUsers.DataSource = sourceUsers; ValidExtensions_bindingList = new BindingList <FileExtensions>(conf.ValidExtensions); var sourceExtensions = new BindingSource(ValidExtensions_bindingList, null); grdValidExtensions.DataSource = sourceExtensions; } ServiceState st = ServiceHelper.GetServiceStatus("EFTService"); lblServicestatus.Text = Enum.GetName(typeof(ServiceState), st); btnUninstall.Visible = new[] { 1, 4, 7 }.Contains((int)st); lblCurrentUsername.Text = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToLower(); CheckUserAccess(); }
private void FrmSettings_Load(object sender, EventArgs e) { AppConfigs conf = AppConfigs.Load(); txtServerIP.Text = conf.ServerIP; txtSavePath.Text = conf.SavePath; txtDomainUsername.Text = conf.DomainUsername; }
public void InitApp() { var configFilePath = AppConfigs.InitConfigFile(); Console.Out.WriteLine("init completed. you must now edit the config file with your personal information"); Console.Out.WriteLine(""); Console.Out.WriteLine($"config: {configFilePath}"); }
private void BtnSaveCulture_Click(object sender, RoutedEventArgs e) { AppConfigs ac = new AppConfigs(); ac.updateAppSettings("Lang", cmbCulture.Text); GlobalObjects.CurrentLanguage = cmbCulture.Text; Restart(this); }
protected BaseController( IMapper mapper, [FromServices] IProductCatalogueServiceFacade productCatalogueServiceFacade, IOptions <AppConfigs> configs) { _mapper = mapper; _configs = configs.Value; _productCatalogueServiceFacade = productCatalogueServiceFacade; }
private void btnSave_Click(object sender, EventArgs e) { AppConfigs conf = new AppConfigs(); conf.ServerIP = txtServerIP.Text; conf.SavePath = txtSavePath.Text; conf.DomainUsername = txtDomainUsername.Text; AppConfigs.Save(conf); Close(); }
private void LoadAppConfigs() { try { WebRequest webRequest = new WebRequest(); webRequest.Session = Session; webRequest.Code = (int)S1200Codes.GetAppConfigList; Service12001Client client = new Service12001Client( WebHelper.CreateBasicHttpBinding(Session) , WebHelper.CreateEndpointAddress(Session.AppServerInfo, "Service12001")); WebReturn webReturn = client.DoOperation(webRequest); client.Close(); if (!webReturn.Result) { WriteLog("LoadAppConfigs", string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message)); return; } if (webReturn.ListData == null) { WriteLog("LoadAppConfigs", string.Format("ListData is null")); return; } int count = webReturn.ListData.Count; if (AppConfigs == null) { AppConfigs = new AppConfigs(); } AppConfigs.ListApps.Clear(); OperationReturn optReturn; for (int i = 0; i < count; i++) { string strInfo = webReturn.ListData[i]; optReturn = XMLHelper.DeserializeObject <AppConfigInfo>(strInfo); if (!optReturn.Result) { WriteLog("LoadAppConfigs", string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message)); continue; } AppConfigInfo info = optReturn.Data as AppConfigInfo; if (info == null) { WriteLog("LoadAppConfigs", string.Format("AppConfigInfo is null")); continue; } AppConfigs.ListApps.Add(info); } WriteLog("LoadAppConfigs", string.Format("Load end.\tCount:{0}", count)); } catch (Exception ex) { WriteLog("LoadAppConfigs", string.Format("Fail.\t{0}", ex.Message)); } }
private void StartWatching() { watcher = new FileSystemWatcher(); watcher.Path = string.Concat(AppConfigs.Load().SavePath, "\\"); watcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.LastAccess | NotifyFilters.CreationTime | NotifyFilters.FileName; watcher.Filter = "clipboard_ServerToClient.txt"; watcher.Created += Watcher_Created; watcher.Changed += Watcher_Created; watcher.EnableRaisingEvents = true; }
internal Fs AppFs(string appName) { Fs result = null; AppConf conf = AppConfigs.Where(ac => ac.Name.Equals(appName) || ac.Name.Equals(appName.ToLowerInvariant())).FirstOrDefault(); if (conf != null) { result = conf.AppRoot; } return(result); }
public DataContext CreateDbContext(string[] args) { string connectionString = AppConfigs.GetDbConnectionString(); var dbContextOptionsBuilder = new DbContextOptionsBuilder <DataContext>(); dbContextOptionsBuilder.UseSqlServer(connectionString); DbContextOptions <DataContext> dbContextOptions = dbContextOptionsBuilder.Options; return(new DataContext(dbContextOptions)); }
public void StartProcess() { var currentDate = DateTime.Now; //ProcessData.GetData(); var date = currentDate.ToString("yyyy-MM-dd"); currentDate = DateTime.Parse(date); if (AppConfigs.LastRun < currentDate) { // UploadFile.ProcessFile(); AppConfigs.UpdateAppconfig(); } }
private void btnSave_Click(object sender, EventArgs e) { AppConfigs conf = new AppConfigs(); int MaxSize = 1; if (int.TryParse(txtMaxSize.Text, out MaxSize)) { conf.MaxSize = MaxSize; } conf.Employees = ValidUsers_bindingList.ToList <Employee>(); conf.ValidExtensions = ValidExtensions_bindingList.ToList <FileExtensions>(); AppConfigs.Save(conf); Close(); }
public void OnIntroducerInputApply(bool result) { if (SelectedModel?.PersonID > 0) { cache.Remove(SelectedModel.PersonID ?? 0); } if (result) { Task.Run(RefreshIntroducers); } AppConfigs.Update(); ViewState = STATE_VIEW; AppUIManager.Manager.Remove(AppRegions.Introducer, AppModules.IntroducerInput); }
public DataContext CreateDbContext(string[] args) { DbOption selectedDbOption = AppConfigs.SelectedDbOption(); var dbContextOptionsBuilder = new DbContextOptionsBuilder<DataContext>(); switch (selectedDbOption.DbType) { case DbTypes.SqlServer: dbContextOptionsBuilder.UseSqlServer(selectedDbOption.ConnectionStr); break; default: throw new ArgumentOutOfRangeException(); } DbContextOptions<DataContext> dbContextOptions = dbContextOptionsBuilder.Options; return new DataContext(dbContextOptions); }
private void SaveLogonName(string loginName) { AppConfigs ac = new AppConfigs(); //如果在appconfig中还不存在该用户,则保存该用户登陆名 if (!ac.valueExistInAppSettings(loginName)) { ac.addAppSettings("user", loginName); //如果选择了记住密码,则保存对应密码 if (chb_remberPassword.IsChecked.Value) { System.Text.Encoding encoder = System.Text.Encoding.UTF8; Byte[] data = XXTEA.Encrypt(encoder.GetBytes(pwdPassword.Password), encoder.GetBytes("1234567890abcdef")); string password = System.Convert.ToBase64String(data); ac.addAppSettings(loginName, password); } } //如果该用户已经存在,则判断是否选择保存密码 else { if (chb_remberPassword.IsChecked.Value) { //如果保存密码,则察看该用户密码是否已经存在,如果不存在则保存密码 System.Text.Encoding encoder = System.Text.Encoding.UTF8; Byte[] data = XXTEA.Encrypt(encoder.GetBytes(pwdPassword.Password), encoder.GetBytes("1234567890abcdef")); string password = System.Convert.ToBase64String(data); if (!ac.keyExistInAppSettings(loginName)) { ac.addAppSettings(loginName, password); } else { ac.updateAppSettings(loginName, password); } } else { //如果不保存密码,则察看该用户密码是否已经存在,如果存在则删除该密码 if (ac.keyExistInAppSettings(loginName)) { ac.delAppSettings(loginName); } } } }
public void Send(string FilePath) { string _fName = string.Concat(Path.GetFileName(FilePath), "■", AppConfigs.Load().DomainUsername); // append username to filename Socket clientSock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); byte[] fileName = Encoding.UTF8.GetBytes(_fName); //file name byte[] fileData = File.ReadAllBytes(FilePath); //file byte[] fileNameLen = BitConverter.GetBytes(fileName.Length); //lenght of file name byte[] m_clientData = new byte[4 + fileName.Length + fileData.Length]; fileNameLen.CopyTo(m_clientData, 0); fileName.CopyTo(m_clientData, 4); fileData.CopyTo(m_clientData, 4 + fileName.Length); clientSock.Connect(AppConfigs.Load().ServerIP, _portSend); //target machine's ip address and the port number clientSock.Send(m_clientData); clientSock.Close(); }
public void InitializeConfigs() { //Read the Test Configs(including the ones in app.config) string nameOfTestingDirectory = Assembly.GetExecutingAssembly().GetName().Name; //Get the current context path TestConfigs.SetCurrentContextPath(nameOfTestingDirectory); //Read the Test Configs (including the ones in app.config) TestConfigs.Init(); //This is a workaround to overcome the problem of placing all the configs under the test project string applicationConfigs = TestConfigs.AutomationDirectory.Replace(".Automation.Test", ".Automation.Application"); //Read Application Configs AppConfigs.ReadApplicationConfigs(applicationConfigs); ////TODO: Virtual ////Read the automated app configs //TestConfigs.ReadApplicationConfigs(); }
private static IHostBuilder GetHostBuilder(string[] args) { string[] urls = AppConfigs.AppUrls(); IHostBuilder hostBuilder = Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup <Startup>() .ConfigureAppConfiguration((hostingContext, config) => { AppConfigs.PrepareConfig(config); }) .ConfigureLogging((host, logging) => { logging.ClearProviders(); logging.AddConsole(); }) .UseUrls(urls) ; }); return(hostBuilder); }
/// <summary> /// get rebuilt kv list /// </summary> /// <param name="configid"></param> /// <returns></returns> public List <KeyValuePair <AppConfigs.SingleCardStatus, int> > CountStatus(string configid) { var originals = AppConfigs.GetStatusSingleCard(); //orignal enum data. List <KeyValuePair <AppConfigs.SingleCardStatus, int> > dbList = _DAL.CountStatus(configid); List <KeyValuePair <AppConfigs.SingleCardStatus, int> > rslt = new List <KeyValuePair <AppConfigs.SingleCardStatus, int> >(); foreach (var item in originals) { if (!dbList.Any(a => a.Key == (AppConfigs.SingleCardStatus)item.Key)) { rslt.Add(new KeyValuePair <AppConfigs.SingleCardStatus, int>((AppConfigs.SingleCardStatus)item.Key, 0)); } } rslt.AddRange(dbList); return(rslt); }
public void ConfigureServices(IServiceCollection services) { services.AddCors(options => { options.AddPolicy(ALLOWED_ORIGIN_POLICY, builder => { builder.AllowAnyHeader() .AllowAnyMethod() .AllowAnyOrigin(); }); }); services.AddControllers() .AddNewtonsoftJson(options => { options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); options.SerializerSettings.DefaultValueHandling = DefaultValueHandling.Include; options.SerializerSettings.StringEscapeHandling = StringEscapeHandling.Default; options.SerializerSettings.TypeNameAssemblyFormatHandling = TypeNameAssemblyFormatHandling.Full; options.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc; options.SerializerSettings.DateFormatHandling = DateFormatHandling.IsoDateFormat; options.SerializerSettings.ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor; }) .AddApplicationPart(typeof(HomeController).Assembly); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo()); }); string connectionString = AppConfigs.GetDbConnectionString(); services.AddDbContext <DataContext>((provider, builder) => { var loggerFactory = provider.GetService <ILoggerFactory>(); builder.UseLoggerFactory(loggerFactory) .EnableSensitiveDataLogging() .UseSqlServer(connectionString); }); services.AddScoped <IUserRepository, UserRepository>(); }
public void ReadCallback(IAsyncResult ar) { pb.Invoke(new ReceiveDelegate(pbShow)); int fileNameLen = 1; String content = String.Empty; StateObject state = (StateObject)ar.AsyncState; Socket handler = state.workSocket; int bytesRead = handler.EndReceive(ar); if (bytesRead > 0) { if (_flag == 0) { fileNameLen = BitConverter.ToInt32(state.buffer, 0); string fileName = Encoding.UTF8.GetString(state.buffer, 4, fileNameLen); _receivedPath = AppConfigs.Load().SavePath + "\\" + fileName; _flag++; } if (_flag >= 1) { BinaryWriter writer = new BinaryWriter(File.Open(_receivedPath, FileMode.Create)); if (_flag == 1) { writer.Write(state.buffer, 4 + fileNameLen, bytesRead - (4 + fileNameLen)); _flag++; } else { writer.Write(state.buffer, 0, bytesRead); } writer.Close(); handler.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0, new AsyncCallback(ReadCallback), state); } } else { pb.Invoke(new ReceiveDelegate(pbHide)); } }
protected void RunProcess(object sender, ElapsedEventArgs e) { try { var currentDate = DateTime.Now; var date = currentDate.ToString("yyyy-MM-dd"); ProcessData.GetData(); currentDate = DateTime.Parse(date); if (AppConfigs.LastRun < currentDate) { UploadFile.ProcessFile(); AppConfigs.UpdateAppconfig(); } } catch (Exception x) { EventLogging.LogError("Error Msg : " + x.Message + "\n" + "Source : " + x.Source + "\n" + "Event : RunProcess"); } }
/// <summary> /// /// </summary> /// <param name="ConfigPath"></param> /// <param name="fileName"> Contains username eg : test.txt■mabna\sharafi</param> /// <returns></returns> public static string GetSavePath(string ConfigPath, string fileNameWithUsername) { try { #if DEBUG using (EventLog eventLog = new EventLog("Application")) { eventLog.Source = "EFTService"; eventLog.WriteEntry("GetSavePath fileNameWithUsername : "******" ConfigPath : " + ConfigPath, EventLogEntryType.Information, 101, 1); } #endif JavaScriptSerializer _serializer = new JavaScriptSerializer(); ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap(); AppConfigs conf = new AppConfigs(); fileMap.ExeConfigFilename = ConfigPath; Configuration config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None); var settings = config.AppSettings.Settings; if (settings["AppConfigs"] != null && settings["AppConfigs"].Value != "") { conf = (AppConfigs)_serializer.Deserialize(settings["AppConfigs"].Value, typeof(AppConfigs)); } string currUser = fileNameWithUsername.Split('■')[1]; string filename = fileNameWithUsername.Split('■')[0]; return(conf.Employees.Where(e => e.Username.Trim().ToLower() == currUser.Trim().ToLower()).FirstOrDefault().SavePath + "\\" + filename); } catch (Exception ex) { using (EventLog eventLog = new EventLog("Application")) { eventLog.Source = "EFTService"; eventLog.WriteEntry("GetSavePath ex : " + ex.Message + Environment.NewLine + ex.StackTrace, EventLogEntryType.Error, 101, 1); } return(""); } }
private async void Page_Loaded(object sender, RoutedEventArgs e) { string strErrorMsg = string.Empty; AppConfigs ac = new AppConfigs(); List <string> user_list = ac.getAppSettingsByKey("user"); foreach (string name in user_list) { cmb_loginName.Items.Add(name); } if (cmb_loginName.Items.Count > 0) { cmb_loginName.SelectedIndex = 0; List <string> pass_list = ac.getAppSettingsByKey(cmb_loginName.Text); if (pass_list.Count > 0) { //有密码信息,增解密并设置 System.Text.Encoding encoder = System.Text.Encoding.UTF8; try { pwdPassword.Password = encoder.GetString(XXTEA.Decrypt(System.Convert.FromBase64String(pass_list[0]), encoder.GetBytes("1234567890abcdef"))); chb_remberPassword.IsChecked = true; } catch (Exception) { //AisinoMessageBox.Show("记录密码读取错误", "提示", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); //AisinoMessageBox.Show("记录密码读取错误", UIResources.MsgInfo, MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); strErrorMsg = "记录密码读取错误"; } if (strErrorMsg != string.Empty) { await DialogManager.ShowMessageAsync(Application.Current.MainWindow as MetroWindow, UIResources.MsgInfo, strErrorMsg, MessageDialogStyle.Affirmative, null); } } } cmb_loginName.Focus(); }
public static void InitializeConfigurations(IConfiguration configuration) { AppConfigs.CreateInstance(configuration); }
public FrmSettings() { InitializeComponent(); AppConfigs conf = new AppConfigs(); }
/// <summary> /// 点击登录按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SignUp_Click(object sender, RoutedEventArgs e) { try { ThriftServiceNameSpace.ThriftService its = new ThriftServiceNameSpace.ThriftService(); string ip = IP.Text; string port = Port.Text; int result = ThriftServiceBasic.Singin(ref ip, ref port); if (result == 200) { if (GlobalCache.Func_AutoSignin) { autoLogin.Stop(); //auto singin funcation } if (Config.SaveUserInfo(IP.Text, Port.Text) == 200) //save ip&port { AppConfigs.AsyncSelectFaceType(); var config = Config.RegionList.FirstOrDefault(region => region.RegionNO == GlobalCache.AppRegion); if (config != null) { try { GlobalCache.AppLocation = config.RegionName; MainWindow _mainWindow = new MainWindow(); this.Close(); _mainWindow.Show(); xiaowen = true; } catch (Exception ex) { string err = ex.Message; Logger <Login> .Log.Error("SignUp_Click", ex); MyMessage.Show("该问题需要联系技术人员处理,\n数据或程序问题"); return; } } else { MyMessage.Show("exe.config文件与AreaInfo.xml文件中的区域类型不一致"); return; } } else { MyMessage.Show("请您先检查userinfo.xml文件是否存在,若存在,\n请联系技术人员处理"); } } else if (result == 404) { MyMessage.Show(string.Format("无法连接到 {0}:{1}", ip, port)); } } catch (Exception ex) { Logger <Login> .Log.Error("SignUp_Click", ex); } finally { LoadingVisiblity = Visibility.Collapsed; } }
public void Common_Setup() { AppConfigs.Init(); } //end method Common Setup
async void AsyncSignUpFunc() { LoadingVisiblity = Visibility.Visible; try { if (string.IsNullOrEmpty(Host) && string.IsNullOrEmpty(Port)) { MyMessage.Show("IP和端口不能为空"); return; } ThriftServiceNameSpace.ThriftService its = new ThriftServiceNameSpace.ThriftService(); string ip = Host; string port = Port; int result = ThriftServiceBasic.Singin(ref ip, ref port); if (result == 200) { if (GlobalCache.Func_AutoSignin) { autoLogin.Stop(); //auto singin funcation } if (Config.SaveUserInfo(Host, Port) == 200) //save ip&port { AppConfigs.AsyncSelectFaceType(); var config = Config.RegionList.FirstOrDefault(region => region.RegionNO == GlobalCache.AppRegion); if (config != null) { try { GlobalCache.AppLocation = config.RegionName; HomeView home = new HomeView(); CurrentWindow.Close(); home.Show(); } catch (Exception ex) { string err = ex.Message; Logger <SignUpViewModel> .Log.Error("SignUp_Click", ex); MyMessage.Show("该问题需要联系技术人员处理,\n数据或程序问题"); return; } } else { MyMessage.Show("exe.config文件与AreaInfo.xml文件中的区域类型不一致"); return; } } else { MyMessage.Show("请您先检查userinfo.xml文件是否存在,若存在,\n请联系技术人员处理"); } } else if (result == 404) { MyMessage.Show(string.Format("无法连接到 {0}:{1}", ip, port)); } } catch (Exception ex) { Logger <SignUpViewModel> .Log.Error("SignUp_Click", ex); } finally { LoadingVisiblity = Visibility.Collapsed; } }