示例#1
0
        /// <summary>
        /// MVC post method for update decision
        /// </summary>
        /// <param name="dmvm">Decision view model with regarding information</param>
        /// <returns>updated decision view</returns>
        public ActionResult UpdateDecision(DecisionModelVM dmvm)
        {
            IssueDecision id            = new IssueDecision();
            DecisionModel decisionModel = new DecisionModel();

            decisionModel.AlternativeId = dmvm.AlternativeId;
            decisionModel.ChangeDate    = dmvm.ChangeDate;
            decisionModel.Explanation   = dmvm.Explanation;
            decisionModel.IssueId       = dmvm.IssueId;
            id.UpdateDecision(decisionModel, GetUserIdFromClaim());

            int           issueId = decisionModel.IssueId;
            int           userId  = GetUserIdFromClaim();
            DecisionVM    dvm     = new DecisionVM();
            IssueCreating ic      = new IssueCreating();

            dvm.OldDecisions = id.GetOldDecisions(issueId, userId);
            dvm.Decision     = id.GetDecision(issueId, userId);
            dvm.Issue        = ic.GetIssue(issueId);
            var ctx2 = GlobalHost.ConnectionManager.GetHubContext <NotificationHub>();

            ctx2.Clients.All.decisionUpdated(dvm, issueId);

            return(RedirectToAction("Decision", "Issue", new { issueId = decisionModel.IssueId }));
        }
 public DecisionViewModel(IWindowManager manager)
 {
     config         = IoC.Get <ConfigViewModel>(); //we will want to use config if its loaded with data to aid our standard
     _windowMgr     = manager;
     firstDecision  = new DecisionModel();
     secondDecision = new DecisionModel();
 }
示例#3
0
        public JsonResult SetDecision(DecisionModel model)
        {
            model.attemptID     = Guid.NewGuid().ToString("N");
            model.underwriterID = this.context.UserId;

            log.Debug("Update decision for {0}.", model);

            try {
                var mdar = this.serviceClient.Instance.SetManualDecision(model);

                var reply = new {
                    error   = mdar.Map["error"],
                    warning = mdar.Map["warning"],
                };

                log.Debug(
                    "Reply on update decision for {0}: error is '{1}', warning is '{2}'.",
                    model,
                    reply.error,
                    reply.warning
                    );

                return(Json(reply));
            } catch (Exception e) {
                log.Alert(e, "Failed to set manual decision for {0}.", model);

                return(Json(new {
                    error = string.Format(
                        "Failed to apply your decision, please retry. Error code is '{0}'.",
                        model.attemptID
                        ),
                    warning = string.Empty,
                }));
            }     // try
        }         // SetDecision
        /// <inheritdoc />
        public void StoreDecision(DecisionModel decision)
        {
            this.RemoveAllOccurences(decision);

            string titre = decision.EstSupprimée ? RemovedIndicator + decision.Titre : decision.Titre;
            var    item  = new RssItem
            {
                title       = titre,
                pubDate     = decision.Date.ToString("ddd, dd MMM yyyy HH:mm:ss"),
                description = decision.Description,
                link        = decision.Lien?.ToString(),
                guid        = new Guid {
                    isPermaLink = false, Value = decision.GetHashCode().ToString()
                }
            };

            foreach (Domaine decisionDomaine in decision.Domaines)
            {
                RssChannel channel = this.OpenOrCreateChannelForDomaine(decisionDomaine);
                channel.Add(item);

                var rss = new Rss {
                    channel = new [] { channel }
                };
                var serializer = new XmlSerializer(typeof(Rss));

                IFile file = this._feedsStorageDirectory.CreateOrReturn(FileNameForDomaine(decisionDomaine));

                using (StreamWriter writer = file.CreateWriter())
                    serializer.Serialize(writer, rss);
            }
        }
        public async Task RemoveDomaine_RemovesDomainInStorage()
        {
            DecisionModel currentPrototype = this.Prototype;
            Domaine       firstDomain      = currentPrototype.Domaines.Single();
            Domaine       secondDomain     = TestingDomaineGenerator.DifferentByName().Take(1).Single();

            // Bloc 1 : création initiale de la décision
            {
                DecisionModel decision = currentPrototype;
                decision.Domaines.Add(secondDomain);

                Assert.AreEqual(2, decision.Domaines.Count);
                await this.Persister.StoreDecisionAsync(decision);
            }

            // Bloc 2 : Enlever un domaine à la décision
            {
                DecisionModel decision = (await this.Persister.FetchAllAsync()).Single();
                decision.Domaines.Remove(secondDomain);
                await this.Persister.StoreDecisionAsync(decision);
            }

            // Bloc final : vérification que la décision ne contient qu'un seul domaine
            {
                DecisionModel decision = (await this.Persister.FetchAllAsync()).Single();
                Assert.IsTrue(decision.Domaines.Contains(firstDomain));
                Assert.IsFalse(decision.Domaines.Contains(secondDomain));
            }
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public org.maltparser.core.feature.FeatureVector predictExtract(org.maltparser.core.feature.FeatureModel featureModel, org.maltparser.parser.history.action.GuideDecision decision) throws org.maltparser.core.exception.MaltChainedException
        public virtual FeatureVector predictExtract(FeatureModel featureModel, GuideDecision decision)
        {
            if (decision is SingleDecision)
            {
                throw new GuideException("A branched decision model expect more than one decisions. ");
            }
            featureModel.update();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.maltparser.parser.history.action.SingleDecision singleDecision = ((org.maltparser.parser.history.action.MultipleDecision)decision).getSingleDecision(decisionIndex);
            SingleDecision singleDecision = ((MultipleDecision)decision).getSingleDecision(decisionIndex);

            if (instanceModel == null)
            {
                initInstanceModel(featureModel, singleDecision.TableContainer.TableContainerName);
            }
            FeatureVector fv = instanceModel.predictExtract(featureModel.getFeatureVector(branchedDecisionSymbols, singleDecision.TableContainer.TableContainerName), singleDecision);

            if (decisionIndex + 1 < decision.numberOfDecisions())
            {
                if (singleDecision.continueWithNextDecision())
                {
                    DecisionModel child = children[singleDecision.DecisionCode];
                    if (child == null)
                    {
                        child = initChildDecisionModel(((MultipleDecision)decision).getSingleDecision(decisionIndex + 1), branchedDecisionSymbols + (branchedDecisionSymbols.Length == 0?"":"_") + singleDecision.DecisionSymbol);
                        children[singleDecision.DecisionCode] = child;
                    }
                    child.predictExtract(featureModel, decision);
                }
            }

            return(fv);
        }
示例#7
0
        public ApplyManualDecision(DecisionModel model)
        {
            this.now = DateTime.UtcNow;
            Warning  = string.Empty;
            Error    = string.Empty;

            this.decisionModel = model;
        }         // constructor
        public async Task CannotStoreDecision_WithZeroDomain()
        {
            DecisionModel decision = this.Generators.WithSpecificDomainesGenerator(new Domaine[0][]).Take(1).Single();

            await this.Persister.StoreDecisionAsync(decision);

            Assert.Fail("Exception non-obtenue");
        }
示例#9
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void terminate() throws org.maltparser.core.exception.MaltChainedException
        public virtual void terminate()
        {
            if (decisionModel != null)
            {
                decisionModel.terminate();
                decisionModel = null;
            }
        }
        public async Task FetchAll_ReturnsStored_AfterStore()
        {
            DecisionModel decision = this.Prototype;

            await this.Persister.StoreDecisionAsync(decision);

            Assert.AreEqual(decision, (await this.Persister.FetchAllAsync()).Single());
        }
 /// <summary>
 /// Constructeur
 /// </summary>
 public DecisionViewModel(DecisionModel decision)
 {
     this.DecisionModel = decision;
     this.EstSupprimée  = new InstanceProperty <bool> {
         Value = decision.EstSupprimée
     };
     this.EstSupprimée.ValueChanged += (sender, value) => this.DecisionModel.EstSupprimée = value;
     this.ToolTip = "Description : " + this.DecisionModel.Description;
 }
示例#12
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public SeqDecisionModel(org.maltparser.parser.guide.ClassifierGuide _guide) throws org.maltparser.core.exception.MaltChainedException
        public SeqDecisionModel(ClassifierGuide _guide)
        {
            guide = _guide;
            branchedDecisionSymbols = "";
            //		this.featureModel = _featureModel;
            decisionIndex     = 0;
            modelName         = "sdm" + decisionIndex;
            prevDecisionModel = null;
        }
示例#13
0
        private void StoreDecision(DecisionModel decision)
        {
            if (!decision.Domaines.Any())
            {
                throw new InvalidOperationException("Il faut au moins un domaine pour créer une décision.");
            }

            this._decisionList.Add(decision);
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public BranchedDecisionModel(org.maltparser.parser.guide.ClassifierGuide _guide) throws org.maltparser.core.exception.MaltChainedException
        public BranchedDecisionModel(ClassifierGuide _guide)
        {
            guide = _guide;
            branchedDecisionSymbols = "";
            //		this.featureModel = _featureModel;
            decisionIndex       = 0;
            modelName           = "bdm0";
            parentDecisionModel = null;
            children            = new HashMap <int, DecisionModel>();
        }
        public void Decision_AndTheSameDeleted_AreEqual()
        {
            DecisionModel notDeleted = this.Generators.Prototype;

            DecisionModel deleted = this.Generators.Prototype;

            deleted.EstSupprimée = true;

            Assert.AreEqual(notDeleted, deleted);
        }
        public async Task Exists_ReturnsFalse_IfAnotherAdded()
        {
            var decisions = this.Generators.DifferentByTitleGenerator().Take(2).ToArray();

            DecisionModel decision        = decisions.First();
            DecisionModel anotherDecision = decisions.Last();

            await this.Persister.StoreDecisionAsync(decision);

            Assert.IsFalse(await this.Persister.ExistsAsync(anotherDecision));
        }
示例#17
0
        public static DecisionModel CreateBasicDecisionModel()
        {
            var model = new DecisionModel()
            {
                Id = 0,
                LoanApplicationModelId = 0,
                Decision    = false,
                Description = ""
            };

            return(model);
        }
        public DecisionModelRssItemConverter(DecisionModel model)
        {
            this._builder.Titre        = model.Titre;
            this._builder.Description  = model.Description;
            this._builder.Date         = model.Date;
            this._builder.Lien         = model.Lien.ToString();
            this._builder.EstSupprimée = model.EstSupprimée;

            foreach (Domaine domaine in this.Domaines)
            {
                this._builder.Domaines.Add(domaine);
            }
        }
        public void BuildsItemTitle_FromDecisionTitre_WithRemoveIndicatorIfRemoved()
        {
            DecisionModel notRemovedDecision = PrototypeDecision();
            DecisionModel removedDecision    = PrototypeDecision();

            removedDecision.EstSupprimée = true;

            RssItem itemNotRemoved = new DecisionModelRssItemConverter(notRemovedDecision).BuildItem();
            RssItem itemRemoved    = new DecisionModelRssItemConverter(removedDecision).BuildItem();

            Assert.AreEqual(string.Empty, itemNotRemoved.title);
            Assert.AreEqual(DecisionModelRssItemConverter.RemovedIndicator, itemRemoved.title);
        }
示例#20
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void terminate() throws org.maltparser.core.exception.MaltChainedException
        public virtual void terminate()
        {
            if (instanceModel != null)
            {
                instanceModel.terminate();
                instanceModel = null;
            }
            if (nextDecisionModel != null)
            {
                nextDecisionModel.terminate();
                nextDecisionModel = null;
            }
        }
示例#21
0
        /// <summary>
        /// Constructeur
        /// </summary>
        public DecisionEditViewModel(IDecisionPersister decisionsStorage, IDomaineReference domaineReference, DecisionModel toEdit)
            : base(decisionsStorage, domaineReference)
        {
            this.EditedDecision = toEdit;
            this.PreviewUri     = toEdit.Lien.AbsoluteUri;

            this._initialState = toEdit.Domaines.ToArray();
            this.AjouterDomaines(this._initialState);

            this.DomaineAdd     += (sender, domaine) => toEdit.Domaines.Add(domaine);
            this.DomaineRemoved += (sender, domaine) => toEdit.Domaines.Remove(domaine);

            this.Register(nameof(this.IsEnabled), this.IsEnabled);
        }
        private void RemoveAllOccurences(DecisionModel decision)
        {
            foreach (RssChannel channel in this.Channels)
            {
                var occurences = channel.Items()
                                 .Where(element => ItemsReferesToDecision(element, decision))
                                 .ToArray();

                foreach (RssItem channelItem in occurences)
                {
                    channel.Remove(channelItem);
                }
            }
        }
示例#23
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected void initDecisionModel(org.maltparser.parser.history.action.SingleDecision decision) throws org.maltparser.core.exception.MaltChainedException
        protected internal virtual void initDecisionModel(SingleDecision decision)
        {
            if (decision.RelationToNextDecision == RelationToNextDecision.SEQUANTIAL)
            {
                decisionModel = new SeqDecisionModel(this);
            }
            else if (decision.RelationToNextDecision == RelationToNextDecision.BRANCHED)
            {
                decisionModel = new BranchedDecisionModel(this);
            }
            else if (decision.RelationToNextDecision == RelationToNextDecision.NONE)
            {
                decisionModel = new OneDecisionModel(this);
            }
        }
示例#24
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void initNextDecisionModel(org.maltparser.parser.history.action.SingleDecision decision, String branchedDecisionSymbol) throws org.maltparser.core.exception.MaltChainedException
        private void initNextDecisionModel(SingleDecision decision, string branchedDecisionSymbol)
        {
            if (decision.RelationToNextDecision == RelationToNextDecision.SEQUANTIAL)
            {
                nextDecisionModel = new SeqDecisionModel(guide, this, branchedDecisionSymbol);
            }
            else if (decision.RelationToNextDecision == RelationToNextDecision.BRANCHED)
            {
                nextDecisionModel = new BranchedDecisionModel(guide, this, branchedDecisionSymbol);
            }
            else if (decision.RelationToNextDecision == RelationToNextDecision.NONE)
            {
                nextDecisionModel = new OneDecisionModel(guide, this, branchedDecisionSymbol);
            }
        }
示例#25
0
        /// <summary>
        /// returns the decision
        /// </summary>
        /// <param name="issueId">issue id</param>
        /// <param name="userId">user who is performing this operation</param>
        /// <returns>decisonmodel</returns>

        public DecisionModel GetDecision(int issueId, int userId)
        {
            DecisionModel dm = new DecisionModel();
            Decision      d  = DecisionOp.GetDecision(issueId, userId);

            if (d == null)
            {
                dm.IssueId = issueId;
                return(dm);
            }
            else
            {
                return(dm.ToModel(d));
            }
        }
示例#26
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public OneDecisionModel(org.maltparser.parser.guide.ClassifierGuide _guide) throws org.maltparser.core.exception.MaltChainedException
        public OneDecisionModel(ClassifierGuide _guide)
        {
            branchedDecisionSymbols = "";
            guide = _guide;
            //		this.featureModel = _featureModel;
            decisionIndex = 0;
            if (ReferenceEquals(guide.GuideName, null) || guide.GuideName.Equals(""))
            {
                modelName = "odm" + decisionIndex;
            }
            else
            {
                modelName = guide.GuideName + ".odm" + decisionIndex;
            }
            prevDecisionModel = null;
        }
        public void RemoveAllOccurences(DecisionModel model)
        {
            string hashCodeString = model.GetHashCode().ToString();

            foreach (DomaineRssFeed domaineRssFeed in this._cache.Values)
            {
                domaineRssFeed.DoSomething(feed =>
                {
                    if (feed.item == null)
                    {
                        return;
                    }
                    feed.item = feed.item.Where(item => item.guid.Value != hashCodeString).ToArray();
                });
            }
        }
        private static RssItem PrototypeItem()
        {
            DecisionModel decision = PrototypeDecision();
            var           item     = new RssItem
            {
                title       = decision.Titre,
                description = decision.Description,
                link        = decision.Lien.ToString(),
                guid        = new Normacode.RSS.Guid {
                    isPermaLink = false, Value = decision.GetHashCode().ToString()
                }
            };

            item.SetPubDate(decision.Date);
            return(item);
        }
示例#29
0
文件: Program.cs 项目: LGR3VE/TechDM
        static void Main(string[] args)
        {
            var technologies = SeedData.TechnologyData;

            var techteil = SeedData.TechnologyData.Where(t => t.Name.Equals("Blazor"));


            var results = DecisionModel.CalculateScores(SeedData.UserAnswers, SeedData.TechnologyData);

            var orderresult = technologies.OrderByDescending(t => results.First(ts => ts.TechnologyId.Equals(t.Id)).Score);

            foreach (var technology in orderresult)
            {
                Console.Out.WriteLine(technology.Name + ": " + results.First(ts => ts.TechnologyId.Equals(technology.Id)).Score + " Score");
            }
        }
        public async Task StoreDecisionAsync(DecisionModel decision)
        {
            try
            {
                this._log.Write($"Storing decision {decision} on persister {this._decorated}");
                await this._decorated.StoreDecisionAsync(decision);

                this._log.Write("Decision stored");
            }
            catch (Exception e)
            {
                this._log.Write($"Error while storing decision {decision} on persister {this._decorated}");
                this._log.Write(e.ToString());
                throw;
            }
        }