Beispiel #1
0
        public void ProcessRequest(HttpContext context)
        {
            BLLDrivers dri = new BLLDrivers();

            Utils.WriteTraceLog("Login start");
            context.Response.ContentType = "text/html";
            StreamReader reader = new StreamReader(context.Request.InputStream);
            string       str    = reader.ReadToEnd();

            Dictionary <string, object> dict         = new Dictionary <string, object>();
            JavaScriptSerializer        jsSerializer = new JavaScriptSerializer();
            //获取到登录信息
            string ResultCode = string.Empty;
            var    jarr       = jsSerializer.Deserialize <Dictionary <String, object> >(str);
            string userID     = jarr["userid"] == null ? string.Empty : jarr["userid"].ToString();
            string userPWD    = jarr["userpwd"] == null ? string.Empty : jarr["userpwd"].ToString();

            if (String.IsNullOrEmpty(userID) || String.IsNullOrEmpty(userPWD))
            {
                ResultCode = "2101";
            }


            //走家长登录流程
            else if (!dri.isDriver(userID))
            {
                BLLUsers bllUsers = new BLLUsers();
                string   tokenStr = bllUsers.GetAccessToken(userID, Utils.GetMD5FromString(userPWD));
                if (tokenStr != null && tokenStr != string.Empty)
                {
                    //家长登录成功,返回所需内容
                    ResultCode = "0000";
                    dict.Add("AccessToken", tokenStr);
                    UserInfo userInfo = bllUsers.GetuserInfo(userID);
                    dict.Add("Userid", userInfo.userid);
                    dict.Add("Username", userInfo.username);
                    dict.Add("Address", userInfo.address);
                    dict.Add("Role", userInfo.role);
                }
                else
                {
                    //登录不成功
                    ResultCode = "2102";
                }
            }
            //走司机登录流程
            else
            {
                BLLDrivers bllDrivers = new BLLDrivers();
                string     tokenStr   = bllDrivers.GetAccessToken(userID, Utils.GetMD5FromString(userPWD));
                if (tokenStr != null && tokenStr != string.Empty)
                {
                    //家长登录成功,返回所需内容
                    ResultCode = "0000";
                    dict.Add("AccessToken", tokenStr);
                    DriverModel driveInfo = bllDrivers.GetDriverInfo(userID, Utils.GetMD5FromString(userPWD));
                    dict.Add("Userid", driveInfo.driverid);
                    dict.Add("Username", driveInfo.drivername);
                    dict.Add("Address", driveInfo.address);
                    dict.Add("Role", "driver");
                }
                else
                {
                    //登录不成功
                    ResultCode = "2102";
                }
            }
            dict.Add("ResultCode", ResultCode);
            context.Response.Write(jsSerializer.Serialize(dict));
        }
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                Utils.WriteTraceLog("DeleteSelectedVehicleThroughDriver start");
                StreamReader reader = new StreamReader(context.Request.InputStream);
                string       str    = reader.ReadToEnd();
                reader.Close();
                string     ResultCode                    = string.Empty;
                BLLDrivers bLLDrivers                    = new BLLDrivers();
                BLLBus     bLLBus                        = new BLLBus();
                BLLUsers   bLLUsers                      = new BLLUsers();
                Dictionary <string, object> dict         = new Dictionary <string, object>();
                JavaScriptSerializer        jsSerializer = new JavaScriptSerializer();
                RequestData requestData                  = jsSerializer.Deserialize <RequestData>(str);
                if (requestData == null)
                {
                    ResultCode = "3301";
                }
                else if (requestData.AccessToken == string.Empty || requestData.AccessToken == null)
                {
                    ResultCode = "3302";
                }
                else if (requestData.DriverID == string.Empty || requestData.DriverID == null)
                {
                    ResultCode = "3303";
                }
                else if (!bLLDrivers.verifyDriverID(requestData.DriverID, requestData.AccessToken))
                {
                    ResultCode = "3304";
                }
                else if (requestData.BusID == string.Empty || requestData.BusID == null)
                {
                    ResultCode = "3305";
                }

                else
                {
                    bool     result     = false;
                    string[] userIDList = bLLBus.getUserIDListByBusID(requestData.BusID);
                    if (userIDList == null)
                    {
                        result     = bLLBus.deleteBusInfoByBusID(requestData.BusID);
                        ResultCode = "0000";
                    }
                    else
                    {
                        for (int i = 0; i < userIDList.Length; i++)
                        {
                            bLLUsers.deleteSelectedVehicle(userIDList[i], requestData.BusID);
                        }
                        result     = bLLBus.deleteBusInfoByBusID(requestData.BusID);
                        ResultCode = "0000";
                    }
                }
                dict.Add("ResultCode", ResultCode);
                context.Response.ContentType = "text/html";
                context.Response.Write(jsSerializer.Serialize(dict));
                Utils.WriteTraceLog("DeleteSelectedVehicleThroughDriver ResultCode====" + ResultCode);
                Utils.WriteTraceLog("DeleteSelectedVehicleThroughDriver end");
            }
            catch (Exception ex)
            {
                Dictionary <string, string> dict         = new Dictionary <string, string>();
                JavaScriptSerializer        jsSerializer = new JavaScriptSerializer();
                dict.Add("ResultCode", "9991");
                context.Response.ContentType = "text/html";
                context.Response.Write(jsSerializer.Serialize(dict));
                Utils.WriteTraceLog("DeleteSelectedVehicleThroughDriver Exception " + ex);
                Utils.WriteTraceLog("DeleteSelectedVehicleThroughDriver ResultCode====9991");
                Utils.WriteTraceLog("DeleteSelectedVehicleThroughDriver end");
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            Utils.WriteTraceLog("register start");
            context.Response.ContentType = "text/html";
            try
            {
                StreamReader reader = new StreamReader(context.Request.InputStream);
                string       str    = reader.ReadToEnd();

                Dictionary <string, string> dict         = new Dictionary <string, string>();
                JavaScriptSerializer        jsSerializer = new JavaScriptSerializer();
                //获取到注册信息
                string ResultCode = string.Empty;
                var    jarr       = jsSerializer.Deserialize <Dictionary <String, object> >(str);
                if (jarr == null || jarr["role"].Equals(string.Empty))
                {
                    ResultCode = "2001";
                    dict.Add("ResultCode", ResultCode);
                    context.Response.Write(jsSerializer.Serialize(dict));
                    return;
                }
                string roleStr     = jarr["role"].ToString();
                string useridStr   = jarr["userid"].ToString();
                string usernameStr = jarr["username"].ToString();
                string userpwdStr  = jarr["userpwd"].ToString();
                string addressStr  = jarr["address"].ToString();
                string tokenStr    = Guid.NewGuid().ToString();
                if (roleStr.Equals("parent"))
                {
                    UserInfo userInfo = new UserInfo();
                    userInfo.userid      = useridStr;
                    userInfo.username    = usernameStr;
                    userInfo.userpwd     = Utils.GetMD5FromString(userpwdStr);
                    userInfo.address     = addressStr;
                    userInfo.accesstoken = tokenStr;
                    BLLUsers bllUsers = new BLLUsers();
                    ResultCode = bllUsers.RegisterParent(userInfo);
                }
                else
                {
                    DriverModel driverInfo = new DriverModel();
                    driverInfo.driverid    = useridStr;
                    driverInfo.drivername  = usernameStr;
                    driverInfo.driverpwd   = Utils.GetMD5FromString(userpwdStr);
                    driverInfo.address     = addressStr;
                    driverInfo.accesstoken = tokenStr;
                    BLLDrivers bllDrivers = new BLLDrivers();
                    ResultCode = bllDrivers.RegisterDriver(driverInfo);
                }
                Utils.WriteTraceLog("register ResultCode:" + ResultCode);
                dict.Add("ResultCode", ResultCode);
                context.Response.Write(jsSerializer.Serialize(dict));
            }
            catch (Exception ex)
            {
                string str = ex.StackTrace;
                Utils.WriteTraceLog("register Exception:" + str);
                Dictionary <string, string> dict         = new Dictionary <string, string>();
                JavaScriptSerializer        jsSerializer = new JavaScriptSerializer();
                dict.Add("ResultCode", "9991");
                context.Response.Write(jsSerializer.Serialize(dict));
            }
        }
Beispiel #4
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                Utils.WriteTraceLog("GetStudentsSort start");
                StreamReader reader = new StreamReader(context.Request.InputStream);
                string       str    = reader.ReadToEnd();
                reader.Close();
                string     ResultCode                    = string.Empty;
                BLLDrivers bLLDrivers                    = new BLLDrivers();
                BLLBus     bLLBus                        = new BLLBus();
                BLLUsers   bLLUsers                      = new BLLUsers();
                Dictionary <string, object> dict         = new Dictionary <string, object>();
                JavaScriptSerializer        jsSerializer = new JavaScriptSerializer();
                RequestData requestData                  = jsSerializer.Deserialize <RequestData>(str);
                if (requestData == null)
                {
                    ResultCode = "2401";
                }
                else if (requestData.AccessToken == string.Empty || requestData.AccessToken == null)
                {
                    ResultCode = "2402";
                }
                else if (requestData.DriverID == string.Empty || requestData.DriverID == null)
                {
                    ResultCode = "2403";
                }
                else if (!bLLDrivers.verifyDriverID(requestData.DriverID, requestData.AccessToken))
                {
                    ResultCode = "2404";
                }
                else if (requestData.BusID == string.Empty || requestData.BusID == null)
                {
                    ResultCode = "2405";
                }

                else
                {
                    string[] userIDArray = bLLBus.getUserIDListByBusID(requestData.BusID);
                    if (userIDArray == null)
                    {
                        ResultCode = "2406";
                    }
                    else
                    {
                        ResultCode = "0000";
                        string[] userInfoArray = new string[userIDArray.Length];
                        for (int i = 0; i < userIDArray.Length; i++)
                        {
                            UserInfo userInfo = bLLUsers.GetuserInfo(userIDArray[i]);
                            Dictionary <string, string> dictionary = new Dictionary <string, string>();
                            dictionary.Add("StudentID", userInfo.userid);
                            dictionary.Add("StudentName", userInfo.username);
                            dictionary.Add("FamilyAddress", userInfo.address);
                            userInfoArray[i] = jsSerializer.Serialize(dictionary);
                        }
                        dict.Add("StudentsSortArray", userInfoArray);
                    }
                }
                dict.Add("ResultCode", ResultCode);
                context.Response.ContentType = "text/html";
                context.Response.Write(jsSerializer.Serialize(dict));
                Utils.WriteTraceLog("GetStudentsSort ResultCode====" + ResultCode);
                Utils.WriteTraceLog("GetStudentsSort end");
            }
            catch (Exception ex)
            {
                Dictionary <string, string> dict         = new Dictionary <string, string>();
                JavaScriptSerializer        jsSerializer = new JavaScriptSerializer();
                dict.Add("ResultCode", "9991");
                context.Response.ContentType = "text/html";
                context.Response.Write(jsSerializer.Serialize(dict));
                Utils.WriteTraceLog("GetStudentsSort Exception " + ex);
                Utils.WriteTraceLog("GetStudentsSort ResultCode====9991");
                Utils.WriteTraceLog("GetStudentsSort end");
            }
        }
Beispiel #5
0
 public void ProcessRequest(HttpContext context)
 {
     try
     {
         Utils.WriteTraceLog("UploadStudentsSort start");
         StreamReader reader = new StreamReader(context.Request.InputStream);
         string       str    = reader.ReadToEnd();
         reader.Close();
         string     ResultCode                    = string.Empty;
         BLLDrivers bLLDrivers                    = new BLLDrivers();
         BLLBus     bLLBus                        = new BLLBus();
         Dictionary <string, object> dict         = new Dictionary <string, object>();
         JavaScriptSerializer        jsSerializer = new JavaScriptSerializer();
         RequestData requestData                  = jsSerializer.Deserialize <RequestData>(str);
         if (requestData == null)
         {
             ResultCode = "2501";
         }
         else if (requestData.AccessToken == string.Empty || requestData.AccessToken == null)
         {
             ResultCode = "2502";
         }
         else if (requestData.DriverID == string.Empty || requestData.DriverID == null)
         {
             ResultCode = "2503";
         }
         else if (!bLLDrivers.verifyDriverID(requestData.DriverID, requestData.AccessToken))
         {
             ResultCode = "2504";
         }
         else if (requestData.BusID == string.Empty || requestData.BusID == null)
         {
             ResultCode = "2505";
         }
         else if (requestData.StudentsSortArray == null || requestData.StudentsSortArray.Count == 0)
         {
             ResultCode = "2506";
         }
         else
         {
             ArrayList tmpArrList = new ArrayList();
             foreach (object item in requestData.StudentsSortArray)
             {
                 RequestArrayData requestArrayData = jsSerializer.Deserialize <RequestArrayData>(item.ToString());
                 tmpArrList.Add(requestArrayData);
             }
             requestData.StudentsSortData = tmpArrList;
             int      j          = 0;
             string[] useridList = new string[requestData.StudentsSortData.Count];
             foreach (RequestArrayData dataItem in requestData.StudentsSortData)
             {
                 useridList[j] = dataItem.StudentID;
                 j++;
             }
             int row = bLLBus.updateUseridList(requestData.BusID, useridList);
             if (row > 0)
             {
                 ResultCode = "0000";
             }
             else
             {
                 ResultCode = "2507";
             }
         }
         dict.Add("ResultCode", ResultCode);
         context.Response.ContentType = "text/html";
         context.Response.Write(jsSerializer.Serialize(dict));
         Utils.WriteTraceLog("UploadStudentsSort ResultCode====" + ResultCode);
         Utils.WriteTraceLog("UploadStudentsSort end");
     }
     catch (Exception ex)
     {
         Dictionary <string, string> dict         = new Dictionary <string, string>();
         JavaScriptSerializer        jsSerializer = new JavaScriptSerializer();
         dict.Add("ResultCode", "9991");
         context.Response.ContentType = "text/html";
         context.Response.Write(jsSerializer.Serialize(dict));
         Utils.WriteTraceLog("UploadStudentsSort Exception " + ex);
         Utils.WriteTraceLog("UploadStudentsSort ResultCode====9991");
         Utils.WriteTraceLog("UploadStudentsSort end");
     }
 }
Beispiel #6
0
 public void ProcessRequest(HttpContext context)
 {
     try
     {
         Utils.WriteTraceLog("GetDriverAddedVehicles start");
         StreamReader reader = new StreamReader(context.Request.InputStream);
         string       str    = reader.ReadToEnd();
         reader.Close();
         string     ResultCode                    = string.Empty;
         BLLDrivers bLLDrivers                    = new BLLDrivers();
         BLLBus     bLLBus                        = new BLLBus();
         Dictionary <string, object> dict         = new Dictionary <string, object>();
         JavaScriptSerializer        jsSerializer = new JavaScriptSerializer();
         RequestData requestData                  = jsSerializer.Deserialize <RequestData>(str);
         if (requestData == null)
         {
             ResultCode = "2201";
         }
         else if (requestData.AccessToken == string.Empty || requestData.AccessToken == null)
         {
             ResultCode = "2202";
         }
         else if (requestData.DriverID == string.Empty || requestData.DriverID == null)
         {
             ResultCode = "2203";
         }
         else if (!bLLDrivers.verifyDriverID(requestData.DriverID, requestData.AccessToken))
         {
             ResultCode = "2204";
         }
         else if (bLLBus.getBusInfoByDriverID(requestData.DriverID) == null)
         {
             ResultCode = "2205";
         }
         else
         {
             ResultCode = "0000";
             List <BusInfo> busList  = bLLBus.getBusInfoByDriverID(requestData.DriverID);
             string[]       busArray = new string[busList.Count];
             for (int i = 0; i < busArray.Length; i++)
             {
                 Dictionary <string, string> dictionary = new Dictionary <string, string>();
                 dictionary.Add("BusID", busList[i].busid);
                 dictionary.Add("BusPWD", busList[i].buspwd);
                 dictionary.Add("BusName", busList[i].busname);
                 busArray[i] = jsSerializer.Serialize(dictionary);
             }
             dict.Add("VehiclesArray", busArray);
         }
         dict.Add("ResultCode", ResultCode);
         context.Response.ContentType = "text/html";
         context.Response.Write(jsSerializer.Serialize(dict));
         Utils.WriteTraceLog("GetDriverAddedVehicles ResultCode====" + ResultCode);
         Utils.WriteTraceLog("GetDriverAddedVehicles end");
     }
     catch (Exception ex)
     {
         Dictionary <string, string> dict         = new Dictionary <string, string>();
         JavaScriptSerializer        jsSerializer = new JavaScriptSerializer();
         dict.Add("ResultCode", "9991");
         context.Response.ContentType = "text/html";
         context.Response.Write(jsSerializer.Serialize(dict));
         Utils.WriteTraceLog("GetDriverAddedVehicles Exception " + ex);
         Utils.WriteTraceLog("GetDriverAddedVehicles ResultCode====9991");
         Utils.WriteTraceLog("GetDriverAddedVehicles end");
     }
 }
Beispiel #7
0
 public void ProcessRequest(HttpContext context)
 {
     try
     {
         Utils.WriteTraceLog("UploadDriverAddVehicle start");
         StreamReader reader = new StreamReader(context.Request.InputStream);
         string       str    = reader.ReadToEnd();
         reader.Close();
         string     ResultCode                    = string.Empty;
         BLLDrivers bLLDrivers                    = new BLLDrivers();
         BLLBus     bLLBus                        = new BLLBus();
         Dictionary <string, string> dict         = new Dictionary <string, string>();
         JavaScriptSerializer        jsSerializer = new JavaScriptSerializer();
         RequestData requestData                  = jsSerializer.Deserialize <RequestData>(str);
         if (requestData == null)
         {
             ResultCode = "2301";
         }
         else if (requestData.AccessToken == string.Empty || requestData.AccessToken == null)
         {
             ResultCode = "2302";
         }
         else if (requestData.DriverID == string.Empty || requestData.DriverID == null)
         {
             ResultCode = "2303";
         }
         else if (!bLLDrivers.verifyDriverID(requestData.DriverID, requestData.AccessToken))
         {
             ResultCode = "2304";
         }
         else if (requestData.BusName == string.Empty || requestData.BusName == null)
         {
             ResultCode = "2306";
         }
         else if (bLLBus.IsBusNameExists(requestData.BusName))
         {
             ResultCode = "2307";
         }
         else
         {
             BusInfo newBusInfo = bLLBus.driverAddVehicle(requestData.DriverID, requestData.BusName);
             if (newBusInfo == null)
             {
                 ResultCode = "2305";
             }
             else
             {
                 ResultCode = "0000";
                 dict.Add("BusID", newBusInfo.busid);
                 dict.Add("BusPWD", newBusInfo.buspwd);
                 dict.Add("BusName", newBusInfo.busname);
             }
         }
         dict.Add("ResultCode", ResultCode);
         context.Response.ContentType = "text/html";
         context.Response.Write(jsSerializer.Serialize(dict));
         Utils.WriteTraceLog("UploadDriverAddVehicle ResultCode====" + ResultCode);
         Utils.WriteTraceLog("UploadDriverAddVehicle end");
     }
     catch (Exception ex)
     {
         Dictionary <string, string> dict         = new Dictionary <string, string>();
         JavaScriptSerializer        jsSerializer = new JavaScriptSerializer();
         dict.Add("ResultCode", "9991");
         context.Response.ContentType = "text/html";
         context.Response.Write(jsSerializer.Serialize(dict));
         Utils.WriteTraceLog("UploadDriverAddVehicle Exception " + ex);
         Utils.WriteTraceLog("UploadDriverAddVehicle ResultCode====9991");
         Utils.WriteTraceLog("UploadDriverAddVehicle end");
     }
 }