public static void InitializeWriteToDynamicsCrmN2N(TestContext context)
        {
            connection = Test_Helpers.GetDynamicsCrmConnection();
            var crmConnection = (CrmConnection)connection.GetConnection();

            service = new OrganizationService(crmConnection);
        }
Example #2
0
        public void Test_RelateProductsWithCampaigns()
        {
            var defaultUnits = Test_Helpers.GetDefaultUnitGroup(organizationService);

            Entity campaign = new Entity("campaign");

            campaign.Attributes.Add("name", "test prd_cmpgn 1");
            Guid campaignId = organizationService.Create(campaign);

            Entity product = new Entity("product");

            product.Attributes.Add("name", "test prd_cmpgn 1");
            product.Attributes.Add("productnumber", "prd_cmpgn 1");
            product.Attributes.Add("defaultuomscheduleid", new EntityReference("uomschedule", defaultUnits.DefaultUnitGroupId));
            product.Attributes.Add("defaultuomid", new EntityReference("uom", defaultUnits.PrimaryUnitId));
            product.Attributes.Add("quantitydecimal", 2);
            Guid productId = organizationService.Create(product);

            Microsoft.Crm.Sdk.Messages.PublishProductHierarchyRequest publishProduct = new Microsoft.Crm.Sdk.Messages.PublishProductHierarchyRequest();
            publishProduct.Target = new EntityReference("product", productId);
            organizationService.Execute(publishProduct);

            WriteToDynamicsCrmN2NConfiguration writeToDynamicsCrmN2NConfig = new WriteToDynamicsCrmN2NConfiguration();

            writeToDynamicsCrmN2NConfig.MultipleFoundMode = N2NMultipleFoundMode.None;
            writeToDynamicsCrmN2NConfig.Entity1Name       = "campaign";
            writeToDynamicsCrmN2NConfig.Entity1Mapping    = new List <DataMapping>()
            {
                new DataMapping("CampaigName", "name")
            };
            writeToDynamicsCrmN2NConfig.Entity2Name    = "product;campaignproduct_association";
            writeToDynamicsCrmN2NConfig.Entity2Mapping = new List <DataMapping>()
            {
                new DataMapping("ProductNumber", "productnumber")
            };
            writeToDynamicsCrmN2NConfig.ConfigurationId = Guid.NewGuid();
            writeToDynamicsCrmN2NConfig.SelectedConnectionConfigurationId = Test_Helpers.CRMCONNECTIONID;

            IDatastore dataObject = DataStoreFactory.GetDatastore();

            dataObject.AddColumn(new ColumnMetadata("CampaigName"));
            dataObject.AddColumn(new ColumnMetadata("ProductNumber"));

            dataObject.AddData(new object[] { "test prd_cmpgn 1", "prd_cmpgn 1" });

            IModule module = Activator.CreateInstance(typeof(WriteToDynamicsCrmN2N)) as IModule;

            module.SetConfiguration(writeToDynamicsCrmN2NConfig);

            ((IDataTarget)module).WriteData(connection, new DummyDatabaseInterface(), dataObject, Test_Helpers.ReportProgressMethod);

            organizationService.Delete("campaign", campaignId);
            organizationService.Delete("product", productId);
        }
Example #3
0
        public void Test_DynamicsCrm_ImportLargeDataset()
        {
            var writeToCrmConfig = GetAccountImportConfiguration();

            IDatastore accountDatastore = Test_Helpers.LoadExcelsheet(@"TestData\LargeDataset.xlsx", "Accounts");
            IModule    module           = Activator.CreateInstance(typeof(WriteToDynamicsCrm)) as IModule;

            module.SetConfiguration(writeToCrmConfig);

            ((IDataTarget)module).WriteData(connection, new DummyDatabaseInterface(), accountDatastore, Test_Helpers.ReportProgressMethod);
        }
Example #4
0
        public void Test_RelateContactsWithInvoice()
        {
            Entity contact   = Test_Helpers.CreateDummyContact();
            Guid   contactId = organizationService.Create(contact);

            Entity invoice   = Test_Helpers.CreateDummyInvoice();
            Guid   invoiceId = organizationService.Create(invoice);

            WriteToDynamicsCrmN2NConfiguration writeToDynamicsCrmN2NConfig = new WriteToDynamicsCrmN2NConfiguration();

            writeToDynamicsCrmN2NConfig.MultipleFoundMode = N2NMultipleFoundMode.None;
            writeToDynamicsCrmN2NConfig.Entity1Name       = "contact";
            writeToDynamicsCrmN2NConfig.Entity1Mapping    = new List <DataMapping>()
            {
                new DataMapping("FirstName", "firstname")
            };
            writeToDynamicsCrmN2NConfig.Entity2Name    = "invoice;contactinvoices_association";
            writeToDynamicsCrmN2NConfig.Entity2Mapping = new List <DataMapping>()
            {
                new DataMapping("InvoiceNo", "invoicenumber")
            };
            writeToDynamicsCrmN2NConfig.ConfigurationId = Guid.NewGuid();
            writeToDynamicsCrmN2NConfig.SelectedConnectionConfigurationId = Test_Helpers.CRMCONNECTIONID;

            IDatastore dataObject = DataStoreFactory.GetDatastore();

            dataObject.AddColumn(new ColumnMetadata("FirstName"));
            dataObject.AddColumn(new ColumnMetadata("InvoiceNo"));

            dataObject.AddData(new object[] { contact["firstname"], invoice["invoicenumber"] });

            IModule module = Activator.CreateInstance(typeof(WriteToDynamicsCrmN2N)) as IModule;

            module.SetConfiguration(writeToDynamicsCrmN2NConfig);

            ((IDataTarget)module).WriteData(connection, new DummyDatabaseInterface(), dataObject, Test_Helpers.ReportProgressMethod);

            organizationService.Delete("contact", contactId);
            organizationService.Delete("invoice", invoiceId);
        }
Example #5
0
 public static void InitializeWriteToDynamicsCrmN2N(TestContext context)
 {
     connection          = Test_Helpers.GetDynamicsCrmConnection();
     organizationService = connection.GetConnection() as IOrganizationService;
 }
Example #6
0
 public static void InitializeCrm2013Wrapper(TestContext context)
 {
     connection = Test_Helpers.GetDynamicsCrmConnection();
 }
Example #7
0
 public static void InitializeCrm2013Wrapper(TestContext context)
 {
     connection          = Test_Helpers.GetDynamicsCrmConnection();
     organizationService = connection.GetConnection() as IOrganizationService;
 }