コード例 #1
0
        private void btnLoad_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrWhiteSpace(cmbEndpoint.Text))
            {
                return;
            }

            AbstractFileEasyEndpoint endpoint = GetEndpoint();

            if (endpoint == null)
            {
                return;
            }
            if (!endpoint.CanFunction())
            {
                return;
            }

            using (EndpointFilesForm epfForm = new EndpointFilesForm())
            {
                epfForm.LoadEndPoint(endpoint, cmbEndpoint.Text);
                if (epfForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    txtFileName.Text = epfForm.FileName;
                }
            }
        }
コード例 #2
0
        private AbstractFileEasyEndpoint GetEndpoint()
        {
            AbstractFileEasyEndpoint endpoint = null;

            if ((cmbEndpoint.SelectedItem != null) && (ClientConfiguration.Endpoints.Find(ep => ep.ActionName == cmbEndpoint.SelectedItem.ToString()) != null))
            {
                endpoint = (AbstractFileEasyEndpoint)ClientConfiguration.Endpoints.Find(ep => ep.ActionName == cmbEndpoint.SelectedItem.ToString()).CreateEndpoint();
            }
            return(endpoint);
        }
コード例 #3
0
 public void LoadEndPoint(AbstractFileEasyEndpoint aep, string endpointName)
 {
     Endpoint             = aep;
     lblEndpointName.Text = endpointName;
 }
コード例 #4
0
        public void LoadDataToGridView()
        {
            if (stopWatch.IsRunning)
            {
                stopWatch.Stop();
            }
            if ((tabDataSource.SelectedTab == tabDatasourceText) && (txtTextContents.TextLength == 0))
            {
                return;
            }
            if ((tabDataSource.SelectedTab == tabDatasourceFile) && (txtFileName.TextLength == 0))
            {
                return;
            }
            if ((tabDataSource.SelectedTab == tabDatasourceDatabase) && (String.IsNullOrWhiteSpace(cmbDatasource.Text)))
            {
                return;
            }
            AbstractFileEasyEndpoint endpoint = null;

            if (tabDataSource.SelectedTab == tabDatasourceFile)
            {
                endpoint = GetEndpoint();
                if (endpoint == null)
                {
                    return;
                }
                if (endpoint.GetList(txtFileName.Text).Length == 0)
                {
                    return;
                }
            }
            stopWatch.Restart();
            intAutoNumber      = 0;
            this.UseWaitCursor = true;
            Application.DoEvents();
            lblRecordCount.Text   = "";
            txtRegexContents.Text = "";
            cmbTableName.Items.Clear();
            AbstractContentExtractor extractor = null;

            if ((chkUseTextExtractor.Checked) && (EasyETLEnvironment.Extractors.Find(e => e.DisplayName == cbTextExtractor.Text) != null))
            {
                extractor = (AbstractContentExtractor)Activator.CreateInstance(EasyETLEnvironment.Extractors.Find(e => e.DisplayName == cbTextExtractor.Text).Class);
            }
            try
            {
                EasyXmlDocument xDoc = new EasyXmlDocument();
                xDoc.OnProgress += xDoc_OnProgress;
                if (tabDataSource.SelectedTab == tabDatasourceDatabase)
                {
                    DatasourceEasyParser dbep = null;
                    if ((cmbDatasource.SelectedItem != null) && (ClientConfiguration.Datasources.Find(ds => ds.ActionName == cmbDatasource.SelectedItem.ToString()) != null))
                    {
                        dbep = ClientConfiguration.Datasources.Find(ds => ds.ActionName == cmbDatasource.SelectedItem.ToString()).CreateDatasource();
                        if (chkHasMaxRows.Checked)
                        {
                            dbep.MaxRecords = Convert.ToInt64(nudMaxRows.Value);
                        }
                        xDoc.LoadXml(dbep.Load(txtDatabaseQuery.Text).OuterXml);
                    }
                }
                else
                {
                    AbstractEasyParser ep = null;
                    if (ClientConfiguration.Parsers.Where(p => p.ActionName == cmbParserProfile.Text).Count() > 0)
                    {
                        ep = ClientConfiguration.Parsers.Find(p => p.ActionName == cmbParserProfile.Text).CreateParser();
                    }

                    if ((ep == null) && (EasyETLEnvironment.Parsers.Where(p => p.DisplayName == cmbParserProfile.Text).Count() > 0))
                    {
                        ClassMapping parserClassMapping = EasyETLEnvironment.Parsers.Where(p => p.DisplayName == cmbParserProfile.Text).First();
                        ep = (AbstractEasyParser)Activator.CreateInstance(parserClassMapping.Class);
                    }

                    if (ep != null)
                    {
                        ep.ProgressInterval = 100;
                        if (chkHasMaxRows.Checked)
                        {
                            ep.MaxRecords = Convert.ToInt64(nudMaxRows.Value);
                        }
                        if (!String.IsNullOrWhiteSpace(txtOnLoadContents.Text))
                        {
                            ep.OnLoadSettings = txtOnLoadContents.Text.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                        }
                        if ((tabDataSource.SelectedTab == tabDatasourceFile))
                        {
                            Stream fileStream = endpoint.GetStream(txtFileName.Text);
                            if (extractor != null)
                            {
                                extractor.FileName = txtFileName.Text;
                            }
                            xDoc.Load(fileStream, ep, extractor);
                        }
                        else
                        {
                            xDoc.LoadStr(txtTextContents.Text, ep, extractor);
                        }
                        txtExceptions.Text = "";
                        if ((ep != null) && (ep.Exceptions.Count > 0))
                        {
                            MessageBox.Show("There were " + ep.Exceptions.Count + " Exceptions while loading the document");
                            foreach (MalformedLineException mep in ep.Exceptions)
                            {
                                txtExceptions.Text += String.Format("(Line {0} - {1}", mep.LineNumber, mep.Message) + Environment.NewLine;
                            }
                        }
                    }
                }
                ezDoc = xDoc;
                try
                {
                    TransformDataFromEzDoc();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error Transforming document." + Environment.NewLine + ex.Message);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error loading contents..." + Environment.NewLine + ex.Message);
            }
            endpoint           = null;
            this.UseWaitCursor = false;
        }