Beispiel #1
0
 public ValidateAsyncObjectList(IValidateListBaseServices <ValidateAsyncObjectList, IValidateAsyncObject> services,
                                IShortNameRule <ValidateAsyncObjectList> shortNameRule,
                                IFullNameRule <ValidateAsyncObjectList> fullNameRule
                                ) : base(services)
 {
     RuleManager.AddRules(shortNameRule, fullNameRule);
     ShortNameRule = shortNameRule;
     FullNameRule  = fullNameRule;
 }
Beispiel #2
0
 public EditPerson(IEditBaseServices <EditPerson> services,
                   IShortNameRule <EditPerson> shortNameRule,
                   IFullNameRule <EditPerson> fullNameRule) : base(services)
 {
     RuleManager.AddRules(shortNameRule, fullNameRule);
     InitiallyDefined = new List <int>()
     {
         1, 2, 3
     };
 }
Beispiel #3
0
        private void UpdateRules()
        {
            var updateError = false;

            tsMessage.Text = "Committing changes...";
            Application.DoEvents();

            if (tbAccountName.Text != null)
            {
                var dataTable = dsRules.Tables["Rules"].GetChanges();
                if (dataTable != null)
                {
                    rm.Url      = UrlBuilder.RuleUrl(tbAccountName.Text, tbStreamName.Text);
                    rm.Username = tbUsername.Text;
                    rm.Password = tbPassword.Text;

                    var deleteRules = new List <Gnip.Utilities.JsonClasses.Rule>();
                    var addRules    = new List <Gnip.Utilities.JsonClasses.Rule>();


                    var deletedRows = dataTable.GetChanges(DataRowState.Deleted);

                    if (deletedRows != null)
                    {
                        deleteRules.AddRange(from DataRow dRow in deletedRows.Rows
                                             select new Gnip.Utilities.JsonClasses.Rule()
                        {
                            value = dRow["value", DataRowVersion.Original].ToString(),
                            tag   = dRow["tag", DataRowVersion.Original].ToString()
                        });
                    }

                    var addedRows = dataTable.GetChanges(DataRowState.Added);

                    if (addedRows != null)
                    {
                        addRules.AddRange(from DataRow dRow in addedRows.Rows
                                          select new Gnip.Utilities.JsonClasses.Rule()
                        {
                            value = dRow["value"].ToString(),
                            tag   = dRow["tag"].ToString()
                        });
                    }

                    var modifiedRows = dataTable.GetChanges(DataRowState.Modified);
                    if (modifiedRows != null)
                    {
                        deleteRules.AddRange(from DataRow dRow in modifiedRows.Rows
                                             select new Gnip.Utilities.JsonClasses.Rule()
                        {
                            value = dRow["value", DataRowVersion.Original].ToString(),
                            tag   = dRow["tag", DataRowVersion.Original].ToString()
                        });

                        addRules.AddRange(from DataRow dRow in modifiedRows.Rows
                                          select new Gnip.Utilities.JsonClasses.Rule()
                        {
                            value = dRow["value"].ToString(),
                            tag   = dRow["tag"].ToString()
                        });
                    }

                    if (deleteRules.Count > 0)
                    {
                        if (rm.DeleteRules(deleteRules))
                        {
                            tsMessage.Text = "Rules Deleted";
                        }
                        else
                        {
                            tsMessage.Text = rm.ErrorMessage;
                            updateError    = true;
                        }
                    }

                    if (addRules.Count > 0)
                    {
                        if (rm.AddRules(addRules))
                        {
                            tsMessage.Text += " Rules Deleted";
                        }
                        else
                        {
                            tsMessage.Text = rm.ErrorMessage;
                            updateError    = true;
                        }
                    }
                } // dataTable.GetChanges

                if (!updateError)
                {
                    tsMessage.Text = "Rule changes commited";
                }

                dsRules.AcceptChanges();

                DataLoading = false;
                // dgRules.Show();
                tsMessage.Text = "Rules loaded.";
            }
            else
            {
                tsMessage.ForeColor = Color.Red;
                tsMessage.Text      = "No Rules URL set.  Check settings.";
            }
        }
Beispiel #4
0
 public EditPersonList(IEditListBaseServices <EditPersonList, IEditPerson> services,
                       IShortNameRule <EditPersonList> shortNameRule,
                       IFullNameRule <EditPersonList> fullNameRule) : base(services)
 {
     RuleManager.AddRules(shortNameRule, fullNameRule);
 }