public Result DeleteAccessFile(string fileCoverID, string accessFileName, string account) { Result result = new Result(); try { Guid g = new Guid(fileCoverID); PCBEntities pCBEntities = new PCBEntities(); PCB_AccessFileTB pCB_AccessFileTB = pCBEntities.PCB_AccessFileTB.FirstOrDefault(p => p.CreateAccount == account && p.FileCoverID == g && p.AccessFileName == accessFileName); // pCBEntities.PCB_AccessFileTB.FirstOrDefault(p => p.FileCoverID == new Guid(fileCoverID) && p.CreateAccount == account && p.FileExtension == fileExtension); if (pCB_AccessFileTB == null || pCB_AccessFileTB == default(PCB_AccessFileTB)) { result.IsOK = false; result.Description = "找不到对应的附件"; return(result); } pCBEntities.DeleteObject(pCB_AccessFileTB); result.IsOK = Convert.ToBoolean(pCBEntities.SaveChanges()); if (!result.IsOK) { result.Description = "删除失败"; return(result); } string saveToUrl = @ParameterAPI.GetConfig("FileURL").ConfigValue + @"\\" + account + @"\\" + fileCoverID + @"\\" + accessFileName + "." + pCB_AccessFileTB.FileExtension; File.Delete(saveToUrl); } catch (Exception ex) { LogHelper.WriteLog(GetType()).Info(ex.StackTrace); result.IsOK = false; result.Description = ex.InnerException.Message; } return(result); }
/// <summary> /// 更新订单表记录 /// </summary> /// <param name="account"></param> /// <param name="tradeNO"></param> /// <param name="flag"></param> /// <returns></returns> public static Result UpdateOrderTB(string account, string tradeNO) { Result result = new Result(); try { result.IsOK = true; result.StateCodeID = 0; PCBEntities pCBEntities = new PCBEntities(); PCB_OrderTB PCBOrderTB = pCBEntities.PCB_OrderTB.FirstOrDefault(p => p.CreateAccount == account && p.OrderNumber == tradeNO); if (PCBOrderTB != null) { PCBOrderTB.IsPay = true; PCBOrderTB.UpdateDateTime = DateTime.Now; pCBEntities.Refresh(System.Data.Objects.RefreshMode.ClientWins, PCBOrderTB); result.IsOK = Convert.ToBoolean(pCBEntities.SaveChanges()); } } catch (Exception ex) { LogHelper.WriteLog(typeof(Common)).Info(ex.StackTrace); result.IsOK = false; result.Description = ex.Message; } return(result); }
/// <summary> /// 删除订单表记录 /// </summary> /// <param name="account"></param> /// <param name="tradeNO"></param> /// <param name="flag"></param> /// <returns></returns> public static Result DelectOrderTB(string account, string tradeNO) { Result result = new Result(); try { result.IsOK = true; result.StateCodeID = 0; PCBEntities pCBEntities = new PCBEntities(); PCB_OrderTB PCBOrderTB = pCBEntities.PCB_OrderTB.FirstOrDefault(p => p.CreateAccount == account && p.OrderNumber == tradeNO && p.IsPay == false); if (PCBOrderTB != null) { pCBEntities.DeleteObject(PCBOrderTB); pCBEntities.SaveChanges(); } else { result.IsOK = false; } } catch (Exception ex) { LogHelper.WriteLog(typeof(Common)).Info(ex.StackTrace); result.IsOK = false; result.Description = ex.Message; } return(result); }
protected void Page_Load(object sender, EventArgs e) { string context = "hand?" + Common.Common.Decrypt(HttpContext.Current.Request.Url.Query.TrimStart('?')); HttpContext.Current.RewritePath(context); string mailAddress = HttpContext.Current.Request.QueryString.Get("mailAddress"); string dateTime = HttpContext.Current.Request.QueryString.Get("dateTime"); TimeSpan UseTime = DateTime.Now - Convert.ToDateTime(dateTime); if (UseTime.Seconds >= 60) { Response.Redirect(ParameterAPI.GetConfig("RegisterFURL").ConfigValue + "?mailaddr=" + mailAddress, false); } else { PCBEntities pCBEntities = new PCBEntities(); PCB_EngineerInfo engineerInfo = pCBEntities.PCB_EngineerInfo.FirstOrDefault(p => p.MailAddress == mailAddress); if (engineerInfo != null && engineerInfo != default(PCB_EngineerInfo)) { engineerInfo.UpdateDateTime = DateTime.Now; engineerInfo.StateCode = true; pCBEntities.Refresh(System.Data.Objects.RefreshMode.ClientWins, engineerInfo); bool isok = Convert.ToBoolean(pCBEntities.SaveChanges()); if (isok) { Response.Redirect(ParameterAPI.GetConfig("RegisterSURL").ConfigValue + "?mailaddr=" + mailAddress + "&isconfirm=true", false); } else { Response.Redirect(ParameterAPI.GetConfig("RegisterFURL").ConfigValue + "?mailaddr=" + mailAddress, false); } } } }
public Result FileIsPublish(string fileCoverID, string account, string setPrice, int publishStatus) { Result result = new Result(); try { Guid g = new Guid(fileCoverID); PCBEntities pCBEntities = new PCBEntities(); PCB_FileCoverTB pCB_FileCoverTB = pCBEntities.PCB_FileCoverTB.FirstOrDefault(p => p.FileCoverID == g && p.CreateAccount == account); if (pCB_FileCoverTB == null || pCB_FileCoverTB == default(PCB_FileCoverTB)) { result.IsOK = false; result.Description = "找不到该文件信息"; return(result); } pCB_FileCoverTB.Price = setPrice; pCB_FileCoverTB.IsPublish = Convert.ToBoolean(publishStatus); pCB_FileCoverTB.UpdateDateTime = DateTime.Now; pCBEntities.Refresh(System.Data.Objects.RefreshMode.ClientWins, pCB_FileCoverTB); result.IsOK = Convert.ToBoolean(pCBEntities.SaveChanges()); if (!result.IsOK) { result.Description = "发布失败"; return(result); } result.Description = "发布成功"; } catch (Exception ex) { LogHelper.WriteLog(GetType()).Info(ex.StackTrace); result.IsOK = false; result.Description = ex.InnerException.Message; } return(result); }
public Result UploadQaFile(byte[] qaFile, string qaFolderName, string account, string fileExtension, string qaFileName) { var result = new Result(); var saveToUrl = @ParameterAPI.GetConfig("ShareQAFile").ConfigValue + @"\\" + account + @"\\" + qaFolderName + @"\\" + qaFileName + "." + fileExtension; try { var pcbEntities = new PCBEntities(); var pcbQaFolderTb = pcbEntities.PCB_QAFolderTB.FirstOrDefault(p => p.QAFolderName == qaFolderName && p.CreateAccount == account); if (pcbQaFolderTb == null || pcbQaFolderTb == default(PCB_QAFolderTB)) { result.IsOK = false; result.Description = "找不到该目录"; return(result); } var count = pcbEntities.PCB_QAFileTB.Count <PCB_QAFileTB>(p => p.QAFolderID == pcbQaFolderTb.QAFolderID && p.CreateAccount == account && p.QAFileName == qaFileName && p.FileExtension == fileExtension); if (count > 0) { result.IsOK = false; result.Description = "该目录已经存在改文件"; return(result); } result = Common.Common.FileWrite(saveToUrl, qaFile); if (!result.IsOK) { return(result); } var pcbQaFileTb = new PCB_QAFileTB(); pcbQaFileTb.QAFileID = Guid.NewGuid(); pcbQaFileTb.QAFolderID = pcbQaFolderTb.QAFolderID; pcbQaFileTb.QAFileName = qaFileName; pcbQaFileTb.QAFileURL = ParameterAPI.GetConfig("DowLoadShareFileURL").ConfigValue + "//" + account + "//" + qaFolderName + "//" + qaFileName + "." + fileExtension; pcbQaFileTb.FileExtension = fileExtension; pcbQaFileTb.CreateAccount = account; pcbQaFileTb.FileMD5 = Common.Common.GetMD5Hash(qaFile); pcbQaFileTb.FileSize = qaFile.Length.ToString(); pcbQaFileTb.CreateDateTime = DateTime.Now; pcbEntities.AddToPCB_QAFileTB(pcbQaFileTb); result.IsOK = Convert.ToBoolean(pcbEntities.SaveChanges()); if (!result.IsOK) { File.Delete(saveToUrl); result.Description = "上传失败"; return(result); } } catch (Exception ex) { LogHelper.WriteLog(GetType()).Info(ex.StackTrace); result.IsOK = false; result.Description = ex.Message; } return(result); }
public Result EditFileCover(string fileCoverID, string fileExtension, string fileCoverName, string account, Byte[] newFileData) { string saveToUrl = ""; Result result = new Result(); try { Guid g = new Guid(fileCoverID); PCBEntities pCBEntities = new PCBEntities(); PCB_FileCoverTB pCB_FileCoverTB = pCBEntities.PCB_FileCoverTB.FirstOrDefault(p => p.FileCoverID == g && p.CreateAccount == account); if (pCB_FileCoverTB == null || pCB_FileCoverTB == default(PCB_FileCoverTB)) { result.IsOK = false; result.Description = "找不到该文件信息"; return(result); } String dir = @ParameterAPI.GetConfig("FileURL").ConfigValue + @"\\" + account + @"\\" + fileCoverID; string oldUrl = dir + @"\\" + pCB_FileCoverTB.FileCoverName + "." + pCB_FileCoverTB.FileExtension; if (string.IsNullOrEmpty(fileCoverName)) { pCB_FileCoverTB.FileCoverName = fileCoverName; } if (newFileData.Length > 0) { pCB_FileCoverTB.FileSize = newFileData.Length.ToString(); pCB_FileCoverTB.FileMD5 = Common.Common.GetMD5Hash(newFileData); pCB_FileCoverTB.FileCoverURL = ParameterAPI.GetConfig("DowLoadFileURL").ConfigValue + "//" + account + "//" + g + "//" + fileCoverName + "." + fileExtension; saveToUrl = dir + @"\\" + fileCoverName + "." + fileExtension; result = Common.Common.FileWrite(saveToUrl, newFileData); if (!result.IsOK) { return(result); } pCB_FileCoverTB.UpdateDateTime = DateTime.Now; pCBEntities.Refresh(System.Data.Objects.RefreshMode.ClientWins, pCB_FileCoverTB); result.IsOK = Convert.ToBoolean(pCBEntities.SaveChanges()); if (!result.IsOK) { File.Delete(saveToUrl); result.Description = "编辑失败"; return(result); } File.Delete(oldUrl); result.Description = "编辑成功"; } } catch (Exception ex) { File.Delete(saveToUrl); LogHelper.WriteLog(GetType()).Info(ex.StackTrace); result.IsOK = false; result.Description = ex.InnerException.Message; } return(result); }
public Result UploadFileCover(Byte[] fileData, string account, string fileExtension, string fileCoverName) { Result result = new Result(); try { //byte[] coverPhoto = Convert.FromBase64String(fileData); //MemoryStream ms = new MemoryStream(coverPhoto); //Bitmap bmp = new Bitmap(ms); PCB_FileCoverTB pCB_FileCoverTB = new PCB_FileCoverTB(); pCB_FileCoverTB.FileCoverID = System.Guid.NewGuid(); pCB_FileCoverTB.FileCoverName = fileCoverName; pCB_FileCoverTB.FileMD5 = Common.Common.GetMD5Hash(fileData); pCB_FileCoverTB.FileExtension = fileExtension; pCB_FileCoverTB.FileSize = fileData.Length.ToString(); pCB_FileCoverTB.IsPublish = false; pCB_FileCoverTB.FileCoverURL = ParameterAPI.GetConfig("DowLoadFileURL").ConfigValue + "//" + account + "//" + pCB_FileCoverTB.FileCoverID.ToString() + "//" + pCB_FileCoverTB.FileCoverName + "." + fileExtension; pCB_FileCoverTB.CreateAccount = account; pCB_FileCoverTB.CreateDateTime = DateTime.Now; String dir = @ParameterAPI.GetConfig("FileURL").ConfigValue + @"\\" + account + @"\\" + pCB_FileCoverTB.FileCoverID.ToString(); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } string saveToUrl = dir + @"\\" + pCB_FileCoverTB.FileCoverName + "." + fileExtension; result = Common.Common.FileWrite(saveToUrl, fileData); if (!result.IsOK) { return(result); } //bmp.Save(saveDir); //bmp.Dispose(); //ms.Close(); PCBEntities pCBEntities = new PCBEntities(); pCBEntities.AddToPCB_FileCoverTB(pCB_FileCoverTB); result.IsOK = Convert.ToBoolean(pCBEntities.SaveChanges()); if (!result.IsOK) { Directory.Delete(dir, true); result.Description = "上传失败"; return(result); } } catch (Exception ex) { LogHelper.WriteLog(GetType()).Info(ex.StackTrace); result.IsOK = false; result.Description = ex.InnerException.Message; } return(result); }
public Result NewQaFolder(string qaFolderName, string account) { var result = new Result(); try { var pcbEntities = new PCBEntities(); var count = pcbEntities.PCB_QAFolderTB.Count <PCB_QAFolderTB>(p => p.QAFolderName == qaFolderName && p.CreateAccount == account); if (count > 0) { result.IsOK = false; result.Description = "改目录名称已经存在,请重新命名"; return(result); } var dir = @ParameterAPI.GetConfig("ShareQAFile").ConfigValue + @"\\" + account + @"\\" + qaFolderName; if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } //byte[] coverPhoto = Convert.FromBase64String(fileData); //MemoryStream ms = new MemoryStream(coverPhoto); //Bitmap bmp = new Bitmap(ms); var pcbQaFolderTb = new PCB_QAFolderTB { QAFolderID = System.Guid.NewGuid(), QAFolderName = qaFolderName, CreateAccount = account, CreateDateTime = DateTime.Now }; pcbEntities.AddToPCB_QAFolderTB(pcbQaFolderTb); result.IsOK = Convert.ToBoolean(pcbEntities.SaveChanges()); if (!result.IsOK) { result.Description = "创建失败"; Directory.Delete(dir, true); return(result); } result.Description = "创建成功"; } catch (Exception ex) { LogHelper.WriteLog(GetType()).Info(ex.StackTrace); result.IsOK = false; result.Description = ex.Message; } return(result); }
public Result UpdateSysParams(string key, string value, string remark) { Result result = new Result(); result.StateCodeID = 0; result.IsOK = false; try { PCBEntities pCBEntities = new PCBEntities(); //PCB_ConfigTB configSys = ParameterAPI.GetConfig(key); PCB_ConfigTB configSys = pCBEntities.PCB_ConfigTB.FirstOrDefault(p => p.ConfigCode == key); if (configSys == null) { ////增加 //PCB_ConfigTB confignew = new PCB_ConfigTB(); //confignew.ConfigID = new Guid(); //confignew.ConfigCode = key; //confignew.ConfigValue = value; //confignew.Remark = remark; //pCBEntities.AddToPCB_ConfigTB(confignew); //result.IsOK = Convert.ToBoolean(pCBEntities.SaveChanges()); //if (result.IsOK) // result.Description = "增加" + key + "成功"; result.IsOK = false; result.StateCodeID = 1; result.Description = "没有找到需要更新对应项"; return(result); } else { //更新 configSys.ConfigValue = value; configSys.Remark = remark; pCBEntities.Refresh(System.Data.Objects.RefreshMode.ClientWins, configSys); result.IsOK = Convert.ToBoolean(pCBEntities.SaveChanges()); //result = Common.Common.UpdateConfigTB(key, value, remark); if (result.IsOK) { result.Description = "更新" + key + "成功"; } } } catch (Exception ex) { LogHelper.WriteLog(GetType()).Info(ex.StackTrace); result.IsOK = false; result.Description = ex.Message; } return(result); }
public Result EditeAccountInfo(string account, string password, string accountName, string phoneNo, string weChatAccount) { Result result = new Result(); try { PCBEntities pCBEntities = new PCBEntities(); PCB_EngineerInfo pCB_EngineerInfo = pCBEntities.PCB_EngineerInfo.FirstOrDefault(p => p.Account == account && p.Password == password && p.StateCode == true); if (pCB_EngineerInfo == null) { result.IsOK = false; result.Description = "没有该账号信息"; return(result); } if (!string.IsNullOrEmpty(accountName)) { pCB_EngineerInfo.AccountName = accountName; } if (!string.IsNullOrEmpty(phoneNo)) { pCB_EngineerInfo.PhoneNo = phoneNo; } if (!string.IsNullOrEmpty(weChatAccount)) { pCB_EngineerInfo.WeChatAccount = weChatAccount; } pCB_EngineerInfo.UpdateDateTime = DateTime.Now; pCBEntities.Refresh(System.Data.Objects.RefreshMode.ClientWins, pCB_EngineerInfo); result.IsOK = Convert.ToBoolean(pCBEntities.SaveChanges()); if (!result.IsOK) { result.Description = "保存异常"; return(result); } } catch (Exception ex) { LogHelper.WriteLog(GetType()).Info(ex.StackTrace); result.IsOK = false; result.Description = ex.InnerException.Message; } return(result); }
public Result ChangePassword(string account, string oldPassword, string newPassword) { Result result = new Result(); try { PCBEntities pCBEntities = new PCBEntities(); PCB_EngineerInfo engineerInfo = pCBEntities.PCB_EngineerInfo.FirstOrDefault(p => (p.Account == account || p.MailAddress == account) && p.StateCode == true); if (engineerInfo == null || engineerInfo == default(PCB_EngineerInfo)) { result.IsOK = false; result.Description = "输入的用户" + account + "不存在"; return(result); } if (oldPassword != engineerInfo.Password) { result.IsOK = false; result.Description = "输入的旧密码有误"; return(result); } if (string.IsNullOrEmpty(newPassword)) { result.IsOK = false; result.Description = "输入的新密码不能为空"; return(result); } engineerInfo.Password = newPassword; engineerInfo.UpdateDateTime = DateTime.Now; pCBEntities.Refresh(System.Data.Objects.RefreshMode.ClientWins, engineerInfo); result.IsOK = Convert.ToBoolean(pCBEntities.SaveChanges()); if (!result.IsOK) { result.Description = "修改密码失败"; return(result); } result.Description = "账号" + account + "的密码修改成功"; } catch (Exception ex) { LogHelper.WriteLog(GetType()).Info(ex.StackTrace); result.IsOK = false; result.Description = ex.InnerException.Message; } return(result); }
/// <summary> /// 预下单记录 /// </summary> /// <returns></returns> public static Result RecordPreRenewal(string account, string fileCoverId, string tradeNO) { Result result = new Result(); try { PCBEntities pCBEntities = new PCBEntities(); Guid fid = new Guid(fileCoverId); var pcborderTBlist = from order in pCBEntities.PCB_OrderTB where order.CreateAccount == account && order.FileCoverID == fid select order; if (pcborderTBlist.Count() > 0) { pcborderTBlist.ToList()[0].UpdateDateTime = DateTime.Now; pcborderTBlist.ToList()[0].OrderNumber = tradeNO; for (int i = 1; i < pcborderTBlist.Count(); i++) { pCBEntities.DeleteObject(pcborderTBlist.ToList()[i]); } } else { PCB_OrderTB orderTB = new PCB_OrderTB(); orderTB.OrderID = System.Guid.NewGuid(); orderTB.CreateAccount = account; orderTB.CreateDateTime = DateTime.Now; orderTB.FileCoverID = fid; orderTB.IsPay = false; orderTB.OrderNumber = tradeNO; orderTB.OrderPrice = pCBEntities.PCB_FileCoverTB.FirstOrDefault(p => p.FileCoverID == fid).Price; orderTB.UpdateDateTime = DateTime.Now; pCBEntities.AddToPCB_OrderTB(orderTB); } result.IsOK = Convert.ToBoolean(pCBEntities.SaveChanges()); } catch (Exception ex) { LogHelper.WriteLog(typeof(Common)).Info(ex.StackTrace); result.IsOK = false; result.Description = ex.Message; } return(result); }
public Result NewShareCode(string qaFolderId, string account, string durationTime) { var result = new Result(); try { var shareCode = Common.Common.Encrypt(qaFolderId + "," + account + "," + DateTime.Now); var pcbEntities = new PCBEntities(); var pcbShareCodeTb = new PCB_ShareCodeTB(); pcbShareCodeTb.QAFolderID = new Guid(qaFolderId); pcbShareCodeTb.ShareCode = shareCode; pcbShareCodeTb.CreateAccount = account; pcbShareCodeTb.EffectDatetime = DateTime.Now.AddMinutes(int.Parse(durationTime)); pcbShareCodeTb.CreateDateTime = DateTime.Now; pcbEntities.AddToPCB_ShareCodeTB(pcbShareCodeTb); var list = pcbEntities.PCB_ShareCodeTB.Where(p => p.EffectDatetime < DateTime.Now); foreach (var item in list) { pcbEntities.DeleteObject(item); } result.IsOK = Convert.ToBoolean(pcbEntities.SaveChanges()); if (!result.IsOK) { result.Description = "生成失败"; return(result); } result.Description = "生成成功"; result.ExtData = shareCode; } catch (Exception ex) { LogHelper.WriteLog(GetType()).Info(ex.StackTrace); result.IsOK = false; result.Description = ex.Message; } return(result); }
public Result DelSysParams(string key) { Result result = new Result(); result.StateCodeID = 0; result.IsOK = false; try { PCBEntities pCBEntities = new PCBEntities(); //PCB_ConfigTB configSys = ParameterAPI.GetConfig(key); PCB_ConfigTB configSys = pCBEntities.PCB_ConfigTB.FirstOrDefault(p => p.ConfigCode == key); if (configSys == null) { result.IsOK = false; result.Description = "无对应项"; return(result); } else { //del pCBEntities.DeleteObject(configSys); result.IsOK = Convert.ToBoolean(pCBEntities.SaveChanges()); //result = Common.Common.UpdateConfigTB(key, value, remark); if (result.IsOK) { result.Description = "删除" + key + "成功"; } } return(result); } catch (Exception ex) { LogHelper.WriteLog(GetType()).Info(ex.StackTrace); result.IsOK = false; result.Description = ex.Message; } return(result); }
public Result DeleteFileCover(string fileCoverID, string account) { Result result = new Result(); try { Guid g = new Guid(fileCoverID); PCBEntities pCBEntities = new PCBEntities(); PCB_FileCoverTB pCB_FileCoverTB = pCBEntities.PCB_FileCoverTB.FirstOrDefault(p => p.FileCoverID == g && p.CreateAccount == account); if (pCB_FileCoverTB == null || pCB_FileCoverTB == default(PCB_FileCoverTB)) { result.IsOK = false; result.Description = "找不到该文件信息"; return(result); } pCBEntities.DeleteObject(pCB_FileCoverTB); IQueryable <PCB_AccessFileTB> queryable = pCBEntities.PCB_AccessFileTB.Where(p => p.FileCoverID == g && p.CreateAccount == account); foreach (var item in queryable) { pCBEntities.DeleteObject(item); } result.IsOK = Convert.ToBoolean(pCBEntities.SaveChanges()); if (!result.IsOK) { result.Description = "删除失败"; return(result); } string saveToUrl = @ParameterAPI.GetConfig("FileURL").ConfigValue + @"\\" + account + @"\\" + fileCoverID; Directory.Delete(saveToUrl, true); } catch (Exception ex) { LogHelper.WriteLog(GetType()).Info(ex.StackTrace); result.IsOK = false; result.Description = ex.InnerException.Message; } return(result); }
public Result UploadAccessFile(byte[] accessFile, string fileCoverID, string account, string fileExtension, string accessFileName) { Result result = new Result(); string saveToUrl = @ParameterAPI.GetConfig("FileURL").ConfigValue + @"\\" + account + @"\\" + fileCoverID + @"\\" + accessFileName + "." + fileExtension; try { Guid g = new Guid(fileCoverID); PCBEntities pCBEntities = new PCBEntities(); int count = pCBEntities.PCB_FileCoverTB.Count <PCB_FileCoverTB>(p => p.FileCoverID == g); if (count <= 0) { result.IsOK = false; result.Description = "封面ID不存在"; return(result); } PCB_AccessFileTB pCB_AccessFileTB = pCBEntities.PCB_AccessFileTB.FirstOrDefault(p => p.CreateAccount == account && p.FileExtension == fileExtension && p.FileCoverID == g && p.AccessFileName == accessFileName);// pCBEntities.PCB_AccessFileTB.FirstOrDefault(p => p.FileCoverID == new Guid(fileCoverID) && p.CreateAccount == account && p.FileExtension == fileExtension); if (pCB_AccessFileTB != null || pCB_AccessFileTB != default(PCB_AccessFileTB)) { result.IsOK = false; result.Description = "上传的文件已经存在"; return(result); } //string fileName=Guid.NewGuid().ToString(); result = Common.Common.FileWrite(saveToUrl, accessFile); if (!result.IsOK) { return(result); } pCB_AccessFileTB = new PCB_AccessFileTB(); pCB_AccessFileTB.AccessFileID = Guid.NewGuid(); pCB_AccessFileTB.AccessFileName = accessFileName; pCB_AccessFileTB.FileCoverID = new Guid(fileCoverID); pCB_AccessFileTB.AccessFileURL = ParameterAPI.GetConfig("DowLoadFileURL").ConfigValue + "//" + account + "//" + fileCoverID + "//" + accessFileName + "." + fileExtension; pCB_AccessFileTB.FileExtension = fileExtension; pCB_AccessFileTB.CreateAccount = account; pCB_AccessFileTB.FileMD5 = Common.Common.GetMD5Hash(accessFile); pCB_AccessFileTB.FileSize = accessFile.Length.ToString(); pCB_AccessFileTB.CreateDateTime = DateTime.Now; pCBEntities.AddToPCB_AccessFileTB(pCB_AccessFileTB); result.IsOK = Convert.ToBoolean(pCBEntities.SaveChanges()); if (!result.IsOK) { File.Delete(saveToUrl); result.Description = "上传失败"; return(result); } //Bitmap bmp = new Bitmap(Imagefilename); //MemoryStream ms = new MemoryStream(); //bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); //byte[] arr = new byte[ms.Length]; //ms.Position = 0; //ms.Read(arr, 0, (int)ms.Length); //ms.Close(); //string r = Convert.ToBase64String(arr); //Result ret = UpdateFileCover(r, "chenc"); } catch (Exception ex) { File.Delete(saveToUrl); LogHelper.WriteLog(GetType()).Info(ex.StackTrace); result.IsOK = false; result.Description = ex.InnerException.Message; } return(result); }
public Result CreateEngineer(string account, string accountName, string password, string phoneNo, string mailAddress, string weChatAccount) { // LogHelper.WriteLog(GetType()).Info("CreateEngineer"); Result result = new Result(); try { result.IsOK = true; if (string.IsNullOrEmpty(account)) { result.IsOK = false; result.Description = "注册账号不能为空"; return(result); } if (string.IsNullOrEmpty(accountName)) { result.IsOK = false; result.Description = "注册账号名称不能为空"; return(result); } if (string.IsNullOrEmpty(password)) { result.IsOK = false; result.Description = "注册账号密码不能为空"; return(result); } if (string.IsNullOrEmpty(mailAddress)) { result.IsOK = false; result.Description = "注册邮箱账号不能为空"; return(result); } if (string.IsNullOrEmpty(weChatAccount)) { result.IsOK = false; result.Description = "注册微信账号不能为空"; return(result); } PCBEntities pCBEntities = new PCBEntities(); PCB_EngineerInfo engineerInfo = pCBEntities.PCB_EngineerInfo.FirstOrDefault(p => p.Account == account || p.MailAddress == mailAddress); if (engineerInfo != null || engineerInfo != default(PCB_EngineerInfo)) { if (engineerInfo.StateCode) { if (engineerInfo.Account == account) { result.Description = "用户" + account + "已经存在"; } if (engineerInfo.MailAddress == mailAddress) { result.Description = "邮箱" + mailAddress + "已经存在"; } result.IsOK = false; return(result); } else { TimeSpan UseTime = DateTime.Now - engineerInfo.CreateDateTime; if (UseTime.TotalSeconds <= 60) { result.Description = "已经提交申请,请勿重复操作"; result.IsOK = false; return(result); } else //超过60s删除预注册信息 { pCBEntities.DeleteObject(engineerInfo); } } } engineerInfo = new PCB_EngineerInfo(); engineerInfo.EngineerID = System.Guid.NewGuid(); engineerInfo.Account = account; engineerInfo.Password = password; engineerInfo.AccountName = accountName; engineerInfo.MailAddress = mailAddress; engineerInfo.PhoneNo = phoneNo; engineerInfo.WeChatAccount = weChatAccount; engineerInfo.CreateDateTime = DateTime.Now; engineerInfo.StateCode = false; pCBEntities.AddToPCB_EngineerInfo(engineerInfo); result = Common.Common.SendMail(mailAddress, engineerInfo.CreateDateTime.ToString()); if (!result.IsOK) { return(result); } result.IsOK = Convert.ToBoolean(pCBEntities.SaveChanges()); if (!result.IsOK) { result.Description = "注册账号失败"; return(result); } } catch (Exception ex) { LogHelper.WriteLog(GetType()).Info(ex.StackTrace); result.IsOK = false; result.Description = ex.InnerException.Message; } return(result); }