コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Price")] Consoles consoles)
        {
            if (id != consoles.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(consoles);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ConsolesExists(consoles.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(consoles));
        }
コード例 #2
0
 private static void MigrateTable(string tableName, string identity)
 {
     using (var pconn = new NpgsqlConnection(Parameters.Rds.OwnerConnectionString))
     {
         pconn.OpenAsync();
         using (var sconn = new SqlConnection(Parameters.Migration.SourceConnectionString))
         {
             sconn.Open();
             try
             {
                 MigrateTable(
                     tableName: tableName,
                     identity: identity,
                     pconn: pconn,
                     sconn: sconn);
                 MigrateTable(
                     tableName: tableName + "_deleted",
                     identity: null,
                     pconn: pconn,
                     sconn: sconn);
                 MigrateTable(
                     tableName: tableName + "_history",
                     identity: null,
                     pconn: pconn,
                     sconn: sconn);
             }
             catch (Exception e)
             {
                 Consoles.Write(tableName + ":" + e.Message, Consoles.Types.Info);
             }
             sconn.Close();
         }
         pconn.Close();
     }
 }
コード例 #3
0
        public ConsoleInstance CreateConsole(string consoleName)
        {
            if (string.IsNullOrEmpty(consoleName))
            {
                throw new Exception("Console name is null");
            }

            if (IsConsoleNameValid(consoleName) == false)
            {
                throw new Exception("Console name contains invalid chars");
            }

            ConsoleInstance console = new ConsoleInstance(consoleName);

            Consoles.Add(console);

            if (initializing)
            {
                actualConsoleName = consoleName;
                UpdateTitle();
            }

            initializing = false;
            return(console);
        }
コード例 #4
0
        private static void Execute(ISqlObjectFactory factory, string connectionString)
        {
            var cn = new TextData(connectionString, ';', '=');

            Consoles.Write(cn["uid"], Consoles.Types.Info);
            if (cn["uid"].EndsWith("_Owner"))
            {
                Def.SqlIoBySa(factory).ExecuteNonQuery(
                    factory: factory,
                    dbTransaction: null,
                    dbConnection: null,
                    commandText:
                    Def.Sql.GrantPrivilegeAdmin
                    .Replace("#Uid#", cn["uid"])
                    .Replace("#ServiceName#", Environments.ServiceName));
            }
            else
            {
                Def.SqlIoByAdmin(factory).ExecuteNonQuery(
                    factory: factory,
                    dbTransaction: null,
                    dbConnection: null,
                    commandText:
                    Def.Sql.GrantPrivilegeUser
                    .Replace("#Uid#", cn["uid"])
                    .Replace("#ServiceName#", Environments.ServiceName));
            }
        }
コード例 #5
0
        private static void ConfigureTableSet(string generalTableName)
        {
            Consoles.Write(generalTableName, Consoles.Types.Info);
            var deletedTableName           = generalTableName + "_deleted";
            var historyTableName           = generalTableName + "_history";
            var columnDefinitionCollection = Def.ColumnDefinitionCollection
                                             .Where(o => o.TableName == generalTableName)
                                             .Where(o => !o.NotUpdate)
                                             .Where(o => o.JoinTableName == string.Empty)
                                             .Where(o => o.Calc == string.Empty)
                                             .OrderBy(o => o.No);
            var columnDefinitionHistoryCollection = columnDefinitionCollection
                                                    .Where(o => o.History > 0)
                                                    .OrderBy(o => o.History);

            ConfigureTablePart(
                generalTableName,
                generalTableName,
                false,
                columnDefinitionCollection);
            ConfigureTablePart(
                generalTableName,
                deletedTableName,
                false,
                columnDefinitionCollection);
            ConfigureTablePart(
                generalTableName,
                historyTableName,
                true,
                columnDefinitionHistoryCollection);
        }
コード例 #6
0
        public void Run(bool startAllWorker = false)
        {
            consoleStandardOutput.Clear();

            Stopwatch watch = new Stopwatch();

            watch.Start();

            if (startAllWorker)
            {
                Consoles.ForEach(c => c.Workers.ForEach(w => w.Start()));
            }

            if (Consoles.Count == 0)
            {
                throw new InvalidOperationException("Cannot run ConsoleAsync without at least one console");
            }

            while (isRunning)
            {
                input.Execute(ActiveConsole, watch.ElapsedMilliseconds);
                Renderer.Render(ActiveConsole);
                watch.Restart();
                ManageStandardOutput();
                Task.Delay(10).Wait();
            }
        }
コード例 #7
0
 public ActionResult DeleteConfirmed(int id)
 {
     Consoles consoles = db.consoles.Find(id);
     db.consoles.Remove(consoles);
     db.SaveChanges();
     return RedirectToAction("Index");
 }
コード例 #8
0
 /// <summary>
 /// Закрывает окно с FFMPEG
 /// </summary>
 public void Close()
 {
     //Process.StandardInput.AutoFlush = true;
     //Process.StandardInput.WriteLine("\x3");
     //Process.StandardInput.Close();
     //Process.MainWindowHandle.GetProcessId().GenerateConsoleCtrlEvent(CommonFunctions.ConsoleCtrlEvent.CTRL_C);
     if (Consoles.AttachConsole((uint)Process.Id))
     {
         Consoles.SetConsoleCtrlHandler(null, true);
         try
         {
             if (!Consoles.GenerateConsoleCtrlEvent(Consoles.CTRL_C_EVENT, 0))
             {
                 return;
             }
             Process.WaitForExit();
         }
         finally
         {
             Consoles.FreeConsole();
             Consoles.SetConsoleCtrlHandler(null, false);
         }
         return;
     }
 }
コード例 #9
0
        private static void ConfigureTableSet(string generalTableName)
        {
            Consoles.Write(generalTableName, Consoles.Types.Info);
            var deletedTableName           = generalTableName + "_deleted";
            var historyTableName           = generalTableName + "_history";
            var columnDefinitionCollection = Def.ColumnDefinitionCollection
                                             .Where(o => o.TableName == generalTableName)
                                             .Where(o => !o.NotUpdate)
                                             .Where(o => o.JoinTableName.IsNullOrEmpty())
                                             .Where(o => o.Calc.IsNullOrEmpty())
                                             .OrderBy(o => o.No)
                                             .ToList();
            var columnDefinitionHistoryCollection = columnDefinitionCollection
                                                    .Where(o => o.History > 0)
                                                    .OrderBy(o => o.History);

            ConfigureTablePart(
                generalTableName,
                generalTableName,
                Sqls.TableTypes.Normal,
                columnDefinitionCollection);
            ConfigureTablePart(
                generalTableName,
                deletedTableName,
                Sqls.TableTypes.Deleted,
                columnDefinitionCollection);
            ConfigureTablePart(
                generalTableName,
                historyTableName,
                Sqls.TableTypes.History,
                columnDefinitionHistoryCollection);
        }
コード例 #10
0
 internal static void Configure()
 {
     Def.TableNameCollection().ForEach(generalTableName =>
     {
         try
         {
             ConfigureTableSet(generalTableName);
         }
         catch (System.Data.SqlClient.SqlException e)
         {
             Consoles.Write($"[{e.Number}] {e.Message}", Consoles.Types.Error);
         }
         catch (System.Exception e)
         {
             Consoles.Write($"[{generalTableName}]: {e}", Consoles.Types.Error);
         }
     });
     try
     {
         ConfigureFullTextIndex();
     }
     catch (System.Data.SqlClient.SqlException e)
     {
         Consoles.Write($"[{e.Number}] {e.Message}", Consoles.Types.Error);
     }
     catch (System.Exception e)
     {
         Consoles.Write($"[{nameof(ConfigureFullTextIndex)}]: {e}", Consoles.Types.Error);
     }
 }
コード例 #11
0
ファイル: BaseService.cs プロジェクト: xiaopohou/Farseer.Net
        /// <summary>显示状态</summary>
        protected void ShowStatus()
        {
            Consoles.WriteLine("*************************************************", ConsoleColor.Red);
            var service = Instance;
            var name    = service.ServiceName;

            Console.Write("服务:");
            Consoles.WriteLine(name != service.DisplayName ? $"{service.DisplayName}({name})" : $"{name}", ConsoleColor.Red);

            Console.Write("描述:");
            Consoles.WriteLine(service.Description, ConsoleColor.Red);
            Console.Write("状态:");

            string status;

            switch (WinServer.IsInstalled(service.ServiceName))
            {
            case null: status = "未知"; break;

            case false: status = "未安装"; break;

            default:
                switch (WinServer.IsRunning(service.ServiceName))
                {
                case null: status = "未知"; break;

                case false: status = "未启动"; break;

                default: status = "运行中"; break;
                }
                break;
            }
            Consoles.WriteLine(status, ConsoleColor.Green);
            Consoles.WriteLine("*************************************************", ConsoleColor.Red);
        }
コード例 #12
0
ファイル: Tables.cs プロジェクト: kazuca/Implem.Pleasanter
        internal static void CreateTable(
            string generalTableName,
            string sourceTableName,
            Sqls.TableTypes tableType,
            IEnumerable <ColumnDefinition> columnDefinitionCollection,
            IEnumerable <IndexInfo> tableIndexCollection,
            EnumerableRowCollection <DataRow> rdsColumnCollection,
            string tableNameTemp = "")
        {
            Consoles.Write(sourceTableName, Consoles.Types.Info);
            if (tableNameTemp.IsNullOrEmpty())
            {
                tableNameTemp = sourceTableName;
            }
            var sqlStatement = new SqlStatement(
                Def.Sql.CreateTable,
                Sqls.SqlParamCollection());

            sqlStatement.CreateColumn(sourceTableName, columnDefinitionCollection);
            sqlStatement.CreatePk(sourceTableName, columnDefinitionCollection, tableIndexCollection);
            sqlStatement.CreateIx(generalTableName, sourceTableName, tableType, columnDefinitionCollection);
            sqlStatement.CreateDefault(tableNameTemp, columnDefinitionCollection);
            sqlStatement.DropConstraint(sourceTableName, tableIndexCollection);
            sqlStatement.CommandText = sqlStatement.CommandText.Replace("#TableName#", tableNameTemp);
            Def.SqlIoByAdmin(transactional: true).ExecuteNonQuery(sqlStatement);
        }
コード例 #13
0
        private static void MigrateTable(
            string tableName,
            NpgsqlConnection pconn,
            SqlConnection sconn,
            string suffix = "")
        {
            Consoles.Write(tableName, Consoles.Types.Info);
            var scmd = new SqlCommand(
                cmdText: $"select * from [{tableName}];",
                connection: sconn);

            using (var reader = scmd.ExecuteReader())
            {
                while (reader.Read())
                {
                    var columns = new List <string>();
                    for (int i = 0; i < reader.FieldCount; i++)
                    {
                        columns.Add(reader.GetName(i));
                    }
                    var pcmd = new NpgsqlCommand(
                        cmdText:
                        $"insert into \"{tableName}\"" +
                        $"({columns.Select(columnName => "\"" + columnName + "\"").Join()})" +
                        $"values" +
                        $"({columns.Select(columnName => "@ip" + columnName).Join()});",
                        connection: pconn);
                    columns.ForEach(columnName =>
                                    pcmd.Parameters.AddWithValue(
                                        "@ip" + columnName,
                                        reader[columnName]));
                    pcmd.ExecuteNonQuery();
                }
            }
        }
コード例 #14
0
 private static void CreateSolutionBackup()
 {
     Functions.CodeDefiner.BackupCreater.BackupSolutionFiles();
     Consoles.Write(
         DisplayAccessor.Displays.Get("CodeDefinerBackupCompleted"),
         Consoles.Types.Success);
 }
コード例 #15
0
 private static void CreateMvcCode(string target)
 {
     Functions.AspNetMvc.CSharp.MvcCreator.Create(target);
     Consoles.Write(
         DisplayAccessor.Displays.Get("CodeDefinerMvcCompleted"),
         Consoles.Types.Success);
 }
コード例 #16
0
 private static void CreateCssCode()
 {
     Functions.Web.Styles.CssCreator.Create();
     Consoles.Write(
         DisplayAccessor.Displays.Get("CodeDefinerCssCompleted"),
         Consoles.Types.Success);
 }
コード例 #17
0
 private static void CreateDefinitionAccessorCode()
 {
     Functions.AspNetMvc.CSharp.DefinitionAccessorCreator.Create();
     Consoles.Write(
         DisplayAccessor.Displays.Get("CodeDefinerDefCompleted"),
         Consoles.Types.Success);
 }
コード例 #18
0
 private static void WriteErrorToConsole(IEnumerable <string> args)
 {
     Consoles.Write(
         "Incorrect argument. {0}".Params(args.Join(" ")),
         Consoles.Types.Error,
         abort: true);
 }
コード例 #19
0
ファイル: Tables.cs プロジェクト: zukky0008/Implem.Pleasanter
        internal static void CreateTable(
            string generalTableName,
            string sourceTableName,
            bool old,
            IEnumerable <ColumnDefinition> columnDefinitionCollection,
            IEnumerable <IndexInfo> tableIndexCollection,
            EnumerableRowCollection <DataRow> dbColumnCollection,
            string tableNameTemp = "")
        {
            Consoles.Write(sourceTableName, Consoles.Levels.Info);
            if (tableNameTemp == string.Empty)
            {
                tableNameTemp = sourceTableName;
            }
            var sqlCmd = new SqlCmd(
                Def.Code.Sql_CreateTable,
                SqlCmd.Types.PlainSql,
                Sqls.GetSqlParamCollection());

            sqlCmd.CreateColumn(sourceTableName, columnDefinitionCollection);
            sqlCmd.CreatePk(sourceTableName, columnDefinitionCollection, tableIndexCollection);
            sqlCmd.CreateIx(generalTableName, sourceTableName, old, columnDefinitionCollection);
            sqlCmd.CreateDefault(tableNameTemp, columnDefinitionCollection, dbColumnCollection);
            sqlCmd.DropConstraints(sourceTableName, tableIndexCollection);
            sqlCmd.CommandText = sqlCmd.CommandText.Replace("#TableName#", tableNameTemp);
            Def.GetSqlIoOfAdmin(transactional: true).ExecuteNonQuery(sqlCmd);
        }
コード例 #20
0
 private static void MigrateDatabase()
 {
     Functions.AspNetMvc.CSharp.Migrator.MigrateDatabaseAsync();
     Consoles.Write(
         DisplayAccessor.Displays.Get("CodeDefinerMigrationCompleted"),
         Consoles.Types.Success);
 }
コード例 #21
0
 private static void ConfigureDatabase()
 {
     TryOpenConnections();
     Functions.SqlServer.Configurator.Configure();
     Consoles.Write(
         DisplayAccessor.Displays.Get("CodeDefinerRdsCompleted"),
         Consoles.Types.Success);
 }
コード例 #22
0
 private static void ConfigureDatabase(ISqlObjectFactory factory)
 {
     TryOpenConnections(factory);
     Functions.Rds.Configurator.Configure(factory);
     Consoles.Write(
         DisplayAccessor.Displays.Get("CodeDefinerRdsCompleted"),
         Consoles.Types.Success);
 }
コード例 #23
0
        public async Task <Consoles> Add(Consoles consoles)
        {
            _context.Consoles.Add(consoles);

            await _context.SaveChangesAsync();

            return(consoles);
        }
コード例 #24
0
ファイル: Game.cs プロジェクト: vtavares84/Dio-Projeto-CSharp
 public Game(int id, Genero genero, string titulo, string descricao, Consoles consoles)
 {
     this.Id        = id;
     this.Genero    = genero;
     this.Titulo    = titulo;
     this.Descricao = descricao;
     this.Consoles  = consoles;
     this.Excluido  = false;
 }
コード例 #25
0
 public ProcessSetViewModel(Toolset toolset)
 {
     this.toolset = toolset ?? throw new ArgumentNullException(nameof(toolset));
     Next         = Command.Create(() =>
     {
         NextViewModel = new ConfigurationViewModel(BinarySet !, comPort !);
         PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(NextViewModel)));
     }, () => Consoles.All(c => c.IsSuccess == true) && comPort != null);
 }
コード例 #26
0
 private static IEnumerable <string> PropertyNameCollection(CssDefinition cssDefinition)
 {
     Consoles.Write(cssDefinition.Id, Consoles.Types.Info);
     return(typeof(CssDefinition).GetMembers()
            .Where(o => o.Name != "Id")
            .Where(o => !o.Name.IsNullOrEmpty())
            .Where(o => !cssDefinition[o.Name].ToStr().IsNullOrEmpty())
            .Select(o => o.Name));
 }
コード例 #27
0
 private static void CreateSolutionBackup()
 {
     Performances.Record(MethodBase.GetCurrentMethod().Name);
     Functions.CodeDefiner.BackupCreater.BackupSolutionFiles();
     Consoles.Write(
         DisplayAccessor.Displays.Get("CodeDefinerBackupCompleted"),
         Consoles.Types.Success);
     Performances.Record(MethodBase.GetCurrentMethod().Name);
 }
コード例 #28
0
 private static void CreateCssCode()
 {
     Performances.Record(MethodBase.GetCurrentMethod().Name);
     Functions.Web.Styles.CssCreator.Create();
     Consoles.Write(
         DisplayAccessor.Displays.Get("CodeDefinerCssCompleted"),
         Consoles.Types.Success);
     Performances.Record(MethodBase.GetCurrentMethod().Name);
 }
コード例 #29
0
 private static void CreateMvcCode(string target)
 {
     Performances.Record(MethodBase.GetCurrentMethod().Name);
     Functions.AspNetMvc.CSharp.MvcCreator.Create(target);
     Consoles.Write(
         DisplayAccessor.Displays.Get("CodeDefinerMvcCompleted"),
         Consoles.Types.Success);
     Performances.Record(MethodBase.GetCurrentMethod().Name);
 }
コード例 #30
0
ファイル: Starter.cs プロジェクト: toyoyuki/Implem.Pleasanter
 private static void InsertTestData()
 {
     Performances.Record(MethodBase.GetCurrentMethod().Name);
     Functions.SqlServer.TestData.Insert();
     Consoles.Write(
         DisplayAccessor.Displays.Get("CodeDefinerInsertTestDataCompleted"),
         Consoles.Types.Success);
     Performances.Record(MethodBase.GetCurrentMethod().Name);
 }
コード例 #31
0
 public static AnimatedTextSurface FromFramework(Consoles.AnimatedTextSurface surface)
 {
     return new AnimatedTextSurface()
     {
         Frames = surface.Frames.ToArray(),
         Width = surface.Width,
         Height = surface.Height,
         AnimationDuration = surface.AnimationDuration,
         Name = surface.Name,
         Font = surface.Font,
         Repeat = surface.Repeat,
         Center = surface.Center
     };
 }
コード例 #32
0
        /// <summary>
        /// Creates a colored string by parsing commands embedded in the string.
        /// </summary>
        /// <param name="value">The string to parse.</param>
        /// <param name="surfaceIndex">Index of where this string will be printed.</param>
        /// <param name="surface">The surface the string will be printed to.</param>
        /// <param name="editor">A surface editor associated with the text surface.</param>
        /// <param name="initialBehaviors">Any initial defaults.</param>
        /// <returns></returns>
        public static ColoredString Parse(string value, int surfaceIndex = -1, Consoles.ITextSurface surface = null, SurfaceEditor editor = null, ParseCommandStacks initialBehaviors = null)
        {
            var commandStacks = initialBehaviors != null ? initialBehaviors : new ParseCommandStacks();
            List<ColoredGlyph> glyphs = new List<ColoredGlyph>(value.Length);

            for (int i = 0; i < value.Length; i++)
            {
                var existingGlyphs = glyphs.ToArray();

                if (value[i] == '`' && i + 1 < value.Length && value[i + 1] == '[')
                    continue;

                if (value[i] == '[' && (i == 0 || value[i - 1] != '`'))
                {
                    try
                    {
                        if (i + 4 < value.Length && value[i + 1] == 'c' && value[i + 2] == ':' && value.IndexOf(']', i + 2) != -1)
                        {
                            int commandExitIndex = value.IndexOf(']', i + 2);
                            string command = value.Substring(i + 3, commandExitIndex - (i + 3));
                            string commandParams = "";

                            if (command.Contains(" "))
                            {
                                var commandSections = command.Split(new char[] { ' ' }, 2);
                                command = commandSections[0].ToLower();
                                commandParams = commandSections[1];
                            }

                            // Check for custom command
                            ParseCommandBase commandObject = CustomProcessor != null ? CustomProcessor(command, commandParams, existingGlyphs, surface, editor, commandStacks) : null;

                            // No custom command found, run build in ones
                            if (commandObject == null)
                                switch (command)
                                {
                                    case "recolor":
                                    case "r":
                                        commandObject = new ParseCommandRecolor(commandParams);
                                        break;
                                    case "mirror":
                                    case "m":
                                        commandObject = new ParseCommandSpriteEffect(commandParams);
                                        break;
                                    case "undo":
                                    case "u":
                                        commandObject = new ParseCommandUndo(commandParams, commandStacks);
                                        break;
                                    case "grad":
                                    case "g":
                                        commandObject = new ParseCommandGradient(commandParams);
                                        break;
                                    case "blink":
                                    case "b":
                                        commandObject = new ParseCommandBlink(commandParams, existingGlyphs, commandStacks, editor);
                                        break;
                                    case "sglyph":
                                    case "sg":
                                        commandObject = new ParseCommandSetGlyph(commandParams);
                                        break;
                                    default:
                                        break;
                                }

                            if (commandObject != null && commandObject.CommandType != CommandTypes.Invalid)
                            {
                                commandStacks.AddSafe(commandObject);

                                i = commandExitIndex;
                                continue;
                            }
                        }

                    }
                    catch (System.Exception e1)
                    {
            #if DEBUG
                        throw e1;
            #endif
                    }
                }

                int fixedSurfaceIndex;

                if (surfaceIndex == -1 || surface == null)
                    fixedSurfaceIndex = -1;
                else
                    fixedSurfaceIndex = i + surfaceIndex < surface.Cells.Length ? i + surfaceIndex : -1;

                ColoredGlyph newGlyph;

                if (fixedSurfaceIndex != -1)
                    newGlyph = new ColoredGlyph(surface[i + surfaceIndex]) { Glyph = value[i] };
                else
                    newGlyph = new ColoredGlyph(new Cell()) { Glyph = value[i] };

                // Foreground
                if (commandStacks.Foreground.Count != 0)
                    commandStacks.Foreground.Peek().Build(ref newGlyph, existingGlyphs, fixedSurfaceIndex, surface, editor, ref i, value, commandStacks);

                // Background
                if (commandStacks.Background.Count != 0)
                    commandStacks.Background.Peek().Build(ref newGlyph, existingGlyphs, fixedSurfaceIndex, surface, editor, ref i, value, commandStacks);

                if (commandStacks.Glyph.Count != 0)
                    commandStacks.Glyph.Peek().Build(ref newGlyph, existingGlyphs, fixedSurfaceIndex, surface, editor, ref i, value, commandStacks);

                // SpriteEffect
                if (commandStacks.SpriteEffect.Count != 0)
                    commandStacks.SpriteEffect.Peek().Build(ref newGlyph, existingGlyphs, fixedSurfaceIndex, surface, editor, ref i, value, commandStacks);

                // Effect
                if (commandStacks.Effect.Count != 0)
                    commandStacks.Effect.Peek().Build(ref newGlyph, existingGlyphs, fixedSurfaceIndex, surface, editor, ref i, value, commandStacks);

                glyphs.Add(newGlyph);
            }

            return new ColoredString(glyphs.ToArray()) { IgnoreEffect = !commandStacks.TurnOnEffects };
        }