// Create new subscription
 public WlbReportSubscriptionDialog(string reportDisplayName, Dictionary<string, string> reportParams, Pool pool)
     : base(pool.Connection)
 {
     _rpParams = reportParams;
     _subscription = null;
     _reportDisplayName = reportDisplayName;
     _pool = pool;
     init();
 }
 // Edit existing subscription
 public WlbReportSubscriptionDialog(string reportDisplayName, WlbReportSubscription subscription, Pool pool)
     : base(pool.Connection)
 {
     _subId = subscription.Id;
     _rpParams = subscription.ReportParameters;
     _subscription = subscription;
     _reportDisplayName = reportDisplayName;
     _pool = pool;
     init();
 }
Example #3
0
        /// <summary>
        /// Creates a treeNode for give report name and subscription object
        /// </summary>
        /// <param name="reportName">Name of the report that has the subscription</param>
        /// <param name="subscription">Instance of a subscription</param>
        /// <returns>Return a instance of TreeNode</returns>
        private TreeNode GetReportSubscriptionTreeNode(WlbReportSubscription subscription)
        {
            TreeNode subscriptionTreeNode = new TreeNode();

            subscriptionTreeNode.Text = subscription.Name;
            subscriptionTreeNode.Tag = subscription;
            subscriptionTreeNode.ImageIndex = 1;
            subscriptionTreeNode.SelectedImageIndex = 1;

            return subscriptionTreeNode;
        }
Example #4
0
        /// <summary>
        /// Add subscription nodes if a report has subscriptions
        /// </summary>
        /// <param name="topNode">Report subscription top node</param>
        /// <param name="subscriptionList">A dictionary contains WlbReportSubscription instances</param>
        /// <param name="reportName">Report display name that can be added to WlbReportSubscription instance</param>
        /// <param name="selectedSub">The original selected node before update</param>
        private void AddNewSubscriptionNode(TreeNode subscriptionFolder, Dictionary<string, WlbReportSubscription> subscriptions, string reportName, WlbReportSubscription selectedSub)
        {
            foreach (WlbReportSubscription sub in subscriptions.Values)
            {
                sub.ReportDisplayName = reportName;
                TreeNode subNode = GetReportSubscriptionTreeNode(sub);
                subscriptionFolder.Nodes.Add(subNode);

                // Retrieve selected subscription node if there is one
                if (selectedSub != null && String.Compare(selectedSub.Id, sub.Id, true) == 0)
                {
                    this.treeViewReportList.SelectedNode = subNode;
                }
            }

            // Force to set selected node to the first subscription node of the report
            // only if the original selected subscription node of the report has been deleted.
            if (selectedSub != null && subscriptions.Count > 0 && (this.treeViewReportList.SelectedNode == null || this.treeViewReportList.SelectedNode.Tag == null))
            {
                this.treeViewReportList.SelectedNode = subscriptionFolder.Nodes[0];
            }
        }
 public void TestNullConstructionDoesNotThrow()
 {
     subscription = new WlbReportSubscription(null);
 }
 public void Setup()
 {
     subscription = new WlbReportSubscription("some id");
     validator = new VerifyGettersAndSetters(subscription);
 }
        private void SaveSubscription()
        {
            if (this._subscription == null)
            {
                _subscription = new WlbReportSubscription(String.Empty);
                _subscription.SubscriberName = GetLoggedInAsText();
                _subscription.Created = DateTime.UtcNow;
            }
            _subscription.Name = this.subNameTextBox.Text;
            _subscription.Description = this.subNameTextBox.Text;

            DateTime utcExecuteTime;
            WlbScheduledTask.WlbTaskDaysOfWeek utcDaysOfWeek;
            WlbScheduledTask.GetUTCTaskTimes((WlbScheduledTask.WlbTaskDaysOfWeek)this.schedDeliverComboBox.SelectedValue, this.dateTimePickerSubscriptionRunTime.Value, out utcDaysOfWeek, out utcExecuteTime);
            _subscription.ExecuteTimeOfDay = utcExecuteTime;
            _subscription.DaysOfWeek = utcDaysOfWeek;
            if (_subscription.DaysOfWeek != WlbScheduledTask.WlbTaskDaysOfWeek.All)
            {
                _subscription.TriggerType = (int)WlbScheduledTask.WlbTaskTriggerType.Weekly;
            }
            else
            {
                _subscription.TriggerType = (int)WlbScheduledTask.WlbTaskTriggerType.Daily;
            }
            _subscription.Enabled = true;
            _subscription.EnableDate = this.dateTimePickerSchedStart.Value == DateTime.MinValue ? DateTime.UtcNow : this.dateTimePickerSchedStart.Value.ToUniversalTime();
            _subscription.DisableDate = this.dateTimePickerSchedEnd.Value == DateTime.MinValue ? DateTime.UtcNow.AddMonths(1) : this.dateTimePickerSchedEnd.Value.ToUniversalTime();
            _subscription.LastTouched = DateTime.UtcNow;
            _subscription.LastTouchedBy = GetLoggedInAsText();

            // store email info
            _subscription.EmailTo = this.emailToTextBox.Text.Trim();
            _subscription.EmailCc = this.emailCcTextBox.Text.Trim();
            _subscription.EmailBcc = this.emailBccTextBox.Text.Trim();
            _subscription.EmailReplyTo = this.emailReplyTextBox.Text.Trim();
            _subscription.EmailSubject = this.emailSubjectTextBox.Text.Trim();
            _subscription.EmailComment = this.emailCommentRichTextBox.Text;

            // store reoprt Info
            //sub.ReportId = ;
            _subscription.ReportRenderFormat = this.rpRenderComboBox.SelectedIndex;
            Dictionary<string, string> rps = new Dictionary<string, string>();
            foreach(string key in this._rpParams.Keys)
            {
                if (String.Compare(key, WlbReportSubscription.REPORT_NAME, true) == 0)
                    _subscription.ReportName = this._rpParams[WlbReportSubscription.REPORT_NAME];
                else
                {
                    //Get start date range
                    if (String.Compare(key, "start", true) == 0)
                    {
                        rps.Add(key, ((this.rpParamComboBox.SelectedIndex + 1) * (-7)+1).ToString());
                    }
                    else
                    {
                        rps.Add(key, _rpParams[key]);
                    }
                }
            }
            _subscription.ReportParameters = rps;

            SendWlbConfigurationAction action = new SendWlbConfigurationAction(this._pool, _subscription.ToDictionary(), SendWlbConfigurationKind.SetReportSubscription);
            using (var dialog = new ActionProgressDialog(action, ProgressBarStyle.Blocks))
            {
                dialog.ShowCancel = true;
                dialog.ShowDialog(this);
            }

            if (action.Succeeded)
            {
                DialogResult = DialogResult.OK;
                this.Close();
            }
            else if(!action.Cancelled)
            {
                using (var dlg = new ThreeButtonDialog(
                   new ThreeButtonDialog.Details(
                       SystemIcons.Error,
                       String.Format(Messages.WLB_SUBSCRIPTION_ERROR, _subscription.Description),
                       Messages.XENCENTER)))
                {
                    dlg.ShowDialog(this);
                }
                //log.ErrorFormat("There was an error calling SendWlbConfigurationAction to SetReportSubscription {0}, Action Result: {1}.", _subscription.Description, action.Result);
                DialogResult = DialogResult.None;
            }
        }
 /// <summary>
 /// Reset subscription view
 /// </summary>
 /// <param name="enableWlbReportView">WlbReportSubscription instance</param>
 public void ResetSubscriptionView(WlbReportSubscription subscription)
 {
     this.ReportSubscription = subscription;
     this.BuildPanel();
     this.Visible = true;
 }
Example #9
0
        /// <summary>
        /// Update report treeView when edit/add/delete report subscriptions
        /// </summary>
        private void UpdateReportTreeView()
        {
            // Begin update report treeView
            treeViewReportList.BeginUpdate();

            // If there is a selected subscription node, need to save it before it got cleared
            // There is no need to save selected report node since it never got cleared
            WlbReportSubscription selectedSub = null;
            String selectedSubReportFile      = String.Empty;

            if (this.treeViewReportList.SelectedNode != null && this.treeViewReportList.SelectedNode.Tag != null && this.treeViewReportList.SelectedNode.Tag.GetType() == typeof(WlbReportSubscription))
            {
                // Save selected subscription node for later
                selectedSub = (WlbReportSubscription)this.treeViewReportList.SelectedNode.Tag;

                // Save the report file of the selected subscription node for later
                selectedSubReportFile = ((WlbReportInfo)this.treeViewReportList.SelectedNode.Parent.Parent.Tag).ReportFile;
            }

            // Update subscription nodes
            foreach (TreeNode reportNode in this.treeViewReportList.Nodes)
            {
                // Get subscriptions under the report node
                Dictionary <string, WlbReportSubscription> subscriptionList = _subscriptionCollection.GetReportSubscriptionByReportName(((WlbReportInfo)reportNode.Tag).ReportFile);

                // If there's subscriptions for the current report, add them
                if (subscriptionList.Count > 0)
                {
                    // Add a subscriptions folder if there isn't one
                    if (reportNode.GetNodeCount(true) == 0)
                    {
                        TreeNode subscriptionFolderNode = new TreeNode(Messages.WLB_SUBSCRIPTIONS, 2, 2);
                        reportNode.Nodes.Add(subscriptionFolderNode);
                    }

                    // Delete all the nodes to build the updated list
                    reportNode.Nodes[0].Nodes.Clear();

                    // Add in the latest nodes
                    if (selectedSub != null && String.Compare(selectedSubReportFile, ((WlbReportInfo)reportNode.Tag).ReportFile, true) == 0)
                    {
                        // Add new subscription node and retrieve selected node if there is one
                        AddNewSubscriptionNode(reportNode.Nodes[0], subscriptionList, ((WlbReportInfo)reportNode.Tag).ReportName, selectedSub);
                    }
                    else
                    {
                        // Add new subscription node
                        AddNewSubscriptionNode(reportNode.Nodes[0], subscriptionList, ((WlbReportInfo)reportNode.Tag).ReportName, null);
                    }
                }
                else
                {
                    // Force to select reportNode before clear reportNode's children node
                    // only if the original selected subscription has been deleted
                    // and there are no more subscriptions under the report
                    if (selectedSub != null && String.Compare(selectedSubReportFile, ((WlbReportInfo)reportNode.Tag).ReportFile, true) == 0)
                    {
                        this.treeViewReportList.SelectedNode = reportNode;
                    }

                    // Clear reportNode's children node (subscription folder node)
                    // if there is no subscription under the reportNode
                    reportNode.Nodes.Clear();
                }
            }

            // End updating report treeView
            treeViewReportList.EndUpdate();
        }
Example #10
0
        /// <summary>
        /// Add subscription nodes if a report has subscriptions
        /// </summary>
        /// <param name="topNode">Report subscription top node</param>
        /// <param name="subscriptionList">A dictionary contains WlbReportSubscription instances</param>
        /// <param name="reportName">Report display name that can be added to WlbReportSubscription instance</param>
        /// <param name="selectedSub">The original selected node before update</param>
        private void AddNewSubscriptionNode(TreeNode subscriptionFolder, Dictionary <string, WlbReportSubscription> subscriptions, string reportName, WlbReportSubscription selectedSub)
        {
            foreach (WlbReportSubscription sub in subscriptions.Values)
            {
                sub.ReportDisplayName = reportName;
                TreeNode subNode = GetReportSubscriptionTreeNode(sub);
                subscriptionFolder.Nodes.Add(subNode);

                // Retrieve selected subscription node if there is one
                if (selectedSub != null && String.Compare(selectedSub.Id, sub.Id, true) == 0)
                {
                    this.treeViewReportList.SelectedNode = subNode;
                }
            }

            // Force to set selected node to the first subscription node of the report
            // only if the original selected subscription node of the report has been deleted.
            if (selectedSub != null && subscriptions.Count > 0 && (this.treeViewReportList.SelectedNode == null || this.treeViewReportList.SelectedNode.Tag == null))
            {
                this.treeViewReportList.SelectedNode = subscriptionFolder.Nodes[0];
            }
        }