å€ãã®å Žåãã€ã³ã¹ããŒã©ãŒã®äœæãæåŠãããã¡ã€ã«ãã©ã«ããŒãã¿ãŒã²ããã³ã³ãã¥ãŒã¿ãŒã«ã³ããŒããŠã¢ããªã±ãŒã·ã§ã³ãé åžããããšãæåŠããå¿ èŠæ§ãŸãã¯èŠæããããŸãã Report Viewerã¬ããŒãã䜿çšããŠ.Netã¢ããªã±ãŒã·ã§ã³çšã®ããŒã¿ãã«é åžããããäœæããæ¹æ³ããŸãã¯OracleããŒã¿ããŒã¹ã«ã¢ã¯ã»ã¹ããããã«ã¯ã©ã€ã¢ã³ããšãã©ã€ããŒãããŒã¿ãã«ã«ã³ããŒããæ¹æ³ã«èå³ãããå Žåã¯ãcatã䜿çšããŠãã ããã ç§ã¯ãã¹ãŠã詳现ã«èª¬æããããšããŸãã
å®çšçãªéšåãšããŠãSupermagãã¬ãŒãã£ã³ã°ã·ã¹ãã ïŒå®éã«ã¯OracleããŒã¿ããŒã¹ã䜿çšïŒã®ã¬ããŒãã衚瀺ããã¢ããªã±ãŒã·ã§ã³ã®äœæãæ€èšããŸãã
Oracleã¯ã©ã€ã¢ã³ãã®ããŒã¿ãã«é åžã®å©ç¹ã®1ã€ã¯ããã®æšæºã€ã³ã¹ããŒã«ãå¿«é©ãªäœéšã§ã¯ãªãããšã§ãã ãŸããã¬ããŒããã¥ãŒã¢ãŒãã€ã³ã¹ããŒã«ããå Žåãè€æ°ã®ãã·ã³ã§ã®ã€ã³ã¹ããŒã«ããã»ã¹ã¯é¢åãªã¿ã¹ã¯ã«ãªããªã¹ã¯ããããŸãã ãã¡ããã代æ¿æ段ãšããŠClickOnceã䜿çšã§ããŸãããClickOnceã䜿çšããŠé åžããå Žåããã®äŸã®ããã«ã©ã€ãã©ãªãã©ã«ããŒãã³ããŒããããšãã§ããŸãã
Oracleãžã®ããŒã¿ãã«ã¢ã¯ã»ã¹ãåãããã¹ã¯ãããã¢ããªã±ãŒã·ã§ã³ã«äžå¯æ¬ ãªã©ã€ãã©ãª
Oracle Instant ClientãããŠã³ããŒãããå¿ èŠããããŸãã ããŒã«ã©ã€ãºãããã¢ããªã±ãŒã·ã§ã³ã䜿çšããå Žåããµã€ãºã¯çŽ100Mbã§ãããåºæ¬ããã±ãŒãžã䜿çšããæ¹ãé©åã§ãããã軜ãã30ã¡ã¬ãã€ããšã¯ç°ãªããããªã«æåã䜿çšããããšãä¿èšŒãããŸãã
ã¢ãŒã«ã€ããå±éãããããã2ã€ã®ãã¡ã€ã«ãååŸããŸãã
oci.dll ïŒOracle Call Interfaceã®ç¥ïŒ;
orannzsbb11.dllãŸãã¯orannzsbb12.dll ïŒããŒãžã§ã³12ã䜿çšããå ŽåïŒã
3çªç®ã®ãã¡ã€ã«ãå¿ èŠã§ãã
åºæ¬ããŒãžã§ã³ã䜿çšããå Žåã oraociei11.dllãŸãã¯oraociei12.dll ïŒããŒãžã§ã³12ã§ãåæ§ ïŒã«ãªããŸãã
ã©ã€ãããŒãžã§ã³ã䜿çšããå Žå-oraociicus11.dllãŸãã¯oraociicus12.dll ïŒããŒãžã§ã³12ã®2çªç®ã®ãã¡ã€ã«ã誰ã«ã§ãæããã§ããããšã¯èšåããŸããïŒã
ãŸããOracle Data Provider-ODP.NETïŒXCopyããŒãžã§ã³ã䜿çšããããšããå§ãããŸãããµã€ãºãå°ããæ¹ïŒãå¿ èŠã§ãã2ã€ã®ãã¡ã€ã«ã解åããŠæ€çŽ¢ããŸãã
Oracle.DataAccess.dll ;
OraOps11w.dllãŸãã¯OraOps12w.dll ïŒãã®ãã¡ã€ã«ã¯Oracle.DataAccess.dllãOracle Instant Clientãã¡ã€ã«ãæäœããããã«å¿ èŠã§ãã.Net2.0ãš.Net 4.0ã®äž¡æ¹ã§åãã§ãïŒã
ããŒãžã§ã³12ã䜿çšããå Žåã¯ã次ã®ãªã³ã¯ãã1ã€ã®ODACïŒOracle Data Access ComponentsïŒãã¡ã€ã«ã§Oracle Instant ClientãšODPã®äž¡æ¹ãããŠã³ããŒãã§ããŸãã
ããŒã¿ãã«ã¬ããŒããã¥ãŒã¢ãŒã¢ããªã±ãŒã·ã§ã³ã®å¿ é ã©ã€ãã©ãª
ã¬ããŒããã¥ãŒã¢ãŒã®ããŒã¿ãã«ãªé åžç©ãšããŠãããŒãžã§ã³2010ãåãäžããŸãããã
ç§ã¯ããŒãžã§ã³2013ãããŒã¿ãã«é åžçšã®ããŒãžã§ã³ãšã¯èŠãªããŸããã§ããã Microsoft.ReportViewer.ProcessingobjectModel.dllãèŠã€ãããªãããšãããã£ãåŸãããã³ãã¬ãŒããã¬ãŒã¯ããçºçãã2010幎ã®ã¬ããŒãã¯éââåžžã«è¯å¥œã§ãããšå€æããŸããã 2013ããŒãžã§ã³ã®ããŒã¿ãã«ãã£ã¹ããªãã¥ãŒã·ã§ã³ã®äœææ¹æ³ããåç¥ã®å Žåã¯ãã³ã¡ã³ãããåŸ ã¡ããŠããŸãã 競äºãçºè¡šããããšãã§ããŸãããããã¯äžéã§ã-è³åã¯ãããŸããã
Microsoft Report Viewer Redistributable 2010ãããŠã³ããŒãããexeãã¡ã€ã«ãã¢ãŒã«ã€ããšããŠè§£åããŸãã
解åããããã¡ã€ã«ã®äžã«ã¯ãreportviewer_redist2010core.cabããããŸãã
ãå ¥ãå人圢ããç¶ããŠããã®ãã¡ã€ã«ãé çªã«å±éããŸãã
ãã¡ã€ã«ãèŠã€ããŠã次ã®ããã«ååãå€æŽããŸãã
FL_Microsoft_ReportViewer_Common_dll_117718_117718_x86_ln.3643236F_FC70_11D3_A536_0090278A1BB8
ååãMicrosoft.ReportViewer.Common.dllã«å€æŽããŸã
FL_Microsoft_ReportViewer_Processingobject_125592_125592_x86_ln.3643236F_FC70_11D3_A536_0090278A1BB8
ååãMicrosoft.ReportViewer.ProcessingobjectModel.dllã«å€æŽããŸã
FL_Microsoft_ReportViewer_WebForms_dll_117720_117720_x86_ln.3643236F_FC70_11D3_A536_0090278A1BB8
ååãMicrosoft.ReportViewer.WebForms.dllã«å€æŽããŸã
FL_Microsoft_ReportViewer_WinForms_dll_117722_117722_x86_ln.3643236F_FC70_11D3_A536_0090278A1BB8
ååãMicrosoft.ReportViewer.WinForms.dllã«å€æŽããŸã
éçºè ã®ã³ââã³ãã¥ãŒã¿ãŒã«Oracle ClientãšReport Viewerãã€ã³ã¹ããŒã«ãããŠããå ŽåïŒã€ã³ã¹ããŒã«ããå¿ èŠããããŸãïŒããããã®ãã¡ã€ã«ãžã®ãªã³ã¯ãèšå®ããããšãã§ããŸãããexeã§ãã©ã«ããŒã«ïŒãããžã§ã¯ãã®Debugãã©ã«ããŒãšReleaseãã©ã«ããŒã«ïŒã³ããŒããã ãã§ãã ãã ããOracle.DataAccess.dllã¯ãããžã§ã¯ããã©ã«ãã«é 眮ãããããŒã«ã«ã«ã³ããŒãããããã£ã2ã€ã®ã³ããŒãªãã·ã§ã³ã®ããããã«èšå®ããå¿ èŠããããŸãã
ããŒã¿ãã«é åžã®ææãããã»ã©å€§ãããªãããã«ããã¹ã¯ããã.Nââetã¢ããªã±ãŒã·ã§ã³ã®ã©ã€ãã©ãªæ€çŽ¢ã¢ã«ãŽãªãºã ã«ã€ããŠç°¡åã«èª¬æããŸãã
dllæ€çŽ¢ãéå§ããåã«ãã·ã¹ãã ã¯ãdllãæ¢ã«ã¡ã¢ãªã«ããŒããããŠãããã©ãããããã³dllããã§ã«æ¢ç¥ã®dllã®ãªã¹ãã«ãããã©ããã確èªããŸãïŒã¬ãžã¹ããªã®HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Control \ Session Manager \ KnownDLLsã®ãªã¹ããèŠãŠã¿ãŠãã ããïŒã
dllæ€çŽ¢ã¢ã«ãŽãªãºã ã¯ããã€ãã®èŠå ïŒSafeDllSearchModeã¢ãŒããèšå®ãããŠãããã©ãããªã©ïŒã«äŸåããŸãããã»ãŒåãã§ãïŒãã®äŸã§ã¯SafeDllSearchModeããªãã«ãªã£ãŠããŸãïŒã
1.ã¢ããªã±ãŒã·ã§ã³ã®èµ·åå ã®ãã£ã¬ã¯ããªã
2.çŸåšã®ãã£ã¬ã¯ããªã
3.ã·ã¹ãã ãã£ã¬ã¯ããªã GetSystemDirectoryé¢æ°ã䜿çšããŠããã®ãã£ã¬ã¯ããªãžã®ãã¹ãååŸã§ããŸãã
4. 16ãããã·ã¹ãã ãã£ã¬ã¯ããªã
5. Windowsãã£ã¬ã¯ããªã GetWindowsDirectoryé¢æ°ã䜿çšã§ããŸãã
6. PATHã·ã¹ãã å€æ°ã§æå®ãããŠãããã©ã«ããŒã
PATHã·ã¹ãã å€æ°ãšã¯äœã§ãã©ãã«ããã®ãã次ã®ã¹ã¯ãªãŒã³ã·ã§ãããèŠèŠçã«ç¢ºèªããŠãã ããã
ããã§ã¯ãå®éã®éšåã«ç§»ããŸãããã
WPFã¢ããªã±ãŒã·ã§ã³ïŒããã³ã¬ã€ã¢ãŠããšãã£ã¿ãŒãšããŠã®åŸæ¥ã®ãã©ãŒã ãããXAMLã®æ¹ãæãŸããïŒã§ã¯ãã¬ããŒããã¥ãŒã¢ãŒã³ã³ããŒãã³ãã¯WindowsFormsHostã³ã³ãããŒã«ã䜿çšããŠè¿œå ãããŸãã
<WindowsFormsHost HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,0,0,0" Name="windowsFormsHost1"> <rv:ReportViewer x:Name="_reportViewer"/> </WindowsFormsHost>
ãã®äŸã圹ã«ç«ããªãããã«ãããã¥ã¡ã³ãã®å±¥æŽããããŒã¿ãåãåããŸãã
ã¬ããŒãã«å¿ èŠãªããŒã¿ãä¿åããã«ã¯ãã¯ã©ã¹ãäœæããŸãã
public class ReportDataSM { public DateTime EventTime { get; set; } public string Doc { get; set; } public string UserName { get; set; } public string NewState { get; set; } }
ããã§ãã¬ããŒãã®å€èŠ³çšã®ãã³ãã¬ãŒããã¡ã€ã«ãäœæã§ããŸãïŒéçºè ã®ã³ââã³ãã¥ãŒã¿ãŒã®ããžã¥ã¢ã«ãšãã£ã¿ãŒã§ã¯ãVisual Studioãã€ã³ã¹ããŒã«ãããšãã«ãMicrosoft SQL ServerããŒã¿ããŒã«ã¢ã€ãã ãéžæããå¿ èŠããããŸãïŒã
ã¬ããŒããã¡ã€ã«ããããžã§ã¯ãã«è¿œå ããŸãïŒã¬ããŒãïŒã ãããŒã«ã«ã«ã³ããŒãããããã£ã®å€ããæ°ããå Žåã«ã³ããŒãã«èšå®ããŸãã 次ã«ãäœæããã°ããã®ã¬ããŒããã¡ã€ã«ãéãã[ããŒã¿ãœãŒã¹]ã¿ãã«ç§»åããŸãã [æ°ããããŒã¿ãœãŒã¹ã®è¿œå ]ãã¯ãªãã¯ãã[ãªããžã§ã¯ã]ã¿ã€ããéžæããŸãããªããžã§ã¯ãã®ãªã¹ãã§ãããžã§ã¯ããéããéžæããã¯ã©ã¹ReportDataSMãèŠã€ããŸãã
次ã«ãããŒã¿ãå«ãè¡ã衚瀺ããã«ã¯ãã¬ããŒãã«ããŒãã«ãè¿œå ããŸãã ããŒã¿ã»ããã®ããããã£ãã¯ãšãªã«è¿œå ããå ŽåãããŒã¿ãœãŒã¹ãéžæããååãä»ããŸãïŒäŸã§ã¯DataSet1ïŒã
ãã®ããŒã¿ãœãŒã¹ã¯ãDataSetNameããããã£ã®ããŒãã«ã¿ãã§æå®ãããŸãã rdlcãã¡ã€ã«ã¯ãããžã¥ã¢ã«ãšãã£ã¿ãŒã ãã§ãªããXMLãšãã£ã¿ãŒã䜿çšããŠç·šéããããšãã§ããŸãïŒãã®æ¹æ³ã§ã¯ãå€ãäžèŠãªããŒã¿ãåé€ããã®ã«äŸ¿å©ã§ãïŒã
é åã®ããŒã¿ããåã®å€ãèšå®ããŸãïŒç·ãã¯ãªãã¯ããã®ã¯ç°¡åã§çŽæçã§ãã詳现ã¯èª¬æããŸããïŒã
ã³ãŒããæ€èšãã
ã€ã³ã¿ãŒãã§ã€ã¹ã®åçµã¯éåžžã«æªãç¿æ £ãªã®ã§ãããŒã¿ãµã³ããªã³ã°ã¯å¥ã®ã¹ããªãŒã ã§éå§ããŸãã ããŒã¿ã¹ãã¬ãŒãžã«ã¯ãReportDataSMã¯ã©ã¹ã®ç«¶åããæ±çšïŒæ±çšïŒã³ã¬ã¯ã·ã§ã³ã䜿çšããŸãã å€æ°å®£èšã«è¿œå ããŸãïŒã¯ã©ã¹ã®å é ïŒïŒ
ConcurrentBag<ReportDataSM> list4R;
ã³ãŒãã®ã©ããã§åæåããåŸïŒ
list4R = new ConcurrentBag<ReportDataSM>();
ã€ã³ã¿ãŒãã§ã€ã¹ããããã¯ããã«ããŒã¿ãåä¿¡ããããšã«ããã®ã§ãã¡ãœãããéåæã«åŒã³åºãããªã²ãŒããå¿ èŠã§ãã
delegate void MyGetDataDelegate(string s);
ãã®äŸã§ã¯ãããªã²ãŒãã¯ãã©ã¡ãŒã¿ãŒãšããŠ1ã€ã®æååå€ãåããŸãã
ãã©ã¡ãŒã¿ãŒã¯ãå€æŽå±¥æŽã«é¢ããããŒã¿ãåä¿¡ããããã¥ã¡ã³ãã®èå¥åã«ãªããŸãã
ããªã²ãŒãå®è£ ã§ããã¡ãœããã¯ãgetDataMethodãšåŒã°ããã¡ãœããã§ãã
ããŒã¿ãååŸããæ¹æ³ãå®è£ ããããã®ç°¡ç¥åãããã³ãŒããæäŸããŸãïŒãšã©ãŒãåŠçããããšãªãïŒã
void getDataMethod(string docid){ DataSet dataset = new DataSet(); string oradb = "Data Source=" + "DATABASENAME" + ";User Id=" + "typeusernamehere" + ";Password=" + "password123" + ";"; // , , Oracle // TNSNAMES.ORA , . using (OracleConnection conn = new OracleConnection(oradb)) { if (conn.State != ConnectionState.Open) conn.Open(); string sqltext = "select SMDocLog.EVENTTIME, SMDocLog.ID, SMDocLog.USERNAME, NVL(SSDocStates.DOCSTATENAME,' ') as NEWSTATE"; sqltext = sqltext + " from SMDocLog LEFT JOIN SSDocStates"; sqltext = sqltext + " ON SMDocLog.DOCTYPE=SSDocStates.DOCTYPE and SMDocLog.NEWSTATE=SSDocStates.DOCSTATE"; sqltext = sqltext + " WHERE ID='" + docid + "'"; sqltext = sqltext + " ORDER BY EVENTTIME DESC"; using (OracleCommand cmd = new OracleCommand()) { cmd.Connection = conn; cmd.CommandText = sqltext; cmd.CommandType = CommandType.Text; using (OracleDataAdapter adapterO = new OracleDataAdapter(cmd)) { using (DataSet ds = new DataSet()) { adapterO.Fill(ds); // , foreach (DataRow dr in ds.Tables[0].Rows) { ReportDataSM rd = new ReportDataSM(); rd.EventTime = Convert.ToDateTime(dr["EVENTTIME"]); rd.UserName = dr["USERNAME"].ToString(); rd.Doc = dr["ID"].ToString(); rd.NewState = dr["NEWSTATE"].ToString(); list4R.Add(rd); } } // end using DataSet } // end using OracleDataAdapter } // end using OracleCommand } }
ãã®ã¡ãœãããéåæã§åŒã³åºããŸãïŒ
MyGetDataDelegate dlgt = new MyGetDataDelegate(this.getDataMethod); IAsyncResult ar = dlgt.BeginInvoke(txtDocN.Text, new AsyncCallback(CompletedCallback), null);
ãã©ã¡ãŒã¿ãŒãšããŠæž¡ãããCompletedCallbackã¡ãœããã«æ³šæããŠãã ããã
ãã®å®è£ ã¯ãåŒã³åºãããã¡ãœããã®å®äºåŸã«ä»ã®ã¡ãœãããå®è¡ããããã«å¿ èŠã§ãã ãã®å ŽåãããŒã¿ãæœåºããåŸããã®ããŒã¿ãã¬ããŒãã«ãã€ã³ãããã€ã³ã¿ãŒãã§ãŒã¹ãæŽæ°ããå¿ èŠããããŸãã
void UpdateUserInterface() { _reportViewer.Reset(); ReportDataSource reportDataSource= new ReportDataSource("DataSet1", list4R); // _reportViewer.LocalReport.ReportPath = "ReportSM.rdlc"; _reportViewer.LocalReport.DataSources.Add(reportDataSource); _reportViewer.RefreshReport(); }
ããããã¢ããªã±ãŒã·ã§ã³ã¹ããªãŒã ããã®ã¿ã€ã³ã¿ãŒãã§ã€ã¹ãæŽæ°ã§ãããšããç¹ã§åé¡ããããŸãã
ãããè¡ãã«ã¯ããã£ã¹ãããã£ã¹ã¬ããããã¢ããªã±ãŒã·ã§ã³ã€ã³ã¿ãŒãã§ã€ã¹æŽæ°ã¡ãœãããåŒã³åºããŸãã ã€ãŸããCompletedCallbackã¡ãœããã®å 容ã¯æ¬¡ã®ããã«ãªããŸãã
void CompletedCallback(IAsyncResult result) { Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, new NoArgDelegate(UpdateUserInterface)); }
ç¹°ãè¿ããŸãããã¡ãœãããéåæçã«åŒã³åºãã«ã¯ãããªã²ãŒããå¿ èŠã§ããããä»åã¯ãã©ã¡ãŒã¿ãåãå ¥ããŸããã ã³ãŒãã®å é ã«è¿œå ããŸãã
private delegate void NoArgDelegate();
ãã®ã¢ããªã±ãŒã·ã§ã³ã®ãããªãã®ãååŸããå¿ èŠããããŸãã
æŽæ°ïŒ GitHubãããžã§ã¯ããžã®ãªã³ã¯ ïŒNuGetããã±ãŒãžãããŒãžã£ãŒããã€ã³ã¹ããŒã«ãããOracle.ManagedDataAccessã䜿çšïŒ