Beispiel #1
0
        public bool SaveSurveyRecord(SurveyRecordInfo surveyrecordinfo)
        {
            int           count   = surveyrecordinfo.Answer.Rows.Count;
            StringBuilder builder = new StringBuilder();

            builder.Append("INSERT INTO PE_SurveyRecord");
            builder.Append(surveyrecordinfo.SurveyId.ToString());
            builder.Append(" (");
            builder.Append("SurveyID");
            builder.Append(", UserName");
            builder.Append(", IP");
            builder.Append(", SubmitTime");
            if (count != 0)
            {
                for (int i = 0; i < count; i++)
                {
                    builder.Append(", Q" + surveyrecordinfo.Answer.Rows[i]["QuestionId"]);
                    if (((DataConverter.CLng(surveyrecordinfo.Answer.Rows[i]["QuestionType"]) == 2) || (DataConverter.CLng(surveyrecordinfo.Answer.Rows[i]["QuestionType"]) == 3)) && (DataConverter.CLng(surveyrecordinfo.Answer.Rows[i]["InputType"]) != 0))
                    {
                        builder.Append(", Q" + surveyrecordinfo.Answer.Rows[i]["QuestionId"] + "Input");
                    }
                }
            }
            builder.Append(")");
            builder.Append(" VALUES(");
            builder.Append(surveyrecordinfo.SurveyId.ToString());
            builder.Append(", '");
            builder.Append(DBHelper.FilterBadChar(surveyrecordinfo.UserName));
            builder.Append("', '");
            builder.Append(DBHelper.FilterBadChar(surveyrecordinfo.IP));
            builder.Append("', '");
            builder.Append(surveyrecordinfo.SubmitTime.ToString());
            builder.Append("'");
            if (count != 0)
            {
                for (int j = 0; j < count; j++)
                {
                    builder.Append(", '" + surveyrecordinfo.Answer.Rows[j]["Option"] + "'");
                    if (((DataConverter.CLng(surveyrecordinfo.Answer.Rows[j]["QuestionType"]) == 2) || (DataConverter.CLng(surveyrecordinfo.Answer.Rows[j]["QuestionType"]) == 3)) && (DataConverter.CLng(surveyrecordinfo.Answer.Rows[j]["InputType"]) != 0))
                    {
                        builder.Append(", '" + surveyrecordinfo.Answer.Rows[j]["Input"] + "'");
                    }
                }
            }
            builder.Append(")");
            return(DBHelper.ExecuteSql(builder.ToString()));
        }
Beispiel #2
0
        private static SurveyRecordInfo SurveyRecordFromrdr(NullableDataReader rdr, DataTable dataTable)
        {
            SurveyRecordInfo info = new SurveyRecordInfo();

            info.RecordId   = rdr.GetInt32("RecordID");
            info.SurveyId   = rdr.GetInt32("SurveyID");
            info.UserName   = rdr.GetString("UserName");
            info.IP         = rdr.GetString("IP");
            info.SubmitTime = rdr.GetDateTime("SubmitTime");
            DataRow row = dataTable.NewRow();

            for (int i = 0; i < rdr.FieldCount; i++)
            {
                if (rdr.GetName(i).Contains("Q") || rdr.GetName(i).Contains("Input"))
                {
                    row[rdr.GetName(i)] = rdr[i];
                }
            }
            dataTable.Rows.Add(row);
            info.Answer = dataTable;
            return(info);
        }
        protected void RptAnswerList_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if ((e.Item.ItemType != ListItemType.AlternatingItem) && (e.Item.ItemType != ListItemType.Item))
            {
                return;
            }
            StringBuilder    builder  = new StringBuilder(0x80);
            Literal          literal  = e.Item.FindControl("LtrAnswerList") as Literal;
            SurveyRecordInfo dataItem = e.Item.DataItem as SurveyRecordInfo;

            builder.Append("<tr class='tdbg'>");
            builder.Append("<td>" + dataItem.IP + "</td>");
            string str  = "Q" + this.questionId.ToString();
            string name = str + "Input";

            switch (this.fieldInfo.QuestionType)
            {
            case 0:
            case 1:
            case 6:
            case 8:
            case 9:
                builder.Append("<td>" + dataItem.Answer.Rows[e.Item.ItemIndex][str].ToString() + "</td>");
                goto Label_0438;

            case 2:
            {
                int index = DataConverter.CLng(dataItem.Answer.Rows[e.Item.ItemIndex][str].ToString());
                if (index <= this.fieldInfo.Settings.Count)
                {
                    builder.Append("<td>" + DataSecurity.GetArrayValue(index, this.fieldInfo.Settings) + "</td>");
                    break;
                }
                builder.Append("<td>其他</td>");
                break;
            }

            case 3:
                builder.Append("<td>");
                foreach (string str3 in dataItem.Answer.Rows[e.Item.ItemIndex][str].ToString().Split(new char[] { ',' }))
                {
                    builder.Append(DataSecurity.GetArrayValue(DataConverter.CLng(str3), this.fieldInfo.Settings) + " ");
                }
                builder.Append("</td>");
                if (dataItem.Answer.Columns.Contains(name))
                {
                    builder.Append("<td>" + dataItem.Answer.Rows[e.Item.ItemIndex][name].ToString() + "</td>");
                }
                else
                {
                    builder.Append("<td></td>");
                }
                goto Label_0438;

            case 4:
                builder.Append("<td>" + this.fieldInfo.Settings[DataConverter.CLng(dataItem.Answer.Rows[e.Item.ItemIndex][str].ToString())] + "</td>");
                goto Label_0438;

            case 5:
                builder.Append("<td>");
                foreach (string str4 in dataItem.Answer.Rows[e.Item.ItemIndex][str].ToString().Split(new char[] { ',' }))
                {
                    builder.Append(DataSecurity.GetArrayValue(DataConverter.CLng(str4), this.fieldInfo.Settings) + " ");
                }
                builder.Append("</td>");
                goto Label_0438;

            case 7:
                if (DataConverter.CLng(dataItem.Answer.Rows[e.Item.ItemIndex][str].ToString()) != 0)
                {
                    builder.Append("<td>是</td>");
                }
                else
                {
                    builder.Append("<td>否</td>");
                }
                goto Label_0438;

            default:
                goto Label_0438;
            }
            if (dataItem.Answer.Columns.Contains(name))
            {
                builder.Append("<td>" + dataItem.Answer.Rows[e.Item.ItemIndex][name].ToString() + "</td>");
            }
            else
            {
                builder.Append("<td></td>");
            }
Label_0438:
            builder.Append("</tr>");
            literal.Text = builder.ToString();
        }
Beispiel #4
0
 private void SaveSurveyRecord(int surveyId)
 {
     if (surveyId == 0)
     {
         DynamicPage.WriteErrMsg("问卷调查ID错误!");
     }
     else
     {
         SurveyInfo surveyById = SurveyManager.GetSurveyById(surveyId);
         if (surveyById.IsOpen != 1)
         {
             DynamicPage.WriteErrMsg("问卷调查尚未启用!!!");
         }
         if (surveyById.EndTime != null)//.HasValue)
         {
             DateTime?endTime = surveyById.EndTime;
             DateTime now     = DateTime.Now;
             if (endTime.HasValue ? (endTime.GetValueOrDefault() < now) : false)
             {
                 DynamicPage.WriteErrMsg("问卷调查已经结束!!!");
             }
         }
         if (!SurveyManager.CheckLockUrl(base.Request.ServerVariables["HTTP_REFERER"], surveyById))
         {
             DynamicPage.WriteErrMsg("不允许从外部链接地址提交!!!");
         }
         if (SurveyManager.CheckRepeatIP(PEContext.Current.UserHostAddress, surveyId, surveyById))
         {
             DynamicPage.WriteErrMsg("同一用户不允许填写问卷调查超过" + surveyById.IPRepeat.ToString() + "次!!!");
         }
         if (!string.IsNullOrEmpty(surveyById.SetPassword) && (surveyById.SetPassword != base.Request.Form["SurveyPassword"].ToString()))
         {
             DynamicPage.WriteErrMsg("问卷密码错误!!!");
         }
         if (SurveyManager.CheckIPLock(PEContext.Current.UserHostAddress, surveyById))
         {
             DynamicPage.WriteErrMsg("对不起!您的IP(" + PEContext.Current.UserHostAddress + ")被系统限定,您可以和站长联系。");
         }
         if (surveyById.NeedLogin == 1)
         {
             if (PEContext.Current.User.Identity.IsAuthenticated)
             {
                 if (surveyById.PresentPoint != 0)
                 {
                     int userId = PEContext.Current.User.UserInfo.UserId;
                     Users.Update(userId, "UserPoint", (PEContext.Current.User.UserInfo.UserPoint + surveyById.PresentPoint).ToString());
                     UserPointLogInfo userPointLogInfo = new UserPointLogInfo();
                     userPointLogInfo.IncomePayOut = 1;
                     userPointLogInfo.InfoId       = 0;
                     userPointLogInfo.Inputer      = "System";
                     userPointLogInfo.IP           = PEContext.Current.UserHostAddress;
                     userPointLogInfo.LogId        = UserPointLog.GetTotalInComeAndPayOutAll().Count;
                     userPointLogInfo.LogTime      = DateTime.Now;
                     userPointLogInfo.Memo         = "";
                     userPointLogInfo.ModuleType   = 9;
                     userPointLogInfo.Point        = surveyById.PresentPoint;
                     userPointLogInfo.Remark       = "参与“" + surveyById.SurveyName + "”--问卷调查获得奖励点数";
                     userPointLogInfo.Times        = 1;
                     userPointLogInfo.UserName     = PEContext.Current.User.UserInfo.UserName;
                     UserPointLog.Add(userPointLogInfo);
                 }
             }
             else
             {
                 string absoluteUri = HttpContext.Current.Request.Url.AbsoluteUri;
                 BasePage.ResponseRedirect("../User/Login.aspx?ReturnUrl=" + HttpUtility.UrlEncode(absoluteUri));
             }
         }
         IList <SurveyFieldInfo> fieldList        = SurveyField.GetFieldList(surveyId);
         SurveyRecordInfo        surveyrecordinfo = new SurveyRecordInfo();
         DataTable table = new DataTable();
         table.Columns.Add("Option", typeof(string));
         table.Columns.Add("Input", typeof(string));
         table.Columns.Add("QuestionType", typeof(int));
         table.Columns.Add("InputType", typeof(int));
         table.Columns.Add("QuestionId", typeof(int));
         foreach (SurveyFieldInfo info4 in fieldList)
         {
             string answer = DataSecurity.FilterBadChar(base.Request.Form["Q" + info4.QuestionId]);
             this.CheckForm(info4, answer);
             DataRow row = table.NewRow();
             row["Option"]       = answer;
             row["QuestionType"] = info4.QuestionType;
             row["InputType"]    = info4.InputType;
             row["QuestionId"]   = info4.QuestionId;
             if (info4.InputType > 0)
             {
                 string str3 = DataSecurity.FilterBadChar(base.Request.Form["Q" + info4.QuestionId + "Input"]);
                 row["Input"] = str3;
             }
             if (((info4.QuestionType == 2) || (info4.QuestionType == 4)) || (info4.QuestionType == 7))
             {
                 SurveyVote.Vote(surveyId, info4.QuestionId, DataConverter.CLng(answer));
             }
             if ((info4.QuestionType == 3) || (info4.QuestionType == 5))
             {
                 foreach (string str4 in answer.Split(new char[] { ',' }))
                 {
                     SurveyVote.Vote(surveyId, info4.QuestionId, DataConverter.CLng(str4));
                 }
             }
             table.Rows.Add(row);
         }
         surveyrecordinfo.Answer     = table;
         surveyrecordinfo.UserName   = PEContext.Current.User.UserInfo.UserName;
         surveyrecordinfo.IP         = PEContext.Current.UserHostAddress;
         surveyrecordinfo.SubmitTime = DateTime.Now;
         surveyrecordinfo.SurveyId   = surveyId;
         if (!SurveyRecord.SaveSurveyRecord(surveyrecordinfo))
         {
             DynamicPage.WriteErrMsg("提交问卷失败!");
         }
         else
         {
             DynamicPage.WriteSuccessMsg("提交问卷成功!", "");
         }
     }
 }
Beispiel #5
0
 public static bool SaveSurveyRecord(SurveyRecordInfo surveyrecordinfo)
 {
     return(dal.SaveSurveyRecord(surveyrecordinfo));
 }