private void processConfigResult(Command cmdReceived, uint optionid, ConfigResult result) { /** We receive a result for every config setting we try to update **/ /** Only report these if the form is still open, it is a serious error, if * we receive one of these when the form is closing **/ if (configDialog == null) { return; } // NB: indexes don't seem to be used here. #if !DEBUG try { #endif configDialog.Invoke((Action <uint, ConfigResult>)configDialog.setResult, optionid, result); #if !DEBUG } catch (Exception e) { var error = string.Concat("Failed to process config result:\n", e.Message, "\nStack Trace:\n", e.StackTrace); logError(error); } #endif }
public void setResult(uint optionid, ConfigResult res) { // WORK NEEDED: fix this options[optionid].setResult(res == ConfigResult.Success); if (res != ConfigResult.Success) { statusLabel.Text = string.Concat("Failed to set: ", options[optionid].getDescription(), ". Error: ", ConfigResultText.Text[(int)res]); } var allReceived = options.Values.All(op => op.hasReceivedResult()); if (!allReceived) { return; } var allSucceeded = options.Values.All(op => op.getResult()); if (allSucceeded) { closeMutex.WaitOne(); Close(); closeMutex.ReleaseMutex(); } else { saveButton.Enabled = true; } }
public async Task <ActionResult <IResult> > Get(string datastoreName, string scenarioName) { ConfigResult result = new ConfigResult(); if (string.IsNullOrWhiteSpace(datastoreName)) { result.success = false; result.responseMessage = "datastoreName不能为空。"; } else if (string.IsNullOrWhiteSpace(scenarioName)) { result.success = false; result.responseMessage = "scenarioName不能为空。"; } else { ConfigExecutor executor = new ConfigExecutor(null, datastoreName); (bool isDSExist, bool isScenarioExist, List <ColorConfig> configs) = executor.GetColorConfigs(scenarioName); if (!isDSExist) { result.success = false; result.responseMessage = "Datastore " + datastoreName + "不存在,或没有数据导入。"; } else { if (!isScenarioExist) { result.success = false; result.responseMessage = "scenario " + scenarioName + " 不存在。"; } else { result.success = true; if (configs == null) { result.responseMessage = "scenario " + scenarioName + " 没有 color config 的定义。"; } else { result.responseMessage = "一共有 " + configs.Count + " color config 的定义。"; result.entityColorConfig = new Dictionary <string, string>(); foreach (ColorConfig config in configs) { if (!result.entityColorConfig.ContainsKey(config.itemLabel)) { result.entityColorConfig.Add(config.itemLabel, config.color); } } } } } } log.Information("[Response]: " + JsonConvert.SerializeObject(result)); return(Ok(result)); }
private void loadConfigurationValues(ConfigResult cr) { // Properties tab configs this.memoryNumBox.Value = cr.Configs.memory; this.cpusNumBox.Value = cr.Configs.cpus; this.diskSizeNumBox.Value = cr.Configs.DiskSize; this.pullSecretTxtBox.Text = cr.Configs.PullSecretFile; this.consentTelemetryCheckBox.Checked = cr.Configs.ConsentTelemetry == "no" ? false : true; this.autostartTrayCheckBox.Checked = cr.Configs.AutostartTray; // proxy configs if (cr.Configs.HttpProxy != String.Empty || cr.Configs.HttpsProxy != String.Empty) { this.useProxyTick.Checked = true; enableProxyFields(); this.httpProxyTxtBox.Text = cr.Configs.HttpProxy; this.httpsProxyTxtBox.Text = cr.Configs.HttpsProxy; this.noProxyTxtBox.Text = cr.Configs.NoProxy; this.proxyCAFileTxtBox.Text = cr.Configs.ProxyCAFile; } // Advanced tab configs this.SkipCheckRunningAsAdmin.Checked = cr.Configs.SkipCheckAdminUser; this.SkipCheckWindowsVersion.Checked = cr.Configs.SkipCheckWindowsVersion; this.SkipCheckUserInHypervAdminsGroup.Checked = cr.Configs.SkipCheckUserInHypervGroup; this.nameServerTxtBox.Text = cr.Configs.nameserver; this.disableUpdateCheckBox.Checked = cr.Configs.DisableUpdateCheck; }
public Task BuildConfigLogMessageMinimal() { var config = new ConfigResult(); var message = LogBuilder.BuildConfigLogMessage("theRoot", config, "theConfigFilePath"); return(Verifier.Verify(message)); }
public static string BuildConfigLogMessage(string root, ConfigResult config, string configFilePath) { var header = GetHeader(config); var builder = new StringBuilder($@"Config: RootDir: {root} ReadOnly: {config.ReadOnly} WriteHeader: {config.WriteHeader} Header:{header} UrlPrefix: {config.UrlPrefix} LinkFormat: {config.LinkFormat} TocLevel: {config.TocLevel} MaxWidth: {config.MaxWidth} FileConfigPath: {configFilePath} (exists:{File.Exists(configFilePath)}) "); if (config.Exclude.Any()) { builder.AppendLine($@" Exclude: {string.Join("\r\n ", config.Exclude)}"); } if (config.TocExcludes.Any()) { builder.AppendLine($@" TocExcludes: {string.Join("\r\n ", config.TocExcludes)}"); } if (config.UrlsAsSnippets.Any()) { builder.AppendLine($@" UrlsAsSnippets: {string.Join("\r\n ", config.UrlsAsSnippets)}"); } return(builder.ToString().Trim()); }
public async Task <ActionResult <IResult> > Get(string scenarioName) { GraphExecutor executor = new GraphExecutor(); List <ColorConfig> configs = executor.GetColorConfigs(scenarioName); ConfigResult result = new ConfigResult(); result.success = true; if (configs == null) { result.responseMessage = "There is no color config defined in the KG. "; } else { result.responseMessage = "There are " + configs.Count + " color config defined."; result.entityColorConfig = new Dictionary <string, string>(); foreach (ColorConfig config in configs) { if (!result.entityColorConfig.ContainsKey(config.itemLabel)) { result.entityColorConfig.Add(config.itemLabel, config.color); } } } log.Information("[Response]: " + JsonConvert.SerializeObject(result)); return(Ok(result)); }
private void getConfigurationAndResetChanged() { this.changedConfigs = new Dictionary <string, dynamic>(); this.configsNeedingUnset = new List <string>(); currentConfig = TaskHandlers.ConfigView(); loadConfigurationValues(currentConfig); configChanged = false; }
public async Task <ActionResult <IResult> > Post(string user, string datastoreName, string scenarioName, Dictionary <string, string> entityColorConfig) { ConfigResult result = new ConfigResult(); if (string.IsNullOrWhiteSpace(datastoreName)) { result.success = false; result.responseMessage = "datastoreName不能为空。"; } else if (string.IsNullOrWhiteSpace(scenarioName)) { result.success = false; result.responseMessage = "scenarioName不能为空。"; } else { ConfigExecutor executor = new ConfigExecutor(user, datastoreName); if (entityColorConfig == null || entityColorConfig.Count == 0) { result.success = false; result.responseMessage = "color config 不能为空。"; } List <ColorConfig> colorConfigs = new List <ColorConfig>(); foreach (string entityName in entityColorConfig.Keys) { string colorHexCode = entityColorConfig[entityName].Trim(); if (colorHexCode.StartsWith('#')) { long output; bool isHex = long.TryParse(colorHexCode.Substring(1), System.Globalization.NumberStyles.HexNumber, null, out output); if (isHex) { ColorConfig config = new ColorConfig(); config.itemLabel = entityName; config.color = colorHexCode; colorConfigs.Add(config); } } } (bool success, string msg) = executor.UpdateColorConfigs(scenarioName, colorConfigs); result.success = success; result.responseMessage = msg; } return(Ok(result)); }
public HttpResponseMessage UpdateConfigResult(ConfigResult con) { try { _userBusiness.UpdateConfigResult(con); return(Request.CreateResponse(HttpStatusCode.OK, "")); } catch (Exception ex) { logger.Error(ex.Message, ex.InnerException); return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public bool TryGetAllConfig(bool localOnly, out Dictionary <string, GitConfigSetting> configSettings) { configSettings = null; string localParameter = localOnly ? "--local" : string.Empty; ConfigResult result = new ConfigResult(this.InvokeGitAgainstDotGitFolder("config --list " + localParameter), "--list"); if (result.TryParseAsString(out string output, out string _, string.Empty)) { configSettings = GitConfigHelper.ParseKeyValues(output); return(true); } return(false); }
/// <summary> /// Safely gets the config value give a setting name /// </summary> /// <param name="settingName">The name of the config setting</param> /// <param name="forceOutsideEnlistment"> /// If false, will run the call from inside the enlistment if the working dir found, /// otherwise it will run it from outside the enlistment. /// </param> /// <param value>The value found for the config setting.</param> /// <returns>True if the config call was successful, false otherwise.</returns> public bool TryGetFromConfig(string settingName, bool forceOutsideEnlistment, out string value, PhysicalFileSystem fileSystem = null) { value = null; try { ConfigResult result = this.GetFromConfig(settingName, forceOutsideEnlistment, fileSystem); return(result.TryParseAsString(out value, out string _)); } catch { } return(false); }
public IActionResult Get([FromQuery] string appName, [FromQuery] string env) { if (string.IsNullOrWhiteSpace(appName)) { return(BadRequest("appName is empty")); } if (string.IsNullOrWhiteSpace(env)) { return(BadRequest("env is empty")); } return(Ok(ConfigResult.GetResult(appName, env))); }
public static string BuildConfigLogMessage(string targetDirectory, ConfigResult config, string configFilePath) { var header = GetHeader(config); StringBuilder builder = new($@"Config: TargetDirectory: {targetDirectory} UrlPrefix: {config.UrlPrefix} LinkFormat: {config.LinkFormat} Convention: {config.Convention} TocLevel: {config.TocLevel} ValidateContent: {config.ValidateContent} HashSnippetAnchors: {config.HashSnippetAnchors} TreatMissingAsWarning: {config.TreatMissingAsWarning} FileConfigPath: {configFilePath} (exists:{File.Exists(configFilePath)}) "); if (config.Convention == DocumentConvention.SourceTransform) { builder.AppendLine(@$ " ReadOnly: {config.ReadOnly} WriteHeader: {config.WriteHeader} Header: {header}"); } var maxWidth = config.MaxWidth; if (maxWidth != int.MaxValue && maxWidth != 0) { builder.AppendLine(@$ " MaxWidth: {maxWidth}"); } if (config.Exclude.Any()) { builder.AppendLine($@" Exclude: {string.Join("\r\n ", config.Exclude)}"); } if (config.TocExcludes.Any()) { builder.AppendLine($@" TocExcludes: {string.Join("\r\n ", config.TocExcludes)}"); } if (config.UrlsAsSnippets.Any()) { builder.AppendLine($@" UrlsAsSnippets: {string.Join("\r\n ", config.UrlsAsSnippets)}"); } return(builder.ToString().Trim()); }
static string?GetHeader(ConfigResult config) { var header = config.Header; if (header == null) { return(null); } var newlineIndent = $"{Environment.NewLine} "; header = string.Join(newlineIndent, header.Lines()); header = header.Replace(@"\n", newlineIndent); return($@" {header}"); }
public static string BuildConfigLogMessage(string root, ConfigResult config, string configFilePath) { var header = GetHeader(config); var builder = new StringBuilder($@"Config: RootDir: {root} ReadOnly: {config.ReadOnly} WriteHeader: {config.WriteHeader} Header: {header} UrlPrefix: {config.UrlPrefix} LinkFormat: {config.LinkFormat} Convention: {config.Convention} TocLevel: {config.TocLevel} MaxWidth: {config.MaxWidth} ValidateContent: {config.ValidateContent} HashSnippetAnchors: {config.HashSnippetAnchors} TreatMissingAsWarning: {config.TreatMissingAsWarning} FileConfigPath: {configFilePath} (exists:{File.Exists(configFilePath)}) "); if (config.Exclude.Any()) { builder.AppendLine($@" Exclude: {string.Join("\r\n ", config.Exclude)}"); } if (config.TocExcludes.Any()) { builder.AppendLine($@" TocExcludes: {string.Join("\r\n ", config.TocExcludes)}"); } if (config.UrlsAsSnippets.Any()) { builder.AppendLine($@" UrlsAsSnippets: {string.Join("\r\n ", config.UrlsAsSnippets)}"); } if (config.DocumentExtensions.Any()) { builder.AppendLine($@" DocumentExtensions: {string.Join("\r\n ", config.DocumentExtensions)}"); } return(builder.ToString().Trim()); }
private void button4_Click(object sender, EventArgs e) { ini.WriteINI("Settings", "MaxCount", this.numericUpDown1.Value.ToString()); this.button4.Enabled = false; this.button4.BackColor = Color.Yellow; this.button4.Text = "Wait..."; if (!int.TryParse(ini.ReadINI("Settings", "MaxCount"), out maxCount)) { ini.WriteINI("Settings", "MaxCount", "10"); } config = r.GetResult(); txt_info.Text = "正在准备资源..."; Thread th = new Thread(Genarator); th.IsBackground = true; th.Start(); }
public async Task <ActionResult <IResult> > Post(string user, string datastoreName, string scenarioName, Dictionary <string, string> entityColorConfig) { ConfigResult result = new ConfigResult(); if (string.IsNullOrWhiteSpace(datastoreName)) { result.success = false; result.responseMessage = "datastoreName不能为空。"; } else if (string.IsNullOrWhiteSpace(scenarioName)) { result.success = false; result.responseMessage = "scenarioName不能为空。"; } else { ConfigExecutor executor = new ConfigExecutor(user, datastoreName); if (entityColorConfig == null || entityColorConfig.Count == 0) { result.success = false; result.responseMessage = "color config 不能为空。"; } List <ColorConfig> colorConfigs = new List <ColorConfig>(); foreach (string eName in entityColorConfig.Keys) { ColorConfig config = new ColorConfig(); config.itemLabel = eName; config.color = entityColorConfig[eName]; colorConfigs.Add(config); } (bool success, string msg) = executor.UpdateColorConfigs(scenarioName, colorConfigs); result.success = success; result.responseMessage = msg; } return(Ok(result)); }
public Task BuildConfigLogMessage() { var config = new ConfigResult { WriteHeader = true, Header = @"line1 line2", Exclude = new List <string> { "Dir1", "Dir2" }, ReadOnly = true, LinkFormat = LinkFormat.Tfs, UrlsAsSnippets = new List <string> { "Url1", "Url2" }, TocLevel = 5, MaxWidth = 80 }; var message = LogBuilder.BuildConfigLogMessage("theRoot", config, "theConfigFilePath"); return(Verify(message)); }
public ConfigResult GetConfigResult() { db = new TimeAttendanceEntities(); try { ConfigResult con = new ConfigResult(); var system = db.SystemParam.Where(u => u.ParamName.Equals(Constants.ConfigTimeIn) || u.ParamName.Equals(Constants.ConfigTimeOut) || u.ParamName.Equals(Constants.ConfigPercent) || u.ParamName.Equals(Constants.TimeAttendanceLog) ).ToList(); var ConfigTimeIn = system.FirstOrDefault(u => u.ParamName.Equals(Constants.ConfigTimeIn)); var ConfigTimeOut = system.FirstOrDefault(u => u.ParamName.Equals(Constants.ConfigTimeOut)); var ConfigPercent = system.FirstOrDefault(u => u.ParamName.Equals(Constants.ConfigPercent)); var TimeAttendanceLog = system.FirstOrDefault(u => u.ParamName.Equals(Constants.TimeAttendanceLog)); if (ConfigTimeIn != null) { con.TimeIn = ConfigTimeIn.ParamValue; } if (ConfigTimeOut != null) { con.TimeOut = ConfigTimeOut.ParamValue; } if (ConfigPercent != null) { con.Percent = int.Parse(ConfigPercent.ParamValue); } if (TimeAttendanceLog != null) { con.TimeAttendanceLog = int.Parse(TimeAttendanceLog.ParamValue); } return(con); } catch (Exception ex) { return(null); } }
/// <summary> /// 拉去项目代码 /// </summary> /// <param name="project"></param> /// <returns></returns> public bool GitProjectSourceCode(PdProject project, string RequestUser) { string enlistmentRoot = project.SourcePath; string workingDirectory = project.SourcePath; string repoUrl = project.VersionUrl; string gitBinPath = project.GitBinPath; GitBaseConfig config = new GitAuthConfig(enlistmentRoot, workingDirectory, repoUrl, gitBinPath); CloneService cloneService = new CloneService(config); ConfigResult configResult = cloneService.GetFromLocalConfig(GitConstant.GitCommandConfig.RemoteOriginUrl); string value = ""; string error = ""; Result result; if (configResult.TryParseAsString(out value, out error)) { ConfigResult configResult1 = cloneService.GetFromLocalConfig($"branch.{project.GitBranch}.remote"); if (configResult1.TryParseAsString(out value, out error) && !String.IsNullOrEmpty(value)) { result = cloneService.GitPull(); } else { result = cloneService.ForceCheckout(project.GitBranch); } } else { result = cloneService.GitClone(project.VersionUrl, project.GitBranch); } string message = JsonConvert.SerializeObject(project); string HandleUser = ServerConstData.ServerName; LoginResultType resultType = result.ExitCode == 0 ? LoginResultType.SUCCESS_PUBLISHGIT : LoginResultType.FAILED; int HandleResult = (int)resultType; DataHandleManager.Instance().UcLoginLogHandle. InsertPublishDeployGitLog(RequestUser, message, HandleUser, HandleResult, result.Output); return(result.ExitCodeIsSuccess); }
public ConfigResultArgs(uint optionId, ConfigResult result, int index = -1) : base(optionId, index) { Result = result; }
/// <summary> /// Open up the config menu /// </summary> /// <param name="isFirstStartUp">Forces the user to set a token</param> public void OpenConfig(bool isFirstStartUp = false) { Logger.Log("Entering config menu..."); Console.WriteLine(""); Console.WriteLine("---------------------------------------------------------"); Console.WriteLine(" Bot configuration "); Console.WriteLine("---------------------------------------------------------"); Console.WriteLine("1 - Bot Token"); Console.WriteLine("2 - Bot Prefix"); Console.WriteLine("3 - Bot Name"); Console.WriteLine("4 - APIs"); Console.WriteLine(""); Console.WriteLine("Enter in either '1', '2' ect... or 'exit' to exit the config menu."); ConfigResult tokenResult = new ConfigResult { ResultType = ConfigResult.ResultTypes.Token, WasModified = false }; ConfigResult prefixResult = new ConfigResult { ResultType = ConfigResult.ResultTypes.Prefix, WasModified = false }; ConfigResult nameResult = new ConfigResult { ResultType = ConfigResult.ResultTypes.Name, WasModified = false }; bool somethingWasModified = false; while (true) { string input = Console.ReadLine()?.ToLower().Trim(); switch (input) { case "1": //Bot token { tokenResult = ConfigEditToken(); if (tokenResult.WasModified) { somethingWasModified = true; } break; } case "2": //Bot prefix { prefixResult = ConfigEditPrefix(); if (prefixResult.WasModified) { somethingWasModified = true; } break; } case "3": //Bot name { nameResult = ConfigEditName(); if (nameResult.WasModified) { somethingWasModified = true; } break; } case "4": //API keys { ConfigResult apiResult = ConfigEditApis(); if (apiResult.WasModified) { somethingWasModified = true; } break; } case "exit": //Exit out of config menu { //If it is the first startup, check to make sure the token was modified. if (isFirstStartUp && !tokenResult.WasModified) { //The token was not modified Console.WriteLine("You need to modify the token since this is the first startup!"); break; } //The token was modified, and it isn't the first startup, so alert the user they need to restart the bot for the new token to take effect if (!isFirstStartUp && tokenResult.WasModified) { Logger.Log("For the bot to use the new token you must restart the bot!", LogVerbosity.Warn); } //Set the new prefix if (prefixResult.WasModified) { Global.BotPrefix = Config.bot.BotPrefix; } //Update the console title if the bot name was changed if (nameResult.WasModified) { Global.BotName = Config.bot.BotName; Console.Title = $"{Global.BotName} Console"; } //No point in saving if nothing was changed if (somethingWasModified) { Config.SaveConfig(); Logger.Log("Config has been saved! Exited out of the config menu."); } else { Logger.Log("Nothing was changed, so nothing was saved! Exited out of the config menu."); } return; } default: { Console.WriteLine( "Input either needs to be '1', '2', ect... or 'exit' to exit the config menu."); break; } } } }
public async Task <SDNetwork> NetworkDiscoveryAsync(TransactionContext ltransactionContext, bool force, CancellationToken token = default(CancellationToken)) { using (await discoverLock.LockAsync(token).ConfigureAwait(false)) { logger.Trace($"Network discovery force: {force}"); List <Peer> speers = serviceDiscoveryPeers.Shuffle().ToList(); SDNetwork ret = sdNetwork; if (!force && null != ret && !ret.TimeElapsed) { return(ret); } ret = null; foreach (Peer serviceDiscoveryPeer in speers) { try { SDNetwork lsdNetwork = new SDNetwork(SERVICE_DISCOVER_FREQ_SECONDS); byte[] clientTLSCertificateDigest = serviceDiscoveryPeer.GetClientTLSCertificateDigest(); logger.Info($"Channel {channelName} doing discovery with peer: {serviceDiscoveryPeer}"); if (null == clientTLSCertificateDigest) { throw new ArgumentException($"Channel {channelName}, peer {serviceDiscoveryPeer} requires mutual tls for service discovery."); } ByteString clientIdent = ltransactionContext.Identity.ToByteString(); ByteString tlshash = ByteString.CopyFrom(clientTLSCertificateDigest); AuthInfo authentication = new AuthInfo(); authentication.ClientIdentity = clientIdent; authentication.ClientTlsCertHash = tlshash; List <Query> fq = new List <Query>(2); Query cq = new Query(); Query pq = new Query(); cq.Channel = channelName; pq.Channel = channelName; cq.ConfigQuery = new ConfigQuery(); pq.PeerQuery = new PeerMembershipQuery(); fq.Add(cq); fq.Add(pq); Request request = new Request(); request.Queries.AddRange(fq); request.Authentication = authentication; ByteString payloadBytes = request.ToByteString(); ByteString signatureBytes = ltransactionContext.SignByteStrings(payloadBytes); SignedRequest sr = new SignedRequest(); sr.Payload = payloadBytes; sr.Signature = signatureBytes; if (IS_TRACE_LEVEL && null != diagnosticFileDumper) // dump protobuf we sent { logger.Trace($"Service discovery channel {channelName} {serviceDiscoveryPeer} service chaincode query sent {diagnosticFileDumper.CreateDiagnosticProtobufFile(sr.ToByteArray())}"); } Response response = await serviceDiscoveryPeer.SendDiscoveryRequestAsync(sr, SERVICE_DISCOVERY_WAITTIME, token).ConfigureAwait(false); if (IS_TRACE_LEVEL && null != diagnosticFileDumper) // dump protobuf we get { logger.Trace($"Service discovery channel {channelName} {serviceDiscoveryPeer} service discovery returned {diagnosticFileDumper.CreateDiagnosticProtobufFile(response.ToByteArray())}"); } //serviceDiscoveryPeer.HasConnected; ??? List <QueryResult> resultsList = response.Results.ToList(); QueryResult queryResult = resultsList[0]; //configquery if (queryResult.ResultCase == QueryResult.ResultOneofCase.Error) { logger.Warn($"Channel {channelName} peer: {serviceDiscoveryPeer} error during service discovery {queryResult.Error.Content}"); continue; } QueryResult queryResult2 = resultsList[1]; if (queryResult2.ResultCase == QueryResult.ResultOneofCase.Error) { logger.Warn($"Channel {channelName} peer: {serviceDiscoveryPeer} error during service discovery {queryResult2.Error.Content}"); continue; } ConfigResult configResult = queryResult.ConfigResult; Dictionary <string, FabricMSPConfig> msps = configResult.Msps.ToDictionary(a => a.Key, a => a.Value); HashSet <ByteString> cbbs = new HashSet <ByteString>(); foreach (string i in msps.Keys) { FabricMSPConfig value = msps[i]; string mspid = value.Name; cbbs.AddRange(value.RootCerts); cbbs.AddRange(value.IntermediateCerts); value.RootCerts.ToList().ForEach(a => lsdNetwork.AddTlsCert(mspid, a.ToByteArray())); value.TlsIntermediateCerts.ToList().ForEach(a => lsdNetwork.AddTlsIntermCert(mspid, a.ToByteArray())); } List <byte[]> toaddCerts = new List <byte[]>(); AddCerts(cbbs, toaddCerts); if (toaddCerts.Count > 0) // add them to crypto store. { toaddCerts.ForEach(a => channel.Client.CryptoSuite.Store.AddCertificate(a.ToUTF8String())); } Dictionary <string, SDOrderer> ordererEndpoints = new Dictionary <string, SDOrderer>(); Dictionary <string, Endpoints> orderersMap = configResult.Orderers.ToDictionary(a => a.Key, a => a.Value); foreach (string mspid in orderersMap.Keys) { Endpoints value = orderersMap[mspid]; foreach (Protos.Discovery.Endpoint l in value.Endpoint) { string endpoint = l.Host + ":" + l.Port.ToString().ToLowerInvariant().Trim(); logger.Trace($"Channel {channelName} discovered orderer MSPID: {mspid}, endpoint: {endpoint}"); SDOrderer sdOrderer = new SDOrderer(channel, mspid, endpoint, lsdNetwork.GetTlsCerts(mspid), lsdNetwork.GetTlsIntermediateCerts(mspid)); ordererEndpoints[sdOrderer.Endpoint] = sdOrderer; } } lsdNetwork.SetOrdererEndpoints(ordererEndpoints); PeerMembershipResult membership = queryResult2.Members; Dictionary <string, SDEndorser> endorsers = new Dictionary <string, SDEndorser>(); foreach (string mspId in membership.PeersByOrg.Keys) { Peers peer = membership.PeersByOrg[mspId]; foreach (Protos.Discovery.Peer pp in peer.Peers_) { SDEndorser ppp = new SDEndorser(channel, pp, lsdNetwork.GetTlsCerts(mspId), lsdNetwork.GetTlsIntermediateCerts(mspId)); logger.Trace($"Channel {channelName} discovered peer MSPID: {mspId}, endpoint: {ppp.Endpoint}"); endorsers[ppp.Endpoint] = ppp; } } lsdNetwork.SetEndorsers(endorsers); lsdNetwork.End(); sdNetwork = lsdNetwork; ret = lsdNetwork; break; } catch (Exception e) { logger.Warn($"Channel {channelName} peer {serviceDiscoveryPeer} service discovery error {e.Message}"); } } logger.Debug($"Channel {channelName} service discovery completed: {ret != null}"); return(ret); } }
public void UpdateConfigResult(ConfigResult con) { db = new TimeAttendanceEntities(); try { var ConfigTimeIn = db.SystemParam.FirstOrDefault(u => u.ParamName.Equals(Constants.ConfigTimeIn)); var ConfigTimeOut = db.SystemParam.FirstOrDefault(u => u.ParamName.Equals(Constants.ConfigTimeOut)); var ConfigPercent = db.SystemParam.FirstOrDefault(u => u.ParamName.Equals(Constants.ConfigPercent)); var TimeAttendanceLog = db.SystemParam.FirstOrDefault(u => u.ParamName.Equals(Constants.TimeAttendanceLog)); if (ConfigTimeIn != null) { ConfigTimeIn.ParamValue = con.TimeIn; } else { ConfigTimeIn = new SystemParam(); ConfigTimeIn.SystemParamId = Guid.NewGuid().ToString();; ConfigTimeIn.ParamValue = con.TimeIn; ConfigTimeIn.ParamName = Constants.ConfigTimeIn; db.SystemParam.Add(ConfigTimeIn); } if (ConfigTimeOut != null) { ConfigTimeOut.ParamValue = con.TimeOut; } else { ConfigTimeOut = new SystemParam(); ConfigTimeOut.SystemParamId = Guid.NewGuid().ToString();; ConfigTimeOut.ParamValue = con.TimeOut; ConfigTimeOut.ParamName = Constants.ConfigTimeOut; db.SystemParam.Add(ConfigTimeOut); } if (ConfigPercent != null) { ConfigPercent.ParamValue = con.Percent.ToString(); } else { ConfigPercent = new SystemParam(); ConfigPercent.SystemParamId = Guid.NewGuid().ToString();; ConfigPercent.ParamValue = con.Percent.ToString(); ConfigPercent.ParamName = Constants.ConfigPercent; db.SystemParam.Add(ConfigPercent); } if (TimeAttendanceLog != null) { TimeAttendanceLog.ParamValue = con.TimeAttendanceLog.ToString(); } else { TimeAttendanceLog = new SystemParam(); TimeAttendanceLog.SystemParamId = Guid.NewGuid().ToString();; TimeAttendanceLog.ParamValue = con.TimeAttendanceLog.ToString(); TimeAttendanceLog.ParamName = Constants.TimeAttendanceLog; db.SystemParam.Add(TimeAttendanceLog); } db.SaveChanges(); TimeAttendanceStatic.ConfidenceFix = con.Percent; TimeAttendanceStatic.TimeIn = con.TimeIn; TimeAttendanceStatic.TimeOut = con.TimeOut; } catch (Exception ex) { } }
public ConfigResult Get() { return(ConfigResult.GetResult()); }