//链表为物体信息 public void ExcelMaker(string fileName) { string path = GetFilePath(fileName); FileInfo file = new FileInfo(path); if (!file.Directory.Exists) { file.Directory.Create(); } EmployeeData en = new EmployeeData(); en.ID = 0; en.Name = "11"; for (int iter = 0; iter < EmployeeData.DayCount; iter++) { for (int jter = 0; jter < SignDateData.SignDateCount; jter++) { en.SignDateDatas[iter].SignDate[jter] = (iter * jter).ToString(); } } AllEmployee obj = new AllEmployee(); obj.Data.Add(en); obj.Data.Add(en); obj.Data.Add(en); string str = JsonUtility.ToJson(obj, true); File.WriteAllText(path + ".txt", str); PrintExcel(fileName); }
/// <summary> /// 审核用户是否存在并保存至Person表 /// </summary> /// <param name="userModel"></param> /// <param name="isEdit"></param> /// <returns></returns> public JsonResult CheckUser(AllEmployee userModel, string userID, string accessToken, string position, string mobilePhone) { var model = new ActionResultModel <string>(); model.isSuccess = false; //获取微信官方人员信息 U_WeChatUserID userIDInfo = new U_WeChatUserID(); var userInfo = Common.WeChatPush.WeChatTools.GetUserInfoByUserID(accessToken, userID); userIDInfo = Common.JsonHelper.JsonToModel <U_WeChatUserID>(userInfo); //取微信端手机号存入人员信息 mobilePhone = userIDInfo.mobile; string checkUser = _wl.CheckUser(userModel, userID, position, mobilePhone); if (checkUser == "1") { model.isSuccess = true; string focusResult = Common.WeChatPush.WeChatTools.GetAuthSucee(accessToken, userID); U_FocusResult resultMsg = Common.JsonHelper.JsonToModel <U_FocusResult>(focusResult); if (resultMsg.errcode == 0) { model.respnseInfo = "1";//关注成功 LogHelper.WriteLog("人员注册成功:" + userID + " " + resultMsg.errmsg); } else { model.respnseInfo = resultMsg.errmsg; LogHelper.WriteLog("人员注册失败:" + userID + " " + model.respnseInfo + " " + resultMsg.errcode); _wl.UpdateStatus(userModel.IDCard); //更改状态 } } else if (checkUser == "2") { model.isSuccess = false; model.respnseInfo = "人员注册失败!"; LogHelper.WriteLog("注册时人员保存失败:" + model.respnseInfo); } else if (checkUser == "3") { model.isSuccess = false; model.respnseInfo = "人事库中不存在该人员!"; } return(Json(model, JsonRequestBehavior.AllowGet)); }
public void PrintExcel(string fileName) { string path = GetFilePath(fileName); FileInfo fileinfo = new FileInfo(path + ".txt"); if (!fileinfo.Exists) { return; } string str = File.ReadAllText(path + ".txt"); AllEmployee data = JsonUtility.FromJson <AllEmployee>(str); XlsDocument xls = new XlsDocument(); //新建一个xls文档 xls.FileName = path; // @"D:\tests.xls";//设定文件名 //Add some metadata (visible from Excel under File -> Properties) xls.SummaryInformation.Author = "xyy"; //填加xls文件作者信息 xls.SummaryInformation.Subject = "test"; //填加文件主题信息 string sheetName = "Sheet0"; Worksheet sheet = xls.Workbook.Worksheets.Add(sheetName); //填加名为"chc 实例"的sheet页 Cells cells = sheet.Cells; //Cells实例是sheet页中单元格(cell)集合 //cells //表头 XF xf = xls.NewXF(); xf.TextDirection = TextDirections.LeftToRight; cells.Add(1, 1, "姓名//日期"); for (int iter = 2; iter < EmployeeData.DayCount + 2; iter++) { cells.Add(1, iter, (iter - 1).ToString()); } //内容 for (int iter = 0; iter < data.Data.Count; iter++) { WriteExcel(cells, data.Data[iter], iter * SignDateData.SignDateCount); } xls.Save(); }
/// <summary> /// 手动关注企业号 /// </summary> /// <param name="vguid"></param> /// <returns></returns> public bool UserFocusWeChat(string vguid, out string outString) { bool result = false; outString = string.Empty; using (SqlSugarClient _dbSql = SugarDao.SugarDao_LandaVSql.GetInstance()) { using (SqlSugarClient dbMsSql = SugarDao_MsSql.GetInstance()) { Guid Vguid = Guid.Parse(vguid); Business_Personnel_Information userInfo = dbMsSql.Queryable <Business_Personnel_Information>().Where(i => i.Vguid == Vguid).SingleOrDefault(); try { AllEmployee landaUser = _dbSql.Queryable <AllEmployee>().Where(i => i.IDCard == userInfo.IDNumber).FirstOrDefault(); if (landaUser != null) { dbMsSql.BeginTran(); string weChatJson = JsonHelper.ModelToJson(userInfo); //1为未关注的人 if (userInfo.ApprovalStatus == 1) { //获取accessToken string accessToken = Common.WeChatPush.WeChatTools.GetAccessoken(); //用户关注微信企业号 string focusResult = Common.WeChatPush.WeChatTools.GetAuthSucee(accessToken, userInfo.UserID); U_FocusResult resultMsg = new U_FocusResult(); resultMsg = JsonHelper.JsonToModel <U_FocusResult>(focusResult); if (resultMsg.errcode == 0) { dbMsSql.Update <Business_Personnel_Information>(new { ApprovalStatus = 2 }, i => i.Vguid == Vguid); //更新审批状态 result = true; //关注成功 } else { result = false; //model.respnseInfo = resultMsg.errmsg; LogHelper.WriteLog("人员" + userInfo.UserID + "手动关注失败:错误码为-" + resultMsg.errcode + ",错误消息为_" + resultMsg.errmsg); } //存入操作日志表 _ll.SaveLog(9, 5, CurrentUser.GetCurrentUser().LoginName, userInfo.Name, weChatJson); } else if (userInfo.ApprovalStatus == 4) { //获取accessToken string accessToken = Common.WeChatPush.WeChatTools.GetAccessoken(); //用户关注微信企业号 string focusResult = Common.WeChatPush.WeChatTools.EnableWeChatData(accessToken, userInfo.UserID); U_FocusResult resultMsg = new U_FocusResult(); resultMsg = JsonHelper.JsonToModel <U_FocusResult>(focusResult); if (resultMsg.errcode == 0) { dbMsSql.Update <Business_Personnel_Information>(new { ApprovalStatus = 2 }, i => i.Vguid == Vguid); //更新审批状态 result = true; //关注成功 } else { result = false; outString = "人员" + userInfo.UserID + "手动关注失败:错误码为-" + resultMsg.errcode + ",错误消息为_" + resultMsg.errmsg; LogHelper.WriteLog(outString); } //存入操作日志表 _ll.SaveLog(9, 5, CurrentUser.GetCurrentUser().LoginName, userInfo.Name, weChatJson); } else { result = true; } dbMsSql.CommitTran(); } else { outString = "人事库中不存在该用户,不能关注!"; } } catch (Exception ex) { dbMsSql.RollbackTran(); outString = "人员" + userInfo.UserID + "手动关注异常"; LogHelper.WriteLog("人员" + userInfo.UserID + "手动关注异常:" + ex.Message + "/n" + ex.ToString() + "/n" + ex.StackTrace); } } } return(result); }
/// <summary> /// 审核用户是否存在并保存至Person表 /// </summary> /// <param name="userModel"></param> /// <param name="userID"></param> /// <param name="position"></param> /// <returns></returns> public string CheckUser(AllEmployee userModel, string userID, string position, string mobilePhone) { try { using (SqlSugarClient _dbMsSql = SugarDao.SugarDao_LandaVSql.GetInstance()) { bool result = false; AllEmployee landaUser = null; Queryable <AllEmployee> listAllEmployees = _dbMsSql.Queryable <AllEmployee>().Where(i => i.IDCard == userModel.IDCard); if (listAllEmployees.Count() > 0) { landaUser = listAllEmployees.First(); } if (landaUser != null) { Guid vguid = Guid.NewGuid(); Business_Personnel_Information personInfo = new Business_Personnel_Information(); switch (position) { case "司机": personInfo.DepartmenManager = 1; break; case "普通员工": personInfo.DepartmenManager = 2; break; case "管理人员": personInfo.DepartmenManager = 3; break; } //DateTime now = DateTime.Now; //if (!string.IsNullOrEmpty(landaUser.BirthDay)) //{ // DateTime birthday = DateTime.Parse(landaUser.BirthDay); // int age = now.Year - birthday.Year; // if (now.Month < birthday.Month || (now.Month == birthday.Month && now.Day < birthday.Day)) // age--; // personInfo.Age = age; //年龄 //} personInfo.Name = landaUser.Name; personInfo.Vguid = vguid; string gender = "1"; if (landaUser.Gender.HasValue) { gender = landaUser.Gender.Value.ToString(); //性别 } personInfo.Sex = gender; personInfo.OwnedFleet = Guid.Parse(userModel.OrganizationID); //所属部门 //判断微信带过来的手机号是否为空(如果为空取人员系统中的手机号,不为空则取微信中的手机号) if (string.IsNullOrEmpty(mobilePhone)) { personInfo.PhoneNumber = landaUser.MobilePhone; //人员系统手机号 } else { personInfo.PhoneNumber = mobilePhone; //微信带过来的手机号 } personInfo.UserID = userID; personInfo.ID = userID; personInfo.IDNumber = landaUser.IDCard; //身份证号 personInfo.JobNumber = landaUser.EmployeeNO; //工号 personInfo.LicensePlate = landaUser.DrivingLicense; //车牌号 personInfo.ApprovalStatus = 2; //已审核 personInfo.ApprovalType = 1; //系统审核 personInfo.CreatedDate = DateTime.Now; personInfo.ChangeDate = DateTime.Now; result = SavePersonInfo(personInfo); if (result) { return("1"); //Person表保存成功 } else { _dbMsSql.Update <Business_Personnel_Information>(new { ApprovalStatus = 1 }, it => it.Vguid == vguid); return("2"); //Person表保存失败 } } else { //Business_Personnel_Information personInfo = new Business_Personnel_Information(); //switch (position) //{ // case "司机": // personInfo.DepartmenManager = 1; // break; // case "普通员工": // personInfo.DepartmenManager = 2; // break; // case "管理人员": // personInfo.DepartmenManager = 3; // break; //} //DateTime now = DateTime.Now; ////if (!string.IsNullOrEmpty(landaUser.BirthDay)) ////{ //// DateTime birthday = DateTime.Parse(landaUser.BirthDay); //// int age = now.Year - birthday.Year; //// if (now.Month < birthday.Month || (now.Month == birthday.Month && now.Day < birthday.Day)) //// age--; //// personInfo.Age = age.ToString(); //年龄 ////} //personInfo.Vguid = Guid.NewGuid(); //personInfo.OwnedFleet = Guid.Parse(userModel.OrganizationID); //所属部门 ////判断微信带过来的手机号是否为空(如果为空取人员系统中的手机号,不为空则取微信中的手机号) //if (string.IsNullOrEmpty(mobilePhone)) //{ // personInfo.PhoneNumber = landaUser.MobilePhone; //人员系统手机号 //} //else //{ // personInfo.PhoneNumber = mobilePhone; //微信带过来的手机号 //} //personInfo.UserID = userID; //personInfo.ID = userID; //personInfo.IDNumber = userModel.IDCard; //身份证号 //if (personInfo.IDNumber.Length == 18) //{ // int gender; // bool isSuccess = int.TryParse(personInfo.IDNumber.Substring(16, 1), out gender); // if (isSuccess) // { // personInfo.Sex = gender % 2 == 0 ? "2" : "1"; // } // string strYear = personInfo.IDNumber.Substring(6, 8).Insert(4, "-").Insert(7, "-"); //提取出生年份 // TimeSpan ts = DateTime.Now.Subtract(Convert.ToDateTime(strYear)); // personInfo.Age = ts.Days / 365; //} //personInfo.JobNumber = userModel.EmployeeNO; //工号 //personInfo.ApprovalStatus = 1; //未审核 //personInfo.ApprovalType = 2; //手动关注 //personInfo.CreatedDate = DateTime.Now; //personInfo.ChangeDate = DateTime.Now; //result = SavePersonInfo(personInfo); return("3"); //LandaV9库中不存在 } } } catch (Exception ex) { Common.LogHelper.LogHelper.WriteLog("二次验证:" + ex.Message); return("3"); //LandaV9库中不存在 } }
/// <summary> /// 审核用户是否存在并保存至Person表 /// </summary> /// <param name="userModel"></param> /// <returns></returns> public string CheckUser(AllEmployee userModel, string userID, string position, string mobilePhone) { return(_vl.CheckUser(userModel, userID, position, mobilePhone)); }