Exemple #1
0
        private string GetServerTime(HttpContext context)
        {
            string        strJsonResult = string.Empty;
            string        userAccount   = string.Empty;
            ErrorCodeInfo error         = new ErrorCodeInfo();
            Guid          transactionid = Guid.NewGuid();
            string        funname       = "GetServerTime";

            try
            {
                do
                {
                    AttachResultInfo ar = new AttachResultInfo();
                    ar.data       = DateTime.Now.ToString("yyyy-MM-dd");
                    strJsonResult = JsonHelper.Obj2Json <AttachResultInfo>(ar);// JsonConvert.SerializeObject(ar);
                } 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);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        public bool GetFileList(
            Guid transactionid,
            Guid userid,
            int curpage,
            int pagesize,
            //string orderbyField,
            //string orderbyType,
            out string strJsonResult)
        {
            bool result = true;

            strJsonResult = string.Empty;
            ErrorCodeInfo error    = new ErrorCodeInfo();
            string        paramstr = string.Empty;

            paramstr += $"userid:{userid}";
            paramstr += $"||curpage:{curpage}";
            paramstr += $"||pagesize:{pagesize}";
            //paramstr += $"||orderbyField:{orderbyField}";
            //paramstr += $"||orderbyType:{orderbyType}";
            string funname = "GetFileList";

            try
            {
                do
                {
                    AttachResultInfo resultinfo = new AttachResultInfo();
                    BigFileListInfo  bfli       = new BigFileListInfo();


                    BigAttachDBProvider Provider = new BigAttachDBProvider();
                    result = Provider.GetFileList(transactionid, userid, curpage, pagesize, out bfli, out error);
                    if (result == true)
                    {
                        resultinfo.data = bfli;
                        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调用GetFileList异常", paramstr, ex.ToString(), transactionid);
                strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info);
                result        = false;
            }
            return(result);
        }
Exemple #4
0
        public bool Search(
            Guid transactionid,
            Guid userid,
            string keyword,
            int top,
            out string strJsonResult)
        {
            bool result = true;

            strJsonResult = string.Empty;
            ErrorCodeInfo error    = new ErrorCodeInfo();
            string        paramstr = string.Empty;

            paramstr += $"userid:{userid}";
            paramstr += $"||keyword:{keyword}";
            paramstr += $"||top:{top}";
            string funname = "Search";

            try
            {
                do
                {
                    AttachResultInfo resultinfo = new AttachResultInfo();
                    BigFileListInfo  bfli       = new BigFileListInfo();


                    BigAttachDBProvider Provider = new BigAttachDBProvider();
                    result = Provider.Search(transactionid, userid, keyword, top, out bfli, out error);
                    if (result == true)
                    {
                        resultinfo.data = bfli;
                        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调用GetFileList异常", paramstr, ex.ToString(), transactionid);
                strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info);
                result        = false;
            }
            return(result);
        }
Exemple #5
0
        public bool CheckVerificationCode(
            Guid transactionid,
            string urlcode,
            string valcode,
            out string strJsonResult)
        {
            bool result = true;

            strJsonResult = string.Empty;
            ErrorCodeInfo error    = new ErrorCodeInfo();
            string        paramstr = string.Empty;

            paramstr += $"urlcode:{urlcode}";
            paramstr += $"||valcode:{valcode}";
            string funname = "CheckVerificationCode";
            Guid   userid  = Guid.Empty;

            try
            {
                do
                {
                    AttachResultInfo resultinfo = new AttachResultInfo();

                    BigAttachDBProvider Provider = new BigAttachDBProvider();
                    result = Provider.CheckVerificationCode(transactionid, urlcode, valcode, ref resultinfo, out error);
                    if (result == true)
                    {
                        strJsonResult = JsonConvert.SerializeObject(resultinfo);
                        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调用CheckVerificationCode异常", paramstr, ex.ToString(), transactionid);
                strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info);
                result        = false;
            }
            return(result);
        }
Exemple #6
0
        public bool GetUserIDByEmail(
            Guid transactionid,
            string email,
            out Guid userid,
            out string strJsonResult)
        {
            bool result = true;

            strJsonResult = string.Empty;
            userid        = Guid.Empty;
            ErrorCodeInfo error    = new ErrorCodeInfo();
            string        paramstr = string.Empty;

            paramstr += $"email:{email}";
            string funname = "GetUserIDByEmail";

            try
            {
                do
                {
                    AttachResultInfo resultinfo = new AttachResultInfo();
                    //AttachSettingItem asi = new AttachSettingItem();
                    AttatchUserInfo     aui      = new AttatchUserInfo();
                    BigAttachDBProvider Provider = new BigAttachDBProvider();
                    result = Provider.GetUserIDByEmail(transactionid, email, out userid, out error);
                    if (result == true)
                    {
                        aui.currentEmailAddress = email;
                        resultinfo.data         = aui;
                        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调用{funname}异常", paramstr, ex.ToString(), transactionid);
                strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info);
                result        = false;
            }
            return(result);
        }
Exemple #7
0
        public bool QuickUpload(
            Guid transactionid,
            Guid userid,
            UploadFileItemInfo info,
            out string strJsonResult)
        {
            bool result = true;

            strJsonResult = string.Empty;
            ErrorCodeInfo error    = new ErrorCodeInfo();
            string        paramstr = string.Empty;

            paramstr += $"userid:{userid}";
            paramstr += $"||FileName:{info.FileName}";
            paramstr += $"||HashCode:{info.HashCode}";
            string funname = "QuickUpload";

            try
            {
                do
                {
                    AttachResultInfo    resultinfo = new AttachResultInfo();
                    BigAttachDBProvider Provider   = new BigAttachDBProvider();
                    result = Provider.QuickUpload(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调用{funname}异常", paramstr, ex.ToString(), transactionid);
                strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info);
                result        = false;
            }
            return(result);
        }
Exemple #8
0
        public bool GetShareSettings(
            Guid transactionid,
            Guid userid,
            out string strJsonResult)
        {
            bool result = true;

            strJsonResult = string.Empty;
            ErrorCodeInfo error    = new ErrorCodeInfo();
            string        paramstr = string.Empty;

            paramstr += $"userid:{userid}";
            string funname = "GetShareSettings";

            try
            {
                do
                {
                    AttachResultInfo    resultinfo = new AttachResultInfo();
                    ShareSettingsInfo   ssi        = new ShareSettingsInfo();
                    BigAttachDBProvider Provider   = new BigAttachDBProvider();
                    result = Provider.GetShareSettings(transactionid, userid, ref ssi, out error);
                    if (result == true)
                    {
                        resultinfo.data = ssi;
                        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调用{funname}异常", paramstr, ex.ToString(), transactionid);
                strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info);
                result        = false;
            }
            return(result);
        }
Exemple #9
0
        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"}}";
                } 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);
        }
Exemple #10
0
        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);
        }
Exemple #11
0
        public bool Upload(
            Guid transactionid,
            Guid userid,
            UploadFileItemInfo info,
            out string strJsonResult)
        {
            bool result = true;

            strJsonResult = string.Empty;
            ErrorCodeInfo error = new ErrorCodeInfo();

            AttachResultInfo resultinfo = new AttachResultInfo();
            string           paramstr   = string.Empty;

            paramstr += $"userid:{userid}";
            paramstr += $"||FileName:{info.FileName}";
            paramstr += $"||HashCode:{info.HashCode}";
            paramstr += $"||TempID:{info.TempID}";
            paramstr += $"||TotalChunks:{info.TotalChunks}";
            paramstr += $"||ChunkIndex:{info.ChunkIndex}";
            paramstr += $"||Position:{info.Position}";
            paramstr += $"||FileSizeInt:{info.FileSizeInt}";
            string funname = "Upload";

            try
            {
                do
                {
                    BigAttachDBProvider Provider = new BigAttachDBProvider();
                    UploadFileItemInfo  infonow  = new UploadFileItemInfo();
                    infonow.TempID     = info.TempID;
                    infonow.FileName   = info.FileName;
                    infonow.FileSize   = info.FileSizeInt;
                    infonow.ChunkIndex = info.ChunkIndex;
                    infonow.HashCode   = info.HashCode;

                    if (info.FileName.IndexOf('.') > 0)
                    {
                        infonow.ExtensionName = info.FileName.Substring(info.FileName.LastIndexOf('.'));
                    }

                    result = Provider.CheckFile(transactionid, userid, ref infonow, out error);
                    if (result == false)
                    {
                        //error
                        //?
                        break;
                    }

                    //check file exists and create
                    FileInfo finfo = new FileInfo(infonow.FilePath);
                    if (finfo.Exists == false && infonow.ChunkIndex != 0)
                    {
                        //error
                        //?
                        break;
                    }
                    if (finfo.Exists == false && infonow.ChunkIndex == 0)
                    {
                        FileStream createfs = finfo.Create();
                        createfs.Close();
                    }
                    finfo.Refresh();

                    long sizenow = finfo.Length;

                    FileStream fs = null;
                    try
                    {
                        if (sizenow < info.Position)
                        {
                            ErrorResult er = new ErrorResult();
                            er.ErrorCode    = "3003";
                            er.ChunkIndex   = infonow.ChunkIndex;
                            resultinfo.data = info;
                            strJsonResult   = JsonConvert.SerializeObject(resultinfo);
                            result          = true;
                            //delete file
                            //finfo.Delete();
                            //BigFileItemInfo deleteinfo = new BigFileItemInfo();
                            //deleteinfo.TempID = infonow.TempID;
                            //Provider.CancelUpload(transactionid, userid, ref deleteinfo, out error);
                            //error
                            // to do
                            break;
                        }
                        else if (sizenow > info.Position)
                        {
                            ErrorResult er = new ErrorResult();
                            er.ErrorCode    = "3003";
                            er.ChunkIndex   = infonow.ChunkIndex;
                            resultinfo.data = info;
                            strJsonResult   = JsonConvert.SerializeObject(resultinfo);
                            result          = true;
                        }
                        else
                        {
                            fs = new FileStream(infonow.FilePath, FileMode.Append, FileAccess.Write, FileShare.Read, 1024);

                            fs.Write(info.Data, 0, info.Data.Length);
                            fs.Close();
                        }
                    }
                    catch (Exception ex)
                    {
                        LoggerHelper.Error($"BigAttachManager调用{funname}异常", paramstr, ex.ToString(), transactionid);
                    }
                    finally
                    {
                        if (fs != null)
                        {
                            fs.Close();
                        }
                    }

                    finfo.Refresh();
                    info.TempID = infonow.TempID;
                    if (finfo.Length == infonow.FileSizeInt)
                    {
                        // upload finish
                        // move file to new folder
                        string newpath = infonow.FilePath.Substring(0, infonow.FilePath.LastIndexOf("\\temp\\")) +
                                         @"\" + DateTime.Now.ToString("yyyy-MM-dd");
                        string newfilepath = newpath + infonow.FilePath.Substring(infonow.FilePath.LastIndexOf('\\'));
                        if (Directory.Exists(newpath) == false)
                        {
                            Directory.CreateDirectory(newpath);
                        }
                        finfo.MoveTo(newfilepath);
                        info.FilePath = newfilepath;
                        result        = Provider.UploadFinish(transactionid, userid, ref info, out error);
                        if (result == true)
                        {
                            info.Succeed    = true;
                            resultinfo.data = info;
                            strJsonResult   = JsonConvert.SerializeObject(resultinfo);
                            //LoggerHelper.Info(userid.ToString(), funname, paramstr, Convert.ToString(error.Code), true, transactionid);

                            result = true;
                            break;
                        }
                    }
                    else
                    {
                        result = Provider.Upload(transactionid, userid, ref info, out error);
                        if (result == true)
                        {
                            info.Succeed    = false;
                            resultinfo.data = info;
                            strJsonResult   = JsonConvert.SerializeObject(resultinfo);
                            result          = true;
                            break;
                        }
                    }
                } 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);
        }
Exemple #12
0
        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);
        }