Ejemplo n.º 1
0
        /// <summary>
        /// 拒绝文章首页申请
        /// </summary>
        /// <param name="ArticleId"></param>
        /// <returns></returns>
        public ActionResult Reject()
        {
            if (Session[ConstHelper.Session_USERID] == null)
            {
                return(Redirect("/"));
            }
            if ((UserType)Session[ConstHelper.Session_PRIVILEGE] != UserType.Admin &&
                (UserType)Session[ConstHelper.Session_PRIVILEGE] != UserType.Editor)
            {
                return(Redirect("/"));
            }

            string strMessage = Request.Form["message"];
            string ArticleId  = Request.Form["ArticleID"];

            if (string.IsNullOrEmpty(ArticleId))
            {
                return(Redirect("/"));
            }
            if (Article.GetArticleBySn(ArticleId) == null)
            {
                return(Redirect("/"));
            }
            if (string.IsNullOrEmpty(strMessage))
            {
                return(Redirect("/"));
            }
            Article.Reject(ArticleId, strMessage);
            Article article    = Article.GetArticleBySn(ArticleId);
            var     articleurl = "<a href = '/PostEdit/MarkDownEditor?ArticleId=" + article.Sn + "'>" + article.Title + "</a>";

            SiteMessage.CreateNotify(article.OwnerId, "您的文章[" + articleurl + "]没有通过审核,理由:" + strMessage);
            return(Redirect("/Admin"));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 接受文章被收录到某主题(操作人是文章的拥有者)
        /// </summary>
        /// <param name="TopicOwnerId"></param>
        /// <param name="ArticleId"></param>
        /// <returns></returns>
        public ActionResult AcceptTopic(string TopicOwnerId, string ArticleId, string MessageId)
        {
            if (Session[ConstHelper.Session_USERID] == null)
            {
                return(Redirect("/"));
            }
            string accountid = Session[ConstHelper.Session_USERID].ToString();
            var    article   = Article.GetArticleBySn(ArticleId);

            if (article == null)
            {
                SiteMessage.CloseMessage(MessageId, accountid, "没有发现文章");
            }
            else
            {
                if (accountid != article.OwnerId)
                {
                    return(Redirect("/"));
                }
                TopicArticle.ChangeTopicStatus(TopicOwnerId, ArticleId, true);
                SiteMessage.CreateNotify(TopicOwnerId, "您的收录请求被接受,[" + article.Title + "]被收录到您的文集中", accountid);
                SiteMessage.CloseMessage(MessageId, accountid, "接受");
            }
            return(Redirect("/Author/SiteMessageList"));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 拒绝文章被收录到某主题(操作人是专题的拥有者)
        /// </summary>
        /// <param name="TopicOwnerId"></param>
        /// <param name="ArticleId"></param>
        /// <returns></returns>
        public ActionResult RefuseActicle(string TopicId, string ArticleId, string MessageId)
        {
            if (Session[ConstHelper.Session_USERID] == null)
            {
                return(Redirect("/"));
            }
            string accountid = Session[ConstHelper.Session_USERID].ToString();
            var    article   = Article.GetArticleBySn(ArticleId);
            var    topic     = Topic.GetTopicBySn(TopicId);

            if (article == null || topic == null)
            {
                SiteMessage.CloseMessage(MessageId, accountid, "没有发现文章或者主题");
            }
            else
            {
                if (accountid != topic.OwnerId)
                {
                    return(Redirect("/"));
                }
                TopicArticle.ChangeTopicStatus(topic.OwnerId, ArticleId, false);
                SiteMessage.CreateNotify(article.OwnerId, "您的收录请求被拒绝,[" + article.Title + "]没有被收录到文集中", accountid);
                SiteMessage.CloseMessage(MessageId, accountid, "拒绝");
            }
            return(Redirect("/Author/SiteMessageList"));
        }
Ejemplo n.º 4
0
        //Load page to configure a widget
        public ActionResult Configure()
        {
            AppUser user = AccountServices.GetCurrentUser();

            if (user == null || user.Id == 0)
            {
                SiteMessage msg = new SiteMessage();
                msg.Title              = "ERROR - you are not authorized for this action.";
                msg.Message            = "<a href='/Account/Login'>Please log in</a>to enable managing widgets.";
                Session["siteMessage"] = msg.Message;

                return(RedirectToAction("About", "Home"));
            }
            if (user.Organizations != null && (user.Organizations.Count > 0 || AccountServices.IsUserSiteStaff(user)))
            {
                return(View("~/Views/Widget/Configure.cshtml", new Widget()));
            }
            else
            {
                SiteMessage msg = new SiteMessage()
                {
                    Title = "Not Authorized to Access Widgets", Message = "You must be associated with an approved Credential Engine organization in order to create Widgets. Please ensure your organization is registered with the Credential Engine accounts site, and it is approved to create widgets. "
                };
                Session["SystemMessage"] = msg;
                return(RedirectToAction("Index", "Message"));
            }
        }
        // GET: Base
        //public ActionResult Index()
        //{
        //	return View();
        //}

        protected void SetSystemMessage(string title, string message, string messageType = "success")
        {
            SiteMessage msg = new SiteMessage()
            {
                Title = title, Message = message, MessageType = messageType
            };

            Session["SystemMessage"] = msg;
        }
        protected void SetPopupMessage(string message, string messageType = "info")
        {
            SiteMessage msg = new SiteMessage()
            {
                Message = message, MessageType = messageType
            };

            Session["popupMessage"] = msg;
        }
        protected void SetPopupSuccessMessage(string message)
        {
            SiteMessage msg = new SiteMessage()
            {
                Message = message, MessageType = "success"
            };

            Session["popupMessage"] = msg;
        }
        protected void SetPopupErrorMessage(string message)
        {
            SiteMessage msg = new SiteMessage()
            {
                Message = message, MessageType = "error"
            };

            Session["popupMessage"] = msg;
        }
        public async Task <bool> Handle(SendMessageCommand request, CancellationToken cancellationToken)
        {
            var message    = new SiteMessage(request.Content, request.SenderId, request.ReciverId);
            var messagebox = await repository.GetOrCreateAsync(message.ReceiverId);

            messagebox.Send(message);
            await repository.UnitOfWork.CommitAsync();

            return(true);
        }
Ejemplo n.º 10
0
        public async Task <ActionResult> ConfirmEmail(string userId, string code)
        {
            if (userId == null || code == null)
            {
                SiteMessage msg = new SiteMessage()
                {
                    Title = "Invalid Confirmation Information", Message = "Sorry, that confirmation information was invalid."
                };
                Session["SystemMessage"] = msg;
                return(RedirectToAction("Index", "Message"));
                //return View( "Error" );
            }

            if (!AccountServices.Proxy_IsCodeActive(code))
            {
                SiteMessage msg = new SiteMessage()
                {
                    Title = "Invalid Confirmation Code", Message = "The confirmation code is invalid or has expired."
                };
                Session["SystemMessage"] = msg;
                return(RedirectToAction("Index", "Message"));
            }

            var result = await UserManager.ConfirmEmailAsync(userId, code);

            if (result.Succeeded)
            {
                new AccountServices().Proxy_SetInactivate(code);

                //activate user
                new AccountServices().ActivateUser(userId);
                //return View( "ConfirmEmail" );
                return(View("~/Views/Account/ConfirmEmail.cshtml"));
            }
            else
            {
                AddErrors(result);
                SiteMessage msg = new SiteMessage()
                {
                    Title = "Confirmation Failed"
                };
                if (result.Errors != null && result.Errors.Count() > 0)
                {
                    msg.Message = "Confirmation of email failed: " + result.Errors.ToString();
                }
                else
                {
                    msg.Message = "Confirmation of email failed ";
                }

                Session["SystemMessage"] = msg;
                return(RedirectToAction("Index", "Message"));
            }
        }         //
Ejemplo n.º 11
0
 public async Task <IActionResult> PutMessage(int id, SiteMessage message)
 {
     try
     {
         await _context.EditMessage(id, message);
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
     return(NoContent());
 }
Ejemplo n.º 12
0
        public async Task EditMessage(int id, SiteMessage message)
        {
            var oldMessage = await _context.SiteMessages.FindAsync(id);

            if (oldMessage == null)
            {
                throw new Exception("Site Message not found.");
            }

            oldMessage.Text = message.Text;
            _context.Update(oldMessage);
            await _context.SaveChangesAsync();
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 站内消息
        /// </summary>
        /// <returns></returns>
        public ActionResult SiteMessageList(int PageNo = 1)
        {
            if (Session[ConstHelper.Session_USERID] == null)
            {
                return(Redirect("/"));
            }
            var   msglist = SiteMessage.GetMessage(Session[ConstHelper.Session_USERID].ToString());
            Pages p       = new Pages(msglist.Count, 50);

            p.CurrentPageNo = PageNo;
            ViewBag.Pages   = p;
            ViewData.Model  = p.GetList(msglist);
            ViewBag.Title   = "消息";
            return(View());
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 移出首页
        /// </summary>
        /// <param name="ArticleId"></param>
        /// <returns></returns>
        public ActionResult RemoveFromFirstPage(string ArticleId)
        {
            if (Session[ConstHelper.Session_USERID] == null || (UserType)Session[ConstHelper.Session_PRIVILEGE] != UserType.Admin)
            {
                return(Redirect("/"));
            }
            if (string.IsNullOrEmpty(ArticleId))
            {
                return(Redirect("/"));
            }
            Article.Reject(ArticleId, "移出首页");
            Article article    = Article.GetArticleBySn(ArticleId);
            var     articleurl = "<a href = '/PostEdit/MarkDownEditor?ArticleId=" + article.Sn + "'>" + article.Title + "</a>";

            SiteMessage.CreateNotify(article.OwnerId, "您的文章[" + articleurl + "]被移出首页");
            return(Redirect("/Admin/ArticleList?PageNo=1"));
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 投稿文章到专题
        /// </summary>
        /// <param name="TopicId"></param>
        /// <param name="ArticleId"></param>
        /// <returns></returns>
        public ActionResult PostArticle(string TopicId, string ArticleId)
        {
            if (Session[ConstHelper.Session_USERID] == null)
            {
                return(Redirect("/Home/Index"));
            }
            string accountid = Session[ConstHelper.Session_USERID].ToString();
            var    article   = Article.GetArticleBySn(ArticleId);

            if (article.OwnerId != accountid)
            {
                return(Redirect("/"));
            }
            var topic = Topic.GetTopicBySn(TopicId);

            if (topic == null || (!topic.IsPostable))
            {
                return(Redirect("/"));
            }
            if (topic.IsNeedApproval)
            {
                TopicArticle.InsertTopicArticle(new TopicArticle()
                {
                    ArticleID     = ArticleId,
                    TopicID       = TopicId,
                    PublishStatus = ApproveStatus.Pending
                });
                var parm       = "TopicId=" + topic.Sn + "&ArticleId=" + ArticleId;
                var articleurl = "<a href = '/Article/Index?ArticleId=" + article.Sn + "'>" + article.Title + "</a>";
                var topicurl   = "<a href = '/Author/TopicPage?accountid=" + topic.OwnerId + "'>" + topic.Title + "</a>";
                SiteMessage.CreateYesNo(topic.OwnerId, articleurl + "请求投稿到专题" + topicurl, "/Author/AcceptActicle?" + parm, "/Author/RefuseActicle?" + parm, accountid);
            }
            else
            {
                TopicArticle.InsertTopicArticle(new TopicArticle()
                {
                    ArticleID     = ArticleId,
                    TopicID       = TopicId,
                    PublishStatus = ApproveStatus.Accept
                });
            }
            return(Redirect("/Author/PostToTopic?TopicId=" + TopicId));
        }
Ejemplo n.º 16
0
 public ActionResult MessageBase(SiteMessage p_sul)
 {
     SiteMessage m_su = SiteMessage.GetModel(t => t.id != 0);
     if (IsGet)
     {
         SetSaveFormCollection = b_BLL_SiteMessage.NameValueCollectionEx(ref m_su);
     }
     if (IsPost)
         try
         {
             p_sul.id = m_su.id;
             b_BLL_SiteMessage.AESiteMessage(this, true, ref p_sul);
         }
         catch (Exception ce)
         {
             IsSaveForm = true;
             ExceptionEx.MyExceptionLog.WriteLog(this, ce);
         }
     return View(p_sul ?? new SiteMessage());
 }
Ejemplo n.º 17
0
        /// <summary>
        /// 接受文章首页申请
        /// </summary>
        /// <param name="ArticleId"></param>
        /// <returns></returns>
        public ActionResult Accept(string ArticleId)
        {
            if (string.IsNullOrEmpty(ArticleId))
            {
                return(Redirect("/"));
            }
            if (Session[ConstHelper.Session_USERID] == null)
            {
                return(Redirect("/"));
            }
            if ((UserType)Session[ConstHelper.Session_PRIVILEGE] != UserType.Admin &&
                (UserType)Session[ConstHelper.Session_PRIVILEGE] != UserType.Editor)
            {
                return(Redirect("/"));
            }

            if (Article.GetArticleBySn(ArticleId) == null)
            {
                return(Redirect("/"));
            }
            Article.Accept(ArticleId);
            Article article    = Article.GetArticleBySn(ArticleId);
            var     articleurl = "<a href = '/Article/Index?ArticleId=" + article.Sn + "'>" + article.Title + "</a>";

            SiteMessage.CreateNotify(article.OwnerId, "您的文章[" + articleurl + "]通过审核");
            if (article.IsPutToMyTopic)
            {
                //发布后则加入到自己专题
                var topic = Topic.GetTopicByAccountId(article.OwnerId);
                if (topic != null)
                {
                    TopicArticle.InsertTopicArticle(new TopicArticle()
                    {
                        ArticleID     = article.Sn,
                        TopicID       = topic.Sn,
                        PublishStatus = ApproveStatus.NotNeed
                    });
                }
            }
            return(Redirect("/Admin"));
        }
        // POST api/<controller>
        public IHttpActionResult Post([FromBody] RegistrationRequest request)
        {
            var validators = new Validator <RegistrationRequest>[]
            {
                new PaymentAmountValidator(decimal.Parse(ConfigurationManager.AppSettings["MinPaymentAmount"]),
                                           decimal.Parse(ConfigurationManager.AppSettings["MaxPaymentAmount"])),
                new PhoneValidator(),
                new EmailValidator()
            };

            ClassRegistration registration = ClassRegistration.Process(request, validators);

            if (registration.IsValid)
            {
                StringBuilder body = new StringBuilder();
                body.AppendFormat("<p>This e-mail is a notification that the class registration process has started.  This notification <strong>does not indicate</strong> that the customer has successfully completed payment process through PayPal.  The Registration ID and other contact information can be used to track payment status in PayPal.</p>");
                body.AppendFormat("<div>Registration ID: {0}</div>", registration.RegistrationId);
                body.AppendFormat("<div>Event: {0}</div>", registration.EventName);
                body.AppendFormat("<div>Name: {0}</div>", registration.FullName);
                body.AppendFormat("<div>Payment Amount: {0}</div>", registration.PaymentAmount);
                body.AppendFormat("<div>Address: {0}</div>", registration.Address1);
                body.AppendFormat("<div>Town: {0}</div>", registration.City);
                body.AppendFormat("<div>Phone: {0}</div>", registration.FormattedPhone);
                body.AppendFormat("<div>Email: {0}</div>", registration.Email);
                body.AppendFormat("<div>Special Instructions:</div><p>{0}</p>", registration.SpecialInstructions);

                SiteMessage siteMessage = new SiteMessage()
                {
                    From    = registration.Email,
                    To      = ConfigurationManager.AppSettings["ContactUsEmailAddress"],
                    Subject = "Class Registration: Interactive School House",
                    Body    = body.ToString()
                };

                SendGridMailAdapter sendGridMailAdapter = new SendGridMailAdapter();
                sendGridMailAdapter.Send(siteMessage);
            }

            return(Ok(registration));
        }
Ejemplo n.º 19
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/json";
            string json = string.Empty;

            if (context.Session[ConstHelper.Session_USERID] == null)
            {
                var SessionTimeout = new
                {
                    success = ConstHelper.Fail,
                    message = "[保存失败]系统超时,请重新登陆",
                };
                json = JsonConvert.SerializeObject(SessionTimeout);
                context.Response.Write(json);
                return;
            }
            string strMessageId = context.Request.QueryString["MessageId"];

            if (SiteMessage.CloseMessage(strMessageId, context.Session[ConstHelper.Session_USERID].ToString()))
            {
                var result = new
                {
                    success = ConstHelper.Success,
                    message = "已处理"
                };
                json = JsonConvert.SerializeObject(result);
                context.Response.Write(json);
            }
            else
            {
                var result = new
                {
                    success = ConstHelper.Fail,
                    message = "未处理"
                };
                json = JsonConvert.SerializeObject(result);
                context.Response.Write(json);
            }
        }
Ejemplo n.º 20
0
 public ModelSiteMessage(SiteMessage item)
 {
     title       = item.title;
     message     = item.message;
     createdTime = item.createdTime;
 }
Ejemplo n.º 21
0
 public ActionResult ContactUs(SiteMessage model)
 {
     return(View());
 }
Ejemplo n.º 22
0
        public async Task <ActionResult> CE_Login(string nextUrl)
        {
            // check for token
            string token = Request.Params["Token"];

            if (string.IsNullOrWhiteSpace(token))
            {
                SiteMessage msg = new SiteMessage()
                {
                    Title = "Authorization Failed"
                };
                msg.Message = "A valid authorization token was not found.";
                Session["SystemMessage"] = msg;
                return(RedirectToAction("Index", "Message"));
            }
            LoggingHelper.DoTrace(6, "CE_Login - start");
            string publisherSecretToken = UtilityManager.GetAppKeyValue("finderSecretToken");
            var    output = new ApiResult();
            var    accountsAuthorizeApi = UtilityManager.GetAppKeyValue("accountsAuthorizeApi") + "?Token=" + token + "&Secret=" + publisherSecretToken;

            try
            {
                LoggingHelper.DoTrace(6, "CE_Login - MakeAuthorizationRequest");
                string    rawData = MakeAuthorizationRequest(accountsAuthorizeApi);
                ApiResult data    = new ApiResult();
                //check rawdata for {"data"
                //&& rawData.ToLower().IndexOf( "{\"data\"" ) > 0
                if (rawData != null)
                {
                    data = new JavaScriptSerializer().Deserialize <ApiResult>(rawData);
                    if (data == null)
                    {
                        SiteMessage msg = new SiteMessage()
                        {
                            Title = "Authorization Failed"
                        };
                        msg.Message = "A valid authorization token was not found.";
                        Session["SystemMessage"] = msg;
                        return(RedirectToAction("Index", "Message"));
                    }
                    else
                    {
                        //do error checking, for error, and existing user.
                        if (data.valid == false)
                        {
                            SiteMessage msg = new SiteMessage()
                            {
                                Title = "Authorization Failed"
                            };
                            msg.Message = "Reason: " + data.status;
                            Session["SystemMessage"] = msg;
                            return(RedirectToAction("Index", "Message"));
                        }
                    }
                    LoggingHelper.DoTrace(6, "CE_Login - MakeAuthorizationRequest - data is OK");
                }
                else
                {
                    //check for error string
                    //{"data":null,"valid":false,"status":"Error: Invalid token","extra":null}
                    SiteMessage msg = new SiteMessage()
                    {
                        Title = "Authorization Failed"
                    };
                    msg.Message = "A valid authorization token was not found.</br>" + rawData;
                    Session["SystemMessage"] = msg;
                    return(RedirectToAction("Index", "Message"));
                }
                nextUrl = string.IsNullOrWhiteSpace(nextUrl) ? "~/credentials" : nextUrl;
                //19-12-17 mp - uncommented this:
                nextUrl = UtilityManager.FormatAbsoluteUrl(nextUrl);

                string statusMessage = "";
                //now what
                //login user like external
                //				AppUser user = AccountServices.GetUserByUserName( data.data.Email );

                AccountServices acctServices = new AccountServices();
                LoggingHelper.DoTrace(6, "CE_Login - GetUserByCEAccountId");
                AppUser user = AccountServices.GetUserByCEAccountId(data.data.AccountIdentifier);
                //note user may not yet exist here,
                if (user == null || user.Id == 0)
                {
                    LoggingHelper.DoTrace(4, string.Format("Account.CE_Login. First time login for {0} {1}", data.data.FirstName, data.data.LastName));

                    //will eventually not want to use AspNetUsers
                    var newUser = new ApplicationUser
                    {
                        UserName  = data.data.Email,
                        Email     = data.data.Email,
                        FirstName = data.data.FirstName,
                        LastName  = data.data.LastName
                    };
                    var result = await UserManager.CreateAsync(newUser);

                    if (result.Succeeded)
                    {
                        //add mirror account
                        acctServices.Create(data.data.Email,
                                            data.data.FirstName, data.data.LastName,
                                            data.data.Email,
                                            newUser.Id,
                                            "",
                                            data.data.AccountIdentifier,
                                            ref statusMessage, false, true);
                        UserLoginInfo     info  = new UserLoginInfo("CredentialEngine", data.data.AccessToken);
                        ExternalLoginInfo einfo = new ExternalLoginInfo()
                        {
                            DefaultUserName = data.data.Email, Email = data.data.Email, Login = info
                        };
                        result = await UserManager.AddLoginAsync(newUser.Id, info);

                        if (result.Succeeded)
                        {
                            await SignInManager.SignInAsync(newUser, isPersistent : false, rememberBrowser : false);

                            //now get user and add to session, will include any orgs if found
                            AppUser thisUser = AccountServices.GetUserByCEAccountId(data.data.AccountIdentifier);
                            //get organizations
                            GetOrganizationsForUser(thisUser);
                            return(RedirectToLocal(nextUrl));
                            //return RedirectToAction( "Index", "Search" );
                        }
                    }
                    AddErrors(result);
                    ConsoleMessageHelper.SetConsoleErrorMessage("Error - unexpected issue encountered attempting to sign in.<br/>" + result);
                    LoggingHelper.DoTrace(6, "CE_Login - Error - unexpected issue encountered attempting to add user.<br/>" + result);
                    //where to go for errors?
                }
                else
                {
                    //may want to compare user, and update as needed
                    if (user.Email != data.data.Email ||
                        user.FirstName != data.data.FirstName ||
                        user.LastName != data.data.LastName)
                    {
                        //update user
                        user.Email     = data.data.Email;
                        user.FirstName = data.data.FirstName;
                        user.LastName  = data.data.LastName;

                        acctServices.Update(user, false, ref statusMessage);
                    }
                    LoggingHelper.DoTrace(6, "CE_Login - existing user");
                    ApplicationUser aspUser = this.UserManager.FindByEmail(data.data.Email.Trim());
                    await SignInManager.SignInAsync(aspUser, isPersistent : false, rememberBrowser : false);

                    AppUser thisUser = AccountServices.SetUserByEmail(aspUser.Email);
                    if (thisUser != null && thisUser.Id > 0)
                    {
                        //get organizations - currently only those who can create widgets
                        GetOrganizationsForUser(thisUser);
                    }
                    ActivityServices.UserExternalAuthentication(appUser, "CE SSO");
                    string message = string.Format("Email: {0}, provider: {1}", data.data.Email, "CE SSO");
                    LoggingHelper.DoTrace(5, "AccountController.CE_Login: "******"CE_Login Unable to login user");
            }

            return(View());
        }
Ejemplo n.º 23
0
 public async Task AddMessage(SiteMessage message)
 {
     _context.Add(message);
     await _context.SaveChangesAsync();
 }