示例#1
0
        private async void SimpleButton10_Click(object sender, EventArgs e)
        {
            try
            {
                btn_CreateBoard.Enabled = false;
                if (lookUpEdit2.GetSelectedDataRow() == null)
                {
                    MessageBox.Show("Please Select an account ! ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    btn_CreateBoard.Enabled = true;
                    return;
                }



                dynamic x      = lookUpEdit2.GetSelectedDataRow();
                var     client = new PinSharpClient(x.Row.ItemArray[3].ToString());



                var user = await client.Boards.CreateBoardAsync(txt_boardname.Text, txt_boarddes.Text);

                MessageBox.Show("Board Created", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                LogReport(true, txt_Username.Text, ex.Message);
            }
            txt_boarddes.Text  = "";
            txt_boardname.Text = "";

            btn_CreateBoard.Enabled = true;
        }
示例#2
0
        private async void SimpleButton8_Click(object sender, EventArgs e)
        {
            if (lookUpEdit2.GetSelectedDataRow() == null)
            {
                MessageBox.Show("Please Select an account ! ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            dynamic x = lookUpEdit2.GetSelectedDataRow();

            try
            {
                Lookup_ScrapingAccount.Enabled = false;
                comboBoxEdit3.Enabled          = false;
                var client = new PinSharpClient(x.Row.ItemArray[3].ToString());

                var boards = await client.Me.GetBoardsAsync();

                comboBoxEdit3.Properties.Items.Clear();
                foreach (var bo in boards)
                {
                    comboBoxEdit3.Properties.Items.Add(bo.Name + "[-]" + bo.Id);
                }
            }
            catch (Exception ex)
            {
                LogReport(true, x.Row.ItemArray[0].ToString(), ex.Message);
                Lookup_ScrapingAccount.Enabled = true;
                comboBoxEdit3.Enabled          = true;
            }
            Lookup_ScrapingAccount.Enabled = true;
            comboBoxEdit3.Enabled          = true;
        }
示例#3
0
        private async Task SimpleButton4_ClickAsync(object sender, EventArgs e)
        {
            var client = new PinSharpClient("");

            var pins = await client.Boards.GetPinsAsync("");

            foreach (var pin in pins)
            {
            }
        }
示例#4
0
        private async void SimpleButton7_Click(object sender, EventArgs e)
        {
            try
            {
                if (lookUpEdit2.GetSelectedDataRow() == null)
                {
                    MessageBox.Show("Please Select an account ! ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (comboBoxEdit3.SelectedText == null)
                {
                    MessageBox.Show("Please Select an Board ! ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }



                string boardID = Combo_CurentBoard.SelectedItem.ToString().Split(new string[] { "[-]" }, StringSplitOptions.None)[1];


                dynamic x      = lookUpEdit2.GetSelectedDataRow();
                var     client = new PinSharpClient(x.Row.ItemArray[3].ToString());



                if (radioGroup1.SelectedIndex == 1)
                {
                    if (opf_selectImage.ShowDialog() == DialogResult.OK)
                    {
                        ImageToBase64(opf_selectImage.FileName);
                    }

                    var user = await client.Pins.CreatePinFromBase64Async(comboBoxEdit3.SelectedText, ImageToBase64(opf_selectImage.FileName), Txt_Description.Text, Txt_Link.Text);

                    MessageBox.Show("Pin Posted", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    var user = await client.Pins.CreatePinAsync(comboBoxEdit3.SelectedText, txt_ImageUrl.Text, Txt_Description.Text, Txt_Link.Text);

                    MessageBox.Show("Pin Posted", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                LogReport(true, txt_Username.Text, ex.Message);
            }
        }
示例#5
0
        /// <summary>
        /// The entry point of the program, where the program control starts and ends.
        /// </summary>
        /// <param name="args">The command-line arguments.</param>
        public static void Main(string[] args)
        {
            api_key = ConfigurationManager.AppSettings["apikey"].ToString();
            pinpath = ConfigurationManager.AppSettings["pinpath"].ToString();
            db      = new PinterestDatabase(ConfigurationManager.AppSettings["dbpath"].ToString());

            var target = (NLog.Targets.FileTarget)LogManager.Configuration.FindTargetByName("file");

            target.FileName = System.IO.Path.Combine(pinpath, string.Format(LOG_FILE_NAME, DateTime.Now.ToString("yyyyMMddHHmmss")));
            LogManager.ReconfigExistingLoggers();

            client = new PinSharpClient(api_key);
            logger = LogManager.GetCurrentClassLogger();

            logger.Info("Start Pinterest Downloader");

            try
            {
                db.InitializeDatabase();

                var mecursor        = db.GetPaginationMe();
                var followingcursor = db.GetPaginationFollowing();

                // If there are unfinished fetching, continue those.
                if (mecursor != null)
                {
                    logger.Info(string.Format("Continue downloading {0} {1}", mecursor.BoardId, mecursor.BoardName));
                    FetchPins(BoardType.Me, mecursor.BoardId, mecursor.BoardName, mecursor.Cursor, false).Wait();

                    db.DeletePagination(BoardType.Me);
                }
                else if (followingcursor != null)
                {
                    logger.Info(string.Format("Continue downloading {0} {1}", followingcursor.BoardId, followingcursor.BoardName));
                    FetchPins(BoardType.Following, followingcursor.BoardId, followingcursor.BoardName, followingcursor.Cursor, false).Wait();

                    db.AddExistFollowing(followingcursor.BoardId, followingcursor.BoardName);
                    db.DeletePagination(BoardType.Following);
                }
                else
                {
                    if (args.Length == 1 && args[0] == "status")
                    {
                        // WritePinterestStatus().Wait();
                        var r = db.GetBoards(BoardType.Me);

                        foreach (var b in r)
                        {
                            Console.WriteLine(string.Format("{0}\t{1}\t{2}\t{3}", b.Type.ToString(), b.Id, b.Name, b.Url));
                        }

                        var q = db.GetBoards(BoardType.Following);

                        foreach (var b in q)
                        {
                            Console.WriteLine(string.Format("{0}\t{1}\t{2}\t{3}", b.Type.ToString(), b.Id, b.Name, b.Url));
                        }
                    }
                    else if (args.Length == 1 && args[0] == "fetch")
                    {
                        FetchBoards().Wait();
                    }
                    else if (args.Length == 2 && args[0] == "me" && args[1] != null)
                    {
                        var board_id = args[1];
                        DoPintetestMe(board_id, false).Wait();
                    }
                    else if (args.Length == 2 && args[0] == "1st" && args[1] != null)
                    {
                        var board_id = args[1];
                        DoPintetestMe(board_id, true).Wait();
                    }
                    else if (args.Length == 1 && args[0] == "following")
                    {
                        DoPinterestFollowing().Wait();
                    }
                    else
                    {
                        // Write usage to log file.
                        Console.WriteLine("Select 'staus', 'fetch', 'me [board id]' or 'following'");
                        Console.WriteLine("status : Write my boards info to the log file.");
                        Console.WriteLine("fetch : Write my boards and following boards info to the database.");
                        Console.WriteLine("me [board id] : Download images in [board id] board.");
                        Console.WriteLine("1st [board id] : Download images in the 1st page of [board id] board.");
                        Console.WriteLine("following : Download images in following boards.");
                    }
                }
            } catch (Exception e) {
                logger.Trace("Unhandled exception occurs.");
                logger.Error(e.Message);
                logger.Error(e.StackTrace);
            }
            logger.Info("End Pinterest Downloader");
        }
示例#6
0
 public PinterestClient(ApplicationOptions options)
 {
     _client = new PinSharpClient(options.PinterstApiKey);
 }