Esempio n. 1
0
        public void NewProject(string projectname, string projectlocation)
        {
            m_projectPath = projectlocation  + projectname;
            m_ProjectName = projectname;
            if (Directory.Exists(m_projectPath))
                return;
            Directory.CreateDirectory(m_projectPath);
            // create maps directory
            Directory.CreateDirectory(m_projectPath + "\\Maps");

            // create database file
            m_databasefilepath = m_projectPath + "\\MapData.mdf";

            //string connectionstring = @"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Projects\AccessControl\WebSite\App_Data\permissions.mdf;Integrated Security=True;User Instance=True";
            CurrentProject = new Project("c:\\myfile.mdf");
            //CurrentProject.Connection.ConnectionString = "server=localhost\\;integrated security=SSPI;user instance=true;multipleactiveresultsets=true";
            CurrentProject.CreateDatabase();

            // create project Info file
            CurrentProjectInfo = new ProjectInfo();
            CurrentProjectInfo.ProjectFileVersion = "1.0";
            CurrentProjectInfo.ProjectName = projectname;
            CurrentProjectInfo.DatabaseFilePath = "/MapData.mdf";
            CurrentProjectInfo.DateCreated = DateTime.Now;
            CurrentProjectInfo.DateModified = DateTime.Now;
            CurrentProjectInfo.MapsPath = "/Maps/";
            CurrentProjectInfo.Owner = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
            //CurrentProjectInfo.ScriptsPath = "/Scripts";
            m_projectInfoFileAddress = m_projectPath + "\\" + m_ProjectName + ".mpn";
            XmlSerializer xmlserializer = new XmlSerializer(typeof(ProjectInfo));
            StreamWriter sw = new StreamWriter(m_projectInfoFileAddress);
            xmlserializer.Serialize(sw, CurrentProjectInfo);
            sw.Close();
        }
 internal AddAnimalForm(Project project)
 {
     InitializeComponent();
     RestoreWindow();
     Project = project;
     CurrentUser = Environment.UserDomainName + @"\" + Environment.UserName;
     LoadDataContext();
     SetUpControls();
 }
 internal ProjectDetailsForm(Project project)
 {
     InitializeComponent();
     RestoreWindow();
     Project = project;
     CurrentUser = Environment.UserDomainName + @"\" + Environment.UserName;
     SetDefaultPropertiesBeforeFormLoad();
     LoadDataContext();
     SetUpGeneral();
 }
Esempio n. 4
0
        public DataModel.ProjectCollection GetProjects()
        {
            DataModel.ProjectCollection result = new DataModel.ProjectCollection();
            foreach (Microsoft.TeamFoundation.WorkItemTracking.Client.Project project in workItemStore.Projects)
            {
                DataModel.Project internalProject = new DataModel.Project(project.Name);
                result.Projects.Add(internalProject);
            }

            return(result);
        }
 internal AddEditorForm(Project project, ProjectInvestigator investigator = null, bool lockSelector = false)
 {
     InitializeComponent();
     RestoreWindow();
     Project = project;
     Investigator = investigator;
     LockSelector = lockSelector;
     CurrentUser = Environment.UserDomainName + @"\" + Environment.UserName;
     LoadDataContext();
     SetUpControls();
     EnableControls();
 }
        private void LoadDataContext()
        {
            Database = new AnimalMovementDataContext();
            //Database.Log = Console.Out;
            //Project is in a different DataContext, get one in this DataContext
            if (Project != null)
                Project = Database.Projects.FirstOrDefault(p => p.ProjectId == Project.ProjectId);
            if (Project == null)
                throw new InvalidOperationException("Project Details Form not provided a valid project.");

            var functions = new AnimalMovementFunctions();
            IsInvestigator = Project.ProjectInvestigator.Normalize().Equals(CurrentUser.Normalize(), StringComparison.OrdinalIgnoreCase);
            IsEditor = functions.IsProjectEditor(Project.ProjectId, CurrentUser) ?? false;
        }
        private void LoadDataContext()
        {
            Database = new AnimalMovementDataContext();
            //Database.Log = Console.Out;
            //Project is in a different DataContext, get one in this DataContext
            if (Project != null)
                Project = Database.Projects.FirstOrDefault(p => p.ProjectId == Project.ProjectId);

            //If Project is not provided, Current user must be a PI or an project editor
            if (Project == null)
                if (!Database.Projects.Any(p => p.ProjectInvestigator == CurrentUser) &&
                    !Database.ProjectEditors.Any(e => e.Editor == CurrentUser))
                    throw new InvalidOperationException("Add Animal Form not provided a valid Project or you are not a PI or editor on any projects.");

            Functions = new AnimalMovementFunctions();
            IsEditor = Project != null && (Functions.IsProjectEditor(Project.ProjectId, CurrentUser) ?? false);
        }
Esempio n. 8
0
        /// <summary>
        /// Persist a project into the database
        /// </summary>
        /// <param name="project">The project that will be persisted in DB</param>
        public void saveProject(Project projet)
        {
            try
            {
                // Open session
                NHibernate.ISession session = this.sessionFactory.OpenSession();

                // Start Transaction
                NHibernate.ITransaction transaction = session.BeginTransaction();

                // Tell NHibernate that this object should be saved
                session.Save( projet );

                // Commit transaction
                transaction.Commit();

                // Close session
                session.Close();
            }
            catch( Exception ex )
            {
                throw ex;
            }
        }
Esempio n. 9
0
 private static void HandleException(Exception ex, string path, Project project, ProjectInvestigator manager)
 {
     Console.WriteLine("Unable to load file: {0} for project: {1} or manager: {2} reason: {3}", path,
         project == null ? "<null>" : project.ProjectId, manager == null ? "<null>" : manager.Login, ex.Message);
 }
Esempio n. 10
0
        public bool OpenProject(string fileaddress)
        {
            try{
                FileStream fw = new FileStream(fileaddress,FileMode.Open,FileAccess.ReadWrite,FileShare.Read);

                XmlSerializer xmlserializer = new XmlSerializer(typeof(ProjectInfo));
                ProjectInfo projectinfo = (ProjectInfo)xmlserializer.Deserialize(fw);
                m_projectInfoFileAddress = fileaddress;
                CurrentProject = new Project(projectinfo.DatabaseFilePath);
                if (!CurrentProject.DatabaseExists())
                    new Exception();

            }
            catch(Exception e){
                return false;
            }
            return true;
        }
Esempio n. 11
0
        private void btnSaisirProjet_Click( object sender, EventArgs e )
        {
            try
            {
                // Saisie utilisateur
                string nomProjet = Interaction.InputBox( "Quel est le nom du projet ?" );

                // Création objet
                Project projet = new Project( nomProjet );

                this._dataManager.saveProject( projet );
            }
            catch( Exception ex )
            {
                Program.DisplayException( ex );
            }
        }
Esempio n. 12
0
        private void LoadDataContext()
        {
            Database = new AnimalMovementDataContext();
            //Database.Log = Console.Out;
            //Project and Investigator are in a different DataContext, get them in this DataContext
            if (Project != null)
                Project = Database.Projects.FirstOrDefault(p => p.ProjectId == Project.ProjectId);
            if (Investigator != null)
                Investigator = Database.ProjectInvestigators.FirstOrDefault(pi => pi.Login == Investigator.Login);
            if (Project == null && Investigator == null)
                throw new InvalidOperationException("Add Editor Form not provided a valid Project or Project Investigator.");
            if (Project != null && Investigator != null)
                throw new InvalidOperationException("Add Editor Form cannot have both a valid Project AND Project Investigator.");

            //Only project investigators can add editors/assistants
            IsProjectInvestigator = Database.ProjectInvestigators.Any(pi => pi.Login == CurrentUser);
        }