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; } } } }
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; } } } }
public Issue(IssueDS.IssueTableRow issue) { //Constructor try { if (issue != null) { if (!issue.IsIDNull()) { this._id = issue.ID; } if (!issue.IsTypeIDNull()) { this._typeid = issue.TypeID; } if (!issue.IsTypeNull()) { this._type = issue.Type; } if (!issue.IsSubjectNull()) { this._subject = issue.Subject.Trim(); } if (!issue.IsContactIDNull()) { this._contactid = issue.ContactID; } if (!issue.IsContactNameNull()) { this._contactname = issue.ContactName; } if (!issue.IsCompanyIDNull()) { this._companyid = issue.CompanyID; } if (!issue.IsCompanyNameNull()) { this._companyname = issue.CompanyName; } if (!issue.IsRegionNumberNull()) { this._regionnumber = issue.RegionNumber.Trim(); } if (!issue.IsDistrictNumberNull()) { this._districtnumber = issue.DistrictNumber.Trim(); } if (!issue.IsAgentNumberNull()) { this._agentnumber = issue.AgentNumber.Trim(); } if (!issue.IsStoreNumberNull()) { this._storenumber = issue.StoreNumber; } if (!issue.IsOFD1FromDateNull()) { this._ofd1datefrom = issue.OFD1FromDate; } if (!issue.IsOFD1ToDateNull()) { this._ofd1dateto = issue.OFD1ToDate; } if (!issue.IsPROIDNull()) { this._proid = issue.PROID; } if (!issue.IsFirstActionIDNull()) { this._firstactionid = issue.FirstActionID; } if (!issue.IsFirstActionDescriptionNull()) { this._firstactiondescription = issue.FirstActionDescription; } if (!issue.IsFirstActionUserIDNull()) { this._firstactionuserid = issue.FirstActionUserID; } if (!issue.IsFirstActionCreatedNull()) { this._firstactioncreated = issue.FirstActionCreated; } if (!issue.IsLastActionIDNull()) { this._lastactionid = issue.LastActionID; } if (!issue.IsLastActionDescriptionNull()) { this._lastactiondescription = issue.LastActionDescription; } if (!issue.IsLastActionUserIDNull()) { this._lastactionuserid = issue.LastActionUserID; } if (!issue.IsLastActionCreatedNull()) { this._lastactioncreated = issue.LastActionCreated; } if (!issue.IsZoneNull()) { this._zone = issue.Zone; } if (!issue.IsCoordinatorNull()) { this._coordinator = issue.Coordinator; } } } catch (Exception ex) { throw new ApplicationException("Unexpected error while creating new Issue instance", ex); } }