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; } } } }
//Members //Interface protected void Page_Load(object sender, EventArgs e) { //Event handler for page load event if (!Page.IsPostBack) { //Get query params IssueDS issues = new CustomerProxy().GetIssues(); for (int i = 0; i < issues.IssueTable.Rows.Count; i++) { IssueDS.IssueTableRow issue = issues.IssueTable[i]; TableCell zone = new TableCell(); zone.BorderStyle = BorderStyle.Solid; zone.BorderWidth = 1; zone.BorderColor = System.Drawing.Color.LightGray; zone.Text = !issue.IsZoneNull()?issue.Zone:""; TableCell store = new TableCell(); store.BorderStyle = BorderStyle.Solid; store.BorderWidth = 1; store.BorderColor = System.Drawing.Color.LightGray; store.Text = !issue.IsStoreNumberNull()?issue.StoreNumber.ToString():""; TableCell agent = new TableCell(); agent.BorderStyle = BorderStyle.Solid; agent.BorderWidth = 1; agent.BorderColor = System.Drawing.Color.LightGray; agent.Text = !issue.IsAgentNumberNull()?issue.AgentNumber:""; TableCell company = new TableCell(); company.BorderStyle = BorderStyle.Solid; company.BorderWidth = 1; company.BorderColor = System.Drawing.Color.LightGray; company.Text = !issue.IsCompanyNameNull()?issue.CompanyName:""; TableCell type = new TableCell(); type.BorderStyle = BorderStyle.Solid; type.BorderWidth = 1; type.BorderColor = System.Drawing.Color.LightGray; type.Text = issue.Type; TableCell action = new TableCell(); action.BorderStyle = BorderStyle.Solid; action.BorderWidth = 1; action.BorderColor = System.Drawing.Color.LightGray; action.Text = issue.LastActionDescription; TableCell received = new TableCell(); received.BorderStyle = BorderStyle.Solid; received.BorderWidth = 1; received.BorderColor = System.Drawing.Color.LightGray; received.Text = issue.LastActionCreated.ToString("MM/dd/yyyy"); TableCell subject = new TableCell(); subject.BorderStyle = BorderStyle.Solid; subject.BorderWidth = 1; subject.BorderColor = System.Drawing.Color.LightGray; subject.Text = !issue.IsSubjectNull()?issue.Subject:""; TableCell contact = new TableCell(); contact.BorderStyle = BorderStyle.Solid; contact.BorderWidth = 1; contact.BorderColor = System.Drawing.Color.LightGray; contact.Text = !issue.IsContactNameNull()?issue.ContactName:""; TableCell lastuser = new TableCell(); lastuser.BorderStyle = BorderStyle.Solid; lastuser.BorderWidth = 1; lastuser.BorderColor = System.Drawing.Color.LightGray; lastuser.Text = issue.LastActionUserID; TableCell coordinator = new TableCell(); coordinator.BorderStyle = BorderStyle.Solid; coordinator.BorderWidth = 1; coordinator.BorderColor = System.Drawing.Color.LightGray; coordinator.Text = issue.Coordinator; TableRow tr = new TableRow(); tr.Cells.AddRange(new TableCell[] { zone, store, agent, company, type, action, received, subject, contact, lastuser, coordinator }); this.tblPage.Rows.Add(tr); } } }
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 Issue(IssueDS.IssueTableRow issue, IssueDS actions, IssueDS attachments) { //Constructor try { this.mActions = new IssueDS(); this.mAttachments = new IssueDS(); if (issue == null) { //New issue- add an 'Open' action this.mActions.ActionTable.AddActionTableRow(0, Action.ACTIONTYPE_OPEN, 0, Environment.UserName, DateTime.Now, ""); } else { //Existing issue if (!issue.IsIDNull()) { this._id = issue.ID; } if (!issue.IsTypeIDNull()) { this._typeid = issue.TypeID; } if (!issue.IsSubjectNull()) { this._subject = issue.Subject.Trim(); } if (!issue.IsContactIDNull()) { this._contactid = issue.ContactID; } if (!issue.IsCompanyIDNull()) { this._companyid = issue.CompanyID; } 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.IsZoneNull()) { this._zone = issue.Zone; } if (actions != null) { this.mActions.Merge(actions); } if (attachments != null) { this.mAttachments.Merge(attachments); } } } catch (Exception ex) { throw new ApplicationException("Unexpected error while creating new Issue instance", ex); } }
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); } }