public void CommentOnSnapsVideos(ref InstagramAccountManager accountManager, string url) { Comments objComments = new Comments(); InstagramPhotoLike objInstagramPhotoLike = new InstagramPhotoLike(); string message = string.Empty; ClGlobul.checkHashTagComment = true; string user = accountManager.Username; string commentStatus = string.Empty; string likeStatus = string.Empty; try { try { if (ClGlobul.HashCommentMessage.Count == ClGlobul.NumberofSnapsVideosToComment) { message = ClGlobul.HashCommentMessage[i]; i++; } else { message = ClGlobul.HashCommentMessage[RandomNumberGenerator.GenerateRandom(0, ClGlobul.HashCommentMessage.Count)]; } } catch (Exception ex) { } try { try { DataSet commentDS = DataBaseHandler.SelectQuery("select comment_status from comment_hash_tag where account_holder ='" + user + "' and photo_id = '" + url.Replace("http://websta.me/p/", string.Empty) + "'", "comment_hash_tag"); if (commentDS.Tables[0].Rows.Count != 0) { commentStatus = commentDS.Tables[0].Rows[0].ItemArray[0].ToString(); } } catch(Exception ex) { } try { DataSet likeDS = DataBaseHandler.SelectQuery("select like_status from liker_hash_tag where account_holder ='" + user + "' and photo_id ='" + url.Replace("http://websta.me/p/", string.Empty) + "'", "liker_hash_tag"); if (likeDS.Tables[0].Rows.Count != 0) { likeStatus = likeDS.Tables[0].Rows[0].ItemArray[0].ToString(); } } catch (Exception ex) { } } catch(Exception ex) {} if (!(commentStatus == "Success")) { if (!(counterComment == ClGlobul.NumberofSnapsVideosToComment)) { string status = objComments.Comment(url, message, ref accountManager); Thread.Sleep(ClGlobul.hashTagDelay * 1000); if (status == "Success") { Log("[ " + DateTime.Now + "] " + "[ Commented on snap/video with url : " + url + " with this message : " + message + " ]"); } else { Log("[ " + DateTime.Now + "] " + "[ Could not comment on snap/video with url : " + url + " ]"); } if (ClGlobul.isCommentAndLikeChecked == true) { if (!(likeStatus == "LIKED")) { ClGlobul.checkHashTagLiker = true; string photoStatus = objInstagramPhotoLike.photolike(url, ref accountManager); Thread.Sleep(ClGlobul.hashTagDelay * 1000); if (photoStatus == "LIKED") { Log("[ " + DateTime.Now + "] " + "[ Snap/Video liked with url : " + url + " ]"); } else { Log("[ " + DateTime.Now + "] " + "[ Snap/Video not liked with url : " + url + " ]"); } } else { Log("[ " + DateTime.Now + "] " + "[ Snap/video with url : " + url + " is already liked. ]"); } } counterComment++; } else { ClGlobul.isCommentLimitReached = true; Log("[ " + DateTime.Now + "] " + "[ Commented on " + ClGlobul.NumberofSnapsVideosToLike + " snaps/videos. "); return; } } } catch (Exception ex) { } }
public void getComment(ref InstagramManager.Classes.InstagramAccountManager accountManager, string CommentIdsForMSG_item) { Queue<string> CommentIdQueue = new Queue<string>(); Queue<string> MsgQueue = new Queue<string>(); InstagramManager.Classes.Comments ObjComments = new Comments(); InstagramManager.Classes.InstagramPhotoLike ObjPotoLike = new InstagramPhotoLike(); try { //Fill MSg's In Queue List ... //foreach (string commentMsgList_item in ClGlobul.commentMsgList) //{ // MsgQueue.Enqueue(commentMsgList_item); //} string photoLikeresult = string.Empty; //If the user Choose somment all given Id from every login Accounts ... //Then will be choose check bOx ... //if (chk_MsgAllCommentId.Checked == true) //{ //foreach (string CommentIdsForMSG_item in ClGlobul.CommentIdsForMSG) //{ photoLikeresult = string.Empty; //string message = MsgQueue.Dequeue(); string message = ClGlobul.commentMsgList[RandomNumberGenerator.GenerateRandom(0, ClGlobul.commentMsgList.Count)]; try { string status = ObjComments.Comment(CommentIdsForMSG_item, message, ref accountManager); if (status == "success") { //AddToCommentLogger("[ " + DateTime.Now + " ] => [ comment is successfully posted from " + accountManager.Username + " ]"); AddToCommentLogger("[ " + DateTime.Now + " ] => [ " + accountManager.Username + " comment is successfully posted from " + CommentIdsForMSG_item + " ]"); } else { //AddToCommentLogger("[ " + DateTime.Now + " ] => [ comment is successfully posted from " + accountManager.Username + " ]"); //AddToCommentLogger("[ " + DateTime.Now + " ] => [ Failed for posted from " + accountManager.Username + " ]"); AddToCommentLogger("[ " + DateTime.Now + " ] => [ " + accountManager.Username + " comment is successfully posted from This Id " + CommentIdsForMSG_item + " ]"); } if (chk_CommentWithLike.Checked == true) { try { //Get Photo like if user is required .... photoLikeresult = ObjPotoLike.photolike(CommentIdsForMSG_item, ref accountManager); } catch (Exception ex) { //AddToCommentLogger(DateTime.Now + ":=> Methode Name :- GetComment ()- Photo like :- " + ex.Message); GramBoardProFileHelper.AppendStringToTextfileNewLine((DateTime.Now + ":=> Methode Name :- GetComment ()- Photo like :- " + ex.Message), GramBoardProFileHelper.ErrorLogFilePathForComment); } //Print statuse in logger printStatus(accountManager.Username, status, CommentIdsForMSG_item, photoLikeresult); } else { //Print statuse in logger printStatus(accountManager.Username, status, CommentIdsForMSG_item); } if (!string.IsNullOrEmpty(txtmindelayComment.Text) && NumberHelper.ValidateNumber(txtmindelayComment.Text)) { mindelay = Convert.ToInt32(txtmindelayComment.Text); } if (!string.IsNullOrEmpty(txtmaxdelayComments.Text) && NumberHelper.ValidateNumber(txtmaxdelayComments.Text)) { maxdelay = Convert.ToInt32(txtmaxdelayComments.Text); } int delay = RandomNumberGenerator.GenerateRandom(mindelay, maxdelay); AddToCommentLogger("[ " + DateTime.Now + " ] => [ Delay For " + delay + " Seconds For " + accountManager.Username + " ]"); Thread.Sleep(delay * 1000); } catch (Exception ex) { //AddToCommentLogger(DateTime.Now + ":=> Methode Name => GetComment () :=> " + ex.Message); GramBoardProFileHelper.AppendStringToTextfileNewLine("---------------------------------------------------------------------------------------", GramBoardProFileHelper.ErrorLogFilePathForComment); GramBoardProFileHelper.AppendStringToTextfileNewLine(DateTime.Now + ":=> Methode Name => GetPhotolike () :=> comment Error :- " + ex.Message, GramBoardProFileHelper.ErrorLogFilePathForComment); GramBoardProFileHelper.AppendStringToTextfileNewLine("---------------------------------------------------------------------------------------", GramBoardProFileHelper.ErrorLogFilePathForComment); } //if (MsgQueue.Count == 0) //{ // break; //} //} //} #region From Queue //else //{ // /// When user is choosend single comment in single Photo Id's // /// then program is Full fill this condion // /// and which is Commented in one Id and one MSg // /// also try to avoid duplicacy for it. // if (CommentIdQueue.Count==0) // { // foreach (string CommentIdsForMSG_item in ClGlobul.CommentIdsForMSG) // { // CommentIdQueue.Enqueue(CommentIdsForMSG_item); // } // } // while (true) // { // Thread.Sleep(1000); // photoLikeresult = string.Empty; // string CommentIdForMSG = CommentIdQueue.Dequeue(); // string message = ""; // message = MsgQueue.Dequeue(); // try // { // string status = ObjComments.Comment(CommentIdForMSG, message, ref accountManager); // if (chk_CommentWithLike.Checked == true) // { // try // { // ///..get photo like from given Id // photoLikeresult = ObjPotoLike.photolike(CommentIdForMSG, ref accountManager); // } // catch (Exception) // { // photoLikeresult = "All ready Like"; // } // //Print statuse in logger // printStatus(accountManager.Username, status, CommentIdForMSG, photoLikeresult); // } // else // { // //Print statuse in logger // printStatus(accountManager.Username, status, CommentIdForMSG); // } // } // catch (Exception ex) // { // AddTophotoLogger(" Methode Name => GetLoginForComment (2) :=> " + ex.Message); // AddTophotoLogger(accountManager.Username+"is not Comment to "+CommentIdForMSG); // GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + ":=> Methode Name => GetLoginForComment (2) :=> " + ex.Message, GlobusFileHelper.ErrorLogFilePathForComment); // GlobusFileHelper.AppendStringToTextfileNewLine(accountManager.ClientId + ":" + accountManager.Password + ":" + CommentIdForMSG, GlobusFileHelper.NotCommentedFilePath); // } // //if MESSAGE and Photo ID's are finished // // Then break the while loop ... // if (CommentIdQueue.Count == 0 || MsgQueue.Count==0) // { // if (CommentIdQueue.Count == 0 && MsgQueue.Count == 0) // { // } // else if (CommentIdQueue.Count == 0) // AddToCommentLogger("Photo id's are Finished "); // else if (MsgQueue.Count == 0) // AddToCommentLogger("Messages are Finished "); // break; // } // } //} #endregion } catch (Exception ex) { //AddToCommentLogger(DateTime.Now + ":=> Methode Name => GetComment () :=> " + ex.Message); GramBoardProFileHelper.AppendStringToTextfileNewLine("-----------------------------------------------------------------------------------------------", GramBoardProFileHelper.ErrorLogFilePathForComment); GramBoardProFileHelper.AppendStringToTextfileNewLine(DateTime.Now + ":=> Methode Name => GetPhotolike (2) :=> " + ex.Message, GramBoardProFileHelper.ErrorLogFilePathForComment); GramBoardProFileHelper.AppendStringToTextfileNewLine("-----------------------------------------------------------------------------------------------", GramBoardProFileHelper.ErrorLogFilePathForComment); } finally { AddToCommentLogger("[ " + DateTime.Now + " ] => [ Comment is Finished From Account : " + accountManager.Username + " ]"); } }