Ejemplo n.º 1
0
        private void btnGetParam_Click(object sender, EventArgs e)
        {
            infoBox.Text = "";
            ApplicationParam lastAccess = applicationParamDAO.GetParam("lastAccess", "copyLogImport");

            infoBox.Text = infoBox.Text + lastAccess.name + "    " + lastAccess.value + Environment.NewLine;
            infoBox.Select(0, 1);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Recupera a data de último acesso do banco ( tarefa = printLogImport )
        /// </summary>
        public DateTime GetLastAccess()
        {
            ApplicationParamDAO applicationParamDAO = new ApplicationParamDAO(sqlConnection);
            ApplicationParam    lastAccessParam     = applicationParamDAO.GetParam("lastAccess", "printLogImport");

            return(DateTime.Parse(lastAccessParam.value));
        }
        protected void Page_Load(Object sender, EventArgs e)
        {
            if (!Authentication.IsAuthenticated(Session))
            {
                Response.Redirect("LoginPage.aspx");
            }

            Tenant tenant = (Tenant)Session["tenant"];

            if (tenant == null)
            {
                EmbedClientScript.ShowErrorMessage(this, "Sessão inválida.", true);
                return;
            }

            int     licenseId;
            Boolean isNumeric = int.TryParse(Request.QueryString["licenseId"], out licenseId);

            if (!isNumeric)
            {
                EmbedClientScript.ShowErrorMessage(this, "Os parâmetros passados para a página não estão em um formato válido.", true);
                return;
            }

            // Abre a conexão com o banco
            DataAccess dataAccess = DataAccess.Instance;

            dataAccess.MountConnection(FileResource.MapWebResource(this.Page.Server, "DataAccess.xml"), DatabaseEnum.PrintAccounting);
            dataAccess.OpenConnection();

            ApplicationParamDAO appParamDAO = new ApplicationParamDAO(dataAccess.GetConnection());
            ApplicationParam    urlParam    = appParamDAO.GetParam("url", "webAccounting");

            // Fecha a conexão com o banco
            dataAccess.CloseConnection();
            dataAccess = null;

            if (urlParam == null)
            {
                EmbedClientScript.ShowErrorMessage(this, "Falha ao buscar url do sistema no banco.", true);
                return;
            }

            String serviceUrl = urlParam.value + "/JobRoutingService.aspx";

            DateTime oneYearFromNow = DateTime.Now.AddYears(1);
            DateTime expirationDate = new DateTime(oneYearFromNow.Year, oneYearFromNow.Month, oneYearFromNow.Day, 0, 0, 0);


            this.Response.Clear();
            this.Response.ContentType = "application/octet-stream";
            this.Response.AddHeader("content-disposition", "attachment; filename=ProductKey.bin");

            String licenseKey = LicenseKeyMaker.GenerateKey(serviceUrl, tenant.id, licenseId, expirationDate);

            Response.Write(licenseKey);

            this.Response.End();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Armazena a data de último acesso no banco ( tarefa = printLogImport )
        /// </summary>
        public void SetLastAccess(DateTime date)
        {
            ApplicationParamDAO applicationParamDAO = new ApplicationParamDAO(sqlConnection);
            ApplicationParam    lastAccessParam     = applicationParamDAO.GetParam("lastAccess", "printLogImport");

            lastAccessParam.value = date.ToShortDateString();
            applicationParamDAO.SetParam(lastAccessParam);
        }