Beispiel #1
0
        private void InsertFileAndData(FileDetail fileDetail, string md5 = "")
        {
            var paras = new OracleParameter[19];

            paras[0]        = new OracleParameter("I_FILETYPECODE", OracleType.VarChar);
            paras[0].Value  = fileDetail.FileCode;
            paras[1]        = new OracleParameter("I_FILENAMECN", OracleType.NVarChar, 500);
            paras[1].Value  = fileDetail.FileNameCN;
            paras[2]        = new OracleParameter("I_FILENAMEEN", OracleType.NVarChar, 500);
            paras[2].Value  = fileDetail.FileNameEN;
            paras[3]        = new OracleParameter("I_UPLOADDATE", OracleType.DateTime);
            paras[3].Value  = fileDetail.UploadTime;
            paras[4]        = new OracleParameter("I_REPORTDATE", OracleType.DateTime);
            paras[4].Value  = fileDetail.UploadTime;
            paras[5]        = new OracleParameter("I_AUTHOR", OracleType.VarChar);
            paras[5].Value  = fileDetail.Author;
            paras[6]        = new OracleParameter("I_ISVALID", OracleType.Number);
            paras[6].Value  = fileDetail.IsValid;
            paras[7]        = new OracleParameter("I_EXTENSION", OracleType.VarChar);
            paras[7].Value  = fileDetail.Ext;
            paras[8]        = new OracleParameter("I_INSTITUTIONINFOCODE", OracleType.VarChar);
            paras[8].Value  = fileDetail.InstitutionCode;
            paras[9]        = new OracleParameter("I_FILESIZE", OracleType.NVarChar);
            paras[9].Value  = fileDetail.FileSize;
            paras[10]       = new OracleParameter("I_FILEORDER", OracleType.Number);
            paras[10].Value = fileDetail.FileOrder;
            paras[11]       = new OracleParameter("I_COMMENTS", OracleType.NVarChar, 500);
            paras[11].Value = "";
            paras[12]       = new OracleParameter("I_OPERATORS", OracleType.NVarChar);
            paras[12].Value = fileDetail.Operator;
            paras[13]       = new OracleParameter("I_CTIME", OracleType.DateTime);
            paras[13].Value = fileDetail.CreateTime;
            paras[14]       = new OracleParameter("I_BUSINESSTYPE", OracleType.VarChar);
            paras[14].Value = fileDetail.BusinessCode;
            paras[15]       = new OracleParameter("I_PHYSICALPATH", OracleType.NVarChar, 500);
            paras[15].Value = fileDetail.PhysicalPath;
            paras[16]       = new OracleParameter("I_FILEID", OracleType.Number);
            paras[16].Value = fileDetail.FileId;
            paras[17]       = new OracleParameter("I_FILEMD5", OracleType.VarChar);
            paras[17].Value = md5;
            paras[18]       = new OracleParameter("I_DM1FILEID", OracleType.Number);
            paras[18].Value = fileDetail.Dm1FileId;

            try
            {
                DBHelper.ExecuteStorageWithoutRevalue("FILEDETAIL_INSERT", paras);
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("Get exception when insert filedetail. \n file Id: {0} \n {1} \n", fileDetail.FileId, ex));
            }
        }
Beispiel #2
0
        //call storage service, and insert into filedetail in file db
        public bool InsertReportFile(string path, string instcode, string busicode, string filetypecode, string author, StringBuilder sb)
        {
            //check file
            if (!File.Exists(path))
            {
                return(false);
            }

            FileDetail fileDetail = new FileDetail();

            fileDetail.InstitutionCode = instcode;
            fileDetail.FileOrder       = GetFileOrder();

            string filesize = string.Empty;

            byte[] fileData = GetFileData(path, sb, out filesize);
            fileDetail.FileSize = filesize;
            DateTime dt = DateTime.UtcNow;

            fileDetail.UploadTime = dt;

            fileDetail.CreateTime = dt.ToString("yyyy-MM-dd HH:mm:ss");

            fileDetail.BusinessCode = busicode;
            fileDetail.FileCode     = filetypecode;

            var attachName = Path.GetFileNameWithoutExtension(path);

            fileDetail.FileNameCN = attachName;
            fileDetail.FileNameEN = attachName;
            fileDetail.Ext        = "pdf";
            fileDetail.IsValid    = 1;
            fileDetail.Author     = author;
            fileDetail.Operator   = "";

            var result = SaveResearchReport(fileDetail, fileData);

            if (result)
            {
                sb.AppendFormat("FileId: {0}, FileName: {1} Sync to Storage service successfully.\n", fileDetail.FileId, attachName);
            }

            return(result);
        }
Beispiel #3
0
        private bool IsExistDM1Id(FileDetail fileDetail)
        {
            var paras = new OracleParameter[2];

            paras[0]       = new OracleParameter("I_DM1FILEID", OracleType.Number);
            paras[0].Value = fileDetail.Dm1FileId;
            paras[1]       = new OracleParameter("O_RESULT", OracleType.Number)
            {
                Direction = ParameterDirection.Output
            };

            try
            {
                return(DBHelper.ExecuteStorageWithRevalue("FILEDETAIL_IsExistDM1ID", 1, paras) >= 1);
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("Get exception when insert filedetail. \n file Id: {0} \n {1} \n", fileDetail.FileId, ex));
            }
        }
Beispiel #4
0
        public bool SaveResearchReport(FileDetail detail, byte[] fileData, string md5 = "")
        {
            var fileId = 0;

            //if dm1ID is not null, from DM12DM2 job
            if (detail.Dm1FileId.HasValue)
            {
                var isExistDm1Id = IsExistDM1Id(detail);
                if (isExistDm1Id)
                {
                    fileId = detail.Dm1FileId.Value;
                }
            }
            fileId = fileId == 0 ? GetFileDetailSequence() : fileId;

            var dbPath  = string.Format("|{0}|{1}|{2}", detail.BusinessCode, detail.InstitutionCode, detail.FileCode);
            var success = false;

            try
            {
                success = FileUtil.CallStorageService("|RR" + dbPath, fileData, string.Format("{0}.{1}", fileId, detail.Ext));
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("Get exception when call storage service\n " +
                                                  "webserviceUrl: {0} \n fileId: {1} \n {2} \n", ConfigHelper.GetEndpointClientAddress("StorageServiceImplPort"), fileId, ex));
            }

            if (success)
            {
                detail.FileId       = fileId;
                detail.PhysicalPath = dbPath;
                InsertFileAndData(detail, md5);
            }
            else
            {
                throw new Exception(string.Format("Get failed result when call storage service\n " +
                                                  "webserviceUrl: {0} \n fileId: {1}  \n", ConfigHelper.GetEndpointClientAddress("StorageServiceImplPort"), fileId));
            }
            return(true);
        }
Beispiel #5
0
        public bool InsertReportToService(EmailInfo info, StringBuilder sb)
        {
            var md5 = ReportManager.MD5_Hash(info.CurrentAttrName);

            //处理业务
            if (FileExists(md5))
            {
                sb.Append(string.Format("Email: {0}, attachment name: {1} duplicated with {2}.  synced successfully \n",
                                        info.Ename, info.CurrentAttrName, md5));
                return(true);
            }
            var fileDetail = new FileDetail();

            fileDetail.InstitutionCode = GetInstitutionCode(info.Ename);
            fileDetail.FileOrder       = GetFileOrder();
            fileDetail.Author          = "";
            fileDetail.Operator        = "";
            if (fileDetail.InstitutionCode == "EOthers")
            {
                sb.Append("[ email:" + info.Ename + " doesn't exist in EMAILKEYWORDS:] \n");
            }
            string filesize = string.Empty;

            byte[] fileData = GetFileData(info.CurrentAttrName, sb, out filesize);
            fileDetail.FileSize = filesize;
            DateTime dt = DateTime.Parse(info.Etime);

            dt = DateTime.SpecifyKind(dt, DateTimeKind.Utc);
            dt = TimeZoneInfo.ConvertTime(dt, TimeZoneInfo.Local);
            fileDetail.UploadTime = dt;
            fileDetail.CreateTime = dt.ToString("yyyy-MM-dd HH:mm:ss");
            string ext = Path.GetExtension(info.CurrentAttrName).Substring(1);

            fileDetail.Ext = ext;

            string attachName       = GetFileName(info.CurrentAttrName);
            string attachConfigName = string.Empty;

            //match attachName
            if (Exists(attachName, fileDetail.InstitutionCode, out attachConfigName))
            {
                TranslateResult tranalate = Translate(attachConfigName);
                if (tranalate.BusinessCode == "EOthers" && tranalate.FileCode == "EOthers")
                {
                    return(false);
                }
                else
                {
                    if (IsChineseOrEnglish(attachConfigName))
                    {
                        fileDetail.FileNameCN = attachConfigName;
                        fileDetail.FileNameEN = tranalate.Translate;
                    }
                    else
                    {
                        fileDetail.FileNameEN = attachConfigName;
                        fileDetail.FileNameCN = tranalate.Translate;
                    }
                }
                //if email is not exists ,but input is exists ,use input to find institutioncode, most for @ccb.com. yy 20141223
                if (fileDetail.InstitutionCode.Equals("EOthers") &&
                    !fileDetail.InstitutionCode.Equals(tranalate.InsititutionCode))
                {
                    fileDetail.InstitutionCode = tranalate.InsititutionCode;
                }
                fileDetail.IsValid      = tranalate.IsValid;
                fileDetail.BusinessCode = tranalate.BusinessCode;
                fileDetail.FileCode     = tranalate.FileCode;
            }
            else
            {
                return(false);
            }

            var result = SaveResearchReport(fileDetail, fileData, md5);

            if (result)
            {
                sb.Append(string.Format("Email: {0}, attachment name: {1}, fileId: {2} has synced successfully \n", info.Ename, attachName, fileDetail.FileId));
            }
            return(result);
        }