public List<SubscriptionInfo> Subscription_GetSubscribers(int PortalId, int ForumId, int TopicId, SubscriptionTypes Mode, int AuthorId, string CanSubscribe)
        {
            SubscriptionInfo si;
            var sl = new List<SubscriptionInfo>();
            IDataReader dr = DataProvider.Instance().Subscriptions_GetSubscribers(PortalId, ForumId, TopicId, (int)Mode);
            while (dr.Read())
            {
                if (AuthorId != Convert.ToInt32(dr["UserId"]))
                {
                    si = new SubscriptionInfo
                             {
                                 DisplayName = dr["DisplayName"].ToString(),
                                 Email = dr["Email"].ToString(),
                                 FirstName = dr["FirstName"].ToString(),
                                 LastName = dr["LastName"].ToString(),
                                 UserId = Convert.ToInt32(dr["UserId"]),
                                 Username = dr["Username"].ToString()
                             };

                    if (! (sl.Contains(si)))
                    {
                        if (Permissions.HasPerm(CanSubscribe, si.UserId, PortalId))
                        {
                            sl.Add(si);
                        }
                    }
                }
            }
            dr.Close();
            return sl;
        }
Example #2
0
 public static void Subscribe(ISubscribeable subscriber, SubscriptionTypes subscriptionTypes)
 {
     subscriptions.Add(new Subscription()
     {
         Subscribeable = subscriber, SubscriptionTypes = subscriptionTypes
     });
 }
        public bool Unsubscribe(Guid subscriberId, SubscriptionTypes subscriptionType)
        {
            _logger.Info("Using UnsubscribeStrategy to unsubscribe candidate='{0}' from subscription type='{1}'",
                         subscriberId, subscriptionType);

            return(_unsubscribeStrategy.Unsubscribe(subscriberId, subscriptionType));
        }
Example #4
0
        void subscribe(Socket sock, SubscriptionTypes type, int mIdx)
        {
            mIdx--;             // to zero-based index

            lock (subscriptions) {
                var m = MainForm.Instance.MappingAt(mIdx);
                if (m == null)
                {
                    throw new Exception("No such mapping");
                }

                if (!subscriptions.ContainsKey(sock))
                {
                    subscriptions[sock] = new List <Subscription>();
                }
                var l = subscriptions[sock];

                foreach (var sub in l)
                {
                    if (sub.mappingIndex == mIdx)
                    {
                        // already subscribed
                        if (sub.type != type)
                        {
                            // extend the subscription
                            sub.type = SubscriptionTypes.Both;
                        }
                        return;
                    }
                }

                l.Add(new Subscription(mIdx, type));
            }
        }
Example #5
0
        public MediatorResponse Unsubscribe(Guid?candidateId, Guid subscriberId, SubscriptionTypes subscriptionType)
        {
            var unsubscribed = _candidateServiceProvider.Unsubscribe(subscriberId, subscriptionType);

            if (!unsubscribed)
            {
                return(GetMediatorResponse(UnsubscribeMediatorCodes.Unsubscribe.Error, UnsubscribePageMessages.FailedToUnsubscribe, UserMessageLevel.Error));
            }

            var mediatorCode = UnsubscribeMediatorCodes.Unsubscribe.UnsubscribedNotSignedIn;

            if (!candidateId.HasValue)
            {
                return(GetMediatorResponse(mediatorCode, UnsubscribePageMessages.Unsubscribed, UserMessageLevel.Success));
            }

            switch (subscriptionType)
            {
            case SubscriptionTypes.SavedSearchAlertsViaEmail:
                mediatorCode = UnsubscribeMediatorCodes.Unsubscribe.UnsubscribedShowSavedSearchesSettings;
                break;

            default:
                mediatorCode = UnsubscribeMediatorCodes.Unsubscribe.UnsubscribedShowAccountSettings;
                break;
            }

            return(GetMediatorResponse(mediatorCode, UnsubscribePageMessages.Unsubscribed, UserMessageLevel.Success));
        }
Example #6
0
 public Subscriptions(SubscriptionTypes subscriptionType)
 {
     SubscriptionViewModel.Errors = 0;
     InitializeComponent();
     Messenger.Default.Send <SubscriptionTypes>(subscriptionType);
     Messenger.Reset();
 }
Example #7
0
        public static SubscriptionTypes GetSubscriptionType(DateTypes dateType, int UserId, int ObjectId)
        {
            SubscriptionTypes SubscriptionType = SubscriptionTypes.UNDEFINED;

            using (IDataReader reader = DbSchedule2.GetReminderSubscriptionPersonalForObject((int)dateType, UserId, ObjectId))
            {
                if (reader.Read())
                {
                    SubscriptionType = (SubscriptionTypes)((int)reader["SubscriptionType"]);
                }
            }
            return(SubscriptionType);
        }
Example #8
0
        public void ShouldFailToUnsubscribe()
        {
            var mediator     = new UnsubscribeMediator(_mockCandidateServiceProvider.Object);
            var subscriberId = Guid.NewGuid();

            const SubscriptionTypes subscriptionType = SubscriptionTypes.Unknown;

            _mockCandidateServiceProvider.Setup(mock => mock
                                                .Unsubscribe(subscriberId, subscriptionType))
            .Returns(false);

            // Act.
            var response = mediator.Unsubscribe(null, subscriberId, subscriptionType);

            // Assert.
            response.Should().NotBeNull();
            response.Code.Should().Be(UnsubscribeMediatorCodes.Unsubscribe.Error);
        }
        public async Task UnsubscribeAsync(string pattern, SubscriptionTypes subscriptionType = SubscriptionTypes.Keyspace)
        {
            var baseKey = Activator.CreateInstance <T>().BaseKey;

            if (!pattern.StartsWith(baseKey))
            {
                pattern = baseKey + pattern;
            }

            if (subscriptionType == SubscriptionTypes.Keyspace)
            {
                pattern = "__keyspace@" + DefaultDatabase + "__:" + pattern;
            }

            await CurrentSubscriber.UnsubscribeAsync(pattern, SubscriptionTriggeredResponse, CommandFlags.FireAndForget);

            Subscriptions.Remove(pattern);
        }
Example #10
0
        public void ShouldUnsubscribe(bool isCandidateSignedIn, SubscriptionTypes subscriptionType, string expectedMediatorCode)
        {
            // Arrange.
            var mediator     = new UnsubscribeMediator(_mockCandidateServiceProvider.Object);
            var candidateId  = isCandidateSignedIn ? Guid.NewGuid() : default(Guid?);
            var subscriberId = Guid.NewGuid();

            _mockCandidateServiceProvider.Setup(mock => mock
                                                .Unsubscribe(subscriberId, subscriptionType))
            .Returns(true);

            // Act.
            var response = mediator.Unsubscribe(candidateId, subscriberId, subscriptionType);

            // Assert.
            response.Should().NotBeNull();
            response.Code.Should().Be(expectedMediatorCode);
        }
Example #11
0
        public bool Unsubscribe(Guid subscriberId, SubscriptionTypes subscriptionType)
        {
            var unsubscribed = false;

            try
            {
                var candidate = _candidateReadRepository.GetBySubscriberId(subscriberId);

                switch (subscriptionType)
                {
                case SubscriptionTypes.DailyDigestViaEmail:
                    unsubscribed = UnsubscribeDailyDigestViaEmail(candidate);
                    break;

                case SubscriptionTypes.SavedSearchAlertsViaEmail:
                    unsubscribed = UnsubscribeSavedSearchAlertsViaEmail(candidate);
                    break;

                case SubscriptionTypes.MarketingViaEmail:
                    unsubscribed = UnsubscribeMarketingViaEmail(candidate);
                    break;
                }

                if (unsubscribed)
                {
                    _logger.Info("Unsubscribed subscriptionType='{0}' for subscriberId='{1}'", subscriptionType, subscriberId);
                    _serviceBus.PublishMessage(new CandidateUserUpdate(candidate.EntityId, CandidateUserUpdateType.Update));
                }
                else
                {
                    _logger.Error("Failed to unsubscribe subscriptionType='{0}' for subscriberId='{1}'", subscriptionType, subscriberId);
                }
            }
            catch (Exception e)
            {
                _logger.Error("Error unsubscribing subscriptionType='{0}' for subscriberId='{1}'", e, subscriptionType, subscriberId);
                unsubscribed = false;
            }

            return(unsubscribed);
        }
        public void Subscribe(string pattern, SubscriptionTypes subscriptionType = SubscriptionTypes.Keyspace)
        {
            var baseKey = Activator.CreateInstance <T>().BaseKey;

            if (!pattern.StartsWith(baseKey))
            {
                pattern = baseKey + pattern;
            }

            if (!Subscriptions.Contains(pattern))
            {
                if (subscriptionType == SubscriptionTypes.Keyspace)
                {
                    pattern = "__keyspace@" + DefaultDatabase + "__:" + pattern;
                }

                CurrentSubscriber.Subscribe(pattern, SubscriptionTriggeredResponse, CommandFlags.FireAndForget);

                Subscriptions.Add(pattern);
            }
        }
        public List <SubscriptionInfo> Subscription_GetSubscribers(int PortalId, int ForumId, int TopicId, SubscriptionTypes Mode, int AuthorId, string CanSubscribe)
        {
            SubscriptionInfo si;
            var         sl = new List <SubscriptionInfo>();
            IDataReader dr = DataProvider.Instance().Subscriptions_GetSubscribers(PortalId, ForumId, TopicId, (int)Mode);

            while (dr.Read())
            {
                if (AuthorId != Convert.ToInt32(dr["UserId"]))
                {
                    si = new SubscriptionInfo
                    {
                        DisplayName = dr["DisplayName"].ToString(),
                        Email       = dr["Email"].ToString(),
                        FirstName   = dr["FirstName"].ToString(),
                        LastName    = dr["LastName"].ToString(),
                        UserId      = Convert.ToInt32(dr["UserId"]),
                        Username    = dr["Username"].ToString()
                    };

                    if (!(sl.Contains(si)))
                    {
                        if (Permissions.HasPerm(CanSubscribe, si.UserId, PortalId))
                        {
                            sl.Add(si);
                        }
                    }
                }
            }
            dr.Close();
            return(sl);
        }
        public static void SendSubscriptions(SubscriptionTypes SubscriptionType, DateTime StartDate)
        {
            string sysTemplateName = "DailyDigest";

            if (SubscriptionType == SubscriptionTypes.WeeklyDigest)
            {
                sysTemplateName = "WeeklyDigest";
            }
            var         objRecipients        = new ArrayList();
            IDataReader dr                   = DataProvider.Instance().Subscriptions_GetDigest(Convert.ToString(SubscriptionType), StartDate);
            string      tmpEmail             = string.Empty;
            string      tmpFG                = string.Empty;
            string      sBody                = string.Empty;
            var         sb                   = new System.Text.StringBuilder();
            string      Template             = "";
            string      TemplatePlainText    = "";
            string      TemplateSubject      = "";
            int         tmpModuleId          = 0;
            string      TemplateHeader       = "";
            string      TemplateBody         = "";
            string      TemplateFooter       = "";
            string      TemplateItems        = "";
            string      TemplateGroupSection = "";
            string      ItemsFooter          = "";
            string      Items                = "";
            string      sMessageBody;
            string      FromEmail = string.Empty;
            //Dim newBody As String
            string SubscriberDisplayName = string.Empty;
            string SubscriberUserName    = string.Empty;
            string SubscriberFirstName   = string.Empty;
            string SubscriberLastName    = string.Empty;
            string SubscriberEmail       = string.Empty;

            int i          = 0;
            int GroupCount = 0;

            while (dr.Read())
            {
                SubscriberDisplayName = dr["SubscriberDisplayName"].ToString();
                SubscriberUserName    = dr["SubscriberUserName"].ToString();
                SubscriberFirstName   = dr["SubscriberFirstName"].ToString();
                SubscriberLastName    = dr["SubscriberLastName"].ToString();
                SubscriberEmail       = dr["Email"].ToString();


                //If tmpModuleId <> CInt(dr("ModuleId")) Then
                //    FromEmail = dr("FromEmail").ToString
                //    Dim drTemp As IDataReader = DataProvider.Instance.ActiveForums_GetTemplateBySysName(sysTemplateName, CInt(dr("ModuleId")))
                //    While drTemp.Read
                //        Template = drTemp("Template").ToString & "                     "
                //        'Template = Utilities.ParseSpacer(Template)
                //        'Template = TemplateParser.ResourceParser(Template)
                //        TemplateSubject = drTemp("Subject").ToString
                //        TemplateHeader = Template.Substring(0, Template.IndexOf("[TOPICSECTION]") - 1)
                //        TemplateBody = TemplateUtils.GetTemplateSection("[TOPICSECTION]", "[/TOPICSECTION]", Template)
                //        TemplateGroupSection = TemplateBody.Substring(0, TemplateBody.IndexOf("[TOPICS]") - 1)
                //        TemplateItems = TemplateUtils.GetTemplateSection("[TOPICS]", "[/TOPICS]", TemplateBody)
                //        ItemsFooter = TemplateUtils.GetTemplateSection("[/TOPICS]", "[/TOPICSECTION]", Template)
                //        TemplateFooter = Template.Substring(Template.IndexOf("[/TOPICSECTION]") + 15)
                //    End While
                //    drTemp.Close()
                //    tmpModuleId = CInt(dr("ModuleId"))
                //End If

                string newEmail = dr["Email"].ToString();
                if (i > 0)
                {
                    if (newEmail != tmpEmail)
                    {
                        sMessageBody  = TemplateHeader;
                        sMessageBody += Items + ItemsFooter;
                        sMessageBody += TemplateFooter;
                        Items         = string.Empty;
                        sMessageBody  = sMessageBody.Replace("[SUBSCRIBERDISPLAYNAME]", SubscriberDisplayName);
                        sMessageBody  = sMessageBody.Replace("[SUBSCRIBERUSERNAME]", SubscriberUserName);
                        sMessageBody  = sMessageBody.Replace("[SUBSCRIBERFIRSTNAME]", SubscriberFirstName);
                        sMessageBody  = sMessageBody.Replace("[SUBSCRIBERLASTNAME]", SubscriberLastName);
                        sMessageBody  = sMessageBody.Replace("[SUBSCRIBEREMAIL]", SubscriberEmail);
                        sMessageBody  = sMessageBody.Replace("[DATE]", DateTime.Now.ToString());
                        if ((sMessageBody.IndexOf("[DATE:", 0) + 1) > 0)
                        {
                            string sFormat;
                            int    inStart = (sMessageBody.IndexOf("[DATE:", 0) + 1) + 5;
                            int    inEnd   = (sMessageBody.IndexOf("]", inStart - 1) + 1) - 1;
                            string sValue  = sMessageBody.Substring(inStart, inEnd - inStart);
                            sFormat      = sValue;
                            sMessageBody = sMessageBody.Replace("[DATE:" + sFormat + "]", DateTime.Now.ToString(sFormat));
                        }

                        GroupCount = 0;
                        tmpEmail   = newEmail;
                        Queue.Controller.Add(FromEmail, tmpEmail, TemplateSubject, sMessageBody, "TestPlainText", string.Empty, string.Empty);
                        i = 0;
                    }
                }
                else
                {
                    tmpEmail = dr["Email"].ToString();
                }

                if (tmpFG != dr["GroupName"] + dr["ForumName"].ToString())
                {
                    if (GroupCount > 0)
                    {
                        Items += ItemsFooter;
                    }
                    string sTmpBody = TemplateGroupSection;
                    sTmpBody = sTmpBody.Replace("[TABID]", dr["TabId"].ToString());
                    sTmpBody = sTmpBody.Replace("[PORTALID]", dr["PortalId"].ToString());
                    sTmpBody = sTmpBody.Replace("[GROUPNAME]", dr["GroupName"].ToString());
                    sTmpBody = sTmpBody.Replace("[FORUMNAME]", dr["ForumName"].ToString());
                    sTmpBody = sTmpBody.Replace("[FORUMID]", dr["ForumId"].ToString());
                    sTmpBody = sTmpBody.Replace("[GROUPID]", dr["ForumGroupId"].ToString());
                    Items   += sTmpBody;
                    //sb.Append("<table cellpadding=0 cellspacing=0 width=""100%"">")
                    //sb.Append("<tr><td>" & dr("GroupName").ToString & " > " & dr("ForumName").ToString & "</td></tr>")
                    //tmpFG = dr("GroupName").ToString & dr("ForumName").ToString
                    GroupCount += 1;
                }
                string sTemp = TemplateItems;
                sTemp = sTemp.Replace("[SUBJECT]", dr["Subject"].ToString());
                int intLength = 0;
                if ((sTemp.IndexOf("[BODY:", 0) + 1) > 0)
                {
                    int    inStart = (sTemp.IndexOf("[BODY:", 0) + 1) + 5;
                    int    inEnd   = (sTemp.IndexOf("]", inStart - 1) + 1) - 1;
                    string sLength = sTemp.Substring(inStart, inEnd - inStart);
                    intLength = Convert.ToInt32(sLength);
                }
                string body = dr["Body"].ToString();
                if (intLength > 0)
                {
                    if (body.Length > intLength)
                    {
                        body = body.Substring(0, intLength);
                        body = body + "...";
                    }
                    sTemp = sTemp.Replace("[BODY:" + intLength + "]", body);
                }
                else
                {
                    sTemp = sTemp.Replace("[BODY]", body);
                }
                sTemp = sTemp.Replace("[FORUMID]", dr["ForumId"].ToString());
                sTemp = sTemp.Replace("[POSTID]", dr["PostId"].ToString());
                sTemp = sTemp.Replace("[DISPLAYNAME]", dr["DisplayName"].ToString());
                sTemp = sTemp.Replace("[USERNAME]", dr["UserName"].ToString());
                sTemp = sTemp.Replace("[FIRSTNAME]", dr["FirstName"].ToString());
                sTemp = sTemp.Replace("[LASTNAME]", dr["LASTNAME"].ToString());
                sTemp = sTemp.Replace("[REPLIES]", dr["Replies"].ToString());
                sTemp = sTemp.Replace("[VIEWS]", dr["Views"].ToString());
                sTemp = sTemp.Replace("[TABID]", dr["TabId"].ToString());
                sTemp = sTemp.Replace("[PORTALID]", dr["PortalId"].ToString());



                Items += sTemp;

                i += 1;
            }
            dr.Close();
            dr = null;
            if (Items != "")
            {
                sMessageBody  = TemplateHeader;
                sMessageBody += Items + ItemsFooter;
                sMessageBody += TemplateFooter;
                sMessageBody  = sMessageBody.Replace("[SUBSCRIBERDISPLAYNAME]", SubscriberDisplayName);
                sMessageBody  = sMessageBody.Replace("[SUBSCRIBERUSERNAME]", SubscriberUserName);
                sMessageBody  = sMessageBody.Replace("[SUBSCRIBERFIRSTNAME]", SubscriberFirstName);
                sMessageBody  = sMessageBody.Replace("[SUBSCRIBERLASTNAME]", SubscriberLastName);
                sMessageBody  = sMessageBody.Replace("[SUBSCRIBEREMAIL]", SubscriberEmail);
                sMessageBody  = sMessageBody.Replace("[DATE]", DateTime.Now.ToString());
                if ((sMessageBody.IndexOf("[DATE:", 0) + 1) > 0)
                {
                    string sFormat;
                    int    inStart = (sMessageBody.IndexOf("[DATE:", 0) + 1) + 5;
                    int    inEnd   = (sMessageBody.IndexOf("]", inStart - 1) + 1) - 1;
                    string sValue  = sMessageBody.Substring(inStart, inEnd - inStart);
                    sFormat      = sValue;
                    sMessageBody = sMessageBody.Replace("[DATE:" + sFormat + "]", DateTime.Now.ToString(sFormat));
                }
                Queue.Controller.Add(FromEmail, tmpEmail, TemplateSubject, sMessageBody, "TestPlainText", string.Empty, string.Empty);
            }
        }
        public static bool IsSubscribed(int PortalId, int ModuleId, int ForumId, int TopicId, SubscriptionTypes SubscriptionType, int AuthorId)
        {
            int iSub = DataProvider.Instance().Subscriptions_IsSubscribed(PortalId, ModuleId, ForumId, TopicId, (int)SubscriptionType, AuthorId);

            if (iSub == 0)
            {
                return(false);
            }
            return(true);
        }
        public static void SendSubscriptions(SubscriptionTypes SubscriptionType, DateTime StartDate)
        {
            string sysTemplateName = "DailyDigest";
            if (SubscriptionType == SubscriptionTypes.WeeklyDigest)
            {
                sysTemplateName = "WeeklyDigest";
            }
            var objRecipients = new ArrayList();
            Hashtable objHost = Entities.Portals.PortalSettings.GetHostSettings();
            IDataReader dr = DataProvider.Instance().Subscriptions_GetDigest(Convert.ToString(SubscriptionType), StartDate);
            string tmpEmail = string.Empty;
            string tmpFG = string.Empty;
            string sBody = string.Empty;
            var sb = new System.Text.StringBuilder();
            string Template = "";
            string TemplatePlainText = "";
            string TemplateSubject = "";
            int tmpModuleId = 0;
            string TemplateHeader = "";
            string TemplateBody = "";
            string TemplateFooter = "";
            string TemplateItems = "";
            string TemplateGroupSection = "";
            string ItemsFooter = "";
            string Items = "";
            string sMessageBody;
            string FromEmail = string.Empty;
            //Dim newBody As String
            string SubscriberDisplayName = string.Empty;
            string SubscriberUserName = string.Empty;
            string SubscriberFirstName = string.Empty;
            string SubscriberLastName = string.Empty;
            string SubscriberEmail = string.Empty;

            int i = 0;
            int GroupCount = 0;
            while (dr.Read())
            {
                SubscriberDisplayName = dr["SubscriberDisplayName"].ToString();
                SubscriberUserName = dr["SubscriberUserName"].ToString();
                SubscriberFirstName = dr["SubscriberFirstName"].ToString();
                SubscriberLastName = dr["SubscriberLastName"].ToString();
                SubscriberEmail = dr["Email"].ToString();

                //If tmpModuleId <> CInt(dr("ModuleId")) Then
                //    FromEmail = dr("FromEmail").ToString
                //    Dim drTemp As IDataReader = DataProvider.Instance.ActiveForums_GetTemplateBySysName(sysTemplateName, CInt(dr("ModuleId")))
                //    While drTemp.Read
                //        Template = drTemp("Template").ToString & "                     "
                //        'Template = Utilities.ParseSpacer(Template)
                //        'Template = TemplateParser.ResourceParser(Template)
                //        TemplateSubject = drTemp("Subject").ToString
                //        TemplateHeader = Template.Substring(0, Template.IndexOf("[TOPICSECTION]") - 1)
                //        TemplateBody = TemplateUtils.GetTemplateSection("[TOPICSECTION]", "[/TOPICSECTION]", Template)
                //        TemplateGroupSection = TemplateBody.Substring(0, TemplateBody.IndexOf("[TOPICS]") - 1)
                //        TemplateItems = TemplateUtils.GetTemplateSection("[TOPICS]", "[/TOPICS]", TemplateBody)
                //        ItemsFooter = TemplateUtils.GetTemplateSection("[/TOPICS]", "[/TOPICSECTION]", Template)
                //        TemplateFooter = Template.Substring(Template.IndexOf("[/TOPICSECTION]") + 15)
                //    End While
                //    drTemp.Close()
                //    tmpModuleId = CInt(dr("ModuleId"))
                //End If

                string newEmail = dr["Email"].ToString();
                if (i > 0)
                {
                    if (newEmail != tmpEmail)
                    {
                        sMessageBody = TemplateHeader;
                        sMessageBody += Items + ItemsFooter;
                        sMessageBody += TemplateFooter;
                        Items = string.Empty;
                        sMessageBody = sMessageBody.Replace("[SUBSCRIBERDISPLAYNAME]", SubscriberDisplayName);
                        sMessageBody = sMessageBody.Replace("[SUBSCRIBERUSERNAME]", SubscriberUserName);
                        sMessageBody = sMessageBody.Replace("[SUBSCRIBERFIRSTNAME]", SubscriberFirstName);
                        sMessageBody = sMessageBody.Replace("[SUBSCRIBERLASTNAME]", SubscriberLastName);
                        sMessageBody = sMessageBody.Replace("[SUBSCRIBEREMAIL]", SubscriberEmail);
                        sMessageBody = sMessageBody.Replace("[DATE]", DateTime.Now.ToString());
                        if ((sMessageBody.IndexOf("[DATE:", 0) + 1) > 0)
                        {
                            string sFormat;
                            int inStart = (sMessageBody.IndexOf("[DATE:", 0) + 1) + 5;
                            int inEnd = (sMessageBody.IndexOf("]", inStart - 1) + 1) - 1;
                            string sValue = sMessageBody.Substring(inStart, inEnd - inStart);
                            sFormat = sValue;
                            sMessageBody = sMessageBody.Replace("[DATE:" + sFormat + "]", DateTime.Now.ToString(sFormat));
                        }

                        GroupCount = 0;
                        tmpEmail = newEmail;
                        Queue.Controller.Add(FromEmail, tmpEmail, TemplateSubject, sMessageBody, "TestPlainText", string.Empty, string.Empty);
                        i = 0;
                    }
                }
                else
                {
                    tmpEmail = dr["Email"].ToString();

                }

                if (tmpFG != dr["GroupName"] + dr["ForumName"].ToString())
                {
                    if (GroupCount > 0)
                    {
                        Items += ItemsFooter;
                    }
                    string sTmpBody = TemplateGroupSection;
                    sTmpBody = sTmpBody.Replace("[TABID]", dr["TabId"].ToString());
                    sTmpBody = sTmpBody.Replace("[PORTALID]", dr["PortalId"].ToString());
                    sTmpBody = sTmpBody.Replace("[GROUPNAME]", dr["GroupName"].ToString());
                    sTmpBody = sTmpBody.Replace("[FORUMNAME]", dr["ForumName"].ToString());
                    sTmpBody = sTmpBody.Replace("[FORUMID]", dr["ForumId"].ToString());
                    sTmpBody = sTmpBody.Replace("[GROUPID]", dr["ForumGroupId"].ToString());
                    Items += sTmpBody;
                    //sb.Append("<table cellpadding=0 cellspacing=0 width=""100%"">")
                    //sb.Append("<tr><td>" & dr("GroupName").ToString & " > " & dr("ForumName").ToString & "</td></tr>")
                    //tmpFG = dr("GroupName").ToString & dr("ForumName").ToString
                    GroupCount += 1;
                }
                string sTemp = TemplateItems;
                sTemp = sTemp.Replace("[SUBJECT]", dr["Subject"].ToString());
                int intLength = 0;
                if ((sTemp.IndexOf("[BODY:", 0) + 1) > 0)
                {
                    int inStart = (sTemp.IndexOf("[BODY:", 0) + 1) + 5;
                    int inEnd = (sTemp.IndexOf("]", inStart - 1) + 1) - 1;
                    string sLength = sTemp.Substring(inStart, inEnd - inStart);
                    intLength = Convert.ToInt32(sLength);
                }
                string body = dr["Body"].ToString();
                if (intLength > 0)
                {
                    if (body.Length > intLength)
                    {
                        body = body.Substring(0, intLength);
                        body = body + "...";
                    }
                    sTemp = sTemp.Replace("[BODY:" + intLength + "]", body);
                }
                else
                {
                    sTemp = sTemp.Replace("[BODY]", body);
                }
                sTemp = sTemp.Replace("[FORUMID]", dr["ForumId"].ToString());
                sTemp = sTemp.Replace("[POSTID]", dr["PostId"].ToString());
                sTemp = sTemp.Replace("[DISPLAYNAME]", dr["DisplayName"].ToString());
                sTemp = sTemp.Replace("[USERNAME]", dr["UserName"].ToString());
                sTemp = sTemp.Replace("[FIRSTNAME]", dr["FirstName"].ToString());
                sTemp = sTemp.Replace("[LASTNAME]", dr["LASTNAME"].ToString());
                sTemp = sTemp.Replace("[REPLIES]", dr["Replies"].ToString());
                sTemp = sTemp.Replace("[VIEWS]", dr["Views"].ToString());
                sTemp = sTemp.Replace("[TABID]", dr["TabId"].ToString());
                sTemp = sTemp.Replace("[PORTALID]", dr["PortalId"].ToString());

                Items += sTemp;

                i += 1;
            }
            dr.Close();
            dr = null;
            if (Items != "")
            {
                sMessageBody = TemplateHeader;
                sMessageBody += Items + ItemsFooter;
                sMessageBody += TemplateFooter;
                sMessageBody = sMessageBody.Replace("[SUBSCRIBERDISPLAYNAME]", SubscriberDisplayName);
                sMessageBody = sMessageBody.Replace("[SUBSCRIBERUSERNAME]", SubscriberUserName);
                sMessageBody = sMessageBody.Replace("[SUBSCRIBERFIRSTNAME]", SubscriberFirstName);
                sMessageBody = sMessageBody.Replace("[SUBSCRIBERLASTNAME]", SubscriberLastName);
                sMessageBody = sMessageBody.Replace("[SUBSCRIBEREMAIL]", SubscriberEmail);
                sMessageBody = sMessageBody.Replace("[DATE]", DateTime.Now.ToString());
                if ((sMessageBody.IndexOf("[DATE:", 0) + 1) > 0)
                {
                    string sFormat;
                    int inStart = (sMessageBody.IndexOf("[DATE:", 0) + 1) + 5;
                    int inEnd = (sMessageBody.IndexOf("]", inStart - 1) + 1) - 1;
                    string sValue = sMessageBody.Substring(inStart, inEnd - inStart);
                    sFormat = sValue;
                    sMessageBody = sMessageBody.Replace("[DATE:" + sFormat + "]", DateTime.Now.ToString(sFormat));
                }
                Queue.Controller.Add(FromEmail, tmpEmail, TemplateSubject, sMessageBody, "TestPlainText", string.Empty, string.Empty);
            }
        }
 public static bool IsSubscribed(int PortalId, int ModuleId, int ForumId, int TopicId, SubscriptionTypes SubscriptionType, int AuthorId)
 {
     int iSub = DataProvider.Instance().Subscriptions_IsSubscribed(PortalId, ModuleId, ForumId, TopicId, (int)SubscriptionType, AuthorId);
     if (iSub == 0)
     {
         return false;
     }
     return true;
 }
 public bool Unsubscribe(Guid subscriberId, SubscriptionTypes subscriptionType)
 {
     return(_candidateService.Unsubscribe(subscriberId, subscriptionType));
 }
Example #19
0
 internal Subscription(int i, SubscriptionTypes type)
 {
     mappingIndex = i;
     this.type    = type;
 }
Example #20
0
        public static void ProcessHandler(int handlerId, string argument, int hookId, int?objectId, Guid?objectUid, DateTime dateValue)
        {
            ObjectTypes objectType = ObjectTypes.UNDEFINED;
            DateTypes   dateType   = DateTypes.Undefined;

            if (handlerId == (int)DateTypeHandlers.SendReminder)
            {
                // Напоминать только о тех датах, которые еще не наступили.
                if (dateValue >= DateTime.UtcNow)
                {
                    bool sendReminder = false;

                    int userId = -1;
                    using (IDataReader reader = DbSchedule2.GetReminderSubscriptionByHookId(hookId))
                    {
                        if (reader.Read())
                        {
                            sendReminder = true;

                            if (reader["UserId"] != DBNull.Value)
                            {
                                userId = (int)reader["UserId"];

                                // O.R. [2010-04-01]: Don't process inactive user
                                if (User.GetUserActivity(userId) != User.UserActivity.Active)
                                {
                                    sendReminder = false;
                                }
                            }
                            objectType = (ObjectTypes)reader["ObjectTypeId"];
                            dateType   = (DateTypes)reader["DateTypeId"];
                        }
                    }

                    // Не напоминать о досрочно запущенных или досрочно завершённых объектах [2007-02-16]
                    if (sendReminder)
                    {
                        sendReminder = ConfirmNotification(objectType, dateType, objectId, objectUid);
                    }

                    if (sendReminder)
                    {
                        SubscriptionTypes subscriptionType = (SubscriptionTypes)int.Parse(argument, CultureInfo.InvariantCulture);

                        switch (subscriptionType)
                        {
                        case SubscriptionTypes.Global:
                            ProcessGlobalSubscription(hookId, dateType, objectType, objectId, objectUid);
                            break;

                        case SubscriptionTypes.Personal:
                            ProcessPersonalSubscription(hookId, dateType, userId, objectType, objectId, objectUid);
                            break;

                        case SubscriptionTypes.PersonalForObject:
                            ProcessPersonalSubscriptionForObject(hookId, dateType, userId, objectType, objectId, objectUid);
                            break;
                        }
                    }
                }
            }
            else if (handlerId == (int)DateTypeHandlers.RaiseSystemEvent)
            {
                bool raiseEvent = false;

                using (IDataReader reader = DbSchedule2.GetHook(hookId))
                {
                    if (reader.Read())
                    {
                        raiseEvent = true;

                        objectType = (ObjectTypes)reader["ObjectTypeId"];
                        dateType   = (DateTypes)reader["DateTypeId"];
                    }
                }

                if (raiseEvent)
                {
                    // Не уведомлять о досрочно запущенных или досрочно завершённых объектах [2008-07-29]
                    raiseEvent = ConfirmNotification(objectType, dateType, objectId, objectUid);

                    if (raiseEvent)
                    {
                        SystemEventTypes EventType = (SystemEventTypes)int.Parse(argument);
                        if (objectId.HasValue)
                        {
                            SystemEvents.AddSystemEvents(EventType, objectId.Value);
                        }
                        else if (objectUid.HasValue)
                        {
                            SystemEvents.AddSystemEvents(EventType, objectUid.Value);
                        }
                    }

                    if (objectType == ObjectTypes.Task)
                    {
                        Task.RecalculateAllStates(Task.GetProject(objectId.Value));
                    }
                    else if (objectType == ObjectTypes.ToDo)
                    {
                        ToDo.RecalculateState(objectId.Value);
                    }
                    else if (objectType == ObjectTypes.CalendarEntry)
                    {
                        CalendarEntry.RecalculateState(objectId.Value);
                    }
                }
            }
            else if (handlerId == (int)DateTypeHandlers.BatchAlert)
            {
                if (objectId.HasValue)
                {
                    Alerts2.SendBatch(objectId.Value, dateValue);
                }
            }
            else if (handlerId == (int)DateTypeHandlers.LdapSync)
            {
                if (objectId.HasValue)
                {
                    Ldap.Synchronize(objectId.Value, dateValue);
                }
            }
        }