Exemplo n.º 1
0
        public MainWindow(IMessageContainer groupChat, CacheSession cacheSession, IPluginUIIntegration uiIntegration, bool classicStyle)
        {
            this.InitializeComponent();

            this.GroupChat     = groupChat;
            this.CacheSession  = cacheSession;
            this.UIIntegration = uiIntegration;
            this.ClassicStyle  = classicStyle;

            this.MessagesWithAttachments =
                this.CacheSession.CacheForGroupOrChat
                .AsEnumerable()
                .Where(m => m.Attachments.Count > 0)
                .OrderByDescending(m => m.CreatedAtTime);

            this.HttpListener = new HttpListener();
            this.HttpListener.Prefixes.Add($"http://+:80/Temporary_Listen_Addresses/{this.ServerId}/");
            this.HttpListener.Start();

            this.CancellationTokenSource = new CancellationTokenSource();
            Task.Run(this.RunServer, this.CancellationTokenSource.Token);

            Debug.WriteLine($"http://+:80/Temporary_Listen_Addresses/{this.ServerId}/");

            this.ScriptingHelper = new ObjectForScriptingHelper(this);
            this.webBrowser.ObjectForScripting = this.ScriptingHelper;

            this.webBrowser.Navigate($"http://127.0.0.1:80/Temporary_Listen_Addresses/{this.ServerId}/gallery.html");

            this.Title = $"Image Gallery for {this.GroupChat.Name}";
        }
        public MainWindowViewModel(IMessageContainer messageContainer, CacheSession cacheSession)
        {
            this.MessageContainer = messageContainer;
            this.CacheSession     = cacheSession;

            var mostRecentGroupMessage  = this.CacheSession.GlobalCache.OrderByDescending(m => m.CreatedAtUnixTime).First();
            var mostRecentGlobalMessage = this.CacheSession.CacheForGroupOrChat.OrderByDescending(m => m.CreatedAtUnixTime).First();

            this.SomeGeneratedString = $"The most recent message in this group was {mostRecentGroupMessage.Text}. The most recent message in the cache from all groups is {mostRecentGlobalMessage.Text}";
        }
        public MainWindowViewModel(IMessageContainer groupChat, CacheSession cacheSession, IPluginUIIntegration uIIntegration)
        {
            this.GroupChat     = groupChat;
            this.CacheSession  = cacheSession;
            this.UIIntegration = UIIntegration;

            var mostRecentGroupMessage  = this.CacheSession.CacheForGroupOrChat.OrderByDescending(m => m.CreatedAtUnixTime).First();
            var mostRecentGlobalMessage = this.CacheSession.GlobalCache.OrderByDescending(m => m.CreatedAtUnixTime).First();

            this.MaxNumWords           = 100;
            this.outputText            = "";
            this.phraseDictionary      = new Dictionary <GlobalUser, Dictionary <string, List <string> > >();
            this.phraseDictionaryLocal = new Dictionary <GlobalUser, Dictionary <string, List <string> > >();
            this.RegenerateOutput      = new RelayCommand(this.RegenerateChain);
            this.CopyOutput            = new RelayCommand(this.CopyOutputChain);
        }
Exemplo n.º 4
0
        public Task Activated(IMessageContainer groupOrChat, CacheSession cacheSession, IPluginUIIntegration integration, Action <CacheSession> cleanup)
        {
            MainWindow mainWindow = new MainWindow(groupOrChat, cacheSession, integration, false);

            mainWindow.Closed += (s, e) =>
            {
                cleanup(cacheSession);
            };

            System.Windows.Application.Current.Dispatcher.Invoke(() =>
            {
                mainWindow.Show();
            });

            return(Task.CompletedTask);
        }
Exemplo n.º 5
0
        public static CacheSession Open(HttpSessionStateBase Session)
        {
            SesRequest = null;
            if (Sessions.TryGetValue(GetSessionID(Session), out CacheSession cacheSession))
            {
                return(cacheSession);
            }

            cacheSession = new CacheSession
            {
                Session = Session
            };

            Sessions.Add(GetSessionID(Session), cacheSession);

            return(cacheSession);
        }
Exemplo n.º 6
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            #region 自定义Session 这里使用了长连接,接入了其他服务,改成可以直接独立运行的版本。

            //ShellSession.InitSession<RedisSession>();

            //services.AddDiySession(c =>
            //{
            //    c.GetDiySession<RedisSession>();
            //});

            //services.AddObject(TcpFrame.CreateServer(AppSettings.Get("ServerIp"), 888));

            #endregion

            #region 自定义Session 独立运行版本,0.0.1

            ShellSession.InitSession <CacheSession>();

            services.AddDiySession(c =>
            {
                c.GetDiySession <CacheSession>();
            });

            CacheSession.StartKeep(1); // 每秒一次自检测

            #endregion

            services.AddResponseCompression();

            services.AddAshx(o =>
            {
                //o.IsAsync = true;
                o.JsonOptions = new()// System.Text.Json.JsonSerializerOptions(System.Text.Json.JsonSerializerDefaults.Web)
                {
                    //IgnoreReadOnlyFields = true,
                    Encoder = System.Text.Encodings.Web.JavaScriptEncoder.Create(System.Text.Unicode.UnicodeRanges.All),
                };

                //o.JsonOptions.Converters.Add(JsonConverterHelper.GetDateConverter());
                o.JsonOptions.Converters.Add(JsonConverterHelper.GetDBNullConverter());
            });//注册api。
               //.AddHttpContext();//注册静态方式的HttpContext对象获取。

            services.AddObject(new UpLoad());//上传有关配置注册
        }
        public Task Activated(IMessageContainer groupOrChat, CacheSession cacheSession, IPluginUIIntegration integration, Action <CacheSession> cleanup)
        {
            var mainWindow = new MainWindow(); // application entry point
            var vm         = new MainWindowViewModel(groupOrChat, cacheSession);

            mainWindow.DataContext = vm;

            System.Windows.Application.Current.Dispatcher.Invoke(() =>
            {
                mainWindow.ShowDialog();
            });

            mainWindow.Closing += (s, e) =>
            {
                cleanup(cacheSession);
            };

            return(Task.CompletedTask);
        }
        public Task Activated(IMessageContainer groupOrChat, CacheSession cacheSession, IPluginUIIntegration integration, Action <CacheSession> cleanup)
        {
            var dataContext = new MainWindowViewModel(groupOrChat, cacheSession, integration);
            var window      = new MainWindow
            {
                DataContext = dataContext,
            };

            window.Closing += (s, e) =>
            {
                cleanup(cacheSession);
            };

            System.Windows.Application.Current.Dispatcher.Invoke(() =>
            {
                window.Show();
            });

            return(Task.CompletedTask);
        }