private void ExecuteAboutDataCommand(CommandDto commandDto)
        {
            if (commandDto.CommandType == CommandTypes.ADD)
            {
                ICommandAdd command = new AddAboutDataCommand(_loggerFactory, commandDto);
                command.Execute(_context);
                _commandDataAccessProvider.AddCommand(CommandEntity.CreateCommandEntity(commandDto));
                _commandDataAccessProvider.Save();
                command.UpdateIdforNewItems();
                _undocommands.Push(command);
            }

            if (commandDto.CommandType == CommandTypes.UPDATE)
            {
                ICommand command = new UpdateAboutDataCommand(_loggerFactory, commandDto);
                command.Execute(_context);
                _commandDataAccessProvider.AddCommand(CommandEntity.CreateCommandEntity(commandDto));
                _commandDataAccessProvider.Save();
                _undocommands.Push(command);
            }

            if (commandDto.CommandType == CommandTypes.DELETE)
            {
                ICommand command = new DeleteAboutDataCommand(_loggerFactory, commandDto);
                command.Execute(_context);
                _commandDataAccessProvider.AddCommand(CommandEntity.CreateCommandEntity(commandDto));
                _commandDataAccessProvider.Save();
                _undocommands.Push(command);
            }
        }
Beispiel #2
0
        public void WhenUpsertAndEntityExists_ThenReplacesInRepository()
        {
            var entity = new TestDomainEntity("anupsertedid".ToIdentifier())
            {
                AStringValue = "anewvalue"
            };
            var fetchedEntity  = new CommandEntity("anid");
            var updatedEntity  = new CommandEntity("anid");
            var hydratedEntity = new TestDomainEntity("anid".ToIdentifier());

            this.repository.Setup(repo =>
                                  repo.Retrieve("acontainername", It.IsAny <string>(),
                                                It.IsAny <RepositoryEntityMetadata>()))
            .Returns(fetchedEntity);
            this.repository.Setup(repo =>
                                  repo.Replace("acontainername", It.IsAny <string>(), It.IsAny <CommandEntity>()))
            .Returns(updatedEntity);
            this.domainFactory.Setup(df =>
                                     df.RehydrateEntity(It.IsAny <Type>(), It.IsAny <IReadOnlyDictionary <string, object> >()))
            .Returns(hydratedEntity);

            var result = this.storage.Upsert(entity);

            result.Should().BeEquivalentTo(hydratedEntity);
            this.repository.Verify(repo =>
                                   repo.Retrieve("acontainername", "anupsertedid",
                                                 It.IsAny <RepositoryEntityMetadata>()));
            this.repository.Verify(repo =>
                                   repo.Replace("acontainername", "anupsertedid", It.IsAny <CommandEntity>()));
        }
Beispiel #3
0
        public void TestRectangleCommandInstance()
        {
            string        input   = "r 2 4 2 8";
            CommandEntity command = CommandFactory.GetCommand(input);

            Assert.IsInstanceOfType(command, typeof(RectangleCommand));
        }
        public async Task UpdateCommand(CommandEntity command)
        {
            try
            {
                var query      = @"UPDATE commands
                              SET command = @CommandUpdate, Description = @DescriptionUpdate
                              WHERE Id = @IdUpdate;
                            ";
                var connection = Context
                                 .Database
                                 .GetDbConnection();

                await connection.ExecuteAsync
                    (query,
                    new
                {
                    CommandUpdate     = command.Command,
                    DescriptionUpdate = command.Description,
                    IdUpdate          = command.Id
                }
                    );
            }
            catch
            {
                return;
            }
        }
        public async Task CreateCommandAsync(CommandEntity command)
        {
            try
            {
                var connection = Context
                                 .Database
                                 .GetDbConnection();

                var queryToCreate =
                    @"
                    INSERT INTO commands
                    (Command, Description)
                    VALUES 
                    (@Command, @Description);
                ";

                await connection.ExecuteAsync(queryToCreate,
                                              new
                {
                    Command     = command.Command,
                    Description = command.Description
                });
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                System.Console.WriteLine("Erro ao criar dados");
            }
        }
Beispiel #6
0
        /// <summary>
        /// 发送所有入场车辆原始数据
        /// </summary>
        /// <param name="parkingCode">停车场编码</param>
        /// <returns></returns>
        public bool SendAllPresenceOfVehicleByOriginal(string parkingCode, string deviceMACAddress)
        {
            try
            {
                List <VehicleInModel> list = AllPresenceOfVehicleByOriginal(parkingCode);
                if (list == null || list.Count <= 0)
                {
                    return(true);
                }

                EntryOriginalModel model = new EntryOriginalModel();
                model.DeviceIdentify = deviceMACAddress;

                //每次只发送50条,分批发完
                int itemCount = 50;
                for (int i = 0; i < Math.Ceiling((double)list.Count() / itemCount); i++)
                {
                    model.OriginalList = list.Skip(i * itemCount).Take(itemCount).ToList();
                    CommandEntity <EntryOriginalModel> entity = new CommandEntity <EntryOriginalModel>()
                    {
                        command = BussineCommand.SyncParking,
                        idMsg   = Convert.ToBase64String(Guid.NewGuid().ToByteArray()),
                        message = model
                    };

                    m_rabbitMQ.SendMessageForRabbitMQ("同步所有入场车辆原始数据", m_serializer.Serialize(entity), entity.idMsg, parkingCode);
                }
                return(true);
            }
            catch (Exception ex)
            {
                m_logger.LogFatal(LoggerLogicEnum.Bussiness, "", parkingCode, "", "Fujica.com.cn.Business.ParkLot.CardServiceManager.SendAllPresenceOfVehicleByOriginal", "下发同步所有入场车辆原始数据时发生异常", ex.ToString());
                return(false);
            }
        }
        public CommandEntity Build()
        {
            var built = _entity;

            _entity = new CommandEntity();
            return(built);
        }
        public void TestCanvasCommandInstance()
        {
            string        input   = "c 10 12";
            CommandEntity command = CommandFactory.GetCommand(input);

            Assert.IsInstanceOfType(command, typeof(CanvasCommand));
        }
Beispiel #9
0
        private bool ImportDataToMQ(CardServiceModel model)
        {
            try
            {
                bool           result    = false;
                MonthCardModel sendmodel = new MonthCardModel()
                {
                    CarOwnerName = model.CarOwnerName,
                    CarNo        = model.CarNo,
                    Delete       = model.Enable ? false : true,
                    CarTypeGuid  = model.CarTypeGuid,
                    Locked       = model.Locked,
                    StartDate    = model.StartDate.Date.AddHours(0).AddMinutes(0).AddSeconds(0).ToString("yyyy-MM-dd HH:mm:ss"),
                    EndDate      = model.EndDate.Date.AddDays(1).AddSeconds(-1).ToString("yyyy-MM-dd HH:mm:ss") //结束时间截止到23:59:59
                };

                CommandEntity <MonthCardModel> entity = new CommandEntity <MonthCardModel>()
                {
                    command = BussineCommand.MonthCar,
                    idMsg   = Convert.ToBase64String(Guid.NewGuid().ToByteArray()),
                    message = sendmodel
                };

                result = m_rabbitMQ.SendMessageForRabbitMQ("发送月卡命令", m_serializer.Serialize(entity), entity.idMsg, model.ParkCode);
                return(result);
            }
            catch (Exception ex)
            {
                m_ilogger.LogFatal(LoggerLogicEnum.Tools, "", model.ParkCode, model.CarNo, "CameraUpdateTool.MainForm.ImportDataToMQ", "下发月卡时发生异常", ex.ToString());
                return(false);
            }
        }
Beispiel #10
0
        public void TestBucketCommandInstance()
        {
            string        input   = "b 10 12 o";
            CommandEntity command = CommandFactory.GetCommand(input);

            Assert.IsInstanceOfType(command, typeof(BucketCommand));
        }
        public void WhenUpsertAndEntityExists_ThenReplacesInRepository()
        {
            var entity = new TestDto {
                Id = "anupsertedid".ToIdentifier(), AStringValue = "anewvalue"
            };
            var fetchedEntity  = new CommandEntity("anid");
            var updatedEntity  = new CommandEntity("anid");
            var hydratedEntity = new TestDto {
                Id = "anid".ToIdentifier()
            };

            this.repository.Setup(repo =>
                                  repo.Retrieve("acontainername", It.IsAny <string>(),
                                                It.IsAny <RepositoryEntityMetadata>()))
            .Returns(fetchedEntity);
            this.repository.Setup(repo =>
                                  repo.Replace("acontainername", It.IsAny <string>(), It.IsAny <CommandEntity>()))
            .Returns(updatedEntity);

            var result = this.storage.Upsert(entity);

            result.Should().BeEquivalentTo(hydratedEntity);
            this.repository.Verify(repo =>
                                   repo.Retrieve("acontainername", "anupsertedid",
                                                 It.IsAny <RepositoryEntityMetadata>()));
            this.repository.Verify(repo =>
                                   repo.Replace("acontainername", "anupsertedid", It.IsAny <CommandEntity>()));
        }
Beispiel #12
0
        private void BuildServices(IServiceCollection services)
        {
            Global.Client    = new DiscordSocketClient(SocketEntity.GetDefault());
            Global.WebClient = OriWebClient.Default;

            services
            .AddSingleton <DataContainer>()
            //.AddSingleton(new LockedDblWrapper())
            //.AddSingleton(new DiscordShardedClient(new int[] {0}, SocketEntity.GetDefault()))
            .AddSingleton(new DiscordSocketClient(SocketEntity.GetDefault()))
            .AddSingleton(new CommandService(CommandEntity.GetDefault()))
            .AddSingleton(new AudioDependency())
            .AddSingleton(new CancellationTokenSource())
            .AddSingleton <DynamicManager>()
            //.AddSingleton<EventDependency>()
            .AddSingleton <NetworkManager>()
            .AddSingleton <ConsoleDependency>()
            .AddSingleton <AudioService>()
            .AddSingleton <InsultService>()
            .AddSingleton <StatusService>()
            .AddSingleton <GuildPrefUtility>()
            .AddSingleton <Exceptions>()
            //.AddSingleton<EventLogger>()
            .AddSingleton <Random>()
            .AddSingleton(Configuration);
        }
 public override bool CanResolve(Entity owner, string key, bool fallback = false)
 {
     return((key == Constants.OutputArgumentName &&
             CommandEntity.Decorate(owner).CommandName.Equals("deploy", StringComparison.OrdinalIgnoreCase)) ||
            (key == EntityKeys.InternalDeployPathKey &&
             TargetEntity.Decorate(owner).HasFullName));
 }
        public override Entity Resolve(Entity owner, string key, bool fallback = false)
        {
            if (key == EntityKeys.InternalDeployPathKey)
            {
                TargetEntity     targetEntity  = TargetEntity.Decorate(owner);
                BuildEntity      buildEntity   = BuildEntity.Decorate(owner);
                Entity           project       = owner.Root;
                CommandEntity    commandOrigin = CommandEntity.Decorate(owner.Origin);
                VirtualDirectory outputRoot    = fileSystem.GetDirectory(commandOrigin.Output, project.Path);
                VirtualDirectory deployRoot    = outputRoot.Directory(targetEntity.FullName.Replace(',', '_'),
                                                                      buildEntity.BuildType);
                return(owner.Create(key, deployRoot.FullName, deployRoot));
            }

            CommandEntity command           = CommandEntity.Decorate(owner);
            FileEntity    projectFileEntity = FileEntity.Decorate(owner.Root);
            string        outputDirectory   = command.GetSingleValueArgument(Constants.OutputArgumentName);

            if (string.IsNullOrEmpty(outputDirectory))
            {
                outputDirectory = projectFileEntity.Directory
                                  .Directory(Constants.LibraryFolderName)
                                  .FullName;
            }

            return(owner.Create(key, outputDirectory));
        }
Beispiel #15
0
        /// <summary>
        /// 下发手动开闸车类guid集合
        /// </summary>
        /// <param name="projectGuid"></param>
        /// <param name="parkCode"></param>
        /// <returns></returns>
        public bool SendManualOpenGateGuid(string projectGuid, string parkCode)
        {
            try
            {
                FunctionPointModel model = GetFunctionPoint(projectGuid, parkCode);
                if (model == null || model.ManualOpenGateGuid == null)
                {
                    return(false);
                }
                ManualOpenGateModel sendmodel = new ManualOpenGateModel();
                sendmodel.CarTypeList = new List <string>();
                foreach (var item in model.ManualOpenGateGuid)
                {
                    sendmodel.CarTypeList.Add(item);
                }
                CommandEntity <ManualOpenGateModel> entity = new CommandEntity <ManualOpenGateModel>()
                {
                    command = BussineCommand.ManualOpenGate,
                    idMsg   = Convert.ToBase64String(Guid.NewGuid().ToByteArray()),
                    message = sendmodel
                };

                return(m_rabbitMQ.SendMessageForRabbitMQ("发送手动开闸车类guid集合", m_serializer.Serialize(entity), entity.idMsg, model.ParkCode));
            }
            catch (Exception ex)
            {
                m_logger.LogFatal(LoggerLogicEnum.Bussiness, "", parkCode, "", "Fujica.com.cn.Business.ParkLot.FunctionPointManager.SendManualOpenGateGuid", "下发手动开闸车类guid集合时发生异常", ex.ToString());
                return(false);
            }
        }
Beispiel #16
0
        /// <summary>
        /// 下发黑名单
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool SendTrafficRestriction(BlacklistModel models)
        {
            bool result = false;

            try
            {
                List <BlacklistDetialModel> sendmodel = new List <BlacklistDetialModel>();
                foreach (var model in models.List)
                {
                    BlacklistDetialModel detialmodel = new BlacklistDetialModel();
                    detialmodel.CarNo    = model.CarNo;
                    detialmodel.Always   = model.Always;
                    detialmodel.IsDelete = model.Enable ? false : true;
                    if (!model.Always)
                    {
                        if (model.ByDate)
                        {
                            DateTime startDt = DateTime.MinValue;
                            DateTime.TryParse(model.StartDate, out startDt);
                            DateTime endDt = DateTime.MinValue;
                            DateTime.TryParse(model.EndDate, out endDt);
                            detialmodel.DateInterval = startDt.ToString("yyMMdd") + endDt.ToString("yyMMdd");
                        }
                        if (model.ByTime)
                        {
                            DateTime startTime = DateTime.MinValue;
                            DateTime.TryParse(model.StatrtTime, out startTime);
                            DateTime endTime = DateTime.MinValue;
                            DateTime.TryParse(model.EndTime, out endTime);
                            detialmodel.TimeInterval = startTime.ToString("HHmmss") + endTime.ToString("HHmmss");
                        }
                        if (model.ByWeek)
                        {
                            detialmodel.WeekInterval = model.AssignDay;
                        }
                    }
                    sendmodel.Add(detialmodel);
                }

                CommandEntity <List <BlacklistDetialModel> > entity = new CommandEntity <List <BlacklistDetialModel> >()
                {
                    command = BussineCommand.BlackList,
                    idMsg   = Convert.ToBase64String(Guid.NewGuid().ToByteArray()),
                    message = sendmodel
                };
                result = m_rabbitMQ.SendMessageForRabbitMQ("发送黑名单指令", m_serializer.Serialize(entity), entity.idMsg, models.ParkCode);
                if (!result)
                {
                    LastErrorDescribe = BussinessErrorCodeEnum.BUSINESS_MQ_SEND_ERROR.GetDesc();
                }
                return(result);
            }
            catch (Exception ex)
            {
                m_logger.LogFatal(LoggerLogicEnum.Bussiness, "", models.ParkCode, "", "Fujica.com.cn.Business.ParkLot.BlacklistManager.SendTrafficRestriction", "下发黑名单时发生异常", ex.ToString());
                LastErrorDescribe = BussinessErrorCodeEnum.BUSINESS_MQ_SEND_ERROR.GetDesc();
                return(false);
            }
        }
Beispiel #17
0
 static Command CreateCommand(CommandEntity entity)
 {
     if (entity != null)
     {
         return new Command(entity, null);
     }
     return null;
 }
        public CommandEntity Add(string tableName, CommandEntity entity)
        {
            tableName.GuardAgainstNullOrEmpty(nameof(tableName));
            entity.GuardAgainstNull(nameof(entity));

            ExecuteInsert(tableName, entity.ToTableEntity());

            return(Retrieve(tableName, entity.Id, entity.Metadata));
        }
Beispiel #19
0
 public Command2(CommandEntity commandEntity)
 {
     this.commandEntity = commandEntity;
     var action = ActionParser.ParseToSingle(commandEntity.actionPattern);
     if (!string.IsNullOrEmpty(commandEntity.motion))
     {
         action = new ActionMotion2(commandEntity.motion, action);
     }
     this.action = action;
 }
Beispiel #20
0
        public static bool Execute(string parkingCode, string guid, string carNo, DateTime beginTime, DateTime lastTime)
        {
            if (string.IsNullOrEmpty(guid) || string.IsNullOrEmpty(carNo) || beginTime == null || lastTime == null)
            {
                return(false);
            }

            ILogger        m_ilogger    = new Logger.Logger();
            ISerializer    m_serializer = new JsonSerializer(m_ilogger);
            RabbitMQSender m_rabbitMQ   = new RabbitMQSender(m_ilogger, m_serializer);
            IDatabase      db;

            db = FollowRedisHelper.GetDatabase(0);
            RedisValue parklotredis = db.HashGet("ParkLotList", parkingCode);

            if (parklotredis != RedisValue.Null)
            {
                ParkLotModel parklotmodel = m_serializer.Deserialize <ParkLotModel>(parklotredis);
                if (parklotmodel != null)
                {
                    List <string> drivewaylist = parklotmodel.DrivewayList; //所有车道
                    if (drivewaylist != null)
                    {
                        //要广播的缴费数据
                        TempCardModel tempCarModel = new TempCardModel();
                        tempCarModel.Guid       = guid;
                        tempCarModel.CarNo      = carNo;
                        tempCarModel.BeginTime  = beginTime;
                        tempCarModel.LatestTime = lastTime;
                        tempCarModel.HavePaid   = true;

                        foreach (var drivewayguid in drivewaylist)
                        {
                            DrivewayModel drivewaymodel = m_serializer.Deserialize <DrivewayModel>(db.HashGet("DrivewayList", drivewayguid));
                            //广播到所有出口车道
                            if (drivewaymodel.Type == DrivewayType.Out)
                            {
                                CommandEntity <TempCardModel> sendCommand = new CommandEntity <TempCardModel>()
                                {
                                    command = BussineCommand.TempCar,
                                    idMsg   = Convert.ToBase64String(Guid.NewGuid().ToByteArray()),
                                    message = tempCarModel
                                };

                                if (m_rabbitMQ.SendMessageForRabbitMQ("发送缴费数据广播命令", m_serializer.Serialize(sendCommand), drivewaymodel.DeviceMacAddress, parkingCode))
                                {
                                    //广播成功
                                }
                            }
                        }
                    }
                }
            }
            return(true);
        }
Beispiel #21
0
        /// <summary>
        /// 发送在场车辆删除命令给相机
        /// </summary>
        /// <param name="model">删除实体</param>
        /// <param name="parkingCode">停车场编码</param>
        /// <returns></returns>
        public bool SendInVehicleDeleteToCamera(InVehicleDeleteModel model, string parkingCode)
        {
            CommandEntity <InVehicleDeleteModel> entity = new CommandEntity <InVehicleDeleteModel>()
            {
                command = BussineCommand.FieldDelete,
                idMsg   = Convert.ToBase64String(Guid.NewGuid().ToByteArray()),
                message = model
            };

            return(m_rabbitMQ.SendMessageForRabbitMQ("发送在场车辆删除命令", m_serializer.Serialize(entity), entity.idMsg, parkingCode));
        }
        public void IncludeBasicCommandWord_GivenAliases()
        {
            var           repo          = new Mock <IRepository>();
            CommandEntity commandEntity = _commandBuilder.WithDefaults().Build();

            repo.Setup(x => x.Single(It.IsAny <CommandPolicy>())).Returns(commandEntity);

            var baseCommand = new TestBaseCommand(repo.Object);

            baseCommand.CommandWords.Select(x => x.Word).Should().Contain(commandEntity.CommandWord);
        }
        public void Save(CommandModel command)
        {
            Ensure.NotNull(command, "command");

            CommandEntity entity = CommandEntity.FromModel(command);

            context.Commands.Add(entity);
            context.UnPublishedCommands.Add(new UnPublishedCommandEntity(entity));

            context.Save();
        }
Beispiel #24
0
        /// <summary>
        /// 将新增城市区号信息发送至MQ
        /// </summary>
        /// <param name="cityCode"></param>
        /// <returns></returns>
        private bool AddCityCodeToMq(CityCodeModel model)
        {
            CommandEntity <CityCodeModel> entity = new CommandEntity <CityCodeModel>()
            {
                command = BussineCommand.NewCityCode,
                idMsg   = Convert.ToBase64String(Guid.NewGuid().ToByteArray()),
                message = model
            };

            return(m_rabbitMQ.SendMessageForRabbitMQ("发送新增城市区号命令", m_serializer.Serialize(entity), entity.idMsg, "", "NewCityCode4007004008", "FuJiCaDynamicAddNewCityCode.direct"));
        }
Beispiel #25
0
        /// <summary>
        /// 车道闸口锁定
        /// </summary>
        /// <param name="model"></param>
        /// <param name="parkingCode"></param>
        /// <returns></returns>
        private bool SendGateKeepToMq(CameraKeepModel model, string parkingCode)
        {
            CommandEntity <CameraKeepModel> entity = new CommandEntity <CameraKeepModel>()
            {
                command = BussineCommand.GateKeep,
                idMsg   = Convert.ToBase64String(Guid.NewGuid().ToByteArray()),
                message = model
            };

            return(m_rabbitMQ.SendMessageForRabbitMQ("发送车道闸口锁定命令", m_serializer.Serialize(entity), entity.idMsg, parkingCode));
        }
Beispiel #26
0
        //public void DrawAt ()
        //{
        //    if (Width > 0 && Height > 0)
        //    {
        //        int origX = Console.CursorLeft;
        //        int origY = Console.CursorTop;
        //        int endX = origX + Width + 2;
        //        int endY = origY + Height + 2;

        //        // Draw outer canvas
        //        for (int i = 0; i < Width + 2; i++)
        //        {
        //            // Top border
        //            Point.DrawAt(H_BORDER, origX + i, origY);
        //            // Bottom Border
        //            Point.DrawAt(H_BORDER, origX + i, origY + Height + 1);
        //        }

        //        for (int i = 0; i < Height; i++)
        //        {
        //            // Left Border
        //            Point.DrawAt(V_BORDER, origX, origY + i + 1);
        //            // Rigth Border
        //            Point.DrawAt(V_BORDER, origX + Width + 2, origY + i + 1);
        //        }

        //        // Draw inner canvas
        //        for (int x = 0; x < Width; x++)
        //        {
        //            for(int y = 0; y < Height; y++)
        //            {
        //                if (CanvasArray[x,y] != '\0')
        //                {
        //                    Point.DrawAt(CanvasArray[x, y], origX + x + 1, origY + y + 1);
        //                }
        //            }
        //        }

        //        // reset the cursor to end of last line
        //        Console.SetCursorPosition(endX, endY);
        //    }
        //    else
        //    {
        //        throw new Exception("Width and Height must be positive integers. Width: " + Width + " x Height: " + Height + " is not valid. Please specify a valid width and height.");
        //    }
        //}

        #endregion

        public static Canvas CreateCanvas(
            CommandEntity command
            )
        {
            CanvasCommand canvasCommand = (CanvasCommand)command;

            return(new Canvas(
                       canvasCommand.Width,
                       canvasCommand.Height
                       ));
        }
        private static string GetBuildType(Entity owner)
        {
            CommandEntity commandEntity = CommandEntity.Decorate(owner.Origin);
            string        buildType     = commandEntity.GetSingleValueArgument(EntityKeys.BuildTypeKey);

            if (string.IsNullOrEmpty(buildType))
            {
                buildType = Constants.ReleaseFolderName;
            }

            return(buildType);
        }
Beispiel #28
0
        public CommandEntity Add(string containerName, CommandEntity entity)

        {
            containerName.GuardAgainstNullOrEmpty(nameof(containerName));
            entity.GuardAgainstNull(nameof(entity));

            var container = EnsureContainer(containerName);

            container.CreateItemAsync <dynamic>(entity.ToContainerEntity()).GetAwaiter().GetResult();

            return(Retrieve(containerName, entity.Id, entity.Metadata));
        }
Beispiel #29
0
        /// <summary>
        /// 补发入场记录到入口相机
        /// </summary>
        /// <param name="model">补录车牌实体参数</param>
        /// <returns></returns>
        public bool SendRecordInToEntryCamera(AddRecordModel model)
        {
            CommandEntity <AddRecordModel> entity = new CommandEntity <AddRecordModel>()
            {
                command = BussineCommand.AddRecord,
                idMsg   = Convert.ToBase64String(Guid.NewGuid().ToByteArray()),
                message = model
            };

            //将补发入场的数据通过mq交给相机去处理业务
            return(m_rabbitMQ.SendMessageForRabbitMQ("发送补录入场命令", m_serializer.Serialize(entity), entity.idMsg, model.ParkingCode));
        }
        public CommandEntity Add(string containerName, CommandEntity entity)

        {
            containerName.GuardAgainstNullOrEmpty(nameof(containerName));
            entity.GuardAgainstNull(nameof(entity));

            var table = EnsureTable(containerName);

            SafeExecute(table, () => { table.Execute(TableOperation.Insert(entity.ToTableEntity(this.options))); });

            return(Retrieve(containerName, entity.Id, entity.Metadata));
        }
Beispiel #31
0
        /// <summary>
        /// 车牌修正 发送到相机
        /// </summary>
        /// <param name="model">修正车牌实体参数</param>
        /// <returns></returns>
        public bool SendCorrectToEntryCamera(CorrectCarnoModel model)
        {
            CommandEntity <CorrectCarnoModel> entity = new CommandEntity <CorrectCarnoModel>()
            {
                command = BussineCommand.Correct,
                idMsg   = Convert.ToBase64String(Guid.NewGuid().ToByteArray()),
                message = model
            };

            //将修正车牌数据通过mq交给相机去处理业务流程(新车牌入场、旧车牌出场)
            return(m_rabbitMQ.SendMessageForRabbitMQ("发送修正车牌命令", m_serializer.Serialize(entity), entity.idMsg, model.ParkingCode));
        }
Beispiel #32
0
        /// <summary>
        /// 发送剩余车位数量给相机
        /// </summary>
        /// <param name="remainingNumber">剩余车位数</param>
        /// <param name="parkingCode">停车场编号</param>
        /// <param name="m_ilogger"></param>
        /// <param name="m_serializer"></param>
        /// <returns></returns>
        private static bool SpaceNumberToCamera(int remainingNumber, string parkingCode, ILogger m_ilogger, ISerializer m_serializer)
        {
            CommandEntity <int> entity = new CommandEntity <int>()
            {
                command = BussineCommand.RemainingSpace,
                idMsg   = Convert.ToBase64String(Guid.NewGuid().ToByteArray()),
                message = remainingNumber
            };
            RabbitMQSender rabbitMq = new RabbitMQSender(m_ilogger, m_serializer);

            return(rabbitMq.SendMessageForRabbitMQ("发送剩余车位数", m_serializer.Serialize(entity), entity.idMsg, parkingCode));
        }
Beispiel #33
0
    public Command(CommandEntity commandEntity, FireCondition condition)
    {
        if (Constants.Instance.Editor.VerifyData)
        {
            ActionPattern.Create(actionPattern);
        }

        this.animationName = commandEntity.motion;
        this.priority = commandEntity.queuePriority;
        this.actionPattern = commandEntity.actionPattern;
        this.initCooltime = commandEntity.coolTime;
        this.condition = condition;
    }
Beispiel #34
0
 private static Client FindClient(CommandEntity x)
 {
     if (!m_Clients.ContainsKey(x.ClientId))
     {
         var cli = x.Client;
         m_Clients.Add(x.ClientId, new Client(cli.Hostname)
         {
             DisplayName = cli.DisplayName,
             ClientIdentification = cli.ClientIdentification,
             ImplementedProtocol = cli.ImplementedProtocol == null ? null : new Version(cli.ImplementedProtocol),
             ClientStartedAt = cli.ClientStartedAt
         });
     }
     return m_Clients[x.ClientId];
 }
Beispiel #35
0
 private static Game FindGame(CommandEntity x, Server s)
 {
     if (x.GameId == null)
         return null;
     if (!m_Games.ContainsKey(x.GameId.Value))
     {
         var gam = x.Game;
         m_Games.Add(x.GameId.Value, new Game(FindTable(gam, s))
         {
             GameStartedAt = gam.GameStartedAt
         });
     }
     return m_Games[x.GameId.Value];
 }
Beispiel #36
0
        private static bool IsValidFunction(CommandEntity entity)
        {
            if(entity.SearchCriteria != null && entity.SearchCriteria.Count > 0)
            {
                foreach (CommandParameter property in entity.SearchCriteria[0].Properties)
                {
                    if (property.Name.Equals("ReturnValue", StringComparison.OrdinalIgnoreCase)) continue;

                    if (ExcludeProperty(property))
                        return false;
                }
            }

            return true;
        }
Beispiel #37
0
 private static Server FindServer(CommandEntity x)
 {
     if (!m_Servers.ContainsKey(x.ServerId))
     {
         var serv = x.Server;
         m_Servers.Add(x.ServerId, new Server(serv.ServerIdentification, new Version(serv.ImplementedProtocol))
         {
             ServerStartedAt = serv.ServerStartedAt
         });
     }
     return m_Servers[x.ServerId];
 }
        private void CreateConceptualFunctionEntity(CommandEntity entity)
        {
            // Check to see if this has already been processed.
            if (entity.IsFunction || _conceptualFunctions.Contains(ResolveEntityMappedName(entity.EntityKey(), entity.Name)) || !Configuration.Instance.IncludeFunctions) return;

            //<FunctionImport Name="GetCategoryById">
            //    <Parameter Name="ID" Mode="In" Type="String" />
            //</FunctionImport>

            //<FunctionImport Name="GetCategoryById" ReturnType="Collection(PetShopModel.GetCategoryById_Result1)">
            //   <Parameter Name="ID" Mode="In" Type="String" />
            //</FunctionImport>

            //  <FunctionImport Name="GetCategoryById" EntitySet="Categories" ReturnType="Collection(PetShopModel.Category)">
            //    <Parameter Name="ID" Mode="In" Type="String" />
            //  </FunctionImport>

            //  <FunctionImport Name="GetCategoryById" ReturnType="Collection(Int32)">
            //    <Parameter Name="ID" Mode="In" Type="String" />
            //  </FunctionImport>
            #region Validate the Function exists

            bool exists = true;
            var function = ConceptualSchemaEntityContainer.FunctionImports.Where(f =>
                entity.Name.Equals(f.Name, StringComparison.OrdinalIgnoreCase) ||
                entity.EntityKeyName.Equals(f.Name, StringComparison.OrdinalIgnoreCase) ||
                (!String.IsNullOrEmpty(f.EntitySet) && entity.EntityKeyName.Equals(f.EntitySet, StringComparison.OrdinalIgnoreCase))).FirstOrDefault();

            if (function == null)
            {
                exists = false;
                function = new EntityContainer.FunctionImportLocalType
                               {
                                   Name = ResolveEntityMappedName(entity.EntityKey(), entity.Name)
                               };

                ConceptualSchemaEntityContainer.FunctionImports.Add(function);
            }

            #endregion

            //http://msdn.microsoft.com/en-us/library/bb738614.aspx
            function.Name = ResolveEntityMappedName(entity.EntityKey(), entity.Name);
            var entitySetName = entity.IsAssociated
                                    ? ResolveEntityMappedName(entity.AssociatedEntity.EntityKey(), entity.AssociatedEntity.Name)
                                    : ResolveEntityMappedName(entity.EntityKey(), entity.Name);
            if(exists)
            {
                var type = function.ReturnType != null ? function.ReturnType.ToString().Replace("Collection(", String.Empty).Replace(")", String.Empty).Trim() : String.Empty;
                var complexTypeName = NamingConventions.PropertyName(type.Replace(ConceptualSchema.Namespace + ".", String.Empty));
                if (entity.IsStronglyTypedAssociatedEntity)
                {
                    function.EntitySet = entitySetName;
                    function.ReturnType = String.Format("Collection({0}.{1})", ConceptualSchema.Namespace, entitySetName);
                }
                else if (function.IsComplexType(ConceptualSchema.Namespace) && ConceptualSchema.ComplexTypes.Exists(complexTypeName) && entity.Properties.Count > 0)
                {
                    function.EntitySet = null;
                    function.ReturnType = String.Format("Collection({0}.{1})", ConceptualSchema.Namespace, complexTypeName);
                    CreateConceptualComplexType(entity, complexTypeName);
                }
                else if (!String.IsNullOrEmpty(type) && !SystemTypeMapper.EfConceptualTypeToSystemType.ContainsKey(type))
                {
                    function.ReturnType = null;
                    function.EntitySet = null;
                }
            }
            else if (entity.IsStronglyTypedAssociatedEntity)
            {
                function.EntitySet = entitySetName;
                function.ReturnType = String.Format("Collection({0}.{1})", ConceptualSchema.Namespace, entitySetName);
            }
            else if(entity.Properties.Count > 0)
            {
                function.ReturnType = null;
                //By default create a new ComplexType for a procedure's resultset if it contains more a column in the result set.
                function.ReturnType = String.Format("Collection({0}.{1}Result)", ConceptualSchema.Namespace, ResolveEntityMappedName(entity.EntityKey(), entity.Name));
                CreateConceptualComplexType(entity);
            }
            else
            {
                function.ReturnType = null;
                function.EntitySet = null;
            }

            //<Parameter Name="ApplicationName" Type="nvarchar" Mode="In" />
            //<Parameter Name="ApplicationId" Type="uniqueidentifier" Mode="InOut" />
            #region Process Parameters

            if (entity.SearchCriteria != null && entity.SearchCriteria.Count > 0)
            {
                #region Remove extra properties values.

                var properties = from property in function.Parameters
                                 where !(from prop in entity.SearchCriteria[0].Properties select prop.KeyName).Contains(property.Name) || property.Name.Equals("RETURN_VALUE", StringComparison.OrdinalIgnoreCase)
                                 select property;

                // Remove all of the key properties that don't exist in the table entity.
                foreach (var property in properties)
                {
                    function.Parameters.Remove(property);
                }

                #endregion

                foreach (CommandParameter property in entity.SearchCriteria[0].Properties)
                {
                    if (property.KeyName.Equals("RETURN_VALUE", StringComparison.OrdinalIgnoreCase)) continue;

                    var parameter = function.Parameters.Where(p => property.KeyName.Equals(p.Name, StringComparison.OrdinalIgnoreCase) || property.Name.Equals(p.Name, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                    if (parameter == null)
                    {
                        parameter = new FunctionImportParameter() { Name = property.KeyName };
                        function.Parameters.Add(parameter);
                    }

                    //http://msdn.microsoft.com/en-us/library/ee705451.aspx
                    parameter.Name = property.KeyName;
                    parameter.Mode = property.ParameterDirection == ParameterDirection.Input ? "In" : property.ParameterDirection == ParameterDirection.InputOutput ? "InOut" : "Out";
                    parameter.Type = GetSystemType(property);
                }
            }
            else
            {
                function.Parameters.Clear();
            }

            #endregion

            _conceptualFunctions.Add(ResolveEntityMappedName(entity.EntityKey(), entity.Name));
        }
        private void CreateFunctionMappingComplexTypeMapping(CommandEntity entity, FunctionImportMapping importMapping)
        {
            //<ResultMapping>
            //  <ComplexTypeMapping TypeName="PetShopModel.GetCategoryById_Result">
            string entityName = String.Concat(entity.Name, "Result");
            var mapping = importMapping.ResultMapping != null && importMapping.ResultMapping.ComplexTypeMappings != null
                              ? importMapping.ResultMapping.ComplexTypeMappings.FirstOrDefault()
                              : null;

            if (mapping == null)
            {
                importMapping.ResultMapping = new FunctionImportMappingResultMapping()
                                                  {
                                                      ComplexTypeMappings = new List<FunctionImportComplexTypeMapping>()
                                                  };

                mapping = new FunctionImportComplexTypeMapping() { TypeName = String.Concat(ConceptualSchema.Namespace, ".", entityName) };
                importMapping.ResultMapping.ComplexTypeMappings.Add(mapping);
            }
            else if (!String.IsNullOrEmpty(mapping.TypeName))
            {
                entityName = mapping.TypeName.Replace("IsTypeOf(", "").Replace(String.Format("{0}.", ConceptualSchema.Namespace), "").Replace(")", "");
                entityName = entityName.Equals(entity.Name, StringComparison.OrdinalIgnoreCase) ? entity.Name : entityName;
            }

            if(ConceptualSchema.ComplexTypes.Count(c => c.Name.Equals(entityName, StringComparison.OrdinalIgnoreCase)) == 0)
                entityName = String.Concat(entity.Name, "Result");

            // Check for inheritance.
            mapping.TypeName = String.Format("{0}.{1}", ConceptualSchema.Namespace, entityName);

            _mappingEntityNames.Add(entity.EntityKey(), importMapping.FunctionImportName);
            _mappingEntityNames.Add(entity.EntityKey() + "complex", entityName);

            //<ComplexTypeMapping TypeName="PetShopModel.GetCategoryById_Result">
            //  <ScalarProperty Name="CategoryId" ColumnName="CategoryId" />
            //  <ScalarProperty Name="Name" ColumnName="Name" />
            //  <ScalarProperty Name="Description" ColumnName="Descn" />
            //</ComplexTypeMapping>
            MergeScalarProperties(mapping, entity);
        }
        private void MergeScalarProperties(FunctionImportComplexTypeMapping mappingFragment, CommandEntity entity)
        {
            foreach (var property in mappingFragment.ScalarProperties.Where(p => entity.Properties.Count(prop => prop.KeyName.Equals(p.ColumnName, StringComparison.OrdinalIgnoreCase)) == 0))
                _mappingDroppedEntityPropertyNames[String.Format(PROPERTY_KEY, entity.EntityKeyName, property.ColumnName)] = property.Name;

            var properties = new List<ScalarProperty>();
            foreach (var property in entity.Properties)
            {
                var prop = mappingFragment.ScalarProperties.Where(p => p.ColumnName.Equals(property.KeyName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                if (prop == null)
                {
                    // The property doesn't exist so lets create it.
                    prop = new ScalarProperty() { Name = property.Name };
                }
                else if (!property.Name.Equals(prop.Name, StringComparison.OrdinalIgnoreCase)) // Column matches that in the database.. If the names are different, it wins.
                {
                    // The propertyName has been updated.
                    // TODO: Is there a better way to find out if they renamed the Property?
                    //prop.Name = prop.Name;
                }
                else
                {
                    // Update the propertyName so it is always current with SchemaHelper.
                    prop.Name = property.Name;
                }

                prop.ColumnName = property.KeyName;
                if (!ExcludeProperty(property as ISchemaProperty) && properties.Count(p => p.Name.Equals(prop.Name, StringComparison.OrdinalIgnoreCase)) == 0)
                {
                    properties.Add(prop);
                    _mappingEntityPropertyNames[String.Format("{0}-{1}", entity.Name, property.KeyName)] = prop.Name;
                }
            }

            mappingFragment.ScalarProperties = properties.Distinct().ToList();
        }
        private void CreateFunctionMappingEntity(CommandEntity entity)
        {
            if (!Configuration.Instance.IncludeFunctions || entity.IsFunction || _mappingEntitys.Contains(entity.Name))
            {
                Debug.WriteLine(String.Format("Already Processed Mapping Model Entity {0}", entity.Name), MappingCategory);
                return;
            }

            // <FunctionImportMapping FunctionImportName="GetCategoryById" FunctionName="PetShopModel.Store.GetCategoryById" >
            #region Validate that an EntitySet Exists in the MappingStorageContainer.

            var importMapping = MappingEntityContainer.FunctionImportMappings.Where(e =>
                entity.Name.Equals(e.FunctionImportName, StringComparison.OrdinalIgnoreCase) || // Safe Name.
                entity.EntityKeyName.Equals(e.FunctionImportName, StringComparison.OrdinalIgnoreCase) || // Database Name.
                (e.ResultMapping != null && e.ResultMapping.ComplexTypeMappings.Count > 0 &&
                    (e.ResultMapping.ComplexTypeMappings.Count(et => et.TypeName.Equals(String.Concat(ConceptualSchema.Namespace, ".", entity.Name), StringComparison.OrdinalIgnoreCase)) > 0 ||
                    e.ResultMapping.ComplexTypeMappings.Count(et => et.TypeName.Equals(String.Concat(ConceptualSchema.Namespace, ".", entity.Name, "Result"), StringComparison.OrdinalIgnoreCase)) > 0 ||
                    e.ResultMapping.ComplexTypeMappings.Count(et => et.TypeName.Equals(String.Concat(ConceptualSchema.Namespace, ".", entity.EntityKeyName), StringComparison.OrdinalIgnoreCase)) > 0 ||
                    e.ResultMapping.ComplexTypeMappings.Count(et => et.TypeName.Equals(String.Concat(ConceptualSchema.Namespace, ".", entity.EntityKeyName, "Result"), StringComparison.OrdinalIgnoreCase)) > 0))).FirstOrDefault();

            //NOTE: We could also possibly look up the table name by looking at the StorageModel's EntitySet Tables Property.

            // If the Entity Set does not exist than create a new one.
            if (importMapping == null)
            {
                importMapping = new FunctionImportMapping
                                    {
                                        FunctionImportName = entity.Name,
                                        ResultMapping = new FunctionImportMappingResultMapping()
                                    };

                MappingEntityContainer.FunctionImportMappings.Add(importMapping);
            }

            importMapping.FunctionName = String.Concat(StorageSchema.Namespace, ".", entity.EntityKeyName);

            if (String.IsNullOrEmpty(importMapping.FunctionImportName) || !ConceptualSchemaEntityContainer.FunctionImports.Exists(importMapping.FunctionImportName))
                importMapping.FunctionImportName = entity.Name;

            #endregion

            if (entity.IsStronglyTypedAssociatedEntity)
            {
                if (importMapping.ResultMapping != null && importMapping.ResultMapping.ComplexTypeMappings != null)
                    importMapping.ResultMapping.ComplexTypeMappings = null;

                CreateFunctionMappingEntityTypeMapping(entity, importMapping);
            }
            else if (entity.Properties.Count > 0)
                CreateFunctionMappingComplexTypeMapping(entity, importMapping);
            else if(importMapping.ResultMapping != null && importMapping.ResultMapping.ComplexTypeMappings != null)
                importMapping.ResultMapping.ComplexTypeMappings.Clear();

            _mappingEntitys.Add(entity.Name);
        }
 public static bool IsIgnoredCommand(CommandEntity command)
 {
     return command.Properties.Any(p => _nonCharRegex.IsMatch(p.KeyName));
 }
Beispiel #43
0
 public OnDemandCommand(CommandEntity commandEntity)
     : base(commandEntity)
 {
 }
Beispiel #44
0
 internal void ExecuteRegistering()
 {
     using (var context = Database.GetContext())
     {
         var client = context.AllClients.Single(x => x.Id == Client.Id);
         var server = context.AllServers.Single(x => x.Id == Server.Id);
         var game = Game == null ? null : context.AllGames.Single(x => x.Id == Game.Id);
         var c = new CommandEntity()
         {
             Name = Name,
             Detail = Details,
             IsFromServer = IsFromServer,
             Type = Type,
             Server = server,
             Client = client,
             ExecutionTime = ExecutionTime,
             Game = game
         };
         context.AllCommands.Add(c);
         context.SaveChanges();
     }
 }
 public StartWatchCommand(CommandEntity commandEntity)
 {
     _commandEntity = commandEntity;
 }
Beispiel #46
0
 // http://msdn.microsoft.com/en-us/library/dd283136.aspx
 private void GetFunctionEntity(CommandEntity entity)
 {
     CreateStorageFunctionEntity(entity);
     CreateConceptualFunctionEntity(entity);
 }
        private void CreateStorageFunctionEntity(CommandEntity entity)
        {
            // Check to see if this has already been processed.
            if (_storageFunctions.Contains(entity.EntityKeyName) || !Configuration.Instance.IncludeFunctions)
                return;

            //<Function Name="aspnet_Applications_CreateApplication" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo">

            #region Validate the Function exists

            var function = StorageSchema.Functions.Where(f =>
                (entity.EntityKeyName.Equals(f.Name, StringComparison.OrdinalIgnoreCase) && entity.SchemaName.Equals(f.Schema, StringComparison.OrdinalIgnoreCase)) ||
                (entity.EntityKeyName.Equals(f.Name1, StringComparison.OrdinalIgnoreCase) && entity.SchemaName.Equals(f.Schema1, StringComparison.OrdinalIgnoreCase)) ||
                entity.EntityKeyName.Equals(f.Name1, StringComparison.OrdinalIgnoreCase) || entity.EntityKeyName.Equals(f.Name, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();

            if (function == null) {
                function = new Function() {
                    Name = entity.EntityKeyName
                };

                StorageSchema.Functions.Add(function);
            }

            //http://msdn.microsoft.com/en-us/library/bb738614.aspx
            function.Name = entity.EntityKeyName;
            function.Name1 = entity.EntityKeyName;
            function.Aggregate = false; //TODO: True if the stored procedure returns an aggregate value; otherwise False.
            function.BuiltIn = false; //TODO: True if the function is a built-in1 function; otherwise False. (A built-in function is a function that is defined in the database. For information about functions that are defined in the storage model)
            function.NiladicFunction = false; //TODO:  A niladic function is a function that accepts no parameters and, when called, does not require parentheses.
            function.IsComposable = entity.IsFunction;
            function.ParameterTypeSemantics = "AllowImplicitConversion"; //TODO: Determine if this stored procedure is an AllowImplicitConversion.
            function.Schema = entity.SchemaName;
            function.Schema1 = entity.SchemaName;

            // Return type cannot be set if the function is composible.
            if (entity.IsFunction)
                function.ReturnType = entity.ReturnValueParameter != null ? GetNativeType(entity.ReturnValueParameter) : "int";

            //<Parameter Name="ApplicationName" Type="nvarchar" Mode="In" />
            //<Parameter Name="ApplicationId" Type="uniqueidentifier" Mode="InOut" />

            #region Process Parameters

            if (entity.SearchCriteria != null && entity.SearchCriteria.Count > 0) {
                #region Remove extra properties values.

                var properties = from property in function.Parameters
                    where !(from prop in entity.SearchCriteria[0].Properties select prop.KeyName).Contains(property.Name) || property.Name.Equals("RETURN_VALUE", StringComparison.OrdinalIgnoreCase)
                    select property;

                // Remove all of the key properties that don't exist in the table entity.
                foreach (var property in properties) {
                    function.Parameters.Remove(property);
                }

                #endregion

                foreach (CommandParameter property in entity.SearchCriteria[0].Properties) {
                    if (property.KeyName.Equals("RETURN_VALUE", StringComparison.OrdinalIgnoreCase))
                        continue;

                    var parameter = function.Parameters.Where(p => property.KeyName.Equals(p.Name, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                    if (parameter == null) {
                        parameter = new Parameter() {
                            Name = property.KeyName
                        };
                        function.Parameters.Add(parameter);
                    }

                    //http://msdn.microsoft.com/en-us/library/ee705451.aspx
                    parameter.Name = property.KeyName;
                    parameter.Mode = property.ParameterDirection == ParameterDirection.Input ? "In" : property.ParameterDirection == ParameterDirection.InputOutput ? "InOut" : "Out";
                    parameter.Type = GetNativeType(property);
                }
            } else {
                function.Parameters.Clear();
            }

            #endregion

            #endregion

            _storageFunctions.Add(entity.EntityKeyName);
        }