コード例 #1
0
ファイル: TaskSequence.cs プロジェクト: psyzum/osd-background
 /// <summary>
 ///     If running from a Task Sequence returns the tsVariable,
 /// </summary>
 /// <param name="tsVariable"></param>
 /// <returns></returns>
 public static string GetVariable(string tsVariable)
 {
     try
     {
         ITSEnvClass tsEnvVar = new TSEnvClass();
         return(tsEnvVar[tsVariable]);
     }
     catch (Exception)
     {
         return(string.Empty);
     }
 }
コード例 #2
0
ファイル: TaskSequence.cs プロジェクト: psyzum/osd-background
 /// <summary>
 ///     If running from a Task Sequence set a variable.
 /// </summary>
 /// <param name="tsVariable"></param>
 /// <param name="tsValue"></param>
 public static void SetVariable(string tsVariable, string tsValue)
 {
     try
     {
         ITSEnvClass tsEnvVar = new TSEnvClass();
         tsEnvVar[tsVariable] = tsValue;
     }
     catch (Exception)
     {
         // ignored
     }
 }
コード例 #3
0
        public void PopulateTsEnvLabels()
        {
            // Read TS-env
            ITSEnvClass tsEnvVar = new TSEnvClass();

            // Top labels
            Label_TS_Name.Text    = tsEnvVar["_SMSTSPackageName"].ToString();
            Label_TS_Role.Text    = tsEnvVar["OrgName"].ToString();
            Label_TS_Office.Text  = tsEnvVar["ITOfficeVersion"].ToString();
            Label_TS_Windows.Text = tsEnvVar["ITWindowsName"].ToString();
            // Computer info label
            Label_Device_ComputerName.Content = tsEnvVar["OSDComputerName"].ToString();
        }
コード例 #4
0
ファイル: TaskSequence.cs プロジェクト: psyzum/osd-background
        /// <summary>
        ///     Gets a Dictionary key/value pairs of current TS variables and values.
        /// </summary>
        /// <returns></returns>
        public static Dictionary <string, string> GetAllVariables()
        {
            var variablesDictionary = new Dictionary <string, string>(StringComparer.InvariantCultureIgnoreCase);

            try
            {
                ITSEnvClass tsEnvVar  = new TSEnvClass();
                dynamic     variables = tsEnvVar.GetVariables();

                foreach (string variable in variables)
                {
                    variablesDictionary.Add(variable, tsEnvVar[variable]);
                }
            }
            catch (Exception)
            {
                // ignored
            }

            return(variablesDictionary);
        }
コード例 #5
0
ファイル: TaskSequence.cs プロジェクト: psyzum/osd-background
        /// <summary>
        ///     Show the task sequence dialog. Use null to indicate default values.
        /// </summary>
        public static void ShowTsProgress(string orgName, string tsName, string customTitle, string curAction)
        {
            try
            {
                IProgressUI progressUI = new ProgressUI();
                ITSEnvClass tsEnvVar   = new TSEnvClass();

                orgName     = orgName == null ? tsEnvVar["_SMSTSOrgName"] : orgName;
                tsName      = tsName == null ? tsEnvVar["SMSTSPackageName"] : tsName;
                customTitle = customTitle == null ? tsEnvVar["_SMSTSCustomProgressDialogMessage"] : customTitle;
                curAction   = curAction == null ? tsEnvVar["_SMSTSCurrentActionName"] : curAction;

                uint uStep    = Convert.ToUInt32(tsEnvVar["_SMSTSNextInstructionPointer"]);
                uint uMaxStep = Convert.ToUInt32(tsEnvVar["_SMSTSInstructionTableSize"]);
                progressUI.ShowTSProgress(orgName, tsName, customTitle, curAction, uStep, uMaxStep);
            }
            catch (Exception)
            {
                // ignored
            }
        }
コード例 #6
0
        // Execute Background Worker
        void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            int max    = (int)e.Argument;
            int result = 0;

            // Connect to TSEnvironment
            ITSEnvClass tsEnvVar = new TSEnvClass();

            // Define variables
            int    totalStepNumbers   = 0;
            int    currentStepNumber  = 0;
            int    progressPercentage = 0;
            int    currentStage       = 0;
            bool   lastActionSuccess  = true;
            string currentStepName    = null;

            // Update the progress and step name bar until TS is done
            do
            {
                // Calculate progress %
                totalStepNumbers   = Int32.Parse(tsEnvVar["_SMSTSInstructionTableSize"].ToString());
                currentStepNumber  = Int32.Parse(tsEnvVar["_SMSTSNextInstructionPointer"].ToString());
                progressPercentage = Convert.ToInt32(((double)currentStepNumber / totalStepNumbers) * 100);
                // Set current step name
                currentStepName = tsEnvVar["_SMSTSCurrentActionName"].ToString();

                // Report progress
                (sender as BackgroundWorker).ReportProgress(progressPercentage);
                // Sleep thread
                System.Threading.Thread.Sleep(1);
                result = progressPercentage;
                // Update Current Step Name Label
                Label_TS_CurrentStep.BeginInvoke(new Action(() => { Label_TS_CurrentStep.Content = currentStepName; }));

                // Update stage
                lastActionSuccess = Convert.ToBoolean((string)tsEnvVar["_SMSTSLastActionSucceeded"].ToString());
                currentStage      = Convert.ToInt32((string)tsEnvVar["ITCurrentStage"].ToString());
                Grid_AKA_Stages.Dispatcher.BeginInvoke(new Action(() => { // THIS SHOULD BE FUNCTION
                    // Stage 1
                    if (currentStage == 1)
                    {
                        if (lastActionSuccess == false)
                        {
                            label_Progress_1.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#c0392b"));
                            label_Progress_1.FontSize   = 16;
                        }
                    }
                    // Stage 2
                    if (currentStage == 2)
                    {
                        label_Progress_1.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#27ae60"));
                        label_Progress_1.FontSize   = 12;
                        label_Progress_2.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#f39c12"));
                        label_Progress_2.FontSize   = 16;

                        if (lastActionSuccess == false)
                        {
                            label_Progress_2.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#c0392b"));
                            label_Progress_2.FontSize   = 16;
                        }
                    }
                    // Stage 3
                    if (currentStage == 3)
                    {
                        label_Progress_1.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#27ae60"));
                        label_Progress_1.FontSize   = 12;
                        label_Progress_2.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#27ae60"));
                        label_Progress_2.FontSize   = 12;
                        label_Progress_3.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#f39c12"));
                        label_Progress_3.FontSize   = 16;

                        if (lastActionSuccess == false)
                        {
                            label_Progress_3.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#c0392b"));
                            label_Progress_3.FontSize   = 16;
                        }
                    }
                    // Stage 4
                    if (currentStage == 4)
                    {
                        label_Progress_1.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#27ae60"));
                        label_Progress_1.FontSize   = 12;
                        label_Progress_2.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#27ae60"));
                        label_Progress_2.FontSize   = 12;
                        label_Progress_3.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#27ae60"));
                        label_Progress_3.FontSize   = 12;
                        label_Progress_4.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#f39c12"));
                        label_Progress_4.FontSize   = 16;

                        if (lastActionSuccess == false)
                        {
                            label_Progress_4.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#c0392b"));
                            label_Progress_4.FontSize   = 16;
                        }
                    }
                    // Stage 5
                    if (currentStage == 5)
                    {
                        label_Progress_1.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#27ae60"));
                        label_Progress_1.FontSize   = 12;
                        label_Progress_2.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#27ae60"));
                        label_Progress_2.FontSize   = 12;
                        label_Progress_3.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#27ae60"));
                        label_Progress_3.FontSize   = 12;
                        label_Progress_4.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#27ae60"));
                        label_Progress_4.FontSize   = 12;
                        label_Progress_5.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#f39c12"));
                        label_Progress_5.FontSize   = 16;

                        if (lastActionSuccess == false)
                        {
                            label_Progress_5.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#c0392b"));
                            label_Progress_5.FontSize   = 16;
                        }
                    }
                    // Stage 6
                    if (currentStage == 6)
                    {
                        label_Progress_1.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#27ae60"));
                        label_Progress_1.FontSize   = 12;
                        label_Progress_2.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#27ae60"));
                        label_Progress_2.FontSize   = 12;
                        label_Progress_3.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#27ae60"));
                        label_Progress_3.FontSize   = 12;
                        label_Progress_4.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#27ae60"));
                        label_Progress_4.FontSize   = 12;
                        label_Progress_5.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#27ae60"));
                        label_Progress_5.FontSize   = 12;
                        label_Progress_6.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#f39c12"));
                        label_Progress_6.FontSize   = 16;

                        if (lastActionSuccess == false)
                        {
                            label_Progress_6.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#c0392b"));
                            label_Progress_6.FontSize   = 16;
                        }
                    }
                    // Stage 7
                    if (currentStage == 7)
                    {
                        label_Progress_1.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#27ae60"));
                        label_Progress_1.FontSize   = 12;
                        label_Progress_2.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#27ae60"));
                        label_Progress_2.FontSize   = 12;
                        label_Progress_3.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#27ae60"));
                        label_Progress_3.FontSize   = 12;
                        label_Progress_4.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#27ae60"));
                        label_Progress_4.FontSize   = 12;
                        label_Progress_5.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#27ae60"));
                        label_Progress_5.FontSize   = 12;
                        label_Progress_6.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#27ae60"));
                        label_Progress_6.FontSize   = 12;
                        label_Progress_7.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#f39c12"));
                        label_Progress_7.FontSize   = 16;

                        if (lastActionSuccess == false)
                        {
                            label_Progress_7.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#c0392b"));
                            label_Progress_7.FontSize   = 16;
                        }
                    }
                }));
            } while (progressPercentage <= 100);
            e.Result = result;
        }