/// <summary>
        /// 輸出一列資料
        /// </summary>
        /// <param name="StudentObj"></param>
        public void OutRowData(ValueObj.StudentVO StudentObj)
        {
            int columnIndex = 0;
            _RowIndex++;

            if (_RowIndex > _MAX_ROW_COUNT)
            {
                _IsOverRow = true;
                return;
            }

            // 學生姓名
            SetColumnValue(_OutCells, columnIndex++, StudentObj.StudentName, _Style_Normal);
            // 身分證統一編號
            SetColumnValue(_OutCells, columnIndex++, StudentObj.StudentIdNumber, _Style_Normal);
            // 生日
            if (StudentObj.StudentBirthday.HasValue)
            {
                // 出生年
                string tmp = ((StudentObj.StudentBirthday.Value.Year) - 1911).ToString().PadLeft(3, '0');
                SetColumnValue(_OutCells, columnIndex++, tmp, _Style_Normal);
                // 出生月
                tmp = StudentObj.StudentBirthday.Value.Month.ToString().PadLeft(2, '0');
                SetColumnValue(_OutCells, columnIndex++, tmp, _Style_Normal);
                // 出生日
                tmp = StudentObj.StudentBirthday.Value.Day.ToString().PadLeft(2, '0');
                SetColumnValue(_OutCells, columnIndex++, tmp, _Style_Normal);
            }
            else
            {
                // 出生年
                SetColumnValue(_OutCells, columnIndex++, "000", _Style_Normal);
                // 出生月
                SetColumnValue(_OutCells, columnIndex++, "00", _Style_Normal);
                // 出生日
                SetColumnValue(_OutCells, columnIndex++, "00", _Style_Normal);
            }
            // 就近入學
            SetColumnValue(_OutCells, columnIndex++, "00", _Style_Normal);
            // 扶助弱勢	均衡學習	德行表現	無記過紀錄	獎勵紀錄
            for (int intI = 0; intI < StudentObj.ItemList.Count; intI++)
            {
                decimal point = StudentObj.ItemList.Values.ToArray()[intI];

                // 針對某些欄位格式化
                switch (intI)
                {
                    case Global.index_BalanceLearning:
                        SetColumnValue(_OutCells, columnIndex++, point.ToString().PadLeft(2, '0'), _Style_Normal);
                        break;
                    case Global.index_Merit:
                        SetColumnValue(_OutCells, columnIndex++, String.Format("{0:0.0}", point), _Style_Normal);
                        break;
                    default:
                        SetColumnValue(_OutCells, columnIndex++, point.ToString(), _Style_Normal);
                        break;
                }
            }
        }
 /// <summary>
 /// Change a single value in the list
 /// </summary>
 /// <param name="id">The id of the value to be changed</param>
 /// <param name="value">The new value</param>
 public void Put(int id, [FromBody] ValueObj value)
 {
     if (value == null)
     {
         value = new ValueObj("PutValue");
     }
     lista[id] = value;
 }
        /// <summary>
        /// Insert a single value in the list
        /// </summary>
        /// <param name="value">New value to be inserted</param>
        public void Post([FromBody] ValueObj value)
        {
            if (value == null)
            {
                value = new ValueObj("AddValue");
            }

            lista.Add(value);
        }
Exemple #4
0
 public int CheckValueExist(ValueObj _valueobj)
 {
     for (int i = 0; i < (int)m_List.Count; i++)
     {
         if ((_valueobj.ValueType == m_List[i].ValueType) && (_valueobj.Val.UDINT == m_List[i].Val.UDINT))
         {
             return(i);
         }
     }
     return(-1);
 }
Exemple #5
0
        public int Add(ValueObj _valueobj)
        {
            int ret;

            if ((ret = CheckValueExist(_valueobj)) == -1)
            {
                ValueObj valueobj = new ValueObj();
                valueobj.Val.UDINT = _valueobj.Val.UDINT;
                valueobj.ValueType = _valueobj.ValueType;
                this.m_List.Add(valueobj);
                return(m_List.Count - 1);
            }
            return(ret);
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Recommended constructor used to initialize data. </summary>
        ///
        /// <remarks>   Aedmonds, 8/25/2017. </remarks>
        ///
        /// <param name="colorInfo">    Integer array of color values [r,g,b,a]. </param>
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        public Color(int[] colorInfo)
        {
            //ColorData = colorInfo.ToList<int>();
            ColorData           = colorInfo.ToList <int>();
            LAB                 = colorInfo.ToList <int>();
            InternalLAB         = string.Join(",", LAB);
            InternalColorString = string.Join(",", ColorData);
            ColorStyle          = _displayColorStyle(ColorData);
            ColorString         = _displayColorData(ColorData);
            TimeStamp           = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
            WorkspaceId         = WorkspaceId;

            R = new ValueObj
            {
                Value   = ColorData[0],
                Percent = (int)Math.Round((double)(ColorData[0] / 256 * 100))
                          //Value = RGB[0],
                          //Percent = (int)Math.Round((double)(RGB[0] / 256 * 100))
            };
            G = new ValueObj
            {
                Value = ColorData[1],
                //Value = RGB[1],
                Percent = (int)Math.Round((double)(ColorData[1] / 256 * 100))
            };
            B = new ValueObj
            {
                Value = ColorData[2],
                //Value = RGB[2],
                Percent = (int)Math.Round((double)(ColorData[2] / 256 * 100))
            };

            //L.A.B
            L = new ValueObj
            {
                Value   = LAB[0],
                Percent = (int)Math.Round((float)(LAB[0] / 256 * 100))
            };
            A = new ValueObj
            {
                Value   = LAB[1],
                Percent = (int)Math.Round((float)(LAB[1] / 256 * 100))
            };
            Blab = new ValueObj
            {
                Value   = LAB[2],
                Percent = (int)Math.Round((float)(LAB[2] / 256 * 100))
            };
        }
Exemple #7
0
        /// <summary>
        /// Change a single value in the list
        /// </summary>
        /// <param name='id'>
        /// The id of the value to be changed
        /// </param>
        /// <param name='value'>
        /// The new value
        /// </param>
        /// <param name='customHeaders'>
        /// Headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        /// <return>
        /// A response object containing the response body and response headers.
        /// </return>
        public async Task <HttpOperationResponse> PutByidvalueWithHttpMessagesAsync(int id, ValueObj value, Dictionary <string, List <string> > customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (value == null)
            {
                throw new ValidationException(ValidationRules.CannotBeNull, "value");
            }
            // Tracing
            bool   _shouldTrace  = ServiceClientTracing.IsEnabled;
            string _invocationId = null;

            if (_shouldTrace)
            {
                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
                Dictionary <string, object> tracingParameters = new Dictionary <string, object>();
                tracingParameters.Add("id", id);
                tracingParameters.Add("value", value);
                tracingParameters.Add("cancellationToken", cancellationToken);
                ServiceClientTracing.Enter(_invocationId, this, "PutByidvalue", tracingParameters);
            }
            // Construct URL
            var _baseUrl = this.Client.BaseUri.AbsoluteUri;
            var _url     = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "api/Values/{id}").ToString();

            _url = _url.Replace("{id}", Uri.EscapeDataString(SafeJsonConvert.SerializeObject(id, this.Client.SerializationSettings).Trim('"')));
            // Create HTTP transport objects
            HttpRequestMessage  _httpRequest  = new HttpRequestMessage();
            HttpResponseMessage _httpResponse = null;

            _httpRequest.Method     = new HttpMethod("PUT");
            _httpRequest.RequestUri = new Uri(_url);
            // Set Headers
            if (customHeaders != null)
            {
                foreach (var _header in customHeaders)
                {
                    if (_httpRequest.Headers.Contains(_header.Key))
                    {
                        _httpRequest.Headers.Remove(_header.Key);
                    }
                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
                }
            }

            // Serialize Request
            string _requestContent = null;

            if (value != null)
            {
                _requestContent      = SafeJsonConvert.SerializeObject(value, this.Client.SerializationSettings);
                _httpRequest.Content = new StringContent(_requestContent, Encoding.UTF8);
                _httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
            }
            // Set Credentials
            if (this.Client.Credentials != null)
            {
                cancellationToken.ThrowIfCancellationRequested();
                await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
            }
            // Send Request
            if (_shouldTrace)
            {
                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
            }
            cancellationToken.ThrowIfCancellationRequested();
            _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);

            if (_shouldTrace)
            {
                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
            }
            HttpStatusCode _statusCode = _httpResponse.StatusCode;

            cancellationToken.ThrowIfCancellationRequested();
            string _responseContent = null;

            if ((int)_statusCode != 204)
            {
                var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);

                ex.Request  = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
                if (_shouldTrace)
                {
                    ServiceClientTracing.Error(_invocationId, ex);
                }
                _httpRequest.Dispose();
                if (_httpResponse != null)
                {
                    _httpResponse.Dispose();
                }
                throw ex;
            }
            // Create Result
            var _result = new HttpOperationResponse();

            _result.Request  = _httpRequest;
            _result.Response = _httpResponse;
            if (_shouldTrace)
            {
                ServiceClientTracing.Exit(_invocationId, _result);
            }
            return(_result);
        }
        /// <summary>
        /// 處理扶助弱勢
        /// </summary>
        /// <param name="studentObj"></param>
        /// <param name="tagIdList"></param>
        private decimal Cal_VulnerableGroups(ValueObj.StudentVO studentObj, Dictionary<string, List<string>> tagIdList)
        {
            int ItemIndex = Global.index_VulnerableGroups;
            // 取得大項目的條件
            ValueObj.ItemConditionVO itemCondition = new ValueObj.ItemConditionVO(ItemIndex);
            // 取得子項目的條件
            ValueObj.DetailItemConditionVO detailCondition = new ValueObj.DetailItemConditionVO(ItemIndex);
            // 大項目名稱
            string itemName = itemCondition.ItemName;
            // 項目的積分
            decimal ItemTotalPoints = 0;

            // loop 每個子項目
            for (int intI = 0; intI < Global.DetailItemNameList[ItemIndex].Length; intI++)
            {
                // 子項目名稱
                string detailItemName = Global.DetailItemNameList[ItemIndex][intI];
                // 子項目積分
                decimal points = detailCondition.DetailItemListDic[detailItemName];

                // 看學生的類別有沒有在TagIdList
                bool isFound = Utility.IsContansTagId(studentObj.StudentTagId, tagIdList[detailItemName]);

                if (isFound == false)
                {
                    points = 0;
                }

                // 取得detail item in student
                ValueObj.DetailItemVO detailItem = studentObj.DetailItemList[itemName][detailItemName];

                // 回存此項目顯示的內容
                detailItem.Value = "TagID: " + string.Join(",", tagIdList[detailItemName].ToArray());
                // 回存此項目的積分
                detailItem.Points = points;

                // 加總
                ItemTotalPoints += points;
            }

            // 假如超過上限, 就以上限為主
            ItemTotalPoints = (ItemTotalPoints > itemCondition.MaxItemPoints) ? itemCondition.MaxItemPoints : ItemTotalPoints;

            // 此學生在這個項目的積分
            studentObj.ItemList[itemName] = ItemTotalPoints;

            return ItemTotalPoints;
        }
        /// <summary>
        /// 排序:年級/班級序號/班級名稱/座號/學號/姓名
        /// </summary>
        /// <param name="obj1"></param>
        /// <param name="obj2"></param>
        private int SortStudent(ValueObj.StudentVO obj1, ValueObj.StudentVO obj2)
        {
            string seatno1 = obj1.ClassGradeYear.PadLeft(1, '0');   // 年級
            seatno1 += obj1.ClassDisplayOrder.PadLeft(3, '0');      // 班級序號
            seatno1 += obj1.ClassName.PadLeft(20, '0');             // 班級名稱
            seatno1 += obj1.StudentSeatNo.PadLeft(3, '0');          // 座號
            seatno1 += obj1.StudentNumber.PadLeft(20, '0');         // 學號
            seatno1 += obj1.StudentName.PadLeft(10, '0');           // 姓名

            string seatno2 = obj2.ClassGradeYear.PadLeft(1, '0');   // 年級
            seatno2 += obj2.ClassDisplayOrder.PadLeft(3, '0');      // 班級序號
            seatno2 += obj2.ClassName.PadLeft(20, '0');             // 班級名稱
            seatno2 += obj2.StudentSeatNo.PadLeft(3, '0');          // 座號
            seatno2 += obj2.StudentNumber.PadLeft(20, '0');         // 學號
            seatno2 += obj2.StudentName.PadLeft(10, '0');           // 姓名

            return seatno1.CompareTo(seatno2);
        }
        private bool CheckAssingmentIsValidValue(string str, string typestr)
        {
            ValueObj _valueobj = new ValueObj();

            if ((typestr.ToUpper() == "BOOL") && Common.IsValueBOOL(str, ref _valueobj))
            {
                return(true);
            }
            if ((typestr.ToUpper() == "BYTE") && Common.IsValueBYTE(str, ref _valueobj))
            {
                return(true);
            }
            if ((typestr.ToUpper() == "WORD") && Common.IsValueWORD(str, ref _valueobj))
            {
                return(true);
            }
            if ((typestr.ToUpper() == "DWORD") && Common.IsValueDWORD(str, ref _valueobj))
            {
                return(true);
            }
            if ((typestr.ToUpper() == "LWORD") && Common.IsValueLWORD(str, ref _valueobj))
            {
                return(true);
            }
            if ((typestr.ToUpper() == "SINT") && Common.IsValueSINT(str, ref _valueobj))
            {
                return(true);
            }
            if ((typestr.ToUpper() == "INT") && Common.IsValueINT(str, ref _valueobj))
            {
                return(true);
            }
            if ((typestr.ToUpper() == "DINT") && Common.IsValueDINT(str, ref _valueobj))
            {
                return(true);
            }
            if ((typestr.ToUpper() == "LINT") && Common.IsValueLINT(str, ref _valueobj))
            {
                return(true);
            }
            if ((typestr.ToUpper() == "USINT") && Common.IsValueUSINT(str, ref _valueobj))
            {
                return(true);
            }
            if ((typestr.ToUpper() == "UINT") && Common.IsValueUINT(str, ref _valueobj))
            {
                return(true);
            }
            if ((typestr.ToUpper() == "UDINT") && Common.IsValueUDINT(str, ref _valueobj))
            {
                return(true);
            }
            if ((typestr.ToUpper() == "ULINT") && Common.IsValueULINT(str, ref _valueobj))
            {
                return(true);
            }
            if ((typestr.ToUpper() == "REAL") && Common.IsValueREAL(str, ref _valueobj))
            {
                return(true);
            }
            if ((typestr.ToUpper() == "LREAL") && Common.IsValueLREAL(str, ref _valueobj))
            {
                return(true);
            }
            if ((typestr.ToUpper() == "COLOR") && Common.IsValueColor(str, ref _valueobj))
            {
                return(true);
            }
            if ((typestr.ToUpper() == "TIME") && Common.IsValueTIME(str, ref _valueobj))
            {
                return(true);
            }
            if ((typestr.ToUpper() == "DATE") && Common.IsValueDATE(str, ref _valueobj))
            {
                return(true);
            }
            if ((typestr.ToUpper() == "TOD") && Common.IsValueTOD(str, ref _valueobj))
            {
                return(true);
            }
            if ((typestr.ToUpper() == "DT") && Common.IsValueDT(str, ref _valueobj))
            {
                return(true);
            }
            return(false);
        }
        /// <summary>
        /// 處理無記過紀錄
        /// </summary>
        /// <param name="studentObj"></param>
        /// <param name="gradeMap"></param>
        /// <param name="demeritObj"></param>
        private decimal Cal_Demerit(ValueObj.StudentVO studentObj, Dictionary<int, ValueObj.SchoolYearSemester> gradeMap, ValueObj.DemeritsVO demeritObj)
        {
            int ItemIndex = Global.index_Demerit;
            // 取得大項目的條件
            ValueObj.ItemConditionVO itemCondition = new ValueObj.ItemConditionVO(ItemIndex);
            // 取得子項目的條件
            ValueObj.DetailItemConditionVO detailCondition = new ValueObj.DetailItemConditionVO(ItemIndex);
            // 取得需要看的學年度學期
            List<ValueObj.SchoolYearSemester> needSchoolYearList = Utility.GetNeedSchoolSemester(itemCondition.NeedSemester, gradeMap);

            // 大項目名稱
            string itemName = itemCondition.ItemName;
            decimal ItemTotalPoints = 0;

            #region 處理無記過紀錄
            // 無記過紀錄名稱
            string detailItemName = Global.DetailItemNameList[ItemIndex][0];
            // 無記過紀錄積分
            decimal noDemeritPoints = detailCondition.DetailItemListDic[detailItemName];

            if (demeritObj != null)
            {
                foreach (ValueObj.SchoolYearSemester schoolYear in needSchoolYearList)
                {
                    if (schoolYear == null) continue;
                    int demeritCnt = demeritObj.GetDemeritsBySchoolYear(schoolYear).Count;
                    // 其中有一個學期被記過或警告, 就為0分
                    if (demeritCnt > 0)
                    {
                        noDemeritPoints = 0;
                        break;
                    }
                }
            }

            // 取得detail item in student
            ValueObj.DetailItemVO detailItem = studentObj.DetailItemList[itemName][detailItemName];

            // 回存此項目顯示的內容
            detailItem.Value = "--";
            // 回存此項目的積分
            detailItem.Points = noDemeritPoints;

            #endregion

            if (noDemeritPoints > 0 )
            {
                // 回存此項目顯示的內容
                detailItem.Value = "無記過紀錄!";

                studentObj.ItemList[itemName] = noDemeritPoints;
                
                // 不處理無小過以上記錄
                return noDemeritPoints;
            }

            #region 處理無小過以上記錄

            int MaxDemeritCount = 3;

            // 無小過以上記錄名稱
            detailItemName = Global.DetailItemNameList[ItemIndex][1];
            // 無小過以上記錄積分
            decimal demeritPoints = detailCondition.DetailItemListDic[detailItemName];

            // loop 每個學期, 取得所有的大過, 小過, 警告
            decimal[] Demerit = new decimal[3];
            foreach (ValueObj.SchoolYearSemester schoolYear in needSchoolYearList)
            {
                if (schoolYear == null) continue;

                List<Data.DemeritRecord> demeritList = demeritObj.GetDemeritsBySchoolYear(schoolYear);

                foreach(Data.DemeritRecord rec in demeritList)
                {
                    if(rec.DemeritA.HasValue)
                        Demerit[0] = rec.DemeritA.Value;
                    if(rec.DemeritB.HasValue)
                        Demerit[1] = rec.DemeritB.Value;
                    if(rec.DemeritC.HasValue)
                        Demerit[2] += rec.DemeritC.Value;
                }
            }

            if (Demerit[0] > 0 || Demerit[1] >0 )
            {
                // 此學生在這個項目的積分
                ItemTotalPoints = 0;
            }
            else
            {
                // 看警告有沒有超過三次
                if (Demerit[2] >= MaxDemeritCount)
                    ItemTotalPoints = 0;
                else
                    ItemTotalPoints = demeritPoints;
            }

            // 取得detail item in student
            detailItem = studentObj.DetailItemList[itemName][detailItemName];

            // 回存此項目顯示的內容
            detailItem.Value = "大過:" + Demerit[0] + ", 小過:" + Demerit[1] + ", 警告:" + Demerit[2];
            // 回存此項目的積分
            detailItem.Points = ItemTotalPoints;
            #endregion

            // 此學生在這個項目的積分
            studentObj.ItemList[itemName] = ItemTotalPoints;
            return ItemTotalPoints;
        }
        /// <summary>
        /// 處理獎勵紀錄
        /// </summary>
        /// <param name="studentObj"></param>
        /// <param name="gradeMap"></param>
        /// <param name="meritsObj"></param>
        private decimal Cal_Merit(ValueObj.StudentVO studentObj, Dictionary<int, ValueObj.SchoolYearSemester> gradeMap, ValueObj.MeritsVO meritsObj)
        {
            int ItemIndex = Global.index_Merit;
            // 取得大項目的條件
            ValueObj.ItemConditionVO itemCondition = new ValueObj.ItemConditionVO(ItemIndex);
            // 取得子項目的條件
            ValueObj.DetailItemConditionVO detailCondition = new ValueObj.DetailItemConditionVO(ItemIndex);
            // 取得需要看的學年度學期
            List<ValueObj.SchoolYearSemester> needSchoolYearList = Utility.GetNeedSchoolSemester(itemCondition.NeedSemester, gradeMap);
            // 大項目名稱
            string itemName = itemCondition.ItemName;
            // 項目的積分
            decimal ItemTotalPoints = 0;

            decimal[] meritCount = new decimal[Global.DetailItemNameList[ItemIndex].Length];

            if (meritsObj != null)
            {
                // loop 每個學期分數的大功, 小功, 獎勵
                foreach (ValueObj.SchoolYearSemester schoolYear in needSchoolYearList)
                {
                    if (schoolYear == null) continue;
                    List<Data.MeritRecord> meritList = meritsObj.GetMeritsBySchoolYear(schoolYear);
                    foreach (Data.MeritRecord rec in meritList)
                    {
                        if(rec.MeritA.HasValue)
                            meritCount[0] += rec.MeritA.Value;
                        if(rec.MeritB.HasValue)
                            meritCount[1] += rec.MeritB.Value;
                        if(rec.MeritC.HasValue)
                            meritCount[2] += rec.MeritC.Value;
                    }
                }
            }

            // loop 每個子項目
            for (int intI = 0; intI < Global.DetailItemNameList[ItemIndex].Length; intI++)
            {
                // 子項目名稱
                string meritName = Global.DetailItemNameList[ItemIndex][intI];
                // 子項目積分
                decimal points = detailCondition.DetailItemListDic[meritName];

                // 取得detail item in student
                ValueObj.DetailItemVO detailItem = studentObj.DetailItemList[itemName][meritName];

                // 計算積分
                decimal mixPoints = meritCount[intI] * points;

                // 回存此項目顯示的內容
                detailItem.Value = "Points:" + points + "  Counts:" + meritCount[intI].ToString();

                // 回存此項目的積分
                detailItem.Points = mixPoints;

                // 加總
                ItemTotalPoints += mixPoints;
            }

            // 假如超過上限, 就以上限為主
            ItemTotalPoints = (ItemTotalPoints > itemCondition.MaxItemPoints) ? itemCondition.MaxItemPoints : ItemTotalPoints;

            // 此學生在這個項目的積分
            studentObj.ItemList[itemName] = ItemTotalPoints;

            return ItemTotalPoints;
        }
        /// <summary>
        /// 處理德行表現
        /// </summary>
        /// <param name="studentObj"></param>
        /// <param name="gradeMap"></param>
        /// <param name="clubsObj"></param>
        /// <param name="servicesObj"></param>
        private decimal Cal_VirtuousConduct(ValueObj.StudentVO studentObj, Dictionary<int, ValueObj.SchoolYearSemester> gradeMap, ValueObj.ClubsVO clubsObj, ValueObj.ServicesVO servicesObj)
        {
            int ItemIndex = Global.index_VirtuousConduct;
            // 取得大項目的條件
            ValueObj.ItemConditionVO itemCondition = new ValueObj.ItemConditionVO(ItemIndex);
            // 取得子項目的條件
            ValueObj.DetailItemConditionVO detailCondition = new ValueObj.DetailItemConditionVO(ItemIndex);
            // 取得需要看的學年度學期
            List<ValueObj.SchoolYearSemester> needSchoolYearList = Utility.GetNeedSchoolSemester(itemCondition.NeedSemester, gradeMap);

            // 大項目名稱
            string itemName = itemCondition.ItemName;
            decimal ItemTotalPoints = 0;


            #region 處理社團
            // 社團名稱
            string detailItemName = Global.DetailItemNameList[ItemIndex][0];
            // 社團積分
            decimal clubPoints = detailCondition.DetailItemListDic[detailItemName];
            decimal clubTotalPoints = 0;
            if (clubsObj != null)
            {
                // loop 每個學期
                foreach (ValueObj.SchoolYearSemester schoolYear in needSchoolYearList)
                {
                    if (schoolYear == null) continue;

                    List<ValueObj.ClubVO> clubList = clubsObj.GetClubsBySchoolYear(schoolYear);
                    // 假如有參加過社團, +1分
                    if (clubList.Count > 0)
                        clubTotalPoints += 1;
                }
            }
            // 取得detail item in student
            ValueObj.DetailItemVO detailItem = studentObj.DetailItemList[itemName][detailItemName];

            // 回存此項目顯示的內容
            detailItem.Value = "Count:" + clubTotalPoints.ToString();

            // 假如超過上限, 就以上限為主
            clubPoints = (clubTotalPoints > clubPoints) ? clubPoints : clubTotalPoints;

            // 回存此項目的積分
            detailItem.Points = clubPoints;

            #endregion

            #region 處理服務學習
            decimal ServiceHours = 6;
            // 服務學習名稱
            detailItemName = Global.DetailItemNameList[ItemIndex][1];
            // 服務學習積分
            decimal servicePoints = detailCondition.DetailItemListDic[detailItemName];
            decimal serviceTotalPoints = 0;

            // 特殊條件
            // 取得三下的學年度學期
            ValueObj.SchoolYearSemester specilSchoolYear = gradeMap[6];
            // 截止時間 103/5/9
            DateTime deadTime = new DateTime(2014, 5, 9);

            if(servicesObj != null)
            {
                // loop 每個學期
                foreach (ValueObj.SchoolYearSemester schoolYear in needSchoolYearList)
                {
                    if (schoolYear == null) continue;

                    decimal hours = 0;
                    List<ValueObj.ServiceVO> serviceList = servicesObj.GetServicesBySchoolYear(schoolYear);
                    // 加總此學期的時數
                    foreach(var serviceObj in serviceList)
                    {
                        if (schoolYear == specilSchoolYear)
                        {
                            if (serviceObj.OccurTime.HasValue && (serviceObj.OccurTime.Value <= deadTime))
                                hours += serviceObj.Hours;
                        }
                        else
                            hours += serviceObj.Hours;
                    }

                    // 假如超過6小時, +1分
                    if (hours >= ServiceHours)
                        serviceTotalPoints += 1;
                }
             }
            
            // 取得detail item in student
            detailItem = studentObj.DetailItemList[itemName][detailItemName];

            // 回存此項目顯示的內容
            detailItem.Value = "Count:" + serviceTotalPoints.ToString();

            // 假如超過上限, 就以上限為主
            servicePoints = (serviceTotalPoints > servicePoints) ? servicePoints : serviceTotalPoints;

            // 回存此項目的積分
            detailItem.Points = servicePoints;

            #endregion

            ItemTotalPoints = clubPoints + servicePoints;

            // 此學生在這個項目的積分
            studentObj.ItemList[itemName] = ItemTotalPoints;

            return ItemTotalPoints;

        }
        private void Assingment2Value(string typestr)
        {
            ValueObj _valueobj = new ValueObj();

            if ((typestr.ToUpper() == "BOOL") && Common.IsValueBOOL(thenField, ref _valueobj))
            {
                m_value.BOOL = _valueobj.Val.BOOL;
                return;
            }
            if ((typestr.ToUpper() == "BYTE") && Common.IsValueBYTE(thenField, ref _valueobj))
            {
                m_value.BYTE = _valueobj.Val.BYTE;
                return;
            }
            if ((typestr.ToUpper() == "WORD") && Common.IsValueWORD(thenField, ref _valueobj))
            {
                m_value.WORD = _valueobj.Val.WORD;
                return;
            }
            if ((typestr.ToUpper() == "DWORD") && Common.IsValueDWORD(thenField, ref _valueobj))
            {
                m_value.DWORD = _valueobj.Val.DWORD;
                return;
            }
            if ((typestr.ToUpper() == "LWORD") && Common.IsValueLWORD(thenField, ref _valueobj))
            {
                m_value.LWORD = _valueobj.Val.LWORD;
                return;
            }
            if ((typestr.ToUpper() == "SINT") && Common.IsValueSINT(thenField, ref _valueobj))
            {
                m_value.SINT = _valueobj.Val.SINT;
                return;
            }
            if ((typestr.ToUpper() == "INT") && Common.IsValueINT(thenField, ref _valueobj))
            {
                m_value.INT = _valueobj.Val.INT;
                return;
            }
            if ((typestr.ToUpper() == "DINT") && Common.IsValueDINT(thenField, ref _valueobj))
            {
                m_value.DINT = _valueobj.Val.DINT;
                return;
            }
            if ((typestr.ToUpper() == "LINT") && Common.IsValueLINT(thenField, ref _valueobj))
            {
                m_value.LINT = _valueobj.Val.LINT;
                return;
            }
            if ((typestr.ToUpper() == "USINT") && Common.IsValueUSINT(Then, ref _valueobj))
            {
                m_value.USINT = _valueobj.Val.USINT;
                return;
            }
            if ((typestr.ToUpper() == "UINT") && Common.IsValueUINT(thenField, ref _valueobj))
            {
                m_value.UINT = _valueobj.Val.UINT;
                return;
            }
            if ((typestr.ToUpper() == "UDINT") && Common.IsValueUDINT(thenField, ref _valueobj))
            {
                m_value.UDINT = _valueobj.Val.UDINT;
                return;
            }
            if ((typestr.ToUpper() == "ULINT") && Common.IsValueULINT(thenField, ref _valueobj))
            {
                m_value.ULINT = _valueobj.Val.ULINT;
                return;
            }
            if ((typestr.ToUpper() == "REAL") && Common.IsValueREAL(thenField, ref _valueobj))
            {
                m_value.REAL = _valueobj.Val.REAL;
                return;
            }
            if ((typestr.ToUpper() == "LREAL") && Common.IsValueLREAL(thenField, ref _valueobj))
            {
                m_value.LREAL = _valueobj.Val.LREAL;
                return;
            }
            if ((typestr.ToUpper() == "COLOR") && Common.IsValueColor(thenField, ref _valueobj))
            {
                m_value.DINT = _valueobj.Val.DINT;
                return;
            }
            if ((typestr.ToUpper() == "TIME") && Common.IsValueTIME(thenField, ref _valueobj))
            {
                m_value.TIME = _valueobj.Val.TIME;
                return;
            }
            if ((typestr.ToUpper() == "DATE") && Common.IsValueDATE(thenField, ref _valueobj))
            {
                m_value.DATE = _valueobj.Val.DATE;
                return;
            }
            if ((typestr.ToUpper() == "TOD") && Common.IsValueTOD(thenField, ref _valueobj))
            {
                m_value.TOD = _valueobj.Val.TOD;
                return;
            }
            if ((typestr.ToUpper() == "DT") && Common.IsValueDT(thenField, ref _valueobj))
            {
                m_value.DT = _valueobj.Val.DT;
                return;
            }
        }
Exemple #15
0
 /// <summary>
 /// Insert a single value in the list
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='value'>
 /// New value to be inserted
 /// </param>
 public static void PostByvalue(this IValues operations, ValueObj value)
 {
     Task.Factory.StartNew(s => ((IValues)s).PostByvalueAsync(value), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
        /// <summary>
        /// 輸出學習歷程或領域成績有問題學生
        /// </summary>
        /// <param name="StudentObj"></param>
        /// <param name="gradeList"></param>
        public void OutWarningData(ValueObj.StudentVO StudentObj, ValueObj.LackMsg msgList)
        {
            int columnIndex = 0;
            _RowIndex++;

            if (_RowIndex > _MAX_ROW_COUNT)
            {
                _IsOverRow = true;
                return;
            }

            StringBuilder sb = new StringBuilder();

            sb.Append(StudentObj.StudentName).Append(" 缺少 ");

            if (msgList.HistoryLack.Count > 0)
            {
                sb.Append(Utility.ComposeHistoryLackMsg(msgList.HistoryLack));
                sb.Append(" ");
            }

            if (msgList.DomainLack.Count >0 )
                sb.Append(Utility.ComposeDomainLackMsg(msgList.DomainLack));

            SetColumnValue(_OutCells, columnIndex++, sb.ToString(), _Style_Error);
        }
        /// <summary>
        /// for debug
        /// </summary>
        /// <param name="StudentObj"></param>
        public void OutDetailData(ValueObj.StudentVO StudentObj)
        {
            
            if (Global.IsDebug == false) return;
            
            int columnIndex = 0;
            if (_DetailRowIndex == 0) OutDetailTitle(_DetailCells);
            _DetailRowIndex++;

            if (_DetailRowIndex > _MAX_ROW_COUNT)
                return;
            // 年級/班級序號/班級名稱/座號/學號/姓名
            _DetailCells[_DetailRowIndex, columnIndex++].PutValue(StudentObj.ClassGradeYear);
            _DetailCells[_DetailRowIndex, columnIndex++].PutValue(StudentObj.ClassDisplayOrder);
            _DetailCells[_DetailRowIndex, columnIndex++].PutValue(StudentObj.ClassName);
            _DetailCells[_DetailRowIndex, columnIndex++].PutValue(StudentObj.StudentSeatNo);
            _DetailCells[_DetailRowIndex, columnIndex++].PutValue(StudentObj.StudentNumber);

            // 學生姓名
            _DetailCells[_DetailRowIndex, columnIndex++].PutValue(StudentObj.StudentName);
            // 身分證統一編號
            _DetailCells[_DetailRowIndex, columnIndex++].PutValue(StudentObj.StudentIdNumber);
            // 生日
            _DetailCells[_DetailRowIndex, columnIndex++].PutValue("" + StudentObj.StudentBirthday);

            // 詳細資料
            foreach (string itemName in StudentObj.ItemList.Keys)
            {
                _DetailCells[_DetailRowIndex, columnIndex++].PutValue("" + StudentObj.ItemList[itemName]);

                foreach (ValueObj.DetailItemVO rec in StudentObj.DetailItemList[itemName].Values)
                {
                    _DetailCells[_DetailRowIndex, columnIndex++].PutValue("" + rec.Value);
                    _DetailCells[_DetailRowIndex, columnIndex++].PutValue("" + rec.Points);
                }
            }
        }
Exemple #18
0
 /// <summary>
 /// Insert a single value in the list
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='value'>
 /// New value to be inserted
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task PostByvalueAsync(this IValues operations, ValueObj value, CancellationToken cancellationToken = default(CancellationToken))
 {
     await operations.PostByvalueWithHttpMessagesAsync(value, null, cancellationToken).ConfigureAwait(false);
 }
        /// <summary>
        /// 處理均衡學習
        /// </summary>
        /// <param name="studentObj"></param>
        /// <param name="gradeMap"></param>
        /// <param name="domains"></param>
        private decimal Cal_BalanceLearning(ValueObj.StudentVO studentObj, Dictionary<int, ValueObj.SchoolYearSemester> gradeMap, ValueObj.DomainsVO domains)
        {
            int ItemIndex = Global.index_BalanceLearning;
            // 取得大項目的條件
            ValueObj.ItemConditionVO itemCondition = new ValueObj.ItemConditionVO(ItemIndex);
            // 取得子項目的條件
            ValueObj.DetailItemConditionVO detailCondition = new ValueObj.DetailItemConditionVO(ItemIndex);
            // 取得需要看的學年度學期
            Dictionary<int, ValueObj.SchoolYearSemester> needSchoolYearList = Utility.GetNeedSchoolSemesterIndex(itemCondition.NeedSemester, gradeMap);
            // 大項目名稱
            string itemName = itemCondition.ItemName;
            // 及格分數
            decimal PassScore = 60;
            // 項目的積分
            decimal ItemTotalPoints = 0;

            if (domains != null)
            {
                // loop 每個需要的領域
                for (int intI = 0; intI < Global.DetailItemNameList[ItemIndex].Length; intI++)
                {
                    // 子項目名稱
                    string detailItemName = Global.DetailItemNameList[ItemIndex][intI];
                    // 子項目積分
                    decimal points = detailCondition.DetailItemListDic[detailItemName];

                    decimal totalScore = 0;
                    decimal avgScore = 0;
                    decimal scoreCount = 0;
                    // loop 領域的每個學期分數
                    foreach (KeyValuePair<int, ValueObj.SchoolYearSemester> pair in needSchoolYearList)
                    {
                        ValueObj.SchoolYearSemester schoolYear = pair.Value;
                        if (schoolYear == null)
                        {
                            // 少了需要的學期
                            if (!_WarningStudentDic.ContainsKey(studentObj))
                                _WarningStudentDic.Add(studentObj, new ValueObj.LackMsg());
                            _WarningStudentDic[studentObj].AddHistoryLack(pair.Key);
                            continue;
                        }
                        List<ValueObj.DomainVO> domainList = domains.GetDomainsBySechoolYear(schoolYear, detailItemName);

                        if (domainList.Count == 0)
                        {
                            // 少了需要的領域
                            if (!_WarningStudentDic.ContainsKey(studentObj))
                                _WarningStudentDic.Add(studentObj, new ValueObj.LackMsg());
                            _WarningStudentDic[studentObj].AddDomainLack(pair.Key);
                            continue;
                        }

                        foreach (ValueObj.DomainVO domain in domainList)
                        {
                            totalScore += domain.DomainScore;
                            scoreCount++;
                        }
                    }

                    // 取得detail item in student
                    ValueObj.DetailItemVO detailItem = studentObj.DetailItemList[itemName][detailItemName];

                    // 領域的平均
                    // 原本是固定除以需要的學期, 這樣有少一個學期分數的話, 會很難看, 所以改成有幾個分數就除以幾
                    // avgScore = Math.Round((totalScore / needSchoolYearList.Count), 2, MidpointRounding.AwayFromZero);
                    if (scoreCount > 0)
                        avgScore = Math.Round((totalScore / scoreCount), 2, MidpointRounding.AwayFromZero);

                    // 回存此項目顯示的內容
                    detailItem.Value = "總分: " + totalScore + ", 學期數: " + scoreCount + ", 平均: " + avgScore.ToString();

                    // 看學生有沒有得到此積分
                    if (avgScore >= PassScore)
                    {
                        ItemTotalPoints += points;
                        // 回存此項目的積分
                        detailItem.Points = points;
                    }

                }
            }
            else
            {
                // 完全沒有領域成績
                if (!_WarningStudentDic.ContainsKey(studentObj))
                    _WarningStudentDic.Add(studentObj, new ValueObj.LackMsg());

                foreach(int rec in needSchoolYearList.Keys)
                    _WarningStudentDic[studentObj].AddDomainLack(rec);
            }

            // 假如超過上限, 就以上限為主
            ItemTotalPoints = (ItemTotalPoints > itemCondition.MaxItemPoints) ? itemCondition.MaxItemPoints : ItemTotalPoints;

            // 此學生在這個項目的積分
            studentObj.ItemList[itemName] = ItemTotalPoints;

            return ItemTotalPoints;
        }