private static IEnumerable <testsuiteProperty> ConvertTestsuiteProperties(ActionIterationReport actionIterationReport) { List <testsuiteProperty> list = new List <testsuiteProperty>(); // action iteration index list.Add(new testsuiteProperty(Properties.Resources.PropName_ActionIterationIndex, actionIterationReport.Index.ToString())); // iteration input/output parameters foreach (ParameterType pt in actionIterationReport.InputParameters) { list.Add(new testsuiteProperty(Properties.Resources.PropName_Prefix_ActionIterationInputParam + pt.NameAndType, pt.value)); } foreach (ParameterType pt in actionIterationReport.OutputParameters) { list.Add(new testsuiteProperty(Properties.Resources.PropName_Prefix_ActionIterationOutputParam + pt.NameAndType, pt.value)); } // owner - action ActionReport actionReport = actionIterationReport.OwnerAction; if (actionReport != null) { // action name list.Add(new testsuiteProperty(Properties.Resources.PropName_Action, actionReport.Name)); // action properties list.AddRange(ConvertTestsuiteProperties(actionReport)); } return(list); }
private static testsuiteTestcase[] ConvertTestcases(ActionReport actionReport, out int count, out int numOfFailures) { count = 0; numOfFailures = 0; List <testsuiteTestcase> list = new List <testsuiteTestcase>(); EnumerableReportNodes <StepReport> steps = new EnumerableReportNodes <StepReport>(actionReport.AllStepsEnumerator); foreach (StepReport step in steps) { testsuiteTestcase tc = ConvertTestcase(step, count); if (tc == null) { continue; } list.Add(tc); if (step.Status == ReportStatus.Failed) { numOfFailures++; } count++; } return(list.ToArray()); }
public static List <ActionReport> GetListByZoneID(string zoneId) { string cons = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString(); List <ActionReport> result = new List <ActionReport>(); using (SqlConnection conn = new SqlConnection(cons)) { string query = @"SELECT Id, Title, ZoneId, IP, HostName, Max, Min, Avg, FullUrl, CreatedTime, Mode, Count, MaxDisplay, MinDisplay, AvgDisplay, IfCreateWhiteLimit, Remark FROM t_Action_Report WHERE ZoneId=@zoneId"; SqlCommand cmd = new SqlCommand(query, conn); cmd.Parameters.AddWithValue("@zoneId", zoneId); conn.Open(); using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { ActionReport item = new ActionReport(); item.Id = Convert.ToInt32(reader["Id"]); item.Title = Convert.ToString(reader["Title"]); item.ZoneId = Convert.ToString(reader["ZoneId"]); item.IP = Convert.ToString(reader["IP"]); item.HostName = Convert.ToString(reader["HostName"]); item.Max = Convert.ToInt32(reader["Max"]); item.Min = Convert.ToInt32(reader["Min"]); item.Avg = Convert.ToInt32(reader["Avg"]); item.FullUrl = Convert.ToString(reader["FullUrl"]); item.CreatedTime = Convert.ToDateTime(reader["CreatedTime"]); item.Mode = Convert.ToString(reader["Mode"]); item.Count = Convert.ToInt32(reader["Count"]); item.Remark = Convert.ToString(reader["Remark"]); item.MaxDisplay = Convert.ToString(reader["MaxDisplay"]); item.MinDisplay = Convert.ToString(reader["MinDisplay"]); item.AvgDisplay = Convert.ToString(reader["AvgDisplay"]); item.IfCreateWhiteLimit = Convert.ToInt32(reader["IfCreateWhiteLimit"]) > 0; result.Add(item); } } } return(result); }
public static List <ActionReport> GetWhiteListByIp(int limit, int offset, DateTime startTime, DateTime endTime, string ip) { string cons = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString(); List <ActionReport> result = new List <ActionReport>(); long arrange = offset + limit; using (SqlConnection conn = new SqlConnection(cons)) { string query = @"SELECT TOP(@limit) * FROM ( SELECT TOP(@arrange) ROW_NUMBER() OVER (ORDER BY CreatedTime DESC ) AS RowNum, * FROM t_Action_Report WHERE IP=@ip AND mode = 'WhiteList' AND CreatedTime >= @startTime AND CreatedTime <= @endTime ) AS tempTable WHERE RowNum BETWEEN @offset + 1 AND @arrange ORDER BY RowNum"; SqlCommand cmd = new SqlCommand(query, conn); cmd.Parameters.AddWithValue("@ip", ip); cmd.Parameters.AddWithValue("@limit", limit); cmd.Parameters.AddWithValue("@arrange", arrange); cmd.Parameters.AddWithValue("@offset", offset); cmd.Parameters.AddWithValue("@startTime", startTime); cmd.Parameters.AddWithValue("@endTime", endTime); conn.Open(); using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { ActionReport item = new ActionReport(); item.Id = Convert.ToInt32(reader["Id"]); item.Title = Convert.ToString(reader["Title"]); item.ZoneId = Convert.ToString(reader["ZoneId"]); item.IP = Convert.ToString(reader["IP"]); item.HostName = Convert.ToString(reader["HostName"]); item.Max = Convert.ToInt32(reader["Max"]); item.Min = Convert.ToInt32(reader["Min"]); item.Avg = Convert.ToInt32(reader["Avg"]); item.FullUrl = Convert.ToString(reader["FullUrl"]); item.CreatedTime = Convert.ToDateTime(reader["CreatedTime"]); item.Mode = Convert.ToString(reader["Mode"]); item.Count = Convert.ToInt32(reader["Count"]); item.Remark = Convert.ToString(reader["Remark"]); item.MaxDisplay = Convert.ToString(reader["MaxDisplay"]); item.MinDisplay = Convert.ToString(reader["MinDisplay"]); item.AvgDisplay = Convert.ToString(reader["AvgDisplay"]); item.IfCreateWhiteLimit = Convert.ToInt32(reader["IfCreateWhiteLimit"]) > 0; result.Add(item); } } } return(result); }
private static void DoReportLine(string prefix, ActionReport report) { if (report.isError) { GUILayout.Box(prefix + report.logText, SkillEditorStyles.ErrorBox, new GUILayoutOption[0]); return; } GUILayout.Label(prefix + report.logText, new GUILayoutOption[0]); }
public override object SetReportAction(Act action, Context context, Amdocs.Ginger.Common.eExecutedFrom executedFrom, bool offlineMode = false) { string executionLogFolder = string.Empty; if (!offlineMode) { executionLogFolder = ExecutionLogfolder; } ActionReport AR = GetActionReportData(action, context, executedFrom); if (System.IO.Directory.Exists(Path.Combine(executionLogFolder, action.ExecutionLogFolder))) { this.SaveObjToReporsitory(AR, Path.Combine(executionLogFolder, action.ExecutionLogFolder, "Action.txt")); // Save screenShots int screenShotCountPerAction = 0; for (var s = 0; s < action.ScreenShots.Count; s++) { try { screenShotCountPerAction++; var screenShotPath = Path.Combine(executionLogFolder, action.ExecutionLogFolder, string.Concat("ScreenShot_", AR.Seq, "_", screenShotCountPerAction.ToString(), ".png")); if (executedFrom == Amdocs.Ginger.Common.eExecutedFrom.Automation) { System.IO.File.Copy(action.ScreenShots[s], screenShotPath, true); } else { System.IO.File.Move(action.ScreenShots[s], screenShotPath); action.ScreenShots[s] = screenShotPath; } } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, "Failed to move screen shot of the action:'" + action.Description + "' to the Execution Logger folder", ex); screenShotCountPerAction--; } } //change the paths to Defect suggestion list var defectSuggestion = WorkSpace.Instance.RunsetExecutor.DefectSuggestionsList.FirstOrDefault(z => z.FailedActionGuid == action.Guid); if (defectSuggestion != null) { defectSuggestion.ScreenshotFileNames = action.ScreenShots.ToList(); } } else { Reporter.ToLog(eLogLevel.ERROR, "Failed to create ExecutionLogger JSON file for the Action :" + action.Description + " because directory not exists :" + Path.Combine(executionLogFolder, action.ExecutionLogFolder)); } return(AR); }
private static void CheckActionReportForErrors() { using (List <ActionReport> .Enumerator enumerator = ActionReport.ActionReportList.GetEnumerator()) { while (enumerator.MoveNext()) { ActionReport current = enumerator.get_Current(); if (current.isError && current.actionIndex < current.state.get_Actions().Length) { FsmErrorChecker.AddError(current.state, current.state.get_Actions()[current.actionIndex], current.parameter, current.logText); } } } }
private void DoSortedByFSM() { this.currentFSM = null; this.currentState = null; this.currentAction = null; using (List <ActionReport> .Enumerator enumerator = ActionReport.ActionReportList.GetEnumerator()) { while (enumerator.MoveNext()) { ActionReport current = enumerator.get_Current(); if (!(current.fsm == null) && current.state != null && current.action != null) { if (current.fsm != this.currentFSM) { this.currentFSM = current.fsm; SkillEditorGUILayout.Divider(new GUILayoutOption[0]); if (GUILayout.Button(Labels.GetFullFsmLabel(current.fsm.get_Fsm()), EditorStyles.get_label(), new GUILayoutOption[0])) { ActionReportWindow.SelectReport(current); break; } EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), 4); } if (current.state != this.currentState) { this.currentState = current.state; SkillEditorGUILayout.LightDivider(new GUILayoutOption[0]); if (GUILayout.Button(Strings.get_Tab() + current.state.get_Name(), EditorStyles.get_label(), new GUILayoutOption[0])) { ActionReportWindow.SelectReport(current); break; } EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), 4); } if (current.action != this.currentAction) { SkillEditorGUILayout.LightDivider(new GUILayoutOption[0]); this.currentAction = current.action; if (GUILayout.Button(Strings.get_Tab2() + Labels.GetActionLabel(current.action), EditorStyles.get_label(), new GUILayoutOption[0])) { ActionReportWindow.SelectReport(current); break; } EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), 4); } ActionReportWindow.DoReportLine(Strings.get_Tab3(), current); } } } }
/// <summary> /// Converts the specified <see cref="ActionReport"/> to the corresponding JUnit <see cref="testsuitesTestsuite"/>. /// </summary> /// <param name="actionReport">The <see cref="ActionReport"/> instance contains the data of an action.</param> /// <param name="index">The index, starts from 0, to identify the order of the testsuites.</param> /// <returns>The converted JUnit <see cref="testsuitesTestsuite"/> instance.</returns> private testsuitesTestsuite ConvertTestsuite(ActionReport actionReport, int index) { // get owner iteration data int iterationIndex = 0; if (actionReport.OwnerIteration != null) { iterationIndex = actionReport.OwnerIteration.Index; } // a GUI test action is converted to a JUnit testsuite testsuitesTestsuite ts = new testsuitesTestsuite(); ts.id = index; // Starts at '0' for the first testsuite and is incremented by 1 for each following testsuite ts.package = Input.TestAndReportName; // Derived from testsuite/@name in the non-aggregated documents // sample: GUI-00012: Iteration 1 / Action 3 ts.name = string.Format("GUI-{0,5:00000}: {1} {2} / {3}", index + 1, Properties.Resources.PropName_Iteration, iterationIndex, actionReport.Name); // other JUnit required fields ts.timestamp = actionReport.StartTime; ts.hostname = Input.HostName; if (string.IsNullOrWhiteSpace(ts.hostname)) { ts.hostname = "localhost"; } ts.time = actionReport.DurationSeconds; // properties List <testsuiteProperty> properties = new List <testsuiteProperty>(ConvertTestsuiteCommonProperties(actionReport)); properties.AddRange(ConvertTestsuiteProperties(actionReport)); ts.properties = properties.ToArray(); // JUnit testcases int testcaseCount = 0; int failureCount = 0; ts.testcase = ConvertTestcases(actionReport, out testcaseCount, out failureCount); ts.tests = testcaseCount; ts.failures = failureCount; return(ts); }
internal ActionReport GetActionReportData(Act action, Context context, Amdocs.Ginger.Common.eExecutedFrom executedFrom) { ActionReport AR = new ActionReport(action, context); AR.Seq = context.Activity.ExecutionLogActionCounter; if ((action.RunDescription != null) && (action.RunDescription != string.Empty)) { if (mVE == null) { mVE = new GingerCore.ValueExpression(context.Environment, null, new ObservableList <GingerCore.DataSource.DataSourceBase>(), false, "", false); } mVE.Value = action.RunDescription; AR.RunDescription = mVE.ValueCalculated; } return(AR); }
public static void Edit(ActionReport item) { string cons = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString(); StringBuilder query = new StringBuilder(@"UPDATE dbo.t_Action_Report SET Title=@title, ZoneId=@zoneId, IP=@ip, HostName=@hostName, Max=@max, Min=@min, Avg=@avg, FullUrl=@fullUrl, CreatedTime=@createdTime, Mode=@mode, Count=@count, MaxDisplay=@maxDisplay, MinDisplay=@minDisplay, AvgDisplay=@avgDisplay, Remark=@remark, IfCreateWhiteLimit=@ifCreateWhiteLimit WHERE Id=@id"); using (SqlConnection conn = new SqlConnection(cons)) { SqlCommand cmd = new SqlCommand(query.ToString(), conn); cmd.Parameters.AddWithValue("@title", item.Title); cmd.Parameters.AddWithValue("@zoneId", item.ZoneId); cmd.Parameters.AddWithValue("@ip", item.IP); cmd.Parameters.AddWithValue("@hostName", item.HostName); cmd.Parameters.AddWithValue("@max", item.Max); cmd.Parameters.AddWithValue("@min", item.Min); cmd.Parameters.AddWithValue("@avg", item.Avg); cmd.Parameters.AddWithValue("@fullUrl", item.FullUrl); cmd.Parameters.AddWithValue("@createdTime", item.CreatedTime); cmd.Parameters.AddWithValue("@mode", item.Mode); cmd.Parameters.AddWithValue("@count", item.Count); cmd.Parameters.AddWithValue("@remark", item.Remark); cmd.Parameters.AddWithValue("@maxDisplay", item.MaxDisplay); cmd.Parameters.AddWithValue("@minDisplay", item.MinDisplay); cmd.Parameters.AddWithValue("@avgDisplay", item.AvgDisplay); cmd.Parameters.AddWithValue("@ifCreateWhiteLimit", item.IfCreateWhiteLimit); cmd.Parameters.AddWithValue("@id", item.Id); conn.Open(); cmd.ExecuteNonQuery(); } }
public override object SetReportAction(Act action, Context context, Amdocs.Ginger.Common.eExecutedFrom executedFrom, bool offlineMode = false) { string executionLogFolder = string.Empty; if (!offlineMode) { executionLogFolder = ExecutionLogfolder; } ActionReport AR = GetActionReportData(action, context, executedFrom); if (System.IO.Directory.Exists(Path.Combine(executionLogFolder, action.ExecutionLogFolder))) { this.SaveObjToReporsitory(AR, Path.Combine(executionLogFolder, action.ExecutionLogFolder, "Action.txt")); // Save screenShots int screenShotCountPerAction = 0; for (var s = 0; s < action.ScreenShots.Count; s++) { try { screenShotCountPerAction++; if (executedFrom == Amdocs.Ginger.Common.eExecutedFrom.Automation) { System.IO.File.Copy(action.ScreenShots[s], Path.Combine(executionLogFolder, action.ExecutionLogFolder, "ScreenShot_" + AR.Seq + "_" + screenShotCountPerAction.ToString() + ".png"), true); } else { System.IO.File.Move(action.ScreenShots[s], Path.Combine(executionLogFolder, action.ExecutionLogFolder, "ScreenShot_" + AR.Seq + "_" + screenShotCountPerAction.ToString() + ".png")); action.ScreenShots[s] = Path.Combine(executionLogFolder, action.ExecutionLogFolder, "ScreenShot_" + AR.Seq + "_" + screenShotCountPerAction.ToString() + ".png"); } } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, "Failed to move screen shot of the action:'" + action.Description + "' to the Execution Logger folder", ex); screenShotCountPerAction--; } } } else { Reporter.ToLog(eLogLevel.ERROR, "Failed to create ExecutionLogger JSON file for the Action :" + action.Description + " because directory not exists :" + Path.Combine(executionLogFolder, action.ExecutionLogFolder)); } return(AR); }
public void SetReportData(ActionReport actionReport) { Seq = actionReport.Seq; GUID = Guid.Parse(actionReport.GUID); Name = actionReport.Name; ActionType = actionReport.ActionType; Description = actionReport.Description; RunDescription = actionReport.RunDescription; ActionType = actionReport.ActionType; StartTimeStamp = actionReport.StartTimeStamp; EndTimeStamp = actionReport.EndTimeStamp; Elapsed = actionReport.Elapsed; RunStatus = actionReport.Status; InputValues = new List <string>(actionReport.InputValues); OutputValues = new List <string>(actionReport.OutputValues); FlowControls = new List <string>(actionReport.FlowControls); CurrentRetryIteration = actionReport.CurrentRetryIteration; Error = actionReport.Error; ExInfo = actionReport.ExInfo; }
public UniversalTimeUnitPassReport MankeAnUniversalTimeUntiPass() { UniversalTimeUnitPassReport universalTimeUnitPassReport = new UniversalTimeUnitPassReport(); if (ObjectToRemoveFromExistanceOnNextOccasion.Count != 0) { foreach (UniversalObject universalObject in ObjectToRemoveFromExistanceOnNextOccasion) { UniversalObjectsInside.Remove(universalObject); } } foreach (UniversalObject universalObject in UniversalObjectsInside) { Being being = universalObject as Being; if (being != null) { if (being.IsALivingBeing) { if (being.IsAlive) { universalTimeUnitPassReport.AliveBeings++; } if (being.IsDecomposed) { ObjectToRemoveFromExistanceOnNextOccasion.Add(universalObject); } } } ActionReport actionReport = universalObject.DoAnythingYoucanDoOrWantTo(this); AttackReport attackReport = actionReport as AttackReport; if (attackReport != null) { universalTimeUnitPassReport.Attacks.Add(attackReport.attackPath); } } return(universalTimeUnitPassReport); }
private string GetBackgroundColor(ActionReport actionReport) { string color = ""; if (actionReport.MaxDisplay.Contains("Not Applicable") || actionReport.MinDisplay.Contains("Not Applicable") || actionReport.AvgDisplay.Contains("Not Applicable")) { color = "background-color:red;"; } else { if (actionReport.MaxDisplay.Contains("(")) { string[] vls = actionReport.MaxDisplay.Replace(")", "").Split('('); int firNum = Convert.ToInt32(vls[0]); int lstNum = Convert.ToInt32(vls[1]); if (firNum > lstNum) { color = "background-color:red;"; } } if (actionReport.AvgDisplay.Contains("(")) { string[] vls = actionReport.AvgDisplay.Replace(")", "").Split('('); int firNum = Convert.ToInt32(vls[0]); int lstNum = Convert.ToInt32(vls[1]); if (firNum > lstNum) { color = "background-color:red;"; } } } return(color); }
protected void SetDirty(bool checkAll = false) { Skill fsmOwner = this.fsmOwner; if (fsmOwner != null) { if (!EditorApplication.get_isPlayingOrWillChangePlaymode() && FsmErrorChecker.FsmHasErrors(fsmOwner)) { ActionReport.Remove(fsmOwner.get_Owner() as PlayMakerFSM); fsmOwner.Reinitialize(); } SkillEditor.SetFsmDirty(fsmOwner, checkAll, false, true); } if (this.globalsOwner != null) { EditorUtility.SetDirty(this.globalsOwner); if (!EditorApplication.get_isPlayingOrWillChangePlaymode() && SkillEditor.SelectedFsmComponent != null && FsmErrorChecker.FsmHasErrors(SkillEditor.SelectedFsm)) { ActionReport.Remove(SkillEditor.SelectedFsmComponent); SkillEditor.SelectedFsm.Reinitialize(); } } }
private void GeneratedActiveReport(string title, ZoneEntity zone, List <List <CloudflareLog> > cloudflareLogs) { var cloundFlareApiService = new CloudFlareApiService(); var whiteList = cloundFlareApiService.GetAccessRuleList(zone.ZoneId, zone.AuthEmail, zone.AuthKey, EnumMode.whitelist); var whiteListIps = whiteList.Select(a => a.configurationValue); var totalList = cloudflareLogs.SelectMany(a => a) .GroupBy(a => new { a.ClientIP, a.ClientRequestHost }) .Select( g => new { IP = g.Key.ClientIP, HostName = g.Key.ClientRequestHost, Count = g.Count(), }) .Where(a => !whiteListIps.Contains(a.IP)) .OrderByDescending(a => a.Count); List <string> ipList = new List <string>(); foreach (var item in totalList) { //取不同的20个IP if (!ipList.Contains(item.IP)) { ipList.Add(item.IP); } if (ipList.Count > 20) { break; } int max = GetMax(cloudflareLogs, item.IP, item.HostName); int min = GetMin(cloudflareLogs, item.IP, item.HostName); int avg = GetAvg(cloudflareLogs, item.IP, item.HostName); List <string> urls = GetTop5Urls(cloudflareLogs, item.IP, item.HostName); string urlsJson = JsonConvert.SerializeObject(urls); int?maxHistory = ActionReportBusiness.GetMaxForAction(zone.ZoneId, item.IP, item.HostName); int?minHistory = ActionReportBusiness.GetMinForAction(zone.ZoneId, item.IP, item.HostName); int?avgHistory = ActionReportBusiness.GetAvgForAction(zone.ZoneId, item.IP, item.HostName); string maxDisplay = string.Format("{0}({1})", max, maxHistory.HasValue ? maxHistory.Value.ToString() : nothing); string minDisplay = string.Format("{0}({1})", min, minHistory.HasValue ? minHistory.Value.ToString() : nothing); string avgDisplay = string.Format("{0}({1})", avg, avgHistory.HasValue ? avgHistory.Value.ToString() : nothing); ActionReport report = new ActionReport { IP = item.IP, HostName = item.HostName, Max = max, Min = min, Avg = avg, FullUrl = urlsJson, Title = title, ZoneId = zone.ZoneId, Count = item.Count, Mode = "Action", CreatedTime = DateTime.UtcNow, MaxDisplay = maxDisplay, MinDisplay = minDisplay, AvgDisplay = avgDisplay, Remark = "", }; ActionReportBusiness.Add(report); } }
private static void SelectReport(ActionReport report) { SkillEditor.SelectFsm(report.fsm.get_Fsm()); SkillEditor.SelectState(report.state, true); SkillEditor.SelectAction(report.state, report.actionIndex, true); }
public static void Add(ActionReport item) { string cons = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString(); StringBuilder query = new StringBuilder(@"INSERT INTO dbo.t_Action_Report ( Title, ZoneId, IP, HostName, Max, Min, Avg, FullUrl, CreatedTime, Mode, Count, Remark, MaxDisplay, MinDisplay, AvgDisplay, IfCreateWhiteLimit ) VALUES ( @title, @zoneId, @ip, @hostName, @max, @min, @avg, @fullUrl, @createdTime, @mode, @count, @remark, @maxDisplay, @minDisplay, @avgDisplay, @ifCreateWhiteLimit )"); using (SqlConnection conn = new SqlConnection(cons)) { SqlCommand cmd = new SqlCommand(query.ToString(), conn); cmd.Parameters.AddWithValue("@title", item.Title); cmd.Parameters.AddWithValue("@zoneId", item.ZoneId); cmd.Parameters.AddWithValue("@ip", item.IP); cmd.Parameters.AddWithValue("@hostName", item.HostName); cmd.Parameters.AddWithValue("@max", item.Max); cmd.Parameters.AddWithValue("@min", item.Min); cmd.Parameters.AddWithValue("@avg", item.Avg); cmd.Parameters.AddWithValue("@fullUrl", item.FullUrl); cmd.Parameters.AddWithValue("@createdTime", item.CreatedTime); cmd.Parameters.AddWithValue("@mode", item.Mode); cmd.Parameters.AddWithValue("@count", item.Count); cmd.Parameters.AddWithValue("@remark", item.Remark); cmd.Parameters.AddWithValue("@maxDisplay", item.MaxDisplay); cmd.Parameters.AddWithValue("@minDisplay", item.MinDisplay); cmd.Parameters.AddWithValue("@avgDisplay", item.AvgDisplay); cmd.Parameters.AddWithValue("@ifCreateWhiteLimit", item.IfCreateWhiteLimit); conn.Open(); cmd.ExecuteNonQuery(); } }
private void GeneratedWhiteListReport(string title, ZoneEntity zone, List <List <CloudflareLog> > cloudflareLogs) { var cloundFlareApiService = new CloudFlareApiService(); var whiteList = cloundFlareApiService.GetAccessRuleList(zone.ZoneId, zone.AuthEmail, zone.AuthKey, EnumMode.whitelist); var subWhiteList = whiteList.Where(a => a.notes.Contains("WHITELIST CLEINT'S IP ADDRESS SITEID")) .Select(a => new WhiteListModel { IP = a.configurationValue }).ToList(); //var subWhiteList = new List< WhiteListModel>(){ // new WhiteListModel { // IP= "131.242.135.253", // }, // new WhiteListModel { // IP= "131.242.135.252", // } //}; var totalList = cloudflareLogs.SelectMany(a => a) .Join(subWhiteList, left => left.ClientIP, right => right.IP, (left, right) => new { left.ClientIP, left.ClientRequestHost }) .GroupBy(a => new { a.ClientIP, a.ClientRequestHost }) .Select( g => new { IP = g.Key.ClientIP, HostName = g.Key.ClientRequestHost, Count = g.Count(), }) .OrderByDescending(a => a.Count); List <string> ipList = new List <string>(); foreach (var item in totalList) { //取不同的20个IP if (!ipList.Contains(item.IP)) { ipList.Add(item.IP); } if (ipList.Count > 20) { break; } int max = GetMax(cloudflareLogs, item.IP, item.HostName); int min = GetMin(cloudflareLogs, item.IP, item.HostName); int avg = GetAvg(cloudflareLogs, item.IP, item.HostName); List <string> urls = GetTop5Urls(cloudflareLogs, item.IP, item.HostName); string urlsJson = JsonConvert.SerializeObject(urls); int?maxHistory = ActionReportBusiness.GetMaxForWhiteList(zone.ZoneId, item.IP, item.HostName); int?minHistory = ActionReportBusiness.GetMinForWhiteList(zone.ZoneId, item.IP, item.HostName); int?avgHistory = ActionReportBusiness.GetAvgForWhiteList(zone.ZoneId, item.IP, item.HostName); string maxDisplay = string.Format("{0}({1})", max, maxHistory.HasValue ? maxHistory.Value.ToString() : nothing); string minDisplay = string.Format("{0}({1})", min, minHistory.HasValue ? minHistory.Value.ToString() : nothing); string avgDisplay = string.Format("{0}({1})", avg, avgHistory.HasValue ? avgHistory.Value.ToString() : nothing); ActionReport report = new ActionReport { IP = item.IP, HostName = item.HostName, Max = max, Min = min, Avg = avg, FullUrl = urlsJson, Title = title, ZoneId = zone.ZoneId, Count = item.Count, Mode = "WhiteList", CreatedTime = DateTime.UtcNow, MaxDisplay = maxDisplay, MinDisplay = minDisplay, AvgDisplay = avgDisplay, Remark = "", }; ActionReportBusiness.Add(report); } }
void SendReport(ActionReport report) { this.World.AddReport(report); }
void SendFailReport(ActionReport report, string message) { report.SetFail(message); this.World.AddReport(report); }
public static void Edit(ActionReport item) { ActionReportAccess.Edit(item); }
public override void ActionEnd(uint eventTime, Act action, bool offlineMode = false) { ActionReport actionReport = new ActionReport(action, null);//need to provide valid Context SaveObjToJSonFile(actionReport, Path.Combine(CurrentActivityFolder, CurrentActionFolder, "ActionReport.txt")); }
public static void Add(ActionReport item) { ActionReportAccess.Add(item); }
private void DoSortedByAction() { List <Type> list = new List <Type>(); using (List <ActionReport> .Enumerator enumerator = ActionReport.ActionReportList.GetEnumerator()) { while (enumerator.MoveNext()) { ActionReport current = enumerator.get_Current(); Type type = current.action.GetType(); if (!list.Contains(type)) { list.Add(type); } } } this.currentAction = null; using (List <Type> .Enumerator enumerator2 = list.GetEnumerator()) { while (enumerator2.MoveNext()) { Type current2 = enumerator2.get_Current(); SkillEditorGUILayout.Divider(new GUILayoutOption[0]); GUILayout.Label(Labels.GetActionLabel(current2), EditorStyles.get_boldLabel(), new GUILayoutOption[0]); this.currentFSM = null; this.currentState = null; List <SkillState> list2 = new List <SkillState>(); List <ActionReport> list3 = new List <ActionReport>(); List <string> list4 = new List <string>(); SkillEditorGUILayout.LightDivider(new GUILayoutOption[0]); GUILayout.Label(Strings.get_ActionReportWindow_Action_Changes_Title(), EditorStyles.get_boldLabel(), new GUILayoutOption[0]); using (List <ActionReport> .Enumerator enumerator3 = ActionReport.ActionReportList.GetEnumerator()) { while (enumerator3.MoveNext()) { ActionReport current3 = enumerator3.get_Current(); Type type2 = current3.action.GetType(); if (type2 == current2) { if (!list2.Contains(current3.state)) { list3.Add(current3); list2.Add(current3.state); } if (!list4.Contains(current3.logText)) { ActionReportWindow.DoReportLine(Strings.get_Tab(), current3); list4.Add(current3.logText); } } } } SkillEditorGUILayout.LightDivider(new GUILayoutOption[0]); GUILayout.Label(Strings.get_ActionReportWindow_Effected_States_Title(), EditorStyles.get_boldLabel(), new GUILayoutOption[0]); using (List <ActionReport> .Enumerator enumerator4 = list3.GetEnumerator()) { while (enumerator4.MoveNext()) { ActionReport current4 = enumerator4.get_Current(); if (current4.state != null && !(current4.fsm == null)) { if (GUILayout.Button(Strings.get_Tab() + Labels.GetFullStateLabel(current4.state), EditorStyles.get_label(), new GUILayoutOption[0])) { ActionReportWindow.SelectReport(current4); return; } EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), 4); } } } } } }