public ApiMessage <string> Save(staff user) { if (string.IsNullOrEmpty(user.ID)) { user.ID = Guid.NewGuid().ToString(); user.CreateDate = DateTime.Now; user.Phone = user.Phone; user.PassWord = Encrypt.MD5(user.PassWord); return(_dal.Add(user)); } else { if (user.PassWord.Split('-').Length < 5) { user.PassWord = Encrypt.MD5(user.PassWord); } return(_dal.Edit(user)); } }
private List <object> WriteStaffData(DataTable table) { List <object> result = new List <object>(); Random r = new Random(); Staff s = new Staff(); long num = s.SearchCount(d => d.staff_Id != 0); for (int i = 0; i < table.Rows.Count; i++) { staff sf = new staff() { staff_Id = 1, staff_TrueName = table.Rows[i][0].ToString(), staff_Email = table.Rows[i][1].ToString(), staff_Department = table.Rows[i][2].ToString(), staff_IsWrite = false, staff_IsDel = false, staff_OwnCompanyId = table.Rows[i][3].ToString(), staff_Username = table.Rows[i][3].ToString() + (num + i) + r.Next(10), staff_Password = Md5.GetMd5Word("123456"), }; if (s.SearchCount(d => d.staff_TrueName == sf.staff_TrueName && d.staff_Email == sf.staff_Email && d.staff_Department == sf.staff_Department && d.staff_OwnCompanyId == sf.staff_OwnCompanyId && d.staff_IsDel == false) == 0) { try { s.Add(sf); } catch (Exception ex) { if (result.Count == 0) { result.Add(10); result.Add("导入成功!但有点数据未被导入...."); result.Add("sf"); } result.Add(sf.staff_TrueName); result.Add(sf.staff_Email); result.Add(sf.staff_Department); result.Add(sf.staff_OwnCompanyId); result.Add(ex.Message); } } else { if (result.Count == 0) { result.Add(10); result.Add("导入完成!但有点数据未被导入...."); result.Add("sf"); } result.Add(sf.staff_TrueName); result.Add(sf.staff_Email); result.Add(sf.staff_Department); result.Add(sf.staff_OwnCompanyId); result.Add("数据已存在!"); } } if (result.Count == 0) { result.Add(11); result.Add("导入成功!"); } return(result); }
public List <object> SubmitKey(string datas, long id, long testInfoId) { List <object> result = new List <object>(); try { string[] data = datas.Substring(0, datas.Length - 1).Split(','); string[] qId = new string[data.Length]; string[] keys = new string[data.Length]; for (int i = 0; i < data.Length; i++) { qId[i] = data[i].Split('=')[0]; keys[i] = data[i].Split('=')[1]; } for (int i = 0; i <= data.Length; i++) { for (int k = i + 1; k < data.Length; k++) { if (Convert.ToInt32(qId[i]) > Convert.ToInt32(qId[k])) { string nark = qId[i]; qId[i] = qId[k]; qId[k] = nark; string temp = keys[i]; keys[i] = keys[k]; keys[k] = temp; } } } key ky = new key(); Type myData = typeof(key); for (int i = 0; i < data.Length; i++) { string value = "key_key" + (i + 1); foreach (PropertyInfo info in myData.GetProperties()) { if (info.Name == value) { info.SetValue(ky, keys[i]); } } } ky.key_StaffId = id; ky.key_TestInfoId = testInfoId; ky.key_IsDel = false; base.Add(ky); Staff sf = new Staff(); staff s = sf.Search(d => d.staff_Id == id && d.staff_IsDel == false)[0]; s.staff_IsWrite = true; sf.Modify(s, "staff_IsWrite"); result.Add(1); result.Add("提交成功!谢谢参与"); } catch { result.Add(0); result.Add("提交失败!系统未知错误....."); } return(result); }
/// <summary> /// /// </summary> /// <param name="user"></param> /// <param name="userType">1系统管理员</param> /// <returns></returns> public ApiMessage <staff> LoginOn(staff user) { return(_dal.LoginOn(user)); }
public int Add(staff staff) { return(dal.Add(staff)); }
public int Remove(staff t) { return(dal.Remove(t)); }