예제 #1
0
        public virtual string ReceiveFile(byte[] fileInfo, string fileNmae, string businessFunID, string heritageId)
        {
            //遗产地 + 大类+ 功能 +文件
            //var ftpUserID   = System.Configuration.ConfigurationManager.AppSettings["ftpUser"];
            //var ftpPassword = System.Configuration.ConfigurationManager.AppSettings["ftpPassword"];
            SystemLogger.getLogger().Info(DateTime.Now + "访问bug");
            var ftpAddress  = System.Configuration.ConfigurationManager.AppSettings["Address"];
            var rPath       = "";
            var filePath    = CommonBusiness.GetFileTempPath(businessFunID, heritageId, ftpAddress, out rPath);
            var fileNewGuid = Guid.NewGuid().ToString();

            var filePathAll = Path.Combine(filePath, fileNewGuid + "." + fileNmae.GetExtensioName());

            if (!System.IO.Directory.Exists(filePath))
            {
                SystemLogger.getLogger().Info(DateTime.Now + "创建目录");
                System.IO.Directory.CreateDirectory(filePath);
            }
            FileStream fstream = File.Create(filePathAll, fileInfo.Length);

            fstream.Write(fileInfo, 0, fileInfo.Length);   //
            SystemLogger.getLogger().Info(DateTime.Now + "创建目录正常");
            try
            {
                var dbContext = DBHelperPool.Instance.GetDbHelper();
                if (dbContext == null)
                {
                    return(JsonHelper.SerializeObject(ToolResult.Failure("数据连接异常!")));
                }
                var sql = @"INSERT INTO `HPF_TEMP_FILE` (`ID`,`WJMC`,`WJLX`,`WJLJ`)	VALUES ('{0}','{1}','{2}','{3}')";
                SystemLogger.getLogger().Info(DateTime.Now + "访问bug1");
                var iResult = dbContext.execute(string.Format(sql, fileNewGuid, fileNmae, fileNmae.GetExtensioName(), rPath + fileNewGuid + "." + fileNmae.GetExtensioName()));
                SystemLogger.getLogger().Info(DateTime.Now + "访问bug2");
                SystemLogger.getLogger().Info("返回结果:" + iResult);
                return(iResult > 0 ? fileNewGuid : "");
            }
            catch (Exception ex)
            {
                var strErr = string.Format("遗产地对接文件类数据错误,参数:{0}#{1}#{2},具体错误:{3}", fileNmae, businessFunID, heritageId, ex.Message);
                SystemLogger.getLogger().Error(strErr);
            }
            finally
            {
                fstream.Close();
            }
            SystemLogger.getLogger().Info(DateTime.Now + "访问bug4");
            return(fileNewGuid);
        }