public string GetAllRetweetMentionBydays(string userid, string profileId, string days) { Guid UserId = Guid.Parse(userid); string data = string.Empty; try { string usertweets = string.Empty; string usertweetsDates = string.Empty; string retweets = string.Empty; string retweetsDates = string.Empty; string mentions = string.Empty; string mentionsDates = string.Empty; int _TwitterMention = objTwitterMessageRepository.getTotalMentionBydays(UserId, profileId, Convert.ToInt32(days)); int _TwitterRetweet = objTwitterMessageRepository.getTotalRetweetBydays(UserId, profileId, Convert.ToInt32(days)); dynamic _TwitterMessage = objTwitterMessageRepository.getAllRetweetMentionBydays(UserId, profileId, Convert.ToInt32(days)); if (_TwitterMessage != null) { foreach (var item in _TwitterMessage) { if (item[3] == "twt_usertweets") { usertweets += item[0].ToString() + ','; usertweetsDates += item[1].ToString() + ','; } else if (item[3] == "twt_retweets") { retweets += item[0].ToString() + ','; retweetsDates += item[1].ToString() + ','; } else if (item[3] == "twt_mentions") { mentions += item[0].ToString() + ','; mentionsDates += item[1].ToString() + ','; } } try { usertweets = usertweets.Substring(0, usertweets.Length - 1); usertweetsDates = usertweetsDates.Substring(0, usertweetsDates.Length - 1); usertweets = "usrtwet^" + usertweets + "^" + usertweetsDates; } catch (Exception ex) { int Day = Convert.ToInt32(days); string[] Days = new string[Day]; for (int i = 0; i < Day; i++) { DateTime d1 = DateTime.Now.AddDays(-i); Days[i] = Convert.ToString(d1); } foreach (string item in Days) { usertweets += "0" + ','; usertweetsDates += item.ToString() + ','; usertweets = "mention^" + usertweets + "^" + usertweetsDates; } } try { mentions = mentions.Substring(0, mentions.Length - 1); mentionsDates = mentionsDates.Substring(0, mentionsDates.Length - 1); mentions = "mention^" + mentions + "^" + mentionsDates; } catch (Exception ex) { int Day = Convert.ToInt32(days); string[] Days = new string[Day]; for (int i = 0; i < Day; i++) { DateTime d1 = DateTime.Now.AddDays(-i); try { Days[i] = Convert.ToString(d1); } catch (Exception ex1) { throw; } } foreach (string item in Days) { mentions += "0" + ','; mentionsDates += item.ToString() + ','; mentions = "mention^" + mentions + "^" + mentionsDates; } } try { retweets = retweets.Substring(0, retweets.Length - 1); retweetsDates = retweetsDates.Substring(0, retweetsDates.Length - 1); retweets = "retwet^" + retweets + "^" + retweetsDates; } catch (Exception ex) { int Day = Convert.ToInt32(days); string[] Days = new string[Day]; for (int i = 0; i < Day; i++) { DateTime d1 = DateTime.Now.AddDays(-i); Days[i] = Convert.ToString(d1); } foreach (string item in Days) { retweets += "0" + ','; retweetsDates += item.ToString() + ','; retweets = "mention^" + retweets + "^" + retweetsDates; } } } String totalmention = "metion" + _TwitterMention; string totalretweet = "retwet" + _TwitterRetweet; data = usertweets + "@" + mentions + "@" + retweets + "@" + totalmention + "@" + totalretweet; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } return(data); }