Example #1
0
        private async Task Trigger(TriggerRule command)
        {
            var @event = SimpleMapper.Map(command, new RuleManuallyTriggered {
                RuleId = Snapshot.Id, AppId = Snapshot.AppId
            });

            await ruleEnqueuer.EnqueueAsync(Snapshot.RuleDef, Snapshot.Id, Envelope.Create(@event));
        }
        public async Task<IActionResult> TriggerRule(string app, Guid id)
        {
            var command = new TriggerRule { RuleId = id };

            await CommandBus.PublishAsync(command);

            return NoContent();
        }
Example #3
0
        private async Task <object?> Trigger(TriggerRule command)
        {
            await EnsureLoadedAsync();

            var @event = SimpleMapper.Map(command, new RuleManuallyTriggered {
                RuleId = Snapshot.Id, AppId = Snapshot.AppId
            });

            await ruleEnqueuer.Enqueue(Snapshot.RuleDef, Snapshot.Id, Envelope.Create(@event));

            return(null);
        }
 protected Mechanic(long skillId, string inGameName, MechanicPlotlySetting plotlySetting, string shortName, string description, string fullName, int internalCoolDown, List <MechanicChecker> conditions, TriggerRule rule)
 {
     InGameName       = inGameName;
     SkillId          = skillId;
     PlotlySetting    = plotlySetting;
     ShortName        = shortName;
     FullName         = fullName;
     Description      = description;
     InternalCooldown = internalCoolDown;
     ShowOnTable      = true;
     _triggerConditions.AddRange(conditions);
     _triggerRule = rule;
 }
        public void RunWithArguments(Document doc, NameValueMap map)
        {
            using (new HeartBeat())
            {
                var rootDir = System.IO.Directory.GetCurrentDirectory();
                if (doc == null)
                {
                    ActivateDefaultProject(rootDir);
                    //doc = inventorApplication.Documents.Open(map.Item["_1"]);
                }

                var drawingExtensions = new List <string> {
                    ".idw", ".dwg"
                };
                var      oldVersion = @"oldversions\";
                string[] drawings   = System.IO.Directory.GetFiles(rootDir, "*.*", System.IO.SearchOption.AllDirectories)
                                      .Where(file => drawingExtensions.IndexOf(System.IO.Path.GetExtension(file.ToLower())) >= 0 &&
                                             !file.ToLower().Contains(oldVersion)).ToArray();

                if (drawings.Length == 0)
                {
                    return;
                }

                var drawingsPath = System.IO.Path.Combine(rootDir, "drawing");
                System.IO.Directory.CreateDirectory(drawingsPath);

                foreach (var filePath in drawings)
                {
                    LogTrace($"Updating drawing {filePath}");
                    var drawingDocument = inventorApplication.Documents.Open(filePath);
                    LogTrace("Drawing opened");

                    // Drawing may contain iLogic rules, trigger them if needed
                    LogTrace("Triggering drawing rules");
                    TriggerRule.Trigger(drawingDocument, "iTrigger0");

                    drawingDocument.Update2(true);
                    LogTrace("Drawing updated");
                    drawingDocument.Save2(true);
                    LogTrace("Drawing saved");
                    // copy to new place with keeping the folder structure
                    var pathInArchive = filePath.Substring(rootDir.Length + 1);
                    pathInArchive = pathInArchive.Substring(pathInArchive.IndexOf(System.IO.Path.DirectorySeparatorChar) + 1);
                    var destPath = System.IO.Path.Combine(drawingsPath, pathInArchive);
                    System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(destPath));
                    LogTrace($"Copy {pathInArchive} to {destPath}");
                    System.IO.File.Copy(filePath, destPath);
                }
            }
        }
Example #6
0
        public async Task Trigger_should_invoke_rule_enqueue_but_not_change_snapshot()
        {
            var command = new TriggerRule();

            await ExecuteCreateAsync();

            var result = await sut.ExecuteAsync(CreateRuleCommand(command));

            Assert.Null(result.Value);

            A.CallTo(() => ruleEnqueuer.Enqueue(sut.Snapshot.RuleDef, sut.Id,
                                                A <Envelope <IEvent> > .That.Matches(x => x.Payload is RuleManuallyTriggered)))
            .MustHaveHappened();
        }
Example #7
0
        public async Task Trigger_should_invoke_rule_enqueue_but_not_change_snapshot()
        {
            var command = new TriggerRule();

            await ExecuteCreateAsync();

            await PublishAsync(command);

            Assert.Equal(0, sut.Version);

            A.CallTo(() => ruleEnqueuer.EnqueueAsync(sut.Snapshot.RuleDef, sut.Snapshot.Id,
                                                     A <Envelope <IEvent> > .That.Matches(x => x.Payload is RuleManuallyTriggered)))
            .MustHaveHappened();
        }
        public void RunWithArguments(Document doc, NameValueMap map)
        {
            using (new HeartBeat())
            {
                var dir = System.IO.Directory.GetCurrentDirectory();
                if (doc == null)
                {
                    ActivateDefaultProject(dir);
                    doc = inventorApplication.Documents.Open(map.Item["_1"]);
                }
                var fullFileName = doc.FullFileName;
                var path         = System.IO.Path.GetFullPath(fullFileName);
                var fileName     = System.IO.Path.GetFileNameWithoutExtension(fullFileName);
                var drawing      = inventorApplication.DesignProjectManager.ResolveFile(path, fileName + ".idw");
                LogTrace("Looking for drawing: " + fileName + ".idw " + "inside: " + path + " with result: " + drawing);
                if (drawing == null)
                {
                    drawing = inventorApplication.DesignProjectManager.ResolveFile(path, fileName + ".dwg");
                    LogTrace("Looking for drawing: " + fileName + ".dwg " + "inside: " + path + " with result: " + drawing);
                }

                if (drawing != null)
                {
                    LogTrace("Found drawing to export at: " + drawing);
                    var drawingDocument = inventorApplication.Documents.Open(drawing);
                    LogTrace("Drawing opened");

                    // Drawing may contain iLogic rules, trigger them if needed
                    LogTrace("Triggering drawing rules");
                    TriggerRule.Trigger(drawingDocument, "iTrigger0");

                    drawingDocument.Update2(true);
                    LogTrace("Drawing updated");
                    drawingDocument.Save2(true);
                    LogTrace("Drawing saved");
                    var pdfPath = System.IO.Path.Combine(dir, "Drawing.pdf");
                    LogTrace("Exporting drawing to: " + pdfPath);
                    ExportIDWToPDF(drawingDocument, pdfPath);
                    //drawingDocument.SaveAs(pdfPath, true);
                    LogTrace("Drawing exported");
                }
            }
        }
Example #9
0
        /// <summary>
        /// NOTE:
        /// AssemblyPath and ActivityName should be manually specified by developers
        /// For TriggerRule table, PK is [Name & MajorVersion & MinorVersion]
        /// </summary>
        void SeedRuleSet()
        {
            // use assembly path to construct WorkflowAssemblyPath.
            var path = HttpContext.Current.ApplicationInstance.Server.MapPath("/");

            string[] names = Assembly.GetExecutingAssembly().GetManifestResourceNames();
            foreach (string name in names)
            {
                if (name.StartsWith(@"WuKeSong.KnowledgeBase.RuleSet"))
                {
                    if (name.Contains(@"Trigger"))
                    {
                        String str = ResourceHelper.GetEmbededResourceFileAsString(name);
                        var    doc = new XmlDocument();
                        doc.LoadXml(str);
                        var nodes = doc.GetElementsByTagName("RuleSet");
                        foreach (XmlNode node in nodes)
                        {
                            TriggerRule rule = new TriggerRule()
                            {
                                Name         = node.Attributes["Name"].InnerText,
                                AssemblyPath = path + ConfigurationManager.AppSettings["WorkflowAssemblyPath"],
                                ActivityName = ConfigurationManager.AppSettings["WorkflowActivityName"],
                                TimeStamp    = System.DateTime.Now,
                                RuleSet      = node.OuterXml,
                                Status       = EnumItemStatus.Effective.ToString(),
                                PPV          = EnumPPVLevel.Probable.ToString()
                            };
                            db.TriggerRule.Add(rule);
                            rule.ClinicalProblemDefinition = db.ClinicalProblemDefinition.FirstOrDefault(x => x.Name == rule.Name);
                            db.SaveChanges();
                        }
                    }
                    else if (name.Contains(@"Handler"))
                    {
                        String str = ResourceHelper.GetEmbededResourceFileAsString(name);
                    }
                }
            }
        }
Example #10
0
 public EnemyCastStartMechanic(long skillId, string inGameName, MechanicPlotlySetting plotlySetting, string shortName, string description, string fullName, int internalCoolDown, List <MechanicChecker> conditions, TriggerRule rule) : base(skillId, inGameName, plotlySetting, shortName, description, fullName, internalCoolDown, conditions, rule)
 {
     IsEnemyMechanic = true;
 }
Example #11
0
 public EnemyCastStartMechanic(long skillId, string inGameName, MechanicPlotlySetting plotlySetting, string shortName, int internalCoolDown, List <MechanicChecker> conditions, TriggerRule rule) : this(skillId, inGameName, plotlySetting, shortName, shortName, shortName, internalCoolDown, conditions, rule)
 {
 }
 public PlayerBoonRemoveMechanic(long skillId, string inGameName, MechanicPlotlySetting plotlySetting, string shortName, string description, string fullName, int internalCoolDown, List <MechanicChecker> conditions, TriggerRule rule) : base(skillId, inGameName, plotlySetting, shortName, description, fullName, internalCoolDown, conditions, rule)
 {
 }
 public FirstHitSkillOnPlayerMechanic(long skillId, string inGameName, MechanicPlotlySetting plotlySetting, string shortName, int internalCoolDown, List <MechanicChecker> conditions, TriggerRule rule) : this(skillId, inGameName, plotlySetting, shortName, shortName, shortName, internalCoolDown, conditions, rule)
 {
 }