Esempio n. 1
0
        /// <summary>
        /// Cập nhật bài viết
        /// </summary>
        /// <param name="ID"></param>
        /// <param name="update"></param>
        /// <returns></returns>
        public Boolean updateEnglish(int _id, tblEnglish update)
        {
            LTDHDataContext DB = new LTDHDataContext(@strPathDB);

            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    var english = DB.tblEnglishes.Single(e => e.ID == _id);

                    english.Title = update.Title;
                    english.Type = update.Type;
                    english.Contents = update.Contents;
                    english.Author = update.Author;
                    english.Posted = update.Posted;
                    ltktDAO.Users userDao = new ltktDAO.Users();
                    if (english.State == CommonConstants.STATE_UNCHECK
                    && update.State == CommonConstants.STATE_CHECKED)
                    {
                        userDao.addNumberOfArticle(english.Author.Trim());
                    }
                    else if (english.State == CommonConstants.STATE_CHECKED
                    && update.State == CommonConstants.STATE_UNCHECK)
                    {
                        userDao.subNumberOfArticle(english.Author.Trim());
                    }
                    english.State = update.State;
                    english.Point = update.Point;
                    english.Tag = update.Tag;
                    english.HtmlEmbedLink = update.HtmlEmbedLink;
                    english.HtmlPreview = update.HtmlPreview;
                    english.StickyFlg = update.StickyFlg;
                    english.Checker = update.Checker;
                    english.Score = update.Score;
                    english.Thumbnail = update.Thumbnail;
                    english.Class = update.Class;
                    english.Location = update.Location;
                    english.Comment = update.Comment;
                    english.FolderID = update.FolderID;

                    DB.SubmitChanges();
                    ts.Complete();
                }
            }
            catch (Exception e)
            {
                log.writeLog(DBHelper.strPathLogFile, update.Author, e.Message
                                                        + CommonConstants.NEWLINE
                                                        + e.Source
                                                        + CommonConstants.NEWLINE
                                                        + e.StackTrace
                                                        + CommonConstants.NEWLINE
                                                        + e.HelpLink);
                return false;
            }
            return true;
        }
Esempio n. 2
0
 public bool setDeleteFlagArticle(int _id)
 {
     LTDHDataContext DB = new LTDHDataContext(@strPathDB);
     try
     {
         using (TransactionScope ts = new TransactionScope())
         {
             var english = DB.tblEnglishes.Single(e => e.ID == _id);
             english.DeleteFlg = true;
             if (english.State == CommonConstants.STATE_CHECKED)
             {
                 ltktDAO.Users userDao = new ltktDAO.Users();
                 userDao.subNumberOfArticle(english.Author.Trim());
             }
             DB.SubmitChanges();
             ts.Complete();
         }
     }
     catch (Exception ex)
     {
         writeException(ex);
         return false;
     }
     return true;
 }
Esempio n. 3
0
        /// <summary>
        /// set delete Flag is true
        /// </summary>
        /// <param name="_id"></param>
        /// <param name="_username"></param>
        public bool setDeleteFlag(int _id, string _username)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    var inf = DB.tblInformatics.Single(a => a.ID == _id);
                    inf.DeleteFlg = true;
                    if (inf.State == CommonConstants.STATE_CHECKED)
                    {
                        ltktDAO.Users userDao = new ltktDAO.Users();
                        userDao.subNumberOfArticle(inf.Author.Trim());
                    }
                    DB.SubmitChanges();

                    ts.Complete();
                }
                log.writeLog(DBHelper.strPathLogFile, _username,
                                BaseServices.createMsgByTemplate(CommonConstants.SQL_DELETE_SUCCESSFUL_TEMPLATE,
                                                                    _id.ToString(),
                                                                    CommonConstants.SQL_TABLE_INFORMATICS));

            }
            catch (Exception e)
            {
                log.writeLog(DBHelper.strPathLogFile, _username,
                                  BaseServices.createMsgByTemplate(CommonConstants.SQL_DELETE_FAILED_TEMPLATE,
                                                                      _id.ToString(),
                                                                      CommonConstants.SQL_TABLE_INFORMATICS));
                log.writeLog(DBHelper.strPathLogFile, _username, e.Message
                                                        + CommonConstants.NEWLINE
                                                        + e.Source
                                                        + CommonConstants.NEWLINE
                                                        + e.StackTrace
                                                        + CommonConstants.NEWLINE
                                                        + e.HelpLink);
                return false;
            }
            return true;
        }
Esempio n. 4
0
        //public Boolean insertInformatic(string _title, int _type, string _content,
        //    string _author, DateTime _posted, string _location, string _tag)
        //{
        //    return false;
        //}
        /// <summary>
        /// Cập nhật bài viết
        /// </summary>
        /// <param name="update"></param>
        /// <returns></returns>
        public Boolean updateInformatic(int _id, tblInformatic update, string currentUsername)
        {
            LTDHDataContext DB = new LTDHDataContext(@strPathDB);
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    var informatic = DB.tblInformatics.Single(info => info.ID == _id);
                    if (informatic != null)
                    {
                        informatic.Title = update.Title;
                        informatic.Type = update.Type;
                        informatic.Chapeau = update.Chapeau;
                        informatic.Contents = update.Contents;
                        informatic.Author = update.Author;
                        informatic.Posted = update.Posted;
                        ltktDAO.Users userDao = new ltktDAO.Users();
                        if (informatic.State == CommonConstants.STATE_UNCHECK
                        && update.State == CommonConstants.STATE_CHECKED)
                        {
                            userDao.addNumberOfArticle(informatic.Author.Trim());
                        }
                        else if (informatic.State == CommonConstants.STATE_CHECKED
                        && update.State == CommonConstants.STATE_UNCHECK)
                        {
                            userDao.subNumberOfArticle(informatic.Author.Trim());
                        }
                        informatic.State = update.State;
                        informatic.Tag = update.Tag;
                        informatic.HtmlEmbedLink = update.HtmlEmbedLink;
                        informatic.HtmlPreview = update.HtmlPreview;
                        //informatic.DeleteFlg = false;
                        informatic.Checker = update.Checker;
                        informatic.Leitmotif = update.Leitmotif;
                        informatic.StickyFlg = update.StickyFlg;
                        informatic.Comment = update.Comment;
                        informatic.Thumbnail = update.Thumbnail;
                        informatic.Location = update.Location;

                        DB.SubmitChanges();
                    }
                    ts.Complete();

                    //write log
                    log.writeLog(DBHelper.strPathLogFile, currentUsername,
                                    BaseServices.createMsgByTemplate(CommonConstants.SQL_UPDATE_SUCCESSFUL_TEMPLATE,
                                                                    _id.ToString(),
                                                                    CommonConstants.SQL_TABLE_INFORMATICS));
                }
            }
            catch (Exception e)
            {
                log.writeLog(DBHelper.strPathLogFile, currentUsername, e.Message
                                                        + CommonConstants.NEWLINE
                                                        + e.Source
                                                        + CommonConstants.NEWLINE
                                                        + e.StackTrace
                                                        + CommonConstants.NEWLINE
                                                        + e.HelpLink);
                return false;
            }
            return true;
        }
Esempio n. 5
0
        public bool updateContest(int id,
            string userAdmin,
            string _title,
            int _state,
            bool _isSticky,
            bool _isUniversity,
            int _branch,
            string _sub,
            int _year,
            string _content,
            string _tag,
            int _score,
            string _fileContent,
            string _fileSolving,
            string _fileThumbnail,
            string _htmlPreview,
            string _htmlEmbed,
            string _checker)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    var cont = DB.tblContestForUniversities.Single(u => u.ID == id);

                    cont.Title = _title;
                    cont.Contents = _content;
                    ltktDAO.Users userDao = new ltktDAO.Users();
                    if (cont.State == CommonConstants.STATE_UNCHECK
                        && _state == CommonConstants.STATE_CHECKED)
                    {
                        userDao.addNumberOfArticle(cont.Author.Trim());
                    }
                    else if (cont.State == CommonConstants.STATE_CHECKED
                        && _state == CommonConstants.STATE_UNCHECK)
                    {
                        userDao.subNumberOfArticle(cont.Author.Trim());
                    }
                    cont.State = _state;
                    cont.isUniversity = _isUniversity;
                    cont.Branch = _branch;
                    cont.Year = _year;
                    cont.Score = _score;
                    cont.Tag = _tag;
                    cont.Subject = _sub;
                    cont.StickyFlg = _isSticky;
                    cont.Location = _fileContent;
                    cont.Solving = _fileSolving;
                    cont.Thumbnail = _fileThumbnail;
                    cont.HtmlPreview = _htmlPreview;
                    cont.HtmlEmbedLink = _htmlEmbed;
                    cont.Checker = _checker;

                    DB.SubmitChanges();
                    ts.Complete();

                    log.writeLog(DBHelper.strPathLogFile, userAdmin,
                                        BaseServices.createMsgByTemplate(CommonConstants.SQL_UPDATE_SUCCESSFUL_TEMPLATE,
                                                                         Convert.ToString(id),
                                                                         CommonConstants.SQL_TABLE_CONTEST_UNIVERSITY));
                }
            }
            catch (Exception e)
            {
                log.writeLog(DBHelper.strPathLogFile, userAdmin,
                                  BaseServices.createMsgByTemplate(CommonConstants.SQL_UPDATE_FAILED_TEMPLATE,
                                                                      Convert.ToString(id),
                                                                      CommonConstants.SQL_TABLE_CONTEST_UNIVERSITY));
                log.writeLog(DBHelper.strPathLogFile, userAdmin, e.Message
                                                        + CommonConstants.NEWLINE
                                                        + e.Source
                                                        + CommonConstants.NEWLINE
                                                        + e.StackTrace
                                                        + CommonConstants.NEWLINE
                                                        + e.HelpLink);
                return false;
            }
            return true;
        }