public IssueDS GetIssues(string agentNumber) { //Get issue search data IssueMgtServiceClient client = null; IssueDS issues = null; try { client = new IssueMgtServiceClient(); if (agentNumber == null) { issues = client.GetIssues(); } else { issues = new IssueDS(); IssueDS _issues = client.GetIssues(); issues.Merge(_issues.IssueTable.Select("AgentNumber='" + agentNumber + "'")); issues.Merge(_issues.IssueTable.Select("AgentNumber=''")); } client.Close(); } catch (FaultException fe) { throw new ApplicationException("GetIssues() service error.", fe); } catch (TimeoutException te) { client.Abort(); throw new ApplicationException("GetIssues() timeout error.", te); } catch (CommunicationException ce) { client.Abort(); throw new ApplicationException("GetIssues() communication error.", ce); } return(issues); }
private void postIssueUpdates() { //Check for new issue actions and fire an event for each one found DateTime lastUpdated = this.mLastIssueUpdateTime; IssueDS issues = new IssueDS(); issues.Merge(this.mIssues); for (int i = 0; i < issues.IssueTable.Rows.Count; i++) { //Find issues with LastAction that has not been posted yet //Skip 'New' actions and actions from creator IssueDS.IssueTableRow issue = issues.IssueTable[i]; if (issue.LastActionCreated.CompareTo(lastUpdated) > 0 && issue.LastActionDescription != "New" && issue.LastActionUserID != Environment.UserName) { //Post a NewIssue event with an issue instance that includes the last action IssueDS actions = new IssueDS(); actions.ActionTable.AddActionTableRow(issue.LastActionID, (byte)0, issue.ID, issue.LastActionUserID, issue.LastActionCreated, issue.LastActionDescription); Issue _issue = new Issue(issue, actions, null); if (this.NewIssue != null) { this.NewIssue(this, new NewIssueEventArgs(_issue)); } //Update mLastIssueUpdateTime time to keep notification to once for an updated issue if (issue.LastActionCreated.CompareTo(this.mLastIssueUpdateTime) > 0) { this.mLastIssueUpdateTime = issue.LastActionCreated; } } } }
public static void RefreshCache() { //Refresh cached data DataSet ds = null; try { //Validate if (_Mediator == null) { return; } if (!_Mediator.OnLine) { return; } //Issue types _IssueTypes.Clear(); ds = _Mediator.FillDataset(USP_ISSUETYPES, TBL_ISSUETYPES, null); if (ds.Tables[TBL_ISSUETYPES].Rows.Count > 0) { _IssueTypes.Merge(ds); } //Action types _ActionTypes.Clear(); ds = _Mediator.FillDataset(USP_ACTIONTYPES, TBL_ACTIONTYPES, null); if (ds.Tables[TBL_ACTIONTYPES].Rows.Count > 0) { _ActionTypes.Merge(ds); } } catch (ApplicationException ex) { throw ex; } catch (Exception ex) { throw new ApplicationException("Unexpected error while caching CRGFactory data.", ex); } }
public Issue GetIssue(long issueID) { //Get an existing issue Issue issue = null; try { //New or existing? if (issueID == 0) { //Build a new issue object issue = new Issue(); } else { //Build an issue object (including actions and attachments) IssueDS issues = new IssueDS(); DataSet ds = fillDataset(USP_ISSUE_GET, TBL_ISSUE, new object[] { issueID }); if (ds.Tables[TBL_ISSUE].Rows.Count == 0) { throw new ApplicationException("Issue not found."); } else { issues.Merge(ds); } issue = new Issue(issues.IssueTable[0]); } } catch (Exception ex) { throw new ApplicationException("Unexpected error while reading issue.", ex); } return(issue); }
public DataSet ToDraft() { //Return a dataset containing values for this object IssueDS ds = null; try { ds = new IssueDS(); IssueDS.IssueTableRow issue = ds.IssueTable.NewIssueTableRow(); issue.ID = this._id; issue.TypeID = this._typeid; issue.Type = this.Type; issue.Subject = this._subject; issue.ContactID = this._contactid; issue.ContactName = this.Contact; issue.CompanyID = this._companyid; issue.CompanyName = this.Company; issue.RegionNumber = this._regionnumber; issue.DistrictNumber = this._districtnumber; issue.AgentNumber = this._agentnumber; issue.StoreNumber = this._storenumber; issue.OFD1FromDate = this._ofd1datefrom; issue.OFD1ToDate = this._ofd1dateto; issue.PROID = this._proid; issue.Zone = this._zone; issue.FirstActionID = issue.LastActionID = 0; issue.FirstActionDescription = issue.LastActionDescription = this.LastAction; issue.FirstActionCreated = issue.LastActionCreated = this.LastCreated; issue.FirstActionUserID = issue.LastActionUserID = this.LastUser; ds.IssueTable.AddIssueTableRow(issue); ds.Merge(this.mActions); } catch (Exception) { } return(ds); }
public Attachments GetAttachments(long issueID, long actionID) { //Get attachments for the specified action Attachments attachments = null; try { //Filter attachments attachments = new Attachments(); if (issueID != 0) { DataSet ds = fillDataset(USP_ATTACHMENTS, TBL_ATTACHMENTS, new object[] { issueID }); if (ds.Tables[TBL_ATTACHMENTS].Rows.Count != 0) { IssueDS attachmentsDS = new IssueDS(); attachmentsDS.Merge(ds); for (int i = 0; i < attachmentsDS.AttachmentTable.Rows.Count; i++) { Attachment attachment = new Attachment(attachmentsDS.AttachmentTable[i]); if (attachment.ActionID == actionID) { attachments.Add(attachment); } } } } } catch (ApplicationException ex) { throw ex; } catch (Exception ex) { throw new ApplicationException("Unexpected error while reading issue attachments.", ex); } return(attachments); }
public static DataSet GetIssues() { //Get issues IssueDS issues = new IssueDS(); try { if (_IssueCache == null) { _IssueCacheLastUpdate = DateTime.Today.AddDays(-IssueDaysBack); } DateTime fromDate = _IssueCacheLastUpdate; _Client = new IssueMgtServiceClient(); DataSet ds = _Client.GetIssuesForDate(fromDate); _Client.Close(); System.Diagnostics.Debug.WriteLine("PAYLOAD: fromDate=" + fromDate.ToString("MM/dd/yyyy HH:mm:ss") + "; bytes=" + ds.GetXml().Length); updateIssueCache(ds); if (_IssueCache != null) { issues.Merge(_IssueCache); } } catch (FaultException fe) { throw new ApplicationException("GetIssueCategorys() service error.", fe); } catch (TimeoutException te) { _Client.Abort(); throw new ApplicationException("GetIssueCategorys() timeout error.", te); } catch (CommunicationException ce) { _Client.Abort(); throw new ApplicationException("GetIssueCategorys() communication error.", ce); } return(issues); }
public Actions GetIssueActions(long issueID) { //Get all actions for the specified issue Actions actions = null; try { //New or existing? actions = new Actions(); if (issueID > 0) { DataSet ds = fillDataset(USP_ACTIONS, TBL_ACTIONS, new object[] { issueID }); if (ds.Tables[TBL_ACTIONS].Rows.Count == 0) { throw new ApplicationException("No actions found for this issue."); } else { DataSet _ds = new DataSet(); _ds.Merge(ds.Tables[TBL_ACTIONS].Select("", "Created DESC")); IssueDS actionsDS = new IssueDS(); actionsDS.Merge(_ds); for (int i = 0; i < actionsDS.ActionTable.Rows.Count; i++) { Action action = new Action(actionsDS.ActionTable[i]); actions.Add(action); } } } } catch (ApplicationException ex) { throw ex; } catch (Exception ex) { throw new ApplicationException("Unexpected error while reading issue actions.", ex); } return(actions); }
public virtual DataSet ToDataSet() { //Return a dataset containing values for this object IssueDS ds = null; try { ds = new IssueDS(); IssueDS.IssueTableRow issue = ds.IssueTable.NewIssueTableRow(); issue.ID = this._id; issue.TypeID = this._typeid; issue.Subject = this._subject; issue.ContactID = this._contactid; issue.CompanyID = this._companyid; issue.RegionNumber = this._regionnumber; issue.DistrictNumber = this._districtnumber; issue.AgentNumber = this._agentnumber; issue.StoreNumber = this._storenumber; issue.OFD1FromDate = this._ofd1datefrom; issue.OFD1ToDate = this._ofd1dateto; issue.PROID = this._proid; issue.Zone = this._zone; ds.IssueTable.AddIssueTableRow(issue); ds.Merge(this.mActions); } catch (Exception) { } return(ds); }
private void loadActions() { //Event handler for change in actions collection //Load actions for this issue this.lsvActions.Groups.Clear(); this.lsvActions.Items.Clear(); if (this.mIssue != null) { //Create action listitems sorted by date/time IssueDS actions = new IssueDS(); actions.Merge(this.mIssue.Actions.ActionTable.Select("", "Created DESC")); for (int i = 0; i < actions.ActionTable.Rows.Count; i++) { //Add attachment symbol as required //Tag is used to enable attachement to newest action only Issue.Action action = this.mIssue.Item(actions.ActionTable[i].ID); ListViewItem item = this.lsvActions.Items.Add(action.ID.ToString(), action.UserID, (action.Attachments.AttachmentTable.Rows.Count > 0 ? 0 : -1)); item.Tag = i.ToString(); //Assign to listitem group DateTime created = actions.ActionTable[i].Created; bool useYesterday = DateTime.Today.DayOfWeek != DayOfWeek.Monday; if (created.CompareTo(DateTime.Today) >= 0) { this.lsvActions.Groups.Add("Today", "Today"); item.SubItems.Add(created.ToString("ddd HH:mm")); item.Group = this.lsvActions.Groups["Today"]; } else if (useYesterday && created.CompareTo(DateTime.Today.AddDays(-1)) >= 0) { this.lsvActions.Groups.Add("Yesterday", "Yesterday"); item.SubItems.Add(created.ToString("ddd HH:mm")); item.Group = this.lsvActions.Groups["Yesterday"]; } else if (created.CompareTo(DateTime.Today.AddDays(0 - DateTime.Today.DayOfWeek)) >= 0) { this.lsvActions.Groups.Add("This Week", "This Week"); item.SubItems.Add(created.ToString("ddd HH:mm")); item.Group = this.lsvActions.Groups["This Week"]; } else if (created.CompareTo(DateTime.Today.AddDays(0 - DateTime.Today.DayOfWeek - 7)) >= 0) { this.lsvActions.Groups.Add("Last Week", "Last Week"); item.SubItems.Add(created.ToString("ddd MM/dd HH:mm")); item.Group = this.lsvActions.Groups["Last Week"]; } else { this.lsvActions.Groups.Add("Other", "Other"); item.SubItems.Add(created.ToString("ddd MM/dd/yyyy HH:mm")); item.Group = this.lsvActions.Groups["Other"]; } } } if (this.lsvActions.Items.Count > 0) { this.lsvActions.Items[0].Selected = true; } OnActionSelected(null, EventArgs.Empty); }
public IssueDS GetIssues(string agentNumber) { //Get issues IssueDS issues = new IssueDS(); IssueDS _issues = new Argix.Customers.CustomerService().GetIssues(); issues.Merge(_issues.IssueTable.Select("AgentNumber='" + agentNumber + "'")); return(issues); }
public IssueDS SearchIssuesAdvanced(string agentNumber, object[] criteria) { //Get issue search data IssueDS issues = new IssueDS(); IssueDS _issues = new Argix.Customers.CustomerService().SearchIssuesAdvanced(criteria); issues.Merge(_issues.IssueTable.Select("AgentNumber='" + agentNumber + "'")); return(issues); }
public IssueDS SearchIssues(string agentNumber, string searchText) { //Get issue search data IssueDS issues = new IssueDS(); IssueDS _issues = new Argix.Customers.CustomerService().SearchIssues(searchText); issues.Merge(_issues.IssueTable.Select("AgentNumber='" + agentNumber + "'")); return(issues); }
public static bool UpdateIssue(Issue issue) { //Update an existing issue bool b = false; try { //Update the updateable issue attributes _Mediator.ExecuteNonQuery(USP_ISSUE_UPDATE, new object[] { issue.ID, issue.ContactID, issue.OFD1FromDate, issue.OFD1ToDate, issue.PROID }); //Add any new actions and associated attachments DataSet ds = issue.Actions.GetChanges(DataRowState.Added); if (ds != null) { //NOTE: Should never be more than 1 new action (constrained by the issue.Add() // method which saves actions immediately) IssueDS actions = new IssueDS(); actions.Merge(ds); for (int i = 0; i < actions.ActionTable.Rows.Count; i++) { IssueDS.ActionTableRow a = actions.ActionTable[i]; object ao = _Mediator.ExecuteNonQueryWithReturn(USP_ACTION_NEW, new object[] { null, a.TypeID, issue.ID, a.UserID, a.Comment }); long aid = (long)ao; //Add associated attachments //NOTE: Attachments are held in the issue, but saved (associated) to the action try { DataSet _ds = issue.Attachments.GetChanges(DataRowState.Added); if (_ds != null) { IssueDS attachments = new IssueDS(); attachments.Merge(_ds); for (int j = 0; j < attachments.AttachmentTable.Rows.Count; j++) { IssueDS.AttachmentTableRow at = attachments.AttachmentTable[j]; SaveFileAttachment(aid, at.FileName, at.File); } } } catch (Exception ex) { throw new ApplicationException("Unexpected error while saving file attachment to new action.", ex); } } } b = true; } catch (Exception ex) { throw new ApplicationException("Unexpected error while updating issue.", ex); } finally { if (IssuesChanged != null) { IssuesChanged(null, EventArgs.Empty); } } return(b); }
public static Issue GetIssue(long issueID) { //Get an existing issue Issue issue = null; try { //New or existing? if (issueID == 0) { //Build a new issue object issue = new Issue(); } else { //Build an issue object (including actions and attachments) IssueDS issues = new IssueDS(); DataSet ds = _Mediator.FillDataset(USP_ISSUE_GET, TBL_ISSUE, new object[] { issueID }); if (ds.Tables[TBL_ISSUE].Rows.Count == 0) { throw new ApplicationException("Issue not found."); } else { issues.Merge(ds); } //Actions; skip the attachments (get on demand) IssueDS actions = new IssueDS(); ds = _Mediator.FillDataset(USP_ACTIONS, TBL_ACTIONS, new object[] { issueID }); if (ds.Tables[TBL_ACTIONS].Rows.Count == 0) { throw new ApplicationException("No actions found for this issue."); } else { actions.Merge(ds); } //Attachments IssueDS attachments = new IssueDS(); ds = _Mediator.FillDataset(USP_ATTACHMENTS, TBL_ATTACHMENTS, new object[] { issueID }); if (ds.Tables[TBL_ATTACHMENTS].Rows.Count > 0) { attachments.Merge(ds); } issue = new Issue(issues.IssueTable[0], actions, attachments); } } catch (Exception ex) { throw new ApplicationException("Unexpected error while reading issues.", ex); } return(issue); }
public IssueDS SearchIssues(string searchText) { //Get issue search data IssueDS search = new IssueDS(); try { //Validate data access DataSet ds = fillDataset(USP_ISSUES_SEARCH, TBL_ISSUES, new object[] { searchText }); if (ds.Tables[TBL_ISSUES].Rows.Count > 0) { search.Merge(ds); } } catch (Exception ex) { throw new ApplicationException("Unexpected error while searching issues.", ex); } return(search); }
public IssueDS SearchIssuesAdvanced(object[] criteria) { //Get issue search data IssueDS search = new IssueDS(); try { //Validate data access DataSet ds = fillDataset(USP_ISSUES_SEARCHADVANCED, TBL_ISSUES, criteria); if (ds.Tables[TBL_ISSUES].Rows.Count > 0) { search.Merge(ds); } } catch (Exception ex) { throw new ApplicationException("Unexpected error while searching issues.", ex); } return(search); }
private void OnActionSelected(object sender, EventArgs e) { //Event handler for change in selected action try { this.txtAction.Text = ""; this.lsvAttachments.Items.Clear(); if (this.lsvActions.SelectedItems.Count > 0) { //Show the selected action long actionID = Convert.ToInt64(this.lsvActions.SelectedItems[0].Name); Issue.Action action = this.mIssue.Item(actionID); if (action != null) { IssueDS actions = new IssueDS(); actions.Merge(this.mIssue.Actions.ActionTable.Select("Created <= '" + action.Created.AddSeconds(1) + "'", "Created DESC")); int start = 0; for (int i = 0; i < actions.ActionTable.Rows.Count; i++) { string header = actions.ActionTable[i].Created.ToString("f") + " " + actions.ActionTable[i].UserID + ", " + Issue.Action.GetActionTypeName(actions.ActionTable[i].TypeID); this.txtAction.AppendText(header); this.txtAction.Select(start, header.Length); this.txtAction.SelectionFont = new Font(this.txtAction.Font, FontStyle.Bold); this.txtAction.AppendText("\r\n\r\n"); this.txtAction.AppendText(actions.ActionTable[i].Comment); this.txtAction.AppendText("\r\n"); this.txtAction.AppendText("".PadRight(75, '-')); this.txtAction.AppendText("\r\n"); start = this.txtAction.Text.Length; } //Show the attachments IssueDS attachments = action.Attachments; this.lsvAttachments.Items.Clear(); for (int i = 0; i < attachments.AttachmentTable.Rows.Count; i++) { string key = attachments.AttachmentTable[i].ID.ToString(); string text = attachments.AttachmentTable[i].FileName.Trim(); this.lsvAttachments.Items.Add(text); } this.lsvAttachments.View = View.List; } } } catch (Exception ex) { reportError(new ControlException("Unexpected error on change of selected issue action in the IssueInspector control.", ex)); } finally { setUserServices(); }; }
public static DataSet GetIssues(DateTime fromDate) { // IssueDS issues = new IssueDS(); if (_Mediator.OnLine) { //Get issues DateTime toDate = DateTime.Today.AddDays(1).AddSeconds(-1); DataSet ds = _Mediator.FillDataset(USP_ISSUES, TBL_ISSUES, new object[] { fromDate, toDate }); if (ds.Tables[TBL_ISSUES].Rows.Count > 0) { issues.Merge(ds); } } return(issues); }
public IssueDS GetIssues(DateTime fromDate) { //Get issues IssueDS issues = new IssueDS(); try { DateTime toDate = DateTime.Today.AddDays(1).AddSeconds(-1); DataSet ds = fillDataset(USP_ISSUES, TBL_ISSUES, new object[] { fromDate, toDate }); if (ds.Tables[TBL_ISSUES].Rows.Count > 0) { DataSet _ds = new DataSet(); _ds.Merge(ds.Tables[TBL_ISSUES].Select("", "LastActionCreated DESC")); issues.Merge(_ds); } } catch (Exception ex) { throw new ApplicationException("Unexpected error while reading issues.", ex); } return(issues); }
public string GetAllActionComments() { //Get a running comment for this action string comments = ""; IssueDS actions = new IssueDS(); actions.Merge(this.mActions.ActionTable.Select("", "Created DESC")); for (int i = 0; i < actions.ActionTable.Rows.Count; i++) { if (i > 0) { comments += "\r\n\r\n"; comments += "".PadRight(75, '-'); comments += "\r\n"; } comments += actions.ActionTable[i].Created.ToString("f") + ", " + actions.ActionTable[i].UserID + ", " + Action.GetActionTypeName(actions.ActionTable[i].TypeID); comments += "\r\n\r\n"; comments += actions.ActionTable[i].Comment; } return(comments); }
public Actions GetActions(long issueID, long actionID) { //Get all actions chronologically prior to and including the specified action for the specified issue Actions actions = null; try { actions = new Actions(); if (issueID > 0) { DataSet ds = fillDataset(USP_ACTIONS, TBL_ACTIONS, new object[] { issueID }); if (ds.Tables[TBL_ACTIONS].Rows.Count == 0) { throw new ApplicationException("No actions found for this issue."); } else { DataSet _ds = new DataSet(); _ds.Merge(ds.Tables[TBL_ACTIONS].Select("", "Created DESC")); IssueDS actionsDS = new IssueDS(); actionsDS.Merge(_ds); //Select all actions chronologically prior to and including specified action //Note: Return all actions if specified action is not found IssueDS.ActionTableRow[] rows = (IssueDS.ActionTableRow[])actionsDS.ActionTable.Select("ID=" + actionID.ToString()); Action _action = rows.Length > 0 ? new Action(rows[0]) : null; for (int i = 0; i < actionsDS.ActionTable.Rows.Count; i++) { Action action = new Action(actionsDS.ActionTable[i]); if (_action == null || DateTime.Compare(action.Created, _action.Created) <= 0) { actions.Add(action); } } } } } catch (ApplicationException ex) { throw ex; } catch (Exception ex) { throw new ApplicationException("Unexpected error while reading issue actions.", ex); } return(actions); }
public static IssueDS IssueHistory(Issue issue) { //Get issue history data IssueDS history = new IssueDS(); try { //Validate data access if (_Mediator.OnLine) { object store = null; if (issue.StoreNumber > 0) { store = issue.StoreNumber; } DataSet ds = _Mediator.FillDataset(USP_ISSUES_HISTORY, TBL_ISSUES, new object[] { issue.CompanyID, issue.RegionNumber, issue.DistrictNumber, issue.AgentNumber, store }); if (ds.Tables[TBL_ISSUES].Rows.Count > 0) { history.Merge(ds); } } } catch (Exception ex) { throw new ApplicationException("Unexpected error while reading issue history.", ex); } return(history); }
private static void updateIssueCache(DataSet ds) { //Get last issue time if (ds.Tables["IssueTable"].Rows.Count > 0) { DateTime lastUpdated = _IssueCacheLastUpdate; if (_IssueCache == null) { _IssueCache = new IssueDS(); } IssueDS issues = new IssueDS(); issues.Merge(ds); for (int i = 0; i < issues.IssueTable.Rows.Count; i++) { IssueDS.IssueTableRow issue = issues.IssueTable[i]; IssueDS.IssueTableRow[] _issues = (IssueDS.IssueTableRow[])_IssueCache.IssueTable.Select("ID=" + issue.ID); if (_issues.Length == 0) { IssueDS.IssueTableRow _issue = _IssueCache.IssueTable.NewIssueTableRow(); #region New to cache _issue.ID = issue.ID; if (!issue.IsAgentNumberNull()) { _issue.AgentNumber = issue.AgentNumber; } if (!issue.IsCompanyIDNull()) { _issue.CompanyID = issue.CompanyID; } if (!issue.IsCompanyNameNull()) { _issue.CompanyName = issue.CompanyName; } if (!issue.IsContactIDNull()) { _issue.ContactID = issue.ContactID; } if (!issue.IsContactNameNull()) { _issue.ContactName = issue.ContactName; } if (!issue.IsCoordinatorNull()) { _issue.Coordinator = issue.Coordinator; } if (!issue.IsDistrictNumberNull()) { _issue.DistrictNumber = issue.DistrictNumber; } if (!issue.IsFirstActionCreatedNull()) { _issue.FirstActionCreated = issue.FirstActionCreated; } if (!issue.IsFirstActionDescriptionNull()) { _issue.FirstActionDescription = issue.FirstActionDescription; } if (!issue.IsFirstActionIDNull()) { _issue.FirstActionID = issue.FirstActionID; } if (!issue.IsFirstActionUserIDNull()) { _issue.FirstActionUserID = issue.FirstActionUserID; } if (!issue.IsLastActionCreatedNull()) { _issue.LastActionCreated = issue.LastActionCreated; } if (!issue.IsLastActionDescriptionNull()) { _issue.LastActionDescription = issue.LastActionDescription; } if (!issue.IsLastActionIDNull()) { _issue.LastActionID = issue.LastActionID; } if (!issue.IsLastActionUserIDNull()) { _issue.LastActionUserID = issue.LastActionUserID; } if (!issue.IsOFD1FromDateNull()) { _issue.OFD1FromDate = issue.OFD1FromDate; } if (!issue.IsOFD1ToDateNull()) { _issue.OFD1ToDate = issue.OFD1ToDate; } if (!issue.IsPROIDNull()) { _issue.PROID = issue.PROID; } if (!issue.IsStoreNumberNull()) { _issue.StoreNumber = issue.StoreNumber; } if (!issue.IsSubjectNull()) { _issue.Subject = issue.Subject; } if (!issue.IsTypeNull()) { _issue.Type = issue.Type; } if (!issue.IsTypeIDNull()) { _issue.TypeID = issue.TypeID; } if (!issue.IsZoneNull()) { _issue.Zone = issue.Zone; } #endregion _IssueCache.IssueTable.AddIssueTableRow(_issue); Debug.WriteLine("CACHE: New issue#" + _issue.ID.ToString() + "; lastActionCreated=" + _issue.LastActionCreated.ToString("MM/dd/yyyy HH:mm:ss")); } else { //Existing in cache if (issue.LastActionCreated.CompareTo(_issues[0].LastActionCreated) > 0) { #region Update existing if (!issue.IsAgentNumberNull()) { _issues[0].AgentNumber = issue.AgentNumber; } if (!issue.IsCompanyIDNull()) { _issues[0].CompanyID = issue.CompanyID; } if (!issue.IsCompanyNameNull()) { _issues[0].CompanyName = issue.CompanyName; } if (!issue.IsContactIDNull()) { _issues[0].ContactID = issue.ContactID; } if (!issue.IsContactNameNull()) { _issues[0].ContactName = issue.ContactName; } if (!issue.IsCoordinatorNull()) { _issues[0].Coordinator = issue.Coordinator; } if (!issue.IsDistrictNumberNull()) { _issues[0].DistrictNumber = issue.DistrictNumber; } if (!issue.IsFirstActionCreatedNull()) { _issues[0].FirstActionCreated = issue.FirstActionCreated; } if (!issue.IsFirstActionDescriptionNull()) { _issues[0].FirstActionDescription = issue.FirstActionDescription; } if (!issue.IsFirstActionIDNull()) { _issues[0].FirstActionID = issue.FirstActionID; } if (!issue.IsFirstActionUserIDNull()) { _issues[0].FirstActionUserID = issue.FirstActionUserID; } if (!issue.IsLastActionCreatedNull()) { _issues[0].LastActionCreated = issue.LastActionCreated; } if (!issue.IsLastActionDescriptionNull()) { _issues[0].LastActionDescription = issue.LastActionDescription; } if (!issue.IsLastActionIDNull()) { _issues[0].LastActionID = issue.LastActionID; } if (!issue.IsLastActionUserIDNull()) { _issues[0].LastActionUserID = issue.LastActionUserID; } if (!issue.IsOFD1FromDateNull()) { _issues[0].OFD1FromDate = issue.OFD1FromDate; } if (!issue.IsOFD1ToDateNull()) { _issues[0].OFD1ToDate = issue.OFD1ToDate; } if (!issue.IsPROIDNull()) { _issues[0].PROID = issue.PROID; } if (!issue.IsStoreNumberNull()) { _issues[0].StoreNumber = issue.StoreNumber; } if (!issue.IsSubjectNull()) { _issues[0].Subject = issue.Subject; } if (!issue.IsTypeNull()) { _issues[0].Type = issue.Type; } if (!issue.IsTypeIDNull()) { _issues[0].TypeID = issue.TypeID; } if (!issue.IsZoneNull()) { _issues[0].Zone = issue.Zone; } _issues[0].AcceptChanges(); #endregion Debug.WriteLine("CACHE: Updated issue#" + _issues[0].ID.ToString() + "; lastActionCreated=" + _issues[0].LastActionCreated.ToString("MM/dd/yyyy HH:mm:ss")); } } if (issue.LastActionCreated.CompareTo(lastUpdated) > 0 && issue.LastActionCreated.CompareTo(_IssueCacheLastUpdate) > 0) { _IssueCacheLastUpdate = issue.LastActionCreated; } } } }
private void postIssueUpdates() { //Check for new issue actions and fire an event for each one found DateTime lastUpdated = this.mLastIssueUpdateTime; IssueDS issues = new IssueDS(); issues.Merge(this.mIssues); for (int i = 0; i < issues.IssueTable.Rows.Count; i++) { //Find issues with LastAction that has not been posted yet //Skip 'New' actions and actions from creator IssueDS.IssueTableRow issue = issues.IssueTable[i]; if (issue.LastActionCreated.CompareTo(lastUpdated) > 0 && issue.LastActionDescription != "New" && issue.LastActionUserID != Environment.UserName) { //Post a NewIssue event with an issue instance that includes the last action IssueDS action = new IssueDS(); action.ActionTable.AddActionTableRow(issue.LastActionID, (byte)0, issue.ID, issue.LastActionUserID, issue.LastActionCreated, issue.LastActionDescription, 0); Issue _issue = new Issue(); _issue.ID = issue.ID; if (!issue.IsTypeIDNull()) { _issue.TypeID = issue.TypeID; } if (!issue.IsTypeNull()) { _issue.Type = issue.Type; } if (!issue.IsSubjectNull()) { _issue.Subject = issue.Subject.Trim(); } if (!issue.IsContactIDNull()) { _issue.ContactID = issue.ContactID; } if (!issue.IsContactNameNull()) { _issue.ContactName = issue.ContactName; } if (!issue.IsCompanyIDNull()) { _issue.CompanyID = issue.CompanyID; } if (!issue.IsCompanyNameNull()) { _issue.CompanyName = issue.CompanyName; } if (!issue.IsRegionNumberNull()) { _issue.RegionNumber = issue.RegionNumber.Trim(); } if (!issue.IsDistrictNumberNull()) { _issue.DistrictNumber = issue.DistrictNumber.Trim(); } if (!issue.IsAgentNumberNull()) { _issue.AgentNumber = issue.AgentNumber.Trim(); } if (!issue.IsStoreNumberNull()) { _issue.StoreNumber = issue.StoreNumber; } if (!issue.IsOFD1FromDateNull()) { _issue.OFD1FromDate = issue.OFD1FromDate; } if (!issue.IsOFD1ToDateNull()) { _issue.OFD1ToDate = issue.OFD1ToDate; } if (!issue.IsPROIDNull()) { _issue.PROID = issue.PROID; } if (!issue.IsFirstActionIDNull()) { _issue.FirstActionID = issue.FirstActionID; } if (!issue.IsFirstActionDescriptionNull()) { _issue.FirstActionDescription = issue.FirstActionDescription; } if (!issue.IsFirstActionUserIDNull()) { _issue.FirstActionUserID = issue.FirstActionUserID; } if (!issue.IsFirstActionCreatedNull()) { _issue.FirstActionCreated = issue.FirstActionCreated; } if (!issue.IsLastActionIDNull()) { _issue.LastActionID = issue.LastActionID; } if (!issue.IsLastActionDescriptionNull()) { _issue.LastActionDescription = issue.LastActionDescription; } if (!issue.IsLastActionUserIDNull()) { _issue.LastActionUserID = issue.LastActionUserID; } if (!issue.IsLastActionCreatedNull()) { _issue.LastActionCreated = issue.LastActionCreated; } if (!issue.IsZoneNull()) { _issue.Zone = issue.Zone; } if (!issue.IsCoordinatorNull()) { _issue.Coordinator = issue.Coordinator; } Action _action = new Action(); _action.IssueID = issue.ID; if (!action.ActionTable[0].IsIDNull()) { _action.ID = action.ActionTable[0].ID; } if (!action.ActionTable[0].IsTypeIDNull()) { _action.TypeID = action.ActionTable[0].TypeID; } if (!action.ActionTable[0].IsUserIDNull()) { _action.UserID = action.ActionTable[0].UserID; } if (!action.ActionTable[0].IsCreatedNull()) { _action.Created = action.ActionTable[0].Created; } if (!action.ActionTable[0].IsCommentNull()) { _action.Comment = action.ActionTable[0].Comment; } if (!action.ActionTable[0].IsAttachmentsNull()) { _action.Attachments = action.ActionTable[0].Attachments; } if (!action.ActionTable[0].IsIssueIDNull()) { _action.IssueID = action.ActionTable[0].IssueID; } if (this.NewIssue != null) { this.NewIssue(this, new NewIssueEventArgs(_issue, _action)); } //Update mLastIssueUpdateTime time to keep notification to once for an updated issue if (issue.LastActionCreated.CompareTo(this.mLastIssueUpdateTime) > 0) { this.mLastIssueUpdateTime = issue.LastActionCreated; } } } }
public IssueDS GetValidActionTypes() { //Get valid action types for this issue //1 Open New //2 Dismiss Closed //3 Close Closed //4 Notify All All //5 Notify Agent Systems Agent Systems //6 Notify CRG CRG //7 Other Pending IssueDS actionTypes = null; try { //Get full list actionTypes = new IssueDS(); actionTypes.Merge(CRGFactory.ActionTypes); //Remove actions that don't apply IssueDS actions = this._parent.Actions; if (actions.ActionTable.Rows.Count == 0) { //New: Open only for (int i = 0; i < actionTypes.ActionTypeTable.Rows.Count; i++) { if (actionTypes.ActionTypeTable[i].ID != 1) { actionTypes.ActionTypeTable[i].Delete(); } } } else if (actions.ActionTable.Rows.Count == 1) { //Open: Dismiss, Notify All, Notify Agent Systems, Notify CRG for (int i = 0; i < actionTypes.ActionTypeTable.Rows.Count; i++) { if (actionTypes.ActionTypeTable[i].ID == 1) { actionTypes.ActionTypeTable[i].Delete(); } else if (actionTypes.ActionTypeTable[i].ID == 3) { actionTypes.ActionTypeTable[i].Delete(); } } } else if (actions.ActionTable.Rows.Count > 1) { //Unresolved: Close, Notify All, Notify Agent Systems, Notify CRG, Other for (int i = 0; i < actionTypes.ActionTypeTable.Rows.Count; i++) { if (actionTypes.ActionTypeTable[i].ID == 1) { actionTypes.ActionTypeTable[i].Delete(); } else if (actionTypes.ActionTypeTable[i].ID == 2) { actionTypes.ActionTypeTable[i].Delete(); } } } //Commit changes actionTypes.AcceptChanges(); } catch (Exception ex) { throw new ApplicationException("Unexpected error while reading action types.", ex); } return(actionTypes); }