Esempio n. 1
0
        /// <summary>
        /// Sync with cloud data
        /// </summary>
        /// <returns></returns>
        public async Task <NoteList> Sync()
        {
            await Task.Delay(700);

            var cloud = await Download();

            if (cloud == null || cloud.Notes == null || cloud.Notes.Count == 0)
            {
                return(dat);
            }

            foreach (var lnote in dat.Notes)
            {
                if (cloud.Contains(lnote))
                {
                    var cnote = cloud.Get(lnote);
                    foreach (var ckey in cnote.UniversalData.Keys)
                    {
                        var clist = cnote.UniversalData[ckey];
                        var llist = lnote.UniversalData.GetValueOrDefault(ckey, true, k => new List <NoteHistRecord>());
                        foreach (var ch in clist)
                        {
                            var lh = llist.Find(a => Math.Abs((a.DT - ch.DT).TotalSeconds) < 1);
                            if (lh == null)
                            {
                                llist.Add(ch);  // Add cloud only data to local storage
                            }
                            else
                            {
                                if (lh.Value.Equals(ch.Value) == false)
                                {
                                    llist.Add(ch);  // Fail safe 同じ時間なのに値が違うレコードはローカルに追加
                                }
                            }
                        }
                        llist.Sort((a, b) => a.DT.CompareTo(b.DT));
                    }
                }
            }

            // save cloud only data
            foreach (var cnote in cloud.Notes)
            {
                if (dat.Contains(cnote) == false)
                {
                    dat.Add(cnote);
                }
            }

            Save();
            await Upload();

            return(dat);
        }
Esempio n. 2
0
        private void Rename(object para)
        {
            Note note = para as Note;

            if (note == null)
            {
                return;
            }
            NewWindow newWindow = new NewWindow(this)
            {
                Owner = mainWindow
            };

            newWindow.ShowDialog();
            if (TitleInput == "")
            {
                return;
            }
            string oldPath = note.FilePath;
            string newName = TitleInput;

            if (dataService.RenameData(oldPath, newName))
            {
                NoteList.Remove(note);
                NoteList.Add(new Note(dataService.GetPath(newName)));
                SelectedIndex = NoteList.Count - 1;
                OnAddedNewNote();
            }
            TitleInput = "";
        }
Esempio n. 3
0
        //public CommonCommand RefreshToDoListCommand
        //{
        //    get
        //    {
        //        return new CommonCommand((o) =>
        //        {
        //            RefreshToDoList();
        //        });
        //    }
        //}
        public override void LoadInfo()
        {
            EpisodeList.Clear();
            TargetObject.EpisodeList.ForEach(v =>
            {
                EpisodeList.Add(new EpisodeViewModel()
                {
                    TargetObject = v
                });
            });
            SceneList.Clear();
            TargetObject.SceneList.ForEach(v =>
            {
                SceneList.Add(new SceneViewModel()
                {
                    TargetObject = v
                });
            });
            NoteList.Clear();
            TargetObject.NoteList.ForEach(v => NoteList.Add(new NoteViewModel()
            {
                TargetObject = v
            }));

            //RefreshToDoList();

            base.LoadInfo();
        }
Esempio n. 4
0
 public void LoadNoteFields()
 {
     NoteList.Clear();
     foreach (IAnnotationField item in PageNoteFieldSet.AnnotationFields)
     {
         NoteList.Add(new NodeViewModel(item, false));
     }
 }
Esempio n. 5
0
        public NodeViewModel AddNote()
        {
            IAnnotationField field = PageNoteFieldSet.CreateAnnotationField(GetNoteName(), AnnotationFieldType.Text);

            NodeViewModel node = new NodeViewModel(field);

            NoteList.Add(node);

            return(node);
        }
Esempio n. 6
0
 void LoadNoteList()
 {
     if (TargetObject == null)
     {
         return;
     }
     NoteList.Clear();
     foreach (var note in TargetObject.NoteList)
     {
         NoteList.Add(new NoteViewModel()
         {
             TargetObject = note
         });
     }
     CurrentNote = NoteList.FirstOrDefault();
 }
Esempio n. 7
0
        public void ShowSpecificTaskLog()
        {
            ActivityLog.Clear();
            List <Activity> SpecificDateActivityList = ModelsHelpers.GetSpecificDateActivityLog(LogDate);

            NoteList.Clear();
            List <Note> SpecificDateNote = ChangeMemoListToNoteList(MemoModel.GetSpecificDateMemo(LogDate));

            if (SelectedEachTaskId != null)
            {
                SpecificDateActivityList = SpecificDateActivityList.Where(activity => activity.EachTaskId == SelectedEachTaskId).ToList();
                SpecificDateNote         = SpecificDateNote.Where(note => note.EachTaskId == SelectedEachTaskId).ToList();
            }

            SpecificDateActivityList.ForEach(activity => ActivityLog.Add(activity));
            SpecificDateNote.ForEach(note => NoteList.Add(note));
        }
Esempio n. 8
0
        private void LoadNote(bool isLoad)
        {
            SearchText = "";
            NoteList.Clear();
            FilePaths.Clear();
            List <NoteModel> currentList = new List <NoteModel>();

            //便签存储路径
            string filePath = $"{AppDomain.CurrentDomain.BaseDirectory}Notes";

            if (!Directory.Exists(filePath))
            {
                Directory.CreateDirectory(filePath);
            }
            //获取文件夹内的json文件
            string[] files = Directory.GetFiles(filePath);

            //使用foreach赋值
            foreach (var file in files)
            {
                var       current = File.ReadAllText(file);
                NoteModel nm      = JsonConvert.DeserializeObject <NoteModel>(current);
                currentList.Add(nm);
                //NoteList.Add(nm);
                FilePaths.Add(nm.GuidId, file);
            }
            currentList.Sort((left, right) =>
            {
                if (Convert.ToDateTime(left.NoteDate) > Convert.ToDateTime(right.NoteDate))
                {
                    return(-1);
                }
                else
                {
                    return(1);
                }
            });

            for (int i = 0; i < currentList.Count; i++)
            {
                NoteList.Add(currentList[i]);
            }
            //NoteList = new ObservableCollection<NoteModel>(currentList);
        }
Esempio n. 9
0
        public void TestSimpleInjection()
        {
            //Arrange
            var dataStorage = new DataStorage();
            var noteList    = new NoteList(dataStorage);
            var noteText    = "myCustomNote";

            //Act
            noteList.Add(noteText);

            //Assert
            using (StreamReader reader = new StreamReader("db.txt"))
            {
                var all = reader.ReadToEnd();
                Assert.IsTrue(all.Contains(noteText));
            }

            File.Delete("db.txt");
        }
Esempio n. 10
0
 /// <summary>
 /// 获取数据
 /// </summary>
 public void GetDate()
 {
     try
     {
         List <SeatManage.ClassModel.AMS_Advertisement> modelList = SeatManage.Bll.AdvertisementOperation.GetAdList(null, SeatManage.EnumType.AdType.SchoolNotice);
         NoteList.Clear();
         foreach (SeatManage.ClassModel.AMS_Advertisement model in modelList)
         {
             SeatManage.ClassModel.SchoolNoteInfo view = SeatManage.ClassModel.SchoolNoteInfo.ToModel(model.AdContent);
             view.AdContent = model.AdContent;
             view.ID        = model.ID;
             NoteList.Add(view);
         }
     }
     catch (Exception ex)
     {
         ErrorMessage = ex.Message;
         SeatManage.SeatManageComm.WriteLog.Write("获取学校通知失败" + ex.Message);
     }
 }
Esempio n. 11
0
        public void TestInjectorWorks()
        {
            //Set injector
            Injector.Map <IDataStorage, DataStorage>();

            //Arrange
            var dataStorage = Injector.Get <IDataStorage>();
            var noteList    = new NoteList(dataStorage);
            var noteText    = "myCustomNote";

            //Act
            noteList.Add(noteText);

            //Assert
            using (StreamReader reader = new StreamReader("db.txt"))
            {
                var all = reader.ReadToEnd();
                Assert.IsTrue(all.Contains(noteText));
            }

            File.Delete("db.txt");
        }
Esempio n. 12
0
        public void ShowSpecificTaskLog()
        {
            try
            {
                ActivityLog.Clear();
                List <Activity> SpecificDateActivityList = ModelsHelpers.GetSpecificDateActivityLog(LogDate);
                NoteList.Clear();
                List <Note> SpecificDateNote = ChangeMemoListToNoteList(MemoModel.GetSpecificDateMemo(LogDate));

                if (SelectedEachTaskId != null)
                {
                    SpecificDateActivityList = SpecificDateActivityList.Where(activity => activity.EachTaskId == SelectedEachTaskId).ToList();
                    SpecificDateNote         = SpecificDateNote.Where(note => note.EachTaskId == SelectedEachTaskId).ToList();
                }

                SpecificDateActivityList.ForEach(activity => ActivityLog.Add(activity));
                SpecificDateNote.ForEach(note => NoteList.Add(note));
            }
            catch
            {
                CommonViewModel.NotifySystemMessage(GetLangMessage.GetMessage("Exception"));
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Fetches tuning and scale intervals from the data file.
        /// Creates notes and fills the note list.
        /// </summary>
        private void CreateNotes()
        {
            // Passing selected tuning from database to array
            string[] tuning = (from node in Doc.Descendants("Tunings").Elements("Tuning")
                               where node.Element("Name").Value == Tuning && node.Attribute("strings").Value == Strings.ToString()
                               select node.Element("Interval").Value).Single().Split(' ');

            string[] scale = (from node in Doc.Descendants("Scales").Elements("Scale")
                              where node.Element("Name").Value == Scale
                              select node.Element("Interval").Value).Single().Split(' ');


            // Creating notes and adding them to the grid
            for (int numString = 0; numString < Strings; numString++)
            {
                List <FretNote> tempNoteList = new List <FretNote>();
                int             index        = int.Parse(tuning[numString]); // Getting individual string tunning

                for (int numFret = 0; numFret <= Frets; numFret++)
                {
                    // Calculating note order based on tuning and root note
                    IntLimited key = new IntLimited(numFret, 0, 12);
                    key.Value = key + index;

                    IntLimited a = new IntLimited(key.Value - Root, 0, 12);

                    // Checking if note fits scale
                    bool IsActive = scale.Contains(a.Value.ToString()) ? true : false;

                    // Creating the note
                    FretNote note = new FretNote(key.Value, Size * 0.8, IsActive, Root, new Point(numFret, numString), NoteGrid);
                    tempNoteList.Add(note);
                }

                NoteList.Add(tempNoteList); // Generating list of notes for future reference
            }
        }
Esempio n. 14
0
        private void New(object parameter)
        {
            TitleInput = "";
            NewWindow newWindow = new NewWindow(this)
            {
                Owner = mainWindow
            };

            newWindow.ShowDialog();
            if (TitleInput == "")
            {
                return;
            }
            Note newNote = dataService.AddNewData(TitleInput);

            if (newNote != null)
            {
                NoteList.Add(newNote);
                SelectedIndex = NoteList.Count - 1;
                OnAddedNewNote();
            }
            ClearSearchResult();
            TitleInput = "";
        }
Esempio n. 15
0
        public void ShorOtherDateLog()
        {
            TaskListData.Clear();

            List <EachTask> specificTaskList = GetSpecificDateEachTaskList(LogDate);

            specificTaskList.ForEach(eachTask => TaskListData.Add(eachTask));

            ActivityLog.Clear();
            ModelsHelpers.GetSpecificDateActivityLog(LogDate).ForEach(activity => ActivityLog.Add(activity));

            NoteList.Clear();
            ChangeMemoListToNoteList(MemoModel.GetSpecificDateMemo(LogDate)).ForEach(memo => NoteList.Add(memo));
        }
Esempio n. 16
0
        public void ShorOtherDateLog()
        {
            try
            {
                TaskListData.Clear();

                List <EachTask> specificTaskList = GetSpecificDateEachTaskList(LogDate);
                specificTaskList.ForEach(eachTask => TaskListData.Add(eachTask));

                ActivityLog.Clear();
                ModelsHelpers.GetSpecificDateActivityLog(LogDate).ForEach(activity => ActivityLog.Add(activity));

                NoteList.Clear();
                ChangeMemoListToNoteList(MemoModel.GetSpecificDateMemo(LogDate)).ForEach(memo => NoteList.Add(memo));
            }
            catch
            {
                CommonViewModel.NotifySystemMessage(GetLangMessage.GetMessage("Exception"));
            }
        }