Ejemplo n.º 1
0
        public static string CreatePoll(string pollItemName, int multiple, int maxchoices, int visiblepoll, int allowview, string enddatetime, int tid, string[] pollitem, int userid)
        {
            string        result        = null;
            StringBuilder stringBuilder = new StringBuilder("");

            for (int i = 0; i < pollitem.Length; i++)
            {
                stringBuilder.Append("0\r\n");
            }
            string text = Utils.HtmlEncode(pollItemName);

            if (text != "")
            {
                if (multiple <= 0)
                {
                    multiple = 0;
                }
                if (multiple == 1 && maxchoices > pollitem.Length)
                {
                    maxchoices = pollitem.Length;
                }
                if (!Polls.CreatePoll(tid, multiple, pollitem.Length, text.Trim(), stringBuilder.ToString().Trim(), enddatetime, userid, maxchoices, visiblepoll, allowview))
                {
                    result = "投票错误";
                }
            }
            else
            {
                result = "投票项为空";
            }
            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 创建投票
        /// </summary>
        /// <param name="pollItemName"></param>
        /// <param name="multiple"></param>
        /// <param name="maxchoices"></param>
        /// <param name="visiblepoll"></param>
        /// <param name="enddatetime"></param>
        /// <param name="tid"></param>
        /// <param name="pollitem"></param>
        /// <param name="userid"></param>
        /// <returns></returns>
        public static string CreatePoll(string pollItemName, int multiple, int maxchoices, int visiblepoll, int allowview, string enddatetime, int tid, string[] pollitem, int userid)
        {
            string        msg           = null;
            StringBuilder itemvaluelist = new StringBuilder("");

            // 生成以回车换行符为分割的项目与结果列
            for (int i = 0; i < pollitem.Length; i++)
            {
                itemvaluelist.Append("0\r\n");
            }

            string PollItemname = Utils.HtmlEncode(pollItemName);

            if (PollItemname != "")
            {
                if (multiple <= 0)
                {
                    multiple = 0;
                }

                if (multiple == 1 && maxchoices > pollitem.Length)
                {
                    maxchoices = pollitem.Length;
                }

                if (!Polls.CreatePoll(tid, multiple, pollitem.Length, PollItemname.Trim(), itemvaluelist.ToString().Trim(), enddatetime, userid, maxchoices, visiblepoll, allowview))
                {
                    msg = "投票错误";
                }
            }
            else
            {
                msg = "投票项为空";
            }

            return(msg);
        }