Ejemplo n.º 1
0
        public JsonResult AddTopicReply(ForumModelView model)
        {
            int    result = -1;
            string strMsg = "";

            try
            {
                if (String.IsNullOrEmpty(model.Message) || model.Message.Trim() == "")
                {
                    result = -2;
                    strMsg = "Message required.";
                }
                else
                {
                    ForumHelper helper = new ForumHelper();
                    string      msg    = helper.AddTopicReply(model);
                    if (msg == "success")
                    {
                        strMsg = "You have replied successfully.";
                        result = 0;
                    }
                    else
                    {
                        strMsg = "Error! Try again later.";
                        result = -3;
                    }
                }
            }
            catch (Exception ex)
            {
                strMsg = "Exception: " + ex.Message;
            }
            return(Json(new { counter = result, msg = strMsg, topicId = model.TopicId }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            MembershipUser currentUser = Membership.GetUser();

            if (currentUser != null)
            {
                if (Registration.AllowEnterGame(currentUser))
                {
                    string gameServers = ConfigurationSettings.AppSettings["SharedWeb.EnterGame.GameServers"];
                    gameServers            = gameServers.Replace(" ", "");
                    GameServersScript.Text = "<script type=\"text/javascript\">var gameServers = new Array();";
                    int gameServerID = 0;
                    foreach (string serverHost in gameServers.Split(','))
                    {
                        GameServersScript.Text += string.Format("gameServers[{0}] = \"{1}\";", gameServerID, serverHost);
                        gameServerID++;
                    }
                    GameServersScript.Text += "</script>";


                    string loginResponse = ForumHelper.CurrentLoginResponse(YafContext.Current.Localization.LanguageCode);
                    GameLoginDataScript.Text = string.Format("<script type=\"text/javascript\">var LoginData='{0}'</script>", loginResponse);
                }
                else
                {
                    GameLoginDataScript.Text = "<script type=\"text/javascript\">var LoginData='Unconfirmed'</script>";
                    BlockedImg.Visible       = true;
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Load the Forum message listing
        /// </summary>
        /// <param name="keyword"></param>
        /// <param name="sortBy"></param>
        /// <param name="pageNo"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public PartialViewResult LoadForumList(string keyword, string sortBy, string pageNo, string pageSize = "10")
        {
            ForumHelper helper = new ForumHelper();
            ForumModel  model  = new ForumModel();

            model.StratasBoardId = ClientSessionData.ClientStrataBoardId;
            var forumList = helper.GetForumListing(model);


            if (!string.IsNullOrEmpty(keyword))
            {
                forumList = forumList.Where(x => x.Topic.ToLower().Contains(keyword.ToLower()) || x.TopicContent.ToLower().Contains(keyword.ToLower())).ToList();
            }

            if (!string.IsNullOrEmpty(sortBy))
            {
                if (sortBy == "date asc")
                {
                    forumList = forumList.OrderBy(x => x.CreatedOn).ToList();
                }
                else if (sortBy == "date desc")
                {
                    forumList = forumList.OrderByDescending(x => x.CreatedOn).ToList();
                }
                else if (sortBy == "title asc")
                {
                    forumList = forumList.OrderBy(x => x.Topic).ToList();
                }
                else if (sortBy == "title desc")
                {
                    forumList = forumList.OrderByDescending(x => x.Topic).ToList();
                }
                else
                {
                    forumList = forumList.OrderByDescending(x => x.CreatedOn).ToList();
                }
            }


            int totalRecords = forumList.Count;

            ForumModelView forumViewModel = new ForumModelView();

            forumViewModel.TotalPages = totalRecords / Convert.ToInt32(pageSize);
            if (totalRecords % Convert.ToInt32(pageSize) > 0)
            {
                forumViewModel.TotalPages++;
            }

            var skip = Convert.ToInt32(pageSize) * (Convert.ToInt32(pageNo) - 1);

            forumViewModel.ListForum = forumList.Skip(skip).Take(Convert.ToInt32(pageSize)).ToList();

            return(PartialView("_ForumListPartial", forumViewModel));
        }
Ejemplo n.º 4
0
        public JsonResult AddFlagOnTopic(ForumFlaggedModel model)
        {
            int    result = -1;
            string strMsg = "";

            try
            {
                if (String.IsNullOrEmpty(model.ForumMessageType) || model.ForumMessageType.Trim() == "")
                {
                    result = -4;
                    strMsg = "Error! Try again later.";
                }
                else if (model.AutoId <= 0)
                {
                    result = -5;
                    strMsg = "Error! Try again later.";
                }
                else if (String.IsNullOrEmpty(model.Comment) || model.Comment.Trim() == "")
                {
                    result = -2;
                    strMsg = "Comment required.";
                }
                else
                {
                    ForumHelper helper      = new ForumHelper();
                    int         returnValue = helper.MarkFlagOnForum(model);
                    if (returnValue == 0)
                    {
                        strMsg = "You have flagged it successfully.";
                        result = 0;
                    }
                    else
                    {
                        strMsg = "Error! Try again later.";
                        result = -3;
                    }
                }
            }
            catch (Exception ex)
            {
                strMsg = "Exception: " + ex.Message;
            }
            return(Json(new { counter = result, msg = strMsg, autoid = model.AutoId, type = model.ForumMessageType, userRole = ClientSessionData.ClientRoleName.ToLower() }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 5
0
        public JsonResult ReadMessage(long topicId)
        {
            int result = 0;

            try
            {
                if (topicId > 0)
                {
                    ForumHelper helper = new ForumHelper();
                    int         remainingMessageCount = helper.ReadMessage(topicId, ClientSessionData.UserClientId, ClientSessionData.ClientStrataBoardId);
                    if (remainingMessageCount > 0)
                    {
                        result = remainingMessageCount;
                    }
                }
            }
            catch {
            }
            return(Json(new { counter = result }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 6
0
        public JsonResult DeleteFlagOnTopic(ForumFlaggedModelView model)
        {
            int    result = -1;
            string strMsg = "";

            try
            {
                if (String.IsNullOrEmpty(model.ForumMessageTypeView) || model.ForumMessageTypeView.Trim() == "")
                {
                    result = -4;
                    strMsg = "Error! Try again later.";
                }
                else if (model.AutoIdView <= 0)
                {
                    result = -5;
                    strMsg = "Error! Try again later.";
                }
                else
                {
                    ForumHelper helper      = new ForumHelper();
                    int         returnValue = helper.DeleteForum(model);
                    if (returnValue == 0)
                    {
                        strMsg = "You have deleted it successfully.";
                        result = 0;
                    }
                    else
                    {
                        strMsg = "Error! Try again later.";
                        result = -3;
                    }
                }
            }
            catch (Exception ex)
            {
                strMsg = "Exception: " + ex.Message;
            }
            return(Json(new { counter = result, msg = strMsg, autoid = model.AutoIdView, type = model.ForumMessageTypeView }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 7
0
        public void Execute(IServiceProvider serviceProvider)
        {
            SqlDataAccess sda = null;

            try
            {
                sda = new SqlDataAccess();
                sda.openConnection(Globals.ConnectionString);

                #region | SERVICE |
                IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

                #region | Validate Request |
                //Target yoksa veya Entity tipinde değilse, devam etme.
                if (!context.InputParameters.Contains("Target") || !(context.InputParameters["Target"] is Entity))
                {
                    return;
                }
                #endregion

                IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
                IOrganizationService        service        = serviceFactory.CreateOrganizationService(context.UserId);

                #endregion

                Entity entity = (Entity)context.InputParameters["Target"];

                #region |DEFINE IMAGE IF EXISTS|
                Entity postImage = null;
                if (context.PostEntityImages.Contains("PostImage") && context.PostEntityImages["PostImage"] is Entity)
                {
                    postImage = (Entity)context.PostEntityImages["PostImage"];
                }
                #endregion

                #region | VARIABLES |
                List <ScoreLimit> lstLimits = new List <ScoreLimit>();

                EntityReference portal = null;
                EntityReference user   = null;

                if (postImage.Contains("new_portalid") && postImage["new_portalid"] != null)
                {
                    portal = (EntityReference)postImage["new_portalid"];
                }

                if (postImage.Contains("new_userid") && postImage["new_userid"] != null)
                {
                    user = (EntityReference)postImage["new_userid"];
                }
                #endregion

                if (entity.Contains("statuscode") && entity["statuscode"] != null && ((OptionSetValue)entity["statuscode"]).Value == 1)
                {
                    MsCrmResultObject limitRes = ScoreHelper.GetScoreLimitsByType(ScoreType.ForumSubject, sda);

                    if (limitRes.Success)
                    {
                        lstLimits = (List <ScoreLimit>)limitRes.ReturnObject;

                        for (int i = 0; i < lstLimits.Count; i++)
                        {
                            int      recCount = 0;
                            DateTime start    = GeneralHelper.GetStartDateByScorePeriod(lstLimits[i].Period);
                            DateTime end      = GeneralHelper.GetEndDateByScorePeriod(lstLimits[i].Period);

                            recCount = ForumHelper.GetUserForumSubjectCount(portal.Id, user.Id, start, end, sda);

                            if (lstLimits[i].Frequency >= recCount)
                            {
                                Score sc = new Score()
                                {
                                    Point     = lstLimits[i].Point,
                                    Portal    = portal,
                                    User      = user,
                                    ScoreType = ScoreType.ForumSubject
                                };

                                MsCrmResult scoreRes = ScoreHelper.CreateScore(sc, service);

                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //LOG
                throw new InvalidPluginExecutionException(ex.Message);
            }
            finally
            {
                if (sda != null)
                {
                    sda.closeConnection();
                }
            }
        }
Ejemplo n.º 8
0
        public ActionResult ReenableSideBar()
        {
            ForumHelper.UnpauseConnections();

            return(Redirect("/admin"));
        }
Ejemplo n.º 9
0
        public JsonResult AddTopic(ForumModel model)
        {
            int    result = 0;
            string strMsg = "";

            try
            {
                if (String.IsNullOrEmpty(model.Topic) || model.Topic.Trim() == "")
                {
                    result = -3;
                    strMsg = "Topic required.";
                }
                else if (String.IsNullOrEmpty(model.TopicContent) || model.TopicContent.Trim() == "")
                {
                    result = -4;
                    strMsg = "Comment required.";
                }

                if (model.ImageType != null)
                {
                    string ext = Path.GetExtension(model.ImageType.FileName).ToLower();
                    if (ext != ".jpg" && ext != ".jpeg" && ext != ".pdf" && ext != ".png" && ext != ".xlsx" && ext != ".docx" && ext != ".pptx")
                    {
                        result = -1;
                        strMsg = "Please upload only .jpg, .png, .pdf, .pptx, .docx or .xlsx File";
                    }
                    else
                    {
                        Guid guid = Guid.NewGuid();
                        model.UploadedFileActualName = model.ImageType.FileName;
                        model.UploadedFileName       = guid.ToString() + ext;


                        string path        = string.Empty;
                        string initialPath = "~/content/resources/strataboard";
                        if (!Directory.Exists(Server.MapPath(initialPath)))
                        {
                            Directory.CreateDirectory(Server.MapPath(initialPath));
                        }

                        initialPath = initialPath + "/" + ClientSessionData.ClientStrataBoardId;
                        if (!Directory.Exists(Server.MapPath(initialPath)))
                        {
                            Directory.CreateDirectory(Server.MapPath(initialPath));
                        }

                        initialPath = initialPath + "/myforum";
                        if (!Directory.Exists(Server.MapPath(initialPath)))
                        {
                            Directory.CreateDirectory(Server.MapPath(initialPath));
                        }

                        // save the file locally
                        path = Server.MapPath(Path.Combine(initialPath + "/" + model.UploadedFileName));
                        model.ImageType.SaveAs(path);

                        // save the file on s3
                        int fileMapped = AwsS3Bucket.CreateFile("resources/strataboard/" + ClientSessionData.ClientStrataBoardId + "/myforum/" + model.UploadedFileName, path);
                        if (fileMapped != 0)
                        {
                            result = -2;
                            strMsg = "Error is uploading file in S3, Try again later.";
                        }
                        // delete the file locally
                        if (System.IO.File.Exists(path))
                        {
                            System.IO.File.Delete(path);
                        }
                    }
                }


                if (result == 0)
                {
                    ForumHelper helper = new ForumHelper();
                    string      msg    = helper.AddTopic(model);
                    if (msg != "success")
                    {
                        strMsg = "Error: Try again later";
                        result = -3;
                    }
                }
            }
            catch (Exception ex)
            {
                strMsg = "Exception: " + ex.Message;
                result = -5;
            }
            return(Json(new { counter = result, msg = strMsg }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 10
0
    protected void InstallWizard_NextButtonClick(object sender, WizardNavigationEventArgs e)
    {
        bool IsOK = false;

        if (e.CurrentStepIndex == 4)
        {
            //Step 4 - DATABASES

            IsOK = false;
            ErrorMessagePanel.Visible = false;
            SuccMessagePanel.Visible  = false;

            web_server.Text = web_server.Text.Replace(":", ",");

            string websiteCS = "Data Source=" + web_server.Text + "; Initial Catalog=" + web_name.Text +
                               "; Integrated Security=false; User ID=" + web_username.Text + "; Password="******";";

            string forumCS = "Data Source=" + web_server.Text + "; Initial Catalog=" + forum_name.Text +
                             "; Integrated Security=false; User ID=" + forum_username.Text + "; Password="******";";

            string log = "";

            try
            {
                log += "Connecting to Website database...";
                //Connect to SQL locally WEBSITE
                using (SqlConnection sqlConnection = new SqlConnection(websiteCS))
                {
                    sqlConnection.Open();
                    log += "OK.<br/>";

                    log += "Executing Website SQL scripts...";

                    //Check if already done
                    bool done = true;
                    try
                    {
                        SqlCommand command = new SqlCommand("SELECT UpgradeProcessorButtonEnabled FROM ApplicationSettings", sqlConnection);
                        command.ExecuteScalar();
                    }
                    catch (Exception ex)
                    {
                        done = false;
                    }

                    if (done)
                    {
                        log += "OK (skipped).<br/>";
                    }
                    else
                    {
                        //Execute
                        using (StreamReader sr = new StreamReader(HttpContext.Current.Server.MapPath("~/install/sql/website.txt")))
                        {
                            String line    = sr.ReadToEnd();
                            var    scripts = SplitSqlStatements(line);

                            foreach (var splitScript in scripts)
                            {
                                try
                                {
                                    SqlCommand command = new SqlCommand(splitScript, sqlConnection);
                                    command.ExecuteNonQuery();
                                }
                                catch (Exception ex) { }
                            }
                        }
                        log += "OK.<br/>";
                    }

                    sqlConnection.Close();
                }

                log += "Connecting to Forum database...";
                //Connect to SQL locally FORUM
                using (SqlConnection sqlConnection = new SqlConnection(forumCS))
                {
                    sqlConnection.Open();
                    log += "OK.<br/>";

                    log += "Executing Forum SQL scripts...";

                    //Check if already done
                    bool done = true;
                    try
                    {
                        SqlCommand command = new SqlCommand("SELECT Name FROM yaf_AccessMask", sqlConnection);
                        command.ExecuteScalar();
                    }
                    catch (Exception ex)
                    {
                        done = false;
                    }

                    if (done)
                    {
                        log += "OK (skipped).<br/>";
                    }
                    else
                    {
                        //Execute
                        using (StreamReader sr = new StreamReader(HttpContext.Current.Server.MapPath("~/install/sql/forum.txt")))
                        {
                            String line    = sr.ReadToEnd();
                            var    scripts = SplitSqlStatements(line);

                            foreach (var splitScript in scripts)
                            {
                                try
                                {
                                    SqlCommand command = new SqlCommand(splitScript, sqlConnection);
                                    command.ExecuteNonQuery();
                                }
                                catch (Exception ex) { }
                            }
                        }
                        log += "OK.<br/>";
                    }

                    sqlConnection.Close();
                }

                //Connect to SQL remotely

                log += "Checking remote connection to Website...";

                using (WebClient client = new WebClient())
                {
                    var response = client.DownloadString("https://usetitan.com/Handlers/cs.ashx?c=" + HttpUtility.UrlEncode(websiteCS));
                    if (response == "OK")
                    {
                        log += "OK.<br/>";
                    }
                    else
                    {
                        throw new Exception(response);
                    }
                }

                log += "Checking remote connection to Forum...";

                using (WebClient client = new WebClient())
                {
                    var response = client.DownloadString("https://usetitan.com/Handlers/fcs.ashx?c=" + HttpUtility.UrlEncode(forumCS));
                    if (response == "OK")
                    {
                        log += "OK.<br/>";
                    }
                    else
                    {
                        throw new Exception(response);
                    }
                }


                //Modify Web.config
                var configuration = WebConfigurationManager.OpenWebConfiguration("~");
                var section       = (ConnectionStringsSection)configuration.GetSection("connectionStrings");
                section.ConnectionStrings["ClientDbString"].ConnectionString = websiteCS;
                section.ConnectionStrings["yafnet"].ConnectionString         = forumCS;
                configuration.Save();

                IsOK = true;

                SuccMessagePanel.Visible = true;
                SuccMessage.Text         = log;
            }
            catch (Exception ex)
            {
                SuccMessagePanel.Visible = true;
                SuccMessage.Text         = log;

                ErrorMessagePanel.Visible = true;
                ErrorMessage.Text         = ex.Message;
            }

            if (!IsOK)
            {
                e.Cancel = true;
            }
        }
        if (e.CurrentStepIndex == 5)
        {
            //Step 5 - EMAILS

            IsOK = false;
            SuccPanel2.Visible  = false;
            ErrorPanel2.Visible = false;
            string log = "";

            try
            {
                log += "Sending test email message...";

                AppSettings.Email.Username     = settings_Username.Text.Trim();
                AppSettings.Email.Password     = settings_Password.Text.Trim();
                AppSettings.Email.Host         = settings_Host.Text.Trim();
                AppSettings.Email.Port         = Convert.ToInt32(settings_Port.Text.Trim());
                AppSettings.Email.IsSecureMail = settings_Secure.Checked;
                AppSettings.Email.Forward      = AppSettings.Email.NoReply = settings_ForwardEmail.Text.Trim();
                AppSettings.Email.Save();

                Mailer.SendEmailToUser("*****@*****.**", "Test server", "Test");

                log += "OK.<br/>";
                IsOK = true;

                ForumHelper.UpdateForumDB(ForumHelper.BDProperty.Email, AppSettings.Email.Forward);

                SuccPanel2.Visible = true;
                SuccMess2.Text     = log;
            }
            catch (Exception ex)
            {
                SuccPanel2.Visible = true;
                SuccMess2.Text     = log;

                ErrorPanel2.Visible = true;
                ErrorMess2.Text     = ex.Message;
            }

            if (!IsOK)
            {
                e.Cancel = true;
            }
        }
        if (e.CurrentStepIndex == 6)
        {
            Commission.UpdateCommissionSystem();

            //CRON
            IsOK = false;
            ErrorPanel3.Visible = false;

            bool IsGood   = false;
            var  cronLogs = TableHelper.SelectAllRows <CronEntry>();

            foreach (var entry in cronLogs)
            {
                if (entry.Date.Date == DateTime.Now.Date)
                {
                    IsGood = true;
                }
            }

            if (IsGood)
            {
                IsOK = true;
                AppSettings.Site.Url = BaseUrl;
                AppSettings.Site.Save();

                ForumHelper.UpdateForumDB(ForumHelper.BDProperty.BaseURL, BaseUrl + "forum");
            }
            else
            {
                ErrorPanel3.Visible = true;
                ErrorMess3.Text     = "The CRON file for today did not trigger successfully. Try again.";
            }


            if (!IsOK)
            {
                e.Cancel = true;
            }
        }
        if (e.CurrentStepIndex == 7)
        {
            //Admin password
            IsOK = false;
            ErrorPanel4.Visible = false;

            if (String.IsNullOrWhiteSpace(adminpassword.Text))
            {
                ErrorPanel4.Visible = true;
                ErrorMess4.Text     = "The password cannot be blank.";
            }
            else
            {
                Member admin       = new Member("admin");
                string newPassword = adminpassword.Text;
                admin.PrimaryPassword = MemberAuthenticationService.ComputeHash(newPassword);
                admin.Save();
                IsOK = true;
            }

            if (!IsOK)
            {
                e.Cancel = true;
            }
        }
    }