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(); }
void ScaricaPrenotazione(DataAccess Conn, string idbooking) { vistaform_storeunload_magazzino DS = new vistaform_storeunload_magazzino(); CQueryHelper QHC = new CQueryHelper(); QueryHelper QHS = Conn.GetQueryHelper(); //WebLog.Log(this, "Visualizza Login_Servizi"); object Obooking_on_invoice = Conn.DO_READ_VALUE("config", QHS.CmpEq("ayear", Conn.GetSys("esercizio")), "booking_on_invoice"); if (Obooking_on_invoice == null || Obooking_on_invoice == DBNull.Value || Obooking_on_invoice.ToString() == "") { Obooking_on_invoice = "N"; } Obooking_on_invoice = Obooking_on_invoice.ToString().ToUpper(); bool booking_on_invoice = (Obooking_on_invoice.ToString() == "S"); DataTable BookingToUnload = Conn.RUN_SELECT("booktotalview", "*", null, QHS.AppAnd(QHS.CmpGt("allocated", 0), QHS.CmpEq("idbooking", idbooking)), null, true); DataTable TStockView = Conn.CreateTableByName("stockview", "*"); TStockView.PrimaryKey = new DataColumn[] { TStockView.Columns["idstock"] }; Meta_EasyDispatcher Disp = new Meta_EasyDispatcher(Conn); MetaData MetaStoreUnload = Disp.Get("storeunload"); MetaStoreUnload.SetDefaults(DS.storeunload); MetaData MetaStoreUnloadDetail = Disp.Get("storeunloaddetail"); MetaStoreUnloadDetail.SetDefaults(DS.storeunloaddetail); DataRow[] Selected = BookingToUnload.Select(); if (Selected.Length == 0) { //niente da scaricare lblMessaggio.Text = "Non c'è nulla da scaricare"; txtCodice.Text = ""; return; } DataRow RStoreUnload = MetaStoreUnload.Get_New_Row(null, DS.storeunload); RStoreUnload["description"] = "Scarico prenotazione da magazzino"; RStoreUnload["idstore"] = Selected[0]["idstore"]; RStoreUnload["adate"] = DateTime.Now; Hashtable idlistToStock = new Hashtable();//l'elemento della hashtable è un list<int> //Prende una riga di prenotazione foreach (DataRow R in Selected) // riga di prenotazione { string filterbooking = QHS.CmpEq("idbooking", R["idbooking"]); string filterbookingdetail = QHS.AppAnd(filterbooking, QHS.CmpEq("idlist", R["idlist"])); DataTable B = Conn.RUN_SELECT("bookingdetail", "*", null, filterbookingdetail, null, false); DataTable Bmain = Conn.RUN_SELECT("booking", "*", null, filterbooking, null, false); DataRow BookingDetail = null; string filterstock = QHS.AppAnd(QHS.CmpEq("idstore", R["idstore"]), QHS.CmpEq("idlist", R["idlist"]), QHS.CmpGt("residual", 0)); string filterstockds = QHC.AppAnd(QHC.CmpEq("idstore", R["idstore"]), QHC.CmpEq("idlist", R["idlist"]), QHC.CmpGt("residual", 0)); //legge in TStockView i cespiti di stock disponibili ad essere scaricati if (booking_on_invoice) { filterstock = QHS.AppAnd(filterstock, QHS.CmpEq("idstock", R["idstock"])); filterstockds = QHC.AppAnd(filterstockds, QHC.CmpEq("idstock", R["idstock"])); } if (TStockView.Select(filterstockds).Length == 0) { Conn.RUN_SELECT_INTO_TABLE(TStockView, "expiry asc, idstock asc", filterstock, null, true); } ///SViewRows = cespiti disponibili (da stockview) allo scarico DataRow[] SViewRows = TStockView.Select(filterstockds); if (SViewRows.Length == 0) { continue; } DataRow RS; decimal tounload = CfgFn.GetNoNullDecimal(R["allocated"]); int i = 0; //Cerca di scaricare prendendo le righe in SViewRows while (i < SViewRows.Length && tounload > 0) { DataRow RStock = SViewRows[i]; decimal unloadable = CfgFn.GetNoNullDecimal(RStock["residual"]); if (unloadable > tounload) { unloadable = tounload; } //devo scaricare unloadable string fbooking = filterbooking; //devo scaricare unloadable fbooking = QHC.AppAnd(fbooking, QHC.CmpEq("idstock", RStock["idstock"])); //cerca una riga in storeunloaddetail di pari idstock e idbooking (idstock è sempre noto a questo punto) if (DS.storeunloaddetail.Select(fbooking).Length > 0) { RS = DS.storeunloaddetail.Select(fbooking)[0]; RS["number"] = CfgFn.GetNoNullDecimal(RS["number"]) + unloadable; } else { RS = MetaStoreUnloadDetail.Get_New_Row(DS.storeunload.Rows[0], DS.storeunloaddetail); RS["number"] = unloadable; RS["idbooking"] = R["idbooking"]; // Determino idstock // io ho una serie di di idlist e idstore // in base ai dettagli selezionati mi servono // per accedere alla vista delle giacenze di stock e creo // una tabella che deve essere filtrata per idlist // idstore e giacenza > 0 RS["idstock"] = RStock["idstock"];//T.Rows[0]["idstock"]; if (B.Rows.Count > 0) { BookingDetail = B.Rows[0]; RS["idsor1"] = BookingDetail["idsor1"]; RS["idsor2"] = BookingDetail["idsor2"]; RS["idsor3"] = BookingDetail["idsor3"]; RS["idman"] = Bmain.Rows[0]["idman"]; } } tounload -= unloadable; RStock["residual"] = CfgFn.GetNoNullDecimal(RStock["residual"]) - unloadable; i++; } } StoreUnloadSendMail SUSM = new StoreUnloadSendMail(Conn); SUSM.PrepareMailToSend(DS); Easy_PostData EP = new Easy_PostData(); EP.InitClass(DS, Conn); ProcedureMessageCollection PC = EP.DO_POST_SERVICE(); if (PC.Count > 0) { string err = ""; foreach (EasyProcedureMessage PM in PC) { err += PM.AuditID + "/" + PM.TableName + "/" + PM.Operation + "/" + PM.EnforcementNumber + "(" + PM.LongMess + ") "; } string data = ""; foreach (DataRow r in DS.storeunloaddetail.Rows) { data += "[idstock=" + r["idstock"].ToString() + ",number=" + r["number"].ToString() + ",idbooking=" + r["idbooking"].ToString() + ",idman=" + r["idman"].ToString() + "] "; } lblMessaggio.Text = "Errore in fase di salvataggio dati: " + err + " Data: " + data; GetVars.ClearUserConn(this); } else { EP.DO_POST_SERVICE(); DataRow Curr = DS.storeunload.Rows[0]; StampaReport(Conn, CfgFn.GetNoNullInt32(Curr["idstoreunload"])); SUSM.SendMail(); lblMessaggio.Text = "Scarico effettuato."; txtCodice.Text = ""; } }
protected void Page_Load(object sender, EventArgs e) { //Master.SetTitle("WebEasy - Accesso Servizi Dipartimento "); lblMessaggio.Text = ""; labExtMessage.Text = ""; error_dep = false; if (!Page.IsPostBack || Page.Session.IsNewSession) { Session["utente"] = ""; Session["Responsabile"] = ""; Session["Fornitore"] = ""; Session["CodiceResponsabile"] = null; Session["CodiceFornitore"] = null; } if (Request != null) { if (Request.Params["x"] != null && Request.Params["x"].ToString() != "") { Session["DepCode"] = Request.Params["x"]; } } if (Session["DepCode"] == null || Session["DepCode"].ToString() == "") { lblMessaggio.Text = "E' necessario chiamare la pagina magazzino_out.aspx con il parametro dep=codice dipartimento"; WebLog.Log(this, "Parametro dep non fornito."); error_dep = true; return; } //if (Session["DoLogon"] == null || !((bool)Session["DoLogon"])) { // lblMessaggio.Text = "Applicazione non inizializzata correttamente."; // WebLog.Log(this, "Applicazione non inizializzata correttamente."); // return; //} 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; } MetaMaster MM = Master as MetaMaster; //if (MM != null) MM.ShowClientMessage("NINO", false); string error; DataAccess Conn = GetVars.GetSystemDataAccess(this, out error); if (Conn == null) { //lblMessaggio.Text = "Connessione al DB di sistema non riuscita." + error; //Attenzione qui l'errore contiene la password del Database ! lblMessaggio.Text = "Connessione al DB di sistema non riuscita."; WebLog.Log(this, "Connessione al db di sistema non riuscita."); return; } lblMessaggio.Text = "Il servizio Web è attivo"; GetVars.ClearUserConn(this); }
protected void Page_Load(object sender, EventArgs e) { //Master.SetTitle("WebEasy - Accesso Servizi Dipartimento "); lblMessaggio.Text = ""; labExtMessage.Text = ""; if (!Page.IsPostBack || Page.Session.IsNewSession) { Session["utente"] = ""; Session["Responsabile"] = ""; Session["Fornitore"] = ""; Session["CodiceResponsabile"] = null; Session["CodiceFornitore"] = null; } if (Request != null) { if (Request.Params["x"] != null && Request.Params["x"].ToString() != "") { Session["DepCode"] = Request.Params["x"]; } } if (Session["DepCode"] == null || Session["DepCode"].ToString() == "") { lblMessaggio.Text = "E' necessario chiamare la pagina magazzino_in.aspx con il parametro dep=codice dipartimento"; WebLog.Log(this, "Parametro dep non fornito."); return; } //if (Session["DoLogon"] == null || !((bool)Session["DoLogon"])) { // lblMessaggio.Text = "Applicazione non inizializzata correttamente."; // WebLog.Log(this, "Applicazione non inizializzata correttamente."); // return; //} 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; } MetaMaster MM = Master as MetaMaster; //if (MM != null) MM.ShowClientMessage("NINO", false); string error; DataAccess Conn = GetVars.GetSystemDataAccess(this, out error); if (Conn == null) { //lblMessaggio.Text = "Connessione al DB di sistema non riuscita." + error; //Attenzione qui l'errore contiene la password del Database ! lblMessaggio.Text = "Connessione al DB di sistema non riuscita."; WebLog.Log(this, "Connessione al db di sistema non riuscita."); return; } lblMessaggio.Text = "Il servizio Web è attivo"; GetVars.ClearUserConn(this); MetaMaster master = Page.Master as MetaMaster; master?.setUniversita(Session["system_config_nome_universita"] as string); if (!Page.IsPostBack) { ldapauth ldpauth = new ldapauth(Conn); if (!ldpauth.getconfig()) { rbTipuUtente.Items.RemoveAt(3); } } //WebLog.Log(this, "Visualizza Login_Servizi"); DateTime D = DateTime.Now; if (IsPostBack) { if (txtNomeUtente.Text == "") { lblMessaggio.Text = "Il nome utente è un campo obbligatorio."; //MM.ShowClientMessage("Il nome utente è un campo obbligatorio.", "Errore", // System.Windows.Forms.MessageBoxButtons.OK); return; } if (txtPassword.Text == "") { lblMessaggio.Text = "La password è un campo obbligatorio."; //MM.ShowClientMessage("La password è un campo obbligatorio.", "Errore", // System.Windows.Forms.MessageBoxButtons.OK); return; } } if (IsPostBack && Request != null) { //Cerco prima nella tabella contatto e poi nella tabella responsabile. string NomeUtente = txtNomeUtente.Text; string Password = txtPassword.Text; // Request.Form["txtPassword"].ToString(); if (rbTipuUtente.SelectedValue == "1" || rbTipuUtente.SelectedValue == "2") { //Responsabile o Fornitore ConnectToDepartment(Session["DepCode"].ToString(), null, null, D); } if (rbTipuUtente.SelectedValue == "3") //Utente dell'applicazione { ConnectToDepartment(Session["DepCode"].ToString(), NomeUtente, txtPassword.Text, D); } bool ldapauthok = false; if (rbTipuUtente.SelectedValue == "4") // Utente LDAP { ldapauth lauth = new ldapauth(Conn); if (!lauth.getconfig()) { // Nessuna configurazione LDAP lblMessaggio.Text = lauth.ErrorMsg; return; } else { if (!lauth.Authenticate(NomeUtente, txtPassword.Text)) { // autenticazione fallita lblMessaggio.Text = lauth.ErrorMsg; return; } else { // autenticazione LDAP riuscita NomeUtente = lauth.user_decoded; ConnectToDepartment(Session["DepCode"].ToString(), null, null, D); ldapauthok = true; } } } //Connessione al Server.Database privato del software. Easy_DataAccess UsrConn = GetVars.GetUserConn(this); if (UsrConn == null) { return; //Messaggio già viualizzato da ConnectToDepartment() } QueryHelper QHS = UsrConn.GetQueryHelper(); string user = null; string forename = null; string lastname = null; string cf = null; string email = null; if (rbTipuUtente.SelectedValue == "3") { if (!CambioDataConsentita(UsrConn, D)) { UsrConn.Close(); labExtMessage.Text = "Accesso non consentito in tale data \rin base alla gestione della sicurezza."; // MM.ShowClientMessage("Accesso non consentito in tale data in base alla gestione della sicurezza.", "Errore", // System.Windows.Forms.MessageBoxButtons.OK); lblMessaggio.Text = "Accesso negato"; return; } } if (UsrConn.Open() == false) { //Il Server del Dipartimento non è in rete. //Il servizio non è disponibile in quanto il computer potrebbe essere spento. labExtMessage.Text = "Il Server del Dipartimento non risponde.\r" + "Potrebbe essere spento o momentaneamente fuori rete. \r" + "Provi in seguito"; txtNomeUtente.ReadOnly = true; WebLog.Log(this, "Il Server del dipartimento non risponde."); return; } UsrConn.Close(); Meta_EasyDispatcher Disp = new Meta_EasyDispatcher(UsrConn); ApplicationState APS = new ApplicationState(Disp, UsrConn); string path = this.MapPath("."); string filename = Path.Combine(path, "proxyserver.html"); if (File.Exists(filename)) { StreamReader SR = new StreamReader(filename); string webauth = SR.ReadToEnd(); webauth = webauth.Replace("\n", "").Replace("\r", "").Trim(); APS.webautorithy = webauth; SR.Close(); } APS.SaveApplicationState(this); labExtMessage.Text = "Connessione al server effettuata."; if (rbTipuUtente.SelectedValue == "1") { int countresp = UsrConn.RUN_SELECT_COUNT("manager", QHS.CmpEq("userweb", NomeUtente), false); if (countresp > 1) { lblMessaggioPass.Text = "Chiedere al Segreterio Amministrativo l'assegnazione di una nuova login"; WebLog.Log(this, "Attenzione !!! Login assegnata a piu responsabili"); return; } DataTable Responsabile = UsrConn.RUN_SELECT("manager", "*", null, QHS.AppAnd(QHS.CmpEq("userweb", NomeUtente), QHS.CmpEq("passwordweb", Password)), null, false); if (Responsabile.Rows.Count == 0) { //Dati non corretti labExtMessage.Text = "Nome utente o password non sono corretti."; WebLog.Log(this, "Nome Resp:" + NomeUtente + " e password:"******" non corretti"); return; } Session["LoginResponsabile"] = NomeUtente; Session["PasswordResponsabile"] = Password; Session["Responsabile"] = Responsabile.Rows[0]["title"].ToString(); Session["CodiceResponsabile"] = Responsabile.Rows[0]["idman"]; Session["TipoUtente"] = "responsabile"; WebLog.Log(this, "Riconosciuto responsabile: " + Session["Responsabile"].ToString()); } if (rbTipuUtente.SelectedValue == "2") { int countforn = UsrConn.RUN_SELECT_COUNT("registryreferenceview", QHS.CmpEq("userweb", NomeUtente), false); if (countforn > 1) { lblMessaggioPass.Text = "Chiedere al Segreterio Amministrativo l'assegnazione di una nuova login"; WebLog.Log(this, "Attenzione !!! Login assegnata a piu fornitori"); return; } DataTable Contatto = UsrConn.RUN_SELECT("registryreferenceview", "*", null, QHS.AppAnd(QHS.CmpEq("userweb", NomeUtente), QHS.CmpEq("passwordweb", Password)), null, false); if (Contatto.Rows.Count == 0) { //Dati non corretti labExtMessage.Text = "Nome utente o password non sono corretti."; WebLog.Log(this, "Nome Fornitore:" + NomeUtente + " e password:"******" non corretti"); return; } Session["LoginFornitore"] = NomeUtente; Session["Fornitore"] = Contatto.Rows[0]["registry"]; Session["CodiceFornitore"] = Contatto.Rows[0]["idreg"]; Session["PasswordFornitore"] = Password; Session["TipoUtente"] = "fornitore"; WebLog.Log(this, "Riconosciuto fornitore: " + Session["Fornitore"].ToString()); } if (rbTipuUtente.SelectedValue == "3") { Session["TipoUtente"] = "utente"; Session["Utente"] = NomeUtente; Session["PasswordUtente"] = Password; } if (ldapauthok || (rbTipuUtente.SelectedValue == "1") || (rbTipuUtente.SelectedValue == "2") || (rbTipuUtente.SelectedValue == "3")) { int userkind = Convert.ToInt32(rbTipuUtente.SelectedValue); string filter = QHS.AppAnd(QHS.CmpEq("username", NomeUtente), QHS.CmpEq("codicedipartimento", Session["DepCode"].ToString()), QHS.CmpEq("userkind", userkind) ); // prelevare l'idflowchart e poi fare la connecttodepartment DataTable virtualuser = Conn.RUN_SELECT("virtualuser", "*", null, filter, null, false); if (virtualuser != null && virtualuser.Rows.Count != 0) { user = virtualuser.Rows[0]["sys_user"].ToString(); forename = virtualuser.Rows[0]["forename"].ToString(); lastname = virtualuser.Rows[0]["surname"].ToString(); email = virtualuser.Rows[0]["email"].ToString(); cf = virtualuser.Rows[0]["cf"].ToString(); UsrConn.SetUsr("HasVirtualUser", "S"); // Controllare se è anche un responsabile // Vediamo se esiste un manager il cui login="******" // se si, assegnamo le due variabili di responsabile come // nel caso "2" filter = QHS.CmpEq("userweb", virtualuser.Rows[0]["username"].ToString()); DataTable manager = UsrConn.RUN_SELECT("manager", "*", null, filter, null, false); if (manager != null && manager.Rows.Count != 0) { Session["Responsabile"] = manager.Rows[0]["title"].ToString(); Session["CodiceResponsabile"] = manager.Rows[0]["idman"]; } EasySecurity sec = UsrConn.Security as EasySecurity; UsrConn.externalUser = NomeUtente; sec.SetSys("user", user); sec.SetUsr("usergrouplist", null); sec.CalculateGroupList(); sec.RecalcUserEnvironment(); sec.ReadAllGroupOperations(); sec.SetUsr("forename", forename); sec.SetUsr("surname", lastname); sec.SetUsr("email", email); sec.SetUsr("cf", cf); if (!CambioDataConsentita(UsrConn, D)) { labExtMessage.Text = "Accesso non consentito in tale data \rin base alla gestione della sicurezza."; lblMessaggio.Text = "Accesso negato"; return; } } else { if (ldapauthok) { lblMessaggio.Text = "Utente non valido."; return; } } } if (rbTipuUtente.SelectedValue == "4") { Session["TipoUtente"] = "Utente LDAP"; Session["Utente"] = forename + " " + lastname; Session["PasswordUtente"] = Password; } StampaReport(UsrConn, cf); //Response.Redirect("IndiceReport.aspx"); } }