Пример #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 JsonResult GET(string BusID, string TeacherID, string ReportType, string Content)
        {
            if (!ValidateSession())
            {
                return(SessionError);
            }
            if (TeacherID != CurrentUser.ObjectId)
            {
                return(RequestIllegal);
            }
            if (DataBaseOperation.QuerySingle(new DBQuery().WhereIDIs(BusID).WhereEqualTo("TeacherObjectID", TeacherID), out SchoolBusObject bus) != DBQueryStatus.ONE_RESULT)
            {
                return(RequestIllegal);
            }

            BusReport busReport = new BusReport
            {
                BusID      = BusID,
                TeacherID  = TeacherID,
                ReportType = (BusReportTypeE)Convert.ToInt32(ReportType),
                OtherData  = Content
            };

            if (DataBaseOperation.CreateData(ref busReport) != DBQueryStatus.ONE_RESULT)
            {
                return(DataBaseError);
            }

            InternalMessage message_TP = new InternalMessage(InternalMessageTypes.Bus_Status_Report, CurrentUser, busReport, BusID);

            MessagingSystem.AddMessageProcesses(message_TP);
            return(Json(new { Report = busReport }));
        }
        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);
        }
Пример #4
0
        public JsonResult GET(string BusID, string TeacherID, string ReportType, string Content)
        {
            Dictionary <string, string> dict = new Dictionary <string, string>();

            if (ValidateSession())
            {
                if (TeacherID != CurrentUser.ObjectId)
                {
                    return(RequestIllegal);
                }
                if (DataBaseOperation.QuerySingleData(
                        new DBQuery()
                        .WhereEqualTo("objectId", BusID)
                        .WhereEqualTo("TeacherObjectID", TeacherID)
                        , out SchoolBusObject bus) != DBQueryStatus.ONE_RESULT)
                {
                    return(RequestIllegal);
                }
                BusReport busReport = new BusReport
                {
                    BusID      = BusID,
                    TeacherID  = TeacherID,
                    ReportType = (BusReportTypeE)Convert.ToInt32(ReportType),
                    OtherData  = Content
                };
                if (DataBaseOperation.CreateData(ref busReport) == DBQueryStatus.ONE_RESULT)
                {
                    InternalMessage message_TC = new InternalMessage()
                    {
                        DataObject = busReport,
                        ObjectId   = BusID,
                        User       = CurrentUser,
                        _Type      = GlobalMessageTypes.Bus_Status_Report_TC
                    };
                    InternalMessage message_TP = new InternalMessage()
                    {
                        DataObject = busReport,
                        ObjectId   = BusID,
                        User       = CurrentUser,
                        _Type      = GlobalMessageTypes.Bus_Status_Report_TP
                    };

                    MessagingSystem.AddMessageProcesses(message_TC, message_TP);
                    dict.Add("CreatedAt", busReport.CreatedAt.ToNormalString());
                    dict.Add("ErrCode", "0");
                    dict.Add("ReportID", busReport.ObjectId);
                    dict.Add("ErrMessage", "null");
                }
                else
                {
                    return(DataBaseError);
                }
            }
            return(Json(dict));
        }
        public IActionResult RequestChange()
        {
            ViewData["where"] = ControllerName;
            if (ValidateSession())
            {
                if (Request.HasFormContentType)
                {
                    Microsoft.AspNetCore.Http.IFormCollection form = Request.Form;
                    UserChangeRequestTypes types = (UserChangeRequestTypes)Enum.Parse(typeof(UserChangeRequestTypes), form[nameof(UserChangeRequest.RequestTypes)][0]);
                    string            reason     = form[nameof(UserChangeRequest.DetailTexts)][0];
                    string            newVal     = form[nameof(UserChangeRequest.NewContent)][0];
                    UserChangeRequest request    = new UserChangeRequest()
                    {
                        DetailTexts  = reason,
                        SolverID     = "",
                        NewContent   = newVal,
                        Status       = UCRProcessStatus.NotSolved,
                        RequestTypes = types,
                        UserID       = CurrentUser.ObjectId
                    };

                    if (DataBaseOperation.CreateData(ref request) != DBQueryStatus.ONE_RESULT)
                    {
                        LW.E("AccountController->ProcessNewUCR: Create UCR Failed!");
                        return(DatabaseError(ServerAction.MyAccount_CreateChangeRequest, XConfig.Messages["CreateUCR_Failed"]));
                    }

                    InternalMessage messageAdmin = new InternalMessage()
                    {
                        _Type = GlobalMessageTypes.UCR_Created_TO_ADMIN, DataObject = request, User = CurrentUser, ObjectId = request.ObjectId
                    };
                    InternalMessage message_User = new InternalMessage()
                    {
                        _Type = GlobalMessageTypes.UCR_Created__TO_User, DataObject = request, User = CurrentUser, ObjectId = request.ObjectId
                    };
                    MessagingSystem.AddMessageProcesses(messageAdmin, message_User);

                    return(Redirect($"/{HomeController.ControllerName}/{nameof(HomeController.RequestResult)}?req=changereq&status=ok&callback=/Account/"));
                }
                else
                {
                    ViewData["cUser"] = CurrentUser.ToString();
                    return(View(new UserChangeRequest()
                    {
                        UserID = CurrentUser.ObjectId
                    }));
                }
            }
            else
            {
                return(LoginFailed("/" + ControllerName + "/" + nameof(RequestChange)));
            }
        }
Пример #6
0
        public JsonResult POST()
        {
            FormCollection myform            = (FormCollection)Request.Form;
            Dictionary <string, string> dict = new Dictionary <string, string>();

            foreach (var item in myform)
            {
                dict.Add(item.Key, item.Value[0]);
            }
            if (!string.IsNullOrEmpty(dict["UserName"]))
            {
                if (dict.ContainsKey("Password"))
                {
                    if (ValidateSession())
                    {
                        string password = Cryptography.SHA256Encrypt(dict["Password"]);
                        if (CurrentUser.UserName == dict["UserName"])
                        {
                            CurrentUser.Password = password;
                            var temp = CurrentUser;
                            if (DataBaseOperation.UpdateData(ref temp) == DBQueryStatus.ONE_RESULT)
                            {
                                Response.Redirect("/Home");
                                return(SpecialisedInfo("OK"));
                            }
                            else
                            {
                                return(DataBaseError);
                            }
                        }
                        else
                        {
                            return(RequestIllegal);
                        }
                    }
                    else
                    {
                        return(SessionError);
                    }
                }
                else
                {
                    UserObject user = new UserObject()
                    {
                        UserName    = dict["UserName"],
                        RealName    = dict["RealName"],
                        Sex         = dict["Sex"],
                        PhoneNumber = dict["PhoneNumber"]
                    };
                    if (DataBaseOperation.CreateData(ref user) == DBQueryStatus.ONE_RESULT)
                    {
                        MessagingSystem.AddMessageProcesses(new InternalMessage()
                        {
                            User = user, _Type = GlobalMessageTypes.User__Pending_Verify, DataObject = dict["table"]
                        });
                        Response.Redirect("/Home");
                        return(SpecialisedInfo("OK"));
                    }
                    else
                    {
                        Response.Redirect("/Home/Error");
                        return(InternalError);
                    }
                }
            }
            else
            {
                return(RequestIllegal);
            }
        }
Пример #7
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;
        }