示例#1
0
        public async override Task ApplicationInitializedAsync()
        {
            await base.ApplicationInitializedAsync();

            Framework.Data.InternalStorageDestination curDatabase = ActiveStorageDestination;
            if (curDatabase != null)
            {
                _recentDatabases.Add(curDatabase);
            }
            loadMostRecentDatabases();
            SetMostRecentDatabasesMenu();
        }
示例#2
0
        private void loadMostRecentDatabases()
        {
            try
            {
                _mostRecentFile = System.IO.Path.Combine(Core.PluginDataPath, string.Format("{0}.xml", this.GetType().ToString().Replace(".", "")));

                if (System.IO.File.Exists(_mostRecentFile))
                {
                    Framework.Data.InternalStorageDestination curDatabase = null;
                    if (_recentDatabases.Count > 0)
                    {
                        curDatabase = _recentDatabases[0];
                    }

                    XmlDocument doc = new XmlDocument();
                    doc.Load(_mostRecentFile);
                    XmlElement root = doc.DocumentElement;

                    XmlNodeList bmNodes = root.SelectNodes("recent");
                    if (bmNodes != null)
                    {
                        foreach (XmlNode n in bmNodes)
                        {
                            Framework.Data.InternalStorageDestination bm = new Framework.Data.InternalStorageDestination();
                            bm.Name       = n.SelectSingleNode("Name").InnerText;
                            bm.PluginType = n.SelectSingleNode("PluginType").InnerText;
                            XmlNodeList cNodes = n.SelectSingleNode("infos").SelectNodes("info");
                            if (cNodes != null)
                            {
                                bm.StorageInfo = new string[cNodes.Count];
                                for (int i = 0; i < cNodes.Count; i++)
                                {
                                    bm.StorageInfo[i] = cNodes[i].InnerText;
                                }
                            }
                            if (curDatabase == null || !curDatabase.SameDestination(bm))
                            {
                                _recentDatabases.Add(bm);
                            }
                        }
                    }
                }
            }
            catch
            {
            }
        }
示例#3
0
        public async Task <bool> SetStorageDestination(Framework.Data.InternalStorageDestination dst)
        {
            bool result = false;

            if (CheckBackgroundTaskNotRunning())
            {
                if (dst != null)
                {
                    if (await checkDataSaved())
                    {
                        if (PrepareSetStorageDestination(dst))
                        {
                            await ExecuteInBackground(new Action(this.OpenMethod));

                            result = _actionResult;
                            saveMostRecentDatabases();
                        }
                    }
                }
            }
            return(result);
        }
示例#4
0
        private void loadMostRecentDatabases()
        {
            try
            {
                _mostRecentFile = System.IO.Path.Combine(Core.PluginDataPath, string.Format("{0}.xml",this.GetType().ToString().Replace(".","")));

                if (System.IO.File.Exists(_mostRecentFile))
                {
                    Framework.Data.InternalStorageDestination curDatabase = null;
                    if (_recentDatabases.Count > 0)
                    {
                        curDatabase = _recentDatabases[0];
                    }

                    XmlDocument doc = new XmlDocument();
                    doc.Load(_mostRecentFile);
                    XmlElement root = doc.DocumentElement;

                    XmlNodeList bmNodes = root.SelectNodes("recent");
                    if (bmNodes != null)
                    {
                        foreach (XmlNode n in bmNodes)
                        {
                            Framework.Data.InternalStorageDestination bm = new Framework.Data.InternalStorageDestination();
                            bm.Name = n.SelectSingleNode("Name").InnerText;
                            bm.PluginType = n.SelectSingleNode("PluginType").InnerText;
                            XmlNodeList cNodes = n.SelectSingleNode("infos").SelectNodes("info");
                            if (cNodes != null)
                            {
                                bm.StorageInfo = new string[cNodes.Count];
                                for (int i = 0; i < cNodes.Count; i++)
                                {
                                    bm.StorageInfo[i] = cNodes[i].InnerText;
                                }
                            }
                            if (curDatabase == null || !curDatabase.SameDestination(bm))
                            {
                                _recentDatabases.Add(bm);
                            }
                        }
                    }
                }

            }
            catch
            {
            }
        }
示例#5
0
 protected virtual bool PrepareSetStorageDestination(Framework.Data.InternalStorageDestination dst)
 {
     return(false);
 }
示例#6
0
        private void saveMostRecentDatabases()
        {
            //set current to number 1
            Framework.Data.InternalStorageDestination curDatabase = ActiveStorageDestination;
            if (curDatabase != null)
            {
                _recentDatabases.Insert(0, curDatabase);

                //filter out current in list after 1
                int i = 1;
                while (i < _recentDatabases.Count)
                {
                    if (curDatabase.SameDestination(_recentDatabases[i]))
                    {
                        _recentDatabases.RemoveAt(i);
                    }
                    else
                    {
                        i++;
                    }
                }

                //max 9
                while (_recentDatabases.Count > 9)
                {
                    _recentDatabases.RemoveAt(_recentDatabases.Count - 1);
                }
            }

            //save
            try
            {
                XmlDocument doc  = new XmlDocument();
                XmlElement  root = doc.CreateElement("mostrecent");
                doc.AppendChild(root);
                foreach (Framework.Data.InternalStorageDestination bmi in _recentDatabases)
                {
                    XmlElement bm = doc.CreateElement("recent");
                    root.AppendChild(bm);

                    XmlElement el  = doc.CreateElement("Name");
                    XmlText    txt = doc.CreateTextNode(bmi.Name);
                    el.AppendChild(txt);
                    bm.AppendChild(el);

                    el  = doc.CreateElement("PluginType");
                    txt = doc.CreateTextNode(bmi.PluginType);
                    el.AppendChild(txt);
                    bm.AppendChild(el);

                    el = doc.CreateElement("infos");
                    bm.AppendChild(el);

                    if (bmi.StorageInfo != null)
                    {
                        foreach (string c in bmi.StorageInfo)
                        {
                            XmlElement cel = doc.CreateElement("info");
                            txt = doc.CreateTextNode(c);
                            cel.AppendChild(txt);
                            el.AppendChild(cel);
                        }
                    }
                }
                doc.Save(_mostRecentFile);
            }
            catch
            {
            }

            //rebuild menu according new order
            SetMostRecentDatabasesMenu();
        }