public PartialViewResult KeywordSynonymCombo(string name, T_KEYWORD_COND Cond, string selectedValue, string optionLabel, string htmlAttributes) { List <SelectListItem> combolist = new List <SelectListItem>(); Cond.PAGE = 1; Cond.PAGE_COUNT = 100; Cond.IS_SYNONYM = true; IList <T_KEYWORD> list = new KeywordService().GetKeywordPageList(Cond); if (list == null) { list = new List <T_KEYWORD>(); } DROPDOWN_COND data = new DROPDOWN_COND { name = name , selectList = list.Select(s => new SelectListItem { Value = s.KEYWORD_CODE.ToString(), Text = s.KEYWORD_NAME, Selected = true }).ToList() , optionLabel = optionLabel , htmlAttributes = JsonConvert.DeserializeAnonymousType(htmlAttributes, new { @class = "", @style = "", @placeholder = "", @readonly = "", @multiple = "" }) }; return(PartialCombo(data)); }
public JsonResult KeywordSave(List <T_KEYWORD> list) { RTN_SAVE_DATA rtnData = new KeywordService().T_KEYWORD_Save(list, SessionHelper.LoginInfo.MEMBER.MEMBER_CODE); return(new JsonResult { Data = rtnData }); }
public JsonResult KEYWORD_Synonym_Save(KEYWORD_SYNONYM_SAVE saveData) { RTN_SAVE_DATA rtnData = new KeywordService().KEYWORD_Synonym_Save(saveData); return(new JsonResult { Data = rtnData }); }
public JsonResult KeywordList(string q, string type) { IList <CODE_DATA> list = new KeywordService().GetKeywordKoreanList(new ALT.VO.loggal.KEYWORD_COND { KEYWORD_TYPE = type, KEYWORD_NAME = q }); return(Json(list, JsonRequestBehavior.AllowGet)); }
private void _main_KeywordClick(object sender, EventArgs e) { IKeywordView _keyword = _main.CreateKeywordView(); IKeywordService keywordService = new KeywordService(); KeywordPresenter pres = new KeywordPresenter(_main, keywordService, _keyword); _keyword.ShowView(); _main.ShowKeywordView(_keyword); }
public JsonResult CategoryKeywordSave(CATEGORY_KEYWORD_SAVE Param) { Param.REG_CODE = SessionHelper.LoginInfo.MEMBER.MEMBER_CODE; RTN_SAVE_DATA rtnData = new KeywordService().CategoryKeywordSave(Param); return(new JsonResult { Data = rtnData }); }
private static IServiceCollection AddKeywordService( this IServiceCollection services, ConfigurationManager configuration) { // Add as singleton so all clients use the same file lock instance var keywordsJsonPath = configuration["KeywordsJsonPath"]; var keywordService = new KeywordService(keywordsJsonPath); return(services.AddSingleton(keywordService)); }
public void Setup() { var itemRepositoryMock = MockServiceGenerator.CreateItemRepositoryMock(); var pictureRepositoryMock = MockServiceGenerator.CreatePictureRepositoryMock(); var featureRepositoryMock = MockServiceGenerator.CreateFeaturesRepositoryMock(); var keywordsRepositoryMock = MockServiceGenerator.CreateKeywordRepository(); var categoryRepositoryMock = MockServiceGenerator.CreateCategoryRepository(); featureService = new FeatureService(featureRepositoryMock); var keywordService = new KeywordService(keywordsRepositoryMock); var categoryService = new CategoryService(categoryRepositoryMock); itemService = new ItemService(itemRepositoryMock, featureService, keywordService, categoryService, pictureRepositoryMock); }
public async Task <ActionResult> Keyword() { var topThreeReviewList = _cache.Get("topThreeReviewList") as List <ReviewRoot>; var sortedList = _cache.Get("sortedBusinessList") as List <Business>; KeywordService service = new KeywordService(); IEnumerable <KeyPhrase> keyPhraseList = service.CreateKeyPhraseList(topThreeReviewList); var keywords = await service.GetKeyWordsFromCognitiveServices(keyPhraseList); keywords = service.RemoveBusinessName(keywords, sortedList); _cache.Set("keywordcache", keywords, _policy); return(View(keywords)); }
public async Task Add(string name, [Remainder] string message) { const int delay = 3000; KeywordService.Post(name, Context.Guild.Id, Context.Message.Author.Id, message); await Task.Delay(delay); var res = await Context.Channel.SendMessageAsync("Added keyword."); await Task.Delay(delay); await res.DeleteAsync(); await Context.Message.DeleteAsync(); }
public JsonResult GetAdData(long?id) { var data = new AdvertisingService().GetT_AD_List((long)(id == null ? 0 : id)).FirstOrDefault(); data = data == null ? new T_AD() { STATUS = 9, HIDE = false } : data; var keyword = new KeywordService().GetAdDeviceSearchKeyword(new CATEGORY_KEYWORD_COND { AD_CODE = Convert.ToInt64(id.ToString("-1")), KEYWORD_TYPE = 2 }); return(new JsonResult { Data = new { AD_DATA = data, KEYWORD_DATA = keyword } }); }
public PartialViewResult CategoryKeywordCombo(string name, CATEGORY_KEYWORD_COND Cond, string selectedValue, string optionLabel, string htmlAttributes) { List <SelectListItem> combolist = new List <SelectListItem>(); IList <CODE_DATA> list = new KeywordService().GetCategoryKeywordList2(Cond); if (list == null) { list = new List <CODE_DATA>(); } DROPDOWN_COND data = new DROPDOWN_COND { name = name , selectList = list.Select(s => new SelectListItem { Value = s.CODE.ToString(), Text = s.NAME, Selected = true }).ToList() , optionLabel = optionLabel , htmlAttributes = JsonConvert.DeserializeAnonymousType(htmlAttributes, new { @class = "", @style = "", @placeholder = "", @readonly = "", @multiple = "" }) }; return(PartialCombo(data)); }
public async Task RunAsync() { isDev = !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("WAZEBOT_ISDEV")); var token = Environment.GetEnvironmentVariable("DISCORD_API_TOKEN"); if (token == null) { throw new ArgumentNullException(nameof(token), "No Discord API token env var found"); } VerifyEnvironmentVariables(); var clientConfig = new DiscordSocketConfig { LogLevel = isDev ? LogSeverity.Info : LogSeverity.Warning, AlwaysDownloadUsers = true }; client = new DiscordSocketClient(clientConfig); client.Log += Log; var commandsConfig = new CommandServiceConfig { CaseSensitiveCommands = false }; commands = new CommandService(commandsConfig); httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.UserAgent.ParseAdd("WazeBotDiscord/1.0"); var autoreplyService = new AutoreplyService(); await autoreplyService.InitAutoreplyServiceAsync(); var keywordService = new KeywordService(); await keywordService.InitKeywordServiceAsync(); var glossaryService = new GlossaryService(httpClient); await glossaryService.InitAsync(); var lookupService = new LookupService(httpClient); await lookupService.InitAsync(); var serviceCollection = new ServiceCollection(); serviceCollection.AddSingleton(commands); serviceCollection.AddSingleton(autoreplyService); serviceCollection.AddSingleton(keywordService); serviceCollection.AddSingleton(lookupService); serviceCollection.AddSingleton(glossaryService); serviceCollection.AddSingleton(httpClient); client.Ready += async() => await client.SetGameAsync("with junction boxes"); var twitterService = new TwitterService(client); serviceCollection.AddSingleton(twitterService); client.Connected += async() => await twitterService.InitTwitterServiceAsync(); client.Disconnected += (ex) => { twitterService.StopAllStreams(); return(Task.CompletedTask); }; services = serviceCollection.BuildServiceProvider(); client.MessageReceived += async(SocketMessage msg) => await AutoreplyHandler.HandleAutoreplyAsync(msg, autoreplyService); client.MessageReceived += async(SocketMessage msg) => await KeywordHandler.HandleKeywordAsync(msg, keywordService, client); client.UserJoined += async(SocketGuildUser user) => await UserJoinedRoleSyncEvent.SyncRoles(user, client); await InstallCommands(); await client.LoginAsync(TokenType.Bot, token); await client.StartAsync(); await Task.Delay(-1); }
public async Task KeywordAsync(string keyword) { string messageToSend = await KeywordService.GetAsync(keyword, Context.Guild.Id); await Context.Channel.SendMessageAsync(messageToSend); }
/// <summary> /// This method gets called by the runtime. Use this method to add services to the container. /// </summary> /// <param name="services">Specifies the contract for a <see cref="IServiceCollection"/> of service descriptors.</param> public void ConfigureServices(IServiceCollection services) { var secretKey = Configuration.GetSection("botFileSecret")?.Value; var botFilePath = Configuration.GetSection("botFilePath")?.Value; if (!File.Exists(botFilePath)) { throw new FileNotFoundException($"The .bot configuration file was not found. botFilePath: {botFilePath}"); } // Loads .bot configuration file and adds a singleton that your Bot can access through dependency injection. BotConfiguration botConfig = null; try { botConfig = BotConfiguration.Load(botFilePath, secretKey); } catch { var msg = @"Error reading bot file. Please ensure you have valid botFilePath and botFileSecret set for your environment. - You can find the botFilePath and botFileSecret in the Azure App Service application settings. - If you are running this bot locally, consider adding a appsettings.json file with botFilePath and botFileSecret. - See https://aka.ms/about-bot-file to learn more about .bot file its use and bot configuration. "; throw new InvalidOperationException(msg); } services.AddSingleton(sp => botConfig ?? throw new InvalidOperationException($"The .bot configuration file could not be loaded. botFilePath: {botFilePath}")); // Add BotServices singleton. // Create the connected services from .bot file. services.AddSingleton(sp => new BotServices(botConfig)); // Create PimBotServiceProvider var featureService = new FeatureService(new FeatureRepository()); var keywordService = new KeywordService(new KeywordRepository()); var categoryService = new CategoryService(new CategoryRepository()); var itemService = new ItemService(new ItemRepository(), featureService, keywordService, categoryService, new PictureRepository()); var serviceProvider = new PimBotServiceProvider(itemService, keywordService, featureService, categoryService); services.AddSingleton <IPimbotServiceProvider>(serviceProvider); services.AddScoped <IKeywordService, KeywordService>(); // Retrieve current endpoint. var environment = _isProduction ? "production" : "development"; var service = botConfig.Services.FirstOrDefault(s => s.Type == "endpoint" && s.Name == environment); if (service == null && _isProduction) { // Attempt to load development environment service = botConfig.Services.Where(s => s.Type == "endpoint" && s.Name == "development").FirstOrDefault(); } if (!(service is EndpointService endpointService)) { throw new InvalidOperationException($"The .bot file does not contain an endpoint with name '{environment}'."); } // For testing and develop IStorage dataStore = new MemoryStorage(); // For publishing // IStorage dataStore = new CosmosDbStorage(new CosmosDbStorageOptions() // { // AuthKey = Constants.CosmosDBKey, // CollectionId = Constants.CosmosDBCollectionName, // CosmosDBEndpoint = new Uri(Constants.CosmosServiceEndpoint), // DatabaseId = Constants.CosmosDBDatabaseName, // }); // Create and add conversation state. var conversationState = new ConversationState(dataStore); services.AddSingleton(conversationState); services.AddScoped <IKeywordService, KeywordService>(); var userState = new UserState(dataStore); services.AddSingleton(userState); var blobStorage = new AzureBlobTranscriptStore( Constants.AzureBlogStorageConnectionString, Constants.BlobTranscriptStorageContainerName); services.AddBot <PimBot.PimBot>(options => { options.CredentialProvider = new SimpleCredentialProvider(endpointService.AppId, endpointService.AppPassword); options.ChannelProvider = new ConfigurationChannelProvider(Configuration); ILogger logger = _loggerFactory.CreateLogger <PimBot.PimBot>(); // For logging every single conversations // options.Middleware.Add(new TranscriptLoggerMiddleware(blobStorage)); options.Middleware.Add(new ShowTypingMiddleware()); var middleware = options.Middleware; // Catches any errors that occur during a conversation turn and logs them to currently // configured ILogger. options.OnTurnError = async(context, exception) => { logger.LogError($"Exception caught : {exception}"); if (exception is System.Net.Http.HttpRequestException || exception is System.Net.Sockets.SocketException) { await context.SendActivityAsync(Messages.ServerIssue); } else { await context.SendActivityAsync(Messages.SomethingWrong); } }; }); }
public PartialViewResult KeywordCount(string Keyword) { IKeywordService service = new KeywordService(); return(PartialView("_AJAXEnabledServicedKeywordCount", service.KeywordCount(Keyword))); }
public void TestInitialize() { path = GetNewPath(); TestData.Create(path); keywordService = new KeywordService(path); }