static public CaptureConfig GetConfig(string sectionName) { CaptureConfig cc = new CaptureConfig(); try { SettingItem imageSetting = AppSettingHelper.GetSpecifySection(sectionName); cc.VideoDeviceName = imageSetting.ReadSetting("VideoDeviceName"); cc.ResolutionIndex = imageSetting.ReadInt("ResolutionIndex"); cc.InputPort = imageSetting.ReadInt("InputPort"); cc.VideoEncode = (VideoCodec)Enum.Parse(typeof(VideoCodec), imageSetting.ReadSetting("VideoEncode", VideoCodec.MPEG4.ToString())); cc.SoundHint = imageSetting.ReadBool("SoundHint"); cc.PopupHint = imageSetting.ReadBool("PopupHint"); cc.FrameRate = imageSetting.ReadInt("FrameRate"); cc.RecordDate = imageSetting.ReadBool("RecordDate"); } catch (Exception ex) { MsgBox.ShowException(ex); } return(cc); }
static public void SetConfig(CaptureConfig cc, string sectionName) { SettingItem imageSetting = AppSettingHelper.GetSpecifySection(sectionName); imageSetting.BatchBegin(); try { imageSetting.WriteSetting("VideoDeviceName", cc.VideoDeviceName); imageSetting.WriteInt("ResolutionIndex", cc.ResolutionIndex); imageSetting.WriteInt("InputPort", cc.InputPort); imageSetting.WriteSetting("VideoEncode", cc.VideoEncode.ToString()); imageSetting.WriteBool("SoundHint", cc.SoundHint); imageSetting.WriteBool("PopupHint", cc.PopupHint); imageSetting.WriteInt("FrameRate", cc.FrameRate); imageSetting.WriteBool("RecordDate", cc.RecordDate); imageSetting.BatchCommit(); } catch (Exception ex) { imageSetting.BatchCancel(); MsgBox.ShowException(ex); } }
public async void Run() { // check allow scheduler if ((bool)AppSettingHelper.GetAppSetting(typeof(bool), "AllowScheduler", true, false)) { // construct a scheduler factory var props = new NameValueCollection { { "quartz.serializer.type", "binary" } }; // init schedule var schedFact = new StdSchedulerFactory(props); // get a scheduler _sched = await schedFact.GetScheduler(); // job scheduler // init job var jobScheduler = JobBuilder.Create <JobScheduler>() .WithIdentity("jobScheduler", "scheduler").Build(); var triggerScheduler = TriggerBuilder.Create() .WithIdentity("triggerScheduler", "scheduler") .WithCronSchedule((string)AppSettingHelper.GetAppSetting(typeof(string), "CronExpression", CronExpression, false)) .WithSimpleSchedule(x => x.WithIntervalInSeconds(60).RepeatForever().WithMisfireHandlingInstructionFireNow()) .ForJob(jobScheduler) .Build(); // add to schedule await _sched.ScheduleJob(jobScheduler, triggerScheduler); // start await _sched.Start(); } }
public void Prepare() { var uri = AppSettingHelper.GetOne("UpdateServer"); ThrowHelper.TryThrow("" != uri, StepEnum.OnPrepare, Language.I.Text("empty_update_uri", "Can not get update url!")); this.updateChecker.SetURI(uri); }
private void FrmAccount_Load(object sender, System.EventArgs e) { if (Context == null) { Context = AppSettingHelper.GetApiContext(); Context.ApiLogManager = new ApiLogManager(); Context.ApiLogManager.ApiLoggerList.Add(new eBay.Service.Util.FileLogger("Log.txt", true, true, true)); Context.ApiLogManager.EnableLogging = true; Context.Site = eBay.Service.Core.Soap.SiteCodeType.US; } string[] sites = Enum.GetNames(typeof(SiteCodeType)); foreach (string site in sites) { if (site != "CustomCode") { CboSite.Items.Add(site); } } string[] langs = Enum.GetNames(typeof(ErrorLanguageCodeType)); foreach (string lang in langs) { if (lang != "CustomCode") { CboLanguage.Items.Add(lang); } } CboSite.SelectedIndex = 0; SetBindings(); }
private void replaceConfigSettings() { XmlDocument xDoc = new XmlDocument(); AppDomain myDomain = System.AppDomain.CurrentDomain; string sFileName = myDomain.SetupInformation.ConfigurationFile; try { AppSettingHelper.SetAppSetting(AppSettingHelper.DEV_ID, Context.ApiCredential.ApiAccount.Developer); AppSettingHelper.SetAppSetting(AppSettingHelper.APP_ID, Context.ApiCredential.ApiAccount.Application); AppSettingHelper.SetAppSetting(AppSettingHelper.CERT_ID, Context.ApiCredential.ApiAccount.Certificate); //annotated by peter // AppSettingHelper.SetAppSetting(AppSettingHelper.EBAY_USER, Context.ApiCredential.eBayAccount.UserName); // AppSettingHelper.SetAppSetting(AppSettingHelper.EBAY_PASSWORD, Context.ApiCredential.eBayAccount.Password); AppSettingHelper.SetAppSetting(AppSettingHelper.API_TOKEN, Context.ApiCredential.eBayToken); AppSettingHelper.SetAppSetting(AppSettingHelper.API_SERVER_URL, Context.SoapApiServerUrl); AppSettingHelper.SetAppSetting(AppSettingHelper.SIGNIN_URL, Context.SignInUrl); AppSettingHelper.SetAppSetting(AppSettingHelper.EPS_SERVER_URL, Context.EPSServerUrl); AppSettingHelper.SetAppSetting(AppSettingHelper.VERSION, Context.Version); AppSettingHelper.SetAppSetting(AppSettingHelper.TIME_OUT, Context.Timeout.ToString()); AppSettingHelper.SetAppSetting(AppSettingHelper.LOG_FILE_NAME, ((eBay.Service.Util.FileLogger)(Context.ApiLogManager.ApiLoggerList.ItemAt(0))).FileName); AppSettingHelper.SaveAppSettings(); } catch (Exception ex) { #if DEBUG System.Windows.Forms.MessageBox.Show("replaceConfigSettings()" + ex.Message); #else System.Windows.Forms.MessageBox.Show("Unable to save changes"); #endif xDoc = null; } }
private void APIAccount_Load(object sender, EventArgs e) { if (apiContext == null) { apiContext = AppSettingHelper.GetApiContext(); apiContext.ApiLogManager = new ApiLogManager(); LoggingProperties logProps = AppSettingHelper.GetLoggingProperties(); apiContext.ApiLogManager.ApiLoggerList.Add(new FileLogger(logProps.LogFileName, true, true, true)); apiContext.ApiLogManager.EnableLogging = true; apiContext.Site = SiteCodeType.US; } string[] sites = Enum.GetNames(typeof(SiteCodeType)); foreach (string site in sites) { if (site != "CustomCode") { CboSite.Items.Add(site); } } string[] langs = Enum.GetNames(typeof(ErrorLanguageCodeType)); foreach (string lang in langs) { if (lang != "CustomCode") { CboLanguage.Items.Add(lang); } } CboSite.SelectedIndex = 0; SetBindings(); }
private static void Main(string[] args) { try { CacheHelper.DeleteCacheString("cache"); var repositoryConfig = new RepositoryConfiguration { ConnectionString = AppSettingHelper.GetDbConnection() }; string rootAddress = "0x15118dB6ED8Fa2f461d62F395DC55C51c42f3488"; string rootPassword = "******"; EthereumRpc.SetAdminAddressPassword(rootAddress, rootPassword); for (var i = 0; i < 1; i++) { var ts = new Thread(() => RunSend(repositoryConfig)); ts.Start(); } } catch (Exception e) { Console.WriteLine(e.ToString()); } }
public void CreateAllWalletForUser(string userId) { var repositoryConfig = new RepositoryConfiguration() { ConnectionString = AppSettingHelper.GetDbConnection() }; var persistence = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig); _walletBusiness = new Vakapay.WalletBusiness.WalletBusiness(persistence); var user = new User(); user.Id = userId; //blockChain.Name = NetworkName.ETH; //var resultTest = _walletBusiness.CreateNewWallet(user, blockChain.Name); //Assert.AreEqual(Status.StatusSuccess, resultTest.Status); //blockChain.Name = NetworkName.BTC; //_walletBusiness.CreateNewWallet(user, blockChain.Name); //Assert.AreEqual(Status.StatusSuccess, resultTest.Status); //blockChain.Name = NetworkName.VAKA; //_walletBusiness.CreateNewWallet(user, blockChain.Name); var resultTest = _walletBusiness.MakeAllWalletForNewUser(user); Console.WriteLine(JsonHelper.SerializeObject(resultTest)); Assert.AreEqual(Status.STATUS_SUCCESS, resultTest.Status); }
public async Task <ReturnObject> TestSmartContractFunction() { try { // var unlockResult = await web3.Personal.UnlockAccount.SendRequestAsync(senderAddress, password, new HexBigInteger(120)); // Assert.True(unlockResult); // bool unlockResult = await Web3Api.UnlockAccount(AppSettingHelper.GetSmartContractPublicKey(), AppSettingHelper.GetSmartContractPrivateKey(), 120); string abi = AppSettingHelper.GetSmartContractAbi(); Nethereum.Contracts.Contract contract = Web3Api.GetContract(abi, AppSettingHelper.GetSmartContractAddress()); Function funct1 = Web3Api.getFunction(contract, "balanceDollars"); var result1 = await funct1.CallAsync <BigInteger>("0xc942F1D286d9b8002206CbB3196f46Fa892aAD93"); Function funct = Web3Api.getFunction(contract, "transfer"); var _thing = await funct.SendTransactionAndWaitForReceiptAsync( AppSettingHelper.GetSmartContractPublicKey(), null, "0xc942F1D286d9b8002206CbB3196f46Fa892aAD93", 100000000000000); // var result = await funct.CallDeserializingToObjectAsync<bool>("0xc942F1D286d9b8002206CbB3196f46Fa892aAD93", 100000000000000); Console.WriteLine(_thing); return(new ReturnObject { Status = Status.STATUS_COMPLETED, }); } catch (Exception e) { Console.WriteLine(e.ToString()); return(new ReturnObject { Status = Status.STATUS_ERROR, Message = e.Message }); } }
static void Main(string[] args) { var persistenceFactory = new SmartContractRepositoryMysqlPersistenceFactory(new RepositoryConfiguration { ConnectionString = AppSettingHelper.GetDbConnection() }); var addAddressBusiness = new AutoCreateAddress.AutoCreateAddress(persistenceFactory); while (true) { try { var result = addAddressBusiness.CreateAddressAsync(); Console.WriteLine(JsonHelper.SerializeObject(result)); } catch (Exception e) { Console.WriteLine(e.ToString()); } Thread.Sleep(1000); } }
public static void ExecuteNonQuery(string storedProcedureName) { Exception thrownException = null; try { string connString = AppSettingHelper.GetConnectionString(); using (SqlConnection connection = new SqlConnection(connString)) { connection.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = connection; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = storedProcedureName; cmd.CommandTimeout = defaultCommandTimeout; cmd.ExecuteNonQuery(); } } catch (Exception ex) { thrownException = ex; throw ex; } finally { WriteExecutionInformation(DataAccessCallType.StoredProcedure, storedProcedureName, null, thrownException); } }
private ConnectionManager() { int limit = AppSettingHelper.GetInteger(Constant.Appsetting_MaxConnectionCount, Constant.Appsetting_MaxConnectionCount_Default); _connectionString = AppSettingHelper.GetConnectionString(Constant.Connection_Name, Constant.Connection_String_Default); _connectionLimit = new Semaphore(limit, limit); }
public void RetryExecute(Action action) { int retryTime = AppSettingHelper.GetInteger(Constant.Appsetting_RetryTime, Constant.Appsetting_RetryTime_Default); try { do { try { action(); break; } catch (SqlException sqlEx) { _log.Log(sqlEx); _log.Log(string.Format("Retring Time Remains: {0}", retryTime)); if (retryTime <= 0) { throw; } } }while ((retryTime--) > 0); } finally { } }
public void FakeDeposite(int numOfTrans) { var repositoryConfig = new RepositoryConfiguration { ConnectionString = AppSettingHelper.GetDbConnection() }; var persistenceFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig); _ethBus = new Vakapay.EthereumBusiness.EthereumBusiness(persistenceFactory); var trans = new EthereumDepositTransaction() { UserId = "8377a95b-79b4-4dfb-8e1e-b4833443c306", ToAddress = "0x12890d2cce102216644c59dae5baed380d84830c", FromAddress = "0x3a2e25cfb83d633c184f6e4de1066552c5bf4517", Amount = 10 }; ReturnObject outPut = null; for (int i = 0; i < numOfTrans; i++) { outPut = _ethBus.FakeDepositTransaction(trans); } Console.WriteLine(JsonHelper.SerializeObject(outPut)); Assert.IsNotNull(outPut); }
public void AfterLogin() { Console.WriteLine("start"); var repositoryConfig = new RepositoryConfiguration { ConnectionString = AppSettingHelper.GetDbConnection() }; Console.WriteLine("New Address"); PersistenceFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig); var userBus = new UserBusiness.UserBusiness(PersistenceFactory); var walletBusiness = new WalletBusiness.WalletBusiness(PersistenceFactory); var userRepo = PersistenceFactory.GetUserRepository(PersistenceFactory.GetOldConnection()); var resultCreated = userBus.Login( new User { Email = "*****@*****.**", PhoneNumber = "+84988478266", FullName = "Ngo Ngoc Huan" }); walletBusiness.MakeAllWalletForNewUser(userRepo.FindByEmailAddress("*****@*****.**")); Console.WriteLine(JsonHelper.SerializeObject(resultCreated)); Assert.IsNotNull(resultCreated); resultCreated = userBus.Login( new User { Email = "*****@*****.**", PhoneNumber = "+84965995710", FullName = "Tieu Thanh Liem" }); walletBusiness.MakeAllWalletForNewUser(userRepo.FindByEmailAddress("*****@*****.**")); Console.WriteLine(JsonHelper.SerializeObject(resultCreated)); Assert.IsNotNull(resultCreated); }
private static void Main() { var repositoryConfig = new RepositoryConfiguration { ConnectionString = AppSettingHelper.GetDbConnection() }; var persistenceFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig); var sendSmsBusiness = new SendSmsBusiness.SendSmsBusiness(persistenceFactory); while (true) { try { var result = sendSmsBusiness.SendSmsAsync(AppSettingHelper.GetElasticSmsUrl(), AppSettingHelper.GetElasticApiKey()); Console.WriteLine(JsonHelper.SerializeObject(result.Result)); } catch (Exception e) { Console.WriteLine(e); throw; } Thread.Sleep(1000); } }
private HttpUitls() { //初始化 httpClient = new HttpClient(); var url = AppSettingHelper.getAppConfig("baseUrl"); if (url != null) { httpClient.BaseAddress = new Uri(url); } if (string.IsNullOrEmpty(Properties.Settings.Default.IMEI)) { Properties.Settings.Default.IMEI = "windows:" + Guid.NewGuid().ToString().Replace("-", ""); Properties.Settings.Default.Save(); } httpClient.Timeout = TimeSpan.FromSeconds(30); httpClient.DefaultRequestHeaders.Add("dbrand", new GetOSystem().getSystem()); httpClient.DefaultRequestHeaders.Add("deviceinfo", new GetOSystem().getSystem()); httpClient.DefaultRequestHeaders.Add("client", "windows"); httpClient.DefaultRequestHeaders.Add("imei", Properties.Settings.Default.IMEI); Assembly currentAssembly = Assembly.LoadFile(Assembly.GetExecutingAssembly().Location); httpClient.DefaultRequestHeaders.Add("version", currentAssembly.GetName().Version.ToString()); downloadUrls = new List <string>(); request = new NetworkTaskScheduler(Environment.ProcessorCount); }
public static DataSet ExecuteStoredProcedure(string storedProcedureName, string dataSetName) { DataSet returnData = new DataSet(); Exception thrownException = null; try { string connString = AppSettingHelper.GetConnectionString(); using (SqlConnection connection = new SqlConnection(connString)) { connection.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = connection; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = storedProcedureName; cmd.CommandTimeout = defaultCommandTimeout; returnData.DataSetName = dataSetName; SqlDataAdapter dataAdapter = new SqlDataAdapter(cmd); dataAdapter.Fill(returnData); } } catch (Exception ex) { thrownException = ex; throw ex; } finally { WriteExecutionInformation(DataAccessCallType.StoredProcedure, storedProcedureName, null, thrownException); } return(returnData); }
private void InitialTray() { //实例化一个NotifyIcon对象 notifyIcon = new NotifyIcon(); //托盘图标气泡显示的内容 notifyIcon.BalloonTipText = AppSettingHelper.GetOne("IconHint", "Print server was runing in backgroud"); //托盘图标显示的内容 notifyIcon.Text = AppSettingHelper.GetOne("HideHint", "Click icon to open main window"); notifyIcon.Icon = this.GetTaskBarIcon(); //true表示在托盘区可见,false表示在托盘区不可见 notifyIcon.Visible = true; //气泡显示的时间(单位是毫秒) notifyIcon.ShowBalloonTip(2000); //notifyIcon.MouseClick += notifyIcon_MouseClick; MenuItem reciveNoti = new MenuItem("接收通知"); //reciveNoti.Click += reciveNoti_Click; MenuItem stopNoti = new MenuItem("暂停通知"); //stopNoti.Click += about_Click; MenuItem exit = new MenuItem("退出"); //exit.Click += new EventHandler(exit_Click); ////关联托盘控件 //注释的这一行与下一行的区别就是参数不同,setting这个参数是为了实现二级菜单 //MenuItem[] childen = new MenuItem[] { setting, help, about, exit }; MenuItem[] childen = new MenuItem[] { reciveNoti, stopNoti, exit }; notifyIcon.ContextMenu = new ContextMenu(childen); //窗体关闭时触发 this.FormClosing += this.Main_FormClosing; }
private static void RunSend(RepositoryConfiguration repositoryConfig) { var repoFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig); var bitcoinBusiness = new BitcoinBusiness.BitcoinBusiness(repoFactory); var connection = repoFactory.GetOldConnection() ?? repoFactory.GetDbConnection(); try { while (true) { Console.WriteLine("Start Send Bitcoin...."); var rpc = new BitcoinRpc(AppSettingHelper.GetBitcoinNode(), AppSettingHelper.GetBitcoinRpcAuthentication()); using (var bitcoinRepo = repoFactory.GetBitcoinWithdrawTransactionRepository(connection)) { var resultSend = bitcoinBusiness.SendTransactionAsync(bitcoinRepo, rpc); Console.WriteLine(JsonHelper.SerializeObject(resultSend.Result)); Console.WriteLine("Send Bitcoin End..."); Thread.Sleep(1000); } } } catch (Exception e) { connection.Close(); _logger.Error(e, "Send Bitcoin"); Console.WriteLine(e.ToString()); } }
public async System.Threading.Tasks.Task CreateNewAddressAsync(string walletId) { var repositoryConfig = new RepositoryConfiguration { ConnectionString = AppSettingHelper.GetDbConnection() }; var persistenceFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig); _ethBus = new Vakapay.EthereumBusiness.EthereumBusiness(persistenceFactory); var connection = persistenceFactory.GetDbConnection(); using (var ethAddressRepos = persistenceFactory.GetEthereumAddressRepository(connection)) { _walletBusiness = new WalletBusiness.WalletBusiness(persistenceFactory); string pass = "******"; // var resultTest = _ethBus.CreateNewAddAddress(wallet); var outPut = await _ethBus.CreateAddressAsync <EthereumAddress>(ethAddressRepos, RpcClass, walletId, pass); Assert.IsNotNull(outPut); } }
private static void RunSend(RepositoryConfiguration repositoryConfig) { var repoFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig); var ethereumBusiness = new EthereumBusiness.EthereumBusiness(repoFactory); var connection = repoFactory.GetDbConnection(); try { while (true) { Console.WriteLine("Start Send Ethereum...."); var rpc = new EthereumRpc(AppSettingHelper.GetEthereumNode()); using (var ethereumRepo = repoFactory.GetEthereumWithdrawTransactionRepository(connection)) { var resultSend = ethereumBusiness.SendTransactionAsync(ethereumRepo, rpc); Console.WriteLine(JsonHelper.SerializeObject(resultSend.Result)); Console.WriteLine("Send Ethereum End..."); Thread.Sleep(1000); } } } catch (Exception e) { connection.Close(); Console.WriteLine(e.ToString()); } }
static GlobalConfig() { CacheType = AppSettingHelper.Get <string>("CacheType", "cache").ToUpper(); CacheTime = AppSettingHelper.Get <int>("CacheTime", 120); SessionType = AppSettingHelper.Get <string>("SessionType", "cache").ToUpper(); RedisPath = AppSettingHelper.Get <string>("RedisPath"); }
private IocContainer() { this.DBType = AppSettingHelper.Get("DBType"); this.Builder = new ContainerBuilder(); this.Register(this.Builder); this.Container = this.Builder.Build(); }
public HttpResponseMessage GetZookeeperHost() { var host = AppSettingHelper.Get <string>("ZookeeperHost"); return(new HttpResponseMessage { Content = new StringContent(host, Encoding.GetEncoding("UTF-8"), "text/plain") }); }
private int GetServerPort() { var portString = AppSettingHelper.GetOne("ServerPort", this.port.ToString()); int.TryParse(portString, out this.port); return(this.port); }
public Entity() { var mongoUrl = new MongoUrl(AppSettingHelper.GetStringFromFileJson("connectstring", "ConnectionStrings:DefaultConnection").Result); _MongoClient = new MongoClient(mongoUrl.ToString().Replace(@"/" + mongoUrl.DatabaseName, "")); _MongoDatabase = _MongoClient.GetDatabase(mongoUrl.DatabaseName); }
private static void Main(string[] args) { var repositoryConfig = new RepositoryConfiguration { ConnectionString = AppSettingHelper.GetDbConnection() }; RunScan(repositoryConfig); }
public AddressController() { var repositoryConfig = new RepositoryConfiguration { ConnectionString = AppSettingHelper.GetDbConnection() }; VakapayRepositoryFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig); }