Exemple #1
0
        /// <summary>
        /// Called when a selection changes. The snap-in should override this method to read the updated <see cref="P:Microsoft.ManagementConsole.MmcListView.SelectedNodes"></see> property and update <see cref="T:Microsoft.ManagementConsole.SelectionData"></see> class accordingly.
        /// </summary>
        /// <param name="status">The object that holds the status information.</param>
        protected override void OnSelectionChanged(SyncStatus status)
        {
            if (this.SelectedNodes.Count == 0)
            {
                // No items are selected; clear selection data and associated actions.
                SelectionData.Clear();
                SelectionData.ActionsPaneItems.Clear();
            }
            else
            {
                StringBuilder selectedItems = new StringBuilder();

                foreach (ResultNode node in this.SelectedNodes)
                {
                    selectedItems.Append(node.DisplayName);
                    selectedItems.Append(" ");
                    selectedItems.Append(string.Join(" ", node.SubItemDisplayNames.ToArray()));
                    selectedItems.AppendLine();
                }

                SelectionData.Update(selectedItems.ToString(), this.SelectedNodes.Count > 1, null, null);

                SelectionData.ActionsPaneItems.Clear();
                SelectionData.ActionsPaneItems.Add(this.CopyToClipboardAction);
            }
        }
        /// <summary>
        /// The OnSelectionChanged method is called when the selection changes.
        /// The snap-in must override this method to read the updated selected nodes
        /// property and update the selection data accordingly.
        /// NOTE: MmcListViewOptions is already set to SingleSelect
        /// </summary>
        /// <param name="status">The object that holds the status information.</param>
        protected override void OnSelectionChanged(SyncStatus status)
        {
            int count = SelectedNodes.Count;

            if (count == 0)
            {
                // No items are selected; clear selection data and associated actions.
                SelectionData.Clear();
                SelectionData.ActionsPaneItems.Clear();
            }
            else
            {
                SelectionData.Update(SelectedNodes[0], count > 1, null, null);
                SelectionData.ActionsPaneItems.Clear();

                ManagementObjectSearcher ServiceQuery = new ManagementObjectSearcher
                                                            ("Select * from Win32_Service Where DisplayName = '" + SelectedNodes[0].DisplayName + "'");

                foreach (ManagementObject ServiceObject in ServiceQuery.Get())
                {
                    SelectionData.ActionsPaneItems.AddRange(new ActionsPaneItem[]
                    {
                        new Action("Start", "Start", -1, "Start"),
                        new Action("Stop", "Stop", -1, "Stop"),
                        new Action("Pause", "Pause", -1, "Pause"),
                        new Action("Resume", "Resume", -1, "Resume"),
                        new Action("Properties", "Properties", -1, "Properties")
                    }
                                                            );

                    string serviceState = ServiceObject.GetPropertyValue("State").ToString();

                    switch (serviceState)
                    {
                    case "Running":
                        ((Action)SelectionData.ActionsPaneItems[0]).Enabled = false;
                        ((Action)SelectionData.ActionsPaneItems[3]).Enabled = false;
                        break;

                    case "Stopped":
                        ((Action)SelectionData.ActionsPaneItems[1]).Enabled = false;
                        ((Action)SelectionData.ActionsPaneItems[2]).Enabled = false;
                        ((Action)SelectionData.ActionsPaneItems[3]).Enabled = false;
                        break;

                    case "Paused":
                        ((Action)SelectionData.ActionsPaneItems[0]).Enabled = false;
                        ((Action)SelectionData.ActionsPaneItems[2]).Enabled = false;
                        break;
                    }
                }
            }
        }
Exemple #3
0
 /// <summary>
 /// Defines actions for selection.
 /// </summary>
 /// <param name="status"></param>
 protected override void OnSelectionChanged(SyncStatus status)
 {
     if (SelectedNodes.Count == 0)
     {
         SelectionData.Clear();
     }
     else
     {
         SelectionData.Update(GetSelectedUsers(), SelectedNodes.Count > 1, null, null);
         SelectionData.ActionsPaneItems.Clear();
         SelectionData.ActionsPaneItems.Add(new MmcAction("Show Selected", "Shows list of selected Users.", -1, "ShowSelected"));
     }
 }
 protected override void OnSelectionChanged(SyncStatus status)
 {
     if (SelectedNodes.Count == 0)
     {
         SelectionData.Clear();
     }
     else
     {
         SelectionData.Update(GetDetails(), SelectedNodes.Count > 1, null, null);
         SelectionData.ActionsPaneItems.Clear();
         SelectionData.ActionsPaneItems.Add(new Action("Show Certificate", "Shows certificate details", (int)TreeImageIndex.TrustedCertificate, ActionShowCertificate));
         SelectionData.ActionsPaneItems.Add(new Action("Remove Certificate", "Remove Certificate", -1, ActionRemoveSslCertificate));
     }
 }
Exemple #5
0
        /// <summary>
        /// Called when a selection changes. The snap-in should override this method to read the updated <see cref="P:Microsoft.ManagementConsole.MmcListView.SelectedNodes"></see> property and update <see cref="T:Microsoft.ManagementConsole.SelectionData"></see> class accordingly.
        /// </summary>
        /// <param name="status">The object that holds the status information.</param>
        protected override void OnSelectionChanged(SyncStatus status)
        {
            if (this.SelectedNodes.Count == 0)
            {
                // No items are selected; clear selection data and associated actions.
                SelectionData.Clear();
                SelectionData.ActionsPaneItems.Clear();
            }
            else
            {
                //    WritableSharedData writableSharedData = new WritableSharedData();

                //    WritableSharedDataItem writableSharedDataItem = new WritableSharedDataItem(DataFormats.UnicodeText, true);
                //    writableSharedDataItem.SetData(Encoding.Unicode.GetBytes("asdasdas asd adasd asdas das d"));
                //    writableSharedData.Add(writableSharedDataItem);

                //    WritableSharedDataItem writableSharedDataItem2 = new WritableSharedDataItem(DataFormats.Text, true);
                //    writableSharedDataItem2.SetData(Encoding.ASCII.GetBytes("asdasdas asd adasd asdas das d"));
                //    writableSharedData.Add(writableSharedDataItem2);

                //WritableSharedDataItem writableSharedDataItem3 = new WritableSharedDataItem(DataFormats.Html, false);
                //writableSharedDataItem3.SetData(Encoding.ASCII.GetBytes("asdasdas asd adasd asdas das d"));
                //writableSharedData.Add(writableSharedDataItem3);

                StringBuilder selectedItems = new StringBuilder();

                foreach (ResultNode node in this.SelectedNodes)
                {
                    selectedItems.Append(node.DisplayName);
                    selectedItems.Append(" ");
                    selectedItems.Append(string.Join(" ", node.SubItemDisplayNames.ToArray()));
                    selectedItems.AppendLine();
                }

                SelectionData.Update(selectedItems.ToString(), this.SelectedNodes.Count > 1, null, null);

                SelectionData.ActionsPaneItems.Clear();
                SelectionData.ActionsPaneItems.Add(this.CopyToClipboardAction);
            }
        }
Exemple #6
0
        /// <summary>
        ///     Allows you to populate the current wish list item object using a WishListItemDTO instance
        /// </summary>
        /// <param name="dto">An instance of the wish list item from the REST API</param>
        public void FromDto(WishListItemDTO dto)
        {
            if (dto == null)
            {
                return;
            }

            Id             = dto.Id;
            StoreId        = dto.StoreId;
            CustomerId     = dto.CustomerId;
            LastUpdatedUtc = dto.LastUpdatedUtc;
            ProductId      = dto.ProductId ?? string.Empty;
            Quantity       = dto.Quantity;
            SelectionData.Clear();
            if (dto.SelectionData != null)
            {
                foreach (var op in dto.SelectionData)
                {
                    var o = new OptionSelection();
                    o.FromDto(op);
                    SelectionData.OptionSelectionList.Add(o);
                }
            }
        }
Exemple #7
0
        protected override void OnSelectionChanged(SyncStatus status)
        {
            if (this.SelectedNodes.Count == 0)
            {
                // No items are selected; clear selection data and associated actions.
                SelectionData.Clear();
                SelectionData.ActionsPaneItems.Clear();
            }
            else
            {
                List <CompanyScopeNode> selectedCompanyIds = new List <CompanyScopeNode>();

                bool activeCompanyEnable   = false;
                bool inactiveCompanyEnable = false;

                bool activeSchedulerEnable   = false;
                bool inactiveSchedulerEnable = false;

                foreach (CompanyScopeNode node in this.SelectedNodes)
                {
                    if (node.IsActive)
                    {
                        activeCompanyEnable = true;
                    }
                    else
                    {
                        inactiveCompanyEnable = true;
                    }

                    if (node.IsEnableShedulerService)
                    {
                        activeSchedulerEnable = true;
                    }
                    else
                    {
                        inactiveSchedulerEnable = true;
                    }

                    selectedCompanyIds.Add(node);
                }

                if (status != null)
                {
                    SelectionData.Update(selectedCompanyIds.ToArray(), this.SelectedNodes.Count > 1, null, null);
                }

                this.SelectionData.ActionsPaneItems.Clear();

                this.SelectionData.ActionsPaneItems.Add(this.StartAction);
                this.SelectionData.ActionsPaneItems.Add(this.StopAction);

                this.SelectionData.ActionsPaneItems.Add(new ActionSeparator());

                this.SelectionData.ActionsPaneItems.Add(this.ChangePortalPool);
                this.SelectionData.ActionsPaneItems.Add(this.UpgradeAction);

                this.SelectionData.ActionsPaneItems.Add(new ActionSeparator());

                // Enable Disable Company List
                if (inactiveCompanyEnable)
                {
                    this.StartAction.Enabled    = true;
                    this.StartAction.ImageIndex = 10;
                }
                else
                {
                    this.StartAction.Enabled    = false;
                    this.StartAction.ImageIndex = 13;
                }

                if (activeCompanyEnable)
                {
                    this.StopAction.Enabled    = true;
                    this.StopAction.ImageIndex = 11;
                }
                else
                {
                    this.StopAction.Enabled    = false;
                    this.StopAction.ImageIndex = 14;
                }

                // Scheduler Service
                if (inactiveSchedulerEnable)
                {
                    this.SelectionData.ActionsPaneItems.Add(this.EnableSchedulerServiceAction);
                }
                if (activeSchedulerEnable)
                {
                    this.SelectionData.ActionsPaneItems.Add(this.DisableSchedulerServiceAction);
                }

                //this.UpgradeAction.Enabled = false;
            }
        }
        /// <summary>
        ///     Allows you to populate the current line item object using a LineItemDTO instance
        /// </summary>
        /// <param name="dto">An instance of the line item from the REST API</param>
        public void FromDto(LineItemDTO dto)
        {
            if (dto == null)
            {
                return;
            }

            Id                   = dto.Id;
            StoreId              = dto.StoreId;
            LastUpdatedUtc       = dto.LastUpdatedUtc;
            BasePricePerItem     = dto.BasePricePerItem;
            LineTotal            = dto.LineTotal;
            AdjustedPricePerItem = dto.AdjustedPricePerItem;
            IsUserSuppliedPrice  = dto.IsUserSuppliedPrice;
            IsBundle             = dto.IsBundle;
            IsGiftCard           = dto.IsGiftCard;
            PromotionIds         = dto.PromotionIds;
            FreeQuantity         = dto.FreeQuantity;

            DiscountDetails.Clear();
            if (dto.DiscountDetails != null)
            {
                foreach (var detail in dto.DiscountDetails)
                {
                    var d = new DiscountDetail();
                    d.FromDto(detail);
                    DiscountDetails.Add(d);
                }
            }
            OrderBvin               = dto.OrderBvin ?? string.Empty;
            ProductId               = dto.ProductId ?? string.Empty;
            VariantId               = dto.VariantId ?? string.Empty;
            ProductName             = dto.ProductName ?? string.Empty;
            ProductSku              = dto.ProductSku ?? string.Empty;
            ProductShortDescription = dto.ProductShortDescription ?? string.Empty;
            Quantity         = dto.Quantity;
            QuantityReturned = dto.QuantityReturned;
            QuantityShipped  = dto.QuantityShipped;
            ShippingPortion  = dto.ShippingPortion;
            TaxRate          = dto.TaxRate;
            TaxPortion       = dto.TaxPortion;
            StatusCode       = dto.StatusCode ?? string.Empty;
            StatusName       = dto.StatusName ?? string.Empty;
            SelectionData.Clear();
            if (dto.SelectionData != null)
            {
                foreach (var op in dto.SelectionData)
                {
                    var o = new OptionSelection();
                    o.FromDto(op);
                    SelectionData.OptionSelectionList.Add(o);
                }
            }
            IsNonShipping         = dto.IsNonShipping;
            TaxSchedule           = dto.TaxSchedule;
            ProductShippingHeight = dto.ProductShippingHeight;
            ProductShippingLength = dto.ProductShippingLength;
            ProductShippingWeight = dto.ProductShippingWeight;
            ProductShippingWidth  = dto.ProductShippingWidth;
            CustomProperties.Clear();
            if (dto.CustomProperties != null)
            {
                foreach (var cpd in dto.CustomProperties)
                {
                    var prop = new CustomProperty();
                    prop.FromDto(cpd);
                    CustomProperties.Add(prop);
                }
            }
            ShipFromAddress.FromDto(dto.ShipFromAddress);
            ShipFromMode           = (ShippingMode)(int)dto.ShipFromMode;
            ShipFromNotificationId = dto.ShipFromNotificationId ?? string.Empty;
            ShipSeparately         = dto.ShipSeparately;
            ExtraShipCharge        = dto.ExtraShipCharge;
            ShippingCharge         = (ShippingChargeType)(int)dto.ShippingCharge;
        }