예제 #1
0
        private void toolStripMenuItemAddRecordMapping_Click(object sender, EventArgs e)
        {
            dataGridView1.EndEdit();
            RecordMapping rr = new RecordMapping();

            rr.SourceRecordId = Guid.Empty;
            rr.TargetRecordId = Guid.Empty;
            rm.Add(rr);

            dataGridView1.DataSource = null;
            dataGridView1.DataSource = rm;
        }
예제 #2
0
        private void mapToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                dataGridView1.EndEdit();
                Guid SourceBUId = Guid.Empty;
                Guid TargetBUId = Guid.Empty;
                //Get Source Default Transaction Currency
                string          fetchBU          = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false' count='1'>
                                      <entity name='businessunit'>
                                        <attribute name='businessunitid' />
                                        <attribute name='createdon' />
                                        <order attribute='createdon' descending='false' />
                                      </entity>
                                    </fetch> ";
                MSCRMConnection connectionSource = rdt.currentProfile.getSourceConneciton();
                _serviceProxySource = cm.connect(connectionSource);

                EntityCollection resultSource = _serviceProxySource.RetrieveMultiple(new FetchExpression(fetchBU));
                foreach (var s in resultSource.Entities)
                {
                    SourceBUId = (Guid)s.Attributes["businessunitid"];
                }

                //Get Target Default Transaction Currency
                MSCRMConnection connectionTarget = rdt.currentProfile.getTargetConneciton();
                _serviceProxyTarget = cm.connect(connectionTarget);

                EntityCollection resultTarget = _serviceProxyTarget.RetrieveMultiple(new FetchExpression(fetchBU));
                foreach (var t in resultTarget.Entities)
                {
                    TargetBUId = (Guid)t.Attributes["businessunitid"];
                }

                //Add the mapping
                RecordMapping rr = new RecordMapping();
                rr.EntityName     = "businessunit";
                rr.SourceRecordId = SourceBUId;
                rr.TargetRecordId = TargetBUId;
                rm.Add(rr);
                dataGridView1.DataSource = null;
                dataGridView1.DataSource = rm;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Mapping error: " + ex.Message);
            }
        }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RecordsMapping"/> class.
        /// </summary>
        /// <param name="rdt">The RDT.</param>
        public RecordsMapping(ReferenceDataTransporter rdt)
        {
            this.rdt = rdt;

            //Strange datagridview behaviour fix
            bool tempRecordMappingAdded = false;

            if (rdt.currentProfile.RecordMappings == null)
            {
                tempRecordMappingAdded            = true;
                rdt.currentProfile.RecordMappings = new List <RecordMapping>();
                RecordMapping rd = new RecordMapping {
                    SourceRecordId = Guid.Empty, TargetRecordId = Guid.Empty
                };
                rdt.currentProfile.RecordMappings.Add(rd);
            }
            rm = rdt.currentProfile.RecordMappings;

            InitializeComponent();

            dataGridView1.AutoGenerateColumns = false;

            //Setup Entities Combobox Binding source
            List <string> entitiesList = new List <string>();

            foreach (EnvEntity ee in rdt.es.Entities)
            {
                entitiesList.Add(ee.EntityName);
            }
            BindingSource bindingSourceEntities = new BindingSource();

            bindingSourceEntities.DataSource = entitiesList;
            DataGridViewComboBoxColumn ColumnEntities = (DataGridViewComboBoxColumn)dataGridView1.Columns[0];

            ColumnEntities.DataSource = bindingSourceEntities;

            dataGridView1.DataSource = rm;

            //Cleanup temporary record mapping
            if (tempRecordMappingAdded)
            {
                rm.RemoveAt(0);
                dataGridView1.DataSource = null;
                dataGridView1.DataSource = rm;
            }
        }
예제 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RecordsMapping"/> class.
        /// </summary>
        /// <param name="rdt">The RDT.</param>
        public RecordsMapping(ReferenceDataTransporter rdt)
        {
            this.rdt = rdt;

            //Strange datagridview behaviour fix
            bool tempRecordMappingAdded = false;

            if (rdt.currentProfile.RecordMappings == null)
            {
                tempRecordMappingAdded = true;
                rdt.currentProfile.RecordMappings = new List<RecordMapping>();
                RecordMapping rd = new RecordMapping { SourceRecordId = Guid.Empty, TargetRecordId = Guid.Empty };
                rdt.currentProfile.RecordMappings.Add(rd);
            }
            rm = rdt.currentProfile.RecordMappings;

            InitializeComponent();

            dataGridView1.AutoGenerateColumns = false;

            //Setup Entities Combobox Binding source
            List<string> entitiesList = new List<string>();

            foreach (EnvEntity ee in rdt.es.Entities)
                entitiesList.Add(ee.EntityName);
            BindingSource bindingSourceEntities = new BindingSource();
            bindingSourceEntities.DataSource = entitiesList;
            DataGridViewComboBoxColumn ColumnEntities = (DataGridViewComboBoxColumn)dataGridView1.Columns[0];
            ColumnEntities.DataSource = bindingSourceEntities;

            dataGridView1.DataSource = rm;

            //Cleanup temporary record mapping
            if (tempRecordMappingAdded)
            {
                rm.RemoveAt(0);
                dataGridView1.DataSource = null;
                dataGridView1.DataSource = rm;
            }
        }
        /// <summary>
        /// Maps the records.
        /// </summary>
        /// <param name="profile">The profile.</param>
        /// <param name="entity">The entity.</param>
        /// <returns>The Mapped Record</returns>
        public Entity MapRecords(TransportationProfile profile, Entity entity)
        {
            if (profile.RecordMappings == null || profile.RecordMappings.Count == 0)
            {
                return(entity);
            }

            List <KeyValuePair <string, object> > kvList = new List <KeyValuePair <string, object> >();

            foreach (KeyValuePair <string, object> p in entity.Attributes)
            {
                Type t = p.Value.GetType();
                if (t.Name == "EntityReference")
                {
                    kvList.Add(p);
                }
            }

            foreach (KeyValuePair <string, object> kv in kvList)
            {
                EntityReference er = (EntityReference)kv.Value;

                RecordMapping rmList = profile.RecordMappings.Find(rm => rm.EntityName == er.LogicalName && rm.SourceRecordId == er.Id);

                if (rmList == null)
                {
                    continue;
                }

                entity[kv.Key] = new EntityReference {
                    Id = rmList.TargetRecordId, LogicalName = rmList.EntityName
                };
            }

            return(entity);
        }
예제 #6
0
        private void toolStripMenuItemAddRecordMapping_Click(object sender, EventArgs e)
        {
            dataGridView1.EndEdit();
            RecordMapping rr = new RecordMapping();
            rr.SourceRecordId = Guid.Empty;
            rr.TargetRecordId = Guid.Empty;
            rm.Add(rr);

            dataGridView1.DataSource = null;
            dataGridView1.DataSource = rm;
        }
예제 #7
0
        private void mapToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                dataGridView1.EndEdit();
                Guid SourceBUId = Guid.Empty;
                Guid TargetBUId = Guid.Empty;
                //Get Source Default Transaction Currency
                string fetchBU = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false' count='1'>
                                      <entity name='businessunit'>
                                        <attribute name='businessunitid' />
                                        <attribute name='createdon' />
                                        <order attribute='createdon' descending='false' />
                                      </entity>
                                    </fetch> ";
                MSCRMConnection connectionSource = rdt.currentProfile.getSourceConneciton();
                _serviceProxySource = cm.connect(connectionSource);

                EntityCollection resultSource = _serviceProxySource.RetrieveMultiple(new FetchExpression(fetchBU));
                foreach (var s in resultSource.Entities) { SourceBUId = (Guid)s.Attributes["businessunitid"]; }

                //Get Target Default Transaction Currency
                MSCRMConnection connectionTarget = rdt.currentProfile.getTargetConneciton();
                _serviceProxyTarget = cm.connect(connectionTarget);

                EntityCollection resultTarget = _serviceProxyTarget.RetrieveMultiple(new FetchExpression(fetchBU));
                foreach (var t in resultTarget.Entities) { TargetBUId = (Guid)t.Attributes["businessunitid"]; }

                //Add the mapping
                RecordMapping rr = new RecordMapping();
                rr.EntityName = "businessunit";
                rr.SourceRecordId = SourceBUId;
                rr.TargetRecordId = TargetBUId;
                rm.Add(rr);
                dataGridView1.DataSource = null;
                dataGridView1.DataSource = rm;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Mapping error: " + ex.Message);
            }
        }