Пример #1
0
        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;
                }
            }
        }
Пример #2
0
    //Members

    //Interface
    protected void Page_Load(object sender, EventArgs e)
    {
        //Event handler for page load event
        if (!Page.IsPostBack)
        {
            //Get query params
            CRMDataset issues = new CustomersGateway().ViewIssues(null);
            for (int i = 0; i < issues.IssueTable.Rows.Count; i++)
            {
                CRMDataset.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.IsContactNull()?issue.Contact:"";
                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);
            }
        }
    }
Пример #3
0
 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); }
 }