Example #1
0
        public static string GetNotes(string userid)
        {
            string notes;

            UserNotes.TryGetValue(userid, out notes);
            return(notes);
        }
 public IActionResult UpdateUser(UserNotes data)
 {
     if (data == null)
     {
         return(BadRequest());
     }
     else
     {
         IActionResult result = _operations.UpdateUserData(data);
         return(result);
     }
 }
        public UserNotes GetUserDataError(string username)
        {
            Users user = _db.Users.Where(x => x.Username == username).FirstOrDefault();

            if (user.Activated)
            {
                UserNotes userData = _db.UserNotes.Where(x => x.Id == user.UserData).FirstOrDefault();
                return(userData);
            }
            else
            {
                return(null);
            }
        }
        public async Task <UserNotes> CreateNote(string notes, string userId, string createdBy, string modifiedBy)
        {
            var nt = new UserNotes
            {
                Modifiedby = modifiedBy,
                Createdby  = createdBy,
                DtCreated  = DateTime.Now,
                DtModified = DateTime.Now,
                Note       = notes,
                Userid     = userId
            };

            return(await uow.ClientNoteRepository.AddAsync(nt));
        }
Example #5
0
        public List <UserNotes> List(string UserName, bool HistoryFlag)
        {
            List <UserNotes> List = new List <UserNotes>();

            try
            {
                SqlCon.Open();
                var SqlCmd = new SqlCommand("[config].[uspReadUserNotes]", SqlCon)
                {
                    CommandType = CommandType.StoredProcedure
                };

                //Insert Parameters
                SqlCmd.Parameters.AddWithValue("@UserName", UserName);
                SqlCmd.Parameters.AddWithValue("@HistoryFlag", HistoryFlag);

                using (var dr = SqlCmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        var detail = new UserNotes
                        {
                            NoteID           = Convert.ToInt32(dr["NoteID"]),
                            UserID           = Convert.ToInt32(dr["UserID"]),
                            RequestNote      = dr["RequestNote"].ToString(),
                            NoteDate         = Convert.ToDateTime(dr["NoteDate"]),
                            InsertedBy       = dr["InsertedBy"].ToString(),
                            ResponseRequired = Convert.ToBoolean(dr["ResponseRequired"]),
                            ResponseNote     = dr["ResponseNote"].ToString(),
                            ReadFlag         = Convert.ToBoolean(dr["ReadFlag"])
                        };
                        if (!Convert.IsDBNull(dr["ResponseDate"]))
                        {
                            detail.ResponseDate = Convert.ToDateTime(dr["ResponseDate"]);
                        }
                        List.Add(detail);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            if (SqlCon.State == ConnectionState.Open)
            {
                SqlCon.Close();
            }
            return(List);
        }
Example #6
0
        public UserNotes Details(int NoteID)
        {
            UserNotes Note = new UserNotes();

            try
            {
                SqlCon.Open();
                var SqlCmd = new SqlCommand("[config].[uspReadUserNotes]", SqlCon)
                {
                    CommandType = CommandType.StoredProcedure
                };

                //Insert Parameters
                SqlCmd.Parameters.AddWithValue("@NoteID", NoteID);

                using (var dr = SqlCmd.ExecuteReader())
                {
                    dr.Read();
                    if (dr.HasRows)
                    {
                        Note.NoteID           = Convert.ToInt32(dr["NoteID"]);
                        Note.UserID           = Convert.ToInt32(dr["UserID"]);
                        Note.RequestNote      = dr["RequestNote"].ToString();
                        Note.NoteDate         = Convert.ToDateTime(dr["NoteDate"]);
                        Note.ResponseRequired = Convert.ToBoolean(dr["ResponseRequired"]);
                        Note.InsertedBy       = dr["InsertedBy"].ToString();
                        Note.ResponseNote     = dr["ResponseNote"].ToString();

                        Note.ReadFlag = Convert.ToBoolean(dr["ReadFlag"]);

                        if (!Convert.IsDBNull(dr["ResponseDate"]))
                        {
                            Note.ResponseDate = Convert.ToDateTime(dr["ResponseDate"]);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            if (SqlCon.State == ConnectionState.Open)
            {
                SqlCon.Close();
            }

            return(Note);
        }
Example #7
0
        private void ShowModalWindow(string dateDay, string para, int paraNumber, UserNotes note, ref Button butonClick)
        {
            switch ((butonClick.Content as MaterialDesignThemes.Wpf.PackIcon).Kind)
            {
            case MaterialDesignThemes.Wpf.PackIconKind.NoteAddOutline:
                _mWindow._homePage                      = this;
                _mWindow._buttonRefAddNote              = butonClick;
                _mWindow.GridModalWindows.Visibility    = System.Windows.Visibility.Visible;
                _mWindow.ModalWindowAddNotes.Visibility = System.Windows.Visibility.Visible;
                _mWindow.DosentOpacityGrid.IsEnabled    = false;
                _mWindow.NameGridChangeOrAddNotes.Text  = "Добавление заметки";
                _mWindow.SaveNoteButton.Content         = "Сохранить";
                _mWindow.SaveNoteButton.ToolTip         = "Сохранить заметку";
                _mWindow.KindHeaderTextBock.Kind        = MaterialDesignThemes.Wpf.PackIconKind.NoteAddOutline;
                _mWindow.SaveNoteButton.Visibility      = System.Windows.Visibility.Hidden;
                _mWindow.DateNoteTextBlock.Text         = dateDay;
                _mWindow.ParaNoteTextBlock.Text         = para;
                _mWindow.paraNumber                     = paraNumber;
                Storyboard sb = _mWindow.FindResource("ShowModalWindowAddNewNote") as Storyboard;
                sb.Begin();
                _mWindow.NewNoteTextBox.Clear();
                notes = note;
                break;

            case MaterialDesignThemes.Wpf.PackIconKind.NoteMultipleOutline:
                notes = note;
                _mWindow._homePage                      = this;
                _mWindow._buttonRefAddNote              = butonClick;
                _mWindow.GridModalWindows.Visibility    = System.Windows.Visibility.Visible;
                _mWindow.ModalWindowAddNotes.Visibility = System.Windows.Visibility.Visible;
                _mWindow.DosentOpacityGrid.IsEnabled    = false;
                _mWindow.NameGridChangeOrAddNotes.Text  = "Изменение заметки";
                _mWindow.SaveNoteButton.Content         = "Изменить";
                _mWindow.SaveNoteButton.ToolTip         = "Изменить заметку";
                _mWindow.KindHeaderTextBock.Kind        = MaterialDesignThemes.Wpf.PackIconKind.NoteMultipleOutline;
                _mWindow.SaveNoteButton.Visibility      = System.Windows.Visibility.Visible;
                _mWindow.DateNoteTextBlock.Text         = dateDay;
                _mWindow.ParaNoteTextBlock.Text         = para;
                _mWindow.paraNumber                     = paraNumber;
                _mWindow.NewNoteTextBox.Text            = note.NoteText;
                _mWindow.tmpNoteUserId                  = note.IDNotes;
                Storyboard sbChangeNote = _mWindow.FindResource("ShowModalWindowAddNewNote") as Storyboard;
                sbChangeNote.Begin();
                break;
            }
        }
        public IActionResult Unhandled(string username)
        {
            UserNotes result = _operations.GetUserDataError(username);

            if (result == null)
            {
                var response = new
                {
                    message = "User is not activated",
                    HttpStatusCode.NoContent
                };
                return(new JsonResult(response));
            }
            else
            {
                return(new JsonResult(result));
            }
        }
        public async Task SaveUserNote(UserNotes userNote)
        {
            Notes Notes = new Notes();

            int       month = userNote.NoteDate.Month;
            int       day   = userNote.NoteDate.Day;
            int       year  = userNote.NoteDate.Year;
            UserNotes note;

            if ((note = await Notes.UserNotes.Where(n => n.UserLogin.Equals(userNote.UserLogin) &&
                                                    n.NoteDate.Year.Equals(year) &&
                                                    n.NoteDate.Month.Equals(month) &&
                                                    n.NoteDate.Day.Equals(day))
                        .FirstOrDefaultAsync()) != null)
            {
                if (string.IsNullOrWhiteSpace(userNote.Note))
                {
                    Notes.UserNotes.Remove(note);
                }
                else
                {
                    note.Note = userNote.Note;
                    Notes.Entry(note).State = EntityState.Modified;
                }
            }
            else if (string.IsNullOrWhiteSpace(userNote.Note))
            {
                return;
            }
            else
            {
                UserNotes newNote = new UserNotes
                {
                    Note      = userNote.Note,
                    UserLogin = userNote.UserLogin,
                    NoteDate  = userNote.NoteDate
                };

                Notes.UserNotes.Add(newNote);
            }

            await Notes.SaveChangesAsync();
        }
        public IActionResult UpdateUserData(UserNotes data)
        {
            Users user = _db.Users.Where(x => x.UserData == data.Id).FirstOrDefault();

            try
            {
                if (user.Activated)
                {
                    _db.UserNotes.Update(data);
                    _db.SaveChanges();
                    return(new OkResult());
                }
                else
                {
                    return(new UnprocessableEntityResult());
                }
            }
            catch (NullReferenceException)
            {
                return(new NotFoundResult());
            }
        }
 public GetUserDataResult GetUserData(string username)
 {
     try
     {
         Users user = _db.Users.Where(x => x.Username == username).FirstOrDefault();
         if (user == null)
         {
             return(new GetUserDataResult(null, "not found"));
         }
         if (user.Activated)
         {
             UserNotes userData = _db.UserNotes.Where(x => x.Id == user.UserData).FirstOrDefault();
             return(new GetUserDataResult(userData, "ok"));
         }
         else
         {
             return(new GetUserDataResult(null, "not active"));
         }
     }
     catch (Exception)
     {
         return(new GetUserDataResult(null, "error"));
     }
 }
Example #12
0
        public bool AddNote(UserNotes Note, string InsertUser)
        {
            bool rpta = false;

            try
            {
                SqlCon.Open();
                var SqlCmd = new SqlCommand("[adm].[uspAddUserNote]", SqlCon)
                {
                    CommandType = CommandType.StoredProcedure
                };

                //Insert Parameters
                SqlParameter ParInsertUser = new SqlParameter
                {
                    ParameterName = "@InsertUser",
                    SqlDbType     = SqlDbType.VarChar,
                    Size          = 50,
                    Value         = InsertUser
                };
                SqlCmd.Parameters.Add(ParInsertUser);

                SqlParameter pUserID = new SqlParameter
                {
                    ParameterName = "@UserID",
                    SqlDbType     = SqlDbType.Int,
                    Value         = Note.UserID
                };
                SqlCmd.Parameters.Add(pUserID);

                SqlParameter pNote = new SqlParameter
                {
                    ParameterName = "@RequestNote",
                    SqlDbType     = SqlDbType.VarChar,
                    Value         = Note.RequestNote.Trim()
                };
                SqlCmd.Parameters.Add(pNote);

                SqlParameter pResponseRequired = new SqlParameter
                {
                    ParameterName = "@ResponseRequired",
                    SqlDbType     = SqlDbType.Bit,
                    Value         = Note.ResponseRequired
                };
                SqlCmd.Parameters.Add(pResponseRequired);

                //EXEC Command
                SqlCmd.ExecuteNonQuery();

                rpta = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            if (SqlCon.State == ConnectionState.Open)
            {
                SqlCon.Close();
            }
            return(rpta);
        }
Example #13
0
        // Get Teacher Sheldue
        private List <Sheldue> ParseWordFileTeacherMethod()
        {
            List <Sheldue> allSheldue = new List <Sheldue>();

            try
            {
                string      pathFileWord    = Path.GetFullPath(departmnetListReferensToFile["Информационное"]);
                Application app             = new Application();
                string[]    nameTeacher     = _name.ToUpper().Split(' ');
                Document    doc             = app.Documents.Open(pathFileWord, Visible: false);
                bool        twoGroupInTable = true;
                try
                {
                    foreach (Table table in doc.Tables)
                    {
                        twoGroupInTable = table.Columns.Count > 7 ? true : false;
                        switch (twoGroupInTable)
                        {
                        case true:
                            try
                            {
                                for (int i = 3; i < table.Rows.Count; i++)
                                {
                                    string[] teacherCellParse = RangeText(table.Cell(i, 5).Range.Text).Split(new char[] { ' ', '/' });
                                    foreach (var name in teacherCellParse)
                                    {
                                        if (nameTeacher[0] == name)
                                        {
                                            string paraNumber = RangeText(table.Cell(i, 2).Range.Text);
                                            string work       = RangeText(table.Cell(i, 3).Range.Text);
                                            string auditoria  = RangeText(table.Cell(i, 4).Range.Text);
                                            string teacher    = RangeText(table.Cell(i, 5).Range.Text);

                                            UserNotes note = new UserNotes();
                                            if (userNotes.Count != 0)
                                            {
                                                note = GetUserNote(paraNumber, work);
                                            }
                                            allSheldue.Add(new Sheldue(System.Windows.Visibility.Visible,
                                                                       note.Para != null ? MaterialDesignThemes.Wpf.PackIconKind.NoteMultipleOutline : MaterialDesignThemes.Wpf.PackIconKind.NoteAddOutline,
                                                                       $"Para{paraNumber}",
                                                                       paraNumber,
                                                                       work,
                                                                       teacher,
                                                                       auditoria,
                                                                       note));
                                        }
                                    }
                                    teacherCellParse = RangeText(table.Cell(i, 9).Range.Text).Split(new char[] { ' ', '/' });
                                    foreach (var name in teacherCellParse)
                                    {
                                        if (nameTeacher[0] == name)
                                        {
                                            string paraNumber = RangeText(table.Cell(i, 6).Range.Text);
                                            string work       = RangeText(table.Cell(i, 7).Range.Text);
                                            string auditoria  = RangeText(table.Cell(i, 8).Range.Text);
                                            string teacher    = RangeText(table.Cell(i, 9).Range.Text);

                                            UserNotes note = new UserNotes();
                                            if (userNotes.Count != 0)
                                            {
                                                note = GetUserNote(paraNumber, work);
                                            }
                                            allSheldue.Add(new Sheldue(System.Windows.Visibility.Visible,
                                                                       note.Para != null ? MaterialDesignThemes.Wpf.PackIconKind.NoteMultipleOutline : MaterialDesignThemes.Wpf.PackIconKind.NoteAddOutline,
                                                                       $"Para{paraNumber}",
                                                                       paraNumber,
                                                                       work,
                                                                       teacher,
                                                                       auditoria,
                                                                       note));
                                        }
                                    }
                                }
                            }
                            catch
                            {
                                continue;
                            }
                            break;

                        case false:
                            try
                            {
                                for (int i = 3; i < table.Rows.Count; i++)
                                {
                                    string[] teacherCellParse = RangeText(table.Cell(i, 5).Range.Text).Split(new char[] { ' ', '/' });
                                    foreach (var name in teacherCellParse)
                                    {
                                        if (nameTeacher[0] == name)
                                        {
                                            string    paraNumber = RangeText(table.Cell(i, 2).Range.Text);
                                            string    work       = RangeText(table.Cell(i, 3).Range.Text);
                                            string    auditoria  = RangeText(table.Cell(i, 4).Range.Text);
                                            string    teacher    = RangeText(table.Cell(i, 5).Range.Text);
                                            UserNotes note       = new UserNotes();
                                            if (userNotes.Count != 0)
                                            {
                                                note = GetUserNote(paraNumber, work);
                                            }

                                            allSheldue.Add(new Sheldue(System.Windows.Visibility.Visible,
                                                                       note.Para != null ? MaterialDesignThemes.Wpf.PackIconKind.NoteMultipleOutline : MaterialDesignThemes.Wpf.PackIconKind.NoteAddOutline,
                                                                       $"Para{paraNumber}",
                                                                       paraNumber,
                                                                       work,
                                                                       teacher,
                                                                       auditoria,
                                                                       note));
                                        }
                                    }
                                }
                            }
                            catch
                            {
                                continue;
                            }
                            break;
                        }
                    }
                }
                catch
                {
                    doc.Close();
                    app.Quit();
                    return(allSheldue);
                }
                finally
                {
                    doc.Close();
                    app.Quit();
                }
            }
            catch (Exception ex)
            {
                int lineEx = new System.Diagnostics.StackTrace(ex, true).GetFrame(0).GetFileLineNumber();
                IFCore.IFCore.loggerMain.Error("DAL => ParseCellsRanegTextTable class " + ex.ToString() + lineEx);
            }
            return(allSheldue);
        }
Example #14
0
        // Get Student Sheldue
        private List <Sheldue> ParseWordFileStudentMethod()
        {
            List <Sheldue> allSheldue = new List <Sheldue>();

            try
            {
                string      pathFileWord = Path.GetFullPath(departmnetListReferensToFile[_department]);
                Application app          = new Application();
                string      group        = $"ГРУППА {_group.Replace(" ", "")}";
                Document    doc          = app.Documents.Open(pathFileWord, Visible: false);
                try
                {
                    foreach (Table table in doc.Tables)
                    {
                        try
                        {
                            for (int j = 1; j < table.Columns.Count - 1; j++)
                            {
                                if (RangeText(table.Cell(1, j).Range.Text) == group)
                                {
                                    if (j > 4)
                                    {
                                        for (int i = 3; i <= table.Rows.Count; i++)
                                        {
                                            try
                                            {
                                                if (RangeText(table.Cell(i, 6).Range.Text) != string.Empty)
                                                {
                                                    string    paraNumber = RangeText(table.Cell(i, 6).Range.Text);
                                                    string    work       = RangeText(table.Cell(i, 7).Range.Text);
                                                    string    auditoria  = RangeText(table.Cell(i, 8).Range.Text);
                                                    string    teacher    = RangeText(table.Cell(i, 9).Range.Text);
                                                    UserNotes note       = new UserNotes();
                                                    if (userNotes.Count != 0)
                                                    {
                                                        note = GetUserNote(paraNumber, work);
                                                    }
                                                    allSheldue.Add(new Sheldue(System.Windows.Visibility.Visible,
                                                                               note.Para != null
                                                                    ? MaterialDesignThemes.Wpf.PackIconKind.NoteMultipleOutline
                                                                    : MaterialDesignThemes.Wpf.PackIconKind.NoteAddOutline,
                                                                               $"Para{paraNumber}",
                                                                               paraNumber,
                                                                               work,
                                                                               teacher,
                                                                               auditoria,
                                                                               note));
                                                }
                                            }
                                            catch
                                            {
                                                continue;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        for (int i = 3; i <= table.Rows.Count - 1; i++)
                                        {
                                            try
                                            {
                                                if (RangeText(table.Cell(i, 2).Range.Text) != string.Empty)
                                                {
                                                    string paraNumber = RangeText(table.Cell(i, 2).Range.Text);
                                                    string work       = RangeText(table.Cell(i, 3).Range.Text);
                                                    string auditoria  = RangeText(table.Cell(i, 4).Range.Text);
                                                    string teacher    = RangeText(table.Cell(i, 5).Range.Text);

                                                    UserNotes note = new UserNotes();
                                                    if (userNotes.Count != 0)
                                                    {
                                                        note = GetUserNote(paraNumber, work);
                                                    }
                                                    allSheldue.Add(new Sheldue(System.Windows.Visibility.Visible,
                                                                               note.Para != null ? MaterialDesignThemes.Wpf.PackIconKind.NoteMultipleOutline : MaterialDesignThemes.Wpf.PackIconKind.NoteAddOutline,
                                                                               $"Para{paraNumber}",
                                                                               paraNumber,
                                                                               work,
                                                                               teacher,
                                                                               auditoria,
                                                                               note));
                                                }
                                            }
                                            catch
                                            {
                                                continue;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            int lineEx = new System.Diagnostics.StackTrace(ex, true).GetFrame(0).GetFileLineNumber();
                            IFCore.IFCore.loggerMain.Error("DAL => ParseWordFileStudentMethod class " + ex.ToString() + lineEx);
                        }
                    }
                    return(allSheldue);
                }
                catch (Exception ex)
                {
                    doc.Close();
                    app.Quit();
                    int lineEx = new System.Diagnostics.StackTrace(ex, true).GetFrame(0).GetFileLineNumber();
                    IFCore.IFCore.loggerMain.Error("DAL => ParseWordFileStudentMethod class " + ex.ToString() + lineEx);
                    return(allSheldue);
                }
                finally
                {
                    doc.Close();
                    app.Quit();
                }
            }
            catch (Exception ex)
            {
                int lineEx = new System.Diagnostics.StackTrace(ex, true).GetFrame(0).GetFileLineNumber();
                IFCore.IFCore.loggerMain.Error("DAL => ParseWordFileStudentMethod class " + ex.ToString() + lineEx);
            }
            return(allSheldue);
        }
Example #15
0
 public bool AddNote(UserNotes Note, string InsertUser)
 {
     return(UDAL.AddNote(Note, InsertUser));
 }
        public async Task <IActionResult> UpdateNote([FromBody] IDictionary <string, string> noteModel)
        {
            UserNotes note = _clientNoteService.UpdateNote(noteModel["Note"], noteModel["NoteId"], noteModel["Modifiedby"]);

            return(Ok(note));
        }
Example #17
0
 public static void SetNotes(string userid, string notes)
 {
     UserNotes.AddOrUpdate(userid, notes, (olduserid, oldnote) => notes);
 }