Example #1
0
        public bool AddFile(string filename)
        {
            // We can only add to folder type objects
            if (mType == TYPE.Folder &&
                mContents != null)
            {
                // Make sure it doesn't already exist
                if (!mContents.Contains(filename))
                {
                    // Add this file
                    mContents.Add(filename, new DirectorySetInfo(filename, FolderName, DirectorySetInfo.TYPE.File));
                    //Debug.Write(filename, "\nAdded File to - " + FolderName);
                }
                else
                {
                    // Warn the user they have a colliding asset
                    string message = "Multiple assets are syncing to the same local filename.\n" +
                                     "FILENAME: " + Path.Combine(FolderName, filename) + "\n\n" +
                                     "The coliding assets can be seen from the project's Sync View tree.\n" +
                                     "Please remove the extra colliding assets from the project.";
                    MOG_Report.ReportMessage("Colliding Assets Detected", message, "", MOG_ALERT_LEVEL.ERROR);
                    return(false);
                }

                return(true);
            }

            return(false);
        }
        private int LoadIcon(string imageFileName, ImageList imageList)
        {
            try
            {
                if (imageFileName != null && imageFileName.Length > 0)
                {
                    // Load the icon specified by the Icon= key
                    string iconName = imageFileName;

                    // Make sure that the icon file exists
                    if (DosUtils.FileExist(iconName))
                    {
                        // Get the image
                        Image myImage = new Bitmap(iconName);

                        // Add the image and the type to the arrayLists
                        imageList.Images.Add(myImage);

                        return(imageList.Images.Count - 1);
                    }
                }
            }
            catch (Exception e)
            {
                MOG_Report.ReportMessage("Load Icon", e.Message, e.StackTrace, MOG_ALERT_LEVEL.CRITICAL);
            }

            return(0);
        }
Example #3
0
 static public void MOGGlobalToolsPermisions(MogMainForm mainForm)
 {
     // Encapsulate everything in a try-catch
     try
     {
         if (MOG_ControllerProject.GetPrivileges() != null)
         {
             MogControl_PrivilegesForm privilegesForm = new MogControl_PrivilegesForm(MOG_ControllerProject.GetPrivileges());
             privilegesForm.StartPosition = FormStartPosition.CenterParent;
             DialogResult result = privilegesForm.ShowDialog(mainForm);
             result.ToString();
         }
         else
         {
             MOG_Prompt.PromptMessage("Permissions Error!", "Unable to open Permissions Form.  "
                                      + "Please make sure a valid project is selected.\r\n\r\nYou may try clicking Projects |"
                                      + " (The Current Project) to resolve this error, and/or close and re-open MOG.", Environment.StackTrace);
         }
     }
     // Catch any .NET-explainable exceptions.
     catch (Exception ex)
     {
         MOG_Report.ReportMessage("Error in Privileges Change Form!", ex.Message,
                                  ex.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.ERROR);
     }
 }
Example #4
0
        static private int LoadIcon(string imageFileName, string assetClassName)
        {
            try
            {
                // Load the icon specified by the Icon= key
                string iconName = imageFileName;

                // Make sure this is a full path, if not append the tools directory to it?
                iconName = MOG_ControllerSystem.LocateTool(imageFileName);

                lock (mAssetTypes)
                {
                    // Make sure that the icon file exists
                    if (iconName.Length > 0 && DosUtils.FileExist(iconName))
                    {
                        // Get the image
                        Image myImage = new Bitmap(iconName);

                        // Add the image and the type to the arrayLists
                        mAssetTypeImages.Images.Add(myImage);
                        mAssetTypes.Add(assetClassName, mAssetTypeImages.Images.Count - 1);

                        return(mAssetTypeImages.Images.Count - 1);
                    }
                }
            }
            catch (Exception e)
            {
                MOG_Report.ReportMessage("Load Icon", e.Message, e.StackTrace, MOG_ALERT_LEVEL.CRITICAL);
            }

            return(0);
        }
Example #5
0
        //----------------------------------------------------------
        // returns a list of available client versions
        public ArrayList GetCompatibleBuilds(ListViewItem server)
        {
            try
            {
                VersionNode serverVersion    = (VersionNode)server.Tag;
                ArrayList   compatibleBuilds = new ArrayList();
                foreach (VersionNode version in mClientVersions)                        // go through client list
                {
                    // major versions must match!
                    if (version.MajorVersion == serverVersion.MajorVersion)
                    {
                        //if(version.MinorVersion >= serverVersion.MinorVersion)
                        {
                            compatibleBuilds.Add(version);
                        }
                    }
                }

                return(compatibleBuilds);
            }
            catch (Exception e)
            {
                MOG_Report.ReportMessage("Get Compatible Builds", e.Message, e.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.ERROR);
                return(new ArrayList());
            }
        }
Example #6
0
        static public string Update(string project, string directory, string toolsPath)
        {
            string command   = "";
            string output    = "";
            string arguments = "";

            // set current dir
            Environment.CurrentDirectory = directory;

            command   = string.Concat(toolsPath, "\\cvs.bat");
            arguments = string.Concat(directory, " update -d");

            // Run the command
            Process p = new Process();

            p.StartInfo.FileName  = command;
            p.StartInfo.Arguments = arguments;

            try
            {
                p.Start();
            }
            catch (Exception e)
            {
                MOG_Report.ReportMessage("SpawnDosCommand Error", String.Concat("Could not waitForExit (", e.Message, ")"), e.StackTrace, MOG_ALERT_LEVEL.CRITICAL);
            }


            p.Close();
            return(output);
        }
Example #7
0
        public void KillCommand()
        {
            try
            {
                List <ListViewItem> killed = new List <ListViewItem>();

                foreach (ListViewItem item in mainForm.CommandspendingListView.SelectedItems)
                {
                    UInt32 commandID = Convert.ToUInt32(item.SubItems[(int)CommandsColumns.COMMANDID].Text);
                    if (MOG_ControllerSystem.KillCommandFromServer(commandID))
                    {
                        killed.Add(item);
                    }
                }

                foreach (ListViewItem item in killed)
                {
                    item.Remove();
                }
            }
            catch (Exception e)
            {
                MOG_Report.ReportMessage("Kill Command Error", e.Message, e.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.ERROR);
            }
        }
        /// <summary>
        /// After rename, fixup the directory and update the MOG_ControllerSyncData
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GameDataTreeView_AfterLabelEdit(object sender, System.Windows.Forms.NodeLabelEditEventArgs e)
        {
            try
            {
                guiAssetTreeTag tag = (guiAssetTreeTag)e.Node.Tag;

                string targetDirectoryName = tag.FullFilename.Replace(e.Node.Text, e.Label);

                if (!Directory.Exists(targetDirectoryName))
                {
                    DirectoryInfo dir = new DirectoryInfo(tag.FullFilename);
                    dir.MoveTo(targetDirectoryName);

                    e.Node.Tag = new guiAssetTreeTag(targetDirectoryName, e.Node);

                    GameDataTreeView.LabelEdit = false;
                }
                else
                {
                    MOG_Report.ReportMessage("Rename Directory", "A name of that directory already exist", Environment.StackTrace, MOG_ALERT_LEVEL.ERROR);
                    e.CancelEdit = true;
                    return;
                }
            }
            catch
            {
            }
        }
Example #9
0
        private void StartTimer_Tick(object sender, System.EventArgs e)
        {
            try
            {
                if (mainForm == null)
                {
                    //StartTimer.Stop();
                    InitializeMainMogForm(mCommandLineArgs);
                    //StartTimer.Start();
                }
                else
                {
                    if (mInitializationComplete)
                    {
                        Visible = false;

                        this.Splash.Dispose();
                        if (bitmap != null)
                        {
                            bitmap.Dispose();
                            bitmap = null;
                        }

                        StartTimer.Stop();
                        mainForm.Show();
                    }
                }
            }
            catch (Exception ex)
            {
                MOG_Report.ReportMessage("Major Error", "MOG cannot start because of the following:\r\n\r\n" + ex.Message, ex.StackTrace, MOG_ALERT_LEVEL.CRITICAL);
                this.Close();
                this.Dispose(true);
            }
        }
Example #10
0
        static public int ShellExecute(string command, string arguments)
        {
            //string output = "";
            int rc = 0;

            // Run the command
            Process p = new Process();

            p.StartInfo.FileName  = command;
            p.StartInfo.Arguments = arguments;

            try
            {
                p.Start();
            }
            catch (Exception e)
            {
                MOG_Report.ReportMessage("SpawnDosCommand Error", String.Concat("Could not waitForExit (", e.Message, ")"), e.StackTrace, MOG_ALERT_LEVEL.CRITICAL);
            }

            try
            {
                p.WaitForExit();
            }
            catch (Exception e)
            {
                MOG_Report.ReportMessage("SpawnDosCommand Error", String.Concat("Could not waitForExit (", e.Message, ")"), e.StackTrace, MOG_ALERT_LEVEL.CRITICAL);
            }


            p.Close();

            return(rc);
        }
Example #11
0
        public void CreateAssetConfigs()
        {
            RaiseAssetImport_Begin();

            try
            {
                MOG_Project proj = MOG_ControllerProject.GetProject();
                if (proj != null)
                {
                    ProgressDialog progress = new ProgressDialog("Importing Assets", "Please wait while the Assets are imported into the Project's Repository.", CreateAssetConfigs_Worker, null, true);
                    progress.ShowDialog();

                    // Post the projects new assets skipping the PostScanProcess
                    MOG_ControllerProject.PostAssets(MOG_ControllerProject.GetProjectName(), MOG_ControllerProject.GetBranchName(), MOG_ControllerProject.GetProjectName(), true);
                }
            }
            catch (Exception e)
            {
                MOG_Report.ReportMessage("Unable to import asset", e.Message, e.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.CRITICAL);
            }
            finally
            {
                RaiseAssetImport_Finish();
            }
        }
        /// <summary>
        /// Find a TreeNode, given its full path.  NOTE: This does not expand down to the node, so if
        ///  the TreeView is not expanded, you will receive the closest parent node.
        /// </summary>
        /// <returns>null, if no Node found</returns>
        public TreeNode FindNode(string fullPath)
        {
            //string[] pathParts = fullPath.Split(this.PathSeparator.ToCharArray());
            TreeNode foundNode = null;

            try
            {
                TreeNodeCollection currentNodes = this.Nodes;

                // New fast search
                TreeNode [] foundNodes = currentNodes.Find(fullPath, true);
                if (foundNodes != null && foundNodes.Length > 0)
                {
                    if (foundNodes.Length == 1)
                    {
                        return(foundNodes[0]);
                    }
                }
                // KLK - Removed this old way of finding nodes because you can use the trees built in find if you set the name of each node = its fullpath.
                //else
                //{
                //    // Foreach part of our pathParts, look for a node that matches our currentPart...
                //    foreach (string currentPart in pathParts)
                //    {
                //        // Foreach node in currentNodes, see if we match
                //        foreach (TreeNode node in currentNodes)
                //        {
                //            // If we match, set foundNode to node, then exit out of this foreach
                //            if (string.Compare(node.Text, currentPart, true) == 0)
                //            //if (node.Text.ToLower() == currentPart.ToLower())
                //            {
                //                foundNode = node;
                //                break;
                //            }
                //        }

                //        // If our foundNode.Nodes is not the same as our currentNodes collection, continue...
                //        if (foundNode != null && foundNode.Nodes != currentNodes)
                //        {
                //            // Select our next set of Nodes
                //            currentNodes = foundNode.Nodes;
                //        }
                //        // Else, we've found what we're looking for (or `null`), so terminate
                //        else
                //        {
                //            break;
                //        }
                //    }
                //}
            }
            catch (Exception ex)
            {
                MOG_Report.ReportMessage("Error Finding Node", ex.Message, ex.StackTrace, MOG_ALERT_LEVEL.ERROR);
            }

            return(foundNode);
        }
Example #13
0
        /// <summary>
        /// Makes the selected assets the current version in the current branch
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MakeCurrentMenuItem_Click(object sender, System.EventArgs e)
        {
            try
            {
                ArrayList selectedItems  = ControlGetSelectedItems();
                ArrayList assetFilenames = new ArrayList();

                // Scan the list and prepare it for delivery to the DLL
                string message = "";
                foreach (guiAssetTreeTag tag in selectedItems)
                {
                    if (tag.Execute)
                    {
                        MOG_Filename filename = new MOG_Filename(tag.FullFilename);
                        if (filename.GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset)
                        {
                            assetFilenames.Add(filename);
                        }

                        message = message + filename.GetAssetFullName() + "\n";
                    }
                }

                // Check if this request effects more than 1 asset??
                if (selectedItems.Count > 1)
                {
                    if (MOG_Prompt.PromptResponse("Are you sure you want to make all of these assets the current versions?", message, MOGPromptButtons.OKCancel) != MOGPromptResult.OK)
                    {
                        return;
                    }
                }

                // Stamp all the specified assets
                if (MOG_ControllerProject.MakeAssetCurrentVersion(assetFilenames, "Made current by " + MOG_ControllerProject.GetUserName_DefaultAdmin()))
                {
                    // Check if this request effects more than 1 asset??
                    if (selectedItems.Count > 1)
                    {
                        // Inform the user this may take a while
                        MOG_Prompt.PromptResponse("Completed",
                                                  "This change requires Slave processing.\n" +
                                                  "The project will not reflect these changes until all slaves have finished processing the generated commands.\n" +
                                                  "The progress of this task can be monitored in the Connections Tab.");
                    }
                }
                else
                {
                    MOG_Prompt.PromptMessage("Make Current Failed", "The system was unable to fully complete the task!", Environment.StackTrace);
                }
            }
            catch (Exception ex)
            {
                MOG_Report.ReportMessage("MakeCurrent Exception", ex.Message, ex.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.CRITICAL);
            }
        }
Example #14
0
        private void InitializeMOG()
        {
            // Check to see if we can init the server
            if (!MOG_Main.Init_Client("", "Remote Server Manager"))
            {
                // Inform the user that we failed to connect and will continue in an offline mode
                string message = "Failed to connect to the MOG Server.\n" +
                                 "Please be advised that you will most likely experience limited functionality during this session.";
                MOG_Report.ReportMessage("Connection Failed", message, "", MOG_ALERT_LEVEL.ALERT);
            }

            RemoteServerSettings.Initialize();
        }
Example #15
0
        private void GameDataCreateMenuItem_Click(object sender, System.EventArgs e)
        {
            try
            {
                // Create a directory as a child directory of a node
                if (GameDataTreeView.SelectedNode != null)
                {
                    guiAssetTreeTag tag = GameDataTreeView.SelectedNode.Tag as guiAssetTreeTag;

                    string   directoryPath = tag.FullFilename + "\\NewDirectory";
                    TreeNode directory     = CreateDirectoryNode(tag.FullFilename + "\\NewDirectory", null);

                    // Now create the folder
                    if (!DosUtils.DirectoryCreate(directoryPath))
                    {
                        MOG_Prompt.PromptResponse("Create Directory", DosUtils.GetLastError(), MOGPromptButtons.OK);
                    }
                    else
                    {
                        // Now edit the name of this node
                        GameDataTreeView.LabelEdit = true;
                        GameDataTreeView.SelectedNode.Nodes.Add(directory);
                        GameDataTreeView.SelectedNode = directory;
                        GameDataTreeView.SelectedNode.BeginEdit();
                    }
                }
                else
                {
                    // Create a directory at the root of the project
                    string   directoryPath = MOG_ControllerProject.GetCurrentSyncDataController().GetSyncDirectory() + "\\NewDirectory";
                    TreeNode directory     = CreateDirectoryNode(directoryPath, null);

                    // Now create the folder
                    if (!DosUtils.DirectoryCreate(directoryPath))
                    {
                        MOG_Prompt.PromptResponse("Create Directory", DosUtils.GetLastError(), MOGPromptButtons.OK);
                    }
                    else
                    {
                        // Now edit the name of this node
                        GameDataTreeView.LabelEdit    = true;
                        GameDataTreeView.SelectedNode = directory;
                        directory.BeginEdit();
                    }
                }
            }
            catch (Exception ex)
            {
                MOG_Report.ReportMessage("Create Directory", ex.Message, ex.StackTrace, MOG_ALERT_LEVEL.CRITICAL);
            }
        }
Example #16
0
        static void Main(string[] args)
        {
            Control.CheckForIllegalCrossThreadCalls = false;

            SplashForm form = null;

            try
            {
                // Check for multiple instances
                Process mogProcess = RunningInstance();
                if (mogProcess != null)
                {
                    // we've got a duplicate process - ask the user if they want to continue anyway
                    DialogResult res = MessageBox.Show("An instance of the MOG Server Manager is already running on this machine.\nIt is possible that this instance is the result of a crash or other problem,\nin which case you should contact your MOG or network administrator.\n\nWould you like to start the Manager anyway?",
                                                       "Manager Already Running", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);

                    // if not, shutdown
                    if (res == DialogResult.No)
                    {
                        return;
                    }

                    // user wants to spawn a new instance
                }

                form                  = new SplashForm(args);
                form.Closing         += new CancelEventHandler(form_Closing);
                form.Closed          += new EventHandler(form_Closed);
                form.HandleDestroyed += new EventHandler(form_HandleDestroyed);
                Application.Run(form);
            }
            catch (Exception e)
            {
                MOG_Report.ReportMessage("Main", e.Message, e.StackTrace, MOG_ALERT_LEVEL.CRITICAL);
                // Write our problem out to our Output window in VS.NET
                System.Diagnostics.Debug.WriteLine(e.ToString() + "\n" + e.StackTrace);
                // Shutdown our process
                if (form != null)
                {
                    form.Close();
                    if (form.mainForm.mMogProcess != null)
                    {
                        form.mainForm.mMogProcess.Abort();
                    }
                }
                // Exit our application so we can set a breakpoint here and try again
                MOG_Main.Shutdown();
                Application.Exit();
            }
        }
		/// <summary>
		/// Remove a Package from the PackageManagement Tree. 
		///  Adapted from MogControl_AssetContextMenu.cs::MenuItemRemoveFromProject_Click()
		/// </summary>
		private void RemovePackage(MOG_Filename packageName)
		{
			try
			{
				if (!MOG_ControllerProject.RemoveAssetFromProject(packageName, "No longer needed", false))
				{
					return;
				}
			}
			catch (Exception ex)
			{
				MOG_Report.ReportMessage("Remove From Project", ex.Message, ex.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.CRITICAL);
			}
		}
Example #18
0
        public static bool Process(string fullName)
        {
            try
            {
                MOG_ControllerInbox.RipAsset(new MOG_Filename(fullName));
            }
            catch (Exception e)
            {
                MOG_Report.ReportMessage("Process", fullName + "\n\n" + e.Message, e.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.ERROR);
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// Delete directory
        /// </summary>
        private void LocalDirectoryDeleteMenuItem_Click(object sender, System.EventArgs e)
        {
            try
            {
                guiAssetTreeTag tag = (guiAssetTreeTag)GameDataTreeView.SelectedNode.Tag;
                if (MOG_Prompt.PromptResponse("Delete Directory", "Are you sure you wan to delete this directory with all its contents?\n\nDirectory:\n\n" + tag.FullFilename, MOGPromptButtons.YesNo) == MOGPromptResult.Yes)
                {
                    if (tag.Object != null)
                    {
                        // Get our gameData handle from the item's tag
                        MOG_ControllerSyncData gameDataHandle = (MOG_ControllerSyncData)tag.Object;
                        if (gameDataHandle != null)
                        {
                            MOG_Report.ReportMessage("Delete Directory", "Cannot delete a directory that is a MOG Local Workspace! Remove this Workspace first then try again.", Environment.StackTrace, MOG_ALERT_LEVEL.ERROR);
                            return;
//							// Remove the synced location
//							if (!MOG_DBSyncedDataAPI.RemoveSyncedLocation(MOG_ControllerSystem.GetComputerName(), gameDataHandle.GetProjectName(), gameDataHandle.GetPlatformName(), gameDataHandle.GetGameDataPath()))
//							{
//								throw new Exception("Database could not remove this synced location!");
//							}
//
//							// Remove all the updated records
//							string filter = gameDataHandle.GetGameDataPath() + "\\*";
//							if (!MOG_DBInboxAPI.InboxRemoveAllAssets("Local", null, null, filter))
//							{
//								throw new Exception("Database inbox could not remove this synced location!");
//							}
                        }
                    }

                    // Now, actually delete the directory
                    ArrayList FilesToDelete = DosUtils.FileGetRecursiveList(tag.FullFilename, "*.*");

                    ProgressDialog progress = new ProgressDialog("Delete Directory", "Deleting...", LocalDirectoryDelete_Worker, FilesToDelete, true);
                    if (progress.ShowDialog() == DialogResult.OK)
                    {
                        // Now delete all the files left behind
                        Directory.Delete(tag.FullFilename, true);

                        // Remove the node
                        GameDataTreeView.SelectedNode.Remove();
                    }
                }
            }
            catch (Exception ex)
            {
                MOG_Report.ReportMessage("Delete Directory", "Could not delete this directory!\n\nMessage:" + ex.Message, ex.StackTrace, MOG_ALERT_LEVEL.CRITICAL);
            }
        }
Example #20
0
        static public string Checkout(string project, string directory, string toolsPath)
        {
            string command   = "";
            string target    = "";
            string output    = "";
            string arguments = "";

            target = string.Concat(directory, "\\", project);

            // Check if the target directory exists
            if (DosUtils.DirectoryExist(target))
            {
                if (MessageBox.Show("Target directory already exists!  Checkout will delete current data!  Do you want to continue?", "Checkout", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    return("");
                }
                else
                {
                    DosUtils.DirectoryDelete(target);
                }
            }

            // Create dir
            DosUtils.DirectoryCreate(directory);
            Environment.CurrentDirectory = directory;

            command   = string.Concat(toolsPath, "\\cvs.bat");
            arguments = string.Concat(directory, " checkout ", project);

            // Run the command
            Process p = new Process();

            p.StartInfo.FileName  = command;
            p.StartInfo.Arguments = arguments;

            try
            {
                p.Start();
            }
            catch (Exception e)
            {
                MOG_Report.ReportMessage("SpawnDosCommand Error", String.Concat("Could not waitForExit (", e.Message, ")"), e.StackTrace, MOG_ALERT_LEVEL.CRITICAL);
            }


            p.Close();

            return(output);
        }
        private int AppendSummary(string section, string comment, Color nodeColor)
        {
            // Get all the file copies
            if (mSummary.SectionExist(section))
            {
                string[] keys = mSummary.GetSectionKeys(section);
                foreach (string key in keys)
                {
                    // Get the asset/file information from the summary file
                    string assetName = mSummary.GetString(section, key);
                    string fileName  = key;

                    // Trim any starting '\'
                    if (fileName != null && fileName.Length > 0)
                    {
                        fileName = fileName.TrimStart("\\".ToCharArray());
                    }

                    try
                    {
                        string fullfilename = MOG_ControllerProject.GetCurrentSyncDataController().GetSyncDirectory() + "\\" + fileName;

                        ListViewItem item = new ListViewItem();
                        item.Text      = Path.GetFileName(fileName);
                        item.ForeColor = nodeColor;

                        FileInfo file = new FileInfo(fullfilename);
                        item.SubItems.Add(file.LastWriteTime.ToShortDateString() + " " + file.LastWriteTime.ToShortTimeString());
                        item.SubItems.Add(comment);

                        item.ImageIndex = MogUtil_AssetIcons.GetFileIconIndex(fullfilename);

                        SummaryListView.Items.Add(item);
                    }
                    catch (Exception e)
                    {
                        MOG_Report.ReportMessage("Update Summary", e.Message, e.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.ERROR);
                    }
                }

                return(mSummary.CountKeys(section));
            }

            return(0);
        }
        internal bool ReleaseSlave(MOG_Command pCommand)
        {
            // Scan mActiveSlaves looking for one that matches this command
            // This way is safer just in case NetworkIDs get reset from a reconnect event
            for (int s = 0; s < mActiveSlaves.Count; s++)
            {
                MOG_Command pSlave = (MOG_Command)mActiveSlaves[s];

                // Check if this slave is working on something?
                if (pSlave.GetCommand() != null)
                {
                    // Check if the CommandID matches?
                    if (pSlave.GetCommand().GetCommandID() == pCommand.GetCommandID())
                    {
                        // Clear this slave's command
                        pSlave.SetCommand(null);
                        // Refresh the command's SetAssignedSlaveID
                        pCommand.SetAssignedSlaveID(pSlave.GetNetworkID());

                        // Send out needed Notify command
                        MOG_Command pNotify = MOG_CommandFactory.Setup_NotifyActiveConnection(pSlave);
                        mServerCommandManager.SendToActiveTab("Connections", pNotify);

                        pNotify = MOG_CommandFactory.Setup_NotifyActiveCommand(pCommand);
                        mServerCommandManager.SendToActiveTab("Connections", pNotify);

                        // Insert the slave at the top of mAvailableSlaves so it will be immeadiately reused
                        mAvailableSlaves.Insert(0, pSlave);
                        // Erase the slave from mActiveSlaves
                        mActiveSlaves.RemoveAt(s);

                        // Return the command that the slave was processing for reference
                        return(true);
                    }
                }
            }

            string message = String.Concat("Server could not release slave because it failed to locate the slave in mActiveSlaves\n",
                                           "Command:", pCommand.ToString(), "     NetworkID:", pCommand.GetNetworkID(), "     Asset:", pCommand.GetAssetFilename().GetOriginalFilename());

            MOG_Report.ReportMessage("Server", message, Environment.StackTrace, MOG_ALERT_LEVEL.ERROR);
            return(false);
        }
Example #23
0
        public void PlaySound(string filename)
        {
            if (!mSoundAvailable)
            {
                return;
            }

            try
            {
                mPlayer.SoundLocation = filename;
                mPlayer.Load();
                mPlayer.Play();
            }
            catch (Exception e)
            {
                MOG_Report.ReportMessage("Sound Error", e.Message, e.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.CRITICAL);
                mSoundAvailable = false;
                return;
            }
        }
Example #24
0
        public string RefreshConnectionToolText()
        {
            // get SQL server and MOG Repository drive mapping info
            string connectionString = MOG_ControllerSystem.GetDB().GetConnectionString();
            string sqlServerName    = "NONE";

            if (connectionString.ToLower().IndexOf("data source") != -1)
            {
                // parse out sql server name
                //sqlServerName = connectionString.Substring(connectionString.ToLower().IndexOf("data source=")+13,
                string[] substrings = connectionString.Split(";".ToCharArray());

                // look for correct part o' the connection string
                foreach (string substring in substrings)
                {
                    if (substring.ToLower().StartsWith("data source="))
                    {
                        sqlServerName = substring.Substring(substring.IndexOf("=") + 1).ToUpper();
                    }
                }
            }

            try
            {
                // get MOG repository drive and mapping info
                string mogDrive       = MOG_ControllerSystem.GetSystemRepositoryPath();
                char   mogDriveLetter = Path.GetPathRoot(mogDrive)[0];
                string mogDriveTarget = new NetworkDriveMapper().GetDriveMapping(mogDriveLetter);

                // Connected to X-SERVER @IP 192.168.5.5; SQL Server: JBIANCHI; MOG Repository M: mapped to \\GX\MOG
                //ConnectionString=Packet size=4096;integrated security=SSPI;data source=NEMESIS;persist security info=False;initial catalog=mog16;

                return(string.Concat(MOG_ControllerSystem.GetServerComputerName(), " SQL SERVER: ", sqlServerName));
            }
            catch (Exception e)
            {
                MOG_Report.ReportMessage("RefreshConnectionToolText", e.Message, e.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.CRITICAL);
            }

            return("Connected");
        }
 private void resetToGroupDefaultsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         ToolStripMenuItem menuItem = sender as ToolStripMenuItem;
         if (menuItem != null)
         {
             TreeNode node = MainTreeView.SelectedNode;
             // Create identifiers for our userName and the groupName we will be changing to
             string userName  = node.Text;
             string groupName = menuItem.Text;
             ResetToGroupDefaults(node, userName, groupName);
         }
     }
     // Tell the user if there was an error
     catch (Exception ex)
     {
         MOG_Report.ReportMessage("Error Assigning to Group " + ((MenuItem)sender).Text,
                                  ex.Message, ex.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.ERROR);
     }
 }
Example #26
0
        private void Rename_Worker(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            bRenameSuccessful = true;

            try
            {
                // Store a list of assets we were unable to rename
                string listOfFailedRenames = "";

                // Iterates through asset(s) to be renamed.
                for (int i = 0; i < mSourceFiles.Count && !worker.CancellationPending; i++)
                {
                    string asset = mSourceFiles[i] as string;

                    // We jump here when we ignore errors (for missing files)
                    MOG_Filename assetName  = new MOG_Filename(asset);
                    string       targetName = GetTargetName(assetName);

                    // Rename the file with a new MOG_Controller
                    MOG_ControllerInbox.Rename(assetName, targetName, this.RenameFiles.Checked);

                    worker.ReportProgress(i * 100 / mSourceFiles.Count);
                }

                if (listOfFailedRenames.Length > 0)
                {
                    MOG_Prompt.PromptMessage("Failed Rename", "Unable to rename the following because "
                                             + "you account does not have the permission to do so:\r\n\r\n"
                                             + listOfFailedRenames);
                }
            }
            catch (Exception ex)
            {
                MOG_Report.ReportMessage("Rename ERROR!", "The following error occured: \n"
                                         + ex.Source + " <-- " + ex.Message, ex.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.CRITICAL);
                bRenameSuccessful = false;
            }
        }
        /// <summary>
        /// Remove a Package from the PackageManagement Tree.
        ///  Adapted from MogControl_AssetContextMenu.cs::MenuItemRemoveFromProject_Click()
        /// </summary>
        private void RemovePackageFromProject(Mog_BaseTag packageTag)
        {
            try
            {
                string message = "Are you sure you want to remove this package from the game?\r\n" + packageTag.PackageFullName;

                // If user OKs our removal...
                if (MOG_Prompt.PromptResponse("Remove Asset From Project", message, MOGPromptButtons.OKCancel) == MOGPromptResult.OK)
                {
                    if (packageTag.Execute)
                    {
                        MOG_Filename filename = new MOG_Filename(packageTag.FullFilename);

                        // Make sure we are an asset before showing log
                        if (filename.GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset)
                        {
                            // Proceed to remove this package from the project; skiping the unpackage merge event
                            if (MOG_ControllerProject.RemoveAssetFromProject(filename, "No longer needed", false))
                            {
                                // Go ahead and actually remove the node
                                packageTag.ItemRemove();
                            }
                            else
                            {
                                MOG_Prompt.PromptMessage("Remove Package From Project Failed",
                                                         "The package could not be removed from the project.\n" +
                                                         "PACKAGE: " + filename.GetAssetFullName() + "\n\n" +
                                                         "We are now aborting the remove process.\n", Environment.StackTrace);
                                return;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MOG_Report.ReportMessage("Remove From Project", ex.Message, ex.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.CRITICAL);
            }
        }
Example #28
0
        /// <summary>
        /// Get all the versions within the specified directory, and add them to either the server array or the clients array
        /// </summary>
        /// <param name="FullName"></param>
        private void GetAllVersions(string FullName)
        {
            ArrayList fileList = new ArrayList();

            try
            {
                DirectoryInfo updateDir = new DirectoryInfo(FullName);
                // Scan all the folders in this specified directory
                foreach (DirectoryInfo dir in updateDir.GetDirectories())
                {
                    // Ommit the 'current' directory unless that is the only directory
                    if (string.Compare(dir.Name, DeploymentTarget, true) != 0 || updateDir.GetDirectories().Length == 1)
                    {
                        // Create the version node
                        VersionNode node = this.CreateVersionNode(dir.Name, dir.FullName);
                        if (node != null)
                        {
                            // Assign it to the correct arrayList
                            switch (node.Type.ToUpper())
                            {
                            case "SERVER":
                                this.mServerVersions.Add(node);
                                break;

                            default:
                                this.mClientVersions.Add(node);
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MOG_Report.ReportMessage("Build version list", e.Message, e.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.ERROR);
            }
        }
Example #29
0
        private void MogProcess()
        {
            while (!MOG_Main.IsShutdown())
            {
                try
                {
                    MOG_Main.Process();
                }
                catch (Exception ex)
                {
                    MOG_Report.ReportMessage("MOG Process", ex.Message, ex.StackTrace, MOG_ALERT_LEVEL.CRITICAL);
                }

                Thread.Sleep(1);
            }

            // Inform our parent thread that we have exited
            mMogProcess = null;

            // Gracefully wait a while to see if our parent thread will terminate the application for us?
            Thread.Sleep(500);
            // At this point, let's take the inititive and shut ourselves down
            Application.Exit();
        }
Example #30
0
        static public int Shell(string command, string arguments, ProcessWindowStyle windowStyle, ref string output, bool WaitForExit)
        {
            int rc = -1;
            // Run the command
            Process p = new Process();

            p.StartInfo.FileName         = command;
            p.StartInfo.Arguments        = arguments;
            p.StartInfo.WorkingDirectory = DosUtils.PathGetDirectoryPath(command);

            p.StartInfo.WindowStyle = windowStyle;

            if (windowStyle == ProcessWindowStyle.Hidden)
            {
                p.StartInfo.CreateNoWindow         = true;
                p.StartInfo.RedirectStandardOutput = true;
                p.StartInfo.RedirectStandardError  = true;
                p.StartInfo.UseShellExecute        = false;
            }

            try
            {
                p.Start();
            }
            catch (Exception e)
            {
                MOG_Prompt.PromptMessage("ShellExecute", "Command:" + p.StartInfo.FileName + "\n" +
                                         "Args:" + p.StartInfo.Arguments + "\n" +
                                         e.Message, e.StackTrace, MOG_ALERT_LEVEL.ERROR);
                return(-1);
            }

            if (windowStyle == ProcessWindowStyle.Hidden)
            {
                output = string.Concat("StdOut", p.StandardOutput.ReadToEnd());
                output = string.Concat(output, " StdError:", p.StandardError.ReadToEnd());
                rc     = p.ExitCode;
            }

            try
            {
                if (WaitForExit)
                {
                    p.WaitForExit();

                    rc = p.ExitCode;

                    // If the process exited with an error, let our user know it was not MOG's fault
                    if (rc != 0)
                    {
                        MOG_Report.ReportMessage("Unable to Open " + Path.GetFileNameWithoutExtension(command),
                                                 "Windows was unable to open the viewer: \r\n\r\n" + command, "", MOG_ALERT_LEVEL.ALERT);
                    }

                    p.Close();
                }
                else
                {
                    rc = 0;
                }
            }
            catch
            {
                p.Close();
            }

            return(rc);
        }