예제 #1
0
        public void TargetConsoleSync()
        {
            bool   success     = true;
            string summaryFile = "";

            try
            {
                // Initialize our progress dialog
                mProgress = new CallbackDialogForm();

                // Initialize our summery files for reporting what was copied
                summaryFile = InitializeSummaryMap();

                // Initialize our file map to tell us what patterns to copy
                InitializeFileMap();

                // Initialize a timestamp map to help us not copy over the same stuff every time
                InitializeTimeStampMap();

                if (mConsoleCopy)
                {
                    // Logon to correct xbox
                    XboxUtils.SetXboxName(mTargetConsole, false);
                }

                // Create initial console directory
                InitializeTargetDirectory();

                // Get the total number of files to be copied
                success = InitializeFileCounts();

                string message = "Preforming platform data Sync: \n" +
                                 "   Project Sync file map:" + mProjectSyncFile + "\n" +
                                 "   User Sync file map:" + mUserSyncFile + "\n";

                mProgress.DialogInitialize("(" + mTargetConsole + ")Platform Data Sync", message, "Cancel");
                Application.DoEvents();

                // Walk the 'FileMap' and compare to our local game directory and sync to the Xbox
                if (success)
                {
                    mGetFileCount = false;
                    mFileNumber   = 0;
                    mProgress.CallbackDialogFilesProgressBar.Maximum = mTotalFilesToCopy + 2;

                    // Walk the map file directories
                    for (int i = 0; i < mPlatformSync.CountKeys("FileMap"); i++)
                    {
                        string sourcePath  = FormatString(mPlatformSync.GetKeyNameByIndex("FileMap", i).ToLower());
                        string targetPath  = "";
                        string filePattern = mPlatformSync.GetKeyByIndex("FileMap", i).ToLower();

                        if (RemapString(sourcePath, ref targetPath))
                        {
                            success = SyncDirectories(sourcePath, filePattern, mSyncRoot);

                            // Check if the user has canceled
                            if (!success)
                            {
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MOG_REPORT.ShowMessageBox("Console Sync", e.Message.ToString(), MessageBoxButtons.OK);
            }

            // Clean up our progress dialog
            if (mProgress != null)
            {
                mProgress.DialogKill();
                mProgress.CallbackDialogFilesProgressBar.Maximum = 100;
                mProgress = null;
            }

            // Close and save the timestamps file
            if (mTargetTimestamps != null)
            {
                mTargetTimestamps.Save();
                mTargetTimestamps.Close();
            }

            // Close the  platform.sinc.info
            if (mPlatformSync != null)
            {
                mPlatformSync.CloseNoSave();
            }

            // Close the summary file
            if (mSummary != null)
            {
                mSummary.Save();
            }

            // Check if we are supposed to launch the game after the sync
            if (mRunAfterSync)
            {
                RunXbox();
            }

            // Show the update summary form
            if (mShowSummary)
            {
                UpdateBuildSummaryForm summary = new UpdateBuildSummaryForm(summaryFile);
                summary.ShowDialog();
            }
        }
예제 #2
0
        private bool InitializeFileMap()
        {
            mPlatformSync = new MOG_Ini();

            // Get the platformSinc.info file
            string platformSyncFile = mMog.GetProject().GetProjectToolsPath() + "\\" + mProjectSyncFile;

            if (DosUtils.Exist(platformSyncFile))
            {
                // Open the global sinc file to determine what to sinc
                mPlatformSync.Open(platformSyncFile, FileShare.Read);
                mPlatformSync.SetFilename(mMog.GetUser().GetUserToolsPath() + "\\platformSinc." + mMog.GetActivePlatform().mPlatformName + ".Merge.info", false);
            }

            // Check if the user has a custom sync file
            string userSyncFile = mMog.GetUser().GetUserToolsPath() + "\\" + mUserSyncFile;

            if (DosUtils.FileExist(userSyncFile))
            {
                // Should we force ourselves to use only the user sync file?
                if (string.Compare(mProjectSyncFile, "none", true) == 0)
                {
                    mPlatformSync.CloseNoSave();
                    mPlatformSync.Open(userSyncFile, FileShare.Read);
                }
                else
                {
                    // Lets merge the two then
                    mPlatformSync.PutFile(userSyncFile);
                }
            }

            // Make sure we got 'a' Map file loaded
            if (mPlatformSync.GetFilename().Length > 0)
            {
                // Is this a local sync
                if (Path.IsPathRooted(mTargetConsole))
                {
                    string root = "";
                    // Get our local directory root path
                    // Get our console root path
                    if (mUseDefaultUser)
                    {
                        root = FormatString(mPlatformSync.GetString(mMog.GetActivePlatform().mPlatformName, "SpecialRoot").ToLower());
                    }
                    else
                    {
                        root = FormatString(mPlatformSync.GetString(mMog.GetActivePlatform().mPlatformName, "Root").ToLower());
                    }

                    // Fix up the pc console name
                    mSyncRoot    = mTargetConsole + "\\" + Path.GetFileNameWithoutExtension(root);
                    mConsoleCopy = false;
                }
                else
                {
                    // Get our console root path
                    if (mUseDefaultUser)
                    {
                        mSyncRoot = FormatString(mPlatformSync.GetString(mMog.GetActivePlatform().mPlatformName, "SpecialRoot").ToLower());
                    }
                    else
                    {
                        mSyncRoot = FormatString(mPlatformSync.GetString(mMog.GetActivePlatform().mPlatformName, "Root").ToLower());
                    }
                }
            }
            else
            {
                throw(new Exception("Valid platform sync file never properly loaded!"));
            }

            return(true);
        }
예제 #3
0
        private void SyncSaveButton_Click(object sender, System.EventArgs e)
        {
            SyncSaveFileDialog.InitialDirectory = MOG_ControllerProject.GetUser().GetUserToolsPath();

            // Save this custom sync file
            if (SyncSaveFileDialog.ShowDialog() == DialogResult.OK)
            {
                string  syncFilename = SyncSaveFileDialog.FileName;
                MOG_Ini syncFile     = new MOG_Ini(syncFilename);

                foreach (TreeNode sectionNode in XboxSincTreeView.Nodes)
                {
                    string section = sectionNode.Text;

                    foreach (TreeNode keyNode in sectionNode.Nodes)
                    {
                        string key = keyNode.Text;

                        if (keyNode.Nodes.Count > 0)
                        {
                            foreach (TreeNode valNode in keyNode.Nodes)
                            {
                                string val = valNode.Text;

                                syncFile.PutString(section, key, val);
                            }
                        }
                        else
                        {
                            syncFile.PutSectionString(section, key);
                        }
                    }
                }

                // Verify that the newly created sync file has the correct number amount of sections
                if (syncFile.SectionExist("Filemap"))
                {
                    if (syncFile.CountKeys("Filemap") > 0 && string.Compare(SyncProjectMapComboBox.Text, "None") == 0)
                    {
                        MOG_Prompt.PromptMessage("Missing syncfile data", "The required 'FILEMAP' section was not found in this custom sync file.  Aborting...");
                        syncFile.CloseNoSave();
                        return;
                    }
                }
                else
                {
                    MOG_Prompt.PromptMessage("Missing syncfile data", "The required 'FILEMAP' section was not found in this custom sync file.  Aborting...");
                    syncFile.CloseNoSave();
                    return;
                }

                // Make sure we have a valid root definition
                if (syncFile.SectionExist(MOG_ControllerProject.GetCurrentSyncDataController().GetPlatformName()))
                {
                    if (syncFile.CountKeys(MOG_ControllerProject.GetCurrentSyncDataController().GetPlatformName()) > 0 && string.Compare(SyncProjectMapComboBox.Text, "None") == 0)
                    {
                        MOG_Prompt.PromptMessage("Missing syncfile data", "The required '" + MOG_ControllerProject.GetCurrentSyncDataController().GetPlatformName() + "' section was not found in this custom sync file.  Aborting...");
                        syncFile.CloseNoSave();
                        return;
                    }
                }
                else
                {
                    MOG_Prompt.PromptMessage("Missing syncfile data", "The required '" + MOG_ControllerProject.GetCurrentSyncDataController().GetPlatformName() + "' section was not found in this custom sync file.  Aborting...");
                    syncFile.CloseNoSave();
                    return;
                }

                // Save out our new syncFile
                syncFile.Save();
                SyncSaveButton.Enabled = false;

                mUserMap = syncFile.GetFilename();
            }
        }