예제 #1
0
    //TODO: IDEA: Make debug menu to set the position of the model through the view to make it easier to debug through the editor

    protected override void OnViewReady()
    {
        ViewDeltaTransform       = new EntityTransform();
        ViewDeltaTransform.Scale = Vector3.zero;

        SelfModel = MVCUtil.GetModel <EntityModel>(this);
    }
예제 #2
0
        public ActionResult Program()
        {
            if (!UserValid())
            {
                return(RedirectToAction("Index", "Home"));
            }
            ProgramService ProgramSvc = new ProgramService();

            ViewBag.Title = "Program";
            ViewData      = MVCUtil.PopulateCRUDViewData(typeof(program), "Program", ProgramSvc, Request, ViewData);
            return(View("~/Views/Shared/EntityMng.cshtml"));
        }
예제 #3
0
        public ActionResult Member()
        {
            if (!UserValid())
            {
                return(RedirectToAction("Index", "Home"));
            }
            MemberService MemberSvc = new MemberService();

            ViewBag.Title = "Member";
            ViewData      = MVCUtil.PopulateCRUDViewData(typeof(member), "Member", MemberSvc, Request, ViewData);
            return(View("~/Views/Shared/EntityMng.cshtml"));
        }
예제 #4
0
        public ActionResult Section()
        {
            if (!UserValid())
            {
                return(RedirectToAction("Index", "Home"));
            }
            SectionService SectionSvc = new SectionService();

            ViewBag.Title = "Section";
            ViewData      = MVCUtil.PopulateCRUDViewData(typeof(section), "Section", SectionSvc, Request, ViewData);
            return(View("~/Views/Shared/EntityMng.cshtml"));
        }
예제 #5
0
        public ActionResult Post()
        {
            if (!UserValid())
            {
                return(RedirectToAction("Index", "Home"));
            }
            PostService PostSvc = new PostService();

            ViewData      = MVCUtil.EnableTimeLine("Post", "title", "date", ViewData);
            ViewBag.Title = "Post";
            ViewData      = MVCUtil.PopulateCRUDViewData(typeof(post), "Post", PostSvc, Request, ViewData);
            return(View("~/Views/Shared/EntityMng.cshtml"));
        }
예제 #6
0
        public ActionResult DivisionSvc()
        {
            bool        Access   = UserValid() && IsAdmin();
            WebResponse Response = new WebResponse();

            if (!Access || !StringUtil.NotNullAndNotBlank(Request.Form["Action"]))
            {
                return(Json(Response));
            }
            string          Action    = Request.Form["Action"].ToString();
            DivisionService EntitySvc = new DivisionService();

            switch (Action)
            {
            case "List":
                Response = MVCUtil.generateResponseList(EntitySvc, Request, LoggedUser, new string[]
                {
                    "id", "name", "description", "institution_id"
                }, typeof(division));

                break;

            case "Form":
                Response = MVCUtil.generateResponseWithForm(typeof(division), EntitySvc, Request);
                break;

            case "Post":
                division Division = (division)ObjectUtil.FillObjectWithMap(new division(), BaseService.ReqToDict(Request));
                if (Division != null)
                {
                    Division.institution_id = LoggedUser.institution_id;

                    string[] ObjParamToSend = new string[] {
                        "id", "name", "description", "institution_id"
                    };
                    Response = MVCUtil.UpdateEntity(EntitySvc, Division, ObjParamToSend, Response);
                }
                break;

            case "Delete":
                Response = MVCUtil.DeleteEntity(EntitySvc, Request, Response);
                break;

            default:
                break;
            }
            return(Json(Response));
        }
예제 #7
0
        public ActionResult EventSvc()
        {
            bool        Access   = UserValid();
            WebResponse Response = new WebResponse();

            if (!Access || !StringUtil.NotNullAndNotBlank(Request.Form["Action"]))
            {
                return(Json(Response));
            }
            string       Action    = Request.Form["Action"].ToString();
            EventService EntitySvc = new EventService();

            switch (Action)
            {
            case "List":
                Response = MVCUtil.generateResponseList(EntitySvc, Request, LoggedUser, new string[]
                {
                    "id", "program_id", "user_id", "date", "location", "participant", "info", "done", "name"
                }, typeof(@event));
                break;

            case "Form":
                Response = MVCUtil.generateResponseWithForm(typeof(@event), EntitySvc, Request);
                break;

            case "Post":
                @event Event = (@event)ObjectUtil.FillObjectWithMap(new @event(), BaseService.ReqToDict(Request));
                if (Event != null)
                {
                    Event.user_id = LoggedUser.id;
                    string[] ObjParamToSend = new string[] {
                        "id", "program_id", "user_id", "date", "location", "participant", "info", "done", "name"
                    };
                    Response = MVCUtil.UpdateEntity(EntitySvc, Event, ObjParamToSend, Response);
                }
                break;

            case "Delete":
                Response = MVCUtil.DeleteEntity(EntitySvc, Request, Response);
                break;

            default:
                break;
            }
            return(Json(Response));
        }
예제 #8
0
        public ActionResult ProgramSvc()
        {
            bool        Access   = UserValid();
            WebResponse Response = new WebResponse();

            if (!Access || !StringUtil.NotNullAndNotBlank(Request.Form["Action"]))
            {
                return(Json(Response));
            }
            string         Action    = Request.Form["Action"].ToString();
            ProgramService EntitySvc = new ProgramService();

            switch (Action)
            {
            case "List":
                Response = MVCUtil.generateResponseList(EntitySvc, Request, LoggedUser, new string[]
                {
                    "id", "name", "description", "sect_id"
                }, typeof(program));
                break;

            case "Form":
                Response = MVCUtil.generateResponseWithForm(typeof(program), EntitySvc, Request);
                break;

            case "Post":
                program Program = (program)ObjectUtil.FillObjectWithMap(new program(), BaseService.ReqToDict(Request));
                if (Program != null)
                {
                    string[] ObjParamToSend = new string[] {
                        "id", "name", "description", "sect_id"
                    };
                    Response = MVCUtil.UpdateEntity(EntitySvc, Program, ObjParamToSend, Response);
                }
                break;

            case "Delete":
                Response = MVCUtil.DeleteEntity(EntitySvc, Request, Response);
                break;

            default:
                break;
            }
            return(Json(Response));
        }
예제 #9
0
        public ActionResult UserSvc()
        {
            bool        Access   = UserValid() && IsAdmin();
            WebResponse Response = new WebResponse();

            if (LoggedUser.admin != 1 || !Access || !StringUtil.NotNullAndNotBlank(Request.Form["Action"]))
            {
                return(Json(Response));
            }
            string      Action    = Request.Form["Action"].ToString();
            UserService EntitySvc = new UserService();

            switch (Action)
            {
            case "List":
                Response = MVCUtil.generateResponseList(EntitySvc, Request, LoggedUser, new string[]
                {
                    "id", "name", "username", "password", "email"
                }, typeof(user));
                break;

            case "Form":
                Response = MVCUtil.generateResponseWithForm(typeof(user), EntitySvc, Request);
                break;

            case "Post":
                user User = (user)ObjectUtil.FillObjectWithMap(new user(), BaseService.ReqToDict(Request));
                User.institution_id = LoggedUser.institution_id;
                if (User != null)
                {
                    Response = MVCUtil.UpdateEntity(EntitySvc, User, new string[] {
                        "id", "name", "username", "password", "email"
                    }, Response);
                }
                break;

            case "Delete":
                Response = MVCUtil.DeleteEntity(EntitySvc, Request, Response);
                break;

            default:
                break;
            }
            return(Json(Response));
        }
예제 #10
0
        public ActionResult PositionSvc()
        {
            bool        Access   = UserValid() && IsAdmin();
            WebResponse Response = new WebResponse();

            if (!Access || !StringUtil.NotNullAndNotBlank(Request.Form["Action"]))
            {
                return(Json(Response));
            }
            string          Action    = Request.Form["Action"].ToString();
            PositionService EntitySvc = new PositionService();

            switch (Action)
            {
            case "List":
                Response = MVCUtil.generateResponseList(EntitySvc, Request, LoggedUser, new string[]
                {
                    "id", "name", "description", "section_id", "parent_position_id"
                }, typeof(position));
                break;

            case "Form":
                Response = MVCUtil.generateResponseWithForm(typeof(position), EntitySvc, Request);
                break;

            case "Post":
                position position = (position)ObjectUtil.FillObjectWithMap(new position(), BaseService.ReqToDict(Request));
                if (position != null)
                {
                    Response = MVCUtil.UpdateEntity(EntitySvc, position, new string[] {
                        "id", "name", "description", "section_id", "parent_position_id"
                    }, Response);
                }
                break;

            case "Delete":
                Response = MVCUtil.DeleteEntity(EntitySvc, Request, Response);
                break;

            default:
                break;
            }
            return(Json(Response));
        }
예제 #11
0
        public ActionResult Event()
        {
            if (!UserValid())
            {
                return(RedirectToAction("Index", "Home"));
            }
            EventService EventSvc = new EventService();

            //enable timeline
            ViewData = MVCUtil.EnableTimeLine("Event", "name", "date", ViewData);
            //ViewData["EnableTimeLine"] = true;
            //ViewData["Entity"] = "Event";
            //ViewData["DateId"] = "date";
            //

            ViewBag.Title = "Event";
            ViewData      = MVCUtil.PopulateCRUDViewData(typeof(@event), "Event", EventSvc, Request, ViewData);
            return(View("~/Views/Shared/EntityMng.cshtml"));
        }
예제 #12
0
 protected override void OnViewReady()
 {
     base.OnViewReady();
     _model = MVCUtil.GetModel <TurretModel>(this);
     _model.TargetSetEvent += OnTargetSetEvent;
 }
예제 #13
0
 protected override void OnViewDestroy()
 {
     MVCUtil.GetModel <AIModel>(this).StateSetEvent -= OnStateSetEvent;
     OnStateSetEvent(null);
 }
예제 #14
0
 protected override void OnViewReady()
 {
     _waveSystemModel = MVCUtil.GetModel <WaveSystemModel>(this);
     _waveSystemModel.SpawnEnemyEvent += OnSpawnEnemyEvent;
 }
예제 #15
0
        public async Task <ActionResult> PostSvc()
        {
            bool        Access   = UserValid();
            WebResponse Response = new WebResponse();

            if (/*!Access || */ !StringUtil.NotNullAndNotBlank(Request.Form["Action"]))
            {
                return(Json(Response));
            }
            string      Action    = Request.Form["Action"].ToString();
            PostService EntitySvc = new PostService();

            Dictionary <string, object> PostProps = new Dictionary <string, object>()
            {
                { "id", null },
                { "user_id", null },
                { "title", null },
                { "body", null },
                { "date", null },
                { "user", new Dictionary <string, object> {
                      { "name", null }
                  } },
                { "type", null },
                { "post_id", null }
            };

            switch (Action)
            {
            case "List":
                string Scope    = Request.Form["Scope"];
                bool   isPublic = (Scope != null && Scope.Equals("Public"))
                ;
                Response = MVCUtil.generateResponseList(EntitySvc, Request, LoggedUser, PostProps, typeof(post), isPublic);
                break;

            case "Form":
                if (!Access)
                {
                    return(Json(Response));
                }
                Response = MVCUtil.generateResponseWithForm(typeof(post), EntitySvc, Request);
                break;

            case "Post":
                if (!Access)
                {
                    return(Json(Response));
                }
                post post = (post)ObjectUtil.FillObjectWithMap(new post(), BaseService.ReqToDict(Request));
                post.user_id = LoggedUser.id;
                if (post != null)
                {
                    Response = MVCUtil.UpdateEntity(EntitySvc, post, new string[] {
                        "id", "user_id", "title", "body", "date", "type", "post_id"
                    }, Response);
                }
                break;

            case "Delete":
                if (!Access)
                {
                    return(Json(Response));
                }
                Response = MVCUtil.DeleteEntity(EntitySvc, Request, Response);
                break;

            case "Latest":
                // if (!Access) return Json(Response);
                string DateStr     = Request.Form["timestamp"];
                post   CurrentPost = EntitySvc.findLatestPost();
                if (CurrentPost != null)
                {
                    DateTime Date = CurrentPost.created_date;
                    DateStr = DateStr.Replace("T", " ");
                    DateStr = DateStr.Replace("Z", "");
                    DateStr = DateStr.Replace("-", "");
                    try
                    {
                        Date = DateTime.ParseExact(DateStr, "yyyyMMdd HH:mm:ss.fff", CultureInfo.InvariantCulture);
                    }catch (Exception ex)
                    {
                        Date = CurrentPost.created_date;
                    }
                    post     LatestPost  = new post();
                    DateTime requestTime = DateTime.Now;
                    DateTime runningTime;

                    Boolean update    = true;
                    bool    hasUpdate = Date <= CurrentPost.created_date;
                    while (CurrentPost.created_date <= Date)
                    {
                        runningTime = DateTime.Now;
                        LatestPost  = EntitySvc.findLatestPost();
                        if (LatestPost != null)
                        {
                            Date = LatestPost.created_date;
                        }
                        TimeSpan deltaTime = runningTime - requestTime;
                        if (deltaTime.TotalMilliseconds >= 6000.0)
                        {
                            update = false;
                            break;
                        }
                    }

                    Response = new WebResponse(update ? 0 : 1, StringUtil.DateTimeToString(DateTime.Now),
                                               ObjectUtil.GetObjectValues(new string[] { "id", "title" }, LatestPost));
                }
                else
                {
                    Response = new WebResponse(0, "NoUpdate");
                }
                break;

            default:
                break;
            }
            return(Json(Response));
        }
예제 #16
0
 protected override void OnViewReady()
 {
     _model = MVCUtil.GetModel <TimekeeperModel>(this);
 }
예제 #17
0
 protected override void OnViewReady()
 {
     MVCUtil.GetModel <AIModel>(this).StateSetEvent += OnStateSetEvent;
 }