Esempio n. 1
0
 public void Dispose()
 {
     this._dbApp           = null;
     this.Attributes       = null;
     this.AttributesSystem = null;
     //this.DataContainerValidator = null;
 }
Esempio n. 2
0
        private static void ExportDataSource(IdpeDataSource dataSource, string fileName)
        {
            if (File.Exists(fileName))
            {
                if (MessageBox.Show("The file " + fileName + " already exists. Do you want to overwrite the file?", "File Already Exists",
                                    MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    File.Delete(fileName);
                }
                else
                {
                    return;
                }
            }

            try
            {
                DataSourceBundle dsb = new DataSourceBundle();
                dsb.Export(dataSource.Id, fileName);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 3
0
 private void tsbShowDataSource_Click(object sender, EventArgs e)
 {
     if (_SreDataSource != null)
     {
         DataSource = _SreDataSource;
     }
 }
Esempio n. 4
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if ((lbSystemDataSources.Items.Count == 0) || (mAddMode))
     {
         if (!string.IsNullOrEmpty(txtSearch.Text))
         {
             IdpeDataSource newDs = new IdpeDataSource();
             newDs.Name     = txtSearch.Text;
             newDs.IsActive = true;
             newDs.IsSystem = true;
             int newDsId = new Manager().Save(newDs);
             newDs.Id = newDsId;
             SelectedSystemDataSource = newDs;
             ToggleMode();
         }
     }
     else
     {
         if (lbSystemDataSources.SelectedItems.Count > 0)
         {
             SelectedSystemDataSource = (IdpeDataSource)lbSystemDataSources.SelectedItems[0];
         }
         this.Close();
     }
 }
Esempio n. 5
0
        void Init(int?dataSourceId)
        {
            if ((dataSourceId != null) &&
                (dataSourceId != 0))
            {
                _DataSource        = new Manager().GetDataSourceDetails((int)dataSourceId);
                lblFrom.Text       = _DataSource.Name;
                txtExportFile.Text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), _DataSource.Name + ".idpex");
            }
            if (_Exporting)
            {
                this.Text       = "Export Data Source";
                label1.Visible  = true;
                label3.Text     = "To";
                lblFrom.Visible = true;
            }
            else
            {
                this.Text          = "Import Data Source";
                label1.Visible     = false;
                label3.Text        = "From";
                lblFrom.Visible    = false;
                txtExportFile.Text = "";

                label3.Top        = label1.Top;
                txtExportFile.Top = label1.Top;
                btnBrowse.Top     = label1.Top;
                label1.Visible    = false;
                lblFrom.Visible   = false;
                pnlText.Height    = pnlText.Height / 2;
                this.Height       = this.Height - pnlText.Height;
            }
        }
Esempio n. 6
0
 private void cbDataSources_SelectedIndexChanged(object sender, EventArgs e)
 {
     SelectedDataSource = cbDataSources.SelectedItem as IdpeDataSource;
     if (FormActivated)
     {
         BindData();
     }
 }
Esempio n. 7
0
 public RenameDataSource(IdpeDataSource dataSource)
 {
     InitializeComponent();
     ;
     DataSource        = dataSource;
     this.Text         = "Rename DataSource - " + dataSource.Name;
     pictureBox1.Image = System.Drawing.SystemIcons.Warning.ToBitmap();
 }
Esempio n. 8
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (lbDataSources.SelectedItems.Count > 0)
     {
         SelectedDataSource = (IdpeDataSource)lbDataSources.SelectedItems[0];
     }
     this.Close();
 }
Esempio n. 9
0
 public frmCopyDataSource(IdpeDataSource fromDataSource)
 {
     InitializeComponent();
     this.Icon               = Icon.ExtractAssociatedIcon(System.Reflection.Assembly.GetExecutingAssembly().Location);
     DataManager             = new Manager();
     FromDataSource          = fromDataSource;
     lblFrom.Text            = FromDataSource.Name;
     txtApplicationName.Text = FromDataSource.Name + "_New";
     Bind();
 }
Esempio n. 10
0
 private void btnCancel_Click(object sender, EventArgs e)
 {
     if (mAddMode)
     {
         ToggleMode();
     }
     else
     {
         SelectedSystemDataSource = null;
         this.Close();
     }
 }
Esempio n. 11
0
        void OnDataSourceAddButtonClicked(object sender, EventArgs e)
        {
            IdpeDataSource newDs = new IdpeDataSource();

            newDs.IsSystem           = false;
            newDs.IsActive           = true;
            newDs.DataFeederType     = (int)DataFeederTypes.PullLocalFileSystem;
            newDs.DataFormatType     = (int)DataFormatTypes.Delimited;
            newDs.Delimiter          = ",";
            newDs.SystemDataSourceId = 0;
            newDs.OutputType         = (int)OutputTypes.Delimited;
            newDs.PusherType         = (int)PusherTypes.None;
            m_dm_Property.DataSource = newDs;
            m_dm_Property.ToggleDataSource(false);
            m_dm_Property.propertyGrid.Focus();
        }
Esempio n. 12
0
        /// <summary>
        /// Keeps pulling from database (MS SQL, MS SQL CE, Oracle)
        /// </summary>
        /// <param name="dataSource">The data source object</param>
        public SqlWatcher(IdpeDataSource dataSource)
        {
            this.DataSource = new DataSource(dataSource.Id, string.Empty);
            //DataSourceName = dataSource.Name;
            ProcessingBy = dataSource.ProcessingBy;
            if (string.IsNullOrEmpty(ProcessingBy))
            {
                ProcessingBy = dataSource.Name;
            }

            string strinterval = DataSource.Keys.GetKeyValue(IdpeKeyTypes.SqlWatchInterval);
            int    interval    = 0;

            int.TryParse(strinterval, out interval);
            if (interval <= 0)
            {
                interval = 2;
            }
            this.Interval = interval;

            string appPullFolder   = IdpeConfigurationSection.CurrentConfig.LocalFileWatcher.DirectoryPull + "\\" + dataSource.Id;
            string appOutputFolder = IdpeConfigurationSection.CurrentConfig.LocalFileWatcher.DirectoryOutput + "\\" + dataSource.Id + "\\" + DateTime.Now.ToString("yyyyMMdd");

            this.DataSourceParameters = new Dictionary <string, object>();

            DataSourceParameters.Add("DataSourceId", dataSource.Id);
            DataSourceParameters.Add("PullFolder", appPullFolder);
            DataSourceParameters.Add("OutputFolder", appOutputFolder);
            DataSourceParameters.Add("ProcessingBy", dataSource.ProcessingBy);

            this.ReturnType = DataSource.Keys.GetKeyValue(IdpeKeyTypes.PullSqlReturnType);
            if (this.ReturnType == "I")
            {
                this.InterfaceName = DataSource.Keys.GetKeyValue(IdpeKeyTypes.PullSqlInterfaceName);
                if ((!string.IsNullOrEmpty(this.InterfaceName)) &&
                    (Type.GetType(this.InterfaceName) != null))
                {
                    object objInputFileGenerator = Activator.CreateInstance(Type.GetType(this.InterfaceName), this);
                    this.InputFileGenerator = (InputFileGenerator)objInputFileGenerator;
                }
            }
        }
Esempio n. 13
0
        private void BindData()
        {
            Manager        manager = new Manager();
            IdpeDataSource ds      = manager.GetDataSourceDetails(DataSourceId);

            if ((ds.Delimiter != null) &&
                (ds.Delimiter.ToLower() == "\t"))
            {
                cmbDelmiter.Text = "Tab";
            }
            else
            {
                cmbDelmiter.Text = ds.Delimiter;
            }

            List <IdpeKey> keys = manager.GetKeys(DataSourceId);

            rtbXslt.Text = keys.GetKeyValue(IdpeKeyTypes.EDIX12Xslt);
            SyntaxHighLighter.HighLight(rtbXslt, _blueKeyWords, _redKeyWords);

            string strHeader = keys.GetKeyValue(IdpeKeyTypes.IsFirstRowHeader);

            if (!string.IsNullOrEmpty(strHeader))
            {
                bool boolVal = false;
                bool.TryParse(strHeader, out boolVal);
                chkFileHasHeader.Checked = boolVal;
            }
            chkRenameHeaders.Enabled = chkFileHasHeader.Checked;

            string strRenCol = keys.GetKeyValue(IdpeKeyTypes.RenameColumnHeader);

            if (!string.IsNullOrEmpty(strRenCol))
            {
                bool boolVal = false;
                bool.TryParse(strRenCol, out boolVal);
                chkRenameHeaders.Checked = boolVal;
            }
        }
Esempio n. 14
0
 private void Bind(int selectedSystemDataSourceId = 0)
 {
     lbSystemDataSources.DataSource    = new Manager().GetDataSources(2).OrderBy(ds => ds.Name).ToList();
     lbSystemDataSources.DisplayMember = "Name";
     if (selectedSystemDataSourceId > 0)
     {
         int  i     = 0;
         bool found = false;
         for (i = 0; i < lbSystemDataSources.Items.Count; i++)
         {
             IdpeDataSource ds = lbSystemDataSources.Items[i] as IdpeDataSource;
             if ((ds != null) && (ds.Id == selectedSystemDataSourceId))
             {
                 found = true;
                 break;
             }
         }
         if (found)
         {
             lbSystemDataSources.SelectedIndex = i;
         }
     }
 }
Esempio n. 15
0
        public void KeepVersionInternal(Manager manager, VersionObjectTypes versionObjectType, int referenceId)
        {
            if (referenceId == 0)
            {
                return;
            }

            IdpeVersion version = GetCurrentVersion(versionObjectType, referenceId);

            if (version == null)
            {
                return;
            }

            version.Version     = manager.GetLatestVersionNumber(versionObjectType, referenceId) + 1;
            version.Type        = (int)versionObjectType;
            version.ReferenceId = referenceId;

            switch (versionObjectType)
            {
            case VersionObjectTypes.DataSource:
                IdpeDataSource ds = manager.GetDataSourceDetails(referenceId);
                version.Data      = new Binary(GZipArchive.Compress(new DataSourceBundle().Export(referenceId, false).GetByteArray()));
                version.CreatedTS = ds.CreatedTS;
                break;

            case VersionObjectTypes.Rule:
                IdpeRule        rule  = manager.GetRule(referenceId);
                DataSourcePatch patch = new DataSourcePatch();
                patch.Rules.Add(rule);
                version.Data      = new Binary(GZipArchive.Compress(patch.Export().GetByteArray()));
                version.CreatedTS = rule.CreatedTS;
                break;
            }
            manager.Save(version);
        }
Esempio n. 16
0
        private void CopyDataSource()
        {
            Copying = true;
            toolStripProgressBar1.Visible = true;
            toolStripProgressBar1.Increment(10);
            toolStripStatusLabel1.Text = "Copying datsource...";
            Application.DoEvents();
            IdpeDataSource newDataSource = new IdpeDataSource();

            newDataSource.IsActive                   = true;
            newDataSource.Name                       = txtApplicationName.Text;
            newDataSource.Description                = FromDataSource.Description;
            newDataSource.IsSystem                   = FromDataSource.IsSystem;
            newDataSource.DataFeederType             = FromDataSource.DataFeederType;
            newDataSource.DataFormatType             = FromDataSource.DataFormatType;
            newDataSource.Delimiter                  = FromDataSource.Delimiter;
            newDataSource.SystemDataSourceId         = FromDataSource.SystemDataSourceId;
            newDataSource.DataContainerValidatorType = FromDataSource.DataContainerValidatorType;
            newDataSource.OutputType                 = FromDataSource.OutputType;
            newDataSource.OutputWriterTypeFullName   = FromDataSource.OutputWriterTypeFullName;
            newDataSource.PlugInsType                = FromDataSource.PlugInsType;
            newDataSource.ProcessingBy               = FromDataSource.ProcessingBy;
            newDataSource.PusherType                 = FromDataSource.PusherType;
            newDataSource.PusherTypeFullName         = FromDataSource.PusherTypeFullName;
            newDataSource.Id = DataManager.Save(newDataSource);
            NewDataSourceId  = newDataSource.Id;

            toolStripProgressBar1.Increment(20);
            toolStripStatusLabel1.Text = "Copying attributes...";
            Application.DoEvents();

            List <IdpeAttributeDataSource> sadss = new List <IdpeAttributeDataSource>();

            foreach (TreeNode node in treeView.Nodes[0].Nodes)
            {
                if (node.Checked)
                {
                    sadss.Add((IdpeAttributeDataSource)node.Tag);
                    toolStripStatusLabel1.Text = "Copying attribute..." + node.Text;
                    Application.DoEvents();
                }
            }

            DataManager.SaveAssociations(NewDataSourceId, sadss);
            toolStripProgressBar1.Increment(20);
            toolStripStatusLabel1.Text = "Copying keys...";
            Application.DoEvents();

            #region Copy Internal Keys
            //we have to copy internal keys anyways...

            List <IdpeKey> keys = DataManager.GetApplicationKeys(FromDataSource.Id, false);
            foreach (IdpeKey key in keys)
            {
                if (((IdpeKeyTypes)key.Type) != IdpeKeyTypes.Custom)
                {
                    DataManager.Save(key, newDataSource.Id);
                    toolStripStatusLabel1.Text = "Copying key..." + key.Name;
                    Application.DoEvents();
                }
            }
            #endregion Copy Internal Keys

            #region Copy External Keys
            foreach (TreeNode node in treeView.Nodes[1].Nodes)
            {
                if (node.Checked)
                {
                    IdpeKey ckey = (IdpeKey)node.Tag;
                    DataManager.Save(ckey, newDataSource.Id);
                    toolStripStatusLabel1.Text = "Copying key..." + ckey.Name;
                    Application.DoEvents();
                }
            }
            #endregion Copy External Keys

            toolStripProgressBar1.Increment(20);
            toolStripStatusLabel1.Text = "Copying rules...";
            Application.DoEvents();
            string newRuleName = string.Empty;


            foreach (TreeNode node in treeView.Nodes[2].Nodes)
            {
                if (node.Checked)
                {
                    IdpeRule rule = node.Tag as IdpeRule;
                    rule.Name        = rule.Name + "_" + newDataSource.Id;
                    rule.Description = rule.Description == null ? string.Empty : rule.Description;
                    rule.Id          = 0;
                    int newRuleId = DataManager.Save(rule);

                    IdpeRuleDataSource idpeRuleDataSource = new IdpeRuleDataSource();
                    idpeRuleDataSource.Priority     = (int)rule.Priority;
                    idpeRuleDataSource.RuleSetType  = (int)rule.RuleSetType;
                    idpeRuleDataSource.IsActive     = true;
                    idpeRuleDataSource.RuleId       = newRuleId;
                    idpeRuleDataSource.DataSourceId = newDataSource.Id;
                    DataManager.SaveRuleAssociationDuringCopy(idpeRuleDataSource);

                    toolStripStatusLabel1.Text = "Copying rule..." + rule.Name;
                    Application.DoEvents();
                }
            }

            toolStripProgressBar1.Increment(30);
            toolStripStatusLabel1.Text = "Done";
            txtApplicationName.Enabled = false;
            btnOK.Enabled = true;
            Copying       = false;
            Application.DoEvents();

            toolStripProgressBar1.Value = toolStripProgressBar1.Maximum;
            Application.DoEvents();
        }
Esempio n. 17
0
        public void InsertSystemObjects()
        {
            string sdsSqlStatement = "INSERT INTO [IdpeDataSource]([Id],[Name],[Description],[IsSystem],[IsActive],[CreatedTS],[CreatedBy]) VALUES(-99,'Global Datasource','Global datasource to keep global keys, connectionstrings',1,1, getdate(),'System')";
            string dsSqlStatement  = "INSERT INTO [IdpeDataSource] ([Id],[Name],[Description],[IsSystem],[DataFeederType],[DataFormatType],[Delimiter],[SystemDataSourceId],[OutputType],[IsActive],[CreatedTS],[CreatedBy]) VALUES(100,'System Data Source','System data source to handle deployment restart etc',0,2,99,',',-99,1,1,getdate(),'System')";

            IDal          dal        = new DataAccessLayer(EyediaCoreConfigurationSection.CurrentConfig.Database.DatabaseType).Instance;
            IDbConnection connection = dal.CreateConnection(ConfigurationManager.ConnectionStrings[Constants.ConnectionStringName].ToString());

            connection.Open();
            IDbTransaction transaction = dal.CreateTransaction(connection);

            //inserting default groups
            var gAdmin = CoreDatabaseObjects.Instance.Groups.Where(g => g.Name.Equals("Admins", StringComparison.OrdinalIgnoreCase)).SingleOrDefault();

            if (gAdmin == null)
            {
                CoreDatabaseObjects.Instance.ExecuteStatement("insert into [Group](Name, Description, CreatedTs, CreatedBy, Source) values ('Admins', 'Default administrator groups', getdate(), 'System', 'Installer')", dal, connection, transaction);
            }

            var gUsers = CoreDatabaseObjects.Instance.Groups.Where(g => g.Name.Equals("Users", StringComparison.OrdinalIgnoreCase)).SingleOrDefault();

            if (gUsers == null)
            {
                CoreDatabaseObjects.Instance.ExecuteStatement("insert into [Group](Name, Description, CreatedTs, CreatedBy, Source) values ('Users', 'Default user groups', getdate(), 'System', 'Installer')", dal, connection, transaction);
            }

            string sqlStatement = string.Empty;

            try
            {
                IdpeDataSource sds = GetDataSourceDetails(-99);
                if (sds == null)
                {
                    CoreDatabaseObjects.Instance.ExecuteStatement(sdsSqlStatement, dal, connection, transaction);
                }
                IdpeDataSource ds = GetDataSourceDetails(100);
                if (ds == null)
                {
                    CoreDatabaseObjects.Instance.ExecuteStatement(dsSqlStatement, dal, connection, transaction);
                }

                sdInsertAttribute(string.Empty, 1, dal, connection, transaction);
                sdInsertAttribute("DeploymentResult", 2, dal, connection, transaction);
                sdInsertAttribute("DeploymentTrace", 3, dal, connection, transaction);
                sdInsertRule(dal, connection, transaction);
                dsInsertKeys(dal, connection, transaction);
                transaction.Commit();
            }
            catch (Exception ex)
            {
                transaction.Rollback();
                Trace.TraceInformation(ex.ToString());
                Trace.Flush();
                throw new Exception(ex.Message, ex);
            }
            finally
            {
                if (connection.State == ConnectionState.Open)
                {
                    connection.Close();
                }
                connection.Dispose();
                transaction.Dispose();
            }
        }
Esempio n. 18
0
        private void Bind()
        {
            if (DataSource == null)
            {
                tableLayoutPanel1.Visible = false;
                return;
            }
            Manager manager = new Manager();

            IdpeDataSource sysDs = manager.GetDataSourceDetails((int)DataSource.SystemDataSourceId);

            tableLayoutPanel1.Visible = true;
            switch (DataSource.DataFeederType)
            {
            case DataFeederTypes.PullLocalFileSystem:
            case DataFeederTypes.PullFtp:
            case DataFeederTypes.PullSql:
                lblDataFeeder.Text = "Pulls from";
                break;

            case DataFeederTypes.Push:
                lblDataFeeder.Text = "Hosted as Service";
                break;
            }
            LinkLabel.Link link = new LinkLabel.Link();
            link.LinkData = DataSource.LocalFileSystemFolderPullFolder;
            lblDataFeederValue.Links.Clear();
            lblDataFeederValue.Links.Add(link);
            List <string> folders = new List <string>(DataSource.LocalFileSystemFolderPullFolder.Split("\\".ToCharArray()));

            if (folders.Count >= 3)
            {
                folders = folders.Skip(Math.Max(0, folders.Count() - 3)).ToList();
            }
            else if (folders.Count >= 2)
            {
                folders = folders.Skip(Math.Max(0, folders.Count() - 2)).ToList();
            }
            else if (folders.Count >= 1)
            {
                folders = folders.Skip(Math.Max(0, folders.Count() - 1)).ToList();
            }

            lblDataFeederValue.Text = string.Empty;
            foreach (string folder in folders)
            {
                lblDataFeederValue.Text += folder + "\\";
            }

            if (DataSource.BusinessRules != null)
            {
                llPreValidate.Text  = DataSource.BusinessRules.Where(r => r.RuleSetType == RuleSetTypes.PreValidate).ToList().Count.ToString();
                llRowPreparing.Text = DataSource.BusinessRules.Where(r => r.RuleSetType == RuleSetTypes.RowPreparing).ToList().Count.ToString();
                llRowPrepared.Text  = DataSource.BusinessRules.Where(r => r.RuleSetType == RuleSetTypes.RowPrepared).ToList().Count.ToString();
                llRowValidate.Text  = DataSource.BusinessRules.Where(r => r.RuleSetType == RuleSetTypes.RowValidate).ToList().Count.ToString();
                llPostValidate.Text = DataSource.BusinessRules.Where(r => r.RuleSetType == RuleSetTypes.PostValidate).ToList().Count.ToString();
            }
            else
            {
                llPreValidate.Text  = "0";
                llRowPreparing.Text = "0";
                llRowPrepared.Text  = "0";
                llRowValidate.Text  = "0";
                llPostValidate.Text = "0";
            }

            llKeys.Text        = manager.GetDataSourceKeys(DataSourceId, true).Count.ToString();
            llPostEvents.Text  = DataSource.PusherType.ToString();
            lblSystemName.Text = sysDs != null ? sysDs.Name : string.Empty;
        }
Esempio n. 19
0
 public SreDataSourceProperty(IdpeDataSource dataSource)
     : base(dataSource)
 {
 }
Esempio n. 20
0
 public SrePropertyGrid(IdpeDataSource datasource)
 {
     this.DataSource = datasource;
     //this.DataSourceOriginal = this.DataSource.Clone();
     Assign();
 }
Esempio n. 21
0
        void OnDataSourceChanged(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            dockPanel.SuspendLayout(true);
            ListViewControl sreListView = sender as ListViewControl;

            if (sreListView != null)
            {
                if (sreListView.ListView.SelectedItems.Count > 0)
                {
                    //if (((IdpeDataSource)sreListView.ListView.SelectedItems[0].Tag).Id == 100)
                    //{
                    //    m_dm_GlobalAttributes.btnAssociateBoth.Enabled = false;
                    //    m_dm_GlobalAttributes.btnAssociateAttributeDataSource.Enabled = false;
                    //    m_dm_GlobalAttributes.btnAssociateAttributeSystemDataSource.Enabled = false;
                    //    this.Cursor = Cursors.Default;
                    //    return;
                    //}
                    //else
                    //{
                    //    m_dm_GlobalAttributes.btnAssociateBoth.Enabled = true;
                    //    m_dm_GlobalAttributes.btnAssociateAttributeDataSource.Enabled = true;
                    //    m_dm_GlobalAttributes.btnAssociateAttributeSystemDataSource.Enabled = true;
                    //}

                    if ((m_dm_Property.propertyGrid.SelectedObject != null) &&
                        (((SrePropertyGrid)m_dm_Property.propertyGrid.SelectedObject).HasChanged))
                    {
                        this.Cursor = Cursors.WaitCursor;
                        toolStripStatusLabel1.Text = "Please wait...Saving properties...";
                        Application.DoEvents();
                        ((SrePropertyGrid)m_dm_Property.propertyGrid.SelectedObject).Save();

                        toolStripStatusLabel1.Text = "Please wait...Clearing cache...";
                        Application.DoEvents();
                        if (ServiceCommunicator.ClearDataSource(SelectedDataSource.Id, string.Empty))
                        {
                            SetToolStripStatusLabel("Ready");
                        }
                        else
                        {
                            SetToolStripStatusLabel("Failed to clear cache", true);
                        }

                        toolStripStatusLabel1.Text = "Please wait...Refresing...";
                        Application.DoEvents();
                        RefreshData();
                        if (MainWindowShown)
                        {
                            SetToolStripStatusLabel("Ready");
                        }
                        this.Cursor = Cursors.Default;
                    }

                    if (sreListView.ListView.SelectedItems.Count > 0)
                    {
                        toolStripStatusLabel1.Text = "Please wait...Refresing...";
                        Application.DoEvents();
                        if ((sreListView.DefaultItemId > 0) && (!MainWindowShown))
                        {
                            SelectedDataSource = sreListView.ListView.Items.Cast <ListViewItem>().Select(x => x.Tag).ToList().Cast <IdpeDataSource>().Where(ds => ds.Id == sreListView.DefaultItemId).SingleOrDefault();
                            if (sreListView.DefaultItem != null)
                            {
                                sreListView.DefaultItem.EnsureVisible();
                            }

                            if (SelectedDataSource == null)
                            {
                                SelectedDataSource = sreListView.ListView.Items[0].Tag as IdpeDataSource;
                            }
                        }
                        else
                        {
                            SelectedDataSource = sreListView.ListView.SelectedItems[0].Tag as IdpeDataSource;
                        }

                        m_dm_DataSources.SelectedDataSource      = SelectedDataSource;
                        m_dm_Attributes.SelectedDataSource       = SelectedDataSource;
                        m_dm_SystemAttributes.SelectedDataSource = SelectedDataSource;
                        m_dm_GlobalAttributes.SelectedDataSource = SelectedDataSource;
                        if (MainWindowShown)
                        {
                            SetToolStripStatusLabel("Ready");
                        }
                        Application.DoEvents();
                    }
                    m_dm_Attributes.DataSourceId             = SelectedDataSource.Id;
                    m_dm_SystemAttributes.SystemDataSourceId = (int)SelectedDataSource.SystemDataSourceId;
                    m_dm_Property.DataSource = SelectedDataSource;
                    SetToolStripStatusLabel("Ready");
                }
            }
            dockPanel.ResumeLayout(true, true);
            this.Cursor = Cursors.Default;
            sreListView.ListView.Focus();
        }
Esempio n. 22
0
 private void btnCancel_Click(object sender, EventArgs e)
 {
     SelectedDataSource = null;
     this.Close();
 }
Esempio n. 23
0
        /// <summary>
        /// Data source object, generally intialized by a Job
        /// </summary>
        /// <param name="id"></param>
        /// <param name="name"></param>
        public DataSource(int id, string name)
        {
            Manager am = new Manager();

            _dbApp = new IdpeDataSource();
            _dbApp = Cache.Instance.Bag[id] as IdpeDataSource;
            if (_dbApp == null)
            {
                _dbApp = Cache.Instance.Bag[name] as IdpeDataSource;
            }

            if (_dbApp == null)
            {
                if (id > 0)
                {
                    _dbApp = am.GetDataSourceDetails(id);
                    Cache.Instance.Bag.Add(id, _dbApp);
                }
                else if ((!(string.IsNullOrEmpty(name))) && (_dbApp == null))
                {
                    _dbApp = am.GetApplicationDetails(name);
                    Cache.Instance.Bag.Add(name, _dbApp);
                }
            }

            if (_dbApp != null)
            {
                this.IsValid        = true;
                this.Id             = _dbApp.Id;
                this.Name           = _dbApp.Name;
                this.DataFeederType = (DataFeederTypes)_dbApp.DataFeederType;
                this.DataFormatType = (DataFormatTypes)_dbApp.DataFormatType;

                this.Attributes = Cache.Instance.Bag[this.Id + ".attributes"] as List <IdpeAttribute>;
                if (this.Attributes == null)
                {
                    this.Attributes = am.GetAttributes(this.Id);
                    Cache.Instance.Bag.Add(this.Id + ".attributes", this.Attributes);
                }

                this.AttributesSystem = Cache.Instance.Bag[this.Id + ".attributessystem"] as List <IdpeAttribute>;
                if (this.AttributesSystem == null)
                {
                    this.AttributesSystem = am.GetAttributes((int)_dbApp.SystemDataSourceId);
                    Cache.Instance.Bag.Add(this.Id + ".attributessystem", this.AttributesSystem);
                }

                RefreshKeys();

                this.BusinessRules = Cache.Instance.Bag[this.Id + ".rules"] as BusinessRules;
                if (this.BusinessRules == null)
                {
                    InitRuleSets(am);
                    Cache.Instance.Bag.Add(this.Id + ".rules", this.BusinessRules);
                }
            }
            else
            {
                this.IsValid = false;
                this.Id      = id;
                this.Name    = name;
            }
        }