Пример #1
0
        public async Task <IActionResult> GetAll([FromQuery] SubjectParams subjectParams)
        {
            var levels = await _repo.GetAll <Level>(subjectParams);

            Response.AddPaginationHeader(levels.CurrentPage, levels.PageSize, levels.TotalItems, levels.TotalPages);
            return(Ok(levels));
        }
Пример #2
0
        public async Task <IActionResult> GetAll([FromQuery] SubjectParams subjectParams)
        {
            var examplesFromDb = await _repo.GetAll <Example>(subjectParams);

            Response.AddPaginationHeader(examplesFromDb.CurrentPage, examplesFromDb.PageSize, examplesFromDb.TotalItems, examplesFromDb.TotalPages);
            return(Ok(examplesFromDb));
        }
Пример #3
0
        public async Task <IActionResult> GetAll([FromQuery] SubjectParams subjectParams)
        {
            var subjects = await _repo.GetAll <Subject>(subjectParams);

            var returnSubjects = _mapper.Map <IEnumerable <SubjectDTO> >(subjects);

            {
                switch (subjectParams.OrderBy)
                {
                case "az":
                    returnSubjects = returnSubjects.OrderBy(t => t.SubjectName);
                    break;

                case "za":
                    returnSubjects = returnSubjects.OrderByDescending(t => t.SubjectName);
                    break;

                case "enrolled":
                    returnSubjects = returnSubjects.OrderByDescending(t => t.EnrolledCount);
                    break;

                case "exp":
                    returnSubjects = returnSubjects.OrderByDescending(t => t.ExpGain);
                    break;

                default:
                    break;
                }
            }
            Response.AddPaginationHeader(subjects.CurrentPages, subjects.PageSize, subjects.TotalCount, subjects.TotalPages);
            return(Ok(returnSubjects));
        }
Пример #4
0
        public async Task <IActionResult> GetAll(SubjectParams subjectParams)
        {
            var temp = await _repo.GetAll <Level>(subjectParams, "Accounts");

            var levelListForReturn = _mapper.Map <IEnumerable <LevelDetailDTO> >(temp);

            return(Ok(levelListForReturn.ToList()));
        }
Пример #5
0
        public async Task <IActionResult> GetAllQuizzes([FromQuery] SubjectParams subjectParams)
        {
            var quizzesFromDb = await _repo.GetAll <Quiz>(null, "Section, Questions");

            var quizzes = _mapper.Map <IEnumerable <QuizDetailDTO> >(quizzesFromDb);

            return(Ok(quizzes));
        }
Пример #6
0
 public async Task <ActionResult <IEnumerable <Subject> > > GetSubjects([FromQuery] SubjectParams subjectParams)
 {
     if (subjectParams.userid != 0)
     {
         return(await _context.Subjects.Where(s => s.ChefID == subjectParams.userid).ToListAsync());
     }
     return(await _context.Subjects.ToListAsync());
 }
Пример #7
0
        public async Task <IActionResult> SearchPosts([FromQuery] SubjectParams subjectParams, [FromBody] SearchDTO searchDTO)
        {
            var postsFromDb = await _repo.GetAll <Post>(subjectParams, post => post.Title.ToLower().Contains(searchDTO.Search.ToLower().Trim()) || post.Content.ToLower().Contains(searchDTO.Search.ToLower().Trim()), "Account");

            var returnPosts = _mapper.Map <IEnumerable <PostDTO> >(postsFromDb);

            return(Ok(returnPosts));
        }
Пример #8
0
        public async Task <IActionResult> GetFollowingPosts(int accountId, [FromQuery] SubjectParams subjectParams)
        {
            var posts = await _cRUDRepo.GetAll <Post>(subjectParams, post => post.PostRatings.Any(r => r.AccountId == accountId) || post.Comments.Any(c => c.AccountId == accountId), includeProperties : "PostRatings,Account");

            var returnPosts = _mapper.Map <IEnumerable <PostDTO> >(posts);

            return(Ok(returnPosts));
        }
Пример #9
0
        public async Task <IActionResult> GetAll([FromQuery] SubjectParams subjectParams)
        {
            var groupsFromDb = await _repo.GetAll <Group>(subjectParams, includeProperties : "Account");

            var returnGroups = _mapper.Map <IEnumerable <GroupDTO> >(groupsFromDb);

            return(Ok(returnGroups));
        }
Пример #10
0
        public async Task <IActionResult> GetNewPosts([FromQuery] SubjectParams subjectParams)
        {
            var posts = await _repo.GetAll <Post>(subjectParams, null, "Account", order => order.OrderByDescending(post => post.Date));

            var returnPosts = _mapper.Map <IEnumerable <PostDTO> >(posts);

            return(Ok(returnPosts));
        }
Пример #11
0
        public async Task <IActionResult> GetAllPosts([FromQuery] SubjectParams subjectParams)
        {
            var posts = await _repo.GetAll <Post>(subjectParams, null, "Account, Comments, PostRatings");

            var returnPosts = _mapper.Map <IEnumerable <PostDTO> >(posts);

            return(Ok(returnPosts));
        }
Пример #12
0
        public async Task <IActionResult> GetAdminPublishing([FromQuery] SubjectParams subjectParams)
        {
            var notifications = await _repo.GetAll <Notification>(subjectParams, noti => noti.IsClientNotify == false && noti.IsPublish);

            var returnNotifications = notifications.OrderByDescending(noti => noti.PublishedDate);

            Response.AddPaginationHeader(notifications.CurrentPage, notifications.PageSize, notifications.TotalItems, notifications.TotalPages);
            return(Ok(returnNotifications));
        }
Пример #13
0
        public async Task <IActionResult> GetFollowingPosts([FromQuery] SubjectParams subjectParams)
        {
            var userId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value);
            var posts  = await _repo.GetAll <Post>(subjectParams, post => post.PostRatings.Any(account => account.AccountId == userId), "Account");

            var returnPosts = _mapper.Map <IEnumerable <PostDTO> >(posts);

            return(Ok(returnPosts));
        }
Пример #14
0
        public async Task <IActionResult> GetAllWord([FromQuery] SubjectParams subjectParams)
        {
            var wordsQueryable = await _repo.GetOneWithManyToMany <Word>();

            var words = await wordsQueryable.Include(w => w.Examples).ThenInclude(w => w.Example).ToListAsync();

            var returnWords = _mapper.Map <IEnumerable <WordDTO> >(words);

            return(Ok(returnWords));
        }
Пример #15
0
        public async Task <Paging <T> > GetAll <T>(SubjectParams subjectParams, string includeProperties = "") where T : class
        {
            var _dbSet = _db.Set <T>();
            var query  = _dbSet.Take(_dbSet.Count());

            if (includeProperties != null)
            {
                foreach (var properties in includeProperties.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    query = query.Include(properties);
                }
            }
            return(await Paging <T> .CreateAsync(query, subjectParams.PageNumber, subjectParams.PageSize));
        }
Пример #16
0
        public async Task <IActionResult> GetAll([FromQuery] SubjectParams subjectParams)
        {
            int id = -1;

            if (User.FindFirst(ClaimTypes.NameIdentifier) != null)
            {
                id = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value);
            }
            var accounts = await _repo.GetAll(subjectParams);

            var temp           = accounts.Where(account => account.Id != id);
            var returnAccounts = _mapper.Map <IEnumerable <AccountDetailDTO> >(temp);

            return(Ok(returnAccounts));
        }
Пример #17
0
        public async Task <IActionResult> GetAll([FromQuery] SubjectParams subjectParams, [FromQuery] string type = null, [FromQuery] string category = "exam")
        {
            var questions = await _repo.GetAll <Question>(null, "");

            if (type != null)
            {
                switch (type)
                {
                case "reading":
                    switch (category)
                    {
                    case "exam":
                        var readingExamQuestions = questions.Where(q => q.IsFillOutQuestion && q.IsQuizQuestion == false).ToList();
                        return(Ok(readingExamQuestions));

                    case "quiz":
                        var readingQuizQuestions = questions.Where(q => q.IsListeningQuestion == false && q.IsQuizQuestion).ToList();
                        return(Ok(readingQuizQuestions));

                    default:
                        break;
                    }
                    break;

                case "listening":
                    switch (category)
                    {
                    case "exam":
                        var listeningExamQuestions = questions.Where(q => q.IsListeningQuestion && q.IsQuizQuestion == false).ToList();
                        return(Ok(listeningExamQuestions));

                    case "quiz":
                        var listeningQuizQuestions = questions.Where(q => q.IsListeningQuestion && q.IsQuizQuestion).ToList();
                        return(Ok(listeningQuizQuestions));

                    default:
                        break;
                    }
                    break;

                default:
                    break;
                }
            }
            return(Ok(questions));
        }
Пример #18
0
    ///////////////////////////////////////////////////////////////////////////////
    // Construction and Initializing methods                                     //
    ///////////////////////////////////////////////////////////////////////////////
    #region CONSTRUCTION

    /// <summary>
    /// Initializes a new instance of the SubjectVariable class.
    /// </summary>
    /// <param name="newFlag">A flag that unique identifies this variable.</param>
    /// <param name="newColumnName">The short name (8 characters) of the column in which the value should be written.</param>
    /// <param name="newColumnDescription">The long description of the column that describes the variable.</param>
    /// <param name="newColumnType">The <see cref="Type"/> of the column contents.</param>
    /// <param name="newColumnFormat">A <see cref="string"/> with the column formatting. (e.g. "N2")</param>
    /// <param name="newCheckBox">The <see cref="CheckBox"/> that enables or disables this variable.</param>
    /// <param name="newReturnValues">A <see cref="string"/> describing the return values of this
    /// variable.</param>
    public SubjectVariable(
      SubjectParams newFlag, 
      string newColumnName,
      string newColumnDescription,
      Type newColumnType, 
      string newColumnFormat, 
      CheckBox newCheckBox, 
      string newReturnValues)
      : base(
      newColumnName, 
      newColumnDescription, 
      newColumnType, 
      newColumnFormat,
      newCheckBox, 
      newReturnValues)
    {
      this.paramFlag = newFlag;
    }
Пример #19
0
        ///////////////////////////////////////////////////////////////////////////////
        // Construction and Initializing methods                                     //
        ///////////////////////////////////////////////////////////////////////////////
        #region CONSTRUCTION

        /// <summary>
        /// Initializes a new instance of the SubjectVariable class.
        /// </summary>
        /// <param name="newFlag">A flag that unique identifies this variable.</param>
        /// <param name="newColumnName">The short name (8 characters) of the column in which the value should be written.</param>
        /// <param name="newColumnDescription">The long description of the column that describes the variable.</param>
        /// <param name="newColumnType">The <see cref="Type"/> of the column contents.</param>
        /// <param name="newColumnFormat">A <see cref="string"/> with the column formatting. (e.g. "N2")</param>
        /// <param name="newCheckBox">The <see cref="CheckBox"/> that enables or disables this variable.</param>
        /// <param name="newReturnValues">A <see cref="string"/> describing the return values of this
        /// variable.</param>
        public SubjectVariable(
            SubjectParams newFlag,
            string newColumnName,
            string newColumnDescription,
            Type newColumnType,
            string newColumnFormat,
            CheckBox newCheckBox,
            string newReturnValues)
            : base(
                newColumnName,
                newColumnDescription,
                newColumnType,
                newColumnFormat,
                newCheckBox,
                newReturnValues)
        {
            this.paramFlag = newFlag;
        }
Пример #20
0
        public async Task <IActionResult> GetSections([FromQuery] SubjectParams subjectParams)
        {
            var sections = await _repo.GetAll <Section>(subjectParams, includeProperties : "Quizzes");

            var returnSections = _mapper.Map <IEnumerable <SectionDTO> >(sections);

            if (User.FindFirst(ClaimTypes.NameIdentifier) != null)
            {
                var userId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value);
                foreach (var section in returnSections)
                {
                    var done = await _repo.GetOneWithCondition <AccountSection>(a => a.AccountId == userId && a.SectionId == section.Id);

                    if (done != null)
                    {
                        section.DPA = done.QuizDoneCount;
                    }
                }
            }
            return(Ok(returnSections));
        }
Пример #21
0
        public async Task <IActionResult> GetAllExam([FromQuery] SubjectParams subjectParams)
        {
            var examsFromDb = await _repo.GetAll <Exam>(subjectParams, expression : null, includeProperties : "ExamHistories", exam => exam.OrderByDescending(o => o.Questions.Count()));

            if (User.FindFirst(ClaimTypes.NameIdentifier) != null)
            {
                var userId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value);
                foreach (var exam in examsFromDb)
                {
                    exam.ExamHistories = exam.ExamHistories.Where(history => history.AccountId == userId && history.IsDoing == false);
                }
            }
            else
            {
                examsFromDb = examsFromDb.SetNullProperty("ExamHistories");
            }
            var returnExams = _mapper.Map <IEnumerable <ExamDTO> >(examsFromDb);

            Response.AddPaginationHeader(examsFromDb.CurrentPage, examsFromDb.PageSize, examsFromDb.TotalItems, examsFromDb.TotalPages);
            return(Ok(returnExams));
        }
Пример #22
0
        // public async Task<PagingList<T>> GetAll<T>(Expression<Func<T, bool>> expression, Func<IQueryable<T>, IOrderedQueryable<T>> orderBy, SubjectParams subjectParams = null, string includeProperties = "") where T : class
        // {
        //     var dbSet = _db.Set<T>();
        //     var queryableDbSet = dbSet.Take(await dbSet.CountAsync());
        //     if(expression != null)
        //     {
        //         queryableDbSet = queryableDbSet.Where(expression);
        //     }
        //     if(includeProperties != null)
        //     {
        //         foreach(var property in includeProperties.Split(new char[] {','}, StringSplitOptions.RemoveEmptyEntries))
        //         {
        //            queryableDbSet =  queryableDbSet.Include(property);
        //         }
        //     }
        //     if(orderBy != null)
        //     {
        //         queryableDbSet =  orderBy(queryableDbSet);
        //     }

        //     return await PagingList<T>.OnCreateAsync(queryableDbSet, subjectParams.CurrentPage, subjectParams.PageSize);
        // }

        public async Task <PagingList <T> > GetAll <T>(SubjectParams subjectParams = null, Expression <Func <T, bool> > expression = null, string includeProperties = "", Func <IQueryable <T>, IOrderedQueryable <T> > orderBy = null) where T : class
        {
            var dbSet          = _db.Set <T>();
            var queryableDbSet = dbSet.Take(await dbSet.CountAsync());

            if (expression != null)
            {
                queryableDbSet = queryableDbSet.Where(expression);
            }
            if (includeProperties != null)
            {
                foreach (var property in includeProperties.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    queryableDbSet = queryableDbSet.Include(property.Trim());
                }
            }
            if (orderBy != null)
            {
                queryableDbSet = orderBy(queryableDbSet);
            }
            return(await PagingList <T> .OnCreateAsync(queryableDbSet, subjectParams.CurrentPage, subjectParams.PageSize));
        }
Пример #23
0
        public async Task <IActionResult> GetGroupsOfAccount([FromQuery] SubjectParams subjectParams, int accountId)
        {
            if (User.FindFirst(ClaimTypes.NameIdentifier) != null)
            {
                int id = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value);
                if (id != accountId)
                {
                    return(Unauthorized());
                }
            }
            var groupsOfAcc = await _repo.GetOneWithManyToMany <Group>(g => g.AccountId == accountId);

            var groups = await groupsOfAcc.Include(a => a.Account).Include(g => g.Words).ThenInclude(g => g.Word).ThenInclude(w => w.Examples).ThenInclude(e => e.Example).ToListAsync();

            var returnGroups = _mapper.Map <IEnumerable <GroupDTO> >(groups);

            if (groupsOfAcc == null)
            {
                return(NotFound());
            }
            return(Ok(returnGroups));
        }
Пример #24
0
        public async Task <IActionResult> GetPost(int id, [FromQuery] SubjectParams subjectParams, [FromQuery] string orderBy = "newest")
        {
            var postQuery = await _repo.GetOneWithManyToMany <Post>(pos => pos.Id == id);

            var post = await postQuery.Include(p => p.Account).Include(p => p.Comments).ThenInclude(c => c.Account).FirstOrDefaultAsync();

            if (post == null)
            {
                return(NotFound());
            }
            post.Comments = post.Comments.Where(c => c.IsReplyComment == false);
            foreach (var comment in post.Comments)
            {
                var temp = await _repo.GetOneWithManyToMany <CommentReply>(r => r.CommentId == comment.Id);

                comment.Replies = await temp.Include(r => r.Reply).ThenInclude(a => a.Account).ToListAsync();
            }
            var returnPost = _mapper.Map <PostDetailDTO>(post);

            switch (orderBy)
            {
            case "like":
                returnPost.Comments = returnPost.Comments.Where(c => c.IsReplyComment == false).OrderByDescending(c => c.Like).ToList();
                break;

            case "newest":
                returnPost.Comments = returnPost.Comments.Where(c => c.IsReplyComment == false).OrderByDescending(c => c.Date).ToList();
                break;

            case "oldest":
                returnPost.Comments = returnPost.Comments.Where(c => c.IsReplyComment == false).OrderBy(c => c.Date).ToList();
                break;

            default: break;
            }
            return(Ok(returnPost));
        }
Пример #25
0
        private void ButtonSelectConfigFile_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog fileDialog = new OpenFileDialog
            {
                InitialDirectory = Environment.CurrentDirectory,
                Filter           = "ini 配置文件|*.ini",
                Multiselect      = false,
            };

            if (fileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                ViewModel.ConfigFilePath = fileDialog.FileName;
            }
            ;
            PushMessage("加载配置文件中。\n");
            if (Workbook != null)
            {
                Workbook.Save();
                Workbook.Close();
                SheetName2ExcelSheet.Clear();
                SheetConfigModels.Clear();
                BodyParams.Clear();
                SubjectParams.Clear();
                MailToParams.Clear();
                OutPutText.Clear();
                ParamsDict.Clear();
                buttonStart.Click        -= ButtonStart_Click;
                buttonSendTestMail.Click -= ButtonSendTestMail_Click;
            }
            bool loadSuccess = LoadConfig();

            if (loadSuccess)
            {
                buttonStart.Click        += ButtonStart_Click;
                buttonSendTestMail.Click += ButtonSendTestMail_Click;
            }
        }
Пример #26
0
    /// <summary>
    /// The <see cref="Control.Click"/> event handler for the
    ///   <see cref="ToolStripMenuItem"/> <see cref="cmuRemoveColumn"/>.
    ///   Context menu delete column clicked.
    /// </summary>
    /// <param name="sender">
    /// Source of the event
    /// </param>
    /// <param name="e">
    /// An empty <see cref="EventArgs"/>
    /// </param>
    private void cmuRemoveColumn_Click(object sender, EventArgs e)
    {
      int index = this.dGVExportTable.HitTest(this.mouseClickLocation.X, this.mouseClickLocation.Y).ColumnIndex;
      if (index <= this.dGVExportTable.Columns.Count && index >= 0)
      {
        string currentColumnName = this.dGVExportTable.Columns[index].Name;
        if (this.dGVExportTable.Columns[currentColumnName] != null)
        {
          this.dGVExportTable.Columns.Remove(currentColumnName);
          foreach (DefaultVariable var in this.defaultVariables.Values)
          {
            if (var.ColumnName == currentColumnName)
            {
              var.CheckBox.Checked = false;
              if (var is SubjectVariable)
              {
                this.subjectParams &= ~((SubjectVariable)var).Flag;
              }
              else if (var is TrialVariable)
              {
                this.trialParams &= ~((TrialVariable)var).Flag;
              }
              else if (var is GazeVariable)
              {
                this.gazeParams &= ~((GazeVariable)var).Flag;
              }
              else if (var is MouseVariable)
              {
                this.mouseParams &= ~((MouseVariable)var).Flag;
              }

              break;
            }
          }

          foreach (CustomVariable var in this.gazeCustomParams)
          {
            if (var.ColumnName == currentColumnName)
            {
              this.gazeCustomParams.Remove(var);
              break;
            }
          }

          foreach (CustomVariable var in this.mouseCustomParams)
          {
            if (var.ColumnName == currentColumnName)
            {
              this.mouseCustomParams.Remove(var);
              break;
            }
          }
        }
      }
    }
Пример #27
0
    ///////////////////////////////////////////////////////////////////////////////
    // Construction and Initializing methods                                     //
    ///////////////////////////////////////////////////////////////////////////////
    #region CONSTRUCTION

    /// <summary>
    /// Initializes a new instance of the Statistic class.
    /// Initializes variables to calculate by setting the flag members
    /// of this Statistics object.
    /// </summary>
    /// <param name="newSubjectParams">A <see cref="SubjectParams"/> with the flags set to the
    /// subject variables that should be calculated.</param>
    /// <param name="newTrialParams">A <see cref="TrialParams"/> with the flags set to the
    /// trial variables that should be calculated.</param>
    /// <param name="newGazeParams">A <see cref="GazeParams"/> with the flags set to the
    /// gaze variables that should be calculated.</param>
    /// <param name="newGazeCustomParams">A <see cref="List{CustomVariable}"/> with
    /// custom defined gaze variables. Will only be used, when <see cref="GazeParams.Custom"/>
    /// is set.</param>
    /// <param name="newMouseParams">A <see cref="MouseParams"/> with the flags set to the
    /// mouse variables that should be calculated.</param>
    /// <param name="newMouseCustomParams">A <see cref="List{CustomVariable}"/> with
    /// custom defined mouse variables. Will only be used, when <see cref="MouseParams.Custom"/>
    /// is set.</param>
    /// <param name="newTolerance">A <see cref="int"/> tolerance value for 
    /// widening areas of interest to get a better hit rate in pixel.</param>
    public Statistic(
      SubjectParams newSubjectParams,
      TrialParams newTrialParams,
      GazeParams newGazeParams,
      List<CustomVariable> newGazeCustomParams,
      MouseParams newMouseParams,
      List<CustomVariable> newMouseCustomParams,
      int newTolerance)
    {
      this.subjectParams = newSubjectParams;
      this.trialParams = newTrialParams;
      this.gazeParams = newGazeParams;
      this.gazeCustomParams = newGazeCustomParams != null ? newGazeCustomParams : new List<CustomVariable>();
      this.mouseParams = newMouseParams;
      this.mouseCustomParams = newMouseCustomParams != null ? newMouseCustomParams : new List<CustomVariable>();
      tolerance = newTolerance;
    }
Пример #28
0
        public async Task <IActionResult> GetPublishedBanner([FromQuery] SubjectParams subjectParams)
        {
            var banners = await _repo.GetAll <Banner>(subjectParams, banner => banner.IsPublished == true);

            return(Ok(banners));
        }
Пример #29
0
        public async Task <IActionResult> GetAllBanner([FromQuery] SubjectParams subjectParams)
        {
            var banners = await _repo.GetAll <Banner>(subjectParams);

            return(Ok(banners));
        }
Пример #30
0
        public async Task <IActionResult> GetAllFooter([FromQuery] SubjectParams subjectParams)
        {
            var footersFromDb = await _repo.GetAll <Footer>(subjectParams);

            return(Ok(footersFromDb));
        }
Пример #31
0
        /// <summary>
        /// 加载配置文件
        /// </summary>
        /// <returns></returns>
        private bool LoadConfig()
        {
            string configPath = ViewModel.ConfigFilePath;

            if (File.Exists(configPath))
            {
                try
                {
                    MainConfigModel = new MainConfigModel
                    {
                        FilePath              = IniFileReadUtil.ReadIniData("Main", "FilePath", null, configPath),
                        SuccessSimple         = IniFileReadUtil.ReadIniData("Main", "SuccessSimple", null, configPath),
                        SuccessSimpleLocation = IniFileReadUtil.ReadIniData("Main", "SuccessSimpleLocation", null, configPath),
                        SheetNames            = IniFileReadUtil.ReadIniData("Main", "SheetNames", null, configPath).Split(',').ToList(),
                        MainSheetName         = IniFileReadUtil.ReadIniData("Main", "MainSheetName", null, configPath),
                        TemplatePath          = IniFileReadUtil.ReadIniData("Main", "TemplatePath", null, configPath),
                        BodyParamCount        = int.Parse(IniFileReadUtil.ReadIniData("Main", "BodyParamCount", null, configPath)),
                        SubjectParamCount     = int.Parse(IniFileReadUtil.ReadIniData("Main", "SubjectParamCount", null, configPath)),
                        MailToParamCount      = int.Parse(IniFileReadUtil.ReadIniData("Main", "MailToParamCount", null, configPath)),
                        AttachmentCount       = int.Parse(IniFileReadUtil.ReadIniData("Main", "AttachmentCount", null, configPath)),
                    };
                    MailConfigModel = new MailConfigModel
                    {
                        MailTo       = IniFileReadUtil.ReadIniData("Mail", "MailTo", null, configPath),
                        MailAddress  = IniFileReadUtil.ReadIniData("Mail", "MailAddress", null, configPath),
                        MailPassword = IniFileReadUtil.ReadIniData("Mail", "MailPassword", null, configPath),
                        MailSubject  = IniFileReadUtil.ReadIniData("Mail", "MailSubject", null, configPath),
                        SMTPAddress  = IniFileReadUtil.ReadIniData("Mail", "SMTPAddress", null, configPath),
                        Port         = int.Parse(IniFileReadUtil.ReadIniData("Mail", "Port", null, configPath)),
                        EnableSsl    = bool.Parse(IniFileReadUtil.ReadIniData("Mail", "EnableSsl", null, configPath)),
                        Priority     = int.Parse(IniFileReadUtil.ReadIniData("Mail", "Priority", null, configPath)),
                    };
                    foreach (var sheetName in MainConfigModel.SheetNames)
                    {
                        SheetConfigModel sheetConfigModel = new SheetConfigModel
                        {
                            StartingLine           = int.Parse(IniFileReadUtil.ReadIniData(sheetName, "StartingLine", null, configPath)),
                            EndLine                = int.Parse(IniFileReadUtil.ReadIniData(sheetName, "EndLine", null, configPath)),
                            UniquelyIdentifiesLine = IniFileReadUtil.ReadIniData(sheetName, "UniquelyIdentifiesLine", null, configPath),
                        };
                        SheetConfigModels[sheetName] = sheetConfigModel;
                    }
                    for (int i = 0; i < MainConfigModel.BodyParamCount; i++)
                    {
                        BodyParams.Add(IniFileReadUtil.ReadIniData("BodyParams", i.ToString(), null, configPath));
                    }
                    for (int i = 0; i < MainConfigModel.SubjectParamCount; i++)
                    {
                        SubjectParams.Add(IniFileReadUtil.ReadIniData("SubjectParams", i.ToString(), null, configPath));
                    }
                    for (int i = 0; i < MainConfigModel.MailToParamCount; i++)
                    {
                        MailToParams.Add(IniFileReadUtil.ReadIniData("MailToParams", i.ToString(), null, configPath));
                    }
                    for (int i = 0; i < MainConfigModel.AttachmentCount; i++)
                    {
                        Attachments.Add(IniFileReadUtil.ReadIniData("Attachments", i.ToString(), null, configPath));
                    }
                    //加载工作簿相关内容
                    Workbook = LoadWorkbook(MainConfigModel.FilePath);
                    foreach (var sheetName in MainConfigModel.SheetNames)
                    {
                        SheetName2ExcelSheet[sheetName] = LoadWorksheet(Workbook, sheetName);
                    }
                    PushMessage("读取成功。\n");
                    return(true);
                }
                catch (Exception ex)
                {
                    PushMessage("读取失败。\n");
                    PushMessage(ex.Message + "\n");
                    return(false);
                }
            }
            else
            {
                PushMessage("找不到配置文件!\n");
                return(false);
            }
        }
Пример #32
0
 /// <summary>
 /// User switched a default check box in Tab "Subject information".
 ///   Add referring column to datagridview table and set analysis flag.
 /// </summary>
 /// <param name="sender">
 /// Source of the event.
 /// </param>
 /// <param name="e">
 /// An empty <see cref="EventArgs"/>
 /// </param>
 private void chbSubjectDefault_CheckedChanged(object sender, EventArgs e)
 {
   var chbSender = (CheckBox)sender;
   var var = (SubjectVariable)this.defaultVariables[chbSender.Name];
   this.InsertOrRemoveColumn(chbSender.Checked, var);
   if (chbSender.Checked)
   {
     this.subjectParams |= var.Flag;
   }
   else
   {
     this.subjectParams &= ~var.Flag;
   }
 }
Пример #33
0
        public async Task <IActionResult> GetAll(SubjectParams subjectParams)
        {
            var certificates = await _repo.GetAll <Certificate>(subjectParams);

            return(Ok(certificates));
        }
Пример #34
0
 /// <summary>
 /// The <see cref="CheckedListBox.ItemCheck"/> event handler.
 ///   Inserts or removes the selected custom subject parameter
 ///   from the statistics output table.
 /// </summary>
 /// <param name="sender">
 /// Source of the event.
 /// </param>
 /// <param name="e">
 /// An <see cref="ItemCheckEventArgs"/> with the event data.
 /// </param>
 private void clbSUBCustomparameters_ItemCheck(object sender, ItemCheckEventArgs e)
 {
   var var = (SubjectVariable)this.defaultVariables["SUB_C" + e.Index.ToString()];
   bool isChecked = e.NewValue == CheckState.Checked ? true : false;
   this.InsertOrRemoveColumn(isChecked, var);
   if (isChecked)
   {
     this.subjectParams |= var.Flag;
   }
   else
   {
     this.subjectParams &= ~var.Flag;
   }
 }
Пример #35
0
 public async Task <IActionResult> GetAll(SubjectParams subjectParams)
 {
     return(Ok(await _repo.GetAll <History>(subjectParams, "Account,Subject")));
 }