Exemple #1
0
        private static async Task CheckWall( Api vk )
        {
            var mox = 8895502;
            var count = (await vk.Wall.Get( mox, count: 0 ).ConfigureAwait( false )).Count;
            var chunk = 100;
            List<Post> posts = new List<Post>(count);
            for ( int i = 0; i < count; i+=chunk ) {
                var t = Task.Delay( 350 ).ConfigureAwait( false );
                posts.AddRange( await vk.Wall.Get( mox, count: chunk, offset: i ).ConfigureAwait( false ) );
                await t;
            }
            Console.WriteLine( posts.Sum( a => a.Text?.Length ?? 0 ) );
            Console.WriteLine(  );
            //File.WriteAllText(@"C:\Temp\mox\posts.json", JsonConvert.SerializeObject( posts, Formatting.Indented ));

            //foreach ( var post in posts ) {
            //    Console.WriteLine( new string( '#', 79 ) );
            //    Console.WriteLine( $"post {post.Id} by {post.OwnerId} on {post.Date.LocalDateTime}" );
            //    Console.WriteLine(new string('#', 79));
            //    Console.WriteLine( post.Text );
            //    Console.WriteLine(new string('#', 79));
            //    Console.WriteLine( "Attachments:" );
            //    foreach ( var attachment in post.Attachments ?? new Attachment[] {} ) {
            //        Console.WriteLine( $"   Attached {attachment.Type}: {attachment.ToString()}" );
            //    }
            //}
        }
 public ActionResult DeclineReview(int id, string reason="", int userId=-1)
 {
     pendingRepository.Delete (id);
     string result = "Without messaging";
     if (userId != 1) {
         result = "Message sent!";
         var message = "Mmfeedback: Ваш отзыв был отклонен.\n " + reason;
         var api = new Api ();
         api.AddToken (new Token (token));
         try {
             api.Messages.SendSync (userId: userId, message: message);
         } catch (Exception e) {
             result = "Message not sent! Reason: " + e.Message;
         }
     }
     return Content ("Declined. " + result );
 }
Exemple #3
0
        private static async Task Main2() {
            var vk = new Api();
#if DEBUG
            var str = Token.GetOAuthURL( 3174839, Permission.Everything );
            Console.WriteLine( str );
            Console.WriteLine("Enter redirect url or Ctrl-C");
            var redirecturl = Console.ReadLine();

            vk.AddToken( Token.FromRedirectUrl( redirecturl ) );
#else
            try{
                
                foreach (var v in File.ReadAllLines("debug.token"))
                    vk.AddToken(Token.FromRedirectUrl(v));
            }
            catch(Exception ex){
                Console.WriteLine( ex.Message );
            }
#endif
            await Impl( vk ).ConfigureAwait(false);
        }
Exemple #4
0
 private static async Task DeleteLikes( Api vk ) {
     EntityList<Post> posts = await vk.Fave.GetPosts().ConfigureAwait(false);
     foreach (var post in posts)
     {
         try
         {
             var t = Task.Delay(350);
             var ret = await vk.Executor.ExecRawAsync(
                 new Request<int>()
                 {
                     MethodName = "likes.delete",
                     Parameters = new Dictionary<string, string>() { { "type", "post" }, { "owner_id", post.OwnerId.ToNCString() }, { "item_id", post.Id.ToNCString() } },
                     Token = vk.CurrentToken
                 }).ConfigureAwait(false);
             Console.WriteLine( ret );
             await t.ConfigureAwait(false);
         }
         catch (Exception e)
         {
             Console.WriteLine(e);
         }
     }
 }
Exemple #5
0
 internal MethodGroup_Video(Api parent){_parent=parent;}
Exemple #6
0
 internal MethodGroup_Utils(Api parent){_parent=parent;}
Exemple #7
0
 internal MethodGroup_Users(Api parent){_parent=parent;}
Exemple #8
0
 internal MethodGroup_Storage(Api parent){_parent=parent;}
Exemple #9
0
 internal MethodGroup_Docs(Api parent){_parent=parent;}
Exemple #10
0
 private static async Task TestFriends(Api vk) {
     var entityList = await vk.Friends.Get( 8878040, null, UserSortOrder.ById, 0, 100 ).ConfigureAwait(false);
     Console.WriteLine(entityList);
 }
Exemple #11
0
 internal MethodGroup_Apps(Api parent){_parent=parent;}
Exemple #12
0
 internal MethodGroup_Photos(Api parent){_parent=parent;}
Exemple #13
0
 internal MethodGroup_Pages(Api parent){_parent=parent;}
Exemple #14
0
 internal MethodGroup_Notifications(Api parent){_parent=parent;}
Exemple #15
0
 internal MethodGroup_Notes(Api parent){_parent=parent;}
Exemple #16
0
 internal MethodGroup_Newsfeed(Api parent){_parent=parent;}
Exemple #17
0
 internal MethodGroup_Friends(Api parent){_parent=parent;}
Exemple #18
0
 internal MethodGroup_Fave(Api parent){_parent=parent;}
Exemple #19
0
 internal MethodGroup_Wall(Api parent){_parent=parent;}
Exemple #20
0
 internal MethodGroup_Likes(Api parent){_parent=parent;}
Exemple #21
0
 private async static Task Impl(Api vk)
 {
     //await DeleteLikes(vk).ConfigureAwait(false);
     await CheckWall( vk ).ConfigureAwait( false );
 }
Exemple #22
0
 internal MethodGroup_Audio(Api parent){_parent=parent;}
Exemple #23
0
 internal MethodGroup_Board(Api parent){_parent=parent;}
Exemple #24
0
 internal MethodGroup_Polls(Api parent){_parent=parent;}
Exemple #25
0
 internal MethodGroup_Database(Api parent){_parent=parent;}
Exemple #26
0
 internal MethodGroup_Account(Api parent){_parent=parent;}
Exemple #27
0
 internal MethodGroup_Status(Api parent){_parent=parent;}
 public int UpdateCommunityDiscussionsCount(int id)
 {
     int count;
     var element = _database
         .Descendants ("review")
         .Where (review => Int32.Parse (review.Element ("id").Value) == id)
         .Select (review => review)
         .FirstOrDefault ();
     var postId = Int32.Parse (element.Element ("postid").Value);
     var oldCount = Int32.Parse (element.Element ("communutydiscussionscount").Value);
     var api = new Api ();
     //api.AddToken (new Token ("22b299f8c56446504035cc2c561b95823a3a21b5afa2377b620e0e36aac1e8ac947520d0f12c673a6d8ea"));
     api.AddToken(new Token("cf54ae77fdfba85e3e141c865552d916191a636d0dd682b6472f3ba2a1b9883cecae7e2f7dab7273afcd3"));
     try{
         count = api.Wall.GetByIdSync(0,
             new string[] { "-106361362_" + postId })[0].Comments.Count;
     }
     catch (IndexOutOfRangeException e){
         count = oldCount;
     }
     element.Element ("communutydiscussionscount").Value = count.ToString ();
     _database.Save (_dbPath);
     return count;
 }
Exemple #29
0
 public ActionResult PostReview(int id, string description, string tags, string author="",
     string authorId="", string title="", string category="")
 {
     var sign = author != "" ? "Отзыв написан: " + author : "";
     var api = new Api ();
     api.AddToken (new Token (token));
     var message = new StringBuilder ();
     message.AppendLine (sign);
     message.AppendLine (title);
     message.Append (description);
     var postRequest = api.Wall.PostSync (ownerId: -106361362, message: message.ToString());
     var review = new Review () {
         Id = repository.GetNextId(),
         PostId = postRequest.PostId,
         Title = title,
         Description = description,
         Tags = tags.Split (','),
         CommunityUrl = "https://vk.com/moiseyfomin?w=wall-106361362_" + postRequest.PostId,
         CommunutyDiscussionsCount = 0,
         Category = category,
         Date = DateTime.Now.ToShortDateString(),
         Author = author,
         AuthorId = authorId
     };
     pendingRepository.Delete (id);
     repository.Add (review);
     return Content ("accepted");
 }