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); }
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 ); }
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; }
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"); }