Exemplo n.º 1
0
        public override void Initialization()
        {
            var strWhere = "";

            if (ID == 55) //Fx market
            {
                strWhere = "WHERE num<=5 AND BusinessCodeType='FX' ";
            }
            else if (ID == 61) // Fi market
            {
                strWhere += "WHERE num<=5 AND BusinessCodeType IN('FI','MM') ";
            }
            else if (ID == 22003)
            {
                strWhere = "WHERE num<=5 AND BusinessCodeType IN('Agriculture','Energy','Commodities','Metal','Others') ";
            }
            var oracleDBHelper =
                new OracleDBHelper(ConfigurationManager.AppSettings["FileDBConStr"]);
            var sql = "select * FROM GETReseachReportByType " + strWhere +
                      "ORDER BY InstitutionOrder,Code,TypeOrder,fileTypeCTIME,ReportDate DESC,num";
            var dt = oracleDBHelper.GetDataTableBySql(sql);

            //var cmd = new OracleCommand
            //{
            //    Connection = (OracleConnection)(db.Database.Connection),
            //    CommandText = "select * FROM GETReseachReportByType " + strWhere +
            //                  "ORDER BY InstitutionOrder,Code,TypeOrder,fileTypeCTIME,ReportDate DESC,num"
            //};
            //var da = new OracleDataAdapter(cmd);
            //da.Fill(dt);
            InstitList = (from DataRow dr in dt.Rows
                          select new InstitutionViewModel
            {
                Code = dr["Code"].ToString(),
                InstitutionNameCn = dr["InstitutionNameCn"].ToString(),
                InstitutionNameEn = dr["InstitutionNameEn"].ToString(),
                Mtime = Convert.ToDateTime(dr["MTIME"]),
                InstitutionExtension = dr["InstitutionExtension"].ToString(),
                FileTypeNameCn = dr["FileTypeNameCn"].ToString(),
                FileTypeNameEn = dr["FileTypeNameEn"].ToString(),
                FileNameCn = dr["FileNameCn"].ToString(),
                FileNameEn = dr["FileNameEn"].ToString(),
                FileId = Convert.ToInt32(dr["FileId"]),
                Extension = dr["Extension"].ToString(),
                ReportDate = Convert.ToDateTime(dr["ReportDate"]),
            }).ToList();
            INSTITUTIONINFO = (from m in InstitList.Select(re => new { re.InstitutionNameCn, re.InstitutionNameEn, re.Mtime, re.Code, Extension = re.InstitutionExtension }).Distinct()
                               select new INSTITUTIONINFO {
                INSTITUTIONNAMECN = m.InstitutionNameCn, INSTITUTIONNAMEEN = m.InstitutionNameEn, MTIME = m.Mtime, CODE = m.Code, EXTENSION = m.Extension
            }).Distinct().ToList();
            foreach (var inst in INSTITUTIONINFO)
            {
                inst.LogoPath = GetLogoImagePath(inst);
            }
        }