示例#1
0
        //public ThreadModel(string forumID, string threadID, Func<string, string, XmlNode> fun = null)
        //{
        //    XmlNode node=null;
        //    if (fun == null)
        //        node = CommunityHelper.ReadThread(forumID, threadID);
        //    else
        //        node = fun(forumID, threadID);

        //    Initialize(node);

        // }

        public void Initialize(XmlNode childNode)
        {
            if (childNode != null)
            {
                ThreadID = childNode.SelectSingleNode("Id").InnerText;
                ForumID  = childNode.SelectSingleNode("ForumId").InnerText;
                // TODO: Complete member initialization
                //this.childNode = childNode;
                Subject      = childNode.SelectSingleNode("Subject").InnerText;
                ReplyCount   = childNode.SelectSingleNode("ReplyCount").InnerText ?? "0";
                LastPostDate = Convert.ToDateTime(childNode.SelectSingleNode("LatestPostDate").InnerText);
                LastPostTime = formatDateFunc(childNode.SelectSingleNode("LatestPostDate").InnerText);
                if (!ReplyCount.Equals("0"))
                {
                    LastPostUser = Replies.OrderByDescending(x => x.Date).First().AuthorName;
                    LastPostBody = Replies.OrderByDescending(x => x.Date).First().Body;
                }
                StartedBy     = childNode.SelectSingleNode("Author/Username").InnerText ?? "admin";
                Snippet       = formatBodyFunc(childNode.SelectSingleNode("Body").InnerText);
                Body          = childNode.SelectSingleNode("Body").InnerText;
                ContentId     = childNode.SelectSingleNode("ContentId").InnerText;
                ContentTypeId = childNode.SelectSingleNode("ContentTypeId").InnerText;
            }
            else
            {
                throw new Exception("Null object");
            }
        }
        /// <summary>
        /// Returns false if the supplied Imgur Comment has already been processed.
        /// This is determined by checking the direct Replies to the Comment,
        /// and seeing if any of them were made by the application,
        /// specifically if <see cref="ImgurInterfacer.isCommentByThisApplication"/> returns true.
        /// This method may call the Imgur API.
        /// </summary>
        protected async Task <bool> ShouldProcess(IComment ToProcess)
        {
            IEnumerable <IComment> Replies;

            //??? Imgur seems inconsistent in whether or not Comment Replies are included
            if (ToProcess.Children.Count() > 0)
            {
                Replies = ToProcess.Children;
            }
            else
            {
                Log.Imgur_.LogVerbose("No sub-Comments found in model of Comment #{0:D}; lazily loading sub-Comments", ToProcess.Id);
                try{
                    Replies = await Imgur.ReadCommentReplies(ToProcess);
                }catch (ImgurException Error) {
                    Log.Imgur_.LogError(
                        "Unable to retrieve replies for Comment with ID {0:D} (by '{1}' on {2:u}) to determine if it has been processed; skipping Comment. Details: {3}",
                        ToProcess.Id, ToProcess.Author, ToProcess.DateTime, Error.Message
                        );
                    return(false);
                }
            }
            if (Replies.Any(
                    C => Imgur.isCommentByThisApplication(C)
                    ))
            {
                return(false);
            }
            return(true);
        }
 ///<inheritdoc/>
 public async Task <ApiReply> PostAsync(string route, object value)
 {
     Routes.Push(route);
     Parameters.Push(value);
     Methods.Push(HttpMethod.Post);
     return(await Task.FromResult(Replies.Pop()));
 }
示例#4
0
        /// <summary>
        ///     This function does the merge. It assumes
        ///     that both r are to the same parent.
        /// </summary>
        private bool MergeRepliesInternal(Replies target, Replies otherSet)
        {
            bool updated = false;

            Dictionary <long, Comment> initial = target.Comments.ToDictionary(z => z.Id, z => z);

            for (int i = 0; i < otherSet.Comments.Count; i++)
            {
                Comment c = otherSet.Comments[i];

                // Do we have a comment with the same id?
                Comment existed;
                if (initial.TryGetValue(c.Id, out existed))
                {
                    // We do.
                    updated |= MergeCommentDataInternal(existed, c);
                }
                else
                {
                    // We don't have a comment with the same id.
                    // Insert it.
                    int bestIndex = target.Comments.FindIndex(z => z.Id > c.Id);
                    if (bestIndex == -1)
                    {
                        bestIndex = target.Comments.Count;
                    }

                    Comment cloned = c.MakeClone();
                    target.Comments.Insert(bestIndex, cloned);
                    updated = true;
                }
            }

            return(updated);
        }
示例#5
0
        public bool AddReply(Reply Reply, int PostId, int CommentID, string BlogPostJsonPath)
        {
            try
            {
                var            jsonContent = File.ReadAllText(BlogPostJsonPath);
                var            blogPosts   = JsonConvert.DeserializeObject <blogPosts>(jsonContent);
                List <Comment> Comments    = blogPosts.BlogPosts.Where(obj => obj.id == PostId)?.First()?.Comments;
                var            Replies     = Comments.ElementAt(CommentID - 1).Replies;

                if (Replies == null)
                {
                    Replies = new List <Reply>();
                }
                Replies.Add(Reply);
                Comments.ElementAt(CommentID - 1).Replies = Replies;

                blogPosts.BlogPosts.Where(obj => obj.id == PostId).First().Comments = Comments;
                if (!File.Exists(BlogPostJsonPath))
                {
                    var file = System.IO.File.Create(BlogPostJsonPath);
                    file.Close();
                }
                string res = JsonConvert.SerializeObject(blogPosts);
                File.WriteAllText(BlogPostJsonPath, res);
                return(true);
            }
            catch
            {
                return(false);
            }
        }
示例#6
0
        public void Approval(string topicid, string replyid, string jsonform)
        {
            var form = HttpUtility.UrlDecode(jsonform);

            System.Collections.Specialized.NameValueCollection formresult = HttpUtility.ParseQueryString(form);
            string reason     = formresult["ctl00$txtReason"];
            int    adminmodid = Convert.ToInt32(formresult["ctl00$hdnModerator"]);

            if (!String.IsNullOrEmpty(topicid))
            {
                Topics.SetTopicStatus(Convert.ToInt32(topicid), (int)Enumerators.PostStatus.Open);
            }
            if (!String.IsNullOrEmpty(replyid))
            {
                Replies.SetReplyStatus(Convert.ToInt32(replyid), (int)Enumerators.PostStatus.Open);
                ReplyInfo reply = Replies.GetReply(Convert.ToInt32(replyid));
                var       topic = Topics.GetTopic(Convert.ToInt32(reply.TopicId));
                topic.UnModeratedReplies -= 1;
                Topics.Update(topic);
            }
            if (!string.IsNullOrEmpty(reason) && Config.UseEmail)
            {
                ProcessModeration(1, Convert.ToInt32(topicid), Convert.ToInt32(replyid), adminmodid, reason);
            }
        }
示例#7
0
        public void SaveReply(Replies reply, int id)
        {
            var post = _repo.Query <Posts>().Where(p => p.Id == id).Include(p => p.Reply).FirstOrDefault();

            _repo.Add(post);
            _repo.SaveChanges();
        }
示例#8
0
        private void JumpToReply(string reply)
        {
            int replyPage = Replies.FindReplyPage(Convert.ToInt32(reply));

            CurrentPage             = replyPage;
            ReplyPager.CurrentIndex = CurrentPage;
        }
示例#9
0
        protected override void ParseToEvent(Replies.Reply reply)
        {
            base.ParseToEvent(reply);

            int index = 0;
            string[] split = EventLine.Split(' ');

            for (int i = index; i < split.Length; i++)
            {
                if (split[i].Contains("="))
                {
                    string key = split[i].Split('=')[0];
                    string value = split[i].Split('=')[1];

                    switch (key.ToUpper())
                    {
                        case "ID":
                            ID = value;
                            break;
                        case "READ":
                            int r = 0;
                            int.TryParse(value, out r);
                            BytesRead = r;
                            break;
                        case "WRITTEN":
                            int w = 0;
                            int.TryParse(value, out w);
                            BytesWritten = w;
                            break;
                    }
                }
            }
        }
示例#10
0
        //create user reply

        public void SaveReply(Replies reply, int id)
        {
            var replys = _repo.Query <Replies>().Where(p => p.Id == id).Include(p => p.Title).FirstOrDefault();

            _repo.Add(replys);
            _repo.SaveChanges();
        }
示例#11
0
        public async Task <IActionResult> createPostRepliesAsync([FromBody] PostRepliesWriteDTO model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var ReplyData = new Replies();
                ReplyData.user_Id       = model.user_Id;
                ReplyData.post_Id       = model.post_Id;
                ReplyData.reply_message = model.message;
                ReplyData.created_at    = DateTime.Now;
                ReplyData.updated_at    = null;

                uow.Replies.Create(ReplyData);
                await uow.save();

                return(Ok(new { success = true, message = "Reply sent successfully" }));
            }
            catch (Exception ex)
            {
                return(Ok(ex.Message));
            }
        }
示例#12
0
        private void SetupForEditMessage()
        {
            string msg = String.Empty;

            //fetch original message from db
            switch (_type)
            {
            case "reply":
                ReplyInfo reply = Replies.GetReply(_recId);
                SubjectDiv.Visible = false;
                ForumDiv.Visible   = false;
                msg = HttpUtility.HtmlDecode(reply.Message);
                break;

            case "topics":
                ForumDiv.Visible = (IsAdministrator || (_inModeratedList && !Config.RestrictModeratorMove));

                ForumDropDown.SelectedValue = _thisTopic.ForumId.ToString();
                SubjectDiv.Visible          = true;
                tbxSubject.Text             = HttpUtility.HtmlDecode(_thisTopic.Subject);
                string poll = "";
                if (_thisTopic.PollId != null)
                {
                    poll = Polls.GetTopicPollString(_thisTopic.PollId);
                }
                msg = poll + HttpUtility.HtmlDecode(_thisTopic.Message);
                break;
            }

            Message.Text = msg;
        }
 private void Add_Click(object sender, RoutedEventArgs e)
 {
     if (Reply != null && MoveToFAQ != null)
     {
         if ((bool)MoveToFAQ.IsChecked)
         {
             Questions.selectedQuestion.question.FrequentlyAsked = true;
             QuestionReply questionReply = new QuestionReply();
             questionReply.Author  = MainWindow.doctor;
             questionReply.Content = Reply.Text;
             questionReply.Date    = DateTime.Today;
             questionController.AnswerQuestion(Questions.selectedQuestion.question, questionReply);
         }
         else
         {
             Questions.selectedQuestion.question.FrequentlyAsked = false;
             QuestionReply questionReply = new QuestionReply();
             questionReply.Author  = MainWindow.doctor;
             questionReply.Content = Reply.Text;
             questionReply.Date    = DateTime.Today;
             questionController.AnswerQuestion(Questions.selectedQuestion.question, questionReply);
         }
         Replies.Navigate(new Uri("/Pages/BlogPages/Questions.xaml", UriKind.Relative));
     }
 }
示例#14
0
 void InitializeModules()
 {
     ApplicationName = Auth.ApplicationName;
     Permissions     = new Permissions(driveService);
     Files           = new Files(driveService);
     Comments        = new Comments(driveService);
     Replies         = new Replies(driveService);
 }
示例#15
0
        public void AddRepl(Replies r)
        {
            string sql = "INSERT INTO dbo.Replies(content, writer, foreignBoard, groupId, pid) " +
                         "VALUES(N'" + r.content + "', N'" + r.writer + "', " + r.foreignBoard + ", " +
                         r.groupId + ", " + r.pid + ")";

            db.Query(sql);
        }
示例#16
0
        public Reply GetReply()
        {
            if (Replies.Count <= 1)
            {
                return(Replies.FirstOrDefault());
            }

            return(Replies[HelperMethods.RandomInt(Replies.Count)]);
        }
        public Task ReplyAsync(Message message)
        {
            Replies.Add(message);
#if NET452
            return(Task.FromResult <object>(null));
#else
            return(Task.CompletedTask);
#endif
        }
示例#18
0
        // [Authorize]
        public IActionResult Post([FromBody] Replies reply)
        {
            //var userId = _userManager.GetUserId(this.User);
            //reply.User = userId;
            //reply.IsActive = true;
            //reply.TimeCreated = DateTime.Today;
            _service.SaveReply(reply, reply.PostId);

            return(Ok(reply));
        }
示例#19
0
            public new State <TS, TD, TE> Replying(object replyValue)
            {
                if (Replies == null)
                {
                    Replies = new List <object>();
                }
                var newReplies = Replies.ToArray().ToList();

                newReplies.Add(replyValue);
                return(Copy(Timeout, replies: newReplies));
            }
示例#20
0
        public IActionResult RepliesAdd(Replies reply)
        {
            var addReplies = new Replies()
            {
                Id = reply.Id, Content = reply.Content, Member_id = reply.Member_id, Topic_id = reply.Topic_id
            };

            replies.Add(addReplies);

            return(Ok(new { Status = "Success", Message = "SUccess Add Data", data = replies }));
        }
 private void Close_Click(object sender, RoutedEventArgs e)
 {
     if (!Reply.Text.Equals(""))
     {
         MessageBox.Children.Clear();
         MessageBox.Children.Add(new MessageBox());
     }
     else
     {
         Replies.Navigate(new Uri("/Pages/BlogPages/Questions.xaml", UriKind.Relative));
     }
 }
示例#22
0
 private Dictionary <string, object> CreateEmailDictionary(Replies reply, Requests requests)
 {
     return(new Dictionary <string, object>
     {
         ["lastname"] = requests.lastname,
         ["firstname"] = requests.firstname,
         ["email"] = requests.email,
         ["response"] = reply.response,
         ["sender_lastname"] = reply.lastname,
         ["sender_firstname"] = reply.firstname
     });
 }
示例#23
0
        public void ProcessTopicSubscriptions(int topicid, int replyid, HttpContext context)
        {
            TopicInfo topic = Topics.GetTopic(topicid);
            ReplyInfo reply = Replies.GetReply(replyid);

            var t = new Thread(() => SendSubscriptions(Enumerators.Subscription.TopicSubscription, topic, reply, context))
            {
                IsBackground = true
            };

            t.Start();
        }
示例#24
0
        public void AppendItems(System.Text.StringBuilder oBuilder, ForumInfo forum)
        {
            foreach (TopicInfo row in Forums.GetForumTopics(forum.Id, 0, 10).OrderByDescending(t => t.LastPostDate))
            {
                int       topicId = row.Id;
                TopicInfo topic   = Topics.GetTopic(topicId);
                string    sTitle  = topic.Subject;
                string    sGuid   = string.Format("{0}Content/Forums/Topic/{1}", Config.ForumUrl, topicId);
                string    sLink   = string.Format("{0}Content/Forums/topic.aspx?TOPIC={1}&amp;whichpage=-1", Config.ForumUrl, topicId);
                if (topic.LastReplyId > 0)
                {
                    sLink += "#" + topic.LastReplyId;
                }

                string sDescription = topic.Message; //topic.Message.Length > 512 ? topic.Message.Substring(0, 512) + " ... " : topic.Message;
                string sPubDate     = topic.LastPostDate.Value.ToISO8601Date(false, null);
                string author       = topic.AuthorName;
                if (topic.LastReplyId > 0)
                {
                    if (topic.LastReplyId != null)
                    {
                        ReplyInfo rep = Replies.GetReply((int)topic.LastReplyId);
                        author       = rep.AuthorName;
                        sDescription = rep.Message;  //rep.Message.Length > 256 ? rep.Message.Substring(0, 256) + " ... " : rep.Message;
                    }
                }

                oBuilder.Append("<item>");
                oBuilder.Append("<category>");
                oBuilder.Append(forum.Subject.WrapCData());
                oBuilder.Append("</category>");
                oBuilder.Append("<title>");
                oBuilder.Append(sTitle.WrapCData());
                oBuilder.Append("</title>");
                oBuilder.Append("<author>");
                oBuilder.Append(author);
                oBuilder.Append("</author>");
                oBuilder.Append("<link>");
                oBuilder.Append(sLink);
                oBuilder.Append("</link>");
                oBuilder.Append("<guid isPermaLink=\"true\">");
                oBuilder.Append(sGuid);
                oBuilder.Append("</guid>");
                oBuilder.Append("<description>");
                oBuilder.Append(sDescription.ParseTags().WrapCData());
                oBuilder.Append("</description>");
                oBuilder.Append("<pubDate>");
                oBuilder.Append(sPubDate);
                oBuilder.Append("</pubDate>");
                oBuilder.Append("</item>");
            }
        }
示例#25
0
        private string GetQuotedMessage()
        {
            switch (_type)
            {
            case "reply":
                ReplyInfo reply = Replies.GetReply(_recId);
                return(String.Format("[quote=\"{0}\"]{1}[/quote]", reply.AuthorName, reply.Message));

            case "topics":
                return(String.Format("[quote=\"{0}\"]{1}[/quote]", _thisTopic.AuthorName, _thisTopic.Message));
            }
            return(String.Empty);
        }
示例#26
0
        public async Task <IActionResult> Put(Replies value)
        {
            var entity = await _service.Update(value);

            if (entity != null)
            {
                return(Ok(entity));
            }
            else
            {
                return(BadRequest("something broke"));
            }
        }
示例#27
0
        protected override void ParseToEvent(Replies.Reply reply)
        {
            base.ParseToEvent(reply);

            string[] split = EventLine.Split(' ');

            Type = split[0];

            Name = split[1];

            Address = split[2];

            Port = split[3];
        }
示例#28
0
        public async Task <ActionResult <Replies> > Post(Replies value)
        {
            System.Diagnostics.Debug.WriteLine("Testing");
            var entity = await _service.Create(value);

            if (entity != null)
            {
                return(Ok(entity));
            }
            else
            {
                return(BadRequest("something broke "));
            }
        }
示例#29
0
        public static Message ApplyAndDisplay(ArcadeUser user, DailyResultFlag flag)
        {
            long           reward = Reward;
            string         header = $"{Reward:##,0}";
            ImmutableColor color  = ImmutableColor.GammaGreen;
            var            icon   = "+ 💸";

            switch (flag)
            {
            case DailyResultFlag.Cooldown:
                TimeSpan sinceLast = StatHelper.SinceLast(user, CooldownVars.Daily);
                TimeSpan rem       = Cooldown - sinceLast;
                DateTime time      = DateTime.UtcNow.Add(rem);

                color  = GammaPalette.Amber[Gamma.Max];
                header = Format.Countdown(rem);
                icon   = Icons.GetClock(time.Hour);
                break;

            case DailyResultFlag.Reset:
                color = GammaPalette.NeonRed[Gamma.Max];
                user.SetVar(Stats.DailyStreak, 0);
                break;

            case DailyResultFlag.Bonus:
                color   = GammaPalette.Glass[Gamma.Max];
                header += $" + {Bonus:##,0}";
                reward += Bonus;
                break;
            }

            if (flag != DailyResultFlag.Cooldown)
            {
                user.SetVar(CooldownVars.Daily, DateTime.UtcNow.Ticks);
                user.AddToVar(Stats.DailyStreak);
                user.AddToVar(Stats.TimesDaily);
                Var.SetIfGreater(user, Stats.LongestDailyStreak, Stats.DailyStreak);
                user.Give(reward);
            }

            var message  = new MessageBuilder();
            var embedder = Embedder.Default;

            embedder.Color   = color;
            embedder.Header  = $"**{icon} {header}**";
            message.Content  = $"*\"{Replies.GetReply(flag)}\"*";
            message.Embedder = embedder;

            return(message.Build());
        }
示例#30
0
        private void EditReply()
        {
            Replies.UpdateReply(_recId, Message.Text, Member, IsAdministrator, cbxSig.Checked);

            if (cbxLock.Checked && _inModeratedList)
            {
                Topics.SetTopicStatus(_thisTopic.Id, (int)Enumerators.PostStatus.Closed);
            }
            if (_inModeratedList)
            {
                Topics.MakeSticky(_thisTopic.Id, cbxSticky.Checked);
            }
            Response.Redirect("/Content/Forums/topic.aspx?TOPIC=" + TopicId + "&whichpage=-1#" + _recId);
        }
示例#31
0
            /// <inheritdoc/>
            public override int GetHashCode()
            {
                unchecked
                {
                    var hashCode = EqualityComparer <TS> .Default.GetHashCode(StateName);

                    hashCode = (hashCode * 397) ^ EqualityComparer <TD> .Default.GetHashCode(StateData);

                    hashCode = (hashCode * 397) ^ Timeout.GetHashCode();
                    hashCode = (hashCode * 397) ^ (StopReason != null ? StopReason.GetHashCode() : 0);
                    hashCode = (hashCode * 397) ^ (Replies != null ? Replies.GetHashCode() : 0);
                    return(hashCode);
                }
            }
示例#32
0
 public IEnumerable <Reply> GetReplies(bool isModerator)
 {
     if (isModerator)
     {
         return(Replies
                .OrderBy(x => x.PostedDate));
     }
     else
     {
         return(Replies
                .Where(x => !x.ModsOnly)
                .OrderBy(x => x.PostedDate));
     }
 }
示例#33
0
        protected override void ParseToEvent(Replies.Reply reply)
        {
            base.ParseToEvent(reply);

            int index = 0;
            string[] split = EventLine.Split(' ');

            Name = split[index];
            index++;

            for (int i = index; i < split.Length; i++)
            {
                if (split[i].Contains("="))
                {
                    string key = split[i].Split('=')[0];
                    string value = split[i].Split('=')[1];

                    switch (key.ToUpper())
                    {
                        case "ID":
                            ConnectionID = value;
                            break;
                        case "READ":
                            int r = 0;
                            int.TryParse(value, out r);
                            ReadBucket = r;
                            break;
                        case "WRITTEN":
                            int w = 0;
                            int.TryParse(value, out w);
                            WriteBucket = w;
                            break;
                        case "LAST":
                            int l = 0;
                            int.TryParse(value, out l);
                            LastRefill = l;
                            break;
                    }
                }
            }
        }
示例#34
0
        protected override void ParseToEvent(Replies.Reply reply)
        {
            base.ParseToEvent(reply);

            int index = 0;
            string[] split = EventLine.Split(' ');

            Action = Utility.ParseEnum<HsDescActions>(split[index]);
            index++;

            Address = split[index];
            index++;

            AuthType = Utility.ParseEnum<HsDescAuthTypes>(split[index]);
            index++;

            Name = split[index];
            index++;

            if (!split[index].Contains("="))
            {
                DescriptorID = split[index];
                index++;
            }

            for (int i = index; i < split.Length; i++)
            {
                if (split[i].Contains("="))
                {
                    string key = split[i].Split('=')[0];
                    string value = split[i].Split('=')[1];

                    switch (key.ToUpper())
                    {
                        case "REASON":
                            Reason = value;
                            break;
                    }
                }
            }
        }
        public void EnumerateFoldedComments_Works()
        {
            Replies cs = new Replies();
            Comment a = new Comment() { Id = 11, IsFull = false, Text = String.Empty };
            Comment a_b = new Comment() { Id = 12, IsFull = true, Text = "2" };
            Comment a_b_c = new Comment() { Id = 13, IsFull = false, Text = String.Empty };
            Comment a_d = new Comment() { Id = 14, IsFull = false, Text = String.Empty };

            cs.Comments.Add(a);
            a.Replies.Comments.Add(a_b);
            a.Replies.Comments.Add(a_d);
            a_b.Replies.Comments.Add(a_b_c);

            long[] texts = _rh.EnumerateRequiringFullUp(cs).Select(z => z.Id).ToArray();
            Assert.AreEqual(3, texts.Length, "Should've found 3 comments.");
            CollectionAssert.AreEqual(new long[] { 11, 13, 14 }, texts, "Collections match.");

            Assert.AreEqual(1, _rh.EnumerateFull(cs).Count(), "Should've found 1 comment.");

            Assert.AreEqual(4, _rh.EnumerateAll(cs).Count(), "Should've found 4 comments.");

        }
示例#36
0
 protected override void ParseToEvent(Replies.Reply reply)
 {
     base.ParseToEvent(reply);
 }
示例#37
0
        protected override void ParseToEvent(Replies.Reply reply)
        {
            base.ParseToEvent(reply);

            Status = EventLine;
        }
        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);
        }