示例#1
0
        /// <summary>
        ///     获取当前会员等级是否满足条件
        /// </summary>
        /// <param name="gradeInfo"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public Tuple <bool, Guid> GetKpiResult(GradeInfo gradeInfo, User user, IScope scope)
        {
            var rules = UpgradeRule.GetRules();
            var rule  = rules.FirstOrDefault(r => r.BeforeGradeId == user.GradeId);

            if (rule != null)
            {
                // 书生升级秀才
                if (rule.BaseGradeId == Guid.Empty)
                {
                    //  直推大于等于3个,团队15人
                    if (gradeInfo.RecomendCount >= rule.GradeCount && gradeInfo.TeamCount >= rule.TeamNumber)
                    {
                        return(Tuple.Create(true, rule.GradeId));
                    }
                }
                else if (gradeInfo.TeamCount >= rule.TeamNumber)
                {
                    // 满足团队数,在来执行市场人数
                    var count = GetKpiItemResult(gradeInfo, user, rule, scope);
                    if (count >= rule.GradeCount)
                    {
                        return(Tuple.Create(true, rule.GradeId));
                    }
                }
            }

            return(Tuple.Create(false, Guid.Empty));
        }
示例#2
0
    private void OnLeftMouseClick()
    {
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, Mathf.Infinity))
        {
            if (hit.transform.CompareTag("tower"))
            {
                if (Input.GetKey(KeyCode.G))
                {
                    Time.timeScale   = 0;
                    currentGradeInfo = hit.transform.GetComponent <GradeInfo>();
                    currentGradeItem = currentGradeInfo.GetCurrentGrade();
                    currentTower     = hit.transform.GetComponent <ITower>();
                    if (currentGradeItem != null)
                    {
                        LoadAllInfo();
                    }
                    else
                    {
                        ShowOffDialog();
                    }
                }
            }
        }
    }
        public void BatchDeleteTest()
        {
            GradeInfo v1 = new GradeInfo();
            GradeInfo v2 = new GradeInfo();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v1.ID   = 14;
                v1.Code = "lPxmir";
                v1.Name = "fg6w922S0";
                v2.ID   = 85;
                v2.Code = "1MYfrvms";
                v2.Name = "5fNg07pI";
                context.Set <GradeInfo>().Add(v1);
                context.Set <GradeInfo>().Add(v2);
                context.SaveChanges();
            }

            var rv = _controller.BatchDelete(new string[] { v1.ID.ToString(), v2.ID.ToString() });

            Assert.IsInstanceOfType(rv, typeof(OkObjectResult));

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                var data1 = context.Set <GradeInfo>().Find(v1.ID);
                var data2 = context.Set <GradeInfo>().Find(v2.ID);
                Assert.AreEqual(data1.IsValid, false);
                Assert.AreEqual(data2.IsValid, false);
            }

            rv = _controller.BatchDelete(new string[] {});
            Assert.IsInstanceOfType(rv, typeof(OkResult));
        }
示例#4
0
        public async Task <IActionResult> Edit(int id, [Bind("GradeId,Grade")] GradeInfo gradeInfo)
        {
            if (id != gradeInfo.GradeId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(gradeInfo);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GradeInfoExists(gradeInfo.GradeId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(gradeInfo));
        }
示例#5
0
        public async Task <IActionResult> Create([Bind("GradeId,Grade")] GradeInfo gradeInfo)
        {
            if (ModelState.IsValid)
            {
                _context.Add(gradeInfo);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(gradeInfo));
        }
示例#6
0
        private Int32 AddGrade()
        {
            GradeInfo v = new GradeInfo();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.ID   = 37;
                v.Code = "KQQwkEYd";
                v.Name = "fTCyrbRy";
                context.Set <GradeInfo>().Add(v);
                context.SaveChanges();
            }
            return(v.ID);
        }
示例#7
0
        private Int32 AddGrade()
        {
            GradeInfo v = new GradeInfo();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.ID   = 50;
                v.Code = "0D10D";
                v.Name = "DSHxhO";
                context.Set <GradeInfo>().Add(v);
                context.SaveChanges();
            }
            return(v.ID);
        }
        private Int32 AddGrade()
        {
            GradeInfo v = new GradeInfo();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.ID   = 92;
                v.Code = "UmZ8IX4xl";
                v.Name = "CF9C";
                context.Set <GradeInfo>().Add(v);
                context.SaveChanges();
            }
            return(v.ID);
        }
示例#9
0
        private Int32 AddGrade()
        {
            GradeInfo v = new GradeInfo();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.ID   = 61;
                v.Code = "7gwX";
                v.Name = "P0eJH9at";
                context.Set <GradeInfo>().Add(v);
                context.SaveChanges();
            }
            return(v.ID);
        }
        private Int32 AddGrade()
        {
            GradeInfo v = new GradeInfo();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.ID   = 81;
                v.Code = "hmOZnHcl";
                v.Name = "qgdULr";
                context.Set <GradeInfo>().Add(v);
                context.SaveChanges();
            }
            return(v.ID);
        }
示例#11
0
    IEnumerator SendPost(string _url, WWWForm _wForm)
    {
        WWW postData = new WWW(_url, _wForm);

        yield return(postData);

        if (postData.error != null)
        {
            Debug.Log(postData.error);
        }
        else
        {
            Debug.Log(postData.text);

            JsonData data = JsonMapper.ToObject(postData.text);

            GradeStruct structInfo = new GradeStruct();
            structInfo.pageSize         = (int)data["pageSize"];
            structInfo.currentPageIndex = (int)data["currentPageIndex"];
            structInfo.totalRecord      = (int)data["totalRecord"];
            structInfo.totalPage        = (int)data["totalPage"];

            if (data["datas"].IsArray)
            {
                List <GradeInfo> list = new List <GradeInfo>();
                foreach (JsonData datas in data["datas"])
                {
                    //Debug.Log(datas["name"]);
                    GradeInfo info = new GradeInfo();
                    list.Add(info);

                    info.id          = (int)datas["id"];
                    info.name        = (string)datas["name"];
                    info.schoolId    = (int)datas["schoolId"];
                    info.teacherId   = (int)datas["teacherId"];
                    info.schoolName  = (string)datas["schoolName"];
                    info.teacherName = (string)datas["teacherName"];
                }

                structInfo.gradeArr = list;
            }

            if (_callBack != null)
            {
                _callBack(structInfo);
            }
        }
    }
示例#12
0
        public void GetTest()
        {
            GradeInfo v = new GradeInfo();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.ID   = 14;
                v.Code = "lPxmir";
                v.Name = "fg6w922S0";
                context.Set <GradeInfo>().Add(v);
                context.SaveChanges();
            }
            var rv = _controller.Get(v.ID.ToString());

            Assert.IsNotNull(rv);
        }
示例#13
0
        public List <GradeInfo> GetAllGradeInfo()
        {
            List <GradeInfo> list = new List <GradeInfo>();
            string           sql  = "select * from GradeInfo";

            using (SqlDataReader sdr = DBHelpers.GetAllInfo(sql))
            {
                while (sdr.Read())
                {
                    GradeInfo grade = new GradeInfo();
                    grade.GradeInfoID = Convert.ToInt32(sdr["GradeInfoID"]);
                    grade.GradeName   = sdr["GradeName"].ToString();
                    grade.GradeSimple = sdr["GradeSimple"].ToString();
                    list.Add(grade);
                }
            }
            return(list);
        }
示例#14
0
        private static GradeInfo GetGradeInfo(JsonValue gradeValue)
        {
            JsonObject gradeObject = gradeValue.GetObject();
            GradeInfo  info        = new GradeInfo();

            info.CourseCode   = gradeObject.GetNamedString("course_code");
            info.CourseTitle  = gradeObject.GetNamedString("course_title");
            info.CourseType   = gradeObject.GetNamedString("course_type");
            info.CourseOption = gradeObject.GetNamedString("option").ToUpper();
            info.Credits      = (ushort)gradeObject.GetNamedNumber("credits");
            info.Grade        = gradeObject.GetNamedString("grade")[0];
            info.AssignExamDate(gradeObject.GetNamedString("exam_held"));

            if (info.CourseOption == "NIL")
            {
                info.CourseOption = "";
            }

            return(info);
        }
示例#15
0
        public void EditTest()
        {
            GradeInfo v = new GradeInfo();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.ID   = 14;
                v.Code = "lPxmir";
                v.Name = "fg6w922S0";
                context.Set <GradeInfo>().Add(v);
                context.SaveChanges();
            }

            GradeInfoVM vm    = _controller.Wtm.CreateVM <GradeInfoVM>();
            var         oldID = v.ID;

            v    = new GradeInfo();
            v.ID = oldID;

            v.Code    = "1MYfrvms";
            v.Name    = "5fNg07pI";
            vm.Entity = v;
            vm.FC     = new Dictionary <string, object>();

            vm.FC.Add("Entity.ID", "");
            vm.FC.Add("Entity.Code", "");
            vm.FC.Add("Entity.Name", "");
            var rv = _controller.Edit(vm);

            Assert.IsInstanceOfType(rv, typeof(OkObjectResult));

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                var data = context.Set <GradeInfo>().Find(v.ID);

                Assert.AreEqual(data.Code, "1MYfrvms");
                Assert.AreEqual(data.Name, "5fNg07pI");
                Assert.AreEqual(data.UpdateBy, "user");
                Assert.IsTrue(DateTime.Now.Subtract(data.UpdateTime.Value).Seconds < 10);
            }
        }
        public static IEnumerable <OpenXmlElement> GetSection(SelectedSchool School, GradeInfo Grade)
        {
            if (School == null)
            {
                throw new System.Exception("School cannot be null");
            }

            return(new List <OpenXmlElement>()
            {
                TableHelper.StyledTable(
                    new TableRow(
                        TableHelper.LabelCell("School:", JustificationValues.Center).WithWidth(66.6),
                        TableHelper.LabelCell("Grade:", JustificationValues.Center).WithWidth(33.3)
                        ),
                    new TableRow(
                        TableHelper.ValueCell($"{School?.Name} ({School?.DAN})", JustificationValues.Center),
                        TableHelper.ValueCell(Grade?.Grade, JustificationValues.Center)
                        )
                    ),
                ParagraphHelper.WhiteSpace()
            });
        }
示例#17
0
        public static List <GradeInfo> All(string type)
        {
            using SQLiteCommand cmd = GlobalFunction.OpenDbConnection();
            List <GradeInfo> grades = new List <GradeInfo>();

            cmd.CommandText = "SELECT * FROM grades";

            using SQLiteDataReader rdr = cmd.ExecuteReader();

            while (rdr.Read())
            {
                GradeInfo grade = new GradeInfo()
                {
                    GradeId      = rdr.GetInt32(0),
                    StudentId    = rdr.GetInt32(1),
                    Grade        = rdr.GetFloat(2),
                    Coeff        = rdr.GetInt32(3),
                    CreationDate = rdr.GetInt32(4)
                };
                grades.Add(grade);
            }
            return(grades);
        }
示例#18
0
        /// <summary>
        /// Returns all grades of a student
        /// </summary>
        /// <param name="studentId"></param>
        /// <returns>List of GradeInfo</returns>
        public static List <GradeInfo> AllFromStudentId(int studentId)
        {
            using SQLiteCommand cmd = GlobalFunction.OpenDbConnection();
            cmd.CommandText         = "SELECT * FROM grades WHERE studentId = @studentId";
            cmd.Parameters.AddWithValue("studentId", studentId);
            cmd.Prepare();

            List <GradeInfo> gradesList = new List <GradeInfo>();

            using SQLiteDataReader rdr = cmd.ExecuteReader();
            while (rdr.Read())
            {
                GradeInfo gradeInfo = new GradeInfo()
                {
                    GradeId      = rdr.GetInt32(0),
                    StudentId    = rdr.GetInt32(1),
                    Grade        = rdr.GetFloat(2),
                    Coeff        = rdr.GetInt32(3),
                    CreationDate = rdr.GetInt32(4)
                };
                gradesList.Add(gradeInfo);
            }
            return(gradesList);
        }
示例#19
0
        /// <summary>
        ///     最小项目的Kpi计算
        /// </summary>
        /// <param name="gradeInfo"></param>
        /// <returns></returns>
        public long GetKpiItemResult(GradeInfo gradeInfo, User user, UpgradeRule rule, IScope scope)
        {
            long result     = 0;
            var  childUsers = scope.Resolve <IUserService>().GetList(r => r.ParentId == user.Id);

            if (childUsers.Count < rule.GradeCount)
            {
                return(result);
            }

            foreach (var child in childUsers)
            {
                var map = scope.Resolve <IUserMapService>().GetSingle(r => r.UserId == child.Id);
                if (map != null)
                {
                    var parentMap = map.ParentMap.ToObject <List <ParentMap> >();
                    if (parentMap.Any())
                    {
                        var userIds = parentMap.Select(r => r.UserId).ToList();
                        var sql     =
                            $"select count(id) from User_User where GradeId='{rule.BaseGradeId}' and Id in({userIds.ToSqlString()})";
                        var sqlResult = scope.Resolve <IUserRepository>().RepositoryContext.ExecuteScalar(sql);
                        var count     = sqlResult.ConvertToLong();
                        if (count > 0)
                        {
                            result++;
                            if (result >= rule.GradeCount)
                            {
                                break;
                            }
                        }
                    }
                }
            }
            return(result);
        }
示例#20
0
        public void CreateTest()
        {
            GradeInfoVM vm = _controller.Wtm.CreateVM <GradeInfoVM>();
            GradeInfo   v  = new GradeInfo();

            v.ID      = 14;
            v.Code    = "lPxmir";
            v.Name    = "fg6w922S0";
            vm.Entity = v;
            var rv = _controller.Add(vm);

            Assert.IsInstanceOfType(rv, typeof(OkObjectResult));

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                var data = context.Set <GradeInfo>().Find(v.ID);

                Assert.AreEqual(data.ID, 14);
                Assert.AreEqual(data.Code, "lPxmir");
                Assert.AreEqual(data.Name, "fg6w922S0");
                Assert.AreEqual(data.CreateBy, "user");
                Assert.IsTrue(DateTime.Now.Subtract(data.CreateTime.Value).Seconds < 10);
            }
        }
示例#21
0
        public List <List <AssignmentCourse> > GetAssignmentsFromMarkingPeriod(string link)
        {
            var courseList   = new List <List <AssignmentCourse> >();
            var documentList = new List <HtmlDocument>();
            var data         = RequestData.GetData(_httpClient, link, ResponseType.Assignments);

            var htmlDocument = new HtmlDocument();

            htmlDocument.LoadHtml(data.Result);

            var form = new GradesForm(htmlDocument);
            var reportingPeriodNames = form.ReportingPeriodNames();

            foreach (var name in reportingPeriodNames)
            {
                var body     = form.GenerateFormBody(name);
                var response = RequestData.GetDataWithBody(_httpClient, link, ResponseType.Assignments, body);
                var doc      = new HtmlDocument();
                doc.LoadHtml(response.Result);
                documentList.Add(doc);
            }

            foreach (var(htmlDocument1, run) in documentList.WithIndex())
            {
                var localCourseList = new List <AssignmentCourse>();
                var courseHtml      = htmlDocument1.DocumentNode.Descendants("div")
                                      .Where(node => node.GetAttributeValue("class", "")
                                             .Equals("AssignmentClass")).ToList();

                foreach (var(htmlNode, i) in courseHtml.WithIndex())
                {
                    var courseNode = htmlNode.Descendants("a")
                                     .FirstOrDefault(node => node.GetAttributeValue("class", "")
                                                     .Equals("sg-header-heading"));

                    if (courseNode == null)
                    {
                        continue;
                    }

                    //gets teacher information (name and room)
                    //gets section key
                    var sectionKey = courseNode.Attributes["onclick"].Value;

                    sectionKey = Regex.Match(sectionKey, @"\d+").Groups[0].Value;
                    var param = $"?section_key={sectionKey}&rcrun={run + 1}";

                    //gets html for popup
                    var popUpData = RequestData.GetData(_httpClient, link, ResponseType.ClassPopUp, "Student", param);
                    var popUpDoc  = new HtmlDocument();
                    popUpDoc.LoadHtml(popUpData.Result);

                    //extracts info
                    var sessionInfo = popUpDoc.GetElementbyId("plnMain_dgSessionInfo");
                    var sessionData = sessionInfo.ChildNodes[2].ChildNodes;
                    var teacherName = Utils.FormatName(sessionData[1].InnerText.Trim(), true);
                    var teacherRoom = sessionData[2].InnerText.Trim();

                    //gets and formats course info
                    var course = courseNode.InnerText.Trim();
                    var x      = new Regex(@"\w+\s-\s\d\s");

                    var courseName = x.Replace(course, @"").Trim();
                    var courseId   = x.Match(course).ToString().Trim();

                    var courseInfo = Utils.BeautifyCourseInfo(courseName, courseId);
                    (courseName, courseId) = courseInfo;

                    string courseGrade;
                    try {
                        courseGrade = htmlDocument1
                                      .GetElementbyId($"plnMain_rptAssigmnetsByCourse_lblOverallAverage_{i}")
                                      .InnerText.Trim();
                    }
                    catch {
                        continue;
                    }

                    //Gets grading information
                    //Prone to error as this typo is a hac problem
                    var courseInfoTable =
                        htmlDocument1.GetElementbyId($"plnMain_rptAssigmnetsByCourse_dgCourseCategories_{i}");
                    var gradeData = courseInfoTable.Descendants("tr").Where(node => node.GetAttributeValue("class", "")
                                                                            .Equals("sg-asp-table-data-row"));

                    string gradeType = null;
                    double totalPointsMax, totalPointsPercent, gradeScaleTotal, gradeScaleEarned;
                    var    totalPointsEarned =
                        totalPointsMax = totalPointsPercent = gradeScaleTotal = gradeScaleEarned = 0;

                    foreach (var gradeInput in gradeData)
                    {
                        var gradeInputNodes = gradeInput.ChildNodes;
                        gradeType          = gradeInputNodes[1].InnerText;
                        totalPointsEarned  = double.Parse(gradeInputNodes[2].InnerText);
                        totalPointsMax     = double.Parse(gradeInputNodes[3].InnerText);
                        totalPointsPercent = double.Parse(gradeInputNodes[4].InnerText.TrimEnd('%'));
                        gradeScaleTotal    = double.Parse(gradeInputNodes[5].InnerText);
                        gradeScaleEarned   = double.Parse(gradeInputNodes[6].InnerText);
                    }

                    var gradeInfo = new GradeInfo {
                        GradeType          = gradeType,
                        TotalPointsEarned  = totalPointsEarned,
                        TotalPointsMax     = totalPointsMax,
                        TotalPointsPercent = totalPointsPercent,
                        GradeScaleTotal    = gradeScaleTotal,
                        GradeScaleEarned   = gradeScaleEarned
                    };

                    var assignmentList = new List <Assignment>();

                    //gets all the assignments for a course
                    var assignmentTable = htmlNode.Descendants("table").FirstOrDefault(node =>
                                                                                       node.GetAttributeValue("class", "").Equals("sg-asp-table"));

                    foreach (var assignmentNode in assignmentTable.Descendants("tr").Where(node =>
                                                                                           node.GetAttributeValue("class", "").Equals("sg-asp-table-data-row")))
                    {
                        var assignment = new Assignment();
                        //Regex pattern = new Regex(".+:\\s");
                        var assignmentData = assignmentNode.ChildNodes[3].Descendants("a").FirstOrDefault()
                                             .Attributes["title"].Value;
                        var parsedAssignmentData = Regex.Replace(assignmentData, ".+:", "").Trim();


                        foreach (var(item, index) in new LineReader(() => new StringReader(parsedAssignmentData))
                                 .WithIndex())
                        {
                            switch (index)
                            {
                            case 0:
                                assignment.Title = item.Trim();
                                break;

                            case 1:
                                assignment.Name = FixAssignmentTitle(item.Trim());
                                break;

                            case 2:
                                assignment.Category = item.Trim();
                                break;

                            case 3:
                                var date = DateTime.Parse(item.Trim());
                                assignment.DueDate = date;
                                break;

                            case 4:
                                assignment.MaxPoints = double.Parse(item.Trim());
                                break;

                            case 5:
                                assignment.CanBeDropped = item.Contains("Y");
                                break;

                            case 6:
                                assignment.ExtraCredit = item.Contains("Y");
                                break;

                            case 7:
                                assignment.HasAttachments = item.Contains("Y");
                                break;
                            }
                        }

                        var score = assignmentNode.ChildNodes[5].InnerText.Trim();

                        assignment.Status = score switch {
                            "M" => AssignmentStatus.Missing,
                            "I" => AssignmentStatus.Incomplete,
                            "EXC" => AssignmentStatus.Excused,
                            "L" => AssignmentStatus.Late,
                            _ => AssignmentStatus.Upcoming
                        };

                        if (double.TryParse(score, out var points))
                        {
                            assignment.Status = AssignmentStatus.Complete;
                        }

                        assignment.Score = points.ToString(CultureInfo.CurrentCulture);
                        assignmentList.Add(assignment);
                    }

                    localCourseList.Add(new AssignmentCourse {
                        CourseName  = courseName, CourseId = courseId, CourseAverage = double.Parse(courseGrade),
                        Assignments = assignmentList, GradeInfo = gradeInfo, Teacher = teacherName,
                        RoomNumber  = teacherRoom
                    });
                }

                courseList.Add(localCourseList);
            }

            return(courseList);
        }
        private static GradeInfo GetGradeInfo(JsonValue gradeValue)
        {
            JsonObject gradeObject = gradeValue.GetObject();
            GradeInfo info = new GradeInfo();
            info.CourseCode = gradeObject.GetNamedString("course_code");
            info.CourseTitle = gradeObject.GetNamedString("course_title");
            info.CourseType = gradeObject.GetNamedString("course_type");
            info.CourseOption = gradeObject.GetNamedString("option").ToUpper();
            info.Credits = (ushort)gradeObject.GetNamedNumber("credits");
            info.Grade = gradeObject.GetNamedString("grade")[0];
            info.AssignExamDate(gradeObject.GetNamedString("exam_held"));

            if (info.CourseOption == "NIL")
                info.CourseOption = "";

            return info;
        }