예제 #1
0
        public static ConversationResponse GetConversations(string accountToken, int offset = 0)
        {
            Console.WriteLine("Getting conversations starting with " + offset);
            ConversationResponse response = new ConversationResponse();

            var paramDic = new Dictionary <string, string>();

            paramDic.Add("offset", "" + offset);
            paramDic.Add("count", "" + 200);
            paramDic.Add("extended", "" + 1);
            string url        = BuildURL("messages.getConversations", paramDic, accountToken);
            var    result     = Get(url);
            var    dynoResult = ReadResponse(result);

            response.Total = dynoResult.response.count;
            for (int a = 0; a < dynoResult.response.items.Count; a++)
            {
                Conversation convo = new Conversation();
                convo.id   = dynoResult.response.items[a].conversation.peer.id;
                convo.type = dynoResult.response.items[a].conversation.peer.type;
                if (convo.type.Equals("chat") && dynoResult.response.items[a].conversation.chat_settings != null)
                {
                    convo.title = dynoResult.response.items[a].conversation.chat_settings.title;
                }
                response.Conversations.Add(convo);
            }
            return(response);
        }
예제 #2
0
 public MainForm()
 {
     InitializeComponent();
     store         = new UserGlobalStore();
     conversations = new ConversationResponse();
     downloader    = new MainDownloader();
 }
예제 #3
0
        private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
        {
            if (e.Url.AbsoluteUri.StartsWith("https://oauth.vk.com/blank.html#"))
            {
                try
                {
                    var uri = e.Url.AbsoluteUri;
                    uri = uri.Replace("#", "?");
                    var args = Tools.GetParams(uri);
                    store.userID       = Int32.Parse(args["user_id"]);
                    store.accountToken = args["access_token"];

                    webBrowser1.Hide();
                    mainPanel.Show();
                    var username = VKTools.GetUsername(store.accountToken);
                    LogThis("User Profile Loaded");
                    welcomeLabel.Text = "Привет, " + username;

                    conversations = VKTools.GetAllConversations(store.accountToken);
                    LogThis("Total Conversations:" + conversations.Total);
                    SetStatus("У вас " + conversations.Total + " чатов. Укажите папку куда их скачать и нажмите Download.");

                    /*for (var a = 0; a < convos.Conversations.Count; a++)
                     * {
                     *  LogThis("   " + convos.Conversations[a].type + " (" + convos.Conversations[a].id + ") " + convos.Conversations[a].title);
                     * }*/
                } catch (Exception ex)
                {
                    LogThis(ex.Message);
                    LogThis(ex.StackTrace);
                }
            }
        }
예제 #4
0
        public static ConversationResponse GetAllConversations(string accountToken)
        {
            Console.WriteLine("Getting all conversations");
            ConversationResponse response = GetConversations(accountToken);

            while (response.Total > response.Conversations.Count)
            {
                var respTemp = GetConversations(accountToken, response.Conversations.Count);
                for (int a = 0; a < respTemp.Conversations.Count; a++)
                {
                    response.Conversations.Add(respTemp.Conversations[a]);
                }
            }
            return(response);
        }
예제 #5
0
 public void SetConvos(ConversationResponse convos)
 {
     this.convos = convos;
 }