/// <summary>
            /// Called before the action executes, after model binding is complete
            /// </summary>
            /// <param name="context">A context for action filters</param>
            public void OnActionExecuting(ActionExecutingContext context)
            {
                if (context == null)
                {
                    throw new ArgumentNullException(nameof(context));
                }

                //check whether this filter has been overridden for the Action
                CheckAccessClosedStoreAttribute actionFilter = context.ActionDescriptor.FilterDescriptors
                                                               .Where(filterDescriptor => filterDescriptor.Scope == FilterScope.Action)
                                                               .Select(filterDescriptor => filterDescriptor.Filter).OfType <CheckAccessClosedStoreAttribute>().FirstOrDefault();

                //ignore filter (the action is available even if a store is closed)
                if (actionFilter?.IgnoreFilter ?? _ignoreFilter)
                {
                    return;
                }


                //store isn't closed
                if (!_storeInformationSettings.StoreClosed)
                {
                    return;
                }

                //get action and controller names
                ControllerActionDescriptor actionDescriptor = context.ActionDescriptor as ControllerActionDescriptor;
                string actionName     = actionDescriptor?.ActionName;
                string controllerName = actionDescriptor?.ControllerName;

                if (string.IsNullOrEmpty(actionName) || string.IsNullOrEmpty(controllerName))
                {
                    return;
                }

                //topics accessible when a store is closed
                if (controllerName.Equals("Topic", StringComparison.InvariantCultureIgnoreCase) &&
                    actionName.Equals("TopicDetails", StringComparison.InvariantCultureIgnoreCase))
                {
                    //get identifiers of topics are accessible when a store is closed
                    System.Collections.Generic.IEnumerable <int> allowedTopicIds = _topicService.GetAllTopics(_storeContext.CurrentStore.Id)
                                                                                   .Where(topic => topic.AccessibleWhenStoreClosed).Select(topic => topic.Id);

                    //check whether requested topic is allowed
                    int?requestedTopicId = context.RouteData.Values["topicId"] as int?;
                    if (requestedTopicId.HasValue && allowedTopicIds.Contains(requestedTopicId.Value))
                    {
                        return;
                    }
                }



                //store is closed and no access, so redirect to 'StoreClosed' page
                string storeClosedUrl = _urlHelperFactory.GetUrlHelper(context).RouteUrl("StoreClosed");

                context.Result = new RedirectResult(storeClosedUrl);
            }
Ejemplo n.º 2
0
        public void AnalyzeSymbol(SymbolAnalysisContext context,
                                  INamedTypeSymbol iCollectionType, INamedTypeSymbol gCollectionType,
                                  INamedTypeSymbol iEnumerableType, INamedTypeSymbol gEnumerableType,
                                  INamedTypeSymbol iListType, INamedTypeSymbol gListType)
        {
            var namedTypeSymbol = (INamedTypeSymbol)context.Symbol;

            System.Collections.Generic.IEnumerable <INamedTypeSymbol> allInterfaces = namedTypeSymbol.AllInterfaces.Select(t => t.OriginalDefinition);

            foreach (INamedTypeSymbol @interface in allInterfaces)
            {
                if ((@interface.Equals(iCollectionType) && !allInterfaces.Contains(gCollectionType)) ||
                    (@interface.Equals(iEnumerableType) && !allInterfaces.Contains(gEnumerableType)) ||
                    (@interface.Equals(iListType) && !allInterfaces.Contains(gListType)))
                {
                    context.ReportDiagnostic(Diagnostic.Create(Rule, namedTypeSymbol.Locations.First(), namedTypeSymbol.Name, @interface.Name));
                    break;
                }
            }
        }
Ejemplo n.º 3
0
        string TranslateProfiles(System.Collections.Generic.IEnumerable <ConnectionProfile> profiles)
        {
            string p = "";

            if (profiles.Contains(ConnectionProfile.Ethernet))
            {
                p += Resources.Ethernet;
            }
            if (profiles.Contains(ConnectionProfile.WiFi))
            {
                if (p != "")
                {
                    p += ", ";
                }
                p += "WiFi";
            }
            if (profiles.Contains(ConnectionProfile.Cellular))
            {
                if (p != "")
                {
                    p += ", ";
                }
                p += Resources.Cellular;
            }
            if (profiles.Contains(ConnectionProfile.Unknown))
            {
                if (p != "")
                {
                    p += ", ";
                }
                p += Resources.Unknown;
            }
            if (p == "")
            {
                p = p += Resources.Unknown + ", " + Resources.IsAirplaneMode;
            }
            return(p);
        }
Ejemplo n.º 4
0
 private void AtribuirEscolas(AtribuicaoSupervisorUEDto atribuicaoSupervisorEscolaDto, System.Collections.Generic.IEnumerable <string> codigosEscolasDominio)
 {
     if (atribuicaoSupervisorEscolaDto.UESIds != null)
     {
         foreach (var codigoEscolaDto in atribuicaoSupervisorEscolaDto.UESIds)
         {
             if (codigosEscolasDominio != null && !codigosEscolasDominio.Contains(codigoEscolaDto))
             {
                 repositorioSupervisorEscolaDre.Salvar(new SupervisorEscolaDre()
                 {
                     DreId        = atribuicaoSupervisorEscolaDto.DreId,
                     SupervisorId = atribuicaoSupervisorEscolaDto.SupervisorId,
                     EscolaId     = codigoEscolaDto
                 });
             }
         }
     }
 }
Ejemplo n.º 5
0
 private bool IsSetArg(System.Collections.Generic.IEnumerable <string> args, string argName, bool ignoreCase)
 {
     if (ignoreCase)
     {
         foreach (string arg in args)
         {
             if (Leayal.StringHelper.IsEqual(arg, argName, true))
             {
                 return(true);
             }
         }
         return(false);
     }
     else
     {
         return(args.Contains(argName));
     }
 }
Ejemplo n.º 6
0
        private string SelectCorral(System.Collections.Generic.IEnumerable <string> corralNames)
        {
            string selectedCorral;

            do
            {
                Console.Clear();
                Console.WriteLine("Corral List");
                foreach (var corral in workflowEngine.Corrals)
                {
                    Console.WriteLine($"[{corral.Name}] Max Runners: {corral.MaxElements}");
                }

                Console.WriteLine();
                Console.Write($"Type Corral name to configure or [N] to proced : ");
                selectedCorral = Console.ReadKey().KeyChar.ToString().ToUpper();
            } while (!corralNames.Contains(selectedCorral) && selectedCorral != "N");
            return(selectedCorral);
        }
Ejemplo n.º 7
0
        public System.String IsRecognized(System.String fileSpecification)
        {
            fileSpecification = fileSpecification.TrimToNull();
            if (System.String.IsNullOrEmpty(fileSpecification))
            {
                throw new System.ArgumentNullException("fileSpecification");
            }

            if (null == myNetIdList)
            {
                System.Threading.Interlocked.CompareExchange <System.Collections.Generic.IEnumerable <System.String> >(ref myNetIdList, DbNetId.GetNetIdList(), null);
            }

            var fileName = System.IO.Path.GetFileName(fileSpecification);
            var fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(fileName);
            var section    = Configuration.FileRecognizerConfigurationSection.GetSection();
            var element    = section.Recognizer;
            var expression = element.NetIdExpression;
            var opt        = System.Text.RegularExpressions.RegexOptions.Singleline | System.Text.RegularExpressions.RegexOptions.IgnoreCase;

            if (!System.Text.RegularExpressions.Regex.IsMatch(fileNameWithoutExtension, expression, opt))
            {
                return(null);
            }

            var netId = System.Text.RegularExpressions.Regex.Match(fileNameWithoutExtension, expression, opt).Groups[element.NetIdCaptureName].Value;

            if (!myNetIdList.Contains(netId, System.StringComparer.OrdinalIgnoreCase))
            {
                return(null);
            }

            return(System.Text.RegularExpressions.Regex.IsMatch(fileNameWithoutExtension, expression, opt)
                                ? System.IO.Path.Combine(element.Destination, fileNameWithoutExtension + System.IO.Path.GetExtension(fileName))
                                : null
                   );
        }
        private string CreateOutputContent()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("<?xml version=\"1.0\" standalone=\"yes\" ?>");
            sb.AppendLine("<LatestEvents>");

            using (AppDataContext db = new AppDataContext())
            {
                //var list = db.LatestEvents
                //            .Where(x => x.ResolveFlag != (byte)ResolveFlag.Processed)
                //            .Where(x => HostTag.All.Where(u => u.TagId != 0).Select(u => u.TagId).ToArray().Contains(x.TagId))
                //            .OrderByDescending(x => x.LastHappenTime)
                //            .ToList();

                var list = db.TagAlerts.Where(l => l.AlertStatus == (byte)AlertStatusType.New)
                           .Where(l => l.HostId > 0)
                           .OrderByDescending(l => l.WriteTime)
                           .ThenByDescending(l => l.AlertLevel)
                           //.OrderByDescending(l => l.AlertLevel)
                           .ToList();

                //lyz 获取用户的类型
                System.Collections.Generic.IEnumerable <int>            hostidds = list.Select(u => u.HostId);
                System.Collections.Generic.IEnumerable <Data.HostGroup> hgs      = db.HostGroups.Where(_d => hostidds.Contains(_d.HostId) && (_d.HostGroupId == 1 || _d.HostGroupId == 2)).AsEnumerable();

                var str = "	<item id='{0}' tagId='{1}' tagMac='{2}' tagName='{3}' coordinatesId='{4}' coodinatesName='{5}' eventType='{6}' eventDescription='{7}' lastHappenTime='{8}' hostGroupID='{9}' />\r\n";
                foreach (var i in list)
                {
                    //lyz 获取用户的类型
                    Data.HostGroup hg = hgs.Where(_d => _d.HostId == i.HostId).FirstOrDefault();

                    //20100106: select by host
                    //TagStatusView tagStatusView = TagStatusView.SelectTagStatus(i.TagId);
                    TagStatusView tagStatusView = TagStatusView.SelectTagStatusByHostId(i.HostId);
                    if (hg != null && tagStatusView != null)//判断对象是否存在 lyz
                    {
                        sb.AppendFormat(str, i.HostId, i.TagId, tagStatusView.Mac, tagStatusView.HostTag.HostName, i.CoordinatesId, Coordinates.GetName(i.CoordinatesId), i.AlertType, CommonExtension.GetEventDescription((SupportEvent)i.AlertType, i.HostId), i.WriteTime, hg.HostGroupId);
                    }
                }
            }

            sb.AppendLine("</LatestEvents>");
            return(sb.ToString());
        }
Ejemplo n.º 9
0
 private bool IsSetArg(System.Collections.Generic.IEnumerable <string> args, string argName)
 {
     return(args.Contains(argName));
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Handles the OnDataBinding event of the SubstateList control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void SubstateList_OnDataBinding(object sender, System.EventArgs e)
        {
            System.Collections.Generic.IEnumerable <string> controlIDs = this.SubstateList.Items.Select(dataItem => dataItem.Controls.OfType <System.Web.UI.WebControls.CheckBox>().Single().UniqueID);
            UpdatePanelControlTrigger[] triggersToRemove = this.ControlContainer.Triggers.OfType <UpdatePanelControlTrigger>().Where(trigger => controlIDs.Contains(trigger.ControlID)).ToArray();

            foreach (UpdatePanelControlTrigger trigger in triggersToRemove)
            {
                this.ControlContainer.Triggers.Remove(trigger);
            }
        }