Exemplo n.º 1
0
 public static Guid CreateEntity(Entity entity, CrmConnection connection = null)
 {
     using (CrmOrganizationServiceContext service = new CrmOrganizationServiceContext(connection ?? XrmConnection.Connection))
     {
         Guid id = service.Create(entity);
         entity.Id = id;
         return(id);
     }
 }
Exemplo n.º 2
0
        private static Guid CreateImportEntity(CrmOrganizationServiceContext serviceContext, string sourceEntityName)
        {
            var import = new Import
            {
                Name     = "Import of " + sourceEntityName,
                ModeCode = new OptionSetValue(0)
            };

            return(serviceContext.Create(import));
        }
Exemplo n.º 3
0
        public Guid CreateAccount(string name)
        {
            var entity = new Entity("account")
            {
                Attributes = new Microsoft.Xrm.Sdk.AttributeCollection
                {
                    { "name", name }
                }
            };

            var id = _crmContext.Create(entity);

            return(id);
        }
Exemplo n.º 4
0
        private void CreateImportFileEntity(CrmOrganizationServiceContext serviceContext, string content, Guid importId, Guid dataMapId)
        {
            var importFile = new ImportFile
            {
                Name                     = Path.GetFileName(this.FilePath),
                Source                   = this.FilePath,
                Content                  = content,
                SourceEntityName         = this.SourceEntityName,
                TargetEntityName         = this.TargetEntityName,
                FileTypeCode             = new OptionSetValue(0),
                DataDelimiterCode        = new OptionSetValue(1),
                FieldDelimiterCode       = new OptionSetValue(2),
                IsFirstRowHeader         = new bool?(true),
                EnableDuplicateDetection = new bool?(false),
                ProcessCode              = new OptionSetValue(1),
                ImportId                 = new EntityReference("import", importId),
                ImportMapId              = new EntityReference("importmap", dataMapId)
            };

            serviceContext.Create(importFile);
        }
Exemplo n.º 5
0
        private void CreateImportFileEntity(CrmOrganizationServiceContext serviceContext, string content, Guid importId, Guid dataMapId)
        {
            var importFile = new ImportFile
            {
                Name = Path.GetFileName(this.FilePath),
                Source = this.FilePath,
                Content = content,
                SourceEntityName = this.SourceEntityName,
                TargetEntityName = this.TargetEntityName,
                FileTypeCode = new OptionSetValue(0),
                DataDelimiterCode = new OptionSetValue(1),
                FieldDelimiterCode = new OptionSetValue(2),
                IsFirstRowHeader = new bool?(true),
                EnableDuplicateDetection = new bool?(false),
                ProcessCode = new OptionSetValue(1),
                ImportId = new EntityReference("import", importId),
                ImportMapId = new EntityReference("importmap", dataMapId)
            };

            serviceContext.Create(importFile);
        }
Exemplo n.º 6
0
        private static Guid CreateImportEntity(CrmOrganizationServiceContext serviceContext, string sourceEntityName)
        {
            var import = new Import
            {
                Name = "Import of " + sourceEntityName,
                ModeCode = new OptionSetValue(0)
            };

            return serviceContext.Create(import);
        }