public void ProcessRequest(HttpContext context)
 {
     try
     {
         Utils.WriteTraceLog("UploadParentAddVehicle start");
         StreamReader reader = new StreamReader(context.Request.InputStream);
         string       str    = reader.ReadToEnd();
         reader.Close();
         string   ResultCode = string.Empty;
         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 = "2801";
         }
         else if (requestData.AccessToken == string.Empty || requestData.AccessToken == null)
         {
             ResultCode = "2802";
         }
         else if (requestData.ParentID == string.Empty || requestData.ParentID == null)
         {
             ResultCode = "2803";
         }
         else if (!bLLUsers.verifyUserID(requestData.ParentID, requestData.AccessToken))
         {
             ResultCode = "2804";
         }
         else if (!bLLBus.verifyBusPwd(requestData.BusID, requestData.BusPWD))
         {
             ResultCode = "2805";
         }
         else
         {
             string useridListString = bLLBus.getStringUserIDListByBusID(requestData.BusID);
             if (useridListString == null)
             {
                 useridListString = requestData.ParentID;
             }
             else
             {
                 string[] userids = useridListString.Split(',');
                 if (!userids.Contains(requestData.ParentID))
                 {
                     useridListString = useridListString + "," + requestData.ParentID;
                 }
             }
             int row = bLLBus.updateStringUseridList(requestData.BusID, useridListString);
             if (row == 0)
             {
                 ResultCode = "2806";
             }
             else
             {
                 UserInfo userInfo = bLLUsers.GetuserInfo(requestData.ParentID);
                 if (userInfo.busarray == null || userInfo.busarray == string.Empty)
                 {
                     userInfo.busarray = requestData.BusID;
                 }
                 else
                 {
                     string[] busArray = userInfo.busarray.Split(',');
                     if (!busArray.Contains(requestData.BusID))
                     {
                         userInfo.busarray = userInfo.busarray + "," + requestData.BusID;
                     }
                 }
                 int row1 = bLLUsers.updateBusArray(requestData.ParentID, userInfo.busarray);
                 if (row1 == 0)
                 {
                     ResultCode = "2807";
                 }
                 else
                 {
                     ResultCode = "0000";
                 }
             }
         }
         dict.Add("ResultCode", ResultCode);
         context.Response.ContentType = "text/html";
         context.Response.Write(jsSerializer.Serialize(dict));
         Utils.WriteTraceLog("UploadParentAddVehicle ResultCode====" + ResultCode);
         Utils.WriteTraceLog("UploadParentAddVehicle 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("UploadParentAddVehicle Exception " + ex);
         Utils.WriteTraceLog("UploadParentAddVehicle ResultCode====9991");
         Utils.WriteTraceLog("UploadParentAddVehicle end");
     }
 }
 public void ProcessRequest(HttpContext context)
 {
     try
     {
         Utils.WriteTraceLog("GetParentAddedVehicles start");
         StreamReader reader = new StreamReader(context.Request.InputStream);
         string       str    = reader.ReadToEnd();
         reader.Close();
         string   ResultCode = string.Empty;
         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 = "2701";
         }
         else if (requestData.AccessToken == string.Empty || requestData.AccessToken == null)
         {
             ResultCode = "2702";
         }
         else if (requestData.ParentID == string.Empty || requestData.ParentID == null)
         {
             ResultCode = "2703";
         }
         else if (!bLLUsers.verifyUserID(requestData.ParentID, requestData.AccessToken))
         {
             ResultCode = "2704";
         }
         else
         {
             UserInfo userInfo = bLLUsers.GetuserInfo(requestData.ParentID);
             if (userInfo.busarray == null)
             {
                 ResultCode = "2705";
             }
             else
             {
                 ResultCode = "0000";
                 string[]      buss     = userInfo.busarray.Split(',');
                 List <string> busArray = new List <string>();
                 for (int i = 0; i < buss.Length; i++)
                 {
                     if (!buss[i].Equals(string.Empty))
                     {
                         BusInfo busInfo = bLLBus.getBusInfoByBusID(buss[i]);
                         if (busInfo != null)
                         {
                             Dictionary <string, string> dictionary = new Dictionary <string, string>();
                             dictionary.Add("BusID", busInfo.busid);
                             dictionary.Add("BusName", busInfo.busname);
                             busArray.Add(jsSerializer.Serialize(dictionary));
                         }
                     }
                 }
                 dict.Add("AddedVehiclesArray", busArray.ToArray());
                 dict.Add("SelectedVehicleBusID", userInfo.selectbusid);
             }
         }
         dict.Add("ResultCode", ResultCode);
         context.Response.ContentType = "text/html";
         context.Response.Write(jsSerializer.Serialize(dict));
         Utils.WriteTraceLog("GetParentAddedVehicles ResultCode====" + ResultCode);
         Utils.WriteTraceLog("GetParentAddedVehicles 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("GetParentAddedVehicles Exception " + ex);
         Utils.WriteTraceLog("GetParentAddedVehicles ResultCode====9991");
         Utils.WriteTraceLog("GetParentAddedVehicles end");
     }
 }
Ejemplo n.º 3
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");
            }
        }
Ejemplo n.º 4
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));
        }
Ejemplo n.º 5
0
 public void ProcessRequest(HttpContext context)
 {
     try
     {
         Utils.WriteTraceLog("UploadParentSelectedVehicle start");
         StreamReader reader = new StreamReader(context.Request.InputStream);
         string       str    = reader.ReadToEnd();
         reader.Close();
         string   ResultCode = string.Empty;
         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 = "2901";
         }
         else if (requestData.AccessToken == string.Empty || requestData.AccessToken == null)
         {
             ResultCode = "2902";
         }
         else if (requestData.ParentID == string.Empty || requestData.ParentID == null)
         {
             ResultCode = "2903";
         }
         else if (!bLLUsers.verifyUserID(requestData.ParentID, requestData.AccessToken))
         {
             ResultCode = "2904";
         }
         else if (requestData.BusID == string.Empty || requestData.BusID == null)
         {
             ResultCode = "2905";
         }
         else
         {
             UserInfo userInfo = bLLUsers.GetuserInfo(requestData.ParentID);
             string[] userids  = bLLBus.getUserIDListByBusID(userInfo.selectbusid);
             if (userids != null)
             {
                 if (userids.Contains(requestData.ParentID))
                 {
                     List <string> arrayList = userids.ToList();
                     for (int i = 0; i < arrayList.Count; i++)
                     {
                         if (arrayList[i].Equals(requestData.ParentID))
                         {
                             arrayList.RemoveAt(i);
                         }
                     }
                     string[] newuserids = arrayList.ToArray();
                     int      row1       = bLLBus.updateUseridList(userInfo.selectbusid, newuserids);
                     if (row1 == 0)
                     {
                         ResultCode = "2906";
                     }
                 }
             }
             if (!ResultCode.Equals("2906"))
             {
                 int row = bLLUsers.updateSelectBusID(requestData.ParentID, requestData.BusID);
                 if (row == 0)
                 {
                     ResultCode = "2906";
                 }
                 else
                 {
                     string stringUserids = bLLBus.getStringUserIDListByBusID(requestData.BusID);
                     if (stringUserids == null)
                     {
                         stringUserids = requestData.ParentID;
                     }
                     else
                     {
                         string[] oldUserids = stringUserids.Split(',');
                         if (!oldUserids.Contains(requestData.ParentID))
                         {
                             stringUserids = stringUserids + "," + requestData.ParentID;
                         }
                     }
                     int row2 = bLLBus.updateStringUseridList(requestData.BusID, stringUserids);
                     if (row2 == 0)
                     {
                         ResultCode = "2906";
                     }
                     else
                     {
                         ResultCode = "0000";
                     }
                 }
             }
         }
         dict.Add("ResultCode", ResultCode);
         context.Response.ContentType = "text/html";
         context.Response.Write(jsSerializer.Serialize(dict));
         Utils.WriteTraceLog("UploadParentSelectedVehicle ResultCode====" + ResultCode);
         Utils.WriteTraceLog("UploadParentSelectedVehicle 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("UploadParentSelectedVehicle Exception " + ex);
         Utils.WriteTraceLog("UploadParentSelectedVehicle ResultCode====9991");
         Utils.WriteTraceLog("UploadParentSelectedVehicle end");
     }
 }