public static void PopulateCmbAgencySchemes(DropDownList ddlAgencySchemes)
        {
            ddlAgencySchemes.Items.Clear();
            WSModel dal = new WSModel();

            //if (true)
            //{
            //    GetXmlAgencies(ddlAgencySchemes);
            //    return;
            //}

            ISdmxObjects agencies = dal.GetAllAgencyScheme(false);
            if (agencies.AgenciesSchemes != null && agencies.AgenciesSchemes.Count > 0)
            {
                ISTATUtils.LocalizedUtils loc = new ISTATUtils.LocalizedUtils(Utils.LocalizedCulture);
                foreach (IAgencyScheme aScheme in agencies.AgenciesSchemes)
                {
                    ListItem tmpItem = new ListItem(string.Format("{0}+{1}+{2}", aScheme.Id, aScheme.AgencyId, aScheme.Version));
                    ddlAgencySchemes.Items.Add(tmpItem);
                }
            }
        }
Example #2
0
        private void GVDataBind()
        {
            if (_textObjectList != null)
            {
                ISTATUtils.LocalizedUtils loc = new ISTATUtils.LocalizedUtils(Utils.LocalizedCulture);
                txtViewText.Text = loc.GetLocalizedText(_textObjectList);

                gvText.DataSource = _textObjectList;
                gvText.DataBind();

            }
        }
        public static void PopulateCmbAgencies(DropDownList ddlAgencies, bool excludeAgenciesForUser)
        {
            ddlAgencies.Items.Clear();

            if (HttpContext.Current.Session[SESSION_KEYS.USER_OK] != null && ((bool)HttpContext.Current.Session[SESSION_KEYS.USER_OK]) == true && excludeAgenciesForUser)
            {
                User currentUser = HttpContext.Current.Session[SESSION_KEYS.USER_DATA] as User;
                string currentLanguageSession = HttpContext.Current.Session[SESSION_KEYS.KEY_LANG] as string;
                if (currentUser != null)
                {
                    List<UserAgency> currentUserAgencies = currentUser.agencies.ToList<UserAgency>();
                    List<UserAgency> currentUserAgenciesForCurrentLanguage = currentUser.agencies.Where<UserAgency>(currentAgency => currentAgency.lang.Equals(currentLanguageSession)).ToList<UserAgency>();
                    List<UserAgency> currentUserAgenciesForDifferentLanguages = currentUser.agencies.Where<UserAgency>(currentAgency => !currentAgency.lang.Equals(currentLanguageSession)).ToList<UserAgency>();

                    List<string> agenciesAlreadyAdded = new List<string>();

                    foreach (UserAgency ag in currentUserAgenciesForCurrentLanguage)
                    {
                        string currentAgencyId = ag.id;
                        ListItem tmpItem = null;
                        //if (!ag.text.Trim().Equals(string.Empty))
                        //{
                        //    tmpItem = new ListItem(string.Format("{0} - {1}", ag.id, ag.text));
                        //}
                        //else
                        //{
                        tmpItem = new ListItem(ag.id);
                        //}
                        ddlAgencies.Items.Add(tmpItem);
                        agenciesAlreadyAdded.Add(currentAgencyId);
                    }

                    foreach (UserAgency ag in currentUserAgenciesForDifferentLanguages)
                    {
                        string currentAgencyId = ag.id;
                        ListItem tmpItem = tmpItem = new ListItem(ag.id);
                        if (!agenciesAlreadyAdded.Contains(currentAgencyId))
                        {
                            ddlAgencies.Items.Add(tmpItem);
                            agenciesAlreadyAdded.Add(currentAgencyId);
                        }
                    }
                }
            }
            else
            {
                WSModel dal = new WSModel();

                //if (true)
                //{
                //    GetXmlAgencies(ddlAgencies);
                //    return;
                //}

                ISdmxObjects agencies;
                try
                {
                    agencies = dal.GetAllAgencyScheme(false);
                }
                catch (Exception ex)
                {
                    if (ex.Message == "Not Implemented")
                        return;

                    throw ex;
                }

                if (agencies.AgenciesSchemes != null && agencies.AgenciesSchemes.Count > 0)
                {
                    ISTATUtils.LocalizedUtils loc = new ISTATUtils.LocalizedUtils(Utils.LocalizedCulture);

                    foreach (IAgencyScheme aScheme in agencies.AgenciesSchemes)
                    {
                        foreach (IAgency ag in aScheme.Items)
                        {
                            ListItem tmpItem = null;
                            string agencyDescription = loc.GetNameableDescription(ag);
                            if (agencyDescription.Trim().Equals(string.Empty))
                            {
                                tmpItem = new ListItem(ag.Id);
                            }
                            else
                            {
                                tmpItem = new ListItem(string.Format("{0} - {1}", ag.Id, agencyDescription));
                            }
                            if (!ddlAgencies.Items.Contains(tmpItem))
                            {
                                ddlAgencies.Items.Add(tmpItem);
                            }
                        }
                    }
                }
            }
        }
        private void BindData()
        {
            if (_annotations == null)
            {
                gridView.DataBind();
                return;
            }

            ISTATUtils.LocalizedUtils localUtils = new ISTATUtils.LocalizedUtils(Utils.LocalizedCulture);
            ISTAT.EntityMapper.EntityMapper eMapper = new ISTAT.EntityMapper.EntityMapper(Utils.LocalizedLanguage);

            IList<ISTAT.Entity.Annotation> lAnnoations = new List<ISTAT.Entity.Annotation>();
            foreach (IAnnotationMutableObject annotation in _annotations)
            {
                if (annotation.Type == null || ((annotation.Type != null) && (annotation.Type.Trim() != "@ORDER@" && annotation.Type.Trim() != "CategoryScheme_node_order")))
                {
                    // Valore standard per le codelist immesso automaticmante
                    lAnnoations.Add(new ISTAT.Entity.Annotation(
                        annotation.Id,
                        annotation.Title,
                        annotation.Type,
                        (annotation.Uri != null) ? annotation.Uri.AbsoluteUri : string.Empty,
                        localUtils.GetLocalizedText(annotation.Text)));
                }
            }
            gridView.DataSource = lAnnoations.OrderBy(ann => ann.ID).ToList();
            gridView.DataBind();
        }