Exemple #1
0
        private void tsbImportNN_Click(object sender, EventArgs e)
        {
            if (txtFilePath.Text.Length == 0)
                return;

            listLog.Items.Clear();

            var settings = new ImportFileSettings
            {
                FirstEntity = ((EntityInfo)cbbFirstEntity.SelectedItem).Metadata.LogicalName,
                FirstAttributeIsGuid = rdbFirstGuid.Checked,
                FirstAttributeName = ((AttributeInfo)cbbFirstEntityAttribute.SelectedItem).Metadata.LogicalName,
                Relationship = ((RelationshipInfo)cbbRelationship.SelectedItem).Metadata.SchemaName,
                SecondEntity = ((EntityInfo)cbbSecondEntity.SelectedItem).Metadata.LogicalName,
                SecondAttributeIsGuid = rdbSecondGuid.Checked,
                SecondAttributeName = ((AttributeInfo)cbbSecondEntityAttribute.SelectedItem).Metadata.LogicalName,
            };

            WorkAsync(new WorkAsyncInfo
            {
                Message = "Importing many to many relationship records...",
                AsyncArgument = new object[] { settings, txtFilePath.Text },
                Work = (bw, evt) =>
                {
                    var innerSettings = (ImportFileSettings)((object[])evt.Argument)[0];
                    var filePath = ((object[])evt.Argument)[1].ToString();
                    var ie = new ImportEngine(filePath, this.Service, innerSettings);
                    ie.RaiseError += ie_RaiseError;
                    ie.RaiseSuccess += ie_RaiseSuccess;
                    ie.Import();
                },
                PostWorkCallBack = evt => { }
            });
        }
Exemple #2
0
        private void tsbExport_Click(object sender, EventArgs e)
        {
            var sfd = new SaveFileDialog { Title = "Select where to save the file", Filter = "Csv file|*.csv" };
            if (sfd.ShowDialog(ParentForm) != DialogResult.OK)
            {
                return;
            }

            listLog.Items.Clear();

            var settings = new ImportFileSettings
            {
                FirstEntity = ((EntityInfo)cbbFirstEntity.SelectedItem).Metadata.LogicalName,
                FirstAttributeIsGuid = rdbFirstGuid.Checked,
                FirstAttributeName = ((AttributeInfo)cbbFirstEntityAttribute.SelectedItem).Metadata.LogicalName,
                Relationship = ((RelationshipInfo)cbbRelationship.SelectedItem).Metadata.IntersectEntityName,
                SecondEntity = ((EntityInfo)cbbSecondEntity.SelectedItem).Metadata.LogicalName,
                SecondAttributeIsGuid = rdbSecondGuid.Checked,
                SecondAttributeName = ((AttributeInfo)cbbSecondEntityAttribute.SelectedItem).Metadata.LogicalName,
            };

            WorkAsync(new WorkAsyncInfo
            {
                Message = "Exporting many to many relationship records...",
                AsyncArgument = new object[] { settings, sfd.FileName },
                Work = (bw, evt) =>
                {
                    var innerSettings = (ImportFileSettings)((object[])evt.Argument)[0];
                    var filePath = ((object[])evt.Argument)[1].ToString();
                    var ee = new ExportEngine(filePath, this.Service, innerSettings);
                    ee.RaiseError += ee_RaiseError;
                    ee.Export();
                },
                PostWorkCallBack = evt => { }
            });
        }
Exemple #3
0
 public ImportEngine(string filePath, IOrganizationService service, ImportFileSettings settings)
 {
     this.filePath = filePath;
     this.service = service;
     this.settings = settings;
 }
        private void tsbImportNN_Click(object sender, EventArgs e)
        {
            infoPanel = InformationPanel.GetInformationPanel(this, "Importing many to many relationships...", 340, 150);

            listLog.Items.Clear();

            var settings = new ImportFileSettings
            {
                FirstEntity = ((EntityInfo)cbbFirstEntity.SelectedItem).Metadata.LogicalName,
                FirstAttributeIsGuid = rdbFirstGuid.Checked,
                FirstAttributeName = ((AttributeInfo)cbbFirstEntityAttribute.SelectedItem).Metadata.LogicalName,
                Relationship = ((RelationshipInfo)cbbRelationship.SelectedItem).Metadata.SchemaName,
                SecondEntity = ((EntityInfo)cbbSecondEntity.SelectedItem).Metadata.LogicalName,
                SecondAttributeIsGuid = rdbSecondGuid.Checked,
                SecondAttributeName = ((AttributeInfo)cbbSecondEntityAttribute.SelectedItem).Metadata.LogicalName,
            };

            var importWorker = new BackgroundWorker();
            importWorker.DoWork += importWorker_DoWork;
            importWorker.RunWorkerCompleted += importWorker_RunWorkerCompleted;
            importWorker.RunWorkerAsync(new object[]{settings, txtFilePath.Text});
        }
        private void tsbExport_Click(object sender, EventArgs e)
        {
            var sfd = new SaveFileDialog {Title = "Select where to save the file", Filter="Csv file|*.csv"};
            if (sfd.ShowDialog(ParentForm) != DialogResult.OK)
            {
                return;
            }

            infoPanel = InformationPanel.GetInformationPanel(this, "Exporting many to many relationship records...", 340, 150);

            listLog.Items.Clear();

            var settings = new ImportFileSettings
            {
                FirstEntity = ((EntityInfo)cbbFirstEntity.SelectedItem).Metadata.LogicalName,
                FirstAttributeIsGuid = rdbFirstGuid.Checked,
                FirstAttributeName = ((AttributeInfo)cbbFirstEntityAttribute.SelectedItem).Metadata.LogicalName,
                Relationship = ((RelationshipInfo)cbbRelationship.SelectedItem).Metadata.IntersectEntityName,
                SecondEntity = ((EntityInfo)cbbSecondEntity.SelectedItem).Metadata.LogicalName,
                SecondAttributeIsGuid = rdbSecondGuid.Checked,
                SecondAttributeName = ((AttributeInfo)cbbSecondEntityAttribute.SelectedItem).Metadata.LogicalName,
            };

            var exportWorker = new BackgroundWorker();
            exportWorker.DoWork += exportWorker_DoWork;
            exportWorker.RunWorkerCompleted += exportWorker_RunWorkerCompleted;
            exportWorker.RunWorkerAsync(new object[] { settings, sfd.FileName });
        }
Exemple #6
0
        private void tsbImportNN_Click(object sender, EventArgs e)
        {
            listLog.Items.Clear();

            var settings = new ImportFileSettings
            {
                FirstEntity = ((EntityInfo)cbbFirstEntity.SelectedItem).Metadata.LogicalName,
                FirstAttributeIsGuid = rdbFirstGuid.Checked,
                FirstAttributeName = ((AttributeInfo)cbbFirstEntityAttribute.SelectedItem).Metadata.LogicalName,
                Relationship = ((RelationshipInfo)cbbRelationship.SelectedItem).Metadata.SchemaName,
                SecondEntity = ((EntityInfo)cbbSecondEntity.SelectedItem).Metadata.LogicalName,
                SecondAttributeIsGuid = rdbSecondGuid.Checked,
                SecondAttributeName = ((AttributeInfo)cbbSecondEntityAttribute.SelectedItem).Metadata.LogicalName,
            };

            WorkAsync("Importing many to many relationships...",
                evt =>
                {
                    var innerSettings = (ImportFileSettings)((object[])evt.Argument)[0];
                    var filePath = ((object[])evt.Argument)[1].ToString();
                    var ie = new ImportEngine(filePath, service, innerSettings);
                    ie.RaiseError += ie_RaiseError;
                    ie.RaiseSuccess += ie_RaiseSuccess;
                    ie.Import();
                },
                evt =>{},
                new object[] { settings, txtFilePath.Text });
        }