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();
        }
Esempio n. 2
0
        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();
        }