private Member_Account ToMemberAccount(CBK_SHERC_USERINFO model) { APIBLL api = new APIBLL(); Member_Account account = new Member_Account(); account.UserName = model.ENAME; account.Password = model.PWD; account.Email = model.EMAIL; account.Status = 2; string organ = model.SCHOOLID == null ? "" : model.SCHOOLID.ToString(); organ = api.ConvertKey("Organ", organ); if (!string.IsNullOrEmpty(organ)) account.OrganId = Convert.ToInt32(organ); account.Pic = model.IMAGES; account.Nickname = model.REALNAME; account.IsRealName = !string.IsNullOrEmpty(model.REALNAME); account.OutSourceId = model.ID; account.CreateDate = DateTime.Now; return account; }
private MemberBaseInfo ToMemberBaseInfo(CBK_SHERC_USERINFO model) { APIBLL api = new APIBLL(); MemberBaseInfo info = new MemberBaseInfo(); info.TeacherNo = model.TEACHNUMBER; info.RealName = model.REALNAME; if (!string.IsNullOrEmpty(model.TELE)) { if (model.TELE.Split('@').Length == 2) { info.Mobile = model.TELE.Split('@')[1]; info.Phone = model.TELE.Split('@')[0]; } else { info.Mobile = ""; info.Phone = ""; } } else { info.Mobile = ""; info.Phone = ""; } info.Address = string.IsNullOrEmpty(model.ADDRESS) ? "" : model.ADDRESS; info.PostCode = model.POST; info.CredentialsType = 57; info.CredentialsNumber = model.IDCARD; if (model.SEX == "男") info.Sex = 1; else info.Sex = 0; if (string.IsNullOrEmpty(model.BIRTHDAY)) info.Birthday = new DateTime(1900, 1, 1); else info.Birthday = Convert.ToDateTime(model.BIRTHDAY); string nation = model.NATIONALID == null ? "" : model.NATIONALID.ToString(); nation = api.ConvertKey("Nation", nation); if (!string.IsNullOrEmpty(nation)) info.Nation = Convert.ToInt32(nation); else info.Nation = 0; string political = model.POLITICSID == null ? "" : model.POLITICSID.ToString(); political = api.ConvertKey("Political", political); if (!string.IsNullOrEmpty(political)) info.PoliticalStatus = Convert.ToInt32(political); else info.PoliticalStatus = 0; string region = model.QUXIANID == null ? "" : model.QUXIANID.ToString();//RegionId是区县Id region = api.ConvertKey("Organ", region); if (!string.IsNullOrEmpty(region)) info.RegionId = Convert.ToInt32(region); else info.RegionId = 0; string organ = model.SCHOOLID == null ? "" : model.SCHOOLID.ToString(); organ = api.ConvertKey("Organ", organ); if (!string.IsNullOrEmpty(organ)) info.Organid = Convert.ToInt32(organ); else info.Organid = 0; info.StudySection = model.XUEDUANID; info.TraningObject = model.TrainingObjectID; info.EduLevel = model.XUELIID; info.EduDegree = model.XUEWEIID; info.EduMajor = model.ZYDM; info.GraduateSchool = model.SchoolTag; info.GraduateTime = model.TIMESOFGRADUATE; info.CreateDate = DateTime.Now; return info; }
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); }