private bool GetTurtor(uint uAccno, out UNITUTOR res) { res = new UNITUTOR(); REQUESTCODE uResponse = REQUESTCODE.EXECUTE_FAIL; TUTORREQ vrGet = new TUTORREQ(); vrGet.dwStudentAccNo = uAccno; UNITUTOR[] vtRes; uResponse = m_Request.Account.TutorGet(vrGet, out vtRes); if (uResponse == REQUESTCODE.EXECUTE_SUCCESS && vtRes != null && vtRes.Length > 0) { res = vtRes[0]; return(true); } return(false); //return null; }
void Import(string szFilePath, string szErrListRawFile, out uint nImported, out uint nFailed) { ErrorLines = new ArrayList(); nImported = 0; nFailed = 0; string strline; StreamWriter tWrite = new StreamWriter(szErrListRawFile, false, Encoding.GetEncoding("gb2312")); System.IO.StreamReader mysr = new StreamReader(Server.MapPath(szFilePath), Encoding.GetEncoding("gb2312")); while ((strline = mysr.ReadLine()) != null) { string[] szList = strline.Split(','); if (szList.Length < 8) { continue; } string szSLogonName = szList[0]; string szSTrueName = szList[1]; string szSHandPhone = szList[2]; string szSEmail = szList[3]; string szTLogonName = szList[4]; string szTTrueName = szList[5]; string szTHandPhone = szList[6]; string szTEmail = szList[7]; UNIACCOUNT studentAcc = new UNIACCOUNT(); UNIACCOUNT teacherAcc = new UNIACCOUNT(); if (GetAccByLogonName(szSLogonName.Trim(), out studentAcc, true) && GetAccByLogonName(szTLogonName.Trim(), out teacherAcc)) { int uAuto = ConfigConst.GCTurtorReacher; if (uAuto == 1) { TUTORREQ tutorReq = new TUTORREQ(); tutorReq.dwTutorID = teacherAcc.dwAccNo; UNITUTOR[] vtTutor; if (m_Request.Account.TutorGet(tutorReq, out vtTutor) == REQUESTCODE.EXECUTE_SUCCESS && vtTutor != null && vtTutor.Length > 0) { } else { UNITUTOR setTutor = new UNITUTOR(); setTutor.dwAccNo = teacherAcc.dwAccNo; setTutor.szTrueName = teacherAcc.szTrueName; RESEARCHTEST setResarch = new RESEARCHTEST(); setResarch.szRTName = teacherAcc.szTrueName; setResarch.dwRTKind = (uint)RESEARCHTEST.DWRTKIND.RTKIND_RTASK; UNIGROUP setGroup = new UNIGROUP(); setGroup.dwKind = (uint)UNIGROUP.DWKIND.GROUPKIND_RERV; setGroup.szName = teacherAcc.szTrueName + ConfigConst.GCTutorName + "组"; if (m_Request.Group.SetGroup(setGroup, out setGroup) == REQUESTCODE.EXECUTE_SUCCESS) { setResarch.dwGroupID = setGroup.dwGroupID; } setResarch.szRTName = setTutor.szTrueName + ConfigConst.GCReachTestName; setResarch.dwLeaderID = setTutor.dwAccNo; setResarch.szLeaderName = setTutor.szTrueName; if (m_Request.Reserve.SetResearchTest(setResarch, out setResarch) == REQUESTCODE.EXECUTE_SUCCESS) { // m_Request.Account.TutorSet(setTutor); } } } else { TUTORREQ tutorReq = new TUTORREQ(); tutorReq.dwTutorID = teacherAcc.dwAccNo; UNITUTOR[] vtTutor; if (m_Request.Account.TutorGet(tutorReq, out vtTutor) == REQUESTCODE.EXECUTE_SUCCESS && vtTutor != null && vtTutor.Length > 0) { } else { EXTIDENTACC setTutor = new EXTIDENTACC(); setTutor.dwAccNo = teacherAcc.dwAccNo; setTutor.szTrueName = teacherAcc.szTrueName; RESEARCHTEST setResarch = new RESEARCHTEST(); setResarch.szRTName = teacherAcc.szTrueName; setResarch.dwRTKind = (uint)RESEARCHTEST.DWRTKIND.RTKIND_RTASK; setResarch.szRTName = setTutor.szTrueName + ConfigConst.GCReachTestName; setResarch.dwLeaderID = setTutor.dwAccNo; setResarch.szLeaderName = setTutor.szTrueName; if (m_Request.Reserve.SetResearchTest(setResarch, out setResarch) == REQUESTCODE.EXECUTE_SUCCESS) { m_Request.Account.ExtIdentAccSet(setTutor); } } } TUTORSTUDENT turtorStudent = new TUTORSTUDENT(); turtorStudent.dwTutorID = teacherAcc.dwAccNo; turtorStudent.szTutorName = teacherAcc.szTrueName; turtorStudent.dwAccNo = studentAcc.dwAccNo; turtorStudent.dwStatus = ((uint)ADMINCHECK.DWCHECKSTAT.CHECKSTAT_ADMINOK); turtorStudent.szPID = studentAcc.szLogonName; turtorStudent.szTrueName = studentAcc.szTrueName; m_Request.Account.TutorStudentSet(turtorStudent); nImported = nImported + 1; } } tWrite.Close(); }
protected void Page_Load(object sender, EventArgs e) { string sAccno = Request["sLogonName"]; string tLogonName = Request["tLogonName"]; string szHandPhone = Request["Handphone"]; string szEmail = Request["email"]; Response.CacheControl = "no-cache"; UNIACCOUNT studentAcc = new UNIACCOUNT(); UNIACCOUNT teacherAcc = new UNIACCOUNT(); if (GetAccByLogonName(sAccno, out studentAcc) && GetAccByLogonName(tLogonName, out teacherAcc)) { int uAuto = ConfigConst.GCTurtorReacher; if (uAuto == 1) { TUTORREQ tutorReq = new TUTORREQ(); tutorReq.dwTutorID = teacherAcc.dwAccNo; UNITUTOR[] vtTutor; if (m_Request.Account.TutorGet(tutorReq, out vtTutor) == REQUESTCODE.EXECUTE_SUCCESS && vtTutor != null && vtTutor.Length > 0) { } else { UNITUTOR setTutor = new UNITUTOR(); setTutor.dwAccNo = teacherAcc.dwAccNo; setTutor.szTrueName = teacherAcc.szTrueName; RESEARCHTEST setResarch = new RESEARCHTEST(); setResarch.szRTName = teacherAcc.szTrueName; setResarch.dwRTKind = (uint)RESEARCHTEST.DWRTKIND.RTKIND_RTASK; UNIGROUP setGroup = new UNIGROUP(); setGroup.dwKind = (uint)UNIGROUP.DWKIND.GROUPKIND_RERV; setGroup.szName = teacherAcc.szTrueName + ConfigConst.GCTutorName + "组"; if (m_Request.Group.SetGroup(setGroup, out setGroup) == REQUESTCODE.EXECUTE_SUCCESS) { setResarch.dwGroupID = setGroup.dwGroupID; } setResarch.szRTName = setTutor.szTrueName + ConfigConst.GCReachTestName; setResarch.dwHolderID = setTutor.dwAccNo; setResarch.szHolderName = setTutor.szTrueName; if (m_Request.Reserve.SetResearchTest(setResarch, out setResarch) == REQUESTCODE.EXECUTE_SUCCESS) { //m_Request.Account.TutorSet(setTutor); custom } } } TUTORSTUDENT turtorStudent = new TUTORSTUDENT(); turtorStudent.dwTutorID = teacherAcc.dwAccNo; turtorStudent.szTutorName = teacherAcc.szTrueName; turtorStudent.dwAccNo = studentAcc.dwAccNo; turtorStudent.dwStatus = ((uint)ADMINCHECK.DWCHECKSTAT.CHECKSTAT_ADMINOK); turtorStudent.szPID = studentAcc.szLogonName; turtorStudent.szTrueName = studentAcc.szTrueName; if (szHandPhone != null) { studentAcc.szHandPhone = szHandPhone; } if (szEmail != null) { studentAcc.szEmail = szEmail; } m_Request.Account.Set(studentAcc, out studentAcc); if (m_Request.Account.TutorStudentSet(turtorStudent) == REQUESTCODE.EXECUTE_SUCCESS) { Response.Write("{\"message\":\"succ\"}"); } else { Response.Write("{\"message\":\"" + m_Request.szErrMessage + "\"}"); } } else { Response.Write("{\"message\":\"" + ConfigConst.GCTutorName + "信息未指定" + "\"}"); } }
protected void Page_Load(object sender, EventArgs e) { string szTerm = Request["term"]; string szType = Request["Type"]; Response.CacheControl = "no-cache"; ACCREQ vrGet = new ACCREQ(); UNIACCOUNT[] vtAccount; if (szType == null || szType == "") { vrGet.szTrueName = szTerm; // vrGet.dwGetType = (uint)ACCREQ.DWGETTYPE.ACCGET_BYTRUENAME; } else if (szType.ToLower() == "logonname") { vrGet.szLogonName = szTerm;// (uint)ACCREQ.DWGETTYPE.ACCGET_BYLOGONNAME; } else if (szType.ToLower() == "truename") { vrGet.szTrueName = szTerm;// (uint)ACCREQ.DWGETTYPE.truname; } uint dwIdent = ToUint(Request["dwIdent"]); if (Request["dwIdent"] != null && dwIdent != 0) { vrGet.dwIdent = dwIdent; } // vrGet.szGetID = szTerm; vrGet.szReqExtInfo.dwNeedLines = 10; //最多10条 if (m_Request.Account.Get(vrGet, out vtAccount) == REQUESTCODE.EXECUTE_SUCCESS && vtAccount != null) { MyString szOut = new MyString(); szOut += "["; for (int i = 0; i < vtAccount.Length; i++) { string szTurotorIs = ""; string szTurtorName = ""; string szTurTorLogonName = ""; UNITUTOR turtor = new UNITUTOR(); if (GetTurtor((uint)vtAccount[i].dwAccNo, out turtor)) { szTurtorName = ConfigConst.GCTutorName + ":" + turtor.szTrueName; szTurotorIs = "true"; UNIACCOUNT getTurAcc = new UNIACCOUNT(); if (GetAccByAccno(turtor.dwAccNo.ToString(), out getTurAcc)) { szTurTorLogonName = getTurAcc.szLogonName.ToString(); } } else { szTurtorName = ConfigConst.GCTutorName + "未指定:"; szTurotorIs = "false"; } szOut += "{\"id\":\"" + vtAccount[i].dwAccNo + "\",\"label\": \"" + vtAccount[i].szTrueName + ";" + szTurtorName + "(" + vtAccount[i].szDeptName + ")" + "\",\"szIsExistTur\": \"" + szTurotorIs + "\",\"szTurtorID\": \"" + vtAccount[i].dwTutorID.ToString() + "\",\"szTrueName\": \"" + vtAccount[i].szTrueName + "\",\"szTurTor\": \"" + szTurtorName + "\",\"szTurTorLogonName\": \"" + szTurTorLogonName + "\",\"szTrueName\": \"" + vtAccount[i].szTrueName + "\",\"szHandPhone\": \"" + vtAccount[i].szHandPhone + "\",\"szTurtorTrueName\": \"" + turtor.szTrueName + "\",\"szTel\": \"" + vtAccount[i].szTel + "\",\"szEmail\": \"" + vtAccount[i].szEmail + "\"}"; //szOut += "{\"id\":\"" + vtAccount[i].dwAccNo + "\",\"label\": \"" + vtAccount[i].szTrueName + "\"}"; if (i < vtAccount.Length - 1) { szOut += ","; } } szOut += "]"; Response.Write(szOut); } else { Response.Write("[{}]"); } }
void Import(string szFilePath, string szErrListRawFile, out uint nImported, out uint nFailed) { ErrorLines = new ArrayList(); nImported = 0; nFailed = 0; string strline; StreamWriter tWrite = new StreamWriter(szErrListRawFile, false, Encoding.GetEncoding("gb2312")); System.IO.StreamReader mysr = new StreamReader(Server.MapPath(szFilePath), Encoding.GetEncoding("gb2312")); REQUESTCODE uResponse = REQUESTCODE.EXECUTE_FAIL; System.IO.StringWriter swCSV = new System.IO.StringWriter(); bool bAllRight = true; int count = 0; while ((strline = mysr.ReadLine()) != null) { count = count + 1; string[] szList = strline.Split(','); if (szList.Length < 8) { continue; } string researchSN = szList[0]; string researchName = szList[1]; string szLogonName = szList[2]; string szTrueName = szList[3]; string szDeptName = szList[4]; string szDate = szList[5]; string szDeptName2 = szList[6]; string szLevel = szList[7]; UNIACCOUNT studentAcc; UNIACCOUNT[] accList; string szLogonNameError = "不能存在账户:"; string szMemo = ""; if (GetAccByLogonName(szLogonName.Trim(), out studentAcc, true)) { } else { accList = GetAccByTrueName(szTrueName.Trim()); if (accList == null) { szMemo = "账户不存在"; } else if (accList.Length > 1) { for (int i = 0; i < accList.Length; i++) { szMemo += accList[i].szLogonName + "," + accList[i].szTrueName + "," + accList[i].szDeptName + ";"; } } else { studentAcc = accList[0]; } } if (studentAcc.dwAccNo == null) { System.Text.StringBuilder sbText = new System.Text.StringBuilder(); sbText = AppendCSVFields(sbText, researchSN); sbText = AppendCSVFields(sbText, researchName); sbText = AppendCSVFields(sbText, szLogonName); sbText = AppendCSVFields(sbText, szTrueName); sbText = AppendCSVFields(sbText, szDeptName); //协助 sbText = AppendCSVFields(sbText, szDate); ////使用 sbText = AppendCSVFields(sbText, szDeptName2); //样品费 sbText = AppendCSVFields(sbText, szLevel); //样品费 sbText = AppendCSVFields(sbText, szMemo); //样品费 sbText.Remove(sbText.Length - 1, 1); swCSV.WriteLine(sbText.ToString()); if (count != 1) { bAllRight = false; } continue; } UNIDEPT dept; RESEARCHTEST setValue = new RESEARCHTEST(); if (GetDeptByName(szDeptName, out dept)) { setValue.dwDeptID = dept.dwID; } else { setValue.dwDeptID = 0; } setValue.dwLeaderID = studentAcc.dwAccNo; setValue.dwLeaderID = studentAcc.dwAccNo; setValue.szLeaderName = studentAcc.szTrueName; setValue.szLeaderName = studentAcc.szTrueName; setValue.szRTName = researchName; setValue.szRTSN = researchSN; setValue.dwBeginDate = GetDate(szDate); setValue.dwRTLevel = Parse(szLevel); setValue.szFromUnit = szDeptName2; UNIGROUP setGroup; if (NewGroup(setValue.szRTName, (uint)UNIGROUP.DWKIND.GROUPKIND_RERV, out setGroup)) { setValue.dwGroupID = setGroup.dwGroupID; } else { continue; } uResponse = m_Request.Reserve.SetResearchTest(setValue, out setValue); if (uResponse == REQUESTCODE.EXECUTE_SUCCESS) { nImported = nImported + 1; AddGroupMember(setGroup.dwGroupID, setValue.dwLeaderID, (uint)GROUPMEMBER.DWKIND.MEMBERKIND_PERSONAL); UNITUTOR setTutor = new UNITUTOR(); setTutor.dwAccNo = setValue.dwLeaderID; // m_Request.Account.TutorSet(setTutor); } else { szMemo = m_Request.szErrMessage; System.Text.StringBuilder sbText = new System.Text.StringBuilder(); sbText = AppendCSVFields(sbText, researchSN); sbText = AppendCSVFields(sbText, researchName); sbText = AppendCSVFields(sbText, szLogonName); sbText = AppendCSVFields(sbText, szTrueName); sbText = AppendCSVFields(sbText, szDeptName); //协助 sbText = AppendCSVFields(sbText, szDate); ////使用 sbText = AppendCSVFields(sbText, szDeptName2); //样品费 sbText = AppendCSVFields(sbText, szLevel); //样品费 sbText = AppendCSVFields(sbText, szMemo); //样品费 sbText.Remove(sbText.Length - 1, 1); swCSV.WriteLine(sbText.ToString()); bAllRight = false; uResponse = m_Request.Group.DelGroup(setGroup); } { szLogonNameError += szLogonName + ","; } } if (!bAllRight) { DownloadFile(Response, swCSV.GetStringBuilder(), "resarchTestImport.csv"); } swCSV.Close(); Response.End(); }