Esempio n. 1
0
        public void WhenCallingChangeNote_TheTextIsUpdated()
        {
            var note = new DiaryNote(Guid.NewGuid(), "A super note");

            note.ChangeText("A great note");

            Assert.Equal("A great note", note.Text);
        }
Esempio n. 2
0
 public void Intialize(DiaryNote owner, string filepath, LogTree logTree, string text)
 {
     ownerNote_ = owner;
     name       = Path.GetFileName(filepath);
     filepath_  = filepath;
     logTree_   = logTree;
     GetComponentInChildren <Text>().text = text;
     graphic_ = GetComponent <Button>().targetGraphic;
     if (logTree_ == null)
     {
         graphic_.color = ColorManager.MakeAlpha(graphic_.color, 0.6f);
     }
 }
Esempio n. 3
0
        public async Task <ActionResult> DiaryNoteQueue([FromBody] DiaryNote diaryNote)
        {
            var eventMsg = _mapper.Map <SaveDiaryNoteEvent>(diaryNote);

            eventMsg.RequestID = Guid.NewGuid();

            try
            {
                _eventBus.PublishSaveDiaryNoteEvent(EventBusConsts.DiaryNoteQueue, eventMsg);
            }
            catch (Exception)
            {
            }

            return(Accepted());
        }
Esempio n. 4
0
        private void Create()
        {
            var note = new DiaryNote();

            Console.WriteLine("Input date");
            note.Date = DateTime.Parse(Console.ReadLine());

            Console.WriteLine("Input pressure");
            note.Pressure = int.Parse(Console.ReadLine());

            Console.WriteLine("Input cloudness");
            note.Cloudness = (CloudnessEnum)Enum.Parse(typeof(CloudnessEnum), Console.ReadLine());

            Console.WriteLine("Input wind direction");
            note.WindDirection = Console.ReadLine();

            _client.ProcessRequest("/api/diarynote/", HttpMethod.Post, JsonSerializer.Serialize(note));
        }
Esempio n. 5
0
    public void OpenDiary(bool isActive = true)
    {
        // ノートを開いていなければできない
        if (MainTabGroup.Count == 0)
        {
            return;
        }

        DiaryNote diaryNote = MainTabGroup.ExistDiaryNote;

        if (diaryNote == null)
        {
            TabButton tab = Instantiate(TabButtonPrefab.gameObject, TabParent.transform).GetComponent <TabButton>();
            diaryNote = Instantiate(DiaryNotePrefab.gameObject, NoteParent.transform).GetComponent <DiaryNote>();

            MainTabGroup.OnTabCreated(tab);

            diaryNote.LoadDiary(tab);
        }
        diaryNote.IsActive = isActive;

        FileMenu.Close();
    }
Esempio n. 6
0
        public async Task <ActionResult <IEnumerable <DiaryNote> > > Create([FromBody] DiaryNote diaryNote)
        {
            await _repository.Create(diaryNote);

            return(Ok());
        }
Esempio n. 7
0
 public ActionResult Post(DiaryNote note)
 {
     _repository.Create(note);
     return(Ok(note));
 }
Esempio n. 8
0
 public ActionResult Put(DiaryNote note)
 {
     _repository.Update(note);
     return(Ok(note));
 }
Esempio n. 9
0
        public void WhenPassingTextThroughCtor_TheTextIsReflected()
        {
            var note = new DiaryNote(Guid.NewGuid(), "A super note");

            Assert.Equal("A super note", note.Text);
        }
Esempio n. 10
0
        private void AssignNote(IList <Deal> deals, UnitOfWork unit)
        {
            string code = deals.First().Code;

            DiaryNote note = null;

            note = unit.DiaryNoteRepository.Query <DiaryNote>(n => n.Code == code && n.Close == null, new string[] { "NotePositions.Deal" }).SingleOrDefault();

            foreach (Deal deal in deals)
            {
                if (note == null)
                {
                    note = new DiaryNote()
                    {
                        Code = code
                    };
                    unit.DiaryNoteRepository.Create(note);
                }

                if (note.Open == null)
                {
                    note.Open = deal.DateTime;

                    note.NoteType = deal.OrderOperation == OrderOperationEnum.Buy ? NoteType.Long : NoteType.Short;
                }

                int posCount = deal.Count;

                note.NotePositions.Add(new NotePosition()
                {
                    Deal  = deal,
                    Count = posCount
                });

                //размер позиции
                note.Count = note.NoteType == NoteType.Long ? note.NotePositions.Where(p => p.Deal.OrderOperation == OrderOperationEnum.Buy).Sum(p => p.Count) : note.NotePositions.Where(p => p.Deal.OrderOperation == OrderOperationEnum.Sell).Sum(p => p.Count);

                int overFlow = note.NoteType == NoteType.Long ? note.NotePositions.Where(p => p.Deal.OrderOperation == OrderOperationEnum.Sell).Sum(p => p.Count) - note.Count : note.NotePositions.Where(p => p.Deal.OrderOperation == OrderOperationEnum.Buy).Sum(p => p.Count) - note.Count;

                //переполнение
                if (overFlow > 0)
                {
                    note.NotePositions.Last().Count -= overFlow;
                }

                if (note.NotePositions.Where(p => p.Deal.OrderOperation == OrderOperationEnum.Buy).Sum(p => p.Count) == note.NotePositions.Where(p => p.Deal.OrderOperation == OrderOperationEnum.Sell).Sum(p => p.Count))
                {
                    note.Close = deal.DateTime;

                    decimal openPrice = note.NoteType == NoteType.Long ? note.NotePositions.Where(p => p.Deal.OrderOperation == OrderOperationEnum.Buy).Sum(p => p.Deal.Price * p.Count) / note.Count : note.NotePositions.Where(p => p.Deal.OrderOperation == OrderOperationEnum.Sell).Sum(p => p.Deal.Price * p.Count) / note.Count;

                    decimal closePrice = note.NoteType == NoteType.Long ? note.NotePositions.Where(p => p.Deal.OrderOperation == OrderOperationEnum.Sell).Sum(p => p.Deal.Price * p.Count) / note.Count : note.NotePositions.Where(p => p.Deal.OrderOperation == OrderOperationEnum.Buy).Sum(p => p.Deal.Price * p.Count) / note.Count;

                    note.OpenPrice  = openPrice;
                    note.ClosePrice = closePrice;

                    int lotSize = unit.SecurityRepository.Query <Security>(s => s.Code == code, null).Single().LotSize;

                    note.OpenValue  = note.NoteType == NoteType.Long ? note.NotePositions.Where(p => p.Deal.OrderOperation == OrderOperationEnum.Buy).Sum(p => p.Deal.Price * p.Count * lotSize) : note.NotePositions.Where(p => p.Deal.OrderOperation == OrderOperationEnum.Sell).Sum(p => p.Deal.Price * p.Count * lotSize);
                    note.CloseValue = note.NoteType == NoteType.Long ? note.NotePositions.Where(p => p.Deal.OrderOperation == OrderOperationEnum.Sell).Sum(p => p.Deal.Price * p.Count * lotSize) : note.NotePositions.Where(p => p.Deal.OrderOperation == OrderOperationEnum.Buy).Sum(p => p.Deal.Price * p.Count * lotSize);
                    //create new note
                    note = null;
                }

                if (overFlow > 0)
                {
                    note = new DiaryNote()
                    {
                        Code = code
                    };
                    unit.DiaryNoteRepository.Create(note);

                    note.Open = deal.DateTime;

                    note.NoteType = deal.OrderOperation == OrderOperationEnum.Buy ? NoteType.Long : NoteType.Short;

                    note.NotePositions.Add(new NotePosition()
                    {
                        Deal  = deal,
                        Count = overFlow
                    });
                }

                deal.Processed = true;
            }
        }
 public async Task Create(DiaryNote diaryNote)
 {
     await _context.DiaryNotes.InsertOneAsync(diaryNote);
 }