private void DisposeAllScheduledPublicationsPostingTasks() { try { lock (this._PublicationScheduleREgistersTable) { IEnumerator enumm = default(IEnumerator); enumm = this._PublicationScheduleREgistersTable.GetEnumerator(); PublicationScheduledTaskRegister reg = default(PublicationScheduledTaskRegister); while (enumm.MoveNext()) { reg = (PublicationScheduledTaskRegister)((DictionaryEntry)enumm.Current).Value; reg.keepScheduleTaskWorking = false; try { reg.scheduledPostTaskThread.Abort(); } catch (Exception) { } } this._PublicationScheduleREgistersTable.Clear(); } } catch (Exception) { } }
internal void AbortScheduledPublicationPostTask(string publicationName) { if (this.ContainsScheduledPublicationPost(publicationName)) { lock (this._ContainerOfScheduledPublicationsPostingOnServer) { this._ContainerOfScheduledPublicationsPostingOnServer.RemovePublicationDefinition(publicationName); lock (this._PublicationScheduleREgistersTable) { PublicationScheduledTaskRegister reg = default(PublicationScheduledTaskRegister); reg = (PublicationScheduledTaskRegister)this._PublicationScheduleREgistersTable[publicationName]; if (!(reg == null)) { reg.keepScheduleTaskWorking = false; try { reg.scheduledPostTaskThread.Abort(); } catch (Exception) { } } try { this._PublicationScheduleREgistersTable.Remove(publicationName); } catch (Exception) { } } } } }
internal void ScheduleTaskToPostAPublicationOnServer(DPE_ClientPublicationDefinition publicationDefinition) { if (!this.ContainsScheduledPublicationPost(publicationDefinition.PublicationName)) { lock (this._ContainerOfScheduledPublicationsPostingOnServer) { if (!this._ContainerOfScheduledPublicationsPostingOnServer.ContainsPublicationDefinition(publicationDefinition)) { this._ContainerOfScheduledPublicationsPostingOnServer.AddPublicationDefinition(publicationDefinition); System.Threading.Thread scheduleTask = new System.Threading.Thread(new System.Threading.ThreadStart(ScheduleTaskToPostAPublicationOnServer_ThreadFcn)); scheduleTask.IsBackground = true; scheduleTask.Priority = System.Threading.ThreadPriority.Normal; PublicationScheduledTaskRegister reg = new PublicationScheduledTaskRegister(publicationDefinition, scheduleTask); lock (this._PublicationScheduleREgistersTable) { try { this._PublicationScheduleREgistersTable.Remove(publicationDefinition.PublicationName); } catch (Exception) { } this._PublicationScheduleREgistersTable.Add(publicationDefinition.PublicationName, reg); } lock (this._publicationsScheduledPostingQueue) { this._publicationsScheduledPostingQueue.Enqueue(reg); } scheduleTask.Start(); string msg = ""; msg = "Task to post the publication \'" + publicationDefinition.PublicationName + " was scheduled and started\'"; CustomEventLog.WriteEntry(EventLogEntryType.Information, msg); } } } }
private void ScheduleTaskToPostAPublicationOnServer_ThreadFcn() { try { PublicationScheduledTaskRegister regFromQueue = null; regFromQueue = null; lock (this._publicationsScheduledPostingQueue) { if (this._publicationsScheduledPostingQueue.Count > 0) { try { regFromQueue = (PublicationScheduledTaskRegister)this._publicationsScheduledPostingQueue.Dequeue(); } catch (Exception) { regFromQueue = null; } } } if (!(regFromQueue == null)) { PublicationScheduledTaskRegister regFromTable = default(PublicationScheduledTaskRegister); lock (this._PublicationScheduleREgistersTable) { regFromTable = (PublicationScheduledTaskRegister)this._PublicationScheduleREgistersTable[regFromQueue.PublicationDefinition.PublicationName]; } while (regFromQueue.keepScheduleTaskWorking) { if (this._STXDataSocketClient.IsConnected) { try { this._STXDataSocketClient.PublicationsPostManager.PostPublicationOnServer(regFromTable.PublicationDefinition); this._PublicationScheduleREgistersTable.Remove(regFromTable.PublicationDefinition); this._ContainerOfScheduledPublicationsPostingOnServer.RemovePublicationDefinition(regFromTable.PublicationDefinition); this.RemovePublicationScheduledTask(regFromTable.PublicationDefinition.PublicationName); string msg = ""; msg = "Publication \'" + regFromTable.PublicationDefinition.PublicationName + "\' was restored on the Server."; CustomEventLog.WriteEntry(EventLogEntryType.SuccessAudit, msg); regFromTable.keepScheduleTaskWorking = false; regFromQueue = null; regFromTable = null; break; } catch (Exception) { regFromTable.IncreaseTrialcounter(); } } System.Threading.Thread.Sleep(2000); } } } catch (Exception ex) { CustomEventLog.WriteEntry(ex); } }