Esempio n. 1
0
        public void OpenReport()
        {
            try
            {
                updateDisplay(RsViewEngine.Locale.GetTagText("wait_Init"));
                createCrystalViewer();
                //_Document.RefreshReport += new EventHandler(EH_RefreshReport);

                opened = true;

                updateDisplay(RsViewEngine.Locale.GetTagText("wait_Open") + "\n" + _RptFile);
                ReportProvider = new RsReportProvider(_RptFile);
            }
            catch (Exception E)
            {
                RsViewEngine.TreatCriticalError(E);
            }

            /// <summary>
            ///   Collecting and if possible setting up datasource logon info
            /// </summary>
            updateDisplay(RsViewEngine.Locale.GetTagText("wait_DSBuild"));

            List <InternalConnectionInfo> lConnections = ReportProvider.GetAllConnections();

            foreach (InternalConnectionInfo iConnInfo in lConnections)
            {
                string lConnectionName = iConnInfo.DatabaseName == "" ?
                                         iConnInfo.ServerName :
                                         iConnInfo.DatabaseName;

                if (FileFormats.IsExcel(lConnectionName))
                {
                    continue;
                }

                CSecurityNode lSec = RsViewEngine.RSSecurity.GetSecurityNode("report", lConnectionName, _RptFile);
                if (lSec == null)
                {
                    lSec = RsViewEngine.RSSecurity.GetSecurityNode("DatasourceSecurity", lConnectionName);
                }

                if (lSec != null)
                {
                    iConnInfo.SetLogon(lSec.UserName, lSec.Password);
                }
                else
                {
                    if (!ShowAuthDialog(lConnectionName, iConnInfo))
                    {
                        System.Windows.Forms.Application.Exit();
                    }
                }
            }

            addRptToViewer();
            hideDisplay();
        }