Beispiel #1
0
        // PUT api/mcomplain/5
        //public void Put(int id, [FromBody]string value)
        //{
        //}

        // DELETE api/mcomplain/5
        public void Delete(string ID, string UserKeys, string Description, string Case_id, int CancelID)
        {
            result = falseresult("ข้อมูลไม่ถูกต้อง");
            try
            {
                CustomerMapDao CusMap = new CustomerMapDao();
                int            _id    = MobileEncryption.Decrypt(ID.UrlDescriptHttp()).Toint();
                string         Key    = MobileEncryption.Decrypt(UserKeys.UrlDescriptHttp());
                var            Cus    = CusMap.FindByActive().Where(o => o.ID == _id && o.Keygen == Key).FirstOrDefault();
                if (Cus != null)
                {
                    ComplainsMapDao Map     = new ComplainsMapDao();
                    var             CompObj = Map.FindByCustomerID(Cus.ID).Where(o => o.Complain_Code_ID == Case_id).FirstOrDefault();
                    if (CompObj != null)
                    {
                        SaveComplain.Cancel(CompObj.Keygen, Description, CancelID);
                        result = Trueresult("ยกเลิกข้อมูลสำเร็จ");
                    }
                    else
                    {
                        result = falseresult("ไม่พบข้อมูล");
                    }
                }
            }
            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 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();
        }
Beispiel #3
0
        public ActionResult Confirm()
        {
            ComplainsMapDao Map    = new ComplainsMapDao();
            var             Obj    = Map.FindByCustomerID(Helplibery.GetUserID()).LastOrDefault();
            CustomerMapDao  CusMap = new CustomerMapDao();
            var             Cmap   = CusMap.FindById(Obj.CustomerID.Toint());

            ViewBag.fullname = Cmap.FullNameStr;
            return(View(Obj));
        }
Beispiel #4
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();
        }
Beispiel #5
0
        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 Post([FromUri] SavefileModel Value)
        {
            if (string.IsNullOrEmpty(Value.tokenId))
            {
                result = falseresult("UnAuthorized.");
            }
            if (!IsValidateToken(Value.tokenId))
            {
                result = falseresult("UnAuthorized.");
            }
            //ComplainsMapDao ComMApDao = new ComplainsMapDao();
            //var CompTemp = ComMApDao.FindByComplain_Code_ID(Value.Complain_Code).FirstOrDefault();

            //var Obj = Value.File.fileupload(CompTemp.Keygen, Value.Description, Value.Filename, Value.TypeFile);


            //Complains_FileUploadMapDao FileMap = new Complains_FileUploadMapDao();
            //Complains_FileUpload Fileobj = new Complains_FileUpload();
            //Fileobj.ComplainID = CompTemp.ID;
            //Fileobj.TypeAtID = 11;
            //Fileobj.Description = Value.Description;
            //Fileobj.Qty = 1;
            //Fileobj.Keygen = Guid.NewGuid().ToString();
            //Fileobj.Active = true;
            //Fileobj.CreateDate = DateTime.Now;
            //FileMap.Add(Fileobj);
            //FileMap.CommitChange();
            //foreach (var items in Obj)
            //{
            //    AttachFileMapDao AttachMap = new AttachFileMapDao();
            //    AttachFile _fileObj = new AttachFile();
            //    _fileObj.GUID = Fileobj.Keygen;
            //    _fileObj.path = items.path;
            //    _fileObj.Folder = items.folder;
            //    //_fileObj.Title = File.file_name;
            //    _fileObj.FileName = items.file_name;
            //    _fileObj.FileType = items.file_Type;
            //    _fileObj.CreateDate = DateTime.Now;
            //    _fileObj.Active = true;
            //    AttachMap.Add(_fileObj);
            //    AttachMap.CommitChange();
            //}

            try
            {
                var queryString = this.Request.GetQueryNameValuePairs();
                var httpRequest = HttpContext.Current.Request;
                if (httpRequest.Files.Count > 0)
                {
                    var docfiles = new List <string>();
                    foreach (string file in httpRequest.Files)
                    {
                        HttpPostedFile             postedFile = httpRequest.Files[file];
                        ComplainsMapDao            ComMApDao  = new ComplainsMapDao();
                        var                        CompTemp   = ComMApDao.FindByComplain_Code_ID(Value.Complain_Code).FirstOrDefault();
                        var                        Obj        = postedFile.fileupload(CompTemp.Keygen, Value.Description);
                        Complains_FileUploadMapDao FileMap    = new Complains_FileUploadMapDao();
                        Complains_FileUpload       Fileobj    = new Complains_FileUpload();
                        Fileobj.ComplainID  = CompTemp.ID;
                        Fileobj.TypeAtID    = 11;
                        Fileobj.Description = Value.Description;
                        Fileobj.Qty         = 1;
                        Fileobj.Keygen      = Guid.NewGuid().ToString();
                        Fileobj.Active      = true;
                        Fileobj.CreateDate  = DateTime.Now;
                        FileMap.Add(Fileobj);
                        FileMap.CommitChange();
                        foreach (var items in Obj)
                        {
                            AttachFileMapDao AttachMap = new AttachFileMapDao();
                            AttachFile       _fileObj  = new AttachFile();
                            _fileObj.GUID   = Fileobj.Keygen;
                            _fileObj.path   = items.path;
                            _fileObj.Folder = items.folder;
                            //_fileObj.Title = File.file_name;
                            _fileObj.FileName   = items.file_name;
                            _fileObj.FileType   = items.file_Type;
                            _fileObj.CreateDate = DateTime.Now;
                            _fileObj.Active     = true;
                            AttachMap.Add(_fileObj);
                            AttachMap.CommitChange();
                        }
                    }
                }
            }
            catch (IOException)
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }


            HttpResponseMessage response = new HttpResponseMessage();

            response.StatusCode = HttpStatusCode.Created;
            //return response;
            result = Trueresult(response);
            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();
        }
        public void _CancelStatus(string tokenId, string Case_Id)
        {
            try
            {
                if (string.IsNullOrEmpty(tokenId))
                {
                    result = falseresult("UnAuthorized.");
                }

                { result = falseresult("Please provide Identification number."); }

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

                //if (!IsValidateToken(key))
                //    result = falseresult("UnAuthorized.");
                if (!IsValidateToken(tokenId))
                {
                    result = falseresult("UnAuthorized.");
                }
                else
                {
                    var comList = ComplainData.GetComplainLogByCaseId(TokenValid.ApiKey, Case_Id);

                    if (comList.Count > 0)
                    {
                        ComplainsMapDao Map = new ComplainsMapDao();

                        var Temp = Map.FindAll().Where(o => o.Complain_Code_ID == Case_Id).FirstOrDefault();
                        if (SaveComplain.Cancel(Temp.Keygen, "", 228))
                        {
                            result = Trueresult("ยกเลิกข้อมูลสำเร็จ.");
                        }
                        else
                        {
                            result = falseresult("การยกเลิกข้อมูลมีปัญหา.");
                        }
                    }
                    else
                    {
                        result = falseresult("การยกเลิกข้อมูลมีปัญหา.");
                    }
                }
            }
            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();
        }