public void ServiceContentHandler(CancellationToken token) { while (!token.IsCancellationRequested) { try { RecentMTContents = DBT.GetFewUnProcessedMT(); } catch (Exception ex) { log.Error(ex.Message + " " + (ex.InnerException != null?ex.InnerException.ToString():"") + " " + " Failing to Fetch Data, Some Issue at the Database Interaction"); //MessageBox.Show(ex.Message + "\n" + " Failed to Fetch Data, Some Issue at the Database Interaction"); AlertTran.AlertSMS("IDEX- Issue in DB Fetch operation"); } string IDEXStatus; //IDEXStatus = IXUtil.ServiceContentPush(LinkID: "1212", ChannelID: "1205", Message: "TEST"); foreach (integral_smscontentpush_mt_messages MT in RecentMTContents) { IDEXStatus = IXUtil.ServiceContentPush(LinkID: MT.id.ToString(), ChannelID: MT.category_ids, Message: MT.message); MT.flag = IDEXStatus; MT.process_date = DateTime.Now; try { DBT.UpdateMTStatus(MT); } catch (Exception ex) //New transaction is not allowed because there are other threads running in the session.- Cant be saved from inside foreach, need to do a ToList() on it to disconnect it from the database before running your loop { log.Error(ex.Message + " " + (ex.InnerException != null ? ex.InnerException.ToString() : "") + " while processing Record with ID= " + MT.id); //MessageBox.Show(ex.Message + "\n" + " at Record = " + MT.id ); AlertTran.AlertSMS("IDEX- Issue in DB Update operation"); } } } }
private void PendingCheckAlertTimer_Tick(object sender, EventArgs e) { AlertTran.AlertSMS(DBT.GetAllUnProcessedMT().Count().ToString() + " Service Contents Remaining"); }