Пример #1
0
        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);
        }