Beispiel #1
0
        private TranslateResult CreateDefaultTranslate(string input)
        {
            TranslateResult result = new TranslateResult();

            result.IsValid          = 0;
            result.BusinessCode     = "EOthers";
            result.FileCode         = "EOthers";
            result.Translate        = input;
            result.InsititutionCode = "EOthers";
            return(result);
        }
Beispiel #2
0
        private TranslateResult CreateTranslateByDataRow(DataRow dr)
        {
            TranslateResult result = new TranslateResult();

            result.IsValid          = Convert.ToInt32(dr["isvalid"]);
            result.BusinessCode     = dr["businessCode"].ToString();
            result.FileCode         = dr["typecode"].ToString();
            result.Translate        = dr["translate"].ToString();
            result.InsititutionCode = dr["InsititutionCode"].ToString();
            return(result);
        }
Beispiel #3
0
        private TranslateResult Translate(string input)
        {
            string sql = "select translate,isvalid ,businessCode,typecode,InsititutionCode from EMAILKEYWORDS where input=:input";

            OracleParameter[] paras =
            {
                new OracleParameter(":input", input)
            };

            DataTable       tb     = DBHelper.GetDataTableBySql(sql, paras);
            TranslateResult result = null;

            if (tb != null && tb.Rows.Count == 1)
            {
                result = CreateTranslateByDataRow(tb.Rows[0]);
            }
            else
            {
                result = CreateDefaultTranslate(input);
            }

            return(result);
        }
Beispiel #4
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);
        }