public static string GetDisplayValue(this SPClient.FieldUrlValue value) { if (value == null) { return(string.Empty); } return(value.Url); }
public SP.FieldUrlValue GetValue(object value) { SP.FieldUrlValue val = value as SP.FieldUrlValue; if (val == null || !(value is SP.FieldUrlValue)) { val = new SP.FieldUrlValue(); } return(val); }
public SP.FieldUrlValue SetValue(string url, string description, string displayFormat) { object value; if (url.Trim().ToLower() == "http://" || url.Trim().ToLower() == "https://") { value = null; } else { if (String.IsNullOrEmpty(description) && displayFormat == "Hyperlink") { description = url; } SP.FieldUrlValue v = new SP.FieldUrlValue(); v.Url = url; v.Description = description; value = v; } return(value as SP.FieldUrlValue); }
private string GetStringValueFromField(object spValue, string textValue, string SASType, string spFieldType) { if (spValue == null) { throw new ArgumentNullException("spValue"); } string rc = "\"\""; System.Type st = spValue.GetType(); string rawValue; switch (st.FullName) { case "System.String": if (removeHTML) { rawValue = textValue; } else { rawValue = (System.String)spValue; } break; case "System.String[]": { if (removeHTML) { rawValue = textValue; } else { String[] stvals = (String[])spValue; StringBuilder sb = new StringBuilder(); foreach (string str in stvals) { if (sb.Length > 0) { sb.Append(", "); } sb.Append(str); } rawValue = sb.ToString(); } } break; case "Microsoft.SharePoint.Client.FieldUserValue": rawValue = ((FieldUserValue)spValue).LookupValue; break; case "Microsoft.SharePoint.Client.FieldUserValue[]": { FieldUserValue[] suv = (FieldUserValue[])spValue; StringBuilder sb = new StringBuilder(); foreach (FieldUserValue fuv in suv) { if (sb.Length > 0) { sb.Append(", "); } sb.AppendFormat("{0}", fuv.LookupValue); } rawValue = sb.ToString(); } break; case "System.DateTime": if (SASType == SPColumn.SASChar) { rawValue = spValue.ToString(); } else { DateTime dtDotNet = TimeZoneInfo.ConvertTimeFromUtc((DateTime)spValue, TimeZoneInfo.Local); double dtSAS = spWrap.DotNetToSASDatetime(dtDotNet); rawValue = dtSAS.ToString(); } break; case "Microsoft.SharePoint.Client.FieldUrlValue": { Microsoft.SharePoint.Client.FieldUrlValue url = (Microsoft.SharePoint.Client.FieldUrlValue)spValue; rawValue = url.Url; } break; default: rawValue = spValue.ToString(); break; } if (!string.IsNullOrEmpty(rawValue)) { if (rawValue.Contains('"')) { rawValue = rawValue.Replace("\"", "\"\""); } if (rawValue.Contains(Environment.NewLine)) { rawValue = rawValue.Replace(Environment.NewLine, " "); } if (rawValue.Contains('\n')) { rawValue = rawValue.Replace("\n", " "); } rawValue = ConvertUnicodeToSASServerEncoding(rawValue); rc = string.Format("\"{0}\"", rawValue); } return(rc); }
private void BuscarV2() { String reg_act_tomo = txTomo.Text; String reg_act_semestre = txSemestre.Text; String reg_act_año = txAnio.Text; String reg_act_seccion = txSeccion.Text; String reg_act_serie = txSerie.Text; String reg_act_partida = txPartida.Text; String reg_act_libro = txLibro.Text; bool firstParameter = true; bool secondParameter = false; bool nextParameter = false; string query = ""; if (reg_act_tomo.Length > 0) { if (firstParameter) { query = query + "<Eq><FieldRef Name='Fec_Reg_Tomo' /><Value Type='Number'>{0}</Value></Eq>"; firstParameter = false; secondParameter = true; } else { if (secondParameter) { query = "<And>" + query + "<Eq><FieldRef Name='Fec_Reg_Tomo' /><Value Type='Number'>{0}</Value></Eq></And>"; secondParameter = false; nextParameter = true; } else { query = "<And>" + query + "<Eq><FieldRef Name='Fec_Reg_Tomo' /><Value Type='Number'>{0}</Value></Eq></And>"; } } } if (reg_act_semestre.Length > 0) { if (firstParameter) { query = query + "<Eq><FieldRef Name='Fec_Reg_Semestre' /><Value Type='Number'>{1}</Value></Eq>"; firstParameter = false; secondParameter = true; } else { if (secondParameter) { query = "<And>" + query + "<Eq><FieldRef Name='Fec_Reg_Semestre' /><Value Type='Number'>{1}</Value></Eq></And>"; secondParameter = false; nextParameter = true; } else { query = "<And>" + query + "<Eq><FieldRef Name='Fec_Reg_Semestre' /><Value Type='Number'>{1}</Value></Eq></And>"; } } } if (reg_act_año.Length > 0) { if (firstParameter) { query = query + "<Eq><FieldRef Name='Fec_Reg_A_x00f1_o_x0020_Semestre' /><Value Type='Number'>{2}</Value></Eq>"; firstParameter = false; secondParameter = true; } else { if (secondParameter) { query = "<And>" + query + "<Eq><FieldRef Name='Fec_Reg_A_x00f1_o_x0020_Semestre' /><Value Type='Number'>{2}</Value></Eq></And>"; secondParameter = false; nextParameter = true; } else { query = "<And>" + query + "<Eq><FieldRef Name='Fec_Reg_A_x00f1_o_x0020_Semestre' /><Value Type='Number'>{2}</Value></Eq></And>"; } } } if (reg_act_seccion.Length > 0) { if (firstParameter) { query = query + "<Eq><FieldRef Name='Fec_Reg_Seccion' /><Value Type='Number'>{3}</Value></Eq>"; firstParameter = false; secondParameter = true; } else { if (secondParameter) { query = "<And>" + query + "<Eq><FieldRef Name='Fec_Reg_Seccion' /><Value Type='Number'>{3}</Value></Eq></And>"; secondParameter = false; nextParameter = true; } else { query = "<And>" + query + "<Eq><FieldRef Name='Fec_Reg_Seccion' /><Value Type='Number'>{3}</Value></Eq></And>"; } } } if (reg_act_serie.Length > 0) { if (firstParameter) { query = query + "<Eq><FieldRef Name='Fec_Reg_Partida' /><Value Type='Text'>{4}</Value></Eq>"; firstParameter = false; secondParameter = true; } else { if (secondParameter) { query = "<And>" + query + "<Eq><FieldRef Name='Fec_Reg_Partida' /><Value Type='Text'>{4}</Value></Eq></And>"; secondParameter = false; nextParameter = true; } else { query = "<And>" + query + "<Eq><FieldRef Name='Fec_Reg_Partida' /><Value Type='Text'>{4}</Value></Eq></And>"; } } } if (reg_act_partida.Length > 0) { if (firstParameter) { query = query + "<Eq><FieldRef Name='Partida' /><Value Type='Number'>{5}</Value></Eq>"; firstParameter = false; secondParameter = true; } else { if (secondParameter) { query = "<And>" + query + "<Eq><FieldRef Name='Partida' /><Value Type='Number'>{5}</Value></Eq></And>"; secondParameter = false; nextParameter = true; } else { query = "<And>" + query + "<Eq><FieldRef Name='Partida' /><Value Type='Number'>{5}</Value></Eq></And>"; } } } if (reg_act_libro.Length > 0) { if (firstParameter) { query = query + "<Eq><FieldRef Name='Fec_Reg_Libro' /><Value Type='Number'>{6}</Value></Eq>"; firstParameter = false; secondParameter = true; } else { if (secondParameter) { query = "<And>" + query + "<Eq><FieldRef Name='Fec_Reg_Libro' /><Value Type='Number'>{6}</Value></Eq></And>"; secondParameter = false; nextParameter = true; } else { query = "<And>" + query + "<Eq><FieldRef Name='Fec_Reg_Libro' /><Value Type='Number'>{6}</Value></Eq></And>"; } } } query = "<View><Query><Where>" + query + "</Where></Query></View>"; query = string.Format(@query, reg_act_tomo, reg_act_semestre, reg_act_año, reg_act_seccion, reg_act_serie, reg_act_partida, reg_act_libro); try { using (ClientContext ctx = new ClientContext("http://servidors04/sitios/digitalizacion")) { Web web = ctx.Web; List list = web.Lists.GetById(new Guid("9c3f7319-7740-426f-87a4-bf9b8c0eb6b8")); var q = new CamlQuery() { ViewXml = query }; Microsoft.SharePoint.Client.ListItemCollection arlRows = list.GetItems(q); ctx.Load(arlRows); ctx.ExecuteQuery(); lblResultado.Text = "Se han obtenido " + arlRows.Count + " resultados de la búsqueda."; foreach (var item in arlRows) { List <Prelacion> resultados = new List <Prelacion>(); Prelacion r = new Prelacion(); for (int i = 0; i <= arlRows.Count - 1; i++) { Microsoft.SharePoint.Client.ListItem itemRepositorio = (Microsoft.SharePoint.Client.ListItem)arlRows[i]; Dictionary <string, object> dc = (Dictionary <string, object>)itemRepositorio.FieldValues; Microsoft.SharePoint.Client.FieldUrlValue fURl = (Microsoft.SharePoint.Client.FieldUrlValue)dc["Pagina"]; r = new Prelacion(); r.RepositoryUrl = fURl.Url; r.Tramitante = dc["No_x002e__x0020_Notaria"].ToString(); r.IdPrelacion = int.Parse(dc["ID"].ToString()); r.Partida = dc["Partida"].ToString(); r.NumeroDocumento = dc["Numero_x0020_de_x0020_Documento"].ToString(); resultados.Add(r); //lblError.Text = lblError.Text + "\n" + fURl.Url.ToString(); } gvResultados.DataSource = resultados; gvResultados.DataBind(); } } } catch (Exception exc) { lblError.Text = exc.Message; } }
/* #region PERFIL DE USUARIO * protected void llenarDatosUsuario() * { * * Usuario usuarioLog = (Usuario)Session.Contents["usuario"]; * txNombre.Text = usuarioLog.Nombre; * txAPaterno.Text = usuarioLog.ApellidoPaterno; * txAMaterno.Text = usuarioLog.ApellidoMaterno; * txUsuario.Text = usuarioLog.Login; * txTipoUsuario.Text = usuarioLog.TipoUsuario; * txRFC.Text = usuarioLog.Rfc; * txCURP.Text = usuarioLog.Curp; * txCalle.Text = usuarioLog.Calle; * txColonia.Text = usuarioLog.Colonia; * txCodigoPostal.Text = usuarioLog.CodigoPostal; * txTelefono1.Text = usuarioLog.Telefono1; * txTelefono2.Text = usuarioLog.Telefono2; * txNacimiento.Text = DateTime.Parse(usuarioLog.FechaNacimiento).ToString("yyyy-MM-dd"); * txControl.Text = usuarioLog.NoControl; * //Llenar el dropdownlist de municipios para el formulario de Tramitantes * foreach (Municipio item in main.Municipios.Catalogo()) * { * ListItem l = new ListItem(); * l.Text = item.Nombre; * l.Value = item.Clave.ToString(); * ddlMunicipiosU.Items.Add(l); * } * ddlMunicipiosU.SelectedValue = usuarioLog.Municipio.ToString(); * //Llenar el dropdownlist de poblaciones para el formulario de Tramitantes * foreach (Poblacion item in main.Poblaciones.CatalogoPorMunicipio(usuarioLog.Municipio)) * { * ListItem l = new ListItem(); * l.Text = item.Nombre; * l.Value = item.ClavePoblacion.ToString(); * ddlPoblacionesU.Items.Add(l); * } * ddlPoblacionesU.SelectedValue = usuarioLog.Poblacion.ToString(); * * } * protected void btCambiarPass_Click(object sender, EventArgs e) * { * Usuario currentUser = (Usuario)Session.Contents["usuario"]; * if (txPass1.Text.Equals(txPass2.Text) && !txPass1.Text.Equals("") && !txPass2.Text.Equals("")) * { * String resultado = Usuario.CambiarPasswordUsuario(currentUser.IdUsuario, txPass2.Text); * if (resultado.Equals("OK")) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Contraseña cambiada correctamente.')", true); } * else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Error al cambiar la contraseña.')", true); } * } * else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Los campos de Contraseña deben Coincidir.')", true); } * } * * protected void btGuardarCambios_Click(object sender, EventArgs e) * { * if (!txNombre.Text.Equals("") && !txAPaterno.Text.Equals("") && !txAMaterno.Text.Equals("")) * { * Usuario currentUser = (Usuario)Session.Contents["usuario"]; * Usuario datosUsuario = new Usuario(); * datosUsuario.IdUsuario = currentUser.IdUsuario; * datosUsuario.IdTipoUsuario = currentUser.IdTipoUsuario; * datosUsuario.Login = txUsuario.Text; * datosUsuario.Nombre = txNombre.Text; * datosUsuario.ApellidoPaterno = txAPaterno.Text; * datosUsuario.ApellidoMaterno = txAMaterno.Text; * datosUsuario.Rfc = txRFC.Text; * datosUsuario.Curp = txCURP.Text; * datosUsuario.FechaNacimiento = txNacimiento.Text; * datosUsuario.Calle = txCalle.Text; * datosUsuario.Colonia = txColonia.Text; * datosUsuario.CodigoPostal = txCodigoPostal.Text; * datosUsuario.Telefono1 = txTelefono1.Text; * datosUsuario.Telefono2 = txTelefono2.Text; * datosUsuario.NoControl = txControl.Text; * datosUsuario.Municipio = int.Parse(ddlMunicipiosU.SelectedValue.ToString()); * datosUsuario.Poblacion = int.Parse(ddlPoblacionesU.SelectedValue.ToString()); * * String resultado = Usuario.CambiarDatosUsuario(datosUsuario); * if (resultado.Equals("OK")) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Datos Actualizados Correctamente.')", true); } * else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Error al Actualizar los Datos de Usuario.')", true); } * } * else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Debes al menos completar los datos del Nombre.)", true); } * } * protected void ddlMunicipiosU_SelectedIndexChanged(object sender, EventArgs e) * { * ddlPoblacionesU.Items.Clear(); * foreach (Poblacion item in main.Poblaciones.CatalogoPorMunicipio(int.Parse(ddlMunicipiosU.SelectedValue.ToString()))) * { * ListItem l = new ListItem(); * l.Text = item.Nombre; * l.Value = item.ClavePoblacion.ToString(); * ddlPoblacionesU.Items.Add(l); * } * } #endregion */ private void Buscar() { try { RPPMain.SharepointLibrary spLibrary = new RPPMain.SharepointLibrary("http://servidors04/sitios/digitalizacion", "Seccion Primera", "autostore", "Rpp1234"); //spLibrary.Prueba(); lblError.Text = ""; //int documentoID = int.Parse(Page.Request.QueryString["documentoID"]); String reg_act_tomo = txTomo.Text; String reg_act_semestre = txSemestre.Text; String reg_act_año = txAnio.Text; String reg_act_seccion = txSeccion.Text; String reg_act_serie = txSerie.Text; String reg_act_partida = txPartida.Text; String reg_act_libro = txLibro.Text; bool firstParameter = true; bool secondParameter = false; bool nextParameter = false; string query = ""; if (reg_act_tomo.Length > 0) { if (firstParameter) { query = query + "<And><Eq><FieldRef Name='Fec_Reg_Tomo' /><Value Type='Text'>{0}</Value></Eq>"; firstParameter = false; secondParameter = true; } else { if (secondParameter) { query = query + "<Eq><FieldRef Name='Fec_Reg_Tomo' /><Value Type='Text'>{0}</Value></Eq></And>"; secondParameter = false; nextParameter = true; } else { query = "<And>" + query + "<Eq><FieldRef Name='Fec_Reg_Tomo' /><Value Type='Text'>{0}</Value></Eq></And>"; } } } if (reg_act_semestre.Length > 0) { if (firstParameter) { query = query + "<And><Eq><FieldRef Name='Fec_Reg_Semestre' /><Value Type='Text'>{1}</Value></Eq>"; firstParameter = false; secondParameter = true; } else { if (secondParameter) { query = query + "<Eq><FieldRef Name='Fec_Reg_Semestre' /><Value Type='Text'>{1}</Value></Eq></And>"; secondParameter = false; nextParameter = true; } else { query = "<And>" + query + "<Eq><FieldRef Name='Fec_Reg_Semestre' /><Value Type='Text'>{1}</Value></Eq></And>"; } } } if (reg_act_año.Length > 0) { if (firstParameter) { query = query + "<And><Eq><FieldRef Name='Fec_Reg_A_x00f1_o_x0020_Semestre' /><Value Type='Text'>{2}</Value></Eq>"; firstParameter = false; secondParameter = true; } else { if (secondParameter) { query = query + "<Eq><FieldRef Name='Fec_Reg_A_x00f1_o_x0020_Semestre' /><Value Type='Text'>{2}</Value></Eq></And>"; secondParameter = false; nextParameter = true; } else { query = "<And>" + query + "<Eq><FieldRef Name='Fec_Reg_A_x00f1_o_x0020_Semestre' /><Value Type='Text'>{2}</Value></Eq></And>"; } } } if (reg_act_seccion.Length > 0) { if (firstParameter) { query = query + "<And><Eq><FieldRef Name='Fec_Reg_Seccion' /><Value Type='Text'>{3}</Value></Eq>"; firstParameter = false; secondParameter = true; } else { if (secondParameter) { query = query + "<Eq><FieldRef Name='Fec_Reg_Seccion' /><Value Type='Text'>{3}</Value></Eq></And>"; secondParameter = false; nextParameter = true; } else { query = "<And>" + query + "<Eq><FieldRef Name='Fec_Reg_Seccion' /><Value Type='Text'>{3}</Value></Eq></And>"; } } } if (reg_act_serie.Length > 0) { if (firstParameter) { query = query + "<And><Eq><FieldRef Name='Fec_Reg_Partida' /><Value Type='Text'>{4}</Value></Eq>"; firstParameter = false; secondParameter = true; } else { if (secondParameter) { query = query + "<Eq><FieldRef Name='Fec_Reg_Partida' /><Value Type='Text'>{4}</Value></Eq></And>"; secondParameter = false; nextParameter = true; } else { query = "<And>" + query + "<Eq><FieldRef Name='Fec_Reg_Partida' /><Value Type='Text'>{4}</Value></Eq></And>"; } } } if (reg_act_partida.Length > 0) { if (firstParameter) { query = query + "<And><Eq><FieldRef Name='Partida' /><Value Type='Text'>{5}</Value></Eq>"; firstParameter = false; secondParameter = true; } else { if (secondParameter) { query = query + "<Eq><FieldRef Name='Partida' /><Value Type='Text'>{5}</Value></Eq></And>"; secondParameter = false; nextParameter = true; } else { query = "<And>" + query + "<Eq><FieldRef Name='Partida' /><Value Type='Text'>{5}</Value></Eq></And>"; } } } if (reg_act_libro.Length > 0) { if (firstParameter) { query = query + "<And><Eq><FieldRef Name='Fec_Reg_Libro' /><Value Type='Text'>{6}</Value></Eq>"; firstParameter = false; secondParameter = true; } else { if (secondParameter) { query = query + "<Eq><FieldRef Name='Fec_Reg_Libro' /><Value Type='Text'>{6}</Value></Eq></And>"; secondParameter = false; nextParameter = true; } else { query = "<And>" + query + "<Eq><FieldRef Name='Fec_Reg_Libro' /><Value Type='Text'>{6}</Value></Eq></And>"; } } } query = "<View><Query><Where>" + query + "</Where></Query></View>"; query = "<Query><Where><Eq><FieldRef Name='Numero_x0020_de_x0020_Documento' /><Value Type='Text'>154456</Value></Eq></Where></Query>"; /* * query = string.Format(@"<View> * <Query> * <Where> * <And> * <And> * <And> * <And> * <And> * <And> * <Eq><FieldRef Name='Fec_Reg_Tomo' /><Value Type='Text'>{0}</Value></Eq> * <Eq><FieldRef Name='Fec_Reg_Semestre' /><Value Type='Text'>{1}</Value></Eq> * </And> * <Eq><FieldRef Name='Fec_Reg_A_x00f1_o_x0020_Semestre' /><Value Type='Text'>{2}</Value></Eq> * </And> * <Eq><FieldRef Name='Fec_Reg_Seccion' /><Value Type='Text'>{3}</Value></Eq> * </And> * <Eq><FieldRef Name='Fec_Reg_Partida' /><Value Type='Text'>{4}</Value></Eq> * </And> * <Eq><FieldRef Name='Partida' /><Value Type='Text'>{5}</Value></Eq> * </And> * <Eq><FieldRef Name='Fec_Reg_Libro' /><Value Type='Text'>{6}</Value></Eq> * </And> * </Where> * </Query> * </View>", * reg_act_tomo, * reg_act_semestre, * reg_act_año, * reg_act_seccion, * reg_act_serie, * reg_act_partida, * reg_act_libro); */ /* * * query = string.Format(@query, * reg_act_tomo, * reg_act_semestre, * reg_act_año, * reg_act_seccion, * reg_act_serie, * reg_act_partida, * reg_act_libro);*/ System.Collections.ArrayList arlRows = spLibrary.GetLibraryItem(query); if (arlRows.Count > 0) { lblError.Text = arlRows.Count.ToString(); List <Prelacion> resultados = new List <Prelacion>(); Prelacion r = new Prelacion(); for (int i = 0; i <= arlRows.Count - 1; i++) { Microsoft.SharePoint.Client.ListItem itemRepositorio = (Microsoft.SharePoint.Client.ListItem)arlRows[i]; Dictionary <string, object> dc = (Dictionary <string, object>)itemRepositorio.FieldValues; Microsoft.SharePoint.Client.FieldUrlValue fURl = (Microsoft.SharePoint.Client.FieldUrlValue)dc["Pagina"]; r = new Prelacion(); r.RepositoryUrl = fURl.Url; r.Tramitante = dc["No_x002e__x0020_Notaria"].ToString(); r.IdPrelacion = int.Parse(dc["ID"].ToString()); r.NumeroDocumento = dc["Numero_x0020_de_x0020_Documento"].ToString(); resultados.Add(r); //lblError.Text = lblError.Text + "\n" + fURl.Url.ToString(); } gvResultados.DataSource = resultados; gvResultados.DataBind(); /* * try * { * System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(fURl.Url); * request.UseDefaultCredentials = true; * * System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse(); * * System.IO.Stream responseStream = response.GetResponseStream(); * * Response.ContentType = "image/jpeg"; * new System.Drawing.Bitmap(responseStream).Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg); * Response.End(); * * * } * catch (System.Exception ex) * { * lblError.Text = lblError.Text + " 1.- " + ex.Message; * }*/ } } catch (System.Exception ex) { lblError.Text = lblError.Text + " 2.- " + ex.Message; } }
public DataTable refresh_Candidate_Store() { using (Microsoft.SharePoint.Client.ClientContext context = new Microsoft.SharePoint.Client.ClientContext(spCandidateSite)) { try { context.Credentials = new Microsoft.SharePoint.Client.SharePointOnlineCredentials(O365UserName, O365Password); context.Load(context.Web, w => w.Title); context.ExecuteQuery(); //toolStripStatusLabel1.Text = "Connecting to Libraries.."; Microsoft.SharePoint.Client.List list = context.Web.Lists.GetByTitle(quizListName); context.Load(list); context.ExecuteQuery(); Microsoft.SharePoint.Client.ListItemCollection listitems = list.GetItems(Microsoft.SharePoint.Client.CamlQuery.CreateAllItemsQuery()); context.Load(listitems); context.ExecuteQuery(); DataTable dt = new DataTable(); dt.Columns.Add("CandidateID", typeof(string)); dt.Columns.Add("First_name", typeof(string)); dt.Columns.Add("Last_name", typeof(string)); dt.Columns.Add("Job", typeof(string)); dt.Columns.Add("Hire_Status", typeof(string)); dt.Columns.Add("FolderUrl", typeof(string)); dt.Columns.Add("Remaining_Test", typeof(string)); dt.Columns.Add("Category", typeof(string)); dt.Columns.Add("DOB", typeof(string)); dt.Columns.Add("Date", typeof(string)); dt.Columns.Add("DisplayCombobox", typeof(string)); foreach (Microsoft.SharePoint.Client.ListItem item in listitems) { DataRow row = dt.NewRow(); row["CandidateID"] = item["CandidateID"]; row["First_Name"] = item["First_name"]; row["Last_name"] = item["Last_name"]; //change before full deployment //row["Job"] = ((FieldLookupValue)item["JobSite"]).LookupValue; ; row["Job"] = Convert.ToString(item["Job"]); row["Hire_Status"] = item["Hire_Status"]; row["Remaining_Test"] = item["Remaining_Test"]; row["Category"] = item["Category"]; row["DOB"] = item["DOB"]; Microsoft.SharePoint.Client.FieldUrlValue _url = (Microsoft.SharePoint.Client.FieldUrlValue)item["FolderUrl"]; row["FolderUrl"] = _url.Url; row["Date"] = item["Modified"]; row["DisplayCombobox"] = item["First_name"] + "_" + item["Last_name"] + " - " + item["CandidateID"]; dt.Rows.Add(row); } dt.TableName = "CandidateInfo"; SerializeDataSet(dt, "candidateInfo.xml"); return(dt); //toolStripStatusLabel1.Text = "Connecting to Lists.."; //Microsoft.SharePoint.Client.List list = context.Web.Lists.GetByTitle(quizListName); //context.Load(list); } catch (Exception ex) { return(null); } } }
private void BuscaPorFolioInterno() { try { //RPPMain.SharepointLibrary spLibrary = new RPPMain.SharepointLibrary("http://servidors04/sitios/digitalizacion", "Seccion Primera", "autostore", "Rpp1234"); lblError.Text = ""; String numero_documento = txNumeroDocumento.Text; string query = ""; query = "<Eq><FieldRef Name='Numero_x0020_de_x0020_Documento' /><Value Type='Number'>{0}</Value></Eq>"; query = "<View><Query><Where>" + query + "</Where></Query></View>"; query = string.Format(@query, numero_documento); //System.Collections.ArrayList arlRows = spLibrary.GetLibraryItem(query); using (ClientContext ctx = new ClientContext("http://servidors04/sitios/digitalizacion")) { Web web = ctx.Web; List list = web.Lists.GetById(new Guid("9c3f7319-7740-426f-87a4-bf9b8c0eb6b8")); var q = new CamlQuery() { ViewXml = query }; Microsoft.SharePoint.Client.ListItemCollection arlRows = list.GetItems(q); ctx.Load(arlRows); ctx.ExecuteQuery(); lblError.Text = "Se han obtenido " + arlRows.Count + " resultados de la búsqueda."; foreach (var item in arlRows) { List <Prelacion> resultados = new List <Prelacion>(); Prelacion r = new Prelacion(); for (int i = 0; i <= arlRows.Count - 1; i++) { Microsoft.SharePoint.Client.ListItem itemRepositorio = (Microsoft.SharePoint.Client.ListItem)arlRows[i]; Dictionary <string, object> dc = (Dictionary <string, object>)itemRepositorio.FieldValues; Microsoft.SharePoint.Client.FieldUrlValue fURl = (Microsoft.SharePoint.Client.FieldUrlValue)dc["Pagina"]; r = new Prelacion(); r.RepositoryUrl = fURl.Url; r.Tramitante = dc["No_x002e__x0020_Notaria"].ToString(); r.IdPrelacion = int.Parse(dc["ID"].ToString()); r.Partida = dc["Partida"].ToString(); r.NumeroDocumento = dc["Numero_x0020_de_x0020_Documento"].ToString(); resultados.Add(r); //lblError.Text = lblError.Text + "\n" + fURl.Url.ToString(); } gvResultados.DataSource = resultados; gvResultados.DataBind(); } } } catch (Exception exc) { lblError.Text = exc.Message; } }
private void Bw_sharepoint_DoWork(object sender, DoWorkEventArgs e) { string local_data_path = Create_Directory(); jobSiteInfo = new DataTable(); string filename = local_data_path + "\\" + "JobInfo.xml"; toolStripStatusLabel1.Text = "Connecting to Operations Sharepoint site"; using (Microsoft.SharePoint.Client.ClientContext context = new Microsoft.SharePoint.Client.ClientContext(spJobsite)) { try { context.Credentials = new Microsoft.SharePoint.Client.SharePointOnlineCredentials(O365UserName, O365Password); context.Load(context.Web, w => w.Title); context.ExecuteQuery(); e.Result = context.Web; Microsoft.SharePoint.Client.List list = context.Web.Lists.GetByTitle(joblistName); context.Load(list); Microsoft.SharePoint.Client.ListItemCollection listitems = list.GetItems(Microsoft.SharePoint.Client.CamlQuery.CreateAllItemsQuery()); context.Load(listitems); context.ExecuteQuery(); DataTable dt = new DataTable(); dt.Columns.Add("Name", typeof(string)); dt.Columns.Add("JobNumber", typeof(string)); dt.Columns.Add("SiteUrl", typeof(string)); dt.Columns.Add("ProjectType", typeof(string)); foreach (Microsoft.SharePoint.Client.ListItem item in listitems) { DataRow row = dt.NewRow(); //un comment for new release //row["Name"] = item["JobNumber"] + " - " + item["Title"]; row["Name"] = item["JobFullName"]; row["JobNumber"] = item["Title"]; Microsoft.SharePoint.Client.FieldUrlValue _url = (Microsoft.SharePoint.Client.FieldUrlValue)item["Site_x0020_Url"]; row["SiteUrl"] = _url.Url; row["ProjectType"] = item["Project_x0020_Category"]; dt.Rows.Add(row); } dt.TableName = "JobSiteInfo"; SerializeDataSet(dt, "JobInfo.xml"); jobSiteInfo = dt.Copy(); jobSiteInfo.TableName = "JobSiteInfo"; dataBank.Tables.Add(jobSiteInfo); } catch (Exception ex) { e.Result = ex; toolStripStatusLabel1.Text = "Connecting to Local Datastore for Job Info"; if (checkLocalDataStore_Operations()) { jobSiteInfo.ReadXml(filename); jobSiteInfo.TableName = "JobSiteInfo"; dataBank.Tables.Add(jobSiteInfo); } else { MessageBox.Show("Could not find jobsiteInfo.xml"); } } } }
private void Bw_sharepoint_safety_site_list_DoWork(object sender, DoWorkEventArgs e) { //throw new NotImplementedException(); toolStripStatusLabel1.Text = "Connecting to Safety Libraries"; string local_data_path = Create_Directory(); candidateInfo = new DataTable(); string filename = local_data_path + "\\" + "candidateInfo.xml"; using (Microsoft.SharePoint.Client.ClientContext context = new Microsoft.SharePoint.Client.ClientContext(spCandidateSite)) { try { context.Credentials = new Microsoft.SharePoint.Client.SharePointOnlineCredentials(O365UserName, O365Password); context.Load(context.Web, w => w.Title); context.ExecuteQuery(); //toolStripStatusLabel1.Text = "Connecting to Libraries.."; Microsoft.SharePoint.Client.List list = context.Web.Lists.GetByTitle(quizListName); context.Load(list); context.ExecuteQuery(); Microsoft.SharePoint.Client.ListItemCollection listitems = list.GetItems(Microsoft.SharePoint.Client.CamlQuery.CreateAllItemsQuery()); context.Load(listitems); context.ExecuteQuery(); DataTable dt = new DataTable(); dt.Columns.Add("CandidateID", typeof(string)); dt.Columns.Add("First_name", typeof(string)); dt.Columns.Add("Last_name", typeof(string)); dt.Columns.Add("Job", typeof(string)); dt.Columns.Add("Hire_Status", typeof(string)); dt.Columns.Add("FolderUrl", typeof(string)); dt.Columns.Add("Remaining_Test", typeof(string)); dt.Columns.Add("Category", typeof(string)); dt.Columns.Add("DOB", typeof(string)); dt.Columns.Add("Date", typeof(string)); dt.Columns.Add("DisplayCombobox", typeof(string)); foreach (Microsoft.SharePoint.Client.ListItem item in listitems) { DataRow row = dt.NewRow(); row["CandidateID"] = item["CandidateID"]; row["First_Name"] = item["First_name"]; row["Last_name"] = item["Last_name"]; // enable when deploying througout organization //row["Job"] = ((FieldLookupValue)item["JobSite"]).LookupValue; row["Job"] = item["Job"]; row["Hire_Status"] = item["Hire_Status"]; row["Remaining_Test"] = item["Remaining_Test"]; row["Category"] = item["Category"]; row["DOB"] = item["DOB"]; Microsoft.SharePoint.Client.FieldUrlValue _url = (Microsoft.SharePoint.Client.FieldUrlValue)item["FolderUrl"]; row["FolderUrl"] = _url.Url; row["Date"] = item["Modified"]; // row["DisplayCombobox"] = item["CandidateID"] + " - " + item["First_name"] + "_" + item["Last_name"]; row["DisplayCombobox"] = item["First_name"] + "_" + item["Last_name"] + " - " + item["CandidateID"]; dt.Rows.Add(row); } dt.TableName = "CandidateInfo"; SerializeDataSet(dt, "candidateInfo.xml"); candidateInfo = dt.Copy(); candidateInfo.TableName = "CandidateInfo"; dataBank.Tables.Add(candidateInfo); //toolStripStatusLabel1.Text = "Connecting to Lists.."; //Microsoft.SharePoint.Client.List list = context.Web.Lists.GetByTitle(quizListName); //context.Load(list); e.Result = list; } catch (Exception ex) { e.Result = ex; if (checkLocalDataStore_candidate()) { candidateInfo.ReadXml(filename); candidateInfo.TableName = "CandidateInfo"; dataBank.Tables.Add(candidateInfo); } else { MessageBox.Show("Could not find candiateInfo.xml"); } } } }