protected void Page_Load(object sender, EventArgs e) { CurrentMaster.Title.TitleText = GetString("Task.ViewHeader"); CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_Integration/tasks.png"); IntegrationTaskInfo ti = IntegrationTaskInfoProvider.GetIntegrationTaskInfo(TaskID); // Set edited object EditedObject = ti; if (ti != null) { CurrentMaster.Title.TitleText += " (" + HTMLHelper.HTMLEncode(ti.TaskTitle) + ")"; string direction = GetString(ti.TaskIsInbound ? "integration.inbound" : "integration.outbound"); // Prepare task description StringBuilder sbTaskInfo = new StringBuilder(); sbTaskInfo.Append("<table>"); sbTaskInfo.Append("<tr><td class=\"Title Grid\">" + GetString("integration.taskdirection") + ":</td><td>" + direction + "</td></tr>"); sbTaskInfo.Append("<tr><td class=\"Title Grid\">" + GetString("integration.tasktype") + ":</td><td>" + ti.TaskType + "</td></tr>"); sbTaskInfo.Append("<tr><td class=\"Title Grid\">" + GetString("integration.tasktime") + ":</td><td>" + ti.TaskTime + "</td></tr>"); sbTaskInfo.Append("</table>"); string objectType = ti.TaskObjectType; if (ti.TaskNodeID > 0) { objectType = PredefinedObjectType.DOCUMENT; } viewDataSet.ObjectType = objectType; viewDataSet.DataSet = GetDataSet(ti.TaskData, ti.TaskType, ti.TaskObjectType); viewDataSet.AdditionalContent = sbTaskInfo.ToString(); } }
protected void Page_Load(object sender, EventArgs e) { PageTitle.TitleText = GetString("Task.ViewHeader"); RegisterModalPageScripts(); IntegrationTaskInfo ti = IntegrationTaskInfoProvider.GetIntegrationTaskInfo(TaskID); // Set edited object EditedObject = ti; if (ti != null) { PageTitle.TitleText += " (" + HTMLHelper.HTMLEncode(ti.TaskTitle) + ")"; string direction = GetString(ti.TaskIsInbound ? "integration.inbound" : "integration.outbound"); // Prepare task description StringBuilder sbTaskInfo = new StringBuilder(); sbTaskInfo.Append("<table class='table table-hover'>"); sbTaskInfo.Append("<tr><td style='width: 20%;'><strong>" + GetString("integration.taskdirection") + ":</strong></td><td>" + direction + "</td></tr>"); sbTaskInfo.Append("<tr><td><strong>" + GetString("integration.tasktype") + ":</strong></td><td>" + ti.TaskType + "</td></tr>"); sbTaskInfo.Append("<tr><td><strong>" + GetString("integration.tasktime") + ":</strong></td><td>" + ti.TaskTime + "</td></tr>"); sbTaskInfo.Append("</table>"); string objectType = ti.TaskObjectType; if (ti.TaskNodeID > 0) { objectType = TreeNode.OBJECT_TYPE; } viewDataSet.ObjectType = objectType; viewDataSet.DataSet = GetDataSet(ti.TaskData, ti.TaskType, ti.TaskObjectType); viewDataSet.AdditionalContent = sbTaskInfo.ToString(); } }
protected override void OnPreRender(EventArgs e) { if (SynchronizationInfo != null) { IntegrationTaskInfo ti = IntegrationTaskInfoProvider.GetIntegrationTaskInfo(SynchronizationInfo.SynchronizationTaskID); IntegrationConnectorInfo si = IntegrationConnectorInfoProvider.GetIntegrationConnectorInfo(SynchronizationInfo.SynchronizationConnectorID); // Prepare task description StringBuilder sbTaskInfo = new StringBuilder(); sbTaskInfo.Append("<table>"); if ((ti != null) || (si != null)) { if (ti != null) { sbTaskInfo.Append("<tr><td class=\"Title Grid\">" + GetString("integration.tasktitle") + ":</td><td>" + HTMLHelper.HTMLEncode(ti.TaskTitle) + "</td></tr>"); } if (si != null) { sbTaskInfo.Append("<tr><td class=\"Title Grid\">" + GetString("integration.connectorname") + ":</td><td>" + HTMLHelper.HTMLEncode(si.ConnectorDisplayName) + "</td></tr>"); } } sbTaskInfo.Append("</table>"); lblInfo.Text = sbTaskInfo.ToString(); } lblInfo.Visible = (lblInfo.Text != ""); base.OnPreRender(e); }
protected override void OnPreRender(EventArgs e) { if (SynchronizationInfo != null) { IntegrationTaskInfo ti = IntegrationTaskInfoProvider.GetIntegrationTaskInfo(SynchronizationInfo.SynchronizationTaskID); IntegrationConnectorInfo si = IntegrationConnectorInfoProvider.GetIntegrationConnectorInfo(SynchronizationInfo.SynchronizationConnectorID); // Prepare task description StringBuilder sbTaskInfo = new StringBuilder(); sbTaskInfo.Append("<div class=\"form-horizontal\">"); if ((ti != null) || (si != null)) { if (ti != null) { sbTaskInfo.Append("<div class=\"form-group\"><div class=\"editing-form-label-cell\"><span class=\"control-label\">" + GetString("integration.tasktitle") + ":</span></div><div class=\"editing-form-value-cell\"><span class=\"form-control-text\">" + HTMLHelper.HTMLEncode(ti.TaskTitle) + "</span></div></div>"); } if (si != null) { sbTaskInfo.Append("<div class=\"form-group\"><div class=\"editing-form-label-cell\"><span class=\"control-label\">" + GetString("integration.connectorname") + ":</span></div><div class=\"editing-form-value-cell\"><span class=\"form-control-text\">" + HTMLHelper.HTMLEncode(si.ConnectorDisplayName) + "</span></div></div>"); } } sbTaskInfo.Append("</div>"); lblInfo.Text = sbTaskInfo.ToString(); } lblInfo.Visible = (lblInfo.Text != ""); base.OnPreRender(e); }
/// <summary> /// Deletes selected tasks. /// </summary> protected void DeleteSelected(object parameter) { List <String> list = parameter as List <String>; if (list == null) { return; } CanceledString = GetString("Tasks.DeletionCanceled"); eventCode = "DELETESELECTEDTASKS"; try { AddLog(GetString("Synchronization.DeletingTasks")); list.Sort(); foreach (string synchronizationIdString in list) { int synchronizationId = ValidationHelper.GetInteger(synchronizationIdString, 0); if (synchronizationId > 0) { IntegrationSynchronizationInfo synchronization = IntegrationSynchronizationInfoProvider.GetIntegrationSynchronizationInfo(synchronizationId); if (synchronization != null) { IntegrationTaskInfo task = IntegrationTaskInfoProvider.GetIntegrationTaskInfo(synchronization.SynchronizationTaskID); if (task != null) { DeleteSynchronization(synchronizationId, task.TaskTitle); } } } } CurrentInfo = GetString("tasks.deletionok"); AddLog(CurrentInfo); } catch (ThreadAbortException ex) { if (CMSThread.Stopped(ex)) { // Canceled by user CurrentInfo = CanceledString; AddLog(CurrentInfo); } else { CurrentError = GetString("Tasks.DeletionFailed"); AddErrorLog(CurrentError); } } catch (Exception ex) { CurrentError = GetString("Tasks.DeletionFailed") + ": " + ex.Message; AddErrorLog(CurrentError); } }
/// <summary> /// All items synchronization. /// </summary> protected void SynchronizeAll(object parameter) { StringBuilder result = new StringBuilder(); eventCode = "SYNCALLTASKS"; CanceledString = GetString("Tasks.SynchronizationCanceled"); try { AddLog(GetString("Synchronization.RunningTasks")); // Get the synchronizations DataSet ds = IntegrationTaskInfoProvider.GetIntegrationTasksView(gridElem.CompleteWhereCondition, "SynchronizationID ASC", -1, "TaskTitle, SynchronizationConnectorID, SynchronizationTaskID"); if (!DataHelper.DataSourceIsEmpty(ds)) { foreach (DataRow row in ds.Tables[0].Rows) { // Get necessary synchronization properties int taskId = ValidationHelper.GetInteger(row["SynchronizationTaskID"], 0); int connectorId = ValidationHelper.GetInteger(row["SynchronizationConnectorID"], 0); result.Append(ProcessSynchronization(connectorId, taskId)); } } // Log possible errors if (!String.IsNullOrEmpty(result.ToString())) { CurrentError = GetString("Tasks.SynchronizationFailed"); AddErrorLog(CurrentError); } else { CurrentInfo = GetString("Tasks.SynchronizationOK"); AddLog(CurrentInfo); } } catch (ThreadAbortException ex) { if (CMSThread.Stopped(ex)) { // Canceled by user CurrentInfo = CanceledString; AddLog(CurrentInfo); } else { CurrentError = GetString("Tasks.SynchronizationFailed"); AddErrorLog(CurrentError, result.ToString()); } } catch (Exception ex) { CurrentError = GetString("Tasks.SynchronizationFailed") + ": " + ex.Message; AddErrorLog(CurrentError); } }
/// <summary> /// Deletes all tasks. /// </summary> protected void DeleteAll(object parameter) { eventCode = "DELETEALLTASKS"; CanceledString = GetString("Tasks.DeletionCanceled"); try { AddLog(GetString("Synchronization.DeletingTasks")); // Get synchronizations DataSet ds = IntegrationTaskInfoProvider.GetIntegrationTasksView(gridElem.CompleteWhereCondition, "SynchronizationID ASC", -1, "SynchronizationID, TaskTitle"); if (!DataHelper.DataSourceIsEmpty(ds)) { foreach (DataRow row in ds.Tables[0].Rows) { // Get synchronization id int synchronizationId = ValidationHelper.GetInteger(row["SynchronizationID"], 0); if (synchronizationId > 0) { string taskTitle = ValidationHelper.GetString(row["TaskTitle"], String.Empty); DeleteSynchronization(synchronizationId, taskTitle); } } } CurrentInfo = GetString("Tasks.DeleteOK"); AddLog(CurrentInfo); } catch (ThreadAbortException ex) { string state = ValidationHelper.GetString(ex.ExceptionState, string.Empty); if (state == CMSThread.ABORT_REASON_STOP) { // Canceled by user CurrentInfo = CanceledString; AddLog(CurrentInfo); } else { CurrentError = GetString("Tasks.DeletionFailed"); AddErrorLog(CurrentError); } } catch (Exception ex) { CurrentError = GetString("Tasks.DeletionFailed") + ": " + ex.Message; AddErrorLog(CurrentError); } finally { // Finalize log context FinalizeContext(); } }
private string ProcessSynchronization(int connectorId, int taskId) { if ((taskId > 0) && (connectorId > 0)) { // Get connector and task IntegrationConnectorInfo connectorInfo = IntegrationConnectorInfoProvider.GetIntegrationConnectorInfo(connectorId); IntegrationTaskInfo taskInfo = IntegrationTaskInfoProvider.GetIntegrationTaskInfo(taskId); if ((connectorInfo != null) && (taskInfo != null)) { if (connectorInfo.ConnectorEnabled) { // Get connector instance BaseIntegrationConnector connector = IntegrationHelper.GetConnector(connectorInfo.ConnectorName) as BaseIntegrationConnector; if (connector != null) { AddLog(String.Format(ResHelper.GetAPIString("synchronization.running", "Processing '{0}' task"), HTMLHelper.HTMLEncode(taskInfo.TaskTitle))); // Process the task if (TasksAreInbound) { // Always try to process the task when requested from UI taskInfo.TaskProcessType = IntegrationProcessTypeEnum.Default; return(connector.ProcessExternalTask(taskInfo)); } else { return(connector.ProcessInternalTask(taskInfo)); } } else { // Can't load connector AddLog(String.Format(ResHelper.GetAPIString("synchronization.skippingunavailable", "Skipping '{0}' task - failed to load associated connector."), HTMLHelper.HTMLEncode(taskInfo.TaskTitle))); } } else { // Connector is disabled AddLog(String.Format(ResHelper.GetAPIString("synchronization.skippingdisabled", "Skipping '{0}' task - associated connector is disabled."), HTMLHelper.HTMLEncode(taskInfo.TaskTitle))); } } } return(null); }
protected void gridElem_OnAction(string actionName, object actionArgument) { int synchronizationId = ValidationHelper.GetInteger(actionArgument, 0); switch (actionName.ToLowerInvariant()) { case "delete": // Delete synchronization IntegrationSynchronizationInfoProvider.DeleteIntegrationSynchronizationInfo(synchronizationId); break; case "run": // Get synchronization IntegrationSynchronizationInfo synchronization = IntegrationSynchronizationInfoProvider.GetIntegrationSynchronizationInfo(synchronizationId); if (synchronization != null) { // Get connector and task IntegrationConnectorInfo connectorInfo = IntegrationConnectorInfoProvider.GetIntegrationConnectorInfo(synchronization.SynchronizationConnectorID); IntegrationTaskInfo taskInfo = IntegrationTaskInfoProvider.GetIntegrationTaskInfo(synchronization.SynchronizationTaskID); if ((connectorInfo != null) && (taskInfo != null)) { // Get connector instance BaseIntegrationConnector connector = IntegrationHelper.GetConnector(connectorInfo.ConnectorName) as BaseIntegrationConnector; if (connector != null) { // Process the task if (TasksAreInbound) { // Always try to process the task when requested from UI taskInfo.TaskProcessType = IntegrationProcessTypeEnum.Default; connector.ProcessExternalTask(taskInfo); } else { connector.ProcessInternalTask(taskInfo); } } } } break; } }
private IEnumerable <KeyValuePair <string, string> > GetMetricData() { string stringData = null; IEnumerable <KeyValuePair <string, string> > tupleData = null; // Gather data for each row, return special message if data is null switch (MetricCodeName) { // Categories case MetricDataEnum.support_metrics: case MetricDataEnum.support_metrics_system: case MetricDataEnum.support_metrics_environment: case MetricDataEnum.support_metrics_counters: case MetricDataEnum.support_metrics_ecommerce: case MetricDataEnum.support_metrics_tasks: case MetricDataEnum.support_metrics_eventlog: return(null); #region System case MetricDataEnum.support_metrics_system_version: stringData = CMSVersion.GetVersion(true, true, true, true); break; case MetricDataEnum.support_metrics_system_appname: stringData = SettingsHelper.AppSettings["CMSApplicationName"]; break; case MetricDataEnum.support_metrics_system_instancename: stringData = SystemContext.InstanceName; break; case MetricDataEnum.support_metrics_system_physicalpath: stringData = SystemContext.WebApplicationPhysicalPath; break; case MetricDataEnum.support_metrics_system_apppath: stringData = SystemContext.ApplicationPath; break; case MetricDataEnum.support_metrics_system_uiculture: stringData = LocalizationContext.CurrentUICulture.CultureName; break; case MetricDataEnum.support_metrics_system_installtype: stringData = SystemContext.IsWebApplicationProject ? "Web App" : "Web site"; break; case MetricDataEnum.support_metrics_system_portaltemplatepage: stringData = URLHelper.PortalTemplatePage; break; case MetricDataEnum.support_metrics_system_timesinceapprestart: stringData = (DateTime.Now - CMSApplication.ApplicationStart).ToString(@"dd\:hh\:mm\:ss"); break; case MetricDataEnum.support_metrics_system_discoveredassemblies: tupleData = AssemblyDiscoveryHelper.GetAssemblies(true).Select((a, i) => GetKeyValuePair(i, a.FullName)); break; case MetricDataEnum.support_metrics_system_targetframework: HttpRuntimeSection httpRuntime = ConfigurationManager.GetSection("system.web/httpRuntime") as HttpRuntimeSection; stringData = httpRuntime.TargetFramework; break; case MetricDataEnum.support_metrics_system_authmode: AuthenticationSection Authentication = ConfigurationManager.GetSection("system.web/authentication") as AuthenticationSection; stringData = Authentication?.Mode.ToString(); break; case MetricDataEnum.support_metrics_system_sessionmode: SessionStateSection SessionState = ConfigurationManager.GetSection("system.web/sessionState") as SessionStateSection; stringData = SessionState?.Mode.ToString(); break; case MetricDataEnum.support_metrics_system_debugmode: CompilationSection Compilation = ConfigurationManager.GetSection("system.web/compilation") as CompilationSection; stringData = Compilation?.Debug.ToString(); break; case MetricDataEnum.support_metrics_system_runallmanagedmodules: var xmlDoc = new System.Xml.XmlDocument(); xmlDoc.Load(URLHelper.GetPhysicalPath("~/Web.config")); stringData = xmlDoc.SelectSingleNode("/configuration/system.webServer/modules").Attributes["runAllManagedModulesForAllRequests"]?.Value; break; #endregion System #region Environment case MetricDataEnum.support_metrics_environment_trustlevel: AspNetHostingPermissionLevel trustLevel = AspNetHostingPermissionLevel.None; if (!SystemContext.IsWebSite) { trustLevel = AspNetHostingPermissionLevel.Unrestricted; } // Check the trust level by evaluation of levels foreach (AspNetHostingPermissionLevel permissionLevel in new[] { AspNetHostingPermissionLevel.Unrestricted, AspNetHostingPermissionLevel.High, AspNetHostingPermissionLevel.Medium, AspNetHostingPermissionLevel.Low, AspNetHostingPermissionLevel.Minimal }) { try { new AspNetHostingPermission(permissionLevel).Demand(); } catch (SecurityException) { continue; } trustLevel = permissionLevel; break; } stringData = trustLevel.ToString(); break; case MetricDataEnum.support_metrics_environment_iisversion: stringData = MetricServerVariables["SERVER_SOFTWARE"]; break; case MetricDataEnum.support_metrics_environment_https: stringData = MetricServerVariables["HTTPS"]; break; case MetricDataEnum.support_metrics_environment_windowsversion: using (RegistryKey versionKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion")) { var productName = versionKey?.GetValue("ProductName"); var currentBuild = versionKey?.GetValue("CurrentBuild"); var releaseId = versionKey?.GetValue("ReleaseId"); stringData = String.Format("{0}, build {1}, release {2}", productName.ToString(), currentBuild.ToString(), releaseId.ToString()); } break; case MetricDataEnum.support_metrics_environment_netversion: using (RegistryKey ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\")) { var keyValue = ndpKey?.GetValue("Release"); if (keyValue != null) { var releaseKey = (int)keyValue; if (releaseKey >= 461808) { stringData = "4.7.2 or later"; } else if (releaseKey >= 461308) { stringData = "4.7.1"; } else if (releaseKey >= 460798) { stringData = "4.7"; } else if (releaseKey >= 394802) { stringData = "4.6.2"; } else if (releaseKey >= 394254) { stringData = "4.6.1"; } else if (releaseKey >= 393295) { stringData = "4.6"; } else if (releaseKey >= 379893) { stringData = "4.5.2"; } else if (releaseKey >= 378675) { stringData = "4.5.1"; } else if (releaseKey >= 378389) { stringData = "4.5"; } } } break; case MetricDataEnum.support_metrics_environment_sqlserverversion: var dtm = new TableManager(null); stringData = dtm.DatabaseServerVersion; break; case MetricDataEnum.support_metrics_environment_azure: var azureStats = new Dictionary <string, string>(4) { { "Is a Cloud Service", (SettingsHelper.AppSettings["CMSAzureProject"] == "true").ToString("false") }, { "Is file system on Azure", (SettingsHelper.AppSettings["CMSExternalStorageName"] == "azure").ToString("false") }, { "Azure storage account", SettingsHelper.AppSettings["CMSAzureAccountName"] ?? String.Empty }, { "Azure CDN endpoint", SettingsHelper.AppSettings["CMSAzureCDNEndpoint"] ?? String.Empty } }; tupleData = azureStats.Select(s => GetKeyValuePair(s.Key, s.Value)); break; case MetricDataEnum.support_metrics_environment_amazon: var amazonStats = new Dictionary <string, string>(3) { { "Is file system on Amazon", (SettingsHelper.AppSettings["CMSExternalStorageName"] == "amazon").ToString() }, { "Amazon bucket name", SettingsHelper.AppSettings["CMSAmazonBucketName"] ?? String.Empty }, { "Amazon public access", SettingsHelper.AppSettings["CMSAmazonPublicAccess"] ?? String.Empty }, }; tupleData = amazonStats.Select(s => GetKeyValuePair(s.Key, s.Value)); break; case MetricDataEnum.support_metrics_environment_services: tupleData = ServiceManager.GetServices().Select(s => GetKeyValuePair(s.ServiceName, s.Status)); break; #endregion Environment #region Counters case MetricDataEnum.support_metrics_counters_webfarmservers: stringData = CoreServices.WebFarm.GetEnabledServerNames().Count().ToString(); break; case MetricDataEnum.support_metrics_counters_stagingservers: stringData = ServerInfoProvider.GetServers().GetCount().ToString(); break; case MetricDataEnum.support_metrics_counters_pagemostchildren: CMS.DocumentEngine.TreeProvider tree = new CMS.DocumentEngine.TreeProvider(); var pageWithMostChildren = tree.SelectNodes().OnCurrentSite().Published() .ToDictionary(n => n, n => n.Children.Count) .Aggregate((l, r) => l.Value > r.Value ? l : r); tupleData = new[] { GetKeyValuePair(URLHelper.GetAbsoluteUrl("~" + pageWithMostChildren.Key.NodeAliasPath), pageWithMostChildren.Value) }; break; case MetricDataEnum.support_metrics_counters_modules: stringData = ResourceInfoProvider.GetResources().GetCount().ToString(); break; case MetricDataEnum.support_metrics_counters_medialibraries: stringData = MediaLibraryInfoProvider.GetMediaLibraries().WhereNull("LibraryGroupID").GetCount().ToString(); break; case MetricDataEnum.support_metrics_counters_activities: stringData = ActivityInfoProvider.GetActivities().GetCount().ToString(); break; case MetricDataEnum.support_metrics_counters_contacts: stringData = ContactInfoProvider.GetContacts().GetCount().ToString(); break; case MetricDataEnum.support_metrics_counters_contactgroups: stringData = ContactGroupInfoProvider.GetContactGroups().GetCount().ToString(); break; case MetricDataEnum.support_metrics_counters_omrules: stringData = RuleInfoProvider.GetRules().GetCount().ToString(); break; case MetricDataEnum.support_metrics_counters_products: stringData = SKUInfoProvider.GetSKUs(SiteContext.CurrentSiteID).WhereNull("SKUOptionCategoryID").GetCount().ToString(); break; #endregion Counters #region Tasks case MetricDataEnum.support_metrics_tasks_webfarm: stringData = WebFarmTaskInfoProvider.GetWebFarmTasks() .WhereLessThan("TaskCreated", DateTime.Now.AddDays(-1)) .GetCount().ToString(); break; case MetricDataEnum.support_metrics_tasks_staging: stringData = StagingTaskInfoProvider.GetTasks() .WhereLessThan("TaskTime", DateTime.Now.AddDays(-1)) .GetCount().ToString(); break; case MetricDataEnum.support_metrics_tasks_integration: stringData = IntegrationTaskInfoProvider.GetIntegrationTasks() .WhereLessThan("TaskTime", DateTime.Now.AddDays(-1)) .GetCount().ToString(); break; case MetricDataEnum.support_metrics_tasks_scheduled: stringData = TaskInfoProvider.GetTasks() .WhereTrue("TaskDeleteAfterLastRun") .WhereLessThan("TaskNextRunTime", DateTime.Now.AddDays(-1)) .GetCount().ToString(); break; case MetricDataEnum.support_metrics_tasks_search: stringData = SearchTaskInfoProvider.GetSearchTasks() .WhereLessThan("SearchTaskCreated", DateTime.Now.AddDays(-1)) .GetCount().ToString(); break; case MetricDataEnum.support_metrics_tasks_email: stringData = EmailInfoProvider.GetEmailCount("EmailStatus = 1 AND EmailLastSendResult IS NOT NULL").ToString(); break; #endregion Tasks #region Event log case MetricDataEnum.support_metrics_eventlog_macroerrors: var macroErrors = EventLogProvider.GetEvents() .WhereEquals("Source", "MacroResolver") .WhereGreaterThan("EventTime", DateTime.Now.Subtract(TimeSpan.FromDays(7))) .OrderByDescending("EventTime") .TopN(10); tupleData = macroErrors.Select(e => GetKeyValuePair(String.Format("{0} from {1} at {2} in {3}", e.EventCode, e.Source, e.EventTime, e.EventMachineName), e.EventDescription.Length > CUTOFF ? e.EventDescription.Substring(0, CUTOFF) : e.EventDescription) ); break; case MetricDataEnum.support_metrics_eventlog_stagingerrors: var stagingErrors = EventLogProvider.GetEvents() .WhereEquals("Source", "staging") .WhereIn("EventType", new[] { "E", "W" }) .WhereGreaterThan("EventTime", DateTime.Now.Subtract(TimeSpan.FromDays(7))) .OrderByDescending("EventTime") .TopN(10); tupleData = stagingErrors.Select(e => GetKeyValuePair(String.Format("{0} from {1} at {2} in {3}", e.EventCode, e.Source, e.EventTime, e.EventMachineName), e.EventDescription.Length > CUTOFF ? e.EventDescription.Substring(0, CUTOFF) : e.EventDescription) ); break; case MetricDataEnum.support_metrics_eventlog_searcherrors: var searchErrors = EventLogProvider.GetEvents() .WhereEquals("Source", "search") .WhereIn("EventType", new[] { "E", "W" }) .WhereGreaterThan("EventTime", DateTime.Now.Subtract(TimeSpan.FromDays(7))) .OrderByDescending("EventTime") .TopN(10); tupleData = searchErrors.Select(e => GetKeyValuePair(String.Format("{0} from {1} at {2} in {3}", e.EventCode, e.Source, e.EventTime, e.EventMachineName), e.EventDescription.Length > CUTOFF ? e.EventDescription.Substring(0, CUTOFF) : e.EventDescription) ); break; case MetricDataEnum.support_metrics_eventlog_contenterrors: var contentErrors = EventLogProvider.GetEvents() .WhereEquals("Source", "content") .WhereIn("EventType", new[] { "E", "W" }) .WhereGreaterThan("EventTime", DateTime.Now.Subtract(TimeSpan.FromDays(7))) .OrderByDescending("EventTime") .TopN(10); tupleData = contentErrors.Select(e => GetKeyValuePair(String.Format("{0} from {1} at {2} in {3}", e.EventCode, e.Source, e.EventTime, e.EventMachineName), e.EventDescription.Length > CUTOFF ? e.EventDescription.Substring(0, CUTOFF) : e.EventDescription) ); break; case MetricDataEnum.support_metrics_eventlog_exceptions: var exceptions = EventLogProvider.GetEvents() .WhereEquals("EventCode", "exception") .WhereGreaterThan("EventTime", DateTime.Now.Subtract(TimeSpan.FromDays(7))) .OrderByDescending("EventTime") .TopN(10); tupleData = exceptions.Select(e => GetKeyValuePair(String.Format("{0} from {1} at {2} in {3}", e.EventCode, e.Source, e.EventTime, e.EventMachineName), e.EventDescription.Length > CUTOFF ? e.EventDescription.Substring(0, CUTOFF) : e.EventDescription) ); break; case MetricDataEnum.support_metrics_eventlog_upgrade: EventLogInfo upgrade = EventLogProvider.GetEvents().WhereLike("Source", "upgrade%").FirstOrDefault(); var version = upgrade?.Source.Split(' ')[2]; if (!String.IsNullOrEmpty(version)) { var parameters = new QueryDataParameters { { "@versionnumber", version } }; var events = ConnectionHelper.ExecuteQuery("SupportHelper.CustomMetric.checkupgrade", parameters); tupleData = (from DataRow row in events.Tables[0]?.Rows select row) .Select(r => new EventLogInfo(r)).Select(e => GetKeyValuePair(String.Format("{0} from {1} at {2} in {3}", e.EventCode, e.Source, e.EventTime, e.EventMachineName), e.EventDescription.Length > CUTOFF ? e.EventDescription.Substring(0, CUTOFF) : e.EventDescription) ); } break; #endregion Event log } if (tupleData?.Count() > 0) { return(tupleData); } if (stringData != null) { return(new[] { GetKeyValuePair(0, stringData) }); } return(new[] { GetKeyValuePair(0, ResHelper.GetStringFormat("support.metrics.invalid", MetricDisplayName, MetricCodeName)) }); }
/// <summary> /// Deletes selected tasks. /// </summary> protected void DeleteSelected(object parameter) { ArrayList list = parameter as ArrayList; if (list == null) { return; } CanceledString = GetString("Tasks.DeletionCanceled"); eventCode = "DELETESELECTEDTASKS"; try { AddLog(GetString("Synchronization.DeletingTasks")); list.Sort(); foreach (string synchronizationIdString in list) { int synchronizationId = ValidationHelper.GetInteger(synchronizationIdString, 0); if (synchronizationId > 0) { IntegrationSynchronizationInfo synchronization = IntegrationSynchronizationInfoProvider.GetIntegrationSynchronizationInfo(synchronizationId); if (synchronization != null) { IntegrationTaskInfo task = IntegrationTaskInfoProvider.GetIntegrationTaskInfo(synchronization.SynchronizationTaskID); if (task != null) { DeleteSynchronization(synchronizationId, task.TaskTitle); } } } } CurrentInfo = GetString("Tasks.DeleteOK"); AddLog(CurrentInfo); } catch (ThreadAbortException ex) { string state = ValidationHelper.GetString(ex.ExceptionState, string.Empty); if (state == CMSThread.ABORT_REASON_STOP) { // Canceled by user CurrentInfo = CanceledString; AddLog(CurrentInfo); } else { CurrentError = GetString("Tasks.DeletionFailed"); AddErrorLog(CurrentError); } } catch (Exception ex) { CurrentError = GetString("Tasks.DeletionFailed") + ": " + ex.Message; AddErrorLog(CurrentError); } finally { // Finalize log context FinalizeContext(); } }