コード例 #1
0
ファイル: BaseController.cs プロジェクト: Will-Kim/IOTAPI
        // Error 처리
        private HKRheader setHKRheader_Err(HKRheader header, int noErr,
                                           string msgErr, string token, LOGDBDataContext logdb, LOG Log)
        {
            header.auth_token = token;
            // 결과에 대한 result_code 처리 로직 추가 필요
            header.result_code = noErr;
            header.message     = msgErr;

            Log.result = msgErr;
            logdb.LOGs.InsertOnSubmit(Log);
            logdb.SubmitChanges();

            return(header);
        }
コード例 #2
0
        public ActionResult AddRoadBike(int?id)
        {
            Stream req = Request.InputStream;

            req.Seek(0, System.IO.SeekOrigin.Begin);
            string json = new StreamReader(req).ReadToEnd();
            //AppendLog("[REQ HKSports/LoginController]" + json);

            string   actionName = "AddRoadBike";
            DateTime dtNow      = DateTime.Now;

            // 객체 초기화
            JsonRoadBike jsonRoadBike   = null;
            UserInfo     returnUserInfo = new UserInfo();
            HKRheader    rHeader        = new HKRheader();
            UserInfoBody uiBody         = new UserInfoBody();

            LOG newLog = new LOG(); // 로그 객체

            // DB Context 가져오기
            HKRiderDBDataContext db    = new HKRiderDBDataContext(/*connectionString here */);
            LOGDBDataContext     logdb = new LOGDBDataContext(/**/);

            try
            {
                jsonRoadBike = JsonConvert.DeserializeObject <JsonRoadBike>(json);

                // Log 처리 루틴 -------------------------------------------------
                newLog.action     = jsonRoadBike.header.action;
                newLog.auth_token = jsonRoadBike.header.auth_token;
                newLog.json       = json;
                newLog.dt_created = dtNow;
                newLog.user_id    = jsonRoadBike.body.nickname;
                // Log 처리 루틴 -------------------------------------------------

                if (!jsonRoadBike.header.action.Equals(actionName))
                {
                    returnUserInfo.header = setHKRheader_Err(rHeader, 101, "[ERROR] Action is wrong: " + jsonRoadBike.header.action,
                                                             returnUserInfo.header.auth_token, logdb, newLog);
                    return(Json(returnUserInfo, JsonRequestBehavior.AllowGet));
                }
                else if (jsonRoadBike.header.auth_token == null || jsonRoadBike.header.auth_token == "")
                {
                    returnUserInfo.header = setHKRheader_Err(rHeader, 103, "[ERROR] Auth Token is wrong: " + jsonRoadBike.header.auth_token,
                                                             returnUserInfo.header.auth_token, logdb, newLog);
                    return(Json(returnUserInfo, JsonRequestBehavior.AllowGet));
                }

                // Version Check 추가 예정

                // User 가져오기
                USER thisUser = (from u in db.USERs
                                 where   u.Auth_Token == jsonRoadBike.header.auth_token
                                 select u).SingleOrDefault();

                if (thisUser == null)
                {
                    //Error 202: 다시 접속하세요. 유저정보를 확인할 수 없습니다.
                    returnUserInfo.header = setHKRheader_Err(rHeader, 202, "[ERROR] 다시 접속하세요. 유저정보를 확인할 수 없습니다: " +
                                                             jsonRoadBike.header.auth_token, jsonRoadBike.header.auth_token, logdb, newLog);
                    return(Json(returnUserInfo, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    ROADBIKE theBike = thisUser.ROADBIKEs.Where(r => r.Nickname == jsonRoadBike.body.nickname).SingleOrDefault();

                    if (theBike == null) //신규 바이크.
                    {
                        foreach (ROADBIKE rb in thisUser.ROADBIKEs)
                        {
                            if (rb.DeviceID.Equals(jsonRoadBike.body.device_id))
                            {
                                //Error 204: 이미 존재하는 디바이스 ID입니다.
                                returnUserInfo.header = setHKRheader_Err(rHeader, 204,
                                                                         "[ERROR] 이미 존재하는 디바이스 ID입니다: " + jsonRoadBike.body.device_id + "," +
                                                                         thisUser.EMail, thisUser.Auth_Token, logdb, newLog);
                                return(Json(returnUserInfo, JsonRequestBehavior.AllowGet));
                            }
                        }
                        ROADBIKE newRoadBike = new ROADBIKE();
                        newRoadBike.Nickname            = jsonRoadBike.body.nickname;
                        newRoadBike.Type                = (byte)jsonRoadBike.body.type; // 타입을 정수로 보관할 필요가 있는지?
                        newRoadBike.Typename            = jsonRoadBike.body.typename;   // 타입 이름이 있으므로...
                        newRoadBike.WheelSize           = jsonRoadBike.body.wheel_size;
                        newRoadBike.Modelname           = jsonRoadBike.body.modelname;
                        newRoadBike.ColorSize           = jsonRoadBike.body.color_size;
                        newRoadBike.FrameNo             = jsonRoadBike.body.frame_no;
                        newRoadBike.Characteristics     = jsonRoadBike.body.characteristics;
                        newRoadBike.DeviceID            = jsonRoadBike.body.device_id;
                        newRoadBike.Pictures            = jsonRoadBike.body.pictures;
                        newRoadBike.AvatarLevel         = 1;
                        newRoadBike.RidingScore         = 0;
                        newRoadBike.RidingCount         = 0;
                        newRoadBike.DistanceAccumulated = 0;
                        newRoadBike.TimeAccumulated     = 0;
                        newRoadBike.AverageDistance     = 0;
                        newRoadBike.AverageRidingTime   = 0;
                        newRoadBike.CaloriesAccumulated = 0;
                        newRoadBike.AverageCalories     = 0;
                        newRoadBike.Lost                = "N";
                        newRoadBike.LastGPS             = "";

                        newRoadBike.DT_registered = dtNow;
                        newRoadBike.DT_lastaccess = dtNow;
                        //theBike.USERS_id = thisUser.id; // 오류남.

                        thisUser.ROADBIKEs.Add(newRoadBike);
                        thisUser.DT_lastaccess = dtNow;
                    }
                    else // 기존 바이크 업데이트
                    {
                        //theBike.Nickname = jsonRoadBike.body.nickname;
                        theBike.Type            = (byte)jsonRoadBike.body.type; // 타입을 정수로 보관할 필요가 있는지?
                        theBike.Typename        = jsonRoadBike.body.typename;   // 타입 이름이 있으므로...
                        theBike.WheelSize       = jsonRoadBike.body.wheel_size;
                        theBike.Modelname       = jsonRoadBike.body.modelname;
                        theBike.ColorSize       = jsonRoadBike.body.color_size;
                        theBike.FrameNo         = jsonRoadBike.body.frame_no;
                        theBike.Characteristics = jsonRoadBike.body.characteristics;
                        theBike.DeviceID        = jsonRoadBike.body.device_id;
                        theBike.Pictures        = jsonRoadBike.body.pictures;
                        //theBike.Lost = jsonRoadBike.body.lost; // 분실 도움 요청. --> 신고 및 취소에서 만 반영
                        theBike.DT_lastaccess = dtNow;
                        theBike.LastGPS       = jsonRoadBike.body.last_gps;
                    }
                }

                db.SubmitChanges();
                logdb.LOGs.InsertOnSubmit(newLog);

                returnUserInfo.header = rHeader;
                returnUserInfo.body   = uiBody;
                returnUserInfo        = getUserInformation(returnUserInfo, thisUser); // 다시 계정 정보를 받아서 리턴해 준다.

                return(Json(returnUserInfo, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                // Error: Exception
                returnUserInfo.header = setHKRheader_Err(rHeader, 301, "[ERROR] Exception: " + ex.Message
                                                         , jsonRoadBike == null?"jsonRoadBike is null":jsonRoadBike.header.auth_token, logdb, newLog);
                return(Json(returnUserInfo, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #3
0
        public ActionResult GetBikeLost(int?id)
        {
            Stream req = Request.InputStream;

            req.Seek(0, System.IO.SeekOrigin.Begin);
            string json = new StreamReader(req).ReadToEnd();
            //AppendLog("[REQ HKSports/LoginController]" + json);

            string   actionName = "GetBikeLost";
            DateTime dtNow      = DateTime.Now;

            // 객체 초기화
            JsonBikeLost jsonBikeLost   = null;
            JsonBikeLost returnBikeLost = new JsonBikeLost();
            HKRheader    rHeader        = new HKRheader();
            BikeLost     bikeLostBody   = new BikeLost();

            LOG newLog = new LOG(); // 로그 객체

            // DB Context 가져오기
            HKRiderDBDataContext db    = new HKRiderDBDataContext(/*connectionString here */);
            LOGDBDataContext     logdb = new LOGDBDataContext(/**/);

            try
            {
                jsonBikeLost = JsonConvert.DeserializeObject <JsonBikeLost>(json);

                // Log 처리 루틴 -------------------------------------------------
                newLog.action     = jsonBikeLost.header.action;
                newLog.auth_token = jsonBikeLost.header.auth_token;
                newLog.json       = json;
                newLog.dt_created = dtNow;
                newLog.user_id    = jsonBikeLost.body.nickname;
                // Log 처리 루틴 -------------------------------------------------

                if (!jsonBikeLost.header.action.Equals(actionName))
                {
                    returnBikeLost.header = setHKRheader_Err(rHeader, 101, "[ERROR] Action is wrong: " + jsonBikeLost.header.action,
                                                             jsonBikeLost.header.auth_token, logdb, newLog);
                    return(Json(returnBikeLost, JsonRequestBehavior.AllowGet));
                }
                else if (jsonBikeLost.header.auth_token == null || jsonBikeLost.header.auth_token == "")
                {
                    returnBikeLost.header = setHKRheader_Err(rHeader, 103, "[ERROR] Auth Token is wrong: " + jsonBikeLost.header.auth_token,
                                                             jsonBikeLost.header.auth_token, logdb, newLog);
                    return(Json(returnBikeLost, JsonRequestBehavior.AllowGet));
                }

                // Version Check 추가 예정

                // User 가져오기
                USER thisUser = (from u in db.USERs
                                 where   u.Auth_Token == jsonBikeLost.header.auth_token
                                 select u).SingleOrDefault();

                if (thisUser == null) // 유저가 존재하는지 확인
                {
                    //Error 202: 다시 접속하세요. 유저정보를 확인할 수 없습니다.
                    returnBikeLost.header = setHKRheader_Err(rHeader, 202, "[ERROR] 다시 접속하세요. 유저정보를 확인할 수 없습니다: " +
                                                             thisUser.EMail, thisUser.Auth_Token, logdb, newLog);
                    return(Json(returnBikeLost, JsonRequestBehavior.AllowGet));
                }
                else // 분실신고 바이크의 정보가 있는지 확인.
                {
                    ROADBIKE theBike = db.ROADBIKEs.Where(r => r.Nickname == jsonBikeLost.body.nickname).SingleOrDefault();

                    if (theBike == null) //존재하지 않는 바이크.
                    {
                        //Error 205: 아바타 정보를 확인할 수 없습니다. 계속 문제 발생시 다시 로그인해 주세요.
                        returnBikeLost.header = setHKRheader_Err(rHeader, 205, "[ERROR] 아바타 정보를 확인할 수 없습니다. 계속 문제 발생시 다시 로그인해 주세요.: " +
                                                                 thisUser.EMail, thisUser.Auth_Token, logdb, newLog);
                        return(Json(returnBikeLost, JsonRequestBehavior.AllowGet));
                    }
                    else // 분실 신고 테이블에서 조회.
                    {
                        LOSTBIKE lostBike = (from l in db.LOSTBIKEs
                                             where l.BikeNickname == jsonBikeLost.body.nickname &&
                                             l.Status.Contains("L")
                                             select l).SingleOrDefault();
                        if (lostBike == null) //존재하지 않는 분실신고.
                        {
                            //Error 208: 조회할 분실신고가 없습니다.
                            returnBikeLost.header = setHKRheader_Err(rHeader, 208, "[ERROR] 조회할 분실신고가 없습니다.: " +
                                                                     thisUser.EMail, thisUser.Auth_Token, logdb, newLog);
                            return(Json(returnBikeLost, JsonRequestBehavior.AllowGet));
                        }
                        else
                        {
                            bikeLostBody.characteristics = lostBike.Characteristics;
                            bikeLostBody.color_size      = lostBike.ColorSize;
                            bikeLostBody.device_id       = lostBike.DeviceID;
                            bikeLostBody.extra_info      = lostBike.ExtraInfo;
                            bikeLostBody.frame_no        = lostBike.FrameNo;
                            bikeLostBody.location_lost   = lostBike.LocationLost;
                            bikeLostBody.modelname       = lostBike.ModelName;
                            bikeLostBody.nickname        = lostBike.BikeNickname;
                            bikeLostBody.phone_no        = lostBike.PhoneNo;
                            bikeLostBody.status          = lostBike.Status;
                            bikeLostBody.username        = lostBike.UserName;
                            bikeLostBody.dt_lost         = lostBike.DT_lost;
                        }
                    }
                }

                logdb.LOGs.InsertOnSubmit(newLog);


                returnBikeLost.header = rHeader;
                returnBikeLost.body   = bikeLostBody;

                return(Json(returnBikeLost, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                // Error: Exception
                returnBikeLost.header = setHKRheader_Err(rHeader, 301, "[ERROR] Exception: " + ex.Message
                                                         , jsonBikeLost == null?"jsonRoadBike is null": jsonBikeLost.header.auth_token, logdb, newLog);
                return(Json(returnBikeLost, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #4
0
        public ActionResult AddBikeLost(int?id)
        {
            Stream req = Request.InputStream;

            req.Seek(0, System.IO.SeekOrigin.Begin);
            string json = new StreamReader(req).ReadToEnd();
            //AppendLog("[REQ HKSports/LoginController]" + json);

            string   actionName = "AddBikeLost";
            DateTime dtNow      = DateTime.Now;

            // 객체 초기화
            JsonBikeLost jsonBikeLost   = null;
            UserInfo     returnUserInfo = new UserInfo();
            HKRheader    rHeader        = new HKRheader();
            UserInfoBody uiBody         = new UserInfoBody();

            LOG newLog = new LOG(); // 로그 객체

            // DB Context 가져오기
            HKRiderDBDataContext db    = new HKRiderDBDataContext(/*connectionString here */);
            LOGDBDataContext     logdb = new LOGDBDataContext(/**/);

            try
            {
                jsonBikeLost = JsonConvert.DeserializeObject <JsonBikeLost>(json);

                // Log 처리 루틴 -------------------------------------------------
                newLog.action     = jsonBikeLost.header.action;
                newLog.auth_token = jsonBikeLost.header.auth_token;
                newLog.json       = json;
                newLog.dt_created = dtNow;
                newLog.user_id    = jsonBikeLost.body.nickname;
                // Log 처리 루틴 -------------------------------------------------

                if (!jsonBikeLost.header.action.Equals(actionName))
                {
                    returnUserInfo.header = setHKRheader_Err(rHeader, 101, "[ERROR] Action is wrong: " + jsonBikeLost.header.action,
                                                             jsonBikeLost.header.auth_token, logdb, newLog);
                    return(Json(returnUserInfo, JsonRequestBehavior.AllowGet));
                }
                else if (jsonBikeLost.header.auth_token == null || jsonBikeLost.header.auth_token == "")
                {
                    returnUserInfo.header = setHKRheader_Err(rHeader, 103, "[ERROR] Auth Token is wrong: " + jsonBikeLost.header.auth_token,
                                                             jsonBikeLost.header.auth_token, logdb, newLog);
                    return(Json(returnUserInfo, JsonRequestBehavior.AllowGet));
                }

                // Version Check 추가 예정

                // User 가져오기
                USER thisUser = (from u in db.USERs
                                 where   u.Auth_Token == jsonBikeLost.header.auth_token
                                 select u).SingleOrDefault();

                if (thisUser == null) // 유저가 존재하는지 확인
                {
                    //Error 202: 다시 접속하세요. 유저정보를 확인할 수 없습니다.
                    returnUserInfo.header = setHKRheader_Err(rHeader, 202, "[ERROR] 다시 접속하세요. 유저정보를 확인할 수 없습니다: " +
                                                             thisUser.EMail, thisUser.Auth_Token, logdb, newLog);
                    return(Json(returnUserInfo, JsonRequestBehavior.AllowGet));
                }
                else // 분실신고 바이크의 정보가 있는지 확인.
                {
                    ROADBIKE theBike = thisUser.ROADBIKEs.Where(r => r.Nickname == jsonBikeLost.body.nickname).SingleOrDefault();

                    if (theBike == null) //존재하지 않는 바이크.
                    {
                        //Error 205: 아바타 정보를 확인할 수 없습니다. 계속 문제 발생시 다시 로그인해 주세요.
                        returnUserInfo.header = setHKRheader_Err(rHeader, 205, "[ERROR] 아바타 정보를 확인할 수 없습니다. 계속 문제 발생시 다시 로그인해 주세요.: " +
                                                                 thisUser.EMail, thisUser.Auth_Token, logdb, newLog);
                        return(Json(returnUserInfo, JsonRequestBehavior.AllowGet));
                    }
                    else // 분실 신고 테이블에 등록
                    {
                        LOSTBIKE lostBike = (from l in db.LOSTBIKEs
                                             where l.BikeNickname == jsonBikeLost.body.nickname &&
                                             l.DeviceID == jsonBikeLost.body.device_id &&
                                             l.Status.Contains("L")
                                             select l).SingleOrDefault();
                        if (lostBike != null) //이미 분실신고 되어 있음.
                        {
                            //Error 206: 이미 분실신고 되었습니다.
                            returnUserInfo.header = setHKRheader_Err(rHeader, 205, "[ERROR] 이미 분실신고 되었습니다.: " +
                                                                     thisUser.EMail, thisUser.Auth_Token, logdb, newLog);
                            return(Json(returnUserInfo, JsonRequestBehavior.AllowGet));
                        }
                        else
                        {
                            LOSTBIKE newLostBike = new LOSTBIKE();
                            newLostBike.BikeNickname = jsonBikeLost.body.nickname;
                            newLostBike.UserName     = jsonBikeLost.body.username;
                            newLostBike.PhoneNo      = jsonBikeLost.body.phone_no;
                            newLostBike.ExtraInfo    = jsonBikeLost.body.extra_info;
                            newLostBike.DeviceID     = jsonBikeLost.body.device_id;
                            newLostBike.LocationLost = jsonBikeLost.body.location_lost;
                            newLostBike.DT_lost      = jsonBikeLost.body.dt_lost;

                            newLostBike.USERS_id        = theBike.USERS_id;
                            newLostBike.ROADBIKES_id    = theBike.id;
                            newLostBike.ModelName       = theBike.Modelname;
                            newLostBike.ColorSize       = theBike.ColorSize;
                            newLostBike.FrameNo         = theBike.FrameNo;
                            newLostBike.Characteristics = theBike.Characteristics;

                            newLostBike.Status        = "L"; // L:losted, F:found, C:canceled
                            newLostBike.DT_registered = dtNow;
                            newLostBike.Dt_updated    = dtNow;

                            db.LOSTBIKEs.InsertOnSubmit(newLostBike); // 분실신고 추가.

                            theBike.Lost          = "Y";              //N: 분실아님, Y: 분실.
                            theBike.DT_lastaccess = dtNow;

                            PUSHRECORD pushRecord = new PUSHRECORD();
                            pushRecord.dt = dtNow;

                            sendFCM_lostbike(newLostBike, "L", pushRecord);

                            db.PUSHRECORDs.InsertOnSubmit(pushRecord);
                        }
                    }
                }


                db.SubmitChanges();
                logdb.LOGs.InsertOnSubmit(newLog);

                returnUserInfo.header = rHeader;
                returnUserInfo.body   = uiBody;
                returnUserInfo        = getUserInformation(returnUserInfo, thisUser); // 다시 계정 정보를 받아서 리턴해 준다.

                return(Json(returnUserInfo, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                // Error: Exception
                returnUserInfo.header = setHKRheader_Err(rHeader, 301, "[ERROR] Exception: " + ex.Message
                                                         , jsonBikeLost == null?"jsonRoadBike is null": jsonBikeLost.header.auth_token, logdb, newLog);
                return(Json(returnUserInfo, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #5
0
        public ActionResult GetRidingLogs(int?id)
        {
            Stream req = Request.InputStream;

            req.Seek(0, System.IO.SeekOrigin.Begin);
            string json = new StreamReader(req).ReadToEnd();

            string   actionName = "GetRidingLogs";
            DateTime dtNow      = DateTime.Now;

            // 객체 초기화
            JsonGetRidingLogs  jsonGetRidingLogs = null;
            ResponseRidingLogs resRidingLogs     = new ResponseRidingLogs();
            HKRheader          rHeader           = new HKRheader();
            List <RidingLog>   Body = new List <RidingLog>();

            LOG newLog = new LOG(); // 로그 객체

            // DB Context 가져오기
            HKRiderDBDataContext db    = new HKRiderDBDataContext(/*connectionString here */);
            LOGDBDataContext     logdb = new LOGDBDataContext(/**/);

            try
            {
                jsonGetRidingLogs = JsonConvert.DeserializeObject <JsonGetRidingLogs>(json);

                // Log 처리 루틴 -------------------------------------------------
                newLog.action     = jsonGetRidingLogs.header.action;
                newLog.auth_token = jsonGetRidingLogs.header.auth_token;
                newLog.json       = json;
                newLog.dt_created = dtNow;
                // Log 처리 루틴 -------------------------------------------------

                if (!jsonGetRidingLogs.header.action.Equals(actionName))
                {
                    resRidingLogs.header = setHKRheader_Err(rHeader, 101, "[ERROR] Action is wrong: " + jsonGetRidingLogs.header.action,
                                                            resRidingLogs.header.auth_token, logdb, newLog);
                    return(Json(resRidingLogs, JsonRequestBehavior.AllowGet));
                }
                else if (jsonGetRidingLogs.header.auth_token == null || jsonGetRidingLogs.header.auth_token == "")
                {
                    resRidingLogs.header = setHKRheader_Err(rHeader, 103, "[ERROR] Auth Token is wrong: " + jsonGetRidingLogs.header.auth_token,
                                                            resRidingLogs.header.auth_token, logdb, newLog);
                    return(Json(resRidingLogs, JsonRequestBehavior.AllowGet));
                }

                // Version Check 추가 예정

                // User 가져오기
                USER thisUser = (from u in db.USERs
                                 where   u.Auth_Token == jsonGetRidingLogs.header.auth_token
                                 select u).SingleOrDefault();

                if (thisUser == null)
                {
                    //Error 202: 다시 접속하세요. 유저정보를 확인할 수 없습니다.
                    resRidingLogs.header = setHKRheader_Err(rHeader, 202, "[ERROR] 다시 접속하세요. 유저정보를 확인할 수 없습니다: ",
                                                            resRidingLogs.header.auth_token, logdb, newLog);
                    return(Json(resRidingLogs, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    ROADBIKE theBike = thisUser.ROADBIKEs.Where(r => r.DeviceID == jsonGetRidingLogs.body.mac_address).SingleOrDefault();

                    if (theBike == null) //해당 맥주소가 해당 유저에게는 존재하지 않음.
                    {
                        //Error 203: 주행기록을 저장한 유저정보를 확인할 수 없습니다. 다시 접속하세요.
                        resRidingLogs.header = setHKRheader_Err(rHeader, 203, "[ERROR] 주행기록을 저장한 유저정보를 확인할 수 없습니다. 다시 접속하세요.: ",
                                                                resRidingLogs.header.auth_token, logdb, newLog);
                        return(Json(resRidingLogs, JsonRequestBehavior.AllowGet));
                    }
                    else // 존재함.
                    {
                        if (jsonGetRidingLogs.body.remove_id > 0)
                        {
                            var rDel = db.RIDINGLOGs.Where(r => r.id == jsonGetRidingLogs.body.remove_id).SingleOrDefault();
                            db.RIDINGLOGs.DeleteOnSubmit(rDel);
                            db.SubmitChanges();
                        }

                        DateTime FromDt = FromMillisJava((long)jsonGetRidingLogs.body.from_date).ToLocalTime();
                        DateTime ToDt   = FromMillisJava((long)jsonGetRidingLogs.body.to_date).ToLocalTime();
                        ToDt = ToDt.AddDays(1); // 하루 추가.

                        var ridingLogs = (from l in db.RIDINGLOGs
                                          where l.USERS_id == thisUser.id &&
                                          l.ROADBIKES_id == theBike.id &&
                                          l.DT_Start >= FromDt &&
                                          l.DT_Start < ToDt
                                          select l);

                        List <RidingLog> listRidingLogs = new List <RidingLog>();
                        foreach (var rl in ridingLogs)
                        {
                            RidingLog newRL = new RidingLog();
                            newRL.id             = rl.id;
                            newRL.average_speed  = rl.AverageSpeed;
                            newRL.calories_burn  = rl.CaloriesBurn;
                            newRL.distance       = rl.Distance;
                            newRL.dt_end         = DateTime2Long(rl.DT_End);
                            newRL.dt_start       = DateTime2Long(rl.DT_Start);
                            newRL.duration       = rl.Duration;
                            newRL.start_location = rl.StartLocation;
                            newRL.end_location   = rl.EndLocation;
                            newRL.mac_address    = theBike.DeviceID;
                            newRL.max_speed      = rl.MaxSpeed;
                            newRL.riding_score   = rl.RidingScore;
                            newRL.gps_records    = rl.GPSrecords;
                            newRL.last_gps       = rl.LastGPS;
                            listRidingLogs.Add(newRL);
                        }
                        Body = listRidingLogs;
                    }
                }

                db.SubmitChanges();
                logdb.LOGs.InsertOnSubmit(newLog);

                resRidingLogs.header = rHeader;
                resRidingLogs.body   = Body;

                return(Json(resRidingLogs, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                // Error: Exception
                resRidingLogs.header = setHKRheader_Err(rHeader, 301, "[ERROR] Exception: " + ex.Message
                                                        , jsonGetRidingLogs == null?"jsonGetRidingLogs is null": jsonGetRidingLogs.header.auth_token, logdb, newLog);
                return(Json(resRidingLogs, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #6
0
        public ActionResult AddRidingLog(int?id)
        {
            Stream req = Request.InputStream;

            req.Seek(0, System.IO.SeekOrigin.Begin);
            string json = new StreamReader(req).ReadToEnd();

            string   actionName = "AddRidingLog";
            DateTime dtNow      = DateTime.Now;

            // 객체 초기화
            JsonRidingLog jsonRidingLog  = null;
            UserInfo      returnUserInfo = new UserInfo();
            HKRheader     rHeader        = new HKRheader();
            UserInfoBody  uiBody         = new UserInfoBody();
            RIDINGLOG     ridingLog;

            LOG newLog = new LOG(); // 로그 객체

            // DB Context 가져오기
            HKRiderDBDataContext db    = new HKRiderDBDataContext(/*connectionString here */);
            LOGDBDataContext     logdb = new LOGDBDataContext(/**/);

            try
            {
                jsonRidingLog = JsonConvert.DeserializeObject <JsonRidingLog>(json);

                // Log 처리 루틴 -------------------------------------------------
                newLog.action     = jsonRidingLog.header.action;
                newLog.auth_token = jsonRidingLog.header.auth_token;
                newLog.json       = json;
                newLog.dt_created = dtNow;
                // Log 처리 루틴 -------------------------------------------------

                if (!jsonRidingLog.header.action.Equals(actionName))
                {
                    returnUserInfo.header = setHKRheader_Err(rHeader, 101, "[ERROR] Action is wrong: " + jsonRidingLog.header.action,
                                                             returnUserInfo.header.auth_token, logdb, newLog);
                    return(Json(returnUserInfo, JsonRequestBehavior.AllowGet));
                }
                else if (jsonRidingLog.header.auth_token == null || jsonRidingLog.header.auth_token == "")
                {
                    returnUserInfo.header = setHKRheader_Err(rHeader, 103, "[ERROR] Auth Token is wrong: " + jsonRidingLog.header.auth_token,
                                                             returnUserInfo.header.auth_token, logdb, newLog);
                    return(Json(returnUserInfo, JsonRequestBehavior.AllowGet));
                }

                // Version Check 추가 예정

                // User 가져오기
                USER thisUser = (from u in db.USERs
                                 where   u.Auth_Token == jsonRidingLog.header.auth_token
                                 select u).SingleOrDefault();

                if (thisUser == null)
                {
                    //Error 202: 다시 접속하세요. 유저정보를 확인할 수 없습니다.
                    returnUserInfo.header = setHKRheader_Err(rHeader, 202, "[ERROR] 다시 접속하세요. 유저정보를 확인할 수 없습니다: " +
                                                             jsonRidingLog.header.auth_token, returnUserInfo.header.auth_token, logdb, newLog);
                    return(Json(returnUserInfo, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    ROADBIKE theBike = thisUser.ROADBIKEs.Where(r => r.DeviceID == jsonRidingLog.body.mac_address).SingleOrDefault();

                    if (theBike == null) //해당 맥주소가 해당 유저에게는 존재하지 않음.
                    {
                        //Error 203: 주행기록을 저장한 유저정보를 확인할 수 없습니다. 다시 접속하세요.
                        returnUserInfo.header = setHKRheader_Err(rHeader, 203, "[ERROR] 주행기록을 저장한 유저정보를 확인할 수 없습니다. 다시 접속하세요.: " +
                                                                 thisUser.EMail, thisUser.Auth_Token, logdb, newLog);
                        return(Json(returnUserInfo, JsonRequestBehavior.AllowGet));
                    }
                    else // 존재함.
                    {
                        ridingLog               = new RIDINGLOG();
                        ridingLog.RidingScore   = (int)jsonRidingLog.body.riding_score;
                        ridingLog.Distance      = (int)jsonRidingLog.body.distance;
                        ridingLog.Duration      = (long)jsonRidingLog.body.duration;
                        ridingLog.DT_Start      = FromMillisJava((long)jsonRidingLog.body.dt_start).ToLocalTime();
                        ridingLog.DT_End        = FromMillisJava((long)jsonRidingLog.body.dt_end).ToLocalTime();
                        ridingLog.AverageSpeed  = (int)jsonRidingLog.body.average_speed;
                        ridingLog.MaxSpeed      = (int)jsonRidingLog.body.max_speed;
                        ridingLog.CaloriesBurn  = (int)jsonRidingLog.body.calories_burn;
                        ridingLog.StartLocation = jsonRidingLog.body.start_location;
                        ridingLog.EndLocation   = jsonRidingLog.body.end_location;
                        ridingLog.GPSrecords    = jsonRidingLog.body.gps_records;
                        ridingLog.LastGPS       = jsonRidingLog.body.last_gps;
                        if (jsonRidingLog.body.debug_data != null)
                        {
                            ridingLog.DebugData = jsonRidingLog.body.debug_data;
                        }
                        ridingLog.dt_registered = dtNow;
                        ridingLog.ROADBIKES_id  = theBike.id;
                        ridingLog.USERS_id      = thisUser.id;

                        int ridingCnt     = theBike.RidingCount + 1;
                        int totalCals     = theBike.CaloriesAccumulated + (int)jsonRidingLog.body.calories_burn;
                        int totalDistance = theBike.DistanceAccumulated + (int)jsonRidingLog.body.distance;
                        int totalRidingT  = theBike.TimeAccumulated + (int)jsonRidingLog.body.duration;

                        int score4max = 0;
                        if (theBike.MaxSpeed < (int)jsonRidingLog.body.max_speed)
                        {
                            theBike.MaxSpeed = (int)jsonRidingLog.body.max_speed;
                            score4max        = (int)(((int)jsonRidingLog.body.max_speed / 3.6) - (theBike.MaxSpeed / 3.6));
                        }
                        int ridingScore = theBike.RidingScore + (int)jsonRidingLog.body.riding_score + score4max;

                        theBike.RidingScore         = ridingScore;
                        theBike.AvatarLevel         = GetLevel(ridingScore);
                        theBike.RidingCount         = ridingCnt;
                        theBike.CaloriesAccumulated = totalCals;
                        theBike.AverageCalories     = totalCals / ridingCnt;
                        theBike.DistanceAccumulated = totalDistance;
                        theBike.AverageDistance     = totalDistance / ridingCnt;
                        theBike.AverageRidingTime   = totalRidingT / ridingCnt;
                        theBike.AverageSpeed        = totalDistance / totalRidingT; //m per sec
                        theBike.TimeAccumulated     = totalRidingT;
                        theBike.LastGPS             = jsonRidingLog.body.last_gps;
                        theBike.RIDINGLOGs.Add(ridingLog);
                        theBike.DT_lastaccess  = dtNow;
                        thisUser.DT_lastaccess = dtNow;
                    }
                }

                db.SubmitChanges();
                logdb.LOGs.InsertOnSubmit(newLog);

                rHeader.ret_string    = ridingLog.id.ToString();
                returnUserInfo.header = rHeader;
                returnUserInfo.body   = uiBody;
                returnUserInfo        = getUserInformation(returnUserInfo, thisUser); // 다시 계정 정보를 받아서 리턴해 준다.

                return(Json(returnUserInfo, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                // Error: Exception
                returnUserInfo.header = setHKRheader_Err(rHeader, 301, "[ERROR] Exception: " + ex.Message
                                                         , jsonRidingLog == null?"jsonRidingLog is null":jsonRidingLog.header.auth_token, logdb, newLog);
                return(Json(returnUserInfo, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #7
0
        public async System.Threading.Tasks.Task <ActionResult> UploadBikeImage(HttpPostedFileBase file)
        {
            DateTime dtNow = DateTime.Now;

            // 객체 초기화
            ResponseSimple rs      = new ResponseSimple();
            HKRheader      rHeader = new HKRheader();

            LOG newLog = new LOG(); // 로그 객체

            // DB Context 가져오기
            LOGDBDataContext logdb = new LOGDBDataContext(/**/);

            // Log 처리 루틴 -------------------------------------------------
            newLog.action     = "UploadBikeImage: ";// + fileName;
            newLog.auth_token = "";
            newLog.json       = "";
            newLog.dt_created = dtNow;
            // Log 처리 루틴 -------------------------------------------------

            try
            {
                long len = Request.InputStream.Length;
                AppendLog("Request.InputStream.Length: " + len);

                var streamContent = new StreamContent(Request.InputStream);
                AppendLog("A");
                streamContent.Headers.ContentType = MediaTypeHeaderValue.Parse(Request.ContentType);

                var provider = await streamContent.ReadAsMultipartAsync();

                AppendLog("provider.Contents: " + provider.Contents.Count);
                foreach (var httpContent in provider.Contents)
                {
                    var fileName = httpContent.Headers.ContentDisposition.FileName;
                    AppendLog(fileName + ": " + httpContent.Headers.ContentType + "," + httpContent.Headers.ContentLength);
                    if (string.IsNullOrWhiteSpace(fileName))
                    {
                        continue;
                    }

                    using (Stream fileContents = await httpContent.ReadAsStreamAsync())
                    {
                        var filePath = "D:\\Images\\" + fileName;
                        filePath = filePath.Replace("\"", "");
                        AppendLog("filePath: " + filePath);
                        if (System.IO.File.Exists(filePath))
                        {
                            System.IO.File.Delete(filePath);
                        }
                        using (var fileStream = new FileStream(filePath, FileMode.Create, FileAccess.Write))
                        {
                            fileContents.CopyTo(fileStream);
                        }
                    }
                }

                rs.header = rHeader;
                logdb.LOGs.InsertOnSubmit(newLog);

                return(Json(rs, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                AppendLog("Error: " + ex.Message);

                // Error: Exception
                rs.header = setHKRheader_Err(rHeader, 301, "[ERROR] Exception: " + ex.Message
                                             , "", logdb, newLog);
                return(Json(rs, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #8
0
        public ActionResult GetUserInfo(int?id)
        {
            Stream req = Request.InputStream;

            req.Seek(0, System.IO.SeekOrigin.Begin);
            string json = new StreamReader(req).ReadToEnd();
            //AppendLog("[REQ HKSports/LoginController]" + json);

            DateTime today = DateTime.Now;

            // 객체 초기화
            Login        login    = null;
            UserInfo     userInfo = new UserInfo();
            HKRheader    rHeader  = new HKRheader();
            UserInfoBody uiBody   = new UserInfoBody();

            LOG newLog = new LOG(); // 로그 객체

            // DB Context 가져오기
            HKRiderDBDataContext db    = new HKRiderDBDataContext(/*connectionString here */);
            LOGDBDataContext     logdb = new LOGDBDataContext(/**/);

            try
            {
                login = JsonConvert.DeserializeObject <Login>(json);

                // Log 처리 루틴 -------------------------------------------------
                newLog.action     = login.header.action;
                newLog.auth_token = login.header.auth_token;
                newLog.json       = json;
                newLog.dt_created = DateTime.Now;
                // Log 처리 루틴 -------------------------------------------------

                if (!login.header.action.Equals("GetUserInfo"))
                {
                    userInfo.header = setHKRheader_Err(rHeader, 101, "[ERROR] Action is wrong: " + login.header.action,
                                                       login.header.auth_token, logdb, newLog);
                    return(Json(userInfo, JsonRequestBehavior.AllowGet));
                }

                // Version Check 추가 예정

                if (login.header.client_market == null || login.body.email == null)
                {
                    userInfo.header = setHKRheader_Err(rHeader, 102, "[ERROR] No client_market or No user_id",
                                                       login.header.auth_token, logdb, newLog);
                    return(Json(userInfo, JsonRequestBehavior.AllowGet));
                }

                USER   thisUser = null;
                string passwd   = login.body.password;
                string token    = login.header.auth_token;

                // User 가져오기
                if (passwd != null && passwd.Length > 0)
                {
                    thisUser = (from u in db.USERs
                                where u.EMail == login.body.email &&
                                u.Client_Market == login.header.client_market &&
                                u.Passwd == passwd
                                select u).SingleOrDefault();
                }
                else if (token != null && token.Length > 0)
                {
                    thisUser = (from u in db.USERs
                                where u.EMail == login.body.email &&
                                u.Client_Market == login.header.client_market &&
                                u.Auth_Token == token
                                select u).SingleOrDefault();
                }

                if (thisUser == null)
                {
                    // Error: 아이디, 패스워드를 다시 확인하세요.
                    userInfo.header = setHKRheader_Err(rHeader, 201, "[ERROR] 아이디, 패스워드를 다시 확인하세요: " +
                                                       login.body.email, login.header.auth_token, logdb, newLog);
                    return(Json(userInfo, JsonRequestBehavior.AllowGet));
                }

                // 토큰 발급: 로그인으로 들어온 경우는 대부분 Expired 된 경우이다.
                if (token != null && token.Length > 0 && !token.Equals(thisUser.Auth_Token) ||
                    thisUser.Auth_Token == null || thisUser.Auth_Token == "")
                {
                    token = Convert.ToBase64String(Guid.NewGuid().ToByteArray());
                    thisUser.Auth_Token = token;
                }

                if (!login.header.auth_device_id.Equals(thisUser.FCM_Token))
                {
                    thisUser.FCM_Token = login.header.auth_device_id;
                }


                db.SubmitChanges();
                logdb.LOGs.InsertOnSubmit(newLog);
                logdb.SubmitChanges();

                userInfo.header = rHeader;
                userInfo.body   = uiBody;
                userInfo        = getUserInformation(userInfo, thisUser);

                //userInfo.header = rHeader;
                //userInfo.body = uiBody;
                return(Json(userInfo, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                // Error: Exception
                userInfo.header = setHKRheader_Err(rHeader, 301, "[ERROR] Exception: " + ex.Message
                                                   , login == null ? "Login is null" : login.header.auth_token, logdb, newLog);
                return(Json(userInfo, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #9
0
        public ActionResult ReportBikeLost(int?id)
        {
            Stream req = Request.InputStream;

            req.Seek(0, System.IO.SeekOrigin.Begin);
            string json = new StreamReader(req).ReadToEnd();
            //AppendLog("[REQ HKSports/LoginController]" + json);

            string   actionName = "ReportBikeLost";
            DateTime dtNow      = DateTime.Now;

            // 객체 초기화
            JsonBikeLost jsonBikeLost   = null;
            UserInfo     returnUserInfo = new UserInfo();
            HKRheader    rHeader        = new HKRheader();
            UserInfoBody uiBody         = new UserInfoBody();

            LOG newLog = new LOG(); // 로그 객체

            // DB Context 가져오기
            HKRiderDBDataContext db    = new HKRiderDBDataContext(/*connectionString here */);
            LOGDBDataContext     logdb = new LOGDBDataContext(/**/);

            try
            {
                jsonBikeLost = JsonConvert.DeserializeObject <JsonBikeLost>(json);

                // Log 처리 루틴 -------------------------------------------------
                newLog.action     = jsonBikeLost.header.action;
                newLog.auth_token = jsonBikeLost.header.auth_token;
                newLog.json       = json;
                newLog.dt_created = dtNow;
                newLog.user_id    = jsonBikeLost.body.nickname;
                // Log 처리 루틴 -------------------------------------------------

                if (!jsonBikeLost.header.action.Equals(actionName))
                {
                    returnUserInfo.header = setHKRheader_Err(rHeader, 101, "[ERROR] Action is wrong: " + jsonBikeLost.header.action,
                                                             jsonBikeLost.header.auth_token, logdb, newLog);
                    return(Json(returnUserInfo, JsonRequestBehavior.AllowGet));
                }
                else if (jsonBikeLost.header.auth_token == null || jsonBikeLost.header.auth_token == "")
                {
                    returnUserInfo.header = setHKRheader_Err(rHeader, 103, "[ERROR] Auth Token is wrong: " + jsonBikeLost.header.auth_token,
                                                             jsonBikeLost.header.auth_token, logdb, newLog);
                    return(Json(returnUserInfo, JsonRequestBehavior.AllowGet));
                }

                // Version Check 추가 예정

                // User 가져오기
                USER thisUser = (from u in db.USERs
                                 where   u.Auth_Token == jsonBikeLost.header.auth_token
                                 select u).SingleOrDefault();

                if (thisUser == null) // 유저가 존재하는지 확인
                {
                    //Error 202: 다시 접속하세요. 유저정보를 확인할 수 없습니다.
                    returnUserInfo.header = setHKRheader_Err(rHeader, 202, "[ERROR] 다시 접속하세요. 유저정보를 확인할 수 없습니다: " +
                                                             thisUser.EMail, thisUser.Auth_Token, logdb, newLog);
                    return(Json(returnUserInfo, JsonRequestBehavior.AllowGet));
                }
                else // 분실신고 바이크의 정보가 있는지 확인.
                {
                    ROADBIKE theBike = db.ROADBIKEs.Where(r => r.Nickname == jsonBikeLost.body.nickname).SingleOrDefault();

                    if (theBike == null) //존재하지 않는 바이크.
                    {
                        //Error 205: 아바타 정보를 확인할 수 없습니다. 계속 문제 발생시 다시 로그인해 주세요.
                        returnUserInfo.header = setHKRheader_Err(rHeader, 205, "[ERROR] 아바타 정보를 확인할 수 없습니다. 계속 문제 발생시 다시 로그인해 주세요.: " +
                                                                 thisUser.EMail, thisUser.Auth_Token, logdb, newLog);
                        return(Json(returnUserInfo, JsonRequestBehavior.AllowGet));
                    }
                    else // 분실 신고 테이블에 등록
                    {
                        USER theUser = db.USERs.Where(u => u.id == theBike.USERS_id).SingleOrDefault();
                        if (theUser == null) // 유저가 존재하는지 확인
                        {
                            //Error 202: 다시 접속하세요. 유저정보를 확인할 수 없습니다.
                            returnUserInfo.header = setHKRheader_Err(rHeader, 202, "[ERROR] 다시 접속하세요. 유저정보를 확인할 수 없습니다: " +
                                                                     theUser.EMail, thisUser.Auth_Token, logdb, newLog);
                            return(Json(returnUserInfo, JsonRequestBehavior.AllowGet));
                        }

                        LOSTBIKE lostBike = (from l in db.LOSTBIKEs
                                             where l.BikeNickname == jsonBikeLost.body.nickname &&
                                             l.DeviceID == jsonBikeLost.body.device_id &&
                                             l.Status.Contains("L")
                                             select l).SingleOrDefault();
                        if (lostBike == null) //존재하지 않는 분실신고.
                        {
                            //Error 207: 취소할 분실신고가 없습니다.
                            returnUserInfo.header = setHKRheader_Err(rHeader, 207, "[ERROR] 취소할 분실신고가 없습니다.: " +
                                                                     thisUser.EMail, thisUser.Auth_Token, logdb, newLog);
                            return(Json(returnUserInfo, JsonRequestBehavior.AllowGet));
                        }
                        else
                        {
                            theBike.LastGPS = jsonBikeLost.body.dt_lost + ":" + jsonBikeLost.body.location_lost;

                            PUSHRECORD pushRecord = new PUSHRECORD();
                            pushRecord.dt = dtNow;

                            sendFCM_lostbike_found(theUser, jsonBikeLost.body, pushRecord);

                            db.PUSHRECORDs.InsertOnSubmit(pushRecord);
                        }
                    }
                }


                db.SubmitChanges();
                logdb.LOGs.InsertOnSubmit(newLog);

                returnUserInfo.header = rHeader;
                returnUserInfo.body   = uiBody;
                returnUserInfo        = getUserInformation(returnUserInfo, thisUser); // 다시 계정 정보를 받아서 리턴해 준다.

                return(Json(returnUserInfo, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                // Error: Exception
                returnUserInfo.header = setHKRheader_Err(rHeader, 301, "[ERROR] Exception: " + ex.Message
                                                         , jsonBikeLost == null?"jsonRoadBike is null": jsonBikeLost.header.auth_token, logdb, newLog);
                return(Json(returnUserInfo, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #10
0
        public ActionResult RemoveRoadBike(int?id)
        {
            Stream req = Request.InputStream;

            req.Seek(0, System.IO.SeekOrigin.Begin);
            string json = new StreamReader(req).ReadToEnd();
            //AppendLog("[REQ HKSports/LoginController]" + json);

            string   actionName = "RemoveRoadBike";
            DateTime dtNow      = DateTime.Now;

            // 객체 초기화
            JsonRoadBike jsonRoadBike   = null;
            UserInfo     returnUserInfo = new UserInfo();
            HKRheader    rHeader        = new HKRheader();
            UserInfoBody uiBody         = new UserInfoBody();

            LOG newLog = new LOG(); // 로그 객체

            // DB Context 가져오기
            HKRiderDBDataContext db    = new HKRiderDBDataContext(/*connectionString here */);
            LOGDBDataContext     logdb = new LOGDBDataContext(/**/);

            try
            {
                jsonRoadBike = JsonConvert.DeserializeObject <JsonRoadBike>(json);

                // Log 처리 루틴 -------------------------------------------------
                newLog.action     = jsonRoadBike.header.action;
                newLog.auth_token = jsonRoadBike.header.auth_token;
                newLog.json       = json;
                newLog.dt_created = dtNow;
                // Log 처리 루틴 -------------------------------------------------

                if (!jsonRoadBike.header.action.Equals(actionName))
                {
                    returnUserInfo.header = setHKRheader_Err(rHeader, 101, "[ERROR] Action is wrong: " + jsonRoadBike.header.action,
                                                             returnUserInfo.header.auth_token, logdb, newLog);
                    return(Json(returnUserInfo, JsonRequestBehavior.AllowGet));
                }
                else if (jsonRoadBike.header.auth_token == null || jsonRoadBike.header.auth_token == "")
                {
                    returnUserInfo.header = setHKRheader_Err(rHeader, 103, "[ERROR] Auth Token is wrong: " + jsonRoadBike.header.auth_token,
                                                             returnUserInfo.header.auth_token, logdb, newLog);
                    return(Json(returnUserInfo, JsonRequestBehavior.AllowGet));
                }

                // Version Check 추가 예정

                List <RIDINGLOG> removeList = db.RIDINGLOGs.Where(r => r.ROADBIKES_id == jsonRoadBike.body.id).ToList();
                db.RIDINGLOGs.DeleteAllOnSubmit(removeList);

                var removeObj = db.ROADBIKEs.Where(r => r.id == jsonRoadBike.body.id).SingleOrDefault();
                db.ROADBIKEs.DeleteOnSubmit(removeObj);

                // User 가져오기
                USER thisUser = (from u in db.USERs
                                 where u.Auth_Token == jsonRoadBike.header.auth_token
                                 select u).SingleOrDefault();
                thisUser.DT_lastaccess = dtNow;

                db.SubmitChanges();
                logdb.LOGs.InsertOnSubmit(newLog);

                returnUserInfo.header = rHeader;
                returnUserInfo.body   = uiBody;
                returnUserInfo        = getUserInformation(returnUserInfo, thisUser); // 다시 계정 정보를 받아서 리턴해 준다.

                return(Json(returnUserInfo, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                // Error: Exception
                returnUserInfo.header = setHKRheader_Err(rHeader, 301, "[ERROR] Exception: " + ex.Message
                                                         , jsonRoadBike == null?"jsonRoadBike is null":jsonRoadBike.header.auth_token, logdb, newLog);
                return(Json(returnUserInfo, JsonRequestBehavior.AllowGet));
            }
        }