Example #1
0
 // Use this for initialization
 void Start()
 {
     userDb            = new UserDb();
     historyDb         = new HistoryDb();
     lastChangeCounter = changeCounter;
     getData();
 }
Example #2
0
 //Закрывает историю, если надо то копирует новый файл
 public void CloseHistory()
 {
     try
     {
         if (SubHistory != null)
         {
             SubHistory.Dispose();
         }
         if (History != null)
         {
             History.Dispose();
         }
         if (SuperHistory != null)
         {
             SuperHistory.Dispose();
         }
         if (ErrorsRec != null)
         {
             ErrorsRec.Dispose();
         }
         if (HistoryDb != null)
         {
             HistoryDb.Dispose();
         }
         SubHistory   = null;
         History      = null;
         SuperHistory = null;
         ErrorsRec    = null;
         HistoryDb    = null;
     }
     catch { }
 }
Example #3
0
    //ScoreManager scoreManager;

    // Use this for initialization
    void Start()
    {
        historyDb = new HistoryDb();
        userDb    = new UserDb();
        //scoreManager = GameObject.FindObjectOfType<ScoreManager>();
        lastChangeCounter = changeCounter;
        getData();
    }
Example #4
0
        public static WatchedVM GetVM(WatchedSearchResult searchResult)
        {
            var vm = new WatchedVM(searchResult ?? throw new ArgumentNullException(nameof(searchResult)));

            HistoryDb.Add(new HistoryRecord
            {
                Type  = HistoryRecordType.Watched,
                Uri   = vm.SearchResult.SearchUri,
                Title = vm.Keyword,
            });
            Cache[vm.SearchQuery] = vm;
            return(vm);
        }
Example #5
0
        public static FavoritesVM GetVM(FavoritesSearchResult searchResult)
        {
            var vm    = new FavoritesVM(searchResult ?? throw new ArgumentNullException(nameof(searchResult)));
            var query = vm.SearchQuery;

            HistoryDb.Add(new HistoryRecord
            {
                Type  = HistoryRecordType.Favorites,
                Uri   = vm.SearchResult.SearchUri,
                Title = vm.Keyword,
            });
            Cache[query] = vm;
            return(vm);
        }
Example #6
0
 //Сохранение спписка ошибок
 public void CloseErrorsList()
 {
     if (GridErrorsCount != GridErrors.Count)
     {
         ErrorsRec.Dispose();
         HistoryDb.Execute("DELETE * FROM ErrorsList");
         ErrorsRec = new RecDao(HistoryDb, "SELECT * FROM ErrorsList ORDER BY Id");
         foreach (var ge in GridErrors)
         {
             ge.ToRecordset(ErrorsRec);
         }
         ErrorsRec.MoveLast();
     }
     State = State.Stopped;
 }
        /**
         * Save message to history in database
         */
        public static void Add(Message message, Room room)
        {
            DatabaseModels.Message databaseMessage = new DatabaseModels.Message();
            databaseMessage.Room      = room.GetName();
            databaseMessage.Content   = message.Content.ToString();
            databaseMessage.Timestamp = message.Timestamp;
            databaseMessage.Username  = message.Username;
            databaseMessage.Id        = Guid.NewGuid();

            using (HistoryDb context = new HistoryDb())
            {
                context.Messages.Add(databaseMessage);
                context.SaveChanges();
            }
        }
Example #8
0
    private void ShowResult()
    {
        UserDb     userDb    = new UserDb();
        HistoryDb  historyDb = new HistoryDb();
        UserEntity user      = userDb.getActiveUser();

        if (user != null || user._id != "")
        {
            historyDb.addData(new HistoryEntity(user._id, typeSoal, "" + score));
        }
        userDb.close();
        historyDb.close();
        scorePanel.SetActive(true);
        scoreText.text = "" + score;
    }
Example #9
0
        public static SearchVM GetVM(CategorySearchResult searchResult)
        {
            var vm = new SearchVM(searchResult ?? throw new ArgumentNullException(nameof(searchResult)));

            using (var db = new HistoryDb())
            {
                db.AddHistory(new HistoryRecord
                {
                    Type  = HistoryRecordType.Search,
                    Uri   = vm.SearchResult.SearchUri,
                    Title = vm.Keyword,
                });
            }
            Cache[vm.SearchQuery] = vm;
            return(vm);
        }
 /**
  * Returns list of last 10 (max) messages in chatroom room
  */
 public static List <Message> GetLastTenMessagesInRoom(Room room)
 {
     using (HistoryDb context = new HistoryDb())
     {
         String roomName = room.GetName();
         return(context.Messages.Where(x => x.Room == roomName)
                .OrderByDescending(x => x.Timestamp)
                .Take(10)
                .OrderBy(x => x.Timestamp)
                .Select(x => new Message()
         {
             Content = x.Content,
             Timestamp = x.Timestamp,
             Username = x.Username,
             Type = Message.MessageType.normal
         }).ToList());
     }
 }
Example #11
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            base.OnCreateView(inflater, container, savedInstanceState);

            var view = inflater.Inflate(Resource.Layout.CostOverview, container, false);


            //Setup Actionbar
            _activity = (AppCompatActivity)Activity;
            _activity.SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            _activity.SupportActionBar.SetHomeButtonEnabled(true);
            _activity.SupportActionBar.Title = GetString(Resource.String.CostOverviewDialog);
            _activity.SupportActionBar.SetDisplayUseLogoEnabled(false);

            //Setup PayButton
            _pay        = view.FindViewById <TextView>(Resource.Id.textOptionPay);
            _pay.Text   = GetString(Resource.String.Pay);
            _pay.Click += _pay_Click;

            //Load DB
            _historyDb = new HistoryDb();
            _historyDb.CreateDataBase();

            //Get Account Balance
            _currentSum      = view.FindViewById <TextView>(Resource.Id.textCurrentSum);
            _currentSum.Text = GetString(Resource.String.CurrentSum) + _historyDb.GetBalance(MainActivity.UserName);

            //Get Name and Cost
            GetDatabaseEntires();

            //Setup ListViews With Adapter
            _adapterL          = new MyArrayAdapter(Context, _activity, _coffeeNames, _time, _cost, _isPayed);
            _listViewL         = view.FindViewById <ListView>(Resource.Id.listViewL);
            _listViewL.Adapter = _adapterL;

            return(view);
        }
Example #12
0
        public static async Task RefreshJumplistAsync()
        {
            if (!JumpList.IsSupported())
            {
                return;
            }
            var jl = await JumpList.LoadCurrentAsync();

            foreach (var item in jl.Items)
            {
                if (item.RemovedByUser && item.GroupName == RECENT_GROUP_NAME)
                {
                    HistoryDb.Remove(new Uri(item.Arguments));
                }
            }
            jl.Items.Clear();
            using (var db = new HistoryDb())
            {
                var          records     = db.HistorySet.OrderByDescending(r => r.TimeStamp).Take(50).ToArray();
                var          added       = new HashSet <HistoryRecord>(HistoryRecordComparer.Instance);
                var          dtformatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("shortdate shorttime");
                const string sep         = " - ";
                foreach (var record in records)
                {
                    if (!added.Add(record))
                    {
                        continue;
                    }
                    var item = JumpListItem.CreateWithArguments(record.Uri.ToString(), record.ToDisplayString());
                    item.GroupName   = RECENT_GROUP_NAME;
                    item.Logo        = new Uri($"ms-appx:///Assets/JumpList/{record.Type.ToString()}.png");
                    item.Description = item.DisplayName + sep + dtformatter.Format(record.Time);
                    jl.Items.Add(item);
                }
            }
            await jl.SaveAsync();
        }
Example #13
0
        public void TestApplyChangesetNewNodesInNewWay()
        {
            var historyDb = new HistoryDb(new MemoryHistoryDb());

            historyDb.Add(new OsmGeo[] {
                new Node()
                {
                    Id      = 1,
                    Version = 1
                },
                new Node()
                {
                    Id      = 2,
                    Version = 1
                }
            });

            var osmChange = new OsmChange();

            osmChange.Create = new OsmGeo[]
            {
                new Node()
                {
                    Id      = -1,
                    Version = 1
                },
                new Node()
                {
                    Id      = -2,
                    Version = 1
                },
                new Way()
                {
                    Id      = -1,
                    Version = 1,
                    Nodes   = new long[]
                    {
                        1, -1, -2, 2
                    }
                }
            };

            var results = historyDb.ApplyChangeset(1, osmChange);

            Assert.IsNotNull(results);
            Assert.IsNotNull(results.Result);
            Assert.IsNotNull(results.Result.Results);
            Assert.AreEqual(3, results.Result.Results.Length);
            var result = results.Result.Results[0];

            Assert.IsInstanceOf <NodeResult>(result);
            Assert.AreEqual(3, result.NewId);
            Assert.AreEqual(-1, result.OldId);
            Assert.AreEqual(1, result.NewVersion);
            result = results.Result.Results[1];
            Assert.IsInstanceOf <NodeResult>(result);
            Assert.AreEqual(4, result.NewId);
            Assert.AreEqual(-2, result.OldId);
            Assert.AreEqual(1, result.NewVersion);
            result = results.Result.Results[2];
            Assert.IsInstanceOf <WayResult>(result);
            Assert.AreEqual(1, result.NewId);
            Assert.AreEqual(-1, result.OldId);
            Assert.AreEqual(1, result.NewVersion);

            var way = historyDb.Get(OsmGeoType.Way, 1) as Way;

            Assert.IsNotNull(way);
            Assert.IsNotNull(way.Nodes);
            Assert.AreEqual(4, way.Nodes.Length);
            Assert.AreEqual(1, way.Nodes[0]);
            Assert.AreEqual(3, way.Nodes[1]);
            Assert.AreEqual(4, way.Nodes[2]);
            Assert.AreEqual(2, way.Nodes[3]);
        }