Exemplo n.º 1
0
        public RulePointContext(RulePoint rulePoint, RulePointContext parentContext, RuleConfigContext ruleConfigContext)
            : base(rulePoint.Name, parentContext, ruleConfigContext)
        {
            if (rulePoint == null)
            {
                throw new ArgumentNullException("rulePoint");   // NOXLATE
            }

            _displayName = rulePoint.DisplayName;
            UpdateDisplayTexts();

            _signature = rulePoint.Signature;

            if (_signature != null)
            {
                DeleteContentOperation = new OperationContext(
                    Properties.Resources.DeleteRulePointDisplayName,
                    new RelayCommand(obj => DeleteContent()));
                CreateContentOperation = new OperationContext(
                    Properties.Resources.CreateRuleContentDisplayName,
                    new RelayCommand(obj => CreateContent()));
                CreateNamedRuleOperation = new OperationContext(
                    Properties.Resources.CreateNewSubruleDisplayName,
                    new RelayCommand(obj => CreateNewNamedRule(Properties.Resources.DefaultNewSubruleName)));
                CopyOperation = new OperationContext(
                    Properties.Resources.CopyRulePointDisplayName,
                    new RelayCommand(obj => CopyToClipboard(), obj => HasContent));
                PasteNamedRuleOperation = new OperationContext(
                    Properties.Resources.PasteNamedRuleDisplayName,
                    new RelayCommand(obj => PasteAsNamedRule(), obj => CanPasteNamedRule()));
            }
        }
Exemplo n.º 2
0
        public override RuleEditingContext GetEditingContext()
        {
            var       ruleManager = RuleAppExtension.RuleManagerInstance;
            RulePoint rulePoint   = ruleManager.GetRulePoint(Path);

            return(new RuleEditingContext(rulePoint.Signature));
        }
        public override void UpdateSelectItems()
        {
            SelectItems.Clear();
            pathToSelectItemMap.Clear();
            RuleEditingContext context = Parent.RuleEditingContext;

            if (context == null)
            {
                return;
            }

            IEnumerable <NamedRule> namedRules = context.GetNamedRuleActivities();

            foreach (var namedRule in namedRules)
            {
                SelectItem newItem = new SelectItem(namedRule.Name, namedRule.DisplayName, namedRule);
                RulePoint  parent  = namedRule.Parent;
                // Build the hierarchy.
                HierarchicalSelectItem parentSelectItem = GetSelectItem(namedRule.Parent);
                parentSelectItem.Children.Add(newItem);
            }

            var    ruleManager = context.GetRuleSignature().Owner;
            string rootPath    = ruleManager.RootRulePoint.Path;

            if (pathToSelectItemMap.ContainsKey(rootPath))
            {
                var rootItem = pathToSelectItemMap[rootPath];
                foreach (var selectItem in rootItem.Children)
                {
                    SelectItems.Add(selectItem);
                }
            }
        }
Exemplo n.º 4
0
        public static RulePoint AddEmployeePoint(string name, decimal value, bool final = false)
        {
            var res = new RulePoint {
                Name = name, Value = value, Final = final
            };

            Utils.Res.Results.Add(res);
            return(res);
        }
Exemplo n.º 5
0
        private string CreateDefaultContent()
        {
            RulePoint rulePoint = GetRulePoint();

            Debug.Assert(rulePoint != null && rulePoint.Signature != null);
            DynamicActivity activity = rulePoint.Signature.CreateDefaultRoutine();

            activity.Name = RuleBase.RuleClassName;
            ActivitySerializer serializer = new ActivitySerializer();

            return(serializer.Serialize(activity));
        }
Exemplo n.º 6
0
        public static RulePoint AddEmployeePoint(JobPosition job, string name, decimal value, bool final = false)
        {
            var res = new RulePoint {
                Name = name, Value = value, Final = final
            };

            if (!Utils.Res.JobResults.Any(j => j.Key == job.DictionaryName))
            {
                Utils.Res.JobResults.Add(job.DictionaryName, new JobPositionResult());
            }
            Utils.Res.JobResults[job.DictionaryName].Results.Add(res);
            return(res);
        }
Exemplo n.º 7
0
 public static RulePoint AddCalculationPoint(string name, decimal value, bool final = false)
 {
     try
     {
         var res = new RulePoint {
             Name = name, Value = value, Final = final
         };
         Utils.Res.CalculationPoints.Add(res);
         return(res);
     }
     catch (Exception ex)
     {
         throw exceptionConvertor(ex, "اضافه کردن  مقدار محاسبه با عنوان " + name);
     }
 }
Exemplo n.º 8
0
        public static RulePoint AddEmployeePoint(JobPosition job, KeyValuePair <JobIndex, Dictionary <Employee, List <Inquiry> > > index,
                                                 string name, decimal value, bool final = false)
        {
            var res = new RulePoint {
                Name = name, Value = value, Final = final
            };

            if (!Utils.Res.JobResults.Any(j => j.Key == job.DictionaryName))
            {
                Utils.Res.JobResults.Add(job.DictionaryName, new JobPositionResult());
            }
            if (!Utils.Res.JobResults[job.DictionaryName].IndexResults.Any(j => j.Key == index.Key.DictionaryName))
            {
                Utils.Res.JobResults[job.DictionaryName].IndexResults.Add(index.Key.DictionaryName, new List <RulePoint>());
            }
            Utils.Res.JobResults[job.DictionaryName].IndexResults[index.Key.DictionaryName].Add(res);
            return(res);
        }
Exemplo n.º 9
0
 public static RulePoint GetPoint(CalculationData data, JobPosition job, string indexName, string name)
 {
     try
     {
         RulePoint res = null;
         if (data.Points.JobResults.ContainsKey(job.DictionaryName))
         {
             if (data.Points.JobResults[job.DictionaryName].IndexResults.ContainsKey(indexName))
             {
                 res = data.Points.JobResults[job.DictionaryName].IndexResults[indexName].SingleOrDefault(j => j.Name == name);
             }
         }
         return(res);
     }
     catch (Exception ex)
     {
         throw exceptionConvertor(ex, name);
     }
 }
Exemplo n.º 10
0
 public static RulePoint GetPoint(JobPosition job, KeyValuePair <JobIndex, Dictionary <Employee, List <Inquiry> > > index, string name)
 {
     try
     {
         RulePoint res = null;
         if (Utils.Res.JobResults.ContainsKey(job.DictionaryName))
         {
             if (Utils.Res.JobResults[job.DictionaryName].IndexResults.ContainsKey(index.Key.DictionaryName))
             {
                 res =
                     Utils.Res.JobResults[job.DictionaryName].IndexResults[index.Key.DictionaryName]
                     .SingleOrDefault(j => j.Name == name);
             }
         }
         return(res);
     }
     catch (Exception ex)
     {
         throw exceptionConvertor(ex, name);
     }
 }
Exemplo n.º 11
0
        public void ConfigureRule()
        {
            InitializeRule();

            ((RuleLibrary)RuleManagerInstance.Storage).Load();

            // Create a default rule
            RulePoint rp = RuleManagerInstance.GetRulePoint("/PipeRule");

            if (!rp.HasActivity)
            {
                rp.CreateDefaultWorkflow();
            }

            System.Windows.Application app    = new System.Windows.Application();
            RuleConfigDialog           dialog = RuleConfigDialog.GetInstance();

            dialog.SelectedRulePath = "/PipeRule";
            app.Run(dialog);

            ((RuleLibrary)RuleManagerInstance.Storage).Save();
        }
Exemplo n.º 12
0
 public override void Commit()
 {
     if (String.IsNullOrEmpty(Text))
     {
         // If the content is empty, we should remove content from rule storage.
         RulePoint rulePoint = GetRulePoint();
         Debug.Assert(rulePoint != null);
         rulePoint.Delete();
     }
     else
     {
         // Save the content.
         AudActivitySerializer serializer = new AudActivitySerializer();
         using (StringReader sr = new StringReader(Text))
         {
             DynamicActivity da          = serializer.Deserialize(sr, typeof(DynamicActivity)) as DynamicActivity;
             var             ruleManager = RuleAppExtension.RuleManagerInstance;
             var             rulePoint   = ruleManager.GetRulePoint(Path);
             rulePoint.Save(da);
         }
     }
     IsDirty = false;
 }
Exemplo n.º 13
0
 public void RemoveRulePointWorkflow(RulePoint rulePoint)
 {
     _activities.Remove(rulePoint.ActivityID);
 }
Exemplo n.º 14
0
 public void SetRulePointWorkflow(RulePoint rulePoint, DynamicActivity workflow)
 {
     _activities[rulePoint.ActivityID] = workflow;
 }