Exemple #1
0
 private void CreateCol()
 {
     _ankiCol = _ankiPackageDbContext.Cols.FirstOrDefault();
     if (_ankiCol == null)
     {
         _ankiCol = _ankiEntityBuilder.BuildAnkiCol();
         _ankiPackageDbContext.Cols.Add(_ankiCol);
     }
     else
     {
         _ankiCol.DeserializeProperties();
     }
 }
        public Dictionary <string, string> BuildFieldsPairs(AnkiNote note, AnkiCol ankiCol)
        {
            var result = new Dictionary <string, string>();

            var fields = ankiCol.AnkiModel.Model.Flds.Select(f => f.Name).ToList();
            var values = note.Fields.Split(new string[1] {
                FIELD_DELIMETER
            }, StringSplitOptions.None);

            for (var i = 0; i < fields.Count(); i++)
            {
                result.Add(fields[i], values[i]);
            }
            return(result);
        }
        public AnkiCard BuildAnkiCard(Card card, AnkiCol ankiCol)
        {
            var fields = _ankiFieldsBuilder.BuildFieldsString(card, ankiCol.AnkiModel.Model.Flds);
            var epoch  = new DateTimeOffset().ToUnixTimeSeconds();

            var ankiNote = new AnkiNote
            {
                Guid     = Guid.NewGuid().ToString(),
                ModleId  = long.Parse(ankiCol.AnkiModel.Model.Id),
                Modified = epoch,
                Usn      = -1,
                Tags     = string.Empty,
                Fields   = fields,
                Sfld     = 1,
                Csum     = 896145707,
                Flags    = 0,
                Data     = string.Empty,
            };

            return(new AnkiCard
            {
                Note = ankiNote,
                DeckId = long.Parse(ankiCol.AnkiDeckInfo.Deck.Id),
                Ordinal = 0,
                ModifiedTime = epoch,
                Usn = -1,
                Type = 0,
                Queue = 0,
                Due = 1,
                Interval = 0,
                Factor = 2500,
                NumberOfReviews = 0,
                Lapses = 0,
                Left = 1001,
                Odue = 0,
                Odid = 0,
                Flags = 0,
                Data = string.Empty,
            });
        }