Example #1
0
        /// <summary>
        /// Check For UnloadXML Args
        /// </summary>
        /// <param name="client"></param>
        /// <param name="args"></param>
        public void OnCommand(GameClient client, string[] args)
        {
            if (args.Length < 2)
            {
                DisplaySyntax(client);
                return;
            }

            IList <Type> types = LoaderUnloaderXML.GetAllDataTableTypes();

            string argTable = args[1].ToLower();

            // Prepare Write Path
            string directory = Path.IsPathRooted(XML_UNLOAD_DB_DIRECTORY) ? XML_UNLOAD_DB_DIRECTORY : string.Format("{0}{1}scripts{1}{2}", GameServer.Instance.Configuration.RootDirectory, Path.DirectorySeparatorChar, XML_UNLOAD_DB_DIRECTORY);

            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }


            switch (argTable)
            {
            case "full":
                foreach (Type table in types)
                {
                    string dir         = directory;
                    Type   workingType = table;
                    System.Threading.Tasks.Task.Factory.StartNew(() => LoaderUnloaderXML.UnloadXMLTable(workingType, dir));
                }
                break;

            default:

                Type findType = types.Where(t => t.Name.ToLower().Equals(argTable) ||
                                            t.GetCustomAttributes(typeof(DataTable), false).Cast <DataTable>()
                                            .Where(dt => dt.TableName.ToLower().Equals(argTable)).Any())
                                .FirstOrDefault();
                if (findType == null)
                {
                    DisplaySyntax(client);
                    if (log.IsInfoEnabled)
                    {
                        log.InfoFormat("Could not find table to unload with search string : {0}", argTable);
                    }
                    return;
                }

                System.Threading.Tasks.Task.Factory.StartNew(() => LoaderUnloaderXML.UnloadXMLTable(findType, directory));
                break;
            }
        }
        /// <summary>
        /// Check For UnloadXML Args
        /// </summary>
        /// <param name="client"></param>
        /// <param name="args"></param>
        public void OnCommand(GameClient client, string[] args)
        {
            if (args.Length < 2)
            {
                DisplaySyntax(client);
                return;
            }

            var types = LoaderUnloaderXML.GetAllDataTableTypes();

            var argTable = args[1];

            // Prepare Write Path
            var directory = Path.IsPathRooted(XML_UNLOAD_DB_DIRECTORY) ? XML_UNLOAD_DB_DIRECTORY : string.Format("{0}{1}scripts{1}{2}", GameServer.Instance.Configuration.RootDirectory, Path.DirectorySeparatorChar, XML_UNLOAD_DB_DIRECTORY);

            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }

            switch (argTable)
            {
            case "full":
                foreach (Type table in types)
                {
                    var dir         = directory;
                    var workingType = table;
                    System.Threading.Tasks.Task.Factory.StartNew(() => LoaderUnloaderXML.UnloadXMLTable(workingType, dir));
                }

                break;

            default:
                var finddir  = directory;
                var findType = types.FirstOrDefault(t => t.Name.Equals(argTable, StringComparison.OrdinalIgnoreCase) || AttributesUtils.GetTableName(t).Equals(argTable, StringComparison.OrdinalIgnoreCase));
                if (findType == null)
                {
                    DisplaySyntax(client);
                    if (log.IsInfoEnabled)
                    {
                        log.InfoFormat("Could not find table to unload with search string : {0}", argTable);
                    }

                    return;
                }

                System.Threading.Tasks.Task.Factory.StartNew(() => LoaderUnloaderXML.UnloadXMLTable(findType, finddir));
                break;
            }
        }