protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            //Precisa estar aqui, pois a atualização do periodo acontece após o Page_Load e depois atualiza o período.
            phPeriodOpen.Visible = false;
            using (Lib.Repositories.PeriodRepository rep = new Lib.Repositories.PeriodRepository(this.BasePage.ActiveUser))
            {
                var period = rep.getPeriodOpen();

                if (period != null)
                {
                    linkToRequestCities.NavigateUrl = String.Format("/City/RequestCities.aspx?periodId={0}", HttpUtility.UrlEncode(Commons.SecurityUtils.criptografar(period.Id.ToString())));
                    linkToOpenForms.NavigateUrl = String.Format("/Form/ListResponseForm.aspx?periodId={0}", HttpUtility.UrlEncode(Commons.SecurityUtils.criptografar(period.Id.ToString())));
                    menu_period_period.Text = String.Format(Resources.Label.menu_period, period.FinalDate.ToString("dd/MM/yyyy"));
                    phPeriodOpen.Visible = true;
                }
                else
                {
                    menu_period_period.Text = String.Format(Resources.Label.menu_period, "");
                }
            }
        }
        //private void loadRequestCities(long cityId, long periodId)
        //{
        //    using (Lib.Repositories.UserRepository ctx = new Lib.Repositories.UserRepository(this.ActiveUser))
        //    {
        //        var listPendingRequests = ctx.getAllRequestsFromCity(cityId, periodId);
        //        listPendingRequests.Select(l=>l.
        //    }
        //}
        private void loadPeriodInformation(Lib.Entities.City city)
        {
            phOpenPeriodInformation.Visible = false;
            using (Lib.Repositories.PeriodRepository ctx = new Lib.Repositories.PeriodRepository(this.ActiveUser))
            {
                var periodOpen = ctx.getPeriodOpen();

                if (periodOpen != null)
                {
                    ltOpenPeriodTitle.Text = String.Format("Responsáveis e colaboradores no período ({0})", periodOpen.Name);
                    hdOpenPeriodId.Value = Commons.SecurityUtils.criptografar(periodOpen.Id.ToString());
                    phOpenPeriodInformation.Visible = true;

                    if (city != null)
                    {
                        //Recupera o grupo da cidade e periodo selecionado
                        var group = city.Groups.Where(g => g.PeriodId == periodOpen.Id).FirstOrDefault();

                        if (group != null)
                        {
                            var list = group.Collaborators.Select(c => new
                            {
                                Id = c.Id,
                                Name = c.Name
                            }).ToList();

                            JavaScriptSerializer js = new JavaScriptSerializer();
                            hdCurrentCollabsJson.Value = js.Serialize(list);

                            hdCollabValues.Value = String.Join(",", list.Select(i => i.Id).ToList());
                            hdCurrentCollabs.Value = hdCollabValues.Value;

                            if (group.Responsable != null)
                            {
                                ddlResponsable.SelectedValue = group.ResponsableId.ToString();
                            }
                        }

                        //loadRequestCities(city.Id, periodOpen.Id);
                    }
                }
            }
        }
        private void verifyWarnings()
        {
            using (Lib.Repositories.PeriodRepository rep = new Lib.Repositories.PeriodRepository(this.ActiveUser))
            {
                var periodOpen = rep.getPeriodOpen();
                DateTime lastDate = DateTime.MinValue;

                var allPeriods = rep.getAll();
                if (allPeriods.Count > 0)
                {
                    lastDate = allPeriods.Max(p => p.FinalDate);
                }

                if (periodOpen != null)
                {
                    phMessageWarning.Visible = true;
                    ltMessageWarning.Text = String.Format(Resources.Message.exists_an_open_period_from_to, periodOpen.InitialDate, periodOpen.FinalDate);
                }

                if (lastDate != DateTime.MinValue)
                {
                    phMessageWarning2.Visible = true;
                    ltMessageWarning2.Text = String.Format(Resources.Message.need_create_period_from, lastDate);
                }
            }
        }