/// <summary> /// Synchronizes selected documents. /// </summary> /// <param name="parameter">List of document identifiers.</param> public void SynchronizeSelected(object parameter) { List <String> list = parameter as List <String>; if (list == null) { return; } string result = string.Empty; eventCode = "SYNCSELECTEDDOCS"; CanceledString = GetString("Tasks.SynchronizationCanceled"); try { AddLog(GetString("Synchronization.RunningTasks")); // Run the synchronization result = StagingHelper.RunSynchronization(list, serverId, true, currentSiteId, AddLog); // Log possible error if (!String.IsNullOrEmpty(result)) { CurrentError = GetString("Tasks.SynchronizationFailed"); AddErrorLog(CurrentError, null); } else { CurrentInfo = GetString("Tasks.SynchronizationOK"); 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.SynchronizationFailed"); AddErrorLog(CurrentError, result); } } catch (Exception ex) { EventLogProvider.LogException("Staging", "SYNCHRONIZE", ex); CurrentError = GetString("Tasks.SynchronizationFailed") + ": " + ex.Message; AddErrorLog(CurrentError); } finally { // Finalize log context FinalizeContext(); } }
/// <summary> /// Synchronizes all tasks. Called when the "Get and synchronize tasks" button is pressed. /// Expects the CreateStagingServer method to be run first and that there are tasks logged /// for the server. /// </summary> private bool GetAndSynchronizeTasks() { // Get server ServerInfo server = ServerInfoProvider.GetServerInfo("MyNewServer", SiteContext.CurrentSiteID); if (server != null) { // Get tasks for the server DataSet tasks = StagingTaskInfoProvider.SelectTaskList(SiteContext.CurrentSiteID, server.ServerID, null, null); if (!DataHelper.DataSourceIsEmpty(tasks)) { foreach (DataRow taskDr in tasks.Tables[0].Rows) { // Create task info object from data row StagingTaskInfo task = new StagingTaskInfo(taskDr); // Synchronize the task if (!string.IsNullOrEmpty(StagingHelper.RunSynchronization(task.TaskID, server.ServerID))) { apiGetAndSynchronizeTasks.ErrorMessage = "Synchronization failed."; return(false); } } return(true); } apiGetAndSynchronizeTasks.ErrorMessage = "No tasks found."; } return(false); }
private string SynchronizeCompleteInternal() { int sid = SelectedServerID; if (sid <= 0) { sid = SynchronizationInfoProvider.ENABLED_SERVERS; } AddLog(GetString("Synchronization.LoggingTasks")); var objectTypes = GetObjectTypes(); // Create update tasks SynchronizationHelper.LogObjectChange(objectTypes, 0, DateTimeHelper.ZERO_TIME, TaskTypeEnum.UpdateObject, true, false, false, false, false, CurrentSiteID, sid); AddLog(GetString("Synchronization.RunningTasks")); // Get the tasks DataSet ds = GetStagingDataTasks(); // Run the synchronization string result = StagingHelper.RunSynchronization(ds, SelectedServerID, true, CurrentSiteID, AddLog); return(result); }
private string SynchronizeCurrentInternal() { int sid = SelectedServerID; if (sid <= 0) { sid = SynchronizationInfoProvider.ENABLED_SERVERS; } string result = null; // Process all types string[] syncTypes = objectType.Split(';'); foreach (string syncType in syncTypes) { if (syncType != string.Empty) { AddLog(GetString("Synchronization.LoggingTasks")); // Create update tasks SynchronizationHelper.LogObjectChange(syncType, synchronizedSiteId, DateTimeHelper.ZERO_TIME, TaskTypeEnum.UpdateObject, true, false, false, false, false, CurrentSiteID, sid); AddLog(GetString("Synchronization.RunningTasks")); // Get the tasks string where = GetSiteWhere(); DataSet ds = StagingTaskInfoProvider.SelectObjectTaskList(CurrentSiteID, SelectedServerID, syncType, @where, "TaskID", -1, "TaskID, TaskTitle"); // Run the synchronization result += StagingHelper.RunSynchronization(ds, SelectedServerID, true, synchronizedSiteId, AddLog); } } return(result); }
private string SynchronizeSelectedInternal(IEnumerable <string> list) { AddLog(GetString("Synchronization.RunningTasks")); // Run the synchronization string result = StagingHelper.RunSynchronization(list, SelectedServerID, true, CurrentSiteID, AddLog); return(result); }
/// <summary> /// All items synchronization. /// </summary> protected void SynchronizeAll(object parameter) { string result = string.Empty; eventCode = "SYNCALLOBJECTS"; CanceledString = GetString("Tasks.SynchronizationCanceled"); try { AddLog(GetString("Synchronization.RunningTasks")); // Get the tasks string where = GetWhere(); DataSet ds = StagingTaskInfoProvider.SelectObjectTaskList(currentSiteId, serverId, objectType, where, "TaskID", -1, "TaskID, TaskTitle"); // Run the synchronization result = StagingHelper.RunSynchronization(ds, serverId, true, currentSiteId, AddLog); // Log possible errors if (result != string.Empty) { CurrentError = GetString("Tasks.SynchronizationFailed"); AddErrorLog(CurrentError, null); } else { CurrentInfo = GetString("Tasks.SynchronizationOK"); 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.SynchronizationFailed"); AddErrorLog(CurrentError, result); } } catch (Exception ex) { CurrentError = GetString("Tasks.SynchronizationFailed") + ": " + ex.Message; AddErrorLog(CurrentError); } finally { // Finalize log context FinalizeContext(); } }
/// <summary> /// All items synchronization. /// </summary> public void SynchronizeAll(object parameter) { string result = string.Empty; eventCode = "SYNCALLDOCS"; CanceledString = GetString("Tasks.SynchronizationCanceled"); try { AddLog(GetString("Synchronization.RunningTasks")); // Process all records DataSet ds = TaskInfoProvider.SelectDocumentTaskList(currentSiteId, serverId, aliasPath, null, "TaskID", -1, "TaskID, TaskTitle"); // Run the synchronization result = StagingHelper.RunSynchronization(ds, serverId, true, currentSiteId, AddLog); // Log possible error if (!String.IsNullOrEmpty(result)) { CurrentError = GetString("Tasks.SynchronizationFailed"); AddErrorLog(CurrentError, null); } else { CurrentInfo = GetString("Tasks.SynchronizationOK"); 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.SynchronizationFailed"); AddErrorLog(CurrentError, result); } } catch (Exception ex) { CurrentError = GetString("Tasks.SynchronizationFailed") + ": " + ex.Message; AddErrorLog(CurrentError); } finally { // Finalize log context FinalizeContext(); } }
protected void gridTasks_OnAction(string actionName, object actionArgument) { // Parse action argument int taskId = ValidationHelper.GetInteger(actionArgument, 0); eventType = EventLogProvider.EVENT_TYPE_INFORMATION; if (taskId > 0) { TaskInfo task = TaskInfoProvider.GetTaskInfo(taskId); if (task != null) { switch (actionName.ToLower()) { case "delete": // Delete task eventCode = "DELETESELECTEDDATA"; AddEventLog(string.Format(ResHelper.GetAPIString("deletion.running", "Deleting '{0}' task"), HTMLHelper.HTMLEncode(task.TaskTitle))); SynchronizationInfoProvider.DeleteSynchronizationInfo(taskId, serverId, currentSiteId); break; case "synchronize": string result = null; try { // Run task synchronization eventCode = "SYNCSELECTEDDATA"; result = StagingHelper.RunSynchronization(taskId, serverId, true, currentSiteId); if (string.IsNullOrEmpty(result)) { lblInfo.Text = GetString("Tasks.SynchronizationOK"); } else { lblError.Text = GetString("Tasks.SynchronizationFailed"); eventType = EventLogProvider.EVENT_TYPE_ERROR; } } catch (Exception ex) { result = ex.Message; lblError.Text = GetString("Tasks.SynchronizationFailed"); eventType = EventLogProvider.EVENT_TYPE_ERROR; } // Log message AddEventLog(result + string.Format(ResHelper.GetAPIString("synchronization.running", "Processing '{0}' task"), HTMLHelper.HTMLEncode(task.TaskTitle))); break; } } } }
private string SynchronizeAllInternal() { AddLog(GetString("Synchronization.RunningTasks")); // Get the tasks DataSet ds = StagingTaskInfoProvider.SelectTaskList(CurrentSiteID, SelectedServerID, GridTasks.CustomFilter.WhereCondition, "TaskID", -1, "TaskID, TaskTitle"); // Run the synchronization string result = StagingHelper.RunSynchronization(ds, SelectedServerID, true, CurrentSiteID, AddLog); return(result); }
private string CreateUpdateTasksAndRunTasksInternal(string action) { string result; int sid = SelectedServerID; if (sid <= 0) { sid = SynchronizationInfoProvider.ENABLED_SERVERS; } EventCode = "SYNCHRONIZE"; AddLog(GetString("Synchronization.LoggingTasks")); // Prepare settings for current node var settings = new LogMultipleDocumentChangeSettings { EnsurePublishTask = true, NodeAliasPath = aliasPath, TaskType = TaskTypeEnum.UpdateDocument, ServerID = sid, KeepTaskData = false, RunAsynchronously = false, SiteName = CurrentSiteName }; // Create update task for current node var currentNodeUpdateTask = DocumentSynchronizationHelper.LogDocumentChange(settings); // Create update tasks for subtree or for the whole tree, depends on sync action if (action != SYNCHRONIZE_CURRENT) { settings.NodeAliasPath = action == SYNCHRONIZE_COMPLETE ? "/%" : aliasPath.TrimEnd('/') + "/%"; DocumentSynchronizationHelper.LogDocumentChange(settings); } AddLog(GetString("Synchronization.RunningTasks")); if (action == SYNCHRONIZE_CURRENT) { // Run sync for the current node only result = StagingHelper.RunSynchronization(currentNodeUpdateTask, SelectedServerID, true, CurrentSiteID, AddLog); } else { // Get all tasks for given path, depends on the sync action and run them string path = action == SYNCHRONIZE_COMPLETE ? "/" : aliasPath; DataSet ds = StagingTaskInfoProvider.SelectDocumentTaskList(CurrentSiteID, SelectedServerID, path, null, "TaskID", -1, "TaskID, TaskTitle"); result = StagingHelper.RunSynchronization(ds, SelectedServerID, true, CurrentSiteID, AddLog); } return(result); }
private string SynchronizeAllInternal() { EventCode = "SYNCALLDOCS"; AddLog(GetString("Synchronization.RunningTasks")); // Process all records DataSet ds = StagingTaskInfoProvider.SelectDocumentTaskList(CurrentSiteID, SelectedServerID, aliasPath, tasksUniGrid.CustomFilter.WhereCondition, "TaskID", -1, "TaskID, TaskTitle"); // Run the synchronization var result = StagingHelper.RunSynchronization(ds, SelectedServerID, true, CurrentSiteID, AddLog); return(result); }
private string SynchronizeAllInternal() { string where = new WhereCondition() .Where(GetAllTasksWhere()) .And() .Where(gridTasks.CustomFilter.WhereCondition) .ToString(true); AddLog(GetString("Synchronization.RunningTasks")); // Get the tasks DataSet ds = StagingTaskInfoProvider.SelectObjectTaskList(CurrentSiteID, SelectedServerID, objectType, where, "TaskID", -1, "TaskID,TaskTitle"); // Run the synchronization string result = StagingHelper.RunSynchronization(ds, SelectedServerID, true, CurrentSiteID, AddLog); return(result); }
/// <summary> /// Tests calculating a number of directed sequences. /// </summary> public static Func <string> GetTestDirectedSequences(Router router, Profiles.Profile profile, int count) { var random = new System.Random(); var list = new List <(RouterPoint[] routerpoints, float?[] preferredDirections)> { (router.Resolve(profile, StagingHelper.GetLocations("./Tests/data/sequence1.geojson")), null), // http://geojson.io/#id=gist:xivk/e4d07e82b1abfb424e4626ab0b6fc2c9&map=15/49.8486/6.0846 (router.Resolve(profile, StagingHelper.GetLocations("./Tests/data/sequence1.geojson")), new float?[] { 90f, null, null }), // http://geojson.io/#id=gist:xivk/ec116b8a58c0a2a93c7f53a86603139c&map=16/49.8501/6.0792 (router.Resolve(profile, StagingHelper.GetLocations("./Tests/data/sequence1.geojson")), new float?[] { null, -90, null }), // http://geojson.io/#id=gist:xivk/e4d07e82b1abfb424e4626ab0b6fc2c9&map=15/49.8486/6.0846 (router.Resolve(profile, StagingHelper.GetLocations("./Tests/data/sequence1.geojson")), new float?[] { 90f, null, 90 }), // the last perferred direction is impossible, but this should still work. (router.Resolve(profile, StagingHelper.GetLocations("./Tests/data/sequence2.geojson")), null), (router.Resolve(profile, StagingHelper.GetLocations("./Tests/data/sequence2.geojson")), new float?[] { null, null, null, null, null, null, null, 180, null, -90 }), (router.Resolve(profile, StagingHelper.GetLocations("./Tests/data/sequence3.geojson")), null) }; return(() => { var errors = 0; for (var i = 0; i < list.Count; i++) { var route = router.TryCalculate(profile, list[i].routerpoints, 60, list[i].preferredDirections); if (route.IsError) { #if DEBUG #endif errors++; } else { #if DEBUG var json = route.Value.ToGeoJson(); #endif } } return string.Format("{0}/{1} routes failed.", errors, list.Count); }); }
/// <summary> /// Tests calculating a number of sequences. /// </summary> public static Func <string> GetTestSequences(Router router, Profiles.Profile profile, int count) { var random = new System.Random(); var list = new List <RouterPoint[]>(); var locations = StagingHelper.GetLocations("./Tests/data/sequence1.geojson"); var routerpoints = router.Resolve(profile, locations); list.Add(routerpoints); locations = StagingHelper.GetLocations("./Tests/data/sequence2.geojson"); routerpoints = router.Resolve(profile, locations); list.Add(routerpoints); return(() => { var errors = 0; for (var i = 0; i < list.Count; i++) { var route = router.TryCalculate(profile, list[i].ToArray()); if (route.IsError) { #if DEBUG #endif errors++; } else { #if DEBUG var json = route.Value.ToGeoJson(); #endif } } return string.Format("{0}/{1} routes failed.", errors, list.Count); }); }
/// <summary> /// Runs the task synchronization for specified server. /// </summary> /// <param name="taskId">Task ID</param> /// <param name="serverId">Server ID</param> /// <param name="runOlder">Runs also older tasks</param> /// <param name="siteId">Site ID (specifies the site which should be used to get the servers when no server is specified)</param> protected override string RunSynchronization(int taskId, int serverId, bool runOlder, int siteId) { return(StagingHelper.RunSynchronization(taskId, serverId, runOlder, siteId)); }
public void SynchronizeComplete(object parameter) { string result = null; eventCode = "SYNCCOMPLETE"; CanceledString = GetString("Tasks.SynchronizationCanceled"); try { int sid = serverId; if (sid <= 0) { sid = SynchronizationInfoProvider.ENABLED_SERVERS; } AddLog(GetString("Synchronization.LoggingTasks")); // Synchronize root node IEnumerable <ISynchronizationTask> tasks = DocumentSynchronizationHelper.LogDocumentChange(CMSContext.CurrentSiteName, "/", TaskTypeEnum.UpdateDocument, null, sid, false, false); AddLog(GetString("Synchronization.RunningTasks")); // Run the synchronization StagingHelper.RunSynchronization(tasks, serverId, true, currentSiteId, AddLog); AddLog(GetString("Synchronization.LoggingTasks")); // Synchronize subnodes tasks = DocumentSynchronizationHelper.LogDocumentChange(CMSContext.CurrentSiteName, "/%", TaskTypeEnum.UpdateDocument, null, sid, false, false); AddLog(GetString("Synchronization.RunningTasks")); // Run the synchronization result = StagingHelper.RunSynchronization(tasks, serverId, true, currentSiteId, AddLog); // Log possible errors if (!string.IsNullOrEmpty(result)) { CurrentError = GetString("Tasks.SynchronizationFailed"); AddErrorLog(CurrentError, null); } else { CurrentInfo = GetString("Tasks.SynchronizationOK"); 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.SynchronizationFailed"); AddErrorLog(CurrentError, result); } } catch (Exception ex) { EventLogProvider.LogException("Staging", "SYNCHRONIZE", ex); CurrentError = GetString("Tasks.SynchronizationFailed") + ": " + ex.Message; AddErrorLog(CurrentError); } finally { // Finalize log context FinalizeContext(); } }
/// <summary> /// Internal method for synchronizing current document. /// </summary> /// <param name="parameter">Parameter</param> /// <param name="eventCodeForLog">Event code to set</param> /// <param name="finalizeEventLog">Indicates whether to finalize eventlog</param> /// <returns>Result of synchronization</returns> private string SynchronizeCurrentInternal(object parameter, string eventCodeForLog, bool finalizeEventLog) { string result = string.Empty; eventCode = eventCodeForLog; bool finish = ValidationHelper.GetBoolean(parameter, true); CanceledString = GetString("Tasks.SynchronizationCanceled"); int sid = serverId; if (sid <= 0) { sid = SynchronizationInfoProvider.ENABLED_SERVERS; } AddLog(GetString("Synchronization.LoggingTasks")); try { // Get the tasks IEnumerable <ISynchronizationTask> tasks = DocumentSynchronizationHelper.LogDocumentChange(currentSiteName, aliasPath, TaskTypeEnum.UpdateDocument, null, sid, false, false); AddLog(GetString("Synchronization.RunningTasks")); // Run the synchronization foreach (TaskInfo task in tasks.OfType <TaskInfo>()) { AddLog(string.Format(ResHelper.GetAPIString("synchronization.running", "Processing '{0}' task"), HTMLHelper.HTMLEncode(task.TaskTitle))); result += StagingHelper.RunSynchronization(task.TaskID, serverId, true, currentSiteId); } if (finish) { // Log possible error if (result != string.Empty) { CurrentError = GetString("Tasks.SynchronizationFailed"); AddErrorLog(CurrentError, null); } else { CurrentInfo = GetString("Tasks.SynchronizationOK"); 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.SynchronizationFailed"); AddErrorLog(CurrentError, result); } } catch (Exception ex) { CurrentError = GetString("Tasks.SynchronizationFailed") + ": " + ex.Message; AddErrorLog(CurrentError); } finally { if (finalizeEventLog) { // Finalize log context FinalizeContext(); } } return(result); }
/// <summary> /// Synchronizes document subtree. /// </summary> /// <param name="parameter">Leave empty</param> protected void SynchronizeSubtree(object parameter) { string result = string.Empty; eventCode = SYNCHRONIZE_SUBTREE; CanceledString = GetString("Tasks.SynchronizationCanceled"); try { // Synchronize current node first result = SynchronizeCurrentInternal(false, SYNCHRONIZE_SUBTREE, false); if (String.IsNullOrEmpty(result)) { // Synchronize subnodes int sid = serverId; if (sid <= 0) { sid = SynchronizationInfoProvider.ENABLED_SERVERS; } AddLog(GetString("Synchronization.LoggingTasks")); // Get the tasks var settings = new LogMultipleDocumentChangeSettings() { EnsurePublishTask = true, NodeAliasPath = aliasPath.TrimEnd('/') + "/%", TaskType = TaskTypeEnum.UpdateDocument, ServerID = sid, KeepTaskData = false, RunAsynchronously = false, SiteName = currentSiteName }; IEnumerable <ISynchronizationTask> tasks = DocumentSynchronizationHelper.LogDocumentChange(settings); AddLog(GetString("Synchronization.RunningTasks")); // Run the synchronization result = StagingHelper.RunSynchronization(tasks, serverId, true, currentSiteId, AddLog); } // Log possible error if (!String.IsNullOrEmpty(result)) { CurrentError = GetString("Tasks.SynchronizationFailed"); AddErrorLog(CurrentError, null); } else { CurrentInfo = GetString("Tasks.SynchronizationOK"); 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.SynchronizationFailed"); AddErrorLog(CurrentError, result); } } catch (Exception ex) { EventLogProvider.LogException("Staging", "SYNCHRONIZE", ex); CurrentError = GetString("Tasks.SynchronizationFailed") + ": " + ex.Message; AddErrorLog(CurrentError); } finally { // Finalize log context FinalizeContext(); } }
/// <summary> /// Synchronizes the current object type. /// </summary> private void SynchronizeCurrent(object parameter) { string result = null; eventCode = "SYNCCURRENTOBJECT"; CanceledString = GetString("Tasks.SynchronizationCanceled"); try { int sid = serverId; if (sid <= 0) { sid = SynchronizationInfoProvider.ENABLED_SERVERS; } // Process all types string[] syncTypes = objectType.Split(';'); foreach (string syncType in syncTypes) { if (syncType != string.Empty) { AddLog(GetString("Synchronization.LoggingTasks")); // Get the tasks List <ISynchronizationTask> tasks = SynchronizationHelper.LogObjectChange(syncType, siteId, DateTimeHelper.ZERO_TIME, TaskTypeEnum.UpdateObject, true, false, false, false, false, currentSiteId, sid); AddLog(GetString("Synchronization.RunningTasks")); // Run the synchronization result += StagingHelper.RunSynchronization(tasks, serverId, true, siteId, AddLog); } } // Log possible error if (!string.IsNullOrEmpty(result)) { CurrentError = GetString("Tasks.SynchronizationFailed"); AddErrorLog(CurrentError, null); } else { CurrentInfo = GetString("Tasks.SynchronizationOK"); 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.SynchronizationFailed"); AddErrorLog(CurrentError, result); } } catch (Exception ex) { CurrentError = GetString("Tasks.SynchronizationFailed") + ": " + ex.Message; AddErrorLog(CurrentError); } finally { // Finalize log context FinalizeContext(); } }
/// <summary> /// All items synchronization. /// </summary> protected void SynchronizeAll(object parameter) { string result = string.Empty; eventCode = "SYNCALLDATA"; CanceledString = GetString("Tasks.SynchronizationCanceled"); try { string where = "TaskSiteID IS NULL"; string classWhere = string.Empty; AddLog(GetString("Synchronization.RunningTasks")); // Ensure only data task selection if (string.IsNullOrEmpty(objectType)) { DataSet dsTables = DataClassInfoProvider.GetCustomTableClasses(currentSiteId, null, null, 0, "ClassName"); if (!DataHelper.DataSourceIsEmpty(dsTables)) { foreach (DataRow dr in dsTables.Tables[0].Rows) { classWhere += "N'" + CustomTableItemProvider.GetObjectType(dr["ClassName"].ToString()).Replace("'", "''") + "',"; } classWhere = classWhere.TrimEnd(new char[] { ',' }); } where = SqlHelperClass.AddWhereCondition(where, "TaskObjectType IN (" + classWhere + ")"); } // Get the tasks DataSet ds = TaskInfoProvider.SelectObjectTaskList(currentSiteId, serverId, objectType, where, "TaskID", -1, "TaskID,TaskTitle"); if (!DataHelper.DataSourceIsEmpty(ds)) { foreach (DataRow row in ds.Tables[0].Rows) { string taskTitle = ValidationHelper.GetString(row["TaskTitle"], string.Empty); AddLog(string.Format(ResHelper.GetAPIString("synchronization.running", "Processing '{0}' task"), HTMLHelper.HTMLEncode(taskTitle))); // Get ID int taskId = ValidationHelper.GetInteger(row["TaskID"], 0); if (taskId > 0) { result += StagingHelper.RunSynchronization(taskId, serverId, true, currentSiteId); } } } // Log possible error if (result != string.Empty) { CurrentError = GetString("Tasks.SynchronizationFailed"); AddErrorLog(CurrentError, null); } else { CurrentInfo = GetString("Tasks.SynchronizationOK"); 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.SynchronizationFailed"); AddErrorLog(CurrentError, result); } } catch (Exception ex) { CurrentError = GetString("Tasks.SynchronizationFailed") + ": " + ex.Message; AddErrorLog(CurrentError); } finally { // Finalize log context FinalizeContext(); } }
/// <summary> /// Complete synchronization. /// </summary> public void SynchronizeComplete(object parameter) { string result = null; eventCode = "SYNCCOMPLETEDATA"; CanceledString = GetString("Tasks.SynchronizationCanceled"); try { int sid = serverId; if (sid <= 0) { sid = SynchronizationInfoProvider.ENABLED_SERVERS; } AddLog(GetString("Synchronization.LoggingTasks")); // Get custom tables object types string objectTypes = string.Empty; DataSet dsTables = DataClassInfoProvider.GetCustomTableClasses(currentSiteId, null, null, 0, "ClassName"); if (!DataHelper.DataSourceIsEmpty(dsTables)) { DataTable table = dsTables.Tables[0]; foreach (DataRow dr in table.Rows) { objectTypes += CustomTableItemProvider.GetObjectType(dr["ClassName"].ToString()) + ";"; } } // Get the tasks List <ISynchronizationTask> tasks = SynchronizationHelper.LogObjectChange(objectTypes.Trim(';'), 0, DateTimeHelper.ZERO_TIME, TaskTypeEnum.UpdateObject, true, false, false, false, false, currentSiteId, sid); AddLog(GetString("Synchronization.RunningTasks")); // Run the synchronization foreach (TaskInfo task in tasks.OfType <TaskInfo>()) { AddLog(string.Format(ResHelper.GetAPIString("synchronization.running", "Processing '{0}' task"), HTMLHelper.HTMLEncode(task.TaskTitle))); result += StagingHelper.RunSynchronization(task.TaskID, serverId, true, currentSiteId); } // Log possible errors if (!string.IsNullOrEmpty(result)) { CurrentError = GetString("Tasks.SynchronizationFailed"); AddErrorLog(CurrentError, null); } else { CurrentInfo = GetString("Tasks.SynchronizationOK"); 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.SynchronizationFailed"); AddErrorLog(CurrentError, result); } } catch (Exception ex) { CurrentError = GetString("Tasks.SynchronizationFailed") + ": " + ex.Message; AddErrorLog(CurrentError); } finally { // Finalize log context FinalizeContext(); } }
/// <summary> /// Synchronizes the current object type. /// </summary> private void SynchronizeCurrent(object parameter) { string result = string.Empty; eventCode = "SYNCCURRENTDATA"; CanceledString = GetString("Tasks.SynchronizationCanceled"); try { int sid = serverId; if (sid <= 0) { sid = SynchronizationInfoProvider.ENABLED_SERVERS; } AddLog(GetString("Synchronization.LoggingTasks")); // Get the tasks List <ISynchronizationTask> tasks = SynchronizationHelper.LogObjectChange(objectType, 0, DateTimeHelper.ZERO_TIME, TaskTypeEnum.UpdateObject, true, false, false, false, false, currentSiteId, sid); AddLog(GetString("Synchronization.RunningTasks")); // Run the synchronization foreach (TaskInfo task in tasks.OfType <TaskInfo>()) { AddLog(string.Format(ResHelper.GetAPIString("synchronization.running", "Processing '{0}' task"), HTMLHelper.HTMLEncode(task.TaskTitle))); result += StagingHelper.RunSynchronization(task.TaskID, serverId, true, currentSiteId); } // Log possible error if (!string.IsNullOrEmpty(result)) { CurrentError = GetString("Tasks.SynchronizationFailed"); AddErrorLog(CurrentError, null); } else { CurrentInfo = GetString("Tasks.SynchronizationOK"); 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.SynchronizationFailed"); AddErrorLog(CurrentError, result); } } catch (Exception ex) { CurrentError = GetString("Tasks.SynchronizationFailed") + ": " + ex.Message; AddErrorLog(CurrentError); } finally { // Finalizes log context FinalizeContext(); } }
/// <summary> /// Synchronization of selected items. /// </summary> /// <param name="parameter">ArrayList of selected items</param> public void SynchronizeSelected(object parameter) { if (parameter == null) { return; } string result = string.Empty; eventCode = "SYNCSELECTEDDATA"; ArrayList list = (ArrayList)parameter; CanceledString = GetString("Tasks.SynchronizationCanceled"); try { AddLog(GetString("Synchronization.RunningTasks")); foreach (string taskIdString in list) { int taskId = ValidationHelper.GetInteger(taskIdString, 0); if (taskId > 0) { // Synchronize the task TaskInfo task = TaskInfoProvider.GetTaskInfo(taskId); if (task != null) { AddLog(string.Format(ResHelper.GetAPIString("synchronization.running", "Processing '{0}' task"), HTMLHelper.HTMLEncode(task.TaskTitle))); result += StagingHelper.RunSynchronization(taskId, serverId, true, currentSiteId); } } } // Log possible error if (result != string.Empty) { CurrentError = GetString("Tasks.SynchronizationFailed"); AddErrorLog(CurrentError, null); } else { CurrentInfo = GetString("Tasks.SynchronizationOK"); 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.SynchronizationFailed"); AddErrorLog(CurrentError, result); } } catch (Exception ex) { CurrentError = GetString("Tasks.SynchronizationFailed") + ": " + ex.Message; AddErrorLog(CurrentError); } finally { // Finalize log context FinalizeContext(); } }
/// <summary> /// Internal method for synchronizing current document. /// </summary> /// <param name="parameter">Parameter</param> /// <param name="eventCodeForLog">Event code to set</param> /// <param name="finalizeEventLog">Indicates whether to finalize eventlog</param> /// <returns>Result of synchronization</returns> private string SynchronizeCurrentInternal(object parameter, string eventCodeForLog, bool finalizeEventLog) { string result = string.Empty; eventCode = eventCodeForLog; bool finish = ValidationHelper.GetBoolean(parameter, true); CanceledString = GetString("Tasks.SynchronizationCanceled"); int sid = serverId; if (sid <= 0) { sid = SynchronizationInfoProvider.ENABLED_SERVERS; } AddLog(GetString("Synchronization.LoggingTasks")); try { // Get the tasks IEnumerable <ISynchronizationTask> tasks = DocumentSynchronizationHelper.LogDocumentChange(currentSiteName, aliasPath, TaskTypeEnum.UpdateDocument, null, sid, false, false); AddLog(GetString("Synchronization.RunningTasks")); // Run the synchronization result = StagingHelper.RunSynchronization(tasks, serverId, true, currentSiteId, AddLog); if (finish) { // Log possible error if (!String.IsNullOrEmpty(result)) { CurrentError = GetString("Tasks.SynchronizationFailed"); AddErrorLog(CurrentError, null); } else { CurrentInfo = GetString("Tasks.SynchronizationOK"); 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.SynchronizationFailed"); AddErrorLog(CurrentError, result); } } catch (Exception ex) { EventLogProvider.LogException("Staging", "SYNCHRONIZE", ex); CurrentError = GetString("Tasks.SynchronizationFailed") + ": " + ex.Message; AddErrorLog(CurrentError); } finally { if (finalizeEventLog) { // Finalize log context FinalizeContext(); } } return(result); }
/// <summary> /// All items synchronization. /// </summary> protected void SynchronizeAll(object parameter) { string result = string.Empty; eventCode = "SYNCALLOBJECTS"; CanceledString = GetString("Tasks.SynchronizationCanceled"); try { AddLog(GetString("Synchronization.RunningTasks")); // Get the tasks string where = GetWhere(); DataSet ds = TaskInfoProvider.SelectObjectTaskList(currentSiteId, serverId, objectType, where, "TaskID", -1, "TaskID, TaskTitle"); if (!DataHelper.DataSourceIsEmpty(ds)) { foreach (DataRow row in ds.Tables[0].Rows) { string taskTitle = ValidationHelper.GetString(row["TaskTitle"], string.Empty); AddLog(string.Format(ResHelper.GetAPIString("synchronization.running", "Processing '{0}' task"), HTMLHelper.HTMLEncode(taskTitle))); // Get ID int taskId = ValidationHelper.GetInteger(row["TaskID"], 0); if (taskId > 0) { result += StagingHelper.RunSynchronization(taskId, serverId, true, currentSiteId); } } } // Log possible errors if (result != string.Empty) { CurrentError = GetString("Tasks.SynchronizationFailed"); AddErrorLog(CurrentError, null); } else { CurrentInfo = GetString("Tasks.SynchronizationOK"); 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.SynchronizationFailed"); AddErrorLog(CurrentError, result); } } catch (Exception ex) { CurrentError = GetString("Tasks.SynchronizationFailed") + ": " + ex.Message; AddErrorLog(CurrentError); } finally { // Finalize log context FinalizeContext(); } }
/// <summary> /// All items synchronization. /// </summary> protected void SynchronizeAll(object parameter) { string result = string.Empty; eventCode = "SYNCALLDATA"; CanceledString = GetString("Tasks.SynchronizationCanceled"); try { string where = "TaskSiteID IS NULL"; string classWhere = string.Empty; AddLog(GetString("Synchronization.RunningTasks")); // Ensure only data task selection if (string.IsNullOrEmpty(objectType)) { DataSet dsTables = CustomTableHelper.GetCustomTableClasses(currentSiteId).Column("ClassName"); if (!DataHelper.DataSourceIsEmpty(dsTables)) { foreach (DataRow dr in dsTables.Tables[0].Rows) { classWhere += "N'" + SqlHelper.EscapeQuotes(CustomTableItemProvider.GetObjectType(dr["ClassName"].ToString())) + "',"; } classWhere = classWhere.TrimEnd(new [] { ',' }); } where = SqlHelper.AddWhereCondition(where, "TaskObjectType IN (" + classWhere + ")"); } // Get the tasks DataSet ds = StagingTaskInfoProvider.SelectObjectTaskList(currentSiteId, serverId, objectType, where, "TaskID", -1, "TaskID,TaskTitle"); // Run the synchronization result = StagingHelper.RunSynchronization(ds, serverId, true, currentSiteId, AddLog); // Log possible error if (result != string.Empty) { CurrentError = GetString("Tasks.SynchronizationFailed"); AddErrorLog(CurrentError, null); } else { CurrentInfo = GetString("Tasks.SynchronizationOK"); 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.SynchronizationFailed"); AddErrorLog(CurrentError, result); } } catch (Exception ex) { CurrentError = GetString("Tasks.SynchronizationFailed") + ": " + ex.Message; AddErrorLog(CurrentError); } finally { // Finalize log context FinalizeContext(); } }