miércoles, 18 de enero de 2012
miércoles, 11 de enero de 2012
Información del directorio activo desde InfoPath
1- Crear un proyecto de infopath
2- Opciones Avanzadas
3- Seguridad y confianza
3- Programacion
4- Compatibilidad
5- Codigo fuente
Se debe asignar un directorio para almacenar el archivo xml, que contiene las propiedades que van a consultarse.
En ambientes de producción se deben dar los permisos a la carpeta.
Ej:
document.Load(@"C:\Users\Administrator\Documents\InfoPath Projects\codigoInfopath\Properties.xml");
Properties.xml
<?xml version="1.0" encoding="utf-8" ?>
<document>
<property
id="givenname" value="FirstName"/>
<property
id="sn" value="LastName"/>
<property
id="title" value="Job"/>
<property
id="l" value="City"/>
<property
id="department" value="Area"/>
<property
id="company" value="Company"/>
</document>
6- Editor de codigo
Directorio del xml
document.Load(@"C:\Users\Administrator\Documents\InfoPath Projects\codigoInfopath\Properties.xml");
Credenciales Dominio
DirectoryEntry root = new DirectoryEntry("LDAP://think.com", @"Administrator", "Shar3p0int");
public void InternalStartup()
{
EventManager.FormEvents.Loading += new LoadingEventHandler(FormEvents_Loading);
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
public void FormEvents_Loading(object sender, LoadingEventArgs e)
{
// Escriba aquí su código.
// Get the user name of the current user.
string userName = this.Application.User.UserName;
//ActiveDirectoryAccess obj = new ActiveDirectoryAccess();
Dictionary<string, string> dictionary = new Dictionary<string, string>();
List<string> list = new List<string>();
XmlDocument document = new XmlDocument();
document.Load(@"C:\Users\Administrator\Documents\InfoPath Projects\codigoInfopath\Properties.xml");
XmlNodeList nodes = document.SelectNodes("document/property");
foreach (XmlNode node in nodes)
{
dictionary.Add(node.Attributes["id"].Value, node.Attributes["value"].Value);
}
foreach (KeyValuePair<string, string> pair in dictionary)
{
list.Add(pair.Key);
}
Dictionary<string, string> ADDictionary = GetInformation(userName, list);
XPathNavigator xnMyForm;
XmlNamespaceManager ns;
try
{
xnMyForm = this.CreateNavigator();
ns = this.NamespaceManager;
foreach (KeyValuePair<string, string> pair in dictionary)
{
xnMyForm.SelectSingleNode("/my:myFields/my:" + pair.Value, ns).SetValue(ADDictionary[pair.Key]);
}
}
catch (Exception ex)
{
throw;
}
finally
{
// Clean up.
xnMyForm = null;
}
// Clean up.
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
public Dictionary<string,
string> GetInformation(string userName, List<string> list)
{
DirectorySearcher
searcher = null;
SearchResult
result = null;
DirectoryEntry
employee = null;
Dictionary<string, string>
dictionary = new Dictionary<string, string>();
try
{
//
Create a DirectorySearcher object using the user name
// as
the LDAP search filter. If using a directory other
//
than Exchange, use sAMAccountName instead of mailNickname.
DirectoryEntry
root = new DirectoryEntry("LDAP://think.com", @"Administrator", "Shar3p0int");
searcher = new DirectorySearcher(root,
"(samaccountname=" + userName + ")");
foreach
(string data in
list)
{
searcher.PropertiesToLoad.Add(data);
}
//
Search for the specified user.
result = searcher.FindOne();
//
Make sure the user was found.
if
(result == null)
{
// MessageBox.Show("Error
finding user: " + userName);
}
else
{
//
Create a DirectoryEntry object to retrieve the collection
//
of attributes (properties) for the user.
employee =
result.GetDirectoryEntry();
foreach
(string name in
list)
{
if (!dictionary.ContainsKey(name))
{
if (employee.Properties[name].Value != null)
{
dictionary.Add(name,
employee.Properties[name].Value.ToString());
}
}
}
}
}
catch
(Exception ex)
{
//MessageBox.Show("The
following error occurred: " + ex.Message.ToString());
throw;
}
finally
{
//
Clean up.
searcher.Dispose();
result = null;
employee.Close();
}
return
dictionary;
}
7- Publicacion SharePoint Server
Manage form templates
Seleccionar la plantilla previamente creada.
8- Usar Plantilla desde SharePoint
- Crear una libreria de formularios
- Activar Tipos de Contenido
- Abrir en el browser
- Adicionar tipo de contenido de la plantilla y predeterminarlo, y borrando el que viene por defecto.
9- Adicionar Documento a la libreria
10- Resultado final
lunes, 5 de diciembre de 2011
Installing Office Web Apps for SharePoint 2010
Deploy Office Web Apps
http://technet.microsoft.com/en-us/library/ff431687.aspx
Installing Office Web Apps for SharePoint 2010
http://sharepointgeorge.com/2010/installing-office-web-apps-for-sharepoint-2010/
Word Web App cannot open this document for viewing because of an unexpected error. To view this document, open it in Microsoft Word
http://yaohany.wordpress.com/2010/09/22/word-web-app-cannot-open-this-document-for-viewing-because-of-an-unexpected-error-to-view-this-document-open-it-in-microsoft-word/
http://technet.microsoft.com/en-us/library/ff431687.aspx
Installing Office Web Apps for SharePoint 2010
http://sharepointgeorge.com/2010/installing-office-web-apps-for-sharepoint-2010/
Word Web App cannot open this document for viewing because of an unexpected error. To view this document, open it in Microsoft Word
http://yaohany.wordpress.com/2010/09/22/word-web-app-cannot-open-this-document-for-viewing-because-of-an-unexpected-error-to-view-this-document-open-it-in-microsoft-word/
viernes, 2 de diciembre de 2011
Sincronizar imagen de sharepoint con el directorio activo
En el siguiente Blog se encuentra detallado el proceso que se debe realizar para sincronizar las imagenes guardadas en directorio activo y SharePoint
Si no tienen las imagenes en directorio activo
, existen varios programas que hacen esto…
martes, 29 de noviembre de 2011
martes, 22 de noviembre de 2011
Adicionar links dinámicos a columnas en listas SharePoint
1- Crear una columna tipo Hyperlink
2- Abrir la lista desde SharePoint Designer
3- Crear vista
4- Editar vista en modo avanzado
5- Habilitar la vista codigo avanzado
6- Codigo fuente del web part
7- El codigo generado de la vista es
<xsl:template name="FieldRef_Hyperlink_URL_body.enlace" ddwrt:dvt_mode="body" match="FieldRef[(@Format='Hyperlink') and @Name='enlace']" mode="URL_body" ddwrt:ghost="hide">
<xsl:param name="thisNode" select="."/>
<xsl:variable name="url" select="$thisNode/@*[name()=current()/@Name]" />
<xsl:variable name="desc" select="$thisNode/@*[name()=concat(current()/@Name, '.desc')]" />
<xsl:choose>
<xsl:when test="$url=''">
<xsl:if test="$desc=''">
<xsl:value-of select="$desc"/>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<a href="{$url}" >
<xsl:choose>
<xsl:when test="$desc=''">
<xsl:value-of select="$url"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$desc"/>
</xsl:otherwise>
</xsl:choose>
</a>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
8- El codigo que coloca a la columna enlace una url concatenada con un valor que se encuentra en las columnas de la lista es el siguiente:
Reemplace el codigo generado que se visualiza en (7) con el siguiente:
<xsl:template name="FieldRef_Hyperlink_URL_body.enlace" ddwrt:dvt_mode="body" match="FieldRef[(@Format='Hyperlink') and @Name='enlace']" mode="URL_body" ddwrt:ghost="">
<xsl:param name="thisNode" select="."/>
<xsl:variable name="url" select="$thisNode/@*[name()=current()/@Name]" />
<xsl:variable name="desc" select="$thisNode/@*[name()=concat(current()/@Name, '.desc')]" />
<a href="{concat('http://server/Reuniones/SitePages/ToPDF.aspx?IDReunion=',$thisNode/@ID)}" >
<xsl:value-of select="concat('Convertir a',' PDF')"/>
</a>
</xsl:template>
9- Ver los resultados en el browser
10- De esta manera podemos generar url con parametros dinamicos, sin necesidad de escribir javascript adicional, simplemente usando el xslt del que disponemos y el resultado es el siguiente:
martes, 15 de noviembre de 2011
Selección automática del Id de la lista Maestra en la creación de items en listas relacionadas
1- Crear Lista Maestra.
2- Crear Lista detalle.
3- Crear una columna en la lista de detalle relacionada con el id de la maestra.
4- Filtrar Lista Detalle de acuerdo a la selección en la lista Maestra
Click en Edit Web Part y luego en el Web Part Menu
5- Crear una pagina para desplegar las listas.
6- Adicionar un control tipo "hidden" para almacenar el valor del item seleccionado, cuando se de click en adicionar en la lista Detalle.
En la pagina que se acabo de crear
y se adiciona el control:
<input id="indexGrilla" type="hidden"/>
7- Se adiciona un editor de contenido en donde se colocara el jquery que busca el item seleccionado en la lista maestra, para colocarlo por defecto en la lista de detalle.
y se edita el html editor con el siguiente contenido:
<script src="/jquery/js/jquery-1.6.2.min.js" type="text/javascript"> </script>
<script>
$(document).ready(function () {
$("#idHomePageNewItem").live('click', function () {
$("#indexGrilla").val($("img[src='/_layouts/images/rbsel.gif']").parent().parent().attr("iid").split(",")[1]);
});
});
</script>
8- En la opción Default New Form de la lista Detalle.
9- Se adiciona un editor de contenido
10- En la opcion "HTML" "Edit HTML Source" coloque el siguiente codigo:
<script src="/jquery/js/jquery-1.6.2.min.js" type="text/javascript"></script><script>
var pw = parent.window;
if(pw){
var inputFrm = pw.document.forms[0];
var indexSEL =inputFrm.elements['indexGrilla'].value;
}
$(document).ready(function (){
$("select[title='IdMaestra']").val(indexSEL);
$("select[title='IdMaestra']").parent().parent().parent().hide();
});
</script>
11- El resultado es un ingreso de elementos en la lista Detalle, sin necesidad de seleccionar el Id de la lista Maestra, por que este se toma automáticamente del ítem seleccionado.
Suscribirse a:
Entradas (Atom)











































