Ejemplo n.º 1
0
 private void ShowForm()
 {
     if (this.MainForm == null)
     {
         this.MainForm = new MainForm(ConfigSystem.GetSettingPort());
         (this.MainForm as MainForm).SetSize(ConfigSystem.GetWIndowSize());
     }
     (this.MainForm as MainForm).Booting();
 }
Ejemplo n.º 2
0
        private void GetSetting(WSNode node)
        {
            var obj = new
            {
                Port  = ConfigSystem.GetSettingPort(),
                Size  = ConfigSystem.GetWIndowSize(),
                Start = ConfigSystem.GetWindowStart()
            };

            String json = JsonConvert.SerializeObject(obj);

            node.Data = json;
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            string mtxName = "PrivateTaskManager";
            Mutex  mtx     = new Mutex(true, mtxName);

            TimeSpan tsWait  = new TimeSpan(0, 0, 1);
            bool     success = mtx.WaitOne(tsWait);

            if (!success)
            {
                String         port    = ConfigSystem.GetSettingPort();
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://localhost:" + port + "/Start");
                using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                {
                    Console.WriteLine(response.StatusCode);
                }
                return;
            }
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainContext());
        }
Ejemplo n.º 4
0
        public MainContext()
        {
            ORMFactory.Initialize();
            this.components         = new Container();
            this.notify             = new NotifyIcon(this.components);
            this.notify.Icon        = new Icon(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "favicon.ico"));
            this.notify.Visible     = true;
            this.notify.ContextMenu = new ContextMenu();
            this.notify.ContextMenu.MenuItems.AddRange(SetMenuItem());

            this.notify.Text = "Private Task Management";
            ThreadPool.QueueUserWorkItem(c =>
            {
                int port = 9999;
                try
                {
                    port = Convert.ToInt32(ConfigSystem.GetSettingPort());
                }
                catch { }
                string path = Path.GetDirectoryName(Application.ExecutablePath);
                var server  = ServerFactory.NewInstance(port);
                var flow    = new Flow();
                var message = new Message(this);
                server.SetDefaultFile("index.html");
                server.SetZip(path + "\\html.data");
                //server.SetRootPath(webpath);

                /*server.Set("/", (res, req) =>
                 * {
                 *  //req.SetCookie("test", "aaa", DateTime.Now.AddMinutes(5));
                 *  //req.SetSession("aaaaa", "asdfasfd");
                 *  req.ReadFile(webpath + @"\index.html");
                 * });*/
                server.Set("/js/define.js", (res, req) =>
                {
                    req.ContextType = "text / javascript; charset = UTF - 8";
                    req.Body        = "var wsurl = \"ws://localhost:" + Convert.ToInt32(ConfigSystem.GetSettingPort()) + "/menu\";";
                });
                server.Set("/Start", (res, req) =>
                {
                    ShowForm();
                    req.StateOK();
                });
                server.SetWebSocket(mes =>
                {
                    Console.WriteLine(mes);
                    WSNode node = WSNode.ToNode(mes.ToString());
                    if (node.Type == 1)
                    {
                        flow.Execute(node.Key, node);
                    }
                    else if (node.Type == 2)
                    {
                        message.Execute(node.Key, node);
                    }
                    return(new WebSocketNode()
                    {
                        OPCode = Opcode.BINARY, Message = node.ToString2()
                    });
                });
            });
            if (String.Equals(ConfigSystem.GetWindowStart(), "on"))
            {
                ShowForm();
            }
        }