Esempio n. 1
0
        public HttpResponseMessage PostProjectTab(ProjectTab projectTab)
        {
            var lstProj    = GetProjectTabs();
            var project_id = 1;

            if (lstProj != null && lstProj.Count() > 0)
            {
                project_id = lstProj.Max(x => x.Project_ID) + 1;
            }

            projectTab.Project_ID = project_id;

            db.ProjectTabs.Add(projectTab);



            try
            {
                db.SaveChanges();

                if (projectTab.Manager != null)
                {
                    projectTab.Manager.Project_ID = project_id;
                    var usersTabController = new UsersTabsController();
                    usersTabController.Put(projectTab.Manager);
                }

                var message = Request.CreateResponse(HttpStatusCode.Created, projectTab);
                return(message);
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ex));
            }
        }
        public void PostTaskTab()
        {
            var projectTab = new ProjectTab();

            projectTab.Project   = "CreatedTestProject";
            projectTab.StartDate = new System.DateTime(2019, 07, 30);
            projectTab.EndDate   = new System.DateTime(2019, 07, 31);
            projectTab.Priority  = 10;

            projectTab.Manager = new UsersTab
            {
                User_ID     = 1,
                FirstName   = "Niraj",
                LastName    = "Kheria",
                Employee_ID = 123456,
                Task_ID     = 3,
                Project_ID  = 1
            };

            var projectCtrl = new ProjectTabsController();

            projectCtrl.Request       = new HttpRequestMessage();
            projectCtrl.Configuration = new HttpConfiguration();
            var tsk = projectCtrl.PostProjectTab(projectTab);

            Assert.AreEqual(tsk.ReasonPhrase, "Created");
        }
Esempio n. 3
0
        // PUT: api/ProjectTabs/5

        public HttpResponseMessage Put(ProjectTab projectTab)
        {
            db.Entry(projectTab).State = EntityState.Modified;

            try
            {
                if (projectTab.Manager != null)
                {
                    projectTab.Manager.Project_ID = projectTab.Project_ID;
                    var usersTabController = new UsersTabsController();
                    var proj        = this.GetProjectTab(projectTab.Project_ID);
                    var prevManager = usersTabController.GetUsersTabs().FirstOrDefault
                                          (x => x.Project_ID == proj.Project_ID);

                    if (prevManager != null && prevManager.Project_ID != null && prevManager.User_ID != projectTab.Manager.User_ID)
                    {
                        prevManager.Project_ID = (int?)null;
                        usersTabController.Put(prevManager);
                        usersTabController.Put(projectTab.Manager);
                    }
                }

                db.SaveChanges();



                var message = Request.CreateResponse(HttpStatusCode.Created, projectTab);
                return(message);
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ex));
            }
        }
Esempio n. 4
0
        private void bunifuThinButton23_Click(object sender, EventArgs e)
        {
            ProjectTab tab = new ProjectTab();

            tab.Visible = true;
            tab.StartInfo();
            Controls.Add(tab);
            tab.Dock = DockStyle.Fill;
            tab.BringToFront();
        }
        public Project[] Open(string prjfile)
        {
            prjfile = Path.GetFullPath(prjfile);

            if (!File.Exists(prjfile))
            {
                return(null);
            }

            Environment.CurrentDirectory = Path.GetDirectoryName(prjfile);

            foreach (MRUFile mru in recentfiles)
            {
                if (string.Compare(mru.filename, prjfile, true) == 0)
                {
                    mru.Update();
                    goto DONE;
                }
            }
            recentfiles.Add(new MRUFile(prjfile));

DONE:

            string ext = Path.GetExtension(prjfile);

            if (ext == ".xaccproj")
            {
                BuildService bm = ServiceHost.Build as BuildService;
                bm.solution = new Microsoft.Build.BuildEngine.Project();
                bm.solution.Load(prjfile);

                bm.solution.GlobalProperties["SolutionDir"] = new BuildProperty("SolutionDir", Path.GetDirectoryName(prjfile) + Path.DirectorySeparatorChar);


                ArrayList projects = new ArrayList();

                foreach (BuildItem prj in bm.solution.GetEvaluatedItemsByName("BuildProject"))
                {
                    Environment.CurrentDirectory = Path.GetDirectoryName(prjfile);

                    Project bp = new Project();

                    bp.SolBuildItem = prj;

                    bp.Load(prj.Include);

                    //bp.SolutionDir = Path.GetDirectoryName(prjfile) + Path.DirectorySeparatorChar;
                    bp.ProjectCreated();
                    Add(bp);
                    bp.OnOpened();

                    projects.Add(bp);

                    if (Opened != null)
                    {
                        Opened(bp, EventArgs.Empty);
                    }
                }

                if (File.Exists(Path.ChangeExtension(prjfile, ".xaccdata")))
                {
                    ServiceHost.Window.Document.Load(Path.ChangeExtension(prjfile, ".xaccdata"));
                }
                else
                {
                    ProjectTab.Show();
                }
                return(projects.ToArray(typeof(Project)) as Project[]);
            }
            else if (ext.EndsWith("proj"))
            {
                Project bp = new Project();

                bp.Load(prjfile);

                bp.MSBuildProject.GlobalProperties["SolutionDir"] = new BuildProperty("SolutionDir", Path.GetDirectoryName(prjfile) + Path.DirectorySeparatorChar);

                bp.ProjectCreated();
                Add(bp);
                bp.OnOpened();

                if (Opened != null)
                {
                    Opened(bp, EventArgs.Empty);
                }
                ProjectTab.Show();

                return(new Project[] { bp });
            }
            else if (ext == ".sln")
            {
                BuildService bm = ServiceHost.Build as BuildService;
                bm.solution = new Microsoft.Build.BuildEngine.Project();

                bm.solution.GlobalProperties["SolutionDir"] = new BuildProperty("SolutionDir", Path.GetDirectoryName(prjfile) + Path.DirectorySeparatorChar);

                using (TextReader r = new StreamReader(prjfile, Encoding.Default, true))
                {
                    string all = r.ReadToEnd();

                    foreach (Match m in SLNPARSE.Matches(all))
                    {
                        string name = m.Groups["name"].Value;
                        if (name == "Solution Items")
                        {
                            continue;
                        }
                        string location = m.Groups["location"].Value;

                        if (File.Exists(Path.Combine(Path.GetDirectoryName(prjfile), location)))
                        {
                            bm.solution.AddNewItem("BuildProject", location);
                        }
                    }
                }

                bm.solution.AddNewImport(Path.Combine(Application.StartupPath, "xacc.imports"), "");

                bm.solution.Save(Path.ChangeExtension(prjfile, ".xaccproj"));

                ArrayList projects = new ArrayList();

                foreach (BuildItem prj in bm.solution.GetEvaluatedItemsByName("BuildProject"))
                {
                    Environment.CurrentDirectory = Path.GetDirectoryName(prjfile);

                    Project bp = new Project();

                    bp.Load(prj.Include);
                    bp.SolBuildItem = prj;
                    bp.ProjectCreated();

                    //bp.SolutionDir = Path.GetDirectoryName(prjfile) + Path.DirectorySeparatorChar;

                    Add(bp);
                    bp.OnOpened();

                    projects.Add(bp);

                    if (Opened != null)
                    {
                        Opened(bp, EventArgs.Empty);
                    }
                }
                ServiceHost.State |= ApplicationState.Project;
                ProjectTab.Show();

                return(projects.ToArray(typeof(Project)) as Project[]);
            }
            else
            {
                return(null);
            }
        }