[Test] public void Matches_2() { var obj = "foo"; var trace = new LogTrace("foo", null); trace.Matches(obj, null); }
public int?UpdateDt(DataTable Dt, string commandText) { //if application is exiting the don't perform DB process if (this.isAppClosing) { return(null); } if (!DoesDBConnectionExists()) { return(null); } try { SQLiteDataAdapter da = new SQLiteDataAdapter(commandText, _connection); SQLiteCommandBuilder cb = new SQLiteCommandBuilder(da); da.UpdateCommand = cb.GetUpdateCommand(); da.InsertCommand = cb.GetInsertCommand(); da.DeleteCommand = cb.GetDeleteCommand(); da.Update(Dt); } catch (Exception ex) { LogTrace.WriteErrorLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name, String.Format("Error in query . " + commandText + ex.StackTrace)); throw; } finally { commandText = string.Empty; } return(Dt.Rows.Count); }
/// <summary> /// 注册 IServiceCollection,并返回 RegisterService,开始注册流程(必须) /// </summary> /// <param name="serviceCollection">IServiceCollection</param> /// <param name="certName">证书名称,必须全局唯一,并且确保在全局 HttpClientFactory 内唯一</param> /// <param name="certSecret">证书密码</param> /// <param name="certPath">证书路径(物理路径)</param> /// <param name="checkValidationResult">设置</param> /// <returns></returns> public static IServiceCollection AddSenparcHttpClientWithCertificate(this IServiceCollection serviceCollection, string certName, string certSecret, string certPath, bool checkValidationResult = false) { //添加注册 if (!string.IsNullOrEmpty(certPath)) { if (File.Exists(certPath)) { try { var cert = new X509Certificate2(certPath, certSecret, X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.MachineKeySet); return(AddSenparcHttpClientWithCertificate(serviceCollection, certName, cert, checkValidationResult)); } catch (Exception ex) { LogTrace.SendCustomLog($"添加微信支付证书发生异常", $"certName:{certName},certPath:{certPath}"); LogTrace.BaseExceptionLog(ex); return(serviceCollection); } } else { LogTrace.SendCustomLog($"已设置微信支付证书,但无法找到文件", $"certName:{certName},certPath:{certPath}"); return(serviceCollection); } } return(serviceCollection); }
/// <summary> /// 注册列表 /// </summary> /// <param name="configurationString">连接字符串</param> public static void RegisterServerList(string configurationString) { if (!string.IsNullOrEmpty(configurationString)) { var dic = new Dictionary <string, int>(); var servers = configurationString.Split(';'); foreach (var server in servers) { try { var serverData = server.Split(':'); dic[serverData[0]] = int.Parse(serverData[1]); } catch (Exception ex) { LogTrace.BaseExceptionLog(new CacheException(ex.Message, ex)); } } if (dic.Count() > 0) { OFoodDI.GlobalServiceCollection.AddSenparcMemcached(options => { foreach (var item in dic) { options.AddServer(item.Key, item.Value); } }); } RegisterServerList(dic); } }
public override async Task <ICacheLock> LockAsync() { var key = _mamcachedStrategy.GetFinalKey(_resourceName); var lockResult = await RetryLockAsync(key, _retryCount, _retryDelay, async() => { try { var ttl = base.GetTotalTtl(_retryCount, _retryDelay); if (await _mamcachedStrategy.Cache.StoreAsync(StoreMode.Add, key, new object(), TimeSpan.FromMilliseconds(ttl))) { base.LockSuccessful = true; return(true);//取得锁 } else { base.LockSuccessful = false; return(false);//已被别人锁住,没有取得锁 } } catch (Exception ex) { LogTrace.Log("Memcached同步锁发生异常:" + ex.Message); return(false); } } ).ConfigureAwait(false); return(lockResult); }
/// <summary> ///Execute a SQLiteCommand (that returns a resultset and takes no parameters) against the database specified in /// the connection string. /// </summary> /// <param name="commandText">the CommandType (stored procedure, text, etc.)</param> /// <param name="behaviour">Behaviour of how the data reader will act.</param> /// <returns>Returns a dataReader.</returns> public SQLiteDataReader ExecuteDataReader(string commandText, CommandBehavior behaviour) { //if application is exiting the don't perform DB process if (this.isAppClosing) { return(null); } //check for DB connectivity if (!DoesDBConnectionExists()) { return(null); } SQLiteDataReader rdr = null; SQLiteCommand cmd = null; try { cmd = GetCommand(commandText); rdr = cmd.ExecuteReader(behaviour); } catch (Exception ex) { LogTrace.WriteErrorLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name, String.Format("Error in query . " + commandText + ex.Message)); } finally { commandText = string.Empty; DisposeObject(cmd); } return(rdr); }
public static LogTrace GetLogTrace(string traceXML) { LogTrace LogTraces = new LogTrace(); try { XDocument document = XDocument.Parse(traceXML); XElement lsttraces = document.Descendants("trace").FirstOrDefault(); LogTraces.SimulationID = lsttraces.Attribute("id").Value; LogTraces.Percentage = GetPercentageInDouble(lsttraces.Attribute("percentage").Value); LogTraces.Title = lsttraces.Attribute("title").Value; IEnumerable <XElement> lstevents = lsttraces.Descendants("event"); List <TraceEvents> LstTraceEvents = new List <TraceEvents>(); foreach (var item in lstevents) { TraceEvents traceEvents = new TraceEvents(); traceEvents.EventID = item.Attribute("id").Value; traceEvents.EventLabel = item.Attribute("label").Value; traceEvents.EventRole = item.Attribute("role").Value; LstTraceEvents.Add(traceEvents); } LogTraces.EventIDs = LstTraceEvents; } catch (Exception) { // throw; } return(LogTraces); }
public virtual IEnumerable <dynamic> GetSearchItems(DbConnect con, DynamicDictionary data_param, int page, int pageSize, string sort_by = null) { BangoCommand cmd = GetSearchItemsCommand(con, data_param, page, pageSize, sort_by, false); string finalSql = cmd.FinalSql; if (finalSql.Length > 0) { IEnumerable <dynamic> items = null; try { items = con.DB.Query <dynamic>(finalSql, cmd.FinalParameters); } catch (Npgsql.NpgsqlException ex) { LogTrace.WriteErrorLog(ex.ToString()); LogTrace.WriteDebugLog(string.Format("Select SQL which gave exception:\r{0}", ex.Routine)); return(null); } //Unused code disabled... ////List<DynamicDictionary> ddList = new List<DynamicDictionary>(); ////if (items != null && items.Count() > 0) ////{ //// foreach (dynamic item in items) //// { //// ddList.Add(Conversion.ToDynamicDictionary(item)); //// } ////} return(items); } throw new NoSqlStringProvidedException(); }
/*Based on a list of scenarios and a trace, find the scenarios that match the trace, * adjust percentages, create Recommendations and return them in a list.*/ public static List <Recommendation> Recommend(List <LogTrace> lstScenarios, LogTrace trace) { List <Recommendation> lst = new List <Recommendation>(); List <LogTrace> matches = SelectScenariosForTrace(lstScenarios, trace); matches = AdjustPercentage(matches); string[] traceEventIds = GetEventIDArray(trace.EventIDs); foreach (LogTrace item in matches) { string[] matchEventIds = GetEventIDArray(item.EventIDs); string nxt = GetNextEvent(traceEventIds, matchEventIds); Recommendation recommendation = new Recommendation(); recommendation.SimulationId = item.SimulationID; recommendation.SimulationTitle = item.Title; if (nxt != null) { recommendation.EventId = nxt; recommendation.EventLabel = XMLParser.GetEventLabelFromLogTrace(lstScenarios, nxt); recommendation.EventRole = XMLParser.GetEventRoleFromLogTrace(lstScenarios, nxt); } recommendation.Probability = item.Percentage; lst.Add(recommendation); } return(lst); }
public virtual List <TNode> GetChildNodes(DbConnect con, DynamicDictionary data_param, int?parent_id, string sort_by = null) { parent_id = parent_id == null ? 0 : parent_id; Errors.Clear(); //List<TNode> tree = new List<TNode>(); BangoCommand cmd = GetChildNodesCommand(con, data_param, parent_id, sort_by); string finalSql = cmd.FinalSql; if (finalSql.Length > 0) { try { IEnumerable <TNode> list = null; list = con.DB.Query <TNode>(finalSql, cmd.FinalParameters); if (list != null) { return(list.ToList <TNode>()); } return(null); } catch (Npgsql.NpgsqlException ex) { Errors.Add(ex.Message); LogTrace.WriteErrorLog(ex.ToString()); LogTrace.WriteDebugLog(string.Format("Select SQL which gave exception:\r{0}", ex.Routine)); return(null); } } throw new NoSqlStringProvidedException(); }
private string WriteTrace(LogTrace entity) { var extraStyles = string.Empty; var sb = this.stringBuilderPool.Get(); // less allocations sb.Append("<span style='color: ").Append(this.GetTraceLevelColor(entity)).Append("; ").Append(extraStyles).Append("'>"); //.Append(logEvent.TrackType.SafeEquals("journal") ? "*" : " "); // journal prefix if (entity.Message?.Length > 5 && entity.Message.Take(6).All(char.IsUpper)) { sb.Append($"<span style='color: #37CAEC;'>{entity.Message.Slice(0, 6)}</span>"); sb.Append(entity.Message.Slice(6)).Append(" (").Append(entity.SpanId).Append('/').Append(entity.ParentSpanId).Append(") "); } else { sb.Append(entity.Message).Append(" (").Append(entity.SpanId).Append('/').Append(entity.ParentSpanId).Append(") "); } sb.Append("<a target='blank' href='/naos/operations/logtraces/").Append(entity.Id).Append("'>*</a> "); sb.Append("<span style='color: gray;font-size: xx-small'>-> took "); sb.Append(entity.Duration.Humanize()); sb.Append("</span>"); sb.Append("</span>"); sb.Append("</div>"); var result = sb.ToString(); this.stringBuilderPool.Return(sb); return(result); }
public virtual DynamicDictionary Get(DbConnect con, DynamicDictionary param, string tableAlias = null) { if (con == null) { throw new DbConnectionNotPassed(); } BangoCommand cmd = GetItemCommand(param, tableAlias); string finalSql = cmd.FinalSql; if (finalSql.Length > 0) { IEnumerable <SqlMapper.DapperRow> items = null; try { items = con.DB.Query <SqlMapper.DapperRow>(finalSql, cmd.FinalParameters, true); } catch (Exception ex) { LogTrace.WriteErrorLog(ex.ToString()); } Errors = con.DB.GetErros(); if (items != null && items.Count() > 0) { return(Conversion.ToDynamicDictionary(items.FirstOrDefault())); } return(null); } return(null); }
/// <summary> /// Execute a SQLiteCommand (that returns no resultset and takes no parameters) against the database /// </summary> /// <param name="commandText">the stored procedure name or T-SQL command</param> /// <returns>Returns an int representing the number of rows affected by the command.</returns> /// <example> /// int result = ExecuteNonQuery("UPdate query"); /// </example> public int ExecuteNonQuery(string commandText) { //if application is exiting the don't perform DB process if (this.isAppClosing) { return(-1); } if (!DoesDBConnectionExists()) { return(-1); } //creating a oracle command for executing the command text. SQLiteCommand cmd = GetCommand(commandText); int iRetVal = -1; try { iRetVal = cmd.ExecuteNonQuery(); } catch (Exception ex) { LogTrace.WriteErrorLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name, ex.ToString()); LogTrace.WriteDebugLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name, commandText); if (ex.Message.ToUpper().Trim() == "no connections") { } else if (ex.Message.Contains("is not unique")) { throw new Exception("The data should be Unique it cannot be repeated ."); } else if (ex.Message.Contains("foreign key constraint failed")) { throw new Exception("Foreign key constraint failed or The data is used in other table so cannot delete it"); } else if (ex.Message.Contains("Abort due to constraint violation")) { string message = ex.Message; message = message.Replace("Abort due to constraint violation", ""); message = message.Replace("columns", ""); message = message.Replace("are not unique", "should be unique.\n Please use the existing data or Input unique data."); throw new Exception(message); } LogTrace.WriteErrorLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name, String.Format("Error in query . " + commandText + ex.StackTrace)); throw ex; } finally { commandText = string.Empty; commandText = null; DisposeObject(cmd); } return(iRetVal); }
/// <summary> /// Execute a commandText (that returns a resultset and takes no parameters) against the database /// </summary> /// <param name="commandText">SQL command</param> /// <returns>Returns a datatable containing the resultset generated by the command</returns> /// <example> /// DataTable dt= DatabaseConnection.ExecuteTable("SELECT * FROM emp"); /// </example> public DataSet ExecuteDataSet(string commandText) { //if application is exiting the don't perform DB process if (this.isAppClosing) { return(null); } if (!DoesDBConnectionExists()) { return(null); } //creating the dataAdapter object to execute the dataTable. SQLiteDataAdapter dataAdapter = null; DataSet dt = new DataSet(); try { //open the data adapter. dataAdapter = new SQLiteDataAdapter(commandText, _connection); //load the data into the dataTable. dataAdapter.Fill(dt); } catch (Exception ex) { //if (false)//ex.Message.ToUpper().Trim() == "ORA-03114: NOT CONNECTED TO ORACLE" || ex.Message.ToUpper().Trim() == "ORA-12571: TNS:PACKET WRITER FAILURE") //{ // //Try to db Re_Connected... // if (MessageBox.Show("*]^fa];;Fu sg]S;g ePsf] %}g\\, s] tkfO{ km]<L *]^fa];;Fu sg]S;g ug]{ xf] M ") == DialogResult.Yes) // { // DisconnectDatabase(); // if (!ConnectDatabase()) // { // MessageBox.Show("*]^fa];;Fu sg]S;g x'g ;s]g "); // // this.MsgBoxNepaliDispose(); // } // } // else // { // this.Dispose(); //if Re-connect not do the project dispose.... // } //} LogTrace.WriteErrorLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name, ex.ToString()); LogTrace.WriteDebugLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name, commandText); throw ex; } finally { commandText = string.Empty; dataAdapter.Dispose(); dataAdapter = null; } return(dt); }
public APMException(string message, string domain, string kindName, string method, Exception inner = null) : base(message, inner, true) { LogTrace.SendCustomLog("APM 执行出错", $@"Domain: {domain} KindName: {kindName} Message: {message} Exception: {inner?.ToString()}"); }
/// <summary> /// 释放 /// </summary> public void Release() { if (m_CurTrace != null) { m_CurTrace.Release(); m_CurTrace = null; } }
/// <summary> /// 发送文本客服消息 /// </summary> /// <param name="accessTokenOrAppId"></param> /// <param name="openId"></param> /// <param name="content"></param> /// <returns></returns> public override ApiResult SendText(string accessTokenOrAppId, string openId, string content) { LogTrace.SendCustomLog("wxTest-sendText", "openID:" + openId + " || appID:" + accessTokenOrAppId + "|| content:" + content); var result = AdvancedAPIs.CustomApi.SendText(accessTokenOrAppId, openId, content); return(new ApiResult((int)result.errcode, result.errmsg, result)); }
/*returns list of recommendations for the next event, with the associated probability of that event being the next.*/ public static List <Recommendation> GetRecommendations(string scenarios, string trace) { List <Recommendation> lst = new List <Recommendation>(); List <LogTrace> lstScenarios = XMLParser.GetLogTraces(scenarios); LogTrace lstsTrace = XMLParser.GetLogTrace(trace); lst = Recommend(lstScenarios, lstsTrace); return(lst); }
/// <summary> /// BaseException /// </summary> /// <param name="message">异常消息</param> /// <param name="inner">内部异常信息</param> /// <param name="logged">是否已经使用WeixinTrace记录日志,如果没有,BaseException会进行概要记录</param> public BaseException(string message, Exception inner, bool logged = false) : base(message, inner) { if (!logged) { //LogTrace.Log(string.Format("BaseException({0}):{1}", this.GetType().Name, message)); LogTrace.BaseExceptionLog(this); } }
public Trace(string requestType, int fromType, string message = null) { watch = new Stopwatch(); watch.Start(); TraceModel = new LogTrace(); TraceModel.CreateTime = DateTime.Now; TraceModel.FromType = fromType; TraceModel.RequestType = requestType; TraceModel.Message = message; }
//[Authorize(Policy = Policies.Controller)] public async Task <ActionResult <WorkflowInstance> > StartWorkflow(string id) { string contentReq = null; using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8)) { contentReq = await reader.ReadToEndAsync(); } var logTrace = new LogTrace(); AiLogger.LogInfo(logTrace, "Workflow Start: " + contentReq); object workflowData = contentReq; string workflowId = null; if (id.Equals(CompressJobWorkflow.WorkflowId)) { workflowId = CompressJobWorkflow.WorkflowId; workflowData = NewtonJsonConvert.DeserializeObject <CompressJobData>(contentReq); } else if (id.Equals(WfFileInWorkflow.WorkflowId)) { workflowId = WfFileInWorkflow.WorkflowId; workflowData = NewtonJsonConvert.DeserializeObject <WfFileInData>(contentReq); } else if (id.Equals(Test01UserWorkflow.WorkflowId)) { var wfEvent = Newtonsoft.Json.JsonConvert.DeserializeObject <Pdf4meWorkflowEvent>(contentReq); workflowData = new Pdf4meWorkflowData() { WorkflowEvent = wfEvent }; workflowId = Test01UserWorkflow.WorkflowId; //workflowData = NewtonJsonConvert.DeserializeObject<WfFileInData>(contentReq); } else { var wfEvent = Newtonsoft.Json.JsonConvert.DeserializeObject <Pdf4meWorkflowEvent>(contentReq); workflowData = new Pdf4meWorkflowData() { WorkflowEvent = wfEvent }; workflowId = id; } var instanceId = await _workflowController.StartWorkflow(workflowId, workflowData); var result = await _persistenceProvider.GetWorkflowInstance(instanceId); return(Created(instanceId, _mapper.Map <WorkflowInstance>(result))); }
// Attach and send the current production public async Task <Dictionary <string[], WsResponse> > sendProd() { try { // preparing request HEADER HttpClientHandler handler = new HttpClientHandler(); HttpClient client = new HttpClient(); byte[] Basic_Auth = Encoding.ASCII.GetBytes(ConfigurationManager.AppSettings["id"] + ":" + ConfigurationManager.AppSettings["pass"]); // tester cet appel je vais pas y revenir une autre fois. client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(Basic_Auth)); client.DefaultRequestHeaders.Add("Accept", "application/json"); client.DefaultRequestHeaders.Add("Accept-Charset", "UTF-8"); //preparing request BODY MultipartFormDataContent requestContent = new MultipartFormDataContent(); // default boundary //string boundary = "----MyBoundary" + DateTime.Now.Ticks.ToString("x"); //requestContent.Headers.Remove("Content-Type"); //requestContent.Headers.TryAddWithoutValidation("Content-Type", "multipart/form-data; boundary=" + boundary); ByteArrayContent json = new ByteArrayContent(Encoding.UTF8.GetBytes(genJson())); // encodage a verifier apres !! json.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json"); // can be configured requestContent.Add(json, "arbitrage"); foreach (binaries bin in this.binaires) { // this can be optimised we have the files dupliated on bianries List Class and pieces List Class ByteArrayContent binaryFile = new ByteArrayContent(bin.ficheirPDF); binaryFile.Headers.ContentType = MediaTypeHeaderValue.Parse("application/octet-stream"); requestContent.Add(binaryFile, "file", bin.nomFichie); } //POST ASYNC CALL HttpResponseMessage message = await client.PostAsync(ConfigurationManager.AppSettings["route"] + this.NumContrat + "/arbitrages", requestContent); // must be extracted LogTrace.Trace("SPI-WS Return Value", LogTrace.MESSAGE_INFO, message.ToString()); string returnMessages = await message.Content.ReadAsStringAsync(); LogTrace.Trace("SPI-WS Return Messages", LogTrace.MESSAGE_INFO, returnMessages); Dictionary <string[], WsResponse> response = new Dictionary <string[], WsResponse>(); response.Add(new string[] { this.ReferenceInterne, this.prodActeID }, new WsResponse { isSuccessCall = message.IsSuccessStatusCode, message = getMessage(returnMessages, message), status_xml = getStatusXml(message), } ); // 1 acte success => prod success if (message.IsSuccessStatusCode) { SuccessActes.Add(this.ReferenceInterne); isSuccess = true; } //waiting until we get the JSON response ! return(response); } catch (Exception ex) { } return(new Dictionary <string[], WsResponse>()); }
public static List <LogTrace> GetLogTraces(string logXML) { XDocument document = XDocument.Parse(logXML); IEnumerable <XElement> lsttraces = document.Descendants("trace"); List <LogTrace> lst = new List <LogTrace>(); foreach (var itemTrace in lsttraces) { LogTrace LogTraces = GetLogTrace(itemTrace.ToString()); lst.Add(LogTraces); } return(lst); }
/// <summary> /// Checks that all the folders we define here are accessible, and if not /// creates them. If something goes wrong returns False. /// </summary> public static bool InitializeFolders() { foreach (string path in FoldersList) { if (!CheckAndCreateDir(path)) { LogTrace.Error("Unable to create folder {0}", path); return(false); } } LogTrace.Log("Folders initialized for {0}", DashboardPath); return(true); }
void SystemEvents_SessionSwitch(object sender, Microsoft.Win32.SessionSwitchEventArgs e) { if (e.Reason == SessionSwitchReason.SessionLock) { LogTrace.WriteInfoLog(string.Format("locked")); cron_daemon.Stop(); } else if (e.Reason == SessionSwitchReason.SessionUnlock) { LogTrace.WriteInfoLog(string.Format("unlocked")); cron_daemon.Start(); } }
//method that serialise the current object (this) into a JSON flow (this method rely on the ShouldSerialiseContratResolver Class) private string genJson() { JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore, ContractResolver = new ShouldSerializeContractResolver() }; Definition.connexionQualif.Close(); LogTrace.Trace("SPI-WS JSON", LogTrace.MESSAGE_INFO, JsonConvert.SerializeObject(this, jsonSetting)); return(JsonConvert.SerializeObject(this, jsonSetting)); }
public void RunCronJob(string jobFile) { var jobs = System.IO.File.ReadAllLines(jobFile); foreach (var job in jobs) { if (job.Trim().Length > 0 && !job.StartsWith("--")) { try { var c = job.Split(new string[] { " " }, StringSplitOptions.None); var cronNotation = string.Join(" ", c.Take(5).ToArray()); var file = string.Join(" ", c.Skip(5).ToArray()); ThreadStart t = new ThreadStart(() => Execute(file)); //string cronNotation = "0 16 * * *";// "* * * * *"; string log = string.Format("Run {0} {1}", file, ExpressionDescriptor.GetDescription(cronNotation)); LogTrace.WriteInfoLog(log); Console.WriteLine(log); cron_daemon.AddJob(cronNotation, t); cron_daemon.Start(); } catch (Exception ex) { Console.WriteLine(job + ":" + ex.Message); } } } Console.WriteLine("Continue ? (Y)"); string cont = Console.ReadLine(); if (cont.Length == 0 || cont.ToUpper() == "Y") { Console.WriteLine("Hide Window ? (Y)"); string hide = Console.ReadLine(); if (hide.Length == 0 || hide.ToUpper() == "Y") { Utility.ShowMe(false); } Console.WriteLine("Started Cron..."); while (true) { Thread.Sleep(6000); } } else { Application.Exit(); } }
public string AddLogTrace(LogTrace Trace) { //Run data validation string ReturnErr = LogTraceBLL.getInstance().Validate(JsonConvert.DeserializeObject <LogTraceBLLModel>(JsonConvert.SerializeObject(Trace))); if (ReturnErr != "") { return(ReturnErr); } //Execute Insert Request string ReturnVal = LogTraceBLL.getInstance().Create(JsonConvert.DeserializeObject <LogTraceBLLModel>(JsonConvert.SerializeObject(Trace))); return(ReturnVal); }
//[Authorize(Policy = Policies.Viewer)] public async Task <ActionResult <WorkflowInstance> > Get(string id) { var logTrace = new LogTrace(); AiLogger.LogInfo(logTrace, "Workflow Get: " + id); var result = await _persistenceProvider.GetWorkflowInstance(id); if (result == null) { return(NotFound()); } return(Ok(_mapper.Map <WorkflowInstance>(result))); }
/// <summary> /// The get agents count. /// return list of agents of specified type and their count in specified state /// </summary> /// <param name="totalAgentsCount"> /// The total agents count. /// </param> /// <param name="stateCount"> /// The state count. /// </param> /// <param name="agentType"> /// The agent type. /// </param> /// <param name="agentState"> /// The agent state. /// </param> private void GetAgentsCount(ref double totalAgentsCount, ref double stateCount, AgentType agentType, AgentState agentState) { LogTrace.WriteTraceFormatted("Attempt to get information about {0} agents int {1} state for {2}", agentType, agentState, NodeServer.IPAddr); List <AgentCurrentStatus> totalAgents = agents.FindAll(agent => agent.AgentId.AgentType == agentType); totalAgentsCount = totalAgents.Count; stateCount = totalAgents.FindAll(agent => agent.AgentState == agentState).Count; LogTrace.WriteTraceFormatted( "{0} agents found of type {1} on server {2}. {3} of them are in state {4}", totalAgents.Count, agentType, NodeServer.IPAddr, stateCount, agentState); }