164 lines
6.3 KiB
C#
164 lines
6.3 KiB
C#
|
|
using System;
|
|||
|
|
using System.Data;
|
|||
|
|
using System.Configuration;
|
|||
|
|
using System.Collections;
|
|||
|
|
using System.Web;
|
|||
|
|
using System.Web.Security;
|
|||
|
|
using System.Web.UI;
|
|||
|
|
using System.Web.UI.WebControls;
|
|||
|
|
using System.Web.UI.WebControls.WebParts;
|
|||
|
|
using System.Web.UI.HtmlControls;
|
|||
|
|
using System.Data.OleDb;
|
|||
|
|
|
|||
|
|
using WeiSha.Common;
|
|||
|
|
|
|||
|
|
using Song.ServiceInterfaces;
|
|||
|
|
using Song.Entities;
|
|||
|
|
using System.Reflection;
|
|||
|
|
using System.Text.RegularExpressions;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
|
|||
|
|
namespace Song.Site.Manage.Questions
|
|||
|
|
{
|
|||
|
|
public partial class Questions_Input5 : Extend.CustomPage
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
int type=WeiSha.Common.Request.QueryString["type"].Int32 ?? 0;
|
|||
|
|
Song.Entities.Organization org = null;
|
|||
|
|
protected void Page_Load(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
protected void ExcelInput1_OnInput(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
org = Business.Do<IOrganization>().OrganCurrent();
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
DataTable dt = ExcelInput1.SheetDataTable;
|
|||
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
//throw new Exception();
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD>
|
|||
|
|
_inputData(dt.Rows[i]);
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>з<EFBFBD><D0B7>ظ<EFBFBD><D8B8>ؼ<EFBFBD>
|
|||
|
|
ExcelInput1.AddError(dt.Rows[i]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
Business.Do<IQuestions>().OnSave(null, EventArgs.Empty);
|
|||
|
|
Business.Do<IOutline>().OnSave(null, EventArgs.Empty);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><>ijһ<C4B3><D2BB><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><DDBC>뵽<EFBFBD><EBB5BD><EFBFBD>ݿ<EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="dr"></param>
|
|||
|
|
/// <param name="dl"></param>
|
|||
|
|
private void _inputData(DataRow dr)
|
|||
|
|
{
|
|||
|
|
Song.Entities.Questions obj = new Song.Entities.Questions();
|
|||
|
|
obj.Qus_IsUse = true;
|
|||
|
|
obj.Qus_Type = this.type;
|
|||
|
|
foreach (KeyValuePair<String, String> rel in ExcelInput1.DataRelation)
|
|||
|
|
{
|
|||
|
|
//Excel<65><6C><EFBFBD>е<EFBFBD>ֵ
|
|||
|
|
string column = dr[rel.Key].ToString();
|
|||
|
|
//<2F><><EFBFBD>ݿ<EFBFBD><DDBF>ֶε<D6B6><CEB5><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
string field = rel.Value;
|
|||
|
|
if (field == "Qus_ID")
|
|||
|
|
{
|
|||
|
|
if (column == string.Empty || column.Trim() == "") continue;
|
|||
|
|
int ques = Convert.ToInt32(column);
|
|||
|
|
Song.Entities.Questions isHavObj = Business.Do<IQuestions>().QuesSingle(ques);
|
|||
|
|
if (isHavObj != null) obj = isHavObj;
|
|||
|
|
}
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>Ѷȡ<D1B6>רҵ<D7A8><D2B5><EFBFBD><EFBFBD><EFBFBD>⽲<EFBFBD><E2BDB2>
|
|||
|
|
if (field == "Qus_Title")
|
|||
|
|
{
|
|||
|
|
if (string.IsNullOrEmpty(column) || column.Trim() == "") return;
|
|||
|
|
obj.Qus_Title = column;
|
|||
|
|
}
|
|||
|
|
if (field == "Qus_Diff") obj.Qus_Diff = Convert.ToInt16(column);
|
|||
|
|
if (field == "Sbj_Name")
|
|||
|
|
{
|
|||
|
|
Song.Entities.Subject subject = Business.Do<ISubject>().SubjectBatchAdd(org.Org_ID, column);
|
|||
|
|
if (subject != null)
|
|||
|
|
{
|
|||
|
|
obj.Sbj_Name = subject.Sbj_Name;
|
|||
|
|
obj.Sbj_ID = subject.Sbj_ID;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (field == "Cou_Name")
|
|||
|
|
{
|
|||
|
|
Song.Entities.Course course = Business.Do<ICourse>().CourseBatchAdd(org.Org_ID, obj.Sbj_ID, column);
|
|||
|
|
if (course != null) obj.Cou_ID = course.Cou_ID;
|
|||
|
|
}
|
|||
|
|
if (field == "Ol_Name")
|
|||
|
|
{
|
|||
|
|
Song.Entities.Outline outline = Business.Do<IOutline>().OutlineBatchAdd(org.Org_ID, obj.Sbj_ID, obj.Cou_ID, column);
|
|||
|
|
if (outline != null) obj.Ol_ID = outline.Ol_ID;
|
|||
|
|
}
|
|||
|
|
if (field == "Qus_Explain") obj.Qus_Explain = column;
|
|||
|
|
//Ψһֵ
|
|||
|
|
obj.Qus_UID = WeiSha.Common.Request.UniqueID();
|
|||
|
|
}
|
|||
|
|
//<2F>ٱ<EFBFBD><D9B1><EFBFBD>һ<EFBFBD>飬ȡ<E9A3AC><C8A1><EFBFBD><EFBFBD>
|
|||
|
|
int ansNum = 0;
|
|||
|
|
List<Song.Entities.QuesAnswer> ansItem = new List<QuesAnswer>();
|
|||
|
|
foreach (KeyValuePair<String, String> rel in ExcelInput1.DataRelation)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD>ݿ<EFBFBD><DDBF>ֶε<D6B6><CEB5><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
string field = rel.Value;
|
|||
|
|
Match match = new Regex(@"(Ans_Context)(\d+)").Match(field);
|
|||
|
|
if (match.Success)
|
|||
|
|
{
|
|||
|
|
//Excel<65><6C><EFBFBD>е<EFBFBD>ֵ
|
|||
|
|
string column = dr[rel.Key].ToString();
|
|||
|
|
if (column == string.Empty || column.Trim() == "") continue;
|
|||
|
|
Song.Entities.QuesAnswer ans = new Song.Entities.QuesAnswer();
|
|||
|
|
ans.Ans_Context = column;
|
|||
|
|
ans.Qus_UID = obj.Qus_UID;
|
|||
|
|
ansNum++;
|
|||
|
|
ansItem.Add(ans);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
obj.Qus_Title = tranTxt(obj.Qus_Title);
|
|||
|
|
int bracketsCount = new Regex(@"<22><>[^<5E><>]+<2B><>").Matches(obj.Qus_Title).Count;
|
|||
|
|
//<2F>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7>д<EFBFBD>
|
|||
|
|
string error = "";
|
|||
|
|
if (bracketsCount <= 0) error = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȱ<EFBFBD><C8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEA3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ű<EFBFBD>ʶ<EFBFBD><CAB6>";
|
|||
|
|
if (ansNum <= 0) error = "ȱ<>ٴ<EFBFBD><D9B4><EFBFBD><EFBFBD><EFBFBD>";
|
|||
|
|
if (ansNum < bracketsCount) error = string.Format("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEA3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>{0}<7D><>,<2C><><EFBFBD><EFBFBD>{1}<7D><>", bracketsCount, ansNum);
|
|||
|
|
//
|
|||
|
|
obj.Qus_IsError = error != "";
|
|||
|
|
obj.Qus_ErrorInfo = error;
|
|||
|
|
if (obj.Sbj_ID == 0) throw new Exception("<22><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>רҵ<D7A8><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|||
|
|
if (obj.Cou_ID == 0) throw new Exception("<22><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڿγ̲<CEB3><CCB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|||
|
|
//if (obj.Ol_ID == 0) throw new Exception("<22><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>½ڲ<C2BD><DAB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|||
|
|
if (org != null) obj.Org_ID = org.Org_ID;
|
|||
|
|
Business.Do<IQuestions>().QuesInput(obj, ansItem);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="txt"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
private string tranTxt(string txt)
|
|||
|
|
{
|
|||
|
|
txt = txt.Replace("(","<22><>");
|
|||
|
|
txt = txt.Replace(")", "<22><>");
|
|||
|
|
txt = txt.Replace("<22><>", "<22><> ");
|
|||
|
|
txt = Regex.Replace(txt, @"<22><>[^<5E><>]_+<2B><>", "<22><>______<5F><5F>");
|
|||
|
|
return txt;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|