コード例 #1
0
        public void SendAboutAddRelationshipEventAdd(RelationshipEvent entity,
                                                     Hashtable fileListInfoHashtable, params Guid[] userID)
        {
            if (userID.Length == 0)
            {
                return;
            }

            NameValueCollection baseEntityData;

            if (entity.EntityID != 0)
            {
                baseEntityData = ExtractBaseDataFrom(entity.EntityType, entity.EntityID);
            }
            else
            {
                var contact = Global.DaoFactory.GetContactDao().GetByID(entity.ContactID);

                baseEntityData                      = new NameValueCollection();
                baseEntityData["title"]             = contact.GetTitle();
                baseEntityData["id"]                = contact.ID.ToString();
                baseEntityData["entityRelativeURL"] = "default.aspx?id=" + contact.ID;

                if (contact is Person)
                {
                    baseEntityData["entityRelativeURL"] += "&type=people";
                }

                baseEntityData["entityRelativeURL"] = String.Concat(PathProvider.BaseAbsolutePath,
                                                                    baseEntityData["entityRelativeURL"]);
            }

            client.BeginSingleRecipientEvent("send about add relationship event add");

            var interceptor = new InitiatorInterceptor(new DirectRecipient(ASC.Core.SecurityContext.CurrentAccount.ID.ToString(), ""));

            client.AddInterceptor(interceptor);

            try
            {
                client.SendNoticeToAsync(
                    NotifyConstants.Event_AddRelationshipEvent,
                    null,
                    userID.Select(item => ToRecipient(item)).ToArray(),
                    true,
                    new TagValue(NotifyConstants.Tag_EntityTitle, baseEntityData["title"]),
                    new TagValue(NotifyConstants.Tag_EntityID, baseEntityData["id"]),
                    new TagValue(NotifyConstants.Tag_EntityRelativeURL, baseEntityData["entityRelativeURL"]),
                    new TagValue(NotifyConstants.Tag_AdditionalData,
                                 new Hashtable {
                    { "Files", fileListInfoHashtable },
                    { "EventContent", entity.Content }
                }));
            }
            finally
            {
                client.RemoveInterceptor(interceptor.Name);
                client.EndSingleRecipientEvent("send about add relationship event add");
            }
        }
コード例 #2
0
        public void SendNewComment(ProjectEntity entity, Comment comment)
        {
            INotifyAction action;

            if (entity.GetType() == typeof(Issue))
            {
                action = NotifyConstants.Event_NewCommentForIssue;
            }
            else if (entity.GetType() == typeof(Message))
            {
                action = NotifyConstants.Event_NewCommentForMessage;
            }
            else if (entity.GetType() == typeof(Milestone))
            {
                action = NotifyConstants.Event_NewCommentForMilestone;
            }
            else if (entity.GetType() == typeof(Task))
            {
                action = NotifyConstants.Event_NewCommentForTask;
            }
            else
            {
                return;
            }

            var interceptor = new InitiatorInterceptor(new DirectRecipient(SecurityContext.CurrentAccount.ID.ToString(), ""));

            try
            {
                client.AddInterceptor(interceptor);
                client.SendNoticeAsync(
                    action,
                    entity.NotifyId,
                    null,
                    new TagValue(NotifyConstants.Tag_ProjectID, entity.Project.ID),
                    new TagValue(NotifyConstants.Tag_ProjectTitle, entity.Project.Title),
                    new TagValue(NotifyConstants.Tag_EntityTitle, entity.Title),
                    new TagValue(NotifyConstants.Tag_EntityID, entity.ID),
                    new TagValue(NotifyConstants.Tag_AdditionalData, comment.Content),
                    GetReplyToEntityTag(entity, comment));
            }
            finally
            {
                client.RemoveInterceptor(interceptor.Name);
            }
        }
コード例 #3
0
        /// <summary>
        /// notify user about his password changed
        /// </summary>
        public void UserPasswordChanged(Guid userID, string password)
        {
            UserInfo Author      = null;
            UserInfo newUserInfo = CoreContext.UserManager.GetUsers(userID);

            if (CoreContext.UserManager.UserExists(SecurityContext.CurrentAccount.ID))
            {
                Author = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);
            }

            ISendInterceptor initInterceptor = null;

            if (Author != null)
            {
                initInterceptor = new InitiatorInterceptor(new[] { UserInfoAsRecipient(Author) });
                client.AddInterceptor(initInterceptor);
            }

            client.SendNoticeToAsync(
                Constants.ActionPasswordChanged,
                null,
                new[] { UserInfoAsRecipient(newUserInfo) },
                new[] { EMailSenderName },
                null,
                new TagValue(Constants.TagUserName, newUserInfo.DisplayUserName()),
                new TagValue(Constants.TagUserEmail, newUserInfo.Email),
                new TagValue(Constants.TagMyStaffLink, GetMyStaffLink()),
                new TagValue(Constants.TagPassword, password)
                );


            if (initInterceptor != null)
            {
                client.RemoveInterceptor(initInterceptor.Name);
            }
        }
コード例 #4
0
        private static void NotifyClientRegisterCallback(Context context, INotifyClient client)
        {
            #region url correction

            var absoluteUrl = new SendInterceptorSkeleton(
                "Web.UrlAbsoluter",
                InterceptorPlace.MessageSend,
                InterceptorLifetime.Global,
                (r, p) =>
            {
                if (r != null && r.CurrentMessage != null && r.CurrentMessage.ContentType == Pattern.HTMLContentType)
                {
                    var body = r.CurrentMessage.Body;

                    body = urlReplacer.Replace(body, m =>
                    {
                        var url = m.Groups["url"].Value;
                        var ind = m.Groups["url"].Index - m.Index;
                        return(string.IsNullOrEmpty(url) && ind > 0 ?
                               m.Value.Insert(ind, CommonLinkUtility.GetFullAbsolutePath(string.Empty)) :
                               m.Value.Replace(url, CommonLinkUtility.GetFullAbsolutePath(url)));
                    });

                    body = textileLinkReplacer.Replace(body, m =>
                    {
                        var url = m.Groups["link"].Value;
                        var ind = m.Groups["link"].Index - m.Index;
                        return(string.IsNullOrEmpty(url) && ind > 0 ?
                               m.Value.Insert(ind, CommonLinkUtility.GetFullAbsolutePath(string.Empty)) :
                               m.Value.Replace(url, CommonLinkUtility.GetFullAbsolutePath(url)));
                    });

                    r.CurrentMessage.Body = body;
                }
                return(false);
            });
            client.AddInterceptor(absoluteUrl);

            #endregion

            #region security and culture

            var securityAndCulture = new SendInterceptorSkeleton(
                "ProductSecurityInterceptor",
                InterceptorPlace.DirectSend,
                InterceptorLifetime.Global,
                (r, p) =>
            {
                try
                {
                    // culture
                    var u = ASC.Core.Users.Constants.LostUser;

                    if (32 <= r.Recipient.ID.Length)
                    {
                        var guid = default(Guid);
                        try
                        {
                            guid = new Guid(r.Recipient.ID);
                        }
                        catch (FormatException) { }
                        catch (OverflowException) { }

                        if (guid != default(Guid))
                        {
                            u = CoreContext.UserManager.GetUsers(guid);
                        }
                    }

                    if (ASC.Core.Users.Constants.LostUser.Equals(u))
                    {
                        u = CoreContext.UserManager.GetUserByEmail(r.Recipient.ID);
                    }

                    if (ASC.Core.Users.Constants.LostUser.Equals(u))
                    {
                        u = CoreContext.UserManager.GetUserByUserName(r.Recipient.ID);
                    }

                    if (!ASC.Core.Users.Constants.LostUser.Equals(u))
                    {
                        var culture = !string.IsNullOrEmpty(u.CultureName) ? u.GetCulture() : CoreContext.TenantManager.GetCurrentTenant().GetCulture();
                        Thread.CurrentThread.CurrentCulture   = culture;
                        Thread.CurrentThread.CurrentUICulture = culture;

                        // security
                        var tag       = r.Arguments.Find(a => a.Tag == CommonTags.ModuleID);
                        var productId = tag != null ? (Guid)tag.Value : Guid.Empty;
                        if (productId == Guid.Empty)
                        {
                            tag       = r.Arguments.Find(a => a.Tag == CommonTags.ProductID);
                            productId = tag != null ? (Guid)tag.Value : Guid.Empty;
                        }
                        if (productId == Guid.Empty)
                        {
                            productId = (Guid)(CallContext.GetData("asc.web.product_id") ?? Guid.Empty);
                        }
                        if (productId != Guid.Empty && productId != new Guid("f4d98afdd336433287783c6945c81ea0") /* ignore people product */)
                        {
                            return(!WebItemSecurity.IsAvailableForUser(productId.ToString(), u.ID));
                        }
                    }

                    var tagCulture = r.Arguments.FirstOrDefault(a => a.Tag == CommonTags.Culture);
                    if (tagCulture != null)
                    {
                        var culture = CultureInfo.GetCultureInfo((string)tagCulture.Value);
                        Thread.CurrentThread.CurrentCulture   = culture;
                        Thread.CurrentThread.CurrentUICulture = culture;
                    }
                }
                catch (Exception error)
                {
                    LogManager.GetLogger(typeof(NotifyConfiguration)).Error(error);
                }
                return(false);
            });
            client.AddInterceptor(securityAndCulture);

            #endregion

            #region white label correction

            var whiteLabel = new SendInterceptorSkeleton(
                "WhiteLabelInterceptor",
                InterceptorPlace.MessageSend,
                InterceptorLifetime.Global,
                (r, p) =>
            {
                try
                {
                    var tags = r.Arguments;

                    var logoTextTag   = tags.FirstOrDefault(a => a.Tag == Constants.LetterLogoText);
                    var logoTextTagTM = tags.FirstOrDefault(a => a.Tag == Constants.LetterLogoTextTM);

                    var logoText   = logoTextTag != null ? (String)logoTextTag.Value : string.Empty;
                    var logoTextTM = logoTextTagTM != null ? (String)logoTextTagTM.Value : string.Empty;

                    if (!string.IsNullOrEmpty(logoText) && !string.IsNullOrEmpty(logoTextTM))
                    {
                        var body = r.CurrentMessage.Body
                                   .Replace(string.Format("${{{0}}}", Constants.LetterLogoTextTM), logoTextTM)
                                   .Replace(string.Format("${{{0}}}", Constants.LetterLogoText), logoText);
                        r.CurrentMessage.Body = body;
                    }
                }
                catch (Exception error)
                {
                    LogManager.GetLogger(typeof(NotifyConfiguration)).Error(error);
                }
                return(false);
            });
            client.AddInterceptor(whiteLabel);

            #endregion
        }
コード例 #5
0
        public static void NotifyClientRegisterCallback(Context context, INotifyClient client)
        {
            client.SetStaticTags(_CommonTags);

            client.AddInterceptor(
                new SendInterceptorSkeleton(
                    "Web.UrlAbsoluter",
                    InterceptorPlace.MessageSend,
                    InterceptorLifetime.Global,
                    (nreq, place) =>
            {
                if (nreq != null && nreq.CurrentMessage != null && nreq.CurrentMessage.ContentType == Pattern.HTMLContentType)
                {
                    DoNotifyRequestAbsoluteUrl(nreq.CurrentMessage);
                }
                return(false);
            }
                    )
                );

            var productSecurityAndCulture = new SendInterceptorSkeleton(
                "ProductSecurityInterceptor",
                InterceptorPlace.DirectSend,
                InterceptorLifetime.Global,
                (r, p) =>
            {
                var u = ASC.Core.Users.Constants.LostUser;
                try
                {
                    if (32 <= r.Recipient.ID.Length)
                    {
                        var guid = default(Guid);
                        try
                        {
                            guid = new Guid(r.Recipient.ID);
                        }
                        catch (FormatException) { }
                        catch (OverflowException) { }

                        if (guid != default(Guid))
                        {
                            u = CoreContext.UserManager.GetUsers(guid);
                        }
                    }

                    if (ASC.Core.Users.Constants.LostUser.Equals(u))
                    {
                        u = CoreContext.UserManager.GetUserByEmail(r.Recipient.ID);
                    }

                    if (ASC.Core.Users.Constants.LostUser.Equals(u))
                    {
                        u = CoreContext.UserManager.GetUserByUserName(r.Recipient.ID);
                    }

                    if (!ASC.Core.Users.Constants.LostUser.Equals(u))
                    {
                        var culture = !string.IsNullOrEmpty(u.CultureName) ?
                                      u.GetCulture() :
                                      CoreContext.TenantManager.GetCurrentTenant().GetCulture();
                        Thread.CurrentThread.CurrentCulture   = culture;
                        Thread.CurrentThread.CurrentUICulture = culture;
                    }
                }
                catch (Exception error)
                {
                    LogManager.GetLogger(typeof(WorkContext)).Error(error);
                }

                if (r.Properties.ContainsKey("asc.web.product_id"))
                {
                    var pid    = (Guid)r.Properties["asc.web.product_id"];
                    var userid = Guid.Empty;
                    try
                    {
                        userid = new Guid(r.Recipient.ID);
                    }
                    catch { }
                    if (pid != Guid.Empty && !ASC.Core.Users.Constants.LostUser.Equals(u))
                    {
                        return(!WebItemSecurity.IsAvailableForUser(pid.ToString(), u.ID));
                    }
                }
                return(false);
            });

            client.AddInterceptor(productSecurityAndCulture);
        }
コード例 #6
0
        public static void NotifyClientRegisterCallback(Context context, INotifyClient client)
        {
            client.SetStaticTags(_CommonTags);

            client.AddInterceptor(
                    new SendInterceptorSkeleton(
                        "Web.UrlAbsoluter",
                        InterceptorPlace.MessageSend,
                        InterceptorLifetime.Global,
                        (nreq, place) =>
                        {
                            if (nreq != null && nreq.CurrentMessage != null && nreq.CurrentMessage.ContentType == Pattern.HTMLContentType)
                                DoNotifyRequestAbsoluteUrl(nreq.CurrentMessage);
                            return false;
                        }
                        )
                    );

            var productSecurityAndCulture = new SendInterceptorSkeleton(
                "ProductSecurityInterceptor",
                 InterceptorPlace.DirectSend,
                 InterceptorLifetime.Global,
                 (r, p) =>
                 {
                     var u = ASC.Core.Users.Constants.LostUser;
                     try
                     {
                         if (32 <= r.Recipient.ID.Length)
                         {
                             var guid = default(Guid);
                             try
                             {
                                 guid = new Guid(r.Recipient.ID);
                             }
                             catch (FormatException) { }
                             catch (OverflowException) { }

                             if (guid != default(Guid))
                             {
                                 u = CoreContext.UserManager.GetUsers(guid);
                             }
                         }

                         if (ASC.Core.Users.Constants.LostUser.Equals(u))
                         {
                             u = CoreContext.UserManager.GetUserByEmail(r.Recipient.ID);
                         }

                         if (ASC.Core.Users.Constants.LostUser.Equals(u))
                         {
                             u = CoreContext.UserManager.GetUserByUserName(r.Recipient.ID);
                         }

                         if (!ASC.Core.Users.Constants.LostUser.Equals(u))
                         {
                             var culture = !string.IsNullOrEmpty(u.CultureName) ?
                                 u.GetCulture() :
                                 CoreContext.TenantManager.GetCurrentTenant().GetCulture();
                             Thread.CurrentThread.CurrentCulture = culture;
                             Thread.CurrentThread.CurrentUICulture = culture;
                         }
                     }
                     catch (Exception error)
                     {
                         LogManager.GetLogger(typeof(WorkContext)).Error(error);
                     }

                     if (r.Properties.ContainsKey("asc.web.product_id"))
                     {
                         var pid = (Guid)r.Properties["asc.web.product_id"];
                         var userid = Guid.Empty;
                         try
                         {
                             userid = new Guid(r.Recipient.ID);
                         }
                         catch { }
                         if (pid != Guid.Empty && !ASC.Core.Users.Constants.LostUser.Equals(u))
                         {
                             return !WebItemSecurity.IsAvailableForUser(pid.ToString(), u.ID);
                         }
                     }
                     return false;
                 });
            client.AddInterceptor(productSecurityAndCulture);
        }
コード例 #7
0
        private static void NotifyClientRegisterCallback(Context context, INotifyClient client)
        {
            var absoluteUrl = new SendInterceptorSkeleton(
                "Web.UrlAbsoluter",
                InterceptorPlace.MessageSend,
                InterceptorLifetime.Global,
                (r, p) =>
                {
                    if (r != null && r.CurrentMessage != null && r.CurrentMessage.ContentType == Pattern.HTMLContentType)
                    {
                        var body = r.CurrentMessage.Body;

                        body = urlReplacer.Replace(body, m =>
                        {
                            var url = m.Groups["url"].Value;
                            var ind = m.Groups["url"].Index - m.Index;
                            return string.IsNullOrEmpty(url) && ind > 0 ?
                                m.Value.Insert(ind, CommonLinkUtility.GetFullAbsolutePath(string.Empty)) :
                                m.Value.Replace(url, CommonLinkUtility.GetFullAbsolutePath(url));
                        });

                        body = textileLinkReplacer.Replace(body, m =>
                        {
                            var url = m.Groups["link"].Value;
                            var ind = m.Groups["link"].Index - m.Index;
                            return string.IsNullOrEmpty(url) && ind > 0 ?
                                m.Value.Insert(ind, CommonLinkUtility.GetFullAbsolutePath(string.Empty)) :
                                m.Value.Replace(url, CommonLinkUtility.GetFullAbsolutePath(url));
                        });

                        r.CurrentMessage.Body = body;
                    }
                    return false;
                });
            client.AddInterceptor(absoluteUrl);

            var securityAndCulture = new SendInterceptorSkeleton(
                "ProductSecurityInterceptor",
                 InterceptorPlace.DirectSend,
                 InterceptorLifetime.Global,
                 (r, p) =>
                 {
                     try
                     {
                         // culture
                         var u = ASC.Core.Users.Constants.LostUser;

                         if (32 <= r.Recipient.ID.Length)
                         {
                             var guid = default(Guid);
                             try
                             {
                                 guid = new Guid(r.Recipient.ID);
                             }
                             catch (FormatException) { }
                             catch (OverflowException) { }

                             if (guid != default(Guid))
                             {
                                 u = CoreContext.UserManager.GetUsers(guid);
                             }
                         }

                         if (ASC.Core.Users.Constants.LostUser.Equals(u))
                         {
                             u = CoreContext.UserManager.GetUserByEmail(r.Recipient.ID);
                         }

                         if (ASC.Core.Users.Constants.LostUser.Equals(u))
                         {
                             u = CoreContext.UserManager.GetUserByUserName(r.Recipient.ID);
                         }

                         if (!ASC.Core.Users.Constants.LostUser.Equals(u))
                         {
                             var culture = !string.IsNullOrEmpty(u.CultureName) ? u.GetCulture() : CoreContext.TenantManager.GetCurrentTenant().GetCulture();
                             Thread.CurrentThread.CurrentCulture = culture;
                             Thread.CurrentThread.CurrentUICulture = culture;

                             // security
                             var tag = r.Arguments.Find(a => a.Tag == CommonTags.ModuleID);
                             var productId = tag != null ? (Guid)tag.Value : Guid.Empty;
                             if (productId == Guid.Empty)
                             {
                                 tag = r.Arguments.Find(a => a.Tag == CommonTags.ProductID);
                                 productId = tag != null ? (Guid)tag.Value : Guid.Empty;
                             }
                             if (productId == Guid.Empty)
                             {
                                 productId = (Guid)(CallContext.GetData("asc.web.product_id") ?? Guid.Empty);
                             }
                             if (productId != Guid.Empty && productId != new Guid("f4d98afdd336433287783c6945c81ea0") /* ignore people product */)
                             {
                                 return !WebItemSecurity.IsAvailableForUser(productId.ToString(), u.ID);
                             }
                         }
                     }
                     catch (Exception error)
                     {
                         LogManager.GetLogger(typeof(NotifyConfiguration)).Error(error);
                     }
                     return false;
                 });
            client.AddInterceptor(securityAndCulture);
        }
コード例 #8
0
ファイル: NotifyClient.cs プロジェクト: sainabob/teamlab.v7.5
        public void SendAboutResponsibleByTask(IEnumerable <Guid> recipients, Task task)
        {
            var interceptor = new InitiatorInterceptor(new DirectRecipient(SecurityContext.CurrentAccount.ID.ToString(), ""));

            client.AddInterceptor(interceptor);
            try
            {
                client.SendNoticeToAsync(
                    NotifyConstants.Event_ResponsibleForTask,
                    task.NotifyId,
                    recipients.Select(ToRecipient).Where(r => r != null).ToArray(),
                    true,
                    new TagValue(NotifyConstants.Tag_ProjectID, task.Project.ID),
                    new TagValue(NotifyConstants.Tag_ProjectTitle, task.Project.Title),
                    new TagValue(NotifyConstants.Tag_EntityTitle, task.Title),
                    new TagValue(NotifyConstants.Tag_EntityID, task.ID),
                    new TagValue(NotifyConstants.Tag_AdditionalData, new Hashtable {
                    { "TaskDescription", HttpUtility.HtmlEncode(task.Description) }
                }),
                    ReplyToTagProvider.Comment("project.task", task.ID.ToString(CultureInfo.InvariantCulture)),
                    new AdditionalSenderTag("push.sender"),
                    new TagValue(PushConstants.PushItemTagName, new PushItem(PushItemType.Task, task.ID.ToString(), task.Title)),
                    new TagValue(PushConstants.PushParentItemTagName, new PushItem(PushItemType.Project, task.Project.ID.ToString(), task.Project.Title)),
                    new TagValue(PushConstants.PushModuleTagName, PushModule.Projects),
                    new TagValue(PushConstants.PushActionTagName, PushAction.Assigned));
            }
            finally
            {
                client.RemoveInterceptor(interceptor.Name);
            }
        }