void CreaPaginaParametri() { DataAccess Conn = GetVars.GetUserConn(this); DataTable Params; GetParamfromDB(); //Leggo i parametri del report dal DB e imposta var. di sessione Params = (DataTable)Session["ParamData"]; if (Params == null) { return; } DataTable UserPar = (DataTable)Session["UserPar"]; if (UserPar == null) { return; } DataRow Par = UserPar.Rows[0]; TxtBoxArr = new WebControl[15]; //Disegno la tabella dei parametri Table1.Width = 800; Table1.BorderStyle = BorderStyle.Solid; //Table1.BackColor = Color.LightSteelBlue; int CountParam = 0; foreach (DataRow MyRowParam in Params.Rows) { if (MyRowParam["selectioncode"].ToString() == "costant.hidden") { continue; } CountParam++; //Incrementa il contatore di parametri che mi server per generare gli ID dei controlli //Aggiunge una riga alla tabella TableRow tRow = new TableRow(); Table1.Rows.Add(tRow); //Aggiunge una cella TableCell tCell1 = new TableCell(); tRow.Cells.Add(tCell1); tCell1.Width = 200; tCell1.Font.Bold = true; //tCell1.BackColor = Color.LightSteelBlue; tCell1.Font.Size = FontUnit.Small; tCell1.Text = MyRowParam["description"].ToString(); //Descrizione del parametro //Nome parametro string ParamName = MyRowParam["paramname"].ToString(); string FlagCombo = MyRowParam["iscombobox"].ToString(); bool FlagNoSelection = MyRowParam["noselectionforall"].ToString().ToUpper() == "S"; if (IsParamLocked(MyRowParam)) { TableCell tCell2 = new TableCell(); tRow.Cells.Add(tCell2); //Crea una TextBox TextBox myTextBox = new TextBox(); //Memorizza la TextBox nell'array di TextBox //TxtBoxArr[countTxt] = myTextBox; myTextBox.Width = 220; tCell2.Controls.Add(myTextBox); MyRowParam["__WebControlID"] = myTextBox.UniqueID; MyRowParam.AcceptChanges(); ///////////////////////////////////////////////////////////////////////////////// ///Attenzione: Inserire in questa sezione i controlli per il blocco dei parametri //Controllo per Responsabile if (MyRowParam["datasource"].ToString().ToLower() == "manager") { myTextBox.ReadOnly = true; myTextBox.BackColor = System.Drawing.Color.LightGray; myTextBox.Text = Session["Responsabile"].ToString(); if (MyRowParam["valuemember"].ToString() == "idman") { Par[ParamName] = Session["codiceresponsabile"]; } else { Par[ParamName] = Session["Responsabile"]; } continue; } if (MyRowParam["datasource"].ToString().ToLower() == "registryreference") { myTextBox.ReadOnly = true; myTextBox.BackColor = System.Drawing.Color.LightGray; myTextBox.Text = Session["Fornitore"].ToString(); myTextBox.Width = 300; if (MyRowParam["valuemember"].ToString() == "idreg") { Par[ParamName] = Session["codicefornitore"]; } else { Par[ParamName] = Session["Fornitore"]; } continue; } } if (FlagCombo.ToUpper() == "S") { //////////////////Aggiunge una DropDownList TableCell tCell2 = new TableCell(); tRow.Cells.Add(tCell2); //Crea una dropDownList DropDownList myDropList = new DropDownList(); tCell2.Controls.Add(myDropList); DataTable myDtCombo; MyRowParam["__WebControlID"] = myDropList.UniqueID; MyRowParam.AcceptChanges(); //Esegue la select per leggere i valori da visualizzare nella dropDownList myDtCombo = GetDataTableXcombo(MyRowParam); foreach (DataRow drCombo in myDtCombo.Rows) { string myValue = drCombo[MyRowParam["displaymember"].ToString()].ToString(); if (myValue.Trim() == "") { continue; } myDropList.Items.Add(myValue); } if (FlagNoSelection) { myDropList.Items.Add("%"); myDropList.SelectedValue = "%"; } if ((ParamName.ToLower().IndexOf("livello") >= 0 || ParamName.ToLower().IndexOf("level") >= 0) && (MyRowParam["hintkind"].ToString().ToUpper() == "NOHINT") ) { if (myDropList.Items.Count > 0) { myDropList.SelectedIndex = 1; } } if (MyRowParam["hintkind"].ToString().ToUpper() != "NOHINT") { try { object def = DefaultForParameter(MyRowParam); DataRow[] Val = myDtCombo.Select(MyRowParam["valuemember"].ToString() + "=" + QueryCreator.quotedstrvalue(def, false)); if ((Val != null) && (Val.Length > 0)) { myDropList.SelectedValue = Val[0][MyRowParam["displaymember"].ToString()].ToString(); } //int NNN = 0; //foreach (DataRow drCombo2 in myDtCombo.Rows) { // string myValue = drCombo2[0].ToString(); // if (myValue.Trim() == "") // continue; // if (myValue == def.ToString()) { // myDropList.SelectedIndex = NNN; // break; // } // NNN++; //} } catch (Exception E) { QueryCreator.MarkEvent(QueryCreator.GetErrorString(E)); }; } else { myDropList.SelectedIndex = myDropList.Items.Count - 1; } } else { //////////////////Aggiunge una TextBox TableCell tCell2 = new TableCell(); tRow.Cells.Add(tCell2); //Crea una TextBox TextBox myTextBox = new TextBox(); //Memorizza la TextBox nell'array di TextBox //TxtBoxArr[countTxt] = myTextBox; myTextBox.Width = 220; tCell2.Controls.Add(myTextBox); MyRowParam["__WebControlID"] = myTextBox.UniqueID; MyRowParam.AcceptChanges(); string tag = "x.y" + MyRowParam["tag"].ToString(); //Inserisce il valore di default del parametro myTextBox.Text = HelpForm.StringValue( DefaultForParameter(MyRowParam), tag); // myTextBox.ID = "IdParam" + CountParam; //Assegna un nome ID alla TextBox; /////////////////////////////////////////////////////////////////////////////////// //////////////////Aggiunge la cella di Help TableCell tCell3 = new TableCell(); tCell3.Width = 400; tCell3.Font.Size = FontUnit.XSmall; //tCell3.BackColor = Color.LightSteelBlue; tRow.Cells.Add(tCell3); tCell3.Text = MyRowParam["help"].ToString(); } } }
void DoLDAP(string S1) { this.Response.Clear(); //this.Response.Output.Write(S); Hashtable HH = DataAccess.GetHashFromString(S1); string E = "Errore"; QueryHelper QHS = Conn.GetQueryHelper(); try { //Elabora la Hashtable per la mail string user = HH["usr"] as string; string pwd = HH["pwd"] as string; string dep = HH["dep"] as string; ldapauth LA = new ldapauth(Conn); if (!LA.getconfig()) { this.Response.Output.Write("Errore LA.getconfig: " + LA.ErrorMsg); return; } if (!LA.Authenticate(user, pwd)) { this.Response.Output.Write("Errore LA.Authenticate: " + LA.ErrorMsg + "(servername=" + LA.servername + "port=" + LA.port.ToString() + "user="******",pwd=" + pwd + ")"); return; } user = LA.user_decoded; string filter = QHS.AppAnd(QHS.CmpEq("username", user), QHS.CmpEq("codicedipartimento", dep), QHS.CmpEq("userkind", 4) ); // 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) { this.Response.Output.Write("Errore: virtualuser not found (" + filter + ")"); Conn.Destroy(); return; } DataRow VU = virtualuser.Rows[0]; string filterdip = QHS.CmpEq("codicedipartimento", dep); DataTable CodDip = Conn.RUN_SELECT("codicidipartimenti", "*", null, filterdip, null, true); if ((CodDip == null) || (CodDip.Rows.Count != 1)) { Conn.Destroy(); return; } Hashtable Hresp = new Hashtable(); Hresp["usr"] = GetVars.DecryptPassword(GetVars.ConvBytes(CodDip.Rows[0]["UserDB"])); Hresp["pwd"] = GetVars.DecryptPassword(GetVars.ConvBytes(CodDip.Rows[0]["PassDB"])); Hresp["vusr"] = VU["sys_user"].ToString(); E = DataAccess.GetStringFromHashTable(Hresp); } catch (Exception EE) { E = "Errore:" + QueryCreator.GetErrorString(EE); } Conn.Destroy(); this.Response.Output.Write(E.ToString()); }