コード例 #1
0
		internal void SetProject(Project project) {
			Trace.Assert(project.FileName != null, "Project should not be null.");
			_project = project;
		}
コード例 #2
0
		public MetadataFile(Project project) {
			if (project != null) {
				this.SetProject(project);
			}
		}
コード例 #3
0
		public MetadataFile(Project project, string fileName) {
			if (project != null) {
				this.SetProject(project);
			}
			Load(fileName);
		}
コード例 #4
0
		private void OpenProject(string fileName) {
			if (!CloseDocuments()) {
				return;
			}
			VerifyOpenProject();
			Project project = Project.Load(fileName);
			if (!project.IsFileVersionCompatible) {
				MessageBox.Show(this,
				                "The file that you are trying to load is not compatible with this version of CH3ETAH. In order to prevent information loss, the project file will not be loaded. Please make sure you are using the most recent version of CH3ETAH in order to load this project file.",
				                "Incompatible file version",
				                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				return;
			}
			tvwProject.Nodes.Clear();
			_project = project;
			Directory.SetCurrentDirectory(Path.GetDirectoryName(fileName));
			RefreshUI();
			_mruList.Add(fileName);
		}
コード例 #5
0
		public static MetadataFile Load(Project project, string fileName) {
			return new MetadataFile(project, fileName);
		}
コード例 #6
0
		private void Test_CodeGeneratorCommand() {
			try {
				Trace.WriteLine("Create a new project and generate using OREntity...");
				Trace.Indent();
				Project p = new Project();
				p.Save(".\\test\\output\\test_ncodegencommandproject_01.ch3");
				p.MetadataBaseDir = "..\\";
				p.TemplatePackageBaseDir = "..\\";
				p.OutputBaseDir = "..\\Output";
				MetadataFile mf = new MetadataFile(p, "UsuarioInformatica.xml");
				p.MetadataFiles.Add(mf);
				CodeGeneratorCommand gc = new CodeGeneratorCommand();
				p.GeneratorCommands.Add(gc);
				gc.IndividualMetadataFiles.Add(p.MetadataFiles[0]);
				gc.Package = "TEST_NCODEGEN_PACKAGE";
				gc.Template = "SPs_CRUD_Object";
				p.GeneratorCommands.Add(gc);
				gc.InputParameters.Add("FileNamePartial", "NCodeGen_Output_01");
				gc.OutputPath = "test_${FileNamePartial}.sql";
				p.Save();
				gc.Execute();
				// UNDONE: need to test whether files were outputted correctly

				Trace.Unindent();
			}
			catch (Exception ex) {
				Trace.WriteLine("\r\n" + ex.ToString() + "\r\n");
			}

		}
コード例 #7
0
		private void NewProject() {
			if (!CloseDocuments()) {
				return;
			}
			if (!DoSaveConfirmation()) {
				return;
			}
			VerifyOpenProject();


//			// TEMP
//			(new ProjectNew()).ShowDialog();
//			return;
//			// END TEMP


			SaveFileDialog dlg = new SaveFileDialog();
			dlg.Title = "New Project...";
			dlg.Filter = "CH3ETAH Project Files (.CH3)|*.ch3|All Files (*.*)|*.*";
			if (dlg.ShowDialog(this) == DialogResult.OK) {
				_project = new Project();
				_project.Save(dlg.FileName);
				Directory.SetCurrentDirectory(Path.GetDirectoryName(dlg.FileName));
			}
			else {
				return;
			}
			RefreshUI();
		}
コード例 #8
0
		protected internal virtual void SetProject(Project project) {
			Debug.Assert(project.FileName != null, "Project should not be null.");
			_project = project;
		}
コード例 #9
0
//		private void Test_MetadataFiles() {
//			try {
//				Trace.WriteLine("Create a new, non-branded metadata file and save...");
//				Trace.Indent();
//				MetadataFile f = new MetadataFile();
//				f.MetadataEntities.Add(new XmlMetadataEntity());
//				XmlMetadataEntity en = (XmlMetadataEntity) f.MetadataEntities[0];
//				en.XmlNode = (new XmlDocument()).CreateElement("Books");
//				en.XmlNode.InnerXml = "<book price=\"100.00\"/>";
//				f.Save(".\\test\\output\\test_create.xml");
//				Trace.Unindent();
//			}
//			catch (Exception ex) {
//				Trace.WriteLine("\r\n" + ex.ToString() + "\r\n");
//			}
//
//			try {
//				Trace.WriteLine("Load a non-branded metadata file and save as...");
//				Trace.Indent();
//				MetadataFile f = new MetadataFile(null, ".\\test\\output\\test_create.xml");
//				f.Save(".\\test\\output\\test_loadsaveas.xml");
//
//				// UNDONE: need to test whether files are identical
//
//				Trace.Unindent();
//			}
//			catch (Exception ex) {
//				Trace.WriteLine("\r\n" + ex.ToString() + "\r\n");
//			}
//
//			try {
//				Trace.WriteLine("Load plain XML file and save as....");
//				Trace.Indent();
//				MetadataFile f = new MetadataFile(null, ".\\test\\raw.xml");
//				f.Save(".\\test\\output\\test_rawsaveas.xml");
//
//				// UNDONE: need to test whether files are identical
//				// this can be a seperate method which takes source and dest file names
//
//				Trace.Unindent();
//			}
//			catch (Exception ex) {
//				Trace.WriteLine("\r\n" + ex.ToString() + "\r\n");
//			}
//
//
//			// Create branded metadata file and save
//
//			// Load a branded metadata file and save as
//
//			// Create mixed (branded/not branded) metadata file and save
//
//			// Load a mixed (branded/not branded) metadata file and save as
//
//		}
//

		#endregion Metadata Files

		#region Project

		private void Test_Project() {
			try {
				Trace.WriteLine("Create a new project and save...");
				Trace.Indent();
				Project p = new Project();
				p.Save(".\\test\\output\\test_projectcreate.ch3");
				p.MetadataBaseDir = "..\\";
				MetadataFile mf = new MetadataFile(p, "raw.xml");
				p.MetadataFiles.Add(mf);
				CodeGeneratorCommand gc = new CodeGeneratorCommand();
				p.GeneratorCommands.Add(gc);
				gc.IndividualMetadataFiles.Add(p.MetadataFiles[0]);
// 				gc.GroupedMetadataFiles.Add(p.MetadataFiles[0]);
				gc.Package = "CSLA";
				gc.Template = "SP_S_Object_By_Index";
				p.Save();
				Trace.Unindent();
			}
			catch (Exception ex) {
				Trace.WriteLine("\r\n" + ex.ToString() + "\r\n");
			}

			try {
				Trace.WriteLine("Load project file and save as...");
				Trace.Indent();
				Project p = Project.Load(".\\test\\output\\test_projectcreate.ch3");
				p.Save(".\\test\\output\\test_projectsaveas.ch3");

				// UNDONE: need to test whether files are identical

				Trace.Unindent();
			}
			catch (Exception ex) {
				Trace.WriteLine("\r\n" + ex.ToString() + "\r\n");
			}
		}
コード例 #10
0
		/// <summary>
		/// Loads a Ch3Etah project from a stream using XML Serialization.
		/// </summary>
		/// <param name="stream"></param>
		public static Project Load(Stream stream, string originalFileName) {
			Project project = null;
			TextReader reader = null;

			reader = new StreamReader(stream);
			XmlSerializer ser = new XmlSerializer(typeof (Project));
			project = (Project) ser.Deserialize(reader);
			
			project._fileName = originalFileName;
			
			project.SetLoadedState();
			project.LoadMetadataFiles();

			// Set's Current Project
			CurrentProject = project;
			return project;
		}
コード例 #11
0
		/// <summary>
		/// Loads a Ch3Etah project from a stream using XML Serialization.
		/// </summary>
		/// <param name="stream"></param>
		public static Project Load(Stream stream, string originalFileName) {
			CheckFileVersionCompatibility(stream);
			stream = UpgradeProjectVersion(stream);
			
			TextReader reader = new StreamReader(stream);
			XmlSerializer ser = new XmlSerializer(typeof (Project));
			Project project = (Project) ser.Deserialize(reader);
			
			project._fileName = originalFileName;
			
			project.SetLoadedState();
			//project.LoadMetadataFiles();

			CurrentProject = project;
			return project;
		}
コード例 #12
0
		private void OpenProject(string fileName) {
			try
			{
				if (!CloseDocuments()) 
				{
					return;
				}
				VerifyOpenProject();
				Project project = Project.Load(fileName);
				if (!project.IsFileVersionCompatible) 
				{
					MessageBox.Show(this,
						"The file that you are trying to load is not compatible with this version of CH3ETAH. In order to prevent information loss, the project file will not be loaded. Please make sure you are using the most recent version of CH3ETAH in order to load this project file.",
						"Incompatible file version",
						MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
					return;
				}
				tvwProject.Nodes.Clear();
				_project = project;
				Directory.SetCurrentDirectory(Path.GetDirectoryName(fileName));
				RefreshUI();
				_mruList.Add(fileName);
			}
			catch (IncompatibleProjectVersionException ex)
			{
				MessageBox.Show(this,
					ex.Message,
					"Incompatible File Version",
					MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				return;
			}
			catch (UnrecognizedProjectFileFormatException ex)
			{
				MessageBox.Show(this,
					ex.Message,
					"Unrecognized File Format",
					MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				return;
			}
			catch (Exception ex)
			{
				MessageBox.Show(this,
					"The following error occurred when trying to load the selected file: \r\n\r\n" + ex.ToString(),
					"File loading error",
					MessageBoxButtons.OK, MessageBoxIcon.Error);
				return;
			}
		}
コード例 #13
0
		public static void UpdateProjectEntities (Project project, TableSchemaCollection tables) {
			
		}
コード例 #14
0
		protected internal override void SetProject(Project project) {
			base.SetProject(project);
			if (project != null) {
				project.MetadataFileObservers.Add(this);
			}
		}
コード例 #15
0
		public DataSource SelectDataSource(Project project) {

			this.lblConnectionString.Text = "";
			this.lblProvider.Text = "";
			this.project = project;
			this.lstDataSources.DataSource = project.DataSources;

			ShowDialog();

			return ds;
		}
コード例 #16
0
		private static bool LoadProject() {
			try {
				// Load the project
				project = Project.Load(projectFileName);
				if (!project.IsFileVersionCompatible)
					throw new Exception("Incompatible project file version");

				// Set the current directory to the project's base dir
				Directory.SetCurrentDirectory(Path.GetDirectoryName(projectFileName));

				return true;
			}
			catch (Exception e) {
				WriteLine("Error loading project file \"{0}\": {1}", projectFileName, e.Message);
				return false;
			}
		}