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); }
private string GetShareFiles(HttpContext context) { string strJsonResult = string.Empty; string userAccount = string.Empty; ErrorCodeInfo error = new ErrorCodeInfo(); Guid transactionid = Guid.NewGuid(); string funname = "GetShareFiles"; try { do { string urlcode = context.Request["code"]; string valcode = context.Request["valcode"]; DownResult arinfo = new DownResult(); BigAttachManager dll = new BigAttachManager(ClientIP); dll.GetShareFiles(transactionid, urlcode, valcode, ref arinfo, out strJsonResult); if (arinfo.error == "Unauthorized") { context.Response.StatusCode = 401; } } 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 CheckVerificationCode(HttpContext context) { string strJsonResult = string.Empty; string userAccount = string.Empty; ErrorCodeInfo error = new ErrorCodeInfo(); Guid transactionid = Guid.NewGuid(); string funname = "CheckVerificationCode"; try { do { string urlcode = context.Request["code"]; string valcode = context.Request["VerificationCode"]; BigAttachManager dll = new BigAttachManager(ClientIP); dll.CheckVerificationCode(transactionid, urlcode, valcode, 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 Search(HttpContext context) { string strJsonResult = string.Empty; string userAccount = string.Empty; ErrorCodeInfo error = new ErrorCodeInfo(); Guid transactionid = Guid.NewGuid(); string funname = "Search"; try { do { int top = Convert.ToInt32(context.Request["Top"]); string keyword = context.Request["keyword"]; Guid userid = this.CheckCookie(context); if (userid == Guid.Empty) { //error? break; } BigAttachManager dll = new BigAttachManager(ClientIP); dll.Search(transactionid, userid, keyword, top, 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 GetShareSettings(HttpContext context) { string strJsonResult = string.Empty; string userAccount = string.Empty; ErrorCodeInfo error = new ErrorCodeInfo(); Guid transactionid = Guid.NewGuid(); string funname = "GetShareSettings"; try { do { Guid userid = this.CheckCookie(context); if (userid == Guid.Empty) { //error? break; } BigAttachManager dll = new BigAttachManager(ClientIP); dll.GetShareSettings(transactionid, userid, out strJsonResult); } while (false); } catch (Exception ex) { error.Code = ErrorCode.Exception; LoggerHelper.Error("Setting.ashx调用接口GetShareSettings异常", 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 GetFileList(HttpContext context) { string strJsonResult = string.Empty; string userAccount = string.Empty; ErrorCodeInfo error = new ErrorCodeInfo(); Guid transactionid = Guid.NewGuid(); string funname = "GetFileList"; try { do { //pageIndex = 1 & pageSize = 30 & orderbyField = LastUpdateTime & orderbyType = DESC & _ = 1582705328638 int pageIndex = Convert.ToInt32(context.Request["pageIndex"]); int pageSize = Convert.ToInt32(context.Request["pageSize"]); string orderbyField = context.Request["orderbyField"]; string orderbyType = context.Request["orderbyType"]; Guid userid = this.CheckCookie(context); if (userid == Guid.Empty) { //error? break; } BigAttachManager dll = new BigAttachManager(ClientIP); dll.GetFileList(transactionid, userid, pageIndex, pageSize, out strJsonResult); //AttachResultInfo resultinfo = new AttachResultInfo(); //BigFileListInfo bfli = new BigFileListInfo(); //bfli.pageCount = 1; //bfli.recordCount = 1; //bfli.files = new List<BigFileItemInfo>(); //BigFileItemInfo fi = new BigFileItemInfo(); //fi.FileName = "test.txt"; //fi.FileSize = 354.0; //bfli.files.Add(fi); //resultinfo.data = bfli; //string json = JsonConvert.SerializeObject(resultinfo); //strJsonResult = json; //{"error":null,"data":{"files":[{"ID":"92eb58d7-f042-4c1c-8f59-50d68b6dfdec","FileName":"versions.json","ExtensionName":".json","FileSize":357.0,"UserID":"9d3ecb19-d692-47cb-b8e5-73c01b8a125c","FolderID":"230cf621-1011-4921-8896-edd973fbda73","UploadTime":"2020-02-26T16:20:50","LastUpdateTime":"2020-02-26T16:20:50","DisplayFileSize":"1 KB"}],"pageCount":1,"recordCount":1}} } while (false); } catch (Exception ex) { error.Code = ErrorCode.Exception; LoggerHelper.Error("File.ashx调用接口GetFileList异常", 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 GetUploadPar(HttpContext context) { string strJsonResult = string.Empty; string userAccount = string.Empty; ErrorCodeInfo error = new ErrorCodeInfo(); Guid transactionid = Guid.NewGuid(); string funname = "GetUploadBar"; try { do { //AttachResultInfo resultinfo = new AttachResultInfo(); //GetUploadParItem gupi = new GetUploadParItem(); //gupi.OutlookFolderID = ""; //gupi.StorageID = ""; //gupi.StorageRelativePath = ""; //gupi.StorageUri = ""; //gupi.UserQuota = 2147483648.0; //gupi.UserUsedQuota = 648.0; //resultinfo.data = gupi; //string json = JsonConvert.SerializeObject(resultinfo); //strJsonResult = json; //{"error":null,"data":{"StorageID":"8522ed80-7edc-4b30-9456-cd8edac0684e","StorageRelativePath":"2020-02-26","StorageUri":"\\\\172.16.6.12\\e","UserQuota":2147483648.0,"UserUsedQuota":357.0,"OutlookFolderID":"230cf621-1011-4921-8896-edd973fbda73"}} Guid userid = this.CheckCookie(context); if (userid == Guid.Empty) { //error? break; } BigAttachManager dll = new BigAttachManager(ClientIP); dll.GetUploadParItem(transactionid, userid, out strJsonResult); } while (false); } catch (Exception ex) { error.Code = ErrorCode.Exception; LoggerHelper.Error("Setting.ashx调用接口GetUploadBar异常", 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 GetGlobalUploadSetting(HttpContext context) { string strJsonResult = string.Empty; string userAccount = string.Empty; ErrorCodeInfo error = new ErrorCodeInfo(); Guid transactionid = Guid.NewGuid(); string funname = "GetGlobalUploadSetting"; try { do { //AttachResultInfo resultinfo = new AttachResultInfo(); //AttachSettingItem asi = new AttachSettingItem(); //asi.MaxFileSize = 6442450944.0; //asi.MaxUploads = 5; //asi.FileUploadBlackList = "ade; adp; app; asa; ashx; asmx; asp; bas; bat; cdx; cer; chm;class; cmd;com;config;cpl;crt;csh;dll;fxp;hlp;hta;htr;htw;ida;idc;idq;inf;ins;isp;its;jar;js;jse;ksh;lnk;mad;maf;mag;mam;maq;mar;mas;mat;mau;mav;maw;mda;mdb;mde;mdt;mdw;mdz;msc;msh;msh1;msh1xml;msh2;msh2xml;mshxml;msi;msp;mst;ops;pcd;pif;prf;prg;printer;pst;reg;rem;scf;scr;sct;shb;shs;shtm;shtml;soap;stm;tmp;url;vb;vbe;vbs;vsmacros;vss;vst;vsw;ws;wsc;wsf;wsh;"; //asi.ChunkSize = 1048576; //asi.AllowDrop = true; //asi.DefaultExtension = ".xdrv"; //resultinfo.data = asi; //string json = JsonConvert.SerializeObject(resultinfo); //strJsonResult = json; //"{"error":null,"data":{"MaxFileSize":6442450944.0,"MaxUploads":5,"FileUploadBlackList":"ade; adp; app; asa; ashx; asmx; asp; bas; bat; cdx; cer; chm;class; cmd;com;config;cpl;crt;csh;dll;fxp;hlp;hta;htr;htw;ida;idc;idq;inf;ins;isp;its;jar;js;jse;ksh;lnk;mad;maf;mag;mam;maq;mar;mas;mat;mau;mav;maw;mda;mdb;mde;mdt;mdw;mdz;msc;msh;msh1;msh1xml;msh2;msh2xml;mshxml;msi;msp;mst;ops;pcd;pif;prf;prg;printer;pst;reg;rem;scf;scr;sct;shb;shs;shtm;shtml;soap;stm;tmp;url;vb;vbe;vbs;vsmacros;vss;vst;vsw;ws;wsc;wsf;wsh;","ChunkSize":1048576,"AllowDrop":true,"DefaultExtension":".xdrv"}}"; Guid userid = this.CheckCookie(context); if (userid == Guid.Empty) { //error? break; } BigAttachManager dll = new BigAttachManager(ClientIP); dll.GetGlobalUploadSetting(transactionid, userid, out strJsonResult); } while (false); } catch (Exception ex) { error.Code = ErrorCode.Exception; LoggerHelper.Error("Setting.ashx调用接口GetGlobalUploadSetting异常", 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 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 QuickUpload(HttpContext context) { string strJsonResult = string.Empty; string userAccount = string.Empty; ErrorCodeInfo error = new ErrorCodeInfo(); Guid transactionid = Guid.NewGuid(); string funname = "QuickUpload"; try { do { string filename = context.Request.Form["FileName"]; string hashcode = context.Request.Form["HashCode"]; UploadFileItemInfo info = new UploadFileItemInfo(); info.FileName = filename; info.HashCode = hashcode; Guid userid = this.CheckCookie(context); if (userid == Guid.Empty) { //error? break; } BigAttachManager dll = new BigAttachManager(ClientIP); dll.QuickUpload(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); }
private string AutoLogin(HttpContext context) { string strJsonResult = string.Empty; string userAccount = string.Empty; ErrorCodeInfo error = new ErrorCodeInfo(); Guid transactionid = Guid.NewGuid(); string funname = "AutoLogin"; try { do { string email = context.Request["mailAddress"]; BigAttachManager dll = new BigAttachManager(ClientIP); Guid userid = Guid.Empty; bool result = dll.GetUserIDByEmail(transactionid, email, out userid, out strJsonResult); if (result == true) { HttpCookie myCookie = new HttpCookie("BGQTUserToken"); myCookie["Token"] = userid.ToString(); myCookie["Account"] = email; myCookie.Expires = DateTime.Now.AddHours(1); context.Response.Cookies.Add(myCookie); } } while (false); } catch (Exception ex) { error.Code = ErrorCode.Exception; LoggerHelper.Error("Setting.ashx调用接口AutoLogin异常", 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 Upload(HttpContext context) { string strJsonResult = string.Empty; string userAccount = string.Empty; ErrorCodeInfo error = new ErrorCodeInfo(); Guid transactionid = Guid.NewGuid(); string funname = "Upload"; try { do { Guid userid = this.CheckCookie(context); if (userid == Guid.Empty) { //error? break; } if (context.Request.Files.Count <= 0) { //error? break; } HttpPostedFile _file = context.Request.Files[0]; Stream stream = _file.InputStream; if (stream.Length <= 0) { //error? break; } byte[] filedata = new byte[stream.Length]; stream.Read(filedata, 0, filedata.Length); string tempid = context.Request.Form["Identifier"]; string HashCode = context.Request.Form["HashCode"]; string TotalChunks = context.Request.Form["TotalChunks"]; string ChunkIndex = context.Request.Form["ChunkIndex"]; string FileName = context.Request.Form["FileName"]; string FileSize = context.Request.Form["FileSize"]; string Position = context.Request.Form["Position"]; UploadFileItemInfo info = new UploadFileItemInfo(); info.TempID = Guid.Parse(tempid); info.TotalChunks = Convert.ToInt32(TotalChunks); info.ChunkIndex = Convert.ToInt32(ChunkIndex); info.FileName = FileName; info.HashCode = HashCode; info.FileSizeInt = Convert.ToInt32(FileSize); info.Position = Convert.ToInt32(Position); info.Data = filedata; BigAttachManager dll = new BigAttachManager(ClientIP); dll.Upload(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); }