コード例 #1
0
ファイル: DemoPage3.aspx.cs プロジェクト: jon-mcmr/Virgin-Tds
        protected SafeDictionary<string> GetRefinements()
        {
            var refinements = new SafeDictionary<string>();

             if (!FieldName1TextBox.Text.IsNullOrEmpty() && !FieldValue1TextBox.Text.IsNullOrEmpty())
            refinements.Add(FieldName1TextBox.Text, FieldValue1TextBox.Text);

             if (!FieldName2TextBox.Text.IsNullOrEmpty() && !FieldValue2TextBox.Text.IsNullOrEmpty())
            refinements.Add(FieldName2TextBox.Text, FieldValue2TextBox.Text);

             return refinements;
        }
コード例 #2
0
        /// <summary>
        /// Reflect the Class Name in the Source
        /// </summary>
        /// <param name="templateSource">
        /// The template source.
        /// </param>
        /// <returns>
        /// </returns>
        private static Item[] RunEnumeration(string templateSource, Item sourceItem)
        {
            templateSource = templateSource.Replace("lucene:", string.Empty);
            var commands = templateSource.Split(';');
            var refinements = new SafeDictionary<string>();

            foreach (var command in commands)
            {
                if (!command.IsNullOrEmpty())
                {
                    var commandSplit = command.Split(':');
                    if (commandSplit.Length == 2)
                    {
                        refinements.Add(commandSplit[0], commandSplit[1]);
                    }
                }
            }

            if (refinements.ContainsKey("location"))
            {
                int hitsCount;
                var items = Context.ContentDatabase.GetItem(refinements["location"]).Search(refinements, out hitsCount);
                return items.ToList().Select(x => x.GetItem()).ToArray();
            }
            else
            {
                int hitsCount;
                var items = sourceItem.Search(refinements, out hitsCount);
                return items.ToList().Select(x => x.GetItem()).ToArray();
            }
        }
コード例 #3
0
 public string Rendered(int? maxWidth, int? maxHeight)
 {
     SafeDictionary<string> parameters = new SafeDictionary<string>();
     if (maxWidth.HasValue)
     {
         parameters.Add("mw", maxWidth.Value.ToString());
     }
     if (maxHeight.HasValue)
     {
         parameters.Add("mh", maxHeight.Value.ToString());
     }
     if (this.field == null)
     {
         return string.Empty;
     }
     return FieldRenderer.Render(this.item, this.field.InnerField.Name, WebUtil.BuildQueryString(parameters, false));
 }
コード例 #4
0
        /// <summary>
        /// Get Items to be loaded when the Control is loaded on the item
        /// </summary>
        /// <param name="current">
        /// The current.
        /// </param>
        /// <returns>
        /// Array of Item
        /// </returns>
        protected override Item[] GetItems(Item current)
        {
            Assert.ArgumentNotNull(current, "current");
            var values = StringUtil.GetNameValues(Source, '=', '&');
            var refinements = new SafeDictionary<string>();
            if (values["FieldsFilter"] != null)
            {
                var splittedFields = StringUtil.GetNameValues(values["FieldsFilter"], ':', ',');
                foreach (string key in splittedFields.Keys)
                {
                    refinements.Add(key, splittedFields[key]);
                }
            }

            var locationFilter = values["StartSearchLocation"];
            locationFilter = MakeFilterQuerable(locationFilter);

            var templateFilter = values["TemplateFilter"];
            templateFilter = MakeTemplateFilterQuerable(templateFilter);

            var pageSize = values["PageSize"];
            var searchParam = new DateRangeSearchParam
            {
                Refinements = refinements,
                LocationIds = locationFilter.IsNullOrEmpty() ? Sitecore.Context.ContentDatabase.GetItem(this.ItemID).GetParentBucketItemOrRootOrSelf().ID.ToString() : locationFilter,
                TemplateIds = templateFilter,
                FullTextQuery = values["FullTextQuery"],
                Language = values["Language"],
                PageSize = pageSize.IsEmpty() ? 10 : int.Parse(pageSize),
                PageNumber = this.pageNumber,
                SortByField = values["SortField"],
                SortDirection = values["SortDirection"]
            };

            this.filter = "&location=" + (locationFilter.IsNullOrEmpty() ? Sitecore.Context.ContentDatabase.GetItem(this.ItemID).GetParentBucketItemOrRootOrSelf().ID.ToString() : locationFilter) +
                     "&filterText=" + values["FullTextQuery"] +
                     "&language=" + values["Language"] +
                     "&pageSize=" + (pageSize.IsEmpty() ? 10 : int.Parse(pageSize)) +
                     "&sort=" + values["SortField"];

            if (values["TemplateFilter"].IsNotNull())
            {
                this.filter += "&template=" + templateFilter;
            }

            using (var searcher = new IndexSearcher(Constants.Index.Name))
            {
                var keyValuePair = searcher.GetItems(searchParam);
                var items = keyValuePair.Value;
                this.pageNumber = keyValuePair.Key / searchParam.PageSize;
                if (this.pageNumber <= 0)
                {
                    this.pageNumber = 1;
                }
                return items.Select(sitecoreItem => sitecoreItem.GetItem()).Where(i => i != null).ToArray();
            }
        }
コード例 #5
0
      public static SafeDictionary<string> CreateRefinements(string fieldName, string fieldValue)
      {
         var refinements = new SafeDictionary<string>();

         if (!String.IsNullOrEmpty(fieldValue) && !String.IsNullOrEmpty(fieldValue))
         {
            if (fieldName.Contains("|"))
            {
               var fieldNames = fieldName.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);

               foreach (var name in fieldNames)
               {
                  refinements.Add(name, fieldValue);
               }
            }
            else
            {
               refinements.Add(fieldName, fieldValue);
            }
         }

         return refinements;
      }
コード例 #6
0
        public static SafeDictionary<string> ToSafeDictionary(this NameValueCollection collection)
        {
            var safeDictionary = new SafeDictionary<string>();
            
            if (collection != null)
            {
                foreach (var key in collection.AllKeys)
                {
                    safeDictionary.Add(key, collection[key]);
                }
            }

            return safeDictionary;
        }
コード例 #7
0
        private static void Initialize()
        {
            TemplateDateFieldCollection = new SafeDictionary<ID, string>();
            Database masterDB = Sitecore.Context.ContentDatabase ?? Sitecore.Configuration.Factory.GetDatabase("master");
            Assert.IsNotNull(masterDB, "content database is not defined");

            Item[] blogPostTemplates = masterDB.SelectItems("fast:/sitecore/templates//*[@@name = 'Blog Post']");

            foreach (Item blogItem in blogPostTemplates)
            {
                if (blogItem != null)
                {
                    TemplateDateFieldCollection.Add(blogItem.ID, "Publish Date");
                }
            }
        }
コード例 #8
0
ファイル: Arsenals.cs プロジェクト: AiiMz/PserverWork
 public Arsenals()
 {
     Inscribed = new SafeDictionary<ArsenalType, SafeDictionary<uint, ArsenalSingle>>(1000);
     Donation = new Dictionary<ArsenalType, ulong>(1000);
     Inscribed.Add(ArsenalType.Headgear, new SafeDictionary<uint, ArsenalSingle>(1000));
     Inscribed.Add(ArsenalType.Armor, new SafeDictionary<uint, ArsenalSingle>(1000));
     Inscribed.Add(ArsenalType.Weapon, new SafeDictionary<uint, ArsenalSingle>(1000));
     Inscribed.Add(ArsenalType.Ring, new SafeDictionary<uint, ArsenalSingle>(1000));
     Inscribed.Add(ArsenalType.Boots, new SafeDictionary<uint, ArsenalSingle>(1000));
     Inscribed.Add(ArsenalType.Necklace, new SafeDictionary<uint, ArsenalSingle>(1000));
     Inscribed.Add(ArsenalType.Fan, new SafeDictionary<uint, ArsenalSingle>(1000));
     Inscribed.Add(ArsenalType.Tower, new SafeDictionary<uint, ArsenalSingle>(1000));
     Donation.Add(ArsenalType.Headgear, 0);
     Donation.Add(ArsenalType.Armor, 0);
     Donation.Add(ArsenalType.Weapon, 0);
     Donation.Add(ArsenalType.Ring, 0);
     Donation.Add(ArsenalType.Boots, 0);
     Donation.Add(ArsenalType.Necklace, 0);
     Donation.Add(ArsenalType.Fan, 0);
     Donation.Add(ArsenalType.Tower, 0);
 }
コード例 #9
0
        private static void Initialize()
        {
            TemplateDateFieldCollection = new SafeDictionary<ID, string>();
            var masterDb = Context.ContentDatabase ?? Factory.GetDatabase("master");
            Assert.IsNotNull(masterDb, "content database is not defined");
            foreach (XmlNode node in Factory.GetConfigNodes("wacomBucketConfiguration/dateFieldMappings/mapping"))
            {

                var templateName = XmlUtil.GetAttribute("template", node);
                var fieldName = XmlUtil.GetAttribute("field", node);
                var template = masterDb.Templates[templateName];
                if (template != null && !string.IsNullOrEmpty(fieldName))
                {
                    TemplateDateFieldCollection.Add(template.ID, fieldName);
                }
                else
                {
                    Log.Info(string.Format("Could not find template : {0}", templateName), new object());
                }

            }
        }
コード例 #10
0
        /// <summary>
        /// Using a strongly types List of SearchStringModel, you can run a search based off a JSON String
        /// </summary>
        /// <returns>IEnumreable List of Results that have been typed to a smaller version of the Item Object</returns>
        public static IEnumerable <SitecoreItem> Search(this Item itm, List <SearchStringModel> currentSearchString, out int hitCount, string indexName = "itembuckets_buckets", string sortField = "", string sortDirection = "", int numberOfItems = 20, int pageNumber = 0)
        {
            var refinements        = new SafeDictionary <string>();
            var searchStringModels = SearchHelper.GetTags(currentSearchString);

            if (searchStringModels.Count > 0)
            {
                foreach (var ss in searchStringModels)
                {
                    var query = ss.Value;
                    if (query.Contains("tagid="))
                    {
                        query = query.Split('|')[1].Replace("tagid=", string.Empty);
                    }
                    var db = Context.ContentDatabase ?? Context.Database;
                    refinements.Add("_tags", db.GetItem(query).ID.ToString());
                }
            }

            using (var searcher = new IndexSearcher(indexName))
            {
                var sitecoreItems = searcher.GetItems(new DateRangeSearchParam()
                {
                    FullTextQuery = SearchHelper.GetText(currentSearchString),
                    RelatedIds    = string.Empty,
                    TemplateIds   = SearchHelper.GetTemplates(currentSearchString),
                    LocationIds   = itm.ID.ToString(),
                    Refinements   = refinements,
                    SortByField   = sortField,
                    PageNumber    = pageNumber,
                    PageSize      = numberOfItems
                });

                hitCount = sitecoreItems.Key;
                return(sitecoreItems.Value);
            }
        }
コード例 #11
0
        /// <summary>
        /// 给出某种时间片的处理信息
        /// </summary>
        /// <returns></returns>
        public TimerProfile GetProfile()
        {
            if (OneServer.Profiling == false)
            {
                return(null);
            }

            string strName = ToString();

            if (strName == null || strName == string.Empty)
            {
                strName = "null";
            }

            TimerProfile timerProfile = s_Profiles.GetValue(strName);

            if (timerProfile == null)
            {
                timerProfile = new TimerProfile();
                s_Profiles.Add(strName, timerProfile);
            }

            return(timerProfile);
        }
コード例 #12
0
            private Resolver <CType> CreateResolverInstanceGeneric <BType, CType>(bool isImplicitBinding)
                where BType : class
                where CType : class, BType
            {
                var bindType = typeof(BType);
                var resolver = new Resolver <CType> (this, bindType, syncLock);

                if (isImplicitBinding)
                {
                    allImplicitResolvers.Add(bindType, resolver);
                    if (!allResolvers.ContainsKey(bindType))
                    {
                        allResolvers.Add(bindType, resolver);
                    }
                }
                else
                {
                    allResolvers.Add(bindType, resolver);
                }

                SetupImplicitPropResolvers <CType> (resolver);

                return(resolver);
            }
コード例 #13
0
ファイル: Nobility.cs プロジェクト: AiiMz/PserverWork
        public static void Sort(uint updateUID)
        {
            SortedDictionary<ulong, SortEntry<uint, NobilityInformation>> sortdict = new SortedDictionary<ulong, SortEntry<uint, NobilityInformation>>();

            foreach (NobilityInformation info in Board.Values)
            {
                if (sortdict.ContainsKey(info.Donation))
                {
                    SortEntry<uint, NobilityInformation> entry = sortdict[info.Donation];
                    entry.Values.Add(info.EntityUID, info);
                }
                else
                {
                    SortEntry<uint, NobilityInformation> entry = new SortEntry<uint, NobilityInformation>();
                    entry.Values = new Dictionary<uint, NobilityInformation>();
                    entry.Values.Add(info.EntityUID, info);
                    sortdict.Add(info.Donation, entry);
                }
            }

            SafeDictionary<uint, NobilityInformation> sortedBoard = new SafeDictionary<uint, NobilityInformation>(10000);

            int Place = 0;
            foreach (KeyValuePair<ulong, SortEntry<uint, NobilityInformation>> entries in sortdict.Reverse())
            {
                foreach (KeyValuePair<uint, NobilityInformation> value in entries.Value.Values)
                {
                    Client.GameState client = null;
                    try
                    {
                        int previousPlace = value.Value.Position;
                        value.Value.Position = Place;
                        NobilityRank Rank = NobilityRank.Serf;

                        if (Place >= 50)
                        {
                            if (value.Value.Donation >= 200000000)
                            {
                                Rank = NobilityRank.Earl;
                                //ServerBase.Kernel.SendWorldMessage(new Message("Congratulation! " + client.Entity.Name + "Donation To Earl in Nobility Rank.", System.Drawing.Color.White, Message.TopLeft), ServerBase.Kernel.GamePool.Values);
                                //Rank = NobilityRank.Earl;
                            }
                            else if (value.Value.Donation >= 100000000)
                            {
                                Rank = NobilityRank.Baron;
                                //ServerBase.Kernel.SendWorldMessage(new Message("Congratulation! " + client.Entity.Name + "Donation To Baron in Nobility Rank.", System.Drawing.Color.White, Message.TopLeft), ServerBase.Kernel.GamePool.Values);
                                //Rank = NobilityRank.Baron;
                            }
                            else if (value.Value.Donation >= 30000000)
                            {
                                Rank = NobilityRank.Knight;
                                //ServerBase.Kernel.SendWorldMessage(new Message("Congratulation! " + client.Entity.Name + "Donation To Knight in Nobility Rank.", System.Drawing.Color.White, Message.TopLeft), ServerBase.Kernel.GamePool.Values);
                                //Rank = NobilityRank.Knight;
                            }
                        }
                        else
                        {
                            if (Place < 3)
                            {
                                //Conquer_Online_Server.ServerBase.Kernel.SendWorldMessage(new Conquer_Online_Server.Network.GamePackets.Message("Congratulation! " + client.Entity.Name + "Donation To King in Nobility Rank!", System.Drawing.Color.White, 2011), Conquer_Online_Server.ServerBase.Kernel.GamePool.Values);
                                Rank = NobilityRank.King;
                                //Conquer_Online_Server.Clan.nobmas(client);
                                // ServerBase.Kernel.SendWorldMessage(new Message("Congratulation! " + client.Entity.Name + "Donation To King/Queen in Nobility Rank.", System.Drawing.Color.White, Message.Center), ServerBase.Kernel.GamePool.Values);
                                //Rank = NobilityRank.King;
                            }
                            else if (Place < 15)
                            {
                                Rank = NobilityRank.Prince;
                                //Conquer_Online_Server.Clan.nobmas(client);
                                // ServerBase.Kernel.SendWorldMessage(new Message("Congratulation! " + client.Entity.Name + "Donation To Prince in Nobility Rank.", System.Drawing.Color.White, Message.Center), ServerBase.Kernel.GamePool.Values);
                                // Rank = NobilityRank.Prince;
                            }
                            else
                            {
                                Rank = NobilityRank.Duke;
                                //Conquer_Online_Server.Clan.nobmas(client);
                                //ServerBase.Kernel.SendWorldMessage(new Message("Congratulation! " + client.Entity.Name + "Donation To Duke in Nobility Rank.", System.Drawing.Color.White, Message.Center), ServerBase.Kernel.GamePool.Values);
                                //Rank = NobilityRank.Duke;
                            }
                        }
                        var oldRank = value.Value.Rank;
                        value.Value.Rank = Rank;
                        if (ServerBase.Kernel.GamePool.TryGetValue(value.Key, out client))
                        {
                            bool updateTheClient = false;
                            if (oldRank != Rank)
                            {
                                updateTheClient = true;
                            }
                            else
                            {
                                if (previousPlace != Place)
                                {
                                    updateTheClient = true;
                                }
                            }
                            if (updateTheClient || client.Entity.UID == updateUID)
                            {
                                NobilityInfo update = new NobilityInfo(true);
                                update.Type = NobilityInfo.Icon;
                                update.dwParam = value.Key;
                                update.UpdateString(value.Value);
                                client.SendScreen(update, true);
                                client.Entity.NobilityRank = value.Value.Rank;
                            }
                        }
                        sortedBoard.Add(value.Key, value.Value);
                        Place++;
                    }
                    catch { }
                }

            }

            Board = sortedBoard;
            lock (BoardList)
            {
                BoardList = Board.Values.ToList();
            }
        }
コード例 #14
0
 /// <summary>
 /// 法术添加
 /// </summary>
 /// <param name="iSpellId"></param>
 public void Add(uint iSpellId)
 {
     m_Spells.Add(iSpellId, new WowPlayerInfoSpell(iSpellId));
 }
コード例 #15
0
 /// <summary>
 /// 技能添加
 /// </summary>
 /// <param name="iSpellId"></param>
 public void Add(uint iButton, uint iActionId, uint iType, uint iMisc)
 {
     m_Actions.Add(iButton, new WowPlayerInfoAction(iButton, iActionId, iType, iMisc));
 }
コード例 #16
0
 /// <summary>
 /// 技能添加
 /// </summary>
 /// <param name="iSpellId"></param>
 public void Add(ulong iSkillId)
 {
     m_Skills.Add(iSkillId, new WowPlayerInfoSkill(iSkillId));
 }
コード例 #17
0
ファイル: ViewManager.cs プロジェクト: zhongshuiyuan/raptordb
 internal void StartTransaction()
 {
     _transactions.Add(Thread.CurrentThread.ManagedThreadId, false);
 }
コード例 #18
0
        internal static object CreateObject(Type t, WorkItem root)
        {
            object instance = null;

            // first check the cache
            if (m_constructorCache.ContainsKey(t))
            {
                return(CreateObjectFromCache(t, root));
            }

            ConstructorInfo ci;

            if (t.IsInterface)
            {
                throw new IOCException(string.Format("Cannot create an instance of an interface class ({0}). Check your registration code.", t.Name));
            }


            // see if there is an injection ctor
            var ctors = (from c in t.GetConstructors(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
                         where c.IsPublic == true &&
                         c.GetCustomAttributes(typeof(InjectionConstructorAttribute), true).Count() > 0
                         select c);

            if (ctors.Count() == 0)
            {
                // no injection ctor, get the default, parameterless ctor
                var parameterlessCtors = (from c in t.GetConstructors(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
                                          where c.GetParameters().Length == 0
                                          select c);
                if (parameterlessCtors.Count() == 0)
                {
                    throw new ArgumentException(string.Format("Type '{0}' has no public parameterless constructor or injection constructor.\r\nAre you missing the InjectionConstructor attribute?", t));
                }

                // create the object
                ci = parameterlessCtors.First();
                try
                {
                    instance = ci.Invoke(null);
                    m_constructorCache.Add(t, new InjectionConstructor {
                        CI = ci
                    });
                }
                catch (TargetInvocationException ex)
                {
                    throw ex.InnerException;
                }
            }
            else if (ctors.Count() == 1)
            {
                // call the injection ctor
                ci = ctors.First();
                ParameterInfo[] paramList = ci.GetParameters();
                object[]        inputs    = GetParameterObjectsForParameterList(paramList, root, t.Name);
                try
                {
                    instance = ci.Invoke(inputs);
                    m_constructorCache.Add(t, new InjectionConstructor {
                        CI = ci, ParameterList = paramList
                    });
                }
                catch (TargetInvocationException ex)
                {
                    throw ex.InnerException;
                }
            }
            else
            {
                throw new ArgumentException(string.Format("Type '{0}' has {1} defined injection constructors.  Only one is allowed", t.Name, ctors.Count()));
            }
            // NOTE: we don't do injections here, as if the created object has a dependency that requires this instance it would fail becasue this instance is not yet in the item list.

            return(instance);
        }
コード例 #19
0
 /// <summary>
 /// Returns a SafeDictionary[string] of the parameters <b>not</b> needed by MediaUrlOptions.
 /// </summary>
 /// <param name="parameters"></param>
 /// <returns></returns>
 public static SafeDictionary<string> ParseUnusedParameters(object parameters)
 {
     var safeParameters = new SafeDictionary<string>();
     var unusedParameters = new SafeDictionary<string>();
     if (parameters != null)
     {
         TypeHelper.CopyProperties(parameters, safeParameters);
         foreach (var param in safeParameters)
         {
             if (!Params.All.Contains(param.Key))
             {
                 unusedParameters.Add(param.Key, param.Value);
             }
         }
     }
     return unusedParameters;
 }
コード例 #20
0
        /// <summary>
        /// Tries to load the referenced assemblies.
        /// </summary>
        /// <param name="inputAssemblies">Assemblies</param>
        private void TryLoadReferencedAssemblies(Assembly[] inputAssemblies)
        {
            var ws = new SafeDictionary<string, Assembly>();

            foreach (Assembly a in inputAssemblies)
            {
                if (a == null)
                {
                    continue;
                }

                // recursively load all the assemblies reachables from the root!
                if (!Assemblies.ContainsKey(
                    a.GetName().FullName) && !ws.ContainsKey(a.GetName().FullName))
                {
                    ws.Add(a.GetName().FullName, a);
                }

                while (ws.Count > 0)
                {
                    var en = ws.Keys.GetEnumerator();
                    en.MoveNext();
                    var a_name = en.Current;
                    var a_assembly = ws[a_name];
                    Assemblies.Add(a_name, a_assembly);
                    ws.Remove(a_name);

                    foreach (AssemblyName name in a_assembly.GetReferencedAssemblies())
                    {
                        Assembly b;
                        ExtendedReflection.Utilities.ReflectionHelper.TryLoadAssembly(name.FullName, out b);

                        if (b != null)
                        {
                            if (!Assemblies.ContainsKey(b.GetName().FullName) &&
                                !ws.ContainsKey(b.GetName().FullName))
                            {
                                ws.Add(b.GetName().FullName, b);
                            }
                        }
                    }
                }
            }
        }
コード例 #21
0
        /// <summary>
        /// Renders HTML for an image
        /// </summary>
        /// <param name="image">The image to render</param>
        /// <param name="attributes">Additional parameters to add. Do not include alt or src</param>
        /// <param name="outputHeightWidth">Indicates if the height and width attributes should be output when rendering the image</param>
        /// <returns>An img HTML element</returns>
        public virtual string RenderImage(
            Fields.Image image,
            SafeDictionary <string> attributes,
            bool outputHeightWidth = false
            )
        {
            if (image == null)
            {
                return(string.Empty);
            }

            if (attributes == null)
            {
                attributes = new SafeDictionary <string>();
            }

            var origionalKeys = attributes.Keys.ToList();

            //should there be some warning about these removals?
            AttributeCheck(attributes, ImageParameterKeys.CLASS, image.Class);
            AttributeCheck(attributes, ImageParameterKeys.ALT, image.Alt);
            AttributeCheck(attributes, ImageParameterKeys.BORDER, image.Border);
            if (image.HSpace > 0)
            {
                AttributeCheck(attributes, ImageParameterKeys.HSPACE, image.HSpace.ToString(CultureInfo.InvariantCulture));
            }
            if (image.VSpace > 0)
            {
                AttributeCheck(attributes, ImageParameterKeys.VSPACE, image.VSpace.ToString(CultureInfo.InvariantCulture));
            }
            if (image.Width > 0)
            {
                AttributeCheck(attributes, ImageParameterKeys.WIDTHHTML, image.Width.ToString(CultureInfo.InvariantCulture));
            }
            if (image.Height > 0)
            {
                AttributeCheck(attributes, ImageParameterKeys.HEIGHTHTML, image.Height.ToString(CultureInfo.InvariantCulture));
            }

            var urlParams  = new SafeDictionary <string>();
            var htmlParams = new SafeDictionary <string>();

            /*
             * ME - This method is used to render images rather than going back to the fieldrender
             * because it stops another call having to be passed to Sitecore.
             */

            if (image == null || image.Src.IsNullOrWhiteSpace())
            {
                return("");
            }

            if (attributes == null)
            {
                attributes = new SafeDictionary <string>();
            }

            Action <string> remove = key => attributes.Remove(key);
            Action <string> url    = key =>
            {
                urlParams.Add(key, attributes[key]);
                remove(key);
            };
            Action <string> html = key =>
            {
                htmlParams.Add(key, attributes[key]);
                remove(key);
            };
            Action <string> both = key =>
            {
                htmlParams.Add(key, attributes[key]);
                urlParams.Add(key, attributes[key]);
                remove(key);
            };

            var keys = attributes.Keys.ToList();

            foreach (var key in keys)
            {
                switch (key)
                {
                case ImageParameterKeys.BORDER:
                case ImageParameterKeys.ALT:
                case ImageParameterKeys.HSPACE:
                case ImageParameterKeys.VSPACE:
                case ImageParameterKeys.CLASS:
                case ImageParameterKeys.WIDTHHTML:
                case ImageParameterKeys.HEIGHTHTML:
                    html(key);
                    break;

                case ImageParameterKeys.OUTPUT_METHOD:
                case ImageParameterKeys.ALLOW_STRETCH:
                case ImageParameterKeys.IGNORE_ASPECT_RATIO:
                case ImageParameterKeys.SCALE:
                case ImageParameterKeys.MAX_WIDTH:
                case ImageParameterKeys.MAX_HEIGHT:
                case ImageParameterKeys.THUMBNAIL:
                case ImageParameterKeys.BACKGROUND_COLOR:
                case ImageParameterKeys.DATABASE:
                case ImageParameterKeys.LANGUAGE:
                case ImageParameterKeys.VERSION:
                case ImageParameterKeys.DISABLE_MEDIA_CACHE:
                case ImageParameterKeys.WIDTH:
                case ImageParameterKeys.HEIGHT:
                    url(key);
                    break;

                default:
                    html(key);
                    break;
                }
            }

            //copy width and height across to url
            if (!urlParams.ContainsKey(ImageParameterKeys.WIDTH) && !urlParams.ContainsKey(ImageParameterKeys.HEIGHT))
            {
                if (origionalKeys.Contains(ImageParameterKeys.WIDTHHTML))
                {
                    urlParams[ImageParameterKeys.WIDTH] = htmlParams[ImageParameterKeys.WIDTHHTML];
                }
                if (origionalKeys.Contains(ImageParameterKeys.HEIGHTHTML))
                {
                    urlParams[ImageParameterKeys.HEIGHT] = htmlParams[ImageParameterKeys.HEIGHTHTML];
                }
            }

            if (!urlParams.ContainsKey(ImageParameterKeys.LANGUAGE) && image.Language != null)
            {
                urlParams[ImageParameterKeys.LANGUAGE] = image.Language.Name;
            }


            //calculate size

            var finalSize = Utilities.ResizeImage(
                image.Width,
                image.Height,
                urlParams[ImageParameterKeys.SCALE].ToFlaot(),
                urlParams[ImageParameterKeys.WIDTH].ToInt(),
                urlParams[ImageParameterKeys.HEIGHT].ToInt(),
                urlParams[ImageParameterKeys.MAX_WIDTH].ToInt(),
                urlParams[ImageParameterKeys.MAX_HEIGHT].ToInt());



            urlParams[ImageParameterKeys.HEIGHT] = finalSize.Height.ToString();
            urlParams[ImageParameterKeys.WIDTH]  = finalSize.Width.ToString();

            Action <string, string> originalAttributeClean = (exists, missing) =>
            {
                if (origionalKeys.Contains(exists) && !origionalKeys.Contains(missing))
                {
                    urlParams.Remove(missing);
                    htmlParams.Remove(missing);
                }
            };

            //we do some smart clean up
            originalAttributeClean(ImageParameterKeys.WIDTHHTML, ImageParameterKeys.HEIGHTHTML);
            originalAttributeClean(ImageParameterKeys.HEIGHTHTML, ImageParameterKeys.WIDTHHTML);

            if (!outputHeightWidth)
            {
                htmlParams.Remove(ImageParameterKeys.WIDTHHTML);
                htmlParams.Remove(ImageParameterKeys.HEIGHTHTML);
            }

            var builder = new UrlBuilder(image.Src);



            foreach (var key in urlParams.Keys)
            {
                builder.AddToQueryString(key, urlParams[key]);
            }

            string mediaUrl = builder.ToString();

#if (SC80 || SC75)
            mediaUrl = ProtectMediaUrl(mediaUrl);
#endif
            return(ImageTagFormat.Formatted(mediaUrl, Utilities.ConvertAttributes(htmlParams, QuotationMark), QuotationMark));
        }
コード例 #22
0
        public void 繞行SafeDictionary操作集合_不同執行緒同時對SafeDictionary新增與刪除元素_不應擲出例外()
        {
            var safeDictionary = new SafeDictionary <int, int>
            {
                { 1, 3 },
                { 2, 8 },
                { 3, 9 }
            };

            Task.Run(() =>
            {
                while (true)
                {
                    safeDictionary.Add(0, 1);
                    safeDictionary.Add(5, 7);
                    safeDictionary.Add(2, 3);
                }
            });

            Task.Run(() =>
            {
                while (true)
                {
                    ((ICollection <KeyValuePair <int, int> >)safeDictionary).Add(new KeyValuePair <int, int>(6, 1));
                    ((ICollection <KeyValuePair <int, int> >)safeDictionary).Add(new KeyValuePair <int, int>(7, 10));
                    ((ICollection <KeyValuePair <int, int> >)safeDictionary).Add(new KeyValuePair <int, int>(8, 4));
                }
            });

            Task.Run(() =>
            {
                while (true)
                {
                    ((ICollection <KeyValuePair <int, int> >)safeDictionary).Remove(new KeyValuePair <int, int>(6, 1));
                    ((ICollection <KeyValuePair <int, int> >)safeDictionary).Remove(new KeyValuePair <int, int>(7, 10));
                    ((ICollection <KeyValuePair <int, int> >)safeDictionary).Remove(new KeyValuePair <int, int>(8, 4));
                }
            });

            Task.Run(() =>
            {
                while (true)
                {
                    safeDictionary.Remove(2);
                    safeDictionary.Remove(5);
                    safeDictionary.Remove(0);
                }
            });

            Task.Run(() =>
            {
                while (true)
                {
                    safeDictionary.Clear();
                }
            });

            var    iterateKeyValuePairs = IterateDictionary(safeDictionary);
            var    iterateKeys          = IterateCollection(safeDictionary.Keys);
            var    iterateValues        = IterateCollection(safeDictionary.Values);
            Action action = () => Task.WaitAll(iterateKeys, iterateValues, iterateKeyValuePairs);

            action.Should().NotThrow();
        }
コード例 #23
0
 /// <summary>
 /// 任务添加
 /// </summary>
 /// <param name="iQuestID"></param>
 public void Add(ulong iQuestID)
 {
     m_Quests.Add(iQuestID, new WowObjectQuest(iQuestID));
 }
コード例 #24
0
 /// <summary>
 /// 添加客户端到集合
 /// </summary>
 internal void InternalAddNetState(NetState netState)
 {
     m_NetStates.Add(netState, netState);
 }
コード例 #25
0
        /// <summary>
        ///   Get Items to be loaded when the Control is loaded on the item
        /// </summary>
        /// <param name="current">
        ///   The current.
        /// </param>
        /// <returns>
        ///   Array of Item
        /// </returns>
        protected override Item[] GetItems(Item current)
        {
            Assert.ArgumentNotNull(current, "current");
            NameValueCollection values = StringUtil.GetNameValues(this.Source, '=', '&');
            var refinements            = new SafeDictionary <string>();

            if (values["FieldsFilter"] != null)
            {
                NameValueCollection splittedFields = StringUtil.GetNameValues(values["FieldsFilter"], ':', ',');
                foreach (string key in splittedFields.Keys)
                {
                    refinements.Add(key, splittedFields[key]);
                }
            }

            string locationFilter = values["StartSearchLocation"];

            locationFilter = this.MakeFilterQuerable(locationFilter);

            string templateFilter = values["TemplateFilter"];

            templateFilter = this.MakeTemplateFilterQuerable(templateFilter);

            string pageSize    = values["PageSize"];
            var    searchParam = new DateRangeSearchParam
            {
                Refinements = refinements,
                LocationIds =
                    locationFilter.IsNullOrEmpty()
                                ? Sitecore.Context.ContentDatabase.GetItem(this.ItemID)
                    .GetParentBucketItemOrRootOrSelf()
                    .ID.ToString()
                                : locationFilter,
                TemplateIds   = templateFilter,
                FullTextQuery = values["FullTextQuery"],
                Language      = values["Language"],
                PageSize      = pageSize.IsEmpty() ? 10 : int.Parse(pageSize),
                PageNumber    = this.pageNumber,
                SortByField   = values["SortField"],
                SortDirection = values["SortDirection"]
            };

            this.filter = "&location="
                          + (locationFilter.IsNullOrEmpty()
                         ? Sitecore.Context.ContentDatabase.GetItem(this.ItemID)
                             .GetParentBucketItemOrRootOrSelf()
                             .ID.ToString()
                         : locationFilter) + "&filterText=" + values["FullTextQuery"] + "&language="
                          + values["Language"] + "&pageSize=" + (pageSize.IsEmpty() ? 10 : int.Parse(pageSize)) + "&sort="
                          + values["SortField"];

            if (values["TemplateFilter"].IsNotNull())
            {
                this.filter += "&template=" + templateFilter;
            }

            using (var searcher = new IndexSearcher(Constants.Index.Name))
            {
                KeyValuePair <int, List <SitecoreItem> > keyValuePair = searcher.GetItems(searchParam);
                List <SitecoreItem> items = keyValuePair.Value;
                this.pageNumber = keyValuePair.Key / searchParam.PageSize;
                if (this.pageNumber <= 0)
                {
                    this.pageNumber = 1;
                }

                return(items.Select(sitecoreItem => sitecoreItem.GetItem()).Where(i => i != null).ToArray());
            }
        }
コード例 #26
0
        public static SafeDictionary<string> GetTagRefinements(List<SearchStringModel> currentSearchString)
        {
            var refinements = new SafeDictionary<string>();
            var tagsList = new List<string>();
            var searchStringModels = SearchHelper.GetTags(currentSearchString);

            if (searchStringModels.Count > 0)
            {
                foreach (var ss in searchStringModels)
                {
                    var query = ss.Value;
                    if (query.Contains("tagid="))
                    {
                        query = query.Split('|')[1].Replace("tagid=", string.Empty);
                    }
                    string result = "";
                    var db = Context.ContentDatabase ?? Context.Database;
                    if (ID.IsID(query))
                    {
                        Item tagItem = db.GetItem(query);
                        if (tagItem != null)
                        {
                            result = db.GetItem(query).ID.ToShortID().ToString();
                        }
                    }
                    else
                    {
                        Item tagParentItem = ((ReferenceField)ItemBucket.Kernel.Util.Constants.SettingsItem.Fields["Tag Parent"]).TargetItem;
                        if (tagParentItem != null)
                        {
                            Item tagItem = tagParentItem.Axes.GetChild(query);
                            if (tagItem != null)
                            {
                                result = tagItem.ID.ToShortID().ToString();
                            }
                        }
                    }
                    if (!String.IsNullOrEmpty(result))
                    {
                        tagsList.Add(result);
                    }
                }
                if (tagsList.Count > 0)
                {
                    string refinementValue = "(" + tagsList[0];
                    tagsList.RemoveAt(0);
                    foreach (string part in tagsList)
                    {
                        refinementValue += " AND " + part;
                    }
                    refinementValue += ")";
                    string tagFieldName = ItemBucket.Kernel.Util.Constants.SettingsItem.Fields["Tag FieldName"].Value;
                    refinements.Add(tagFieldName, refinementValue);
                }
            }
            return refinements;
        }
コード例 #27
0
ファイル: MasterPageBase.cs プロジェクト: pczy/Pub.Class
        /// <summary>
        /// 取所有语言
        /// </summary>
        /// <returns></returns>
        private ISafeDictionary<string, string> GetLang() {
            if (lang.IsNullEmpty()) Msg.WriteEnd("语言未设置!");
            string path = "".GetMapPath() + "\\lang\\{0}.lang".FormatWith(lang);
            if (!FileDirectory.FileExists(path)) Msg.WriteEnd("语言文件{0}.lang不存在!".FormatWith(lang));

            string lineText = string.Empty; ISafeDictionary<string, string> list = new SafeDictionary<string, string>();
            using (StreamReader reader = new StreamReader(path, System.Text.Encoding.UTF8)) {
                while ((lineText = reader.ReadLine()).IsNotNull()) {
                    int len = lineText.IndexOf('=');
                    if (lineText.IsNullEmpty() || len == -1) continue;
                    string key = lineText.Substring(0, len).Trim();
                    string value = lineText.Substring(len + 1).Trim();
                    if (!list.ContainsKey(key)) list.Add(key, value); else list[key] = value;
                }
            }
            return list;
        }
コード例 #28
0
    public static void GetLevelSevenDictionary(Level currentLevel)
    {
        currentLevel.LevelContainsEmpty = false;
        Dictionary <(int, int), List <Block> > dict = currentLevel.CurrentMap.PointBlockPairs;

        Tools.AddBorder(dict);

        // bone text
        SafeDictionary.Add(dict, (10, 1), new List <Block> {
            new Block.ThingText.TextBone()
        });

        // is text
        SafeDictionary.Add(dict, (11, 1), new List <Block> {
            new Block.SpecialText.TextIs()
        });

        // kill text
        SafeDictionary.Add(dict, (12, 1), new List <Block> {
            new Block.SpecialText.TextKill()
        });


        // 3x3 walls

        // top left
        Tools.Add3x3FakeWallBorder(dict, (3, 3), true);

        // mid left
        for (int i = 1; i < 3; i += 1)
        {
            SafeDictionary.Add(dict, (i, 7), new List <Block> {
                new Block.Thing.FakeWall()
            });
            SafeDictionary.Add(dict, (i, 9), new List <Block> {
                new Block.Thing.FakeWall()
            });
        }
        SafeDictionary.Add(dict, (2, 8), new List <Block> {
            new Block.Thing.FakeWall()
        });
        SafeDictionary.Add(dict, (1, 8), new List <Block> {
            new Block.Thing.Wall()
        });

        // baba in center
        Tools.Add3x3FakeWallBorder(dict, (7, 8), false);
        SafeDictionary.Add(dict, (9, 8), new List <Block> {
            new Block.Thing.Baba()
        });

        // best in center
        Tools.Add3x3FakeWallBorder(dict, (2, 13), false);
        SafeDictionary.Add(dict, (14, 3), new List <Block> {
            new Block.ThingText.TextBest()
        });

        // bottom left
        Tools.Add3x3FakeWallBorder(dict, (15, 1), true);

        // baba text
        SafeDictionary.Add(dict, (4, 12), new List <Block> {
            new Block.ThingText.TextBaba()
        });

        // is text
        SafeDictionary.Add(dict, (4, 13), new List <Block> {
            new Block.SpecialText.TextIs()
        });

        // you text
        SafeDictionary.Add(dict, (4, 14), new List <Block> {
            new Block.SpecialText.TextYou()
        });

        // keke text
        SafeDictionary.Add(dict, (8, 17), new List <Block> {
            new Block.ThingText.TextKeke()
        });

        // is text
        SafeDictionary.Add(dict, (9, 17), new List <Block> {
            new Block.SpecialText.TextIs()
        });

        // move text
        SafeDictionary.Add(dict, (10, 17), new List <Block> {
            new Block.SpecialText.TextMove()
        });

        // bone thing
        for (int i = 12; i < 19; i += 1)
        {
            if (i != 15)
            {
                SafeDictionary.Add(dict, (i, 10), new List <Block> {
                    new Block.Thing.Bone()
                });
            }
        }

        for (int i = 11; i < 19; i += 1)
        {
            SafeDictionary.Add(dict, (12, i), new List <Block> {
                new Block.Thing.Bone()
            });
        }

        // grass
        for (int i = 11; i < 19; i += 1)
        {
            for (int j = 13; j < 19; j += 1)
            {
                if (!((i == 12 && j == 15) || (i == 14 && j == 16)))
                {
                    SafeDictionary.Add(dict, (j, i), new List <Block> {
                        new Block.Thing.Grass()
                    });
                }
            }
        }

        // win text
        SafeDictionary.Add(dict, (15, 10), new List <Block> {
            new Block.SpecialText.TextWin()
        });

        // wall thing
        SafeDictionary.Add(dict, (15, 12), new List <Block> {
            new Block.Thing.Wall()
        });

        // keke thing
        Block keke = new Block.Thing.Keke();

        keke.Facing = "left";
        SafeDictionary.Add(dict, (16, 14), new List <Block> {
            keke
        });

        // wall text
        SafeDictionary.Add(dict, (18, 2), new List <Block> {
            new Block.ThingText.TextWall()
        });

        // is text
        SafeDictionary.Add(dict, (18, 3), new List <Block> {
            new Block.SpecialText.TextIs()
        });

        // stop text
        SafeDictionary.Add(dict, (18, 4), new List <Block> {
            new Block.SpecialText.TextStop()
        });
    }
コード例 #29
0
        public static DateRangeSearchParam GetSearchSettings(List<SearchStringModel> currentSearchString, string locationFilter)
        {
            var startDate = DateTime.Now;
            var endDate = DateTime.Now.AddDays(1);
            var locationSearch = locationFilter;
            var refinements = new SafeDictionary<string>();
            refinements = GetTagRefinements(currentSearchString);

            var author = SearchHelper.GetAuthor(currentSearchString);

            var languages = SearchHelper.GetLanguages(currentSearchString);
            if (languages.Length > 0)
            {
                refinements.Add("_language", languages);
            }

            var references = SearchHelper.GetReferences(currentSearchString);

            var custom = SearchHelper.GetCustom(currentSearchString);
            if (custom.Length > 0)
            {
                var customSearch = custom.Split('|');
                if (customSearch.Length > 0)
                {
                    try
                    {
                        refinements.Add(customSearch[0], customSearch[1]);
                    }
                    catch (Exception exc)
                    {
                        Log.Error("Could not parse the custom search query", exc);
                    }
                }
            }

            var search = SearchHelper.GetField(currentSearchString);
            if (search.Length > 0)
            {
                var customSearch = search;
                refinements.Add(customSearch, SearchHelper.GetText(currentSearchString));
            }

            var fileTypes = SearchHelper.GetFileTypes(currentSearchString);
            if (fileTypes.Length > 0)
            {
                refinements.Add("extension", SearchHelper.GetFileTypes(currentSearchString));
            }

            var s = SearchHelper.GetSite(currentSearchString);
            if (s.Length > 0)
            {
                SiteContext siteContext = SiteContextFactory.GetSiteContext(SiteManager.GetSite(s).Name);
                var db = Context.ContentDatabase ?? Context.Database;
                var startItemId = db.GetItem(siteContext.StartPath);
                locationSearch = startItemId.ID.ToString();
            }

            var culture = CultureInfo.CreateSpecificCulture("en-US");
            var startFlag = true;
            var endFlag = true;
            if (SearchHelper.GetStartDate(currentSearchString).Any())
            {
                if (!DateTime.TryParse(SearchHelper.GetStartDate(currentSearchString), culture, DateTimeStyles.None, out startDate))
                {
                    startDate = DateTime.Now;
                }

                startFlag = false;
            }

            if (SearchHelper.GetEndDate(currentSearchString).Any())
            {
                if (!DateTime.TryParse(SearchHelper.GetEndDate(currentSearchString), culture, DateTimeStyles.None, out endDate))
                {
                    endDate = DateTime.Now.AddDays(1);
                }

                endFlag = false;
            }

            var location = SearchHelper.GetLocation(currentSearchString, locationSearch);

            var rangeSearch = new DateRangeSearchParam
            {
                ID = SearchHelper.GetID(currentSearchString).IsEmpty() ? SearchHelper.GetRecent(currentSearchString) : SearchHelper.GetID(currentSearchString),
                ShowAllVersions = false,
                FullTextQuery = SearchHelper.GetText(currentSearchString),
                Refinements = refinements,
                RelatedIds = references.Any() ? references : string.Empty,
                TemplateIds = SearchHelper.GetTemplates(currentSearchString),
                LocationIds = location,
                Language = languages,
                Author = author == string.Empty ? string.Empty : author,
                ItemName = SearchHelper.GetItemName(currentSearchString)
            };

            if (!startFlag || !endFlag)
            {
                rangeSearch.Ranges = new List<DateRangeSearchParam.DateRangeField>
                                             {
                                                 new DateRangeSearchParam.DateRangeField(SearchFieldIDs.CreatedDate, startDate, endDate)
                                                     {
                                                         InclusiveStart = true, InclusiveEnd = true
                                                     }
                                             };
            }
            return rangeSearch;
        }
コード例 #30
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {

                var indexOfRo = System.Web.HttpContext.Current.Request.UrlReferrer.Query.IndexOf("ro=");
                var requestString = new NameValueCollection();
                if (indexOfRo > 0)
                {
                    requestString =
                        System.Web.HttpUtility.ParseQueryString(
                            System.Web.HttpContext.Current.Request.UrlReferrer.Query.Substring(indexOfRo));
                    requestString = StringUtil.GetNameValues(requestString[0], '=', '&');

                }

                else if (System.Web.HttpContext.Current.Request.UrlReferrer.Query.Contains("xmlcontrol=AddFromTemplate") || System.Web.HttpContext.Current.Request.UrlReferrer.Query.Contains("xmlcontrol=SetMasters") || System.Web.HttpContext.Current.Request.UrlReferrer.Query.Contains("xmlcontrol=SetBaseTemplates"))
                {
                    requestString["StartSearchLocation"] = "{3C1715FE-6A13-4FCF-845F-DE308BA9741D}";
                    requestString["TemplateFilter"] = "{AB86861A-6030-46C5-B394-E8F99E8B87DB}";
                }

                else if (System.Web.HttpContext.Current.Request.UrlReferrer.Query.Contains("xmlcontrol=CopyDeviceTo"))
                {
                    requestString["StartSearchLocation"] = "{11111111-1111-1111-1111-111111111111}";

                }

                else if (System.Web.HttpContext.Current.Request.UrlReferrer.Query.Contains("xmlcontrol=Sitecore.Shell.Applications.Dialogs.SelectItem"))
                {
                    requestString["StartSearchLocation"] = Sitecore.ItemIDs.RootID.ToString();
                }

                var refinements = new SafeDictionary<string>();
                 if (requestString["FieldsFilter"] != null)
                 {
                     var splittedFields = StringUtil.GetNameValues(requestString["FieldsFilter"], ':', ',');
                     foreach (string key in splittedFields.Keys)
                     {
                         refinements.Add(key, splittedFields[key]);
                     }
                 }

                 else if (System.Web.HttpContext.Current.Request.UrlReferrer.AbsolutePath == "/sitecore/shell/sitecore/content/Applications/Workbox")
                 {
                     requestString["Custom"] = "__workflow\\ state|*";
                     requestString["StartSearchLocation"] = Sitecore.ItemIDs.RootID.ToString();
                     thisIsWorkBox = "true";
                 }

                 else if (System.Web.HttpContext.Current.Request.UrlReferrer.AbsolutePath == "/sitecore/shell/Applications/Templates/Change%20template.aspx")
                 {
                     requestString["StartSearchLocation"] = "{3C1715FE-6A13-4FCF-845F-DE308BA9741D}";
                     requestString["TemplateFilter"] = "{AB86861A-6030-46C5-B394-E8F99E8B87DB}";
                 }

                 var locationFilter = requestString["StartSearchLocation"];
                 if (locationFilter.IsNotNull())
                 {
                     if (locationFilter.StartsWith("query:"))
                     {
                         locationFilter = locationFilter.Replace("->", "=");
                         Item itemArray;
                         string query = locationFilter.Substring(6);
                         bool flag = query.StartsWith("fast:");
                         Opcode opcode = null;
                         if (!flag)
                         {
                             QueryParser.Parse(query);
                         }
                         if (flag || (opcode is Root))
                         {
                             itemArray =
                                 Sitecore.Context.Item.Database.SelectSingleItem(query);
                         }
                         else
                         {
                             itemArray = Sitecore.Context.Item.Axes.SelectSingleItem(query);
                         }

                         locationFilter = itemArray.ID.ToString();
                     }
                 }

                 var pageSize = requestString["PageSize"];

                 var locationFinal = (locationFilter.IsNullOrEmpty() ? Sitecore.Context.ContentDatabase.GetItem(requestString["id"]).GetParentBucketItemOrRootOrSelf().ID.ToString(): locationFilter);
                 _ID = locationFinal;
                 Filter = "location=" +
                          locationFinal +

                          "&text=" + requestString["FullTextQuery"] +
                          "&language=" + requestString["Language"] +
                          "&pageSize=" + (pageSize.IsEmpty() ? 20 : Int32.Parse(pageSize)) +
                          "&custom=" + requestString["Custom"] +
                          "&sort=" + requestString["SortField"];

                 if (requestString["TemplateFilter"].IsNotNull())
                 {

                     Filter += "&template=" + requestString["TemplateFilter"];
                 }

            }
            catch (Exception exc)
            {

                Log.Error("Failed to Resolve Field Value", exc, this);
            }
            finally
            {
                if (!Id.IsNullOrEmpty())
                {
                    var item = Sitecore.Context.ContentDatabase.GetItem(Id);
                    Page.Response.Write(
                        "<style>.token-input-list-facebook.boxme {background-image: url(/temp/IconCache/" + (item.IsNotNull() ? item.Appearance.Icon : "") +
                        ");background-size:16px 16px;background-position: 2% 50%;background-repeat: no-repeat;}</style>");
                }
                var script = "<script type='text/javascript' language='javascript'>var filterForSearch='" + Filter +
                             "';var workBox='" + thisIsWorkBox +"';</script>";
                Page.Response.Write(script);
            }
        }
コード例 #31
0
ファイル: Arena.cs プロジェクト: faresali/co-pserver
        public static void YesterdaySort()
        {
            SortedDictionary<ulong, SortEntry<uint, ArenaStatistic>> sortDictionary = new SortedDictionary<ulong, SortEntry<uint, ArenaStatistic>>();
            foreach (ArenaStatistic info in ArenaStatistics.Values)
            {
                if (sortDictionary.ContainsKey(info.LastSeasonArenaPoints))
                {
                    SortEntry<uint, ArenaStatistic> entry = sortDictionary[info.LastSeasonArenaPoints];
                    entry.Values.Add(info.EntityID, info);
                }
                else
                {
                    SortEntry<uint, ArenaStatistic> entry = new SortEntry<uint, ArenaStatistic>();
                    entry.Values = new Dictionary<uint, ArenaStatistic>();
                    entry.Values.Add(info.EntityID, info);
                    sortDictionary.Add(info.LastSeasonArenaPoints, entry);
                }
            }
            SafeDictionary<uint, ArenaStatistic> toReplace = new SafeDictionary<uint, ArenaStatistic>(10000);

            uint Place = 1;
            foreach (KeyValuePair<ulong, SortEntry<uint, ArenaStatistic>> entries in sortDictionary.Reverse())
            {
                foreach (uint e in entries.Value.Values.Keys)
                {
                    if (ArenaStatistics[e].YesterdayTotal != 0)
                    {
                        ArenaStatistics[e].LastSeasonRank = Place;
                        Place++;
                        toReplace.Add(e, ArenaStatistics[e]);
                    }
                }
            }

            YesterdayArenaStatistics = toReplace;
        }
コード例 #32
0
        /// <summary>
        /// Makes the editable.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="field">The field.</param>
        /// <param name="standardOutput">The standard output.</param>
        /// <param name="model">The model.</param>
        /// <param name="parameters">The parameters.</param>
        /// <returns>System.String.</returns>
        /// <exception cref="Glass.Mapper.MapperException">
        /// To many parameters in linq expression {0}.Formatted(field.Body)
        /// or
        /// Expression doesn't evaluate to a member {0}.Formatted(field.Body)
        /// or
        /// Page editting error. Could not find property {0} on type {1}.Formatted(memberExpression.Member.Name, config.Type.FullName)
        /// or
        /// Page editting error. Could not find data handler for property {2} {0}.{1}.Formatted(
        ///                         prop.DeclaringType, prop.Name, prop.MemberType)
        /// </exception>
        /// <exception cref="System.NullReferenceException">Context cannot be null</exception>
        private RenderingResult MakeEditable <T>(
            Expression <Func <T, object> > field,
            Expression <Func <T, string> > standardOutput,
            T model,
            object parameters,
            Context context,
            Database database,
            TextWriter writer)
        {
            string firstPart = string.Empty;
            string lastPart  = string.Empty;

            try
            {
                if (field == null)
                {
                    throw new NullReferenceException("No field set");
                }
                if (model == null)
                {
                    throw new NullReferenceException("No model set");
                }

                string parametersStringTemp = string.Empty;

                SafeDictionary <string> dictionary = new SafeDictionary <string>();

                if (parameters == null)
                {
                    parametersStringTemp = string.Empty;
                }
                else if (parameters is string)
                {
                    parametersStringTemp = parameters as string;
                    dictionary           = WebUtil.ParseQueryString(parametersStringTemp ?? string.Empty);
                }
                else if (parameters is NameValueCollection)
                {
                    var collection = (NameValueCollection)parameters;
                    foreach (var key in collection.AllKeys)
                    {
                        dictionary.Add(key, collection[key]);
                    }
                }
                else
                {
                    var collection = Utilities.GetPropertiesCollection(parameters, true);
                    foreach (var key in collection.AllKeys)
                    {
                        dictionary.Add(key, collection[key]);
                    }
                }


                if (IsInEditingMode)
                {
                    MemberExpression memberExpression;
                    var finalTarget = Mapper.Utilities.GetTargetObjectOfLamba(field, model, out memberExpression);
                    var config      = Mapper.Utilities.GetTypeConfig <T, SitecoreTypeConfiguration>(field, context, model);
                    var dataHandler = Mapper.Utilities.GetGlassProperty <T, SitecoreTypeConfiguration>(field, context, model);

                    var scClass = config.ResolveItem(finalTarget, database);

                    using (new ContextItemSwitcher(scClass))
                    {
                        RenderFieldArgs renderFieldArgs = new RenderFieldArgs();
                        renderFieldArgs.Item = scClass;

                        var fieldConfig = (SitecoreFieldConfiguration)dataHandler;
                        if (fieldConfig.FieldId != (ID)null && fieldConfig.FieldId != ID.Null)
                        {
                            renderFieldArgs.FieldName = fieldConfig.FieldId.ToString();
                        }
                        else
                        {
                            renderFieldArgs.FieldName = fieldConfig.FieldName;
                        }

                        renderFieldArgs.Parameters     = dictionary;
                        renderFieldArgs.DisableWebEdit = false;

                        CorePipeline.Run("renderField", (PipelineArgs)renderFieldArgs);

                        firstPart = renderFieldArgs.Result.FirstPart;
                        lastPart  = renderFieldArgs.Result.LastPart;
                    }
                }
                else
                {
                    if (standardOutput != null)
                    {
                        firstPart = GetCompiled(standardOutput)(model).ToString();
                    }
                    else
                    {
                        object target = (GetCompiled(field)(model) ?? string.Empty);

                        if (ImageType.IsInstanceOfType(target))
                        {
                            var image = target as Image;
                            firstPart = RenderImage(image, dictionary);
                        }
                        else if (LinkType.IsInstanceOfType(target))
                        {
                            var link       = target as Link;
                            var sb         = new StringBuilder();
                            var linkWriter = new StringWriter(sb);
                            var result     = BeginRenderLink(link, dictionary, null, linkWriter);
                            result.Dispose();
                            linkWriter.Flush();
                            linkWriter.Close();

                            firstPart = sb.ToString();
                        }
                        else
                        {
                            firstPart = target.ToString();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                firstPart = "<p>{0}</p><pre>{1}</pre>".Formatted(ex.Message, ex.StackTrace);
                Sitecore.Diagnostics.Log.Error("Failed to render field", ex, typeof(IGlassHtml));
            }

            return(new RenderingResult(writer, firstPart, lastPart));


            //return field.Compile().Invoke(model).ToString();
        }
コード例 #33
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                var indexOfRo     = System.Web.HttpContext.Current.Request.UrlReferrer.Query.IndexOf("ro=");
                var requestString = new NameValueCollection();
                if (indexOfRo > 0)
                {
                    requestString =
                        System.Web.HttpUtility.ParseQueryString(
                            System.Web.HttpContext.Current.Request.UrlReferrer.Query.Substring(indexOfRo));
                    requestString = StringUtil.GetNameValues(requestString[0], '=', '&');
                }

                else if (System.Web.HttpContext.Current.Request.UrlReferrer.Query.Contains("xmlcontrol=AddFromTemplate") || System.Web.HttpContext.Current.Request.UrlReferrer.Query.Contains("xmlcontrol=SetMasters") || System.Web.HttpContext.Current.Request.UrlReferrer.Query.Contains("xmlcontrol=SetBaseTemplates"))
                {
                    requestString["StartSearchLocation"] = "{3C1715FE-6A13-4FCF-845F-DE308BA9741D}";
                    requestString["TemplateFilter"]      = "{AB86861A-6030-46C5-B394-E8F99E8B87DB}";
                }

                else if (System.Web.HttpContext.Current.Request.UrlReferrer.Query.Contains("xmlcontrol=CopyDeviceTo"))
                {
                    requestString["StartSearchLocation"] = "{11111111-1111-1111-1111-111111111111}";
                }

                else if (System.Web.HttpContext.Current.Request.UrlReferrer.Query.Contains("xmlcontrol=Sitecore.Shell.Applications.Dialogs.SelectItem"))
                {
                    requestString["StartSearchLocation"] = Sitecore.ItemIDs.RootID.ToString();
                }

                var refinements = new SafeDictionary <string>();
                if (requestString["FieldsFilter"] != null)
                {
                    var splittedFields = StringUtil.GetNameValues(requestString["FieldsFilter"], ':', ',');
                    foreach (string key in splittedFields.Keys)
                    {
                        refinements.Add(key, splittedFields[key]);
                    }
                }


                else if (System.Web.HttpContext.Current.Request.UrlReferrer.AbsolutePath == "/sitecore/shell/sitecore/content/Applications/Workbox")
                {
                    requestString["Custom"] = "__workflow\\ state|*";
                    requestString["StartSearchLocation"] = Sitecore.ItemIDs.RootID.ToString();
                    thisIsWorkBox = "true";
                }

                else if (System.Web.HttpContext.Current.Request.UrlReferrer.AbsolutePath == "/sitecore/shell/Applications/Templates/Change%20template.aspx")
                {
                    requestString["StartSearchLocation"] = "{3C1715FE-6A13-4FCF-845F-DE308BA9741D}";
                    requestString["TemplateFilter"]      = "{AB86861A-6030-46C5-B394-E8F99E8B87DB}";
                }

                var locationFilter = requestString["StartSearchLocation"];
                if (locationFilter.IsNotNull())
                {
                    if (locationFilter.StartsWith("query:"))
                    {
                        locationFilter = locationFilter.Replace("->", "=");
                        Item   itemArray;
                        string query  = locationFilter.Substring(6);
                        bool   flag   = query.StartsWith("fast:");
                        Opcode opcode = null;
                        if (!flag)
                        {
                            QueryParser.Parse(query);
                        }
                        if (flag || (opcode is Root))
                        {
                            itemArray =
                                Sitecore.Context.Item.Database.SelectSingleItem(query);
                        }
                        else
                        {
                            itemArray = Sitecore.Context.Item.Axes.SelectSingleItem(query);
                        }

                        locationFilter = itemArray.ID.ToString();
                    }
                }

                var pageSize = requestString["PageSize"];

                var locationFinal = (locationFilter.IsNullOrEmpty() ? Sitecore.Context.ContentDatabase.GetItem(requestString["id"]).GetParentBucketItemOrRootOrSelf().ID.ToString(): locationFilter);
                _ID    = locationFinal;
                Filter = "location=" +
                         locationFinal +

                         "&text=" + requestString["FullTextQuery"] +
                         "&language=" + requestString["Language"] +
                         "&pageSize=" + (pageSize.IsEmpty() ? 20 : Int32.Parse(pageSize)) +
                         "&custom=" + requestString["Custom"] +
                         "&sort=" + requestString["SortField"];

                if (requestString["TemplateFilter"].IsNotNull())
                {
                    Filter += "&template=" + requestString["TemplateFilter"];
                }
            }
            catch (Exception exc)
            {
                Log.Error("Failed to Resolve Field Value", exc, this);
            }
            finally
            {
                if (!Id.IsNullOrEmpty())
                {
                    var item = Sitecore.Context.ContentDatabase.GetItem(Id);
                    Page.Response.Write(
                        "<style>.token-input-list-facebook.boxme {background-image: url(/temp/IconCache/" + (item.IsNotNull() ? item.Appearance.Icon : "") +
                        ");background-size:16px 16px;background-position: 2% 50%;background-repeat: no-repeat;}</style>");
                }
                var script = "<script type='text/javascript' language='javascript'>var filterForSearch='" + Filter +
                             "';var workBox='" + thisIsWorkBox + "';</script>";
                Page.Response.Write(script);
            }
        }
コード例 #34
0
        /// <summary>
        /// Makes the editable.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="field">The field.</param>
        /// <param name="standardOutput">The standard output.</param>
        /// <param name="model">The model.</param>
        /// <param name="parameters">The parameters.</param>
        /// <returns>System.String.</returns>
        /// <exception cref="Glass.Mapper.MapperException">
        /// To many parameters in linq expression {0}.Formatted(field.Body)
        /// or
        /// Expression doesn't evaluate to a member {0}.Formatted(field.Body)
        /// or
        /// Page editting error. Could not find property {0} on type {1}.Formatted(memberExpression.Member.Name, config.Type.FullName)
        /// or
        /// Page editting error. Could not find data handler for property {2} {0}.{1}.Formatted(
        ///                         prop.DeclaringType, prop.Name, prop.MemberType)
        /// </exception>
        /// <exception cref="System.NullReferenceException">Context cannot be null</exception>
        private RenderingResult MakeEditable <T>(
            Expression <Func <T, object> > field,
            Expression <Func <T, string> > standardOutput,
            T model,
            object parameters,
            Context context, Database database,
            TextWriter writer)
        {
            string firstPart = string.Empty;
            string lastPart  = string.Empty;

            try
            {
                if (field == null)
                {
                    throw new NullReferenceException("No field set");
                }
                if (model == null)
                {
                    throw new NullReferenceException("No model set");
                }

                string parametersStringTemp = string.Empty;

                SafeDictionary <string> dictionary = new SafeDictionary <string>();

                if (parameters == null)
                {
                    parametersStringTemp = string.Empty;
                }
                else if (parameters is string)
                {
                    parametersStringTemp = parameters as string;
                    dictionary           = WebUtil.ParseQueryString(parametersStringTemp ?? string.Empty);
                }
                else if (parameters is NameValueCollection)
                {
                    var collection = (NameValueCollection)parameters;
                    foreach (var key in collection.AllKeys)
                    {
                        dictionary.Add(key, collection[key]);
                    }
                }
                else
                {
                    var collection = Utilities.GetPropertiesCollection(parameters, true);
                    foreach (var key in collection.AllKeys)
                    {
                        dictionary.Add(key, collection[key]);
                    }
                }


                if (IsInEditingMode)
                {
                    if (field.Parameters.Count > 1)
                    {
                        throw new MapperException("To many parameters in linq expression {0}".Formatted(field.Body));
                    }

                    MemberExpression memberExpression;

                    if (field.Body is UnaryExpression)
                    {
                        memberExpression = ((UnaryExpression)field.Body).Operand as MemberExpression;
                    }
                    else if (!(field.Body is MemberExpression))
                    {
                        throw new MapperException("Expression doesn't evaluate to a member {0}".Formatted(field.Body));
                    }
                    else
                    {
                        memberExpression = (MemberExpression)field.Body;
                    }



                    //we have to deconstruct the lambda expression to find the
                    //correct model object
                    //For example if we have the lambda expression x =>x.Children.First().Content
                    //we have to evaluate what the first Child object is, then evaluate the field to edit from there.

                    //this contains the expression that will evaluate to the object containing the property
                    var objectExpression = memberExpression.Expression;

                    var finalTarget =
                        Expression.Lambda(objectExpression, field.Parameters).Compile().DynamicInvoke(model);

                    var site = global::Sitecore.Context.Site;

                    if (context == null)
                    {
                        throw new NullReferenceException("Context cannot be null");
                    }

                    var config = context.GetTypeConfiguration <SitecoreTypeConfiguration>(finalTarget);



                    var scClass = config.ResolveItem(finalTarget, database);

                    //lambda expression does not always return expected memberinfo when inheriting
                    //c.f. http://stackoverflow.com/questions/6658669/lambda-expression-not-returning-expected-memberinfo
                    var prop = config.Type.GetProperty(memberExpression.Member.Name);

                    //interfaces don't deal with inherited properties well
                    if (prop == null && config.Type.IsInterface)
                    {
                        Func <Type, PropertyInfo> interfaceCheck = null;
                        interfaceCheck = (inter) =>
                        {
                            var interfaces = inter.GetInterfaces();
                            var properties =
                                interfaces.Select(x => x.GetProperty(memberExpression.Member.Name)).Where(
                                    x => x != null);
                            if (properties.Any())
                            {
                                return(properties.First());
                            }
                            else
                            {
                                return(interfaces.Select(x => interfaceCheck(x)).FirstOrDefault(x => x != null));
                            }
                        };
                        prop = interfaceCheck(config.Type);
                    }

                    if (prop != null && prop.DeclaringType != prop.ReflectedType)
                    {
                        //properties mapped in data handlers are based on declaring type when field is inherited, make sure we match
                        prop = prop.DeclaringType.GetProperty(prop.Name);
                    }

                    if (prop == null)
                    {
                        throw new MapperException(
                                  "Page editting error. Could not find property {0} on type {1}".Formatted(
                                      memberExpression.Member.Name, config.Type.FullName));
                    }

                    //ME - changed this to work by name because properties on interfaces do not show up as declared types.
                    var dataHandler = config.Properties.FirstOrDefault(x => x.PropertyInfo.Name == prop.Name);
                    if (dataHandler == null)
                    {
                        throw new MapperException(
                                  "Page editing error. Could not find data handler for property {2} {0}.{1}".Formatted(
                                      prop.DeclaringType, prop.Name, prop.MemberType));
                    }



                    using (new ContextItemSwitcher(scClass))
                    {
                        RenderFieldArgs renderFieldArgs = new RenderFieldArgs();
                        renderFieldArgs.Item = scClass;

                        var fieldConfig = (SitecoreFieldConfiguration)dataHandler;
                        if (fieldConfig.FieldId != (Sitecore.Data.ID)null && fieldConfig.FieldId != ID.Null)
                        {
                            renderFieldArgs.FieldName = fieldConfig.FieldId.ToString();
                        }
                        else
                        {
                            renderFieldArgs.FieldName = fieldConfig.FieldName;
                        }

                        renderFieldArgs.Parameters     = dictionary;
                        renderFieldArgs.DisableWebEdit = false;

                        CorePipeline.Run("renderField", (PipelineArgs)renderFieldArgs);

                        firstPart = renderFieldArgs.Result.FirstPart;
                        lastPart  = renderFieldArgs.Result.LastPart;
                    }
                }
                else
                {
                    if (standardOutput != null)
                    {
                        firstPart = GetCompiled <T>(standardOutput)(model).ToString();
                    }
                    else
                    {
                        var    type   = field.Body.Type;
                        object target = (GetCompiled <T>(field)(model) ?? string.Empty);

                        if (type == ImageType)
                        {
                            var image = target as Image;
                            firstPart = RenderImage(image, dictionary);
                        }
                        else if (type == LinkType)
                        {
                            var link       = target as Link;
                            var sb         = new StringBuilder();
                            var linkWriter = new StringWriter(sb);
                            var result     = BeginRenderLink(link, dictionary, null, linkWriter);
                            result.Dispose();
                            linkWriter.Flush();
                            linkWriter.Close();

                            firstPart = sb.ToString();
                        }
                        else
                        {
                            firstPart = target.ToString();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                firstPart = "<p>{0}</p><pre>{1}</pre>".Formatted(ex.Message, ex.StackTrace);
                Sitecore.Diagnostics.Log.Error("Failed to render field", ex, typeof(IGlassHtml));
            }

            return(new RenderingResult(writer, firstPart, lastPart));


            //return field.Compile().Invoke(model).ToString();
        }
コード例 #35
0
 /// <summary>
 /// 技能添加
 /// </summary>
 /// <param name="iSpellId"></param>
 public void Add(ulong iItemId, uint iAmount)
 {
     m_Items.Add(iItemId, new WowPlayerInfoItem(iItemId, iAmount));
 }
コード例 #36
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                var indexOfRo     = System.Web.HttpContext.Current.Request.UrlReferrer.Query.IndexOf("ro=");
                var requestString =
                    System.Web.HttpUtility.ParseQueryString(
                        System.Web.HttpContext.Current.Request.UrlReferrer.Query.Substring(indexOfRo));
                requestString = StringUtil.GetNameValues(requestString[0], '=', '&');
                var refinements = new SafeDictionary <string>();
                if (requestString["FieldsFilter"] != null)
                {
                    var splittedFields = StringUtil.GetNameValues(requestString["FieldsFilter"], ':', ',');
                    foreach (string key in splittedFields.Keys)
                    {
                        refinements.Add(key, splittedFields[key]);
                    }
                }

                var locationFilter = requestString["StartSearchLocation"];
                if (locationFilter.IsNotNull())
                {
                    if (locationFilter.StartsWith("query:"))
                    {
                        locationFilter = locationFilter.Replace("->", "=");
                        Item   itemArray;
                        string query  = locationFilter.Substring(6);
                        bool   flag   = query.StartsWith("fast:");
                        Opcode opcode = null;
                        if (!flag)
                        {
                            QueryParser.Parse(query);
                        }
                        if (flag || (opcode is Root))
                        {
                            itemArray =
                                Sitecore.Context.Item.Database.SelectSingleItem(query);
                        }
                        else
                        {
                            itemArray = Sitecore.Context.Item.Axes.SelectSingleItem(query);
                        }

                        locationFilter = itemArray.ID.ToString();
                    }
                }

                var pageSize = requestString["PageSize"];

                var locationFinal = (locationFilter.IsNullOrEmpty() ? Sitecore.Context.ContentDatabase.GetItem(requestString["id"]).GetParentBucketItemOrRootOrSelf().ID.ToString(): locationFilter);
                _ID    = locationFinal;
                Filter = "location=" +
                         locationFinal +

                         "&text=" + requestString["FullTextQuery"] +
                         "&language=" + requestString["Language"] +
                         "&pageSize=" + (pageSize.IsEmpty() ? 20 : Int32.Parse(pageSize)) +

                         "&sort=" + requestString["SortField"];

                if (requestString["TemplateFilter"].IsNotNull())
                {
                    Filter += "&template=" + requestString["TemplateFilter"];
                }
            }
            catch (Exception exc)
            {
                Log.Error("Failed to Resolve Datasource", exc, this);
            }
            finally
            {
                if (!Id.IsNullOrEmpty())
                {
                    Page.Response.Write(
                        "<style>.token-input-list-facebook.boxme {background-image: url(/temp/IconCache/" +
                        Sitecore.Context.ContentDatabase.GetItem(Id).Appearance.Icon +
                        ");background-size:16px 16px;background-position: 2% 50%;background-repeat: no-repeat;}</style>");
                }
                var script = "<script type='text/javascript' language='javascript'>var filterForSearch='" + Filter +
                             "';</script>";
                Page.Response.Write(script);
            }
        }
コード例 #37
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="iSpellId"></param>
 public void Add(uint iFaction, int iStanding, byte iFlag)
 {
     m_FactionReputations.Add(iFaction, new WowFactionReputation(iFaction, iStanding, iFlag));
 }
コード例 #38
0
ファイル: ArsenalsTable.cs プロジェクト: AiiMz/PserverWork
        public static void Load(Game.ConquerStructures.Society.Guild g)
        {
            MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
            cmd.Select("guild_arsenalsdonation").Where("guild_uid", g.ID);
            MySqlReader r = new MySqlReader(cmd);
            SafeDictionary<uint, ArsenalSingle> ass = new SafeDictionary<uint, ArsenalSingle>(1000);
            while (r.Read())
            {
                ArsenalSingle s = new ArsenalSingle();
                s.D_UID = r.ReadUInt32("d_uid");
                s.Name = r.ReadString("name");
                s.UID = r.ReadUInt32("item_uid");
                s.Donation = r.ReadUInt32("item_donation");
                s.Type = (ArsenalType)r.ReadByte("item_arsenal_type");
                ass.Add(s.UID, s);
            }
            r.Close();
            foreach (ArsenalSingle s in ass.Values)
            {
                s.Item = ConquerItemTable.GetSingleItem(s.UID);
                g.Arsenal.Inscribe(s.Type, s);
            }
            ass = new SafeDictionary<uint, ArsenalSingle>(1000);
            ass = null;

            cmd = new MySqlCommand(MySqlCommandType.SELECT);
            cmd.Select("guild_arsenals").Where("guild_uid", g.ID);
            r = new MySqlReader(cmd);
            if (r.Read())
            {
                g.A_Packet.Headgear_Avaliable = r.ReadByte("head_allowed") == 1;
                g.A_Packet.Armor_Avaliable = r.ReadByte("armor_allowed") == 1;
                g.A_Packet.Weapon_Avaliable = r.ReadByte("weapon_allowed") == 1;
                g.A_Packet.Ring_Avaliable = r.ReadByte("ring_allowed") == 1;
                g.A_Packet.Boots_Avaliable = r.ReadByte("boots_allowed") == 1;
                g.A_Packet.Necklace_Avaliable = r.ReadByte("neck_allowed") == 1;
                g.A_Packet.Fan_Avaliable = r.ReadByte("fan_allowed") == 1;
                g.A_Packet.Tower_Avaliable = r.ReadByte("tower_allowed") == 1;
            }
            r.Close();
        }
コード例 #39
0
        public static DateRangeSearchParam GetBaseQuery(List<SearchStringModel> _searchQuery, string locationFilter)
        {
            var startDate = DateTime.Now;
            var endDate = DateTime.Now.AddDays(1);
            var locationSearch = locationFilter;
            var refinements = new SafeDictionary<string>();
            var searchStringModels = GetTags(_searchQuery);

            if (searchStringModels.Count > 0)
            {
                foreach (var ss in searchStringModels)
                {
                    var query = ss.Value;
                    if (query.Contains("tagid="))
                    {
                        query = query.Split('|')[1].Replace("tagid=", string.Empty);
                    }
                    var db = Context.ContentDatabase ?? Context.Database;
                    refinements.Add("_tags", db.GetItem(query).ID.ToString());
                }
            }

            var author = GetAuthor(_searchQuery);
            var languages = GetLanguages(_searchQuery);
            if (languages.Length > 0)
            {
                refinements.Add("_language", languages);
            }

            var references = GetReferences(_searchQuery);

            var custom = GetCustom(_searchQuery);
            if (custom.Length > 0)
            {
                var customSearch = custom.Split('|');
                if (customSearch.Length > 0)
                {
                    try
                    {
                        refinements.Add(customSearch[0], customSearch[1]);
                    }
                    catch (Exception exc)
                    {
                        Log.Error("Could not parse the custom search query", exc);
                    }
                }
            }

            var search = GetField(_searchQuery);
            if (search.Length > 0)
            {
                var customSearch = search;
                refinements.Add(customSearch, GetText(_searchQuery));
            }

            var fileTypes = GetFileTypes(_searchQuery);
            if (fileTypes.Length > 0)
            {
                refinements.Add("extension", GetFileTypes(_searchQuery));
            }

            var s = GetSite(_searchQuery);
            if (s.Length > 0)
            {
                var siteContext = SiteContextFactory.GetSiteContext(SiteManager.GetSite(s).Name);
                var db = Context.ContentDatabase ?? Context.Database;
                var startItemId = db.GetItem(siteContext.StartPath);
                locationSearch = startItemId.ID.ToString();
            }

            var culture = CultureInfo.CreateSpecificCulture("en-US");
            var startFlag = true;
            var endFlag = true;
            if (GetStartDate(_searchQuery).Any())
            {
                if (!DateTime.TryParse(GetStartDate(_searchQuery), culture, DateTimeStyles.None, out startDate))
                {
                    startDate = DateTime.Now;
                }

                startFlag = false;
            }

            if (GetEndDate(_searchQuery).Any())
            {
                if (!DateTime.TryParse(GetEndDate(_searchQuery), culture, DateTimeStyles.None, out endDate))
                {
                    endDate = DateTime.Now.AddDays(1);
                }

                endFlag = false;
            }

            var returnResult = new DateRangeSearchParam
            {
                ID = GetID(_searchQuery),
                ShowAllVersions = false,
                FullTextQuery = GetText(_searchQuery),
                Refinements = refinements,
                RelatedIds = references.Any() ? IdHelper.ParseId(references) : null,
                TemplateIds = GetTemplates(_searchQuery),
                LocationIds = IdHelper.ParseId(GetLocation(_searchQuery, locationFilter)),
                Language = languages,
                IsFacet = true,
                Author = author == string.Empty ? string.Empty : author,
            };
            if (!startFlag || !endFlag)
            {
                returnResult.Ranges = new List<DateRangeSearchParam.DateRangeField>
                                             {
                                                 new DateRangeSearchParam.DateRangeField(SearchFieldIDs.CreatedDate, startDate, endDate)
                                                 {
                                                     InclusiveStart = true,
                                                     InclusiveEnd = true
                                                 }
                                             };
            }

            return returnResult;
        }
コード例 #40
0
        /// <summary>
        /// Using a strongly types List of SearchStringModel, you can run a search based off a JSON String
        /// </summary>
        /// <param name="itm">
        /// The itm.
        /// </param>
        /// <param name="currentSearchString">
        /// The current Search String.
        /// </param>
        /// <param name="hitCount">
        /// The hit Count.
        /// </param>
        /// <param name="indexName">
        /// The index Name.
        /// </param>
        /// <param name="sortField">
        /// The sort Field.
        /// </param>
        /// <param name="sortDirection">
        /// The sort Direction.
        /// </param>
        /// <param name="pageSize">
        /// The page Size.
        /// </param>
        /// <param name="pageNumber">
        /// The page Number.
        /// </param>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        /// <returns>
        /// IEnumreable List of Results that have been typed to a smaller version of the Item Object
        /// </returns>
        public static IEnumerable<SitecoreItem> FullSearch(Item itm, List<SearchStringModel> currentSearchString, out int hitCount, string indexName = "itembuckets_buckets", string sortField = "", string sortDirection = "", int pageSize = 0, int pageNumber = 0, object[] parameters = null)
        {
            var startDate = DateTime.Now;
            var endDate = DateTime.Now.AddDays(1);
            var locationSearch = LocationFilter;
            var refinements = new SafeDictionary<string>();
            var searchStringModels = SearchHelper.GetTags(currentSearchString);

            if (searchStringModels.Count > 0)
            {
                foreach (var ss in searchStringModels)
                {
                    var query = ss.Value;
                    if (query.Contains("tagid="))
                    {
                        query = query.Split('|')[1].Replace("tagid=", string.Empty);
                    }
                    var db = Context.ContentDatabase ?? Context.Database;
                    refinements.Add("_tags", db.GetItem(query).ID.ToString());
                }
            }

            var author = SearchHelper.GetAuthor(currentSearchString);

            var languages = SearchHelper.GetLanguages(currentSearchString);
            if (languages.Length > 0)
            {
                refinements.Add("_language", languages);
            }

            var references = SearchHelper.GetReferences(currentSearchString);

            var custom = SearchHelper.GetCustom(currentSearchString);
            if (custom.Length > 0)
            {
                var customSearch = custom.Split('|');
                if (customSearch.Length > 0)
                {
                    try
                    {
                        refinements.Add(customSearch[0], customSearch[1]);
                    }
                    catch (Exception exc)
                    {
                        Log.Error("Could not parse the custom search query", exc);
                    }
                }
            }

            var search = SearchHelper.GetField(currentSearchString);
            if (search.Length > 0)
            {
                var customSearch = search;
                refinements.Add(customSearch, SearchHelper.GetText(currentSearchString));
            }

            var fileTypes = SearchHelper.GetFileTypes(currentSearchString);
            if (fileTypes.Length > 0)
            {
                refinements.Add("extension", SearchHelper.GetFileTypes(currentSearchString));
            }

            var s = SearchHelper.GetSite(currentSearchString);
            if (s.Length > 0)
            {
                SiteContext siteContext = SiteContextFactory.GetSiteContext(SiteManager.GetSite(s).Name);
                var db = Context.ContentDatabase ?? Context.Database;
                var startItemId = db.GetItem(siteContext.StartPath);
                locationSearch = startItemId.ID.ToString();
            }

            var culture = CultureInfo.CreateSpecificCulture("en-US");
            var startFlag = true;
            var endFlag = true;
            if (SearchHelper.GetStartDate(currentSearchString).Any())
            {
                if (!DateTime.TryParse(SearchHelper.GetStartDate(currentSearchString), culture, DateTimeStyles.None, out startDate))
                {
                    startDate = DateTime.Now;
                }

                startFlag = false;
            }

            if (SearchHelper.GetEndDate(currentSearchString).Any())
            {
                if (!DateTime.TryParse(SearchHelper.GetEndDate(currentSearchString), culture, DateTimeStyles.None, out endDate))
                {
                    endDate = DateTime.Now.AddDays(1);
                }

                endFlag = false;
            }

            using (var searcher = new IndexSearcher(indexName))
            {
                var location = IdHelper.ParseId(SearchHelper.GetLocation(currentSearchString, locationSearch));
                var locationIdFromItem = itm != null ? itm.ID.ToGuid().ToEnumerable() : null;
                var rangeSearch = new DateRangeSearchParam
                {
                    ID = SearchHelper.GetID(currentSearchString).IsEmpty() ? SearchHelper.GetRecent(currentSearchString) : SearchHelper.GetID(currentSearchString),
                    ShowAllVersions = false,
                    FullTextQuery = SearchHelper.GetText(currentSearchString),
                    Refinements = refinements,
                    RelatedIds = references.Any() ? IdHelper.ParseId(references) : null,
                    SortDirection = sortDirection,
                    TemplateIds = SearchHelper.GetTemplates(currentSearchString),
                    LocationIds = !location.Any() ? locationIdFromItem : location,
                    Language = languages,
                    SortByField = sortField,
                    PageNumber = pageNumber,
                    PageSize = pageSize,
                    Author = author == string.Empty ? string.Empty : author,
                };

                if (!startFlag || !endFlag)
                {
                    rangeSearch.Ranges = new List<DateRangeSearchParam.DateRangeField>
                                             {
                                                 new DateRangeSearchParam.DateRangeField(SearchFieldIDs.CreatedDate, startDate, endDate)
                                                     {
                                                         InclusiveStart = true, InclusiveEnd = true
                                                     }
                                             };
                }

                var returnResult = searcher.GetItems(rangeSearch);
                hitCount = returnResult.Key;
                return returnResult.Value;
            }
        }
コード例 #41
0
 public void ReadyToPlay()
 {
     try
     {
         Screen = new Game.Screen(this);
         Inventory = new Game.ConquerStructures.Inventory(this);
         Equipment = new Game.ConquerStructures.Equipment(this);
         WarehouseOpen = false;
         WarehouseOpenTries = 0;
         TempPassword = "";
         Warehouses = new SafeDictionary<PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID, PhoenixProject.Game.ConquerStructures.Warehouse>(20);
         Warehouses.Add(PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.TwinCity, new PhoenixProject.Game.ConquerStructures.Warehouse(this, PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.TwinCity));
         Warehouses.Add(PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.PhoenixCity, new PhoenixProject.Game.ConquerStructures.Warehouse(this, PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.PhoenixCity));
         Warehouses.Add(PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.ApeCity, new PhoenixProject.Game.ConquerStructures.Warehouse(this, PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.ApeCity));
         Warehouses.Add(PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.DesertCity, new PhoenixProject.Game.ConquerStructures.Warehouse(this, PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.DesertCity));
         Warehouses.Add(PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.BirdCity, new PhoenixProject.Game.ConquerStructures.Warehouse(this, PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.BirdCity));
         Warehouses.Add(PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.StoneCity, new PhoenixProject.Game.ConquerStructures.Warehouse(this, PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.StoneCity));
         Warehouses.Add(PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.Market, new PhoenixProject.Game.ConquerStructures.Warehouse(this, PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.Market));
         Warehouses.Add(PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.House, new PhoenixProject.Game.ConquerStructures.Warehouse(this, PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.House));
         Warehouses.Add(PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.poker1, new PhoenixProject.Game.ConquerStructures.Warehouse(this, PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.poker1));
         Warehouses.Add(PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.poker2, new PhoenixProject.Game.ConquerStructures.Warehouse(this, PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.poker2));
         Warehouses.Add(PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.House2, new PhoenixProject.Game.ConquerStructures.Warehouse(this, PhoenixProject.Game.ConquerStructures.Warehouse.WarehouseID.House2));
         Trade = new Game.ConquerStructures.Trade();
         ArenaStatistic = new ArenaStatistic(true);
         Prayers = new List<GameState>();
         MagicDef = new List<GameState>();
         map = null;
     }
     catch (Exception e)
     {
         Program.SaveException(e);
     }
 }
コード例 #42
0
    public static void GetLevelThreeDictionary(Level currentLevel)
    {
        currentLevel.LevelContainsEmpty = false;
        Dictionary <(int, int), List <Block> > dict = currentLevel.CurrentMap.PointBlockPairs;

        Tools.AddBorder(dict);

        // baba text
        SafeDictionary.Add(dict, (1, 1), new List <Block> {
            new Block.ThingText.TextBaba()
        });

        // is text
        SafeDictionary.Add(dict, (1, 2), new List <Block> {
            new Block.SpecialText.TextIs()
        });

        // you text
        SafeDictionary.Add(dict, (1, 3), new List <Block> {
            new Block.SpecialText.TextYou()
        });

        // wall text
        SafeDictionary.Add(dict, (2, 1), new List <Block> {
            new Block.ThingText.TextWall()
        });

        // is text
        SafeDictionary.Add(dict, (2, 2), new List <Block> {
            new Block.SpecialText.TextIs()
        });

        // stop text
        SafeDictionary.Add(dict, (2, 3), new List <Block> {
            new Block.SpecialText.TextStop()
        });

        // wall thing
        for (int i = 1; i < 5; i += 1)
        {
            SafeDictionary.Add(dict, (3, i), new List <Block> {
                new Block.Thing.Wall()
            });
        }

        // wall thing
        for (int i = 1; i < 3; i += 1)
        {
            SafeDictionary.Add(dict, (i, 4), new List <Block> {
                new Block.Thing.Wall()
            });
        }

        // goop text
        SafeDictionary.Add(dict, (8, 2), new List <Block> {
            new Block.ThingText.TextGoop()
        });

        // is text
        SafeDictionary.Add(dict, (9, 2), new List <Block> {
            new Block.SpecialText.TextIs()
        });

        // sink text
        SafeDictionary.Add(dict, (10, 2), new List <Block> {
            new Block.SpecialText.TextSink()
        });

        // baba thing
        SafeDictionary.Add(dict, (8, 7), new List <Block> {
            new Block.Thing.Baba()
        });

        // rock thing
        for (int i = 10; i < 12; i += 1)
        {
            SafeDictionary.Add(dict, (i, 7), new List <Block> {
                new Block.Thing.Rock()
            });
        }

        // wall (main wall)
        for (int i = 6; i < 14; i += 1)
        {
            SafeDictionary.Add(dict, (i, 3), new List <Block> {
                new Block.Thing.Wall()
            });
        }

        for (int i = 4; i < 9; i += 1)
        {
            SafeDictionary.Add(dict, (6, i), new List <Block> {
                new Block.Thing.Wall()
            });
            SafeDictionary.Add(dict, (13, i), new List <Block> {
                new Block.Thing.Wall()
            });
        }


        for (int i = 3; i < 17; i += 1)
        {
            if (i < 8 || i > 11)
            {
                SafeDictionary.Add(dict, (i, 9), new List <Block> {
                    new Block.Thing.Wall()
                });
            }
            SafeDictionary.Add(dict, (i, 16), new List <Block> {
                new Block.Thing.Wall()
            });
        }

        for (int i = 10; i < 16; i += 1)
        {
            SafeDictionary.Add(dict, (3, i), new List <Block> {
                new Block.Thing.Wall()
            });
            SafeDictionary.Add(dict, (16, i), new List <Block> {
                new Block.Thing.Wall()
            });
        }


        // fake wall thing
        for (int i = 4; i < 9; i += 1)
        {
            for (int j = 7; j < 13; j += 1)
            {
                if (i == 5)
                {
                    if (j < 9 || j > 11)
                    {
                        SafeDictionary.Add(dict, (j, i), new List <Block> {
                            new Block.Thing.FakeWall()
                        });
                    }
                }
                else if (i == 7)
                {
                    if (j != 8 || j != 10 || j != 11)
                    {
                        SafeDictionary.Add(dict, (j, i), new List <Block> {
                            new Block.Thing.FakeWall()
                        });
                    }
                }
                else
                {
                    SafeDictionary.Add(dict, (j, i), new List <Block> {
                        new Block.Thing.FakeWall()
                    });
                }
            }
        }


        // rock text
        SafeDictionary.Add(dict, (9, 5), new List <Block> {
            new Block.ThingText.TextRock()
        });

        // is text
        SafeDictionary.Add(dict, (10, 5), new List <Block> {
            new Block.SpecialText.TextIs()
        });

        // push text
        SafeDictionary.Add(dict, (11, 5), new List <Block> {
            new Block.SpecialText.TextPush()
        });

        // goop thing (row)
        for (int i = 8; i < 12; i += 1)
        {
            SafeDictionary.Add(dict, (i, 9), new List <Block> {
                new Block.Thing.Goop()
            });
        }

        // goop thing (bottom left)
        for (int i = 13; i < 16; i += 1)
        {
            for (int j = 4; j < 7; j += 1)
            {
                if (i != 15 || j != 4)
                {
                    SafeDictionary.Add(dict, (j, i), new List <Block> {
                        new Block.Thing.Goop()
                    });
                }
            }
        }

        // flag thing
        SafeDictionary.Add(dict, (4, 15), new List <Block> {
            new Block.Thing.Flag()
        });

        // flag text
        SafeDictionary.Add(dict, (12, 14), new List <Block> {
            new Block.ThingText.TextFlag()
        });

        // is text
        SafeDictionary.Add(dict, (13, 14), new List <Block> {
            new Block.SpecialText.TextIs()
        });

        // win text
        SafeDictionary.Add(dict, (14, 14), new List <Block> {
            new Block.SpecialText.TextWin()
        });
    }
コード例 #43
0
    public static void GetLevelElevenDictionary(Level currentLevel)
    {
        currentLevel.LevelContainsEmpty = true;
        Dictionary <(int, int), List <Block> > dict = currentLevel.CurrentMap.PointBlockPairs;

        Tools.AddBorder(dict);

        // anni text
        SafeDictionary.Add(dict, (1, 3), new List <Block> {
            new Block.ThingText.TextAnni()
        });

        // is text
        SafeDictionary.Add(dict, (2, 3), new List <Block> {
            new Block.SpecialText.TextIs()
        });

        // best text
        SafeDictionary.Add(dict, (3, 3), new List <Block> {
            new Block.ThingText.TextBest()
        });

        // TODO: anni thing
        // SafeDictionary.Add(dict, (2, 2), new List<Block> { new Block.Thing.Anni() });

        // love thing
        SafeDictionary.Add(dict, (2, 1), new List <Block> {
            new Block.Thing.Love()
        });

        // flag text
        SafeDictionary.Add(dict, (7, 1), new List <Block> {
            new Block.ThingText.TextFlag()
        });

        // is text
        SafeDictionary.Add(dict, (8, 1), new List <Block> {
            new Block.SpecialText.TextIs()
        });

        // win text
        SafeDictionary.Add(dict, (9, 1), new List <Block> {
            new Block.SpecialText.TextWin()
        });

        // wall thing (top left)
        for (int i = 1; i < 5; i += 1)
        {
            SafeDictionary.Add(dict, (i, 4), new List <Block> {
                new Block.Thing.Wall()
            });
        }

        for (int i = 1; i < 4; i += 1)
        {
            SafeDictionary.Add(dict, (4, i), new List <Block> {
                new Block.Thing.Wall()
            });
        }

        // wall thing
        for (int i = 12; i < 17; i += 1)
        {
            SafeDictionary.Add(dict, (i, 3), new List <Block> {
                new Block.Thing.Wall()
            });
            SafeDictionary.Add(dict, (i, 7), new List <Block> {
                new Block.Thing.Wall()
            });
        }

        for (int i = 4; i < 7; i += 1)
        {
            SafeDictionary.Add(dict, (12, i), new List <Block> {
                new Block.Thing.Wall()
            });
            SafeDictionary.Add(dict, (16, i), new List <Block> {
                new Block.Thing.Wall()
            });
        }

        // flag thing
        SafeDictionary.Add(dict, (14, 5), new List <Block> {
            new Block.Thing.Flag()
        });

        // baba thing
        SafeDictionary.Add(dict, (6, 10), new List <Block> {
            new Block.Thing.Baba()
        });

        // ice thing
        for (int i = 10; i < 15; i += 1)
        {
            for (int j = 7; j < 12; j += 1)
            {
                if (i != 12 || j != 9)
                {
                    SafeDictionary.Add(dict, (j, i), new List <Block> {
                        new Block.Thing.Ice()
                    });
                }
            }
        }

        // empty thing
        SafeDictionary.Add(dict, (9, 12), new List <Block> {
            new Block.ThingText.TextEmpty()
        });

        // ice text
        SafeDictionary.Add(dict, (3, 12), new List <Block> {
            new Block.ThingText.TextIce()
        });

        // is text
        SafeDictionary.Add(dict, (3, 13), new List <Block> {
            new Block.SpecialText.TextIs()
        });

        // slip text
        SafeDictionary.Add(dict, (3, 14), new List <Block> {
            new Block.SpecialText.TextSlip()
        });

        // wall text
        SafeDictionary.Add(dict, (18, 12), new List <Block> {
            new Block.ThingText.TextWall()
        });

        // is text
        SafeDictionary.Add(dict, (18, 13), new List <Block> {
            new Block.SpecialText.TextIs()
        });

        // stop text
        SafeDictionary.Add(dict, (18, 14), new List <Block> {
            new Block.SpecialText.TextStop()
        });

        // baba text
        SafeDictionary.Add(dict, (4, 18), new List <Block> {
            new Block.ThingText.TextBaba()
        });

        // is text
        SafeDictionary.Add(dict, (5, 18), new List <Block> {
            new Block.SpecialText.TextIs()
        });

        // you text
        SafeDictionary.Add(dict, (6, 18), new List <Block> {
            new Block.SpecialText.TextYou()
        });

        // wall thing
        for (int i = 15; i < 19; i += 1)
        {
            SafeDictionary.Add(dict, (i, 16), new List <Block> {
                new Block.Thing.Wall()
            });
        }

        for (int i = 17; i < 19; i += 1)
        {
            SafeDictionary.Add(dict, (15, i), new List <Block> {
                new Block.Thing.Wall()
            });
        }

        // love text
        SafeDictionary.Add(dict, (16, 17), new List <Block> {
            new Block.ThingText.TextLove()
        });

        // is text
        SafeDictionary.Add(dict, (17, 17), new List <Block> {
            new Block.SpecialText.TextIs()
        });

        // stop text
        SafeDictionary.Add(dict, (18, 17), new List <Block> {
            new Block.SpecialText.TextStop()
        });

        // anni text
        SafeDictionary.Add(dict, (16, 18), new List <Block> {
            new Block.ThingText.TextAnni()
        });

        // is text
        SafeDictionary.Add(dict, (17, 18), new List <Block> {
            new Block.SpecialText.TextIs()
        });

        // stop text
        SafeDictionary.Add(dict, (18, 18), new List <Block> {
            new Block.SpecialText.TextStop()
        });
    }
コード例 #44
0
 /// <summary>
 ///
 /// </summary>
 public void RegisterAbility(BaseAbility baseAbility, BaseTreeNode baseTreeNode)
 {
     m_TreeNodes.Add(baseAbility, baseTreeNode);
 }
コード例 #45
0
        /// <summary>
        /// Renders HTML for an image
        /// </summary>
        /// <param name="image">The image to render</param>
        /// <param name="attributes">Additional parameters to add. Do not include alt or src</param>
        /// <param name="outputHeightWidth">Indicates if the height and width attributes should be output when rendering the image</param>
        /// <returns>An img HTML element</returns>
        public virtual string RenderImage(
            Image image,
            SafeDictionary <string> attributes,
            bool outputHeightWidth = false
            )
        {
            if (image == null)
            {
                return(string.Empty);
            }

            if (attributes == null)
            {
                attributes = new SafeDictionary <string>();
            }

            var origionalKeys = attributes.Keys.ToList();

            //should there be some warning about these removals?
            AttributeCheck(attributes, ImageParameterKeys.CLASS, image.Class);

            if (!attributes.ContainsKey(ImageParameterKeys.ALT))
            {
                attributes[ImageParameterKeys.ALT] = image.Alt;
            }
            AttributeCheck(attributes, ImageParameterKeys.BORDER, image.Border);
            if (image.HSpace > 0)
            {
                AttributeCheck(attributes, ImageParameterKeys.HSPACE, image.HSpace.ToString(CultureInfo.InvariantCulture));
            }
            if (image.VSpace > 0)
            {
                AttributeCheck(attributes, ImageParameterKeys.VSPACE, image.VSpace.ToString(CultureInfo.InvariantCulture));
            }
            if (image.Width > 0)
            {
                AttributeCheck(attributes, ImageParameterKeys.WIDTHHTML, image.Width.ToString(CultureInfo.InvariantCulture));
            }
            if (image.Height > 0)
            {
                AttributeCheck(attributes, ImageParameterKeys.HEIGHTHTML, image.Height.ToString(CultureInfo.InvariantCulture));
            }

            var urlParams  = new SafeDictionary <string>();
            var htmlParams = new SafeDictionary <string>();

            /*
             * ME - This method is used to render images rather than going back to the fieldrender
             * because it stops another call having to be passed to Sitecore.
             */

            if (image == null || image.Src.IsNullOrWhiteSpace())
            {
                return(String.Empty);
            }

            if (attributes == null)
            {
                attributes = new SafeDictionary <string>();
            }

            Action <string> remove = key => attributes.Remove(key);
            Action <string> url    = key =>
            {
                urlParams.Add(key, attributes[key]);
                remove(key);
            };
            Action <string> html = key =>
            {
                htmlParams.Add(key, attributes[key]);
                remove(key);
            };
            Action <string> both = key =>
            {
                htmlParams.Add(key, attributes[key]);
                urlParams.Add(key, attributes[key]);
                remove(key);
            };

            var keys = attributes.Keys.ToList();

            foreach (var key in keys)
            {
                //if we have not config we just add it to both
                if (SitecoreContext.Config == null)
                {
                    both(key);
                }
                else
                {
                    bool found = false;

                    if (SitecoreContext.Config.ImageAttributes.Contains(key))
                    {
                        html(key);
                        found = true;
                    }
                    if (SitecoreContext.Config.ImageQueryString.Contains(key))
                    {
                        url(key);
                        found = true;
                    }

                    if (!found)
                    {
                        html(key);
                    }
                }
            }

            //copy width and height across to url
            if (!urlParams.ContainsKey(ImageParameterKeys.WIDTH) && !urlParams.ContainsKey(ImageParameterKeys.HEIGHT))
            {
                if (origionalKeys.Contains(ImageParameterKeys.WIDTHHTML))
                {
                    urlParams[ImageParameterKeys.WIDTH] = htmlParams[ImageParameterKeys.WIDTHHTML];
                }
                if (origionalKeys.Contains(ImageParameterKeys.HEIGHTHTML))
                {
                    urlParams[ImageParameterKeys.HEIGHT] = htmlParams[ImageParameterKeys.HEIGHTHTML];
                }
            }

            if (!urlParams.ContainsKey(ImageParameterKeys.LANGUAGE) && image.Language != null)
            {
                urlParams[ImageParameterKeys.LANGUAGE] = image.Language.Name;
            }


            //calculate size

            var finalSize = Utilities.ResizeImage(
                image.Width,
                image.Height,
                urlParams[ImageParameterKeys.SCALE].ToFlaot(),
                urlParams[ImageParameterKeys.WIDTH].ToInt(),
                urlParams[ImageParameterKeys.HEIGHT].ToInt(),
                urlParams[ImageParameterKeys.MAX_WIDTH].ToInt(),
                urlParams[ImageParameterKeys.MAX_HEIGHT].ToInt());


            if (finalSize.Height > 0)
            {
                urlParams[ImageParameterKeys.HEIGHT] = finalSize.Height.ToString();
            }
            if (finalSize.Width > 0)
            {
                urlParams[ImageParameterKeys.WIDTH] = finalSize.Width.ToString();
            }

            Action <string, string> originalAttributeClean = (exists, missing) =>
            {
                if (origionalKeys.Contains(exists) && !origionalKeys.Contains(missing))
                {
                    urlParams.Remove(missing);
                    htmlParams.Remove(missing);
                }
            };

            //we do some smart clean up
            originalAttributeClean(ImageParameterKeys.WIDTHHTML, ImageParameterKeys.HEIGHTHTML);
            originalAttributeClean(ImageParameterKeys.HEIGHTHTML, ImageParameterKeys.WIDTHHTML);

            if (!outputHeightWidth)
            {
                htmlParams.Remove(ImageParameterKeys.WIDTHHTML);
                htmlParams.Remove(ImageParameterKeys.HEIGHTHTML);
            }

            var builder = new UrlBuilder(image.Src);



            foreach (var key in urlParams.Keys)
            {
                builder.AddToQueryString(key, urlParams[key]);
            }

            string mediaUrl = builder.ToString();

#if (SC81 || SC80 || SC75 || SC82)
            mediaUrl = ProtectMediaUrl(mediaUrl);
#endif
            mediaUrl = HttpUtility.HtmlEncode(mediaUrl);
            return(ImageTagFormat.Formatted(mediaUrl, Utilities.ConvertAttributes(htmlParams, QuotationMark), QuotationMark));
        }
コード例 #46
0
        public static void Load()
        {
            BaseInformations = new SafeDictionary<uint, ConquerItemBaseInformation>(10000);
            PlusInformations = new SafeDictionary<uint, SafeDictionary<byte, ConquerItemPlusInformation>>(10000);
            GradeInformations = new SafeDictionary<string, SafeDictionary<int, ConquerItemBaseInformation>>(10000);
            GradeInformations2 = new SafeDictionary<string, SafeDictionary<uint, int>>(10000);
            string[] baseText = File.ReadAllLines(ServerBase.Constants.ItemBaseInfosPath);
            string text = "►◄►◄►◄►◄►◄►◄►◄►◄►◄►◄►◄►◄►◄►◄►◄►◄►◄►◄►◄►◄";
            int for1prg = baseText.Length / (System.Console.WindowWidth - text.Length);
            int count = 0;
            System.Console.Write(text);
            var old1 = System.Console.BackgroundColor;
            var old2 = System.Console.ForegroundColor;
            System.Console.BackgroundColor = ConsoleColor.Gray;
            System.Console.ForegroundColor = ConsoleColor.Gray;
            int gkey = 0;
            int lastlevel = 0;
            string lastgr = "";
            foreach (string line in baseText)
            {
                count++;
                if (count == for1prg)
                {
                    count = 0;
                    System.Console.Write("▼◘");
                }
                string _item_ = line.Trim();
                if (_item_.Length > 11)
                {
                    if (_item_.IndexOf("//", 0, 2) != 0)
                    {
                        ConquerItemBaseInformation CIBI = new ConquerItemBaseInformation();
                        CIBI.Parse(_item_);

                        var Grades = GradeInformations[CIBI.Description];
                        BaseInformations.Add(CIBI.ID, CIBI);
                        if (GradeInformations.ContainsKey(CIBI.Description) == false)
                        {
                            GradeInformations2.Add(CIBI.Description, new SafeDictionary<uint, int>(1000));
                            GradeInformations2[CIBI.Description].Add((uint)(CIBI.ID / 10), 0);
                            lastlevel = CIBI.Level;
                            GradeInformations.Add(CIBI.Description, new SafeDictionary<int, ConquerItemBaseInformation>(1000));
                            gkey = 0;
                        }
                        else
                        {
                            if (lastgr != CIBI.Description)
                                gkey = GradeInformations2[CIBI.Description].Count - 1;

                            if (GradeInformations2[CIBI.Description].ContainsKey(CIBI.ID / 10) && CIBI.Level == lastlevel)
                            {
                                CIBI.GradeKey = gkey;
                                continue;
                            }
                            else
                            {
                                GradeInformations2[CIBI.Description].Add((uint)(CIBI.ID / 10), 0);
                                lastlevel = CIBI.Level;
                                gkey = gkey + 1;
                            }
                        }
                        lastgr = CIBI.Description;
                        CIBI.GradeKey = gkey;
                        GradeInformations[CIBI.Description].Add(gkey, CIBI);
                    }
                }
            }
            GradeInformations2.Base.Clear();
            System.Console.BackgroundColor = old1;
            System.Console.ForegroundColor = old2;
            baseText = File.ReadAllLines(ServerBase.Constants.ItemPlusInfosPath);

            foreach (string line in baseText)
            {
                try
                {
                    string _item_ = line.Trim();
                    ConquerItemPlusInformation CIPI = new ConquerItemPlusInformation();
                    CIPI.Parse(_item_);
                    SafeDictionary<byte, ConquerItemPlusInformation> info = null;
                    if (PlusInformations.TryGetValue(CIPI.ID, out info))
                    {
                        info.Add(CIPI.Plus, CIPI);
                    }
                    else
                    {
                        PlusInformations.Add(CIPI.ID, new SafeDictionary<byte, ConquerItemPlusInformation>(1000));
                        if (PlusInformations.TryGetValue(CIPI.ID, out info))
                        {
                            info.Add(CIPI.Plus, CIPI);
                        }
                    }
                }
                catch
                {
                    Console.WriteLine(line);
                    Console.ReadLine();
                }
            }
            Console.WriteLine("Item Base and Plus information loaded.");
        }
コード例 #47
0
        /// <summary>
        /// Renders HTML for an image
        /// </summary>
        /// <param name="image">The image to render</param>
        /// <param name="attributes">Additional parameters to add. Do not include alt or src</param>
        /// <returns>An img HTML element</returns>
        public virtual string RenderImage(Fields.Image image, SafeDictionary <string> attributes)
        {
            var urlParams  = new NameValueCollection();
            var htmlParams = new SafeDictionary <string>();

            /*
             * ME - This method is used to render images rather than going back to the fieldrender
             * because it stops another call having to be passed to Sitecore.
             */

            if (image == null || image.Src.IsNullOrWhiteSpace())
            {
                return("");
            }

            if (attributes == null)
            {
                attributes = new SafeDictionary <string>();
            }

            Action <string> remove = key => attributes.Remove(key);
            Action <string> url    = key =>
            {
                urlParams.Add(key, attributes[key]);
                remove(key);
            };
            Action <string> html = key =>
            {
                htmlParams.Add(key, attributes[key]);
                remove(key);
            };
            Action <string> both = key =>
            {
                htmlParams.Add(key, attributes[key]);
                urlParams.Add(key, attributes[key]);
                remove(key);
            };

            var keys = attributes.Keys.ToList();

            foreach (var key in keys)
            {
                switch (key)
                {
                case ImageParameterKeys.BORDER:
                case ImageParameterKeys.ALT:
                case ImageParameterKeys.HSPACE:
                case ImageParameterKeys.VSPACE:
                case ImageParameterKeys.CLASS:
                case ImageParameterKeys.WIDTHHTML:
                case ImageParameterKeys.HEIGHTHTML:
                    html(key);
                    break;

                case ImageParameterKeys.OUTPUT_METHOD:
                case ImageParameterKeys.ALLOW_STRETCH:
                case ImageParameterKeys.IGNORE_ASPECT_RATIO:
                case ImageParameterKeys.SCALE:
                case ImageParameterKeys.MAX_WIDTH:
                case ImageParameterKeys.MAX_HEIGHT:
                case ImageParameterKeys.THUMBNAIL:
                case ImageParameterKeys.BACKGROUND_COLOR:
                case ImageParameterKeys.DATABASE:
                case ImageParameterKeys.LANGUAGE:
                case ImageParameterKeys.VERSION:
                case ImageParameterKeys.DISABLE_MEDIA_CACHE:
                    url(key);
                    break;

                case ImageParameterKeys.WIDTH:
                case ImageParameterKeys.HEIGHT:
                    both(key);
                    break;

                default:
                    both(key);
                    break;
                }
            }

            var builder = new UrlBuilder(image.Src);

            foreach (var key in urlParams.AllKeys)
            {
                builder[key] = urlParams[key];
            }

            //should there be some warning about these removals?
            AttributeCheck(htmlParams, ImageParameterKeys.CLASS, image.Class);
            AttributeCheck(htmlParams, ImageParameterKeys.ALT, image.Alt);
            AttributeCheck(htmlParams, ImageParameterKeys.BORDER, image.Border);
            if (image.HSpace > 0)
            {
                AttributeCheck(htmlParams, ImageParameterKeys.HSPACE, image.HSpace.ToString(CultureInfo.InvariantCulture));
            }
            if (image.VSpace > 0)
            {
                AttributeCheck(htmlParams, ImageParameterKeys.VSPACE, image.VSpace.ToString(CultureInfo.InvariantCulture));
            }

            if (htmlParams.Keys.Any(x => x == ImageParameterKeys.HEIGHT) && htmlParams["height"] == null)
            {
                htmlParams["height"] = htmlParams[ImageParameterKeys.HEIGHT];
            }
            htmlParams.Remove(ImageParameterKeys.HEIGHT);

            if (htmlParams.Keys.Any(x => x == ImageParameterKeys.WIDTH) && htmlParams["width"] == null)
            {
                htmlParams["width"] = htmlParams[ImageParameterKeys.WIDTH];
            }
            htmlParams.Remove(ImageParameterKeys.WIDTH);

            return(ImageTagFormat.Formatted(builder.ToString(), Utilities.ConvertAttributes(htmlParams)));
        }
コード例 #48
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                var indexOfRo = System.Web.HttpContext.Current.Request.UrlReferrer.Query.IndexOf("fo=");
                var requestString =
                    System.Web.HttpUtility.ParseQueryString(
                        System.Web.HttpContext.Current.Request.UrlReferrer.Query.Substring(indexOfRo));
                //requestString = StringUtil.GetNameValues(requestString[0], '=', '&');
                var refinements = new SafeDictionary<string>();
                if (requestString["FieldsFilter"] != null)
                {
                    var splittedFields = StringUtil.GetNameValues(requestString["FieldsFilter"], ':', ',');
                    foreach (string key in splittedFields.Keys)
                    {
                        refinements.Add(key, splittedFields[key]);
                    }
                }

                var locationFilter = requestString["StartSearchLocation"];
                if (locationFilter.IsNotNull())
                {
                    if (locationFilter.StartsWith("query:"))
                    {
                        locationFilter = locationFilter.Replace("->", "=");
                        Item itemArray;
                        string query = locationFilter.Substring(6);
                        bool flag = query.StartsWith("fast:");
                        Opcode opcode = null;
                        if (!flag)
                        {
                            QueryParser.Parse(query);
                        }
                        if (flag || (opcode is Root))
                        {
                            itemArray =
                                Sitecore.Context.Item.Database.SelectSingleItem(query);
                        }
                        else
                        {
                            itemArray = Sitecore.Context.Item.Axes.SelectSingleItem(query);
                        }

                        locationFilter = itemArray.ID.ToString();

                    }
                }

                var pageSize = requestString["PageSize"];

                var locationFinal = (locationFilter.IsNullOrEmpty() ? Sitecore.Context.ContentDatabase.GetItem(requestString["id"]).GetParentBucketItemOrRootOrSelf().ID.ToString() : locationFilter);
                _ID = locationFinal;
                Filter = "location=" +
                         locationFinal +

                         "&text=" + requestString["FullTextQuery"] +
                         "&language=" + requestString["Language"] +
                         "&pageSize=" + (pageSize.IsNullOrEmpty() ? 20 : Int32.Parse(pageSize)) +

                         "&sort=" + requestString["SortField"];

                if (requestString["TemplateFilter"].IsNotNull())
                {

                    Filter += "&template=" + requestString["TemplateFilter"];
                }

            }
            catch(Exception exc)
            {
                Log.Error("Failed to Resolve Rich Text Editor Source", exc, this);

            }
            finally
            {
                if (!Id.IsNullOrEmpty())
                {
                    Page.Response.Write(
                        "<style>.token-input-list-facebook.boxme {background-image: url(/temp/IconCache/" +
                        Sitecore.Context.ContentDatabase.GetItem(Id).Appearance.Icon +
                        ");background-size:16px 16px;background-position: 2% 50%;background-repeat: no-repeat;}</style>");
                }
                var script = "<script type='text/javascript' language='javascript'>var filterForSearch='" + Filter +
                             "';</script>";
                Page.Response.Write(script);
            }
        }
コード例 #49
0
        /// <summary>
        /// Using a strongly types List of SearchStringModel, you can run a search based off a JSON String
        /// </summary>
        /// <returns>IEnumreable List of Results that have been typed to a smaller version of the Item Object</returns>
        public static IEnumerable<SitecoreItem> Search(this Item itm, List<SearchStringModel> currentSearchString, out int hitCount, string indexName = "itembuckets_buckets", string sortField = "", string sortDirection = "", int numberOfItems = 20, int pageNumber = 0)
        {
            var refinements = new SafeDictionary<string>();
            var searchStringModels = SearchHelper.GetTags(currentSearchString);

            if (searchStringModels.Count > 0)
            {
                foreach (var ss in searchStringModels)
                {
                    var query = ss.Value;
                    if (query.Contains("tagid="))
                    {
                        query = query.Split('|')[1].Replace("tagid=", string.Empty);
                    }
                    var db = Context.ContentDatabase ?? Context.Database;
                    refinements.Add("_tags", db.GetItem(query).ID.ToString());
                }
            }

            using (var searcher = new IndexSearcher(indexName))
            {
                var sitecoreItems = searcher.GetItems(new DateRangeSearchParam()
                    {
                        FullTextQuery = SearchHelper.GetText(currentSearchString),
                        RelatedIds = string.Empty,
                        TemplateIds = SearchHelper.GetTemplates(currentSearchString),
                        LocationIds = itm.ID.ToString(),
                        Refinements = refinements,
                        SortByField = sortField,
                        PageNumber = pageNumber,
                        PageSize = numberOfItems
                    });

                hitCount = sitecoreItems.Key;
                return sitecoreItems.Value;
            }
        }
コード例 #50
0
        /// <summary>
        /// Prints the pitch book.
        /// </summary>
        /// <param name="biographyIds">The biographyIds.</param>
        /// <param name="projectId">The project id.</param>
        /// <param name="username">The username.</param>
        /// <returns></returns>
        public static string PrintPitchBook(string projectId, string biographyIds = null, string articleIds = null, string serviceIds = null, string relatedContentIds = null, string username = null, string resultFileName = null, string publishingFolder = null)
        {
            if (string.IsNullOrEmpty(projectId))
            {
                projectId = defaultProjectId;
            }

            var db = Sitecore.Context.ContentDatabase ??
                     Sitecore.Context.Database;

            var manager = new Sitecore.PrintStudio.PublishingEngine.PrintManager(db, Sitecore.Context.Language);

            var parameters = new SafeDictionary<string, object>();

            if (!string.IsNullOrEmpty(biographyIds))
            {
                parameters.Add("BiographyIds", biographyIds);
            }

            if (!string.IsNullOrEmpty(username))
            {
                parameters.Add("Weil_Username", username);
            }

            if (!string.IsNullOrEmpty(articleIds))
            {
                parameters.Add("ArticleIds", articleIds);
            }

            if (!string.IsNullOrEmpty(serviceIds))
            {
                parameters.Add("ServiceIds", serviceIds);
            }

            if (!string.IsNullOrEmpty(relatedContentIds))
            {
                parameters.Add("relatedContentIds", relatedContentIds);
            }

            var printOptions = new PrintOptions
            {
                PrintExportType = PrintExportType.Pdf,
                UseHighRes = true,
                Parameters = parameters,
                ResultFolder = publishingFolder ?? PublisherFolder
            };
            if (string.IsNullOrEmpty(resultFileName))
            {
                printOptions.ResultFileName = String.Format(fileNameFormat, "PitchBook", db.GetItem(projectId).Name.Replace(" ", "_"), DateTime.Now.Ticks, printOptions.ResultExtension, username);
            }
            else
            {
                printOptions.ResultFileName = resultFileName;
            }
            return manager.Print(projectId, printOptions);
        }
コード例 #51
0
        public static DateRangeSearchParam GetSearchSettings(List <SearchStringModel> currentSearchString, string locationFilter)
        {
            var locationSearch = locationFilter;
            var refinements    = new SafeDictionary <string>();

            refinements = GetTagRefinements(currentSearchString);

            var author = SearchHelper.GetAuthor(currentSearchString);


            var languages = SearchHelper.GetLanguages(currentSearchString);

            if (languages.Length > 0)
            {
                refinements.Add("_language", languages);
            }

            var references = SearchHelper.GetReferences(currentSearchString);

            var custom = SearchHelper.GetCustom(currentSearchString);

            if (custom.Length > 0)
            {
                var customSearch = custom.Split('|');
                if (customSearch.Length > 0)
                {
                    try
                    {
                        refinements.Add(customSearch[0], customSearch[1]);
                    }
                    catch (Exception exc)
                    {
                        Log.Error("Could not parse the custom search query", exc);
                    }
                }
            }

            var search = SearchHelper.GetField(currentSearchString);

            if (search.Length > 0)
            {
                var customSearch = search;
                refinements.Add(customSearch, SearchHelper.GetText(currentSearchString));
            }

            var fileTypes = SearchHelper.GetFileTypes(currentSearchString);

            if (fileTypes.Length > 0)
            {
                refinements.Add("extension", SearchHelper.GetFileTypes(currentSearchString));
            }

            var s = SearchHelper.GetSite(currentSearchString);

            if (s.Length > 0)
            {
                SiteContext siteContext = SiteContextFactory.GetSiteContext(SiteManager.GetSite(s).Name);
                var         db          = Context.ContentDatabase ?? Context.Database;
                var         startItemId = db.GetItem(siteContext.StartPath);
                locationSearch = startItemId.ID.ToString();
            }

            var location = SearchHelper.GetLocation(currentSearchString, locationSearch);

            var rangeSearch = new DateRangeSearchParam
            {
                ID = SearchHelper.GetID(currentSearchString).IsEmpty() ? SearchHelper.GetRecent(currentSearchString) : SearchHelper.GetID(currentSearchString),
                ShowAllVersions = false,
                FullTextQuery   = SearchHelper.GetText(currentSearchString),
                Refinements     = refinements,
                RelatedIds      = references.Any() ? references : string.Empty,
                TemplateIds     = SearchHelper.GetTemplates(currentSearchString),
                LocationIds     = location,
                Language        = languages,
                Author          = author == string.Empty ? string.Empty : author,
                ItemName        = SearchHelper.GetItemName(currentSearchString),
                Ranges          = GetDateRefinements(SearchHelper.GetStartDate(currentSearchString), SearchHelper.GetEndDate(currentSearchString))
            };

            return(rangeSearch);
        }
コード例 #52
0
 /// <summary>
 ///
 /// </summary>
 public void AddAbility(BaseAbility baseAbility)
 {
     m_Abilitys.Add(baseAbility, baseAbility);
 }
コード例 #53
0
        /// <summary>
        /// An extension of Item that allows you to launch a Search from an item
        /// </summary>
        /// <returns>List of Results of Type IEnumerable List of SitecoreItem (which implements IItem)</returns>
        /// <param name="startLocationItem">The start location of the search</param>
        /// <param name="hitCount">This will output the hitCount of the search</param>
        /// <param name="currentSearchString">The raw JSON Parse query</param>
        /// <param name="indexName">Force query to run on a particular index</param>
        /// <param name="sortField">Sort query by field (must be in index)</param>
        /// <param name="sortDirection">Sort in either "asc" or "desc"</param>
        /// <example>BucketManager.Search(Sitecore.Context.Item, SearchModel)</example>
        public static IEnumerable<SitecoreItem> Search(Item startLocationItem, out int hitCount, List<SearchStringModel> currentSearchString, string indexName = "itembuckets_buckets", string sortField = "", string sortDirection = "")
        {
            var refinements = new SafeDictionary<string>();
            var searchStringModels = SearchHelper.GetTags(currentSearchString);

            if (searchStringModels.Count > 0)
            {
                foreach (var ss in searchStringModels)
                {
                    var query = ss.Value;
                    if (query.Contains("tagid="))
                    {
                        query = query.Split('|')[1].Replace("tagid=", string.Empty);
                    }
                    var db = Context.ContentDatabase ?? Context.Database;
                    refinements.Add("_tags", db.GetItem(query).ID.ToString());
                }
            }
            using (var searcher = new IndexSearcher(indexName))
            {
                var keyValuePair = searcher.GetItems(new DateRangeSearchParam { FullTextQuery = SearchHelper.GetText(currentSearchString),
                    RelatedIds = null,
                    SortDirection = sortDirection,
                    TemplateIds = SearchHelper.GetTemplates(currentSearchString),
                    LocationIds = startLocationItem.ID.ToGuid().ToEnumerable(),
                    SortByField = sortField, Refinements = refinements});
                hitCount = keyValuePair.Key;
                return keyValuePair.Value;
            }
        }
コード例 #54
0
    public static void GetLevelTenDictionary(Level currentLevel)
    {
        currentLevel.LevelContainsEmpty = false;
        Dictionary <(int, int), List <Block> > dict = currentLevel.CurrentMap.PointBlockPairs;

        Tools.AddBorder(dict);

        // wall text
        SafeDictionary.Add(dict, (3, 1), new List <Block> {
            new Block.ThingText.TextWall()
        });

        // is text
        SafeDictionary.Add(dict, (4, 1), new List <Block> {
            new Block.SpecialText.TextIs()
        });

        // stop text
        SafeDictionary.Add(dict, (5, 1), new List <Block> {
            new Block.SpecialText.TextStop()
        });

        // lava text
        SafeDictionary.Add(dict, (12, 1), new List <Block> {
            new Block.ThingText.TextLava()
        });

        // is text
        SafeDictionary.Add(dict, (13, 1), new List <Block> {
            new Block.SpecialText.TextIs()
        });

        // kill text
        SafeDictionary.Add(dict, (14, 1), new List <Block> {
            new Block.SpecialText.TextKill()
        });

        // love text
        SafeDictionary.Add(dict, (11, 6), new List <Block> {
            new Block.ThingText.TextLove()
        });

        // is text
        SafeDictionary.Add(dict, (11, 7), new List <Block> {
            new Block.SpecialText.TextIs()
        });

        // win text
        SafeDictionary.Add(dict, (11, 8), new List <Block> {
            new Block.SpecialText.TextWin()
        });

        Block keke = new Block.Thing.Keke();

        keke.Facing = "left";
        SafeDictionary.Add(dict, (6, 2), new List <Block> {
            keke
        });
        keke        = new Block.Thing.Keke();
        keke.Facing = "left";
        SafeDictionary.Add(dict, (15, 6), new List <Block> {
            keke
        });
        keke        = new Block.Thing.Keke();
        keke.Facing = "left";
        SafeDictionary.Add(dict, (13, 12), new List <Block> {
            keke
        });
        keke        = new Block.Thing.Keke();
        keke.Facing = "right";
        SafeDictionary.Add(dict, (3, 4), new List <Block> {
            keke
        });
        keke        = new Block.Thing.Keke();
        keke.Facing = "right";
        SafeDictionary.Add(dict, (17, 17), new List <Block> {
            keke
        });
        keke        = new Block.Thing.Keke();
        keke.Facing = "up";
        SafeDictionary.Add(dict, (10, 15), new List <Block> {
            keke
        });
        keke        = new Block.Thing.Keke();
        keke.Facing = "down";
        SafeDictionary.Add(dict, (3, 14), new List <Block> {
            keke
        });

        // baba thing
        SafeDictionary.Add(dict, (6, 12), new List <Block> {
            new Block.Thing.Baba()
        });

        // baba text
        SafeDictionary.Add(dict, (5, 15), new List <Block> {
            new Block.ThingText.TextBaba()
        });

        // is text
        SafeDictionary.Add(dict, (6, 15), new List <Block> {
            new Block.SpecialText.TextIs()
        });

        // you text
        SafeDictionary.Add(dict, (7, 15), new List <Block> {
            new Block.SpecialText.TextYou()
        });

        // keke text
        SafeDictionary.Add(dict, (12, 15), new List <Block> {
            new Block.ThingText.TextKeke()
        });

        // is text
        SafeDictionary.Add(dict, (13, 15), new List <Block> {
            new Block.SpecialText.TextIs()
        });

        // move text
        SafeDictionary.Add(dict, (14, 15), new List <Block> {
            new Block.SpecialText.TextMove()
        });

        Tools.AddBlockOfFakeWall(dict, (16, 5), 3);
        Tools.AddBlockOfFakeWall(dict, (16, 12), 3);

        // wall thing
        for (int i = 8; i < 11; i += 1)
        {
            SafeDictionary.Add(dict, (i, 4), new List <Block> {
                new Block.Thing.Wall()
            });
        }

        for (int i = 5; i < 12; i += 1)
        {
            SafeDictionary.Add(dict, (8, i), new List <Block> {
                new Block.Thing.Wall()
            });
            SafeDictionary.Add(dict, (10, i), new List <Block> {
                new Block.Thing.Wall()
            });
        }

        SafeDictionary.Add(dict, (11, 9), new List <Block> {
            new Block.Thing.Wall()
        });

        // fake wall thing
        SafeDictionary.Add(dict, (9, 6), new List <Block> {
            new Block.Thing.FakeWall()
        });
        SafeDictionary.Add(dict, (9, 11), new List <Block> {
            new Block.Thing.FakeWall()
        });

        // lava thing
        for (int i = 7; i < 11; i += 1)
        {
            SafeDictionary.Add(dict, (9, i), new List <Block> {
                new Block.Thing.Lava()
            });
        }

        // love thing
        Block love = new Block.Thing.Love();

        love.Facing = "down";
        SafeDictionary.Add(dict, (9, 5), new List <Block> {
            love
        });
    }
コード例 #55
0
ファイル: GameState.cs プロジェクト: AiiMz/PserverWork
        public void ReadyToPlay()
        {
            Screen = new Game.Screen(this);

            Inventory = new Game.ConquerStructures.Inventory(this);
            Equipment = new Game.ConquerStructures.Equipment(this);
            WarehouseOpen = false;
            WarehouseOpenTries = 0;
            TempPassword = "";
            Warehouses = new SafeDictionary<Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID, Conquer_Online_Server.Game.ConquerStructures.Warehouse>(20);
            Warehouses.Add(Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.TwinCity, new Conquer_Online_Server.Game.ConquerStructures.Warehouse(this, Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.TwinCity));
            Warehouses.Add(Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.PhoenixCity, new Conquer_Online_Server.Game.ConquerStructures.Warehouse(this, Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.PhoenixCity));
            Warehouses.Add(Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.ApeCity, new Conquer_Online_Server.Game.ConquerStructures.Warehouse(this, Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.ApeCity));
            Warehouses.Add(Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.DesertCity, new Conquer_Online_Server.Game.ConquerStructures.Warehouse(this, Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.DesertCity));
            Warehouses.Add(Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.BirdCity, new Conquer_Online_Server.Game.ConquerStructures.Warehouse(this, Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.BirdCity));
            Warehouses.Add(Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.StoneCity, new Conquer_Online_Server.Game.ConquerStructures.Warehouse(this, Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.StoneCity));
            Warehouses.Add(Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.Market, new Conquer_Online_Server.Game.ConquerStructures.Warehouse(this, Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.Market));
            Trade = new Game.ConquerStructures.Trade();
            ArenaStatistic = new ArenaStatistic(true);
            Prayers = new List<GameState>();
            map = null;
        }
コード例 #56
0
 /// <summary>
 /// 添加道具类型到集合
 /// </summary>
 public void AddItemTemplate(long itemTemplateId, T itemTemplateT)
 {
     m_ItemTemplates.Add(itemTemplateId, itemTemplateT);
 }
コード例 #57
0
        /// <summary>
        /// Using a strongly types List of SearchStringModel, you can run a search based off a JSON String
        /// </summary>
        /// <param name="itm">
        /// The itm.
        /// </param>
        /// <param name="currentSearchString">
        /// The current Search String.
        /// </param>
        /// <param name="hitCount">
        /// The hit Count.
        /// </param>
        /// <param name="indexName">
        /// The index Name.
        /// </param>
        /// <param name="sortField">
        /// The sort Field.
        /// </param>
        /// <param name="sortDirection">
        /// The sort Direction.
        /// </param>
        /// <param name="pageSize">
        /// The page Size.
        /// </param>
        /// <param name="pageNumber">
        /// The page Number.
        /// </param>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        /// <returns>
        /// IEnumreable List of Results that have been typed to a smaller version of the Item Object
        /// </returns>
        public static IEnumerable <SitecoreItem> FullSearch(this Item itm, List <SearchStringModel> currentSearchString, out int hitCount, string indexName = "itembuckets_buckets", string sortField = "", string sortDirection = "", int pageSize = 0, int pageNumber = 0, object[] parameters = null)
        {
            var startDate          = DateTime.Now;
            var endDate            = DateTime.Now.AddDays(1);
            var locationSearch     = LocationFilter;
            var refinements        = new SafeDictionary <string>();
            var searchStringModels = SearchHelper.GetTags(currentSearchString);

            if (searchStringModels.Count > 0)
            {
                foreach (var ss in searchStringModels)
                {
                    var query = ss.Value;
                    if (query.Contains("tagid="))
                    {
                        query = query.Split('|')[1].Replace("tagid=", string.Empty);
                    }
                    var db = Context.ContentDatabase ?? Context.Database;
                    refinements.Add("_tags", db.GetItem(query).ID.ToString());
                }
            }

            var author = SearchHelper.GetAuthor(currentSearchString);


            var languages = SearchHelper.GetLanguages(currentSearchString);

            if (languages.Length > 0)
            {
                refinements.Add("_language", languages);
            }

            var references = SearchHelper.GetReferences(currentSearchString);

            var custom = SearchHelper.GetCustom(currentSearchString);

            if (custom.Length > 0)
            {
                var customSearch = custom.Split('|');
                if (customSearch.Length > 0)
                {
                    try
                    {
                        refinements.Add(customSearch[0], customSearch[1]);
                    }
                    catch (Exception exc)
                    {
                        Log.Error("Could not parse the custom search query", exc);
                    }
                }
            }

            var search = SearchHelper.GetField(currentSearchString);

            if (search.Length > 0)
            {
                var customSearch = search;
                refinements.Add(customSearch, SearchHelper.GetText(currentSearchString));
            }

            var fileTypes = SearchHelper.GetFileTypes(currentSearchString);

            if (fileTypes.Length > 0)
            {
                refinements.Add("extension", SearchHelper.GetFileTypes(currentSearchString));
            }

            var s = SearchHelper.GetSite(currentSearchString);

            if (s.Length > 0)
            {
                SiteContext siteContext = SiteContextFactory.GetSiteContext(SiteManager.GetSite(s).Name);
                var         db          = Context.ContentDatabase ?? Context.Database;
                var         startItemId = db.GetItem(siteContext.StartPath);
                locationSearch = startItemId.ID.ToString();
            }

            var culture   = CultureInfo.CreateSpecificCulture("en-US");
            var startFlag = true;
            var endFlag   = true;

            if (SearchHelper.GetStartDate(currentSearchString).Any())
            {
                if (!DateTime.TryParse(SearchHelper.GetStartDate(currentSearchString), culture, DateTimeStyles.None, out startDate))
                {
                    startDate = DateTime.Now;
                }

                startFlag = false;
            }

            if (SearchHelper.GetEndDate(currentSearchString).Any())
            {
                if (!DateTime.TryParse(SearchHelper.GetEndDate(currentSearchString), culture, DateTimeStyles.None, out endDate))
                {
                    endDate = DateTime.Now.AddDays(1);
                }

                endFlag = false;
            }

            using (var searcher = new IndexSearcher(indexName))
            {
                var location           = SearchHelper.GetLocation(currentSearchString, locationSearch);
                var locationIdFromItem = itm != null?itm.ID.ToString() : string.Empty;

                var rangeSearch = new DateRangeSearchParam
                {
                    ID = SearchHelper.GetID(currentSearchString).IsEmpty() ? SearchHelper.GetRecent(currentSearchString) : SearchHelper.GetID(currentSearchString),
                    ShowAllVersions = false,
                    FullTextQuery   = SearchHelper.GetText(currentSearchString),
                    Refinements     = refinements,
                    RelatedIds      = references.Any() ? references : string.Empty,
                    SortDirection   = sortDirection,
                    TemplateIds     = SearchHelper.GetTemplates(currentSearchString),
                    LocationIds     = location == string.Empty ? locationIdFromItem : location,
                    Language        = languages,
                    SortByField     = sortField,
                    PageNumber      = pageNumber,
                    PageSize        = pageSize,
                    Author          = author == string.Empty ? string.Empty : author,
                };

                if (!startFlag || !endFlag)
                {
                    rangeSearch.Ranges = new List <DateRangeSearchParam.DateRangeField>
                    {
                        new DateRangeSearchParam.DateRangeField(SearchFieldIDs.CreatedDate, startDate, endDate)
                        {
                            InclusiveStart = true, InclusiveEnd = true
                        }
                    };
                }

                var returnResult = searcher.GetItems(rangeSearch);
                hitCount = returnResult.Key;
                return(returnResult.Value);
            }
        }
コード例 #58
0
ファイル: BucketList.cs プロジェクト: golden86/ItemBuckets
        protected override Item[] GetItems(Item current)
        {
            Assert.ArgumentNotNull(current, "current");

            //Split the source from the DataSource field
            var values = StringUtil.GetNameValues(Source, '=', '&');
            //Split the field FieldsFilter
            var refinements = new SafeDictionary<string>();
            if (values["FieldsFilter"] != null)
            {
                var splittedFields = StringUtil.GetNameValues(values["FieldsFilter"], ':', ',');

                foreach (string key in splittedFields.Keys)
                {
                    refinements.Add(key, splittedFields[key]);
                }
            }

            var searchParam = new FieldValueSearchParam
            {
                Refinements = refinements,
                //LocationIds = values["LocationFilter"],
                LocationIds = SelectedDropTreeValue,
                TemplateIds = values["TemplateFilter"],
                FullTextQuery = values["FullTextQuery"],
                Occurance = QueryOccurance.Must,
                ShowAllVersions = false,
                Language = values["Language"]
            };

            //Execute the search
            using (var searcher = new IndexSearcher("buckets"))
            {
                var items = searcher.GetItems(searchParam);
                return SearchHelper.GetItemListFromInformationCollection(items).ToArray();
            }
        }