protected void Page_Load(object sender, EventArgs e) { UserModuleID = Int32.Parse(SageUserModuleID); PortalID = GetPortalID; modulePath = ResolveUrl(this.AppRelativeTemplateSourceDirectory); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "globalVariables", " var PollingServicePath='" + ResolveUrl(modulePath) + "';", true); IncludeJS(); IncludeCSS(); divMsg.Visible = false; if (!IsPostBack) { PollingController objc = new PollingController(); pollID = objc.getActivePollID(Int32.Parse(SageUserModuleID), GetPortalID); if (pollID > 0) { hidPollID.Value = pollID.ToString(); showPoll();//show the poll } else { divMsg.InnerHtml = "<span class='cssClassNotFound'>There are no active polls available.</span>"; divPoll.Visible = false; divMsg.Visible = true; return; } } GenerateResultContainer(); }
/// <summary> /// show the existing poll in edit mode /// This is for demo only Never write ur database logic here. Always use classes and SPs to seperate them from codebehind /// </summary> private void ShowExistingPoll(int PollId) { PollingController objc = new PollingController(); Pollinginfo objPoll = new Pollinginfo(); DataSet dsPoll = objc.SelectPoll(PollId, Int32.Parse(SageUserModuleID), GetPortalID); if (dsPoll.Tables[0].Rows.Count > 0) { txtQuestion.Text = dsPoll.Tables[0].Rows[0]["Question"].ToString(); string blockMode = dsPoll.Tables[0].Rows[0]["BlockMode"].ToString(); if (blockMode == Pollinginfo.BlockMode.COOKIE.ToString()) { rdoCookie.Checked = true; } else if (blockMode == Pollinginfo.BlockMode.IP_ADDRESS.ToString()) { rdoIP.Checked = true; } else { rdoNone.Checked = true; } ShowChoices(dsPoll.Tables[1]); hidRowIndex.Value = dsPoll.Tables[1].Rows.Count.ToString(); //btnSave.Text = "Update Poll"; } else //can't find the poll.. change to INSERT MODE { hidPollID.Value = ""; // btnSave.Text = "Save Poll"; } }
private void showPoll() { PollingController objc = new PollingController(); DataSet dsPoll = objc.SelectPoll(pollID, Int32.Parse(SageUserModuleID), GetPortalID); if (dsPoll.Tables[0].Rows.Count > 0) { litQuestion.Text = dsPoll.Tables[0].Rows[0]["Question"].ToString(); //if the BlockMode is not NONE findout whether the user is already Polled or not - if polled show the result only string blockMode = dsPoll.Tables[0].Rows[0]["BlockMode"].ToString(); isPolled = isPolled = CheckAlreadyPolled(blockMode); if (isPolled) //show the result { divAnswers.InnerHtml = getResultHTML(dsPoll); divAnswers.InnerHtml += "<div class='poll-total' id='divVoted'>You have already voted.</div>"; } else //show the poll { rptChoices.DataSource = dsPoll.Tables[1]; rptChoices.DataBind(); rptChoices.Visible = rptChoices.Items.Count > 0; } } else { divMsg.InnerHtml = "<b>Note: </b>The poll you are looking for is not found."; divMsg.Visible = true; } }
private void EditPoll(int PollId) { divform.Attributes.Add("style", "display:block"); divManipulateData.Attributes.Add("style", "display:none"); PollingController objc = new PollingController(); ShowExistingPoll(PollId); }
private void DeletePoll(int PollId) { PollingController objc = new PollingController(); objc.DeletePoll(PollId); divform.Attributes.Add("style", "display:none"); divManipulateData.Attributes.Add("style", "display:block"); }
/// <summary> /// The input choices can come in 3 mode - /// 1 - INSERT - IF its added as NEW - it will not have a corresponding Choice ID hidden field /// 2 - UPDATE - IF a choice text input has corresponding hidden ID present itss in UPDATE mode /// 3 - DELETE - IF a choice text input has corresponding hidden ID present but the text value is empty /// </summary> /// <param name="pollID"></param> private void InsertUpdateChoices(int pollID, int UserModuleID, int PortalID) { Pollinginfo objPoll = new Pollinginfo(); PollingController objc = new PollingController(); //INSERT/UPDATE THE CHOICES //LOOPING THRU ALL THE FORM KEYVALUES TO FIND THE INPUT TEXTS //IF A CHOICE HAS CORRESPONDING ID THEN IT HAS TO BE UPDATES/ ELSE INSERT foreach (string key in Request.Form) { if (key.IndexOf("txtChoice") >= 0) { string hidPollChoiceID = "hidPollChoiceID" + key.Substring(key.Length - 1, 1); int choiceID = 0; string chc = Request.Form[key]; if (Session["PollID"] != null) { if (Request.Form[hidPollChoiceID] != null && int.TryParse(Request.Form[hidPollChoiceID], out choiceID)) { if (Request.Form[key].Trim().Length > 0) //UPDATE if the choice text box is not empty and has a corresponding ID { objPoll.PollChoiceID = choiceID; objPoll.Choice = Request.Form[key]; objPoll.UserModuleID = UserModuleID; objPoll.PortalID = PortalID; objc.UpdateChoice(objPoll); } else //DELETE the choice if its empty { objc.DeleteChoice(choiceID); } } else if (Request.Form[key].Trim().Length > 0)//New choice - insert only if the text is not empty { objPoll.PollID = pollID; objPoll.Choice = Request.Form[key].Trim(); objPoll.UserModuleID = UserModuleID; objPoll.PortalID = PortalID; objc.InsertChoice(objPoll); } } else { if (Request.Form[key].Trim().Length > 0)//New choice - insert only if the text is not empty { objPoll.PollID = pollID; objPoll.Choice = Request.Form[key].Trim(); objPoll.UserModuleID = UserModuleID; objPoll.PortalID = PortalID; objc.InsertChoice(objPoll); } } } } hidRowIndex.Value = null; }
private void listPolls() { int UserModuleID = Int32.Parse(SageUserModuleID); int PortalID = GetPortalID; PollingController objPoll = new PollingController(); DataSet dtPoll = objPoll.ListPoll(UserModuleID, PortalID); gvListPoll.DataSource = dtPoll; gvListPoll.DataBind(); }
public int InsertPoll(string question, string blockMode) { Pollinginfo objInf = new Pollinginfo(); objInf.Question = question; objInf.blockMode = blockMode; objInf.UserModuleID = Int32.Parse(SageUserModuleID); objInf.PortalID = GetPortalID; PollingController objc = new PollingController(); return(objc.InsertPoll(objInf)); }
protected void btnSaveIsVisible_Click(object sender, ImageClickEventArgs e) { foreach (GridViewRow grdRow in gvListPoll.Rows) { int PollID = 0; HiddenField hdfpollID = grdRow.FindControl("hdfPollID") as HiddenField; PollID = Convert.ToInt32(hdfpollID.Value); bool isActive = ((CheckBox)grdRow.FindControl("rdbActive")).Checked; PollingController objPro = new PollingController(); objPro.SaveHideShowPoll(PollID, isActive); } ShowMessage(SageMessageTitle.Information.ToString(), SageMessage.GetSageModuleLocalMessageByVertualPath("Modules/Polling/ModuleLocalText", "SettingSavedSucessfully"), "", SageMessageType.Success); }
/// <summary> /// Update the poll and return the number of rows affected /// </summary> /// <param name="pollID"></param> /// <param name="question"></param> /// <returns>Number of rows affected</returns> public void UpdatePoll(int pollID, string question, string blockMode) { Pollinginfo obj = new Pollinginfo(); obj.PollID = pollID; obj.Question = question; obj.blockMode = blockMode; PollingController objc = new PollingController(); objc.UpdatePoll(obj); // return db.ExecuteNonQuery("usp_poll_update", pollID, question, blockMode, active); }
protected void Page_Load(object sender, EventArgs e) { PollingController objc = new PollingController(); // pollID = objc.getActivePollID(Int32.Parse(SageUserModuleID), GetPortalID);//Saving the ID to use later string modulePath = ResolveUrl(this.AppRelativeTemplateSourceDirectory); if (!IsPostBack) { ImageUrl(); listPolls(); Session["PollID"] = null; } ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "globalVariables", " var PollingEditServicePath='" + ResolveUrl(modulePath) + "';", true); }
public bool StartTesting(IController controller) { StopTesting(); if (controller.RequiresPolling) { controller = new PollingController(controller, 1000 / 60); } _controller = controller; _controller.StateUpdated += OnControllerStateUpdated; if (controller.Activate()) { OnControllerStateUpdated(null, null); // initial update return(true); } return(false); }
private bool CheckAlreadyPolled(string blockMode) { bool isPolled = false; //if the block mode of this Poll is by IP,, check in the DB whether a poll is already existing from this IP if (blockMode == Pollinginfo.BlockMode.IP_ADDRESS.ToString()) { string ip = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if (ip == null) { ip = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; } PollingController objPollC = new PollingController(); int id = objPollC.SelectPollIP(int.Parse(hidPollID.Value), ip); if (id > 0) { isPolled = true; } } else if (blockMode == Pollinginfo.BlockMode.COOKIE.ToString()) //If block by Cookie read the cookie to see if there is an entry for this blog { if (Request.Cookies["Poll"] != null && Request.Cookies["Poll"]["ID"] != null) { //the cookie will have comma seperated IDs of all the polls that already voted string commaSeperatedPollIDs = Request.Cookies["Poll"]["ID"]; //split it with comma string[] pollIDs = commaSeperatedPollIDs.Split(",".ToCharArray()); //and loop through each pollID to find whethere the current poll is already voted foreach (string pID in pollIDs) { //if yes break if (pID == hidPollID.Value) { isPolled = true; break; } } } } return(isPolled); }
/// <summary> /// show the existing poll in edit mode /// This is for demo only Never write ur database logic here. Always use classes and SPs to seperate them from codebehind /// </summary> private void ShowExistingPoll(int PollId) { PollingController objc = new PollingController(); Pollinginfo objPoll = new Pollinginfo(); DataSet dsPoll = objc.SelectPoll(PollId, Int32.Parse(SageUserModuleID), GetPortalID); if (dsPoll.Tables[0].Rows.Count > 0) { txtQuestion.Text = dsPoll.Tables[0].Rows[0]["Question"].ToString(); string blockMode = dsPoll.Tables[0].Rows[0]["BlockMode"].ToString(); if (blockMode == Pollinginfo.BlockMode.COOKIE.ToString()) rdoCookie.Checked = true; else if (blockMode == Pollinginfo.BlockMode.IP_ADDRESS.ToString()) rdoIP.Checked = true; else rdoNone.Checked = true; ShowChoices(dsPoll.Tables[1]); hidRowIndex.Value = dsPoll.Tables[1].Rows.Count.ToString(); //btnSave.Text = "Update Poll"; } else //can't find the poll.. change to INSERT MODE { hidPollID.Value = ""; // btnSave.Text = "Save Poll"; } }
private bool CheckAlreadyPolled(string blockMode) { bool isPolled = false; //if the block mode of this Poll is by IP,, check in the DB whether a poll is already existing from this IP if (blockMode == Pollinginfo.BlockMode.IP_ADDRESS.ToString()) { string ip = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if (ip == null) { ip = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; } PollingController objPollC = new PollingController(); int id = objPollC.SelectPollIP(int.Parse(hidPollID.Value), ip); if (id > 0) isPolled = true; } else if (blockMode == Pollinginfo.BlockMode.COOKIE.ToString()) //If block by Cookie read the cookie to see if there is an entry for this blog { if (Request.Cookies["Poll"] != null && Request.Cookies["Poll"]["ID"] != null) { //the cookie will have comma seperated IDs of all the polls that already voted string commaSeperatedPollIDs = Request.Cookies["Poll"]["ID"]; //split it with comma string[] pollIDs = commaSeperatedPollIDs.Split(",".ToCharArray()); //and loop through each pollID to find whethere the current poll is already voted foreach (string pID in pollIDs) { //if yes break if (pID == hidPollID.Value) { isPolled = true; break; } } } } return isPolled; }
public int InsertPoll(string question, string blockMode) { Pollinginfo objInf = new Pollinginfo(); objInf.Question = question; objInf.blockMode = blockMode; objInf.UserModuleID = Int32.Parse(SageUserModuleID); objInf.PortalID = GetPortalID; PollingController objc = new PollingController(); return objc.InsertPoll(objInf); }