Ejemplo n.º 1
0
 public m_Customer getProfileByUserId(string user_id)
 {
     using (OracleConnection conn = new OracleConnection(Database.conString))
     {
         try
         {
             conn.Open();
             using (var cmd = new OracleCommand(SqlCmd.Line.getProfileByUserId, conn)
             {
                 CommandType = System.Data.CommandType.Text
             })
             {
                 cmd.Parameters.Add("line_user_id", user_id);
                 var reader = cmd.ExecuteReader();
                 reader.Read();
                 if (reader.HasRows)
                 {
                     var data = new m_Customer
                     {
                         CUST_NO      = Int32.Parse(reader["CUST_NO"].ToString()),
                         CUST_NAME    = (string)reader["CUST_NAME"],
                         CITIZEN_NO   = reader["CITIZEN_NO"] == DBNull.Value ? string.Empty : (string)reader["CITIZEN_NO"],
                         TEL          = reader["TEL"] == DBNull.Value ? string.Empty : (string)reader["TEL"],
                         PERMIT       = (string)reader["PERMIT"],
                         LINE_USER_ID = reader["LINE_USER_ID"] == DBNull.Value ? string.Empty : reader["LINE_USER_ID"].ToString()
                     };
                     reader.Dispose();
                     cmd.Dispose();
                     return(data);
                 }
                 reader.Dispose();
                 cmd.Dispose();
                 return(null);
             }
         }
         finally
         {
             conn.Close();
             conn.Dispose();
         }
     }
 }
Ejemplo n.º 2
0
        public IHttpActionResult GetCheckPhone2(string serial_sim, string deviceId, string brand, string model, double app_version, string api_version)
        {
            //var setting = (AppSettingsSection)WebConfigurationManager.OpenWebConfiguration("~").GetSection("appSettings");
            //var appService = setting.Settings["AppService"].Value;
            //if (appService == "False")
            //    return Unauthorized();
            m_LogReq mlog      = new m_LogReq();
            string   IPAddress = HttpContext.Current.Request.UserHostAddress;
            string   url       = HttpContext.Current.Request.Path;

            try
            {
                m_Customer result = new m_Customer();
                if (serial_sim == "1111111111" || serial_sim == "2222222222")
                {
                    result = _user.getProfileByDeviceId(deviceId);
                }
                //else
                //result = _user.getProfileBySerialSim(serial_sim);

                if (result != null && result.CUST_NO != 0)
                {
                    if (result.PERMIT == "SMS" || result.PERMIT == "BOTH")
                    {
                        var device = _user.checkCurrentDevice(deviceId);
                        if (device != null)
                        {
                            if (app_version != device.app_version)
                            {
                                _user.updateAppVersion(app_version, deviceId);
                            }

                            _user.updateIdentify(deviceId);
                            var chat = _user.getChatOn();
                            if (device.device_status == "ACT")
                            {
                                var version   = _user.getAppVersion(serial_sim);
                                var broadcast = _user.getBroadcast();

                                mlog.cust_no     = result.CUST_NO;
                                mlog.device_id   = deviceId;
                                mlog.tel         = result.TEL;
                                mlog.serial_sim  = serial_sim;
                                mlog.ip_addr     = IPAddress;
                                mlog.action      = "IDENTIFY";
                                mlog.status      = "SUCCESS";
                                mlog.note        = "ระบุตัวตนสำเร็จ";
                                mlog.brand       = brand;
                                mlog.model       = model;
                                mlog.app_version = app_version;
                                mlog.api_version = api_version;
                                log.logSignin(mlog);
                                monitor.sendMessage(url, IPAddress, new { serial_sim = serial_sim, deviceId = deviceId /*, app_version = app_version*/ }, new { code = 200, message = "ระบุตัวตนสำเร็จ", data = result });
                                return(Ok(new { code = 200, message = "ข้อมูลถูกต้อง", data = new m_identify {
                                                    CUST_NO = result.CUST_NO, CUST_NAME = result.CUST_NAME, CITIZEN_NO = result.CITIZEN_NO, TEL = result.TEL, PERMIT = result.PERMIT, CHAT = chat, APP_VERSION = version, BROADCAST = broadcast
                                                } }));
                            }
                            else if (device.device_status == "CHANGE_TEL")
                            {
                                mlog.cust_no     = result.CUST_NO;
                                mlog.device_id   = deviceId;
                                mlog.tel         = result.TEL;
                                mlog.serial_sim  = serial_sim;
                                mlog.ip_addr     = IPAddress;
                                mlog.action      = "IDENTIFY";
                                mlog.status      = "FAIL";
                                mlog.note        = "ลูกค้าเปลี่ยนหมายเลขโทรศัพท์";
                                mlog.brand       = brand;
                                mlog.model       = model;
                                mlog.app_version = app_version;
                                mlog.api_version = api_version;
                                log.logSignin(mlog);
                                monitor.sendMessage(url, IPAddress, new { serial_sim = serial_sim, deviceId = deviceId /*, app_version = app_version*/ }, new { code = 402, message = "ข้อมูลลูกค้าอยู่ในขั้นตอนการเปลี่ยนหมายเลขโทรศัพท์", data = result });
                                return(Ok(new { code = 402, message = "กรุณาใช้หมายเลขโทรศัพท์ใหม่", data = result }));
                            }
                            else
                            {
                                mlog.cust_no     = result.CUST_NO;
                                mlog.device_id   = deviceId;
                                mlog.tel         = result.TEL;
                                mlog.serial_sim  = serial_sim;
                                mlog.ip_addr     = IPAddress;
                                mlog.action      = "IDENTIFY";
                                mlog.status      = "FAIL";
                                mlog.note        = "เครื่องลูกค้าถูกระงับการใช้งาน";
                                mlog.brand       = brand;
                                mlog.model       = model;
                                mlog.app_version = app_version;
                                mlog.api_version = api_version;
                                //log.logSignin(mlog);
                                monitor.sendMessage(url, IPAddress, new { serial_sim = serial_sim, deviceId = deviceId /*, app_version= app_version */ }, new { code = 403, message = "เครื่องลูกค้าถูกระงับการใช้งาน!", data = result });
                                return(Ok(new { code = 403, message = "เครื่องลูกค้าถูกระงับการใช้งาน!", data = result }));
                            }
                        }
                        else
                        {
                            mlog.cust_no     = result.CUST_NO;
                            mlog.device_id   = deviceId;
                            mlog.tel         = result.TEL;
                            mlog.serial_sim  = serial_sim;
                            mlog.ip_addr     = IPAddress;
                            mlog.action      = "IDENTIFY";
                            mlog.status      = "FAIL";
                            mlog.note        = "ไม่พบเครื่องลูกค้าในระบบ";
                            mlog.brand       = brand;
                            mlog.model       = model;
                            mlog.app_version = app_version;
                            mlog.api_version = api_version;
                            log.logSignin(mlog);
                            monitor.sendMessage(url, IPAddress, new { serial_sim = serial_sim, deviceId = deviceId /*, app_version = app_version*/ }, new { code = 404, message = "ไม่พบเครื่องลูกค้าในระบบ!", data = result });
                            return(Ok(new { code = 404, message = "ไม่พบเครื่องลูกค้าในระบบ!", data = result }));
                        }
                    }
                    else
                    {
                        mlog.cust_no     = result.CUST_NO;
                        mlog.device_id   = deviceId;
                        mlog.tel         = result.TEL;
                        mlog.serial_sim  = serial_sim;
                        mlog.ip_addr     = IPAddress;
                        mlog.action      = "IDENTIFY";
                        mlog.status      = "FAIL";
                        mlog.note        = "ลูกค้าถูกระงับบริการ SMS";
                        mlog.brand       = brand;
                        mlog.model       = model;
                        mlog.app_version = app_version;
                        mlog.api_version = api_version;
                        log.logSignin(mlog);
                        monitor.sendMessage(url, IPAddress, new { serial_sim = serial_sim, deviceId = deviceId /*, app_version = app_version*/ }, new { code = 401, message = "ลูกค้าถูกระงับบริการ SMS!", data = result });
                        return(Ok(new { code = 401, message = "ลูกค้าถูกระงับบริการ SMS!", data = result }));
                    }
                }
                else
                {
                    mlog.cust_no    = 0;
                    mlog.device_id  = deviceId;
                    mlog.tel        = string.Empty;
                    mlog.serial_sim = serial_sim;
                    mlog.ip_addr    = IPAddress;
                    mlog.action     = "IDENTIFY";
                    mlog.status     = "FAIL";
                    mlog.note       = "ไม่พบเครื่องของลูกค้าในระบบ";

                    //log.logSignin(mlog);
                    monitor.sendMessage(url, IPAddress, new { serial_sim = serial_sim, deviceId = deviceId /*, app_version = app_version*/ }, new { code = 407, message = "ไม่พบเลขซิมการ์ดของลูกค้าในระบบ!", data = result });
                    return(Ok(new { code = 409, message = "ไม่พบเครื่องของลูกค้าในระบบ!", data = result }));
                }
            }
            catch (Exception e)
            {
                mlog.cust_no     = 0;
                mlog.device_id   = deviceId;
                mlog.tel         = string.Empty;
                mlog.serial_sim  = serial_sim;
                mlog.ip_addr     = IPAddress;
                mlog.action      = "IDENTIFY";
                mlog.status      = "FAIL";
                mlog.note        = e.Message;
                mlog.brand       = brand;
                mlog.model       = model;
                mlog.app_version = app_version;
                mlog.api_version = api_version;
                log.logSignin(mlog);
                monitor.sendMessage(url, IPAddress, new { serial_sim = serial_sim, deviceId = deviceId /*, app_version = app_version */ }, new { Message = e.Message });
                return(Ok(new { code = 500, message = e.Message, data = string.Empty }));
            }
        }