示例#1
0
        public int SMGSendMessage(List <int> UList, string subject, string message, string sessionUser)
        {
            using (TransactionScope scope1 = new TransactionScope())
            {
                try
                {
                    MongoClient mongoClient = InitializeMongoClient();
                    _UserDetailsBusinessLogic = new UserDetailsBusinessLogic();

                    var mongoDatabase = mongoClient.GetDatabase(mongoDBTargetDatabase);

                    var UserVar       = mongoDatabase.GetCollection <SystemUser>("SystemUser").AsQueryable().ToList();
                    int sessionUserID = UserVar.AsQueryable().First(s => s.Username.ToLower() == sessionUser.ToLower()).UserId;

                    int parentMessageID = SMGGetNewMessageID();
                    foreach (int Uid in UList)
                    {
                        var MessageCollection = mongoDatabaseRunTime.GetCollection <ErrorLogDataAccess.DataClasses.UserMessage>("UserMessage");
                        var messageRow        = new ErrorLogDataAccess.DataClasses.UserMessage()
                        {
                            UserMessageId       = SMGGetNewMessageID(),
                            ParentUserMessageId = parentMessageID,
                            MessageSubject      = subject,
                            MessageBody         = message,
                            IsMessageRead       = false,
                            SentUserId          = sessionUserID,
                            ReceivedUserId      = Uid,
                            MessageSentDate     = DateTime.Now
                        };
                        MessageCollection.InsertOne(messageRow);
                    }

                    rnd = new Random();
                    string requestId = rnd.Next(1, 1000).ToString();

                    string sessionUserName = _UserDetailsBusinessLogic.GetUserDetails(sessionUserID)
                                             .FirstOrDefault().Username;
                    string msgSubject = sessionUserName + " sent you  a message";
                    string msgBody    = "Click the following link and navigate to 'Message Portal 'to view the message" + Environment.NewLine +
                                        userMessageEmailLink + requestId;

                    MailMessage msg = CommonCommunicationBusinessLogic.ConstructEmail(msgSubject, msgBody, UList);
                    CommonCommunicationBusinessLogic.SendEmail(msg);


                    scope1.Complete();
                    return(0);
                }
                catch (Exception ex)
                {
                    scope1.Dispose();
                    throw;
                }
            }
        }
示例#2
0
        public JsonResult GetRedirectedUserDetails()
        {
            FormsAuthenticationTicket ticket = null;

            try
            {
                _UserDetailsBusinessLogic = new UserDetailsBusinessLogic();

                HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];

                if (authCookie != null)
                {
                    ticket = FormsAuthentication.Decrypt(authCookie.Value);

                    if (redirectedUserId == 0)
                    {
                        var userDetails = _UserDetailsBusinessLogic.GetUserDetails(ticket.Name).ToArray();

                        return(Json(userDetails));
                    }
                    else
                    {
                        var userDetails = _UserDetailsBusinessLogic.GetUserDetails(redirectedUserId).ToArray();

                        return(Json(userDetails));
                    }
                }
                else
                {
                    return(Json(null));
                }
            }
            catch (Exception ex)
            {
                currentFile = this.ControllerContext.RouteData.Values["controller"].ToString(); // System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName();
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                methodName = sf.GetMethod().Name;
                ErrorLogHelper.UpdatingErrorLog(currentFile + "-" + methodName, ticket == null ? "N/A" : ticket.Name, ex);
                return(Json(null));
            }
        }
        public ActionResult Index()
        {
            FormsAuthenticationTicket ticket = null;

            try
            {
                _UserDetailsBusinessLogic = new UserDetailsBusinessLogic();
                // string LoginUserType = System.Web.HttpContext.Current.Session["LoginUserType"].ToString();
                HttpCookie authCookie = System.Web.HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];
                if (authCookie != null)
                {
                    ticket = FormsAuthentication.Decrypt(authCookie.Value);

                    if (_UserDetailsBusinessLogic.GetUserType(ticket.Name).ToLower().Trim() == "administrator")
                    {
                        ViewBag.ProfilePicURL = _UserDetailsBusinessLogic.GetUserDetails(ticket.Name)
                                                .FirstOrDefault().ProfilePicURL;
                        ViewBag.Username         = ticket.Name;
                        ViewBag.UserType         = _UserDetailsBusinessLogic.GetUserType(ticket.Name).ToLower().Trim();
                        ViewBag.RedirectedUserId = "0";


                        return(View());
                    }
                    else
                    {
                        this.HttpContext.Session["ErrorMsg"] = "AccessDeniedError";
                        return(RedirectToAction("Index", "LoginError"));
                    }
                }
                else
                {
                    this.HttpContext.Session["ErrorMsg"] = "LoginErr";
                    return(RedirectToAction("Index", "Login"));
                }
            }
            catch (Exception ex)
            {
                currentFile = this.ControllerContext.RouteData.Values["controller"].ToString(); // System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName();
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                methodName = sf.GetMethod().Name;
                ErrorLogHelper.UpdatingErrorLog(currentFile + "-" + methodName, ticket == null ? "N/A" : ticket.Name, ex);

                this.HttpContext.Session["ErrorMsg"] = "PageLoadError";
                return(RedirectToAction("Index", "LoginError"));
            }
        }
        public ActionResult Index()
        {
            try
            {
                HttpCookie authCookie = System.Web.HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];
                if (authCookie != null)
                {
                    _UserDetailsBusinessLogic = new UserDetailsBusinessLogic();

                    FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value);

                    ViewBag.ProfilePicURL = _UserDetailsBusinessLogic.GetUserDetails(ticket.Name)
                                            .FirstOrDefault().ProfilePicURL;
                    ViewBag.Username = ticket.Name;
                    ViewBag.UserType = _UserDetailsBusinessLogic.GetUserType(ticket.Name).ToLower().Trim();

                    return(View());
                }
                else
                {
                    this.HttpContext.Session["ErrorMsg"] = "LoginErr";
                    return(RedirectToAction("Index", "Login"));
                }
            }
            catch (Exception ex)
            {
                currentFile = new System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName();
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                methodName = sf.GetMethod().Name;
                ErrorLogHelper.UpdatingErrorLog(currentFile + "-" + methodName, "UName", ex);


                this.HttpContext.Session["ErrorMsg"] = "PageLoadError";
                return(RedirectToAction("Index", "LoginError"));
            }
        }
示例#5
0
        private static List <SystemUser> GetToEMailAdresses(List <int> userList)
        {
            UserDetailsBusinessLogic _UserDetailsBusinessLogic = new UserDetailsBusinessLogic();

            return(_UserDetailsBusinessLogic.GetUserDetails(userList));
        }
        public ActionResult Index(string requestId = null)
        {
            FormsAuthenticationTicket ticket = null;

            try
            {
                _UserDetailsBusinessLogic = new UserDetailsBusinessLogic();
                HttpCookie authCookie = System.Web.HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];
                ViewBag.RequestId = requestId;
                bool isSessionTicketDecryptable = true;


                if (authCookie != null)
                {
                    try
                    {
                        ticket = FormsAuthentication.Decrypt(authCookie.Value);
                    }
                    catch (Exception ex)
                    {
                        isSessionTicketDecryptable = false;
                    }

                    if (isSessionTicketDecryptable == true)
                    {
                        ViewBag.ProfilePicURL = _UserDetailsBusinessLogic.GetUserDetails(ticket.Name)
                                                .FirstOrDefault().ProfilePicURL;
                        ViewBag.Username = ticket.Name;
                        ViewBag.UserType = _UserDetailsBusinessLogic.GetUserType(ticket.Name).ToLower().Trim();
                        return(View());
                    }
                    else
                    {
                        return(RedirectToAction("Index", "Login", new RouteValueDictionary(new { id = "RedirectedLogin", userMsgRequestIdParam = requestId })));
                    }
                }
                else
                {
                    if (requestId != null)
                    {
                        return(RedirectToAction("Index", "Login", new RouteValueDictionary(new { id = "RedirectedLogin", userMsgRequestIdParam = requestId })));
                    }
                    else
                    {
                        this.HttpContext.Session["ErrorMsg"] = "LoginErr";
                        return(RedirectToAction("Index", "LoginError"));
                    }
                }
            }
            catch (Exception ex)
            {
                currentFile = new System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName();
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(1);
                methodName = sf.GetMethod().Name;
                ErrorLogHelper.UpdatingErrorLog(currentFile + "-" + methodName, "UName", ex);

                this.HttpContext.Session["ErrorMsg"] = "PageLoadError";
                return(RedirectToAction("Index", "LoginError"));
            }
        }