Beispiel #1
0
		private MigrateStatus ConvertProject(string proj)
		{
			bool fOk;
			try
			{
				string dbName = proj;
				// 1. Check database version number.  If >= 200260, goto step 4.
				int version =  GetDbVersion(proj);
				if (version < 200260)
				{
					// 2. Make a temporary copy of the project.
					// 3. Migrate that temporary copy.
					if (m_fTempMigrationDbExists)
					{
						fOk = m_importer.DeleteTempDatabase();
						if (!fOk)
							return MigrateStatus.Failed;
						m_fTempMigrationDbExists = false;
					}
					string msg = String.Format(Properties.Resources.ksCreatingATemporaryCopy, proj);
					string sErrorMsgFmt = String.Format(Properties.Resources.ksCreatingATemporaryCopyFailed,
						proj, "{0}", "{1}");
					fOk = m_importer.CopyToTempDatabase(proj, msg, sErrorMsgFmt);
					if (!fOk)
						return MigrateStatus.Failed;
					m_fTempMigrationDbExists = true;
					string msg2 = String.Format(Properties.Resources.ksMigratingTheCopy, proj);
					string errMsgFmt2 = String.Format(Properties.Resources.ksMigratingTheCopyFailed,
						proj, "{0}", "{1}");
					fOk = m_importer.MigrateTempDatabase(msg2, errMsgFmt2);
					if (!fOk)
						return MigrateStatus.Failed;
					dbName = ImportFrom6_0.TempDatabaseName;
				}
				// 4. Dump XML for project (or for the temporary project copy)
				string projDir = Path.Combine(FwDirectoryFinder.ProjectsDirectory, proj);
				string projName = proj;
				if (Directory.Exists(projDir))
				{
					using (var dlg = new ExistingProjectDlg(proj))
					{
						if (dlg.ShowDialog(this) == DialogResult.Cancel)
							return MigrateStatus.Canceled;
						projName = dlg.TargetProjectName;
					}
					projDir = Path.Combine(FwDirectoryFinder.ProjectsDirectory, projName);
					if (!Directory.Exists(projDir))
						Directory.CreateDirectory(projDir);
				}
				else
				{
					Directory.CreateDirectory(projDir);
				}
				string projXml = Path.Combine(projDir, "tempProj.xml");
				string msgDump = String.Format(Properties.Resources.ksWritingFw60XML, proj);
				string msgDumpErrorFmt = String.Format(Properties.Resources.ksWritingFw60XMLFailed,
					proj, "{0}", "{1}");
				if (dbName != proj)
				{
					msgDump = String.Format(Properties.Resources.ksWritingCopyAsFw60XML, proj); ;
					msgDumpErrorFmt = String.Format(Properties.Resources.ksWritingCopyAsFw60XMLFailed,
					proj, "{0}", "{1}");
				}
				fOk = m_importer.DumpDatabaseAsXml(dbName, projXml, msgDump, msgDumpErrorFmt);
				if (!fOk)
					return MigrateStatus.Failed;
				// 5. Convert FW 6.0 XML to FW 7.0 XML
				string projFile = Path.Combine(projDir, projName + FdoFileHelper.ksFwDataXmlFileExtension);
				fOk = m_importer.ImportFrom6_0Xml(projXml, projDir, projFile);
			}
			catch (CannotConvertException e)
			{
				fOk = false;
				MessageBox.Show(e.Message, Properties.Resources.ksCannotConvert);
			}
			return fOk ? MigrateStatus.OK : MigrateStatus.Failed;
		}
Beispiel #2
0
        private MigrateStatus ConvertProject(string proj)
        {
            bool fOk;

            try
            {
                string dbName = proj;
                // 1. Check database version number.  If >= 200260, goto step 4.
                int version = GetDbVersion(proj);
                if (version < 200260)
                {
                    // 2. Make a temporary copy of the project.
                    // 3. Migrate that temporary copy.
                    if (m_fTempMigrationDbExists)
                    {
                        fOk = m_importer.DeleteTempDatabase();
                        if (!fOk)
                        {
                            return(MigrateStatus.Failed);
                        }
                        m_fTempMigrationDbExists = false;
                    }
                    string msg          = String.Format(Properties.Resources.ksCreatingATemporaryCopy, proj);
                    string sErrorMsgFmt = String.Format(Properties.Resources.ksCreatingATemporaryCopyFailed,
                                                        proj, "{0}", "{1}");
                    fOk = m_importer.CopyToTempDatabase(proj, msg, sErrorMsgFmt);
                    if (!fOk)
                    {
                        return(MigrateStatus.Failed);
                    }
                    m_fTempMigrationDbExists = true;
                    string msg2       = String.Format(Properties.Resources.ksMigratingTheCopy, proj);
                    string errMsgFmt2 = String.Format(Properties.Resources.ksMigratingTheCopyFailed,
                                                      proj, "{0}", "{1}");
                    fOk = m_importer.MigrateTempDatabase(msg2, errMsgFmt2);
                    if (!fOk)
                    {
                        return(MigrateStatus.Failed);
                    }
                    dbName = ImportFrom6_0.TempDatabaseName;
                }
                // 4. Dump XML for project (or for the temporary project copy)
                string projDir  = Path.Combine(FwDirectoryFinder.ProjectsDirectory, proj);
                string projName = proj;
                if (Directory.Exists(projDir))
                {
                    using (var dlg = new ExistingProjectDlg(proj))
                    {
                        if (dlg.ShowDialog(this) == DialogResult.Cancel)
                        {
                            return(MigrateStatus.Canceled);
                        }
                        projName = dlg.TargetProjectName;
                    }
                    projDir = Path.Combine(FwDirectoryFinder.ProjectsDirectory, projName);
                    if (!Directory.Exists(projDir))
                    {
                        Directory.CreateDirectory(projDir);
                    }
                }
                else
                {
                    Directory.CreateDirectory(projDir);
                }
                string projXml         = Path.Combine(projDir, "tempProj.xml");
                string msgDump         = String.Format(Properties.Resources.ksWritingFw60XML, proj);
                string msgDumpErrorFmt = String.Format(Properties.Resources.ksWritingFw60XMLFailed,
                                                       proj, "{0}", "{1}");
                if (dbName != proj)
                {
                    msgDump         = String.Format(Properties.Resources.ksWritingCopyAsFw60XML, proj);;
                    msgDumpErrorFmt = String.Format(Properties.Resources.ksWritingCopyAsFw60XMLFailed,
                                                    proj, "{0}", "{1}");
                }
                fOk = m_importer.DumpDatabaseAsXml(dbName, projXml, msgDump, msgDumpErrorFmt);
                if (!fOk)
                {
                    return(MigrateStatus.Failed);
                }
                // 5. Convert FW 6.0 XML to FW 7.0 XML
                string projFile = Path.Combine(projDir, projName + FdoFileHelper.ksFwDataXmlFileExtension);
                fOk = m_importer.ImportFrom6_0Xml(projXml, projDir, projFile);
            }
            catch (CannotConvertException e)
            {
                fOk = false;
                MessageBox.Show(e.Message, Properties.Resources.ksCannotConvert);
            }
            return(fOk ? MigrateStatus.OK : MigrateStatus.Failed);
        }