示例#1
0
 private void OnRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     //Event handler for worker thread completed DoWork (this is on the main thread)
     try {
         //Notify user of open reminders
         if (e.Error == null)
         {
             CRMDataset reminders = (CRMDataset)e.Result;
             if (reminders != null && reminders.ReminderTable.Rows.Count > 0)
             {
                 for (int i = 0; i < reminders.ReminderTable.Rows.Count; i++)
                 {
                     long      id     = reminders.ReminderTable[i].IssueID;
                     string    userID = reminders.ReminderTable[i].UserID;
                     DataRow[] rows   = this.mOpenReminders.ReminderTable.Select("IssueID=" + id + " AND UserID='" + userID + "'");
                     if (rows.Length == 0)
                     {
                         this.mOpenReminders.ReminderTable.ImportRow(reminders.ReminderTable[i]);
                     }
                 }
                 this.mDialog.Show();
             }
         }
     }
     catch { }
 }
示例#2
0
        public static CRMDataset GetIssueCategories()
        {
            //Issue type category
            CRMDataset categorys = null;

            try {
                ObjectCache cache = MemoryCache.Default;
                categorys = cache["categorys"] as CRMDataset;
                if (categorys == null)
                {
                    categorys = new CRMDataset();
                    CRMDataset issueTypes = GetIssueTypes("");
                    Hashtable  groups     = new Hashtable();
                    for (int i = 0; i < issueTypes.IssueTypeTable.Rows.Count; i++)
                    {
                        if (!groups.ContainsKey(issueTypes.IssueTypeTable[i].Category))
                        {
                            groups.Add(issueTypes.IssueTypeTable[i].Category, issueTypes.IssueTypeTable[i].Category);
                            categorys.IssueTypeTable.AddIssueTypeTableRow(0, "", issueTypes.IssueTypeTable[i].Category, "");
                        }
                    }
                    categorys.AcceptChanges();

                    DateTimeOffset policy = new DateTimeOffset(DateTime.Now.AddMinutes(1440));
                    cache.Set("categorys", categorys, policy);
                }
            }
            catch (Exception ex) { throw new ApplicationException(ex.Message); }
            return(categorys);
        }
示例#3
0
        public static CRMDataset GetCompanies()
        {
            //Companies; cache companies
            CRMDataset       companies = null;
            CRMServiceClient client    = null;

            try {
                ObjectCache cache = MemoryCache.Default;
                companies = cache["companies"] as CRMDataset;
                if (companies == null)
                {
                    companies = new CRMDataset();
                    client    = new CRMServiceClient();
                    DataSet ds = client.GetCompanies();
                    client.Close();
                    if (ds.Tables["CompanyTable"] != null && ds.Tables["CompanyTable"].Rows.Count > 0)
                    {
                        CRMDataset _ds = new CRMDataset();
                        _ds.CompanyTable.AddCompanyTableRow(0, "All", "000", "", 1);
                        _ds.Merge(ds.Tables["CompanyTable"].Select("IsActive = 1", "CompanyName ASC"));
                        companies.Merge(_ds);
                    }

                    DateTimeOffset policy = new DateTimeOffset(DateTime.Now.AddMinutes(1440));
                    cache.Set("companies", companies, policy);
                }
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <EnterpriseFault> cfe) { client.Abort(); throw new ApplicationException(cfe.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(companies);
        }
示例#4
0
        public static CRMDataset GetIssueTypes(string issueCategory)
        {
            //Issue types- all or filtered by category
            CRMDataset       issueTypes = null;
            CRMServiceClient client     = null;

            try {
                ObjectCache cache = MemoryCache.Default;
                issueTypes = cache["issueTypes" + issueCategory] as CRMDataset;
                if (issueTypes == null)
                {
                    issueTypes = new CRMDataset();
                    client     = new CRMServiceClient();
                    DataSet ds = client.GetIssueTypes(issueCategory);
                    client.Close();
                    if (ds.Tables["IssueTypeTable"] != null && ds.Tables["IssueTypeTable"].Rows.Count > 0)
                    {
                        issueTypes.Merge(ds);
                    }

                    DateTimeOffset policy = new DateTimeOffset(DateTime.Now.AddMinutes(1440));
                    cache.Set("issueTypes" + issueCategory, issueTypes, policy);
                }
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException fe) { throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(issueTypes);
        }
示例#5
0
        public static CRMDataset GetAgents()
        {
            //Get a list of all agents
            CRMDataset       agents = null;
            CRMServiceClient client = null;

            try {
                ObjectCache cache = MemoryCache.Default;
                agents = cache["agents"] as CRMDataset;
                if (agents == null)
                {
                    agents = new CRMDataset();

                    client = new CRMServiceClient();
                    DataSet ds = client.GetAgents();
                    client.Close();
                    if (ds.Tables["AgentTable"] != null && ds.Tables["AgentTable"].Rows.Count > 0)
                    {
                        agents.Merge(ds);
                    }

                    DateTimeOffset policy = new DateTimeOffset(DateTime.Now.AddMinutes(1440));
                    cache.Set("agents", agents, policy);
                }
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <EnterpriseFault> cfe) { client.Abort(); throw new ApplicationException(cfe.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(agents);
        }
示例#6
0
        public static CRMDataset GetIssues()
        {
            //Get issues
            CRMDataset       issues = new CRMDataset();
            CRMServiceClient client = null;

            try {
                if (_Cache == null)
                {
                    _Cache = new IssueCache(DateTime.Today.AddDays(-App.Config.IssueDaysBack));
                }
                client = new CRMServiceClient();
                DataSet ds = client.GetIssuesForDate(_Cache.LastUpdated);
                client.Close();
                System.Diagnostics.Debug.WriteLine("PAYLOAD: fromDate=" + _Cache.LastUpdated.ToString("MM/dd/yyyy HH:mm:ss") + "; bytes=" + ds.GetXml().Length);

                CRMDataset _issues = new CRMDataset();
                if (ds.Tables["IssueTable"] != null && ds.Tables["IssueTable"].Rows.Count > 0)
                {
                    _issues.Merge(ds);
                    _Cache.UpdateCache(_issues);
                    issues.Merge(_Cache.Issues);
                }
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <CustomersFault> cfe) { client.Abort(); throw new ApplicationException(cfe.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(issues);
        }
示例#7
0
 //Interface
 public dlgReminders(ReminderService service, CRMDataset reminders)
 {
     //Constructor
     InitializeComponent();
     this.mService                = service;
     this.mOpenReminders          = reminders;
     this.grdReminders.DataSource = this.mOpenReminders;
 }
示例#8
0
        public Issue GetIssue(long issueID)
        {
            //Get an existing issue
            Issue issue = null;

            try {
                //Load the issue
                CRMDataset issuesDS = new CRMDataset();
                issuesDS.Merge(new CRMGateway().GetIssue(issueID));
                if (issuesDS.IssueTable.Rows.Count > 0)
                {
                    issue = new Issue(issuesDS.IssueTable[0]);

                    //Get the actions and attachments for this issue
                    CRMDataset actionDS = new CRMDataset();
                    actionDS.Merge(new CRMGateway().GetActions(issueID));
                    CRMDataset attachmentDS = new CRMDataset();
                    attachmentDS.Merge(new CRMGateway().GetAttachments(issueID));

                    //Attach actions to the issue and attachents to the actions
                    Actions actions = new Actions();
                    if (actionDS != null)
                    {
                        for (int i = 0; i < actionDS.ActionTable.Rows.Count; i++)
                        {
                            //Load an action and add to actions collection
                            Action action = new Action(actionDS.ActionTable[i]);
                            actions.Add(action);

                            //Attach attachments to this action if applicable
                            if (action.AttachmentCount > 0 && attachmentDS != null)
                            {
                                Attachments attachments = new Attachments();
                                for (int j = 0; j < attachmentDS.AttachmentTable.Rows.Count; j++)
                                {
                                    Attachment attachment = new Attachment(attachmentDS.AttachmentTable[j]);
                                    if (attachment.ActionID == action.ID)
                                    {
                                        attachments.Add(attachment);
                                    }
                                }
                                action.Attachments = attachments;
                            }
                            else
                            {
                                action.Attachments = new Attachments();
                            }
                        }
                    }
                    issue.Actions = actions;
                }
            }
            catch (Exception ex) { throw new FaultException <CustomersFault>(new CustomersFault(ex.Message), "Service Error"); }
            return(issue);
        }
示例#9
0
        private void OnScopeChanged(object sender, EventArgs e)
        {
            //Event handler for change in scope
            try {
                //Prepare a location selector for the specified scope
                string scope = this.cboScope.SelectedItem != null?this.cboScope.SelectedItem.ToString() : SCOPE_NONE;

                this.cboLocation.Visible = (scope == SCOPE_NONE || scope == SCOPE_DISTRICTS || scope == SCOPE_REGIONS || scope == SCOPE_AGENTS);
                this.txtStore.Visible    = (scope == SCOPE_STORES || scope == SCOPE_SUBSTORES);

                this.cboLocation.DataSource = null;
                CRMDataset locationDS = new CRMDataset();
                CRMDataset ds         = null;
                int        companyID  = int.Parse(this.cboCompany.SelectedValue.ToString());
                string     number     = this.cboCompany.SelectedValue.ToString().PadLeft(8, '0').Substring(5, 3);
                switch (scope)
                {
                case SCOPE_DISTRICTS:
                    ds = CRMGateway.GetDistricts(number);
                    this.cboLocation.DisplayMember = "LocationTable.LocationName";
                    this.cboLocation.ValueMember   = "LocationTable.Location";
                    break;

                case SCOPE_REGIONS:
                    ds = CRMGateway.GetRegions(number);
                    this.cboLocation.DisplayMember = "LocationTable.LocationName";
                    this.cboLocation.ValueMember   = "LocationTable.Location";
                    break;

                case SCOPE_STORES:
                case SCOPE_SUBSTORES:
                    this.txtStore.Text = "";
                    break;

                case SCOPE_AGENTS:
                    ds = CRMGateway.GetAgents(number);
                    this.cboLocation.DisplayMember = "AgentTable.AgentSummary";
                    this.cboLocation.ValueMember   = "AgentTable.AgentNumber";
                    break;
                }
                if (ds != null)
                {
                    locationDS.Merge(ds);
                    this.cboLocation.DataSource = locationDS;
                }
                this.cboLocation.Enabled = this.cboLocation.Items.Count > 0;
                if (this.cboLocation.Items.Count > 0)
                {
                    this.cboLocation.SelectedIndex = 0;
                }
                OnCompanyLocationChanged(null, EventArgs.Empty);
            }
            catch (Exception ex) { App.ReportError(new ApplicationException("Unexpected error when location scope changed.", ex)); }
        }
示例#10
0
        public static CRMDataset GetRegions(string clientNumber)
        {
            //Get a list of regional locations for the specified client; convert schema field names to generic Location, LocationName
            CRMDataset       regions = null;
            CRMServiceClient client  = null;

            try {
                ObjectCache cache = MemoryCache.Default;
                regions = cache["regions" + clientNumber] as CRMDataset;
                if (regions == null)
                {
                    regions = new CRMDataset();
                    regions.LocationTable.AddLocationTableRow("All", "All");
                    if (clientNumber.Length > 3)
                    {
                        clientNumber = clientNumber.Substring(clientNumber.Length - 3, 3);
                    }
                    if (clientNumber == "000")
                    {
                        clientNumber = null;
                    }

                    client = new CRMServiceClient();
                    DataSet ds = client.GetRegionsDistricts(clientNumber);
                    client.Close();

                    //Filter out duplicate regions since resultset is district-region (child-parent)
                    System.Collections.Hashtable table = new System.Collections.Hashtable();
                    if (ds.Tables["LocationTable"] != null)
                    {
                        for (int i = 0; i < ds.Tables["LocationTable"].Rows.Count; i++)
                        {
                            string location     = ds.Tables["LocationTable"].Rows[i]["Region"].ToString().Trim();
                            string locationName = ds.Tables["LocationTable"].Rows[i]["RegionName"].ToString().Trim();
                            if (!table.ContainsKey(location))
                            {
                                table.Add(location, locationName);
                                regions.LocationTable.AddLocationTableRow(location, locationName);
                            }
                        }
                    }
                    regions.AcceptChanges();

                    DateTimeOffset policy = new DateTimeOffset(DateTime.Now.AddMinutes(1440));
                    cache.Set("regions" + clientNumber, regions, policy);
                }
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <EnterpriseFault> cfe) { client.Abort(); throw new ApplicationException(cfe.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(regions);
        }
示例#11
0
        //Interface
        public ReminderService()
        {
            //
            this.mReminders     = new CRMDataset();
            this.mOpenReminders = new CRMDataset();
            this.mDialog        = new dlgReminders(this, this.mOpenReminders);

            this.mTimer                      = new System.Windows.Forms.Timer();
            this.mTimer.Interval             = 15000;
            this.mTimer.Tick                += new EventHandler(OnTick);
            this.mWorker                     = new BackgroundWorker();
            this.mWorker.DoWork             += new DoWorkEventHandler(OnDoWork);
            this.mWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(OnRunWorkerCompleted);
        }
示例#12
0
        public static CRMDataset GetAgents(string clientNumber)
        {
            //Get a list of agents for the specified client
            CRMDataset       agents = null;
            CRMServiceClient client = null;

            try {
                ObjectCache cache = MemoryCache.Default;
                agents = cache["agents" + clientNumber] as CRMDataset;
                if (agents == null)
                {
                    agents = new CRMDataset();
                    agents.AgentTable.AddAgentTableRow("All", "", "All", "", "", "", "", "", 0, "", "", "", "", "", "", "", "", "", "All");
                    if (clientNumber.Length > 3)
                    {
                        clientNumber = clientNumber.Substring(clientNumber.Length - 3, 3);
                    }
                    if (clientNumber == "000")
                    {
                        clientNumber = null;
                    }

                    client = new CRMServiceClient();
                    DataSet ds = client.GetAgentsByClient(clientNumber);
                    client.Close();
                    if (ds.Tables["AgentTable"] != null && ds.Tables["AgentTable"].Rows.Count > 0)
                    {
                        CRMDataset _ds = new CRMDataset();
                        _ds.Merge(ds);
                        for (int i = 0; i < _ds.AgentTable.Rows.Count; i++)
                        {
                            _ds.AgentTable.Rows[i]["AgentSummary"] = (!_ds.AgentTable.Rows[i].IsNull("MainZone") ? _ds.AgentTable.Rows[i]["MainZone"].ToString().PadLeft(2, ' ') : "  ") + " - " +
                                                                     (!_ds.AgentTable.Rows[i].IsNull("AgentNumber") ? _ds.AgentTable.Rows[i]["AgentNumber"].ToString() : "    ") + " - " +
                                                                     (!_ds.AgentTable.Rows[i].IsNull("AgentName") ? _ds.AgentTable.Rows[i]["AgentName"].ToString().Trim() : "");
                        }
                        agents.Merge(_ds.AgentTable.Select("", "MainZone ASC"));
                        agents.AgentTable.AcceptChanges();
                    }

                    DateTimeOffset policy = new DateTimeOffset(DateTime.Now.AddMinutes(1440));
                    cache.Set("agents" + clientNumber, agents, policy);
                }
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <EnterpriseFault> cfe) { client.Abort(); throw new ApplicationException(cfe.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(agents);
        }
示例#13
0
        public static CRMDataset GetDistricts(string clientNumber)
        {
            //Get a list of client districts; convert schema field names to generic Location, LocationName
            CRMDataset       districts = null;
            CRMServiceClient client    = null;

            try {
                ObjectCache cache = MemoryCache.Default;
                districts = cache["districts" + clientNumber] as CRMDataset;
                if (districts == null)
                {
                    districts = new CRMDataset();
                    districts.LocationTable.AddLocationTableRow("All", "All");
                    if (clientNumber.Length > 3)
                    {
                        clientNumber = clientNumber.Substring(clientNumber.Length - 3, 3);
                    }
                    if (clientNumber == "000")
                    {
                        clientNumber = null;
                    }

                    client = new CRMServiceClient();
                    DataSet ds = client.GetRegionsDistricts(clientNumber);
                    client.Close();

                    if (ds.Tables["LocationTable"] != null)
                    {
                        for (int i = 0; i < ds.Tables["LocationTable"].Rows.Count; i++)
                        {
                            string location     = ds.Tables["LocationTable"].Rows[i]["District"].ToString().Trim();
                            string locationName = ds.Tables["LocationTable"].Rows[i]["DistrictName"].ToString().Trim();
                            districts.LocationTable.AddLocationTableRow(location, locationName);
                        }
                    }
                    districts.AcceptChanges();

                    DateTimeOffset policy = new DateTimeOffset(DateTime.Now.AddMinutes(1440));
                    cache.Set("districts" + clientNumber, districts, policy);
                }
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <EnterpriseFault> cfe) { client.Abort(); throw new ApplicationException(cfe.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(districts);
        }
示例#14
0
        private void OnStoreKeyUp(object sender, KeyEventArgs e)
        {
            //Event handler for store textbox key up event
            try {
                if (e.KeyCode == Keys.Enter)
                {
                    this.txtStoreName.Text = this.txtStoreAddress.Text = this.txtStoreDetail.Text = "";
                    if (this.cboClient.SelectedValue != null && this.mskStore.Text.Trim().Length > 0)
                    {
                        CRMDataset ds = new CRMDataset();
                        ds.Merge(CRMGateway.GetStoreDetail(int.Parse(this.cboClient.SelectedValue.ToString()), int.Parse(this.mskStore.Text)));
                        if (ds.StoreTable.Rows.Count > 0)
                        {
                            CRMDataset.StoreTableRow store = ds.StoreTable[0];
                            this.txtStoreName.Text = store.StoreName.Trim() + " (store #" + store.StoreNumber.ToString() + "; substore #" + store.SubStoreNumber.Trim() + ")";

                            StringBuilder address = new StringBuilder();
                            address.AppendLine((!store.IsStoreAddressline1Null() ? store.StoreAddressline1.Trim() : ""));
                            address.AppendLine((!store.IsStoreAddressline2Null() ? store.StoreAddressline2.Trim() : ""));
                            address.AppendLine((!store.IsStoreCityNull() ? store.StoreCity.Trim() : "") + ", " +
                                               (!store.IsStoreStateNull() ? store.StoreState.Trim() : "") + " " +
                                               (!store.IsStoreZipNull() ? store.StoreZip.Trim() : ""));
                            this.txtStoreAddress.Text = address.ToString();

                            StringBuilder detail = new StringBuilder();
                            detail.AppendLine((!store.IsRegionDescriptionNull() ? store.RegionDescription.Trim() : "") +
                                              " (" + (!store.IsRegionNull() ? store.Region.Trim() : "") + "), " +
                                              (!store.IsDistrictNameNull() ? store.DistrictName.Trim() : "") +
                                              " (" + (!store.IsDistrictNull() ? store.District.Trim() : "") + ")");
                            detail.AppendLine("Zone " + (!store.IsZoneNull() ? store.Zone.Trim() : "") + ", " +
                                              "Agent " + (!store.IsAgentNumberNull() ? store.AgentNumber.Trim() : "") + " " +
                                              (!store.IsAgentNameNull() ? store.AgentName.Trim() : ""));
                            detail.AppendLine("Window " + (!store.IsWindowTimeStartNull() ? store.WindowTimeStart.ToString("HH:mm") : "") + " - " +
                                              (!store.IsWindowTimeEndNull() ? store.WindowTimeEnd.ToString("HH:mm") : "") + ", " +
                                              "Del Days " + getDeliveryDays(store) + ", " +
                                              (!store.IsScanStatusDescrptionNull() ? store.ScanStatusDescrption.Trim() : ""));
                            detail.AppendLine("JA Transit " + (!store.IsStandardTransitNull() ? store.StandardTransit.ToString() : "") + ", " + "OFD " + getOFD(store));
                            detail.AppendLine("Special Inst: " + (!store.IsSpecialInstructionsNull() ? store.SpecialInstructions.Trim() : ""));
                            this.txtStoreDetail.Text = detail.ToString();
                        }
                    }
                    refreshReports();
                }
            }
            catch (Exception ex) { App.ReportError(new ApplicationException("Unexpected error when store keyed in.", ex)); }
        }
示例#15
0
 private void OnDoWork(object sender, DoWorkEventArgs e)
 {
     //Event handler for background worker thread DoWork event; runs on worker thread
     try {
         //Find reminders that are ready to be published; marshall to main thread
         CRMDataset reminders = new CRMDataset();
         lock (this.mReminders) {
             DataRow[] rows = this.mReminders.ReminderTable.Select("Time<='" + DateTime.Now.ToString() + "'");
             for (int i = 0; i < rows.Length; i++)
             {
                 reminders.ReminderTable.ImportRow(rows[i]);
             }
         }
         e.Result = reminders;
     }
     catch { }
 }
示例#16
0
        public static CRMDataset GetStoreDetail(int companyID, string subStore)
        {
            //Get a list of store locations
            CRMDataset       stores = new CRMDataset();
            CRMServiceClient client = null;

            try {
                client = new CRMServiceClient();
                DataSet ds = client.GetSubStoreDetail(companyID, subStore);
                client.Close();
                stores.Merge(ds);
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <EnterpriseFault> cfe) { client.Abort(); throw new ApplicationException(cfe.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(stores);
        }
示例#17
0
        public static CRMDataset GetDeliveries(int companyID, int storeNumber, DateTime from, DateTime to)
        {
            //Get a list of store locations
            CRMDataset       deliveries = new CRMDataset();
            CRMServiceClient client     = null;

            try {
                client = new CRMServiceClient();
                DataSet ds = client.GetDeliveries(companyID, storeNumber, from, to);
                client.Close();
                deliveries.Merge(ds);
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <EnterpriseFault> cfe) { client.Abort(); throw new ApplicationException(cfe.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(deliveries);
        }
示例#18
0
        public static CRMDataset GetAgentTerminalDetail(string agentNumber)
        {
            //Get details of an agent terminal
            CRMDataset       agent  = new CRMDataset();
            CRMServiceClient client = null;

            try {
                client = new CRMServiceClient();
                CRMDataset agents = GetAgentTerminals(agentNumber);
                client.Close();
                agent.Merge(agents.AgentTable.Select("AgentNumber = '" + agentNumber + "'", ""));
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <EnterpriseFault> cfe) { client.Abort(); throw new ApplicationException(cfe.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(agent);
        }
示例#19
0
        public CRMDataset SearchIssues(string agentNumber, string searchText)
        {
            //Get issue search data
            CRMDataset       issues = new CRMDataset();
            CRMServiceClient client = new CRMServiceClient();

            try {
                DataSet ds = client.SearchIssues(searchText);
                client.Close();
                if (ds != null && ds.Tables["IssueTable"] != null && ds.Tables["IssueTable"].Rows.Count > 0)
                {
                    issues.Merge(ds);
                }
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(issues);
        }
示例#20
0
        public static CRMDataset GetActionTypes(long issueID)
        {
            //Action types for an issue (state driven)
            CRMDataset       actionTypes = new CRMDataset();
            CRMServiceClient client      = null;

            try {
                client = new CRMServiceClient();
                DataSet ds = client.GetActionTypes(issueID);
                client.Close();
                if (ds.Tables["ActionTypeTable"] != null && ds.Tables["ActionTypeTable"].Rows.Count > 0)
                {
                    actionTypes.Merge(ds);
                }
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <CustomersFault> cfe) { throw new ApplicationException(cfe.Detail.Message); }
            catch (FaultException fe) { throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(actionTypes);
        }
示例#21
0
        public static CRMDataset SearchIssuesAdvanced(object[] criteria)
        {
            //Get issues
            CRMDataset       issues = new CRMDataset();
            CRMServiceClient client = null;

            try {
                client = new CRMServiceClient();
                DataSet ds = client.SearchIssuesAdvanced(criteria);
                client.Close();
                if (ds.Tables["IssueTable"] != null && ds.Tables["IssueTable"].Rows.Count > 0)
                {
                    issues.Merge(ds);
                }
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <CustomersFault> cfe) { client.Abort(); throw new ApplicationException(cfe.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(issues);
        }
示例#22
0
        private void OnAgentTerminalChanged(object sender, EventArgs e)
        {
            //Event handler for change in agent terminal
            try {
                this.txtTerminalName.Text = this.txtTerminalAddress.Text = this.txtTermainlDetail.Text = "";
                if (this.cboTerminal.SelectedValue != null)
                {
                    CRMDataset ds = new CRMDataset();
                    ds.Merge(CRMGateway.GetAgentTerminalDetail(this.cboTerminal.SelectedValue.ToString()));
                    if (ds.AgentTable.Rows.Count > 0)
                    {
                        CRMDataset.AgentTableRow agent = ds.AgentTable[0];
                        this.txtTerminalName.Text = agent.AgentNumber.ToString() + " - " + agent.AgentName.Trim();

                        StringBuilder address = new StringBuilder();
                        address.AppendLine((!agent.IsAddressLine1Null() ? agent.AddressLine1.Trim() : ""));
                        address.AppendLine((!agent.IsAddressLine2Null() ? agent.AddressLine2.Trim() : ""));
                        address.AppendLine((!agent.IsCityNull() ? agent.City.Trim() : "") + ", " +
                                           (!agent.IsStateNull() ? agent.State.Trim() : "") + " " +
                                           (!agent.IsZipNull() ? agent.Zip.Trim() : ""));
                        this.txtTerminalAddress.Text = address.ToString();

                        StringBuilder detail = new StringBuilder();
                        detail.AppendLine("Contact: " + (!agent.IsContactNull() ? agent.Contact.Trim() : ""));
                        detail.AppendLine("Phone: " + (!agent.IsPhoneNull() ? agent.Phone.Trim() : ""));
                        detail.AppendLine("Coordinator: " + (!agent.IsCoordinatorNull() ? agent.Coordinator.Trim() : ""));
                        detail.AppendLine("Agent Type: " + (!agent.IsTypeNull() ? agent.Type.Trim() : ""));
                        detail.AppendLine(
                            ("Main Zone: " + (!agent.IsMainZoneNull() ? agent.MainZone.Trim() : "")) + ", " +
                            ("Type= " + (!agent.IsZoneTypeNull() ? agent.ZoneType.Trim() : "")) + ", " +
                            ("Status= " + (!agent.IsZoneStatusNull() ? agent.ZoneStatus.Trim() : "")) + ", " +
                            ("Is Main= " + (!agent.IsIsMainZoneNull() ? agent.IsMainZone.ToString() : ""))
                            );
                        this.txtTermainlDetail.Text = detail.ToString();
                    }
                    refreshReports();
                }
            }
            catch (Exception ex) { App.ReportError(new ApplicationException("Unexpected error on agent selection.", ex)); }
        }
示例#23
0
        public CRMDataset SearchIssuesAdvanced(string agentNumber, string zone, string store, string agent, string company, string type, string action, string received, string subject, string contact, string originator, string coordinator)
        {
            //Get issue search data
            CRMDataset       issues = new CRMDataset();
            CRMServiceClient client = null;

            try {
                string _zone        = (zone != null && zone.Trim().Length > 0) ? zone : null;
                string _store       = (store != null && store.Trim().Length > 0) ? store : null;
                string _agent       = (agent != null && agent.Trim().Length > 0) ? agent : null;
                string _company     = (company != null && company.Trim().Length > 0) ? company : null;
                string _type        = (type != null && type.Trim().Length > 0) ? type : null;
                string _action      = (action != null && action.Trim().Length > 0) ? action : null;
                string _received    = (received != null && received.Trim().Length > 0) ? received : null;
                string _subject     = (subject != null && subject.Trim().Length > 0) ? subject : null;
                string _contact     = (contact != null && contact.Trim().Length > 0) ? contact : null;
                string _originator  = (originator != null && originator.Trim().Length > 0) ? originator : null;
                string _coordinator = (coordinator != null && coordinator.Trim().Length > 0) ? coordinator : null;
                if (_zone == null && _store == null && _agent == null && _company == null && _type == null && _action == null && _received == null && _subject == null && _contact == null && _originator == null && _coordinator == null)
                {
                    issues = new CRMDataset();
                }
                else
                {
                    object[] criteria = new object[] { _zone, _store, _agent, _company, _type, _action, _received, _subject, _contact, _originator, _coordinator };
                    client = new CRMServiceClient();
                    DataSet ds = client.SearchIssuesAdvancedForAgent(agentNumber, criteria);
                    client.Close();

                    if (ds != null && ds.Tables["IssueTable"] != null && ds.Tables["IssueTable"].Rows.Count > 0)
                    {
                        issues.Merge(ds);
                    }
                }
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(issues);
        }
示例#24
0
        public CRMDataset ViewIssues(string agentNumber)
        {
            //Get issue search data
            CRMDataset       issues = new CRMDataset();
            CRMServiceClient client = new CRMServiceClient();

            try {
                DataSet ds = client.ViewIssuesForAgent(agentNumber);
                client.Close();
                if (ds != null)
                {
                    //CRMDataset _issues = new CRMDataset();
                    //_issues.Merge(ds);
                    //issues.Merge(_issues.IssueTable.Select("LastActionDescription <> 'closed'","LastActionCreated DESC"));
                    issues.Merge(ds);
                }
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(issues);
        }
示例#25
0
        private void showStoreDetail()
        {
            //
            this.txtStoreDetail.Clear();
            if (this.cboCompany.SelectedValue != null && this.txtStore.Text.Length > 0)
            {
                CRMDataset ds = new CRMDataset();
                switch (this.cboScope.SelectedItem.ToString())
                {
                case SCOPE_STORES:
                    ds.Merge(CRMGateway.GetStoreDetail(int.Parse(this.cboCompany.SelectedValue.ToString()), int.Parse(this.txtStore.Text)));
                    break;

                case SCOPE_SUBSTORES:
                    ds.Merge(CRMGateway.GetStoreDetail(int.Parse(this.cboCompany.SelectedValue.ToString()), this.txtStore.Text));
                    break;
                }
                if (ds.StoreTable.Rows.Count > 0)
                {
                    this.txtStoreDetail.Text = getStoreDetailString(ds.StoreTable[0]);
                }
            }
        }
示例#26
0
        public DataSet SearchIssuesAdvanced(string agentNumber, object[] criteria)
        {
            //Get issue search data
            DataSet issues = new DataSet();

            try {
                DataSet ds = SearchIssuesAdvanced(criteria);
                if (ds != null)
                {
                    CRMDataset _issues = new CRMDataset();
                    _issues.Merge(ds);
                    if (agentNumber == null)
                    {
                        issues.Merge(_issues.IssueTable.Select("", "LastActionCreated DESC"));
                    }
                    else
                    {
                        issues.Merge(_issues.IssueTable.Select("AgentNumber='" + agentNumber + "'", "LastActionCreated DESC"));
                    }
                }
            }
            catch (Exception ex) { throw new FaultException <CustomersFault>(new CustomersFault(ex.Message), "Service Error"); }
            return(issues);
        }
示例#27
0
        public DataSet ViewIssues(string agentNumber)
        {
            //View issues for the specified agent
            DataSet issues = new DataSet();

            try {
                DataSet ds = ViewIssues();
                if (ds != null)
                {
                    CRMDataset _issues = new CRMDataset();
                    _issues.Merge(ds);
                    if (agentNumber == null)
                    {
                        issues.Merge(_issues.IssueTable.Select("", "LastActionCreated DESC"));
                    }
                    else
                    {
                        issues.Merge(_issues.IssueTable.Select("AgentNumber='" + agentNumber + "'", "LastActionCreated DESC"));
                    }
                }
            }
            catch (Exception ex) { throw new FaultException <CustomersFault>(new CustomersFault(ex.Message), "Service Error"); }
            return(issues);
        }
示例#28
0
        public static CRMDataset GetAgentTerminals(string agentNumber)
        {
            //Get a list of agent terminals for the specified agent
            CRMDataset       terminals = null;
            CRMServiceClient client    = null;

            try {
                ObjectCache cache        = MemoryCache.Default;
                CRMDataset  allTerminals = cache["agentterminals"] as CRMDataset;
                if (allTerminals == null)
                {
                    allTerminals = new CRMDataset();
                    client       = new CRMServiceClient();
                    DataSet ds = client.GetAgentTerminals(null);
                    client.Close();
                    if (ds.Tables["AgentTable"] != null && ds.Tables["AgentTable"].Rows.Count > 0)
                    {
                        allTerminals.Merge(ds);
                    }

                    DateTimeOffset policy = new DateTimeOffset(DateTime.Now.AddMinutes(1440));
                    cache.Set("agentterminals", allTerminals, policy);
                }

                terminals = new CRMDataset();
                if (allTerminals.AgentTable.Rows.Count > 0)
                {
                    terminals.Merge(allTerminals.AgentTable.Select("AgentNumber = '" + agentNumber + "' OR AgentParentNumber = '" + agentNumber + "'", "AgentName ASC"));
                }
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <EnterpriseFault> cfe) { client.Abort(); throw new ApplicationException(cfe.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(terminals);
        }
示例#29
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;
                }
            }
        }
示例#30
0
 //Interface
 public IssueCache(DateTime lastUpdated)
 {
     //Constructor
     this.mIssues      = new CRMDataset();
     this.mLastUpdated = lastUpdated;
 }