예제 #1
0
        public static void ExportPoll(int siteId, string directoryPath, int pollId)
        {
            var pollInfo = PollManager.GetPollInfo(siteId, pollId);
            var filePath = PollUtils.PathCombine(directoryPath, pollInfo.Id + ".xml");

            var feed = GetEmptyFeed();

            foreach (var tableColumn in PollManager.Repository.TableColumns)
            {
                SetValue(feed.AdditionalElements, tableColumn, pollInfo);
            }

            var styleDirectoryPath = PollUtils.PathCombine(directoryPath, pollInfo.Id.ToString());

            ExportFields(pollInfo.Id, styleDirectoryPath);

            var logInfoList = LogManager.Repository.GetLogInfoList(pollInfo.Id, 0, 0);

            foreach (var logInfo in logInfoList)
            {
                var entry = GetAtomEntry(logInfo);
                feed.Entries.Add(entry);
            }
            feed.Save(filePath);
        }
예제 #2
0
        public IHttpActionResult Submit()
        {
            try
            {
                var request = Context.AuthenticatedRequest;

                var pollInfo = PollManager.GetPollInfo(request);
                if (pollInfo == null)
                {
                    return(NotFound());
                }
                if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(pollInfo.SiteId, PollUtils.PluginId))
                {
                    return(Unauthorized());
                }

                var fieldId = request.GetPostInt("fieldId");
                var value   = request.GetPostString("value");

                var fieldInfo = FieldManager.GetFieldInfo(pollInfo.Id, fieldId);
                fieldInfo.Validate = value;

                FieldManager.Repository.Update(fieldInfo, false);

                return(Ok(new{}));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
예제 #3
0
        private void BindData()
        {
            Poll poll = PollManager.GetPollById(this.PollId);

            if (poll != null)
            {
                CommonHelper.SelectListItem(this.ddlLanguage, poll.LanguageId);
                this.txtName.Text             = poll.Name;
                this.txtSystemKeyword.Text    = poll.SystemKeyword;
                this.cbPublished.Checked      = poll.Published;
                this.cbShowOnHomePage.Checked = poll.ShowOnHomePage;
                if (poll.StartDate.HasValue)
                {
                    this.ctrlStartDate.SelectedDate = poll.StartDate;
                }
                if (poll.EndDate.HasValue)
                {
                    this.ctrlEndDate.SelectedDate = poll.EndDate;
                }
                this.txtDisplayOrder.Value = poll.DisplayOrder;

                pnlPollAnswers.Visible = true;
                var pollAnswers = poll.PollAnswers;
                gvPollAnswers.DataSource = pollAnswers;
                gvPollAnswers.DataBind();
            }
            else
            {
                pnlPollAnswers.Visible = false;
            }
        }
예제 #4
0
        public IHttpActionResult Get()
        {
            try
            {
                var request = Context.AuthenticatedRequest;

                var siteId = request.GetQueryInt("siteId");
                if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(siteId, PollUtils.PluginId))
                {
                    return(Unauthorized());
                }

                var formInfoList = PollManager.GetPollInfoList(siteId, 0);

                var type             = request.GetQueryString("type");
                var name             = request.GetQueryString("name");
                var templateInfoList = TemplateManager.GetTemplateInfoList(type);
                var templateInfo     =
                    templateInfoList.FirstOrDefault(x => PollUtils.EqualsIgnoreCase(name, x.Name));

                return(Ok(new
                {
                    Value = templateInfo,
                    PollInfoList = formInfoList
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
예제 #5
0
        public IHttpActionResult Get()
        {
            try
            {
                var request = Context.AuthenticatedRequest;

                var pollInfo = PollManager.GetPollInfo(request);
                if (pollInfo == null)
                {
                    return(NotFound());
                }
                if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(pollInfo.SiteId, PollUtils.PluginId))
                {
                    return(Unauthorized());
                }

                var fieldId   = request.GetQueryInt("fieldId");
                var fieldInfo = FieldManager.GetFieldInfo(pollInfo.Id, fieldId);

                var veeValidate = string.Empty;
                if (fieldInfo != null)
                {
                    veeValidate = fieldInfo.Validate;
                }

                return(Ok(new
                {
                    Value = veeValidate
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
예제 #6
0
        /// <summary>
        /// Carga la encuesta de satisfacción.
        /// </summary>
        public void LoadPoll()
        {
            try
            {
                PollManager pollManager = new PollManager();
                Poll        poll        = pollManager.GetInstantPoll();
                SessionUtilHelper.KeepInSession(poll.Id.ToString(), Session);

                if (poll != null && poll.Questions.Count > 0)
                {
                    txtPollTitle.InnerText  = poll.Name;
                    pollRepeater.DataSource = poll.Questions;
                    pollRepeater.DataBind();
                    divPoll.Visible = true;
                }
                else
                {
                    // No es prolijo porque se mezcla la parte visual con los datos, pero sirve
                    divPoll.Visible = false;
                }
            }
            catch (Exception exception)
            {
                //TODO - aplicar contorl e errores
                //((front)Master).Alert.Show("Excepción", exception.Message);
            }
        }
예제 #7
0
        void BindGrid()
        {
            var pollCollection = PollManager.GetAllPolls(0);

            gvPolls.DataSource = pollCollection;
            gvPolls.DataBind();
        }
예제 #8
0
        protected void BindData(bool showResults)
        {
            var poll = PollManager.GetPollById(this.PollId);

            if (poll != null && poll.Published)
            {
                lblPollName.Text   = Server.HtmlEncode(poll.Name);
                lblTotalVotes.Text = string.Format(GetLocaleResourceString("Polls.TotalVotes"), poll.TotalVotes);

                var pollAnswers = poll.PollAnswers;
                pnlTakePoll.Visible    = !showResults;
                pnlPollResults.Visible = showResults;
                if (showResults)
                {
                    dlResults.DataSource = pollAnswers;
                    dlResults.DataBind();
                }
                else
                {
                    rblPollAnswers.DataSource = pollAnswers;
                    rblPollAnswers.DataBind();
                }
            }
            else
            {
                pnlTakePoll.Visible    = false;
                pnlPollResults.Visible = false;
            }
        }
예제 #9
0
        public IHttpActionResult Down()
        {
            try
            {
                var request  = Context.AuthenticatedRequest;
                var pollInfo = PollManager.GetPollInfo(request);
                if (pollInfo == null)
                {
                    return(NotFound());
                }
                if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(pollInfo.SiteId, PollUtils.PluginId))
                {
                    return(Unauthorized());
                }

                var itemId = request.GetPostInt("itemId");

                ItemManager.Repository.TaxisDown(pollInfo.Id, itemId);

                return(Ok(new
                {
                    Value = true
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
예제 #10
0
        public IHttpActionResult GetItems()
        {
            try
            {
                var request  = Context.AuthenticatedRequest;
                var pollInfo = PollManager.GetPollInfo(request);
                if (pollInfo == null)
                {
                    return(NotFound());
                }
                if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(pollInfo.SiteId, PollUtils.PluginId))
                {
                    return(Unauthorized());
                }

                var items      = ItemManager.GetItemInfoList(pollInfo.Id);
                var totalCount = items.Sum(x => x.Count);
                var adminToken = Context.AdminApi.GetAccessToken(request.AdminId, request.AdminName, TimeSpan.FromDays(1));

                return(Ok(new
                {
                    Value = items,
                    TotalCount = totalCount,
                    PollInfo = pollInfo,
                    AdminToken = adminToken
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
예제 #11
0
        public PollController()
        {
            var pollRepo = new PollRepository(_data);

            _poll     = new PollManager(pollRepo);
            _response = new ResponseManager(new ResponseRepository(_data));
        }
예제 #12
0
        public Poll SaveInfo()
        {
            Poll     poll      = PollManager.GetPollById(this.PollId);
            DateTime?startDate = ctrlStartDate.SelectedDate;
            DateTime?endDate   = ctrlEndDate.SelectedDate;

            if (startDate.HasValue)
            {
                startDate = DateTime.SpecifyKind(startDate.Value, DateTimeKind.Utc);
            }
            if (endDate.HasValue)
            {
                endDate = DateTime.SpecifyKind(endDate.Value, DateTimeKind.Utc);
            }

            if (poll != null)
            {
                poll = PollManager.UpdatePoll(poll.PollId, int.Parse(this.ddlLanguage.SelectedItem.Value),
                                              txtName.Text, txtSystemKeyword.Text, cbPublished.Checked, cbShowOnHomePage.Checked, txtDisplayOrder.Value, startDate, endDate);
            }
            else
            {
                poll = PollManager.InsertPoll(int.Parse(this.ddlLanguage.SelectedItem.Value),
                                              txtName.Text, txtSystemKeyword.Text, cbPublished.Checked, cbShowOnHomePage.Checked, txtDisplayOrder.Value, startDate, endDate);
            }
            return(poll);
        }
예제 #13
0
        public IHttpActionResult Delete()
        {
            try
            {
                var request = Context.AuthenticatedRequest;

                var siteId = request.GetQueryInt("siteId");
                if (!request.IsAdminLoggin ||
                    !request.AdminPermissions.HasSitePermissions(siteId, PollUtils.PluginId))
                {
                    return(Unauthorized());
                }

                var pollId = request.GetQueryInt("pollId");

                PollManager.Repository.Delete(siteId, pollId);

                return(Ok(new
                {
                    Value = PollManager.GetPollInfoList(siteId, 0)
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
예제 #14
0
        public IHttpActionResult Add()
        {
            try
            {
                var request = Context.AuthenticatedRequest;

                var siteId = request.GetQueryInt("siteId");
                if (!request.IsAdminLoggin ||
                    !request.AdminPermissions.HasSitePermissions(siteId, PollUtils.PluginId))
                {
                    return(Unauthorized());
                }

                var pollInfo = new PollInfo
                {
                    SiteId      = siteId,
                    Title       = request.GetPostString("title"),
                    Description = request.GetPostString("description")
                };

                PollManager.Repository.Insert(pollInfo);

                return(Ok(new
                {
                    Value = PollManager.GetPollInfoList(siteId, 0)
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
예제 #15
0
        public IHttpActionResult Get()
        {
            try
            {
                var request = Context.AuthenticatedRequest;

                var siteId = request.GetQueryInt("siteId");
                if (!request.IsAdminLoggin ||
                    !request.AdminPermissions.HasSitePermissions(siteId, PollUtils.PluginId))
                {
                    return(Unauthorized());
                }

                var pollInfoList = PollManager.GetPollInfoList(siteId, 0);
                var adminToken   = Context.AdminApi.GetAccessToken(request.AdminId, request.AdminName, TimeSpan.FromDays(1));

                return(Ok(new
                {
                    Value = pollInfoList,
                    AdminToken = adminToken
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
예제 #16
0
        /// <summary>
        /// Muestra el formulario para la edición de un elemento existente.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void ShowEditForm(object sender, UbiquicityEventArg e)
        {
            try {
                int id = Convert.ToInt32(e.TheObject);
                Session["Ubiquicity_itemId"] = id;

                PollManager pollManager = new PollManager();
                Poll        poll        = pollManager.Get(id);

                if (poll == null && pollManager.HasErrors)
                {
                    Alert.ShowUP("Error", pollManager.ErrorDescription);
                }
                else
                {
                    //TODO - agregar controles de error
                    PollOptionManager pollOptionManager = new PollOptionManager();
                    List <PollOption> pollOptions       = pollOptionManager.Get();

                    UCFormPoll.CleanForm(pollOptions);
                    UCFormPoll.FillForm(poll);
                    Session["Ubiquicity_action"] = EDIT;
                    //Page.ClientScript.RegisterStartupScript(this.GetType(), "openModalEdit", "window.onload = function() { $('#modalMap').modal('show'); }", true);
                    ScriptManager.RegisterStartupScript(upUCModalForm, upUCModalForm.GetType(), "openModalEdit", "$('#modalPol').modal('show');", true);
                    upUCModalForm.Update();
                }
            }
            catch (Exception exception) {
                Alert.ShowUP("Exception", exception.Message);
            }
        }
예제 #17
0
        public string GetImportTitle(int siteId, string title)
        {
            string importTitle;

            if (title.IndexOf("_", StringComparison.Ordinal) != -1)
            {
                var inputNameCount = 0;
                var lastInputName  = title.Substring(title.LastIndexOf("_", StringComparison.Ordinal) + 1);
                var firstInputName = title.Substring(0, title.Length - lastInputName.Length);
                try
                {
                    inputNameCount = int.Parse(lastInputName);
                }
                catch
                {
                    // ignored
                }
                inputNameCount++;
                importTitle = firstInputName + inputNameCount;
            }
            else
            {
                importTitle = title + "_1";
            }

            var inputInfo = PollManager.GetPollInfo(siteId, title);

            if (inputInfo != null)
            {
                importTitle = GetImportTitle(siteId, importTitle);
            }

            return(importTitle);
        }
예제 #18
0
        public HomeController()
        {
            var PollRepo = new PollRepository(new DataEntities());

            _poll = new PollManager(PollRepo);

            _vote = new VoteService();
        }
예제 #19
0
        public StreamProcessor()
        {
            this._stateMachine = Environment.GetEnvironmentVariable(ENV_POLL_STATE_MACHINE);
            Console.WriteLine($"Using State Machine {this._stateMachine}");

            this._stepClient = new AmazonStepFunctionsClient();
            this._manager    = new PollManager(new AmazonDynamoDBClient());
        }
예제 #20
0
        public bool Update(PollInfo pollInfo)
        {
            var updated = _repository.Update(pollInfo);

            PollManager.UpdateCache(pollInfo);

            return(updated);
        }
        public IHttpActionResult Get()
        {
            try
            {
                var request = Context.AuthenticatedRequest;

                var pollInfo = PollManager.GetPollInfo(request);
                if (pollInfo == null)
                {
                    return(NotFound());
                }
                if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(pollInfo.SiteId, PollUtils.PluginId))
                {
                    return(Unauthorized());
                }

                var fieldId   = request.GetQueryInt("fieldId");
                var fieldInfo = FieldManager.GetFieldInfo(pollInfo.Id, fieldId) ?? new FieldInfo();

                var isRapid     = true;
                var rapidValues = string.Empty;
                if (fieldInfo.Items.Count == 0)
                {
                    fieldInfo.Items.Add(new FieldItemInfo
                    {
                        Value      = string.Empty,
                        IsSelected = false
                    });
                }
                else
                {
                    var isSelected = false;
                    var list       = new List <string>();
                    foreach (var item in fieldInfo.Items)
                    {
                        list.Add(item.Value);
                        if (item.IsSelected)
                        {
                            isSelected = true;
                        }
                    }

                    isRapid     = !isSelected;
                    rapidValues = string.Join("\r\n", list);
                }

                return(Ok(new
                {
                    Value = fieldInfo,
                    IsRapid = isRapid,
                    RapidValues = rapidValues
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
예제 #22
0
        //[Inject]GetPollDetails
        //public IPublishPollVM publishPollObjectVM;, CRS.DataModel.ViewModel.PublishPollVM _publishPollObjectVM

        public EmailManager(VoteContext _datacontext, UserManager _objUsermanager,
                            PollManager _objPollManager, IPublishPollObject _objPublishPollObject, EmailContent _objEmailContent)
        {
            this.dataContext          = _datacontext;
            this.objUsermanager       = _objUsermanager;
            this.objPollManager       = _objPollManager;
            this.objPublishPollObject = _objPublishPollObject;
            this.objEmailContent      = _objEmailContent;
        }
예제 #23
0
        public IHttpActionResult Delete()
        {
            try
            {
                var request = Context.AuthenticatedRequest;

                var pollInfo = PollManager.GetPollInfo(request);
                if (pollInfo == null)
                {
                    return(NotFound());
                }
                if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(pollInfo.SiteId, PollUtils.PluginId))
                {
                    return(Unauthorized());
                }

                var logId   = request.GetQueryInt("logId");
                var logInfo = LogManager.Repository.GetLogInfo(logId);
                if (logInfo == null)
                {
                    return(NotFound());
                }

                LogManager.Repository.Delete(pollInfo, logInfo);

                var pages = Convert.ToInt32(Math.Ceiling((double)pollInfo.TotalCount / PollUtils.PageSize));
                if (pages == 0)
                {
                    pages = 1;
                }
                var page = request.GetQueryInt("page", 1);
                if (page > pages)
                {
                    page = pages;
                }
                var logInfoList = LogManager.Repository.GetLogInfoList(pollInfo, page);

                var logs = new List <IDictionary <string, object> >();
                foreach (var info in logInfoList)
                {
                    logs.Add(info.ToDictionary());
                }

                return(Ok(new
                {
                    Value = logs,
                    Count = pollInfo.TotalCount,
                    Pages = pages,
                    Page = page
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
예제 #24
0
        public async Task <IActionResult> CreatePollByBuildingId(CancellationToken cancellationToken,
                                                                 [FromRoute] Guid buildingId,
                                                                 [FromBody] CreatePollBinding binding,
                                                                 [FromServices] PollManager mananger)
        {
            await mananger.CreateByBuilding(binding.Question, binding.Answers, binding.OwnerId,
                                            buildingId, cancellationToken);

            return(Ok());
        }
예제 #25
0
        public IHttpActionResult Import()
        {
            try
            {
                var request = Context.AuthenticatedRequest;

                var pollInfo = PollManager.GetPollInfo(request);
                if (pollInfo == null)
                {
                    return(NotFound());
                }
                if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(pollInfo.SiteId, PollUtils.PluginId))
                {
                    return(Unauthorized());
                }

                foreach (string name in HttpContext.Current.Request.Files)
                {
                    var postFile = HttpContext.Current.Request.Files[name];

                    if (postFile == null)
                    {
                        return(BadRequest("Could not read zip from body"));
                    }

                    var filePath = Context.UtilsApi.GetTemporaryFilesPath("poll.zip");
                    PollUtils.DeleteFileIfExists(filePath);

                    if (!PollUtils.EqualsIgnoreCase(Path.GetExtension(postFile.FileName), ".zip"))
                    {
                        return(BadRequest("zip file extension is not correct"));
                    }

                    postFile.SaveAs(filePath);

                    var directoryPath = Context.UtilsApi.GetTemporaryFilesPath("poll");
                    PollUtils.DeleteDirectoryIfExists(directoryPath);
                    Context.UtilsApi.ExtractZip(filePath, directoryPath);

                    var isHistoric = PollBox.IsHistoric(directoryPath);
                    PollBox.ImportFields(pollInfo.SiteId, pollInfo.Id, directoryPath, isHistoric);

                    //FieldManager.Import(pollInfo.SiteId, pollInfo.Id, filePath);
                }

                return(Ok(new
                {
                    Value = true
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
예제 #26
0
        public void ViewPoll()
        {
            //Arrange
            var manager   = new PollManager();
            var mockVotes = new PollModel[] { };
            //Act
            var votes = manager.ViewPoll();

            //Asserts
            Assert.IsTrue(votes.Length > 0, "No Vote was cast");
        }
예제 #27
0
        protected void gvPollAnswers_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int        pollAnswerId = (int)gvPollAnswers.DataKeys[e.RowIndex]["PollAnswerId"];
            PollAnswer pollAnswer   = PollManager.GetPollAnswerById(pollAnswerId);

            if (pollAnswer != null)
            {
                PollManager.DeletePollAnswer(pollAnswer.PollAnswerId);
                BindData();
            }
        }
예제 #28
0
        public void ViewPoll()
        {
            //Arrange
            var mockPollRepo = new MockPollRepository();
            var manager      = new PollManager(mockPollRepo);
            //Act
            var votes = manager.GetPolls();

            //Asserts
            Assert.IsTrue(votes.Length > 0, "No Vote was cast");
        }
예제 #29
0
        public IHttpActionResult Get()
        {
            try
            {
                var request = Context.AuthenticatedRequest;

                var pollInfo = PollManager.GetPollInfo(request);
                if (pollInfo == null)
                {
                    return(NotFound());
                }
                if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(pollInfo.SiteId, PollUtils.PluginId))
                {
                    return(Unauthorized());
                }

                var fieldInfoList      = FieldManager.GetFieldInfoList(pollInfo.Id);
                var listAttributeNames = PollUtils.StringCollectionToStringList(pollInfo.ListAttributeNames);
                var allAttributeNames  = PollManager.GetAllAttributeNames(fieldInfoList);

                var pages = Convert.ToInt32(Math.Ceiling((double)pollInfo.TotalCount / PollUtils.PageSize));
                if (pages == 0)
                {
                    pages = 1;
                }
                var page = request.GetQueryInt("page", 1);
                if (page > pages)
                {
                    page = pages;
                }
                var logInfoList = LogManager.Repository.GetLogInfoList(pollInfo, page);

                var logs = new List <Dictionary <string, object> >();
                foreach (var logInfo in logInfoList)
                {
                    logs.Add(LogManager.GetDict(fieldInfoList, logInfo));
                }

                return(Ok(new
                {
                    Value = logs,
                    Count = pollInfo.TotalCount,
                    Pages = pages,
                    Page = page,
                    FieldInfoList = fieldInfoList,
                    AllAttributeNames = allAttributeNames,
                    ListAttributeNames = listAttributeNames
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
예제 #30
0
 public IActionResult GetPoll(int id)
 {
     try
     {
         PollOption pollOption = PollManager.GetPoll(id);
         return(Ok(pollOption));
     }
     catch
     {
         return(BadRequest());
     }
 }