Exemple #1
0
            public void ShowAllAccounts()
            {
                MySqlConnection conn = connManager.OpenConnection();

                if (conn == null || conn.State == System.Data.ConnectionState.Closed)
                {
                    Debug.Log("Fail to connect to the database.");
                    return;
                }

                string sql = "SELECT `user`.`account`,`user`.`password`" +
                             " FROM `dimensioncollapse`.`user`; ";
                MySqlCommand    command = new MySqlCommand(sql, conn);
                MySqlDataReader reader  = command.ExecuteReader();

                while (reader.Read())
                {
                    Debug.Log(reader["account"].ToString() + ' ' + reader["password"].ToString());
                }

                conn.Dispose();
            }
        public List<ArticleModel> GetArticles(string strQuery)
        {
            ConnManager connManager = new ConnManager();
            connManager.OpenConnection();
            DataSet DSQuestions = new DataSet();
            DSQuestions = connManager.GetData(strQuery);
            connManager.DisposeConn();

            List<ArticleModel> articles = new List<ArticleModel>();
            ArticleModel article;
            foreach (DataRow row in DSQuestions.Tables[0].Rows)
            {
                article = new ArticleModel();
                article.ArticleID = row["ArticleID"].ToString();
                article.ArticleTitle = row["ArticleTitle"].ToString();
                article.InsertedDate = row["InsertedDate"].ToString();
                article.ThumbsUp = row["ThumbsUp"].ToString();
                article.ThumbsDown = row["ThumbsDown"].ToString();
                article.Views = row["Views"].ToString();
                articles.Add(article);
            }
            return articles;
        }
        private void ProcessVotes(string LikeType, string articleID)
        {
            List<string> lstReplies = (List<string>)Session["Articles"];
            string strQuery = "";
            int votes = 0;
            if (lstReplies == null)
            {
                lstReplies = new List<string>();
            }

            if (!lstReplies.Contains(articleID))
            {

                ConnManager connManager = new ConnManager();
                connManager.OpenConnection();

                DataTable dsVotes = connManager.GetDataTable("Select ThumbsUp, ThumbsDown from CodeArticles where ArticleId = " + articleID);

                if (dsVotes != null && dsVotes.Rows.Count > 0)
                {
                    if (LikeType.Equals("Up"))
                    {
                        if (string.IsNullOrEmpty(dsVotes.Rows[0]["ThumbsUp"].ToString()))
                            votes = votes + 1;
                        else
                            votes = int.Parse(dsVotes.Rows[0]["ThumbsUp"].ToString()) + 1;

                        strQuery = "Update CodeArticles set ThumbsUp = " + votes + " where ArticleId = " + articleID;
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(dsVotes.Rows[0]["ThumbsDown"].ToString()))
                            votes = votes - 1;
                        else
                            votes = int.Parse(dsVotes.Rows[0]["ThumbsDown"].ToString()) + 1;

                        strQuery = "Update CodeArticles set ThumbsDown = " + votes + " where ArticleId = " + articleID;
                    }
                }

                SqlCommand command = new SqlCommand(strQuery, connManager.DataCon);

                command.ExecuteNonQuery();
                connManager.DisposeConn();

                lstReplies.Add(articleID);
                Session["Articles"] = lstReplies;

            }

            //GetArticleData(articleID.ToString());
        }
        private void GetArticleData(string strArticleId, ref VwArticlesModel model)
        {
            ConnManager connManager = new ConnManager();
            connManager.OpenConnection();
            DataTable dsQuestion = connManager.GetArticle(strArticleId);

            connManager.DisposeConn();
            if (dsQuestion != null)
            {
                if (dsQuestion.Rows.Count > 0)
                {
                    model.ArticleID = long.Parse(dsQuestion.Rows[0]["ArticleId"].ToString());

                    if (!dsQuestion.Rows[0]["EMail"].ToString().Contains("codeanalyze.com"))
                    {
                        if (!string.IsNullOrEmpty(dsQuestion.Rows[0]["FirstName"].ToString()))
                        {
                            model.AskedUser = "******" + dsQuestion.Rows[0]["FirstName"].ToString() + "<b>";
                            if (!string.IsNullOrEmpty(dsQuestion.Rows[0]["LastName"].ToString()))
                            {
                                model.AskedUser = model.AskedUser + " <b>" + dsQuestion.Rows[0]["LastName"].ToString() + "<b>";
                            }
                        }

                        if (!string.IsNullOrEmpty(dsQuestion.Rows[0]["ImageURL"].ToString()))
                        {
                            model.ImageURL = dsQuestion.Rows[0]["ImageURL"].ToString();
                        }
                        else
                        {
                            model.ImageURL = "~/Images/Person.JPG";
                        }

                        if (!string.IsNullOrEmpty(dsQuestion.Rows[0]["Details"].ToString()))
                        {
                            model.AskedUserDetails = dsQuestion.Rows[0]["Details"].ToString();
                        }

                        if (!string.IsNullOrEmpty(dsQuestion.Rows[0]["Stars"].ToString()))
                        {
                            model.Stars = dsQuestion.Rows[0]["Stars"].ToString();
                        }
                        else
                        {
                            model.Stars = "0";
                        }

                    }

                    Session["AskedUserEMail"] = dsQuestion.Rows[0]["EMail"].ToString();
                    //model.ArticleTitle = "<b>" + dsQuestion.Rows[0]["ArticleTitle"].ToString() + "<b>";
                    model.ArticleTitle = dsQuestion.Rows[0]["ArticleTitle"].ToString();
                    model.ArticleViews = dsQuestion.Rows[0]["Views"].ToString();

                    string filepath = string.Empty;
                    if (Request.Url.ToString().Contains("localhost"))
                          filepath = Server.MapPath("/CodeAnalyzeMVC2015/Articles/" + dsQuestion.Rows[0]["WordFile"].ToString()).Replace("\\Details\\Articles", "");
                    else
                         filepath =  Server.MapPath("/Articles/" + dsQuestion.Rows[0]["WordFile"].ToString()).Replace("\\Details\\Articles", "");

                    using (FileStream fs = new FileStream(filepath, FileMode.Open, FileAccess.Read))
                    {
                        using (TextReader tr = new StreamReader(fs))
                        {
                            string content = tr.ReadToEnd();
                            model.ArticleDetails = content;
                        }
                    }

                    //if (dsQuestion.Rows[0]["SourceFile"] != DBNull.Value && !string.IsNullOrEmpty(dsQuestion.Rows[0]["SourceFile"].ToString()))
                    //{
                    //    hfSourceFile.Value = dsQuestion.Rows[0]["SourceFile"].ToString();
                    //    lnkBtnSourceCode.Enabled = true;
                    //    lnkBtnSourceCode.ForeColor = Color.Blue;
                    //    lnkBtnSourceCode.Text = "Download Source Code";
                    //}
                    //else
                    //{
                    //    lnkBtnSourceCode.Enabled = false;
                    //    lnkBtnSourceCode.ForeColor = Color.Gray;
                    //    lnkBtnSourceCode.Text = "No Source Code Uploaded";
                    //}

                    if (!string.IsNullOrEmpty(dsQuestion.Rows[0]["YouTubURL"].ToString()))
                    {
                        model.iframeVideoURL = "//www.youtube.com/embed?listType=playlist&list=PLr5xM_46LGUtyEyyGilUu3YH5FTNo7SMH";
                    }

                    model.ThumbsUp = dsQuestion.Rows[0]["ThumbsUp"].ToString();
                    model.ThumbsDown = dsQuestion.Rows[0]["ThumbsDown"].ToString();
                    model.HasDemo = Convert.ToInt32(dsQuestion.Rows[0]["HasDemo"].ToString());

                    if (dsQuestion.Rows[0]["DemoURL"]!=null)
                    {
                        model.DemoURL = dsQuestion.Rows[0]["DemoURL"].ToString();
                    }
                }
            }
        }
        private void BindComments(string strQuery, ref VwArticlesModel model)
        {
            ConnManager connManager = new ConnManager();
            connManager.OpenConnection();
            DataTable dsSolution = connManager.GetDataTable(strQuery);
            string strReplyId = "";
            string tblReplies = "<table width=\"100%\" style=\"word-wrap:normal; word-break:break-all\" cell-padding=\"0\" cell-spacing=\"0\">";

            if (dsSolution != null)
            {
                for (int i = 0; i < dsSolution.Rows.Count; i++)
                {

                    //Response no user details
                    string htrResponseNoByDetailsOuterRow = "<tr>";
                    string htcResponseNoByDetailsOuterCell = "<td style=\"background-color:lightgrey;border-radius:10px;\">";

                    string htmlTblResponseNoByDetails = "<table style=\"width:100%\">";

                    #region table
                    string htmlRowResponseNoByDetails = "<tr>";

                    string htcUserImage = "<td>";
                    if (!string.IsNullOrEmpty(dsSolution.Rows[i]["ImageURL"].ToString()))
                    {
                        if (Request.Url.ToString().Contains("localhost"))
                            htcUserImage += "<img src=\"/CodeAnalyzeMVC2015/" + dsSolution.Rows[i]["ImageURL"].ToString().Replace("~", "") + "\" style=\"height:30px;width:30px\" />";
                        else
                            htcUserImage += "<img src=\"" + dsSolution.Rows[i]["ImageURL"].ToString().Replace("~", "") + "\" style=\"height:30px;width:30px\" />";
                    }
                    else
                    {
                        if (Request.Url.ToString().Contains("localhost"))
                            htcUserImage += "<img src=\"/CodeAnalyzeMVC2015/Images/Person.JPG\" style=\"height:25px;width:25px\" />";
                        else
                            htcUserImage += "<img src=\"/Images/Person.JPG\" style=\"height:25px;width:25px\" />";
                    }
                    htcUserImage += "</td>";

                    #region responseNoBy
                    string htcResponseNoByDetails = "<td valign=\"middle\">";
                    string strFirstName = "";
                    string strAnswers = "";
                    string strRepliedDate = "";

                    string strUserId = dsSolution.Rows[i]["UserId"].ToString();
                    if (!string.IsNullOrEmpty(dsSolution.Rows[i]["FirstName"].ToString()))
                        strFirstName = dsSolution.Rows[i]["FirstName"].ToString();
                    else
                        strFirstName = dsSolution.Rows[i]["EMail"].ToString().Split('@')[0];
                    strRepliedDate = dsSolution.Rows[i]["InsertedDate"].ToString().Split('@')[0];

                    DataTable dsCount = new DataTable();
                    dsCount = connManager.GetDataTable("SELECT COUNT(*) FROM VwArticleReplies WHERE (ArticleId = " + strUserId + ") ");

                    if (dsCount != null && dsCount.Rows.Count != 0)
                    {
                        if (dsCount.Rows[0][0].ToString() != "0")
                        {
                            if (dsCount != null)
                                strAnswers = dsCount.Rows[0][0].ToString();
                            else
                                strAnswers = "none";

                            if (!dsSolution.Rows[i]["EMail"].ToString().Contains("codeanalyze.com"))
                                //htcResponseNoByDetails += "Comment No <b>" + (i + 1).ToString() + "</b> by <b>" + strFirstName + "</b>  " + strRepliedDate + "";   // Total replies by user: "******".";
                            htcResponseNoByDetails += "<b>" + strFirstName + "</b>  " + strRepliedDate + "";   // Total replies by user: "******".";
                            else
                            {
                                if (!strFirstName.ToLower().Equals("admin"))
                                    //htcResponseNoByDetails += "Comment No <b>" + (i + 1).ToString() + "</b> by <b>" + strFirstName + "</b>  " + strRepliedDate + "";
                                htcResponseNoByDetails += "<b>" + strFirstName + "</b>  " + strRepliedDate + "";
                                else
                                    //htcResponseNoByDetails += "Comment No <b>" + (i + 1).ToString() + "</b> " + strRepliedDate + "";
                                htcResponseNoByDetails += "</b> " + strRepliedDate + "";

                            }
                        }
                        else
                            if (!strFirstName.ToLower().Equals("admin"))
                            //htcResponseNoByDetails += "Comment No <b>" + (i + 1).ToString() + "</b> by <b>" + strFirstName + "</b>  " + strRepliedDate + "";
                        htcResponseNoByDetails += "<b>" + strFirstName + "</b>  " + strRepliedDate + "";

                        else
                            //htcResponseNoByDetails += "Comment No <b>" + (i + 1).ToString() + "</b> " + strRepliedDate + "";
                        htcResponseNoByDetails += "</b> " + strRepliedDate + "";
                    }
                    else
                        if (!strFirstName.ToLower().Equals("admin"))
                        //htcResponseNoByDetails += "Comment No <b>" + (i + 1).ToString() + "</b> by <b>" + strFirstName + "</b>  " + strRepliedDate + "";
                    htcResponseNoByDetails += "<b>" + strFirstName + "</b>  " + strRepliedDate + "";
                    else
                        //htcResponseNoByDetails += "Comment No <b>" + (i + 1).ToString() + "</b> " + strRepliedDate + " ";
                    htcResponseNoByDetails += "</b> " + strRepliedDate + " ";

                    htcResponseNoByDetails += "</td>";

                    htmlRowResponseNoByDetails += htcUserImage;
                    htmlRowResponseNoByDetails += htcResponseNoByDetails;
                    #endregion

                    htmlRowResponseNoByDetails += "</tr>";
                    #endregion

                    htmlTblResponseNoByDetails += htmlRowResponseNoByDetails + "</table>";

                    htcResponseNoByDetailsOuterCell += htmlTblResponseNoByDetails + "</td>";
                    htrResponseNoByDetailsOuterRow += htcResponseNoByDetailsOuterCell + "</tr>";

                    string htmlRowSolutionContent = string.Empty;
                    string htcReplyContent = string.Empty;
                    strReplyId = dsSolution.Rows[i]["ReplyId"].ToString();
                    htcReplyContent += "<td>" + dsSolution.Rows[i]["ReplyText"].ToString() + "</td>";
                    htmlRowSolutionContent += "<tr>" + htcReplyContent + "</tr>";

                    tblReplies += htrResponseNoByDetailsOuterRow +  htmlRowSolutionContent;

                    tblReplies += "<tr><td><br /></td></tr>";

                }
            }

            tblReplies += "</table>";
            model.ArticleReplies = tblReplies;
            connManager.DisposeConn();
        }
        public ActionResult InsertAns(string SolutionEditor)
        {
            VwSolutionsModel model = new VwSolutionsModel();
            string strContent = SolutionEditor;
            string strTemp = "";

            if (Session["User"] != null)
            {
                user = (Users)Session["User"];
                string quesID = RouteData.Values["id"].ToString();

                ConnManager connManager = new ConnManager();
                connManager.OpenConnection();

                double dblReplyID = 0;
                Replies replies = new Replies();
                SqlConnection LclConn = new SqlConnection();
                SqlTransaction SetTransaction = null;
                bool IsinTransaction = false;
                if (LclConn.State != ConnectionState.Open)
                {
                    replies.SetConnection = replies.OpenConnection(LclConn);
                    SetTransaction = LclConn.BeginTransaction(IsolationLevel.ReadCommitted);
                    IsinTransaction = true;
                }
                else
                {
                    replies.SetConnection = LclConn;
                }

                replies.OptionID = 1;
                replies.QuestionId = double.Parse(quesID.ToString());

                //CleanBeforeInsert(ref SolutionEditor, ref strTemp);

                replies.Reply = SolutionEditor;

                replies.RepliedDate = DateTime.Now;

                if (user.UserId == 1)
                {
                    int[] myy = new int[38] { 16, 17, 18, 19, 23, 24, 25, 26, 32, 34, 35, 37, 39, 40, 41, 42, 44, 45, 46, 47, 48, 51, 52, 54, 55, 56, 57, 58, 59, 63, 69, 70, 71, 72, 73, 82, 104, 106 };
                    Random ran = new Random();
                    int mynum = myy[ran.Next(0, myy.Length)];
                    replies.RepliedUser = mynum;

                    int[] myvotes = new int[12] { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
                    Random ran2 = new Random();
                    int mynum2 = myvotes[ran2.Next(0, myvotes.Length)];
                    replies.UpVotes = mynum2;

                }
                else
                {
                    replies.RepliedUser = user.UserId;
                }

                bool result = replies.CreateReplies(ref dblReplyID, SetTransaction);

                if (IsinTransaction && result)
                {
                    SetTransaction.Commit();
                }
                else
                {
                    SetTransaction.Rollback();
                }

                replies.CloseConnection(LclConn);
                ViewBag.ReplyId = dblReplyID;
                model = SetDefaults();

                try
                {
                    if (!Session["AskedUserEMail"].ToString().Contains("codeanalyze.com"))
                    {
                        Mail mail = new Mail();

                        string EMailBody = System.IO.File.ReadAllText(Server.MapPath("../../../EMailBody.txt"));

                        System.Text.RegularExpressions.Regex rgx = new System.Text.RegularExpressions.Regex("[^a-zA-Z0-9 -]");

                        if (model.QuestionTitle != null)
                        {
                            model.QuestionTitle = rgx.Replace(model.QuestionTitle, "").Replace(" ", "-");
                        }

                        string strLink = "www.codeanalyze.com/Que/Ans/" + quesID.ToString() + "/" + model.QuestionTitle + "";

                        string strBody = "Your question on CodeAnalyse has been answered by one of the users. Check now <a href=" + strLink + "\\>here</a>";

                        mail.Body = string.Format(EMailBody, strBody);

                        mail.FromAdd = "*****@*****.**";
                        mail.Subject = "Code Analyze - Received response for " + model.QuestionTitle;
                        mail.ToAdd = Session["AskedUserEMail"].ToString();
                        mail.CCAdds = "*****@*****.**";
                        mail.IsBodyHtml = true;

                        if (!mail.ToAdd.ToString().ToLower().Equals("*****@*****.**"))
                        {
                            mail.SendMail();
                        }
                    }
                }
                catch(Exception ex)
                {

                }
                //GetQuestionData(quesID.ToString(), ref model);
                //BindSolution("Select * from VwSolutions where QuestionId = " + quesID.ToString(), null);
                //ViewBag.lblAck = string.Empty;
            }
            else
            {
                ViewBag.lblAck = "Please sign in to post your question.";
            }
            return View("../Que/Ans", model);
        }
        private void ProcessVotes(string LikeType, string ReplyId, string quesID)
        {
            List<string> lstReplies = (List<string>)Session["Replies"];
            string strQuery = "";
            int votes = 0;
            if (lstReplies == null)
            {
                lstReplies = new List<string>();
            }

            if (!lstReplies.Contains(ReplyId))
            {

                ConnManager connManager = new ConnManager();
                connManager.OpenConnection();

                DataTable dsVotes = connManager.GetDataTable("Select ThumbsUp, ThumbsDown from Replies where ReplyId = " + ReplyId);

                if (dsVotes != null && dsVotes.Rows.Count > 0)
                {
                    if (LikeType.Equals("UP"))
                    {
                        if (string.IsNullOrEmpty(dsVotes.Rows[0]["ThumbsUp"].ToString()))
                            votes = votes + 1;
                        else
                            votes = int.Parse(dsVotes.Rows[0]["ThumbsUp"].ToString()) + 1;

                        strQuery = "Update Replies set ThumbsUp = " + votes + " where ReplyId = " + ReplyId;
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(dsVotes.Rows[0]["ThumbsDown"].ToString()))
                            votes = votes - 1;
                        else
                            votes = int.Parse(dsVotes.Rows[0]["ThumbsDown"].ToString()) + 1;

                        strQuery = "Update Replies set ThumbsDown = " + votes + " where ReplyId = " + ReplyId;
                    }
                }

                SqlCommand command = new SqlCommand(strQuery, connManager.DataCon);
                command.CommandText = strQuery;
                command.ExecuteNonQuery();
                connManager.DisposeConn();

                lstReplies.Add(ReplyId);
                Session["Replies"] = lstReplies;
            }
            //BindQuestionAskedUserData("Select * from VwQuestions where QuestionId = " + quesID.ToString() + "");
        }
        private void GetQuestionData(string strQuestionId, ref VwSolutionsModel model)
        {
            ConnManager connManager = new ConnManager();
            connManager.OpenConnection();
            DataTable dsQuestion = connManager.GetQuestion(strQuestionId);
            connManager.DisposeConn();
            long quesID;

            string strQuestionDetails = String.Empty;

            if (dsQuestion != null)
            {
                if (dsQuestion.Rows.Count > 0)
                {
                    quesID = long.Parse(dsQuestion.Rows[0]["QuestionId"].ToString());
                    model.QuestionID = quesID.ToString();
                    if (!dsQuestion.Rows[0]["EMail"].ToString().Contains("codeanalyze.com"))
                    {
                        model.AskedUser = dsQuestion.Rows[0]["FirstName"].ToString() + " ";
                        if (!string.IsNullOrEmpty(dsQuestion.Rows[0]["LastName"].ToString()))
                        {
                            model.AskedUser = model.AskedUser + "" + dsQuestion.Rows[0]["LastName"].ToString() + "";
                        }

                        if (!string.IsNullOrEmpty(dsQuestion.Rows[0]["ImageURL"].ToString()))
                            model.ImageURL = dsQuestion.Rows[0]["ImageURL"].ToString();
                        else
                            model.ImageURL = "~/Images/Person.JPG";
                    }
                    //else
                    //{
                    //    model.ImageURL = "~/Images/Person.JPG";
                    //}

                    Session["AskedUserEMail"] = dsQuestion.Rows[0]["EMail"].ToString();
                    model.QuestionTitle = dsQuestion.Rows[0]["QuestionTitle"].ToString();

                    strQuestionDetails = dsQuestion.Rows[0]["Question"].ToString().Replace("font-size: x-small", "font-size: medium");
                    strQuestionDetails = StringClean(strQuestionDetails);

                    model.QuestionDetails = "<table style=\"width:100%\"><tr><td>" + strQuestionDetails + "</td></tr></table>";
                    ViewBag.QuestionDetails = model.QuestionDetails;

                    model.QuestionViews = "<b>" + dsQuestion.Rows[0]["Views"].ToString() + "<b>";

                }
            }
        }
        private void BindSolution(string strQuery, ref VwSolutionsModel model)
        {
            ConnManager connManager = new ConnManager();
            connManager.OpenConnection();
            DataTable dsSolution = connManager.GetDataTable(strQuery);
            string quesID = RouteData.Values["id"].ToString();
            string strReplyId = "";
            string lblUp, lblDown = "0";
            string tblReplies = "<table style=\"word-wrap:break-word; width:98%; \">";
            string strDeleteRow = string.Empty;
            string strTitle = string.Empty;

            if (RouteData.Values["Title"]!=null )
            {
                strTitle = RouteData.Values["Title"].ToString();
            }
            else
            {
                strTitle = model.QuestionTitle;
            }

            if (dsSolution != null && dsSolution.Rows.Count > 0)
            {
                for (int i = 0; i < dsSolution.Rows.Count; i++)
                {

                    lblUp = dsSolution.Rows[i]["ThumbsUp"].ToString();
                    lblDown = dsSolution.Rows[i]["ThumbsDown"].ToString();

                    strReplyId = dsSolution.Rows[i]["ReplyID"].ToString();
                    //Response no user details
                    string htrResponseNoByDetailsOuterRow = "<tr>";
                    string htcResponseNoByDetailsOuterCell = "<td style=\"background-color:lightgrey; border-radius:10px;\">";

                    #region table
                    string htmlTblResponseNoByDetails = "<table style=\"width:100%\">";

                    string htmlRowResponseNoByDetails = "<tr style=\"width:100%;\">";

                    string htcUserImage = "<td align=\"right\"> ";
                    if (!string.IsNullOrEmpty(dsSolution.Rows[i]["ImageURL"].ToString()))
                    {
                        if (Request.Url.ToString().Contains("localhost"))
                            htcUserImage += "<img title=\"User Avatar\" src=\"/CodeAnalyzeMVC2015" + dsSolution.Rows[i]["ImageURL"].ToString().Replace("~", "") + "\" style=\"height:30px;width:30px\" />";
                        else
                            htcUserImage += "<img  title=\"User Avatar\" src=\"" + dsSolution.Rows[i]["ImageURL"].ToString().Replace("~", "").Replace("/CodeAnalyzeMVC2015", "") + "\" style=\"height:30px;width:30px\" />";
                    }
                    else
                    {
                        if (Request.Url.ToString().Contains("localhost"))
                            htcUserImage += "<img title=\"User Avatar\" src=\"/CodeAnalyzeMVC2015/Images/Person.JPG\" style=\"height:25px;width:25px\" />";
                        else
                            htcUserImage += "<img title=\"User Avatar\" src=\"/Images/Person.JPG\" style=\"height:25px;width:25px\" />";
                    }
                    htcUserImage += "</td>";

                    string htcResponseNoByDetails = "<td valign=\"middle\">";

                    #region responseNoBy
                    string strFirstName = "";
                    string strLastName = "";
                    string strAnswers = "";
                    string strRepliedDate = "";

                    string strUserId = dsSolution.Rows[i]["UserId"].ToString();
                    if (!string.IsNullOrEmpty(dsSolution.Rows[i]["FirstName"].ToString()))
                    {
                        strFirstName = dsSolution.Rows[i]["FirstName"].ToString();
                        strLastName = dsSolution.Rows[i]["LastName"].ToString();
                    }
                    else
                        strFirstName = dsSolution.Rows[i]["EMail"].ToString().Split('@')[0];
                    strRepliedDate = dsSolution.Rows[i]["RepliedDate"].ToString().Split('@')[0];

                    strRepliedDate = DateTime.Parse(strRepliedDate).ToShortDateString();

                    DataTable dsCount = new DataTable();
                    dsCount = connManager.GetDataTable("SELECT COUNT(*) FROM VwSolutions WHERE (RepliedUser = "******") AND (AskedUser <> " + strUserId + ")");

                    if (dsCount != null && dsCount.Rows.Count > 0)
                    {
                        if (dsCount.Rows[0][0].ToString() != "0")
                        {
                            if (dsCount != null && dsCount.Rows.Count > 0)
                                strAnswers = dsCount.Rows[0][0].ToString();
                            else
                                strAnswers = "<b>none</b>";

                            if (!dsSolution.Rows[i]["EMail"].ToString().Contains("codeanalyze.com"))
                                //htcResponseNoByDetails += "Response No <b>" + (i + 1).ToString() + "</b> by <b>" + strFirstName + " " + strLastName + "</b>  ";// + strRepliedDate + "";   // Total replies by user: "******".";
                            htcResponseNoByDetails += "<b>" + strFirstName + " " + strLastName + "</b>  " + strRepliedDate + "";   // Total replies by user: "******".";

                            else
                                //htcResponseNoByDetails += "Response No <b>" + (i + 1).ToString() + "</b> by <b>" + strFirstName + "</b>  ";// + strRepliedDate + "";
                            htcResponseNoByDetails += "<b>" + strFirstName + "</b>  " + strRepliedDate + "";
                            //htc4.InnerHtml = "Comment No <b>" + (i + 1).ToString();
                        }
                        else
                            if (!strFirstName.ToLower().Equals("admin"))
                        //    htcResponseNoByDetails += "Response No <b>" + (i + 1).ToString() + "</b> by <b>" + strFirstName + " " + strLastName + "</b>  ";// + strRepliedDate + "";
                        htcResponseNoByDetails += "<b>" + strFirstName + " " + strLastName + "</b>  " + strRepliedDate + "";
                        else
                            //htcResponseNoByDetails += "Response No <b>" + (i + 1).ToString() + "</b> " + strRepliedDate + "";
                        htcResponseNoByDetails += " " + strRepliedDate;
                    }
                    else
                        if (!strFirstName.ToLower().Equals("admin"))
                        //htcResponseNoByDetails += "Response No <b>" + (i + 1).ToString() + "</b> by <b>" + strFirstName + " " + strLastName + "</b>  ";// + strRepliedDate + "";
                    htcResponseNoByDetails += "<b>" + strFirstName + " " + strLastName + "</b>  " + strRepliedDate + "";

                    else
                        //htcResponseNoByDetails += "Response No <b>" + (i + 1).ToString() + "</b> " + strRepliedDate + " ";
                    htcResponseNoByDetails += " " + strRepliedDate + " ";
                    #endregion
                    htcResponseNoByDetails += "</td>";

                    htmlRowResponseNoByDetails += htcUserImage;
                    htmlRowResponseNoByDetails += htcResponseNoByDetails;
                    htmlRowResponseNoByDetails += AddThumbsUpDown(i, quesID, strReplyId, lblUp, lblDown);

                    htmlRowResponseNoByDetails += "</tr>";
                    htmlTblResponseNoByDetails += htmlRowResponseNoByDetails + "</table>";
                    #endregion

                    htcResponseNoByDetailsOuterCell += htmlTblResponseNoByDetails + "</td>";
                    htrResponseNoByDetailsOuterRow += htcResponseNoByDetailsOuterCell + "</tr>";

                    //Solution Row
                    string htmlRowSolutionContent = "<tr>";
                    string htcReplyContent = "<td style=\"font-family:Calibri\" >";
                    strReplyId = dsSolution.Rows[i]["ReplyId"].ToString();
                    #region Reply
                    string strReply = dsSolution.Rows[i]["Reply"].ToString().Replace("font-size: x-small", "font-size: 16px");

                    strReply = StringClean(strReply);

                    #endregion
                    htcReplyContent += strReply + "</td>";
                    htmlRowSolutionContent += htcReplyContent + "</tr>";

                    if (ViewBag.ReplyId != null && strReplyId == Convert.ToString(ViewBag.ReplyId))
                    {
                        strDeleteRow += "<tr><td align=\"right\" style=\"color:red;font-weight:bold;font-family:Calibri;font-size:18px;\">";
                        strDeleteRow += "<input type=\"submit\" name=\"Delete\" value=\"Delete\"; onClick=\"DeletePost('" + quesID + "')\" style=\"color:red;font-weight:bold;font-family:Calibri;font-size:18px;border:solid;border-width:1px;border-color:black\">";
                        strDeleteRow += "</td></tr>";
                        Session["DeleteReplyId"] = strReplyId;
                    }

                    tblReplies += htrResponseNoByDetailsOuterRow + strDeleteRow + htmlRowSolutionContent;

                    tblReplies += "<tr><td><br /></td></tr>";

                }
                tblReplies += "</table>";
                model.AnswerDetails = tblReplies;
                ViewBag.AnswerDetails = tblReplies;
            }
            else
            {
                ViewBag.AnswerDetails = null;
            }

            connManager.DisposeConn();
        }
        private ActionResult CheckUserLogin(string txtEMailId, string txtPassword)
        {
            ConnManager connManager = new ConnManager();
            connManager.OpenConnection();
            DataTable DSUserList = new DataTable();
            DataTable dtUserActivation = new DataTable();

            if (!string.IsNullOrEmpty(txtPassword))
            {
                DSUserList = connManager.GetDataTable("select * from users where email = '" + txtEMailId + "' and Password = '******'");
            }
            else
            {
                DSUserList = connManager.GetDataTable("select * from users where email = '" + txtEMailId + "'");
            }

            if (DSUserList.Rows.Count == 0)
            {
                ViewBag.lblAck = "Invalid login credentials, please try again";
                return View("../Account/Login");
            }
            else
            {

                dtUserActivation = connManager.GetDataTable("select * from UserActivation where UserId = " + double.Parse(DSUserList.Rows[0]["UserId"].ToString()) + " and Email = '" + txtEMailId + "'");
                if (dtUserActivation.Rows.Count > 0)
                {
                    ViewBag.lblAck = "User activation pending";
                    ViewBag.Activation = "Resend Activation Code?";
                    return View("../Account/Login");
                }

                Users user = new Users();
                user.UserId = double.Parse(DSUserList.Rows[0]["UserId"].ToString());
                user.FirstName = DSUserList.Rows[0]["FirstName"].ToString();
                user.LastName = DSUserList.Rows[0]["LastName"].ToString();
                user.Email = DSUserList.Rows[0]["EMail"].ToString();
                user.Address = DSUserList.Rows[0]["Address"].ToString();
                user.ImageURL = DSUserList.Rows[0]["ImageURL"].ToString();
                user.Password = DSUserList.Rows[0]["Password"].ToString();

                user.ImageURL = user.ImageURL.Replace("~", "");
                user.ImageURL = user.ImageURL.Replace("/CodeAnalyzeMVC2015", "");

                DataSet dsQuestions = new DataSet();
                DataSet dsAnswers = new DataSet();
                DataSet dsArticles = new DataSet();

                dsQuestions = connManager.GetData("Select Count(*) from Question where AskedUser = "******"");
                if (dsQuestions.Tables.Count > 0 && dsQuestions.Tables[0].Rows.Count > 0)
                    user.QuestionsPosted = dsQuestions.Tables[0].Rows[0][0].ToString();

                dsAnswers = connManager.GetData("Select Count(*) from Replies where RepliedUser = "******"");
                if (dsAnswers.Tables.Count > 0 && dsAnswers.Tables[0].Rows.Count > 0)
                    user.AnswersPosted = dsAnswers.Tables[0].Rows[0][0].ToString();

                dsArticles = connManager.GetData("Select Count(*) from CodeArticles where UserId = " + user.UserId + "");
                if (dsArticles.Tables.Count > 0 && dsArticles.Tables[0].Rows.Count > 0)
                    user.ArticlesPosted = dsArticles.Tables[0].Rows[0][0].ToString();
                else
                    user.ArticlesPosted = "0";

                user.Details = DSUserList.Rows[0]["Details"].ToString();
                Session["User"] = user;
                Session["user.Email"] = user.Email;
                ViewBag.UserEmail = user.Email;
                connManager.DisposeConn();
                return View("../Account/ViewUser", user);

            }
        }