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 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 GetUpdateFileList() { Result result = new Result(); try { result.IsOK = true; DataTable dt = new DataTable("FileTable"); DataColumn column; //文件版本号,如果版本号为空则为:1.01.1753.0101 column = new DataColumn(); column.DataType = System.Type.GetType("System.String"); column.ColumnName = "FilePath"; dt.Columns.Add(column); //文件MD5校验码 column = new DataColumn(); column.DataType = System.Type.GetType("System.String"); column.ColumnName = "FileMD5"; dt.Columns.Add(column); //文件下载地址 column = new DataColumn(); column.DataType = System.Type.GetType("System.String"); column.ColumnName = "FileURL"; dt.Columns.Add(column); string updatePath = ParameterAPI.GetConfig("ClientDir").ConfigValue; result = Common.Common.GetFileList("", updatePath, ref dt); // DataTable newData = dt.Clone(); //foreach (DataRow item in dt.Rows) //{ // string fileName= item["FilePath"].ToString().Split('\\')[1]; // if (userTB.FilePermission.Contains(fileName)) // { // newData.ImportRow(item); // } //} result.ExtData = JsonConvert.SerializeObject(dt); } catch (Exception ex) { LogHelper.WriteLog(GetType()).Info(ex.StackTrace); result.IsOK = false; result.Description = ex.InnerException.Message; } return(result); }
public Result GetFilePermissionList() { Result result = new Result(); try { result.IsOK = true; DataTable dt = new DataTable("FileTable"); DataColumn column; column = new DataColumn(); column.DataType = System.Type.GetType("System.String"); column.ColumnName = "FileName"; dt.Columns.Add(column); string filePath = ParameterAPI.GetConfig("FileDir").ConfigCode; string[] dirs = Directory.GetDirectories(filePath); if (dirs.Length > 0) { DirectoryInfo directoryInfo = new DirectoryInfo(dirs[0]); var directroies = directoryInfo.GetDirectories(); foreach (var directroy in directroies) { DataRow dr = dt.NewRow(); dr["FileName"] = directroy.Name; dt.Rows.Add(dr); } result.ExtData = JsonConvert.SerializeObject(dt); return(result); } } 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); }