Ejemplo n.º 1
0
        /// <summary>
        /// Searches <paramref name="parsingTarget"/> for fields with
        /// <see cref="ArgumentAttribute">ArgumentAttributes</see> or some of its descendats. Adds new argument
        /// for each such a field and defines binding of the argument to the field.
        /// Also adds <see cref="ArgumentCertification"/> object to <see cref="Certifications"/> collection
        /// for each <see cref="ArgumentCertificationAttribute"/> of <paramref name="parsingTarget"/>.
        /// </summary>
        /// <seealso cref="Argument.Bind"/>
        /// <param name="parsingTarget">object where you with some ArgumentAttributes</param>
        public void ExtractArgumentAttributes(object parsingTarget)
        {
            Type targetType = parsingTarget.GetType();

            MemberInfo[] fields = targetType.GetFields();

            MemberInfo[] properties = targetType.GetProperties();

            List <MemberInfo> fieldAndProps = new List <MemberInfo>(fields);

            fieldAndProps.AddRange(properties);

            foreach (MemberInfo info in fieldAndProps)
            {
                var attrs = info.GetCustomAttributes(typeof(ArgumentAttribute), true).ToArray();

                if (attrs.Length == 1 && attrs[0] is ArgumentAttribute)
                {
                    Arguments.Add(((ArgumentAttribute)attrs[0]).Argument);
                    ((ArgumentAttribute)attrs[0]).Argument.Bind =
                        new FieldArgumentBind(parsingTarget, info.Name);
                }
            }

            object[] typeAttrs = targetType.GetTypeInfo().GetCustomAttributes(typeof(ArgumentCertificationAttribute), true).ToArray();
            foreach (object certificationAttr in typeAttrs)
            {
                Certifications.Add(((ArgumentCertificationAttribute)certificationAttr).Certification);
            }
        }
Ejemplo n.º 2
0
        //public bool Delete(string reference)
        //{
        //    string query = $"delete from dsto_sections where yref_questionaire = '{reference}' or yref_field_inspection = '{reference}' or yref_certification = '{reference}'";
        //    var rows = DbInfo.ExecuteNonQuery(query);
        //    return rows > 0;
        //}



        public Certifications GetCertifications(int configuration_Id)
        {
            Certifications certifications = new Certifications(null);

            try
            {
                string query = $"select * from dsto_Certification where status=0 and configuration_id = '{configuration_Id}' and Deleted=0";
                var    table = DbInfo.ExecuteSelectQuery(query);
                if (table.Rows.Count > 0)
                {
                    foreach (DataRow row in table.Rows)
                    {
                        var certificationType = (CertificationTypes)Enum.Parse(typeof(CertificationTypes), row["CertificationType"].ToString());
                        DCAnalytics.Certification certification = certifications.Add(certificationType);
                        InitCertification(certification, row);
                        certification.Sections = new SectionProvider(DbInfo).GetSections(certification.Key);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(certifications);
        }
        public void AddEmployeeForm_AddCertification(object e)
        {
            var newCertification = new CertificationModel();

            newCertification.Name    = SelectedCertification.Name;
            newCertification.EndDate = _newCertificationExpirationDate;
            newCertification.Id      = SelectedCertification.Id;
            Certifications.Add(newCertification);
        }
Ejemplo n.º 4
0
        public async Task <Certification> AddCertification(CertificationDto cert, UserManager <ApplicationUser> _userManager)
        {
            Certification certification = CertificationFromDto(cert);

            Certifications.Add(certification);

            Task <IdentityResult> result = _userManager.UpdateAsync(this);

            if (result.Result.Succeeded)
            {
                return(certification);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 5
0
        public Certifications CertificationsOverview(int configuration_Id)
        {
            Certifications certifications = new Certifications(null);

            try
            {
                string query = $"select * from dsto_Certification where status=2 or status=3 and configuration_id = '{configuration_Id}'";
                var    table = DbInfo.ExecuteSelectQuery(query);
                if (table.Rows.Count > 0)
                {
                    foreach (DataRow row in table.Rows)
                    {
                        var           certificationType = (CertificationTypes)Enum.Parse(typeof(CertificationTypes), row["CertificationType"].ToString());
                        Certification certification     = certifications.Add(certificationType);
                        InitCertification(certification, row);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(certifications);
        }
Ejemplo n.º 6
0
        private void GetUserData()
        {
            Task.Run(async() =>
            {
                User = await ServiceBus.UserService.GetUserByServerId(UserId);

                var userCvs  = await ServiceBus.UserService.GetUserCvsByServerId(UserId);
                var userInfo = await ServiceBus.UserService.GetUserInfoById(User.UserId);

                Position = userInfo?.Department ?? "?";

                InvokeOnMainThread(() => { UserTechnologyCategoryViewModels.Clear(); });

                var technologyCategoryIds = new Dictionary <string, UserTechnologyCategoryViewModel>();
                foreach (var technologyCvs in userCvs.UserCv.Technologies)
                {
                    if (!technologyCategoryIds.ContainsKey(technologyCvs.Category.Id))
                    {
                        var userTechnologyCategoryViewModel = new UserTechnologyCategoryViewModel
                        {
                            Name = technologyCvs.Category.Name
                        };
                        technologyCategoryIds.Add(technologyCvs.Category.Id, userTechnologyCategoryViewModel);

                        // TODO: Currently replaced with awful approach below
                        InvokeOnMainThread(
                            () => { CategoryViewModels.Add(userTechnologyCategoryViewModel); });
                    }

                    InvokeOnMainThread(() =>
                    {
                        technologyCategoryIds[technologyCvs.Category.Id].UserTechnologyViewModels.Add(
                            new UserTechnologyViewModel(technologyCvs.Name, technologyCvs.Stars));
                    });
                }

                // TODO: Awful approach suggested due to Nested ListViews are poorly supported.
                // TODO: Anyway, UserTechnologyCategoryViewModel has propriate collection of user technologies to create nested binding in future.
                foreach (var userTechnologyCategoryViewModel in technologyCategoryIds.OrderBy(t => t.Value.Name))
                {
                    InvokeOnMainThread(
                        () =>
                    {
                        UserTechnologyCategoryViewModels.Add(userTechnologyCategoryViewModel.Value);
                        foreach (
                            var userTechnologyViewModel in userTechnologyCategoryViewModel
                            .Value
                            .UserTechnologyViewModels
                            .OrderByDescending(i => i.Stars))
                        {
                            UserTechnologyCategoryViewModels.Add(userTechnologyViewModel);
                        }
                    });
                }

                RaisePropertyChanged(() => TechnologiesVisibility);

                foreach (var achievementId in _user.Pdp.AchievementsIds)
                {
                    var achievement       = await ServiceBus.UserService.GetAchievementsById(achievementId);
                    var userAchievementVm = new UserAchievementViewModel
                    {
                        Name     = achievement.Name,
                        Category = achievement.Category.Name,
                        ImageUri = Constants.BaseUrl + achievement.ImageUri
                    };
                    InvokeOnMainThread(() => { Achievements.Add(userAchievementVm); });
                }

                RaisePropertyChanged(() => AchievementsVisibility);

                foreach (var certificationId in _user.Pdp.CertificationsIds)
                {
                    var certification       = await ServiceBus.UserService.GetCertificateByIdAsync(certificationId);
                    var userCertificationVm = new UserCertificationViewModel
                    {
                        Name     = certification.Name,
                        Category = certification.Category.Name,
                        ImageUri = Constants.BaseUrl + certification.ImageUri
                    };
                    InvokeOnMainThread(() => { Certifications.Add(userCertificationVm); });
                }

                RaisePropertyChanged(() => CertificationsVisibility);
            });
        }