1:
2: protected void btnConectar_Click(object sender, EventArgs e)
3: {
4: try
5: {
6: Thread th = new Thread(ConectSPO);
7: th.SetApartmentState(ApartmentState.STA);
8: th.Start();
9: th.Join();
10:
11: using (ctx)
12: {
13: if (ctx != null)
14: {
15: DataTable dtSoluciones =
16: new DataTable();
17: dtSoluciones.Columns.Add("ID");
18: dtSoluciones.Columns.Add("Path");
19: dtSoluciones.Columns.Add("Status");
20: DataRow dtrSolucion;
21:
22: //Acceso a la galería de soluciones
23: MO_NET.List solutionList = ctx.Site.GetCatalog(121);
24:
25: //Acceso al listado de soluciones
26: MO_NET.ListItemCollection licCollection =
27: solutionList.GetItems(MO_NET.CamlQuery.CreateAllItemsQuery());
28:
29: //Definición de operación
30: ctx.Load(licCollection);
31:
32: //Realización de operación
33: ctx.ExecuteQuery();
34:
35: //Procesado de resultados
36: foreach (MO_NET.ListItem li in licCollection)
37: {
38: dtrSolucion = dtSoluciones.NewRow();
39: MO_NET.FieldLookupValue fl =
40: (MO_NET.FieldLookupValue)li.FieldValues["Status"];
41: //Solución activada o no
42: if (fl != null)
43: {
44: dtrSolucion["ID"] = li["ID"];
45: dtrSolucion["Path"] = li["FileRef"];
46: dtrSolucion["Status"] = "Activada";
47: }
48: else
49: {
50: dtrSolucion["ID"] = li["ID"];
51: dtrSolucion["Path"] = li["FileRef"];
52: dtrSolucion["Status"] = "Desactivada";
53: }
54: dtSoluciones.Rows.Add(dtrSolucion);
55: }
56: this.grdSoluciones.DataSource =
57: dtSoluciones;
58: this.grdSoluciones.DataBind();
59:
60: }
61: }
62:
63: }
64: catch (Exception ex)
65: {
66: this.lblInformation.Text =
67: "Error: " + ex.Message;
68: }
69: }
70: }