Rechercher dans ce blog

vendredi 17 août 2012

Le correctif cumulatif 10 pour Microsoft Dynamics CRM 2011

Version : 5.0.9690.2740

Fonctionnalités ajoutées :
Intégration avec Microsoft Office 2013
Intégration avec Windows 8
Intégration avec Internet Explorer 10

Document : Optimiser le serveur CRM 2011

Optimizing and Maintaining the Performance of a Microsoft Dynamics CRM 2011 Server Infrastructure

L'optimisation est un équilibrage permanent entre les décisions de conception et de la disponibilité des ressources. Ce livre blanc donne des conseils et des astuces pour optimiser et pour maintenir la performance d'une infrastructure de serveur Microsoft Dynamics CRM 2011.

lundi 13 août 2012

API : GetHeaderColumnsImportFileRequest

Récupère les entêtes des colonnes du fichier source; ou récupère les entêtes de colonnes générées si le fichier source ne contient pas d'entêtes de colonnes
// Create an import (data import) entity instance.
import import = new import();
import.name = "Importing data";

// Distinguish between an import and an update.
import.isimport = new CrmBoolean();
import.isimport.Value = true;
import.modecode = new Picklist();
import.modecode.Value = ImportModeCode.Create; 

// Create the import (data import) entity instance. 
// in Microsoft Dynamics CRM
Guid importId = service.Create(import);

// Create a logical source file of the data being imported.
importfile importFile = new importfile();
importFile.name = "Account record import.";
importFile.source = "import_accounts.csv";
importFile.sourceentityname = "Account_1";
importFile.targetentityname = EntityName.account.ToString();

// Read contents from disk.
importFile.content = ReadCsvFile("import_accounts.csv");

// Configure delimiters.
importFile.datadelimitercode = new Picklist();
importFile.datadelimitercode.Value = ImportDataDelimiter.DoubleQuote;
importFile.fielddelimitercode = new Picklist();
importFile.fielddelimitercode.Value = ImportFieldDelimiter.Comma;

// Do not allow duplicate records to import.
importFile.enableduplicatedetection = new CrmBoolean();
importFile.enableduplicatedetection.Value = false;

// Relate the import file to the parent import (data import).
importFile.importid = new Lookup();
importFile.importid.type = EntityName.import.ToString();
importFile.importid.Value = importId;

// Relate this import file to the parent data map.
importFile.importmapid = new Lookup();
importFile.importmapid.type = EntityName.importmap.ToString();
importFile.importmapid.Value = importMapId;

// Do not use the first row during import.
importFile.isfirstrowheader = new CrmBoolean();
importFile.isfirstrowheader.Value = true;

// Specify to process the column.
importFile.processcode = new Picklist();
importFile.processcode.Value = ImportProcessCode.Process;

// Specify the current user as the record owner.
WhoAmIRequest systemUserRequest = new WhoAmIRequest();
WhoAmIResponse systemUserReponse = (WhoAmIResponse)service.Execute(systemUserRequest);

// Specify the owner ID.
importFile.recordsownerid = new Lookup();
importFile.recordsownerid.type = EntityName.systemuser.ToString();
importFile.recordsownerid.Value = systemUserReponse.UserId;

// Create the import file.
Guid importFileId = service.Create(importFile);

// Retrieve the header columns used in the import file.
GetHeaderColumnsImportFileRequest headerColumnsRequest = new GetHeaderColumnsImportFileRequest();
headerColumnsRequest.ImportFileId = importFileId;
GetHeaderColumnsImportFileResponse headerColumnsResponse = (GetHeaderColumnsImportFileResponse)service.Execute(headerColumnsRequest);

// Output the header columns.
int columnNum = 1;
foreach(string headerName in headerColumnsResponse.Columns)
{
Console.WriteLine("Column[" + columnNum.ToString() + "] = " + headerName);
columnNum++;
}

vendredi 10 août 2012

Comment importer les pièces jointes par programme

How to Import attachments programmatically

Voici les étapes:
1. Créer un fichier CSV contenant les pièces jointes que tu souhaites importer.
2. créer un enregistrement d'import.
3. Créer un enregistrement pour les pièces jointes qui contient le contenu des fichiers actuels.
4. Créer un enregistrement qui contient le mapping.
5. Appeler les méthodes SDK d'import.

      /// 
 
       /// Impport attachments in CRM
 
       /// 
 
       public void ImportAttachmentRecords()
 
       {            
 
OrganizationServiceProxy _serviceProxy; // Initialize the _serviceProxy appropriately.
 
           // 1. Create a CSV file containing the details of attachments that you want to import.
 
           string fileName = DateTime.UtcNow.Ticks + ".txt";
 
           string attachmentContent = "This is the attachment content"; // Put your attachment contents here.
 
           string attachmentData = Convert.ToBase64String(Encoding.UTF8.GetBytes(attachmentContent));
 
           StringBuilder sb = new StringBuilder();
 
           //Add header row
 
           sb.AppendLine("Title, Document, File Name, Regarding");
 
           string accountId = "04AFD3BF-16D6-E111-A43C-00155D187A0A"; // This is the unique id of CRM record e.g. account with which you want to attach this note.
 
           string dataRow = "attachment1, " + fileName + ", " + fileName + "," + accountId;
 
           sb.AppendLine(dataRow);
 
           string csvData = sb.ToString();
 
           // 2.    Create the root import record
 
           Import import = new Import()
 
           {
 
               ModeCode = new OptionSetValue((int)ImportModeCode.Create),
 
               Name = "Importing data"
 
           };
 
           Guid importId = _serviceProxy.Create(import);
 
          // 3.    Create import file record for attachments which contains actual file contents.
 
           ImportFile importAttachmentFile = new ImportFile()
 
           {
 
               Content = attachmentData, // Read contents from disk.
 
               Name = fileName,
 
               UseSystemMap = true,
 
               ImportId = new EntityReference(Import.EntityLogicalName, importId),
 
               ProcessCode =
 
                   new OptionSetValue((int)ImportFileProcessCode.Internal),
 
               FileTypeCode = new OptionSetValue(2)
 
           };
 
           Guid importAttachmentFileId = _serviceProxy.Create(importAttachmentFile);
 
           // 4.    Create import file record which contains mapping for attachments.
 
           ImportFile importFile = new ImportFile()
 
           {
 
               Content = csvData, // Read contents from disk.
 
               Name = "Attachment Import File",
 
               IsFirstRowHeader = true,
 
               UseSystemMap = true,
 
               Source = "Import Attachment",
 
               SourceEntityName = "attachment",
 
               TargetEntityName = Annotation.EntityLogicalName,
 
               ImportId = new EntityReference(Import.EntityLogicalName, importId),
 
               EnableDuplicateDetection = false,
 
               FieldDelimiterCode =
 
                   new OptionSetValue((int)ImportFileFieldDelimiterCode.Comma),
 
               DataDelimiterCode =
 
                   new OptionSetValue((int)ImportFileDataDelimiterCode.DoubleQuote),
 
               ProcessCode =
 
                   new OptionSetValue((int)ImportFileProcessCode.Process)
 
           };
 
           Guid importFileId = _serviceProxy.Create(importFile);
 
           // 5.    Call import SDK APIs
 
           // Parse the import file.
 
           ParseImportRequest parseImportRequest = new ParseImportRequest()
 
           {
 
               ImportId = importId
 
           };
 
           ParseImportResponse parseImportResponse =
 
               (ParseImportResponse)_serviceProxy.Execute(parseImportRequest);
 
           WaitForAsyncJobCompletion(_serviceProxy, parseImportResponse.AsyncOperationId);
 
           // Transform the import
 
           TransformImportRequest transformImportRequest = new TransformImportRequest()
 
           {
 
               ImportId = importId
 
           };
 
           TransformImportResponse transformImportResponse =
 
               (TransformImportResponse)_serviceProxy.Execute(transformImportRequest);
 
           WaitForAsyncJobCompletion(_serviceProxy, transformImportResponse.AsyncOperationId);
 
           // Upload the records.
 
           ImportRecordsImportRequest importRequest = new ImportRecordsImportRequest()
 
           {
 
               ImportId = importId
 
           };
 
           ImportRecordsImportResponse importResponse =
 
               (ImportRecordsImportResponse)_serviceProxy.Execute(importRequest);
 
           WaitForAsyncJobCompletion(_serviceProxy, importResponse.AsyncOperationId);
 
       }
 
       /// 
 
       /// Waits for the async job to complete.
 
       /// 
 
       /// 
public void WaitForAsyncJobCompletion(OrganizationServiceProxy serviceProxy, Guid asyncJobId)
 
       {
 
           ColumnSet cs = new ColumnSet("statecode", "statuscode");
 
           AsyncOperation asyncjob =
 
               (AsyncOperation)serviceProxy.Retrieve("asyncoperation", asyncJobId, cs);
 
           int retryCount = 100;
 
           while (asyncjob.StateCode.Value != AsyncOperationState.Completed && retryCount > 0)
 
           {
 
               asyncjob = (AsyncOperation)serviceProxy.Retrieve("asyncoperation", asyncJobId, cs);
 
               System.Threading.Thread.Sleep(2000);
 
               retryCount--;
 
           }
 
       }

dimanche 29 juillet 2012

Cacher des groupes de navigation

Pour cacher un groupe de navigation, nous pouvons utiliser du javascript. Mais on peut aussi modifier la solution. Exporter dans une solution, l'entité concernée. Modifier le fichier customizations.xml. Rechercher les balises suivantes :


Supprimer les groupes de navigation non souhaités.


Ajouter le fichier customization.xml dans la solution. Importer la solution et publier.

API : ExportMappingsImportMapRequest

Export au format XML le mapping pour l'import de données

ExportMappingsImportMapRequest exportRequest = new ExportMappingsImportMapRequest();
exportRequest.ImportMapId = importResponse.ImportMapId;

//Execute la requête
ExportMappingsImportMapResponse exportResponse = (ExportMappingsImportMapResponse)Proxy.Execute(exportRequest);

API : ImportMappingsImportMapRequest

Importe une représentation XML du mappage de données et crée un mappage de données

ImportMappingsImportMapRequest importRequest = new ImportMappingsImportMapRequest();
//Chemin du fichier xml
importRequest.MappingsXml = "C:\\Mapping\\SFMap.xml;
importRequest.ReplaceIds = true;

//Execute la requête
ImportMappingsImportMapResponse importResponse = (ImportMappingsImportMapResponse)Proxy.Execute(importRequest);

samedi 28 juillet 2012

API : CreateActivitiesListRequest

Crée une campagne rapide en distribuant les activités aux membres d'une liste marketing

CreateActivitiesListRequest request = new CreateActivitiesListRequest() {
Activity = activityEntity,
ListId = marketingListId,
OwnershipOptions = ownershipOption,
Propagate = isPropagate,
TemplateId = Guid.Empty,
FriendlyName = "Quick Campaign for My List" /*+ _uniqStringForThisRun*/,
Owner = new EntityReference("systemuser", _currentUser)
};

//Execute the request
CreateActivitiesListResponse response = (CreateActivitiesListResponse)_serviceProxy.Execute(request);

//The response has BulkOperationId. This is the Id of the bulkoperation that mimics QuickCampaign in CRM
Guid BOId = response.BulkOperationId;

SP2 pour SQL Server 2008 R2

Version 10.50.4000.0

Nouveauté : les vues de gestion dynamique (DMV) sys.dm_db_stats_properties
Ces vues présentent les informations d'état des serveurs pour diagnostiquer les problèmes et régler les performances des bases de données.

List of the bugs that are fixed in SQL Server 2008 R2 Service Pack 2
Microsoft SQL Server 2008 R2 SP2
Microsoft SQL Server 2008 R2 Express SP2
Microsoft SQL Server 2008 R2 SP2 Feature Pack