Beispiel #1
0
 public HistorySessionTest()
 {
     _client = new Client()
     {
         HistoryList = new HistoryList(), RegisterMap = Vim.RegisterMap
     };
     _historySession = HistoryUtil.CreateHistorySession(_client, 0, "");
     _bindData       = _historySession.CreateBindDataStorage().CreateBindData();
 }
        // APIs to get the state of an entity at a specific point in time

        /*
         * [HttpGet("/api/Exhibits/{id}/History/{timestamp}")]
         * public Task<IActionResult> GetExhibitVersion(int id, DateTimeOffset timestamp) =>
         *  GetVersionAsync<Exhibit>(ResourceType.Exhibit, id, timestamp);
         *
         * [HttpGet("/api/Exhibits/Pages/{id}/History/{timestamp}")]
         * public Task<IActionResult> GetExhibitPageVersion(int id, DateTimeOffset timestamp) =>
         *  GetVersionAsync<ExhibitPage>(ResourceType.ExhibitPage, id, timestamp);
         *
         * [HttpGet("/api/Media/{id}/History/{timestamp}")]
         * public Task<IActionResult> GetMediaVersion(int id, DateTimeOffset timestamp) =>
         *  GetVersionAsync<MediaElement>(ResourceType.Media, id, timestamp);
         *
         * [HttpGet("/api/Routes/{id}/History/{timestamp}")]
         * public Task<IActionResult> GetRouteVersion(int id, DateTimeOffset timestamp) =>
         *  GetVersionAsync<Route>(ResourceType.Route, id, timestamp);
         *
         * [HttpGet("/api/Tags/{id}/History/{timestamp}")]
         * public Task<IActionResult> GetTagVersion(int id, DateTimeOffset timestamp) =>
         *  GetVersionAsync<Route>(ResourceType.Tag, id, timestamp);
         */


        // Private helper methods

        private async Task <IActionResult> GetSummaryAsync(ResourceType type, int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (!UserPermissions.IsAllowedToGetHistory(User.Identity, _entityIndex.Owner(type, id)))
            {
                return(Forbid());
            }

            var summary = await HistoryUtil.GetSummaryAsync(_eventStore.EventStream, (type, id));

            return(Ok(summary));
        }
Beispiel #3
0
 /// <summary>
 /// 往前一天查询:天数间隔不超过7天
 /// </summary>
 public void LastDay()
 {
     if (Mathf.Abs(skipDayNum - 1) < 7)
     {
         HistoryDetail_Hour.SetActive(false);
         HistoryDetail_Minute.SetActive(false);
         skipDayNum--;
         DateTime skipDay = DateTime.Now.AddDays(skipDayNum);
         time     = skipDay.ToString("yyyyMMdd");
         HourTime = 24;
         util     = new HistoryUtil(time, HourTime, tableName, columnIndex, brand);
         HistoryDetail_Hour.SetActive(true);
         HistoryDetail_Minute.SetActive(false);
         hdbh.Init();
     }
 }
Beispiel #4
0
        public HistorySessionTest()
        {
            _client = new Client()
            {
                HistoryList = new HistoryList(), RegisterMap = Vim.RegisterMap
            };

            var vimBuffer = CreateVimBuffer();

            _historySession = HistoryUtil.CreateHistorySession(
                _client,
                0,
                EditableCommand.Empty,
                vimBuffer.VimTextBuffer.LocalAbbreviationMap,
                vimBuffer.MotionUtil);
            _bindData = _historySession.CreateBindDataStorage().CreateMappedBindData();
        }
Beispiel #5
0
    /// <summary>
    /// 初始化
    /// </summary>
    /// <param name="tableName">数据库表明</param>
    /// <param name="index">条目序号</param>
    public void Init(string brand, string deviceName, string titleName, string tableName, int index)
    {
        this.brand       = brand;
        this.deviceName  = deviceName;
        this.titleName   = titleName;
        this.tableName   = tableName;
        this.columnIndex = index;

        time = DateTime.Now.ToString("yyyyMMdd");
        //time = "20171115";
        HourTime = int.Parse(DateTime.Now.ToString("HH"));
        //HourTime = 23;
        util = new HistoryUtil(time, HourTime, tableName, columnIndex, brand);

        HistoryDetail_Hour.SetActive(true);
        HistoryDetail_Minute.SetActive(false);

        hdbh.Init();
    }
Beispiel #6
0
 public StudentScores(HistoryUtil historyUtil)
 {
     _scores      = new Dictionary <SemesterData, JHSemesterScoreRecord>();
     _historyUtil = historyUtil;
 }
Beispiel #7
0
        private void _worker_DoWork(object sender, DoWorkEventArgs e)
        {
            double total = AllStudentID.Count;
            double count = 0;

            //學期歷程
            Dictionary <string, HistoryUtil> utilCache = GetStudentHistories();
            //學期成績
            Dictionary <string, StudentScores> scoreCache = GetStudentScores(utilCache);
            //聯絡資訊
            Dictionary <string, ContactInfo> contactCache = GetStudentContactInfos();

            //等第對照表
            DegreeMapper degreeMapper = new DegreeMapper();

            Workbook book = new Workbook();

            book.Open(new MemoryStream(Properties.Resources.五專集體報名成績匯入檔));
            Worksheet ws = book.Worksheets[0];

            int rowIndex = 2;

            foreach (JHStudentRecord stu in JHStudent.SelectByIDs(AllStudentID))
            {
                count++;

                int colIndex = 3; //前面三個欄位不用管,直接跳過。

                #region 基本資料
                ws.Cells[rowIndex, colIndex++].PutValue((stu.Class != null) ? stu.Class.Name : "");
                ws.Cells[rowIndex, colIndex++].PutValue(stu.StudentNumber);
                ws.Cells[rowIndex, colIndex++].PutValue(stu.Name);
                ws.Cells[rowIndex, colIndex++].PutValue(stu.IDNumber);
                ws.Cells[rowIndex, colIndex++].PutValue((stu.Gender == "男") ? "1" : "2");
                ws.Cells[rowIndex, colIndex++].PutValue(Global.GetFormatedBirthday(stu.Birthday));
                #endregion

                #region 聯絡資訊
                if (contactCache.ContainsKey(stu.ID))
                {
                    ContactInfo contact = contactCache[stu.ID];
                    ws.Cells[rowIndex, colIndex++].PutValue(contact.PhoneNumber);
                    ws.Cells[rowIndex, colIndex++].PutValue(contact.ZipCode);
                    ws.Cells[rowIndex, colIndex++].PutValue(contact.Address);
                }
                else
                {
                    colIndex += 3; //沒有聯絡資訊直接跳過三個欄位
                }
                #endregion

                #region 學期成績
                //有學期歷程及學期成績才會印
                if (utilCache.ContainsKey(stu.ID) && scoreCache.ContainsKey(stu.ID))
                {
                    #region 領域成績
                    int           scoreStartColIndex = 12;
                    HistoryUtil   util         = utilCache[stu.ID];
                    StudentScores studentScore = scoreCache[stu.ID];

                    SemesterData indexSem = new SemesterData(0, 0, 2);
                    for (int i = 0; i < FiveSemester; i++)
                    {
                        colIndex = scoreStartColIndex + i * Global.GetDomains().Count;

                        indexSem = indexSem.NextSemester();
                        if (util.ExistByGradeYear(indexSem.GradeYear, indexSem.Semester) == false)
                        {
                            continue;
                        }

                        foreach (decimal?score in studentScore.GetScoreList(util.SemesterData))
                        {
                            string value = score.HasValue ? degreeMapper.GetDegreeByScore(score.Value) : "";
                            if (ScoreMode) //如果是 ScoreMode,則印出分數
                            {
                                ws.Cells[rowIndex, colIndex++].PutValue("" + score);
                            }
                            else
                            {
                                ws.Cells[rowIndex, colIndex++].PutValue(value);
                            }
                        }
                    }
                    #endregion

                    #region 總平均
                    colIndex = scoreStartColIndex + FiveSemester * Global.GetDomains().Count;
                    decimal?averageScore = studentScore.GetAverage(util.AllSemesterData);
                    string  averageValue = averageScore.HasValue ? degreeMapper.GetDegreeByScore(averageScore.Value) : "";
                    if (ScoreMode) //如果是 ScoreMode,則印出分數
                    {
                        ws.Cells[rowIndex, colIndex++].PutValue("" + averageScore);
                    }
                    else
                    {
                        ws.Cells[rowIndex, colIndex++].PutValue(averageValue);
                    }
                    #endregion
                }
                #endregion

                _worker.ReportProgress((int)(count * 100 / total));
                rowIndex++;
            }

            e.Result = book;
        }