示例#1
0
        public int SearchNumRecords()
        {
            try
            {
                List <FlexMLSInfo> items;
                FlexMLSController  controller = new FlexMLSController();

                items = controller.FlexMLS_Search_LastModified(_type.ToString(),
                                                               _town.ToString(),
                                                               _village.ToString(),
                                                               _beds.ToString(),
                                                               _baths.ToString(),
                                                               _waterfrontYN.ToString(),
                                                               _waterviewYN.ToString(),
                                                               _pricelow.ToString(),
                                                               _pricehigh.ToString(), _listingOfficeMLSID.ToString(),
                                                               _dom.ToString(), DateTime.Today.AddDays(-1).ToString("yyyyMMdd"), _complex.ToString().Replace("'", "''"));

                if (items.Count > 0)
                {
                    return(items.Count);
                }
                else
                {
                    return(0);
                }
            }
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
                return(0);
            }
        }
示例#2
0
        public override void DoWork()
        {
            try
            {
                //Perform required items for logging
                this.Progressing();

                //To log note
                this.ScheduleHistoryItem.AddLogNote("<br />Run notes<br />");

                List <FlexMLSInfo> items;
                FlexMLSController  controller = new FlexMLSController();

                items = controller.FlexMLS_Favorites_GetEmailSearches();
                int TotalRecords   = 0;
                int RecordsEmailed = 0;
                for (int i = 0; i <= items.Count - 1; i++)
                {
                    string mySearchCriteria = SearchCriteria(items[i].Favorite.ToString());

                    string myEmailContent = BuildEmailContent(items[i].Favorite.ToString(), mySearchCriteria.ToString());

                    int clientID       = Int32.Parse(items[i].ClientID.ToString());
                    int agentID        = Int32.Parse(items[i].AgentID.ToString());
                    int clientPortalID = Int32.Parse(items[i].ClientPortalID.ToString());

                    int myRecordCount = 0;
                    myRecordCount = SearchNumRecords();
                    if (myRecordCount > 0)
                    {
                        string subject = myRecordCount.ToString() + " Newly Matched MLS Listings";
                        string body    = myEmailContent.ToString();
                        // NEED THE PORTALID HERE INSTEAD OF A ZERO
                        UserInfo _currentUser     = DotNetNuke.Entities.Users.UserController.GetUserById(clientPortalID, clientID);
                        var      notificationType = NotificationsController.Instance.GetNotificationType("HtmlNotification");
                        // NEED THE PORTALID HERE AND AGENTID
                        var sender       = UserController.GetUserById(clientPortalID, agentID);
                        var notification = new Notification {
                            NotificationTypeID = notificationType.NotificationTypeId, Subject = subject, Body = body, IncludeDismissAction = true, SenderUserID = sender.UserID
                        };
                        NotificationsController.Instance.SendNotification(notification, 0, null, new List <UserInfo> {
                            _currentUser
                        });

                        //    FOR DEBUG LOGGING UNCOMMENT NEXT LINE
                        //    this.ScheduleHistoryItem.AddLogNote(_currentUser.DisplayName.ToString() + " - " + mySearchCriteria.ToString() + "<br />");
                        RecordsEmailed += 1;
                    }
                    else
                    {
                        this.ScheduleHistoryItem.AddLogNote("No search records to send.<br />");
                    }

                    TotalRecords += 1;
                }



                string subject1 = "Newly Matched MLS Listings Report - " + RecordsEmailed.ToString() + " Clients";
                string body1    = RecordsEmailed.ToString() + " clients emailed of " + TotalRecords.ToString();

                UserInfo _currentUser1     = DotNetNuke.Entities.Users.UserController.GetUserById(0, 1);
                var      notificationType1 = NotificationsController.Instance.GetNotificationType("HtmlNotification");

                var sender1       = UserController.GetUserById(0, 1);
                var notification1 = new Notification {
                    NotificationTypeID = notificationType1.NotificationTypeId, Subject = subject1, Body = body1, IncludeDismissAction = true, SenderUserID = sender1.UserID
                };
                NotificationsController.Instance.SendNotification(notification1, 0, null, new List <UserInfo> {
                    _currentUser1
                });



                var objEventLog = new EventLogController();
                objEventLog.AddLog("FlexMLS Scheduler", "Results: " + RecordsEmailed.ToString() + " searches emailed of " + TotalRecords.ToString(), EventLogController.EventLogType.ADMIN_ALERT);


                this.ScheduleHistoryItem.AddLogNote("FlexEmailScheduler Results: " + RecordsEmailed.ToString() + " client searches emailed of " + TotalRecords.ToString());
                //Show success
                this.ScheduleHistoryItem.Succeeded = true;
            }
            catch (Exception ex)
            {
                this.ScheduleHistoryItem.Succeeded = false;
                this.ScheduleHistoryItem.AddLogNote("Exception= " + ex.ToString());
                this.Errored(ref ex);
                DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
            }
        }