示例#1
0
        private void UploadSubscription(ReportItem item, SubscriptionItem subscription)
        {
            try
            {
                var schedule = Schedules.Select(s => s.Value)
                               .FirstOrDefault(s => String.Equals(s.Name, subscription.ScheduleName, StringComparison.InvariantCultureIgnoreCase));
                if (schedule == null)
                {
                    return;
                }

                _Service.CreateSubscription(item.Path, subscription.ExtensionSettings, subscription.Description,
                                            subscription.EventType, schedule.ScheduleID, subscription.ParameterValues);
            }
            catch (Exception)
            {
                // Suppress
            }
        }
        private void ScheduleReport()
        {
            // See if the user wants to schedule this vs. run it now
            if (sharedSchedules.SelectedValue.ToString() != "NS")
            {
                string desc      = "Send report via email";
                string eventType = String.Empty;
                string matchData = String.Empty;
                // If the user selected SnapShot then set up the parameters for a snapshot
                if (sharedSchedules.SelectedValue.ToString() == "SS")
                {
                    eventType = "SnapshotUpdated";
                    matchData = null;
                }
                // otherwise the user is using a subscription
                else
                {
                    eventType = "TimedSubscription";
                    matchData = sharedSchedules.SelectedValue.ToString();
                }

                ParameterValue[] extensionParams = new ParameterValue[8];

                extensionParams[0]       = new ParameterValue();
                extensionParams[0].Name  = "TO";
                extensionParams[0].Value = GetEmailFromAD();

                extensionParams[1]       = new ParameterValue();
                extensionParams[1].Name  = "ReplyTo";
                extensionParams[1].Value = "*****@*****.**";

                extensionParams[2]       = new ParameterValue();
                extensionParams[2].Name  = "IncludeReport";
                extensionParams[2].Value = "True";

                extensionParams[3]       = new ParameterValue();
                extensionParams[3].Name  = "RenderFormat";
                extensionParams[3].Value = "PDF";

                extensionParams[4]       = new ParameterValue();
                extensionParams[4].Name  = "Subject";
                extensionParams[4].Value = "@ReportName was executed at @ExecutionTime";

                extensionParams[5]       = new ParameterValue();
                extensionParams[5].Name  = "Comment";
                extensionParams[5].Value = "Here is your @ReportName report.";

                extensionParams[6]       = new ParameterValue();
                extensionParams[6].Name  = "IncludeLink";
                extensionParams[6].Value = "True";

                extensionParams[7]       = new ParameterValue();
                extensionParams[7].Name  = "Priority";
                extensionParams[7].Value = "NORMAL";

                // Configure the extension settings required for the CreateSubscription method
                ExtensionSettings extSettings = new ExtensionSettings();
                extSettings.ParameterValues = extensionParams;
                extSettings.Extension       = "Report Server Email";

                // Get the reports parameters using the GetParameters form
                GetParameters reportParameters = new GetParameters(url);
                reportParameters.ShowDialog();
                Microsoft.Reporting.WinForms.ReportParameter[] rps = reportParameters.Parameters;

                // Convert the Winforms.ReportParameter returned from the GetParameters
                // to ParameterValues required for the CreateSubscription method

                int i = 0;
                foreach (Microsoft.Reporting.WinForms.ReportParameter rp in rps)
                {
                    if (rp.Values.Count != 0)
                    {
                        i++;
                    }
                }
                ParameterValue[] pvs = new ParameterValue[i];
                int j = 0;
                foreach (Microsoft.Reporting.WinForms.ReportParameter rp in rps)
                {
                    if (rp.Values.Count != 0)
                    {
                        pvs[j]       = new ParameterValue();
                        pvs[j].Name  = rp.Name;
                        pvs[j].Value = rp.Values[0];
                        j++;
                    }
                }

                // Now setup the subscription
                try
                {
                    rs.CreateSubscription(report, extSettings, desc, eventType, matchData, pvs);
                }

                catch (SoapException ex)
                {
                    MessageBox.Show(ex.Detail.InnerXml.ToString());
                }
            }
        }
示例#3
0
        private void syncTreeNodes(string destPath, TreeNodeCollection nodes)
        {
            foreach (TreeNode node in nodes)
            {
                if ((bool)node.Tag)
                {
                    if (node.Nodes.Count > 0)
                    {
                        var childPath = destPath;
                        if (node.Checked)
                        {
                            if (destPath.Equals(ROOT_FOLDER))
                            {
                                childPath = ROOT_FOLDER + node.Text;
                            }
                            else
                            {
                                childPath = destPath + PATH_SEPERATOR + node.Text;
                            }
                        }
                        syncTreeNodes(childPath, node.Nodes);
                    }
                    else
                    {
                        if (!existingPaths.Contains(destPath))
                        {
                            EnsureDestDir(destPath);
                            existingPaths.Add(destPath);
                        }
                        var itemPath = ROOT_FOLDER + node.FullPath.Replace("\\", PATH_SEPERATOR);
                        var itemType = sourceRS.GetItemType(itemPath);
                        if (itemType == ItemTypeEnum.Resource)
                        {
                            //Download the resource
                            string resourceType;
                            var    contents = sourceRS.GetResourceContents(itemPath, out resourceType);
                            uploadResource(destPath, node.Text, resourceType, contents);
                            processedNodeCount++;
                            continue;
                        }
                        var reportDef = sourceRS.GetReportDefinition(itemPath);
                        uploadReport(destPath, node.Text, reportDef);

                        //Sync subscriptions
                        ExtensionSettings extSettings;
                        string            desc;
                        ActiveState       active;
                        string            status;
                        string            eventType;
                        string            matchData;
                        ParameterValue[]  values        = null;
                        Subscription[]    subscriptions = null;
                        ParameterValueOrFieldReference[] extensionParams = null;

                        var destReportPath = destPath;
                        if (destReportPath.EndsWith("/"))
                        {
                            destReportPath += node.Text;
                        }
                        else
                        {
                            destReportPath += "/" + node.Text;
                        }

                        subscriptions = sourceRS.ListSubscriptions(itemPath, txtSourceUser.Text);
                        foreach (var subscription in subscriptions)
                        {
                            sourceRS.GetSubscriptionProperties(subscription.SubscriptionID, out extSettings, out desc, out active, out status, out eventType, out matchData, out values);
                            if (extSettings.Extension == "Report Server FileShare")
                            {
                                ParameterValue para = new ParameterValue();
                                para.Name  = "PASSWORD";
                                para.Value = txtDestPassword.Text;
                                ParameterValueOrFieldReference[] exParams = new ParameterValueOrFieldReference[extSettings.ParameterValues.Length + 1];
                                Array.Copy(extSettings.ParameterValues, exParams, extSettings.ParameterValues.Length);
                                exParams[extSettings.ParameterValues.Length] = para;
                                extSettings.ParameterValues = exParams;
                            }
                            destRS.CreateSubscription(destReportPath, extSettings, desc, eventType, matchData, values);
                        }

                        processedNodeCount++;
                        bwSync.ReportProgress(processedNodeCount * 100 / selectedNodeCount);
                    }
                }
            }
        }