public ActionResult DownloadSharedObjectFile(string objectId,
                                                     string filePropertyName,
                                                     string shareFieldName,
                                                     bool thumbinal)
        {
            ServiceObject svo = objectService.GetServiceObjectById(int.Parse(objectId),
                                                                   new string[] { filePropertyName, shareFieldName },
                                                                   null);
            string file = string.Empty;

            if (svo != null &&
                svo.GetPropertyValue <PrimeObjectField>(shareFieldName)
                .GetStrongTypeValue <int>() == 1)
            {
                var downloadUrl = svo.GetPropertyValue <ObjectFileField>(filePropertyName)
                                  .FileUrl;

                if (thumbinal)
                {
                    downloadUrl = string.Format("~{0}?thumbinal=true", downloadUrl);
                }

                return(Redirect(downloadUrl));
            }

            return(NotFound());
        }
        /// <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;
                    }
                }
            }
        }
示例#3
0
        public void InitializePageControl()
        {
            serviceResultNode = (ResultNode)startupPropertyPage.ParentSheet.SelectionObject;

            ManagementObjectSearcher ServiceQuery = new ManagementObjectSearcher
                                                        ("Select * from Win32_Service Where DisplayName ='" + serviceResultNode.DisplayName + "'");

            foreach (ManagementObject ServiceObject in ServiceQuery.Get())
            {
                TextBoxDisplayName.Text          = ServiceObject.GetPropertyValue("DisplayName").ToString();
                ComboBoxStartupType.SelectedItem = ServiceObject.GetPropertyValue("StartMode").ToString();
            }
        }
        public void InitializePageControl()
        {
            serviceResultNode = (ResultNode)generalPropertyPage.ParentSheet.SelectionObject;

            ManagementObjectSearcher ServiceQuery = new ManagementObjectSearcher
                                                        ("Select * from Win32_Service Where DisplayName ='" + serviceResultNode.DisplayName + "'");

            foreach (ManagementObject ServiceObject in ServiceQuery.Get())
            {
                TextBoxDisplayName.Text = ServiceObject.GetPropertyValue("DisplayName").ToString();
                TextBoxName.Text        = ServiceObject.GetPropertyValue("Name").ToString();
                TextBoxDescription.Text = ServiceObject.GetPropertyValue("Description").ToString();
            }
        }