Esempio n. 1
0
        public Response <Note> AddNote(TokenRequest <AddNoteRequest> request)
        {
            Response <Note> response = new Response <Note>();

            try
            {
                if (request == null || request.RequestData == null)
                {
                    response.Code         = -1;
                    response.Description  = "请求参数为空!";
                    response.ResponseData = null;
                }
                else
                {
                    NoteManager          manager = new NoteManager(request.Version);
                    ManagerResult <Note> result  = manager.AddNote(request.RequestData.Note);
                    response.GetResultInfo(result);
                    response.ResponseData = result.ResultData;
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(LogType.Error, ex);
                response.Code = -1;
            }

            return(response);
        }
        public void TestAddNote()
        {
            NoteManager testManager = new NoteManager();
            Note        note        = new Note("testAdd", new List <string> {
                "tag33", "TAG44"
            });

            testManager.AddNote(note);
            Assert.IsTrue(testManager.Notes.Contains(note));
        }
        public void TestDeleteNote2()
        {
            NoteManager testManager = new NoteManager();

            testManager.AddNote("testAdd", new List <string> {
                "tag33", "TAG44"
            });
            Note note2 = testManager.Notes[0];

            Assert.IsTrue(testManager.Notes.Count == 1);
            Note note = new Note("testAdd", new List <string> {
                "tag3", "TAG44"
            });

            testManager.DeleteNote(note);
            Assert.IsFalse(testManager.Notes.Count == 0);
            testManager.AddNote("testAdd", new List <string> {
                "tag33", "TAG44"
            });
            Assert.IsTrue(testManager.Notes.Count == 2);
            testManager.DeleteNote(note2);
            Assert.IsTrue(testManager.Notes.Count == 1);
        }
Esempio n. 4
0
    private void OnGUI()
    {
        manager      = NoteManager.Instance;
        defaultColor = GUI.backgroundColor;
        if (manager == null)
        {
            return;
        }

        EditorGUILayout.BeginHorizontal();
        GUI.backgroundColor = Color.green;
        if (GUILayout.Button("Add"))
        {
            manager.AddNote();
        }
        GUI.backgroundColor = defaultColor;
        if (GUILayout.Button("Save"))
        {
            PrefabUtility.ReplacePrefab(manager.gameObject, PrefabUtility.GetPrefabParent(manager.gameObject), ReplacePrefabOptions.ConnectToPrefab);
        }
        if (GUILayout.Button("Revert"))
        {
            PrefabUtility.ResetToPrefabState(manager.gameObject);
        }
        EditorGUILayout.EndHorizontal();

        foreach (Note note in manager.notes)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("ID", GUILayout.Width(20));
            note.idNote = EditorGUILayout.TextField(note.idNote, GUILayout.Width(120));
            EditorGUILayout.LabelField("Name", GUILayout.Width(50));
            note.name = EditorGUILayout.TextField(note.name, GUILayout.Width(120));
            EditorGUILayout.LabelField("Text", GUILayout.Width(50));
            note.text = EditorGUILayout.TextField(note.text);

            GUI.backgroundColor = Color.red;
            if (GUILayout.Button("Remove", GUILayout.Width(80)))
            {
                manager.RemoveNote(note);
                return;
            }
            GUI.backgroundColor = defaultColor;

            EditorGUILayout.EndHorizontal();
        }
    }
Esempio n. 5
0
        //[ValidateAntiForgeryToken]特性用来防止伪造的跨站请求,配合表单中的@Html.AntiForgeryToken()使用
        //对数据进行增删改时要防止csrf攻击!
        //该特性表示检测服务器请求是否被篡改。注意:该特性只能用于post请求,get请求无效。
        public ActionResult UpNote(Note note)
        {
            var imgfile     = Request.Files["imgfile"];
            var title       = Request["title"];
            var notecontent = Request["content"];
            var imgpath     = Guid.NewGuid().ToString() + imgfile.FileName;

            imgfile.SaveAs(Request.MapPath("/Images/Noteimg/" + imgpath));
            note.Title       = title;
            note.NoteContent = notecontent;
            note.likenum     = 0;
            note.Time        = DateTime.Now;
            note.Img         = "../Noteimg/" + imgpath;
            note.UserID      = Convert.ToInt32(Session["User_id"]);
            notes.AddNote(note);
            //return View();
            return(Content("<script>alert('发表成功');window.location.href='../YiChuShow/Index';</script>"));
        }
Esempio n. 6
0
        public ActionResult AjaxAddNote(string RelateTo, string Note, string RelatedTable)
        {
            objResponse Response = new objResponse();

            session = new SessionHelper();
            try
            {
                Response = objNoteManager.AddNote(Convert.ToInt64(RelateTo), Note, session.UserSession.UserId, Convert.ToInt64(session.UserSession.PIN), RelatedTable);

                if (Response.ErrorCode == 0)
                {
                    if (RelatedTable == "LEAD")
                    {
                        LeadsModel objLeadModel = new LeadsModel();
                        objLeadModel.Notes = objNoteManager.getNotesByRelateToID(Convert.ToInt64(session.UserSession.PIN), Convert.ToInt64(RelateTo), session.UserSession.UserId, RelatedTable);
                        return(View("AjaxLeadNotes", objLeadModel));
                    }
                    else if (RelatedTable == "OPPORTUNITY")
                    {
                        OpportunityModel objOppoModel = new OpportunityModel();
                        objOppoModel.Notes = objNoteManager.getNotesByRelateToID(Convert.ToInt64(session.UserSession.PIN), Convert.ToInt64(RelateTo), session.UserSession.UserId, RelatedTable);
                        return(View("AjaxOppoNotes", objOppoModel));
                    }
                    else
                    {
                        ClientModel objClientModel = new ClientModel();
                        objClientModel.Notes = objNoteManager.getNotesByRelateToID(Convert.ToInt64(session.UserSession.PIN), Convert.ToInt64(RelateTo), session.UserSession.UserId, RelatedTable);
                        return(View("AjaxClientNote", objClientModel));
                    }
                }
                else
                {
                    return(Json("Fail", JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                BAL.Common.LogManager.LogError("AjaxAddNote conto Method", 1, Convert.ToString(ex.Source), Convert.ToString(ex.Message), Convert.ToString(ex.StackTrace));
                return(Json("Fail", JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 7
0
        public ActionResult AjaxAddNote(string Title, string RelateTo, string Note, string RelatedTable)
        {
            objResponse Response = new objResponse();

            session = new SessionHelper();
            try
            {
                Response = objNoteManager.AddNote(Convert.ToInt64(RelateTo), Note, session.UserSession.UserId, session.UserSession.UserId, RelatedTable);

                if (Response.ErrorCode == 0)
                {
                    return(Json("Success", JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json("Fail", JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                BAL.Common.LogManager.LogError("AjaxAddNote conto Method", 1, Convert.ToString(ex.Source), Convert.ToString(ex.Message), Convert.ToString(ex.StackTrace));
                return(Json("Fail", JsonRequestBehavior.AllowGet));
            }
        }
        public TransactionObject AddLesson(AddLessonFormData alFormData)
        {
            TransactionObject response = new TransactionObject();

            try
            {
                Education education = educationManager.GetEducation(alFormData.StudentID, alFormData.LessonID);

                Student selectedStudent = studentManager.GetStudent(alFormData.StudentID);
                Lesson  selectedLesson  = lessonManager.GetLesson(alFormData.LessonID);

                if (education != null)
                {
                    Period currentPeriod = periodManager.GetPeriod(selectedLesson.Period.Year, selectedLesson.Period.Semester);


                    Note note = new Note
                    {
                        ResultPoint = alFormData.Result,
                        Description = alFormData.Description,
                        EffectRate  = alFormData.Effect,
                        Education   = education
                    };

                    note.Education = education;
                    education.Notes.Add(note);


                    noteManager.AddNote(note);
                }
                else
                {
                    education         = new Education();
                    education.Student = selectedStudent;
                    selectedStudent.Educations.Add(education);

                    education.Lesson = selectedLesson;
                    selectedLesson.Educations.Add(education);


                    Note note = new Note
                    {
                        ResultPoint = alFormData.Result,
                        Description = alFormData.Description,
                        EffectRate  = alFormData.Effect,
                        Education   = education
                    };

                    education.Notes.Add(note);

                    note.Education = education;

                    noteManager.AddNote(note);
                    educationManager.AddEducation(education);
                }

                double avg = 0;
                education.Notes.ForEach(note => avg += (note.EffectRate / 100) * note.ResultPoint);
                education.Average = avg;

                uow.Save();
                response.IsSuccess = true;
            }
            catch (Exception ex)
            {
                response.IsSuccess   = false;
                response.Explanation = base.GetExceptionMessage(ex);
            }


            return(response);
        }
 public void Init()
 {
     testerManager = new NoteManager();
     testerManager.AddNote("test1", new List <string> {
         "not", "and", "or", "xor"
     });
     testerManager.AddNote("test2", new List <string> {
         "not", "and", "or"
     });
     testerManager.AddNote("test3", new List <string> {
         "not", "and"
     });
     testerManager.AddNote("test4", new List <string> {
         "not"
     });
     testerManager.AddNote("test5", new List <string> {
         "and", "or", "xor"
     });
     testerManager.AddNote("test6", new List <string> {
         "or", "xor"
     });
     testerManager.AddNote("test7", new List <string> {
         "xor"
     });
     testerManager.AddNote("test8", new List <string> {
         "not", "xor"
     });
     testerManager.AddNote("test9", new List <string> {
         "not", "and", "xor"
     });
     testerManager.AddNote("test10", new List <string> {
         "not", "or", "xor"
     });
     testerManager.AddNote("test11", new List <string> {
         "and", "or"
     });
     testerManager.AddNote("test12", new List <string> {
         "and", "xor"
     });
     testerManager.AddNote("test13", new List <string> {
         "not", "or"
     });
     testerManager.AddNote("test14", new List <string> {
     });
 }
Esempio n. 10
0
 public bool AddNote(NoteModel note, object whereToAdd)
 {
     return(NoteManager.AddNote(note, whereToAdd));
 }
Esempio n. 11
0
        public ActionResult AddNote(NoteViewModel model)
        {
            noteManager.AddNote(model);

            return(View());
        }
Esempio n. 12
0
        private void Note_Load(object sender, EventArgs e)
        {
            SetMainDesign();

            NoteManager.AddNote(this);
        }