示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            WebJsonResponse ret = null;


            try
            {
                LoginResult auth = LoginUser.AuthUser(this, Request["userLogin"], Request["password"]);

                if ((auth.Status) && (auth.ChangePassword) && (Session["login"] is LoginData))
                {
                    Session["entity_id"] = ((LoginData)Session["login"]).Id;
                    Session["login"]     = null;
                    ret = new WebJsonResponse("/login/changepassword/");
                }
                else if ((auth.Status) && (Session["login"] is LoginData))
                {
                    Int64 enterpriseId = 0;

                    LoginData login = (LoginData)Session["login"];

                    if ((Session["enterprise_data"]) != null && (Session["enterprise_data"] is EnterpriseData))
                    {
                        enterpriseId = ((EnterpriseData)Session["enterprise_data"]).Id;
                    }

                    ret = new WebJsonResponse(Session["ApplicationVirtualPath"] + "autoservice/");

                    using (IAMDatabase database = new IAMDatabase(IAMDatabase.GetWebConnectionString()))
                    {
                        try
                        {
                            using (IAMRBAC rbac = new IAMRBAC())
                                if (rbac.UserAdmin(database, login.Id, enterpriseId))
                                {
                                    ret = new WebJsonResponse(Session["ApplicationVirtualPath"] + "admin/");
                                }
                        }
                        catch { }
                    }
                }
                else
                {
                    ret = new WebJsonResponse("", auth.Text, 3000, true);
                }
            }
            catch (Exception ex)
            {
                Tools.Tool.notifyException(ex);
                throw ex;
            }


            if (ret != null)
            {
                ReturnHolder.Controls.Add(new LiteralControl(ret.ToJSON()));
            }
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            MAutoservice mClass = ((MAutoservice)this.Master);

            Tools.Tool.UpdateUri(this);

            LoginData login   = LoginUser.LogedUser(this.Page);
            Boolean   isAdmin = false;

            if (login != null)
            {
                IAMDatabase database = new IAMDatabase(IAMDatabase.GetWebConnectionString());
                try
                {
                    Int64 enterpriseId = 0;

                    if ((Session["enterprise_data"]) != null && (Session["enterprise_data"] is EnterpriseData))
                    {
                        enterpriseId = ((EnterpriseData)Session["enterprise_data"]).Id;
                    }


                    using (IAMRBAC rbac = new IAMRBAC())
                        isAdmin = rbac.HasAdminConsole(database, login.Id, enterpriseId);
                }
                catch { }
            }

            String html = "";

            html += "<ul class=\"home\">";

            if (isAdmin)
            {
                html += "    <li><a href=\"" + Session["ApplicationVirtualPath"] + "admin/\"><div class=\"btn c2\"><div class=\"inner\"><i class=\"icon-change\"></i><span>Admin</span></div></div></a></li>";
            }

            html += "    <li><a href=\"" + Session["ApplicationVirtualPath"] + "autoservice/user/\"><div class=\"btn c3\"><div class=\"inner\"><i class=\"icon-profile\"></i><span>Informações gerais</span></div></div></a></li>";
            html += "    <li><a href=\"" + Session["ApplicationVirtualPath"] + "autoservice/user/changepassword/\"><div class=\"btn c1\"><div class=\"inner\"><i class=\"icon-key\"></i><span>Alterar senha</span></div></div></a></li>";
            html += "    <li><a href=\"" + Session["ApplicationVirtualPath"] + "autoservice/access_request/\"><div class=\"btn c5\"><div class=\"inner\"><i class=\"icon-page\"></i><span>Requisição de acesso</span></div></div></a></li>";
            html += "    <li><a href=\"" + Session["ApplicationVirtualPath"] + "logout/\"><div class=\"btn c4\"><div class=\"inner\"><i class=\"icon-exit\"></i><span>Desconectar</span></div></div></a></li>";
            html += "</ul>";

            contentHolder.Controls.Add(new LiteralControl(html));
        }
示例#3
0
        /// <summary>
        /// Método privado para processamento do método 'user.resetpassword'
        /// </summary>
        /// <param name="sqlConnection">Conexão com o banco de dados MS-SQL</param>
        /// <param name="parameters">Dicionário (String, Object) contendo todos os parâmetros necessários</param>
        private List <Object> accessrequestlist(IAMDatabase database, Dictionary <String, Object> parameters)
        {
            List <Object> result = new List <Object>();

            DbParameterCollection par = new DbParameterCollection();

            par.Add("@enterprise_id", typeof(Int64)).Value = this._enterpriseId;

            Int32 page     = 1;
            Int32 pageSize = 10;

            if (parameters.ContainsKey("page"))
            {
                Int32.TryParse(parameters["page"].ToString(), out page);
            }

            if (parameters.ContainsKey("page_size"))
            {
                Int32.TryParse(parameters["page_size"].ToString(), out pageSize);
            }

            if (pageSize < 1)
            {
                pageSize = 1;
            }

            if (page < 1)
            {
                page = 1;
            }

            Int32 rStart = ((page - 1) * pageSize) + 1;
            Int32 rEnd   = rStart + (pageSize - 1);

            /*
             * select * from st_workflow_request r with(nolock)
             * inner join entity e  with(nolock) on e.id = r.entity_id
             * inner join context c  with(nolock) on c.id = e.context_id
             * */
            String sql = "";

            sql += "WITH result_set AS (";
            sql += "  SELECT ";
            sql += "    ROW_NUMBER() OVER (ORDER BY r.create_date) AS [row_number], r.*, e.context_id, c.enterprise_id, e.full_name, e.login";
            sql += "     from st_workflow_request r with(nolock)  ";
            sql += "     inner join entity e  with(nolock) on e.id = r.entity_id   ";
            sql += "     inner join context c  with(nolock) on c.id = e.context_id  ";
            sql += "     where (c.enterprise_id = @enterprise_id ";

            if ((parameters.ContainsKey("filter")) && (parameters["filter"] is Dictionary <String, Object>))
            {
                Dictionary <String, Object> filter = (Dictionary <String, Object>)parameters["filter"];
                foreach (String k in filter.Keys)
                {
                    switch (k.ToLower())
                    {
                    case "text":
                        if (!String.IsNullOrWhiteSpace(filter["text"].ToString()))
                        {
                            par.Add("@text", typeof(String)).Value = filter["text"].ToString();
                            sql += " and (e.full_name like '%'+@text+'%' or e.login like '%'+@text+'%' or r.description like '%'+@text+'%')";
                        }
                        break;

                    case "contextid":
                        if (!String.IsNullOrWhiteSpace(filter["contextid"].ToString()))
                        {
                            try
                            {
                                Int64 tmp = Int64.Parse(filter["contextid"].ToString());
                                par.Add("@context_id", typeof(Int64)).Value = tmp;
                                sql += " and c.id = @context_id";
                            }
                            catch { }
                        }
                        break;

                    case "workflowid":
                        if (!String.IsNullOrWhiteSpace(filter["workflowid"].ToString()))
                        {
                            try
                            {
                                Int64 tmp = Int64.Parse(filter["workflowid"].ToString());
                                par.Add("@workflow_id", typeof(Int64)).Value = tmp;
                                sql += " and r.workflow_id = @workflow_id";
                            }
                            catch { }
                        }
                        break;

                    case "status":
                        if (!String.IsNullOrWhiteSpace(filter["status"].ToString()))
                        {
                            try
                            {
                                WorkflowRequestStatus tmp = (WorkflowRequestStatus)Int32.Parse(filter["status"].ToString());
                                par.Add("@status", typeof(Int32)).Value = (Int32)tmp;
                                sql += " and r.status = @status";
                            }
                            catch { }
                        }
                        break;
                    }
                }
            }

            sql += "     )";
            sql += ") SELECT";
            sql += "  *";
            sql += " FROM";
            sql += "  result_set";
            sql += " WHERE";
            sql += "  [row_number] BETWEEN " + rStart + " AND " + rEnd;

            DataTable dtRequest = database.ExecuteDataTable(sql, CommandType.Text, par, null);

            if ((dtRequest != null) && (dtRequest.Rows.Count > 0))
            {
                foreach (DataRow dr1 in dtRequest.Rows)
                {
                    using (IAMRBAC rbac = new IAMRBAC())
                        if (!rbac.UserAdmin(database, Acl.EntityId, this._enterpriseId))
                        {
                            using (WorkflowRequest request = new WorkflowRequest((Int64)dr1["id"]))
                            {
                                WorkflowRequestProccess proc = request.GetInicialData(database);
                                if (!proc.Success)
                                {
                                    Error(ErrorType.InternalError, proc.Message, proc.Debug, null);
                                    return(null);
                                }

                                if (!database.ExecuteScalar <Boolean>("select case when COUNT(*) > 0 then CAST(1 as bit) else CAST(0 as bit) end from entity e with(nolock) where e.id = " + Acl.EntityId + " and (e.id in (" + request.Workflow.Owner + "," + request.Activity.ManualApproval.EntityApprover + ") or e.id in (select i.entity_id from identity_role ir with(nolock) inner join [identity] i with(nolock) on i.id = ir.identity_id where ir.role_id = " + request.Activity.ManualApproval.RoleApprover + "))", CommandType.Text, null))
                                {
                                    continue;
                                }
                            }
                        }

                    Dictionary <string, object> newItem = new Dictionary <string, object>();
                    newItem.Add("access_request_id", dr1["id"]);
                    newItem.Add("userid", dr1["entity_id"]);
                    newItem.Add("context_id", dr1["context_id"]);
                    newItem.Add("enterprise_id", dr1["enterprise_id"]);
                    newItem.Add("workflow_id", dr1["workflow_id"]);
                    newItem.Add("status", dr1["status"]);
                    newItem.Add("description", dr1["description"]);
                    newItem.Add("entity_full_name", dr1["full_name"]);
                    newItem.Add("entity_login", dr1["login"]);
                    newItem.Add("deployed", dr1["deployed"]);
                    newItem.Add("start_date", (dr1["start_date"] != DBNull.Value ? (Int32)((((DateTime)dr1["start_date"]) - new DateTime(1970, 1, 1)).TotalSeconds) : 0));
                    newItem.Add("end_date", (dr1["end_date"] != DBNull.Value ? (Int32)((((DateTime)dr1["end_date"]) - new DateTime(1970, 1, 1)).TotalSeconds) : 0));
                    newItem.Add("create_date", (dr1["create_date"] != DBNull.Value ? (Int32)((((DateTime)dr1["create_date"]) - new DateTime(1970, 1, 1)).TotalSeconds) : 0));

                    WorkflowConfig wk = new WorkflowConfig();
                    wk.GetDatabaseData(database, (Int64)dr1["workflow_id"]);

                    newItem.Add("workflow", wk.ToJsonObject());

                    result.Add(newItem);
                }
            }

            return(result);
        }
示例#4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!EnterpriseIdentify.Identify(this.Page)) //Se houver falha na identificação da empresa finaliza a resposta
            {
                return;
            }

            login = LoginUser.LogedUser(this.Page);

/*#if DEBUG
 *          if (login == null)
 *          {
 *              //Somente para debug na maquina de devel
 *              if (Request.Url.Host == "localhost")
 *              {
 *                  login = new LoginData();
 *                  login.EnterpriseId = 1;
 *                  login.FullName = "Helvio Junior";
 *                  login.Alias = "helvio";
 *                  login.Login = "******";
 *                  login.Id = 937;
 *                  Session["login"] = login;
 *              }
 *          }
 #endif*/

            if (login == null)
            {
                Session["last_page"] = Request.ServerVariables["PATH_INFO"];
                Response.Redirect("/login/");
            }

            if ((Session["enterprise_data"]) != null && (Session["enterprise_data"] is EnterpriseData))
            {
                enterpriseId = ((EnterpriseData)Session["enterprise_data"]).Id;
            }

            if (login != null)
            {
                userName = login.FullName;

                try
                {
                    using (IAMDatabase database = new IAMDatabase(IAMDatabase.GetWebConnectionString()))
                        using (IAMRBAC rbac = new IAMRBAC())
                            isAdmin = rbac.UserAdmin(database, login.Id, enterpriseId);
                }
                catch { }
            }

            //Identifica a página atual com objetivo de mostrar o ícone como selecionado no rodapé
            String scriptName             = Request.Params["SCRIPT_NAME"].ToLower();
            String ApplicationVirtualPath = Session["ApplicationVirtualPath"].ToString();

            if (ApplicationVirtualPath == "/")
            {
                ApplicationVirtualPath = "";
            }

            if (ApplicationVirtualPath != "")
            {
                scriptName = scriptName.Replace(ApplicationVirtualPath, "");
            }

            l1         = l2 = l3 = false;
            scriptName = scriptName.Trim("/ ".ToCharArray());
            switch (scriptName.ToLower())
            {
            case "autoservice":
                l1 = true;
                break;
            }
        }
示例#5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!EnterpriseIdentify.Identify(this.Page)) //Se houver falha na identificação da empresa finaliza a resposta
            {
                return;
            }

            login = LoginUser.LogedUser(this.Page);

            if (login == null)
            {
                Session["last_page"] = Request.ServerVariables["PATH_INFO"];
                Response.Redirect("/login/");
            }

            if ((Session["enterprise_data"]) != null && (Session["enterprise_data"] is EnterpriseData))
            {
                enterpriseId = ((EnterpriseData)Session["enterprise_data"]).Id;
            }

            if (login != null)
            {
                try
                {
                    using (IAMDatabase database = new IAMDatabase(IAMDatabase.GetWebConnectionString()))
                        using (IAMRBAC rbac = new IAMRBAC())
                            isAdmin = rbac.HasAdminConsole(database, login.Id, enterpriseId);
                }
                catch { }
            }


            if (!isAdmin)
            {
                Response.Redirect(System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath + "autoservice/");
            }

            //Identifica a página atual com objetivo de mostrar o ícone como selecionado no rodapé
            String scriptName             = Request.Params["SCRIPT_NAME"].ToLower();
            String ApplicationVirtualPath = Session["ApplicationVirtualPath"].ToString();

            if (ApplicationVirtualPath == "/")
            {
                ApplicationVirtualPath = "";
            }

            if (ApplicationVirtualPath != "")
            {
                scriptName = scriptName.Replace(ApplicationVirtualPath, "");
            }


            l1         = l2 = l3 = false;
            scriptName = scriptName.Trim("/ ".ToCharArray());
            switch (scriptName.ToLower())
            {
            case "admin":
                l1 = true;
                break;
            }
        }