public bool CancelUpload( Guid transactionid, Guid userid, BigFileItemInfo info, out string strJsonResult) { bool result = true; strJsonResult = string.Empty; ErrorCodeInfo error = new ErrorCodeInfo(); string paramstr = string.Empty; paramstr += $"userid:{userid}"; paramstr += $"||TempID:{info.TempID}"; string funname = "CancelUpload"; try { do { AttachResultInfo resultinfo = new AttachResultInfo(); BigAttachDBProvider Provider = new BigAttachDBProvider(); result = Provider.CancelUpload(transactionid, userid, ref info, out error); if (result == true) { //delete temp file if (info.FilePath != string.Empty) { FileInfo fi = new FileInfo(info.FilePath); if (fi.Exists) { fi.Delete(); } } // to do resultinfo.data = true; strJsonResult = JsonConvert.SerializeObject(resultinfo); LoggerHelper.Info(userid.ToString(), funname, paramstr, Convert.ToString(error.Code), true, transactionid); result = true; break; } else { resultinfo.data = false; strJsonResult = JsonConvert.SerializeObject(resultinfo); LoggerHelper.Info(userid.ToString(), funname, paramstr, Convert.ToString(error.Code), false, transactionid); result = false; } } while (false); } catch (Exception ex) { error.Code = ErrorCode.Exception; LoggerHelper.Info(userid.ToString(), funname, paramstr, Convert.ToString(error.Code), false, transactionid); LoggerHelper.Error($"BigAttachManager调用{funname}异常", paramstr, ex.ToString(), transactionid); strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info); result = false; } return(result); }
private string DownloadFileById(HttpContext context) { string strJsonResult = string.Empty; string userAccount = string.Empty; ErrorCodeInfo error = new ErrorCodeInfo(); Guid transactionid = Guid.NewGuid(); string funname = "DownloadFileById"; try { do { string urlcode = context.Request["code"]; string fileid = context.Request["fileid"]; Guid id = Guid.Parse(fileid); BigFileItemInfo info = new BigFileItemInfo(); BigAttachManager dll = new BigAttachManager(ClientIP); bool result = dll.DownloadFileById(transactionid, urlcode, id, ref info, out strJsonResult); if (result && info.FilePath != string.Empty) { downfile2(context, info.FilePath, info.FileName); } } while (false); } catch (Exception ex) { error.Code = ErrorCode.Exception; LoggerHelper.Error($"File.ashx调用接口{funname}异常", context.Request.RawUrl, ex.ToString(), transactionid); LoggerHelper.Info(userAccount, funname, context.Request.RawUrl, Convert.ToString(error.Code), false, transactionid); strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info); } return(strJsonResult); }
public bool DownloadFileById( Guid transactionid, string urlcode, Guid fileid, ref BigFileItemInfo info, out string strJsonResult) { bool result = true; strJsonResult = string.Empty; ErrorCodeInfo error = new ErrorCodeInfo(); string paramstr = string.Empty; paramstr += $"urlcode:{urlcode}"; paramstr += $"||fileid:{fileid}"; string funname = "DownloadFileById"; Guid userid = Guid.Empty; try { do { BigAttachDBProvider Provider = new BigAttachDBProvider(); result = Provider.DownloadFileById(transactionid, urlcode, fileid, ref info, out error); if (result == true) { LoggerHelper.Info(userid.ToString(), funname, paramstr, Convert.ToString(error.Code), true, transactionid); result = true; break; } else { //resultinfo.error = null; //resultinfo.data = false; //strJsonResult = JsonConvert.SerializeObject(resultinfo); LoggerHelper.Info(userid.ToString(), funname, paramstr, Convert.ToString(error.Code), false, transactionid); result = false; } } while (false); } catch (Exception ex) { error.Code = ErrorCode.Exception; LoggerHelper.Info(userid.ToString(), funname, paramstr, Convert.ToString(error.Code), false, transactionid); LoggerHelper.Error("BigAttachManager调用DownloadFileById异常", paramstr, ex.ToString(), transactionid); strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info); result = false; } return(result); }
public bool RenameFile( Guid transactionid, Guid userid, BigFileItemInfo info, out string strJsonResult) { bool result = true; strJsonResult = string.Empty; ErrorCodeInfo error = new ErrorCodeInfo(); string paramstr = string.Empty; paramstr += $"userid:{userid}"; paramstr += $"||ID:{info.ID}"; paramstr += $"||FileName:{info.FileName}"; string funname = "RenameFile"; try { do { AttachResultInfo resultinfo = new AttachResultInfo(); BigAttachDBProvider Provider = new BigAttachDBProvider(); result = Provider.RenameFile(transactionid, userid, ref info, out error); if (result == true) { resultinfo.data = info; strJsonResult = JsonConvert.SerializeObject(resultinfo); LoggerHelper.Info(userid.ToString(), funname, paramstr, Convert.ToString(error.Code), true, transactionid); result = true; break; } else { LoggerHelper.Info(userid.ToString(), funname, paramstr, Convert.ToString(error.Code), false, transactionid); result = false; } } while (false); } catch (Exception ex) { error.Code = ErrorCode.Exception; LoggerHelper.Info(userid.ToString(), funname, paramstr, Convert.ToString(error.Code), false, transactionid); LoggerHelper.Error("BigAttachManager调用GetGlobalUploadSetting异常", paramstr, ex.ToString(), transactionid); strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info); result = false; } return(result); }
private string Share(HttpContext context) { string strJsonResult = string.Empty; string userAccount = string.Empty; ErrorCodeInfo error = new ErrorCodeInfo(); Guid transactionid = Guid.NewGuid(); string funname = "Share"; try { do { string ids = context.Request.Form["fileID"]; string[] idarr = ids.Split(','); List <BigFileItemInfo> infolist = new List <BigFileItemInfo>(); for (int i = 0; i < idarr.Length; i++) { BigFileItemInfo info = new BigFileItemInfo(); info.ID = Guid.Parse(idarr[i]); infolist.Add(info); } Guid userid = this.CheckCookie(context); if (userid == Guid.Empty) { //error? break; } BigAttachManager dll = new BigAttachManager(ClientIP); dll.Share(transactionid, userid, infolist, out strJsonResult); } while (false); } catch (Exception ex) { error.Code = ErrorCode.Exception; LoggerHelper.Error($"File.ashx调用接口{funname}异常", context.Request.RawUrl, ex.ToString(), transactionid); LoggerHelper.Info(userAccount, funname, context.Request.RawUrl, Convert.ToString(error.Code), false, transactionid); strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info); } return(strJsonResult); }
private string RenameFile(HttpContext context) { string strJsonResult = string.Empty; string userAccount = string.Empty; ErrorCodeInfo error = new ErrorCodeInfo(); Guid transactionid = Guid.NewGuid(); string funname = "RenameFile"; try { do { string id = context.Request.Form["fileID"]; string newname = context.Request.Form["newName"]; BigFileItemInfo info = new BigFileItemInfo(); info.ID = Guid.Parse(id); info.FileName = newname; Guid userid = this.CheckCookie(context); if (userid == Guid.Empty) { //error? break; } BigAttachManager dll = new BigAttachManager(ClientIP); dll.RenameFile(transactionid, userid, info, out strJsonResult); } while (false); } catch (Exception ex) { error.Code = ErrorCode.Exception; LoggerHelper.Error($"File.ashx调用接口{funname}异常", context.Request.RawUrl, ex.ToString(), transactionid); LoggerHelper.Info(userAccount, funname, context.Request.RawUrl, Convert.ToString(error.Code), false, transactionid); strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info); } return(strJsonResult); }
public bool Share( Guid transactionid, Guid userid, List <BigFileItemInfo> infolist, out string strJsonResult) { bool result = true; strJsonResult = string.Empty; ErrorCodeInfo error = new ErrorCodeInfo(); string paramstr = string.Empty; paramstr += $"userid:{userid}"; foreach (BigFileItemInfo bi in infolist) { paramstr += $"||ID:{bi.ID}"; } string funname = "Share"; try { do { AttachResultInfo resultinfo = new AttachResultInfo(); BigAttachDBProvider Provider = new BigAttachDBProvider(); ShareSettingsInfo ssi = new ShareSettingsInfo(); result = Provider.GetShareSettings(transactionid, userid, ref ssi, out error); if (result == false) { resultinfo.data = false; LoggerHelper.Info(userid.ToString(), funname, paramstr, Convert.ToString(error.Code), false, transactionid); result = false; break; } string template = ssi.ShareNotificationTemplate; string filestr = string.Empty; for (int i = 0; i < infolist.Count; i++) { BigFileItemInfo info = infolist[i]; result = Provider.GetFileByID(transactionid, userid, ref info, out error); if (result == true) { filestr += $"<span>{info.FileName}<br /></span>"; } } template = template.Replace("{filename}", filestr); ShareInfo si = new ShareInfo(); result = Provider.AddShare(transactionid, userid, ref si, out error); if (result == false) { resultinfo.data = false; LoggerHelper.Info(userid.ToString(), funname, paramstr, Convert.ToString(error.Code), false, transactionid); result = false; break; } template = template.Replace("{exptime}", si.ExpireTime.ToString("yyyy-MM-dd")); template = template.Replace("{url}", si.ShortUrl); template = template.Replace("{validatecode}", si.ValCode); if (result == true) { for (int i = 0; i < infolist.Count; i++) { BigFileItemInfo info = infolist[i]; result = Provider.AddShareFile(transactionid, si.ShareID, info.ID, out error); } resultinfo.data = template; JsonSerializerSettings jsetting = new JsonSerializerSettings(); jsetting.StringEscapeHandling = StringEscapeHandling.EscapeHtml; strJsonResult = JsonConvert.SerializeObject(resultinfo); LoggerHelper.Info(userid.ToString(), funname, paramstr, Convert.ToString(error.Code), true, transactionid); result = true; break; } else { resultinfo.data = false; LoggerHelper.Info(userid.ToString(), funname, paramstr, Convert.ToString(error.Code), false, transactionid); result = false; } } while (false); } catch (Exception ex) { error.Code = ErrorCode.Exception; LoggerHelper.Info(userid.ToString(), funname, paramstr, Convert.ToString(error.Code), false, transactionid); LoggerHelper.Error($"BigAttachManager调用{funname}异常", paramstr, ex.ToString(), transactionid); strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info); result = false; } return(result); }
public bool DeleteFile( Guid transactionid, Guid userid, List <BigFileItemInfo> infolist, out string strJsonResult) { bool result = true; strJsonResult = string.Empty; ErrorCodeInfo error = new ErrorCodeInfo(); string paramstr = string.Empty; paramstr += $"userid:{userid}"; foreach (BigFileItemInfo bi in infolist) { paramstr += $"||ID:{bi.ID}"; } string funname = "DeleteFile"; try { do { AttachResultInfo resultinfo = new AttachResultInfo(); BigAttachDBProvider Provider = new BigAttachDBProvider(); for (int i = 0; i < infolist.Count; i++) { BigFileItemInfo info = infolist[i]; result = Provider.DeleteFile(transactionid, userid, ref info, out error); if (result == true) { //delete temp file if (info.FilePath != string.Empty) { FileInfo fi = new FileInfo(info.FilePath); if (fi.Exists) { fi.Delete(); } } } } if (result == true) { resultinfo.data = true; strJsonResult = JsonConvert.SerializeObject(resultinfo); LoggerHelper.Info(userid.ToString(), funname, paramstr, Convert.ToString(error.Code), true, transactionid); result = true; break; } else { resultinfo.data = false; LoggerHelper.Info(userid.ToString(), funname, paramstr, Convert.ToString(error.Code), false, transactionid); result = false; } } while (false); } catch (Exception ex) { error.Code = ErrorCode.Exception; LoggerHelper.Info(userid.ToString(), funname, paramstr, Convert.ToString(error.Code), false, transactionid); LoggerHelper.Error($"BigAttachManager调用{funname}异常", paramstr, ex.ToString(), transactionid); strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info); result = false; } return(result); }