public void GetAttachmentFiles(string tokenId, string Case_Id)
        {
            //if (string.IsNullOrEmpty(tokenId))
            //    result = falseresult("UnAuthorized.");

            if (string.IsNullOrEmpty(tokenId))
            {
                result = falseresult("UnAuthorized.");
            }
            if (!IsValidateToken(tokenId))
            {
                result = falseresult("UnAuthorized.");
            }

            if (string.IsNullOrEmpty(Case_Id))
            {
                result = falseresult("Please provide Case Id.");
            }
            AuthenticateTokenMapDao _authenMap = new AuthenticateTokenMapDao();
            ComplainsMapDao         _Map       = new ComplainsMapDao();

            try
            {
                //var objToken = _authenMap.FindByKeygen(key).FirstOrDefault();
                //if (objToken != null)
                //{
                //********************* Get Complain list*********************
                //CaseID= Complain_Cause_id
                var comList = ComplainData.GetfileUploadByCaseId(TokenValid.ApiKey, Case_Id).Select(o => new
                {
                    o.Description,
                    o.Complain_file_ID,
                    o.FileName,
                    o.FileType,
                    o.CreateDate,
                    o.GUID
                }).ToList();
                SaveUtility.SaveTransactionLog(TokenValid.ApiKey, "Get Attachment Files", SaveUtility.TransStatus.Create, TokenValid.ApiKey, IPAddress, "s");    //s: service
                result = Trueresult(comList);
                // }
                //else
                //{
                //    result = falseresult("UnAuthorized.");
                //}
            }
            catch (Exception ex)
            {
                SaveUtility.logError(ex);
                result = falseresult(ex.Message);
            }
            finally
            {
                _Map       = null;
                _authenMap = null;
            }
            HttpContext.Current.Response.ContentType = "application/json";
            HttpContext.Current.Response.Write(JsonConvert.SerializeObject(result));
            HttpContext.Current.Response.End();
        }
        public void _GetTimelineHeader_From_Dep(string tokenId, int skip, int take)
        {
            if (string.IsNullOrEmpty(tokenId))
            {
                result = falseresult("UnAuthorized.");
            }
            //string key = Encryption.Decrypt(tokenId);
            //if (!IsValidateToken(key))
            //    result = falseresult("UnAuthorized.");
            if (!IsValidateToken(tokenId))
            {
                result = falseresult("UnAuthorized.");
            }


            if (skip < 1)
            {
                skip = 1;
            }

            if (take < 1)
            {
                take = 20;
            }

            try
            {
                AuthenticateTokenMapDao _authenMap = new AuthenticateTokenMapDao();

                //var objToken = _authenMap.FindByKeygen(key).FirstOrDefault();



                Department_ExMapDao _departMap = new Department_ExMapDao();

                //if (objToken != null)
                //{

                var Dep_ex = _departMap.FindByKeygen(TokenValid.ApiKey).FirstOrDefault();

                var comList = ComplainData.GetTimelineHeader_From_Dep(Dep_ex.ID);
                SaveUtility.SaveTransactionLog(TokenValid.ApiKey, "Get Time line Header", SaveUtility.TransStatus.Create, TokenValid.Keygen, IPAddress, "s");    //s: service
                result = Trueresult(comList);
                //}
                //else
                //{
                //    result = falseresult("UnAuthorized.");
                //}
            }
            catch (Exception ex)
            {
                SaveUtility.logError(ex);
                result = falseresult(ex.Message);
            }

            HttpContext.Current.Response.ContentType = "application/json";
            HttpContext.Current.Response.Write(JsonConvert.SerializeObject(result));
            HttpContext.Current.Response.End();
        }
        public void _SaveClue(string tokenId, string title, string description, string Consumer_firstname, string Consumer_lastname, string Consumer_Email, string Consumer_Mobile, string address, string Amphur_text, string Province_text)
        {
            if (string.IsNullOrEmpty(tokenId))
            {
                result = falseresult("UnAuthorized.");
            }
            //string key = Encryption.Decrypt(tokenId);
            //if (!IsValidateToken(key))
            //    result = falseresult("UnAuthorized.");

            if (!IsValidateToken(tokenId))
            {
                result = falseresult("UnAuthorized.");
            }

            ClueMapDao clueMap = new ClueMapDao();
            AuthenticateTokenMapDao _authenMap = new AuthenticateTokenMapDao();
            Department_ExMapDao     _departMap = new Department_ExMapDao();

            //var objToken = _authenMap.FindByKeygen(key).FirstOrDefault();
            try
            {
                int? ChannelID = _departMap.FindByKeygen(TokenValid.ApiKey).FirstOrDefault().ChanelID;
                Clue obj       = new Clue();
                obj.Active              = true;
                obj.CreateDate          = DateTime.Now;
                obj.Keygen              = Guid.NewGuid().ToString();
                obj.Title               = title;
                obj.Address             = address;
                obj.Description         = description;
                obj.Amphur_text         = Amphur_text;
                obj.Province_text       = Province_text;
                obj.Complain_Channel_id = ChannelID;
                obj.Fname               = Consumer_firstname;
                obj.Lname               = Consumer_lastname;
                obj.Mobile              = Consumer_Mobile;
                obj.Email               = Consumer_Email;
                clueMap.Add(obj);
                clueMap.CommitChange();
                SaveUtility.SaveTransactionLog(obj.Keygen, "Save Clue", SaveUtility.TransStatus.Create, TokenValid.Keygen, IPAddress, "s"); //s: service
                clueMap = null;
                result  = Trueresult("ระบบได้รับคำแจ้งเบาแสเรียบร้อยแล้ว");
            }
            catch (Exception ex)
            {
                clueMap    = null;
                _authenMap = null;
                SaveUtility.logError(ex);
                result = falseresult(ex.Message);
            }
            HttpContext.Current.Response.ContentType = "application/json";
            HttpContext.Current.Response.Write(JsonConvert.SerializeObject(result));
            HttpContext.Current.Response.End();
        }
        protected bool IsValidateToken(string tokenId)
        {
            var Obj = MyExtensions.DecodeObj <_TokenCheck>(tokenId);

            TokenValid = Obj;
            AuthenticateTokenMapDao _authenMap = new AuthenticateTokenMapDao();
            var _obj = _authenMap.FindByKeygenAndActive(Obj.Keygen).Where(o => o.ApiKey == Obj.ApiKey).FirstOrDefault();

            if (_obj == null)
            {
                return(false);
            }
            else
            {
                var start = DateTime.Now;

                if (start.Subtract(Obj.Process_date.Value) <= TimeSpan.FromMinutes(20))
                {
                    //20 minutes were passed from start
                    return(true);
                }
                else
                {
                    return(false);
                }
            }


            //AuthenticateTokenMapDao _authenMap = new AuthenticateTokenMapDao();
            //bool bResult = false;

            //var objToken = _authenMap.FindByKeygen(tokenId).ToList();

            //if (objToken.Count() > 0)
            //{
            //    //disable token
            //    foreach (var item in objToken)
            //    {
            //        if (Convert.ToDateTime(item.Process_date).AddMinutes(item.Process_time) > DateTime.Now)
            //        {
            //            bResult = true;
            //        }
            //        else
            //        {
            //            item.Active = false;
            //            _authenMap.AddOrUpdate(item);
            //            _authenMap.CommitChange();
            //        }
            //    }
            //}
            //_authenMap = null;
            //return bResult;
        }
Exemple #5
0
        //[HttpGet]
        //public void GetToken(string APIKey, string Password)
        //{
        //    string IPAddress = HttpContext.Current.Request.UserHostAddress;
        //    if (string.IsNullOrEmpty(APIKey))
        //        result = falseresult("UnAuthorized...");

        //    if (string.IsNullOrEmpty(Password))
        //        result = falseresult("Please provide Password...");

        //    if (string.IsNullOrEmpty(IPAddress))
        //        result = falseresult("Please provide IP Address...");

        //    //if (!CheckPassEnscrypt(Password, ref Password))
        //    //{ result = falseresult("UnAuthorized..."); }
        //    else
        //    {

        //        Department_ExMapDao map = new Department_ExMapDao();
        //        try
        //        {
        //            OfficerToken _token = new OfficerToken();
        //            string newToken = Guid.NewGuid().ToString();
        //            var obj = map.FindByKeygen(APIKey).Where(o => o.Password == Encryption.Encrypt(Password)).FirstOrDefault();
        //            if (obj != null)
        //            {
        //                GetAuthToken(_token, APIKey, newToken, IPAddress);
        //                //_token.Username = "";
        //                //_token.Org_id = obj.ID.ToString();
        //                _token.Org_name = obj.External_dept_Name;
        //                _token.Office_name = obj.External_dept_Name;
        //                SaveUtility.SaveTransactionLog(newToken, "GetToken", SaveUtility.TransStatus.Create, APIKey, IPAddress, "s"); //s: service
        //                result = Trueresult(_token);
        //            }
        //            else
        //            {
        //                result = falseresult("Invalid Token and Password...");
        //            }
        //        }
        //        catch (Exception ex)
        //        {
        //            SaveUtility.logError(ex);
        //            result = falseresult(ex.Message.ToString());
        //        }
        //        finally
        //        {
        //            map = null;
        //        }
        //    }
        //    HttpContext.Current.Response.ContentType = "application/json";
        //    HttpContext.Current.Response.Write(JsonConvert.SerializeObject(result));
        //    HttpContext.Current.Response.End();
        //}
        //[HttpPost]
        //public void GetToken([FromBody]string value)
        //{
        //    //string IPAddress = HttpContext.Current.Request.UserHostAddress;
        //    //if (string.IsNullOrEmpty(APIKey))
        //    //    result = falseresult("UnAuthorized...");

        //    //if (string.IsNullOrEmpty(Password))
        //    //    result = falseresult("Please provide Password...");

        //    //if (string.IsNullOrEmpty(IPAddress))
        //    //    result = falseresult("Please provide IP Address...");

        //    ////if (!CheckPassEnscrypt(Password, ref Password))
        //    ////{ result = falseresult("UnAuthorized..."); }
        //    //else
        //    //{

        //    //    Department_ExMapDao map = new Department_ExMapDao();
        //    //    try
        //    //    {
        //    //        OfficerToken _token = new OfficerToken();
        //    //        string newToken = Guid.NewGuid().ToString();
        //    //        var obj = map.FindByKeygen(APIKey).Where(o => o.Password == Encryption.Encrypt(Password)).FirstOrDefault();
        //    //        if (obj != null)
        //    //        {
        //    //            GetAuthToken(_token, APIKey, newToken, IPAddress);
        //    //            //_token.Username = "";
        //    //            //_token.Org_id = obj.ID.ToString();
        //    //            _token.Org_name = obj.External_dept_Name;
        //    //            _token.Office_name = obj.External_dept_Name;
        //    //            SaveUtility.SaveTransactionLog(newToken, "GetToken", SaveUtility.TransStatus.Create, APIKey, IPAddress, "s"); //s: service
        //    //            result = Trueresult(_token);
        //    //        }
        //    //        else
        //    //        {
        //    //            result = falseresult("Invalid Token and Password...");
        //    //        }
        //    //    }
        //    //    catch (Exception ex)
        //    //    {
        //    //        SaveUtility.logError(ex);
        //    //        result = falseresult(ex.Message.ToString());
        //    //    }
        //    //    finally
        //    //    {
        //    //        map = null;
        //    //    }
        //    //}
        //    HttpContext.Current.Response.ContentType = "application/json";
        //    HttpContext.Current.Response.Write(JsonConvert.SerializeObject(result));
        //    HttpContext.Current.Response.End();
        //}


        #endregion



        //  [WebMethod(Description = "Get Timeline Header เป็นเมธอดสำหรับใช้ดึงข้อมูล ที่เกียวข้องกับหน่วยงานนั้นๆ <br />"
        //+ "Skip: ลำดับข้อมูลที่ต้องการเริ่มต้น เช่น เริ่มแถวที่ 1 <br />"
        //+ "take: จำนวนข้อมูลที่ต้องการ เช่น 10 ,20 แถว<br />"
        //+ "IsCloseJob: สถานะเรืองร้องทุกข์ (null=ทั้งหมด ,0=กำลังดำเนินการ ,1=ยุติการดำเนินการ)")]
        public void GetTimelineHeader(string tokenId, int skip, int take, string IsCloseJob)
        {
            if (string.IsNullOrEmpty(tokenId))
            {
                result = falseresult("UnAuthorized.");
            }
            string key = Encryption.Decrypt(tokenId);

            if (!IsValidateToken(key))
            {
                result = falseresult("UnAuthorized.");
            }



            if (skip < 1)
            {
                skip = 1;
            }

            if (take < 1)
            {
                take = 20;
            }

            try
            {
                AuthenticateTokenMapDao _authenMap = new AuthenticateTokenMapDao();

                var objToken = _authenMap.FindByKeygen(key).FirstOrDefault();
                if (objToken != null)
                {
                    var comList = ComplainData.GetComplainTimeLine(objToken.ApiKey, skip, take, 0, null);
                    SaveUtility.SaveTransactionLog(objToken.ApiKey, "Get Time line Header", SaveUtility.TransStatus.Create, key, objToken.Owner_ip, "s"); //s: service
                    result = Trueresult(comList);
                }
                else
                {
                    result = falseresult("UnAuthorized.");
                }
            }
            catch (Exception ex)
            {
                SaveUtility.logError(ex);
                result = falseresult(ex.Message);
            }

            HttpContext.Current.Response.ContentType = "application/json";
            HttpContext.Current.Response.Write(JsonConvert.SerializeObject(result));
            HttpContext.Current.Response.End();
        }
        protected void GetAuthToken(OfficerToken token, string key, string newKey, string ip)
        {
            AuthenticateTokenMapDao _authenMap = new AuthenticateTokenMapDao();
            AuthenticateToken       Obj        = new AuthenticateToken();


            //_authenMap.AddOrUpdate(Obj);

            var objToken = _authenMap.FindActiveByAPIKey(key).ToList();

            foreach (var Items in objToken)
            {
                Items.Active = false;
                _authenMap.AddOrUpdate(Items);
                _authenMap.CommitChange();
            }
            //if (objToken.Count() > 0)
            //{
            //    //disable token
            //    foreach (var item in objToken)
            //    {
            //        if (item.Owner_ip == ip && Convert.ToDateTime(item.Process_date).AddMinutes(item.Process_time) > DateTime.Now)
            //        {
            //            token.Token_id = Encryption.Encrypt(item.Keygen);
            //        }
            //        else
            //        {
            //            item.Active = false;
            //            _authenMap.AddOrUpdate(item);
            //            _authenMap.CommitChange();
            //        }
            //    }
            //}

            //if (string.IsNullOrEmpty(token.Token_id))
            //{



            var authen = new AuthenticateToken(key, newKey, ip);

            _authenMap.AddOrUpdate(authen);
            _authenMap.CommitChange();
            token.Token_id = MyExtensions.ParamEncode(new { authen.ApiKey, Process_date = authen.Process_date.ToThaiFormateAndtime(), authen.Process_time, authen.Keygen });
            //token   =
            //}

            //_authenMap = null;
        }
        private void _ReleaseToken(string tokenId)
        {
            if (string.IsNullOrEmpty(tokenId))
            {
                result = falseresult("UnAuthorized...");
            }

            // string key = Encryption.Decrypt(tokenId); //new key
            AuthenticateTokenMapDao _authenMap = new AuthenticateTokenMapDao();

            if (!IsValidateToken(tokenId))
            {
                result = falseresult("UnAuthorized.");
            }

            try
            {
                var objToken = _authenMap.FindByKeygen(TokenValid.Keygen).ToList();
                if (objToken.Count() > 0)
                {
                    //disable token
                    foreach (var item in objToken)
                    {
                        item.Active = false;
                        _authenMap.AddOrUpdate(item);
                        _authenMap.CommitChange();

                        SaveUtility.SaveTransactionLog(item.Keygen, "Release Token", SaveUtility.TransStatus.Create, tokenId, item.Owner_ip, "s");
                    }
                }
            }
            catch (Exception ex)
            {
                SaveUtility.logError(ex);
                result = falseresult(ex.Message);
            }
            finally
            {
                _authenMap = null;
            }

            result = Trueresult("OK");
            HttpContext.Current.Response.ContentType = "application/json";
            HttpContext.Current.Response.Write(JsonConvert.SerializeObject(result));
            HttpContext.Current.Response.End();
        }
Exemple #8
0
        private void _AddComplain(string tokenId, string Identification_number, string Consumer_firstname, string Consumer_lastname, string Consumer_gender, string Consumer_Birth
                                  , string Consumer_Address, string Consumer_ZipCode, string Consumer_Tel, string Consumer_Tel_Ex, string Consumer_Mobile, string Consumer_Fax, string Consumer_Email, string Complain_Subject
                                  , string Complain_Details, string DefendentName, string DefendentDescription, string Payment, string PlacePurchase, string Motive, string IsOversea, string OverseaAddress)
        {
            if (string.IsNullOrEmpty(tokenId))
            {
                result = falseresult("UnAuthorized.");
            }
            if (string.IsNullOrEmpty(Identification_number))
            {
                result = falseresult("Please provide Identification number.");
            }

            //string key = Encryption.Decrypt(tokenId);

            //if (!IsValidateToken(key))
            //    result = falseresult("UnAuthorized.");
            if (!IsValidateToken(tokenId))
            {
                result = falseresult("UnAuthorized.");
            }


            try
            {
                Department_ExMapDao            _departMap = new Department_ExMapDao();
                AuthenticateTokenMapDao        _authenMap = new AuthenticateTokenMapDao();
                CustomerMapDao                 _cusMap    = new CustomerMapDao();
                CustomerVerifyMapDao           _mapVer    = new CustomerVerifyMapDao();
                ComplainsMapDao                _Map       = new ComplainsMapDao();
                Complains_WebService_logMapDao _logMap    = new Complains_WebService_logMapDao();

                Complains _Item = new Complains();
                //var objToken = _authenMap.FindByKeygen(key).FirstOrDefault();
                //if (objToken != null)
                //{
                string Complain_Code_ID = null;
                var    Dep_ex           = _departMap.FindByKeygen(TokenValid.ApiKey).FirstOrDefault();
                int?   ChannelID        = Dep_ex.ChanelID;
                int?   CusID            = SaveAccount.CheckUserAndNewregis(null, Identification_number, Consumer_firstname, Consumer_lastname, Consumer_gender, Consumer_Birth, Consumer_Address, null, null, null, Consumer_ZipCode, Consumer_Tel, Consumer_Tel_Ex, Consumer_Mobile, Consumer_Fax, Consumer_Email, false, null, null);
                if (IsOversea.ToUpper().Trim() == "TRUE")
                {
                    var CusObj = _cusMap.FindById(CusID.Toint());
                    CusObj.IsOversea = true;
                    _cusMap.AddOrUpdate(CusObj);
                    _cusMap.CommitChange();
                    Customer_OverseaMapDao OverSeaMap = new Customer_OverseaMapDao();
                    if (OverSeaMap.FindAll().Where(o => o.CustomerID == CusID).ToList().Count() == 0)
                    {
                        Customer_Oversea SMapObj = new Customer_Oversea();
                        SMapObj.CustomerID      = CusID;
                        SMapObj.address_oversea = OverseaAddress;
                        OverSeaMap.Add(SMapObj);
                        OverSeaMap.CommitChange();
                    }
                }

                int Id = SaveComplain.AddnewComplain(Complain_Subject, ChannelID, CusID, DefendentName, DefendentDescription, Complain_Details
                                                     , null, null, null, null, PlacePurchase, null, Payment, null, Motive, null, null, ref Complain_Code_ID);
                SaveComplain.StartTrack(Id, 3, TokenValid.ApiKey, null);

                _Item = _Map.FindById(Id);

                //*********************Save Complain Service Log

                Complains_WebService_log _log = new Complains_WebService_log();
                _log.IdentityID = Identification_number;
                _log.Sex        = Consumer_gender != null?Consumer_gender.ToLower() : "";

                _log.ApiKey     = TokenValid.ApiKey;
                _log.CreateDate = DateTime.Now;
                _log.FullName   = Consumer_firstname + " " + Consumer_lastname;
                // _log.TitleID = TitleID;
                _log.Fname              = Consumer_firstname;
                _log.Lname              = Consumer_lastname;
                _log.DateOfBirth        = Consumer_Birth;
                _log.Address            = Consumer_Address;
                _log.ZipCode            = Consumer_ZipCode;
                _log.Tel                = Consumer_Tel;
                _log.Tel_ext            = Consumer_Tel_Ex;
                _log.Mobile             = Consumer_Mobile;
                _log.Fax                = Consumer_Fax;
                _log.Email              = Consumer_Email;
                _log.Complain_Subject   = Complain_Subject;
                _log.Complain_Details   = Complain_Details;
                _log.CompanyName        = DefendentName;
                _log.CompanyDescription = DefendentDescription;
                //_log.PaymentID = PaymentID;
                //_log.PlacePurchaseID = PlacePurchaseID;
                //_log.MotiveID = Motive;
                _log.Payment_Text       = Payment;
                _log.PlacePurchase_Text = PlacePurchase;
                _log.Motive_Text        = Motive;
                _log.IsOversea          = (IsOversea.Trim().ToUpper() == "TRUE") ? true : false;
                _log.OverseaAddress     = OverseaAddress;
                _logMap.AddOrUpdate(_log);
                _logMap.CommitChange();
                Complains_DepartmentMapDao DepTMapDao = new Complains_DepartmentMapDao();
                Complains_Department       _Dept      = new Complains_Department();
                _Dept.ComplainID   = Id;
                _Dept.DepartmentID = Dep_ex.ID;
                DepTMapDao.Add(_Dept);
                DepTMapDao.CommitChange();
                SaveUtility.SaveTransactionLog(_Item.Keygen, "Add Complain", SaveUtility.TransStatus.Create, TokenValid.ApiKey, IPAddress, "s");     //s: service
                result = Trueresult(new OCPB.Service.Model.Complain(_Item.Complain_Code_ID, _Item.Complain_Date.ToThaiFormate(), _Item.Complain_Time, _Item.Complain_Subject));
                //}
                //else
                //{
                //    result = falseresult("UnAuthorized.");
                //}
            }
            catch (Exception ex)
            {
                SaveUtility.logError(ex);
                result = falseresult(ex.Message);
            }
            //finally
            //{
            //    _mapVer = null;
            //    _Map = null;
            //    _logMap = null;
            //    _departMap = null;
            //    _authenMap = null;
            //    _cusMap = null;
            //}


            HttpContext.Current.Response.ContentType = "application/json";
            HttpContext.Current.Response.Write(JsonConvert.SerializeObject(result));
            HttpContext.Current.Response.End();
        }
        public void _GetCase(string tokenId, string Case_Id)
        {
            if (string.IsNullOrEmpty(tokenId))
            {
                result = falseresult("UnAuthorized.");
            }

            if (string.IsNullOrEmpty(Case_Id))
            {
                result = falseresult("Please provide Case Id.");
            }

            //if (!IsValidateToken(key))
            //    result = falseresult("UnAuthorized.");
            if (!IsValidateToken(tokenId))
            {
                result = falseresult("UnAuthorized.");
            }
            Department_ExMapDao     _departMap = new Department_ExMapDao();
            AuthenticateTokenMapDao _authenMap = new AuthenticateTokenMapDao();
            ComplainsMapDao         _Map       = new ComplainsMapDao();

            try
            {
                //var objToken = _authenMap.FindByKeygen(key).FirstOrDefault();
                //if (objToken != null)
                //{
                var objDepart = _departMap.FindByKeygen(TokenValid.ApiKey).FirstOrDefault();

                //********************* Get Complain list*********************
                //CaseID= Complain_Code_id
                var comList = ComplainData.GetComplainByCaseId(TokenValid.Keygen, Case_Id).ToList();

                foreach (var i in comList)
                {
                    i.AttachmentFiles = GetfileUpload(i.ID);
                }

                if (comList.Count > 0)
                {
                    // var Status = GetComplain.Get_log_all(obj.Complain_Code_ID, null, null, null, null, null, null, null);

                    var selected = from c in comList
                                   select new
                    {
                        Complain_Code_ID      = c.Complain_Code_ID,
                        Complain_Date         = c.Complain_Date,
                        Complain_Time         = c.Complain_Time,
                        Complain_Subject      = c.Complain_Subject,
                        Complain_Details      = c.Complain_Details,
                        Complain_Channel_id   = c.Complain_Channel_id,
                        Complain_Channel_Text = c.Complain_Channel_Text,
                        Consumer_Citizen_id   = c.CusIden,
                        Consumer_Name         = c.Cusname,
                        Case_id                = c.Complain_Cause_id,
                        Defendent_Name         = c.CompanyName,
                        Defendent_Detail       = c.Complain_Details,
                        PaymentID              = c.PaymentID,
                        PaymentText            = c.PaymentText,
                        Complain_TypeID        = c.Complain_TypeID,
                        Complain_Type_Text     = c.Complain_Type_Text,
                        Complain_Type_Sub_ID   = c.Complain_Type_Sub_ID,
                        Complain_Type_Sub_Text = c.Complain_Type_Sub_Text,
                        Complain_Cause_ID      = c.Complain_Cause_id,
                        Complain_Cause_Text    = c.Complain_Cause_Text,
                        PlacePurchaseID        = c.PlacePurchaseID,
                        PlacePurchase_Text     = c.PlacePurchase_Text,
                        MotiveID               = c.MotiveID,
                        Motive_Text            = c.Motive_Text,
                        // Complain_Status_text = c.Complain_Status_text,
                        Complain_Status_text = Liststatus(c.ID),
                        AttachmentFiles      = c.AttachmentFiles,
                    };

                    SaveUtility.SaveTransactionLog(TokenValid.ApiKey, "Get Case", SaveUtility.TransStatus.Create, TokenValid.ApiKey, IPAddress, "s"); //s: service
                    result = Trueresult(selected);
                }
                else
                {
                    SaveUtility.SaveTransactionLog(TokenValid.ApiKey, "Get Case", SaveUtility.TransStatus.Create, TokenValid.ApiKey, IPAddress, "s"); //s: service
                                                                                                                                                      // result = Trueresult(new OCPB.Model.Complains());
                    result = _Noresult();
                }
                //}
                //else
                //{
                //    result = falseresult("UnAuthorized.");
                //}
            }
            catch (Exception ex)
            {
                SaveUtility.logError(ex);
                result = falseresult(ex.Message);
            }
            finally
            {
                _Map       = null;
                _departMap = null;
                _authenMap = null;
            }
            HttpContext.Current.Response.ContentType = "application/json";
            HttpContext.Current.Response.Write(JsonConvert.SerializeObject(result));
            HttpContext.Current.Response.End();
        }
        public void GetComplainStatus_Log(string tokenId, string Case_Id)
        {
            if (string.IsNullOrEmpty(tokenId))
            {
                result = falseresult("UnAuthorized.");
            }


            if (string.IsNullOrEmpty(Case_Id))
            {
                result = falseresult("Please provide Case Id.");
            }


            ////string key = Encryption.Decrypt(tokenId);

            ////if (!IsValidateToken(key))
            ////    result = falseresult("UnAuthorized.");

            if (!IsValidateToken(tokenId))
            {
                result = falseresult("UnAuthorized.");
            }

            // Department_ExMapDao _departMap = new Department_ExMapDao();
            AuthenticateTokenMapDao _authenMap = new AuthenticateTokenMapDao();

            //ComplainsMapDao _Map = new ComplainsMapDao();

            try
            {
                //var objToken = _authenMap.FindByKeygen(key).FirstOrDefault();
                //if (objToken != null)
                //{
                //  var objDepart = _departMap.FindByKeygen(objToken.ApiKey).FirstOrDefault();

                //********************* Get Complain list*********************
                //CaseID= Complain_Code_id
                var comList = ComplainData.GetComplainLogByCaseId(TokenValid.ApiKey, Case_Id);

                if (comList.Count > 0)
                {
                    SaveUtility.SaveTransactionLog(TokenValid.ApiKey, "Get ComplainStatus_Log", SaveUtility.TransStatus.Create, TokenValid.Keygen, IPAddress, "s");     //s: service
                    result = Trueresult(comList);
                }
                else
                {
                    SaveUtility.SaveTransactionLog(TokenValid.ApiKey, "Get ComplainStatus_Log", SaveUtility.TransStatus.Create, TokenValid.Keygen, IPAddress, "s");     //s: service
                    result = falseresult(new List <OCPB.Service.Model.ComplainLog> {
                        new OCPB.Service.Model.ComplainLog()
                    });
                }

                //}
                //else
                //{
                //    result = falseresult("UnAuthorized.");
                //}
            }
            catch (Exception ex)
            {
                SaveUtility.logError(ex);
                result = falseresult(ex.Message);
            }
            finally
            {
                //_Map = null;
                //_departMap = null;
                _authenMap = null;
            }
            HttpContext.Current.Response.ContentType = "application/json";
            HttpContext.Current.Response.Write(JsonConvert.SerializeObject(result));
            HttpContext.Current.Response.End();
        }
        public void _UpDateCase(string tokenId, string Case_Id, string Status_Date, string Status_Detail, bool Clase_Status)
        {
            if (string.IsNullOrEmpty(tokenId))
            {
                result = falseresult("UnAuthorized.");
            }

            if (string.IsNullOrEmpty(Case_Id))
            {
                result = falseresult("Please provide Case Id.");
            }


            //string key = Encryption.Decrypt(tokenId);

            //if (!IsValidateToken(key))
            //    result = falseresult("UnAuthorized.");
            if (!IsValidateToken(tokenId))
            {
                result = falseresult("UnAuthorized.");
            }

            // Department_ExMapDao _departMap = new Department_ExMapDao();
            AuthenticateTokenMapDao _authenMap = new AuthenticateTokenMapDao();
            ComplainsMapDao         _Map       = new ComplainsMapDao();
            ComplianTrackingMapDao  _track     = new ComplianTrackingMapDao();

            try
            {
                //var objToken = _authenMap.FindByKeygen(key).FirstOrDefault();
                //if (objToken != null)
                //{
                // var objDepart = _departMap.FindByKeygen(objToken.ApiKey).FirstOrDefault();
                var comp = _Map.FindByComplain_Code_ID(Case_Id).FirstOrDefault();
                if (comp != null)
                {
                    var obj = _track.FindByComplain_CodeWithRefKeygen(comp.ID, TokenValid.ApiKey);
                    if (obj != null)
                    {
                        ComplainTrackExLog.AddComplainTrackExLog(obj.ID, Status_Date, Status_Detail, Clase_Status, TokenValid.ApiKey);


                        //update ComplainTracking
                        if (Clase_Status)
                        {
                            //ถ้ามีการ close job ให้ update tracking ใน isclosejob,isclosedate ด้วย
                            obj.IsCloseJob  = Clase_Status;
                            obj.IsCloseDate = DateTime.Now;
                            _track.AddOrUpdate(obj);
                            _track.CommitChange();
                        }


                        SaveUtility.SaveTransactionLog(TokenValid.ApiKey, "Update Case", SaveUtility.TransStatus.Create, TokenValid.Keygen, IPAddress, "s");    //s: service
                        result = Trueresult("OK");
                    }
                    else
                    {
                        result = falseresult("Data not found.");
                    }
                }
                else
                {
                    result = falseresult("Data not found.");
                }
                //}
                //else
                //{
                //    result = falseresult("UnAuthorized.");
                //}
            }
            catch (Exception ex)
            {
                SaveUtility.logError(ex);
                result = falseresult(ex.Message);
            }
            finally
            {
                _Map   = null;
                _track = null;
                // _trackEx = null;
                _authenMap = null;
            }
            HttpContext.Current.Response.ContentType = "application/json";
            HttpContext.Current.Response.Write(JsonConvert.SerializeObject(result));
            HttpContext.Current.Response.End();
        }
Exemple #12
0
        private void _Config(string tokenId, string _Type, string refID)
        {
            if (string.IsNullOrEmpty(tokenId))
            {
                result = falseresult("UnAuthorized.");
            }

            //if (string.IsNullOrEmpty(Case_Id))
            //    result = falseresult("Please provide Case Id.");


            //string key = Encryption.Decrypt(tokenId);

            if (!IsValidateToken(tokenId))
            {
                result = falseresult("UnAuthorized.");
            }

            Department_ExMapDao     _departMap = new Department_ExMapDao();
            AuthenticateTokenMapDao _authenMap = new AuthenticateTokenMapDao();

            try
            {
                //var objToken = _authenMap.FindByKeygen(key).FirstOrDefault();
                //if (objToken != null)
                //{
                //    var objDepart = _departMap.FindByKeygen(objToken.ApiKey).FirstOrDefault();

                //********************* Get Config*********************
                var _obj = new Object();

                switch (_Type.ToUpper())
                {
                case "PROVINCE":
                {
                    Tm_provinceMapDao Map = new Tm_provinceMapDao();
                    _obj = Map.FindByActive().Select(o => new { o.ID, o.Province_NameEN, o.Province_NameTH }).OrderBy(o => o.Province_NameTH).ToList();
                    break;
                }

                case "DISTRICT":
                {
                    Tm_districtMapDao Map = new Tm_districtMapDao();

                    if (!string.IsNullOrEmpty(refID))
                    {
                        _obj = Map.FindByActive().Where(o => o.Prefecture_ID == refID.Toint()).Select(o => new { o.ID, o.Province_ID, o.Prefecture_ID, o.Zipcode, o.District_NameEN, o.District_NameTH }).OrderBy(o => o.District_NameTH).ToList();
                    }
                    else
                    {
                        _obj = Map.FindByActive().Select(o => new { o.ID, o.Province_ID, o.Prefecture_ID, o.Zipcode, o.District_NameEN, o.District_NameTH }).OrderBy(o => o.District_NameTH).ToList();
                    }
                    break;
                }

                case "PREFECTURE":
                {
                    Tm_prefectureMapDao Map = new Tm_prefectureMapDao();
                    if (!string.IsNullOrEmpty(refID))
                    {
                        _obj = Map.FindByActive().Where(o => o.Province_ID == refID.Toint()).Select(o => new { o.ID, o.Prefecture_ID, o.Prefecture_NameEN, o.Prefecture_NameTH, o.Province_ID }).OrderBy(o => o.Prefecture_NameTH).ToList();
                    }
                    else
                    {
                        _obj = Map.FindByActive().Select(o => new { o.ID, o.Prefecture_ID, o.Prefecture_NameEN, o.Prefecture_NameTH, o.Province_ID }).OrderBy(o => o.Prefecture_NameTH).ToList();
                    }
                    break;
                }

                case "TYPE_0":
                {
                    Tm_Complain_TypeMapDao Map = new Tm_Complain_TypeMapDao();
                    _obj = Map.FindByLevel0().Select(o => new { o.Complain_Type_Class, o.Complain_Type_Code, o.Complain_Type_Level, o.Complain_Type_Name, o.complain_type_name_en, o.Complain_Type_Refer, o.Complain_Type_Sub_ID, o.Complain_Type_SubLevel, o.ID }).ToList();
                    break;
                }

                case "TYPE_1":
                {
                    Tm_Complain_TypeMapDao Map = new Tm_Complain_TypeMapDao();
                    if (!string.IsNullOrEmpty(refID))
                    {
                        _obj = Map.FindByLevel1(refID.Toint()).Select(o => new { o.Complain_Type_Class, o.Complain_Type_Code, o.Complain_Type_Level, o.Complain_Type_Name, o.complain_type_name_en, o.Complain_Type_Refer, o.Complain_Type_Sub_ID, o.Complain_Type_SubLevel, o.ID }).ToList();
                    }
                    else
                    {
                        _obj = Map.FindAll().Select(o => new { o.Complain_Type_Class, o.Complain_Type_Code, o.Complain_Type_Level, o.Complain_Type_Name, o.complain_type_name_en, o.Complain_Type_Refer, o.Complain_Type_Sub_ID, o.Complain_Type_SubLevel, o.ID }).ToList();
                    }
                    break;
                }

                case "CASE":
                {
                    if (!string.IsNullOrEmpty(refID))
                    {
                        _obj = GetUtility.GetTm_case(refID.Toint()).Select(o => new { o.CaseID, o.CasenameEN, o.CasenameTH, o.Complain_Cause_id, o.Complain_Type_Name, o.complain_type_name_en, o.Tm_Cause_GruopID, o.Tm_CauseID, o.Tm_Complain_TypeID }).ToList();
                    }
                    else
                    {
                        _obj = GetUtility.GetTm_case().Select(o => new { o.CaseID, o.CasenameEN, o.CasenameTH, o.Complain_Cause_id, o.Complain_Type_Name, o.complain_type_name_en, o.Tm_Cause_GruopID, o.Tm_CauseID, o.Tm_Complain_TypeID }).ToList();
                    }
                    break;
                }

                case "PLACE":
                {
                    Tm_PlaceOfPurchaseMapDao map = new Tm_PlaceOfPurchaseMapDao();
                    _obj = map.FindByActive().Select(o => new { o.ID, o.PlaceNameEng, o.PlaceNameThai }).ToList();
                    break;
                }

                case "MOV":
                {
                    Tm_MotivateMapDao map = new Tm_MotivateMapDao();
                    _obj = map.FindByActive().Select(o => new { o.MotiveNameEng, o.MotiveNameThai, o.ID }).ToList();
                    break;
                }

                case "PAY":
                {
                    Tm_PaymentMapDao map = new Tm_PaymentMapDao();
                    _obj = map.FindByActive().Select(o => new { o.ID, o.PaymentNameEng, o.PaymentNameThai });
                    break;
                }

                case "JOB":
                {
                    Tm_OccupationMapDao map = new Tm_OccupationMapDao();
                    _obj = map.FindByActive().Select(o => new { o.ID, o.Occupation_Name, o.occupation_name_en });
                    break;
                }

                case "SALARY":
                {
                    Tm_SalaryMapDao map = new Tm_SalaryMapDao();
                    _obj = map.FindByActive().Select(o => new { o.ID, o.SalaryName, o.SalaryNameEN });
                    break;
                }

                case "TITLE":
                {
                    User_TitleMapDao map = new User_TitleMapDao();
                    _obj = map.FindByActive().Select(o => new { o.ID, o.Description, o.IsThai });
                    break;
                }

                case "CANCEL":
                {
                    Complain_Cancel_StatusMapDao map = new Complain_Cancel_StatusMapDao();
                    _obj = map.FindByActive().Select(o => new { o.ID, o.ComplainCancelStatusName });
                    break;
                }

                case "OCCUPATION":
                {
                    Tm_OccupationMapDao map = new Tm_OccupationMapDao();
                    _obj = map.FindByActive().Select(o => new { o.ID, o.occupation_name_en, o.Occupation_Name });
                    break;
                }
                }
                SaveUtility.SaveTransactionLog(TokenValid.ApiKey, "Config", SaveUtility.TransStatus.View, tokenId, IPAddress, "s"); //s: service
                result = Trueresult(_obj);
                //}
                //else
                //{
                //    result = falseresult("UnAuthorized.");
                //}
            }
            catch (Exception ex)
            {
                SaveUtility.logError(ex);
                result = falseresult(ex.Message);
            }

            HttpContext.Current.Response.ContentType = "application/json";
            HttpContext.Current.Response.Write(JsonConvert.SerializeObject(result));
            HttpContext.Current.Response.End();
        }