コード例 #1
0
        private IEnumerable <SuggestionType> ExtractSuggestions(TranslationSequence result)
        {
            var types = new List <SuggestionType>();

            foreach (ExtraTranslation extra in result.Suggestions)
            {
                var type = extra.Type.ToString();
                bool IsTypeEqual(SuggestionType item) => item.Type == type;

                SuggestionType belongType = types.Any(IsTypeEqual)
                    ? types.Find(IsTypeEqual)
                    : new SuggestionType(type);

                var suggestion = new Suggestion(extra.Name);
                Parallel.ForEach(extra.Words, extraWord => suggestion.Examples.Add(new SuggestionExample(extraWord)));

                _cts.Token.ThrowIfCancellationRequested();

                if (suggestion.Examples.Count > 0)
                {
                    belongType.Suggestions.Add(suggestion);
                }
                int index = types.IndexOf(types.Find(IsTypeEqual));
                if (index > -1)
                {
                    types[index] = belongType;
                }
                else
                {
                    types.Add(belongType);
                }
            }
            return(types);
        }
コード例 #2
0
        public ActionResult CreateNew(string name, string explanation)
        {
            DatabaseContext db             = new DatabaseContext();
            SuggestionType  SuggestionType = new SuggestionType();
            int             Eid            = Convert.ToInt32(Session["EmployeeID"]);
            Employee        employee       = db.Employees.Where(x => x.EmployeeID == Eid).FirstOrDefault();

            if (string.IsNullOrEmpty(name) == false && string.IsNullOrEmpty(explanation) == false)
            {
                if (employee != null)
                {
                    SuggestionType.Explanation    = explanation;
                    SuggestionType.CreateDate     = DateTime.Now;
                    SuggestionType.CreateEmployee = employee;
                    SuggestionType.Status         = "Active";
                    SuggestionType.Name           = name;
                    db.SuggestionTypes.Add(SuggestionType);
                    db.SaveChanges();
                }
                else
                {
                    return(RedirectToAction("Login", "Employee"));
                }
            }
            return(RedirectToAction("SuggestionTypes", "SuggestionType"));
        }
コード例 #3
0
        public static async Task UpdateBillboardAsync(IGuild guild, IUserMessage message, ISocketMessageChannel channel,
                                                      GovernanceVote vote, SuggestionType type)
        {
            var msg = GetBillboardMessage(type);

            var billboard = (IUserMessage)await channel.GetMessageAsync(vote.VoteBillboardId);

            if (billboard == null)
            {
                return;
            }

            if (type == SuggestionType.Vote)
            {
                var embed = await AddVotesAsync(guild, new EmbedBuilder(), message);

                await billboard.ModifyAsync(props =>
                {
                    props.Content = msg;
                    props.Embed   = embed.WithTitle("Votes").Build();
                });
            }
            else
            {
                await billboard.ModifyAsync(props =>
                {
                    props.Content = msg;
                    props.Embed   = null;
                });
            }
        }
コード例 #4
0
ファイル: SuggestionList.cs プロジェクト: fence-post/sqrach
 public Suggestion(DbColumn c)
 {
     tokenType      = TokenType.Column;
     _expr          = null;
     suggestionType = SuggestionType.Normal;
     dbColumn       = c;
 }
コード例 #5
0
ファイル: SuggestionList.cs プロジェクト: fence-post/sqrach
 public Suggestion(DbTable t)
 {
     tokenType      = TokenType.Table;
     _expr          = null;
     suggestionType = SuggestionType.Normal;
     dbTable        = t;
 }
コード例 #6
0
        public void TestCreate(string searchText, string fullPath, SuggestedPathType suggestedPathType,
                               string relativePath, string parentDir, SuggestionType suggestionType)
        {
            _autoMocker
            .Setup <IPathService, string>(m => m.GetParentDirectory(searchText))
            .Returns(parentDir);
            _autoMocker
            .Setup <IPathService, string>(m => m.GetRelativePath(parentDir, fullPath))
            .Returns(relativePath);
            _autoMocker
            .Setup <IPathService, string>(m => m.LeftTrimPathSeparators(relativePath))
            .Returns(relativePath);

            var factory   = _autoMocker.CreateInstance <SuggestedPathViewModelFactory>();
            var model     = new SuggestionModel(fullPath, suggestionType);
            var viewModel = factory.Create(searchText, model);

            Assert.NotNull(viewModel);
            Assert.IsType <SuggestedPathViewModel>(viewModel);

            var suggestedPathViewModel = (SuggestedPathViewModel)viewModel;

            Assert.Equal(suggestedPathType, suggestedPathViewModel.Type);
            Assert.Equal(relativePath, suggestedPathViewModel.Text);
            Assert.Equal(fullPath, suggestedPathViewModel.FullPath);
        }
コード例 #7
0
        protected async Task CreateSuggestionChannel(SuggestionType type, string shortName, IUser owner,
                                                     Func <IMessageChannel, Task <IUserMessage> > messageGenerator)
        {
            await Context.Message.DeleteAsync();

            var user      = Context.User;
            var guildUser = (IGuildUser)user;

            if (!guildUser.IsStaffOrConsultant())
            {
                throw new Exception("Only staff can suggest new features.");
            }

            var guild  = Context.Guild;
            var config = guild.GetGovernanceConfig();

            var channel = await guild.CreateSuggestionChannel(config.Category, type, shortName);

            await channel.AddPermissionOverwriteAsync(user,
                                                      new OverwritePermissions(viewChannel : PermValue.Allow, sendMessages : PermValue.Allow));

            var message = await messageGenerator(channel);

            if (message == null)
            {
                await channel.DeleteAsync();

                return;
            }

            await channel.ModifyAsync(props =>
            {
                props.Topic = message.Embeds.First().Description;
            });

            var msg = GetBillboardMessage(type);
            var voteBillboardMessage = await channel.SendMessageAsync(msg);

            await message.PinAsync();

            await voteBillboardMessage.PinAsync();

            await Database.UNSAFE_AddGovernanceVoteAsync(new GovernanceVote
            {
                UserId          = owner.Id,
                MessageId       = message.Id,
                ChannelId       = channel.Id,
                VoteBillboardId = voteBillboardMessage.Id
            });

            var perms       = channel.GetPermissionOverwrite(guild.EveryoneRole) ?? new OverwritePermissions();
            var targetPerms = new OverwritePermissions(
                (perms.AllowValue | config.EveryonePermissionsAfterSubmission.AllowValue) &
                ~config.EveryonePermissionsAfterSubmission.DenyValue,
                (perms.DenyValue | config.EveryonePermissionsAfterSubmission.DenyValue) &
                ~config.EveryonePermissionsAfterSubmission.AllowValue
                );
            await channel.AddPermissionOverwriteAsync(guild.EveryoneRole, targetPerms);
        }
コード例 #8
0
ファイル: Suggestion.cs プロジェクト: igitur/CQL
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="suggestionType"></param>
 /// <param name="position"></param>
 /// <param name="selectionLength"></param>
 /// <param name="text"></param>
 /// <param name="usage"></param>
 public Suggestion(SuggestionType suggestionType, int position, int selectionLength, string text, string usage)
 {
     Position        = position;
     SelectionLength = selectionLength;
     Text            = text;
     SuggestionType  = suggestionType;
     Usage           = usage;
 }
コード例 #9
0
 protected static string GetBillboardMessage(SuggestionType type)
 {
     return(type == SuggestionType.Draft
         ? ":warning: Draft mode. Edits to suggestion are allowed but voting is disabled.\n"
            + "Available commands: `g!suggestion edit`, `g!suggestion rename [channel-name]`, `g!suggestion finalize` (owner and staff only)."
         : type == SuggestionType.RFC
             ? ":scroll: RFC mode. Suggest incremental changes, no vote is scheduled.\n"
            + "Available commands: `g!rfc edit`, `g!rfc rename [channel-name]` (owner and staff only)."
             : "");
 }
コード例 #10
0
ファイル: UserExtensions.cs プロジェクト: ee-discord/GregBot
        public static async Task <RestTextChannel> CreateSuggestionChannel(this SocketGuild guild, ulong categoryId,
                                                                           SuggestionType type, string name)
        {
            var suffix = ChannelSuffixes[type];
            var res    = await guild.CreateTextChannelAsync(suffix + name, c =>
            {
                c.CategoryId = categoryId;
            });

            await ReorderChannels(guild);

            return(res);
        }
コード例 #11
0
 public ActionResult EditRecord(int?id)
 {
     if (Session["EmployeeID"] != null)
     {
         DatabaseContext db             = new DatabaseContext();
         SuggestionType  SuggestionType = db.SuggestionTypes.Where(x => x.SuggestionTypeID == id).FirstOrDefault();
         return(PartialView("SuggestionTypePartialView", SuggestionType));
     }
     else
     {
         return(RedirectToAction("Login", "Employee"));
     }
 }
コード例 #12
0
        public ActionResult Detail(int?SuggestionID, Suggestion model, string Approve, string save, string delete, string Denied)
        {
            DatabaseContext db         = new DatabaseContext();
            Suggestion      Suggestion = db.Suggestions.Where(x => x.SuggestionID == SuggestionID).FirstOrDefault();
            int             Eid        = Convert.ToInt32(Session["EmployeeID"]);
            Employee        employee   = db.Employees.Where(x => x.EmployeeID == Eid).FirstOrDefault();

            if (employee != null && Suggestion != null)
            {
                string controlClicked = string.Empty;
                if (!string.IsNullOrEmpty(save))
                {
                    Suggestion.Explanation    = model.Explanation;
                    Suggestion.Name           = model.Name;
                    Suggestion.lastUpdateDate = DateTime.Now;
                    db.SaveChanges();
                    return(RedirectToAction("Detail", "Suggestion", new { Suggestion.SuggestionID }));
                }
                if (!string.IsNullOrEmpty(delete))
                {
                    Suggestion.ApprovedStatus = "Passive";
                    Suggestion.lastUpdateDate = DateTime.Now;
                    db.SaveChanges();
                    return(RedirectToAction("Suggestions", "Suggestion"));
                }
                if (!string.IsNullOrEmpty(Denied))
                {
                    Suggestion.ApprovedStatus = "Denied";
                    Suggestion.ApprovedDate   = DateTime.Now;
                    Suggestion.AppEmployee    = employee.NameSurname;
                    Suggestion.DeniedNote     = model.DeniedNote;
                    db.SaveChanges();
                    return(RedirectToAction("Suggestions", "Suggestion"));
                }
                if (!string.IsNullOrEmpty(Approve))
                {
                    SuggestionType SuggestionType = db.SuggestionTypes.Where(x => x.SuggestionTypeID == model.SuggestionTypeID).FirstOrDefault();
                    Suggestion.SuggestionType = SuggestionType;
                    Suggestion.ApprovedStatus = "Approved";
                    Suggestion.ApprovedDate   = DateTime.Now;
                    Suggestion.AppEmployee    = employee.NameSurname;
                    db.SaveChanges();
                    return(RedirectToAction("Detail", "Suggestion", new { Suggestion.SuggestionID }));
                }
            }
            else
            {
                return(RedirectToAction("Login", "Employee"));
            }
            return(View());
        }
コード例 #13
0
 public ActionResult Delete(int?id)
 {
     if (Session["EmployeeID"] != null)
     {
         DatabaseContext db             = new DatabaseContext();
         SuggestionType  SuggestionType = db.SuggestionTypes.Where(x => x.SuggestionTypeID == id).FirstOrDefault();
         SuggestionType.Status = "Passive";
         db.SaveChanges();
         return(RedirectToAction("SuggestionTypes", "SuggestionType"));
     }
     else
     {
         return(RedirectToAction("Login", "Employee"));
     }
 }
コード例 #14
0
        public ActionResult SuggestionTypes(SuggestionType model)
        {
            if (Session["EmployeeID"] != null)
            {
                DatabaseContext db             = new DatabaseContext();
                SuggestionType  SuggestionType = db.SuggestionTypes.Where(x => x.SuggestionTypeID == model.SuggestionTypeID).FirstOrDefault();
                SuggestionType.Explanation = model.Explanation;
                SuggestionType.Name        = model.Name;
                db.SaveChanges();

                return(RedirectToAction("SuggestionTypes", "SuggestionType"));
            }
            else
            {
                return(RedirectToAction("Login", "Employee"));
            }
        }
コード例 #15
0
 public Channel GetSuggestedChannel(out SuggestionType suggestionType)
 {
     if (Channels.Count > 0)
     {
         suggestionType = SuggestionType.Channel;
         return(Channels.First());
     }
     else if (Logos.Count > 0)
     {
         suggestionType = SuggestionType.Logo;
         return(Logos.First().Channels.First());
     }
     else
     {
         suggestionType = SuggestionType.Alias;
         return(Aliases.First().Channel);
     }
 }
コード例 #16
0
 public Channel GetSuggestedChannel(out SuggestionType suggestionType)
 {
     if (Channels.Count > 0)
     {
         suggestionType = SuggestionType.Channel;
         return Channels.First();
     }
     else if (Logos.Count > 0)
     {
         suggestionType = SuggestionType.Logo;
         return Logos.First().Channels.First();
     }
     else
     {
         suggestionType = SuggestionType.Alias;
         return Aliases.First().Channel;
     }
 }
コード例 #17
0
        public async Task Convert(SuggestionType type, bool force = false)
        {
            var guildUser = (IGuildUser)Context.User;
            var channel   = (SocketTextChannel)Context.Channel;
            var oldType   = channel.GetSuggestionChannelType();

            if (oldType == SuggestionType.Vote && !force)
            {
                throw new Exception(
                          "Suggestion is in voting mode. Converting it would delete all existing votes. To confirm, run the command again with the force flag set.");
            }

            if (!guildUser.IsServerOwner())
            {
                throw new Exception("Only server owner can convert suggestions.");
            }

            if (!channel.IsSuggestionChannelByName())
            {
                throw new InvalidOperationException("Wrong channel!");
            }

            if (type == SuggestionType.Vote)
            {
                throw new Exception("Use g!suggest finalize to start a vote.");
            }

            var vote = await Database.UNSAFE_GetGovernanceVoteAsync(channel.Id);

            if (vote == null)
            {
                throw new Exception("Cannot find information about this suggestion in database!");
            }

            var message = (IUserMessage)await Context.Channel.GetMessageAsync(vote.MessageId);

            await message.RemoveAllReactionsAsync();

            await channel.ConvertSuggestionChannelType(type);

            await UpdateBillboardAsync(Context.Guild, message, channel, vote, type);

            await channel.SendMessageAsync("Suggestion type changed to " + type + ".");
        }
コード例 #18
0
        public IPredictionSuggestionCollection GetSuggestions(SuggestionType type)
        {
            IPredictionSuggestionCollection outerCollection;

            switch (type)
            {
            case SuggestionType.Word:
                var innerCollection = innerPrediction.GetSuggestions(type);
                predictor.UpdateOfferedList(innerCollection);
                outerCollection = new NoveltyWordPredictionSuggestionCollection(predictor, innerCollection);

                var phraseContextList = new List <string>();

                using (var enumerator = outerCollection.GetEnumerator())
                {
                    if (enumerator.MoveNext())
                    {
                        phraseContextList.Add(enumerator.Current.Text);
                    }
                }

                foreach (var word in outerCollection.Context)
                {
                    phraseContextList.Add(word);
                }

                phraseContext = phraseContextList.ToArray();

                break;

            case SuggestionType.Phrase:
                var prediction = (Prediction)innerPrediction;
                outerCollection = prediction.GetPhraseSuggestion(phraseContext);
                break;

            default:
                outerCollection = innerPrediction.GetSuggestions(type);
                break;
            }

            return(outerCollection);
        }
コード例 #19
0
        public IPredictionSuggestionCollection GetSuggestions(SuggestionType type)
        {
            IPredictionSuggestionCollection suggestions;

            switch (type)
            {
            case SuggestionType.Character:
                suggestions = new CharacterProbabilisticSuggestionCollection(text, selectionStart);
                break;

            case SuggestionType.Word:
                suggestions = LuceneWordSuggestionCollection.Create(environment, wordSuggester, text, selectionStart, selectionLength, isAutoSpace);
                break;

            default:
                suggestions = EmptySuggestions.Instance;
                break;
            }

            return(suggestions);
        }
コード例 #20
0
    public void On_CMSG_BUG(PacketClass packet, ClientClass client)
    {
        if (packet.Data.Length - 1 < 14)
        {
            return;
        }

        packet.GetInt16();
        SuggestionType suggestion = (SuggestionType)packet.GetInt32();
        var            cLength    = packet.GetInt32();
        var            cString    = _clusterServiceLocator.Functions.EscapeString(packet.GetString());

        if (packet.Data.Length - 1 < 14 + cString.Length + 5)
        {
            return;
        }

        var tLength = packet.GetInt32();
        var tString = _clusterServiceLocator.Functions.EscapeString(packet.GetString());

        _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_BUG [2]", client.IP, client.Port, suggestion);
        _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.INFORMATION, "Bug report [{0}:{1} Lengths:{2}, {3}] " + cString + Constants.vbCrLf + tString, cLength.ToString(), tLength.ToString());
    }
コード例 #21
0
ファイル: SuggestionModel.cs プロジェクト: CreateLab/Camelot
 public SuggestionModel(string fullPath, SuggestionType type)
 {
     FullPath = fullPath;
     Type     = type;
 }
コード例 #22
0
 /// <summary>Возвращает список профилей пользователей, которые могут быть друзьями текущего пользователя.</summary>
 /// <param name="filter">Типы предрагаемых друзей которые нужно вернуть, перечисленные через запятую</param>
 /// <param name="offset">Cмещение необходимое для выбора определённого подмножества списка</param>
 /// <param name="count">Количество рекомендаций, которое необходимо вернуть</param>
 /// <returns>Ответ сервера в XML или JSON формате.</returns>
 private VKResponseBase getSuggestions(SuggestionType? filter, System.Int32? offset, System.Int32? count)
 {
     manager.AddValueByName("@filter", filter);
     manager.AddValueByName("@offset", offset);
     manager.AddValueByName("@count", count);
     return new VKResponseBase(GetResponse("getSuggestions"), IsXMLResponse);
 }
コード例 #23
0
 /// <summary>Возвращает список профилей пользователей, которые могут быть друзьями текущего пользователя.</summary>
 /// <param name="filter">Типы предрагаемых друзей которые нужно вернуть, перечисленные через запятую</param>
 /// <returns>Ответ сервера в XML или JSON формате.</returns>
 public VKResponseBase GetSuggestions(SuggestionType filter)
 {
     return getSuggestions(filter, null, null);
 }
コード例 #24
0
ファイル: Reference.cs プロジェクト: BNATENSTEDT/PnP
 /// <remarks/>
 public void AddSuggestionsAsync(SuggestionType type, string[] suggestions, double[] weights, object userState) {
     if ((this.AddSuggestionsOperationCompleted == null)) {
         this.AddSuggestionsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnAddSuggestionsOperationCompleted);
     }
     this.InvokeAsync("AddSuggestions", new object[] {
                 type,
                 suggestions,
                 weights}, this.AddSuggestionsOperationCompleted, userState);
 }
コード例 #25
0
ファイル: Reference.cs プロジェクト: BNATENSTEDT/PnP
 /// <remarks/>
 public void AddSuggestionsAsync(SuggestionType type, string[] suggestions, double[] weights) {
     this.AddSuggestionsAsync(type, suggestions, weights, null);
 }
コード例 #26
0
ファイル: Reference.cs プロジェクト: BNATENSTEDT/PnP
 public void AddSuggestions(SuggestionType type, string[] suggestions, double[] weights) {
     this.Invoke("AddSuggestions", new object[] {
                 type,
                 suggestions,
                 weights});
 }
コード例 #27
0
 public SuggestedWord(string word, SuggestionType type)
 {
     Word = word;
     Type = type;
 }
コード例 #28
0
 private static SuggestedPathType CreateFrom(SuggestionType modelType) =>
 modelType switch
 {
コード例 #29
0
 /// <remarks/>
 public System.IAsyncResult BeginAddSuggestions(SuggestionType type, string[] suggestions, double[] weights, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("AddSuggestions", new object[] {
                 type,
                 suggestions,
                 weights}, callback, asyncState);
 }
コード例 #30
0
ファイル: UserExtensions.cs プロジェクト: ee-discord/GregBot
        public static async Task ConvertSuggestionChannelType(this SocketGuildChannel channel, SuggestionType type)
        {
            var name   = GetSuggestionChannelName(channel);
            var suffix = ChannelSuffixes[type];
            var res    = channel.ModifyAsync(c =>
            {
                c.Name = suffix + name;
            });

            await ReorderChannels(channel.Guild);
        }
コード例 #31
0
 public IPredictionSuggestionCollection GetSuggestions(SuggestionType type)
 {
     return(new AmbiguousPredictionCollection(_suggestions));
 }
コード例 #32
0
ファイル: SuggestionList.cs プロジェクト: fence-post/sqrach
 public Suggestion(TokenType typ, string text, SuggestionType t = SuggestionType.Normal)
 {
     tokenType      = typ;
     _expr          = text;
     suggestionType = t;
 }
コード例 #33
0
 public ValueSuggestion(string suggestionValue, SuggestionType suggestionType)
 {
     SuggestionValue = suggestionValue;
     SuggestionType  = suggestionType;
 }