Exemple #1
0
        /// <summary>
        /// 开启ETao服务
        /// </summary>
        public static void StartService(string seller, GetItemsHandler hand, GetCatsHandler hand2)
        {
            //设置域名
            if (ETao.Config.Domain == "http://xxx.com")
            {
                ETao.Config.Domain = String.Format("http://{0}/", global::System.Web.HttpContext.Current.Request.Url.Host);
            }

            //设置账号
            ETao.Config.Seller = seller;

            //开启
            const int interval = 3600000;                 //时间间隔(1小时)


            new global::System.Threading.Thread(() =>
            {
                while (true)
                {
                    DateTime dt = DateTime.Now;
                    if ((dt - ETao.Config.LastBuildTime).Days >= 1)
                    {
                        ETao.Core.GenerateFullIndex(hand());
                        ETao.Core.Generate(hand2());

                        ETao.Config.LastBuildTime = dt;
                        global::System.Threading.Thread.Sleep(interval * 24);
                    }
                    else
                    {
                        global::System.Threading.Thread.Sleep(interval);
                    }
                }
            }).Start();
        }
        public async Task getitems_should_return_right_data()
        {
            var sut = new GetItemsHandler(new ItemRepository(_catalogDataContextFactory.ContextInstance),
                                          new Mapper(new MapperConfiguration(cfg => cfg.AddProfile <CatalogProfile>())), _logger.Object);

            var result =
                await sut.Handle(new GetItemsCommand(), CancellationToken.None);

            result.Count.ShouldBe(3);
        }
        public async Task getitems_should_log_right_information()
        {
            var sut = new GetItemsHandler(new ItemRepository(_catalogDataContextFactory.ContextInstance),
                                          new Mapper(new MapperConfiguration(cfg => cfg.AddProfile <CatalogProfile>())), _logger.Object);

            var result =
                await sut.Handle(new GetItemsCommand(), CancellationToken.None);

            _logger
            .Verify(x => x.Log(It.IsAny <LogLevel>(), It.IsAny <Exception>(), It.IsAny <string>()), Times.AtMost(1));
        }
Exemple #4
0
        /// <summary>
        /// 开启ETao服务 
        /// </summary>
        public static void StartService(string seller,GetItemsHandler hand,GetCatsHandler hand2)
        {
            //设置域名
            if (ETao.Config.Domain == "http://xxx.com")
            {
                ETao.Config.Domain = String.Format("http://{0}/", global::System.Web.HttpContext.Current.Request.Url.Host);
            }

            //设置账号
            ETao.Config.Seller = seller;

            //开启
            const int interval = 3600000;                 //时间间隔(1小时)

            new global::System.Threading.Thread(() =>
            {

                while (true)
                {
                    DateTime dt = DateTime.Now;
                    if ((dt - ETao.Config.LastBuildTime).Days >= 1)
                    {
                        ETao.Core.GenerateFullIndex(hand());
                        ETao.Core.Generate(hand2());

                        ETao.Config.LastBuildTime = dt;
                        global::System.Threading.Thread.Sleep(interval * 24);
                    }
                    else
                    {
                        global::System.Threading.Thread.Sleep(interval);
                    }
                }

            }).Start();
        }
Exemple #5
0
            private static SearchProvider CreateProvider(string type, string label, string filterId, int priority, GetItemsHandler fetchItemsHandler)
            {
                return(new SearchProvider(type, label)
                {
                    priority = priority,
                    filterId = filterId,

                    isEnabledForContextualSearch = () => QuickSearchTool.IsFocusedWindowTypeName("ProjectBrowser"),

                    fetchItems = fetchItemsHandler,

                    fetchKeywords = (context, lastToken, items) =>
                    {
                        if (!lastToken.StartsWith("t:"))
                        {
                            return;
                        }
                        items.AddRange(typeFilter.Select(t => "t:" + t));
                    },

                    fetchDescription = (item, context) =>
                    {
                        if (AssetDatabase.IsValidFolder(item.id))
                        {
                            return item.id;
                        }
                        long fileSize = new FileInfo(item.id).Length;
                        item.description = $"{item.id} ({EditorUtility.FormatBytes(fileSize)})";

                        return item.description;
                    },

                    fetchThumbnail = (item, context) => Utils.GetAssetThumbnailFromPath(item.id),
                    fetchPreview = (item, context, size, options) => Utils.GetAssetPreviewFromPath(item.id),

                    startDrag = (item, context) =>
                    {
                        var obj = AssetDatabase.LoadAssetAtPath <Object>(item.id);
                        if (obj == null)
                        {
                            return;
                        }

                        DragAndDrop.PrepareStartDrag();
                        DragAndDrop.objectReferences = new[] { obj };
                        DragAndDrop.StartDrag(item.label);
                    },

                    trackSelection = (item, context) =>
                    {
                        var asset = AssetDatabase.LoadAssetAtPath <Object>(item.id);
                        if (asset != null)
                        {
                            EditorGUIUtility.PingObject(asset);
                        }
                    },

                    subCategories = new List <NameId>()
                });
            }