Exemple #1
0
 public static SiteUrls GetSiteUrls()
 {
     if (instance == null)
     {
         lock (lockHelper)
         {
             if (instance == null)
             {
                 instance = new SiteUrls();
             }
         }
     }
     return instance;
 }
Exemple #2
0
 public static SiteUrls GetSiteUrls()
 {
     return(SiteUrls.Instance());
 }
Exemple #3
0
        public ActionResult _Invite(string spaceKey, string userIds, string remark)
        {
            StatusMessageData message             = null;
            string            unInviteFriendNames = string.Empty;
            GroupEntity       group = groupService.Get(spaceKey);


            if (group == null)
            {
                return(Json(new StatusMessageData(StatusMessageType.Error, "找不到群组!")));
            }

            //在显示时做了判断
            //已修改
            IUser currentUser = UserContext.CurrentUser;

            List <long> couldBeInvetedUserIds = new List <long>();
            //被邀请人的隐私设置
            IEnumerable <long> inviteUserIds = Request.Form.Gets <long>("userIds", null);
            int count = 0;

            foreach (long inviteUserId in inviteUserIds)
            {
                if (!privacyService.Validate(inviteUserId, currentUser != null ? currentUser.UserId : 0, PrivacyItemKeys.Instance().Invitation()))
                {
                    User user = userService.GetFullUser(inviteUserId);
                    unInviteFriendNames += user.DisplayName + ",";
                }
                else
                {
                    count++;
                    couldBeInvetedUserIds.Add(inviteUserId);
                }
            }



            if (currentUser == null)
            {
                return(Json(new StatusMessageData(StatusMessageType.Error, "您尚未登录!")));
            }

            if (!authorizer.Group_Invite(group))
            {
                return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel
                {
                    Body = "没有邀请好友的权限!",
                    Title = "没有权限",
                    StatusMessageType = StatusMessageType.Hint
                })));
            }

            if (!string.IsNullOrEmpty(userIds))
            {
                //已修改

                IEnumerable <long> ids = Request.Form.Gets <long>("userIds", null);
                if (ids != null && ids.Count() > 0)
                {
                    groupService.SendInvitations(group, currentUser, remark, couldBeInvetedUserIds);
                    if (count < ids.Count())
                    {
                        message = new StatusMessageData(StatusMessageType.Hint, "共有" + count + "个好友邀请成功," + unInviteFriendNames.Substring(0, unInviteFriendNames.Count() - 1) + "不能被邀请!");
                    }
                    else
                    {
                        message = new StatusMessageData(StatusMessageType.Success, "邀请好友成功!");
                    }
                }
                else
                {
                    message = new StatusMessageData(StatusMessageType.Hint, "您尚未选择好友!");
                }
            }
            return(Json(message));
        }
Exemple #4
0
        public override void ProcessRequest(HttpContext context)
        {
            long attachmentId = context.Request.QueryString.Get <long>("attachmentId", 0);

            if (attachmentId <= 0)
            {
                WebUtility.Return404(context);
                return;
            }

            string tenantTypeId = context.Request.QueryString.Get <string>("tenantTypeId", null);

            if (string.IsNullOrEmpty(tenantTypeId))
            {
                WebUtility.Return404(context);
                return;
            }
            AttachmentService <Attachment> attachmentService = new AttachmentService <Attachment>(tenantTypeId);
            Attachment attachment = attachmentService.Get(attachmentId);

            if (attachment == null)
            {
                WebUtility.Return404(context);
                return;
            }

            IUser currentUser = UserContext.CurrentUser;

            //判断是否有附件的购买权限或下载权限,有下载权限肯定有购买权限,目前只有未登录或积分不够时才判定为没有权限
            if (!new Authorizer().Attachment_Buy(attachment))
            {
                WebUtility.Return403(context);
                return;
            }

            //如果还没有下载权限,则说明积分可以支付附件售价,但是还未购买,则先进行积分交易
            if (!new Authorizer().Attachment_Download(attachment))
            {
                //积分交易
                PointService pointService = new PointService();
                pointService.Trade(currentUser.UserId, attachment.UserId, attachment.Price, string.Format("购买附件{0}", attachment.FriendlyFileName), true);
            }

            //创建下载记录
            AttachmentDownloadService attachmentDownloadService = new AttachmentDownloadService();

            attachmentDownloadService.Create(currentUser == null ? 0 : currentUser.UserId, attachment.AttachmentId);

            //下载计数
            CountService countService = new CountService(TenantTypeIds.Instance().Attachment());

            countService.ChangeCount(CountTypes.Instance().DownloadCount(), attachment.AttachmentId, attachment.UserId, 1, false);

            bool enableCaching = context.Request.QueryString.GetBool("enableCaching", true);

            context.Response.Status     = "302 Object Moved";
            context.Response.StatusCode = 302;

            LinktimelinessSettings linktimelinessSettings = DIContainer.Resolve <ILinktimelinessSettingsManager>().Get();
            string token = Utility.EncryptTokenForAttachmentDownload(linktimelinessSettings.Highlinktimeliness, attachmentId);

            context.Response.Headers.Add("Location", SiteUrls.Instance().AttachmentTempUrl(attachment.AttachmentId, tenantTypeId, token, enableCaching));

            context.Response.Flush();
            context.Response.End();
        }
        public ActionResult EditSection(BarSectionEditModel model)
        {
            HttpPostedFileBase logoImage         = Request.Files["LogoImage"];
            string             logoImageFileName = string.Empty;
            Stream             stream            = null;

            if (logoImage != null && !string.IsNullOrEmpty(logoImage.FileName))
            {
                TenantLogoSettings tenantLogoSettings = TenantLogoSettings.GetRegisteredSettings(TenantTypeIds.Instance().BarSection());
                if (!tenantLogoSettings.ValidateFileLength(logoImage.ContentLength))
                {
                    ViewData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Error, string.Format("Logo文件大小不允许超过{0}", Formatter.FormatFriendlyFileSize(tenantLogoSettings.MaxLogoLength * 1024)));
                    return(View(model));
                }

                LogoSettings logoSettings = DIContainer.Resolve <ILogoSettingsManager>().Get();
                if (!logoSettings.ValidateFileExtensions(logoImage.FileName))
                {
                    ViewData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Error, "Logo文件是不支持的文件类型,仅支持" + logoSettings.AllowedFileExtensions);
                    return(View(model));
                }
                stream            = logoImage.InputStream;
                logoImageFileName = logoImage.FileName;
            }


            IEnumerable <long> managerUserIds = Request.Form.Gets <long>("ManagerUserIds");

            if (model.SectionId == 0)
            {
                BarSection section = model.AsBarSection();

                //long userId = Request.QueryString.Gets<long>(model.UserId, new List<long>()).FirstOrDefault();


                section.UserId = Request.Form.Gets <long>("UserId", new List <long>()).FirstOrDefault();
                if (section.UserId == 0)
                {
                    ViewData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Error, "请输入吧主信息");
                    return(View(model));
                }
                section.LogoImage    = logoImageFileName;
                section.DisplayOrder = model.DisplayOrder ?? 100;
                if (managerUserIds != null && managerUserIds.Count() > 0)
                {
                    managerUserIds = managerUserIds.Where(n => n != section.UserId);
                }

                bool isCreated = barSectionService.Create(section, UserContext.CurrentUser.UserId, managerUserIds, stream);

                categoryService.AddItemsToCategory(new List <long> {
                    section.SectionId
                }, model.CategoryId, 0);

                if (isCreated)
                {
                    TempData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Success, "创建成功");
                    return(Redirect(SiteUrls.Instance().EditSection(section.SectionId)));
                }
                ViewData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Error, "创建失败");
                return(View(model));
            }
            else
            {
                BarSection section = model.AsBarSection();



                long userId = Request.Form.Gets <long>("UserId", new List <long>()).FirstOrDefault();
                if (userId == 0)
                {
                    ViewData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Error, "必须输入吧主信息");
                    ViewData["ManagerUserIds"]    = barSectionService.GetSectionManagers(section.SectionId).Select(n => n.UserId);
                    IBarSettingsManager manager  = DIContainer.Resolve <IBarSettingsManager>();
                    BarSettings         settings = manager.Get();
                    ViewData["SectionManagerMaxCount"] = settings.SectionManagerMaxCount;
                    return(View(model));
                }
                section.UserId = userId;
                if (!string.IsNullOrEmpty(logoImageFileName))
                {
                    section.LogoImage = logoImageFileName;
                }
                section.DisplayOrder = model.DisplayOrder ?? 100;
                barSectionService.Update(section, UserContext.CurrentUser.UserId, managerUserIds, stream);
                categoryService.ClearCategoriesFromItem(section.SectionId, 0, TenantTypeIds.Instance().BarSection());
                categoryService.AddItemsToCategory(new List <long> {
                    section.SectionId
                }, model.CategoryId, 0);

                TempData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Success, "更新成功");
                return(Redirect(SiteUrls.Instance().EditSection(model.SectionId)));
            }
        }
Exemple #6
0
 /// <summary>
 /// 处理当前应用搜索的URL
 /// </summary>
 /// <param name="keyword">搜索关键词</param>
 /// <returns></returns>
 public string PageSearchActionUrl(string keyword)
 {
     return(SiteUrls.Instance().WikiPageSearch(keyword));
 }
        /// <summary>
        /// 重写Url
        /// </summary>
        /// <param name="sender">事件的源</param>
        /// <param name="e">包含事件数据的 EventArgs</param>
        private void ReUrl_BeginRequest(object sender, EventArgs e)
        {
            BaseConfigInfo baseconfig = BaseConfigProvider.Instance();

            if (baseconfig == null)
            {
                return;
            }
            GeneralConfigInfo config       = GeneralConfigs.GetConfig();
            HttpContext       context      = ((HttpApplication)sender).Context;
            string            sysPath      = baseconfig.Syspath.ToLower();
            string            requestValue = context.Request.QueryString.ToString();
            string            requestPath  = context.Request.Path.ToString();
            // 当前样式
            string strTemplateid = "1";

            if (requestPath.ToLower().StartsWith(sysPath))
            {
                if (requestPath.ToLower().Substring(sysPath.Length).IndexOf("/") == -1)
                {
                    if (requestPath.ToLower().EndsWith("/default.aspx"))
                    {
                        CreateTemplate(sysPath, Templates.GetTemplateItem(int.Parse(strTemplateid)).Directory, "IndexPage.aspx", int.Parse(strTemplateid));

                        context.RewritePath(sysPath + "aspx/" + strTemplateid + "/IndexPage.aspx");

                        return;
                    }

                    //当使用伪aspx, 如:user-1.aspx等.
                    if (config.Aspxrewrite == 1)
                    {
                        foreach (SiteUrls.URLRewrite url in SiteUrls.GetSiteUrls().Urls)
                        {
                            if (Regex.IsMatch(requestPath, url.Pattern, Utils.GetRegexCompiledOptions() | RegexOptions.IgnoreCase))
                            {
                                string newUrl = Regex.Replace(requestPath.Substring(context.Request.Path.LastIndexOf("/")), url.Pattern, url.QueryString, Utils.GetRegexCompiledOptions() | RegexOptions.IgnoreCase);

                                //if ( url.Page.ToLower() =="/topapirecall.aspx")//淘宝回调处理
                                // {
                                //     context.RewritePath(sysPath + "Services/" + url.Page, string.Empty, newUrl + "&" + requestValue);
                                // }
                                // else
                                // {
                                context.RewritePath(sysPath + "aspx/" + strTemplateid + url.Page, string.Empty, newUrl + "&selectedtemplateid=" + strTemplateid + "&" + requestValue);
                                // }

                                return;
                            }
                        }
                    }

                    context.RewritePath(sysPath + "aspx/" + strTemplateid + requestPath.Substring(context.Request.Path.LastIndexOf("/")), string.Empty, context.Request.QueryString.ToString() + "&selectedtemplateid=" + strTemplateid);

                    return;
                }
                else if (requestPath.ToLower().StartsWith(sysPath + "home") || requestPath.ToLower().StartsWith(sysPath + "userheadimgu"))
                {
                    //当使用伪aspx, 如:user-1.aspx等.
                    if (config.Aspxrewrite == 1)
                    {
                        foreach (SiteUrls.URLRewrite url in SiteUrls.GetSiteUrls().Urls)
                        {
                            if (Regex.IsMatch(requestPath, url.Pattern, Utils.GetRegexCompiledOptions() | RegexOptions.IgnoreCase))
                            {
                                string newUrl = Regex.Replace(requestPath.Substring(context.Request.Path.LastIndexOf("/")), url.Pattern, url.QueryString, Utils.GetRegexCompiledOptions() | RegexOptions.IgnoreCase);

                                context.RewritePath(sysPath + "aspx/" + strTemplateid + url.Page, string.Empty, newUrl + "&selectedtemplateid=" + strTemplateid + "&" + requestValue);

                                return;
                            }
                        }
                    }
                    return;
                }

/*
 *              else if (requestPath.StartsWith(sysPath + "archiver/"))
 *              {
 *                  //当使用伪aspx
 *                  if (config.Aspxrewrite == 1)
 *                  {
 *                      string path = requestPath.Substring(sysPath.Length + 8);
 *                      foreach (SiteUrls.URLRewrite url in SiteUrls.GetSiteUrls().Urls)
 *                      {
 *                          if (Regex.IsMatch(path, url.Pattern, Utils.GetRegexCompiledOptions() | RegexOptions.IgnoreCase))
 *                          {
 *                              string newUrl = Regex.Replace(path, url.Pattern, url.QueryString, Utils.GetRegexCompiledOptions() | RegexOptions.IgnoreCase);
 *
 *                              context.RewritePath(sysPath + "archiver" + url.Page, string.Empty, newUrl);
 *                              return;
 *                          }
 *                      }
 *
 *                  }
 *                  return;
 *              }
 *              else if (requestPath.StartsWith(sysPath + "tools/"))
 *              {
 *                  //当使用伪aspx
 *                  if (config.Aspxrewrite == 1)
 *                  {
 *                      string path = requestPath.Substring(sysPath.Length + 5);
 *                      foreach (SiteUrls.URLRewrite url in SiteUrls.GetSiteUrls().Urls)
 *                      {
 *                          if (Regex.IsMatch(path, url.Pattern, Utils.GetRegexCompiledOptions() | RegexOptions.IgnoreCase))
 *                          {
 *                              string newUrl = Regex.Replace(path, url.Pattern, Utils.UrlDecode(url.QueryString), Utils.GetRegexCompiledOptions() | RegexOptions.IgnoreCase);
 *
 *                              context.RewritePath(sysPath + "tools" + url.Page, string.Empty, newUrl);
 *                              return;
 *                          }
 *                      }
 *                  }
 *                  return;
 *              }
 */
            }
        }
Exemple #8
0
 /// <summary>
 /// 后台管理首页
 /// </summary>
 /// <returns></returns>
 public string BackstageHome()
 {
     return(SiteUrls.Instance().ManageTopics());
 }
Exemple #9
0
 /// <summary>
 /// 用户首页
 /// </summary>
 /// <param name="userId">用户id</param>
 /// <param name="sectionId">贴吧id</param>
 /// <returns></returns>
 public string UserSpaceHome(long userId, long?sectionId = null)
 {
     return(SiteUrls.Instance().SpaceHome(userId));
 }
Exemple #10
0
 /// <summary>
 /// 关注的日志
 /// </summary>
 public static string BlogSubscribed(this SiteUrls siteUrls, string spaceKey)
 {
     return(CachedUrlHelper.Action("Subscribed", "Blog", BlogAreaName, new RouteValueDictionary {
         { "spaceKey", spaceKey }
     }));
 }
Exemple #11
0
 /// <summary>
 /// 解析Url
 /// </summary>
 /// <returns></returns>
 private string UrlTagGenerate(string url, long associateId, long userId, ParsedMedia parsedMedia)
 {
     if (parsedMedia == null)
     {
         return(string.Empty);
     }
     if (parsedMedia != null)
     {
         var microblog = new MicroblogService().Get(associateId);
         if (parsedMedia.MediaType == MediaType.Video)
         {
             microblog.VideoAlias = parsedMedia.Alias;
         }
         else if (parsedMedia.MediaType == MediaType.Audio)
         {
             microblog.AudioAlias = parsedMedia.Alias;
         }
     }
     if (parsedMedia.MediaType == MediaType.Video)
     {
         return(string.Format("<a id=\"attachmentsListLiVideo-{0}\" href=\"{3}\" target=\"_blank\" data-microblogId=\"{1}\">{2}<span class=\"tn-icon tn-icon-movie tn-icon-inline\"></span></a>", parsedMedia.Alias, associateId, url, SiteUrls.Instance()._Microblog_Attachments_Video(userId, associateId, parsedMedia.Alias)));
     }
     else if (parsedMedia.MediaType == MediaType.Audio)
     {
         return(string.Format("<a id=\"attachmentsListLiMusic-{0}\" href=\"{3}\" target=\"_blank\" data-microblogId=\"{1}\" >{2}<span class=\"tn-icon tn-icon-music tn-icon-inline\"></span></a>", parsedMedia.Alias, associateId, url, SiteUrls.Instance()._Microblog_Attachments_Music(userId, associateId, parsedMedia.Alias)));
     }
     else
     {
         return(string.Format("<a href=\"{0}\" target=\"_blank\">{1}</a>", parsedMedia.Url, DIContainer.Resolve <ISettingsManager <ShortUrlSettings> >().Get().ShortUrlDomain + url));
     }
 }
Exemple #12
0
 /// <summary>
 /// 日志分类列表
 /// </summary>
 /// <param name="siteUrls"></param>
 /// <param name="categoryId">不同分类的id</param>
 /// <returns></returns>
 public static string BlogListByCategory(this SiteUrls siteUrls, string categoryId)
 {
     return(CachedUrlHelper.Action("ListByCategory", "ChannelBlog", BlogAreaName, new RouteValueDictionary {
         { "categoryId", categoryId }
     }));
 }
Exemple #13
0
 /// <summary>
 /// 日志标签下的日志
 /// </summary>
 /// <param name="siteUrls"></param>
 /// <param name="tagName">标签名</param>
 /// <returns></returns>
 public static string BlogListByTag(this SiteUrls siteUrls, string tagName)
 {
     return(CachedUrlHelper.Action("ListByTag", "ChannelBlog", BlogAreaName, new RouteValueDictionary {
         { "tagName", WebUtility.UrlEncode(tagName.TrimEnd('.')) }
     }));
 }
Exemple #14
0
 /// <summary>
 /// 日志排行页
 /// </summary>
 /// <param name="siteUrls"></param>
 /// <returns></returns>
 public static string BlogListByRank(this SiteUrls siteUrls, string rank)
 {
     return(CachedUrlHelper.Action("ListByRank", "ChannelBlog", BlogAreaName, new RouteValueDictionary {
         { "rank", rank }
     }));
 }
Exemple #15
0
 /// <summary>
 /// 日志频道首页
 /// </summary>
 /// <param name="siteUrls"></param>
 /// <returns></returns>
 public static string BlogChannelHome(this SiteUrls siteUrls)
 {
     return(CachedUrlHelper.Action("Home", "ChannelBlog", BlogAreaName));
 }
Exemple #16
0
 /// <summary>
 /// 处理地址
 /// </summary>
 /// <param name="userId"></param>
 /// <returns></returns>
 public string GetProcessUrl(long userId)
 {
     return(SiteUrls.FullUrl(SiteUrls.Instance().ListInvitations(UserIdToUserNameDictionary.GetUserName(userId))));
 }
Exemple #17
0
 /// <summary>
 /// 处理快捷搜索的URL
 /// </summary>
 /// <param name="keyword">搜索关键词</param>
 /// <returns></returns>
 public string QuickSearchActionUrl(string keyword)
 {
     return(SiteUrls.Instance().WikiQuickSearch() + "?keyword=" + keyword);
 }
 /// <summary>
 /// 处理地址
 /// </summary>
 /// <param name="userId"></param>
 /// <returns></returns>
 public string GetProcessUrl(long userId)
 {
     return(SiteUrls.FullUrl(SiteUrls.Instance().ListNotices(UserIdToUserNameDictionary.GetUserName(userId), NoticeStatus.Unhandled, null)));
 }
Exemple #19
0
 public ActionResult DeleteUserRank(int rank)
 {
     userRankService.Delete(rank);
     return(Redirect(SiteUrls.Instance().ManageRanks()));
 }
Exemple #20
0
        /// <summary>
        /// 获取管理数据
        /// </summary>
        /// <param name="tenantTypeId">租户类型Id(可以获取该应用下针对某种租户类型的统计计数,默认不进行筛选)</param>
        /// <returns></returns>
        public IEnumerable <ApplicationStatisticData> GetManageableDatas(string tenantTypeId = null)
        {
            tenantTypeId = tenantTypeId ?? TenantTypeIds.Instance().Bar();
            IList <ApplicationStatisticData> applicationStatisticDatas = new List <ApplicationStatisticData>();
            Dictionary <string, long>        barSectionManageableDatas = barSectionService.GetManageableDatas(tenantTypeId);
            Dictionary <string, long>        barThreadManageableDatas  = barThreadService.GetManageableDatas(tenantTypeId);
            Dictionary <string, long>        barPostManageableDatas    = barPostService.GetManageableDatas(tenantTypeId);

            if (tenantTypeId == TenantTypeIds.Instance().Bar())
            {
                if (barSectionManageableDatas.ContainsKey(ApplicationStatisticDataKeys.Instance().SectionPendingCount()))
                {
                    applicationStatisticDatas.Add(new ApplicationStatisticData(ApplicationStatisticDataKeys.Instance().SectionPendingCount(), "帖吧",
                                                                               "帖吧待审核数", barSectionManageableDatas[ApplicationStatisticDataKeys.Instance().SectionPendingCount()])
                    {
                        DescriptionPattern = "{0}个帖吧待审核",
                        Url = SiteUrls.Instance().ManageBars(auditStatus: AuditStatus.Pending)
                    });
                }
                if (barSectionManageableDatas.ContainsKey(ApplicationStatisticDataKeys.Instance().SectionAgainCount()))
                {
                    applicationStatisticDatas.Add(new ApplicationStatisticData(ApplicationStatisticDataKeys.Instance().SectionAgainCount(), "帖吧",
                                                                               "帖吧需再审核数", barSectionManageableDatas[ApplicationStatisticDataKeys.Instance().SectionAgainCount()])
                    {
                        DescriptionPattern = "{0}个帖吧需再审核",
                        Url = SiteUrls.Instance().ManageBars(auditStatus: AuditStatus.Again)
                    });
                }
            }
            if (barThreadManageableDatas.ContainsKey(ApplicationStatisticDataKeys.Instance().PendingCount()))
            {
                applicationStatisticDatas.Add(new ApplicationStatisticData(ApplicationStatisticDataKeys.Instance().PendingCount(), "帖子",
                                                                           "帖子待审核数", barThreadManageableDatas[ApplicationStatisticDataKeys.Instance().PendingCount()])
                {
                    DescriptionPattern = "{0}个帖子待审核",
                    Url = SiteUrls.Instance().ManageThreads(AuditStatus.Pending, tenantTypeId)
                });
            }
            if (barThreadManageableDatas.ContainsKey(ApplicationStatisticDataKeys.Instance().AgainCount()))
            {
                applicationStatisticDatas.Add(new ApplicationStatisticData(ApplicationStatisticDataKeys.Instance().AgainCount(), "帖子",
                                                                           "帖子需再审核数", barThreadManageableDatas[ApplicationStatisticDataKeys.Instance().AgainCount()])
                {
                    DescriptionPattern = "{0}个帖子需再审核",
                    Url = SiteUrls.Instance().ManageThreads(AuditStatus.Again, tenantTypeId)
                });
            }

            if (barPostManageableDatas.ContainsKey(ApplicationStatisticDataKeys.Instance().PostPendingCount()))
            {
                applicationStatisticDatas.Add(new ApplicationStatisticData(ApplicationStatisticDataKeys.Instance().PostPendingCount(), "回帖",
                                                                           "回帖待审核数", barPostManageableDatas[ApplicationStatisticDataKeys.Instance().PostPendingCount()])
                {
                    DescriptionPattern = "{0}个回帖待审核",
                    Url = SiteUrls.Instance().ManagePosts(AuditStatus.Pending, tenantTypeId)
                });
            }
            if (barPostManageableDatas.ContainsKey(ApplicationStatisticDataKeys.Instance().PostAgainCount()))
            {
                applicationStatisticDatas.Add(new ApplicationStatisticData(ApplicationStatisticDataKeys.Instance().PostAgainCount(), "回帖",
                                                                           "回帖需再审核数", barPostManageableDatas[ApplicationStatisticDataKeys.Instance().PostAgainCount()])
                {
                    DescriptionPattern = "{0}个回帖需再审核",
                    Url = SiteUrls.Instance().ManagePosts(AuditStatus.Again, tenantTypeId)
                });
            }
            return(applicationStatisticDatas);
        }
        /// <summary>
        /// 通知处理程序
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        private void GroupMemberApplyNoticeModule_After(GroupMemberApply sender, CommonEventArgs eventArgs)
        {
            GroupService groupService = new GroupService();
            GroupEntity  entity       = groupService.Get(sender.GroupId);

            if (entity == null)
            {
                return;
            }

            User senderUser = DIContainer.Resolve <IUserService>().GetFullUser(sender.UserId);

            if (senderUser == null)
            {
                return;
            }
            InvitationService invitationService = new InvitationService();
            Invitation        invitation;
            NoticeService     noticeService = DIContainer.Resolve <NoticeService>();
            Notice            notice;

            if (eventArgs.EventOperationType == EventOperationType.Instance().Create())
            {
                if (sender.ApplyStatus == GroupMemberApplyStatus.Pending)
                {
                    List <long> toUserIds = new List <long>();
                    toUserIds.Add(entity.UserId);
                    toUserIds.AddRange(entity.GroupManagers.Select(n => n.UserId));
                    foreach (var toUserId in toUserIds)
                    {
                        //申请加入群组的请求
                        if (!groupService.IsMember(sender.GroupId, sender.UserId))
                        {
                            invitation = Invitation.New();
                            invitation.ApplicationId      = GroupConfig.Instance().ApplicationId;
                            invitation.InvitationTypeKey  = InvitationTypeKeys.Instance().ApplyJoinGroup();
                            invitation.UserId             = toUserId;
                            invitation.SenderUserId       = sender.UserId;
                            invitation.Sender             = senderUser.DisplayName;
                            invitation.SenderUrl          = SiteUrls.Instance().SpaceHome(sender.UserId);
                            invitation.RelativeObjectId   = sender.GroupId;
                            invitation.RelativeObjectName = entity.GroupName;
                            invitation.RelativeObjectUrl  = SiteUrls.FullUrl(SiteUrls.Instance().GroupHome(entity.GroupKey));
                            invitation.Remark             = string.Empty;
                            invitationService.Create(invitation);
                        }
                    }
                }
                return;
            }

            string noticeTemplateName = string.Empty;

            if (eventArgs.EventOperationType == EventOperationType.Instance().Approved())
            {
                if (sender.ApplyStatus == GroupMemberApplyStatus.Approved)
                {
                    noticeTemplateName = NoticeTemplateNames.Instance().MemberApplyApproved();
                }
            }
            else if (eventArgs.EventOperationType == EventOperationType.Instance().Disapproved())
            {
                if (sender.ApplyStatus == GroupMemberApplyStatus.Disapproved)
                {
                    noticeTemplateName = NoticeTemplateNames.Instance().MemberApplyDisapproved();
                }
            }

            if (string.IsNullOrEmpty(noticeTemplateName))
            {
                return;
            }

            notice = Notice.New();

            notice.UserId        = sender.UserId;
            notice.ApplicationId = GroupConfig.Instance().ApplicationId;
            notice.TypeId        = NoticeTypeIds.Instance().Hint();
            //notice.LeadingActorUserId = UserContext.CurrentUser.UserId;
            //notice.LeadingActor = UserContext.CurrentUser.DisplayName;
            //notice.LeadingActorUrl = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(UserContext.CurrentUser.UserId));
            notice.RelativeObjectId   = sender.GroupId;
            notice.RelativeObjectName = StringUtility.Trim(entity.GroupName, 64);
            notice.RelativeObjectUrl  = SiteUrls.FullUrl(SiteUrls.Instance().GroupHome(entity.GroupKey));
            notice.TemplateName       = noticeTemplateName;
            noticeService.Create(notice);
        }
Exemple #22
0
 /// <summary>
 /// 处理全局搜索的URL
 /// </summary>
 /// <param name="keyword">搜索关键词</param>
 /// <returns></returns>
 public string GlobalSearchActionUrl(string keyword)
 {
     return(SiteUrls.Instance().TopicGlobalSearch() + "?keyword=" + keyword);
 }
        private void AuthorizeCore(AuthorizationContext filterContext)
        {
            string spaceKey = UserContext.CurrentSpaceKey(filterContext);

            if (string.IsNullOrEmpty(spaceKey))
            {
                filterContext.Result = new HttpNotFoundResult();
                return;
            }
            IUserService userService      = DIContainer.Resolve <IUserService>();
            User         currentSpaceUser = userService.GetFullUser(spaceKey);

            if (currentSpaceUser == null)
            {
                filterContext.Result = new HttpNotFoundResult();
                return;
            }
            IUser currentUser = UserContext.CurrentUser;
            //判断空间访问隐私
            PrivacyService privacyService = new PrivacyService();

            if (!privacyService.Validate(currentSpaceUser.UserId, currentUser != null ? currentUser.UserId : 0, PrivacyItemKeys.Instance().VisitUserSpace()))
            {
                if (currentUser == null)
                {
                    filterContext.Result = new RedirectResult(SiteUrls.Instance().Login(true));
                }
                else
                {
                    filterContext.Result = new RedirectResult(SiteUrls.Instance().PrivacyHome(currentSpaceUser.UserName) /* 跳向无权访问页 */);
                }
                return;
            }

            //判断该用户是否有访问该空间的权限
            if (!RequireOwnerOrAdministrator)
            {
                return;
            }
            //匿名用户要求先登录跳转
            if (currentUser == null)
            {
                filterContext.Result = new RedirectResult(SiteUrls.Instance().Login(true));
                return;
            }

            if (currentSpaceUser.UserId == currentUser.UserId)
            {
                if (currentUser.IsBanned)
                {
                    IAuthenticationService authenticationService = DIContainer.ResolvePerHttpRequest <IAuthenticationService>();
                    authenticationService.SignOut();
                    filterContext.Result = new RedirectResult(SiteUrls.Instance().SystemMessage(filterContext.Controller.TempData, new SystemMessageViewModel
                    {
                        Title             = "帐号被封禁!",
                        Body              = "由于您的非法操作,您的帐号已被封禁,如有疑问,请联系管理员",
                        StatusMessageType = Tunynet.Mvc.StatusMessageType.Error
                    }) /* 跳向无权访问页 */);
                }
                return;
            }
            if (currentUser.IsInRoles(RoleNames.Instance().SuperAdministrator(), RoleNames.Instance().ContentAdministrator()))
            {
                return;
            }
            filterContext.Result = new RedirectResult(SiteUrls.Instance().SystemMessage(filterContext.Controller.TempData, new SystemMessageViewModel
            {
                Title             = "无权访问",
                Body              = "您无权访问此页面,只有空间主人或管理员才能访问",
                StatusMessageType = Tunynet.Mvc.StatusMessageType.Error
            }) /* 跳向无权访问页 */);
        }
Exemple #24
0
 /// <summary>
 /// 详细页面地址
 /// </summary>
 /// <param name="itemId">推荐内容Id</param>
 /// <returns></returns>
 public string RecommendItemDetail(long itemId)
 {
     return(SiteUrls.Instance().PageDetail(itemId));
 }
Exemple #25
0
    public override void Process()
    {
        byte[] uploadFileBytes = null;
        string uploadFileName  = null;

        if (UploadConfig.Base64)
        {
            uploadFileName  = UploadConfig.Base64Filename;
            uploadFileBytes = Convert.FromBase64String(Request[UploadConfig.UploadFieldName]);
        }
        else
        {
            var file = Request.Files[UploadConfig.UploadFieldName];
            uploadFileName = file.FileName;

            if (!CheckFileType(uploadFileName))
            {
                Result.State = UploadState.TypeNotAllow;
                WriteResult();
                return;
            }
            if (!CheckFileSize(file.ContentLength))
            {
                Result.State = UploadState.SizeLimitExceed;
                WriteResult();
                return;
            }

            uploadFileBytes = new byte[file.ContentLength];
            try
            {
                file.InputStream.Read(uploadFileBytes, 0, file.ContentLength);
            }
            catch (Exception)
            {
                Result.State = UploadState.NetworkError;
                WriteResult();
            }
        }

        IUser  user         = UserContext.CurrentUser;
        string tenantTypeId = Request["tenantTypeId"];
        bool   resize       = true;
        long   associateId  = 0;

        long.TryParse(Context.Request["associateId"], out associateId);
        AttachmentService <Attachment> attachementService = new AttachmentService <Attachment>(tenantTypeId);
        long   userId = user.UserId, ownerId = user.UserId;
        string userDisplayName = user.DisplayName;

        Result.OriginFileName = uploadFileName;

        try
        {
            //保存文件
            string       contentType      = MimeTypeConfiguration.GetMimeType(uploadFileName);
            MemoryStream ms               = new MemoryStream(uploadFileBytes);
            string       friendlyFileName = uploadFileName.Substring(uploadFileName.LastIndexOf("\\") + 1);
            Attachment   attachment       = new Attachment(ms, contentType, friendlyFileName);
            attachment.UserId          = userId;
            attachment.AssociateId     = associateId;
            attachment.TenantTypeId    = tenantTypeId;
            attachment.OwnerId         = ownerId;
            attachment.UserDisplayName = userDisplayName;
            attachementService.Create(attachment, ms);
            ms.Dispose();
            Result.Url   = SiteUrls.Instance().AttachmentDirectUrl(attachment);
            Result.State = UploadState.Success;
        }
        catch (Exception e)
        {
            Result.State        = UploadState.FileAccessError;
            Result.ErrorMessage = e.Message;
        }
        finally
        {
            WriteResult();
        }
    }
 /// <summary>
 /// 清除缓存
 /// </summary>
 public ActionResult ResetCache()
 {
     return(Redirect(SiteUrls.Instance().ControlPanelOperating("正在执行清除缓存操作", SiteUrls.Instance().ControlPanelTool(), SiteUrls.Instance().ResetCache(), "你确定要清除缓存吗?")));
 }
Exemple #27
0
 /// <summary>
 /// 生成at用户标签
 /// </summary>
 /// <param name="userName">用户名</param>
 /// <param name="displayName">显示名</param>
 private string AtUserTagGenerate(string userName, string displayName)
 {
     return(string.Format("<a href=\"{1}\" target=\"_blank\" title=\"{0}\">@{0}</a> ", displayName, SiteUrls.Instance().SpaceHome(userName)));
 }
 /// <summary>
 /// 重启站点
 /// </summary>
 public ActionResult UnloadAppDomain()
 {
     return(Redirect(SiteUrls.Instance().ControlPanelOperating("正在执行重启站点操作", SiteUrls.Instance().ControlPanelTool(), SiteUrls.Instance().UnloadAppDomain(), "你确定要重启站点吗?")));
 }
        private void AuthorizeCore(AuthorizationContext filterContext)
        {
            string spaceKey = UserContext.CurrentSpaceKey(filterContext);

            if (string.IsNullOrEmpty(spaceKey))
            {
                throw new ExceptionFacade("spaceKey为null");
            }
            TopicService TopicService = new TopicService();
            TopicEntity  Topic        = TopicService.Get(spaceKey);

            if (Topic == null)
            {
                throw new ExceptionFacade("找不到当前专题");
            }

            IUser currentUser = UserContext.CurrentUser;



            //判断访问专题权限
            if (!DIContainer.Resolve <Authorizer>().Topic_View(Topic))
            {
                if (currentUser == null)
                {
                    filterContext.Result = new RedirectResult(SiteUrls.Instance().Login(true));
                }
                else
                {
                    if (Topic.AuditStatus != AuditStatus.Success)
                    {
                        filterContext.Result = new RedirectResult(SiteUrls.Instance().SystemMessage(filterContext.Controller.TempData, new SystemMessageViewModel
                        {
                            Title             = "无权访问专题!",
                            Body              = "该专题还没有通过审核,所以不能访问!",
                            StatusMessageType = StatusMessageType.Hint
                        }, filterContext.HttpContext.Request.RawUrl) /* 跳向无权访问页 */);
                    }
                    else
                    {
                        filterContext.Result = new RedirectResult(SiteUrls.Instance().SystemMessage(filterContext.Controller.TempData, new SystemMessageViewModel
                        {
                            Title             = "无权访问专题!",
                            Body              = "你没有访问该专题的权限",
                            StatusMessageType = StatusMessageType.Hint
                        }, filterContext.HttpContext.Request.RawUrl) /* 跳向无权访问页 */);
                    }
                }
                return;
            }

            //判断该用户是否有访问该专题管理页面的权限
            if (!RequireManager)
            {
                return;
            }
            //匿名用户要求先登录跳转
            if (currentUser == null)
            {
                filterContext.Result = new RedirectResult(SiteUrls.Instance().Login(true));
                return;
            }

            if (DIContainer.Resolve <Authorizer>().Topic_Manage(Topic))
            {
                return;
            }
            filterContext.Result = new RedirectResult(SiteUrls.Instance().SystemMessage(filterContext.Controller.TempData, new SystemMessageViewModel
            {
                Title             = "无权访问",
                Body              = "您无权访问此页面,只有群主或管理员才能访问",
                StatusMessageType = StatusMessageType.Hint
            }) /* 跳向无权访问页 */);
        }
 /// <summary>
 /// 重启站点
 /// </summary>
 public ActionResult _UnloadAppDomain()
 {
     System.Web.HttpRuntime.UnloadAppDomain();
     return(Redirect(SiteUrls.Instance().ControlPanelSuccess("执行成功", SiteUrls.Instance().ControlPanelTool())));
 }
Exemple #31
0
 public static void SetInstance(SiteUrls anInstance)
 {
     if (anInstance != null)
         instance = anInstance;
 }
Exemple #32
0
 /// <summary>
 /// 日志搜索自动完成
 /// </summary>
 public static string BlogSearchAutoComplete(this SiteUrls siteUrls)
 {
     return(CachedUrlHelper.Action("SearchAutoComplete", "ChannelBlog", BlogAreaName));
 }