예제 #1
0
        private static bool Upload(DataGridViewRow row)
        {
            SchoolBusObject busObject = new SchoolBusObject();

            if (row.Cells[0].Value == null && row.Cells[1].Value == null)
            {
                return(false);
            }
            if (row.Cells[0].Value == "" && row.Cells[1].Value == "")
            {
                return(false);
            }
            busObject.BusName   = (string)row.Cells[1].Value;
            busObject.TeacherID = (string)row.Cells[3].Value ?? "";
            busObject.LSChecked = (bool)row.Cells[4].Value;
            busObject.AHChecked = (bool)row.Cells[5].Value;
            busObject.CSChecked = (bool)row.Cells[6].Value;


            if (row.Cells[0].Value == null || row.Cells[0].Value.ToString() == "")
            {
                return(DataBaseOperation.CreateData(ref busObject) == DBQueryStatus.ONE_RESULT);
            }
            else
            {
                busObject.ObjectId = row.Cells[0].Value.ToString();
                return(DataBaseOperation.UpdateData(ref busObject) == 0);
            }
        }
예제 #2
0
 public IActionResult SignStudent(string signmode)
 {
     ViewData["where"]    = ControllerName;
     ViewData["SignMode"] = signmode;
     if (ValidateSession())
     {
         ViewData["cUser"] = CurrentUser.ToString();
         if (Request.Cookies["SignMode"] == signmode)
         {
             DataBaseOperation.QuerySingle(new DBQuery().WhereEqualTo("TeacherObjectID", CurrentUser.ObjectId), out SchoolBusObject busObject);
             if (busObject == null)
             {
                 busObject = new SchoolBusObject()
                 {
                     ObjectId = "0000000000", BusName = "未找到班车", TeacherID = CurrentUser.ObjectId
                 };
             }
             ViewData["cBus"] = busObject.ObjectId;
             ViewData["mode"] = signmode;
             return(View());
         }
         else
         {
             return(RequestIllegal(ServerAction.BusManage_SignStudents, XConfig.Messages["TokenTimeout"]));
         }
     }
     else
     {
         return(LoginFailed("/" + ControllerName + "/SignStudent?signmode=" + signmode));
     }
 }
        static void Main(string[] args)
        {
            LW.InitLog();
            LW.SetLogLevel(LogLevel.Dbg);
            DataBaseOperation.InitialiseClient();

            LW.D(DataBaseOperation.QuerySingleData(new DBQuery().WhereEqualTo("realname", "刘浩宇"), out UserObject me));
            LW.D(me);
            ClassObject co = new ClassObject()
            {
                CDepartment = "学部",
                CGrade      = "1年级",
                CNumber     = "5班",
                TeacherID   = me.ObjectId
            };

            LW.D(DataBaseOperation.CreateData(ref co));
            me.ClassList.Add(co.ObjectId);
            LW.D(co);


            SchoolBusObject bo = new SchoolBusObject()
            {
                BusName   = "校车方向1",
                TeacherID = me.ObjectId
            };

            LW.D(DataBaseOperation.CreateData(ref bo));

            LW.D(bo);

            for (int cn = 1; cn < 40; cn++)
            {
                StudentObject stu = new StudentObject()
                {
                    BusID       = bo.ObjectId,
                    ClassID     = co.ObjectId,
                    Sex         = "M",
                    StudentName = "学生-" + cn.ToString("000"),
                    AHChecked   = false,
                    CSChecked   = false,
                    LSChecked   = false
                };
                LW.D(DataBaseOperation.CreateData(ref stu));

                LW.D(stu);
                if (cn < 21)
                {
                    me.ChildList.Add(stu.ObjectId);
                }
            }

            me.HeadImagePath = "liuhaoyu.gif";
            LW.D(DataBaseOperation.UpdateData(ref me));
            LW.D(me);
        }
 public ViewStudentInfo(int parentsCount, bool classFound, bool classTeacherFound, bool busFound, bool busTeacherFound, StudentObject student, ClassObject @class, UserObject CTeacher, UserObject[] Parents, SchoolBusObject schoolbus, UserObject BTeacher, bool StudentFound)
 {
     ParentsCount      = parentsCount;
     ClassFound        = classFound;
     ClassTeacherFound = classTeacherFound;
     BusFound          = busFound;
     BusTeacherFound   = busTeacherFound;
     _student          = student;
     _class            = @class;
     _CTeacher         = CTeacher;
     _Parents          = Parents;
     _schoolbus        = schoolbus;
     _BTeacher         = BTeacher;
     this.StudentFound = StudentFound;
 }
예제 #5
0
        private void CheckMyStudents_Shown(object sender, EventArgs e)
        {
            if (CurrentUser.UserGroup.IsBusManager)
            {
                SchoolBusObject busObject = new SchoolBusObject();
                DBQueryStatus   resultX   = DataBaseOperation.QueryMultipleData <SchoolBusObject>(new DBQuery().WhereEqualTo("TeacherObjectID", CurrentUser.ObjectId), out List <SchoolBusObject> result);

                switch (resultX)
                {
                case DBQueryStatus.NO_RESULTS:
                    MessageBox.Show("没有找到你管理的校车");
                    return;

                case DBQueryStatus.ONE_RESULT:
                    break;

                case DBQueryStatus.MORE_RESULTS:
                    MessageBox.Show("找到了多个和你绑定的校车(这不可能……),目前只会显示其中第一项");
                    break;

                default: { MessageBox.Show("出现内部错误:" + resultX.ToString()); return; }
                }
                busObject           = result[0];
                myID.Text           = busObject.ObjectId;
                myDirection.Text    = busObject.BusName;
                LeavingChecked.Text = busObject.LSChecked.ToString();
                ExpNumber.Text      = "尚未加载";
                BackNumber.Text     = "尚未加载";
                ExDescription.Text  = "加载完成";
                Application.DoEvents();
                StudentDataGrid.AutoResizeColumns();
            }
            else if (CurrentUser.UserGroup.IsAdmin)
            {
                MessageBox.Show("管理员用户请到管理页面进行查询和修改记录", "管理员通知", MessageBoxButtons.OK);
            }
            else
            {
                MessageBox.Show("你不是校车老师,只有校车老师和管理员能编辑数据", "只读模式", MessageBoxButtons.OK);
                Close();
            }
        }
예제 #6
0
        static void Main(string[] args)
        {
            L.InitLog();
            XConfig.LoadConfig("XConfig.conf");
            DataBaseOperation.InitialiseClient();

            UserObject me = new UserObject()
            {
                HeadImagePath = "liuhaoyu.gif",
                Password      = "",
                PhoneNumber   = "18632738306",
                Sex           = "M",
                UserGroup     = new UserGroup(true, true, true, true),
                UserName      = "******",
                Precision     = 3,
                RealName      = "刘浩宇",
                CurrentPoint  = new System.Drawing.PointF(0, 0)
            };

            L.D(DataBaseOperation.CreateData(ref me).Stringify());
            //L.D(DataBaseOperation.QuerySingle(new DBQuery().WhereEqualTo("UserName", "liuhaoyu"), out UserObject me).ToString());
            L.D(me.Stringify());

            string[]               dePartMent = { "小学", "初中", "普高", "中加", "剑桥" };
            string[]               namelist   = { "钟天泽", "刑从珊", "牟绮南", "陈绮琴", "柯良俊", "伦腾骏", "闪安梦", "浑诗霜", "晁振华", "李易绿", "咎鸿宝", "士芳茵", "隗依晨", "宿德庸", "夏侯清嘉", "乜白亦", "出依波", "邬天青", "惠秋月", "次兴言", "支嘉珍", "枝承嗣", "濮阳亦绿", "革湛英", "韶琼思", "是觅晴", "抄念之", "泉觅翠", "道德元", "貊依丝", "邶芳春", "贺问梅", "蒉晨濡", "鞠德曜", "蔺暄文", "业英悟", "应芳泽", "苦飞双", "欧锦欣", "第五语梦", "悉晓燕", "保鸿畴", "乌孙思懿", "许天蓝", "亥乐水", "邱雅寒", "阿新蕾", "植叶欣", "图门昊伟", "万娅欣", "夕运凯", "高香芹", "夙成周", "狄访风", "无君昊", "温阳焱", "宋合乐", "苑梦蕊", "徭烨磊", "令狐晴岚", "佟佳湛芳", "赫连安珊", "郁阳曦", "迮姝美", "伏觅双", "苍正雅", "冼和硕", "平子珍", "子车晨潍", "危清婉", "九思松", "太叔冬灵", "宏宛亦", "错淑君", "奈明明", "冉盼夏", "嘉水冬", "建永福", "党瑾瑶", "信孤晴", "訾萧曼", "零向真", "风英韶", "后开畅", "凭桃雨", "苏高峯", "让绿蝶", "盛文林", "范绿兰", "施胤雅", "卓安萱", "辜元正", "肖自强", "舒畅然", "公良幻梅", "丹星纬", "堵博易", "虎坚秉", "甲玉泽", "孟竹月", "詹彩萱" };
            List <ClassObject>     classList  = new List <ClassObject>();
            List <SchoolBusObject> busList    = new List <SchoolBusObject>();

            for (int i = 1; i < 16; i++)
            {
                ClassObject @class = new ClassObject()
                {
                    CDepartment = dePartMent[RandomInt(0, 3)],
                    CGrade      = RandomInt(1, 14) + "年级",
                    CNumber     = RandomInt(1, 8) + "班",
                    TeacherID   = me.ObjectId
                };
                L.D(DataBaseOperation.CreateData(ref @class).ToString());
                L.D(@class.Stringify());
                classList.Add(@class);
            }

            string[] places = { "城镇", /*"莆陂", "城阜", "泉州", "上庄", "辰洞" */ };
            foreach (var item in places)
            {
                SchoolBusObject bo = new SchoolBusObject()
                {
                    BusName     = item,
                    TeacherID   = me.ObjectId,
                    BigWeekOnly = RandomBool,
                    AHChecked   = false,
                    CSChecked   = false,
                    LSChecked   = false
                };
                L.D(DataBaseOperation.CreateData(ref bo).ToString());
                L.D(bo.Stringify());
                busList.Add(bo);
            }


            foreach (var item in namelist)
            {
                StudentObject stu = new StudentObject()
                {
                    BusID        = busList[RandomInt(0, busList.Count)].ObjectId,
                    ClassID      = classList[RandomInt(0, classList.Count)].ObjectId,
                    Sex          = RandomBool ? "M" : "F",
                    StudentName  = item,
                    AHChecked    = false,
                    CSChecked    = false,
                    LSChecked    = false,
                    TakingBus    = true,
                    WeekType     = (StudentBigWeekMode)RandomInt(0, 3),
                    DirectGoHome = (DirectGoHomeMode)RandomInt(0, 3)
                };
                L.D(DataBaseOperation.CreateData(ref stu).ToString());

                L.D(stu.Stringify());
                bool       sexParent = RandomBool;
                UserObject user      = new UserObject()
                {
                    Sex       = sexParent ? "M" : "F",
                    ChildList = new List <string>()
                    {
                        stu.ObjectId
                    },
                    PhoneNumber   = "00000000000",
                    RealName      = stu.StudentName + "的" + (sexParent ? "爸爸" : "妈妈"),
                    UserGroup     = new UserGroup(false, false, false, true),
                    UserName      = "******" + stu.ObjectId,
                    HeadImagePath = ""
                };
                L.D(DataBaseOperation.CreateData(ref user).ToString());
                L.D(user.Stringify());

                if (RandomBool)
                {
                    if (stu != null)
                    {
                        me.ChildList.Add(stu.ObjectId);
                    }
                }
            }

            me.HeadImagePath = "liuhaoyu.gif";
            me.ClassList.Add(classList[RandomInt(0, classList.Count)].ObjectId);
            L.D(DataBaseOperation.UpdateData(ref me).ToString());
            L.D(me.Stringify());


            DatabaseSocketsClient.KillConnection();
            return;
        }
예제 #7
0
        private static bool GenerateWeekReport(InternalMessage message)
        {
            var    dirInfo           = Directory.CreateDirectory("reports");
            string ReportVisibleName = "班车统计报告";
            string ReportFilePath    = dirInfo.FullName + "//" + message.DataObject + "-GenBy-" + message.User.GetIdentifiableCode() + "-" + message.Identifier + ".xlsx";

            if (DataBaseOperation.QueryMultiple(new DBQuery().Limit(5000), out List <SchoolBusObject> busList) <= 0)
            {
                L.E("No Bus Found???"); return(false);
            }
            if (DataBaseOperation.QueryMultiple(new DBQuery().Limit(5000), out List <StudentObject> studentsList) <= 0)
            {
                L.E("No Students Found???"); return(false);
            }
            if (DataBaseOperation.QueryMultiple(new DBQuery().Limit(5000), out List <ClassObject> classList) <= 0)
            {
                L.E("No Classes Found???"); return(false);
            }
            if (DataBaseOperation.QueryMultiple(new DBQuery().Limit(5000), out List <UserObject> userList) <= 0)
            {
                L.E("No Users Found???"); return(false);
            }

            Dictionary <string, SchoolBusObject> SchoolBusDictionary = busList.ToDictionary();
            Dictionary <string, ClassObject>     ClassDictionary     = classList.ToDictionary();
            Dictionary <string, StudentObject>   StudentsDictionary  = studentsList.ToDictionary();
            Dictionary <string, UserObject>      UsersDictionary     = userList.ToDictionary();

            ClassObject emptyClassObject = new ClassObject()
            {
                CDepartment = "-未知-", CGrade = "-未知-", CNumber = "-未知-", TeacherID = DataTableObject.DefaultObjectID, ObjectId = DataTableObject.DefaultObjectID
            };
            UserObject emptyUserObject = new UserObject()
            {
                RealName = "-未知-", ObjectId = DataTableObject.DefaultObjectID
            };
            SchoolBusObject emptySchoolBusObject = new SchoolBusObject()
            {
                BusName = "-未知-", TeacherID = DataTableObject.DefaultObjectID, ObjectId = DataTableObject.DefaultObjectID
            };

            void FillStudentsDataIntoSheet(IXLWorksheet sheet, StudentObject[] students)
            {
                sheet.Row(1).SetValues("学部", "年级", "班级", "班主任", "学生姓名", "性别", "班车方向", "免接送状态", "本周是否坐班车", "带车老师", "离校签到", "返校签到", "到家签到", "家长信息");
                for (int i = 0; i < students.Length; i++)
                {
                    // HERE NEEDS SOME DATA PROCESS ABOUT 'NULL'
                    var _student = students[i];
                    _student.ClassID = _student.ClassID ?? DataTableObject.DefaultObjectID;
                    _student.BusID   = _student.BusID ?? DataTableObject.DefaultObjectID;

                    var _class = ClassDictionary.ContainsKey(_student.ClassID)
                        ? ClassDictionary[_student.ClassID]
                        : emptyClassObject;

                    _class.TeacherID = _class.TeacherID ?? DataTableObject.DefaultObjectID;

                    var _classTeacher = UsersDictionary.ContainsKey(_class.TeacherID)
                        ? UsersDictionary[_class.TeacherID]
                        : emptyUserObject;

                    var _bus = SchoolBusDictionary.ContainsKey(_student.BusID)
                        ? SchoolBusDictionary[_student.BusID]
                        : emptySchoolBusObject;

                    _bus.TeacherID = _bus.TeacherID ?? DataTableObject.DefaultObjectID;

                    var _busTeacher = UsersDictionary.ContainsKey(_bus.TeacherID)
                        ? UsersDictionary[_bus.TeacherID]
                        : emptyUserObject;

                    bool TakingBus;
                    if (XConfig.ServerConfig.IsBigWeek())
                    {
                        //Big and small means this is BIG WEEK....
                        //EVERYONE SHOULD TAKE THE BUS.....
                        TakingBus = _student.TakingBus;
                    }
                    else
                    {
                        //SMALL week, only big and small will go....
                        TakingBus = _student.TakingBus && (_student.WeekType == StudentBigWeekMode.BigAndSmall || _student.WeekType == StudentBigWeekMode.NotSet);
                    }

                    List <string> values = new List <string>
                    {
                        _class.CDepartment, _class.CGrade, _class.CNumber,
                        _classTeacher.RealName,
                        _student.StudentName,
                        _student.Sex == "M" ? "男" : "女",
                        _bus.BusName,
                        _student.DirectGoHome == DirectGoHomeMode.NotSet ? "未设置" : _student.DirectGoHome == DirectGoHomeMode.DirectlyGoHome ? "免接送" : "非免接送",
                        //_student.TakingBus ? "是" : "否"
                        TakingBus ? "是" : "否(" + (!_student.TakingBus ? "手动设置" : "小周") + ")"
                    };

                    if (TakingBus)
                    {
                        values.Add(_busTeacher.RealName);
                        values.Add(_student.LSChecked ? "已签到" : "未签到");
                        values.Add(_student.AHChecked ? "已签到" : "未签到");
                        values.Add(_student.CSChecked ? "已签到" : "未签到");
                    }
                    else
                    {
                        values.AddRange(new string[] { "---", "---", "---", "---" });
                    }

                    var _parents = from k in UsersDictionary where k.Value.ChildList.Contains(_student.ObjectId) select k.Value;
                    values.Add(string.Join("; ", from _ in _parents select _.RealName + "(" + _.PhoneNumber + ")"));

                    sheet.Row(i + 2).SetValues(values.ToArray());
                }
                sheet.Columns().AdjustToContents();
                sheet.SetContentColor();
                sheet.SetHeaderColor();
                sheet.SetGrid();
            }

            XLWorkbook wb = new XLWorkbook();

            wb.Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
            wb.CalculateMode       = XLCalculateMode.Auto;
            wb.Properties.Author   = "WoodenBench For SchoolBus Service";
            wb.Properties.Category = "Weekly Report File";
            switch (((message.DataObject as string) ?? "all").ToLower())
            {
            case "class":
                ReportVisibleName += "(按班级分类).xlsx";
                var classes = classList.OrderBy(k => k.CDepartment).ThenBy(k => k.CGrade).ThenBy(k => k.CNumber);
                //var classes = from _ in ClassDictionary.Values orderby new { _.CDepartment, _.CGrade } select _;
                foreach (var _class in classes)
                {
                    int    count      = 1;
                    string sheetName  = _class.CDepartment + "-" + _class.CGrade + "-" + _class.CNumber;
                    string sheetBName = sheetName;
                    while (wb.Worksheets.Contains(sheetBName))
                    {
                        sheetBName = sheetName + $"({count})";
                        count++;
                    }
                    var sheetClass = wb.Worksheets.Add(sheetBName);
                    FillStudentsDataIntoSheet(sheetClass, (from x in StudentsDictionary.Values where x.ClassID == _class.ObjectId select x).ToArray());
                }
                break;

            case "bus":
                ReportVisibleName += "(按班车分类).xlsx";
                foreach (var _bus in SchoolBusDictionary.Values)
                {
                    int    count      = 1;
                    string sheetName  = _bus.BusName;
                    string sheetBName = sheetName;
                    while (wb.Worksheets.Contains(sheetBName))
                    {
                        sheetBName = sheetName + $"({count})";
                        count++;
                    }
                    var sheetBus = wb.Worksheets.Add(_bus.BusName);
                    FillStudentsDataIntoSheet(sheetBus, (from x in StudentsDictionary.Values where x.BusID == _bus.ObjectId select x).ToArray());
                }
                break;

            case "all":
                ReportVisibleName += "(总表).xlsx";
                var sheetAll = wb.Worksheets.Add("总学生表");
                FillStudentsDataIntoSheet(sheetAll, StudentsDictionary.Values.ToArray());
                break;

            default: L.E("WTF This Week Report Scope is???? " + message.DataObject); return(true);
            }
            wb.SaveAs(ReportFilePath);
            var mediaId = WC_FileUploader.Upload(ReportFilePath, ReportVisibleName);
            WeChatSentMessage fileMsg = new WeChatSentMessage(WeChatSMsg.file, null, mediaId, null, message.Identifier == "##########" ? "liuhaoyu" : message.User.UserName);

            WeChatMessageSystem.AddToSendList(fileMsg);
            if (message.Identifier != "##########")
            {
                WeChatSentMessage msg2 = new WeChatSentMessage(WeChatSMsg.text, null, "报表已经准备好了,请查看!\r\n提示:报表数据量较大,建议发送到电脑或使用第三方查看器打开", null, message.User.UserName);
                WeChatMessageSystem.AddToSendList(msg2);
            }
            return(true);
        }