コード例 #1
0
        //Adding check that Registry values exist
        //FEATURE_BROWSER_EMULATION- Defines in which document mode WebBrowser Control(Internal browser) should launch (IE 11 )
        //FEATURE_SCRIPTURL_MITIGATION - feature allows the href attribute of a objects to support the javascript prototcol.
        //                               It is by default disabled for WebBrowser Control and enabled for IE
        public static void CheckRegistryValues()
        {
            bool   osBitTypeIs64     = false;
            string appExeName        = string.Empty;
            string registryKeyPath   = string.Empty;
            string requiredValueName = string.Empty;
            object requiredValue     = string.Empty;

            try
            {
                //Find out the OS bit type
                osBitTypeIs64 = Environment.Is64BitOperatingSystem;

                //Get the App name
                appExeName = System.AppDomain.CurrentDomain.FriendlyName;

                //######################## FEATURE_BROWSER_EMULATION ###########################
                if (osBitTypeIs64)
                {
                    registryKeyPath = @"SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION";
                }
                else
                {
                    registryKeyPath = @"SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION";
                }
                requiredValueName = appExeName;
                requiredValue     = string.Empty;
                object installedIEVersion =
                    RegistryFunctions.GetRegistryValue(eRegistryRoot.HKEY_LOCAL_MACHINE, @"Software\Microsoft\Internet Explorer", "svcUpdateVersion");
                if (installedIEVersion != null)
                {
                    if (installedIEVersion != null)
                    {
                        requiredValue = (installedIEVersion.ToString().Split(new char[] { '.' }))[0] + "000";
                    }
                }
                if (requiredValue.ToString() == string.Empty || requiredValue.ToString() == "000")
                {
                    requiredValue = "11000"; //defualt value
                }
                //write registry key to the User level if failed to write to Local Machine level

                if (!RegistryFunctions.CheckRegistryValueExist(eRegistryRoot.HKEY_LOCAL_MACHINE, registryKeyPath,
                                                               requiredValueName, requiredValue, Microsoft.Win32.RegistryValueKind.DWord, true, true))
                {
                    //Try User Level
                    registryKeyPath = @"SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION";
                    if (!RegistryFunctions.CheckRegistryValueExist(eRegistryRoot.HKEY_CURRENT_USER, registryKeyPath,
                                                                   requiredValueName, requiredValue, Microsoft.Win32.RegistryValueKind.DWord, true, true))
                    {
                        Reporter.ToLog(eLogLevel.ERROR, "Failed to add the required registry key 'FEATURE_BROWSER_EMULATION' value to both Local Machine and User level");
                    }
                }
                //End

                //######################## FEATURE_SCRIPTURL_MITIGATION ###########################
                if (osBitTypeIs64)
                {
                    registryKeyPath = @"SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_SCRIPTURL_MITIGATION";
                }
                else
                {
                    registryKeyPath = @"SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_SCRIPTURL_MITIGATION";
                }
                requiredValueName = appExeName;
                requiredValue     = 1;
                //write registry key to the User level if failed to write to Local Machine level
                if (!RegistryFunctions.CheckRegistryValueExist(eRegistryRoot.HKEY_LOCAL_MACHINE, registryKeyPath,
                                                               requiredValueName, requiredValue, Microsoft.Win32.RegistryValueKind.DWord, true, true))
                {
                    //Try User Level
                    registryKeyPath = @"SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_SCRIPTURL_MITIGATION";
                    if (!RegistryFunctions.CheckRegistryValueExist(eRegistryRoot.HKEY_CURRENT_USER, registryKeyPath,
                                                                   requiredValueName, requiredValue, Microsoft.Win32.RegistryValueKind.DWord, true, true))
                    {
                        Reporter.ToLog(eLogLevel.ERROR, "Failed to add the required registry key 'FEATURE_SCRIPTURL_MITIGATION' value to both Local Machine and User level");
                    }
                }
                //End
            }
            catch (Exception ex)
            {
                Reporter.ToLog(eLogLevel.ERROR, "Failed to complete the registry values check", ex);
                Reporter.ToUser(eUserMsgKey.RegistryValuesCheckFailed);
            }
        }
コード例 #2
0
        /// <summary>
        /// Check if the Activity supposed to be executed according to it variables dependencies configurations
        /// </summary>
        /// <param name="parentActivity">The Activity parent Business Flow</param>
        /// <param name="setActivityStatus">Define of to set the Activity Status value in case the check fails</param>
        /// <returns></returns>
        public bool?CheckIfVaribalesDependenciesAllowsToRun(BusinessFlow parentBusinessFlow, bool setActivityStatus = false)
        {
            bool?checkStatus = null;

            try
            {
                //check objects are valid
                if (parentBusinessFlow != null)
                {
                    //check if the Activities-variables dependencies mechanisem is enabled
                    if (parentBusinessFlow.EnableActivitiesVariablesDependenciesControl)
                    {
                        //check if the Activity configured to run with all BF selection list variables selected value
                        List <VariableBase> bfListVars = parentBusinessFlow.Variables.Where(v => v.GetType() == typeof(VariableSelectionList) && v.Value != null).ToList();
                        if (bfListVars != null && bfListVars.Count > 0)
                        {
                            foreach (VariableBase listVar in bfListVars)
                            {
                                VariableDependency varDep = null;
                                if (this.VariablesDependencies != null)
                                {
                                    varDep = this.VariablesDependencies.Where(avd => avd.VariableName == listVar.Name && avd.VariableGuid == listVar.Guid).FirstOrDefault();
                                }
                                if (varDep == null)
                                {
                                    varDep = this.VariablesDependencies.Where(avd => avd.VariableGuid == listVar.Guid).FirstOrDefault();
                                }
                                if (varDep != null)
                                {
                                    if (!varDep.VariableValues.Contains(listVar.Value))
                                    {
                                        checkStatus = false;//the Selection List variable selected Value was not configured on the Activity
                                        break;
                                    }
                                }
                                else
                                {
                                    checkStatus = false;//the Selection List variable was not configured on the Activity
                                    break;
                                }
                            }
                            if (checkStatus == null)
                            {
                                checkStatus = true;//All Selection List variable selected values were configured on the Activity
                            }
                        }
                        else
                        {
                            checkStatus = true;//the BF dont has Selection List variables
                        }
                    }
                    else
                    {
                        checkStatus = true;//the mechanisem is disabled
                    }
                }
                else
                {
                    checkStatus = false; //BF object is null
                }
                //Check failed
                if (checkStatus == false && setActivityStatus == true)
                {
                    this.Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Skipped;
                }

                return(checkStatus);
            }
            catch (Exception ex)
            {
                //Check failed
                if (setActivityStatus)
                {
                    this.Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Skipped;
                }
                Reporter.ToLog(eLogLevel.ERROR, $"Method - {MethodBase.GetCurrentMethod().Name}, Error - {ex.Message}");
                return(false);
            }
        }