Пример #1
0
        private void LoadDictionaryByCategory(List <string> categoryNames)
        {
            List <string> tempList = CheckCategory(categoryNames);

            if (tempList.Count > 0)
            {
                ObservableCollection <string> categorys = new ObservableCollection <string>();
                foreach (var item in tempList)
                {
                    categorys.Add(item);
                }

                if (V_DictionaryInfoVM.IsExists(categorys.ToList()) == false)
                {
                    _client.GetDictionaryByCategoryArrayAsync(categorys);
                }
                else
                {
                    GetDictionaryInfoByLocal();
                }
            }
            else
            {
                if (this.OnDictionaryLoadCompleted != null)
                {
                    OnDictionaryLoadCompleted(this, new OnDictionaryLoadArgs()
                    {
                        Result = true, Error = null
                    });
                }
            }
        }
Пример #2
0
        private void GetPostLevel()
        {
            string path = "silverlightcache\\POSTLEVEL.txt";

            try
            {
                var postlevel = SLCache.GetCache <List <V_Dictionary> >(path, 10);
                if (postlevel != null)
                {
                    var ents = from a in postlevel
                               orderby a.DICTIONARYNAME ascending
                               select a;
                    cboPostLevel.BindData(ents.ToList(), "DICTIONARYNAME", "DICTIONARYVALUE");
                }
                else
                {
                    PermissionServiceClient psc = new PermissionServiceClient();
                    System.Collections.ObjectModel.ObservableCollection <string> strs = new System.Collections.ObjectModel.ObservableCollection <string>();
                    strs.Add("POSTLEVEL");
                    //   strs.Add("TYPEAPPROVAL");
                    psc.GetDictionaryByCategoryArrayAsync(strs);
                    psc.GetDictionaryByCategoryArrayCompleted += (o, e) =>
                    {
                        if (e.Error == null)
                        {
                            if (e.Result != null)
                            {
                                //System.Collections.ObjectModel.ObservableCollection<V_Dictionary> dics =e.Result;
                                var ents = from a in e.Result
                                           orderby a.DICTIONARYNAME ascending
                                           select a;
                                cboPostLevel.BindData(ents.ToList(), "DICTIONARYNAME", "DICTIONARYVALUE");
                                SLCache.SaveData <List <V_Dictionary> >(e.Result.ToList(), path);
                            }
                        }
                    };
                }
            }
            catch
            {
                PermissionServiceClient psc = new PermissionServiceClient();
                System.Collections.ObjectModel.ObservableCollection <string> strs = new System.Collections.ObjectModel.ObservableCollection <string>();
                strs.Add("POSTLEVEL");
                //   strs.Add("TYPEAPPROVAL");
                psc.GetDictionaryByCategoryArrayAsync(strs);
                psc.GetDictionaryByCategoryArrayCompleted += (o, e) =>
                {
                    if (e.Error == null)
                    {
                        if (e.Result != null)
                        {
                            //System.Collections.ObjectModel.ObservableCollection<V_Dictionary> dics =e.Result;
                            var ents = from a in e.Result
                                       orderby a.DICTIONARYNAME ascending
                                       select a;
                            cboPostLevel.BindData(ents.ToList(), "DICTIONARYNAME", "DICTIONARYVALUE");
                            SLCache.SaveData <List <V_Dictionary> >(e.Result.ToList(), path);
                        }
                    }
                };
            }
        }
Пример #3
0
        private void GetPostLevel()
        {
            string path = "silverlightcache\\POSTLEVEL.txt";
            try
            {
              
                var postlevel =SLCache.GetCache<List<V_Dictionary>>(path, 10);
                if (postlevel != null)
                {
                    var ents = from a in postlevel
                               orderby a.DICTIONARYNAME ascending
                               select a;
                    cboPostLevel.BindData(ents.ToList(), "DICTIONARYNAME", "DICTIONARYVALUE");
                }
                else
                {
                    PermissionServiceClient psc = new PermissionServiceClient();
                    System.Collections.ObjectModel.ObservableCollection<string> strs = new System.Collections.ObjectModel.ObservableCollection<string>();
                    strs.Add("POSTLEVEL");
                    //   strs.Add("TYPEAPPROVAL");
                    psc.GetDictionaryByCategoryArrayAsync(strs);
                    psc.GetDictionaryByCategoryArrayCompleted += (o, e) =>
                    {
                        if (e.Error == null)
                        {
                            if (e.Result != null)
                            {
                                //System.Collections.ObjectModel.ObservableCollection<V_Dictionary> dics =e.Result;
                                var ents = from a in e.Result
                                           orderby a.DICTIONARYNAME ascending
                                           select a;
                                cboPostLevel.BindData(ents.ToList(), "DICTIONARYNAME", "DICTIONARYVALUE");
                                SLCache.SaveData<List<V_Dictionary>>(e.Result.ToList(), path);
                            }
                        }
                    }; 
                }
            }
            catch
            {
                PermissionServiceClient psc = new PermissionServiceClient();
                System.Collections.ObjectModel.ObservableCollection<string> strs = new System.Collections.ObjectModel.ObservableCollection<string>();
                strs.Add("POSTLEVEL");
                //   strs.Add("TYPEAPPROVAL");
                psc.GetDictionaryByCategoryArrayAsync(strs);
                psc.GetDictionaryByCategoryArrayCompleted += (o, e) =>
                {
                    if (e.Error == null)
                    {
                        if (e.Result != null)
                        {
                            //System.Collections.ObjectModel.ObservableCollection<V_Dictionary> dics =e.Result;
                            var ents = from a in e.Result
                                       orderby a.DICTIONARYNAME ascending
                                       select a;
                            cboPostLevel.BindData(ents.ToList(), "DICTIONARYNAME", "DICTIONARYVALUE");
                            SLCache.SaveData<List<V_Dictionary>>(e.Result.ToList(), path);
                        }
                    }
                }; 
            }
           

        }
Пример #4
0
        private void LoadDictionaryByCategory(List <string> categoryNames)
        {
            List <string> tempList = CheckCategory(categoryNames);

            if (tempList.Count > 0)
            {
                ObservableCollection <string> categorys = new ObservableCollection <string>();
                bool needLoadFromServer      = false;
                List <T_SYS_DICTIONARY> dics = Application.Current.Resources["SYS_DICTIONARY"] as List <T_SYS_DICTIONARY>;
                if (dics != null)
                {
                    if (dics.Count > 0)
                    {
                        foreach (string strcategorys in categoryNames)
                        {
                            var q = from ent in dics
                                    where ent.DICTIONCATEGORY == strcategorys
                                    select ent.DICTIONCATEGORY;
                            if (q.Count() > 0)
                            {
                                continue;
                            }

                            categorys.Add(strcategorys);
                        }
                    }
                    else
                    {
                        foreach (string strcategorys in categoryNames)
                        {
                            categorys.Add(strcategorys);
                        }
                    }
                }
                else
                {
                    foreach (string strcategorys in categoryNames)
                    {
                        categorys.Add(strcategorys);
                    }
                }

                if (categorys.Count > 0)
                {
                    needLoadFromServer = true;
                }

                if (!needLoadFromServer)
                {
                    if (this.OnDictionaryLoadCompleted != null)
                    {
                        OnDictionaryLoadCompleted(this, new OnDictionaryLoadArgs()
                        {
                            Result = true, Error = null
                        });
                    }
                }
                else
                {
                    _client.GetDictionaryByCategoryArrayAsync(categorys);
                }
            }
        }