/// <summary> /// Makes an HTTP request that includes the standard Mobile Services /// headers. It will use an HttpClient with user-defined http handlers. /// </summary> /// <param name="method"> /// The HTTP method used to request the resource. /// </param> /// <param name="uriPathAndQuery"> /// The URI of the resource to request (relative to the Mobile Services /// runtime). /// </param> /// <param name="user"> /// The object representing the user on behalf of whom the request will be sent. /// </param> /// <param name="content"> /// Optional content to send to the resource. /// </param> /// <param name="ensureResponseContent"> /// Optional parameter to indicate if the response should include content. /// </param> /// <param name="requestHeaders"> /// Additional request headers to include with the request. /// </param> /// <param name="features"> /// Value indicating which features of the SDK are being used in this call. Useful for telemetry. /// </param> /// <param name="cancellationToken">The <see cref="System.Threading.CancellationToken"/> token to observe</param> /// <returns> /// The response. /// </returns> public Task <MobileServiceHttpResponse> RequestAsync(HttpMethod method, string uriPathAndQuery, MobileServiceUser user, string content = null, bool ensureResponseContent = true, IDictionary <string, string> requestHeaders = null, MobileServiceFeatures features = MobileServiceFeatures.None, CancellationToken cancellationToken = default(CancellationToken)) { requestHeaders = FeaturesHelper.AddFeaturesHeader(requestHeaders, features); return(this.RequestAsync(true, method, uriPathAndQuery, user, content, ensureResponseContent, requestHeaders, cancellationToken)); }
/// <summary> /// Builds features tree. /// This operatio is performed when control is created. /// </summary> void BuildFeaturesTree() { _featureNodes.Clear(); _featuresSet = FeaturesHelper.CreateFeaturesSet(); foreach (FeatureNode node in _featuresSet.Nodes) { AddFeatureNode(null, node); } tvFeatures.ExpandAll(); }
/// <summary> /// Makes an HTTP request that includes the standard Mobile Services /// headers. It will use an HttpClient with user-defined http handlers. /// </summary> /// <param name="method"> /// The HTTP method used to request the resource. /// </param> /// <param name="uriPathAndQuery"> /// The URI of the resource to request (relative to the Mobile Services /// runtime). /// </param> /// <param name="user"> /// The object representing the user on behalf of whom the request will be sent. /// </param> /// <param name="content"> /// Content to send to the resource. /// </param> /// <param name="requestHeaders"> /// Additional request headers to include with the request. /// </param> /// <param name="features"> /// Value indicating which features of the SDK are being used in this call. Useful for telemetry. /// </param> /// <returns> /// An <see cref="HttpResponseMessage"/>. /// </returns> public async Task <HttpResponseMessage> RequestAsync(HttpMethod method, string uriPathAndQuery, MobileServiceUser user, HttpContent content, IDictionary <string, string> requestHeaders, MobileServiceFeatures features = MobileServiceFeatures.None) { Debug.Assert(method != null); Debug.Assert(!string.IsNullOrEmpty(uriPathAndQuery)); requestHeaders = FeaturesHelper.AddFeaturesHeader(requestHeaders, features); // Create the request HttpRequestMessage request = this.CreateHttpRequestMessage(method, uriPathAndQuery, requestHeaders, content, user); // Get the response HttpResponseMessage response = await this.SendRequestAsync(httpClient, request, ensureResponseContent : false); return(response); }
private byte[] DeleteFeaturesOperHandler(NameValueCollection boundVariables, JsonObject operationInput, string outputFormat, string requestProperties, out string responseProperties) { responseProperties = null; JsonObject joConn; bool found = operationInput.TryGetJsonObject("connectionString", out joConn); if (!found || joConn == null) { throw new ArgumentNullException("connectionString can not parse to jsonobject"); } JsonObject joFC; found = operationInput.TryGetJsonObject("featureClass", out joFC); if (!found || joFC == null) { throw new ArgumentNullException("featureClass can not parse to jsonobject"); } JsonObject joFilter; found = operationInput.TryGetJsonObject("filterWhere", out joFilter); if (!found || joFilter == null) { throw new ArgumentNullException("filterWhere can not parse to jsonobject"); } JsonObject result = new JsonObject(); ConnectionJSObject connJsObj = ParamsParser.ParseConn(joConn); FeatureClassJSObject fcObj = ParamsParser.ParseFeatrureClass(joFC); FilterWhereJSObject filterObj = ParamsParser.ParseFilterWhere(joFilter); bool isok = false; int count = 0; string outMsg = string.Empty; FeaturesHelper helper = new FeaturesHelper(); isok = helper.DeleteFeatures(connJsObj, fcObj, filterObj, out count, out outMsg); result.AddBoolean("isSucess", isok); result.AddLong("recordCount", count); result.AddString("outMsg", outMsg); return(Encoding.UTF8.GetBytes(result.ToJson())); }
/// <summary> /// Makes an HTTP request that includes the standard Mobile Services /// headers. It will use an HttpClient with user-defined http handlers. /// </summary> /// <param name="method"> /// The HTTP method used to request the resource. /// </param> /// <param name="uriPathAndQuery"> /// The URI of the resource to request (relative to the Mobile Services /// runtime). /// </param> /// <param name="user"> /// The object representing the user on behalf of whom the request will be sent. /// </param> /// <param name="content"> /// Content to send to the resource. /// </param> /// <param name="requestHeaders"> /// Additional request headers to include with the request. /// </param> /// <param name="features"> /// Value indicating which features of the SDK are being used in this call. Useful for telemetry. /// </param> /// <param name="cancellationToken">The <see cref="System.Threading.CancellationToken"/> token to observe</param> /// <returns> /// An <see cref="HttpResponseMessage"/>. /// </returns> public async Task <HttpResponseMessage> RequestAsync(HttpMethod method, string uriPathAndQuery, MobileServiceUser user, HttpContent content, IDictionary <string, string> requestHeaders, MobileServiceFeatures features = MobileServiceFeatures.None, CancellationToken cancellationToken = default) { Arguments.IsNotNull(method, nameof(method)); Arguments.IsNotNull(uriPathAndQuery, nameof(uriPathAndQuery)); requestHeaders = FeaturesHelper.AddFeaturesHeader(requestHeaders, features); HttpRequestMessage request = this.CreateHttpRequestMessage(method, uriPathAndQuery, requestHeaders, content, user); return(await SendRequestAsync(httpClient, request, ensureResponseContent : false, cancellationToken : cancellationToken)); }
public void Execute(CalculationContext context) { var helper = new FeaturesHelper(); var random = new Random(); var features = context.Project.Webshops.SelectMany(w => w.Features) .Where(f => !f.Implemented) .OrderByDescending(f => f.RemainingImplementationRequirements != f.Definition.ImplementationRequirements) .ThenByDescending(f => f.Definition.Type == BusinessConstants.FeatureTypes.Webshop) .ThenByDescending(f => f.Definition.Tag == "ERP") .ThenBy(f => helper.GetParentFeatures(f.Definition.Id).Count) .ThenBy(f => random.Next()); context.FeaturesToImplement = features.ToList(); }
/// <summary> /// Makes an HTTP request that includes the standard Mobile Services /// headers. It will use an HttpClient with user-defined http handlers. /// </summary> /// <param name="method"> /// The HTTP method used to request the resource. /// </param> /// <param name="uriPathAndQuery"> /// The URI of the resource to request (relative to the Mobile Services /// runtime). /// </param> /// <param name="user"> /// The object representing the user on behalf of whom the request will be sent. /// </param> /// <param name="content"> /// Content to send to the resource. /// </param> /// <param name="requestHeaders"> /// Additional request headers to include with the request. /// </param> /// <param name="features"> /// Value indicating which features of the SDK are being used in this call. Useful for telemetry. /// </param> /// <param name="cancellationToken">The <see cref="System.Threading.CancellationToken"/> token to observe</param> /// <returns> /// An <see cref="HttpResponseMessage"/>. /// </returns> public async Task <HttpResponseMessage> RequestAsync(HttpMethod method, string uriPathAndQuery, MobileServiceUser user, HttpContent content, IDictionary <string, string> requestHeaders, MobileServiceFeatures features = MobileServiceFeatures.None, CancellationToken cancellationToken = default) { Arguments.IsNotNull(method, nameof(method)); Arguments.IsNotNull(uriPathAndQuery, nameof(uriPathAndQuery)); var stopwatch = new Stopwatch(); if (MobileServiceClient.LogRequestAndResponse) { Serilog.Log.Information("MobileServiceHttpClient.RequestAsync : \n ========= BEGIN REQUEST ========="); Serilog.Log.Information("MobileServiceHttpClient.RequestAsync : URL [" + uriPathAndQuery + "]"); Serilog.Log.Information("MobileServiceHttpClient.RequestAsync : \n ========= END REQUEST =========="); } requestHeaders = FeaturesHelper.AddFeaturesHeader(requestHeaders, features); HttpRequestMessage request = this.CreateHttpRequestMessage(method, uriPathAndQuery, requestHeaders, content, user); // Get the response stopwatch.Start(); HttpResponseMessage response = await this.SendRequestAsync(httpClient, request, ensureResponseContent : false, cancellationToken : cancellationToken); stopwatch.Stop(); Serilog.Log.Information($"MobileServiceHttpClient.RequestAsync : ~~~~~~ ElapsedTime [{stopwatch.ElapsedMilliseconds}] Uri[{request.RequestUri}]"); if (MobileServiceClient.LogRequestAndResponse) { Serilog.Log.Information($"MobileServiceHttpClient.RequestAsync : \n ========= BEGIN RESPONSE ========="); string responseContent = await GetResponseContent(response); var lines = responseContent.Split(new[] { '\r', '\n' }); foreach (var line in lines) { Serilog.Log.Verbose("MobileServiceHttpClient.RequestAsync : \t\t" + line); } Serilog.Log.Information("MobileServiceHttpClient.RequestAsync : \n ========= END RESPONSE ========= \n"); } return(response); }
/// <summary> /// Builds features tree. /// This operatio is performed when control is created. /// </summary> void BuildFeaturesTree() { _featureNodes.Clear(); _featuresSet = FeaturesSet.CreateFeaturesSet(); FeaturesHelper.Translate(_featuresSet); foreach (FeatureNode node in _featuresSet.Nodes) { AddFeatureNode(null, node); } tvFeatures.ExpandAll(); TreeNode tn = tvFeatures.Nodes[0]; tn.EnsureVisible(); }
/// <summary> /// Builds tests tree from a list of tests. /// </summary> /// <param name="tests">List of tests (test information contains information about test group /// also)</param> public void DisplayTests(List <TestInfo> tests) { _groupNumbers = new Dictionary <string, string>(); try { foreach (TestInfo testInfo in tests.OrderBy(ti => ti.Order)) { // Find group node to add this test to. TreeNode groupNode = FindGroupNode(testInfo.Group); string groupNumber = _groupNumbers[testInfo.Group]; string testNumber = groupNumber + "." + (groupNode.Nodes.Count + 1).ToString(); // Add node testInfo.Name = string.Format("{0} {1}", testNumber, testInfo.Name); TreeNode node = groupNode.Nodes.Add(testInfo.Name); // check if all features required are supported bool supported = testInfo.RequiredFeatures.Where( f => FeaturesHelper.FeatureRealization(f) == FeaturesHelper.FeatureRealizationType.Supported) .Count() > 0; // check if all features required are implemented. bool implemented = testInfo.RequiredFeatures.Where( f => FeaturesHelper.FeatureRealization(f) == FeaturesHelper.FeatureRealizationType.Implemented) .Count() > 0; // select image (depends on requirement level) node.ImageKey = FindImageKey(testInfo.RequirementLevel, supported, implemented); node.SelectedImageKey = node.ImageKey; // create tooltip node.ToolTipText = CreateTestTooltip(testInfo, null); node.Tag = testInfo; // add test node to dictionary _testNodes.Add(testInfo, node); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private bool IsFeaturesSelectionValid(IEnumerable <Guid> ids) { if (ids != null) { var featuresHelper = new FeaturesHelper(); foreach (var featureId in ids) { var parents = featuresHelper.GetParentFeatures(featureId); if (parents.Any(parent => !ids.Contains(parent.Id))) { ModelState.AddModelError(nameof(ids), "Invalid selection"); return(false); } } } return(true); }
private static List <Feature> GetSortedFeaturesForBot() { var list = IoC.Session.GetObject <List <Feature> >("BotFeatures"); if (list == null) { var random = new Random(); var helper = new FeaturesHelper(); list = Framework.Features.Get() .OrderByDescending(f => f.Type == BusinessConstants.FeatureTypes.Webshop) .ThenByDescending(f => f.Tag == "ERP") .ThenBy(f => helper.GetParentFeatures(f.Id).Count) .ThenBy(f => random.Next()).ToList(); } IoC.Session.SetObject("BotFeatures", list); return(list); }
/// <summary> /// Run selected test or tests in selected group. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsbRunSelected_Click(object sender, EventArgs e) { TreeNode node = tvTestCases.SelectedNode; if (node != null) { TestInfo testInfo = (TestInfo)node.Tag; TestSuiteParameters parameters = GetParameters(); if (testInfo != null) { parameters.TestCases.Add(testInfo); } else { List <TestInfo> tests = new List <TestInfo>(); AddChildNodes(node, tests); List <TestInfo> allowedTests = new List <TestInfo>(); if (_certificationMode) { allowedTests.AddRange(tests.Where(t => FeaturesHelper.AllFeaturesSelected(t))); } else { allowedTests.AddRange(tests); } if (parameters.InteractiveFirst) { parameters.TestCases.AddRange(allowedTests.OrderBy(t => !t.Interactive).ThenBy(t => t.Order)); } else { parameters.TestCases.AddRange(allowedTests.OrderBy(t => t.Order)); } } ClearTestInfo(); _controller.RunSingle(parameters); } }
/// <summary> /// Handles selection in tests tree. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tvTestCases_AfterSelect(object sender, TreeViewEventArgs e) { if (_controller.Running) { return; } TreeNode node = tvTestCases.SelectedNode; ClearTestInfo(); if (node != null) { bool bCanRunTest = true; if (node.Tag != null) { TestInfo testInfo = (TestInfo)node.Tag; TestResult log = _controller.GetTestResult(testInfo); if (log != null) { DisplayTestResults(log); } if (_certificationMode) { bCanRunTest = FeaturesHelper.AllFeaturesSelected(testInfo); } } else { if (_certificationMode) { bCanRunTest = GroupNodeAllowed(node); } } tsbRunSelected.Enabled = !_controller.Running && bCanRunTest; //tsbRunSelected.Enabled = !_controller.Running; } }
/// <summary> /// Selects child tests available for current features selection in certification mode. /// </summary> /// <param name="node"></param> void SelectAvailableChildTests(TreeNode node) { foreach (TreeNode child in node.Nodes) { if (child.Tag != null) { TestInfo testInfo = (TestInfo)child.Tag; switch (testInfo.RequirementLevel) { case RequirementLevel.Should: case RequirementLevel.Optional: { child.Checked = node.Checked; } break; case RequirementLevel.ConditionalShould: { if (node.Checked) { bool bClear = !FeaturesHelper.AllFeaturesSelected(testInfo); _testNodes[testInfo].Checked = !bClear; } else { child.Checked = false; } } break; } } else { // group child.Checked = node.Checked; CheckIfAllChildrenChecked(child); } } }
public void ToggleFeature(int id) { FeaturesHelper.ToggleFeature(id); }
public bool FeatureIsEnabled(int id) { return(FeaturesHelper.IsEnabled(id)); }
public static bool HaveAccess(FuncionalidadeAutorizacao funcionalidade, MenuHelper menu, ScreensHelper tela, FeaturesHelper acao) { try { var menuEncontrado = funcionalidade.Filhos.Where(f => f.Nome.ToString().Replace("\\", "").Replace(" ", "") == menu.ToString()).FirstOrDefault(); if (menuEncontrado == null) { return(false); } var telaEncontrada = menuEncontrado.Filhos.Where(f2 => f2.Nome.Replace(" ", "") == tela.ToString()).FirstOrDefault(); if (telaEncontrada == null) { return(false); } if (acao == FeaturesHelper.Consultar) { return(true); } foreach (var filho in telaEncontrada.Filhos) { if (filho.Nome == acao.ToString()) { return(true); } } return(false); } catch { return(false); } }
public static bool CheckPermission(MenuHelper menu, ScreensHelper screen, FeaturesHelper feature) { return(HaveAccess(GetSystem().FuncionalidadeAutorizacao, menu, screen, feature)); }
//public string Scope //{ // get { return C_PROFILE_SCOPE; } //} ///// </summary> //public ProfileVersionStatus Status //{ // get { return ProfileVersionStatus.Release; } //} public ProfileStatus Check(out string reason, IEnumerable <Feature> features, IEnumerable <string> scopes, Dictionary <string, object> parameters) { reason = string.Empty; var Name = this.GetProfileName(); var Scope = this.GetProfileScope(); StringBuilder sb = new StringBuilder(); ProfileStatus status = ProfileStatus.NotSupported; sb.AppendLine(string.Format("Check profile support for {0}", Name)); bool scopePresent = scopes.Contains(Scope); sb.AppendLine(string.Format("Scope {0}: \t\t{1}", Scope, scopePresent ? "PRESENT" : "NOT PRESENT")); if (!scopePresent) { sb.AppendFormat("Profile not supported"); } else { bool profileOk = true; bool supported; Action <Feature, string> checkNextMandatory = new Action <Feature, string>( (feature, displayName) => { supported = features.ContainsFeature(feature); LogMandatory(sb, displayName, supported); profileOk = profileOk && supported; }); Action <Feature, string> checkNextOptional = new Action <Feature, string>( (feature, displayName) => { supported = features.Contains(feature); LogOptional(sb, displayName, supported); }); checkNextMandatory(Feature.GetServices, "GetServices"); LogMandatoryFeature(sb, "Discovery"); checkNextMandatory(Feature.DiscoveryTypesTdsDevice, "tds:Device"); LogMandatoryFeature(sb, "Network Configuration"); LogMandatoryFeature(sb, "System"); LogMandatoryFeature(sb, "User Handling"); LogMandatoryFeature(sb, "Event Handling"); checkNextMandatory(Feature.MaxPullPoints, "EventService/GetServiceCapabilities/MaxPullPoints"); if (profileOk) { var v = (int)parameters["MaxPullPoints"]; profileOk = v >= 2; sb.AppendLine(string.Format("EventService/GetServiceCapabilities/MaxPullPoints has value >= 2: {0}", profileOk ? "SUPPORTED" : "NOT SUPPORTED")); } checkNextMandatory(Feature.Digest, "HTTP Digest"); checkNextMandatory(Feature.AccessControlService, "AccessControl Service"); //checkNextMandatory(Feature.AreaChangedEvent, FeaturesHelper.GetDisplayName(Feature.AreaChangedEvent)); //checkNextMandatory(Feature.AccessPointTamperingEvent, FeaturesHelper.GetDisplayName(Feature.AccessPointTamperingEvent)); //if (features.Contains(Feature.ExternalAuthorization)) //{ // checkNextMandatory(Feature.RequestCredentialEvent, FeaturesHelper.GetDisplayName(Feature.RequestCredentialEvent)); // //checkNextMandatory(Feature.AccessGrantedCredentialEvent, FeaturesHelper.GetDisplayName(Feature.AccessGrantedCredentialEvent)); // //checkNextMandatory(Feature.AccessDeniedWithCredentialEvent, FeaturesHelper.GetDisplayName(Feature.AccessDeniedWithCredentialEvent)); // checkNextMandatory(Feature.AccessDeniedCredentialEvent, FeaturesHelper.GetDisplayName(Feature.AccessDeniedCredentialEvent)); //} checkNextMandatory(Feature.DoorControlService, "DoorControl Service"); checkNextMandatory(Feature.AccessDoor, "AccessDoor"); checkNextMandatory(Feature.LockDoor, "LockDoor"); checkNextMandatory(Feature.UnlockDoor, "UnlockDoor"); Action <Feature, Feature> checkPair = new Action <Feature, Feature>( (featureA, featureB) => { if (features.Contains(featureB) && !features.Contains(featureA)) { supported = false; sb.AppendLine(string.Format("{0} feature is NOT SUPPORTED while {1} is SUPPORTED", FeaturesHelper.GetDisplayName(featureA), FeaturesHelper.GetDisplayName(featureB))); } else { if (features.Contains(featureB) && features.Contains(featureA)) { sb.AppendLine(string.Format("Features {0} and {1} are SUPPORTED", FeaturesHelper.GetDisplayName(featureA), FeaturesHelper.GetDisplayName(featureB))); } } }); checkPair(Feature.DoorPhysicalStateEvent, Feature.DoorMonitor); checkPair(Feature.LockPhysicalStateEvent, Feature.LockMonitor); checkPair(Feature.DoubleLockPhysicalStateEvent, Feature.DoubleLockMonitor); checkPair(Feature.DoorAlarmEvent, Feature.DoorAlarm); checkPair(Feature.DoorTamperEvent, Feature.DoorTamper); checkPair(Feature.DoorFaultEvent, Feature.DoorFault); if (profileOk) { status = ProfileStatus.Supported; } else { status = ProfileStatus.Failed; } } reason = sb.ToString(); return(status); }
public void DisplayProfiles(IEnumerable <IProfileDefinition> profiles) { tvProfiles.Nodes.Clear(); _scopeNodes = new Dictionary <String, List <TreeNode> >(); _discoveryTypesNodes = new Dictionary <Feature, List <TreeNode> >(); _functionalityNodes = new Dictionary <Functionality, List <TreeNode> >(); _profileNodes = new Dictionary <IProfileDefinition, TreeNode>(); _groupNodes = new List <TreeNode>(); _profileFunctionalityNodes = new Dictionary <IProfileDefinition, Dictionary <Functionality, TreeNode> >(); foreach (IProfileDefinition profile in profiles) { TreeNode profileNode = tvProfiles.Nodes.Add(profile.GetProfileName()); //if (profile.Status == ProfileVersionStatus.Release) //{ // SetImageKey(profileNode, PROFILEUNDEFINED); //} //else //{ // SetImageKey(profileNode, PROFILERCUNDEFINED); //} SetImageKey(profileNode, PROFILEUNDEFINED); profileNode.Tag = profile; _profileNodes.Add(profile, profileNode); Dictionary <Functionality, TreeNode> funcNodes = new Dictionary <Functionality, TreeNode>(); _profileFunctionalityNodes.Add(profile, funcNodes); TreeNode featureNode = profileNode.Nodes.Add(profile.GetProfileName() + "Scopes", "Scopes"); foreach (String item in profile.MandatoryScopes) { string scopeName = item; TreeNode node = new TreeNode(scopeName); SetImageKey(node, UNDEFINED); node.Tag = profile.MandatoryScopes.Contains(item); featureNode.Nodes.Add(node); if (!_scopeNodes.ContainsKey(item)) { _scopeNodes.Add(item, new List <TreeNode>()); } _scopeNodes[item].Add(node); } var typesNode = profileNode.Nodes.Add(profile.GetProfileName() + "Discovery Types", "Discovery Types"); SetImageKey(typesNode, GROUP); if (null != profile.MandatoryDiscoveryTypes) { foreach (var dt in profile.MandatoryDiscoveryTypes) { var node = new TreeNode(FeaturesHelper.GetDisplayName(dt)); SetImageKey(node, UNDEFINED); node.Tag = true; typesNode.Nodes.Add(node); if (!_discoveryTypesNodes.ContainsKey(dt)) { _discoveryTypesNodes.Add(dt, new List <TreeNode>()); } _discoveryTypesNodes[dt].Add(node); } } TreeNode funcNode = profileNode.Nodes.Add(profile.GetProfileName() + "Functionality", "Functionality"); SetImageKey(funcNode, GROUP); foreach (FunctionalityItem item in profile.Functionalities) { // Find group node to add this test to. TreeNode groupNode = FindGroupNode(funcNode, item.Path); TreeNode node = new TreeNode(Utils.FunctionalityHelper.GetDisplayName(item.Functionality)); SetImageKey(node, UNDEFINED); groupNode.Nodes.Add(node); if (!_functionalityNodes.ContainsKey(item.Functionality)) { _functionalityNodes.Add(item.Functionality, new List <TreeNode>()); } _functionalityNodes[item.Functionality].Add(node); funcNodes.Add(item.Functionality, node); } } }
public ProfileStatus Check(out string reason, IEnumerable <Feature> features, IEnumerable <string> scopes) { reason = string.Empty; StringBuilder sb = new StringBuilder(); ProfileStatus status = ProfileStatus.NotSupported; sb.AppendLine(string.Format("Check profile support for {0}", Name)); bool scopePresent = scopes.Contains(Scope); sb.AppendLine(string.Format("Scope {0}: \t\t{1}", Scope, scopePresent ? "PRESENT" : "NOT PRESENT")); if (!scopePresent) { sb.AppendFormat("Profile not supported"); } else { bool profileOk = true; bool supported; Action <Feature, string> checkNextMandatory = new Action <Feature, string>( (feature, displayName) => { supported = features.Contains(feature); LogMandatory(sb, displayName, supported); profileOk = profileOk && supported; }); Action <Feature, string> checkNextOptional = new Action <Feature, string>( (feature, displayName) => { supported = features.Contains(feature); LogOptional(sb, displayName, supported); }); checkNextMandatory(Feature.GetServices, "GetServices"); checkNextMandatory(Feature.Digest, "HTTP Digest"); checkNextMandatory(Feature.AccessControlService, "AccessControl Service"); checkNextMandatory(Feature.AccessPointEnabledEvent, FeaturesHelper.GetDisplayName(Feature.AccessPointEnabledEvent)); checkNextMandatory(Feature.AccessPointTamperingEvent, FeaturesHelper.GetDisplayName(Feature.AccessPointTamperingEvent)); if (features.Contains(Feature.ExternalAuthorization)) { checkNextMandatory(Feature.RequestCredentialEvent, FeaturesHelper.GetDisplayName(Feature.RequestCredentialEvent)); checkNextMandatory(Feature.AccessGrantedCredentialExternalEvent, FeaturesHelper.GetDisplayName(Feature.AccessGrantedCredentialExternalEvent)); checkNextMandatory(Feature.AccessDeniedCredentialExternalEvent, FeaturesHelper.GetDisplayName(Feature.AccessDeniedCredentialExternalEvent)); } checkNextMandatory(Feature.DoorControlService, "DoorControl Service"); checkNextMandatory(Feature.AccessDoor, "AccessDoor"); checkNextMandatory(Feature.LockDoor, "LockDoor"); checkNextMandatory(Feature.UnlockDoor, "UnlockDoor"); Action <Feature, Feature> checkPair = new Action <Feature, Feature>( (featureA, featureB) => { if (features.Contains(featureB) && !features.Contains(featureA)) { supported = false; sb.AppendLine(string.Format("{0} feature is NOT SUPPORTED while {1} is SUPPORTED", FeaturesHelper.GetDisplayName(featureA), FeaturesHelper.GetDisplayName(featureB))); } else { if (features.Contains(featureB) && features.Contains(featureA)) { sb.AppendLine(string.Format("Features {0} and {1} are SUPPORTED", FeaturesHelper.GetDisplayName(featureA), FeaturesHelper.GetDisplayName(featureB))); } } }); checkPair(Feature.DoorPhysicalStateEvent, Feature.DoorMonitor); checkPair(Feature.LockPhysicalStateEvent, Feature.LockMonitor); checkPair(Feature.DoubleLockPhysicalStateEvent, Feature.DoubleLockMonitor); checkPair(Feature.DoorAlarmEvent, Feature.DoorAlarm); checkPair(Feature.DoorTamperEvent, Feature.DoorTamper); checkPair(Feature.DoorFault, Feature.DoorFault); if (profileOk) { status = ProfileStatus.Supported; } else { status = ProfileStatus.Failed; } } reason = sb.ToString(); return(status); }
/// <summary> /// Returns a random number /// </summary> /// <param name="max">Maximum number</param> /// <returns>Random number between 0 and the max</returns> public int RandomNumber(int max) { return(FeaturesHelper.IsEnabled(2) ? CalculatorsHelper.RandomNumber(max) : CalculatorsHelper.BadRandomNumber(max)); }
public ProfileStatus Check(out string reason, IEnumerable <Feature> features, IEnumerable <string> scopes, Dictionary <string, object> parameters) { reason = string.Empty; var Name = this.GetProfileName(); var Scope = this.GetProfileScope(); StringBuilder sb = new StringBuilder(); ProfileStatus status = ProfileStatus.NotSupported; sb.AppendLine(string.Format("Check profile support for {0}", Name)); bool scopePresent = scopes.Contains(FactoryDefaultScope) || scopes.Contains(OperationalScope); sb.AppendLine(string.Format("Scope {0}: \t\t{1}", FactoryDefaultScope, scopes.Contains(FactoryDefaultScope) ? "PRESENT" : "NOT PRESENT")); sb.AppendLine(string.Format("Scope {0}: \t\t{1}", OperationalScope, scopes.Contains(OperationalScope) ? "PRESENT" : "NOT PRESENT")); if (!scopePresent) { sb.AppendFormat("Profile not supported"); } else { bool profileOk = true; bool supported; Action <Feature> checkNextMandatory = (feature) => { supported = features.ContainsFeature(feature); LogMandatory(sb, FeaturesHelper.GetDisplayName(feature), supported); profileOk = profileOk && supported; }; Action <Feature> logNextMandatory = (feature) => { supported = features.ContainsFeature(feature); LogMandatoryFeature(sb, FeaturesHelper.GetDisplayName(feature)); profileOk = profileOk && supported; }; Action <Feature> checkNextOptional = (feature) => { supported = features.Contains(feature); LogOptional(sb, FeaturesHelper.GetDisplayName(feature), supported); }; checkNextMandatory(Feature.DiscoveryTypesTdsDevice); checkNextMandatory(Feature.GetServices); checkNextMandatory(Feature.MaximumUsernameLength); checkNextMandatory(Feature.MaximumPasswordLength); checkNextMandatory(Feature.ZeroConfiguration); checkNextMandatory(Feature.NTP); checkNextMandatory(Feature.MaxUsers); checkNextMandatory(Feature.MonitoringProcessorUsageEvent); checkNextMandatory(Feature.MonitoringOperatingTimeLastResetEvent); checkNextMandatory(Feature.MonitoringOperatingTimeLastRebootEvent); checkNextMandatory(Feature.MonitoringOperatingTimeLastClockSynchronizationEvent); logNextMandatory(Feature.EventsService); checkNextMandatory(Feature.MaxPullPoints); if (profileOk) { var v = (int)parameters["MaxPullPoints"]; profileOk = v >= 2; sb.AppendLine(string.Format("EventService/GetServiceCapabilities/MaxPullPoints has value >= 2: {0}", profileOk ? "SUPPORTED" : "NOT SUPPORTED")); } if (features.ContainsFeature(Feature.AdvancedSecurity)) { checkNextMandatory(Feature.RSAKeyPairGenerationOrPKCS12CertificateWithRSAPrivateKeyUpload); if (features.ContainsFeature(Feature.RSAKeyPairGeneration)) { checkNextMandatory(Feature.SelfSignedCertificateCreationWithRSAAndPKCS10ExternalCertificationWithRSA); } checkNextMandatory(Feature.MaximumNumberOfKeys); if (profileOk) { var v = (int)parameters["MaximumNumberOfKeys"]; profileOk = v >= 16; sb.AppendLine(string.Format("Advanced Security Service/GetServiceCapabilities/MaximumNumberOfKeys has value >= 16: {0}", profileOk ? "SUPPORTED" : "NOT SUPPORTED")); } checkNextMandatory(Feature.MaximumNumberOfCertificates); if (profileOk) { var v = (int)parameters["MaximumNumberOfCertificates"]; profileOk = v >= 16; sb.AppendLine(string.Format("Advanced Security Service/GetServiceCapabilities/MaximumNumberOfCertificates has value >= 16: {0}", profileOk ? "SUPPORTED" : "NOT SUPPORTED")); } checkNextMandatory(Feature.TLSServerSupport); } if (features.ContainsFeature(Feature.MediaService)) { checkNextMandatory(Feature.GetServices); checkNextMandatory(Feature.RTSS); } checkNextOptional(Feature.DeviceHardwareFailureFanFailureEvent); checkNextOptional(Feature.DeviceHardwareFailurePowerSupplyFailureEvent); checkNextOptional(Feature.DeviceHardwareFailureStorageFailureEvent); checkNextOptional(Feature.DeviceHardwareFailureTemperatureCriticalEvent); checkNextOptional(Feature.MonitoringBackupLastEvent); checkNextMandatory(Feature.DefaultAccessPolicy); checkNextMandatory(Feature.Digest); status = profileOk ? ProfileStatus.Supported : ProfileStatus.Failed; } reason = sb.ToString(); return(status); }