示例#1
0
 public MstReport Get(string ReportCode)
 {
     try
     {
         using (InhCheckupDataContext cdc = new InhCheckupDataContext())
         {
             string server = GetMasterProjectConfigCls.GetConfigFromDB("ServerReport");
             if (GetLocalIP() == server)
             {
                 server = @"D:\www";
             }
             else
             {
                 server = @"\\" + server;
             }
             var result = cdc.mst_reports
                          .Where(x => x.mrt_code == ReportCode && x.mrt_status == 'A')
                          .Select(x => new MstReport
             {
                 ReportNameTH   = x.mrt_tname,
                 ReportNameEN   = x.mrt_ename,
                 ReportFilePath = server + @"\" + x.mrt_path_file + @"\" + x.mrt_file_name
             }).FirstOrDefault();
             return(result);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#2
0
 public ReportDocument Get(string ReportCode)
 {
     try
     {
         using (InhCheckupDataContext cdc = new InhCheckupDataContext())
         {
             var file = cdc.mst_reports
                        .Where(x => x.mrt_code == ReportCode && x.mrt_status == 'A')
                        .Select(x => new
             {
                 x.mrt_path_file,
                 x.mrt_file_name
             }).FirstOrDefault();
             var pathFile = @"\\" + GetMasterProjectConfigCls.GetConfigFromDB("ServerReport") + @"\" + file.mrt_path_file + @"\" + file.mrt_file_name;
             if (!File.Exists(pathFile))
             {
                 throw new Exception("File Report not Found.");
             }
             else
             {
                 ReportDocument rpt = new ReportDocument();
                 rpt.Load(pathFile);
                 new SetReportDatabase().SetDBLogonForReport(rpt);
                 rpt.Refresh();
                 rpt.VerifyDatabase();
                 return(rpt);
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#3
0
        public void SetDBLogonForReport(ReportDocument reportDocument)
        {
            ConnectionInfo connectionInfo = new ConnectionInfo();

            connectionInfo.ServerName   = GetMasterProjectConfigCls.GetConfigFromDB("ServerDataBase");
            connectionInfo.DatabaseName = GetMasterProjectConfigCls.GetConfigFromDB("DataBaseName");
            connectionInfo.UserID       = GetMasterProjectConfigCls.GetConfigFromDB("DataBaseUserName");
            connectionInfo.Password     = GetMasterProjectConfigCls.GetConfigFromDB("DataBasePassword");
            Tables tables = reportDocument.Database.Tables;

            foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
            {
                TableLogOnInfo tableLogonInfo = table.LogOnInfo;
                tableLogonInfo.ConnectionInfo = connectionInfo;
                table.ApplyLogOnInfo(tableLogonInfo);
            }
        }