/// <summary> /// Si collega al dipartimento "codice" con un determinato user e pwd. /// Se user e pwd sono nulle accede con un utente predefinito. /// </summary> /// <param name="codice">Codice dipartimento.</param> /// <param name="user">Nome utente.</param> /// <param name="pwd">Password.</param> /// <param name="datacontabile">Data contabile.</param> void ConnectToDepartment(string codice, string user, string pwd, DateTime datacontabile) { string error; DataAccess Conn = GetVars.GetSystemDataAccess(this, out error); MetaMasterBootstrap master = Page.Master as MetaMasterBootstrap; master?.setUniversita(Session["system_config_nome_universita"] as string); if (codice.Trim().Length == 0) { labExtMessage.Text = "Non è stato selezionato alcun dipartimento"; return; } //Attenzione: leggere da XML IP del server e NomeDB //Inserire da codice NomeUtente e Password string filterdip = "(codicedipartimento=" + QueryCreator.quotedstrvalue(codice, true) + ")"; DataTable CodDip = Conn.RUN_SELECT("codicidipartimenti", "*", null, filterdip, null, true); if ((CodDip == null) || (CodDip.Rows.Count == 0)) { //Dati non corretti WebLog.Log(this, codice + ": Codice non corretto"); labExtMessage.Text = "Il codice inserito non è corretto."; return; } if (CodDip.Rows.Count > 1) { //Attenzione nel DB non è garantita l'unicità dei dati. labExtMessage.Text = "Chiedere al Responsabile del servizio " + "l'assegnazione di un nuovo Codice"; WebLog.Log(this, "Attenzione!!! Duplicazione di codici per " + codice); return; } string err = ""; DataRow myDr = CodDip.Rows[0]; Session["Dipartimento"] = myDr["Dipartimento"].ToString(); //Creo la connessione. DataAccess UsrConn = GetVars.CreateUserConn(this, myDr, user, pwd, datacontabile, out err); if (UsrConn == null) { err = "Connessione per l'utente '" + user + "' rifiutata. <br/> Controllare Nome Utente e/o Password"; string err2 = "Connessione al db del dipartimento " + codice + " non riuscita. <br/>" + err; labExtMessage.Text = err2; WebLog.Log(this, err2); return; } }
protected void Page_Load(object sender, EventArgs e) { lblMessaggio.Text = ""; labExtMessage.Text = ""; // Imposta il nome dell'utente identificato dall'intentity provider. if (Session["samlemail"] == null) { lblMessaggio.Text = "Autenticazione fallita."; WebLog.Log(this, "Autenticazione fallita."); //Response.Redirect("DefaultSAML.aspx"); return; } txtNomeUtente.Text = Session["samlemail"].ToString(); if (!Page.IsPostBack) { Session["utente"] = ""; Session["Responsabile"] = ""; Session["Fornitore"] = ""; Session["CodiceResponsabile"] = null; Session["CodiceFornitore"] = null; Session["TipoUtente"] = null; txtDataContabile.Text = HelpForm.StringValue(DateTime.Now, "x.y"); } DataSet Cfg = GetVars.GetConfigDataSet(this); if (Cfg.Tables[0].Rows.Count == 0) { lblMessaggio.Text = "Servizio non installato correttamente. Manca il file di configurazione."; WebLog.Log(this, "Connessione al db di sistema non riuscita."); return; } string error; Conn = GetVars.GetSystemDataAccess(this, out error); if (Conn == null) { lblMessaggio.Text = "Connessione al DB di sistema non riuscita."; WebLog.Log(this, "Connessione al db di sistema non riuscita."); return; } else { lblMessaggio.Text = "Il servizio Web è attivo."; } MetaMasterBootstrap master = Page.Master as MetaMasterBootstrap; master?.setUniversita(Session["system_config_nome_universita"] as string); GetVars.ClearUserConn(this); if (Request != null) { string dep = Request.Params["dep"]; if (!string.IsNullOrEmpty(dep)) { Label3.Visible = false; cmbDipartimento.Visible = false; } } AggiornaElencoDipartimenti(); }
//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() + ")"); }