public ActionResult AjaxCreate([Bind(Include = "Id, telphone, password, chinaname, building, unit, floor, room")] hsf_owner hsf_owner) { if (!string.IsNullOrEmpty(hsf_owner.chinaname)) { hsf_owner.residential = PingYinHelper.GetFirstSpell(hsf_owner.chinaname);//生成小区首字母 hsf_owner.Id = Guid.NewGuid().ToString(); hsf_owner.deletemark = 0; hsf_owner.host = hsf_owner.residential + "-" + hsf_owner.building + "-" + hsf_owner.unit + "-" + hsf_owner.floor + "-" + hsf_owner.room; hsf_owner.createtime = DateTime.Now; hsf_owner newhsf_owner = ihsf_ownerService.Insert(hsf_owner); AjaxResult ajaxResult = new AjaxResult() { Result = DoResult.Success, PromptMsg = "插入成功" }; return(Json(ajaxResult)); } else { logger.Debug($"error:小区不能为空!"); AjaxResult ajaxResult = new AjaxResult() { Result = DoResult.Failed, PromptMsg = "小区不能为空" }; return(Json(ajaxResult)); } }
public ActionResult CustDeviceAdd(FormCollection CustDevice) { try { using (DataWallContext db = new DataWallContext()) { //当前用户可管理场馆 List <SysLibrary> libList = GetLibraryList(); if (libList.Count == 0) { return(Json(new { code = "202", msg = "当前用户未分配可管理场馆,请联系系统管理员!" })); } ViewData["datalist"] = libList; //客流设备 if (CustDevice["Library"] != null) { string CustDeviceName = CustDevice["CustDeviceName"]; if (db.SysCustDevices.Where(d => d.CustDeviceName == DbFunctions.AsNonUnicode(CustDeviceName)).AsNoTracking().Count() >= 1) { return(Json(new { code = "202", msg = "设备名已存在!" })); } int LibraryId = int.Parse(CustDevice["Library"]); string LibraryName = db.SysLibrarys.Find(LibraryId).LibraryName; string Uuid = PingYinHelper.GetFirstSpell(LibraryName + CustDevice["CustDeviceName"]) + DateTime.Now.Millisecond; string DataGuid = System.Guid.NewGuid().ToString("D"); SysCustDevice sysCustDevice = new SysCustDevice() { CustDeviceName = CustDevice["CustDeviceName"], Uuid = Uuid, DataGuid = DataGuid, SysLibraryId = LibraryId, CrateTime = DateTime.Now, EditTime = DateTime.Now, IsEnable = 0, DelState = 0 }; db.SysCustDevices.Add(sysCustDevice); //添加客流设备 db.SaveChanges(); Lg.AddLog("添加客流设备", "Other", 1, GetUserName()); return(Json(new { code = "200", msg = "添加成功!" })); } else { return(Json(new { code = "202", msg = "请选择内容所属场馆!" })); } } } catch (Exception ex) { LogHelper.ErrorLog("客流设备添加失败:" + ex.Message); return(Json(new { code = "201", msg = "修改失败,请重试或联系管理员!" })); } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (!string.IsNullOrEmpty(this.outPutPath) && !string.IsNullOrEmpty(this.excelFile) && !string.IsNullOrEmpty(this.picUrl)) { int i = e.RowIndex; DataTable dt = this.dataGridView1.DataSource as DataTable; using (FileStream fs = new FileStream(this.picUrl, FileMode.Open, FileAccess.Read)) { Bitmap bmp = new Bitmap(Image.FromStream(fs)); Graphics g = Graphics.FromImage(bmp); //定义绘画的字体 Font f = new Font(new FontFamily("宋体"), 32, FontStyle.Bold); //定义绘画区域大小 Size drawSize = new Size(bmp.Width, bmp.Height); //定义排版格式 StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Center; //左右居中 //定义绘画区域矩形 Rectangle rectName = new Rectangle(new Point(0, 550), drawSize); //绘制姓名 g.DrawString(dt.Rows[i]["姓名"].ToString(), f, new SolidBrush(Color.Black), rectName, sf); Rectangle rectPingYin = new Rectangle(new Point(0, 610), drawSize); //绘制拼音 Font pinyinFont = new Font(new FontFamily("宋体"), 28, FontStyle.Bold); g.DrawString(PingYinHelper.ConvertToAllSpell(dt.Rows[i]["姓名"].ToString()), pinyinFont, new SolidBrush(Color.Black), rectPingYin, sf); //绘制 培训方向 Font f_fangxinag = new Font(new FontFamily("宋体"), 32, FontStyle.Bold); Rectangle fangXingRect = new Rectangle(new Point(299, 820), new Size(189, 50)); g.DrawString(dt.Rows[i]["培训方向"].ToString(), f_fangxinag, new SolidBrush(Color.Black), fangXingRect, sf); //绘制 合格证编号 //78199460901170225 StringFormat sf_left = new StringFormat(); sf_left.Alignment = StringAlignment.Near; Font bianHaoFont = new Font(new FontFamily("宋体"), 26, FontStyle.Bold); Rectangle bianHaoRect = new Rectangle(new Point(585, 1010), new Size(350, 50)); g.DrawString(dt.Rows[i]["合格证编号"].ToString(), bianHaoFont, new SolidBrush(Color.Black), bianHaoRect, sf_left); //绘制身份证号 //42098418909171814 Font cardNOFont = new Font(new FontFamily("宋体"), 26, FontStyle.Bold); Rectangle cardNORect = new Rectangle(new Point(585, 1070), new Size(350, 50)); g.DrawString(dt.Rows[i]["身份证号"].ToString(), cardNOFont, new SolidBrush(Color.Black), cardNORect, sf_left); //绘制日期 DateTime d = DateTime.Parse(dt.Rows[0]["培训结束时间"].ToString()); string time = formatDate(d); Font dateFont = new Font(new FontFamily("宋体"), 26, FontStyle.Bold); Rectangle dateRect = new Rectangle(new Point(585, 1130), new Size(350, 50)); g.DrawString(time, dateFont, new SolidBrush(Color.Black), dateRect, sf_left); //预览图片 this.picBoxView.Image = bmp; fs.Close(); } } }
public string Get(string word) { if (!string.IsNullOrEmpty(word)) { // SpellAndWbConfig.SetData(); string spell = SpellAndWbConfig.GetSpellCode(word); string wb = SpellAndWbConfig.GetWBCode(word); string pinyin = PingYinHelper.ConvertToAllSpell(word); string py = PingYinHelper.GetFirstSpell(word); return($"Spell:{spell},WB:{wb},PinYin:{pinyin},PY:{py}"); } return(""); }
public Result AddOrEdit(Resume model) { var result = Check(model); model.PinYinName = PingYinHelper.GetFirstSpell(model.UserName); //新增 if (model.Id <= 0) { model.InterviewStatus = InterviewStatus.NoInterview; return(result.Succeed ? base.Add(model) : result); } else { return(result.Succeed ? base.Update(model) : result); } }
public ActionResult Edit([Bind(Include = "Id, telphone, password, chinaname, building, unit, floor, room")] hsf_owner hsf_owner) { if (ModelState.IsValid) { hsf_owner hsf_ownerDB = ihsf_ownerService.Find <hsf_owner>(hsf_owner.Id); hsf_ownerDB.telphone = hsf_owner.telphone; hsf_ownerDB.password = hsf_owner.password; hsf_ownerDB.chinaname = hsf_owner.chinaname; hsf_ownerDB.building = hsf_owner.building; hsf_ownerDB.unit = hsf_owner.unit; hsf_ownerDB.floor = hsf_owner.floor; hsf_ownerDB.room = hsf_owner.room; hsf_ownerDB.residential = PingYinHelper.GetFirstSpell(hsf_ownerDB.chinaname);//生成小区首字母 hsf_ownerDB.host = hsf_ownerDB.residential + "-" + hsf_ownerDB.building + "-" + hsf_ownerDB.unit + "-" + hsf_ownerDB.floor + "-" + hsf_ownerDB.room; hsf_ownerDB.createtime = DateTime.Now; ihsf_ownerService.Update(hsf_ownerDB); return(RedirectToAction("Index")); } else { throw new Exception("ModelState未通过检测"); } }
/// <summary> /// 拼音码的获取 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtGTypeName_TextChanged(object sender, EventArgs e) { txtGTPYNo.Text = PingYinHelper.GetFirstSpell(txtGTypeName.Text.Trim()); }
public ActionResult LibraryAdd(FormCollection Library) { try { if (Check("LibraryAdd", 0, Library["LibraryName"])) { using (DataWallContext db = new DataWallContext()) { int Type = int.Parse(Library["Type"]); SysProgramInfo sysProgramInfo = db.SysProgramInfos.AsNoTracking().FirstOrDefault(); List <SysLibrary> sysLibraryList = db.SysLibrarys.AsNoTracking().Where(s => s.DelState == 0).ToList(); switch (Type) { case 0: if (sysLibraryList.Where(s => s.Type == 0).Count() >= sysProgramInfo.MasterNum) { return(Json(new { code = "202", msg = "总馆数量已达上限" })); } break; case 1: if (sysLibraryList.Where(s => s.Type == 1).Count() >= sysProgramInfo.BranchNum) { return(Json(new { code = "202", msg = "分馆数量已达上限" })); } break; } //场馆 int FatherLibraryId = 0; if (Type == 0) { FatherLibraryId = 0; } else { if (Library["FatherLibraryId"] == null) { return(Json(new { code = "201", msg = "请选择上级场馆" })); } FatherLibraryId = int.Parse(Library["FatherLibraryId"]); } string LibraryName = Library["LibraryName"]; string LibraryCode = PingYinHelper.GetFirstSpell(Library["LibraryName"]) + DateTime.Now.Millisecond; SysLibrary sysLibrary = new SysLibrary() { City = "上海", LibraryName = LibraryName, FatherLibraryId = FatherLibraryId, LibraryDescribe = HttpUtility.UrlDecode(Library["Describe"]).Replace("'", "‘"), Type = Type, LibraryCode = LibraryCode, CrateTime = DateTime.Now, EditTime = DateTime.Now, IsEnable = 0, DelState = 0 }; db.SysLibrarys.Add(sysLibrary); //添加 db.SaveChanges(); //添加管理员为管理用户 int SysLibraryId = sysLibrary.ID; List <SysLibraryUser> sysLibraryUsers = new List <SysLibraryUser> { new SysLibraryUser { SysUserID = 1, SysLibraryId = SysLibraryId } }; sysLibraryUsers.ForEach(s => db.SysLibraryUsers.Add(s)); //添加 db.SaveChanges(); Lg.AddLog("添加场馆", "Library", 1, GetUserName()); return(Json(new { code = "200", msg = "添加成功!" })); } } else { return(Json(new { code = "202", msg = "场馆已存在!" })); } } catch (Exception ex) { if (Library.Count > 0) { LogHelper.ErrorLog("场馆添加失败:" + ex.Message); } return(Json(new { code = "201", msg = "添加失败,请重试或联系管理员!" })); } }
public ActionResult LibraryEdit(FormCollection Library) { try { if (Check("LibraryEdit", int.Parse(Library["ID"]), Library["LibraryName"])) { using (DataWallContext db = new DataWallContext()) { int LbraryId = int.Parse(Library["ID"]); int Type = int.Parse(Library["Type"]); SysProgramInfo sysProgramInfo = db.SysProgramInfos.AsNoTracking().FirstOrDefault(); List <SysLibrary> sysLibraryList = db.SysLibrarys.AsNoTracking().Where(s => s.DelState == 0).ToList(); switch (Type) { case 0: if (sysLibraryList.Where(s => s.Type == 0).Count() >= sysProgramInfo.MasterNum) { if (sysLibraryList.Where(s => s.Type == 0 & s.ID == LbraryId & s.DelState == 0).Count() < 1) { return(Json(new { code = "202", msg = "总馆数量已达上限" })); } } break; case 1: if (sysLibraryList.Where(s => s.Type == 1).Count() >= sysProgramInfo.BranchNum) { if (sysLibraryList.Where(s => s.Type == 1 & s.ID == LbraryId & s.DelState == 0).Count() < 1) { return(Json(new { code = "202", msg = "分馆数量已达上限" })); } } break; } //场馆 int FatherLibraryId = 0; if (Type == 0) { FatherLibraryId = 0; } else { if (Library["FatherLibraryId"] == null) { return(Json(new { code = "201", msg = "请选择上级场馆" })); } FatherLibraryId = int.Parse(Library["FatherLibraryId"]); if (int.Parse(Library["ID"]) == FatherLibraryId) { return(Json(new { code = "202", msg = "不可以选择自身为上级场馆" })); } } string LibraryName = Library["LibraryName"]; string LibraryCode = PingYinHelper.GetFirstSpell(Library["LibraryName"]) + DateTime.Now.Millisecond; SysLibrary sysLibrary = new SysLibrary() { ID = LbraryId, LibraryName = Library["LibraryName"], LibraryDescribe = HttpUtility.UrlDecode(Library["Describe"]).Replace("'", "‘"), FatherLibraryId = FatherLibraryId, Type = int.Parse(Library["Type"]), EditTime = DateTime.Now }; db.Entry(sysLibrary).State = EntityState.Modified; //不更新的字段 db.Entry(sysLibrary).Property(x => x.City).IsModified = false; db.Entry(sysLibrary).Property(x => x.LibraryCode).IsModified = false; db.Entry(sysLibrary).Property(x => x.CrateTime).IsModified = false; db.Entry(sysLibrary).Property(x => x.IsEnable).IsModified = false; db.Entry(sysLibrary).Property(x => x.DelState).IsModified = false; db.SaveChanges(); Lg.AddLog("修改场馆", "Library", 2, GetUserName()); return(Json(new { code = "200", msg = "修改成功!" })); } } else { return(Json(new { code = "202", msg = "场馆已存在!" })); } } catch (Exception ex) { if (Library.Count > 0) { LogHelper.ErrorLog("场馆修改失败:" + ex.Message); } return(Json(new { code = "201", msg = "修改失败,请重试或联系管理员!" })); } }
/// <summary> /// 添加车票信息到图片并存放 /// </summary> /// <param name="tickInfo"></param> public static Image MakeTrainTickImage(TrainTicketInfo tickInfo) { if (tickInfo.logid == null) { return(null); } if (TrainTicket.BaseTicketImage == null) { try { TicketImageTool.LoadAllBaseTrainTicketsImage(); } catch { MessageBox.Show("车票模板为空:" + TrainTicket.BaseTickfilePath + "\n" + "请检查是否含有车票模板", "车票目录", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); System.Diagnostics.Process.Start(TrainTicket.BaseTickfilePath); } return(null); } var ticketnumber = new Random().Next(0, TrainTicket.BaseTicketImage.Count); var image = TrainTicket.BaseTicketImage[ticketnumber]; //Console.WriteLine(image.Width + " " + image.Height); Bitmap bitmap = new Bitmap(image, image.Width, image.Height); Graphics g = Graphics.FromImage(bitmap); //cutImage(image, new Point(136,69),50,30); //字体矩形位置 : //x = 图片的长度的中心位置 - 字体长度的一半 - 字行距 //y = 图片的高度的中心位置 - 字体大小的一半 - 偏移(去掉偏移,是居中位置) string year = null; if (tickInfo.date.Length >= 4) { year = tickInfo.date[0].ToString() + tickInfo.date[1].ToString() + tickInfo.date[2].ToString() + tickInfo.date[3].ToString();//年 } string moth = null; if (tickInfo.date.Length >= 7) { moth = tickInfo.date[5].ToString() + tickInfo.date[6].ToString();//月 } string day = null; if (tickInfo.date.Length >= 10) { day = tickInfo.date[8].ToString() + tickInfo.date[9].ToString();//日 } string fickrates = null; if (tickInfo.ticket_rates.Contains("¥")) { fickrates = tickInfo.ticket_rates.Replace("¥", string.Empty); } string Rates = null; if (fickrates != null && fickrates.Contains("元")) { Rates = fickrates.Replace("元", string.Empty); } string Start_Station = null; string Start_Stationpinyin = null; if (!String.IsNullOrWhiteSpace(tickInfo.starting_station)) { Start_Station = tickInfo.starting_station.Remove(tickInfo.starting_station.Length - 1); Start_Stationpinyin = PingYinHelper.GetPinyin(tickInfo.starting_station.Remove(tickInfo.starting_station.Length - 1)); } string destination_Station = null; string Des_Stationpinyin = null; if (!String.IsNullOrWhiteSpace(tickInfo.destination_station)) { destination_Station = tickInfo.destination_station.Remove(tickInfo.destination_station.Length - 1); Des_Stationpinyin = PingYinHelper.GetPinyin(tickInfo.destination_station.Remove(tickInfo.destination_station.Length - 1)); } string S_station = null; string D_station = null; int S_pinyinaddX = 0; int D_pinyinaddX = 0; int max_pinyinmove_length = 9; bool D_ISLongPinyin = false; bool S_ISLongPinyin = false; if (Start_Stationpinyin != null && Start_Stationpinyin.Length <= max_pinyinmove_length) { S_pinyinaddX = 42 - Start_Stationpinyin.Length; } else { S_ISLongPinyin = true; } if (Des_Stationpinyin != null && Des_Stationpinyin.Length <= max_pinyinmove_length) { D_pinyinaddX = 42 - Des_Stationpinyin.Length; } else { D_ISLongPinyin = true; } if (Start_Station != null && Start_Station.Length <= 2) { S_station += Start_Station[0]; S_station += " "; S_station += Start_Station[1]; } else { S_station = Start_Station; } if (destination_Station != null && destination_Station.Length <= 2) { D_station += destination_Station[0]; D_station += " "; D_station += destination_Station[1]; } else { D_station = destination_Station; } string IDinfo = null; char addidinfo; for (int i = 0; i < tickInfo.ID.Length; i++) { if (i >= 10 && i <= 13) { addidinfo = '*'; } else { addidinfo = tickInfo.ID[i]; } IDinfo += addidinfo; } var reduce = new Random().Next(0, 20); AddInfoToImage(tickInfo.ticket_num, g, 40, "arial.ttf", 50, 35 - reduce, RedBrush, FontStyle.Bold); AddInfoToImage(tickInfo.jianpiao, g, 32, 680, 20, blackBrush); AddInfoToImage(S_station, g, 41, 110, 80, blackBrush); if (Start_Stationpinyin != null) { if (S_ISLongPinyin) { AddInfoToImage(Start_Stationpinyin, g, 30, "标准仿宋体简.ttf", 110 + Start_Stationpinyin.Length + S_pinyinaddX, 140, blackBrush, FontStyle.Regular, 0.8f, 1); } else { AddInfoToImage(Start_Stationpinyin, g, 30, "标准仿宋体简.ttf", 110 + Start_Stationpinyin.Length + S_pinyinaddX, 140, blackBrush); } } AddInfoToImage("站", g, 30, 290, 90, blackBrush); AddInfoToImage(D_station, g, 41, 600, 80, blackBrush); if (Des_Stationpinyin != null) { if (D_ISLongPinyin) { AddInfoToImage(Des_Stationpinyin, g, 30, "标准仿宋体简.ttf", 600 + Des_Stationpinyin.Length + D_pinyinaddX, 140, blackBrush, FontStyle.Regular, 0.8f, 1); } else { AddInfoToImage(Des_Stationpinyin, g, 30, "标准仿宋体简.ttf", 600 + Des_Stationpinyin.Length + D_pinyinaddX, 140, blackBrush); } } AddInfoToImage("站", g, 30, 780, 90, blackBrush); //////////////////////////////////////////////// if (tickInfo.train_num.Length < 4) { AddInfoToImage(tickInfo.train_num, g, 40, "车次.ttf", 400 + 20 - tickInfo.train_num.Length, 80, blackBrush); } else if (tickInfo.train_num.Length == 4) { AddInfoToImage(tickInfo.train_num, g, 40, "车次.ttf", 408, 80, blackBrush); } else if (tickInfo.train_num.Length == 5) { AddInfoToImage(tickInfo.train_num, g, 40, "车次.ttf", 392, 80, blackBrush); } ///////////////////////////////////////////////////////////////// AddInfoToImage(tickInfo.train_che, g, 32, "TechnicBold.ttf", 587, 182, blackBrush); AddInfoToImage("车", g, 20, 637, 195, blackBrush); AddInfoToImage(tickInfo.train_hao, g, 32, "TechnicBold.ttf", 660, 182, blackBrush); AddInfoToImage("号", g, 20, 732, 195, blackBrush); //AddInfoToImage("限乘当日当次车", g, 9, 20, 110, blackBrush); ////////////////////////////////////////////////// AddInfoToImage("网", g, 27, 400, 242, blackBrush); AddInfoToImage(tickInfo.seat_category, g, 25, 642, 240, blackBrush); AddInfoToImage(year, g, 34, "TechnicBold.ttf", 79, 182, blackBrush, FontStyle.Regular); AddInfoToImage("年", g, 20, 170, 195, blackBrush); AddInfoToImage(moth, g, 34, "TechnicBold.ttf", 200, 182, blackBrush, FontStyle.Regular); AddInfoToImage("月", g, 20, 255, 195, blackBrush); AddInfoToImage(day, g, 34, "TechnicBold.ttf", 285, 182, blackBrush, FontStyle.Regular); AddInfoToImage("日", g, 20, 337, 195, blackBrush); AddInfoToImage(tickInfo.train_starttime, g, 34, "TechnicBold.ttf", 376, 182, blackBrush, FontStyle.Bold); AddInfoToImage("开", g, 20, 480, 195, blackBrush); //AddInfoToImage("¥", g, 31, "华文宋体.ttf", 80, 240, blackBrush); AddInfoToImage(Rates, g, 33, "TechnicBold.ttf", 119, 240, blackBrush); int yuan_X = 0; if (Rates != null && Rates.Length > 4) { yuan_X += 25; } AddInfoToImage("元", g, 20, 205 + yuan_X, 250, blackBrush); // AddInfoToImage(tickInfo.ticket_num, g, 13, 20, 9, RedBrush); AddInfoToImage(tickInfo.name, g, 31, 460f, 397f, blackBrush); AddInfoToImage(IDinfo, g, 33.5f, "TechnicBoldshort.ttf", 78f, 397f, blackBrush); //AddInfoToImage(tickInfo.bottomid, g, 25f, 80f, 560f, blackBrush,FontStyle.Bold,1f,2f); AddInfoToImage(tickInfo.bottomid, g, 20f, "仿宋_GB2312.ttf", 90f, 560f, blackBrush, FontStyle.Regular, 1.147f, 1.6f); AddInfoToImage(Start_Station, g, 27f, 440f, 560f, blackBrush, FontStyle.Bold); int Shou_X = 0; if (Start_Station != null && Start_Station.Length <= 2) { Shou_X -= 38; } AddInfoToImage("售", g, 27f, 550f + Shou_X, 560f, blackBrush, FontStyle.Bold); string strCode = string.Format("网络异常\n车票读取信息为{0}\n{1}\n{2}→{3}\n{4}年{5}月{6}日{7}\n{8}车{9}号\n{10}", tickInfo.ticket_num, tickInfo.train_num, S_station, D_station, year, moth, day, tickInfo.train_starttime, tickInfo.train_che, tickInfo.train_hao, tickInfo.name); // string strCode = "https://www.12306.cn/index/"; QRCodeGenerator qrGenerator = new QRCoder.QRCodeGenerator(); QRCodeData qrCodeData = qrGenerator.CreateQrCode(strCode, QRCodeGenerator.ECCLevel.Q); QRCode qrcode = new QRCode(qrCodeData); // qrcode.GetGraphic 方法可参考最下发“补充说明” Bitmap qrCodeImage = qrcode.GetGraphic(3, Color.FromArgb(160, 0, 0, 0), Color.FromArgb(0, 0, 0, 0), null, 16, 6, false); AddImageToImage(g, ResizeImage(qrCodeImage, qrCodeImage.Width - 12, qrCodeImage.Height), new Point(735, 377)); var FinalImage = byteToImage(Bitmap2Byte(bitmap)); //"售" //bitmap.Save(TrainTicket.savePath + tickInfo.GetHashCode() + ".jpg", ImageFormat.Jpeg); //TrainTicket.TrainTicketImages.Add(byteToImage(Bitmap2Byte(bitmap))); g.Dispose(); bitmap.Dispose(); //image.Dispose(); return(FinalImage); }
public void DrawPic(DataTable dt) { Thread th = new Thread(new ThreadStart(() => { this.Invoke((Action)(() => { this.saveProgressBar.Maximum = dt.Rows.Count; this.btnStart.Enabled = false; })); int count = 0; for (int i = 0; i < dt.Rows.Count; i++) { using (FileStream fs = new FileStream(this.picUrl, FileMode.Open, FileAccess.Read)) { Bitmap bmp = new Bitmap(Image.FromStream(fs)); Graphics g = Graphics.FromImage(bmp); //定义绘画的字体 Font f = new Font(new FontFamily("宋体"), 32, FontStyle.Bold); //定义绘画区域大小 Size drawSize = new Size(bmp.Width, bmp.Height); //定义排版格式 StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Center; //左右居中 //定义绘画区域矩形 Rectangle rectName = new Rectangle(new Point(0, 550), drawSize); //绘制姓名 g.DrawString(dt.Rows[i]["姓名"].ToString(), f, new SolidBrush(Color.Black), rectName, sf); Rectangle rectPingYin = new Rectangle(new Point(0, 610), drawSize); //绘制拼音 Font pinyinFont = new Font(new FontFamily("宋体"), 28, FontStyle.Bold); g.DrawString(PingYinHelper.ConvertToAllSpell(dt.Rows[i]["姓名"].ToString()), pinyinFont, new SolidBrush(Color.Black), rectPingYin, sf); //绘制 培训方向 Font f_fangxinag = new Font(new FontFamily("宋体"), 32, FontStyle.Bold); Rectangle fangXingRect = new Rectangle(new Point(299, 820), new Size(189, 50)); g.DrawString(dt.Rows[i]["培训方向"].ToString(), f_fangxinag, new SolidBrush(Color.Black), fangXingRect, sf); //绘制 合格证编号 //78199460901170225 StringFormat sf_left = new StringFormat(); sf_left.Alignment = StringAlignment.Near; Font bianHaoFont = new Font(new FontFamily("宋体"), 26, FontStyle.Bold); Rectangle bianHaoRect = new Rectangle(new Point(585, 1010), new Size(350, 50)); g.DrawString(dt.Rows[i]["合格证编号"].ToString(), bianHaoFont, new SolidBrush(Color.Black), bianHaoRect, sf_left); //绘制身份证号 //42098418909171814 Font cardNOFont = new Font(new FontFamily("宋体"), 26, FontStyle.Bold); Rectangle cardNORect = new Rectangle(new Point(585, 1070), new Size(350, 50)); g.DrawString(dt.Rows[i]["身份证号"].ToString(), cardNOFont, new SolidBrush(Color.Black), cardNORect, sf_left); //绘制日期 DateTime d = DateTime.Parse(dt.Rows[0]["培训结束时间"].ToString()); string time = formatDate(d); Font dateFont = new Font(new FontFamily("宋体"), 26, FontStyle.Bold); Rectangle dateRect = new Rectangle(new Point(585, 1130), new Size(350, 50)); g.DrawString(time, dateFont, new SolidBrush(Color.Black), dateRect, sf_left); //保存图片 bmp.Save(this.outPutPath + @"\" + dt.Rows[i]["姓名"].ToString() + ".png"); fs.Close(); this.Invoke((Action)(() => { this.saveProgressBar.Value = i + 1; })); count++; } } this.Invoke((Action)(() => { this.btnStart.Enabled = true; })); MessageBox.Show("生成完成,共生成" + count.ToString() + "张证书"); })); th.IsBackground = true; th.Start(); }
/// <summary> /// 汉字转首字母 /// </summary> /// <param name="value"></param> /// <returns></returns> public IActionResult FirstSpell(string value) { return(Json(new { state = "ok", data = PingYinHelper.FirstSpell(value) })); }
/// <summary> /// 汉子转拼音 首字母全称 /// </summary> /// <param name="chinese"></param> /// <returns></returns> public static ChineseModel ToChinese(this string chinese) { return(PingYinHelper.GetFirstSpell(chinese)); }
/// <summary> /// 发起审批 /// </summary> /// <param name="SubjectId"></param> /// <returns></returns> public Result CreateWork(WorkflowMain model) { string msg = string.Empty; bool status = false; try { if (model.SubjectId <= 0) { return new Result() { Succeed = status, Message = "流程参数丢失" } } ; var SubjectObj = (from a in _subjectRepository.Entites join b in _repositoryTypeSubject.Entites on a.SubjectTypeId equals b.Id select new { b.SubjectTypeName, a.SubjectName } ).FirstOrDefault(); model.BusinessCode = PingYinHelper.GetFirstSpell(SubjectObj.SubjectTypeName) + "_" + DateTime.Now.ToString("yyMMddHHmmssff") + "_" + new Random().Next(1000, 9999); model.SubjectName = SubjectObj.SubjectName; //获取流程节点 var stepList = _subjectStepBusiness.GetDataListBySubjectId(model.SubjectId); List <WorkflowApprovalStep> stepEmpList = Mapper.Map <List <WorkflowApprovalStep> >(stepList).OrderBy(s => s.PassNo).ToList(); //通过流程节点id查询节点对应人 int i = 0; foreach (var item in stepEmpList) { i++; var objStep = _subjectRuleRepository.Entites.Where(s => s.SubjectStepId == item.Id).FirstOrDefault(); List <WorkflowApprovalRecords> list = new List <WorkflowApprovalRecords>(); if (item.PassType != PassType.Summary) { EmployeeDptJobDto modelEmployeeDptJobDto = new EmployeeDptJobDto { CompanyId = objStep.CompanyId, DptId = objStep.DepId, JobId = objStep.JobId, LoadChildDptEmployee = false, OnlySelf = false }; //当前节点对应的人员集合(无序) var userList = ApiBusinessHelper.GetEmployeeDptJobByUserIdAsync(modelEmployeeDptJobDto).Result; foreach (var itemChild in userList) { var approvalRecord = new WorkflowApprovalRecords { AuditidUserId = itemChild.userId, AuditidUserName = itemChild.EmployeeName, DataType = 1, AudioStatus = AudioStatus.UnApprovalInfo }; if (i == 1 && item.PassType == PassType.Audit) { approvalRecord.AudioStatus = AudioStatus.WaitAgree; } else if (i == 1 && item.PassType == PassType.Copy) { approvalRecord.AudioStatus = AudioStatus.Agree;//抄送人员默认是审核成功(不卡流程) } else if (i > 1 && i < stepEmpList.Count && item.PassType == PassType.Copy) { approvalRecord.AudioStatus = AudioStatus.Agree;//抄送人员默认是审核成功(不卡流程) } approvalRecord.ReadStatus = 1; list.Add(approvalRecord); } } else { //复盘节点 var approvalRecordFP = new WorkflowApprovalRecords { DataType = 1, AudioStatus = AudioStatus.UnApprovalInfo }; if (objStep.UserId > 0) {//创建人 approvalRecordFP.AuditidUserId = model.CreateUserId; approvalRecordFP.AuditidUserName = model.CreateUserName; list.Add(approvalRecordFP); } if (objStep.DepId > 0) { //获取部门经理 var empLD = ApiBusinessHelper.GetEmployeeManagerByUserId(model.CreateUserId).Result; approvalRecordFP.AuditidUserId = empLD.userId; approvalRecordFP.AuditidUserName = empLD.employeeName; list.Add(approvalRecordFP); } } item.workflowApprovalRecordList = list; } //stepEmpList.Where(s => s.PassNo == 1).ToList().ForEach(s => s.AuditNo = true); using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope()) { stepEmpList.ForEach(s => s.Id = 0); model.WorkflowApprovalStepList = stepEmpList; status = _repository.Add(model) > 0 ? true : false; ts.Complete();//提交事务 } } catch (Exception ex) { msg = ex.Message.ToString(); } return(new Result() { Succeed = status, Message = msg }); }
/// <summary> /// 新增业主 /// </summary> /// <param name="msg">Reg H4sIAAAAAAAEAKtWKknNKcjIz0tVslIytDAzM7C0NLMwtlTSUSpILC4uzy9KAUkYGZuYmgHFkjMy8xLzEnNBqp9O6H05fcWTHdOertsGlEoqzcxJycxLBykHckvzMkugzLSc/PwiKLsoPz8XxDQwVKoFAL/J9yR8AAAA /// {"telphone":"18660996839","password":"******","chinaname":"名门世家","building":"1","unit":"1","floor":"1","room":"101"}</param> public static string RegOwner(string msg) { try { if (msg.Contains("H4")) { string base64j = EncryptionHelp.Decrypt(msg, true); var owner = JsonConvert.DeserializeObject <hsf_owner>(base64j); using (HsfDBContext hsfDBContext = new HsfDBContext()) { using (RedisHashService service = new RedisHashService()) { ////先验证小区名称是否存在 //string residentialStr = service.GetValueFromHash("Residential", owner.chinaname); //if (string.IsNullOrEmpty(residentialStr)) //{ // var residentialEntity = hsfDBContext.hsf_residential.Where(t => t.chinaname == owner.chinaname && t.deletemark == 0).FirstOrDefault(); // if (residentialEntity != null) // { // residentialStr = residentialEntity.residential; // //缓存小区中文名-拼音缩写 // service.SetEntryInHash("Residential", owner.chinaname, residentialStr); // } // else // { // log.Debug($"注册 Fail,添加业主失败,不存在小区!"); // return "Residential error 小区名称不对!";//error // } //} //owner.residential = residentialStr; //2.不验证小区,有零散客户购买的情况,自己填写小区 if (!string.IsNullOrEmpty(owner.chinaname)) { owner.residential = PingYinHelper.GetFirstSpell(owner.chinaname);//生成小区首字母 } else { log.Debug($"error:小区不能为空!"); return("error:小区不能为空!"); } var ownerEntity = hsfDBContext.hsf_owner.Where(t => t.telphone == owner.telphone && t.deletemark == 0).FirstOrDefault(); if (ownerEntity != null) { ownerEntity.deletemark = 1;//删除老的,新增新的 AddReg(hsfDBContext, service, owner); log.Debug($"注册 Ok,业主信息修改成功!"); } else { //当前业主id需要保存,网关业主id为0,不可以 AddReg(hsfDBContext, service, owner); log.Debug($"注册 OK,添加业主成功!"); } return("Regok");//Addok } } } log.Debug($"注册失败,不是zip数据!"); return("error:Zip data error");//error } catch (Exception) { throw; } }