Пример #1
0
    private static void Main()
    {
        // Abre o servidor e define suas configurações
        Console.Title = "Server";
        Logo();
        Console.WriteLine("[Starting]");

        // Evento de saída do console
        Handler += new EventHandler(Exit);
        SetConsoleCtrlHandler(Handler, true);

        // Verifica se todos os diretórios existem, se não existirem então criá-los
        Directories.Create();
        Console.WriteLine("Directories created.");

        // Carrega todos os dados necessários
        Read.All();

        // Limpa os dados dos jogadores
        Clear.Players();

        // Cria os dispositivos da rede
        Socket.Init();
        Console.WriteLine("Network started. Port: " + Socket.Device.Port);

        // Calcula quanto tempo demorou para inicializar o servidor
        Console.WriteLine("\r\n" + "Server started. Type 'help' to see the commands." + "\r\n");

        // Inicia os laços
        Thread Console_Loop = new Thread(Loop.Commands);

        Console_Loop.Start();
        Loop.Init();
    }
Пример #2
0
        /// <summary>Create a list of ItemBuilder objects and export them in a CSV file</summary>
        /// <param name="itemName">Item name</param>
        /// <returns>Result of action</returns>
        public ActionResult List(string itemName, string instanceName, string connectionString)
        {
            this.itemBuilder = new ItemBuilder(itemName, instanceName);
            StringBuilder fileContent = new StringBuilder(this.CreateHeader());
            var           res         = ActionResult.NoAction;

            ItemDefinition definition = ItemDefinition.Load(itemName, instanceName);
            var            list       = Read.All(definition, instanceName);

            foreach (dynamic data in list)
            {
                if (data == null)
                {
                    continue;
                }

                fileContent.Append(this.CreateRow(data));
            }

            string path = HttpContext.Current.Request.PhysicalApplicationPath;

            if (!path.EndsWith("\\", StringComparison.OrdinalIgnoreCase))
            {
                path = string.Format(CultureInfo.GetCultureInfo("en-us"), @"{0}", path);
            }

            path = string.Format(CultureInfo.InvariantCulture, @"{0}\{2}\{1}.{3}", path, this.itemBuilder.Definition.Layout.LabelPlural, ConstantValue.TemporalFolder, ConstantValue.CommaSeparatedValueExtension);
            string link = string.Format(CultureInfo.InvariantCulture, @"/{1}/{0}.{2}", this.itemBuilder.Definition.Layout.LabelPlural, ConstantValue.TemporalFolder, ConstantValue.CommaSeparatedValueExtension);

            using (StreamWriter fs = new StreamWriter(path, false))
            {
                fs.Write(fileContent);
            }

            res.SetSuccess(link);
            return(res);
        }
 public static ReadOnlyCollection <ItemBuilder> GetAll(string itemName, string instanceName)
 {
     return(Read.All(ItemDefinition.Load(itemName, instanceName), instanceName));
 }