public void LoadSecureBrowserFavoriteList()
        {
            FavoriteList.Clear();

            var favoriteList = PBData.GetFavorites();

            if (favoriteList == null)
            {
                return;
            }

            foreach (var favorite in favoriteList)
            {
                FavoriteListItemViewModel item = new FavoriteListItemViewModel(this);
                item.Favorite  = favorite;
                item.SiteImage = null; //force loading of favicon
                FavoriteList.Add(item);
            }

            if (favoriteList.Count == 0)
            {
                IsFavoriteListEmpty = true;
            }
            else
            {
                IsFavoriteListEmpty = false;
            }
        }
 //To - Do Favorite click
 private void ItemFavoriteClick(object obj)
 {
     try
     {
         //SecureBrowserItem s = (SecureBrowserItem)HomepageItems.FirstOrDefault(x => x.Id == _itemId);
         if (obj != null)
         {
             string _itemId = obj as string;
             foreach (SecureBrowserItem s in HomepageItems)
             {
                 if (s.Id == _itemId)
                 {
                     if (s != null)
                     {
                         if (s.ItemFavorite)
                         {
                             PBData.UpdateSecureItemFavorite(s.Id, false);
                             s.ItemFavorite = false;
                         }
                         else
                         {
                             PBData.UpdateSecureItemFavorite(s.Id, true);
                             s.ItemFavorite = true;
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         logger.Error(ex.Message);
     }
 }
Example #3
0
        public static void JSON()
        {
            List <string> lstr = new List <string>()
            {
                "a"
            };

            Console.WriteLine("原始的List<string>数据 " + lstr[0]);
            string s = Methods.JsonSer(lstr);

            Console.WriteLine("经JSON序列化后的List<string>数据 " + s);
            lstr = Methods.JsonDes <List <string> >(s);
            Console.WriteLine("经JSON序列化后反序列化的List<string>数据 " + lstr[0]);
            PBData data = new PBData()
            {
                Name = "a", Age = 20, IsBoy = true, Data = new PBData()
                {
                    Name = "b", Age = 30, IsBoy = false,
                }
            };

            Console.WriteLine("原始的PBData数据 " + data.Name + " " + data.Age + " " + data.IsBoy + " " +
                              data.Data.Name + " " + data.Data.Age + " " + data.Data.IsBoy);
            s = Methods.JsonSer(data);
            Console.WriteLine("经JSON序列化后的PBData数据 " + s);
            data = Methods.JsonDes <PBData>(s);
            Console.WriteLine("经JSON序列化后反序列化的PBData数据 " + data.Name + " " + data.Age + " " + data.IsBoy + " " +
                              data.Data.Name + " " + data.Data.Age + " " + data.Data.IsBoy);
        }
Example #4
0
        public static void PB()
        {
            Console.WriteLine("普通数据PB测试");
            List <string> lstr = new List <string>()
            {
                "a"
            };

            Console.WriteLine("原始的List<string>数据 " + lstr[0]);
            byte[] b = Methods.PBSer(lstr);
            lstr = Methods.PBDes <List <string> >(b);
            Console.WriteLine("经PB序列化后反序列化的List<string>数据 " + lstr[0]);
            PBData data = new PBData()
            {
                Name = "a", Age = 20, IsBoy = true, Data = new PBData()
                {
                    Name = "b", Age = 30, IsBoy = false,
                }
            };

            Console.WriteLine("原始的PBData数据 " + data.Name + " " + data.Age + " " + data.IsBoy + " " +
                              data.Data.Name + " " + data.Data.Age + " " + data.Data.IsBoy);
            b    = Methods.PBSer(data);
            data = Methods.PBDes <PBData>(b);
            Console.WriteLine("经PB序列化后反序列化的PBData数据 " + data.Name + " " + data.Age + " " + data.IsBoy + " " +
                              data.Data.Name + " " + data.Data.Age + " " + data.Data.IsBoy);
        }
Example #5
0
        public static void WriteJson()
        {
            PBData data = new PBData()
            {
                Name = "名字", Age = 13, IsBoy = true
            };
            string str = Methods.JsonSer(data);

            Methods.WriteJson("PBData", str);
        }
 public void InitialHomePageItemsLoad()
 {
     if (PBData.GetSecureItemCountByType(SecurityItemsDefaultProperties.SecurityItemType_PasswordVault) != 0)
     {
         LoadFavoriteItems();
     }
     else
     {
         LoadRecommendedSites();
     }
 }
        public void LoadRecommendedSites()
        {
            HomepageItems.Clear();
            var recommendedSites = PBData.GetRecommendedSites();

            if (recommendedSites != null)
            {
                foreach (var site in recommendedSites)
                {
                    HomepageItems.Add(new SecureBrowserItem(site));
                }
            }

            HomepageModel = new PageableViewModel <SecureItem>(HomepageItems);
        }
        public void LoadRecentlyUsedItems()
        {
            HomepageItems.Clear();

            var recentlyUsedItemList = PBData.GetSecureItemsByItemType(SecurityItemsDefaultProperties.SecurityItemType_PasswordVault, SecureItemOrderEnum.LastAccess);

            foreach (var item in recentlyUsedItemList)
            {
                HomepageItems.Add(new SecureBrowserItem(item));
                if (HomepageItems.Count() == 24)
                {
                    break;
                }
            }
            HomepageModel = new PageableViewModel <SecureItem>(HomepageItems);
        }
 public void RemoveFromFavoriteListClick(object obj)
 {
     if (obj != null)
     {
         var favorite = PBData.GetFavorites().Where(x => x.Url == obj.ToString()).FirstOrDefault();
         if (favorite != null)
         {
             this.PBData.RemoveFromFavorites(favorite);
             var tabItem = TabItemCollection.Where(x => x.SearchBar.Address == favorite.Url).FirstOrDefault();
             if (tabItem != null)
             {
                 tabItem.SearchBar.SetFavoriteIconVisibility(false);
             }
         }
         this.LoadSecureBrowserFavoriteList();
     }
 }
        public void LoadFavoriteItems()
        {
            HomepageItems.Clear();
            var favoriteSecureItemsList = PBData.GetSecureItemsByItemType(SecurityItemsDefaultProperties.SecurityItemType_PasswordVault).Where(x => x.Favorite).ToList();

            if (favoriteSecureItemsList.Count == 0)
            {
                LoadRecentlyUsedItems();
            }
            foreach (var favoriteItem in favoriteSecureItemsList)
            {
                HomepageItems.Add(new SecureBrowserItem(favoriteItem));
                if (HomepageItems.Count() == 24)
                {
                    break;
                }
            }
            HomepageModel = new PageableViewModel <SecureItem>(HomepageItems);
        }
Example #11
0
    void Start()
    {
        //StartCoroutine(loaderPBDataTest((data) =>
        //{
        //    Debug.Log(data.Length);
        //    MemoryStream m2 = new MemoryStream(data);
        //    PBData cfg = ProtoBuf.Serializer.Deserialize<PBData>(m2);
        //    Debug.Log(cfg.HeroInfoDic.Count);
        //}));

        string     savePath = Path.Combine(Application.streamingAssetsPath, "PBData.bytes");
        FileStream fs       = new FileStream(savePath, FileMode.Open, FileAccess.Read);
        int        len      = (int)fs.Length;

        Debug.Log(len);
        byte[] array = new byte[len];
        fs.Read(array, 0, len);
        MemoryStream ms     = new MemoryStream(array);
        PBData       pbData = null;

        try
        {
            pbData = ProtoBuf.Serializer.Deserialize <PBData>(ms);
        }
        catch (Exception e)
        {
            Debug.Log(e.ToString());
        }

        foreach (var item in pbData.HeroInfoDic)
        {
            Debug.Log(item.Key + "|" + item.Value.Name);
            //Debug.LogError(item.Value.GetSkillInfo(item.Value.BaseSkill.ToString()).SkillIcon);
        }

        foreach (var item2 in pbData.SkillInfoDic)
        {
            Debug.Log(item2.Key + "|" + item2.Value.SkillName);
        }
    }
 public void OpenInCurrentTabClick(object obj)
 {
     if (obj != null)
     {
         var favorite = PBData.GetFavorites().Where(x => x.Url == obj.ToString()).FirstOrDefault();
         if (favorite != null && this.SelectedTabItem != null)
         {
             this.SelectedTabItem.ShowOrHideFavoriteListClick(null);
             this.SelectedTabItem.WebBrowser.Navigate(favorite.Url);
         }
         else if (favorite != null)
         {
             TabItem defaultItem = new TabItem(this, resolver);
             defaultItem.SearchBar.Address = favorite.Url;
             TabItemCollection.Add(defaultItem);
         }
     }
     else
     {
         this.SelectedTabItem.ShowOrHideFavoriteListClick(null);
     }
 }
        private void ItemOpenHomepageItemClick(object obj)
        {
            try
            {
                //SecureBrowserItem s = (SecureBrowserItem)HomepageItems.FirstOrDefault(x => x.Id == _itemId);
                if (obj != null)
                {
                    string _itemId = obj as string;
                    foreach (SecureBrowserItem s in HomepageItems)
                    {
                        if (s.Id == _itemId)
                        {
                            if (s != null)
                            {
                                if (this.SelectedTabItem != null)
                                {
                                    string     uri  = null;
                                    SecureItem item = PBData.GetSecureItemById(_itemId);
                                    if (item != null)
                                    {
                                        uri = item.Site.Uri;
                                    }
                                    else
                                    {
                                        Site siteItem = PBData.GetSiteById(_itemId);
                                        uri = siteItem.Uri;
                                    }

                                    if (uri != null)
                                    {
                                        this.SelectedTabItem.ShowOrHideHomepageClick(null);

                                        resolver.GetInstanceOf <IInAppAnalytics>().Get <Events.InAppBrowser, bool>().Log(true);

                                        if (item != null)
                                        {
                                            _pbExtSecureBrowserBridge.OneClickLogin(_itemId, true, TabItemCollection.ToList().FindIndex(p => p.TabId == SelectedTabItem.TabId));
                                        }
                                        else
                                        {
                                            this.SelectedTabItem.WebBrowser.Navigate(uri);
                                        }
                                    }
                                }
                                else
                                {
                                    SecureItem item = PBData.GetSecureItemById(_itemId);
                                    if (item != null)
                                    {
                                        TabItem defaultItem = new TabItem(this, resolver);
                                        String  siteUri     = item.Site.Uri;
                                        defaultItem.SearchBar.Address = siteUri;
                                        TabItemCollection.Add(defaultItem);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
            }
        }
Example #14
0
        /// <summary>
        /// Excel -> 二进制文件
        /// </summary>
        /// <param name="inPath"></param>
        /// <param name="inFolderName"></param>
        /// <returns></returns>
        public bool Bin(string inPath, string inFolderName)
        {
            Assist.CheckFolderExist(inFolderName);

            PBData data = new PBData();

            Assist.GetObjPaths(".xls", inPath).ForEach(delegate(string path)
            {
                DataSet ds = Assist.ExcelToData(path);
                DataTable dt = ds.Tables[0];

                string classname = Stringer.FirstLetterUp(dt.TableName);

                Type classType = Type.GetType(classname);

                FieldInfo fieldInfo = typeof(PBData).GetField(classname + "Dic");

                IDictionary fieldValue = fieldInfo.GetValue(data) as IDictionary;

                if (classType != null)
                {
                    for (int i = 4; i < dt.Rows.Count; i++)
                    {
                        string key = ""; // key

                        List<string> ls = new List<string>();
                        for (int x = 0; x < dt.Columns.Count; x++)
                        {
                            ls.Add(dt.Rows[i][x].ToString());

                            if (dt.Rows[2][x].ToString().Split('+')[2] == "1")// 当前值为Key值的一部分
                            {
                                key += dt.Rows[i][x].ToString() + "_";
                            }
                        }
                        key = key.Remove(key.Length - 1, 1);
                        IProtoBufable value = Activator.CreateInstance(classType) as IProtoBufable;// value
                        value.Set(ls);
                        fieldValue.Add(key, value);
                    }

                    fieldInfo.SetValue(data, fieldValue);
                }
            });

            #region SceneLayout 读取同级目录下的“Excel/SceneLayout/”内的所有 xml 文件,并将其数据写入 PBData

            Dictionary<string, XmlDocument> doc = Assist.GetXml(Assist.RootPath + "Excel/SceneLayout/");
            foreach (KeyValuePair<string, XmlDocument> item in doc)
            {
                SceneLayout sl = new SceneLayout();
                XmlNodeList xcc = item.Value.SelectSingleNode("Config").ChildNodes;
                for (int i = 0; i < xcc.Count; i++)
                {
                    SceneLayoutItem sli = new SceneLayoutItem();

                    IProtoBufable xmlItemValue = new SceneLayoutItem() as IProtoBufable;// value
                    List<string> xls = new List<string>();
                    for (int x = 0; x < xcc[i].Attributes.Count; x++)
                    {
                        xls.Add(xcc[i].Attributes[x].Value);
                    }
                    xmlItemValue.Set(xls);

                    sl.item.Add(xmlItemValue as SceneLayoutItem);
                }
                data.SceneLayoutDic.Add(item.Key, sl);
            }

            #endregion

            using (var file = System.IO.File.Create("PBData"))
            {
                try
                {
                    ProtoBuf.Serializer.Serialize(file, data);
                }
                catch (Exception e)
                {
                    MainWindow.Show(e.ToString());
                }
            }

            return true;
        }
Example #15
0
 /// <summary>
 /// 获取经验
 /// </summary>
 public HeroExpInfo GetHeroExpInfo(string inArg0, PBData inArg1)
 {
     return(inArg1.HeroExpInfoDic[this.key + "_" + inArg0]);
 }
        public void LoadHomepageItemList()
        {
            HomepageItemList.Clear();
            if (PBData.GetSecureItemCountByType(SecurityItemsDefaultProperties.SecurityItemType_PasswordVault) != 0)
            {
                HomepageItem favoriteSites = new HomepageItem(this);
                favoriteSites.Name = System.Windows.Application.Current.FindResource("SecureBrowserFavoriteSites") as string;
                favoriteSites.Key  = HomepageItem.FAVORITE_ITEM;

                HomepageItem recentlyUsed = new HomepageItem(this);
                recentlyUsed.Name = System.Windows.Application.Current.FindResource("SecureBrowserRecentlyUsed") as string;
                recentlyUsed.Key  = HomepageItem.RECENTLY_USED_ITEM;

                HomepageItem mostUsed = new HomepageItem(this);
                mostUsed.Name = System.Windows.Application.Current.FindResource("SecureBrowserMostUsed") as string;
                mostUsed.Key  = HomepageItem.MOST_USED_ITEM;

                HomepageItemList.Add(favoriteSites);
                HomepageItemList.Add(recentlyUsed);
                HomepageItemList.Add(mostUsed);

                var lastViewKey = PBData.GetPrivateSetting(HomepageItem.SB_LAST_VIEW_KEY);
                if (lastViewKey == null)
                {
                    SelectedHomepageItem = recentlyUsed;
                }
                else
                {
                    SelectedHomepageItem = HomepageItemList.Where(x => x.Key == lastViewKey).FirstOrDefault();
                    if (SelectedHomepageItem == null)
                    {
                        SelectedHomepageItem = recentlyUsed;
                    }
                }
            }


            //LoadFavoriteItems();


            //var favoriteSecureItemsList = PBData.GetSecureItemsByItemType(DefaultProperties.SecurityItemType_PasswordVault);
            //HomepageFavoriteItems.Clear();

            //foreach(var favoriteItem in favoriteSecureItemsList)
            //{
            //    HomepageFavoriteItems.Add(new SecureBrowserItem(favoriteItem));
            //}
            //HomepageFavoriteModel.CreatePaging();

            //var recentlyUsedItemList = PBData.GetSecureItemsByItemType(DefaultProperties.SecurityItemType_PasswordVault, SecureItemOrderEnum.LastAccess);
            //HomepageRecentlyUsedItems.Clear();

            //foreach (var item in recentlyUsedItemList)
            //{
            //    HomepageRecentlyUsedItems.Add(new SecureBrowserItem(item));
            //}
            //HomepageRecentlyUsedModel.CreatePaging();

            //var mostUsedItemList = PBData.GetSecureItemsByItemType(DefaultProperties.SecurityItemType_PasswordVault, SecureItemOrderEnum.AccessCount);
            //HomepageMostUsedItems.Clear();

            //foreach (var item in mostUsedItemList)
            //{
            //    HomepageMostUsedItems.Add(new SecureBrowserItem(item));
            //}
            //HomepageMostUsedModel.CreatePaging();
        }
Example #17
0
        /// <summary>
        /// Excel -> 二进制文件
        /// </summary>
        /// <param name="inPath"></param>
        /// <param name="inFolderName"></param>
        /// <returns></returns>
        public bool Bin(string inPath, string inFolderName)
        {
            Assist.CheckFolderExist(inFolderName);

            PBData data = new PBData();

            Assist.GetObjPaths(".xls", inPath).ForEach(delegate(string path)
            {
                DataSet ds   = Assist.ExcelToData(path);
                DataTable dt = ds.Tables[0];

                string classname = Stringer.FirstLetterUp(dt.TableName);

                Type classType = Type.GetType(classname);

                FieldInfo fieldInfo = typeof(PBData).GetField(classname + "Dic");

                IDictionary fieldValue = fieldInfo.GetValue(data) as IDictionary;

                if (classType != null)
                {
                    for (int i = 4; i < dt.Rows.Count; i++)
                    {
                        string key = ""; // key

                        List <string> ls = new List <string>();
                        for (int x = 0; x < dt.Columns.Count; x++)
                        {
                            ls.Add(dt.Rows[i][x].ToString());

                            if (dt.Rows[2][x].ToString().Split('+')[2] == "1")// 当前值为Key值的一部分
                            {
                                key += dt.Rows[i][x].ToString() + "_";
                            }
                        }
                        key = key.Remove(key.Length - 1, 1);
                        IProtoBufable value = Activator.CreateInstance(classType) as IProtoBufable;// value
                        value.Set(ls);
                        fieldValue.Add(key, value);
                    }

                    fieldInfo.SetValue(data, fieldValue);
                }
            });

            #region SceneLayout 读取同级目录下的“Excel/SceneLayout/”内的所有 xml 文件,并将其数据写入 PBData

            Dictionary <string, XmlDocument> doc = Assist.GetXml(Assist.RootPath + "Excel/SceneLayout/");
            foreach (KeyValuePair <string, XmlDocument> item in doc)
            {
                SceneLayout sl  = new SceneLayout();
                XmlNodeList xcc = item.Value.SelectSingleNode("Config").ChildNodes;
                for (int i = 0; i < xcc.Count; i++)
                {
                    SceneLayoutItem sli = new SceneLayoutItem();

                    IProtoBufable xmlItemValue = new SceneLayoutItem() as IProtoBufable;// value
                    List <string> xls          = new List <string>();
                    for (int x = 0; x < xcc[i].Attributes.Count; x++)
                    {
                        xls.Add(xcc[i].Attributes[x].Value);
                    }
                    xmlItemValue.Set(xls);

                    sl.item.Add(xmlItemValue as SceneLayoutItem);
                }
                data.SceneLayoutDic.Add(item.Key, sl);
            }

            #endregion

            using (var file = System.IO.File.Create("PBData"))
            {
                try
                {
                    ProtoBuf.Serializer.Serialize(file, data);
                }
                catch (Exception e)
                {
                    MainWindow.Show(e.ToString());
                }
            }

            return(true);
        }
Example #18
0
 /// <summary>
 /// 获取经验
 /// </summary>
 public HeroExpInfo GetHeroExpInfo(string inArg0, PBData inArg1)
 {
     return inArg1.HeroExpInfoDic[this.key + "_" + inArg0];
 }
Example #19
0
        public static void ReadJson()
        {
            PBData data = Methods.ReadJson <PBData>("PBData");

            Console.WriteLine(data.Name + " " + data.Age + " " + data.IsBoy);
        }