public void Put(int id, [FromBody] MyNote myNote)
        {
            MyNote NoteItem = MyNoteDbContext.MyNotes.FirstOrDefault(x => x.Id == id);

            NoteItem.Title = myNote.Title;
            MyNoteDbContext.SaveChanges();
        }
Exemple #2
0
        /// <summary>
        /// 通过sql语句和参数查询所有日程信息
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="values"></param>
        /// <returns></returns>
        private static IList <MyNote> GetAllMyNotesBySql(string sql, params SqlParameter [] values)
        {
            IList <MyNote> ltMyNote = new List <MyNote>();

            try
            {
                DataTable dt = DBHelper.GetDataSet(sql, values);
                foreach (DataRow row in dt.Rows)
                {
                    MyNote myNote = new MyNote();
                    myNote.CreateTime  = (DateTime)row["createTime"];
                    myNote.CreateUser  = UserService.GetUserById(Convert.ToString(row["createUser"]));
                    myNote.NoteContent = Convert.ToString(row["noteContent"]);
                    myNote.NoteId      = Convert.ToInt32(row["noteId"]);
                    myNote.NoteTitle   = Convert.ToString(row["noteTitle"]);
                    ltMyNote.Add(myNote);
                }
                return(ltMyNote);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw ex;
            }
        }
Exemple #3
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (!col.gameObject.CompareTag("Note"))
        {
            return;
        }
        MyNote mynote = col.gameObject.GetComponent <MyNote>();

        if (NoteType.NoteTypeSingle == mynote.m_note.m_note_type)
        {
            m_single_notes.Add(mynote);
        }
        else if (NoteType.NoteTypePush == mynote.m_note.m_note_type)
        {
            m_push_notes.Add(mynote);
        }
        else if (NoteType.NoteTypeRelease == mynote.m_note.m_note_type)
        {
            m_release_notes.Add(mynote);
        }
        else if (NoteType.NoteTypeKePressed == mynote.m_note.m_note_type)
        {
            m_keypressed_notes.Add(mynote);
        }
        //m_notes[mynote] = 1;
        //Debug.Log(col.gameObject.name );// + " : " + gameObject.name + " : " + Time.time);
    }
 public async Task <BaseResult <MyNoteDto> > Create(MyNote newEntity)
 {
     _logger.LogInformation("*** {Method} {@Entity}", "Create", newEntity);
     // Agregar verificación de la existencia de la entidad con el Id, solo si el usuario lo provee. (utilizar ServiceEntityExists)
     return(await AppHelpers.ServiceCreateEntityHelper <MyNote, MyNoteDto, uint>(
                newEntity, _idPropertyName, _uow, GetById_Command));
 }
Exemple #5
0
 private static void WriteNote(MyNote note, string path, bool isAppend)
 {
     using (StreamWriter sw = new StreamWriter(path, isAppend))
     {
         sw.WriteLine(JsonConvert.SerializeObject(note));
     }
 }
Exemple #6
0
        //http://stackoverflow.com/questions/5826649/returning-a-file-to-view-download-in-asp-net-mvc


        // I have file not found issue
        // here is a work around
        // https://github.com/aspnet/Mvc/issues/5053
        public IActionResult GetKindleFile(string url)
        {
            // check domain
            var firstPageUri = new Uri(url);

            if (firstPageUri.Scheme == "file")
            {
                var note       = new MyNote();
                var bookHelper = new BookHelper(note);
                var kindleFile = bookHelper.CreateKindleFiles(url, true);
            }
            else
            {
                // special for thuvienhoasen 1 tac gia
                if (firstPageUri.Host == "thuvienhoasen.org" && firstPageUri.Segments.Contains("author/"))
                {
                    var collection = new ThuVienHoaSenCollection();
                    collection.GetWholeCollection(url);
                }
                else
                {
                    GeneralSite setting = SettingFactory.Get(url);

                    if (setting != null)
                    {
                        var bookHelper = new BookHelper(setting);
                        var kindleFile = bookHelper.CreateKindleFiles(url);
                    }
                }
            }

            return(View("Index"));
        }
Exemple #7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         User user = (User)Session["Login"];
         if (user == null)
         {
             Response.Redirect("~/Login.aspx");
         }
         else
         {
             if (Request.QueryString["noteId"] != null)
             {
                 noteId = Convert.ToInt32(Request.QueryString["noteId"]);
                 MyNote myNote = MyNoteManager.GetMyNoteById(noteId);
                 this.txtTitle.Text     = myNote.NoteTitle;
                 this.txtContent.Text   = myNote.NoteContent;
                 this.lblUserId.Text    = myNote.CreateUser.UserName;
                 this.lblTime.Text      = Convert.ToString(myNote.CreateTime.ToShortDateString());
                 this.btnDelete.Enabled = true;
             }
             else
             {
                 this.btnDelete.Enabled = false;
                 this.lblUserId.Text    = user.UserName;
                 this.lblTime.Text      = DateTime.Now.ToShortDateString();
             }
         }
     }
 }
        //http://stackoverflow.com/questions/5826649/returning-a-file-to-view-download-in-asp-net-mvc

        // I have file not found issue
        // here is a work around
        // https://github.com/aspnet/Mvc/issues/5053
        public IActionResult GetKindleFile(string url)
        {
            // check domain
            var firstPageUri = new Uri(url);

            if (firstPageUri.Host.Contains("thuvienhoasen.org"))
            {
                var thuvienhoasen = new ThuVienHoaSen();
                var bookHelper    = new BookHelper(thuvienhoasen);
                //bookHelper.DownloadFolder = AppContext.BaseDirectory; // in case web app cannot access to a file outside of its folder
                // var firstUrlPath = @"/a17221/ban-do-tu-phat";
                // var firstUrlPath = @"/p27a10044/1/bai-van-khuyen-phat-tam-bo-de";

                // this works
                var kindleFile = bookHelper.CreateKindleFiles(url);
                // var fileContent = new System.IO.FileStream(kindleFile, System.IO.FileMode.Open);
                // return File(fileContent, "application/octet-stream", System.IO.Path.GetFileName(kindleFile));
            }
            else if (firstPageUri.Scheme == "file")
            {
                var note       = new MyNote();
                var bookHelper = new BookHelper(note);
                var kindleFile = bookHelper.CreateKindleFiles(url, true);
            }

            return(View("Index"));
        }
Exemple #9
0
        public async Task CreateAsync(MyNote myNote)
        {
            var content = JsonSerializer.Serialize(myNote);

            using (var stringContent = new StringContent(content, Encoding.UTF8, MediaTypeNames.Application.Json))
            {
                await Client.PostAsync("/api/MyNote", stringContent);
            }
        }
Exemple #10
0
        // 修改記事紀錄
        public async Task UpdateAsync(MyNote origMyNote, MyNote myNote)
        {
            var content = JsonSerializer.Serialize(myNote);

            using (var stringContent = new StringContent(content, Encoding.UTF8, "application/json"))
            {
                await Client.PutAsync($"/API/MyNote/{myNote.Id}", stringContent);
            }
        }
Exemple #11
0
        // 建立一筆新記事紀錄
        public async Task CreateAsync(MyNote myNote)
        {
            var content = JsonSerializer.Serialize(myNote);

            using (var stringContent = new StringContent(content, Encoding.UTF8, "application/json"))
            {
                await Client.PostAsync("/API/MyNote", stringContent);
            }
        }
Exemple #12
0
        public async Task UpdateAsync(MyNote originMyNote, MyNote myNote)
        {
            var content = JsonSerializer.Serialize(myNote);

            using (var stringContent = new StringContent(content, Encoding.UTF8, MediaTypeNames.Application.Json))
            {
                await Client.PutAsync($"/api/MyNote/{myNote.Id}", stringContent);
            }
        }
Exemple #13
0
        static void Main(string[] args)
        {
            MyNote mynote = new MyNote();
            Week   w      = Week.Monday;

            w = (Week)Enum.Parse(typeof(Week), "3", true);
            Console.WriteLine(w);
            Console.ReadLine();
        }
Exemple #14
0
    void create_note(ref Note note, Vector3 start_position, System.DateTime current_time)
    {
        float   T = note.m_appear_beat_index / m_beats_per_second;
        Vector3 x = m_velocity * T;

        System.TimeSpan span = m_current_time - m_start_time;
        GameObject      go   = new GameObject();

        go.layer = MyConst.LAYER_NOTE;

        // go.name = "character";
        go.tag = "Note";
        SpriteRenderer renderer = go.AddComponent <SpriteRenderer>();

        if (NoteType.NoteTypeKePressed == note.m_note_type)
        {
            renderer.sprite = Resources.Load <Sprite>("keypressed_note");
        }
        else if (NoteType.NoteTypePush == note.m_note_type)
        {
            renderer.sprite = Resources.Load <Sprite>("push_note");
        }
        else if (NoteType.NoteTypeRelease == note.m_note_type)
        {
            renderer.sprite = Resources.Load <Sprite>("release_note");
        }
        else
        {
            renderer.sprite = Resources.Load <Sprite>("normal_note");
        }
        // renderer.sortingLayerName = MyConsts.SORTING_LAYER_FOREGROUND_NAME;
        go.transform.localPosition = start_position;
        // go.transform.localPosition = x - m_velocity * span.TotalMilliseconds * 1000;

        // rigid body
        Rigidbody2D rigidbody = go.AddComponent <Rigidbody2D>();

        rigidbody.mass           = 0;
        rigidbody.gravityScale   = 0;
        rigidbody.freezeRotation = true;
        BoxCollider2D collider = go.AddComponent <BoxCollider2D>();

        //collider.isTrigger = true;

        note.m_visible     = true;
        note.m_appear_time = current_time;
        note.m_gameobject  = go;

        MyNoteMotor motor = go.AddComponent <MyNoteMotor>();

        motor.set_param(note, start_position, m_velocity);
        motor.index = note.m_appear_beat_index;

        MyNote mynote = go.AddComponent <MyNote>();

        mynote.m_note = note;
    }
        public async Task DeleteAsync(MyNote myNote)
        {
            var targetItem = await _myNoteDbContext.MyNotes.FirstOrDefaultAsync(x => x.Id == myNote.Id);

            if (targetItem != null)
            {
                _myNoteDbContext.MyNotes.Remove(targetItem);
                await _myNoteDbContext.SaveChangesAsync();
            }
        }
        public async Task <IActionResult> Put(uint id, [FromBody] MyNote updatedEntity)
        {
            var response = await _service.Update(id, updatedEntity);

            if (response.Data == null)
            {
                return(NotFound());
            }
            return(Ok(response));
        }
Exemple #17
0
        // 修改記事紀錄
        public async Task UpdateAsync(MyNote origMyNote, MyNote myNote)
        {
            var fooItem = await MyNoteDbContext.MyNotes.FirstOrDefaultAsync(x => x.Id == origMyNote.Id);

            if (fooItem != null)
            {
                fooItem.Title = myNote.Title;
                await MyNoteDbContext.SaveChangesAsync();
            }
        }
        public IActionResult Put(int id, [FromBody] MyNote user)
        {
            var result = repository.UpdateUser(id, user);

            if (result == null)
            {
                return(NotFound("No user exists"));
            }
            return(Ok(result));
        }
Exemple #19
0
 public static void PlayMelody(SoundDevices sd, int[] phrase, MediaPlayer player)
 {
     Thread.Sleep(700);
     for (int i = 0; i < phrase.Length; i++)
     {
         sd.output.SendNoteOn(sd.channel, MyNote.Note(phrase[i], 4), 80);
         System.Threading.Thread.Sleep(440);
         sd.output.SendNoteOff(sd.channel, MyNote.Note(phrase[i], 4), 80);
     }
     System.Threading.Thread.Sleep(500);
     Form1.Replay(player);
 }
Exemple #20
0
        /// <summary>
        /// 通过便签Id修改便签的信息
        /// </summary>
        /// <param name="myNote"></param>
        /// <returns></returns>
        public static int ModifyMyNoteById(MyNote myNote)
        {
            string sql = "update MyNote set NoteTitle=@NoteTitle,NoteContent=@NoteContent where NoteId=@NoteId";

            SqlParameter[] para = new SqlParameter[]
            {
                new SqlParameter("@NoteTitle", myNote.NoteTitle),
                new SqlParameter("@NoteContent", myNote.NoteContent),
                new SqlParameter("@NoteId", myNote.NoteId)
            };
            return(DBHelper.ExecuteCommand(sql, para));
        }
Exemple #21
0
        /// <summary>
        /// 新增便签
        /// </summary>
        /// <param name="myNote"></param>
        /// <returns></returns>
        public static int AddMyNote(MyNote myNote)
        {
            string sql = "insert into MyNote(NoteTitle,NoteContent,CreateTime,CreateUser) values(@NoteTitle,@NoteContent,@CreateTime,@CreateUser);select @@identity";

            SqlParameter[] para = new SqlParameter[]
            {
                new SqlParameter("@NoteTitle", myNote.NoteTitle),
                new SqlParameter("@NoteContent", myNote.NoteContent),
                new SqlParameter("@CreateTime", myNote.CreateTime),
                new SqlParameter("@CreateUser", myNote.CreateUser.UserId),
            };
            return(DBHelper.ExecuteCommand(sql, para));
        }
Exemple #22
0
        public int CreateNote(MyNote mynote)
        {
            var _mynote = repository.GetNoteById(mynote.NoteId);

            if (_mynote == null)
            {
                return(repository.CreateNote(mynote));
            }
            else
            {
                throw new NoteAlreadyExistsException($"Note with id :{mynote.NoteId} already exists");
            }
        }
Exemple #23
0
    static void LoookingForMyNote(object target)
    {
        Type klass = target.GetType();

        object[] attrs = klass.GetCustomAttributes(false);
        foreach (object at in attrs)
        {
            if (at.GetType() == typeof(MyNote))
            {
                MyNote note = (MyNote)at;
                Console.WriteLine(klass + ": MyNote  --- " + note.Label);
            }
        }
    }
 public IActionResult Post([FromBody] MyNote mynote)
 {
     try
     {
         return(StatusCode((int)HttpStatusCode.Created, service.CreateNote(mynote)));
     }
     catch (NoteAlreadyExistsException nae)
     {
         return(Conflict(nae.Message));
     }
     catch
     {
         return(StatusCode((int)HttpStatusCode.InternalServerError));
     }
 }
        // This method is just for reference (no helpers, no global exception handler). Don´t use it.
        public async Task <BaseResult <MyNoteDto> > Update_OLD(object id, MyNote updatedEntity)
        {
            var response = new BaseResult <MyNoteDto>();

            try
            {
                // Business logic

                // Detectar inconsistencia entre el Id y la entidad (deben ser iguales en valores)
                if ((uint)id != updatedEntity.NoteId)
                {
                    throw new Exception(AppMessages.UPDATE_ID_ERROR);
                }

                // Obtener la entidad desde la BD para actualizarla
                var entityFromDb = await _uow.GetRepository <MyNote>().GetById(id);

                // Si la entidad ya está eliminada o no existe, no hacer nada y devolver null
                if (entityFromDb == null || entityFromDb.IsDeleted)
                {
                    response.Data = null;
                    return(response);
                }

                // Comparar con la entidad de la BD y detectar un cambio no permitido
                if (AppHelpers.NotAllowedChanges(entityFromDb, updatedEntity))
                {
                    throw new Exception(AppMessages.UPDATE_FORBIDDEN_FIELDS);
                }

                // Actualizar propiedades de la entidad
                AppHelpers.SetFieldsForEntityUpdate(updatedEntity);

                // Guardar la entidad
                await _uow.GetRepository <MyNote>().Update(updatedEntity);

                await _uow.SaveAsync();

                // Devolver la entidad recien guardada desde la BD
                response.Data = await _connection.QuerySingleOrDefaultAsync <MyNoteDto>(GetById_Command, new { id1 = id });
            }
            catch (Exception)
            {
                //response.Success = false;
                //response.ExceptionMessage = ex.ToString();
            }
            return(response);
        }
Exemple #26
0
        public int UpdateNoteById(MyNote mynote)
        {
            var _mynote = repository.GetNoteById(mynote.NoteId);

            if (_mynote == null)
            {
                throw new NoteNotFoundException($"Note with id : {mynote.NoteId} doesn't exists");
            }
            else
            {
                _mynote.NoteName = mynote.NoteName;
                _mynote.Contact  = mynote.Contact;
                _mynote.City     = mynote.City;
                return(repository.UpdateNoteById(_mynote));
            }
        }
Exemple #27
0
    void OnTriggerExit2D(Collider2D col)
    {
        if (!col.gameObject.CompareTag("Note"))
        {
            return;
        }
        MyNote mynote = col.gameObject.GetComponent <MyNote>();

        remove_mynote(mynote);

        if (!mynote.m_is_hit)
        {
            ScoreCenter.instance().clear_combo_hit_count();
            // on_hit_note(mynote);
        }
    }
Exemple #28
0
    /// <summary>
    /// 添加便签信息和修改便签信息
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            //添加便签信息
            if (Request.QueryString["noteId"] == null)
            {
                MyNote myNote = new MyNote();
                User   user   = (User)Session["Login"];
                myNote.NoteTitle         = this.txtTitle.Text.Trim();
                myNote.NoteContent       = this.txtContent.Text.Trim();
                myNote.CreateTime        = Convert.ToDateTime(this.lblTime.Text);
                myNote.CreateUser.UserId = user.UserId;
                int num = MyNoteManager.AddMyNote(myNote);
                if (num > 0)
                {
                    Response.Redirect("PersonNote.aspx");
                }
                else
                {
                    this.lblMessage.Text = "保存失败!";
                }
            }
            //修改便签信息
            if (Request.QueryString["noteId"] != null)
            {
                noteId = Convert.ToInt32(Request.QueryString["noteId"]);

                MyNote myNote = new MyNote();
                myNote.NoteTitle   = this.txtTitle.Text.Trim();
                myNote.NoteContent = this.txtContent.Text.Trim();
                myNote.NoteId      = noteId;
                int count = MyNoteManager.ModifyMyNoteById(myNote);
                if (count > 0)
                {
                    this.btnDelete.Enabled = true;
                    Response.Redirect("PersonNote.aspx");
                }
                else
                {
                    this.lblMessage.Text = "修改失败!";
                }
            }
        }
    }
        // Use this method when full customization is required.
        public async Task <BaseResult <MyNoteDto> > Create_OLD(MyNote newEntity)
        {
            var response = new BaseResult <MyNoteDto>();

            // Set initial properties
            AppHelpers.SetFieldsForEntityCreation(newEntity);

            // Guardar la entidad
            await _uow.GetRepository <MyNote>().Add(newEntity);

            await _uow.SaveAsync();

            // Devolver la entidad recien guardada desde la BD
            response.Data = await _connection.QuerySingleOrDefaultAsync <MyNoteDto>(GetById_Command, new { id1 = newEntity.NoteId });

            _logger.LogInformation("*** {Method} {@Entity}", "Create", newEntity);
            return(response);
        }
Exemple #30
0
        static void Main(string[] args)
        {
            var note = new MyNote {
                Note = "Foobaz"
            };

            //Refactoring to replace var with an explicit type
            //EnResult<MyNote> result = EnResult<MyNote>.Failure(note, "this", "that", "the other thing");

            //Target-typed new-expressions C# 9.0 - an expression gets the type from the context it is used in
            //the new expression gets the type from the context,
            //which means you don’t have to specify the target-type explicitly to call a constructor.
            //EnResult<MyNote> result = new().Failure(note, "this", "that", "the other thing");
            //var vs target-typed new expressiong - the C# compiler produces exactly the same Intermediate Language code

            var result = EnResult <MyNote> .Failure(note, "this", "that", "the other thing");

            Console.WriteLine(result.Errors.Count());
        }