Exemple #1
0
        public void Publish(WpsConsoleCommandLineOptions options)
        {
            try
            {
                var programOptionsFactory = new ProgramOptionsFactory();
                _options = programOptionsFactory.Get(options.BlogConfigPath);
                var postDal = new PostDal(new Dal(MySqlConnectionString));

                PostOrder postOrder = PostOrder.NewestFirst;
                switch (options.Strategy)
                {
                    case "newest":
                        postOrder = PostOrder.NewestFirst;
                        break;
                    case "oldest":
                        postOrder = PostOrder.OldestFirst;
                        break;
                    case "random":
                        postOrder = PostOrder.Random;
                        break;
                    default:
                        break;
                }

                IList<Post> posts = new List<Post>();// postDal.GetPosts(postOrder, options.NumberToPublish);
                if (options.Strategy == "selected")
                {
                    posts = postDal.GetPosts(options.PostIdsInt);
                }
                else
                {
                    posts = postDal.GetPosts(postOrder, options.NumberToPublish);
                }
                if (posts == null)
                {
                    Console.WriteLine("No posts found to publish!");
                    return;
                }

                foreach (var post in posts)
                {
                    try
                    {
                        Console.WriteLine(string.Format("Publishing '{0}'", post.Title));
                        postDal.PublishPost(post);
                    }
                    catch (Exception exception)
                    {
                        Console.WriteLine(exception.ToString());
                    }
                }

            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.ToString());
            }
            Console.WriteLine("Publishing done.");
        }
Exemple #2
0
        private void btnPublish_Click(object sender, EventArgs e)
        {
            EnDis(false);
            txtStatus.Text = "";

            var postDal = new PostDal(new Dal(MySqlConnectionString));
            var posts = _posts;
            if (_posts == null)
            {
                posts = postDal.GetPosts((PostOrder)cbCriteria.SelectedIndex, (int)numNumberOfPosts.Value);
            }
            else
            {
                posts = postDal.GetPosts(_posts.Select(p => int.Parse(p.Id)).ToList());

            }
            if (posts == null)
            {
                MessageBox.Show("No posts found to publish!");
                EnDis();
                return;
            }

            foreach (var post in posts)
            {
                AddStatus(string.Format("Publishing '{0}'", post.Title));
                Application.DoEvents();
                postDal.PublishPost(post);
            }

            if (chkCreateSlide.Checked)
            {
                CreateVideos(posts);
                if (chkYoutube.Checked)
                {
                    UploadToYoutube();
                }
            }

            AddStatus("Done");
            EnDis();
        }