public string TeacherUpdateReceive(byte[] userModelBytes, byte[] userNameBytes, byte[] logContentBytes, byte[] resultBytes) { bool TnF; string TS; int rst; try { CBK_SHERC_USERINFO model = (CBK_SHERC_USERINFO)(this.DeserializeObject(userModelBytes)); string userName = this.DeserializeObject(userNameBytes).ToString(); string logContent = this.DeserializeObject(logContentBytes).ToString(); string result = this.DeserializeObject(resultBytes).ToString(); Member_Account account = ToMemberAccount(model); MemberBaseInfo info = ToMemberBaseInfo(model); //if (account.OutSourceId == null || account.OutSourceId < 1) //{ // return string.Format("{0};{1};{2}", false, "用户编号不能为空", 0); //} if (string.IsNullOrEmpty(account.UserName)) { return string.Format("{0};{1};{2}", false, "账号不能为空", 0); } APIBLL api = new APIBLL(); //Member_Account tempModel = api.GetMemberAccountByOutId(Convert.ToInt32(account.OutSourceId)); Member_Account tempModel = api.GetMemberAccountByUserName(account.UserName); if (tempModel != null) { using (TransactionScope trans = new TransactionScope()) { int accountId = tempModel.Id; account.Id = accountId; info.AccountId = accountId; api.UpdateMemberAccount(account); api.UpdateMemberBaseInfo(info); api.UpdateSubject(account.Id, api.GetKeyByAccountId("Member_TeachSubject", accountId), api.ConvertKey("Member_TeachSubject", model.XUEKEID)); api.UpdateSection(account.Id, api.GetKeyByAccountId("Member_StudySection", accountId), api.ConvertKey("Member_StudySection", model.XUEDUANID)); api.UpdateGrade(account.Id, api.GetKeyByAccountId("Member_TeachGrade", accountId), api.ConvertKey("Member_TeachGrade", model.NIANJIID)); api.UpdateJob(account.Id, api.GetKeyByAccountId("Member_Job", accountId), api.ConvertKey("Member_Job", model.USERJOBID)); api.UpdateRank(account.Id, api.GetKeyByAccountId("Member_WorkRank", accountId), api.ConvertKey("Member_WorkRank", model.ZHICHENGID)); api.UpdateTrainingType(account.Id, api.GetKeyByAccountId("Member_TraningType", accountId), api.ConvertKey("Member_TraningType", model.TrainingTypeID)); api.UpdateGroup(account.Id, Convert.ToInt32(api.ConvertKey("Organ", model.QUXIANID.ToString())), Convert.ToInt32(api.ConvertKey("Organ", model.SCHOOLID.ToString())), api.GetKeyByAccountId("PlatformManager_Detail", accountId), this.ConvertGroupId(model.USERGroupsID)); trans.Complete(); TnF = true; TS = "更新成功!"; rst = accountId; this.WriteLog(TraceEventType.Information, 1, "更新教师,账号:" + account.UserName); } } else { using (TransactionScope trans = new TransactionScope()) { api.AddMemberAccount(account); info.AccountId = account.Id; api.AddMemberBaseInfo(info); api.UpdateSubject(account.Id, "", api.ConvertKey("Member_TeachSubject", model.XUEKEID)); api.UpdateSection(account.Id, "", api.ConvertKey("Member_StudySection", model.XUEDUANID)); api.UpdateGrade(account.Id, "", api.ConvertKey("Member_TeachGrade", model.NIANJIID)); api.UpdateJob(account.Id, "", api.ConvertKey("Member_Job", model.USERJOBID)); api.UpdateRank(account.Id, "", api.ConvertKey("Member_WorkRank", model.ZHICHENGID)); api.UpdateTrainingType(account.Id, "", api.ConvertKey("Member_TraningType", model.TrainingTypeID)); api.UpdateGroup(account.Id, Convert.ToInt32(api.ConvertKey("Organ", model.QUXIANID.ToString())), Convert.ToInt32(api.ConvertKey("Organ", model.SCHOOLID.ToString())), "", this.ConvertGroupId(model.USERGroupsID)); trans.Complete(); TnF = true; TS = "新增成功!"; rst = account.Id; this.WriteLog(TraceEventType.Information, 1, "新增教师,外部编号:" + account.OutSourceId); } } } catch (Exception e) { string msg = "userModelBytes={" + string.Join(",", userModelBytes) + "}\r\n" + "userNameBytes={" + string.Join(",", userNameBytes) + "}\r\n" + "logContentBytes={" + string.Join(",", logContentBytes) + "}\r\n" + "resultBytes={" + string.Join(",", resultBytes) + "}\r\n"; this.WriteLog(TraceEventType.Error, 0, e.ToString() + msg); TnF = false; TS = "更新失败!"; rst = 0; } TempClass tc = new TempClass(); tc.BIs = TnF; tc.Str = TS; tc.I = rst; return string.Format("{0};{1};{2}", tc.BIs, tc.Str, tc.I); }
public string TeacherDelReceive(byte[] UserIDBytes, byte[] userNameBytes, byte[] logContentBytes, byte[] resultBytes) { bool TnF; string TS; int rst; try { int outId = Convert.ToInt32(this.DeserializeObject(UserIDBytes)); string userName = this.DeserializeObject(userNameBytes).ToString(); string logContent = this.DeserializeObject(logContentBytes).ToString(); string result = this.DeserializeObject(resultBytes).ToString(); APIBLL api = new APIBLL(); using (TransactionScope trans = new TransactionScope()) { Member_Account tempModel = api.GetMemberAccountByOutId(outId); if (tempModel != null) { int accountId = tempModel.Id; api.DeleteMemberAccount(accountId); api.DeleteMemberBaseInfo(accountId); api.DeleteSubject(accountId); api.DeleteSection(accountId); api.DeleteGrade(accountId); api.DeleteJob(accountId); api.DeleteRank(accountId); api.DeleteTrainingType(accountId); trans.Complete(); TnF = true; TS = "删除成功!"; rst = accountId; this.WriteLog(TraceEventType.Information, 1, "删除教师"); } else { TnF = false; TS = "没有用户信息!"; rst = 0; } } } catch (Exception e) { this.WriteLog(TraceEventType.Error, 0, e.ToString()); TnF = false; TS = "删除失败!"; rst = 0; } TempClass tc = new TempClass(); tc.BIs = TnF; tc.Str = TS; tc.I = rst; return string.Format("{0};{1};{2}", tc.BIs, tc.Str, tc.I); }