Exemplo n.º 1
0
        static public void MOGGlobalViewRemoteMachineAdd(MogMainForm mainForm)
        {
            // Ask for a new rdp
            mainForm.MOGOpenFileDialog.Filter      = "Remote connections | *.rdp";
            mainForm.MOGOpenFileDialog.Multiselect = true;

            if (mainForm.MOGOpenFileDialog.ShowDialog(mainForm) == DialogResult.OK)
            {
                foreach (string remoteConnection in mainForm.MOGOpenFileDialog.FileNames)
                {
                    DosUtils.FileCopy(remoteConnection, MOG_ControllerProject.GetUser().GetUserToolsPath() + "\\RemoteConnections\\" + Path.GetFileName(remoteConnection));
                }

                // Rebuild the menuItems array of these newly added rdp's
                MOGGlobalViewRemoteMachineInit(mainForm);
            }
        }
Exemplo n.º 2
0
        private bool SyncFile(string fullFilename, string targetFile)
        {
            bool rc = false;

            // Check for special rules for this asset in the ReMap section
            if (!RemapString(fullFilename, ref targetFile))
            {
                return(false);
            }

            // Get the file
            FileInfo file = new FileInfo(fullFilename);

            bool fileExists = false;

            if (mConsoleCopy && !mFileMapCreate)
            {
                fileExists = XboxUtils.FileExist(targetFile);
            }
            else if (!mConsoleCopy && !mFileMapCreate)
            {
                fileExists = DosUtils.FileExist(targetFile);
            }
            else
            {
                fileExists = false;
            }

            if (fileExists && !mGetFileCount && mConsoleCopy)
            {
                // Check to see if the sizes of the source and target are the same
                uint targetSize = XboxUtils.GetFileSize(targetFile);
                uint sourceSize = (uint)file.Length;
                if (targetSize != sourceSize)
                {
                    fileExists = false;
                }
            }

            // Check if the target file exists
            // If asset is in our timestamp file, it means we have already copied it once.  We need to check if there is a timestamp difference
            // But if the asset does not even exist on the xbox we should force a copy
            if (fileExists &&
                (mTargetTimestamps.SectionExist("ASSETS") && mTargetTimestamps.KeyExist("ASSETS", file.FullName))
                )
            {
                // Get timestamp of target and source
                // Copy if they are not the same
                if (string.Compare(file.LastWriteTime.ToFileTime().ToString(), mTargetTimestamps.GetString("ASSETS", file.FullName)) != 0)
                {
                    if (mGetFileCount)
                    {
                        mTotalFilesToCopy++;
                        mPendingCopy.PutString("COPY_FILE", file.FullName, targetFile);
                        mPendingCopy.Save();
                    }
                    else
                    {
                        mProgress.DialogUpdate(mFileNumber++, string.Concat("Source: ", file.FullName, "\nTarget: ", targetFile));
                        Application.DoEvents();
                        if (mProgress.DialogProcess())
                        {
                            return(false);
                        }

                        if (mConsoleCopy)
                        {
                            rc = XboxUtils.FileCopyVerify(file.FullName, targetFile, true);
                        }
                        else
                        {
                            rc = DosUtils.FileCopy(file.FullName, targetFile, true);
                        }

                        if (!rc)
                        {
                            mSummary.PutString("File.CopyError", file.FullName, targetFile);
                            mSummary.Save();

                            // Check to see if the reason we failed is because we ran out of space
//							UInt64 freeSpace = XboxUtils.GetDiskFreeSpace(mSyncRoot);
//							if (freeSpace < (ulong)file.Length)
//							{
//								MOG_REPORT.ShowErrorMessageBox("Platform Sync: Out of space!", "There is insufficient space on " + mSyncRoot + " to copy " + file.FullName);
//							}
                        }
                        else
                        {
                            mSummary.PutString("File.Copied", file.FullName, targetFile);
                            mSummary.Save();

                            mTargetTimestamps.PutString("ASSETS", file.FullName, file.LastWriteTime.ToFileTime().ToString());
                            mTargetTimestamps.Save();
                        }
                    }
                }
                else
                {
                    if (!mGetFileCount)
                    {
                        // This file is up to date
                        mProgress.DialogUpdate(mFileNumber, string.Concat("FILE UP TO DATE!  Skipping...\nSource: ", file.FullName));
                        Application.DoEvents();
                        // Check if the user cancels
                        if (mProgress.DialogProcess())
                        {
                            return(false);
                        }
                    }
                }
            }
            else
            {
                if (mGetFileCount)
                {
                    mTotalFilesToCopy++;
                    if (mFileMapCreate)
                    {
                        // When making a file map, put the target first then the source
                        mPendingCopy.PutString("MAP", targetFile, file.FullName);
                    }
                    else
                    {
                        // When making a pending file, put the source first then target
                        mPendingCopy.PutString("COPY_FILE", file.FullName, targetFile);
                    }
                    //mPendingCopy.PutString("COPY_FILE", file.FullName, targetFile);
                    mPendingCopy.Save();
                }
                else
                {
                    mProgress.DialogUpdate(mFileNumber++, string.Concat("Source: ", file.FullName, "\nTarget: ", targetFile));
                    Application.DoEvents();
                    // Check if the user cancels
                    if (mProgress.DialogProcess())
                    {
                        return(false);
                    }

                    CreateTargetDirectoryPath(targetFile.Substring(0, targetFile.LastIndexOf("\\")));

                    // Sync the file to the platform
                    try
                    {
                        if (mConsoleCopy)
                        {
                            rc = XboxUtils.FileCopyVerify(file.FullName, targetFile, true);
                        }
                        else
                        {
                            rc = DosUtils.FileCopy(file.FullName, targetFile, true);
                        }
                        //rc = XboxUtils.FileCopyVerify(file.FullName, targetFile, true);
                    }
                    catch (DllNotFoundException e)
                    {
                        MOG_REPORT.ShowMessageBox("DLL ERROR", e.ToString(), MessageBoxButtons.OK);
                        return(false);
                    }
                    catch (EntryPointNotFoundException e)
                    {
                        MOG_REPORT.ShowMessageBox("DLL ERROR", e.ToString(), MessageBoxButtons.OK);
                        return(false);
                    }
                    if (!rc)
                    {
                        // Error
                        mSummary.PutString("File.CopyError", file.FullName, targetFile);
                        mSummary.Save();

                        // Check to see if the reason we failed is because we ran out of space
                        //UInt64 freeSpace = XboxUtils.GetDiskFreeSpace(mSyncRoot);
                        //if (freeSpace < (ulong)file.Length)
                        //{
                        //	MOG_REPORT.ShowErrorMessageBox("Platform Sync: Out of space!", "There is insufficient space on " + mSyncRoot + " to copy " + file.FullName);
                        //}
                    }
                    else
                    {
                        mSummary.PutString("File.Copied", file.FullName, targetFile);
                        mSummary.Save();

                        mTargetTimestamps.PutString("ASSETS", file.FullName, file.LastWriteTime.ToFileTime().ToString());
                        mTargetTimestamps.Save();
                    }
                }
            }

            return(true);
        }