示例#1
0
        /// <summary>
        /// Convenience function for running tests. Creates an object and automatically adds it to the queue for deleting after tests finish.
        /// </summary>
        public async Task <Collect> Create(bool skipAddToCreatedList = false)
        {
            // Create a product to use with these tests.
            var product = await ProductService.CreateAsync(new ShopifySharp.Product()
            {
                CreatedAt   = DateTime.UtcNow,
                Title       = "Burton Custom Freestlye 151",
                Vendor      = "Burton",
                BodyHtml    = "<strong>Good snowboard!</strong>",
                ProductType = "Snowboard",
                Handle      = Guid.NewGuid().ToString(),
                Images      = new List <ProductImage> {
                    new ProductImage {
                        Attachment = "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="
                    }
                },
                PublishedScope = "published"
            });

            var obj = await CollectService.CreateAsync(new Collect()
            {
                CollectionId = CollectionId,
                ProductId    = product.Id.Value,
            });

            if (!skipAddToCreatedList)
            {
                Created.Add(obj);
            }

            return(obj);
        }
示例#2
0
        public async Task InitializeAsync()
        {
            var policy = new LeakyBucketExecutionPolicy();

            Service.SetExecutionPolicy(policy);
            CollectService.SetExecutionPolicy(policy);
            ProductService.SetExecutionPolicy(policy);
            CustomCollectionService.SetExecutionPolicy(policy);

            // Create a custom collection to use with these tests.
            var collection = await CustomCollectionService.CreateAsync(new CustomCollection()
            {
                Title     = "Things",
                Published = false,
                BodyHtml  = "<h1>Hello from ShopifySharp</h1>",
                Image     = new CustomCollectionImage()
                {
                    Attachment = "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="
                }
            });

            CollectionId = collection.Id.Value;

            // Create a collection to use with get, list, count, etc. tests.
            await Create();
        }
示例#3
0
        public void CollectSongReportWork(int size)
        {
            string        directInfoStr = "Report_" + DateTime.Now.ToString("yyyyMMdd");
            DirectoryInfo directInfo    = new DirectoryInfo(directInfoStr);

            if (!directInfo.Exists)
            {
                directInfo.Create();
            }
            for (int i = 1; i <= 2; i++)
            {
                //获取数据
                Console.WriteLine("当前生成第" + i + "个文件");
                List <CollectSongReport> list = new CollectService().GetCollectSongReportListService(i, size);

                string outputPath = directInfoStr + "/" + i + ".xml";
                //写数据
                StringBuilder sBulider = new StringBuilder();
                foreach (CollectSongReport song in list)
                {
                    string row = Row_Temp.Replace("#KeyId", song.KeyId).Replace("#CateName", song.CateName)
                                 .Replace("#ShowCollectId", song.ShowCollectId).Replace("#ShowCollectName", song.ShowCollectName)
                                 .Replace("#Tags", song.Tags).Replace("#SongName", song.SongName)
                                 .Replace("#Singer", song.Singer).Replace("#XM_SongId", song.XM_SongId);
                    //拼接文本,输出文件流,考虑不到文件可能过大,所以分批次
                    sBulider.Append(row + "\n");
                }

                File.WriteAllText(outputPath, FileHeader.Replace("#NumCount", (list.Count + 1).ToString()).Replace("#RowContent", sBulider.ToString()));
                Console.WriteLine("当前第" + i + "个文件,生成完毕");
            }
        }
示例#4
0
        public async Task DisposeAsync()
        {
            foreach (var obj in Created)
            {
                try
                {
                    await CollectService.DeleteAsync(obj.Id.Value);

                    await ProductService.DeleteAsync(obj.ProductId.Value);
                }
                catch (ShopifyException ex)
                {
                    if (ex.HttpStatusCode != HttpStatusCode.NotFound)
                    {
                        Console.WriteLine($"Failed to delete created Collect with id {obj.Id.Value}. {ex.Message}");
                    }
                }
            }

            // Delete the collection
            if (CollectionId != 0)
            {
                await CustomCollectionService.DeleteAsync(CollectionId);
            }
        }
示例#5
0
 public MainWindow(ApplicationDbContext context)
 {
     dbContext         = context;
     mainWindowService = new MainWindowDataService(dbContext);
     subjectService    = new SubjectService(dbContext);
     collectService    = new CollectService(dbContext);
     InitializeComponent();
 }
示例#6
0
 private async void AddCollect(long collectionId, long productId)
 {
     var service = new CollectService(shopifyUrl, shopifyTokenAcces);
     var collect = new Collect()
     {
         CollectionId = collectionId,
         ProductId    = productId
     };
     await service.CreateAsync(collect);
 }
示例#7
0
        public List <Active> GetHistoryList(int roleid)
        {
            List <Active> activelist  = CollectService.GetHistoryList(roleid);
            IRedisClient  redisClient = RedisManager.GetClient();

            redisClient.Set <List <Active> >("active", activelist);
            redisClient.Save();
            redisClient.Dispose();
            return(activelist);
        }
 public AddWorkDoneForm(ApplicationDbContext context)
 {
     dbContext         = context;
     subjectService    = new SubjectService(dbContext);
     solidWasteService = new SolidWasteService(dbContext);
     argumentService   = new ArgumentService(dbContext);
     collectService    = new CollectService(dbContext);
     employeService    = new EmployeService(dbContext);
     InitializeComponent();
 }
示例#9
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         int           userid = int.Parse(Session["UserID"].ToString());
         SqlDataReader dr     = CollectService.SelectCollect(userid);
         ListView1.DataSource = dr;
         ListView1.DataBind();
     }
 }
示例#10
0
        protected void btnshou_Click(object sender, EventArgs e)
        {
            Button  bt  = (Button)sender;
            int     nid = Convert.ToInt32(((HiddenField)(bt.Parent.FindControl("HiddenField1"))).Value);
            Collect cl  = new Collect();

            cl.UserID = int.Parse(Session["UserID"].ToString());
            cl.ObID   = nid;
            cl.CtTime = DateTime.Now;
            if (CollectService.Insert(cl) >= 1)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "true", "<script>alert('收藏成功!')</script>");
            }
        }
示例#11
0
        public void UpdateSongNameWork()
        {
            //更新掉韩文的
            CollectService serviceDal = new CollectService();

            string[] array = File.ReadAllLines("xm_songId.txt");

            List <string> list = array.ToList();

            //serviceDal.GetListSongService();
            //
            //

            foreach (string xm_songid in list)
            {
                //1769129596
                string url  = string.Format("http://www.xiami.com/song/playlist/id/{0}/object_name/default/object_id/0", xm_songid);
                string mess = HttpHelper.OpenWebClient(url, Encoding.UTF8);
                mess = Regex.Replace(mess, "\r\n", "").Replace("\t", "");

                string songname = CommonHelper.GetMatchRegex(songnameRegex, mess).Replace("<![", "").Replace("]]>", "").Trim();
                songname = songname.Replace("'", "''");
                string singer = CommonHelper.GetMatchRegex(singerRegex, mess).Replace("<![", "").Replace("]]>", "").Trim();
                singer = singer.Replace("'", "''");
                string sql = "update CollectSongInfo set SongName=N'" + songname + "',Singer =N'" + singer + "' where XM_SongId = '" + xm_songid + "' \r\n";


                File.AppendAllText("sql.sql", sql, Encoding.UTF8);

                //int result = serviceDal.UpdateSongNameByXm_SongIdService(xm_songid, songanem, singer);
                //if (result > 0)
                //{
                //    Console.WriteLine("更新成功!");
                //}
                //else
                //{
                //    Console.WriteLine("更新失败!");
                //}
                Thread.Sleep(1000);
            }
            Console.WriteLine("文件写入完毕");
            //UpdateSongNameByXm_SongId
            //找到要更新的列表
            // 打开  //http://www.xiami.com/song/playlist/id/1769193354/object_name/default/object_id/0
            //得到歌手名,歌曲名
            //更新
            //执行下一个
        }
示例#12
0
文件: Shopify.cs 项目: raboud/Optimal
        static public Collect AddProductToCollection(Product p, string collection)
        {
            Collect retVal = null;

            if (p.Id.HasValue)
            {
                collection = collection.Trim();
                IEnumerable <CustomCollection> customs = CustomCollectionService.ListAsync().Result;

                CustomCollection cc = customs.FirstOrDefault(c => c.Title == collection);
                if (cc == null)
                {
                    cc = CreateCustomCollection(collection);
                }

                Collect collect = new Collect()
                {
                    ProductId = p.Id.Value, CollectionId = cc.Id.Value
                };
                retVal = CollectService.CreateAsync(collect).Result;
            }
            return(retVal);
        }
示例#13
0
        public async Task Updates_SmartCollection_Products_Order()
        {
            //generate a unique tag
            var tag = Guid.NewGuid().ToString();

            //create collection
            var collection = await Fixture.Service.CreateAsync(new SmartCollection()
            {
                BodyHtml = Fixture.BodyHtml,
                Handle   = Fixture.Handle,
                Title    = Fixture.Title,
                Rules    = new List <SmartCollectionRules>
                {
                    new SmartCollectionRules
                    {
                        Column    = "tag",
                        Condition = tag,
                        Relation  = "equals"
                    }
                }
            });

            //create 4 products with unique tag
            var productService = new ProductService(Utils.MyShopifyUrl, Utils.AccessToken);
            var products       = new List <Product>();

            for (var i = 0; i < 4; i++)
            {
                var product = await productService.CreateAsync(new Product()
                {
                    Title = Guid.NewGuid().ToString(),
                    Tags  = tag
                });

                products.Add(product);
            }

            //reorder items
            products.Reverse();
            var productIds = products.Select(p => p.Id.Value).ToArray();
            await Fixture.Service.UpdateProductOrderAsync(collection.Id.Value, "manual", productIds);


            //get collection
            collection = await Fixture.Service.GetAsync(collection.Id.Value);

            //get products  - use collect service to get products so they are returned in order
            var collectService = new CollectService(Utils.MyShopifyUrl, Utils.AccessToken);
            var collects       = (await collectService.ListAsync(new CollectFilter()
            {
                CollectionId = collection.Id
            })).ToList();

            //check
            Assert.Equal("manual", collection.SortOrder);
            collects.ForEach(c => Assert.True(productIds.Contains(c.ProductId.Value)));

            //delete the objects
            await Fixture.Service.DeleteAsync(collection.Id.Value);

            products.ForEach(async x => await productService.DeleteAsync(x.Id.Value));
        }
示例#14
0
        /// <summary>
        /// 查看点过赞的评论
        /// </summary>
        /// <param name="roleid"></param>
        /// <returns></returns>
        public List <Comment> GetPraiseList(int roleid)
        {
            List <Comment> commentlist = CollectService.GetPraiseList(roleid);

            return(commentlist);
        }