Exemple #1
0
        private void OnRuleAddClick(object sender, EventArgs e)
        {
            ListViewItem  item             = null;
            List <String> doNotIncludeList = selectedRuleListView.ListView.Items.Cast <ListViewItem>().Select(i => i.Text).ToList();

            frmSelectRule frmSelectRuleSet = new frmSelectRule(doNotIncludeList);

            if (frmSelectRuleSet.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                item     = new ListViewItem(frmSelectRuleSet.SelectedRule.Name);
                item.Tag = frmSelectRuleSet.SelectedRule;
            }

            if (item == null)
            {
                return;
            }

            int priority = selectedRuleListView.ListView.Items.Count + 1;

            item.SubItems.Add(priority.ToString());
            selectedRuleListView.ListView.Items.Add(item);

            SreDataSourceProperty.KeepVersion(this.DataSource.Id);

            IdpeRuleDataSource idpeRuleDataSource = new IdpeRuleDataSource();

            idpeRuleDataSource.DataSourceId = DataSource.Id;
            idpeRuleDataSource.RuleId       = frmSelectRuleSet.SelectedRule.Id;
            idpeRuleDataSource.Priority     = priority;
            idpeRuleDataSource.RuleSetType  = (int)selectedRuleSetType;
            new DataManager.Manager().Save(idpeRuleDataSource);
        }
Exemple #2
0
        public List <IdpeRuleDataSource> GetRuleSetApplication(int dataSourceId)
        {
            List <IdpeRuleDataSource> idpeRuleDataSources = new List <IdpeRuleDataSource>();
            string commandText = "select [RuleDataSourceId],[RuleId],[DataSourceId],[Priority],[RuleSetType],[IsActive] from [IdpeRuleDataSource] where DataSourceId = " + dataSourceId;

            DataTable table = CoreDatabaseObjects.Instance.ExecuteCommand(commandText);

            if (table == null || table.Rows.Count == 0)
            {
                return(idpeRuleDataSources);
            }

            foreach (DataRow row in table.Rows)
            {
                IdpeRuleDataSource idpeRuleDataSource = new IdpeRuleDataSource();
                idpeRuleDataSource.RuleDataSourceId = (int)row["RuleDataSourceId"].ToString().ParseInt();
                idpeRuleDataSource.RuleId           = (int)row["RuleId"].ToString().ParseInt();
                idpeRuleDataSource.DataSourceId     = (int)row["DataSourceId"].ToString().ParseInt();
                idpeRuleDataSource.Priority         = (int)row["Priority"].ToString().ParseInt();
                idpeRuleDataSource.RuleSetType      = (int)row["RuleSetType"].ToString().ParseInt();
                idpeRuleDataSource.IsActive         = row["IsActive"].ToString().ParseBool();
                idpeRuleDataSources.Add(idpeRuleDataSource);
            }
            return(idpeRuleDataSources);
        }
Exemple #3
0
        private IdpeRuleDataSource GetSreRuleDataSource(int dataSourceId, int ruleId, int ruleSetType)
        {
            IdpeRuleDataSource idpeRuleDataSource = null;
            string             commandText        = string.Format("select [RuleDataSourceId],[RuleId],[DataSourceId],[Priority],[RuleSetType],[IsActive] from [IdpeRuleDataSource] where [DataSourceId] = {0} and [RuleId] = {1} and [RuleSetType] = {2}"
                                                                  , dataSourceId, ruleId, ruleSetType);

            DataTable table = CoreDatabaseObjects.Instance.ExecuteCommand(commandText);

            if (table == null)
            {
                return(idpeRuleDataSource);
            }

            foreach (DataRow row in table.Rows)
            {
                idpeRuleDataSource = new IdpeRuleDataSource();
                idpeRuleDataSource.RuleDataSourceId = (int)row["RuleDataSourceId"].ToString().ParseInt();
                idpeRuleDataSource.RuleId           = (int)row["RuleId"].ToString().ParseInt();
                idpeRuleDataSource.DataSourceId     = (int)row["DataSourceId"].ToString().ParseInt();
                idpeRuleDataSource.Priority         = (int)row["Priority"].ToString().ParseInt();
                idpeRuleDataSource.RuleSetType      = (int)row["RuleSetType"].ToString().ParseInt();
                idpeRuleDataSource.IsActive         = row["IsActive"].ToString().ParseBool();
            }
            return(idpeRuleDataSource);
        }
Exemple #4
0
        public void SaveRuleAssociationDuringCopy(IdpeRuleDataSource ruleDataSource)
        {
            IDal          dal = new DataAccessLayer(EyediaCoreConfigurationSection.CurrentConfig.Database.DatabaseType).Instance;
            IDbConnection con = dal.CreateConnection(_ConnectionString);

            con.Open();

            string query = string.Format("INSERT INTO [IdpeRuleDataSource] ([RuleId],[DataSourceId],[Priority],[RulesetType],[IsActive]) VALUES ({0},{1},{2},{3},{4})",
                                         ruleDataSource.RuleId,
                                         ruleDataSource.DataSourceId, ruleDataSource.Priority, ruleDataSource.RuleSetType, ruleDataSource.IsActive == true ? 1 : 0);

            using (IDbCommand command = dal.CreateCommand(query, con))
            {
                command.ExecuteNonQuery();
            }
        }
Exemple #5
0
        void OnRepositioned(object sender, EventArgs e)
        {
            Manager manager = new Manager();

            for (int i = 0; i < selectedRuleListView.ListView.Items.Count; i++)
            {
                IdpeRuleDataSource idpeRuleDataSource = new IdpeRuleDataSource();
                IdpeRule           rule = selectedRuleListView.ListView.Items[i].Tag as IdpeRule;
                if (rule == null)
                {
                    rule = manager.GetRule(selectedRuleListView.ListView.Items[i].Text);
                }

                idpeRuleDataSource.DataSourceId = this.DataSource.Id;
                idpeRuleDataSource.RuleId       = rule.Id;
                idpeRuleDataSource.RuleSetType  = (int)selectedRuleSetType;
                idpeRuleDataSource.Priority     = i + 1;
                manager.Save(idpeRuleDataSource);

                selectedRuleListView.ListView.Items[i].SubItems[1].Text = (i + 1).ToString();
            }
        }
Exemple #6
0
        private void sdInsertRule(IDal dal = null, IDbConnection connection = null, IDbTransaction transaction = null)
        {
            IdpeRule rule = new IdpeRule();

            rule.Name        = "System Data Source - Map";
            rule.Description = "System data source rule mapping rule used by system. This rule cannot be deleted.";

            using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Eyedia.IDPE.DataManager." + rule.Name + ".xml"))
                using (StreamReader reader = new StreamReader(stream))
                {
                    rule.Xaml = reader.ReadToEnd();
                }

            rule.Id = Save(rule);

            IdpeRuleDataSource idpeRuleDataSource = new IdpeRuleDataSource();

            idpeRuleDataSource.DataSourceId = 100;
            idpeRuleDataSource.RuleId       = rule.Id;
            idpeRuleDataSource.Priority     = 1;
            idpeRuleDataSource.RuleSetType  = 3;
            Save(idpeRuleDataSource, dal, connection, transaction);
        }
Exemple #7
0
        void ImportRules(IDal dal, IDbConnection connection, IDbTransaction transaction, Manager manager)
        {
            string sqlStatement = string.Empty;

            foreach (IdpeRule rule in this.Rules)
            {
                if (!rule.Name.Equals("DuplicateCheck", StringComparison.OrdinalIgnoreCase))
                {
                    string userName = Information.LoggedInUser.UserName.Contains("'") ? Information.LoggedInUser.UserName.Replace("'", "''") : Information.LoggedInUser.UserName;
                    rule.Id = manager.Save(rule, dal, connection, transaction);
                }

                if (this.DataSource.Id > 0)
                {
                    IdpeRuleDataSource sra = new IdpeRuleDataSource();
                    sra.DataSourceId = this.DataSource.Id;
                    sra.RuleId       = rule.Id;
                    sra.Priority     = (int)rule.Priority;
                    sra.RuleSetType  = (int)rule.RuleSetType;
                    sra.IsActive     = true;
                    manager.Save(sra, dal, connection, transaction);
                }
            }
        }
Exemple #8
0
        public int Save(IdpeRuleDataSource ruleDataSource, IDal dal = null, IDbConnection connection = null, IDbTransaction transaction = null)
        {
            int  ruleDataSourceId = 0;
            bool localTransaction = false;

            if (dal == null)
            {
                dal        = new DataAccessLayer(EyediaCoreConfigurationSection.CurrentConfig.Database.DatabaseType).Instance;
                connection = dal.CreateConnection(_ConnectionString);
                connection.Open();
                transaction      = dal.CreateTransaction(connection);
                localTransaction = true;
            }

            try
            {
                bool               inserted       = false;
                string             query          = string.Empty;
                IdpeRuleDataSource existingObject = GetSreRuleDataSource(ruleDataSource.DataSourceId, ruleDataSource.RuleId, ruleDataSource.RuleSetType);

                if (existingObject == null)
                {
                    query = string.Format("INSERT INTO [IdpeRuleDataSource] ([RuleId],[DataSourceId],[Priority],[RulesetType],[IsActive]) VALUES ({0},{1},{2},{3},{4})",
                                          ruleDataSource.RuleId,
                                          ruleDataSource.DataSourceId, ruleDataSource.Priority, ruleDataSource.RuleSetType, ruleDataSource.IsActive == true ? 1 : 0);
                    inserted = true;
                }
                else
                {
                    ruleDataSourceId = existingObject.RuleDataSourceId;
                    query            = string.Format("update [IdpeRuleDataSource] set [Priority] = {0},[RulesetType] = {1},[IsActive] ={2} where RuleDataSourceId = {3}",
                                                     ruleDataSource.Priority, ruleDataSource.RuleSetType, ruleDataSource.IsActive == true ? 1 : 0, ruleDataSourceId);
                }

                using (IDbCommand command = dal.CreateCommand(query, connection, transaction))
                {
                    command.ExecuteNonQuery();
                }

                if (localTransaction)
                {
                    transaction.Commit();
                }

                if (inserted)
                {
                    query = string.Format("select RuleDataSourceId from IdpeRuleDataSource where [RuleId] = {0} and [DataSourceId] = {1} and [Priority] = {2} and [RulesetType] = {3}",
                                          ruleDataSource.RuleId, ruleDataSource.DataSourceId, ruleDataSource.Priority, (int)ruleDataSource.RuleSetType);

                    using (IDbCommand command = localTransaction ? dal.CreateCommand(query, connection) : dal.CreateCommand(query, connection, transaction))
                    {
                        IDataReader reader = command.ExecuteReader();
                        if (reader.Read())
                        {
                            ruleDataSourceId = int.Parse(reader[0].ToString());
                        }
                        reader.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                if (localTransaction)
                {
                    transaction.Rollback();
                }

                Trace.TraceError("Error while saving IdpeRuleDataSource " + Environment.NewLine + ex.Message + Environment.NewLine + ex.StackTrace);
                throw new Exception(ex.Message, ex);
            }
            finally
            {
                if (localTransaction)
                {
                    if (connection != null)
                    {
                        if (connection.State != System.Data.ConnectionState.Closed)
                        {
                            connection.Close();
                        }
                        connection.Dispose();
                    }
                    if (transaction != null)
                    {
                        transaction.Dispose();
                    }
                }
            }
            return(ruleDataSourceId);
        }
Exemple #9
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();
        }