Exemplo n.º 1
0
        private void SetTaskDelete(WSNode node)
        {
            ITaskDao dao  = ORMFactory.GetService <ITaskDao>(typeof(ITaskDao));
            String   temp = node.Data;
            var      map  = GetParameter(node.Data);
            int      idx  = -1;

            if (!map.ContainsKey("idx"))
            {
                Error(node);
                return;
            }
            try
            {
                idx = Convert.ToInt32(map["idx"]);
            }
            catch
            {
                return;
            }
            Task task = dao.GetEntity(idx);

            task.IsDelete = 1;
            //dao.Delete(task);
            dao.Update(task);
            node.Data = "";
        }
Exemplo n.º 2
0
        public virtual int Save()
        {
            SqlParameter[] parameters;
            String         insert = ORMFactory.BuildInsertSql(this, out parameters);

            return(SqlHelper.ExecuteNonQuery(insert, parameters));
        }
Exemplo n.º 3
0
        private void SetTaskInsert(WSNode node)
        {
            ITaskDao dao  = ORMFactory.GetService <ITaskDao>(typeof(ITaskDao));
            String   temp = node.Data;
            Task     task = new Task();
            var      map  = GetParameter(node.Data);

            if (!map.ContainsKey("title"))
            {
                Error(node);
                node.Data = "Title is nothing.";
                return;
            }
            task.Title    = map["title"];
            task.Contents = map.ContainsKey("contents") && !String.IsNullOrEmpty(map["contents"].Trim()) ? map["contents"] : "";
            try
            {
                task.Importance = map.ContainsKey("importance") && !String.IsNullOrEmpty(map["importance"].Trim()) ? Convert.ToInt32(map["importance"]) : 2;
            }
            catch
            {
                task.Importance = 2;
            }
            task.Tasktype = 0;
            task.Taskdate = DateTime.Now;
            task.IsDelete = 0;
            int scope = dao.InsertAndScope(task);

            task.Idx  = scope;
            node.Data = JsonConvert.SerializeObject(task);
        }
Exemplo n.º 4
0
        private void ExcuteMemoDelete(WSNode node)
        {
            IMemoDao dao    = ORMFactory.GetService <IMemoDao>(typeof(IMemoDao));
            int      idx    = Convert.ToInt32(node.Data);
            var      entity = dao.GetEneity(idx);

            dao.Delete(entity);
        }
Exemplo n.º 5
0
        public int CreateTable()
        {
            if (SqlHelper.ExistTable(ORMUtils.GetTableName(this)))
            {
                return(0);
            }
            String create = ORMFactory.BuildCreateSql(this);

            return(SqlHelper.ExecuteNonQuery(create));
        }
Exemplo n.º 6
0
        private void SetProcess(WSNode node)
        {
            ITaskDao dao      = ORMFactory.GetService <ITaskDao>(typeof(ITaskDao));
            Task     entity   = JsonConvert.DeserializeObject <Task>(node.Data);
            Task     original = dao.GetEntity(entity.Idx);

            original.Tasktype = entity.Tasktype;
            original.Taskdate = DateTime.Now;
            dao.Update(original);
            node.Data = JsonConvert.SerializeObject(original);
        }
Exemplo n.º 7
0
        public virtual int Update()
        {
            if (ID.Length == 0)
            {
                return(0);
            }
            SqlParameter[] parameters;
            String         update = ORMFactory.BuildUpdateSql(this, ID, out parameters);

            return(SqlHelper.ExecuteNonQuery(update, parameters));
        }
Exemplo n.º 8
0
        public virtual int Delete()
        {
            if (ID.Length == 0)
            {
                return(0);
            }
            SqlParameter parameter;
            String       delete = ORMFactory.BuildDeleteSql(this, ID, out parameter);

            return(SqlHelper.ExecuteNonQuery(delete, new SqlParameter[] { parameter }));
        }
Exemplo n.º 9
0
        private void GetTaskList(WSNode node)
        {
            DateTime now;

            try
            {
                String[] temp = node.Data.Split('/');
                for (int i = 0; i < temp.Length; i++)
                {
                    temp[i] = temp[i].Trim();
                }
                now = new DateTime(Convert.ToInt32(temp[0]), Convert.ToInt32(temp[1]), Convert.ToInt32(temp[2]));
            }
            catch
            {
                now = DateTime.Now;
            }
            ITaskDao    dao  = ORMFactory.GetService <ITaskDao>(typeof(ITaskDao));
            List <Task> list = dao.Select() as List <Task>;

            list = list.OrderBy(t =>
            {
                return(t.Tasktype);
            }).Where(t =>
            {
                if (t.IsDelete == 1)
                {
                    return(false);
                }
                if (Util.DayTick(t.Taskdate) > Util.DayTick(now))
                {
                    return(false);
                }
                if (Util.DayTick(t.Taskdate) < Util.DayTick(now) && t.Tasktype == 2)
                {
                    return(false);
                }
                return(true);
            }).OrderBy(t =>
            {
                return(t.Importance);
            }).ToList();
            list.ForEach(t =>
            {
                if (Util.DayTick(t.Taskdate) != Util.DayTick(now))
                {
                    t.Tasktype = 4;
                }
            });
            string json = JsonConvert.SerializeObject(list);

            node.Data = json;
        }
Exemplo n.º 10
0
        private void GetMemoList(WSNode node)
        {
            IMemoDao dao  = ORMFactory.GetService <IMemoDao>(typeof(IMemoDao));
            var      list = dao.Select();

            list = list.OrderByDescending((m) =>
            {
                return(m.RecentlyDate);
            }).ToList();
            string json = JsonConvert.SerializeObject(list);

            node.Data = json;
        }
Exemplo n.º 11
0
        private void SetMemoInsert(WSNode node)
        {
            IMemoDao dao  = ORMFactory.GetService <IMemoDao>(typeof(IMemoDao));
            String   temp = node.Data;
            Memo     memo = new Memo();
            var      map  = GetParameter(node.Data);

            memo.Title        = map.ContainsKey("title") && !String.IsNullOrEmpty(map["title"].Trim()) ? map["title"] : "No title";
            memo.Contents     = map.ContainsKey("contents") && !String.IsNullOrEmpty(map["contents"].Trim()) ? map["contents"] : "";
            memo.RecentlyDate = DateTime.Now;
            int scope = dao.InsertAndScope(memo);

            node.Data = scope.ToString();
        }
Exemplo n.º 12
0
        private void SetMemoModify(WSNode node)
        {
            IMemoDao dao  = ORMFactory.GetService <IMemoDao>(typeof(IMemoDao));
            String   temp = node.Data;
            Memo     memo = new Memo();
            var      map  = GetParameter(node.Data);

            memo.Idx          = Convert.ToInt32(map["idx"]);
            memo              = dao.GetEneity(memo.Idx);
            memo.Title        = map.ContainsKey("title") && !String.IsNullOrEmpty(map["title"].Trim()) ? map["title"] : "No title";
            memo.Contents     = map.ContainsKey("contents") && !String.IsNullOrEmpty(map["contents"].Trim()) ? map["contents"] : "";
            memo.RecentlyDate = DateTime.Now;
            dao.Update(memo);
        }
Exemplo n.º 13
0
        private void GetMemoItem(WSNode node)
        {
            int idx;

            try
            {
                idx = Convert.ToInt32(node.Data);
            }
            catch (Exception)
            {
                Error(node);
                return;
            }
            IMemoDao dao  = ORMFactory.GetService <IMemoDao>(typeof(IMemoDao));
            var      item = dao.GetEneity(idx);

            node.Data = JsonConvert.SerializeObject(item);
        }
Exemplo n.º 14
0
        private void SetTaskModify(WSNode node)
        {
            ITaskDao dao  = ORMFactory.GetService <ITaskDao>(typeof(ITaskDao));
            String   temp = node.Data;
            var      map  = GetParameter(node.Data);
            int      idx  = -1;

            if (!map.ContainsKey("idx"))
            {
                Error(node);
                return;
            }
            try
            {
                idx = Convert.ToInt32(map["idx"]);
            }
            catch
            {
                return;
            }
            Task task = dao.GetEntity(idx);

            if (!map.ContainsKey("title"))
            {
                Error(node);
                node.Data = "Title is nothing.";
                return;
            }
            task.Title    = map["title"];
            task.Contents = map.ContainsKey("contents") && !String.IsNullOrEmpty(map["contents"].Trim()) ? map["contents"] : "";
            if (map.ContainsKey("importance") && !String.IsNullOrEmpty(map["importance"].Trim()))
            {
                try
                {
                    task.Importance = Convert.ToInt32(map["importance"]);
                }
                catch
                {
                }
            }
            dao.Update(task);
        }
Exemplo n.º 15
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();
            }
        }