Beispiel #1
0
        public static async Task AcceptInvitation(ProjectModel project)
        {
            DictModel response = await Instance.ApiManager.AcceptInvitation(project.Id);

            App.User.JoinPotentialProject(project);
            project.AddMember(App.User);
        }
Beispiel #2
0
        /// <summary>
        /// 加载数据文件txt
        /// </summary>
        /// <param name="filePath"></param>
        public void LoadDictFile(string dirPath)
        {
            string         fileName = GetFileName();
            DictFileReader dfr      = new DictFileReader(string.Format("{0}/{1}", dirPath, fileName));

            bool bError = false;

            m_listCache = new List <DictModel>();
            string[] datas;
            do
            {
                datas = dfr.ReadRow();
                if (null != datas)
                {
                    DictModel t = ParseRowData(datas);
                    if (null != t)
                    {
                        m_listCache.Add(t);
                    }
                    else
                    {
                        bError = true;
                        break;
                    }
                }
            }while (null != datas);
            dfr.Close();

            if (bError)
            {
                LoggerHelper.Error(string.Format("{0} LoadDictFile Error!", dirPath));
            }
        }
Beispiel #3
0
        public static async Task RemoveUserFromTask(ProjectModel project, TaskModel task, UserModel user)
        {
            DictModel response = await Instance.ApiManager.RemoveUserFromTask(project.Id, task.Id, user.Id);

            response.EnsureValid();
            task.RemoveMember(user);
        }
Beispiel #4
0
        public static async Task DeclineInvitation(ProjectModel project)
        {
            DictModel response = await Instance.ApiManager.DeclineInvitation(project.Id);

            Debug.WriteLine(response.ToString());
            App.User.RemovePotentialProject(project);
        }
Beispiel #5
0
        public UserModel AddMember(DictModel dict)
        {
            var member = new UserModel(dict);

            _Members.Add(member);
            return(member);
        }
Beispiel #6
0
        public ProjectModel AddPotentialProject(DictModel dict)
        {
            var project = new ProjectModel(dict);

            _PotentialProjects.Add(project);
            return(project);
        }
Beispiel #7
0
        public TaskModel AddTask(DictModel dict, string listName)
        {
            List <TaskModel> list = null;

            if (listName == "todo")
            {
                list = _TasksTodo;
            }
            else if (listName == "doing")
            {
                list = _TasksDoing;
            }
            else if (listName == "done")
            {
                list = _TasksDone;
            }

            if (list != null)
            {
                var task = new TaskModel(dict, Members);
                list.Add(task);
                return(task);
            }
            return(null);
        }
Beispiel #8
0
        private async Task AddMembers()
        {
            DictModel response = await OverlayForm(new TaskMemberForm (MasterFragment.projectContext, task));

            if (response != null)
            {
                UserModel member = null;
                foreach (var m in MasterFragment.projectContext.Members)
                {
                    if (m.Id == response.i("id"))
                    {
                        member = m;
                        break;
                    }
                }
                if (member != null)
                {
                    IsBusy = true;
                    try {
                        await App.AddUserToTask(MasterFragment.projectContext, task, member);

                        Refresh();
                    } catch (Exception ex) {
                        await DisplayAlert("Whoops", ex.Message, "OK");
                    }
                    IsBusy = false;
                }
            }
        }
Beispiel #9
0
        /********** CONSTRUCTOR **********/

        public TaskModel(DictModel dict, IReadOnlyList <UserModel> memberList)
        {
            Id          = dict.i("id");
            Title       = dict.s("title");
            Description = dict.s("description");
            ProjectId   = dict.i("project_id");

            foreach (var i in dict.l("members"))
            {
                DictModel d      = i.ToString();
                UserModel member = null;
                foreach (var m in memberList)
                {
                    if (m.Id == d.i("id"))
                    {
                        member = m;
                        break;
                    }
                }
                if (member != null)
                {
                    AddMember(member);
                }
            }
        }
Beispiel #10
0
        public async Task <DictModel> InviteUserToProject(string email, int projectId)
        {
            DictModel dict = new DictModel("invitation");

            dict.Add("email", email);

            return(await MakeRequestAsync(Globals.PROJECTS_URI + "/" + projectId + "/" + Globals.INVITATIONS_URI, dict, RequestMethod.POST));
        }
Beispiel #11
0
        public async Task <DictModel> CreateProject(string projectName)
        {
            DictModel dict = new DictModel("project");

            dict.Add("name", projectName);

            return(await MakeRequestAsync(Globals.PROJECTS_URI, dict, RequestMethod.POST));
        }
Beispiel #12
0
        public static async Task <ProjectModel> CreateProject(string projectName)
        {
            DictModel response = await Instance.ApiManager.CreateProject(projectName);

            response.EnsureValid();

            return(User.AddProject(response.s("project")));
        }
Beispiel #13
0
 public void UpdatePotentialProjects(DictModel dict)
 {
     _PotentialProjects.Clear();
     foreach (var p in dict.l("potential_projects"))
     {
         AddPotentialProject(p.ToString());
     }
 }
Beispiel #14
0
        public static async Task LeaveProject(ProjectModel project)
        {
            DictModel response = await Instance.ApiManager.LeaveProject(project.Id);

            response.EnsureValid();

            User.RemoveProject(project);
        }
Beispiel #15
0
        public static async Task <TaskModel> CreateTask(DictModel taskDict, ProjectModel project)
        {
            taskDict.Add("project_id", project.Id);
            DictModel response = await Instance.ApiManager.CreateTask(taskDict);

            var task = project.AddTask(response.s("task"), taskDict.s("list"));

            return(task);
        }
Beispiel #16
0
        /********** CONTROL PANEL **********/

        public static async Task TryAutoLogin()
        {
            DictModel response = await Instance.ApiManager.AutoLogin();

            Debug.WriteLine("AutoLogin response: " + response.ToString());
            response.EnsureValid();

            User.UpdateWithJson(response.s("user"));
        }
Beispiel #17
0
        public static async Task Login(string email, string password)
        {
            DictModel response = await Instance.ApiManager.Login(email, password);

            Debug.WriteLine("Login response: " + response.ToString());
            response.EnsureValid();

            User.UpdateWithJson(response.s("user"));
            UseRootPage(new RootSessionPage());
        }
Beispiel #18
0
        public async Task <DictModel> AddUserToTask(int projectId, int taskId, int userId)
        {
            DictModel dict = new DictModel("user");

            dict.Add("id", userId);

            string uri = Globals.PROJECTS_URI + "/" + projectId + "/" + Globals.TASKS_URI + "/" + taskId + "/" + Globals.ASSIGNMENTS_URI;

            return(await MakeRequestAsync(uri, dict, RequestMethod.POST));
        }
Beispiel #19
0
        public static async Task Register(string email, string password, string username)
        {
            DictModel response = await Instance.ApiManager.Register(email, password, username);

            Debug.WriteLine("Register response: " + response.ToString());
            response.EnsureValid();

            User.UpdateWithJson(response.s("user"));
            UseRootPage(new RootSessionPage());
        }
Beispiel #20
0
        public async Task <DictModel> CreateTask(DictModel taskDict)
        {
            DictModel dict = new DictModel("task");

            dict.Add("title", taskDict.s("title"));
            dict.Add("description", taskDict.s("description"));
            dict.Add("list", taskDict.s("list"));

            string uri = Globals.PROJECTS_URI + "/" + taskDict.i("project_id") + "/" + Globals.TASKS_URI;

            return(await MakeRequestAsync(uri, dict, RequestMethod.POST));
        }
Beispiel #21
0
        private async Task AddTask()
        {
            DictModel dict = await OverlayForm(taskForm);

            if (dict != null)
            {
                dict.Add("list", listName);

                await App.CreateTask(dict, project);

                list.BeginRefresh();
            }
        }
Beispiel #22
0
        public ActionResult Save()
        {
            DictModel dict = new DictModel();

            dict = ObjectUtil.Eval(dict, Request.Params, "", "");
            if (string.IsNullOrEmpty(dict.id))
            {
                dict.id = dict.createPk().ToString();
            }
            JsResultObject result = BaseZdBiz.SaveOrUpdate(dict, "字典");

            return(JsonText(result, JsonRequestBehavior.AllowGet));
        }
Beispiel #23
0
        public void UpdateWithJson(string json)
        {
            DictModel dict = json;

            Id    = dict.i("id");
            Email = dict.s("email");

            foreach (var p in dict.l("projects"))
            {
                AddProject(p.ToString());
            }
            UpdatePotentialProjects(dict);
        }
Beispiel #24
0
        public override async Task <DictModel> GetResponse()
        {
            int success = await Success();

            if (success == 0)
            {
                return(null);
            }

            DictModel dict = new DictModel();

            dict.Add("id", selectedUser.Id);

            return(dict);
        }
Beispiel #25
0
        public void ImportDictList()
        {
            IList <ELongBaseCodeAdapter> basecodes = ELongStaticClient.GetBaseCodeList();

            //this.OpenSession();
            // ITransaction tx = this.session.BeginTransaction();
            foreach (ELongBaseCodeAdapter basecode in basecodes)
            {
                DictModel dict = new DictModel();
                dict.from(basecode);
                System.Console.WriteLine(string.Format("{0}:{1}:{2}", dict.type, dict.text, dict.value));
                BaseZdBiz.SaveOrUpdate(dict, "");
            }
            //tx.Commit();
        }
Beispiel #26
0
        public async Task <DictModel> Login(string email, string password)
        {
            DictModel dict = new DictModel("user");

            dict.Add("email", email);
            dict.Add("password", password);

            DictModel response = await MakeRequestAsync(Globals.SESSIONS_URI, dict, RequestMethod.POST);

            response.EnsureValid();
            string authentication_token = response.d("user").s("authentication_token", true);

            RegisterAuthenticationToken(authentication_token);
            return(response);
        }
Beispiel #27
0
        public override async Task <DictModel> GetResponse()
        {
            int success = await Success();

            if (success == 0)
            {
                return(null);
            }

            DictModel dict = new DictModel();

            dict.Add("title", titleEntry.Text);

            return(dict);
        }
Beispiel #28
0
        private async Task ShowProjectForm()
        {
            DictModel dict = await OverlayForm(projectForm);

            try {
                if (dict != null)
                {
                    await App.CreateProject(dict.s("title"));

                    list.BeginRefresh();
                }
            } catch (Exception ex) {
                Debug.WriteLine(ex.ToString());
                await DisplayAlert("Error creating project", ex.Message, "OK");
            }
        }
Beispiel #29
0
        public override async Task <DictModel> GetResponse()
        {
            int success = await Success();

            if (success == 0)
            {
                return(null);
            }

            DictModel dict = new DictModel();

            dict.Add("email", emailEntry.Text);
            dict.Add("password", passwordEntry.Text);

            return(dict);
        }
Beispiel #30
0
        private async Task ProjectActionSelected(ListView sender)
        {
            var a = (sender.SelectedItem as Label);

            if (a != null)
            {
                root.IsPresented    = false;
                sender.SelectedItem = null;
                //TODO: don't check by title
                if (a.Text == "Member list")
                {
                    var memberListPage = MakeNavPage(new MemberListPage(projectContext));
                    PageSelectedCallback.Invoke(memberListPage);
                }
                else if (a.Text == "Invite user to project")
                {
                    var      currentPage = (root.Detail as NavigationPage).CurrentPage;
                    BasePage theCurrentestPage;
                    if (currentPage is TabbedPage)
                    {
                        var theTabbedPage = currentPage as TabbedPage;
                        theCurrentestPage = theTabbedPage.CurrentPage as BasePage;
                    }
                    else
                    {
                        theCurrentestPage = currentPage as BasePage;
                    }

                    //TODO: WHAT'S THIS??
//					theTabbedPage.ToolbarItems

                    DictModel response = await theCurrentestPage.OverlayForm(new InvitationForm (projectContext));

                    if (response != null)
                    {
                        string email = response.s("email");
                        try {
                            await App.InviteUserToProject(email, projectContext.Id);
                            await DisplayAlert("Sweet!", "Successfully invited " + email + " to " + projectContext.Name, "OK");
                        } catch (Exception ex) {
                            await DisplayAlert("Sorry", ex.Message, "OK");
                        }
                    }
                }
            }
        }