public List <IdpeRule> GetApplicationRuleSets(int dataSourceId) { List <IdpeRule> idpeRules = new List <IdpeRule>(); string commandText = "select rs.[Id],rs.[Name],rs.[Description],rs.[Xaml],rsa.[Priority],rsa.[RuleSetType],rs.[CreatedTS],rs.[CreatedBy] from [IdpeRule] rs " + " inner join IdpeRuleDataSource rsa on rs.Id = rsa.RuleId and DataSourceId = " + dataSourceId; DataTable table = CoreDatabaseObjects.Instance.ExecuteCommand(commandText); if (table == null || table.Rows.Count == 0) { return(idpeRules); } foreach (DataRow row in table.Rows) { IdpeRule rule = new IdpeRule(); rule.Id = (int)row["Id"].ToString().ParseInt(); rule.Name = row["Name"].ToString(); rule.Description = row["Description"] != DBNull.Value ? row["Description"].ToString() : null; rule.Xaml = row["Xaml"] != DBNull.Value ? row["Xaml"].ToString() : null; rule.Priority = row["Priority"] != DBNull.Value ? row["Priority"].ToString().ParseInt() : null; rule.RuleSetType = row["RuleSetType"] != DBNull.Value ? row["RuleSetType"].ToString().ParseInt() : null; rule.CreatedTS = (DateTime)(row["CreatedTS"] != DBNull.Value ? row["CreatedTS"].ToString().ParseDateTime() : DateTime.MinValue); rule.CreatedBy = row["CreatedBy"] != DBNull.Value ? row["CreatedBy"].ToString() : null; idpeRules.Add(rule); } return(idpeRules); }
void ExportRuleNames(int dataSourceId) { string sqlStatement = "select r.Name, rds.Priority, rds.RuleSetType "; sqlStatement += "from IdpeRule r "; sqlStatement += "inner join IdpeRuleDataSource rds on r.Id = rds.RuleId "; sqlStatement += "where rds.DataSourceId = " + dataSourceId; DataTable table = CoreDatabaseObjects.Instance.ExecuteCommand(sqlStatement); List <IdpeRule> rules = new List <IdpeRule>(); foreach (DataRow row in table.Rows) { IdpeRule rule = new IdpeRule(); rule.Name = row["Name"].ToString(); rule.Priority = row["Priority"] != DBNull.Value ? row["Priority"].ToString().ParseInt() : null; rule.RuleSetType = row["RuleSetType"] != DBNull.Value ? row["RuleSetType"].ToString().ParseInt() : null; rules.Add(rule); } //following logic implemented to have rule names sequentially ExportRuleNames(rules, RuleSetTypes.PreValidate); ExportRuleNames(rules, RuleSetTypes.RowPreparing); ExportRuleNames(rules, RuleSetTypes.RowPrepared); ExportRuleNames(rules, RuleSetTypes.RowValidate); ExportRuleNames(rules, RuleSetTypes.PostValidate); }
public List <IdpeRule> GetRules(int dataSourceId) { List <IdpeRule> rules = new List <IdpeRule>(); string qry = "select r.Id,name,description,xaml,rds.[priority],rds.rulesettype from IdpeRule r "; qry += "inner join IdpeRuleDataSource rds on rds.ruleId = r.id "; qry += "where datasourceId = " + dataSourceId; DataTable table = Core.Data.CoreDatabaseObjects.Instance.ExecuteCommand(qry); foreach (DataRow row in table.Rows) { IdpeRule rule = new IdpeRule(); rule.Id = (int)row["Id"].ToString().ParseInt(); rule.Name = row["name"].ToString(); rule.Description = row["description"].ToString(); rule.Xaml = row["xaml"].ToString(); rule.Priority = row["priority"].ToString().ParseInt(); rule.RuleSetType = row["rulesettype"].ToString().ParseInt(); rules.Add(rule); } return(rules); }
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e) { bool itemSelected = listView.SelectedItems.Count > 0 ? true : false; copyToToolStripMenuItem.Enabled = itemSelected; deleteToolStripMenuItem.Enabled = itemSelected; btnDelete.Enabled = itemSelected; exportToolStripMenuItem.Enabled = itemSelected; renameToolStripMenuItem.Enabled = itemSelected; if (itemSelected) { if (Information.IsInternalRule(listView.SelectedItems[0].Text)) { deleteToolStripMenuItem.Enabled = false; btnDelete.Enabled = false; } else { deleteToolStripMenuItem.Enabled = true; btnDelete.Enabled = true; } } if (listView.SelectedItems.Count == 1) { IdpeRule rule = listView.SelectedItems[0].Tag as IdpeRule; versionsToolStripMenuItem.Enabled = new Data.UtilDataManager().IsHavingVersion(VersionObjectTypes.Rule, rule.Id); compareWithPreviousVersionToolStripMenuItem.Enabled = versionsToolStripMenuItem.Enabled; } }
public IdpeRule GetRule(int ruleId) { string commandText = "select TOP 1 [Id],[Name],[Description],[Xaml],[Priority],[RuleSetType],[CreatedTS],[CreatedBy] from [IdpeRule] where [Id] = " + ruleId; DataTable table = CoreDatabaseObjects.Instance.ExecuteCommand(commandText); if (table == null || table.Rows.Count == 0) { return(null); } foreach (DataRow row in table.Rows) { IdpeRule rule = new IdpeRule(); rule.Id = (int)row["Id"].ToString().ParseInt(); rule.Name = row["Name"].ToString(); rule.Description = row["Description"] != DBNull.Value ? row["Description"].ToString() : null; rule.Xaml = row["Xaml"] != DBNull.Value ? row["Xaml"].ToString() : null; rule.Priority = row["Priority"] != DBNull.Value ? row["Priority"].ToString().ParseInt() : null; rule.RuleSetType = row["RuleSetType"] != DBNull.Value ? row["RuleSetType"].ToString().ParseInt() : null; rule.CreatedTS = (DateTime)(row["CreatedTS"] != DBNull.Value ? row["CreatedTS"].ToString().ParseDateTime() : DateTime.MinValue); rule.CreatedBy = row["CreatedBy"] != DBNull.Value ? row["CreatedBy"].ToString() : null; return(rule); } return(null); }
public List <IdpeRule> GetRules() { List <IdpeRule> idpeRules = new List <IdpeRule>(); string commandText = "select [Id],[Name],[Description],[Xaml],[Priority],[RuleSetType],[CreatedTS],[CreatedBy] from [IdpeRule] order by [Name]"; DataTable table = CoreDatabaseObjects.Instance.ExecuteCommand(commandText); if (table == null) { return(idpeRules); } foreach (DataRow row in table.Rows) { IdpeRule rule = new IdpeRule(); rule.Id = (int)row["Id"].ToString().ParseInt(); rule.Name = row["Name"].ToString(); rule.Description = row["Description"] != DBNull.Value ? row["Description"].ToString() : null; rule.Xaml = row["Xaml"] != DBNull.Value ? row["Xaml"].ToString() : null; rule.Priority = row["Priority"] != DBNull.Value ? row["Priority"].ToString().ParseInt() : null; rule.RuleSetType = row["RuleSetType"] != DBNull.Value ? row["RuleSetType"].ToString().ParseInt() : null; rule.CreatedTS = (DateTime)(row["CreatedTS"] != DBNull.Value ? row["CreatedTS"].ToString().ParseDateTime() : DateTime.MinValue); rule.CreatedBy = row["CreatedBy"] != DBNull.Value ? row["CreatedBy"].ToString() : null; idpeRules.Add(rule); } return(idpeRules); }
private bool FormAlreadyOpened(IdpeRule idperule) { bool IsAlreadyOpened = false; return(IsAlreadyOpened); }
public void CopyRule(int fromRuleId, string newRuleName) { IdpeRule rule = GetRule(fromRuleId); rule.Id = 0; rule.Name = newRuleName; Save(rule); }
public RulesExtraInformation(IdpeRule idpeRule) { InitializeComponent(); this.Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location); txtName.Text = idpeRule.Name; txtDescription.Text = idpeRule.Description; //txtDescription.SelectedText = idpeRule.Description; }
private void versionsToolStripMenuItem_Click(object sender, EventArgs e) { if (listView.SelectedItems.Count > 0) { IdpeRule rule = listView.SelectedItems[0].Tag as IdpeRule; frmVersions versions = new frmVersions(rule.Id, VersionObjectTypes.Rule); versions.ShowDialog(); } }
private void validateToolStripMenuItem_Click(object sender, EventArgs e) { if (listView.SelectedItems.Count > 0) { IdpeRule rule = listView.SelectedItems[0].Tag as IdpeRule; DataSourceValidator dataSourceValidator = new DataSourceValidator(false, rule.Id, "Attributes & Process Variables Referenced in " + rule.Name, this.Icon); dataSourceValidator.Show(); } }
private void miShowDependencies_Click(object sender, EventArgs e) { if ((selectedRuleListView != null) && (selectedRuleListView.ListView.SelectedItems.Count > 0)) { IdpeRule rule = selectedRuleListView.ListView.SelectedItems[0].Tag as IdpeRule; RuleDependencies ruleDependencies = new RuleDependencies(rule.Id); ruleDependencies.ShowDialog(); } }
private void showDependenciesToolStripMenuItem_Click(object sender, EventArgs e) { if ((listView != null) && (listView.SelectedItems.Count > 0)) { IdpeRule rule = listView.SelectedItems[0].Tag as IdpeRule; RuleDependencies ruleDependencies = new RuleDependencies(rule.Id); ruleDependencies.ShowDialog(); } }
private void DisassociateRuleFromDatabase(ListView listView, bool deleteRule) { SreDataSourceProperty.KeepVersion(this.DataSource.Id); IdpeRule rule = (IdpeRule)listView.SelectedItems[0].Tag; new Manager().DeleteRuleFromDataSource(DataSource.Id, rule.Id, selectedRuleSetType, deleteRule); listView.Items.Remove(listView.SelectedItems[0]); Bind(); }
private void btnAdd_Click(object sender, EventArgs e) { IdpeRule idpeRule = new IdpeRule(); this.Cursor = Cursors.WaitCursor; FormAlreadyOpened(idpeRule); RuleEditor.MainWindow ruleEditor = new RuleEditor.MainWindow(idpeRule, Common.RuleSetTypes.RowPrepared); ElementHost.EnableModelessKeyboardInterop(ruleEditor); ruleEditor.RuleForm = this; this.Cursor = Cursors.Default; ruleEditor.Show(); }
private void renameToolStripMenuItem_Click(object sender, EventArgs e) { if (listView.SelectedItems.Count > 0) { IdpeRule rule = listView.SelectedItems[0].Tag as IdpeRule; InputBox inputBox = new InputBox(rule.Name, "New Name", "Rename Rule", this.Icon); if (inputBox.ShowDialog() == System.Windows.Forms.DialogResult.OK) { new Manager().RenameRule(rule.Id, inputBox.TheInput); RefreshRules(); } } }
private void miRename_Click(object sender, EventArgs e) { if ((selectedRuleListView.ListView != null) && (selectedRuleListView.ListView.SelectedItems.Count > 0)) { IdpeRule rule = selectedRuleListView.ListView.SelectedItems[0].Tag as IdpeRule; InputBox inputBox = new InputBox(rule.Name, "New Name", "Rename Rule"); inputBox.txtInput.TextChanged += new EventHandler(txtInput_TextChanged); if (inputBox.ShowDialog() == System.Windows.Forms.DialogResult.OK) { new Manager().RenameRule(rule.Id, inputBox.TheInput); Bind(); } } }
private void ValidateVersion(IdpeVersion version) { string allErrors = string.Empty; if (version.Type == (int)VersionObjectTypes.Unknown) { allErrors += "Version type cannot be unknown!" + Environment.NewLine; } if (version.ReferenceId == 0) { allErrors += "Version must have a reference Id!" + Environment.NewLine; } else { switch ((VersionObjectTypes)version.Type) { case VersionObjectTypes.Attribute: IdpeAttribute attribute = GetAttribute(version.ReferenceId); if (attribute.AttributeId == 0) { allErrors += "The INSERT statement conflicted with the FOREIGN KEY constraint. The conflict occurred in database, table IdpeAttribute, column 'Id'." + Environment.NewLine; } break; case VersionObjectTypes.DataSource: string dataSourceName = GetApplicationName(version.ReferenceId); if (string.IsNullOrEmpty(dataSourceName)) { allErrors += "The INSERT statement conflicted with the FOREIGN KEY constraint. The conflict occurred in database, table IdpeDataSource, column 'Id'." + Environment.NewLine; } break; case VersionObjectTypes.Rule: IdpeRule rule = GetRule(version.ReferenceId); if (rule.Id == 0) { allErrors += "The INSERT statement conflicted with the FOREIGN KEY constraint. The conflict occurred in database, table IdpeRule, column 'Id'." + Environment.NewLine; } break; } } if (!string.IsNullOrEmpty(allErrors)) { throw new Exception(allErrors); } }
private void compareWithPreviousVersionToolStripMenuItem_Click(object sender, EventArgs e) { if (listView.SelectedItems.Count > 0) { IdpeRule rule = listView.SelectedItems[0].Tag as IdpeRule; List <IdpeVersion> lastVersions = new Manager().GetVersions(VersionObjectTypes.Rule, rule.Id); if (lastVersions.Count >= 2) { VersionComparer.Compare(VersionObjectTypes.Rule, rule.Name, lastVersions[0], lastVersions[1]); } else { MessageBox.Show("Could not retrieve last 2 versions!", "Comparison Tool", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } }
protected override void Execute(CodeActivityContext context) { Job job = context.GetValue(this.Job); WorkerData data = context.GetValue(this.Data); IdpeRule rule = null; int ruleId = context.GetValue(this.RuleId); string ruleName = context.GetValue(this.RuleName); if (ruleId > 0) { rule = new Manager().GetRule(ruleId); } else if (!string.IsNullOrEmpty(ruleName)) { rule = new Manager().GetRule(ruleName); } if (rule != null) { Stream stream = new MemoryStream(ASCIIEncoding.Default.GetBytes(rule.Xaml)); DynamicActivity activity = ActivityXamlServices.Load(stream) as DynamicActivity; IDictionary <string, object> outArgs = null; Dictionary <string, object> inArgs = context.GetValue(this.InArgs); if (job != null) { inArgs.Add("Job", job); } else { inArgs.Add("Data", data); } WorkflowInvoker invoker = new WorkflowInvoker(activity); //outArgs = invoker.Invoke(inArgs); invoker.Invoke(inArgs); //context.SetValue(OutArgs, outArgs); } else { job.TraceError("Could not execute rule {0}, as it is not defined yet!", ruleName); } }
void ExportRules(int dataSourceId) { string sqlStatement = "select r.Name, r.Description, r.Xaml, rds.Priority, rds.RuleSetType "; sqlStatement += "from IdpeRule r "; sqlStatement += "inner join IdpeRuleDataSource rds on r.Id = rds.RuleId "; sqlStatement += "where rds.DataSourceId = " + dataSourceId; DataTable table = CoreDatabaseObjects.Instance.ExecuteCommand(sqlStatement); foreach (DataRow row in table.Rows) { IdpeRule rule = new IdpeRule(); rule.Name = row["Name"].ToString(); rule.Description = row["Description"] != DBNull.Value ? row["Description"].ToString() : null; rule.Xaml = row["Xaml"] != DBNull.Value ? row["Xaml"].ToString() : null; rule.Priority = row["Priority"] != DBNull.Value ? row["Priority"].ToString().ParseInt() : null; rule.RuleSetType = row["RuleSetType"] != DBNull.Value ? row["RuleSetType"].ToString().ParseInt() : null; Rules.Add(rule); } }
public bool Save(string dataSourceName) { string dynamicXamlBody = string.Empty; bool allGood = true; List <Control> mappers = new List <Control>(pnlMain.Controls.Cast <Control>()); mappers.Reverse(); foreach (Control ctl in mappers) { if (ctl is AttributeMapper) { AttributeMapper attributeMapper = (AttributeMapper)ctl; if (attributeMapper.ValidateData() == false) { attributeMapper.Focus(); allGood = false; } else { dynamicXamlBody += attributeMapper.XamlString + Environment.NewLine; } } } if (allGood) { InputBox inputBox = new InputBox(dataSourceName + " - Map", "Enter Rule Name", "Save Rule", this.ParentForm.Icon); if (inputBox.ShowDialog() == System.Windows.Forms.DialogResult.OK) { IdpeRule rule = new IdpeRule(); rule.Name = inputBox.TheInput; rule.Description = inputBox.TheInput + " was created by wizard"; rule.Xaml = string.Format(XamlBody, rule.Name, dynamicXamlBody); new Manager().Save(rule); } } return(allGood); }
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(); } }
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); }
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); }
public virtual string DeployRule(SreEnvironmentConfig toEnvironment, IdpeRule rule) { Packet.DataSourceBundle = new DataSourceBundle(); Packet.DataSourceBundle.Rules.Add(rule); return(Constants.success); }
public MainWindow(IdpeRule idpeRule, RuleSetTypes ruleSetType) { if (!String.IsNullOrEmpty(idpeRule.Name)) { string sname = idpeRule.Name.Replace("-", "").Replace(" ", ""); this.WindowName = sname; } this._TemplateWithJob = System.IO.Path.Combine(Information.TempDirectoryIdpe, "WithJob.xml"); this._TemplateWithData = System.IO.Path.Combine(Information.TempDirectoryIdpe, "WithData.xml"); if (!File.Exists(_TemplateWithJob)) { using (Stream stream = Assembly.GetExecutingAssembly() .GetManifestResourceStream("Eyedia.IDPE.Interface.RuleEditor.Templates.WithJob.xml")) { using (StreamReader reader = new StreamReader(stream)) { using (StreamWriter sw = new StreamWriter(_TemplateWithJob)) { sw.Write(reader.ReadToEnd()); sw.Close(); } } } } if (!File.Exists(_TemplateWithData)) { using (Stream stream = Assembly.GetExecutingAssembly() .GetManifestResourceStream("Eyedia.IDPE.Interface.RuleEditor.Templates.WithData.xml")) { using (StreamReader reader = new StreamReader(stream)) { using (StreamWriter sw = new StreamWriter(_TemplateWithData)) { sw.Write(reader.ReadToEnd()); sw.Close(); } } } } //when new reference added, .new file will be created if (File.Exists(_TemplateWithJob + ".New")) { if (File.Exists(_TemplateWithJob)) { File.Delete(_TemplateWithJob); } File.Copy(_TemplateWithJob + ".New", _TemplateWithJob); File.Delete(_TemplateWithJob + ".New"); } if (File.Exists(_TemplateWithData + ".New")) { if (File.Exists(_TemplateWithData)) { File.Delete(_TemplateWithData); } File.Copy(_TemplateWithData + ".New", _TemplateWithData); File.Delete(_TemplateWithData + ".New"); } _idpeRule = idpeRule; _ruleSetTemplate = ruleSetType; TransactionMode = idpeRule.Id == 0 ? "INSERT" : "UPDATE"; InitializeComponent(); LoadDocument(); }
public bool SaveSreRule(IdpeRule idpeRule) { new Manager().Save(idpeRule); ServiceCommunicator.ClearRule(idpeRule.Id, idpeRule.Name); return(true); }
/// <summary> /// Deploys data source into specific targetConfigironment /// </summary> /// <param name="toConfig">Target environment</param> /// <param name="rule">The rule object</param> public override string DeployRule(SreEnvironmentConfig toEnvironment, IdpeRule rule) { base.DeployRule(toEnvironment, rule); return(CreateAndCopyFile(toEnvironment, Packet) ? Constants.success : Constants.failed); }
private void btnOK_Click(object sender, EventArgs e) { SelectedRule = (IdpeRule)lstBoxRuleSet.SelectedItem; this.Close(); }