Exemplo n.º 1
0
		public NewSamplesForm(Project currentProject, Station currentStation)
		{
			InitializeComponent();
			_updatedProject=currentProject;
			_updatedStation=currentStation;
			selectPicturesFolderDialog.ShowNewFolderButton = false;
		}
Exemplo n.º 2
0
    /// <summary>
    /// Defines page setup, headers, and footers.
    /// </summary>
    static void DefineContentSection(Document document, Project currentProject)
    {
    	try {
    	  Section section = document.AddSection();
	      section.PageSetup.OddAndEvenPagesHeaderFooter = true;
	      section.PageSetup.StartingNumber = 1;
	
	      HeaderFooter header = section.Headers.Primary;
	      header.AddParagraph(currentProject.Name);
	      
	      header = section.Headers.EvenPage;
	      header.AddParagraph(currentProject.Name);
	
	      // Create a paragraph with centered page number. See definition of style "Footer".
	      Paragraph paragraph = new Paragraph();
	      paragraph.AddTab();
	      paragraph.AddPageField();
	
	      // Add paragraph to footer for odd pages.
	      section.Footers.Primary.Add(paragraph);
	      // Add clone of paragraph to footer for odd pages. Cloning is necessary because an object must
	      // not belong to more than one other object. If you forget cloning an exception is thrown.
	      section.Footers.EvenPage.Add(paragraph.Clone());
    	} catch (Exception ex) {
    		throw ex;
    	}
     
    }
Exemplo n.º 3
0
    public static Document CreateDocument(Project currentProject)
    {
    	try {
	      // Create a new MigraDoc document
	      Document document = new Document();
	      document.Info.Title = "Cameratrap Manager Report for "+currentProject.Name;
	      document.Info.Subject = currentProject.Subject;
	      document.Info.Author = currentProject.Creator;
	
	      Styles.DefineStyles(document);
	
	      Cover.DefineCover(document, currentProject);
	//      TableOfContents.DefineTableOfContents(document);
	
	      DefineContentSection(document, currentProject);
	
	      Paragraphs.Project_overview(document, currentProject);
	      Tables.DefineTables(document, currentProject);
	      Charts.DefineCharts(document, currentProject);
	
	      return document;
    	} catch (Exception ex) {
    		throw ex;
    	}
      
    }
Exemplo n.º 4
0
    /// <summary>
    /// Defines the cover page.
    /// </summary>
    public static void DefineCover(Document document, Project currentProject)
    {
    	try {
    		Section section = document.AddSection();

		    Paragraph paragraph = section.AddParagraph();
		    paragraph.Format.SpaceAfter = "3cm";
				    
		    Image image = section.AddImage(System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().Location)+@"\\logo.jpg");
		    image.Width = "6cm";
		
		    paragraph = section.AddParagraph("Report generated using Cameratrap Manager\nfor the project:\n"+currentProject.Name);
		    paragraph.Format.Font.Size = 16;
		    paragraph.Format.Font.Color = Colors.DarkRed;
		    paragraph.Format.SpaceBefore = "6cm";
		    paragraph.Format.SpaceAfter = "3cm";
		
		    paragraph=section.AddParagraph("Creation date: " + currentProject.StartDate.ToString());
		    paragraph=section.AddParagraph("Last modified: " + currentProject.CompletionDate.ToString());
		      
		    paragraph = section.AddParagraph("Rendering date: ");
		    paragraph.AddDateField();
    	} catch (Exception ex) {
    		throw ex;
    	}
    	
     
    }
Exemplo n.º 5
0
    public static void Project_overview(Document document, Project currentProject)
    {
    	try {
    		Paragraph paragraph = document.LastSection.AddParagraph("Camera Trap Project Overview", "Heading1");
	      	paragraph.AddBookmark("Overview");
	      
	        document.LastSection.AddParagraph("Subject", "Heading2");
	    	paragraph = document.LastSection.AddParagraph();
	      	paragraph.Format.Alignment = ParagraphAlignment.Left;
	     	paragraph.AddText(currentProject.Subject);
	     	
	     	document.LastSection.AddParagraph("Description", "Heading2");
	    	paragraph = document.LastSection.AddParagraph();
	      	paragraph.Format.Alignment = ParagraphAlignment.Left;
	     	paragraph.AddText(currentProject.Description);
	     	
	     	document.LastSection.AddParagraph("Type of project", "Heading2");
	    	paragraph = document.LastSection.AddParagraph();
	      	paragraph.Format.Alignment = ParagraphAlignment.Left;
	     	paragraph.AddText(currentProject.Type);
    	} catch (Exception ex) {
    		throw ex;
    	}
    	
    	
      	
    }
Exemplo n.º 6
0
		public static Project LoadProject(string existingProject)
		{
			try {
				string projectsPath = System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().Location);
				Project loadedProj=new Project();
				
				string projectSQL = "SELECT project_base64 FROM project";// WHERE id_project=0"+id_samples.ToString();
				SQLiteConnection projectConn = new SQLiteConnection("Data Source="+ projectsPath + @"\\Projects\\" + existingProject + ".db;Version=3;New=False;Compress=True;Synchronous=Off");
				SQLiteCommand cmd = new SQLiteCommand(projectSQL,projectConn);
				projectConn.Open();
				
				loadedProj = (Project)ConversionUtilities.DeserializeBase64((string)cmd.ExecuteScalar());
				
//				using(SQLiteDataReader sqReader = cmd.ExecuteReader())
//				{
//					if (sqReader.Read())
//					{
//						loadedProj = (Project)ConversionUtilities.DeserializeBase64(sqReader.GetString(0));
//					}
//				}
				
				projectConn.Close();
				
				return loadedProj;
			} catch (Exception ex) {
				throw ex;
			}


		}
Exemplo n.º 7
0
    public static void StatsBySpecies_Table(Document document, Project currentProject)
    {
    	try {
	    	General_queries prjq=new General_queries(currentProject);
	    	List<SpeciesStats> stats = prjq.AllStatsBySpecies;
	    	
	    	document.LastSection.AddParagraph("Statistics by species", "Heading2");
	
		    Table table = document.LastSection.AddTable();
		    table.Borders.Visible = true;
		    table.TopPadding = 10;
		    table.BottomPadding = 10;
		
		    Column column = table.AddColumn(Unit.FromCentimeter(5));
		    column.Format.Alignment = ParagraphAlignment.Center;
		    
		
		    column = table.AddColumn();
		    column.Format.Alignment = ParagraphAlignment.Center;
		
		    column = table.AddColumn();
		    column.Format.Alignment = ParagraphAlignment.Center;
		
		    table.Rows.Height = 20;
		
		    Row row = table.AddRow();
		    row.Shading.Color = Colors.PaleGoldenrod;
		    
		    row.Cells[0].AddParagraph().AddFormattedText("Species", TextFormat.Bold);
		    row.Cells[1].AddParagraph().AddFormattedText("Valid pictures",TextFormat.Bold);
		    row.Cells[2].AddParagraph().AddFormattedText("Species count", TextFormat.Bold);
		    
		    
		    foreach(SpeciesStats spst in stats)
		    {
		    	row = table.AddRow();
		    	if(spst.SpeciesName == "")
		    	{
		    		row.Cells[0].AddParagraph("Pending images");
		    		row.Cells[1].AddParagraph(spst.SpeciesPictures.ToString()).AddFormattedText();
		    		row.Cells[2].AddParagraph(spst.SpeciesCount.ToString());
		    	}
		    	else
		    	{
		    		row.Cells[0].AddParagraph(spst.SpeciesName);
		    		row.Cells[1].AddParagraph(spst.SpeciesPictures.ToString());
		    		row.Cells[2].AddParagraph(spst.SpeciesCount.ToString());
		    	}
		    	
		    }
    	} catch (Exception ex) {
    		throw ex;
    	}
    	
    	
    }
Exemplo n.º 8
0
		public NewStationForm(Project currentProject)
		{
			
			InitializeComponent();
			
			_updatedProject=currentProject;
			selectMainPictureDialog.Filter = "Jpeg files (*.jpg)|*.jpg|All files (*.*)|*.*"; 
   			selectMainPictureDialog.Title = "Select the main picture";

		}
Exemplo n.º 9
0
		private void GetAllStatsBySpecies(Project currentProject)
		{		
			try {
				foreach(string s in SpeciesInProject(currentProject))
				{
					_allStatsBySpecies.Add(StatsBySpecies(s,currentProject));
				}
			} catch (Exception ex) {
				throw ex;
			}
			
		}
Exemplo n.º 10
0
    public static void DefineTables(Document document, Project currentProject)
    {
      Paragraph paragraph = document.LastSection.AddParagraph("Tables", "Heading1");
      paragraph.AddBookmark("Tables");

      StatsBySpecies_Table(document, currentProject);
      StatsByStations_Table(document, currentProject);
      
//      DemonstrateSimpleTable(document);
//      DemonstrateAlignment(document);
//      DemonstrateCellMerge(document);
    }
Exemplo n.º 11
0
    public static void SpeciesCountInProject_PieChart(Document document, Project currentProject)
    {
    	try {
	    	General_queries projq =new General_queries(currentProject);
	    	List<SpeciesStats> stats = projq.AllStatsBySpecies;
	    	
	    	double[] speciesCount=new double[stats.Count];
	    	string[] speciesNames=new string[stats.Count];
	    	
	    	double speciesSum=0;
	    	
	    	for(int i=0; i<stats.Count;i++)
	    	{
	    		speciesSum += stats[i].SpeciesPictures;
	    		speciesCount[i]=stats[i].SpeciesCount;
	    		speciesNames[i]=stats[i].SpeciesName;
	    	}
	    	
	    	document.LastSection.AddParagraph("Species count in project", "Heading2");
	
	      	Chart chart = new Chart();
	      	chart.Type=ChartType.Pie2D;
			chart.Left = 0;
		
		    chart.Width = Unit.FromCentimeter(10);
		    chart.Height = Unit.FromCentimeter(8);
		    
		    Series series = chart.SeriesCollection.AddSeries();
		    series.Add(speciesCount);
		    XSeries xseries = chart.XValues.AddXSeries();
		    xseries.Add(speciesNames);
		    
		    chart.RightArea.AddLegend();
		    
		    chart.DataLabel.Type = DataLabelType.Percent;
		    chart.DataLabel.Position = DataLabelPosition.OutsideEnd;
		    
		
		    document.LastSection.Add(chart);
    	} catch (Exception ex) {
    		throw ex;
    	}
    	
    	
    }
Exemplo n.º 12
0
    public static void DefineCharts(Document document, Project currentProject)
    {
    	try {
	    	Paragraph paragraph = document.LastSection.AddParagraph("Charts", "Heading1");
	    	paragraph.AddBookmark("Charts");
	
	    	SpeciesPicturesInProject_PieChart(document, currentProject);
	    	
//	    	Paragraph paragraph = document.LastSection.AddParagraph("Charts", "Heading1");
//	    	paragraph.AddBookmark("Charts");
	
//	    	SpeciesCountInProject_PieChart(document, currentProject);
	    	SpeciesTimeBehavior_BarChart(document, currentProject);
	    	
    	} catch (Exception ex) {
    		throw ex;
    	}
    
    }
Exemplo n.º 13
0
		private void GetAllStatsByStation(Project currentProject)
		{
			try {
				foreach(Station st in currentProject.StationsList)
				{
					StationStats stst=new StationStats(st.Guid,st.StationID);
					
					foreach(string s in SpeciesInProject(currentProject))//SpeciesInStation(st))
					{
						stst.SpeciesStats.Add(StatsByStation(s,st));
					}
					
					_allStatsByStation.Add(stst);
				}
			} catch (Exception ex) {
				throw ex;
			}

			
		}
Exemplo n.º 14
0
		private void WritePDF(Project currentProject, string PDFfilename)
		{
			try {
				// Create a MigraDoc document
				Document document = Documents.CreateDocument(currentProject);
				
				PdfDocumentRenderer renderer = new PdfDocumentRenderer(true, PdfSharp.Pdf.PdfFontEmbedding.Always);
				renderer.Document = document;
				
				renderer.RenderDocument();
				
				// Save the document...
				renderer.PdfDocument.Save(PDFfilename);
				//Start a viewer.
				Process.Start(PDFfilename);
			} catch (Exception ex) {
				throw ex;
			}
			
		}
Exemplo n.º 15
0
		void BtCreateProjectClick(object sender, EventArgs e)
		{
			try {
				_newProjectCreated = new Project(txtProjectName.Text,
			                        cmbProjectType.Text,
			                        txtProjectCreator.Text,
			                        txtProjectSubject.Text,
			                        txtProjectDescription.Text,
			                        DateTime.Now,
			                        DateTime.Now,
			                        _studyArea, Convert.ToInt16(txtGridSize.Text));
			
			
				ProjectDAO.CreateNewProject(_newProjectCreated);
				
				this.Close();
			} catch (Exception ex) {
				throw ex;
			}
			
		}
Exemplo n.º 16
0
		public static void CreateNewProject(Project newProject)
		{
			try {
				string projectsPath = System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().Location);
				
				using(SQLiteConnection Conn=new SQLiteConnection())
				{
					Conn.ConnectionString = "Data Source="+ projectsPath + @"\\Projects\\" + newProject.Name + ".db;Version=3;New=True;Compress=True;Synchronous=Off";
					Conn.Open();
					
					SQLiteCommand CreateCmd = new SQLiteCommand();
					CreateCmd = Conn.CreateCommand();
					CreateCmd.CommandText = "CREATE TABLE [project] ([id_project] INTEGER  NOT NULL PRIMARY KEY,[project_base64] TEXT NULL)" ;
					CreateCmd.ExecuteNonQuery();
					CreateCmd.CommandText = "CREATE TABLE [images] ( [guid_images] TEXT  NOT NULL PRIMARY KEY, [image_base64] TEXT  NOT NULL)" ;
					CreateCmd.ExecuteNonQuery();
					CreateCmd.Dispose();
					
					
					SQLiteParameter idproject =new SQLiteParameter("@idproject",DbType.Int64){Value= 1};
					SQLiteParameter newproject =new SQLiteParameter("@project",DbType.String){Value= ConversionUtilities.SerializeBase64(newProject)};
					
					
					SQLiteCommand InsertCmd = new SQLiteCommand();
					InsertCmd=Conn.CreateCommand();
					InsertCmd.Parameters.Add(idproject);
					InsertCmd.Parameters.Add(newproject);
					
					
					InsertCmd.CommandText= "INSERT INTO project (id_project, project_base64) VALUES(@idproject, @project)";
					InsertCmd.ExecuteNonQuery();
					InsertCmd.Dispose();
					
				}
			} catch (Exception ex) {
				throw ex;
			}
			
			
		}
		private void WriteGridAbundances(Project currentProject, string shapefileName)
		{
			try {
				List<IPolygon>projectGrids=new List<IPolygon>();
				General_queries projq=new General_queries(currentProject);
				
				foreach(Station st in currentProject.StationsList)
				{
					
					IPolygon grid=st.Grid;
					StationStats tempStationStats=new StationStats(st.Guid,st.StationID);
					
					foreach(StationStats stst in projq.AllStatsByStation)
					{
						if(stst.StationGUID==st.Guid)
						{
							tempStationStats=stst;
							grid.UserData=tempStationStats;
						}
					}
					
					projectGrids.Add(grid);
				}
				
				GeometryCollection gc=new GeometryCollection(projectGrids.ToArray());
				
				//Open Writer
				ShapefileWriter shpWriter = new ShapefileWriter();
				shpWriter.Write(shapefileName, gc);
				
				//Create Header & Columns for points
				DbaseFileHeader dbfHeader = new DbaseFileHeader();
				

				dbfHeader.AddColumn("Station_ID",'C',20,0);
				//One column for each species in project
				foreach(SpeciesStats spcst in projq.AllStatsBySpecies)
				{
					dbfHeader.AddColumn(spcst.SpeciesName,'N',20,0);
				}
				
				dbfHeader.NumRecords = gc.Count;
				
				//DBF Writer
				DbaseFileWriter dbfWriter = new DbaseFileWriter(shapefileName+".dbf");
				dbfWriter.Write(dbfHeader);
				
				//Loop through Business Object to get Features
				foreach (IPolygon p in gc.Geometries)
				{
					StationStats data = (StationStats)p.UserData;
					
					
					ArrayList columnValues = new System.Collections.ArrayList();
					//Add Values
					
					columnValues.Add(data.StationID);
					foreach(SpeciesStats s in data.SpeciesStats)
					{
						columnValues.Add(s.SpeciesPictures);
					}
					
					dbfWriter.Write(columnValues);

				}
				
				//Close File
				dbfWriter.Close();
			} catch (Exception ex) {
				throw ex;
			}
			

		}
Exemplo n.º 18
0
		void CloseProjectToolStripMenuItemClick(object sender, EventArgs e)
		{
			try {
				DialogResult result = MessageBox.Show("Would you like to save your changes?","Save project?",
				                                      MessageBoxButtons.YesNoCancel,MessageBoxIcon.Question);
				
				if (result == DialogResult.Yes)
				{
					ProjectDAO.UpdateProject(_currentProject.Name,_currentProject);
					ProjectDAO.RemoveOrphanImages(_currentProject);
				}
				else if (result == DialogResult.Cancel)
				{
					// Stop the closing and return to the form
					//	            e.Cancel = true;
				}
				else
				{
					tvProject.Nodes.Clear();
					pictureBox1.Image=null;
					_currentProject=null;
					_currentStation=null;
					_currentSample=null;
					lstViewData.Clear();
					dgvSelectSpecies.DataSource=null;
					speciesList.Rows.Clear();
				}
			} catch (Exception ex) {
				throw ex;
			}
			
		}
Exemplo n.º 19
0
		private List<string> SpeciesInProject(Project currentProject)
		{
			try {
				List<string> _allSpeciesList = new List<string>();
				
				foreach (Station st in currentProject.StationsList)
				{
					foreach(Sample smp in st.SamplesList)
					{
						foreach(SpeciesObservation obs in smp.Species_Observations_list)
						{
							if(_allSpeciesList.Contains((string)obs.Value)== false)
							{
								_allSpeciesList.Add((string)obs.Value);
							}

						}
					}
				}
				
				return _allSpeciesList;
			} catch (Exception ex) {
				throw ex;
			}
			

		}
Exemplo n.º 20
0
		private void refreshSpeciesList(Project currentProject)
		{
			try {
				foreach(string s in _currentProject.SpeciesList)
				{
					speciesList.Rows.Add(s);
				}
				dgvSelectSpecies.DataSource=speciesList;
				
			} catch (Exception ex) {
				throw ex;
			}
			
		}
Exemplo n.º 21
0
		void NewStationToolStripMenuItemClick(object sender, EventArgs e)
		{
			if(_currentProject!=null)
			{
				NewStationForm newStatForm = new NewStationForm(_currentProject);
				if (newStatForm.ShowDialog()==DialogResult.OK)
				{
					_currentProject=newStatForm.UpdatedProject;
					ProjectDAO.UpdateProject(_currentProject.Name,_currentProject);
					
					PopulateTree();
				}
			}
			else
			{
				MessageBox.Show("There is no current project");
			}

		}
Exemplo n.º 22
0
		void ExistingProjectToolStripMenuItemClick(object sender, EventArgs e)
		{
			try {
				OpenFileDialog openProjectDialog = new OpenFileDialog();
				openProjectDialog.Filter = "Cameratrap projects (*.db)|*.db|All files (*.*)|*.*";
				openProjectDialog.InitialDirectory = projectsPath;
				openProjectDialog.Title = "Open a existing project";
				
				if( openProjectDialog.ShowDialog() == DialogResult.OK )
				{
					_currentProject = ProjectDAO.LoadProject(Path.GetFileNameWithoutExtension(openProjectDialog.FileName));
					
					refreshSpeciesList(_currentProject);
					
					PopulateTree();
					
					EnableButtons();
					
//					ProjectDAO.VacuumProject(_currentProject.Name);
					
				}
			} catch (Exception ex) {
				throw ex;
			}
			
			
		}
Exemplo n.º 23
0
		void NewProjectToolStripMenuItemClick(object sender, EventArgs e)
		{
			
			try {
				
				NewProjectForm newProjForm=new NewProjectForm();

				if  (newProjForm.ShowDialog()== DialogResult.OK)
				{
					_currentProject=newProjForm.NewProjectCreated;
//					_currentProject.SpeciesList.Add("Empty Picture");
//					_currentProject.SpeciesList.Add("Invalid Picture");
//					_currentProject.SpeciesList.Add("Management");
//					_currentProject.SpeciesList.Add("Unknown");
					
					
					refreshSpeciesList(_currentProject);
					
					PopulateTree();
					
					EnableButtons();
					
				}
				
			} catch (Exception ex)
			{
				throw ex;
			}
			
			
		}
Exemplo n.º 24
0
		void ExitApplication()
		{
			try {
				DialogResult result = MessageBox.Show("Would you like to save your changes?", "Save project?",
				                                      MessageBoxButtons.YesNo,MessageBoxIcon.Question);
				
				if (result == DialogResult.Yes)
				{
					ProjectDAO.UpdateProject(_currentProject.Name,_currentProject);
					ProjectDAO.RemoveOrphanImages(_currentProject);
					
					tvProject.Dispose();
					pictureBox1.Dispose();
					_currentProject=null;
					_currentStation=null;
					_currentSample=null;
					lstViewData.Dispose();
					dgvSelectSpecies.Dispose();
				}
				else if (result == DialogResult.Cancel)
				{
					//				Stop the closing and return to the form
					//				e.Cancel = true;
				}
			} catch (Exception ex) {
				throw ex;
			}

		}
Exemplo n.º 25
0
		private SpeciesStats StatsBySpecies(string species, Project currentProject)
		{
			try {
				int speciesCount=0;
				int speciesPictures=0;
				
				double[] activityPaterns = new double[24];
				
				
				foreach (Station st in currentProject.StationsList)
				{
					foreach(Sample smp in st.SamplesList)
					{
						foreach(SpeciesObservation obs in smp.Species_Observations_list)
						{
							if(obs.Value==species)
							{
								speciesCount+=obs.Count;
								speciesPictures++;
								
								activityPaterns[smp.DateTime.Hour]+=smp.DateTime.Hour;
							}
						}
					}
				}
				

				SpeciesStats spst=new SpeciesStats(species,speciesCount,speciesPictures);
				spst.ActivityPatern=activityPaterns;
				
				
				return spst;
				
			} catch (Exception ex) {
				throw ex;
			}

		}
Exemplo n.º 26
0
		public static void UpdateProject(string oldProjectName, Project updatedProject)
		{
			try {
				string projectsPath = System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().Location);
				
				using(SQLiteConnection Conn=new SQLiteConnection())
				{
					
					Conn.ConnectionString = "Data Source="+ projectsPath + @"\\Projects\\" + oldProjectName +".db;New=False;Compress=True;Synchronous=Off";
					Conn.Open();
					
					SQLiteCommand DeleteCmd=new SQLiteCommand();
					DeleteCmd=Conn.CreateCommand();
					DeleteCmd.CommandText="DELETE FROM project WHERE id_project=1";
					DeleteCmd.ExecuteNonQuery();
					DeleteCmd.Dispose();
					
					SQLiteParameter idproject =new SQLiteParameter("@idproject",DbType.Int64){Value= 1};
					SQLiteParameter newproject =new SQLiteParameter("@project",DbType.String){Value= ConversionUtilities.SerializeBase64(updatedProject)};
					SQLiteCommand InsertCmd = new SQLiteCommand();
					InsertCmd=Conn.CreateCommand();
					InsertCmd.Parameters.Add(idproject);
					InsertCmd.Parameters.Add(newproject);
					
					InsertCmd.CommandText= "INSERT INTO project (id_project, project_base64) VALUES(@idproject, @project)";
					InsertCmd.ExecuteNonQuery();
					InsertCmd.Dispose();
				}
			} catch (Exception ex) {
				throw ex;
			}
			
		}
Exemplo n.º 27
0
		public General_queries(Project currentProject)
		{
			GetAllStatsBySpecies(currentProject);
			GetAllStatsByStation(currentProject);
		}
Exemplo n.º 28
0
		public static void RemoveOrphanImages(Project existingProject)
		{
			try {
				string projectsPath = System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().Location);
				
				using(SQLiteConnection Conn=new SQLiteConnection())
				{
					
					Conn.ConnectionString = "Data Source="+ projectsPath + @"\\Projects\\" + existingProject.Name +".db;New=False;Compress=True;Synchronous=Off";
					Conn.Open();
					
					//Remove unnecesary images from project
					//Get images list
					List<string> existingImages = new List<string>();
					
					SQLiteCommand storedImages=new SQLiteCommand();
					storedImages=Conn.CreateCommand();
					storedImages.CommandText="SELECT * FROM images";
					
					using(SQLiteDataReader dr=storedImages.ExecuteReader())
					{
						while ( dr.Read() )
						{
							existingImages.Add((string)dr["guid_images"]);
							
						}
					}
					
					storedImages.Dispose();
					
					
					//Get remaining images list
					List<string> remainingImages=new List<string>();
					
					foreach(Station st in existingProject.StationsList)
					{
						remainingImages.Add(st.Guid);
						
						foreach(Sample smp in st.SamplesList)
						{
							remainingImages.Add(smp.Guid);
						}
						
					}
					
					
					foreach(string s in existingImages)
					{
						if(remainingImages.Contains(s)==false)
						{
							SQLiteParameter guid =new SQLiteParameter("@guid",DbType.String){Value= s};
							SQLiteCommand DeleteImageCmd=new SQLiteCommand();
							DeleteImageCmd=Conn.CreateCommand();
							DeleteImageCmd.Parameters.Add(guid);
							DeleteImageCmd.CommandText="DELETE FROM images WHERE guid_images = @guid";
							DeleteImageCmd.ExecuteNonQuery();
							DeleteImageCmd.Dispose();
						}
					}
					
				}
			} catch (Exception ex) {
				throw ex;
			}
		}
Exemplo n.º 29
0
		void cntxttbUploadSamplesClick(object sender, EventArgs e)
		{
			if(_currentStation.MainPictureFilename!="Not Provided")
			{
				UploadSamplesToStation();
				_currentProject=ProjectDAO.LoadProject(_currentProject.Name);
				PopulateTree();
			}
			else
			{
				MessageBox.Show("You must load the station main image before upload samples");
			}
		}
Exemplo n.º 30
0
    public static void SpeciesTimeBehavior_BarChart(Document document, Project currentProject)
    {
    	try {
    		
    		General_queries projq =new General_queries(currentProject);
    		
    		
    		foreach(SpeciesStats spst in projq.AllStatsBySpecies)
    		{

    			document.LastSection.AddParagraph(spst.SpeciesName + " Activity Patterns", "Heading2");

    			Chart chart = new Chart();
    			chart.Left = 0;

    			chart.Width = Unit.FromCentimeter(16);
    			chart.Height = Unit.FromCentimeter(12);
    			Series series = chart.SeriesCollection.AddSeries();
    			series.ChartType = ChartType.Column2D;
    			series.Add(spst.ActivityPatern);
    			series.HasDataLabel = true;

    			XSeries xseries = chart.XValues.AddXSeries();
    			xseries.Add("0","1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14","15","16","17","18","19","20","21","22","23");

    			chart.XAxis.MajorTickMark = TickMarkType.Outside;
    			chart.XAxis.Title.Caption = "Hours of day";
    			
    			chart.YAxis.MajorTickMark = TickMarkType.Outside;
    			chart.YAxis.HasMajorGridlines = true;
    			chart.YAxis.MajorGridlines.LineFormat.Color=Colors.DarkGray;
    			chart.YAxis.Title.Caption = "Freq";

    			chart.PlotArea.LineFormat.Color = Colors.DarkGray;
    			chart.PlotArea.LineFormat.Width = 1;

    			document.LastSection.Add(chart);
    		
    		}
      
    	} catch (Exception ex) {
    		throw ex;
    	}
    }