示例#1
0
        /// <summary>
        ///  get the selected mail mode details(inbox,trash,sent)
        /// </summary>
        /// <param name="mailMode"></param>
        /// <returns>return the selected mai mode details in the form of table </returns>
        public string GetMessageContent(string mailMode, int pageNum, int pageSize, string searchKeyWord)
        {
            StringBuilder strContent = new StringBuilder();

            DataControl.CurrentInfo objCurInfo = new DataControl.CurrentInfo();
            DataControl.BLMessaging objMsg     = new DataControl.BLMessaging();
            strContent.Append(" <table cellspacing=0 cellpadding=0 class='table table-email'> <tbody>");
            int totalPageCount = 0;

            try
            {
                List <MVCModels.MessagingModel> lstMsg = new List <MVCModels.MessagingModel>();
                if ("INBOX" == mailMode.ToUpper())
                {
                    lstMsg = new List <MVCModels.MessagingModel>(objMsg.GetMsgInboxContent(objCurInfo.GetCompanyCode(), objCurInfo.GetUserCode(),
                                                                                           pageNum, pageSize, searchKeyWord, ref totalPageCount));
                }
                else if ("SENT" == mailMode.ToUpper())
                {
                    lstMsg = new List <MVCModels.MessagingModel>(objMsg.GetMsgSentContent(objCurInfo.GetCompanyCode(), objCurInfo.GetUserCode(),
                                                                                          pageNum, pageSize, searchKeyWord, ref totalPageCount));
                }
                else if ("DRAFTED" == mailMode.ToUpper())
                {
                    lstMsg = new List <MVCModels.MessagingModel>(objMsg.GetMsgDraftedContent(objCurInfo.GetCompanyCode(), objCurInfo.GetUserCode(),
                                                                                             pageNum, pageSize, searchKeyWord, ref totalPageCount));
                }
                else if ("UNREAD" == mailMode.ToUpper())
                {
                    lstMsg = new List <MVCModels.MessagingModel>(objMsg.GetMsgUnreadContent(objCurInfo.GetCompanyCode(), objCurInfo.GetUserCode(),
                                                                                            pageNum, pageSize, searchKeyWord, ref totalPageCount));
                }
                else
                {
                    lstMsg = new List <MVCModels.MessagingModel>(objMsg.GetMsgDeletedContent(objCurInfo.GetCompanyCode(), objCurInfo.GetUserCode(),
                                                                                             pageNum, pageSize, searchKeyWord, ref totalPageCount));
                }
                if (lstMsg.Count > 0)
                {
                    if ("DRAFTED" == mailMode.ToUpper())
                    {
                        var filterdList = lstMsg.AsEnumerable().Select(x => x.Msg_Code).Distinct().ToList();
                        // totalPageCount = filterdList.Count;
                        int i = 0;
                        foreach (var dr in filterdList)
                        {
                            var           detailsList = lstMsg.AsEnumerable().Where(z => z.Msg_Code == dr.ToString()).ToList();
                            StringBuilder strTousers  = new StringBuilder();
                            foreach (var li in detailsList)
                            {
                                strTousers.Append(li.Employee_Name + ",");
                            }
                            strTousers.ToString().TrimEnd(',');
                            i++;
                            strContent.Append("<tr>");
                            strContent.Append("<td>");
                            strContent.Append("<div>");
                            strContent.Append("<input type='checkbox' name='chkSelect' id='chkMsg_" + i + "' value='"
                                              + dr.ToString() + "~'>");
                            strContent.Append("<label for='chkMsg_" + i + "'></label>");
                            strContent.Append("</div>");
                            strContent.Append("</td>");
                            strContent.Append("<td>");
                            strContent.Append("<a href='#' class='star'><i class='glyphicon glyphicon-star'></i></a>");
                            strContent.Append("</td>");
                            strContent.Append("<td onclick='fnShowMailDetails(\"" + dr.ToString() + "\",\"\");'>");
                            strContent.Append("<div class='media'>");
                            strContent.Append("<a href='#' class='pull-left'>");
                            strContent.Append("<img alt='' src='Images/default_user.jpg' class='media-object userImg'>");
                            strContent.Append("</a>");
                            strContent.Append("<div class='media-body'>");
                            if (strTousers.Length > 150)
                            {
                                strContent.Append("<h4 class='text-primary'>" + strTousers.ToString().TrimEnd(',').Substring(0, 150) + "..." + "</h4>");
                            }
                            else
                            {
                                strContent.Append("<h4 class='text-primary'>" + strTousers.ToString().TrimEnd(',') + "</h4>");
                            }

                            strContent.Append("<small class='text-muted'></small>");
                            strContent.Append("<p class='email-summary'>");
                            strContent.Append("" + detailsList[0].Subject + "</p>");
                            strContent.Append("</div>");
                            strContent.Append("</div>");
                            strContent.Append("</td>");
                            if (!string.IsNullOrEmpty(detailsList[0].Attachment_Path1))
                            {
                                strContent.Append("<td onclick='fnShowMailDetails(\"" + dr.ToString()
                                                  + "\",\"\");'><i class='glyphicon glyphicon-paperclip'></i></td>");
                            }
                            else
                            {
                                strContent.Append("<td></td>");
                            }
                            strContent.Append("<td onclick='fnShowMailDetails(\"" + dr.ToString() + "\",\"\");'><span class='media-meta pull-right'>"
                                              + detailsList[0].Date_From + "</span></td>");
                            strContent.Append("</tr>");
                        }
                    }
                    else if ("SENT" == mailMode.ToUpper())
                    {
                        var filterdList = lstMsg.AsEnumerable().Select(x => x.Msg_Code).Distinct().ToList();
                        // totalPageCount = filterdList.Count;
                        int i = 0;
                        foreach (var dr in filterdList)
                        {
                            var           detailsList = lstMsg.AsEnumerable().Where(z => z.Msg_Code == dr.ToString()).ToList();
                            StringBuilder strTousers  = new StringBuilder();
                            foreach (var li in detailsList)
                            {
                                strTousers.Append(li.Employee_Name + ",");
                            }
                            strTousers.ToString().TrimEnd(',');
                            i++;
                            strContent.Append("<tr>");
                            strContent.Append("<td>");
                            strContent.Append("<div>");
                            strContent.Append("<input type='checkbox' name='chkSelect' id='chkMsg_" + i + "' value='"
                                              + dr.ToString() + "~" + objCurInfo.GetUserCode() + "'>");
                            strContent.Append("<label for='chkMsg_" + i + "'></label>");
                            strContent.Append("</div>");
                            strContent.Append("</td>");
                            strContent.Append("<td>");
                            strContent.Append("<a href='#' class='star'><i class='glyphicon glyphicon-star'></i></a>");
                            strContent.Append("</td>");
                            strContent.Append("<td onclick='fnShowMailDetails(\"" + dr.ToString() + "\",\"" + objCurInfo.GetUserCode() + "\");'>");
                            strContent.Append("<div class='media'>");
                            strContent.Append("<a href='#' class='pull-left'>");
                            strContent.Append("<img alt='' src='Images/default_user.jpg' class='media-object userImg'>");
                            strContent.Append("</a>");
                            strContent.Append("<div class='media-body'>");
                            if (strTousers.Length > 150)
                            {
                                strContent.Append("<h4 class='text-primary'>" + strTousers.ToString().TrimEnd(',').Substring(0, 150) + "..." + "</h4>");
                            }
                            else
                            {
                                strContent.Append("<h4 class='text-primary'>" + strTousers.ToString().TrimEnd(',') + "</h4>");
                            }

                            strContent.Append("<small class='text-muted'></small>");
                            strContent.Append("<p class='email-summary'>");
                            strContent.Append("" + detailsList[0].Subject + "</p>");
                            strContent.Append("</div>");
                            strContent.Append("</div>");
                            strContent.Append("</td>");
                            if (!string.IsNullOrEmpty(detailsList[0].Attachment_Path1))
                            {
                                strContent.Append("<td onclick='fnShowMailDetails(\"" + dr.ToString()
                                                  + "\",\"" + objCurInfo.GetUserCode() + "\");'><i class='glyphicon glyphicon-paperclip'></i></td>");
                            }
                            else
                            {
                                strContent.Append("<td></td>");
                            }
                            strContent.Append("<td onclick='fnShowMailDetails(\"" + dr.ToString() + "\",\"" + objCurInfo.GetUserCode() + "\");'><span class='media-meta pull-right'>"
                                              + detailsList[0].Date_From + "</span></td>");
                            strContent.Append("</tr>");
                        }
                    }
                    else if ("UNREAD" == mailMode.ToUpper())
                    {
                        int i = 0;
                        foreach (var dr in lstMsg)
                        {
                            i++;

                            strContent.Append("<tr class='read'>");
                            strContent.Append("<td>");
                            strContent.Append("<div>");
                            strContent.Append("<input type='checkbox' name='chkSelect' id='chkMsg_" + i + "' value='" + dr.Msg_Code + "~" + dr.Target_Address + "'>");
                            strContent.Append("<label for='chkMsg_" + i + "'></label>");
                            strContent.Append("</div>");
                            strContent.Append("</td>");
                            strContent.Append("<td>");
                            strContent.Append("<a href='#' class='star'><i class='glyphicon glyphicon-star'></i></a>");
                            strContent.Append("</td>");
                            strContent.Append("<td onclick='fnShowMailDetails(\"" + dr.Msg_Code + "\",\"" + dr.Target_Address + "\");'>");
                            strContent.Append("<div class='media'>");
                            strContent.Append("<a href='#' class='pull-left'>");
                            strContent.Append("<img alt='' src='Images/default_user.jpg' class='media-object userImg'>");
                            strContent.Append("</a>");
                            strContent.Append("<div class='media-body'>");
                            strContent.Append("<h4 class='text-primary'>" + dr.Employee_Name + "(" + dr.User_Name + ")</h4>");
                            strContent.Append("<small class='text-muted'></small>");
                            strContent.Append("<p class='email-summary'>");
                            strContent.Append("" + dr.Subject + "</p>");
                            strContent.Append("</div>");
                            strContent.Append("</div>");
                            strContent.Append("</td>");
                            if (!string.IsNullOrEmpty(dr.Attachment_Path1))
                            {
                                strContent.Append("<td onclick='fnShowMailDetails(\"" + dr.Msg_Code + "\",\""
                                                  + dr.Target_Address + "\");'><i class='glyphicon glyphicon-paperclip'></i></td>");
                            }
                            else
                            {
                                strContent.Append("<td></td>");
                            }
                            strContent.Append("<td onclick='fnShowMailDetails(\"" + dr.Msg_Code + "\",\""
                                              + dr.Target_Address + "\");'><span class='media-meta pull-right'>"
                                              + dr.Date_From + "</span></td>");
                            strContent.Append("</tr>");
                        }
                    }
                    else
                    {
                        int i = 0;
                        foreach (var dr in lstMsg)
                        {
                            i++;
                            string clsUnread = "";
                            // if (dr.IsRead == "0" && "INBOX" == mailMode.ToUpper())
                            if (dr.IsRead == "0")
                            {
                                clsUnread = "read";
                            }
                            else
                            {
                                clsUnread = "unread";
                            }
                            strContent.Append("<tr class='" + clsUnread + "'>");
                            strContent.Append("<td>");
                            strContent.Append("<div>");
                            strContent.Append("<input type='checkbox' name='chkSelect' id='chkMsg_" + i + "' value='" + dr.Msg_Code + "~" + dr.Target_Address + "'>");
                            strContent.Append("<label for='chkMsg_" + i + "'></label>");
                            strContent.Append("</div>");
                            strContent.Append("</td>");
                            strContent.Append("<td>");
                            strContent.Append("<a href='#' class='star'><i class='glyphicon glyphicon-star'></i></a>");
                            strContent.Append("</td>");
                            strContent.Append("<td onclick='fnShowMailDetails(\"" + dr.Msg_Code + "\",\"" + dr.Target_Address + "\");'>");
                            strContent.Append("<div class='media'>");
                            strContent.Append("<a href='#' class='pull-left'>");
                            strContent.Append("<img alt='' src='Images/default_user.jpg' class='media-object userImg'>");
                            strContent.Append("</a>");
                            strContent.Append("<div class='media-body'>");
                            strContent.Append("<h4 class='text-primary'>" + dr.Employee_Name + "(" + dr.User_Name + ")</h4>");
                            strContent.Append("<small class='text-muted'></small>");
                            strContent.Append("<p class='email-summary'>");
                            strContent.Append("" + dr.Subject + "</p>");
                            strContent.Append("</div>");
                            strContent.Append("</div>");
                            strContent.Append("</td>");
                            if (!string.IsNullOrEmpty(dr.Attachment_Path1))
                            {
                                strContent.Append("<td onclick='fnShowMailDetails(\"" + dr.Msg_Code + "\",\""
                                                  + dr.Target_Address + "\");'><i class='glyphicon glyphicon-paperclip'></i></td>");
                            }
                            else
                            {
                                strContent.Append("<td></td>");
                            }
                            strContent.Append("<td onclick='fnShowMailDetails(\"" + dr.Msg_Code + "\",\""
                                              + dr.Target_Address + "\");'><span class='media-meta pull-right'>"
                                              + dr.Date_From + "</span></td>");
                            strContent.Append("</tr>");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                DataControl.Impl.ExceptionHandler.WriteLog(ex, null);
            }
            strContent.Append("</tbody></table>");
            return(strContent.ToString() + "á" + totalPageCount); //ALT+160 = á
        }