static void Init() { //从配置文件中读取 var config = ConfigurationTool.GetAppSettings <PoolConfig>("OmniCoin.Pool.conf.json", "PoolConfig"); if (config == null) { throw new Exception("read config from OmniCoin.Pool.conf.json failed!!!"); } if (string.IsNullOrWhiteSpace(config.RabbitMqConnectString)) { throw new Exception("RabbitMqConnectString from OmniCoin.Pool.conf.json can't be null or empty!!!"); } RabbitMQ.RabbitMqSetting.CONNECTIONSTRING = config.RabbitMqConnectString; Redis.Setting.Init(config.RedisTestnetConnections, config.RedisMainnetConnections); MiningPool.Data.DataAccessComponent.MainnetConnectionString = config.MySqlMainnetConnectString; MiningPool.Data.DataAccessComponent.TestnetConnectionString = config.MySqlTestnetConnectString; Setting.Init(config.PoolMainPort, config.PoolTestPort); ConfigCenter.ConfigPool = config; RabbitMQApi.Current = new RabbitMQApi(); }
public void GetPageNumberListWhenMirrored() { Common.Testing = true; cTool = new ConfigurationTool(); cToolBL = new ConfigurationToolBL(cTool); Param.LoadSettings(); var rHItem = new SIL.PublishingSolution.ComboBoxItem("Mirrored", "Mirrored"); cTool.DdlRunningHead.Items.Add(rHItem); cTool.DdlRunningHead.SelectedItem = cTool.DdlRunningHead.Items[0]; ReloadPageNumberLocList("Mirrored", cTool); ComboBox result = cToolBL.cTool.DdlPageNumber; var expected = new ComboBox(); var item = new SIL.PublishingSolution.ComboBoxItem("Top Inside Margin", "Top Inside Margin"); expected.Items.Add(item); item = new SIL.PublishingSolution.ComboBoxItem("Top Center", "Top Center"); expected.Items.Add(item); item = new SIL.PublishingSolution.ComboBoxItem("Bottom Inside Margin", "Bottom Inside Margin"); expected.Items.Add(item); item = new SIL.PublishingSolution.ComboBoxItem("Bottom Outside Margin", "Bottom Outside Margin"); expected.Items.Add(item); item = new SIL.PublishingSolution.ComboBoxItem("Bottom Center", "Bottom Center"); expected.Items.Add(item); for (int i = 0; i < result.Items.Count; i++) { Assert.AreEqual(expected.Items[i].ToString(), result.Items[i].ToString(), String.Format("PageNumber[{0}] is loaded wrongly for Mirrored", expected.Items[i])); } Common.Testing = false; }
public void Start() { // Initialize an emty service IService service; // Configure the service to an implementation switch (_configuration.Role) { case Role.Master: service = new MasterNode(_configuration); break; // Child node creation goes here case Role.ConfigurationTool: service = new ConfigurationTool(_configuration); break; default: Log.Error("No role was specified for the node", _configuration.Name); return; } service.Start(); // TODO: Refactor to Task.Run(); while (true) { } }
static void Init(PoolArgs args) { GlobalParameters.IsTestnet = args.IsTestNet; PoolCenterConfig config = ConfigurationTool.GetAppSettings <PoolCenterConfig>("OmniCoin.PoolCenter.conf.json", "PoolCenterSetting"); if (config == null) { throw new Exception("read config from OmniCoin.PoolCenter.conf.json failed!!!"); } if (string.IsNullOrWhiteSpace(config.RabbitMqConnectString)) { throw new Exception("RabbitMqConnectString from OmniCoin.PoolCenter.conf.json can't be null or empty!!!"); } RabbitMQ.RabbitMqSetting.CONNECTIONSTRING = config.RabbitMqConnectString; Pool.Redis.Setting.Init(config.RedisTestnetConnections, config.RedisMainnetConnections); MiningPool.Data.DataAccessComponent.MainnetConnectionString = config.MySqlMainnetConnectString; MiningPool.Data.DataAccessComponent.TestnetConnectionString = config.MySqlTestnetConnectString; ConfigCenter.ConfigPoolCenter = config; Setting.Init(config.NodeRpcMainnet, config.NodeRpcTestnet); //KafkaMQ.KafkaInfo.MqName = Setting.CENTERKAFKAGROUPNAME; NodeApi.Current = new NodeApi(Setting.API_URL); //MQApi.Init(); RabbitMQApi.Init(); }
private void buttonCreateProfileConfig_Click(object sender, RoutedEventArgs e) { MessageBoxResult messageBoxResult = MessageBox.Show("This will close the current profile. Are you sure?", "New configuration confirmation", MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) { ConfigurationTool config = new ConfigurationTool(this.selectedGlove); config.ShowDialog(); refreshControls(); } }
private void CurrentProfileMenuItem_Click(object sender, RoutedEventArgs e) { if (selectedGlove.GloveConfiguration.GloveProfile.Mappings.Count != 0) { ConfigurationTool config = new ConfigurationTool(selectedGlove); config.Show(); } else { MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("No profile loaded.", "No profile", System.Windows.MessageBoxButton.OK); } }
public CommonResponse Test() { ServerSetting setting = ConfigurationTool.GetAppSettings <ServerSetting>("OmniCoin.MiningPool.API.conf.json", "ServerSetting"); if (setting.IsTestNet) { return(OK("Test")); } else { return(OK("Main")); } }
public void Start() { if (isStart) { return; } isStart = true; var setting = ConfigurationTool.GetAppSettings <ServerSetting>("OmniCoin.MiningPool.API.conf.json", "ServerSetting"); isTestnet = setting.IsTestNet; MinerAmount = setting.MinerAmount; updateServerTimer = new Timer(); updateServerTimer.Elapsed += UpdateServerTimer_Elapsed; updateServerTimer.Interval = 1000; updateServerTimer.Start(); }
public static void Main(string[] args) { ServerSetting setting = ConfigurationTool.GetAppSettings <ServerSetting>("OmniCoin.MiningPool.API.conf.json", "ServerSetting"); if (setting == null) { throw new System.Exception("ServerSetting read from OmniCoin.MiningPool.API.conf.json failed !!!"); } //OmniCoin.RabbitMQ.RabbitMqSetting.CONNECTIONSTRING = config.RabbitMqConnectString; Pool.Redis.Setting.Init(setting.RedisTestnetConnections, setting.RedisMainnetConnections); MiningPool.Data.DataAccessComponent.MainnetConnectionString = setting.MySqlMainnetConnectString; MiningPool.Data.DataAccessComponent.TestnetConnectionString = setting.MySqlTestnetConnectString; GlobalParameters.IsTestnet = setting.IsTestNet; CreateWebHostBuilder(args).Build().Run(); }
public RewardList InsertRewardList(RewardList entity) { RewardListDac dac = new RewardListDac(); //if (dac.IsExisted(entity.BlockHash)) //{ // throw new Exception("block hash has existed"); //} //调接口获取奖励 //AuthenticationHeaderValue authHeaderValue = null; //RpcClient client = new RpcClient(new Uri(MiningPoolSetting.API_URI), authHeaderValue, null, null, "application/json"); //RpcRequest request = RpcRequest.WithParameterList("GetBlockReward", new List<object> { entity.BlockHash }, 1); //RpcResponse response = await client.SendRequestAsync(request); //if (response.HasError) //{ // throw new ApiCustomException(response.Error.Code, response.Error.Message); //} //long totalReward = response.GetResult<long>(); RewardList reward = new RewardList(); AwardSetting setting = ConfigurationTool.GetAppSettings <AwardSetting>("OmniCoin.MiningPool.Business.conf.json", "AwardSetting"); //double extractProportion = setting.ExtractProportion; //double serviceFeeProportion = setting.ServiceFeeProportion; reward.BlockHash = entity.BlockHash; reward.GenerateTime = entity.GenerateTime; reward.Hashes = entity.Hashes; reward.MinerAddress = entity.MinerAddress; reward.OriginalReward = entity.OriginalReward; //reward.ActualReward = Convert.ToInt64(entity.OriginalReward * extractProportion); reward.ActualReward = Convert.ToInt64(entity.OriginalReward); reward.Paid = 0; reward.PaidTime = Framework.Time.EpochStartTime.Millisecond; reward.IsCommissionProcessed = 0; reward.CommissionProcessedTime = 0; //此市transaction为“”,需要同步后才能写数据进去 reward.TransactionHash = entity.TransactionHash; dac.Insert(reward); return(reward); }
static MiningPoolSetting() { AwardSetting setting = ConfigurationTool.GetAppSettings <AwardSetting>("OmniCoin.MiningPool.Business.conf.json", "AwardSetting"); if (setting != null) { PoolType = setting.PoolType; } else { PoolType = null; } if (setting == null) { throw new Exception("config read from OmniCoin.MiningPool.Business.conf.json failed !!!"); } API_URI_MAIN = setting.NodeRpcMainnet; API_URI_TEST = setting.NodeRpcTestnet; POS_URL_MAIN = setting.PosCheckServiceUrlMainNet; POS_URL_TEST = setting.PosCheckServiceUrlTestNet; }
protected void SetUp() { cTool = new ConfigurationTool(); Common.Testing = true; cToolBL = new ConfigurationToolBL(); //_pathwayPath = Common.PathCombine(Common.GetAllUserAppPath(), "SIL/Pathway"); _pathwayPath = Common.GetAllUserPath(); stylename = new ArrayList { "OneColumn", "TwoColumn", "LikeBuangPNG", "FieldWorksStyles", "FieldWorksArabicBased", "Draft" }; string folderName = "Styles"; CopyFolderSupportToIO(folderName); }
protected void SetUp() { Common.Testing = true; _configTool = new ConfigurationTool(); string testPath = PathPart.Bin(Environment.CurrentDirectory, "/ConfigurationTool/TestFiles"); _inputBasePath = Common.PathCombine(testPath, "input"); _expectBasePath = Common.PathCombine(testPath, "Expected"); _outputBasePath = Common.PathCombine(testPath, "Output"); if (Directory.Exists(_outputBasePath)) { DirectoryInfo di = new DirectoryInfo(_outputBasePath); Common.CleanDirectory(di); } Directory.CreateDirectory(_outputBasePath); _supportSource = Common.DirectoryPathReplace(testPath + "/../../../../DistFiles"); string fileName = "DictionaryStyleSettings.xml"; CopyFilesSupportToIO(fileName); fileName = "ScriptureStyleSettings.xml"; CopyFilesSupportToIO(fileName); fileName = "StyleSettings.xml"; CopyFilesSupportToIO(fileName); fileName = "StyleSettings.xsd"; CopyFilesSupportToIO(fileName); string folderName = "Styles"; CopyFolderSupportToIO(folderName); LoadParam(); }
public static void SaveRewards(string startMsgId, long nonce, int height) { try { var block = RedisManager.Current.GetDataInRedis <BlockMsg>(startMsgId); if (block == null || block.Header.Height == 0) { return; } var miners = GetAllMiners(); var rewardAddresses = miners.Select(x => x.Address); Blocks blocks = new Blocks(); blocks.Generator = block.Header.GeneratorId; blocks.Hash = block.Header.GetHash(); blocks.Height = block.Header.Height; blocks.Nonce = nonce; var baseReward = POC.GetNewBlockReward(block.Header.Height); var totalReward = block.Transactions[0].Outputs[0].Amount; if (totalReward < baseReward) { totalReward = baseReward; } var totalRewardAllMiner = totalReward * 0.4; var totalRewardSuperNode = totalReward * 0.2; var totalRewardDepositInterest = totalReward * 0.4;//存币利息,需要派分到当前存币大于1的地址 var rewards = new List <RewardList>(); //矿工部分 long totalEffort = 0; foreach (var address in rewardAddresses) { var key = "Pool:MinerMaxNonce:" + address; var maxNonce = RedisManager.Current.GetDataInRedis <string>(key); if (string.IsNullOrEmpty(maxNonce)) { continue; } var effort = int.Parse(maxNonce); RewardList rewardList = new RewardList(); rewardList.BlockHash = blocks.Hash; rewardList.GenerateTime = blocks.Timstamp; rewardList.MinerAddress = address; rewardList.Hashes = effort; rewardList.TransactionHash = ""; rewardList.RewardType = 0; rewards.Add(rewardList); totalEffort += effort; } rewards.ForEach(x => { x.OriginalReward = (long)Math.Floor(totalRewardAllMiner * ((double)x.Hashes / (double)totalEffort)); x.ActualReward = x.OriginalReward; }); blocks.TotalHash = totalEffort; blocks.TotalReward = totalReward; //SuperNode部分 AwardSetting setting = ConfigurationTool.GetAppSettings <AwardSetting>("OmniCoin.MiningPool.Business.conf.json", "AwardSetting"); var superNodeReward = (long)totalRewardSuperNode; rewards.Add(new RewardList { OriginalReward = superNodeReward, ActualReward = superNodeReward, BlockHash = blocks.Hash, GenerateTime = blocks.Timstamp, MinerAddress = setting.SuperNodeAddress, Hashes = 0, TransactionHash = "", RewardType = 1 }); //DepositInterest部分 var currentDepositLists = new RewardListComponent().GetAllNotExpiredDeposit(); if (currentDepositLists != null && currentDepositLists.Any()) { var totalDepositAmount = currentDepositLists.Sum(x => x.Amount); currentDepositLists.ForEach(x => { //利息 = 当前数量 / 总数量 * (Coinbase * 40 % 奖励) var interest = (long)Math.Floor(totalRewardDepositInterest * ((double)x.Amount / (double)totalDepositAmount)); rewards.Add(new RewardList { OriginalReward = interest, ActualReward = interest, BlockHash = blocks.Hash, GenerateTime = blocks.Timstamp, MinerAddress = x.Address, Hashes = 0, TransactionHash = "", AddressDepositTotalAmount = x.Amount, DepositTotalAmount = totalDepositAmount, RewardType = 2, DepositTransactionHash = x.TransactionHash }); }); } var blockComponent = new BlocksComponent(); blockComponent.SaveBlockAndRewardLists(blocks, rewards); } catch (Exception ex) { LogHelper.Error(ex.ToString()); } }
/// <summary> /// Enviar comentario /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void sendButton_Click(object sender, EventArgs e) { try { String sql, strComment, segmentType = string.Empty, codLevels = string.Empty; string codSegm = string.Empty, codType = string.Empty, codLevel = string.Empty, seqLevel = string.Empty, seqLevelT = string.Empty; //,codMot=string.Empty; bool edit = false; //vfin = false; Level resultLevel = new Level(); int res; DataView dt = new DataView(); strComment = txtComment.Text.Replace("'", "''"); if (strComment.Equals("")) { wucMessageControl.Message = "Debe de proveer un comentario"; wucMessageControl.ShowPopup(); } else { /*Obtener las filas para insertar en el Logs*/ dsIncidentNotification.OperationsLogsDataTable dtIncidentLogs = new dsIncidentNotification.OperationsLogsDataTable(); dsIncidentNotificationTableAdapters.OperationsLogsTableAdapter taIncidentLogs = new dsIncidentNotificationTableAdapters.OperationsLogsTableAdapter(); taIncidentLogs.FillByCodIncidence(dtIncidentLogs, Convert.ToInt16(hidIncidentNumber.Value)); /*Obtener código de motivo de Validación*/ dsIncidentNotification.IN_CAT_MOTIVESDataTable dtMotive = new dsIncidentNotification.IN_CAT_MOTIVESDataTable(); dsIncidentNotificationTableAdapters.IN_CAT_MOTIVESTableAdapter taMotive = new dsIncidentNotificationTableAdapters.IN_CAT_MOTIVESTableAdapter(); /**Segmento de código para verificar si se hace modificación en segmentos y tipos*/ //if (trSegment.Visible == true && trType.Visible == true && trStatus.Visible == true) if (trSegment.Visible == true && trType.Visible == true) { segmentType = string.Format(",COD_SEGMENT={0},COD_TYPE={1} ", ddlSegment.SelectedValue, ddlType.SelectedValue); codSegm = ddlSegment.SelectedValue; codType = ddlType.SelectedValue; //El id de la secuencia del nivel del registro actual resultLevel.GetLevelRec(decimal.Parse(dtIncidentLogs[0]["COD_LEVEL"].ToString())); seqLevel = resultLevel.LevelsTable.Rows[0]["LEVEL_SEQUENCE"].ToString(); codLevels = resultLevel.LevelsTable.Rows[0]["COD_LEVEL"].ToString(); //código del nivel //Niveles del tipo seleccionado resultLevel.GetLevelsType(decimal.Parse(ddlType.SelectedValue.ToString())); foreach (DataRow item in resultLevel.LevelsTable.Rows) { seqLevelT = item["LEVEL_SEQUENCE"].ToString(); if (seqLevel == seqLevelT) { break; } } if (seqLevelT != seqLevel)//(seqLevelT != seqLevel) { codLevel = codLevelChg; } else { codLevel = resultLevel.GetCodLevelTypeLevel(decimal.Parse(ddlType.SelectedValue.ToString()), decimal.Parse(seqLevel)).ToString(); } //codLevel= codLevelChg; /*if (ddlStatus.SelectedItem.Text.ToString().ToUpper().Contains("FIN")) * vfin = true; */ edit = true; } taMotive.FillByOperations(dtMotive); decimal criticalityLevel = 0; if (!string.IsNullOrEmpty(dtIncidentLogs[0]["CRITICALITY"].ToString())) { criticalityLevel = decimal.Parse(dtIncidentLogs[0]["CRITICALITY"].ToString()); } sql = "DECLARE\n" + " cod_incidence_log DECIMAL;\n" + " message VARCHAR2(500);\n" + "BEGIN\n"; /* sql += "UPDATE IN_INCIDENCES\n" + * /* string.Format("SET COD_MOTIVE = {0}, \"MONITORING\" = '{1}'" /*+ ((vfin) ? " ,END_DATE=sysdate ": " "), ((edit) ? ddlStatus.SelectedValue : dtMotive.Rows[0][0], strComment) + segmentType + ((edit) ? string.Format(",COD_LEVEL={0}", codLevel) : "") + * "\nWHERE COD_INCIDENCE = " + dtIncidentLogs[0]["COD_INCIDENCE"] + ";\n";*/ sql += "UPDATE IN_INCIDENCES\n" + string.Format("SET COD_MOTIVE = {0}, \"MONITORING\" = :Monitoring", dtMotive.Rows[0][0]) + segmentType + ((edit) ? string.Format(",COD_LEVEL={0}", codLevel) : "") + "\nWHERE COD_INCIDENCE = " + dtIncidentLogs[0]["COD_INCIDENCE"] + ";\n"; sql += "SELECT COD_INCIDENCE_LOG_SEQ.NEXTVAL INTO cod_incidence_log FROM DUAL;\n" + "INSERT INTO IN_INCIDENCE_LOGS (COD_INCIDENCE_LOG,COD_INCIDENCE, COD_LEVEL, COD_MOTIVE, COD_SEGMENT, COD_TYPE, DESCRIPTION,INCIDENCE_CAUSE, \"MONITORING\",LOG_DATE, USERNAME, IS_LEVEL_CHANGE_LOG, RECEIVED_CALLS, SCRIPT, TYPOLOGY,CRITICALITY,IN_COUNTRY_PK,SUBJECT,MAINTENANCE)\n" + String.Format("VALUES (cod_incidence_log,{7},{0},{1},{2},{3},'{4}','{5}',:Monitoring,sysdate,'{6}','N',{8},'{9}','{10}',{11},{12},'{13}','{14}');\n", (edit) ? codLevel : dtIncidentLogs[0]["COD_LEVEL"], /*((edit)? ddlStatus.SelectedValue:*/ dtMotive.Rows[0][0].ToString().Replace("'", "''"), (edit) ? codSegm : dtIncidentLogs[0]["COD_SEGMENT"], (edit) ? codType : dtIncidentLogs[0]["COD_TYPE"], dtIncidentLogs[0]["DESCRIPTION"].ToString().Replace("'", "''"), dtIncidentLogs[0]["INCIDENCE_CAUSE"].ToString().Replace("'", "''"), SafetyPad.GetUserLogin(), dtIncidentLogs[0]["COD_INCIDENCE"], dtIncidentLogs[0]["RECEIVED_CALLS"], dtIncidentLogs[0]["SCRIPT"].ToString().Replace("'", "''"), dtIncidentLogs[0]["TYPOLOGY"].ToString().Replace("'", "''"), criticalityLevel, dtIncidentLogs[0]["IN_COUNTRY_PK"], dtIncidentLogs[0]["SUBJECT"], dtIncidentLogs[0]["MAINTENANCE"]); sql += "\nCOMMIT;\nSELECT IN_OPERATIONS_API.INCIDENCE_REPORT_SENT_FUN(cod_incidence_log) INTO message FROM DUAL; "; sql += "\nEND;"; try { res = ConfigurationTool.ExecQueryParam(sql, strComment); taMotive.FillByOperations(dtMotive); /*taMotive.FillByCodMotive(dtMotive,decimal.Parse (ddlStatus.SelectedValue.ToString()));*/ lblState.Text = dtMotive.Rows[0][1].ToString(); populateGridComments(Convert.ToInt16(hidIncidentNumber.Value)); //txtIncident_TextChanged(null, null); wucMessageControl.Message = "La notificación se realizó correctamente!"; wucMessageControl.Title = "Mensaje"; wucMessageControl.Image = "../include/imagenes/info_32.png"; wucMessageControl.ShowPopup(); txtComment.Text = String.Empty; /*if (vfin) * { * ddlSegment.Enabled = false; * ddlType.Enabled = false; * //ddlStatus.Enabled = false; * txtComment.Enabled = false; * sendButton.Enabled = false; * }*/ } catch (Exception ex) { wucMessageControl.Message = ex.Message; wucMessageControl.Title = "Error"; wucMessageControl.Image = "../include/imagenes/error_32.png"; SafetyPad.SetLogRecord("Operations.aspx.cs", ex.ToString()); wucMessageControl.ShowPopup(); } } } catch (Exception ex) { SafetyPad.SetLogRecord("Operations.aspx.cs", ex.ToString()); } }