예제 #1
0
        public ReturnValue create([FromBody] RequestValue value)
        {
            if (value == null)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            SuggestRegister suggestRegister = JsonConvert.DeserializeObject <SuggestRegister>(Convert.ToString(value.data));

            try
            {
                ObjectParameter userSN     = new ObjectParameter("UserSN", typeof(long));
                ObjectParameter gUID       = new ObjectParameter("GUID", typeof(string));
                ObjectParameter hashPhone  = new ObjectParameter("HashPhone", typeof(string));
                ObjectParameter deviceID   = new ObjectParameter("DeviceID", typeof(string));
                ObjectParameter pushKey    = new ObjectParameter("PushKey", typeof(string));
                ObjectParameter createDate = new ObjectParameter("CreateDate", typeof(DateTime));
                ObjectParameter updateDate = new ObjectParameter("UpdateDate", typeof(DateTime));

                // User SN 정보 조회
                entity.UserGetInfoByToken(value.token, userSN, gUID, hashPhone, deviceID, pushKey, createDate, updateDate);

                // 제안등록
                ObjectParameter suggestSN = new ObjectParameter("SuggestSN", typeof(long));
                entity.SuggestCreate(suggestSN, (long)userSN.Value, (string)hashPhone.Value, suggestRegister.categorysn, suggestRegister.itemsn);

                // 비공개 대상 등록
                foreach (string hashphone in suggestRegister.privateuser)
                {
                    entity.PrivateUserCreate((long)suggestSN.Value, hashphone);
                }

                returnValue.error   = 0;
                returnValue.message = "ok";

                long suggestsn = (long)suggestSN.Value;
                returnValue.data = new
                {
                    suggestsn
                };
            }
            catch (InvalidCastException)
            {
                returnValue.error   = 100;
                returnValue.message = "USER_NOT_FOUND";
            }
            catch (Exception ex)
            {
                entity.ErrorLogCreate(HttpRequestMessageHelper.GetClientIpAddress(Request), Request.RequestUri.AbsoluteUri, ex.Source, ex.TargetSite.Name, ex.Message, ex.StackTrace, JsonConvert.SerializeObject(value));
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }

            return(returnValue);
        }
예제 #2
0
        public ReturnValue create([FromBody] RequestValue value)
        {
            if (value == null)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            try
            {
                // User SN 정보 조회
                ObjectParameter userSN     = new ObjectParameter("UserSN", typeof(long));
                ObjectParameter gUID       = new ObjectParameter("GUID", typeof(string));
                ObjectParameter hashPhone  = new ObjectParameter("HashPhone", typeof(string));
                ObjectParameter deviceID   = new ObjectParameter("DeviceID", typeof(string));
                ObjectParameter pushKey    = new ObjectParameter("PushKey", typeof(string));
                ObjectParameter createDate = new ObjectParameter("CreateDate", typeof(DateTime));
                ObjectParameter updateDate = new ObjectParameter("UpdateDate", typeof(DateTime));

                entity.UserGetInfoByToken(value.token, userSN, gUID, hashPhone, deviceID, pushKey, createDate, updateDate);

                // 저장되 있는 연락처 정보와 업데이트 연락처 정보를 머징.
                ContactsRequest syncdata = JsonConvert.DeserializeObject <ContactsRequest>(Convert.ToString(value.data));

                foreach (string hashphone in syncdata.contacts)
                {
                    entity.ContactsCreate((long)userSN.Value, hashphone);
                }

                returnValue.error   = 0;
                returnValue.message = "OK";
            }
            catch (InvalidCastException)
            {
                returnValue.error   = 100;
                returnValue.message = "USER_NOT_FOUND";
            }
            catch (Exception ex)
            {
                entity.ErrorLogCreate(HttpRequestMessageHelper.GetClientIpAddress(Request), Request.RequestUri.AbsoluteUri, ex.Source, ex.TargetSite.Name, ex.Message, ex.StackTrace, JsonConvert.SerializeObject(value));;
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }

            return(returnValue);
        }
예제 #3
0
        public ReturnValue list([FromBody] RequestValue value, byte categorySN)
        {
            try
            {
                returnValue.error   = 0;
                returnValue.message = "ok";

                List <ItemGetList_Result> items = entity.ItemGetList(categorySN).ToList <ItemGetList_Result>();
                returnValue.data = new
                {
                    items
                };
            }
            catch (Exception ex)
            {
                entity.ErrorLogCreate(HttpRequestMessageHelper.GetClientIpAddress(Request), Request.RequestUri.AbsoluteUri, ex.Source, ex.TargetSite.Name, ex.Message, ex.StackTrace, JsonConvert.SerializeObject(value));;
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }

            return(returnValue);
        }
예제 #4
0
        public ReturnValue auth([FromBody] RequestValue value)
        {
            if (value == null)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            try
            {
                ObjectParameter userSN     = new ObjectParameter("UserSN", typeof(long));
                ObjectParameter gUID       = new ObjectParameter("GUID", typeof(string));
                ObjectParameter hashPhone  = new ObjectParameter("HashPhone", typeof(string));
                ObjectParameter deviceID   = new ObjectParameter("DeviceID", typeof(string));
                ObjectParameter pushKey    = new ObjectParameter("PushKey", typeof(string));
                ObjectParameter createDate = new ObjectParameter("CreateDate", typeof(DateTime));
                ObjectParameter updateDate = new ObjectParameter("UpdateDate", typeof(DateTime));

                // User SN 정보 조회
                entity.UserGetInfoByToken(value.token, userSN, gUID, hashPhone, deviceID, pushKey, createDate, updateDate);

                Users user = new Users();
                user.usersn     = (long)userSN.Value;
                user.guid       = (string)gUID.Value;
                user.hashphone  = (string)hashPhone.Value;
                user.deviceid   = (string)deviceID.Value;
                user.pushkey    = (string)pushKey.Value;
                user.createdate = (DateTime)createDate.Value;
                user.updatedate = (DateTime)updateDate.Value;

                string strGUID = string.Empty;

                if ((string)hashPhone.Value == (string)value.data.hashphone)
                {
                    strGUID = Guid.NewGuid().ToString().Replace("-", string.Empty);

                    returnValue.error   = 0;
                    returnValue.message = "OK";

                    string guid   = strGUID;
                    long   usersn = (long)userSN.Value;
                    returnValue.data = new
                    {
                        usersn,
                        guid
                    };
                }
                else
                {
                    returnValue.error   = 101;
                    returnValue.message = "USER_INVALID_PHONE";
                }

                // guid 를 갱신 한다.
                entity.UserUpdate(value.token, strGUID, null, null, null);
            }
            catch (InvalidCastException)
            {
                returnValue.error   = 100;
                returnValue.message = "USER_NOT_FOUND";
            }
            catch (Exception ex)
            {
                entity.ErrorLogCreate(HttpRequestMessageHelper.GetClientIpAddress(Request), Request.RequestUri.AbsoluteUri, ex.Source, ex.TargetSite.Name, ex.Message, ex.StackTrace, JsonConvert.SerializeObject(value));;
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }

            return(returnValue);
        }
예제 #5
0
        public ReturnValue sync([FromBody] RequestValue value)
        {
            if (value == null)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }


            try
            {
                // User SN 정보 조회
                ObjectParameter userSN     = new ObjectParameter("UserSN", typeof(long));
                ObjectParameter gUID       = new ObjectParameter("GUID", typeof(string));
                ObjectParameter hashPhone  = new ObjectParameter("HashPhone", typeof(string));
                ObjectParameter deviceID   = new ObjectParameter("DeviceID", typeof(string));
                ObjectParameter pushKey    = new ObjectParameter("PushKey", typeof(string));
                ObjectParameter createDate = new ObjectParameter("CreateDate", typeof(DateTime));
                ObjectParameter updateDate = new ObjectParameter("UpdateDate", typeof(DateTime));

                entity.UserGetInfoByToken(value.token, userSN, gUID, hashPhone, deviceID, pushKey, createDate, updateDate);

                // 저장되 있는 연락처 정보와 업데이트 연락처 정보를 머징.
                ContactsRequest syncdata = JsonConvert.DeserializeObject <ContactsRequest>(Convert.ToString(value.data));

                DataTable newContacts = BulkCopy.MakeTable();

                foreach (string hashphone in syncdata.contacts)
                {
                    //entity.ContactsCreate((long)userSN.Value, hashphone);
                    DataRow row = newContacts.NewRow();
                    row["usersn"]    = (long)userSN.Value;
                    row["hashphone"] = hashphone;

                    newContacts.Rows.Add(row);
                }

                newContacts.AcceptChanges();

                DataRow[] rowArray = newContacts.Select();

                BulkCopy bc = new BulkCopy();
                bc.copy(rowArray);

                returnValue.error   = 0;
                returnValue.message = "OK";

                ObjectParameter totalCount   = new ObjectParameter("TotalCount", typeof(int));
                List <string>   installusers = entity.ContactsInstallUserList((long)userSN.Value, totalCount).ToList <string>();

                returnValue.data = new
                {
                    totalcount = (int)totalCount.Value,
                    installusers
                };
            }
            catch (InvalidCastException)
            {
                returnValue.error   = 100;
                returnValue.message = "USER_NOT_FOUND";
            }
            catch (Exception ex)
            {
                entity.ErrorLogCreate(HttpRequestMessageHelper.GetClientIpAddress(Request), Request.RequestUri.AbsoluteUri, ex.Source, ex.TargetSite.Name, ex.Message, ex.StackTrace, JsonConvert.SerializeObject(value));;
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }

            return(returnValue);
        }