Ejemplo n.º 1
0
 public FormAdmin(Form backForm, UserService.UserService service)
 {
     this._backForm = backForm;
     _service = service;
     InitializeComponent();
     cBoxRoles.DataSource = _roles;
 }
Ejemplo n.º 2
0
 public UpdateDatabasesService(ConversationService conversationService, AnalyzationService analyzationService, ConversationUpdateService conversationUpdateService, UserService.UserService userService)
 {
     _conversationService       = conversationService;
     _analyzationService        = analyzationService;
     _covnersationUpdateService = conversationUpdateService;
     _userService = userService;
 }
Ejemplo n.º 3
0
 public UpdateDatabasesService()
 {
     conversationService       = new ConversationService();
     analyzationService        = new AnalyzationService();
     covnersationUpdateService = new ConversationUpdateService();
     userService = new UserService.UserService();
 }
Ejemplo n.º 4
0
 public BotService()
 {
     conversationService       = new ConversationService();
     analyzationService        = new AnalyzationService();
     responseService           = new ResponseService();
     covnersationUpdateService = new ConversationUpdateService();
     userService            = new UserService.UserService();
     updateDatabasesService = new UpdateDatabasesService();
 }
Ejemplo n.º 5
0
 public BotService(ConversationService conversationService, AnalyzationService analyzationService, ResponseService responseService, ReactionService reactionService, ConversationUpdateService conversationUpdateService, UserService.UserService userService, UpdateDatabasesService updateDatabasesService)
 {
     _conversationService       = conversationService;
     _analyzationService        = analyzationService;
     _responseService           = responseService;
     _reactionService           = reactionService;
     _covnersationUpdateService = conversationUpdateService;
     _userService            = userService;
     _updateDatabasesService = updateDatabasesService;
 }
Ejemplo n.º 6
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc(option => option.EnableEndpointRouting = false);

            var corsUrls = Configuration.GetSection("CORS").Get <List <string> >();

            services.AddCors(options =>
            {
                options.AddPolicy("AllowSpecificOrigin", builder => builder.WithOrigins(corsUrls.ToArray()).AllowAnyHeader().AllowAnyMethod());
            });

            services.AddSingleton <ChatRequestValidationService, ChatRequestValidationService>();
            services.AddSingleton <ConversationRequestValidationService, ConversationRequestValidationService>();
            services.AddSingleton <ResponseRequestValidationService, ResponseRequestValidationService>();
            services.AddSingleton <ReactionRequestValidationService, ReactionRequestValidationService>();

            var client = new HttpClient();
            var naturalLanguageApiUrl = Configuration.GetSection("NaturalLanguage:ApiUrl").Value;

            client.BaseAddress = new Uri(naturalLanguageApiUrl);
            var naturalLanguageApiService = new NaturalLanguageApiService(client);

            var redditStalkerHttpClient = new HttpClient();
            var redditStalkerApiUrl     = Configuration.GetSection("Stalker:Reddit").Value;

            redditStalkerHttpClient.BaseAddress = new Uri(redditStalkerApiUrl);

            var analyzationService    = new AnalyzationService(new ConversationSubjectService(new ResponseSubjectService()), new ResponseAnalyzationService(), new ConversationTypeService(), new UserlessMessageService(), new ConversationReadingLevelService(), new ResponseSubjectService(), naturalLanguageApiService);
            var userService           = new UserService.UserService(new UserService.UserNickNameService(), new UserService.UserPropertyService(new UserService.UserNaturalLanguageService(), new UserService.PropertyMatchService(), new UserService.PropertyFromQuestionService()), new UserService.OtherUserPropertyService(new UserService.UserNaturalLanguageService(), new UserService.PropertyMatchService()), new UserService.UserDerivedPropertyService(), new UserDatabase.Services.UserSaveService());
            var updateDatabaseService = new UpdateDatabasesService(new ConversationService(), analyzationService, new ConversationDatabase.Services.ConversationUpdateService(new ConversationDatabase.Services.ConversationSaveService()), userService);

            var matchService             = new ConversationMatcher.Services.MatchService(new ConversationMatcher.Services.SubjectConfidenceService(), new ConversationMatcher.Services.MatchConfidenceService(new SentenceScoreService(new OpenieScoreService(), new SubjectPredicateObjectScoreService(new SubjectPredicateObjectTokenScoreService()), new TokenScoreService(), new SentimentScoreService(), new SentenceTypeScoreService(), new VoiceScoreService())), new ConversationMatcher.Services.GroupChatConfidenceService(), new ConversationMatcher.Services.UniqueConfidenceService(), new ConversationMatcher.Services.ReadingLevelConfidenceService(), new ConversationSteerService.ConversationPathService(new ConversationSteerService.Services.EdgeService(), new ConversationSteerService.Services.VerticeService(), new ConversationSteerService.Services.ShortestPathService()));
            var conversationMatchService = new SharkbotReplier.Services.ConversationMatchService(new ConversationMatcher.Services.BestMatchService(matchService));
            var userPropertyMatchService = new SharkbotReplier.Services.UserPropertyMatchService(new UserService.UserPropertyRetrievalService(new UserService.PropertyValueService(), new UserService.UserSelfPropertyRetrievalService(new UserService.UserNaturalLanguageService(), new UserService.PropertyValueService()), new UserService.UserNaturalLanguageService()), new UserService.BotPropertyRetrievalService(new UserService.BotSelfPropertyRetrievalService(new UserService.PropertyValueService(), new UserService.UserNaturalLanguageService()), new UserService.UserNaturalLanguageService(), new UserService.PropertyValueService()));
            var queueService             = new QueueService(
                new BotService(new ConversationService(), analyzationService,
                               new SharkbotReplier.Services.ResponseService(conversationMatchService, userPropertyMatchService, new SharkbotReplier.Services.LyricsMatchService(), new GoogleMatchService.GoogleMatchService(new ScrapySharp.Network.ScrapingBrowser()), new SharkbotReplier.Services.UrbanDictionaryMatchService(), new SharkbotReplier.Services.SalutationService(), new SharkbotReplier.Services.ResponseConversionService(new UserService.UserPropertyService(new UserService.UserNaturalLanguageService(), new UserService.PropertyMatchService(), new UserService.PropertyFromQuestionService()), new UserService.PropertyValueService())),
                               new SharkbotReplier.Services.ReactionService(new SharkbotReplier.Services.ConversationReactionMatchService(new ConversationMatcher.Services.BestReactionMatchService(matchService))),
                               new ConversationDatabase.Services.ConversationUpdateService(new ConversationDatabase.Services.ConversationSaveService()), userService, updateDatabaseService), new ConversationService(), updateDatabaseService, new StalkerService(redditStalkerHttpClient));

            services.AddSingleton(queueService);

            ConfigurationService.AnalyzationVersion = Configuration.GetSection("NaturalLanguage:AnalyzationVersion").Value;

            UserDatabase.UserDatabase.userDirectory = Configuration.GetSection("UserDirectory").Value;
            UserDatabase.UserDatabase.LoadDatabase(UserDatabase.UserDatabase.userDirectory);

            ConversationDatabase.ConversationDatabase.conversationDirectory = Configuration.GetSection("ConversationDirectory").Value;
            ConversationDatabase.ConversationDatabase.LoadDatabase(ConversationDatabase.ConversationDatabase.conversationDirectory, analyzationService);
        }
Ejemplo n.º 7
0
        public ActionResult UtrustLogin(string user_token)
        {
            UserService.UserService ussc = new UserService.UserService();
            string appid = WorkContext.SiteConfig.appid;

            if (string.IsNullOrEmpty(user_token))
            {
                //return PromptView("/", "登录失败!");
                return(RedirectToAction("indexPc", "home"));
            }
            else
            {
                string     userResult = ussc.getuserinfo(appid, user_token);
                userResult ur         = JsonHelper.DeserializeJsonToObject <userResult>(userResult);
                if (ur.retData != null)
                {
                    UserInfo ui = new UserInfo();
                    //手机号
                    string user_mobile = ur.retData.user_mobile;
                    if (!string.IsNullOrEmpty(user_mobile))
                    {
                        //如果手机号不为空,通过手机号查询网站后台是否存在该管理员
                        PartUserInfo partUserInfo = Users.GetPartUserByMobile(user_mobile);
                        if (partUserInfo != null)
                        {
                            SiteUtils.SetUserCookie(partUserInfo, 30);
                            Response.Write("<script language='javascript'>window.location='/admin'</script>");
                            return(null);
                        }
                    }
                    string tempRole = ur.retData.user_role;
                    //判断用户用户角色编码是否存在
                    if (!string.IsNullOrEmpty(tempRole))
                    {
                        //判断角色是否是教师
                        if (tempRole.Contains("120"))
                        {
                            UserInfo userInfo = new UserInfo();
                            if (tempRole.Contains("110") || tempRole.Contains("102"))
                            {
                                //赋予管理员权限
                                userInfo.AdminGroupID = WorkContext.SiteConfig.wzAdmin;
                                userInfo.UserName     = ur.retData.user_name;
                                userInfo.NickName     = "网站管理员";
                                userInfo.Mobile       = ur.retData.user_mobile;
                                userInfo.Password     = "******";
                                userInfo.Email        = "";
                                userInfo.Avatar       = "";
                                userInfo.RankCredits  = 0;
                                userInfo.UserRankID   = 0;
                                userInfo.VerifyEmail  = 0;
                                userInfo.State        = 0;
                                userInfo.Address      = "";
                                userInfo.Birthday     = DateTime.Parse("1900-1-1");
                                userInfo.Body         = "";
                                userInfo.Gender       = 0;
                                userInfo.IdCard       = "";
                                userInfo.LastIP       = "";
                                userInfo.LastTime     = DateTime.Now;
                                userInfo.RegionId     = 0;
                                userInfo.RegIP        = "";
                                userInfo.RegTime      = DateTime.Now;
                                int userid = Users.CreateUser(userInfo);
                                if (userid > 0)
                                {
                                    PartUserInfo partUserInfo0 = Users.GetPartUserById(userid);
                                    PartUserInfo partUserInfo  = Users.GetPartUserByMobile(partUserInfo0.Mobile);
                                    if (partUserInfo != null && partUserInfo.Mobile.Trim().Equals(ur.retData.user_mobile.Trim()))
                                    {
                                        SiteUtils.SetUserCookie(partUserInfo, 30);
                                        Response.Write("<script language='javascript'>window.location='/admin'</script>");
                                        return(null);
                                    }
                                }
                            }
                            else
                            {
                                //赋予投稿员权限
                                userInfo.AdminGroupID = WorkContext.SiteConfig.Contributor;
                                userInfo.UserName     = ur.retData.user_name;
                                userInfo.NickName     = "投稿员";
                                userInfo.Mobile       = ur.retData.user_mobile;
                                userInfo.Password     = "******";
                                userInfo.Email        = "";
                                userInfo.Avatar       = "";
                                userInfo.RankCredits  = 0;
                                userInfo.UserRankID   = 0;
                                userInfo.VerifyEmail  = 0;
                                userInfo.State        = 0;
                                userInfo.Address      = "";
                                userInfo.Birthday     = DateTime.Parse("1900-1-1");
                                userInfo.Body         = "";
                                userInfo.Gender       = 0;
                                userInfo.IdCard       = "";
                                userInfo.LastIP       = "";
                                userInfo.LastTime     = DateTime.Now;
                                userInfo.RegionId     = 0;
                                userInfo.RegIP        = "";
                                userInfo.RegTime      = DateTime.Now;
                                int userid = Users.CreateUser(userInfo);
                                if (userid > 0)
                                {
                                    PartUserInfo partUserInfo0 = Users.GetPartUserById(userid);
                                    PartUserInfo partUserInfo  = Users.GetPartUserByMobile(partUserInfo0.Mobile);
                                    if (partUserInfo != null && partUserInfo.Mobile.Trim().Equals(ur.retData.user_mobile.Trim()))
                                    {
                                        SiteUtils.SetUserCookie(partUserInfo, 30);
                                        Response.Write("<script language='javascript'>window.location='/admin'</script>");
                                        return(null);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(RedirectToAction("indexPc", "home"));
        }