Exemplo n.º 1
0
        public void CreateReport(ReportGroup reportGroup, Report report, int seq)
        {
            byte[] definition = report.Process(reportGroup.TargetFolder, reportGroup.DataSource);
            if (definition == null)
            {
                return;
            }

            Warning[] warnings = _proxy.CreateReport(
                report.Name,
                Util.FormatPath(reportGroup.TargetFolder),
                true,
                definition,
                null);

            if (warnings != null)
            {
                Logger.LogMessage(string.Format("{0} Report:{1} / [{2}] published successfully with some warnings", seq, reportGroup.Name, report.Name));
                //foreach(Warning warning in warnings)
                //{
                //	Logger.LogMessage(warning.Message);
                //}
            }
            else
            {
                Logger.LogMessage(string.Format("{0} Report:{1} / [{2}] published successfully with no warnings", seq, reportGroup.Name, report.Name));
            }

            if (report.CacheOption != null &&
                report.CacheOption.CacheReport &&
                report.CacheOption.ExpirationMinutes != null)
            {
                _proxy.SetCacheOptions(
                    string.Format("{0}/{1}", Util.FormatPath(reportGroup.TargetFolder), report.Name),
                    true,
                    new TimeExpiration()
                {
                    Minutes = report.CacheOption.ExpirationMinutes.Value
                });
            }
        }
Exemplo n.º 2
0
        private static void ReadSettings(XmlDocument d)
        {
            // Globals
            XmlNodeList list5 = d.SelectNodes("//Settings/Globals/Global");

            _GlobalVariables = new StringDictionary();

            if (list5 != null)
            {
                foreach (XmlNode node in list5)
                {
                    XmlNode key = node.Attributes["Name"];
                    if (key != null)
                    {
                        if (_GlobalVariables.ContainsKey(key.Value))
                        {
                            _GlobalVariables[key.Value] = node.InnerText;
                        }
                        else
                        {
                            _GlobalVariables.Add(key.Value, node.InnerText);
                        }
                    }
                }
            }

            // ReportServers
            XmlNodeList list6 = d.SelectNodes("//Settings/ReportServers/ReportServer");

            if (list6 != null)
            {
                _ReportServers = new Hashtable();
                foreach (XmlNode node in list6)
                {
                    XmlNode n0 = node.Attributes["Name"];
                    if (n0 != null)
                    {
                        string  name   = ProcessGlobals(n0.Value);
                        XmlNode rsHost = node.Attributes["Host"];
                        XmlNode rsPath = node.Attributes["Path"];
                        if (rsHost != null && rsPath != null)
                        {
                            XmlNode rsProtocol = node.Attributes["Protocol"];
                            string  protocol   = rsProtocol != null
                                ? ProcessGlobals(rsProtocol.Value)
                                : "http";

                            XmlNode rsTimeout = node.Attributes["Timeout"];
                            string  timeout   = rsTimeout != null
                                ? ProcessGlobals(rsTimeout.Value)
                                : null;

                            XmlNode rsUserName = node.Attributes["UserName"];
                            string  userName   = rsUserName != null && rsUserName.Value.Trim().Length > 0
                                ? ProcessGlobals(rsUserName.Value)
                                : null;

                            XmlNode rsPassword = node.Attributes["Password"];
                            string  password   = rsPassword != null
                                ? ProcessGlobals(rsPassword.Value)
                                : null;

                            ReportServerInfo rsInfo = new ReportServerInfo(name, protocol, ProcessGlobals(rsHost.Value), ProcessGlobals(rsPath.Value), timeout, userName, password);
                            if (_ReportServers.ContainsKey(name))
                            {
                                _ReportServers[name] = rsInfo;
                            }
                            else
                            {
                                _ReportServers.Add(name, rsInfo);
                            }
                        }
                    }
                }
            }

            // DataSources
            XmlNodeList list1 = d.SelectNodes("//Settings/DataSources/DataSource");

            if (list1 != null)
            {
                _DataSources   = new Hashtable();
                _DBConnections = new StringDictionary();
                foreach (XmlNode node in list1)
                {
                    string name                = null;
                    string userName            = null;
                    string password            = null;
                    string credentialRetrieval = null;
                    string connectionString    = null;
                    string targetFolder        = null;
                    string reportServer        = null;
                    bool   publish             = false;
                    bool   overwrite           = false;
                    bool   windowsCredentials  = false;

                    XmlNode n1 = node.Attributes["Name"];

                    if (n1 != null)
                    {
                        name = n1.Value;
                        XmlNode n2  = node.Attributes["Publish"];
                        XmlNode n3  = node.SelectSingleNode("ConnectionString");
                        XmlNode n4  = node.Attributes["Overwrite"];
                        XmlNode n5  = node.SelectSingleNode("UserName");
                        XmlNode n6  = node.SelectSingleNode("Password");
                        XmlNode n7  = node.SelectSingleNode("CredentialRetrieval");
                        XmlNode n8  = node.SelectSingleNode("WindowsCredentials");
                        XmlNode n9  = node.Attributes["TargetFolder"];
                        XmlNode n10 = node.Attributes["ReportServer"];

                        if (n2 != null)
                        {
                            publish = (n2.Value.ToLower() == "true");
                        }
                        if (n3 != null)
                        {
                            connectionString = ProcessGlobals(n3.InnerText);
                        }
                        if (n4 != null)
                        {
                            overwrite = (n4.Value.ToLower() == "true");
                        }
                        if (n5 != null)
                        {
                            if (n5.InnerText.Trim().Length > 0)
                            {
                                userName = ProcessGlobals(n5.InnerText);
                            }
                        }
                        if (n6 != null)
                        {
                            password = ProcessGlobals(n6.InnerText);
                        }
                        if (n7 != null)
                        {
                            credentialRetrieval = ProcessGlobals(n7.InnerText);
                        }
                        if (n8 != null)
                        {
                            windowsCredentials = (n8.InnerText.ToLower() == "true");
                        }
                        if (n9 != null)
                        {
                            targetFolder = ProcessGlobals(n9.Value);
                        }
                        if (n10 != null)
                        {
                            reportServer = ProcessGlobals(n10.Value);
                        }

                        if (_DataSources.ContainsKey(name))
                        {
                            _DataSources[name]   = new DataSource(name, userName, password, credentialRetrieval, windowsCredentials, connectionString, publish, overwrite, targetFolder, reportServer);
                            _DBConnections[name] = ((DataSource)_DataSources[name]).ConnectionString;
                        }
                        else
                        {
                            _DataSources.Add(name, new DataSource(name, userName, password, credentialRetrieval, windowsCredentials, connectionString, publish, overwrite, targetFolder, reportServer));
                            _DBConnections.Add(name, ((DataSource)_DataSources[name]).ConnectionString);
                        }
                    }
                }
            }

            // Reports
            XmlNodeList list7 = d.SelectNodes("//Settings/Reports/ReportGroup");
            int         k     = 0;

            if (list7 != null)
            {
                _ReportGroups = new ReportGroup[list7.Count];
                foreach (XmlNode node in list7)
                {
                    string   rgName         = null;
                    string   targetFolder   = null;
                    string   dataSourceName = null;
                    string   reportServer   = null;
                    int      cacheTime      = -1;
                    Report[] reports        = null;

                    XmlNode n1  = node.Attributes["Name"];
                    XmlNode n2  = node.Attributes["DataSourceName"];
                    XmlNode n3  = node.Attributes["TargetFolder"];
                    XmlNode n4  = node.Attributes["ReportServer"];
                    XmlNode n14 = node.Attributes["CacheTime"];
                    if (n2 != null && n3 != null && n4 != null)
                    {
                        dataSourceName = ProcessGlobals(n2.Value);
                        targetFolder   = ProcessGlobals(n3.Value);
                        reportServer   = ProcessGlobals(n4.Value);
                        if (n1 != null)
                        {
                            rgName = ProcessGlobals(n1.Value);
                        }
                        if (n14 != null)
                        {
                            cacheTime = int.Parse(ProcessGlobals(n14.Value));
                        }

                        XmlNodeList list2 = node.SelectNodes("Report");
                        int         i     = 0;
                        if (list2 != null)
                        {
                            reports = new Report[list2.Count];
                            foreach (XmlNode node1 in list2)
                            {
                                string  rpName          = null;
                                string  collapsedHeight = null;
                                int     reportCacheTime = cacheTime;
                                XmlNode n11             = node1.SelectSingleNode("FilePath");

                                if (n11 != null)
                                {
                                    XmlNode n12 = node1.Attributes["Name"];
                                    XmlNode n13 = node1.Attributes["CollapsedHeight"];
                                    XmlNode n15 = node1.Attributes["CacheTime"];
                                    if (n12 != null)
                                    {
                                        rpName = ProcessGlobals(n12.Value);
                                    }
                                    if (n13 != null)
                                    {
                                        collapsedHeight = ProcessGlobals(n13.Value);
                                    }
                                    if (n15 != null)
                                    {
                                        reportCacheTime = int.Parse(ProcessGlobals(n15.Value));
                                    }

                                    reports[i] = new Report(rpName, string.Format("{0}{1}", Settings.CurrentDirectory, n11.InnerText), collapsedHeight, reportCacheTime);
                                }

                                i++;
                            }
                        }

                        _ReportGroups[k] = new ReportGroup(rgName, targetFolder, dataSourceName, reportServer, reports);
                    }
                    k++;
                }
            }

            //BinaryFiles
            XmlNodeList list8 = d.SelectNodes("//Settings/BinaryFiles/BinaryFilesGroup");
            int         kk    = 0;

            if (list8 != null)
            {
                _BinaryFilesGroup = new BinaryFilesGroup[list8.Count];
                foreach (XmlNode node in list8)
                {
                    string rgName       = null;
                    string targetFolder = null;
                    //string dataSourceName = null;
                    string       reportServer = null;
                    int          cacheTime    = -1;
                    BinaryFile[] reports      = null;

                    XmlNode n1 = node.Attributes["Name"];
                    // XmlNode n2 = node.Attributes["DataSourceName"];
                    XmlNode n3  = node.Attributes["TargetFolder"];
                    XmlNode n4  = node.Attributes["ReportServer"];
                    XmlNode n14 = node.Attributes["CacheTime"];
                    if (n3 != null && n4 != null)
                    {
                        //  dataSourceName = ProcessGlobals(n2.Value);
                        targetFolder = ProcessGlobals(n3.Value);
                        reportServer = ProcessGlobals(n4.Value);
                        if (n1 != null)
                        {
                            rgName = ProcessGlobals(n1.Value);
                        }
                        if (n14 != null)
                        {
                            cacheTime = int.Parse(ProcessGlobals(n14.Value));
                        }

                        XmlNodeList list2 = node.SelectNodes("BinaryFile");
                        int         ik    = 0;
                        if (list2 != null)
                        {
                            reports = new BinaryFile[list2.Count];
                            foreach (XmlNode node1 in list2)
                            {
                                string  rpName          = null;
                                string  collapsedHeight = null;
                                int     reportCacheTime = cacheTime;
                                XmlNode n11             = node1.SelectSingleNode("FilePath");

                                if (n11 != null)
                                {
                                    XmlNode n12 = node1.Attributes["Name"];
                                    XmlNode n13 = node1.Attributes["CollapsedHeight"];
                                    XmlNode n15 = node1.Attributes["CacheTime"];
                                    if (n12 != null)
                                    {
                                        rpName = ProcessGlobals(n12.Value);
                                    }
                                    if (n13 != null)
                                    {
                                        collapsedHeight = ProcessGlobals(n13.Value);
                                    }
                                    if (n15 != null)
                                    {
                                        reportCacheTime = int.Parse(ProcessGlobals(n15.Value));
                                    }

                                    reports[ik] = new BinaryFile(rpName, string.Format("{0}{1}", Settings.CurrentDirectory, n11.InnerText), collapsedHeight, reportCacheTime);
                                }

                                ik++;
                            }
                        }

                        _BinaryFilesGroup[kk] = new BinaryFilesGroup(rgName, targetFolder, reportServer, reports);
                    }
                    k++;
                }
            }


            // Executions
            XmlNodeList list3 = d.SelectNodes("//Settings/DBExecutions/DBExecution");
            int         j     = 0;

            if (list3 != null)
            {
                _DBExecutions = new DBExecution[list3.Count];
                foreach (XmlNode node in list3)
                {
                    XmlNode dataSourceName = node.Attributes["DataSourceName"];

                    if (dataSourceName != null)
                    {
                        StringCollection files = null;
                        XmlNodeList      list4 = node.SelectNodes("DBFilePath");
                        if (list4 != null)
                        {
                            files = new StringCollection();
                            foreach (XmlNode node1 in list4)
                            {
                                files.Add(ProcessGlobals(node1.InnerText));
                            }
                        }

                        _DBExecutions[j] = new DBExecution(ProcessGlobals(dataSourceName.Value), files);
                    }

                    j++;
                }
            }
        }