private bool CopyIntoPoll(List <PollDataError> pde) { bool check = false; try { foreach (var item in pde) { PollData pd = new PollData(); pd.EmpID = (int)item.DeviceRegID; pd.EntDate = item.EntryDate.Value.Date; pd.EntTime = item.EntryTime.Value; pd.EmpDate = pd.EmpID.ToString() + pd.EntDate.Date.ToString("yyMMdd"); pd.CardNo = "0"; pd.RdrID = 107; pd.FpID = (int)item.DeviceRegID; pd.RdrDuty = 8; pd.Split = false; pd.Process = false; pd.AddedDate = DateTime.Today; db.PollDatas.Add(pd); db.SaveChanges(); } check = true; } catch (Exception ex) { check = false; } return(check); }
public void Vote(int pollId) { PollData poll = pollService.GetById(pollId); if (poll == null) { content(lang("exPollNotFound")); return; } if (poll.CheckHasVote(ctx.viewer.Id)) { content(alang("exVoted")); return; } String choice = ctx.Get("pollOption"); PollDataResult pr = new PollDataResult(); pr.User = (User)ctx.viewer.obj; pr.PollId = poll.Id; pr.Answer = choice; pr.Ip = ctx.Ip; String lnkPoll = to(Show, poll.Id); pollService.CreateResult(pr, lnkPoll); String url = to(Voter, poll.Id); echoRedirect(lang("pollDone"), url); }
public void Awake() { Instance = this; LoadSequenceInstances = new List <PollImageSequenceComponent>(); LoadConfirmationSequenceInstances = new List <PollImageSequenceComponent>(); PollData = new PollData(Application.dataPath + "/poll-questions.json"); StartCoroutine(PollData.GetData()); }
public void Show(int id) { PollData poll = pollService.GetById(id); pollService.AddHits(poll); bindDetail(poll); bindComment(poll); }
private string getCommentUrl(PollData post) { return(t2(new wojilu.Web.Controller.Open.CommentController().List) + "?url=" + alink.ToAppData(post, ctx) + "&dataType=" + typeof(PollData).FullName + "&dataTitle=" + post.Title + "&dataUserId=" + post.Creator.Id + "&dataId=" + post.Id); }
public List <PollData> getPollWithCount(int SocietyID) { List <PollData> newList = new List <PollData>(); try { String getQuery = "Select * from ViewPollDataWithCount where SocietyID = " + SocietyID; DataAccess dacess = new DataAccess(); DataTable Polldatatable = new DataTable(); DataSet Polldata = dacess.ReadData(getQuery); if (Polldata != null) { Polldatatable = Polldata.Tables[0]; for (int i = 0; i < Polldatatable.Rows.Count; i++) { PollData temp = new PollData(); temp.PollID = Convert.ToInt32(Polldatatable.Rows[i]["PollID"]); try { temp.Question = Polldatatable.Rows[i]["Question"].ToString(); temp.Answer[0] = Polldatatable.Rows[i]["Answer1"].ToString(); temp.Answer[1] = Polldatatable.Rows[i]["Answer2"].ToString(); temp.Answer[2] = Polldatatable.Rows[i]["Answer3"].ToString(); temp.Answer[3] = Polldatatable.Rows[i]["Answer4"].ToString(); String Ans1Count = Polldatatable.Rows[i]["Answer1Count"].ToString(); if (Ans1Count != "" && Ans1Count != null) { temp.AnsCount[0] = Convert.ToInt32(Polldatatable.Rows[i]["Answer1Count"].ToString()); temp.AnsCount[1] = Convert.ToInt32(Polldatatable.Rows[i]["Answer2Count"].ToString()); temp.AnsCount[2] = Convert.ToInt32(Polldatatable.Rows[i]["Answer3Count"].ToString()); temp.AnsCount[3] = Convert.ToInt32(Polldatatable.Rows[i]["Answer4Count"].ToString()); } else { temp.AnsCount[0] = temp.AnsCount[1] = temp.AnsCount[2] = temp.AnsCount[3] = 0; } DateTime dstart = Convert.ToDateTime(Polldatatable.Rows[i]["StartDate"]); temp.StartDate = dstart.ToString("dd/MM/yyyy"); DateTime dEnd = Convert.ToDateTime(Polldatatable.Rows[i]["EndDate"]); temp.EndDate = dEnd.ToString("dd/MM/yyyy"); } catch (Exception ex) { int a = 1; } newList.Add(temp); } } } catch (Exception ex) { } return(newList); }
private void DisplayPage(int PageNumber, String Status) { int Poll1Count = (PageNumber - 1) * 2 + 1; int Poll2Count = (PageNumber - 1) * 2 + 2; p = new PollData(); pollCount = p.GetTotalPollCount(muser.currentResident.SocietyID, DisplayStatus); lblPollP1.Text = "Poll " + Poll1Count + " of " + pollCount; lblPollP2.Text = "Poll " + Poll2Count + " of " + pollCount; String orderby = ""; p = new PollData(); pollList = p.GetData(currPageNumber, orderby, muser.currentResident.SocietyID, Status); if (pollList.Count != 0) { lblEmptyPie1.Visible = false; if (PageNumber == 1) { btnPreBottom.Visible = false; } else { btnPreBottom.Visible = true; } if (pollCount <= currPageNumber * 2) { btnNextBottom.Visible = false; } else { btnNextBottom.Visible = true; pnlchart2.Visible = true; } CreatePieChart1(pollList[0]); if (pollCount >= currPageNumber * 2) { CreatePieChart2(pollList[1]); } else { HidePieChart2(); } } else { ShowEmptyPage(); } }
public void Voter(int pollId) { PollData poll = pollService.GetById(pollId); if (poll == null) { content(lang("exPollNotFound")); return; } bindVoterList(poll); }
public void SaveData(PollData _poll) { foreach (PollQuestion q in _poll.questions) { foreach (PollOption o in q.options) { if (o.voted == true) { StartCoroutine(PostVote(_poll.id, o.id)); } } } }
private void bindPollItem(PollData p) { set("poll.Id", p.Id); set("poll.Title", p.Title); set("poll.Question", p.Question); set("poll.Voters", p.VoteCount); set("poll.Created", p.Created); String replies = p.Replies > 0 ? " " + lang("comment") + ":" + p.Replies : ""; set("poll.Replies", replies); set("poll.ShowLink", to(Show, p.Id)); }
private bool SaveAttDataToPollData(List <ReadersCommLibrary.Poll> records, Int16 _RdrID) { bool check = false; using (var context = new TAS2013Entities()) { List <Emp> emps = context.Emps.Where(aa => aa.Status == true).ToList(); foreach (var entry in records) { try { var emp = emps.Where(aa => aa.EmpID == entry.ID); var reader = context.Readers.Where(aa => aa.RdrID == _RdrID); if (emp.Count() > 0) { PollData p = new PollData(); p.EmpID = emp.FirstOrDefault().EmpID; p.EntDate = entry.EntryDateTime.Date; p.EntTime = entry.EntryDateTime; p.EmpDate = emp.FirstOrDefault().EmpID.ToString() + entry.EntryDateTime.Date.ToString("yyMMdd"); p.CardNo = emp.FirstOrDefault().CardNo; p.RdrID = reader.FirstOrDefault().RdrID; p.FpID = entry.ID; p.RdrDuty = reader.FirstOrDefault().RdrDutyCode.RdrDutyID; p.Split = false; p.Process = false; p.AddedDate = DateTime.Today; context.PollDatas.AddObject(p); context.SaveChanges(); check = true; } else { PollDataError pde = new PollDataError(); pde.DeviceRegID = entry.ID; pde.EntryDate = entry.EntryDateTime.Date; pde.EntryTime = entry.EntryDateTime; pde.AddedDate = DateTime.Today; context.PollDataErrors.AddObject(pde); context.SaveChanges(); check = true; } } catch (Exception ex) { check = false; } } } return(check); }
private String getControl(PollData poll, int optionIndex) { Html html = new Html(); if (poll.Type == 1) { html.CheckBox("pollOption", Convert.ToString((optionIndex + 1)), ""); } else { html.Radio("pollOption", Convert.ToString((optionIndex + 1)), ""); } return(html.ToString()); }
public static Task <NfcTarget> PollAsync(this INfcInitiator initiator, NfcModulation[] modulations, byte period, CancellationToken cancellationToken) { TaskCompletionSource <NfcTarget> tcs = new TaskCompletionSource <NfcTarget>(); var data = new PollData { Initiator = (NfcDevice)initiator, Modulations = modulations, Period = period, CancellationToken = cancellationToken, Tcs = tcs, }; ThreadPool.QueueUserWorkItem(PollAsync, data); return(tcs.Task); }
private void SetFields() { currPageNumber = 1; p = new PollData(); pollCount = p.GetTotalPollCount(muser.currentResident.SocietyID, DisplayStatus); if (pollCount == 0) { ShowEmptyPage(); } else { DisplayPage(currPageNumber, DisplayStatus); } }
public void RestartPoll() { AskedQuestions = new List <int>(); UserAnswers = new List <PollUserAnswer>(); Loading = true; Data = new PollData(Application.dataPath + "/poll-questions.json"); m_LeaderboardData = new LeaderboardData(); TopScoreTitleInstance.HideObjects(); TopScoreTextInstance.HideObjects(); TopScoreTextLabelInstance.HideObjects(); YourScoreTextInstance.HideObjects(); YourScoreTextLabelInstance.HideObjects(); BtnStartOver.gameObject.SetActive(false); ShowInstructions(); }
public void ApplyVote(PollData data) { try { if (!data.Authenticate()) { return; } data.ApplyVote(); } catch (Exception error) { Error.Write(error); throw; } }
private void bindVoterList(PollData poll) { ctx.SetItem("poll", poll); load("voteResult", sectionPollResult); DataPage <PollDataResult> voterList = pollService.GetVoterList(poll.Id, 10); IBlock block = getBlock("list"); foreach (PollDataResult result in voterList.Results) { block.Set("user.Name", result.User.Name); block.Set("user.Choice", result.Answer); block.Set("user.Created", result.Created); block.Next(); } set("page", voterList.PageBar); }
private async void optionSelected_Clicked(object sender, EventArgs e) { Frame optionFrame = (Frame)sender; var item = (TapGestureRecognizer)optionFrame.GestureRecognizers[0]; object[] parameters = (object[])item.CommandParameter; PollData pollData = (PollData)parameters[0]; if (pollData.IsAnswerSubmitted == false) { int optionValue = (int)parameters[1]; PollOption selectedOption = pollData.Options.Where(x => x.Value == optionValue).FirstOrDefault(); if (!selectedOption.IsSelected) { selectedOption.IsSelected = true; } PollResponseModel pollResponseModel = await DashBoardService.AddPoll(pollId : Convert.ToInt32(pollData.id), parentId : ParentkidsDetails.id, selectedOption.Name); } }
public RunPollBar(DateTime start, string name, string title, string[] pollvars) { InitializeComponent(); Text = @"Poll ( " + name + @") - Chatinator"; _startTime = start; _optionsName = name; _pollTitle = title; _countEntries = pollvars.Length; _data = new PollData(_countEntries) { Options = pollvars }; ReadOptions(); SetupVars(); if (_optionsName == "_preview") { GeneratePreviewData(); } else { SetupDataStoreWatcher(); } SetClientSizeCore(_options.Width, _options.Height); if (_options.TransparentBackground) { SetStyle(ControlStyles.SupportsTransparentBackColor, true); SetStyle(ControlStyles.UserPaint, true); TransparencyKey = _options.ChromaKey; } BackColor = _options.ChromaKey; Paint += RunPollBar_Paint; Load += RunPollBar_Load; FormClosing += RunPollBar_FormClosing; Disposed += RunPollBar_Disposed; }
protected void btnPieChart2_Click(object sender, EventArgs e) { int newSelection = 0; int previousSelection = 0; int PollID = Convert.ToInt32(HiddenField2.Value); //Added by Aarshi on 18 auh 2017 for session storage if (SessionVariables.SelectedAnswerChart2 != 0) { previousSelection = SessionVariables.SelectedAnswerChart2; } if (RadioChart2Opt1.Checked) { newSelection = 1; } else if (RadioChart2Opt2.Checked) { newSelection = 2; } else if (RadioChart2Opt3.Checked) { newSelection = 3; } else if (RadioChart2Opt4.Checked) { newSelection = 4; } PollData pData = new PollData(); bool result = pData.UpdatePollAnswer(muser.currentResident.ResID, PollID, newSelection, previousSelection); if (result == true) { ClientScript.RegisterStartupScript(this.GetType(), "alert()", "alert('Updated Sucessfully')", true); } DisplayPage(currPageNumber, DisplayStatus); }
public void sectionPollResult() { PollData p = ctx.GetItem("poll") as PollData; bindPollItem(p); set("poll.ResultLink", to(Voter, p.Id)); IBlock opblock = getBlock("options"); for (int i = 0; i < p.OptionList.Length; i++) { OptionResult or = new OptionResult(p, p.OptionList.Length, i); opblock.Set("op.Text", p.OptionList[i]); opblock.Set("op.Id", (i + 1)); opblock.Set("op.ImgWidth", or.ImgWidth * 0.5); opblock.Set("op.Percent", or.VotesAndPercent); opblock.Next(); } set("poll.ExpiryInfo", PollUtil.GetRealExpiryDate(p)); }
private void bindDetail(PollData poll) { set("post.Title", poll.Title); set("post.CreateTime", poll.Created); set("post.ReplyCount", poll.Replies); set("post.Hits", poll.Hits); User user = (User)ctx.viewer.obj; Boolean hasVote = poll.CheckHasVote(user.Id); ctx.SetItem("poll", poll); if (hasVote) { set("post.Content", loadHtml(sectionPollResult)); } else { set("post.Content", loadHtml(sectionPoll)); } }
private void bindPollList(DataPage <PollData> polls) { User user = (User)ctx.viewer.obj; IBlock block = getBlock("list"); for (int i = 0; i < polls.Results.Count; i++) { PollData poll = polls.Results[i]; ctx.SetItem("poll", poll); block.Set("post.UserPic", poll.Creator.PicSmall); Boolean hasVote = poll.CheckHasVote(user.Id); String html = hasVote ? loadHtml(sectionPollResult) : loadHtml(sectionPoll); block.Set("post.Html", html); block.Next(); } set("page", polls.PageBar); }
private void sectionPoll() { PollData p = ctx.GetItem("poll") as PollData; bindPollItem(p); set("poll.VoteLink", to(Vote, p.Id)); IBlock opblock = getBlock("options"); for (int i = 0; i < p.OptionList.Length; i++) { OptionResult or = new OptionResult(p, p.OptionList.Length, i); opblock.Set("op.SelectControl", getControl(p, i)); opblock.Set("op.Text", p.OptionList[i]); opblock.Set("op.Id", (i + 1)); opblock.Next(); } IBlock cmdBlock = getBlock("cmdVote"); IBlock tipBlock = getBlock("plsVote"); if (PollUtil.IsClosed(p)) { } else if (ctx.viewer.IsLogin) { cmdBlock.Next(); } else { tipBlock.Next(); } set("poll.ExpiryInfo", PollUtil.GetRealExpiryDate(p)); }
private static void PollAsync(object state) { PollData data = (PollData)state; NfcTarget result = null; try { int i = 0; Action cancelPolling = () => { var error = NativeMethods.abort_command(data.Initiator.DangerousGetHandle()); }; data.CancellationToken.Register(cancelPolling); while (result == null && !data.CancellationToken.IsCancellationRequested) { result = ((INfcInitiator)data.Initiator).Poll(new[] { data.Modulations[i] }, 1, data.Period); i = (i + 1) % data.Modulations.Length; } if (data.CancellationToken.IsCancellationRequested) { data.Tcs.TrySetCanceled(data.CancellationToken); } else { data.Tcs.TrySetResult(result); } } catch (Exception ex) { data.Tcs.TrySetException(ex); } finally { data.Tcs.TrySetResult(result); } }
public List <PollData> GetData(int PageNumber, String order, int SocietyID, String Status) { order = ""; String orderby = ""; String StatusCond = ""; if (order == "EndDate Descending") { orderby = "EndDate DESC"; } else if (order == "EndDate Ascending") { orderby = "EndDate ASC"; } else if (order == "Creation Date") { orderby = "StartDate ASC"; } else { orderby = "StartDate DESC"; } if (Status == "All") { StatusCond = ""; } else if (Status == "Open") { StatusCond = " and EndDate >= Convert(date, GetUTCDate())"; } else if (Status == "Close") { StatusCond = " and EndDate < Convert(date, GetUTCDate())"; } List <PollData> newList = new List <PollData>(); DataAccess dacess = new DataAccess(); String GetQuery = "SELECT * FROM " + " (SELECT ROW_NUMBER() OVER (ORDER BY " + orderby + ") AS rownumber,* FROM ViewPollDataWithCount where SocietyID = " + SocietyID.ToString() + StatusCond + ") as Poll" + " WHERE rownumber IN (" + (2 * PageNumber - 1) + "," + 2 * PageNumber + ")"; DataTable Polldatatable = new DataTable(); DataSet Polldata = dacess.ReadData(GetQuery); if (Polldata != null) { Polldatatable = Polldata.Tables[0]; for (int i = 0; i < Polldatatable.Rows.Count; i++) { PollData temp = new PollData(); temp.PollID = Convert.ToInt32(Polldatatable.Rows[i]["PollID"]); try { temp.Question = Polldatatable.Rows[i]["Question"].ToString(); temp.Answer[0] = Polldatatable.Rows[i]["Answer1"].ToString(); temp.Answer[1] = Polldatatable.Rows[i]["Answer2"].ToString(); temp.Answer[2] = Polldatatable.Rows[i]["Answer3"].ToString(); temp.Answer[3] = Polldatatable.Rows[i]["Answer4"].ToString(); String Ans1Count = Polldatatable.Rows[i]["Answer1Count"].ToString(); if (Ans1Count != "" && Ans1Count != null) { temp.AnsCount[0] = Convert.ToInt32(Polldatatable.Rows[i]["Answer1Count"].ToString()); temp.AnsCount[1] = Convert.ToInt32(Polldatatable.Rows[i]["Answer2Count"].ToString()); temp.AnsCount[2] = Convert.ToInt32(Polldatatable.Rows[i]["Answer3Count"].ToString()); temp.AnsCount[3] = Convert.ToInt32(Polldatatable.Rows[i]["Answer4Count"].ToString()); } else { temp.AnsCount[0] = temp.AnsCount[1] = temp.AnsCount[2] = temp.AnsCount[3] = 0; } DateTime dstart = Convert.ToDateTime(Polldatatable.Rows[i]["StartDate"]); temp.StartDate = dstart.ToString("dd/MM/yyyy"); DateTime dEnd = Convert.ToDateTime(Polldatatable.Rows[i]["EndDate"]); temp.EndDate = dEnd.ToString("dd/MM/yyyy"); } catch (Exception ex) { int a = 1; } newList.Add(temp); } } return(newList); }
public List <PollData> getPollDataFromDB(String FilterQuery) { List <PollData> newList = new List <PollData>(); DataAccess dacess = new DataAccess(); String PickDataQuery = ""; if (FilterQuery == "") { PickDataQuery = "SELECT * FROM [dbo].[PollingData]"; } else { PickDataQuery = FilterQuery; } // String PickDataQuery = "SELECT TOP 10 * FROM [dbo].[PollingData]"; DataTable Polldatatable = new DataTable(); DataSet Polldata = dacess.ReadData(PickDataQuery); if (Polldata != null) { Polldatatable = Polldata.Tables[0]; for (int i = 0; i < Polldatatable.Rows.Count; i++) { PollData temp = new PollData(); DataRow dr = Polldatatable.Rows[i]; String question = dr["Question"].ToString(); String answer1 = dr["Answer1"].ToString(); DateTime startD = Convert.ToDateTime(dr["StartDate"]); string startDate = startD.ToString("dd/MM/yyyy"); String EndD = dr["EndDate"].ToString(); String Endate = Convert.ToDateTime(EndD).ToString("dd/MM/yyyy"); String Answer1String = dr["Answer1String"].ToString(); int answerCount1 = Convert.ToInt32(dr["Answer1Count"]); if (answer1 != null || answer1 == "") { temp.StartDate = startDate; temp.EndDate = Endate; temp.Question = question; temp.AnswerString[0] = Answer1String; temp.Answer[0] = answer1; temp.AnsCount[0] = answerCount1; } String answer2String = dr["Answer2String"].ToString(); String answer2 = dr["Answer2"].ToString(); int answerCount2 = Convert.ToInt32(dr["Answer2Count"]); if (answer2 != null || answer2 == "") { temp.StartDate = startDate; temp.EndDate = Endate; temp.Question = question; temp.AnswerString[1] = answer2String; temp.Answer[1] = answer2; temp.AnsCount[1] = answerCount2; } String answer3String = dr["Answer3String"].ToString(); String answer3 = dr["Answer3"].ToString(); int answerCount3 = Convert.ToInt32(dr["Answer3Count"]); if (answer3 != null || answer3 == "") { temp.StartDate = startDate; temp.EndDate = Endate; temp.Question = question; temp.AnswerString[2] = answer3String; temp.Answer[2] = answer3; temp.AnsCount[2] = answerCount3; } String answer4String = dr["Answer4String"].ToString(); String answer4 = dr["Answer4"].ToString(); int answerCount4 = Convert.ToInt32(dr["Answer4Count"]); if (answer4 != null || answer4 == "") { temp.StartDate = startDate; temp.EndDate = Endate; temp.Question = question; temp.AnswerString[3] = answer4String; temp.Answer[3] = answer4; temp.AnsCount[3] = answerCount4; } newList.Add(temp); } } else { } return(newList); }
public void SetPoll(PollData _poll) { poll = _poll; startScreen.GetComponentInChildren <Text>().text = "Готово!"; }
private static void ReceivePolls() { Console.WriteLine("Receiving polls... - {0}", DateTime.Now); using (var messaging = new ClientService()) { Poll[] polls = messaging.ListPolls(new AuthenticatedData()); if (polls.Length == 0) Console.WriteLine(" No new polls on the server."); else foreach (Poll poll in polls) { Console.WriteLine(" New Poll: {0}", poll.Question); Console.WriteLine(" Created: {0}, Expires: {1}", poll.DateCreated, poll.DateExpires); foreach (PollOption po in poll.PollOptions) { Console.WriteLine(" Option: {0}", po.Option); } //Vote on a random option var r = new Random(); PollData vote = new PollData() { OptionId = poll.PollOptions[r.Next(0,poll.PollOptions.Length)].Id, OptionIdSpecified = true }; messaging.ApplyVote(vote); } } }
public PollRequest(PollData pollData) => PollData = pollData;
private void bindComment(PollData post) { set("commentUrl", getCommentUrl(post)); }