示例#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()}" );
            //    }
            //}
        }
示例#2
0
 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 );
 }
示例#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);
        }
示例#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);
         }
     }
 }
示例#5
0
 internal MethodGroup_Video(Api parent){_parent=parent;}
示例#6
0
 internal MethodGroup_Utils(Api parent){_parent=parent;}
示例#7
0
 internal MethodGroup_Users(Api parent){_parent=parent;}
示例#8
0
 internal MethodGroup_Storage(Api parent){_parent=parent;}
示例#9
0
 internal MethodGroup_Docs(Api parent){_parent=parent;}
示例#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);
 }
示例#11
0
 internal MethodGroup_Apps(Api parent){_parent=parent;}
示例#12
0
 internal MethodGroup_Photos(Api parent){_parent=parent;}
示例#13
0
 internal MethodGroup_Pages(Api parent){_parent=parent;}
示例#14
0
 internal MethodGroup_Notifications(Api parent){_parent=parent;}
示例#15
0
 internal MethodGroup_Notes(Api parent){_parent=parent;}
示例#16
0
 internal MethodGroup_Newsfeed(Api parent){_parent=parent;}
示例#17
0
 internal MethodGroup_Friends(Api parent){_parent=parent;}
示例#18
0
 internal MethodGroup_Fave(Api parent){_parent=parent;}
示例#19
0
 internal MethodGroup_Wall(Api parent){_parent=parent;}
示例#20
0
 internal MethodGroup_Likes(Api parent){_parent=parent;}
示例#21
0
 private async static Task Impl(Api vk)
 {
     //await DeleteLikes(vk).ConfigureAwait(false);
     await CheckWall( vk ).ConfigureAwait( false );
 }
示例#22
0
 internal MethodGroup_Audio(Api parent){_parent=parent;}
示例#23
0
 internal MethodGroup_Board(Api parent){_parent=parent;}
示例#24
0
 internal MethodGroup_Polls(Api parent){_parent=parent;}
示例#25
0
 internal MethodGroup_Database(Api parent){_parent=parent;}
示例#26
0
 internal MethodGroup_Account(Api parent){_parent=parent;}
示例#27
0
 internal MethodGroup_Status(Api parent){_parent=parent;}
示例#28
0
 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;
 }
示例#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");
 }