Ejemplo n.º 1
0
        /// <summary>
        /// Get a forum adapter to match the provided forum type.
        /// </summary>
        /// <param name="forumType">The type of forum being requested.</param>
        /// <returns>Returns a forum adapter matching the requested forum type.</returns>
        public IForumAdapter2 CreateForumAdapter(ForumType forumType, Uri uri)
        {
            switch (forumType)
            {
            case ForumType.XenForo1:
                return(new XenForo1Adapter2(inputOptions, loggerFactory.CreateLogger <XenForo1Adapter2>()));

            case ForumType.XenForo2:
                return(new XenForo2Adapter2(inputOptions, loggerFactory.CreateLogger <XenForo2Adapter2>()));

            case ForumType.vBulletin3:
                return(new VBulletin3Adapter2(inputOptions, loggerFactory.CreateLogger <VBulletin3Adapter2>()));

            case ForumType.vBulletin4:
                return(new VBulletin4Adapter2(inputOptions, loggerFactory.CreateLogger <VBulletin4Adapter2>()));

            case ForumType.vBulletin5:
                return(new VBulletin5Adapter2(inputOptions, loggerFactory.CreateLogger <VBulletin5Adapter2>()));

            case ForumType.phpBB:
                return(new PhpBBAdapter2(inputOptions, loggerFactory.CreateLogger <PhpBBAdapter2>()));

            //case ForumType.NodeBB:
            //    return new NodeBBAdapter2(inputOptions, loggerFactory.CreateLogger<NodeBBAdapter2>());
            case ForumType.Unknown:
                return(new UnknownForumAdapter2(inputOptions, loggerFactory.CreateLogger <UnknownForumAdapter2>()));

            default:
                throw new ArgumentException($"Unknown forum type: {forumType} for Uri: {uri}", nameof(forumType));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets a forum adapter to match the provided forum type and Uri.
        /// </summary>
        /// <param name="forumType">The type of forum being requested.</param>
        /// <param name="site">The Uri of the site the adapter is for.</param>
        /// <returns>Returns a forum adapter matching the forum type, initialized to the provided Uri.</returns>
        public static IForumAdapter GetForumAdapter(ForumType forumType, Uri site)
        {
            if (cachedAdapters.TryGetValue(forumType, out IForumAdapter adapter))
            {
                adapter.Site = site;
                return(adapter);
            }

            switch (forumType)
            {
            case ForumType.XenForo:
                adapter = new XenForoAdapter(site);
                break;

            case ForumType.vBulletin3:
                adapter = new vBulletinAdapter3(site);
                break;

            case ForumType.vBulletin4:
                adapter = new vBulletinAdapter4(site);
                break;

            case ForumType.vBulletin5:
                adapter = new vBulletinAdapter5(site);
                break;

            default:
                throw new ArgumentException($"Unknown forum type: {forumType}", nameof(forumType));
            }

            cachedAdapters[forumType] = adapter;

            return(adapter);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 论坛版块添加
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static ForumType ForumType_ADD(ForumType model)
 {
     try
     {
         using (var conn = DbHelper.CCService())
         {
             var p = new DynamicParameters();
             p.Add("@ForumTypeID", dbType: DbType.Int32, direction: ParameterDirection.Output);
             p.Add("@OCID", model.OCID);
             p.Add("@CourseID", model.CourseID);
             p.Add("@Title", model.Title);
             p.Add("@IsEssence", model.IsEssence);
             p.Add("@Brief", model.Brief);
             p.Add("@TeachingClassID", model.TeachingClassID);
             p.Add("@IsPublic", model.IsPublic);
             p.Add("@UserID", model.UserID);
             conn.Execute("ForumType_ADD", p, commandType: CommandType.StoredProcedure);
             model.ForumTypeID = p.Get<int>("@ForumTypeID");
             return model;
         }
     }
     catch (Exception e)
     {
         return null;
     }
 }
Ejemplo n.º 4
0
 public static bool ForumType_Del(ForumType model)
 {
     if (!UserService.OC_IsRole(model.OCID))
     {
         return(true);
     }
     return(new ForumTypeBLL().ForumType_Del(model));
 }
Ejemplo n.º 5
0
        public static ForumType ForumType_ADD(ForumType model)
        {
            if (!UserService.OC_IsRole(model.OCID))
            {
                return(null);
            }

            return(new ForumTypeBLL().ForumType_ADD(model));
        }
Ejemplo n.º 6
0
        public async Task Identify_phpBB()
        {
            HtmlDocument doc     = new HtmlDocument();
            string       rawPage = await GetForumResource(ForumType.phpBB);

            doc.LoadHtml(rawPage);

            ForumType forumType = ForumIdentifier.IdentifyForumTypeFromHtmlDocument(doc);

            Assert.AreEqual(ForumType.phpBB, forumType);
        }
Ejemplo n.º 7
0
        void commentTree(string trueEvetId, string photoName, ref DocX outDoc, ForumType forumType)
        {
            //hladnaie rootu akcie / fotky
            var sublist = contentList.Where(c => c.EventId == trueEvetId && c.RootID == null && ((forumType == ForumType.Event && c.IsEvent == true) || (forumType == ForumType.EventPhotoGallery && c.IsPhoto == true && c.ThumbPath.Contains(photoName))));

            foreach (var comment in sublist.Where(c => c.RootID == null)) //iterujeme len rooty
            {
                addComment(comment);
                docTree(comment, 1);
                doc.InsertParagraph();
            }
        }
Ejemplo n.º 8
0
 public virtual OperationResult AddForumType(ForumType ForumTypeInfo)
 {
     try
     {
         PublicHelper.CheckArgument(ForumTypeInfo, "ForumTypeInfo");
         ForumTypeRepository.Insert(ForumTypeInfo);
         return(new OperationResult(OperationResultType.Success, "任务类型添加成功。", ForumTypeInfo));
     }
     catch (Exception ex)
     {
         return(new OperationResult(OperationResultType.Error, ex.Message.ToString()));
     }
 }
Ejemplo n.º 9
0
 /// <summary>
 /// 获取论坛版块详细信息
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static ForumTypeInfo ForumTypeInfo_Get(ForumType model)
 {
     try
     {
         using (IDbConnection conn = DbHelper.CCService())
         {
             ForumTypeInfo ft = new ForumTypeInfo();
             var p = new DynamicParameters();
             p.Add("@ForumTypeID", model.ForumTypeID);
             var multi = conn.QueryMultiple("ForumTypeInfo_Get", p, commandType: CommandType.StoredProcedure);
             var forumtype = multi.Read<ForumType>().Single();
             var forumclasslist = multi.Read<ForumClass>().ToList();
             ft.forumtype = forumtype;
             ft.forumclasslist = forumclasslist;
             return ft;
         }
     }
     catch (Exception e)
     {
         return null;
     }
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Function to check a provided HTML document and use it to determine a forum type.
        /// </summary>
        /// <param name="doc">An HTML document.</param>
        /// <returns>Returns a forum type, if it can be determined based on the provided document.</returns>
        public static ForumType IdentifyForumTypeFromHtmlDocument(HtmlDocument?doc)
        {
            ForumType forumType = ForumType.Unknown;

            if (doc != null)
            {
                if (IdentifyXenForo1(doc))
                {
                    forumType = ForumType.XenForo1;
                }
                else if (IdentifyXenForo2(doc))
                {
                    forumType = ForumType.XenForo2;
                }
                else if (IdentifyVBulletin3(doc))
                {
                    forumType = ForumType.vBulletin3;
                }
                else if (IdentifyVBulletin4(doc))
                {
                    forumType = ForumType.vBulletin4;
                }
                else if (IdentifyVBulletin5(doc))
                {
                    forumType = ForumType.vBulletin5;
                }
                else if (IdentifyPhpBB(doc))
                {
                    forumType = ForumType.phpBB;
                }
                else if (IdentifyNodeBB(doc))
                {
                    forumType = ForumType.NodeBB;
                }
            }

            return(forumType);
        }
Ejemplo n.º 11
0
        private async Task <string> GetForumResource(ForumType forumType)
        {
            string filename = forumType switch
            {
                ForumType.vBulletin3 => "vBulletin3.html",
                ForumType.vBulletin4 => "vBulletin4.html",
                ForumType.vBulletin5 => "vBulletin5.html",
                ForumType.XenForo1 => "Xenforo1.html",
                ForumType.XenForo2 => "Xenforo2.html",
                ForumType.NodeBB => "NodeBB.html",
                ForumType.phpBB => "phpBB.html",
                _ => string.Empty,
            };

            if (string.IsNullOrEmpty(filename))
            {
                return(string.Empty);
            }

            filename = $"Resources/{filename}";

            return(await LoadResource.Read(filename) ?? "");
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 论坛版块列表
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static List<ForumType> ForumType_List(ForumType model)
        {
            try
            {
                using (var conn = DbHelper.CCService())
                {
                    var p = new DynamicParameters();

                    p.Add("@OCID", model.OCID);
                    p.Add("@UserID", model.UserID);
                    return conn.Query<ForumType>("ForumType_List", p, commandType: CommandType.StoredProcedure).ToList();
                }
            }
            catch (Exception e)
            {
                return null;
            }
        }
Ejemplo n.º 13
0
        public bool CreateForum(AuthUser operatorUser, string codeName, string forumName, int parentID, ForumType forumType, string password, string logoSrc
                                , string themeID, string readme, string description, ThreadCatalogStatus threadCatalogStaus, int columnSpan, int sortOrder
                                , ForumExtendedAttribute forumExtendedDatas, out int forumID)
        {
            forumID = 0;
            if (!AllSettings.Current.BackendPermissions.Can(operatorUser, BackendPermissions.Action.Manage_Forum))
            {
                ThrowError <NoPermissionManageForumError>(new NoPermissionManageForumError(0));
                return(false);
            }


            if (false == ValidateForumParams(codeName, forumName, parentID, forumType, password, logoSrc, themeID))
            {
                return(false);
            }
            int result = ForumDaoV5.Instance.CreateForum(codeName, forumName, parentID, forumType, password, logoSrc, themeID, readme, description, threadCatalogStaus, columnSpan, sortOrder, forumExtendedDatas, out forumID);

            switch (result)
            {
            case 13:
                ThrowError <DuplicateForumCodeNameError>(new DuplicateForumCodeNameError("codename", codeName));
                return(false);

            case -1:
                ThrowError <ParentForumNotExistsError>(new ParentForumNotExistsError("parentID"));
                return(false);

            default: break;
            }

            ClearAllCache();
            ThreadCachePool.ClearAllCache();

            return(true);
        }
Ejemplo n.º 14
0
 public UserInfo(string username, string password, int questionID, string answer, ForumType type) : this(username, password, type)
 {
     QuestionID = questionID;
     Answer     = answer;
 }
Ejemplo n.º 15
0
 public static Task<Tuple<bool, string>> CreateNewTopic(string title, string message, ForumType type, int id,
     string question = null, List<string> answers = null)
 {
     return CreateNewTopic(title, message, type == ForumType.Normal
         ? $"/forum/?action=post&boardid={id}"
         : $"/forum/?action=post&club_id={id}", question, answers);
 }
Ejemplo n.º 16
0
 public static List <ForumType> ForumType_List(ForumType ft)
 {
     return(new ForumTypeBLL().ForumType_List(ft));
 }
Ejemplo n.º 17
0
 public static bool ForumType_Del(ForumType model)
 {
     if (!UserService.OC_IsRole(model.OCID))
     {
         return true ;
     }
     return new ForumTypeBLL().ForumType_Del(model);
 }
Ejemplo n.º 18
0
 public static bool ForumType_Upd(ForumType model)
 {
     return(new ForumTypeBLL().ForumType_Upd(model));
 }
Ejemplo n.º 19
0
        private void SaveForum()
        {
            m_IsSuccess = false;
            MessageDisplay message = CreateMessageDisplay("codeName", "forumName", "parentID", "forumType", "logoSrc", "themeID", "password"
                                                          , "DisplayInList", "new_DisplayInList", "VisitForum", "new_VisitForum", "SigninForumWithoutPassword", "new_SigninForumWithoutPassword");

            string    codeName  = _Request.Get("codeName", Method.Post, string.Empty);
            string    forumName = _Request.Get("forumName", Method.Post, string.Empty, false);
            int       sortOrder = _Request.Get <int>("sortorder", Method.Post, 0);
            ForumType forumType = _Request.Get <ForumType>("forumType", Method.Post, ForumType.Normal);

            string password;

            if (forumType == ForumType.Link)
            {
                password = _Request.Get("forumLink", Method.Post, string.Empty, false);
                if (password.Trim() == string.Empty)
                {
                    message.AddError("password", "请填写链接地址");
                }
            }
            else
            {
                password = _Request.Get("password", Method.Post, string.Empty);
            }

            int columnSpan = _Request.Get <int>("colSpan", Method.Post, 0);
            int parentID;

            if (forumType == ForumType.Catalog)
            {
                parentID = 0;
            }
            else
            {
                if (IsEdit)
                {
                    parentID = Forum.ParentID;
                }
                else
                {
                    parentID = _Request.Get <int>("parentForum", Method.Post, 0);
                }
            }
            string description = StringUtil.Trim(_Request.Get("Description", Method.Post, string.Empty, false));
            string readme      = StringUtil.Trim(_Request.Get("readme", Method.Post, string.Empty, false));
            string logoSrc     = _Request.Get("logo", Method.Post, string.Empty);
            string themeID     = _Request.Get("theme", Method.Post, string.Empty);

            ThreadCatalogStatus threadCatalogStatus;

            if (IsEdit)
            {
                threadCatalogStatus = Forum.ThreadCatalogStatus;
            }
            else
            {
                threadCatalogStatus = ThreadCatalogStatus.DisEnable;
            }

            ForumExtendedAttribute extendedDatas = new ForumExtendedAttribute();

            extendedDatas.LinkOpenByNewWidow = _Request.Get <bool>("linktype", Method.Post, false);

            //extendedDatas.AllowGuestVisitForum = _Request.Get<bool>("AllowGuestVisitForum", Method.Post, true);
            //extendedDatas.DisplayInListForGuest = _Request.Get<bool>("DisplayInListForGuest", Method.Post, true);

            //extendedDatas.DisplayInList = new ExceptableSetting.ExceptableItem_bool().GetExceptable("DisplayInList", message);
            //extendedDatas.VisitForum = new ExceptableSetting.ExceptableItem_bool().GetExceptable("VisitForum", message);
            extendedDatas.SigninForumWithoutPassword = new ExceptableSetting.ExceptableItem_bool().GetExceptable("SigninForumWithoutPassword", message);


            extendedDatas.MetaDescription = _Request.Get("MetaDescription", Method.Post, "");
            extendedDatas.MetaKeywords    = _Request.Get("MetaKeywords", Method.Post, "");
            extendedDatas.TitleAttach     = _Request.Get("TitleAttach", Method.Post, "");

            if (message.HasAnyError())
            {
                return;
            }

            try
            {
                using (new ErrorScope())
                {
                    bool success;
                    int  forumID;
                    if (IsEdit)
                    {
                        forumID = Forum.ForumID;
                        success = ForumBO.Instance.UpdateForum(My, forumID, codeName, forumName, forumType, password, logoSrc
                                                               , readme, description, themeID, columnSpan, sortOrder, extendedDatas);
                    }
                    else
                    {
                        success = ForumBO.Instance.CreateForum(My, codeName, forumName, parentID, forumType, password, logoSrc
                                                               , themeID, readme, description, threadCatalogStatus, columnSpan, sortOrder, extendedDatas, out forumID);
                    }
                    if (success == false)
                    {
                        CatchError <ErrorInfo>(delegate(ErrorInfo error)
                        {
                            message.AddError(error);
                        });
                        m_IsSuccess = false;
                    }
                    else
                    {
                        if (new ExceptableItem_bool().AplyAllNode("SigninForumWithoutPassword"))//应用到所有下级版块
                        {
                            Dictionary <int, ForumExtendedAttribute> extendedAttributes = new Dictionary <int, ForumExtendedAttribute>();
                            ForumCollection childForums = ForumBO.Instance.GetAllSubForums(forumID);
                            foreach (Forum tempForum in childForums)
                            {
                                tempForum.ExtendedAttribute.SigninForumWithoutPassword = forum.ExtendedAttribute.SigninForumWithoutPassword;
                                extendedAttributes.Add(tempForum.ForumID, tempForum.ExtendedAttribute);
                            }

                            ForumBO.Instance.UpdateChildForumsExtendedAttributes(My, extendedAttributes);
                        }

                        if (IsEdit == false)
                        {
                            JumpTo("bbs/manage-forum.aspx");
                        }
                        else
                        {
                            BbsRouter.JumpToCurrentUrl("success=1");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                message.AddError(ex.Message);
            }
        }
Ejemplo n.º 20
0
        public override int UpdateForum(int forumID, string codeName, string forumName, ForumType forumType, string password, string logoUrl
            , string readme, string description, string themeID, int columnSpan, int sortOrder, ForumExtendedAttribute forumExtendedDatas)
        {
            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = "bx_v5_UpdateForum";
                query.CommandType = CommandType.StoredProcedure;

                query.CreateParameter<int>("@ForumID", forumID, SqlDbType.Int);
                query.CreateParameter<string>("@CodeName", codeName, SqlDbType.NVarChar, 128);
                query.CreateParameter<string>("@ForumName", forumName, SqlDbType.NVarChar, 1024);
                query.CreateParameter<int>("@ForumType", (int)forumType, SqlDbType.TinyInt);
                query.CreateParameter<string>("@Password", password, SqlDbType.NVarChar, 64);
                query.CreateParameter<string>("@LogoUrl", logoUrl, SqlDbType.NVarChar, 256);
                query.CreateParameter<string>("@ThemeID", themeID, SqlDbType.NVarChar, 64);
                query.CreateParameter<string>("@Readme", readme, SqlDbType.NText);
                query.CreateParameter<string>("@Description", description, SqlDbType.NText);
                query.CreateParameter<int>("@ColumnSpan", columnSpan, SqlDbType.TinyInt);
                query.CreateParameter<int>("@SortOrder", sortOrder, SqlDbType.Int);
                query.CreateParameter<string>("@ExtendedAttributes", forumExtendedDatas.ToString(), SqlDbType.NText);

                query.CreateParameter<int>("@ErrorCode", SqlDbType.Int, ParameterDirection.ReturnValue);

                query.ExecuteNonQuery();
                return (int)query.Parameters["@ErrorCode"].Value;
            }
        }
Ejemplo n.º 21
0
 public UserInfo(string username, string password, ForumType type)
 {
     UserName  = username;
     Password  = password;
     FromForum = type;
 }
Ejemplo n.º 22
0
 public static ForumTypeInfo ForumTypeInfo_Get(ForumType model)
 {
     return new ForumTypeBLL().ForumTypeInfo_Get(model);
 }
Ejemplo n.º 23
0
 public static bool ForumType_Upd(ForumType model)
 {
     return new ForumTypeBLL().ForumType_Upd(model);
 }
Ejemplo n.º 24
0
 public static List<ForumType> ForumType_List(ForumType ft)
 {
     return new ForumTypeBLL().ForumType_List(ft);
 }
Ejemplo n.º 25
0
        public static bool ForumType_Upd(ForumType model)
        {
            try
            {
                using (var conn = DbHelper.CCService())
                {
                    var p = new DynamicParameters();
                    p.Add("@ForumTypeID", model.ForumTypeID);
                    p.Add("@Title", model.Title);
                    p.Add("@IsEssence", model.IsEssence);
                    p.Add("@Brief", model.Brief);
                    p.Add("@IsPublic", model.IsPublic);
                    p.Add("@TeachingClassID", model.TeachingClassID);
                    p.Add("@OCID", model.OCID);
                    p.Add("@UserID", model.UserID);
                    conn.Execute("ForumType_Upd", p, commandType: CommandType.StoredProcedure);

                    return true;
                }
            }
            catch (Exception e)
            {
                return false;
            }
        }
Ejemplo n.º 26
0
 public static ForumTypeInfo ForumTypeInfo_Get(ForumType model)
 {
     return(new ForumTypeBLL().ForumTypeInfo_Get(model));
 }
Ejemplo n.º 27
0
        public static ForumType ForumType_ADD(ForumType model)
        {
            if (!UserService.OC_IsRole(model.OCID ))
            {
                return null;
            }

            return new ForumTypeBLL().ForumType_ADD(model);
        }
Ejemplo n.º 28
0
 /// <summary>
 /// 论坛版块删除
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public static bool ForumType_Del(ForumType model)
 {
     try
     {
         using (var conn = DbHelper.CCService())
         {
             var p = new DynamicParameters();
             p.Add("@ForumTypeID", model.ForumTypeID);
             p.Add("@OCID",model.OCID);
             p.Add("@UserID", model.UserID);
             conn.Execute("ForumType_Del", p, commandType: CommandType.StoredProcedure);
         }
         return true;
     }
     catch (Exception e)
     {
         return false;
     }
 }
Ejemplo n.º 29
0
        public override int UpdateForum(int forumID, string codeName, string forumName, ForumType forumType, string password, string logoUrl
                                        , string readme, string description, string themeID, int columnSpan, int sortOrder, ForumExtendedAttribute forumExtendedDatas)
        {
            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = "bx_v5_UpdateForum";
                query.CommandType = CommandType.StoredProcedure;

                query.CreateParameter <int>("@ForumID", forumID, SqlDbType.Int);
                query.CreateParameter <string>("@CodeName", codeName, SqlDbType.NVarChar, 128);
                query.CreateParameter <string>("@ForumName", forumName, SqlDbType.NVarChar, 1024);
                query.CreateParameter <int>("@ForumType", (int)forumType, SqlDbType.TinyInt);
                query.CreateParameter <string>("@Password", password, SqlDbType.NVarChar, 64);
                query.CreateParameter <string>("@LogoUrl", logoUrl, SqlDbType.NVarChar, 256);
                query.CreateParameter <string>("@ThemeID", themeID, SqlDbType.NVarChar, 64);
                query.CreateParameter <string>("@Readme", readme, SqlDbType.NText);
                query.CreateParameter <string>("@Description", description, SqlDbType.NText);
                query.CreateParameter <int>("@ColumnSpan", columnSpan, SqlDbType.TinyInt);
                query.CreateParameter <int>("@SortOrder", sortOrder, SqlDbType.Int);
                query.CreateParameter <string>("@ExtendedAttributes", forumExtendedDatas.ToString(), SqlDbType.NText);

                query.CreateParameter <int>("@ErrorCode", SqlDbType.Int, ParameterDirection.ReturnValue);

                query.ExecuteNonQuery();
                return((int)query.Parameters["@ErrorCode"].Value);
            }
        }