Beispiel #1
0
        public static async Task<List<ServerModel>> GetData(ClientModel value)
        {
            if (value == null) return null;
            List<ServerModel> data = new List<ServerModel>();

            var conn = LocalDatabaseService.GetMainConnection();
            data = conn.Table<ServerModel>().Where(c => c.parentid == value.serverModel._id).ToList();
            conn.Dispose();
            if (data.Count != 0)
                return data;

            if (value.serverModel.hassubtree)
            {
                data = await DownloadData(value.serverModel);
                value.ChildrenSaved = 1;
            }
            return data;
        }
Beispiel #2
0
        public MainPageViewModel()
        {
            if (IsInDesignMode)
            {
                ServerModel s = new ServerModel()
                {
                    _id = 0,
                    Title = "Windows",
                    Href = "https://msdn.microsoft.com/zh-cn/library/windows/apps/hh703192.aspx",
                    ToolTip = "Windows",
                    hassubtree = true,
                    level = 0
                };
                CurrModel = new ClientModel(s, null);
                ObservableCollection<ClientModel> subs = new ObservableCollection<ClientModel>();
                subs.Add(new ClientModel(new ServerModel() { Title = "热门" }, CurrModel));
                subs.Add(new ClientModel(new ServerModel() { Title = "设计" }, CurrModel));
                subs.Add(new ClientModel(new ServerModel() { Title = "开发" }, CurrModel));
                subs.Add(new ClientModel(new ServerModel() { Title = "发布" }, CurrModel));
                CurrModel.Subs = subs;

            }

        }
Beispiel #3
0
 public ClientModel(Model.DataJson.ServerModel server, ClientModel parent)
 {
     OffsetX = parent == null ? 10 : parent.OffsetX + 15;
     Parent = parent;
     serverModel = server;
     this.Title = server.Title;
     HaveChild = server.hassubtree;
     ChildrenSaved = serverModel.subtreesaved ? 1 : 0.3;
     Subs = new ObservableCollection<ClientModel>();
 }
Beispiel #4
0
 public ClientModel(ClientModel parent)
 {
     Subs = new ObservableCollection<ClientModel>();
 }
Beispiel #5
0
 public async void GoSugges(ServerModel sv)
 {
     ClientModel cm = new ClientModel(sv, null);
     if (cm.Subs.Count == 0 && cm.HaveChild)
     {
         List<ServerModel> sData = await Manager.DataManager.GetData(cm);
         sData.ForEach(c => cm.Subs.Add(new ClientModel(c, cm)));
     }
     if (cmBackUp == null)
         cmBackUp = CurrModel;
     CurrModel = cm;
 }
Beispiel #6
0
 private void OnSelectedClientModelChanged(ClientModel value)
 {
     if (value != null && value.serverModel != null)
     {
         //string path = await Manager.DataManager.DownloadPage(value);
         //WebViewUrl = new Uri(path, UriKind.RelativeOrAbsolute);
         WebViewUrl = new Uri(value.serverModel.Href, UriKind.Absolute);
         IsProgressActive = true;
         UrlString = value.serverModel.Href;
     }
 }
Beispiel #7
0
 internal static bool UpdateObj(ClientModel tempCM)
 {
     var conn = LocalDatabaseService.GetMainConnection();
     int res = conn.Update(tempCM.serverModel);
     conn.Dispose();
     return res == 1 ? true : false;
 }
Beispiel #8
0
 public static async Task<string> DownloadPage(ClientModel value)
 {
     string path = value.GetPath();
     string absolutePath = "ms-appdata:///local/" + path.Replace("\\", "/");
     if (!await StorageHelper.CheckFileExist(path))
     {
         WebRequestAgent request = new WebRequestAgent();
         var res = await request.DownloadAsync(value.serverModel.Href, path);
         if (res.Success)
         {
             return absolutePath;
         }
     }
     else
     {
         return absolutePath;
     }
     return null;
 }