Ejemplo n.º 1
0
        public List <ProgramDTO> ListPrograms()
        {
            var list  = new List <ProgramDTO>();
            var files = Directory.GetFiles(Environment.GetEnvironmentVariable("AppData") + @"\Microsoft\Windows\Start Menu\Programs\Startup");

            foreach (string file in files)
            {
                if (Path.GetExtension(file).ToLower() != ".lnk")
                {
                    continue;
                }
                var originPath = GetShortcutTarget(file);
                var program    = new ProgramDTO()
                {
                    Image       = GetImage(originPath),
                    Name        = new FileInfo(originPath).Name,
                    Command     = "",
                    FilePath    = originPath,
                    TypeAutorun = TypeAutorun.StartMenu
                };
                CheckDigitalSignature(program);
                list.Add(program);
            }
            return(list);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a new ProgramViewModel and initializes itself with the given program dto.
 /// </summary>
 /// <param name="program">The program dto.</param>
 public ProgramViewModel(ProgramDTO program) : this()
 {
     Contract.Requires(program != null, "The program must not be null.");
     Contract.Requires(program.RowVersion != null, "The row version must not be null.");
     this.Contacts                  = program.Contacts;
     this.CountryIsos               = program.CountryIsos;
     this.Description               = program.Description;
     this.Goals                     = program.Goals;
     this.Id                        = program.Id;
     this.Name                      = program.Name;
     this.OwnerDescription          = program.OwnerDescription;
     this.OwnerName                 = program.OwnerName;
     this.OwnerOrganizationId       = program.OwnerOrganizationId;
     this.OwnerOfficeSymbol         = program.OwnerOfficeSymbol;
     this.OwnerOfficeCategoryLabel  = program.OwnerOrganizationCategoryLabel;
     this.OwnerOfficeObjectiveLabel = program.OwnerOrganizationObjectiveLabel;
     this.ParentProgramId           = program.ParentProgramId;
     this.ParentProgramName         = program.ParentProgramName;
     this.RegionIsos                = program.RegionIsos;
     this.RevisedOn                 = program.RevisedOn;
     this.RowVersion                = Convert.ToBase64String(program.RowVersion);
     this.StartDate                 = program.StartDate;
     this.EndDate                   = program.EndDate;
     this.Themes                    = program.Themes;
     this.Categories                = program.Categories;
     this.Objectives                = program.Objectives;
     this.ProgramStatusId           = program.ProgramStatusId;
     this.ProgramStatusName         = program.ProgramStatusName;
     this.Websites                  = program.Websites;
     this.Regions                   = program.Regions;
 }
Ejemplo n.º 3
0
        public List <ProgramDTO> GetAllProgram(string board_Id)
        {
            List <ProgramDTO> listProgram = new List <ProgramDTO>();

            this.ConnectToDatabase();

            MySqlCommand command = this.mySQLConnection.CreateCommand();

            command.CommandText = "SELECT * FROM PROGRAM where PROGRAM_ID = " + board_Id;

            MySqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                string programId = reader.GetString(0);
                string classId   = reader.GetString(1);
                int    level     = reader.GetInt32(2);
                int    fee       = reader.GetInt32(3);

                ProgramDTO program = new ProgramDTO(programId, classId, level, fee);
                listProgram.Add(program);
            }

            reader.Close();
            this.Close();
            return(listProgram);
        }
Ejemplo n.º 4
0
        public ProgramDTO GetProgram(string id)
        {
            ProgramDTO program;

            this.ConnectToDatabase();

            MySqlCommand command = this.mySQLConnection.CreateCommand();

            command.CommandText = "SELECT * FROM PROGRAM WHERE PROGRAM_ID = '" + id + "'";

            MySqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                string programId = reader.GetString(0);
                string classId   = reader.GetString(1);
                int    level     = reader.GetInt32(2);
                int    fee       = reader.GetInt32(3);

                program = new ProgramDTO(programId, classId, level, fee);
                return(program);
            }

            reader.Close();
            this.Close();
            return(null);
        }
Ejemplo n.º 5
0
        private void button3_Click(object sender, EventArgs e)
        {
            ProgramDTO      currentObject = (ProgramDTO)dgvListProgram.CurrentRow.DataBoundItem;
            EditProgramForm f             = new EditProgramForm(currentObject);

            f.ShowDialog();
        }
Ejemplo n.º 6
0
        internal ProgramDTO getById(string programId)
        {
            ProgramDTO program;
            string     queryString =
                "SELECT client_id FROM program " +
                " WHERE @id = id";

            using (SqlConnection connection = EstablishingConnection.GetConnection())
            {
                connection.Open();
                using (SqlCommand command = new SqlCommand(queryString, connection))
                {
                    command.Parameters.AddWithValue("@id", programId);

                    SqlDataReader reader = command.ExecuteReader();
                    program = new ProgramDTO();

                    while (reader.Read())
                    {
                        ProgramDTO programNew = new ProgramDTO
                        {
                            ClientId = (string)reader["client_id"],
                        };

                        program = programNew;
                    }
                    connection.Close();
                }
                return(program);
            }
        }
        public static ProgramDTO ReadOneProgram(ushort focasLibHandle, int progromToRead, short programDetailType = 1)
        {
            ProgramDTO program       = new ProgramDTO();
            int        topProgram    = progromToRead;
            short      prgromsToRead = 1;
            short      ret           = 0;

            ret = 0;
            FocasLibBase.PRGDIR3 d = new FocasLibBase.PRGDIR3();
            try
            {
                ret = FocasLib.cnc_rdprogdir3(focasLibHandle, programDetailType, ref topProgram, ref prgromsToRead, d);

                if (ret != 0)
                {
                    Logger.WriteErrorLog("cnc_rdprogdir3() failed. return value is = " + ret);
                }
                else
                {
                    if (prgromsToRead > 0)
                    {
                        if (topProgram == progromToRead)
                        {
                            program.ProgramNo = d.dir1.number;
                            program.Comment   = d.dir1.comment;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.WriteErrorLog(ex.ToString());
            }
            return(program);
        }
Ejemplo n.º 8
0
        public List <ProgramDTO> GetAllPrograms(string clientId)
        {
            List <ProgramDTO> programs;
            string            queryString =
                "SELECT * from program" +
                " WHERE program.client_id = @client_id";

            using (SqlConnection connection = EstablishingConnection.GetConnection())
            {
                connection.Open();
                using (SqlCommand command = new SqlCommand(queryString, connection))
                {
                    command.Parameters.AddWithValue("@client_id", clientId);
                    SqlDataReader reader = command.ExecuteReader();
                    programs = new List <ProgramDTO>();
                    while (reader.Read())
                    {
                        ProgramDTO program = new ProgramDTO
                        {
                            Id          = (int)reader["id"],
                            ClientId    = (string)reader["client_id"],
                            GoalTypeId  = (int)reader["goal_type_id"],
                            StartTime   = Convert.ToDateTime(reader["start_time"]),
                            EndTime     = Convert.ToDateTime(reader["end_time"]),
                            Description = (string)reader["description"]
                        };
                        programs.Add(program);
                    }
                    connection.Close();
                }
                return(programs);
            }
        }
Ejemplo n.º 9
0
        public ICollection <ProgramDTO> GetUsersPrograms(ProgramDTO newProgram, String userName)
        {
            ActionResponse response = new ActionResponse();

            ProgramRepository repository = RepositoriesFactory.CreateRepository <ProgramRepository, Program>();

            int UserId = GetCurrentUser().UserId;

            ICollection <Program> wantedPrograms;

            if (GetCurrentUser().Permission == (int)Enums.PermissionsType.Admin)
            {
                wantedPrograms = repository.GetALL();
            }
            else
            {
                wantedPrograms =
                    repository.Query().Where(CurrProgram => CurrProgram.UserPrograms.Any(currUser => currUser.UserId == UserId)).ToList();
            }


            ICollection <ProgramDTO> ProgramDrills =
                wantedPrograms.Select <Program, ProgramDTO>(currProgram => ConvertEntityTODTO(currProgram)).ToList();

            return(ProgramDrills);
        }
Ejemplo n.º 10
0
        public ListProgramDTO GetAllPrograms()
        {
            try
            {
                ListProgramDTO listProgramDTO = new ListProgramDTO();

                List <ProgramDTO> listPrograms = new List <ProgramDTO>();

                //Call a DAL method to  to get all Programs in database
                List <Program> programs = _programRepository.GetAll().ToList();

                foreach (var program in programs)
                {
                    ProgramDTO programDTO = new ProgramDTO(
                        program.Id, program.ProgramTitle, program.ArrayOfIncludedModules.ToList(),
                        program.ArrayOfNeedByPotentialTrainees.ToList());
                    listPrograms.Add(programDTO);
                }

                listProgramDTO.ProgramList = listPrograms;
                return(listProgramDTO);
            }
            catch
            {
                return(null);
            }
        }
Ejemplo n.º 11
0
        public ActionResponse UpdateProgram(ProgramDTO program)
        {
            ActionResponse response = ValidateProgram(program, true);

            if (response != null)
            {
                return(response);
            }

            response = CanUserEditProgram(program.Id);

            if (response != null)
            {
                return(response);
            }

            Program programForUpdate = ConvertDTOToEntity(program);

            ProgramRepository programRepository = RepositoriesFactory.CreateRepository <ProgramRepository, Program>();

            Program existingProgram = programRepository.Get(programForUpdate.ProgramId);

            existingProgram.ProgramName = programForUpdate.ProgramName;

            foreach (ProgramDrill currDrill in programForUpdate.ProgramDrills)
            {
                ProgramDrill existingProgramDrill =
                    existingProgram.ProgramDrills.FirstOrDefault(currProgramDrill => currProgramDrill.Id == currDrill.Id);
                if (existingProgramDrill == null)
                {
                    existingProgram.ProgramDrills.Add(currDrill);
                }
                else
                {
                    foreach (Set currSet in currDrill.Sets)
                    {
                        Set existingSet =
                            existingProgramDrill.Sets.FirstOrDefault(currExistingSet => currExistingSet.SetId == currSet.SetId);

                        if (existingSet == null)
                        {
                            existingProgramDrill.Sets.Add(currSet);
                        }
                        else
                        {
                            existingSet.Repetitions = currSet.Repetitions;
                            existingSet.Weight      = currSet.Weight;
                            existingSet.Repetitions = currSet.Repetitions;
                        }
                    }
                }
            }

            programRepository.Update(existingProgram);
            return(new ActionResponse()
            {
                CompletedSuccessfully = true
            });
        }
Ejemplo n.º 12
0
        public ProgramViewViewModel(ProgramDTO program) : base(PageModes.View)
        {
            Drills = program.Drills
                     .Select <ProgramDrillDTO, ProgramDrillViewModel>(currDrill => Converter.Convert <ProgramDrillViewModel>(currDrill))
                     .ToList();

            ProgramName = program.Name;
        }
Ejemplo n.º 13
0
 public Models.Database.Program MapToProgram(ProgramDTO programDTO)
 {
     return(new Models.Database.Program()
     {
         EngSubject = programDTO.EngSubject,
         Hours = programDTO.Hours,
         Subject = programDTO.Subject
     });
 }
Ejemplo n.º 14
0
        public List <AlumnDTO> HämtaAlumnerMedProgram(ProgramDTO program)
        {
            List <AlumnDTO> alumnerMedProgram = new List <AlumnDTO>();

            foreach (AlumnProgramDTO ap in unitOfWork.AlumnRepository.HämtaAlumnerMedProgram(program))
            {
                alumnerMedProgram.Add(unitOfWork.AlumnRepository.GetById(ap.AlumnID));
            }
            return(alumnerMedProgram);
        }
        private static void get_program(List <ProgramDTO> ls, FocasLibBase.PRGDIR3_data dir)
        {
            ProgramDTO pDto = new ProgramDTO();

            pDto.ProgramNo     = dir.number;
            pDto.ProgramLenght = dir.length;
            pDto.Comment       = dir.comment;
            pDto.ModifiedDate  = new DateTime(dir.mdate.year < 2000 ? dir.mdate.year + 2000 : dir.mdate.year, dir.mdate.month, dir.mdate.day, dir.mdate.hour, dir.mdate.minute, 00);
            ls.Add(pDto);
        }
        //OK
        // GET: Client/CreateProgramForClient/5
        public ActionResult CreateProgramForClient(string clientId)
        {
            ProgramDTO program = new ProgramDTO();

            program.ClientId   = clientId;
            program.StartTime  = DateTime.Today;
            program.EndTime    = DateTime.Today;
            ViewBag.goalsItems = goalTypeDAO.GetAll();
            return(View(program));
        }
Ejemplo n.º 17
0
        public void TestConstructor_ProgramDtoArg()
        {
            var list = new List <LocationDTO>();

            var dto = new ProgramDTO();

            dto.Contacts            = ToListOfSimpleLookups(1, "contact");
            dto.CountryIsos         = ToListOfSimpleLookups(2, "iso");
            dto.Description         = "desc";
            dto.Goals               = ToListOfSimpleLookups(4, "goal");
            dto.Regions             = list;
            dto.Id                  = 1;
            dto.Name                = "name";
            dto.ProgramStatusName   = "status";
            dto.ProgramStatusId     = 100;
            dto.OwnerDescription    = "owner desc";
            dto.OwnerName           = "owner name";
            dto.OwnerOrganizationId = 2;
            dto.OwnerOfficeSymbol   = "symbol";
            dto.ParentProgramId     = 3;
            dto.ParentProgramName   = "parent program";
            dto.RegionIsos          = ToListOfSimpleLookups(5, "region iso");
            dto.RevisedOn           = DateTimeOffset.UtcNow;
            dto.RowVersion          = new byte[1] {
                (byte)1
            };
            dto.StartDate = DateTimeOffset.UtcNow.AddDays(-1.0);
            dto.EndDate   = DateTimeOffset.UtcNow.AddDays(1.0);
            dto.Themes    = ToListOfSimpleLookups(6, "theme");

            var viewModel = new ProgramViewModel(dto);

            Assert.AreEqual(dto.Description, viewModel.Description);
            Assert.AreEqual(dto.Id, viewModel.Id);
            Assert.AreEqual(dto.Name, viewModel.Name);
            Assert.AreEqual(dto.OwnerDescription, viewModel.OwnerDescription);
            Assert.AreEqual(dto.OwnerOrganizationId, viewModel.OwnerOrganizationId);
            Assert.AreEqual(dto.OwnerOfficeSymbol, viewModel.OwnerOfficeSymbol);
            Assert.AreEqual(dto.ParentProgramId, viewModel.ParentProgramId);
            Assert.AreEqual(dto.ParentProgramName, viewModel.ParentProgramName);
            Assert.AreEqual(dto.RevisedOn, viewModel.RevisedOn);
            Assert.AreEqual(Convert.ToBase64String(dto.RowVersion), viewModel.RowVersion);
            Assert.AreEqual(dto.StartDate, viewModel.StartDate);
            Assert.AreEqual(dto.EndDate, viewModel.EndDate);
            Assert.AreEqual(dto.ProgramStatusId, viewModel.ProgramStatusId);
            Assert.AreEqual(dto.ProgramStatusName, viewModel.ProgramStatusName);

            CollectionAssert.AreEqual(dto.Contacts.ToList(), viewModel.Contacts.ToList());
            CollectionAssert.AreEqual(dto.CountryIsos.ToList(), viewModel.CountryIsos.ToList());
            CollectionAssert.AreEqual(dto.Goals.ToList(), viewModel.Goals.ToList());
            CollectionAssert.AreEqual(dto.RegionIsos.ToList(), viewModel.RegionIsos.ToList());
            CollectionAssert.AreEqual(dto.Themes.ToList(), viewModel.Themes.ToList());
            Assert.IsTrue(Object.ReferenceEquals(list, dto.Regions));
        }
Ejemplo n.º 18
0
        public ProgramEditViewModel(ProgramDTO program, bool shouldUpdateLocaly = false) : base(UIEnums.PageModes.Edit)
        {
            ShouldUpdateLocaly = shouldUpdateLocaly;
            Program            = program;

            Drills = program.Drills.Select <ProgramDrillDTO, ProgramDrillViewModel>(currDrill =>
            {
                return(Converter.Convert <ProgramDrillViewModel>(currDrill, true));
            }).ToList();

            ProgramName = program.Name;
        }
Ejemplo n.º 19
0
        public ICollection <ProgramDTO> GetAllPrograms(ProgramDTO newProgram)
        {
            ActionResponse response = new ActionResponse();

            ProgramRepository repository = RepositoriesFactory.CreateRepository <ProgramRepository, Program>();

            ICollection <Program> wantedPrograms = repository.GetALL();

            ICollection <ProgramDTO> ProgramDrills = wantedPrograms
                                                     .Select <Program, ProgramDTO>(currProgram => ConvertEntityTODTO(currProgram)).ToList();

            return(ProgramDrills);
        }
Ejemplo n.º 20
0
 public bool Create(ProgramDTO program)
 {
     try
     {
         var data = MapperProfile.MapperConfig().Map <ProgramDTO, Program>(program);
         _unitOfWork.ProgramRepository.Create(data);
         return(_unitOfWork.Commit());
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(false);
     }
 }
Ejemplo n.º 21
0
        public async Task <int> AddProgram(ProgramDTO program)
        {
            if (program == null)
            {
                throw new ArgumentNullException($"Program cannot be null");
            }

            var newProgram = mapper.Map <Program>(program);
            await _ctx.Programs.AddAsync(newProgram);

            await _ctx.SaveChangesAsync();

            return(newProgram.ProgramId);
        }
Ejemplo n.º 22
0
        public ActionResponse DeleteLocalProgram(ProgramDTO program)
        {
            ICollection <ProgramDTO> localProgram = GetLocalPrograms();

            List <ProgramDTO> existingPrograms = localProgram.ToList();

            existingPrograms.RemoveAt(program.LocalId);

            SetLocalPrograms(existingPrograms);

            return(new ActionResponse()
            {
                CompletedSuccessfully = true
            });
        }
Ejemplo n.º 23
0
        public ActionResponse SetLocalProgram(ProgramDTO program)
        {
            ICollection <ProgramDTO> localProgram = GetLocalPrograms();

            ProgramDTO[] existingPrograms = localProgram.ToArray();

            existingPrograms[program.LocalId] = program;

            SetLocalPrograms(existingPrograms);

            return(new ActionResponse()
            {
                CompletedSuccessfully = true
            });
        }
Ejemplo n.º 24
0
 public bool Edit(ProgramDTO program)
 {
     try
     {
         program.ProDateCreate = _unitOfWork.ProgramRepository.GetById(program.ID).ProDateCreate;
         var data = MapperProfile.MapperConfig().Map <ProgramDTO, Program>(program);
         _unitOfWork.ProgramRepository.Edit(data);
         return(_unitOfWork.Commit());
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(false);
     }
 }
Ejemplo n.º 25
0
        public async Task <ProgramDTO> UpdateProgram(ProgramDTO programSrc)
        {
            var entityDest = await _ctx.Programs.FindAsync(programSrc.ProgramId);

            if (entityDest != null)
            {
                entityDest.BaseFee      = programSrc.BaseFee;
                entityDest.Description  = programSrc.Description;
                entityDest.DurationDays = programSrc.DurationDays;
                entityDest.Name         = programSrc.Name;
            }
            await _ctx.SaveChangesAsync();

            return(await Task.FromResult(programSrc));
        }
Ejemplo n.º 26
0
        public bool UpdateProgram(ProgramDTO program)
        {
            this.ConnectToDatabase();

            string Query = "update PROGRAM set PROGRAM_ID='" + program.ProgramId + "',PROGRAM_NAME = '" + program.ProgramName + "',LEVEL = '" + program.Level + "',FEE = '" + program.Fee + "'";

            //This is command class which will handle the query and connection object.
            MySqlCommand command = new MySqlCommand(Query, mySQLConnection);

            command.ExecuteNonQuery();


            this.Close();
            return(true);
        }
Ejemplo n.º 27
0
        public bool InsertProgram(ProgramDTO program)
        {
            this.ConnectToDatabase();

            string Query = "insert into PROGRAM values('" + program.ProgramId + "','" + program.ProgramName + "','" + program.Level + "','" + program.Fee + "');";

            //This is command class which will handle the query and connection object.
            MySqlCommand command = new MySqlCommand(Query, mySQLConnection);

            command.ExecuteNonQuery();


            this.Close();
            return(true);
        }
Ejemplo n.º 28
0
        public ActionResult Edit(ProgramDTO program)
        {
            var data = new ProgramDao(_unitOfWork).GetByid(program.ID);

            ViewBag.TypeProgram = new TypeProgramDao(_unitOfWork).GetAll();
            if (!ModelState.IsValid)
            {
                return(View(data));
            }
            if (new ProgramDao(_unitOfWork).Edit(program))
            {
                return(RedirectToAction("Index"));
            }
            TempData[MessageConst.ERROR] = "Edit Failed";
            return(View(data));
        }
Ejemplo n.º 29
0
        public async Task <ActionResponse> DeleteProgram(ProgramDTO newProgram)
        {
            HttpRequestMessage request = await getRequest(HttpMethod.Delete, "programs/" + newProgram.Id);

            HttpResponseMessage response = await getClient().SendAsync(request);

            if (!response.IsSuccessStatusCode)
            {
                return(new ActionResponse()
                {
                    ErrorMessage = "Operation failed program did not delete properly", CompletedSuccessfully = false
                });
            }

            return(JsonConvert.DeserializeObject <ActionResponse>(await response.Content.ReadAsStringAsync()));
        }
Ejemplo n.º 30
0
        protected void CheckDigitalSignature(ProgramDTO program)
        {
            if (!File.Exists(program.FilePath))
            {
                Debug.WriteLine("File not found");
                return;
            }

            X509Certificate2 theCertificate;

            try
            {
                X509Certificate theSigner = X509Certificate.CreateFromSignedFile(program.FilePath);
                theCertificate = new X509Certificate2(theSigner);
                program.IsDigitalSignatureExists = true;
                program.CompanyName = Parse(theCertificate.Subject, "CN").FirstOrDefault();
            }
            catch (Exception ex)
            {
                Debug.WriteLine("No digital signature found: " + ex.Message);
                program.CompanyName = CompanyNameFromFileInfo(program.FilePath);
                return;
            }

            var theCertificateChain = new X509Chain();

            theCertificateChain.ChainPolicy.RevocationFlag = X509RevocationFlag.ExcludeRoot;

            theCertificateChain.ChainPolicy.RevocationMode = X509RevocationMode.Offline;

            theCertificateChain.ChainPolicy.UrlRetrievalTimeout = new TimeSpan(0, 1, 0);

            theCertificateChain.ChainPolicy.VerificationFlags = X509VerificationFlags.NoFlag;

            program.IsDigitalSignatureCorrect = theCertificateChain.Build(theCertificate);
            if (program.IsDigitalSignatureCorrect)
            {
                Debug.WriteLine("Publisher Information : " + theCertificate.SubjectName.Name);
                Debug.WriteLine("Valid From: " + theCertificate.GetEffectiveDateString());
                Debug.WriteLine("Valid To: " + theCertificate.GetExpirationDateString());
                Debug.WriteLine("Issued By: " + theCertificate.Issuer);
            }
            else
            {
                Debug.WriteLine("Chain Not Valid (certificate is self-signed)");
            }
        }