Esempio n. 1
0
 private void UpdateLastSelection(string categoryName, string databaseName, List<string> tableNames, string timeRange, string viewModel)
 {
     Selection selection = null;
     if (setting.Contains(SelectionKey))
     {
         selection = setting[SelectionKey] as Selection;
     }
     else
     {
         selection = new Selection();
     }
     selection.CategoryName = categoryName;
     selection.DatabaseName = databaseName;
     selection.TableNames = tableNames;
     selection.TimeRange = timeRange;
     selection.ViewModel = viewModel;
     setting[SelectionKey] = selection;
 }
Esempio n. 2
0
        private Action CheckUrl(string url)
        {
            var qs = HtmlPage.Document.DocumentUri.Query;
            string d = "";
            if (qs.Contains("url"))
            {
                d = qs.Substring(5);
                UrlAddress.Text = d;
            }
            else if (url != null)
                d = url;
            if (d == "") return null;

            var serializer = new SharpSerializer(true);

            UrlData ud = null;

            try
            {
                using (MemoryStream ms = new MemoryStream(Convert.FromBase64String(d)))
                {
                    ud = serializer.Deserialize(ms) as UrlData;
                }
            }
            catch
            {
                MessageBox.Show("从url获取数据失败,可能是因为数据太多,请尝试使用'直接粘贴快捷访问标识来查询数据'功能,把url查询字符串复制在文本框中!");
            }

            if (ud != null)
            {
                RemberLastSelection.IsChecked = autoRefreshTime = false;
                AutoRefresh.IsChecked = false;

                if (ud.Type == "List" || ud.Type == "Stat" || ud.Type == "Group")
                {
                    var sc = ud.Condition as SearchCondition;

                    if (sc != null)
                    {
                        selectionFromUrl = new Selection
                        {
                            BeginTime = sc.BeginTime,
                            EndTime = sc.EndTime,
                            CategoryName = sc.DatabasePrefix.Substring(0, sc.DatabasePrefix.IndexOf("__")),
                            DatabaseName = sc.DatabasePrefix.Substring(sc.DatabasePrefix.IndexOf("__") + 2),
                            TableNames = sc.TableNames,
                            ViewModel = ud.Type,
                        };

                        SetFilters(sc.Filters);
                        SetTime(sc.BeginTime, sc.EndTime);

                        if (ud.Type == "Stat")
                            return () =>
                        {
                            ShowStatView(sc, selectionFromUrl.CategoryName, selectionFromUrl.DatabaseName);
                          
                        };
                        if (ud.Type == "List")
                            return () =>
                            {
                                ShowListView(sc, selectionFromUrl.CategoryName, selectionFromUrl.DatabaseName);
                            };
                        if (ud.Type == "Group")
                            return () =>
                            {
                                ShowGroupView(sc, selectionFromUrl.CategoryName, selectionFromUrl.DatabaseName);
                            };
                    }
                }
                else if (ud.Type == "State")
                {
                    var sc = ud.Condition as StateCondition;
                    if (sc != null)
                    {
                        selectionFromUrl = new Selection
                        {
                            CategoryName = sc.DatabasePrefix.Substring(0, sc.DatabasePrefix.IndexOf("__")),
                            DatabaseName = sc.DatabasePrefix.Substring(sc.DatabasePrefix.IndexOf("__") + 2),
                            TableNames = new List<string> { sc.TableName },
                            ViewModel = ud.Type,
                        };

                        return () =>
                        {
                            ShowStateView(sc, selectionFromUrl.CategoryName, selectionFromUrl.DatabaseName);
                        };
                    }
                }
                else if (ud.Type == "Detail")
                {
                    var sc = ud.Condition as DetailCondition;
                    if (sc != null)
                    {
                        selectionFromUrl = new Selection
                        {
                            CategoryName = sc.DatabasePrefix.Substring(0, sc.DatabasePrefix.IndexOf("__")),
                            DatabaseName = sc.DatabasePrefix.Substring(sc.DatabasePrefix.IndexOf("__") + 2),
                            TableNames = new List<string> { sc.TableName },
                            ViewModel = ud.Type,
                        };

                        return () =>
                        {
                            ShowDetailView(sc, selectionFromUrl.CategoryName, selectionFromUrl.DatabaseName);
                        };
                    }
                }
            }

            return null;
        }