コード例 #1
0
        /// <summary>
        /// Unpackages a project
        /// </summary>
        /// <returns></returns>
        //public bool UnpackageProject()
        //{
        //    bool success = false;
        //    success = DeryptPackage();
        //    success = DecompressProject();
        //    string mdbFilePath = compressedPackagePath.Substring(0, compressedPackagePath.Length - 3) + ".mdb";
        //    string prjFilePath = compressedPackagePath.Substring(0, compressedPackagePath.Length - 3) + ".prj";
        //    sourceProject = Util.CreateProjectFileFromDatabase(mdbFilePath, true);
        //    sourceProject = new Project(prjFilePath);
        //    View parentSourceView = sourceProject.Views[destinationView.Name];
        //    List<View> viewsToProcess = new List<View>();
        //    foreach (View view in sourceProject.Views)
        //    {
        //        if (view.Name == parentSourceView.Name)
        //        {
        //            continue;
        //        }
        //        if (ImportExportHelper.IsFormDescendant(view, parentSourceView))
        //        {
        //            viewsToProcess.Add(view);
        //        }
        //    }
        //    FormDataImporter fdi = new FormDataImporter(sourceProject, destinationProject, destinationView, viewsToProcess);
        //    fdi.SetProgressBar += new SetProgressBarDelegate(OnSetProgress);
        //    fdi.SetStatus += new UpdateStatusEventHandler(OnSetStatusMessage);
        //    fdi.AddStatusMessage += new UpdateStatusEventHandler(OnAddStatusMessage);
        //    fdi.SetMaxProgressBarValue += new SetMaxProgressBarValueDelegate(OnSetMaxProgressBarValue);
        //    fdi.Update = this.Update;
        //    fdi.Append = this.Append;
        //    fdi.ImportFormData();
        //    fdi.Dispose();
        //    return success;
        //}
        /// <summary>
        /// Unpackages a series of projects
        /// </summary>
        /// <returns></returns>
        public bool UnpackageProjects()
        {
            bool success = false;

            runningCount = 1;

            foreach (string filePath in PackagePaths)
            {
                string compressedPackagePath = DeryptPackage(filePath);
                success = DecompressProject(compressedPackagePath);

                string mdbFilePath = compressedPackagePath.Substring(0, compressedPackagePath.Length - 3) + ".mdb";
                string prjFilePath = compressedPackagePath.Substring(0, compressedPackagePath.Length - 3) + ".prj";
                sourceProject = Util.CreateProjectFileFromDatabase(mdbFilePath, true);
                sourceProject = new Project(prjFilePath);

                View parentSourceView = sourceProject.Views[destinationView.Name];

                List<View> viewsToProcess = new List<View>();

                foreach (View view in sourceProject.Views)
                {
                    if (view.Name == parentSourceView.Name)
                    {
                        continue;
                    }

                    if (ImportExportHelper.IsFormDescendant(view, parentSourceView))
                    {
                        viewsToProcess.Add(view);
                    }
                }

                FormDataImporter fdi = new FormDataImporter(sourceProject, destinationProject, destinationView, viewsToProcess);
                fdi.SetProgressBar += new SetProgressBarDelegate(OnSetProgress);
                fdi.SetStatus += new UpdateStatusEventHandler(OnSetStatusMessage);
                fdi.AddStatusMessage += new UpdateStatusEventHandler(OnAddStatusMessage);
                fdi.SetMaxProgressBarValue += new SetMaxProgressBarValueDelegate(OnSetMaxProgressBarValue);
                fdi.Update = this.Update;
                fdi.Append = this.Append;
                fdi.ImportFormData();
                fdi.Dispose();

                if (FinishUnpackage != null)
                {
                    FinishUnpackage();
                }

                try
                {
                    File.Delete(compressedPackagePath);
                    File.Delete(mdbFilePath);
                }
                catch (IOException ex)
                {
                    OnAddStatusMessage("There was a problem deleting the unencrypted (plaintext) data from disk. Exception: " + ex);
                }
                runningCount++;
            }

            return success;
        }