Exemple #1
0
        //HtmlGenericControl StartVoceMenu(HtmlGenericControl parent, string testo,string classfun, string buttontag, EventHandler handler) {
        //    HtmlGenericControl LI = new HtmlGenericControl("li");
        //    LI.InnerText = testo;
        //    parent.Controls.Add(LI);
        //    LI.Attributes["onClick"] = "doMenuFunction(\"" + classfun + "\",\"" + buttontag + "\"); return true;";
        //    Page.ClientScript.GetCallbackEventReference(HwMenuButton.ID, buttontag, null, null, null, true);
        //    return LI;
        //}
        //LiteralControl StopVoceMenu(LiteralControl parent) {
        //}
        protected void Page_Load(object sender, System.EventArgs e)
        {
            /////////////////
            WebLog.Log(this, "Visualizza IndiceReport.aspx");
            ////////////////
            MyMenuClass.RegisterScript(this, HwMenuButton);

            MetaMasterBootstrap master = Page.Master as MetaMasterBootstrap;

            master?.setUniversita(Session["system_config_nome_universita"] as string);

            bool IsManager = (Session["CodiceResponsabile"] != null ? true : false);

            if (!IsManager)
            {
                PrenotaWait       = false;
                PrenotaMyTeam     = false;
                RicaricaCard      = false;
                GestisciCard      = false;
                IngressoMagazzino = false;
            }



            //btnRegistroRichiesteBuonoOrdine.Attributes.Add("onclick", "aprifin();");
            if (Session["Cart"] != null)
            {
                ApplicationState APS = ApplicationState.GetApplicationState(this);
                MetaData         M   = APS.Dispatcher.Get("booking");
                M.edit_type = "defaultnew02";
                APS.CallPage(this, M, false);
            }

            if (Session["UserPar"] != null)
            {
                if (Session["ModuleReportRow"] != null)
                {
                    // Report
                    string F = "window.open('WebPDFView.aspx');";

                    if (!Page.ClientScript.IsClientScriptBlockRegistered(typeof(Page), "openwin"))
                    {
                        Page.ClientScript.RegisterClientScriptBlock(
                            typeof(Page), "openwin", F, true);
                    }
                    //if (Session["PageToCameBack"] != null) {
                    //    string url = Session["PageToCameBack"].ToString();
                    //    Session["PageToCameBack"] = null;
                    //    Response.Redirect(url);
                    //    return;
                    //}
                }
                else
                {
                    // Export
                    string F = "window.open('ExportView.aspx');";
                    if (!Page.ClientScript.IsClientScriptBlockRegistered(typeof(Page), "openwin"))
                    {
                        Page.ClientScript.RegisterClientScriptBlock(
                            typeof(Page), "openwin", F, true);
                    }
                }
                //ApplicationState APS = ApplicationState.GetApplicationState(this);
                //MetaData M = APS.Dispatcher.Get("webpdf");
                //M.edit_type = "view";
                //APS.CallPage(this, M, false);
            }
            DataAccess UsrConn = GetVars.GetUserConn(this);

            if (((UsrConn == null) || (UsrConn.Open() == false)))
            {
                return;
            }
            string tipoutente = Session["TipoUtente"] as string;

            //if (tipoutente != "utente" && tipoutente != "Utente LDAP") {
            if (UsrConn.GetUsr("HasVirtualUser") == null && tipoutente != "utente")
            {
                Atto              = false;
                AttoBudget        = false;
                BuonoOrdine       = false;
                VarPrev           = false;
                ViterboVarPrev    = false;
                VarIniziale       = false;
                VarPrevBudget     = false;
                VarInizialeBudget = false;
                Vetrina           = false;
                Prenota           = false;
                IngressoMagazzino = false;
                PrenotaMyTeam     = false;
                PrenotaWait       = false;
                Missioni          = false;
                CataniaMissioni   = false;
                MissioniAuth      = false;
                MissioniMyTeam    = false;
                canChangeRole     = false;
                RicaricaCard      = false;
                GestisciCard      = false;
                Upb           = false;
                Finanziamento = false;
            }

            if (tipoutente == "Utente LDAP" || tipoutente == "Utente SSO")
            {
                CanChangePassword = false;
            }

            if (RicaricaCard && UsrConn.RUN_SELECT_COUNT("lcard", null, false) == 0)
            {
                RicaricaCard = false;
            }
            //if (GestisciCard && UsrConn.RUN_SELECT_COUNT("lcard", null, false) == 0) {
            //    GestisciCard = false;
            //}


            MyMenuClass myMenu = new MyMenuClass(null);

            CheckSecurityOnMenuButtons(myMenu);



            string filter = UsrConn.GetSys("filterrule") as string;

            filter = GetData.MergeFilters(filter, "(webvisible='S')");
            if (tipoutente == "responsabile")
            {
                filter = filter + "AND" +
                         "(reportname in (select reportname from reportparameter where datasource='manager'))";
            }
            if (tipoutente == "fornitore")
            {
                filter = filter + "AND" +
                         "(reportname in (select reportname from reportparameter where datasource='registryreference'))";
            }
            ModRepWeb = UsrConn.RUN_SELECT("report", "*", "modulename,groupname", filter, null, true);

            UsrConn.Security.DeleteAllUnselectable(ModRepWeb);
            QueryHelper  QHS         = UsrConn.GetQueryHelper();
            CQueryHelper QHC         = new CQueryHelper();
            object       idflowchart = UsrConn.GetSys("idflowchart");

            if (idflowchart != null && idflowchart != DBNull.Value)
            {
                //Applica filtro su stampe in base a flowchart
                DataTable MyMod = UsrConn.RUN_SELECT("flowchartmodulegroup", "*", null,
                                                     QHS.CmpEq("idflowchart", idflowchart), null, false);
                if (MyMod != null && MyMod.Columns.Count > 0)
                {
                    MyMod.CaseSensitive = false;
                    foreach (DataRow RM in ModRepWeb.Select())
                    {
                        if (RM["modulename"].ToString() == "" || RM["groupname"].ToString() == "")
                        {
                            continue;
                        }
                        string existfilter = QHC.AppAnd(QHC.CmpEq("modulename", RM["modulename"]),
                                                        QHC.CmpEq("groupname", RM["groupname"]));
                        if (MyMod.Select(existfilter).Length > 0)
                        {
                            continue;
                        }
                        RM.Delete();
                    }
                }
            }
            ModRepWeb.AcceptChanges();

            string lastmodule    = "";
            string lastgroupname = "";

            //Visualizza l'elenco dei report disponibili
            if (ModRepWeb != null && ModRepWeb.Rows.Count > 0)
            {
                MyMenuClass menuReport = new MyMenuClass("Report");
                myMenu.AddChild(menuReport);
                MyMenuClass menuModule = null;
                MyMenuClass menuGruppo = null;
                foreach (DataRow DrReport in ModRepWeb.Rows)
                {
                    if (DrReport["modulename"].ToString().ToLower() != lastmodule)
                    {
                        menuModule = new MyMenuClass(DrReport["modulename"].ToString());
                        menuReport.AddChild(menuModule);
                        lastmodule = DrReport["modulename"].ToString().ToLower();

                        menuGruppo = new MyMenuClass(DrReport["groupname"].ToString(), true);
                        menuModule.AddChild(menuGruppo);
                        lastgroupname = DrReport["groupname"].ToString().ToLower();
                    }

                    if (DrReport["groupname"].ToString().ToLower() != lastgroupname)
                    {
                        menuGruppo = new MyMenuClass(DrReport["groupname"].ToString(), true);
                        menuModule.AddChild(menuGruppo);
                        lastgroupname = DrReport["groupname"].ToString().ToLower();
                    }


                    MyMenuClass voce = new MyMenuClass(DrReport["Description"].ToString(), "r",
                                                       DrReport["ModuleName"].ToString() + "." + DrReport["ReportName"].ToString());
                    menuGruppo.AddChild(voce);
                }
            }

            string filterexpresp = "(webvisible='S') ";

            if (Session["CodiceResponsabile"] != null)
            {
                filterexpresp = filterexpresp + " AND" +
                                "(procedurename in (select procedurename from exportfunctionparam where datasource='manager'))";
            }
            if (Session["CodiceFornitore"] != null)
            {
                filterexpresp = filterexpresp + " AND" +
                                "(procedurename in (select procedurename from exportfunctionparam where datasource='registryreference'))";
            }
            ExportWeb = UsrConn.RUN_SELECT("exportfunction", "*", "modulename", filterexpresp, null, true);

            UsrConn.Security.DeleteAllUnselectable(ExportWeb);
            if (idflowchart != null && idflowchart != DBNull.Value)
            {
                //Applica filtro su stampe in base a flowchart
                DataTable MyMod = UsrConn.RUN_SELECT("flowchartexportmodule", "*", null,
                                                     QHS.CmpEq("idflowchart", idflowchart), null, false);
                if (MyMod != null && MyMod.Columns.Count > 0)
                {
                    MyMod.CaseSensitive = false;
                    foreach (DataRow RM in ExportWeb.Select())
                    {
                        if (RM["modulename"].ToString() == "")
                        {
                            continue;
                        }
                        string existfilter = QHC.CmpEq("modulename", RM["modulename"]);
                        if (MyMod.Select(existfilter).Length > 0)
                        {
                            continue;
                        }
                        RM.Delete();
                    }
                }
            }
            ExportWeb.AcceptChanges();

            lastmodule = "";

            //Visualizza l'elenco delle esportazioni disponibili
            if (ExportWeb != null && ExportWeb.Rows.Count > 0)
            {
                MyMenuClass menuExport = new MyMenuClass("Esportazioni");
                myMenu.AddChild(menuExport);
                MyMenuClass menuExpModule = null;
                //MyMenuClass menuExpGruppo;


                foreach (DataRow DrExport in ExportWeb.Rows)
                {
                    if (DrExport["modulename"].ToString().ToLower() != lastmodule)
                    {
                        menuExpModule = new MyMenuClass(DrExport["modulename"].ToString(), null, null);
                        menuExport.AddChild(menuExpModule);
                        lastmodule = DrExport["modulename"].ToString().ToLower();
                    }

                    MyMenuClass voce = new MyMenuClass(DrExport["Description"].ToString(), "e",
                                                       DrExport["procedurename"].ToString() + "." + DrExport["Description"].ToString());
                    menuExpModule.AddChild(voce);
                }
            }

            /*
             * MyMenuClass sys = new MyMenuClass("Sistema");
             * myMenu.AddChild(sys);
             * sys.AddChild(new MyMenuClass("Disconnetti", "s", "disconnect"));
             * if (canChangeRole) sys.AddChild(new MyMenuClass("Cambio Ruolo", "s", "changerole"));
             * if (CanChangePassword) sys.AddChild(new MyMenuClass("Cambio Password", "s", "changepwd"));
             */


            myMenu.AddChild(new MyMenuClass("Disconnetti", "s", "disconnect"));
            if (canChangeRole)
            {
                myMenu.AddChild(new MyMenuClass("Cambio Ruolo", "s", "changerole"));
            }
            if (CanChangePassword)
            {
                myMenu.AddChild(new MyMenuClass("Cambio Password", "s", "changepwd"));
            }


            myMenu.Optimize();

            MenuPanel.Controls.Add(myMenu.GetControl());
            UsrConn.Close();
            //WebLog.Log(this,"Visualizza Elenco Report disponibili (" + ModRepWeb.Rows.Count.ToString() + ")");
        }