internal bool Command_RequestActiveCommands(MOG_Command pCommand) { bool bFailed = false; // Loop through mActiveSlaves for (int c = 0; c < mActiveSlaves.Count; c++) { // Send off the Notify command for each one MOG_Command pNotify = MOG_CommandFactory.Setup_NotifyActiveCommand((MOG_Command)mActiveSlaves[c]); if (!mServerCommandManager.SendToConnection(pCommand.GetNetworkID(), pNotify)) { bFailed = true; } } // Enumerate through all the jobs foreach (MOG_JobInfo job in mJobOrder) { if (job != null) { if (!job.Command_RequestActiveCommands(pCommand)) { bFailed = true; } } } // Check if we failed? if (!bFailed) { return(true); } return(false); }
internal bool FinishJob() { bool bFinished = false; // First make sure this Job is Finished if (IsJobFinished()) { // Inform everyone that this job has been finished MOG_Command complete = MOG_CommandFactory.Setup_Complete(mStartJobCommand, true); if (mServerJobManager.GetServerCommandManager().SendToServer(complete)) { bFinished = true; } } return(bFinished); }
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); }
public static bool RebuildNetworkPackage(MOG_Filename packageFilename, string jobLabel) { // Make sure this represents the currently blessed revision of this package if (!packageFilename.IsWithinRepository()) { // Obtain the current revision for this specified package packageFilename = MOG_ControllerProject.GetAssetCurrentBlessedVersionPath(packageFilename); } // Now we should be ensured a package located within the repository if (packageFilename.IsWithinRepository()) { // Send our Rebuild package command to the server MOG_Command rebuildPackageCommand = MOG_CommandFactory.Setup_NetworkPackageRebuild(packageFilename.GetEncodedFilename(), packageFilename.GetAssetPlatform(), jobLabel); return(MOG_ControllerSystem.GetCommandManager().SendToServer(rebuildPackageCommand)); } return(false); }
internal bool AssignToSlave(MOG_Command pCommand) { MOG_Command pSlave = null; // Always make sure that the AssignedSlaveID is cleared just in case we fail pCommand.SetAssignedSlaveID(0); // Check if this is an exclusive command? if (pCommand.IsExclusiveCommand()) { // Check if this exclusive command is already actively getting processed? if (CheckExclusiveCommands(pCommand)) { // Don't assign this exclusive command because there is already another one being processed return(false); } } // Identify a valid slave based on the mValidSlaves? if (pCommand.GetValidSlaves().Length > 0) { // Look for a valid slave by scanning mAvailableSlaves for (int s = 0; s < mAvailableSlaves.Count; s++) { // Is this slave's name specified in mValidSlaves? pSlave = (MOG_Command)mAvailableSlaves[s]; if (pSlave != null) { if (IsSlaveListed(pSlave.GetComputerName(), pCommand.GetValidSlaves())) { break; } } // Indicate that this slave wasn't listed in mValidSlaves pSlave = null; } // No available valid slave found? if (pSlave == null) { // Request a new slave respecting this command's valid slaves RequestNewSlave(pCommand); // Bail out since we need to wait for a slave to become available return(false); } } else { // Check if we have run out of available slaves? if (mAvailableSlaves.Count == 0) { // Request a new slave? RequestNewSlave(pCommand); // Bail out here because there were no slaves and it can take some time before any requested slaves will be launched return(false); } // Since mValidSlaves was blank, get the first slave in the list pSlave = (MOG_Command)mAvailableSlaves[0]; } // Did we actually locate a valid available slave? if (pSlave != null) { // Send the command to the available slave if (mServerCommandManager.SendToConnection(pSlave.GetNetworkID(), pCommand)) { // Assign the Slave's NetworkID within the command so we will know who is working on this command pCommand.SetAssignedSlaveID(pSlave.GetNetworkID()); // Stick this command into the RegisteredSlave's command pSlave.SetCommand(pCommand); // Add the slave to mActiveSlaves mActiveSlaves.Add(pSlave); // Remove the top slave from mAvailableSlaves mAvailableSlaves.Remove(pSlave); // 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); return(true); } } return(false); }
bool CanObtainLicense(MOG_Command pCommand) { bool bLicense = false; // Get our server command manager? MOG_CommandServerCS commandServer = (MOG_CommandServerCS)(MOG_ControllerSystem.GetCommandManager()); if (commandServer != null) { // This client is not accounted for, check the license file to see if he can fit into the current situation if (EnsureValidLicense()) { // We have a license file if (!mTimeBomb.IsValidMacAddress()) { //The Mac address is bad String message = String.Concat("This MOG Server's machine hasn't been properly licensed.\n", "You will be limited to 2 client connections.\n", "Contact Mogware to transfer this license."); MOG_Command pBroadcast = MOG_CommandFactory.Setup_NetworkBroadcast("", message); commandServer.SendToConnection(pCommand.GetNetworkID(), pBroadcast); } else { // Since the Mac address is ok, what about the expiration? DateTime commandDate = MOG_Time.GetDateTimeFromTimeStamp(pCommand.GetCommandTimeStamp()); if (mTimeBomb.HasExpired() || mTimeBomb.HasExpired(commandDate)) { //Oh man this license file is expired String message = String.Concat("The MOG Server has been unable to renew the MOG License.\n", "You will be limited to 2 client connections.\n", "Please make sure the MOG Server machine has internet access."); MOG_Command pBroadcast = MOG_CommandFactory.Setup_NetworkBroadcast("", message); commandServer.SendToConnection(pCommand.GetNetworkID(), pBroadcast); } // Check if we are going to expire soon? else if (mTimeBomb.WillExpireSoon()) { // Inform the user of our impending doom String message = String.Concat("The MOG Server has been unable to renew the MOG License.\n", "EXPIRATION DATE: ", mTimeBomb.GetExpireDate().ToString(), "\n", "Please make sure the MOG Server machine has internet access."); MOG_Command pBroadcast = MOG_CommandFactory.Setup_NetworkBroadcast("", message); commandServer.SendToConnection(pCommand.GetNetworkID(), pBroadcast); } } } else { // There is no license file at all String message = String.Concat("You're using an unlicensed server.\n", "You will be limited to 2 client connections.\n", "Licensing can be performed in the ServerManager."); MOG_Command pBroadcast = MOG_CommandFactory.Setup_NetworkBroadcast("", message); commandServer.SendToConnection(pCommand.GetNetworkID(), pBroadcast); } // Call this to see if any more clients can be licensed if (IsLicenseAvailable()) { bLicense = true; } else { // Notify client of failed command request string message = String.Concat("No more available licenses on the server.\n\n", "This client cannot be launched until another client is closed.\n", "Additional seats can be licensed in the ServerManager."); MOG_Command pBroadcast = MOG_CommandFactory.Setup_NetworkBroadcast("", message); commandServer.SendToConnection(pCommand.GetNetworkID(), pBroadcast); } } return(bLicense); }
internal bool Command_RequestActiveCommands(MOG_Command pCommand) { bool bFailed = false; // Send off the Notify commands for this commands list IDictionaryEnumerator enumerator = mTaskCommandList.GetEnumerator(); while (enumerator.MoveNext()) { MOG_Command pActiveCommand = (MOG_Command)(enumerator.Value); MOG_Command pNotify = MOG_CommandFactory.Setup_NotifyActiveCommand(pActiveCommand); if (!mServerJobManager.GetServerCommandManager().SendToConnection(pCommand.GetNetworkID(), pNotify)) { bFailed = true; } } // Send off the Notify commands for this commands list enumerator = mPrimaryCommandList.GetEnumerator(); while (enumerator.MoveNext()) { MOG_Command pActiveCommand = (MOG_Command)(enumerator.Value); MOG_Command pNotify = MOG_CommandFactory.Setup_NotifyActiveCommand(pActiveCommand); if (!mServerJobManager.GetServerCommandManager().SendToConnection(pCommand.GetNetworkID(), pNotify)) { bFailed = true; } } // Send off the Notify commands for this commands list enumerator = mPackageCommandList.GetEnumerator(); while (enumerator.MoveNext()) { MOG_Command pActiveCommand = (MOG_Command)(enumerator.Value); MOG_Command pNotify = MOG_CommandFactory.Setup_NotifyActiveCommand(pActiveCommand); if (!mServerJobManager.GetServerCommandManager().SendToConnection(pCommand.GetNetworkID(), pNotify)) { bFailed = true; } } // Send off the Notify commands for this commands list enumerator = mPostCommandList.GetEnumerator(); while (enumerator.MoveNext()) { MOG_Command pActiveCommand = (MOG_Command)(enumerator.Value); MOG_Command pNotify = MOG_CommandFactory.Setup_NotifyActiveCommand(pActiveCommand); if (!mServerJobManager.GetServerCommandManager().SendToConnection(pCommand.GetNetworkID(), pNotify)) { bFailed = true; } } // Send off the Notify commands for this commands list enumerator = mDeferredCommandList.GetEnumerator(); while (enumerator.MoveNext()) { MOG_Command pActiveCommand = (MOG_Command)(enumerator.Value); MOG_Command pNotify = MOG_CommandFactory.Setup_NotifyActiveCommand(pActiveCommand); if (!mServerJobManager.GetServerCommandManager().SendToConnection(pCommand.GetNetworkID(), pNotify)) { bFailed = true; } } // Check if we failed? if (!bFailed) { return(true); } return(false); }