public void UpdateCache(CRMDataset issues) { //Update issue cache DateTime lastUpdated = this.mLastUpdated; for (int i = 0; i < issues.IssueTable.Rows.Count; i++) { CRMDataset.IssueTableRow issue = issues.IssueTable[i]; CRMDataset.IssueTableRow[] _issues = (CRMDataset.IssueTableRow[]) this.mIssues.IssueTable.Select("ID=" + issue.ID); if (_issues.Length == 0) { //Not in cache; add new CRMDataset.IssueTableRow _issue = this.mIssues.IssueTable.NewIssueTableRow(); #region New to cache: add new issue _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.IsContactNull()) { _issue.Contact = issue.Contact; } if (!issue.IsCoordinatorNull()) { _issue.Coordinator = issue.Coordinator; } if (!issue.IsClientRepNull()) { _issue.ClientRep = issue.ClientRep; } 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.IsFirstActionCommentNull()) { _issue.FirstActionComment = issue.FirstActionComment; } 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.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 this.mIssues.IssueTable.AddIssueTableRow(_issue); Debug.WriteLine("CACHE: New issue#" + _issue.ID.ToString() + "; lastActionCreated=" + _issue.LastActionCreated.ToString("MM/dd/yyyy HH:mm:ss")); } else { //In cache; updated? 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.IsContactNull()) { _issues[0].Contact = issue.Contact; } if (!issue.IsCoordinatorNull()) { _issues[0].Coordinator = issue.Coordinator; } if (!issue.IsClientRepNull()) { _issues[0].ClientRep = issue.ClientRep; } 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.IsFirstActionCommentNull()) { _issues[0].FirstActionComment = issue.FirstActionComment; } 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.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(this.mLastUpdated) > 0) { this.mLastUpdated = issue.LastActionCreated; } } }
public Issue(CRMDataset.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.IsContactNull()) { this._contact = issue.Contact; } 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.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); } }