Example #1
0
        public ProgramEntity Staff_AccessCheck(StaffEntity staffEntity)
        {
            staffEntity.Sqlprms    = new SqlParameter[3];
            staffEntity.Sqlprms[0] = new SqlParameter("@StaffCD", staffEntity.StaffCD);
            staffEntity.Sqlprms[1] = new SqlParameter("@ProgramID", staffEntity.ProgramID);
            staffEntity.Sqlprms[2] = new SqlParameter("@PC", staffEntity.PC);
            DataTable     dtProgram = ckmdl.SelectDatatable("Staff_AccessCheck", GetConnectionString(), staffEntity.Sqlprms);
            ProgramEntity programEntity;
            string        messageID = dtProgram.Rows[0]["MessageID"].ToString();

            if (messageID.Equals("allow"))
            {
                programEntity = new ProgramEntity
                {
                    Insertable  = dtProgram.Rows[0]["Insertable"].ToString(),
                    Updatable   = dtProgram.Rows[0]["Updatable"].ToString(),
                    Deletable   = dtProgram.Rows[0]["Deletable"].ToString(),
                    Inquirable  = dtProgram.Rows[0]["Inquirable"].ToString(),
                    Printable   = dtProgram.Rows[0]["Printable"].ToString(),
                    Outputable  = dtProgram.Rows[0]["Outputable"].ToString(),
                    Runable     = dtProgram.Rows[0]["Runable"].ToString(),
                    ProgramID   = dtProgram.Rows[0]["ProgramID"].ToString(),
                    ProgramName = dtProgram.Rows[0]["ProgramName"].ToString(),
                    Type        = dtProgram.Rows[0]["Type"].ToString()
                };
                return(programEntity);
            }
            else
            {
                ShowMessage(messageID);
                return(null);
            }
        }
Example #2
0
        public ShinyohLogin(bool IsMainCall = false)
        {
            var f = @"C:\DBConfig\DBConfig.ini";
            var d = Path.GetDirectoryName(f);

            if (!IsMainCall)
            {
                if (CheckExistFormRunning())
                {
                    System.Environment.Exit(0);
                }
            }
            this.KeyPreview = true;
            InitializeComponent();
            programEntity = new ProgramEntity();
            bbl           = new BaseBL();
            ff            = new FileFunction();
            staffBL       = new StaffBL();
            if (ApplicationDeployment.IsNetworkDeployed)
            {
                lblVer.Text = ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString(4);
            }
            else
            {
                ckM_Button3.Visible = false;
            }

            BaseBL.IEntity.Version = lblVer.Text;
        }
Example #3
0
        public async Task Should_Create_Program_WithValidInput()
        {
            var expectedEntity = new ProgramEntity()
            {
                Id   = Guid.NewGuid(),
                Name = "mockName"
            };

            _repoMock !.Setup(repo => repo.CreateProgramEntityAsync(It.IsAny <ProgramEntity>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(expectedEntity);
            var programsController = new ProgramsController(_repoMock.Object, Mapper, _logger !.Object);

            Assert.NotNull(programsController);

            var programRequest = new Request <ProgramViewModel.Creation>()
            {
                Data = new ProgramViewModel.Creation()
                {
                    Name = "test"
                }
            };
            var programs = await programsController.CreateProgramAsync(programRequest) as CreatedAtRouteResult;

            Assert.NotNull(programs);
            Assert.Equal("GetProgramById", programs !.RouteName);
            Assert.NotNull(programs.RouteValues);

            var programResponse = programs.Value as Response <ProgramViewModel>;

            Assert.NotNull(programResponse);

            // Assert.NotNull(programResponse.Data);
        }
Example #4
0
        public async Task Should_Get_Program_When_EditProgramById()
        {
            var expectedEntity = new ProgramEntity()
            {
                Id   = Guid.NewGuid(),
                Name = "mockName"
            };

            _repoMock !.Setup(repo =>
                              repo.UpdateEntityAsync(It.IsAny <Guid>(), It.IsAny <ProgramEntity>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(expectedEntity);
            var programsController = new ProgramsController(_repoMock !.Object, Mapper, _logger !.Object);

            Assert.NotNull(programsController);

            var program = await programsController.EditProgramByIdAsync(
                Guid.NewGuid(),
                new Request <ProgramViewModel.Edit>()
            {
                Data = new ProgramViewModel.Edit()
            }
                ) as OkObjectResult;

            Assert.NotNull(program);
            var programResponse = program?.Value as Response <ProgramViewModel>;

            Assert.NotNull(programResponse);
        }
Example #5
0
 public static Program ToProgram(this ProgramEntity program, IList <string> languages, bool addForms = true)
 {
     return(new Program
     {
         Id = program.Id,
         Label = program.Resource.ToLabel(languages),
         Labels = program.Resource.ToLabels(languages),
         Forms =
             addForms
             ? program.Forms
             .Where(f => f.DateDeleted == null)
             .Select(f => f.ToForm(languages, false))
             .ToList()
             : null
     });
 }
Example #6
0
        public ProcessEntity LaunchProgram(QueryBasicProgramDTO basicProgram)
        {
            var process = new ProcessEntity()
            {
                PID = this.GetAvailablePID(),
            };

            this.logger.LogInformation($"程序启动器:Name={basicProgram.Name} ({process.PID})");

            var programComponentType = this.GetProgramComponentType(basicProgram.AssemblyName, basicProgram.TypeName);
            var programEntity        = new ProgramEntity()
            {
                Name = basicProgram.Name
            };

            this.logger.LogInformation($"程序启动器:Type={programComponentType.FullName}");
            process.ProgramRenderFramgment = builder =>
            {
                // 差分算法性能:Region 的序列号必须与程序ID对应
                builder.OpenRegion(process.PID);
                // 差分算法稳定性:Region 内的序列号可以重新开始递增
                builder.OpenComponent(0, programComponentType);
                // Attribute 需要先于其他数据被添加
                builder.AddAttribute(1, nameof(ProgramComponentBase.ProgramEntity), programEntity);
                builder.AddComponentReferenceCapture(2, reference =>
                {
                    process.ProgramComponent = (ProgramComponentBase)reference;
                });
                // 差分算法性能:Component 的 @key 必须与程序ID对应
                builder.SetKey(process.PID);
                // 差分算法要求:标签开启和关闭必须对齐
                builder.CloseComponent();
                builder.CloseRegion();
            };

            this.logger.LogInformation($"程序启动器:添加进程到容器并广播消息...");
            this.programContainer.AddProcess(process);
            this.publisher.Publish(new ProgramLaunchMessage());
            return(process);
        }
Example #7
0
        public async Task Should_Get_ProgramListByIds()
        {
            var expectedEntity = new ProgramEntity()
            {
                Id   = Guid.NewGuid(),
                Name = "mockName"
            };

            _repoMock !.Setup(repo =>
                              repo.GetProgramEntityListByIdsAsync(It.IsAny <Guid[]>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(new List <ProgramEntity>(new[] { expectedEntity }));
            var programsController = new ProgramsController(_repoMock.Object, Mapper, _logger !.Object);

            Assert.NotNull(programsController);

            var programs = await programsController.GetProgramsByIdsAsync(new[] { Guid.NewGuid() }) as OkObjectResult;

            Assert.NotNull(programs);
            var programsResponse = programs?.Value as Response <IList <ProgramViewModel> >;

            Assert.NotNull(programsResponse);
        }
        public void Save(ProgramViewModel vm)
        {
            var entity = new ProgramEntity(0);

            ProgramService.Save(entity);
        }
 public void Save(ProgramEntity alunoEntity)
 {
     ProgramRepository.Save(alunoEntity);
 }