Exemplo n.º 1
0
        public ContainDetailResponse Action()
        {
            ContainDetailResponse response = new ContainDetailResponse();

            try
            {
                DirectoryInfo directoryInfo = new DirectoryInfo(Path.Combine(DefaultNetDrive, _targetPath));
                if (!directoryInfo.Exists)
                {
                    IList <FileInfo> fileInfos = directoryInfo.GetFiles();
                    foreach (FileInfo fileInfo in fileInfos)
                    {
                        response.Files.Add(CryptoBase64.Encryption(fileInfo.FullName));
                    }
                }
                else
                {
                    throw new IOException(Resources.errorContainDetail_001);
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }
            finally {
                DisConnectNetDrive();
            }


            return(response);
        }
Exemplo n.º 2
0
        private void AddAttechFile(DTO.AttachFile attachFile)
        {
            if (((List <DTO.AttachFile>)Session["AttachFiles"]).Where(a => a.AttechType == attachFile.AttechType).Count() > 0)
            {
                throw new ApplicationException(Resources.errorTestUploadData_002);
            }
            else
            {
                using (svc = new FileService.FileTransferServiceClient()) {
                    UploadFileResponse response  = new UploadFileResponse();
                    Stream             fileStrem = fUpload.PostedFile.InputStream;
                    response = svc.UploadFile(new UploadFileRequest()
                    {
                        TargetContainer = attachFile.TargetContainer,
                        TargetFileName  = attachFile.TargetFileName,
                        FileStream      = fileStrem
                    });

                    attachFile.TargetFullName = CryptoBase64.Encryption(response.TargetFullName);
                    ((List <DTO.AttachFile>)Session["AttachFiles"]).Add(attachFile);
                    gv.DataSource = ((List <DTO.AttachFile>)Session["AttachFiles"]);
                    gv.DataBind();
                }
            }
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            String targetImage = Request.QueryString["targetImage"].ToString();
            String pdfFile     = CryptoBase64.Decryption(targetImage);

            // Response.Redirect(String.Format("~/PDF/PDF_OIC/{0}", pdfFile));


            //using (FileService.FileTransferServiceClient svc = new FileService.FileTransferServiceClient())
            //{
            //    DownloadFileResponse response = new DownloadFileResponse();

            //    String targetImage =  Request.QueryString["targetImage"].ToString();

            //    response = svc.DownloadFile(new DownloadFileRequest() { TargetContainer = "", TargetFileName = CryptoBase64.Decryption(targetImage) });



            //    if (response.Code == "0000")
            //    {
            //        if (response.ContentType == "application/pdf")
            //        {
            //            ShowDocument(response.FileByteStream, Convert.ToInt64(response.Length), response.ContentType);
            //        }
            //        else
            //        {
            //            ShowImage(response.FileByteStream, Convert.ToInt64(response.Length), response.ContentType);
            //        }

            //    }


            //}
        }
        public static string Encrypt(string data, string password)
        {
            CryptoTripleDES tdes = new CryptoTripleDES();
            tdes.DeriveKeyFromPassword(password, null, 1000);
            tdes.EncryptTextU(data);

            CryptoBase64 b64 = new CryptoBase64();
            string encryptedData = b64.Encrypt(tdes.Result);

            return encryptedData;
        }
        public static string Decrypt(string data, string password)
        {
            CryptoBase64 b64 = new CryptoBase64();
            b64.Decrypt(data);

            CryptoTripleDES tdes = new CryptoTripleDES();
            tdes.DeriveKeyFromPassword(password, null, 1000);
            string originalData = tdes.DecryptTextU(b64.Result);

            return originalData;
        }
Exemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request["PostReceipt"] != null)
            {
                String[] result = CryptoBase64.Decryption(Request["PostReceipt"]).Split('|');

                if (result.Length == 3)
                {
                    ViewState["username"] = result[0];
                    ViewState["filepath"] = result[2];
                    txtUserName.Text      = result[0];
                }
            }
        }
Exemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            using (FileService.FileTransferServiceClient svc = new FileService.FileTransferServiceClient())
            {
                try
                {
                    String targetImage = Request.QueryString["targetImage"].ToString();

                    DownloadFileResponse response = svc.DownloadFile(new DownloadFileRequest()
                    {
                        TargetContainer = "", TargetFileName = CryptoBase64.Decryption(targetImage)
                    });

                    if (response.Code == "0000")
                    {
                        Int32  index    = response.FileName.LastIndexOf(@"\");
                        String filename = response.FileName.Substring((index > 0) ? index + 1 : 0);
                        if (response.ContentType == Utils.ContentTypeHelper.MimeType(".pdf") ||
                            response.ContentType == Utils.ContentTypeHelper.MimeType(".doc") ||
                            response.ContentType == Utils.ContentTypeHelper.MimeType(".docx") ||
                            response.ContentType == Utils.ContentTypeHelper.MimeType(".xls") ||
                            response.ContentType == Utils.ContentTypeHelper.MimeType(".xlsx"))

                        {
                            ShowDocument(response.FileByteStream, Convert.ToInt64(response.Length), response.ContentType, filename);
                        }
                        else if (response.ContentType == "application/octet-stream" &&
                                 (filename.Substring(filename.LastIndexOf('.')) == ".docx" ||
                                  filename.Substring(filename.LastIndexOf('.')) == ".doc" ||
                                  filename.Substring(filename.LastIndexOf('.')) == ".xls" ||
                                  filename.Substring(filename.LastIndexOf('.')) == ".xlsx"
                                 ))
                        {
                            ShowDocument(response.FileByteStream, Convert.ToInt64(response.Length),
                                         Utils.ContentTypeHelper.MimeType(filename.Substring(filename.LastIndexOf('.'))), filename);
                        }
                        else
                        {
                            ShowImage(response.FileByteStream, Convert.ToInt64(response.Length), response.ContentType, filename);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(ex.Message);
                }
            }
        }
Exemplo n.º 8
0
        public String LinkRecipt(IAS.DAL.Interfaces.IIASPersonEntities ctx)
        {
            AG_IAS_USERS user = ctx.AG_IAS_USERS.FirstOrDefault(a => a.USER_ID == CREATE_BY);

            if (user != null)
            {
                String urlroot     = ConfigurationManager.AppSettings["WebPublicUrl"].ToString();
                String requestdata = CryptoBase64.Encryption(String.Format("{0}||{1}", user.USER_NAME, FilePath));

                return(String.Format("{0}UserControl/ViewFile.aspx?PostReceipt={1}", urlroot, requestdata));
            }
            else
            {
                return("ไม่พบข้อมูลของเจ้าของใบสั่งจ่าย กรุณาติดต่อผู้ดูแลระบบ");
            }
        }
Exemplo n.º 9
0
        public void OnLoad_GetRequestTest()
        {
            String[] result = CryptoBase64.Decryption(Request).Split('|');

            String username = "";
            String filepath = "";

            if (result.Length == 3)
            {
                username = result[0];
                filepath = result[2];
            }

            Assert.AreEqual(username, "2717330117871");
            Assert.AreEqual(filepath, @"Receipt\2717330117871\2717330117871_12122e41300037.pdf");
        }
Exemplo n.º 10
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         if (Request["req"] != null && Request["mode"] != null)
         {
             String path = CryptoBase64.Decryption(Request["req"].ToString());
             String mode = Request["mode"];
             if (mode == "P")
             {
                 Print(path);
             }
             else
             {
                 Download(path);
             }
         }
     }
 }
Exemplo n.º 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            using (FileService.FileTransferServiceClient svc = new FileService.FileTransferServiceClient())
            {
                DownloadFileResponse response = new DownloadFileResponse();

                String targetImage = Request.QueryString["targetImage"].ToString();

                response = svc.DownloadFile(new DownloadFileRequest()
                {
                    TargetContainer = "", TargetFileName = CryptoBase64.Decryption(targetImage)
                });


                if (response.Code == "0000")
                {
                    ShowImage(response.FileByteStream, Convert.ToInt64(response.Length), response.ContentType);
                }
            }
        }
Exemplo n.º 12
0
        protected void btnOk_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtUserName.Text) && !string.IsNullOrEmpty(txtPassword.Text))
            {
                BLL.PersonBiz biz = new BLL.PersonBiz();

                var res = biz.UserAuthen(txtUserName.Text, txtPassword.Text, false, "");
                if (res.IsError)
                {
                    UCModalPopupError.ShowMessageError = res.ErrorMsg;

                    UCModalPopupError.ShowModalError();
                    UpdatePanelForgetPassword.Update();
                    return;
                }
                else
                {
                    if (ViewState["filepath"] != null)
                    {
                        Response.Redirect(String.Format("~/UserControl/ViewFile.aspx?targetImage={0}", CryptoBase64.Encryption(ViewState["filepath"].ToString())));
                    }

                    return;
                }
            }
            else
            {
                UCModalPopupError.ShowMessageError = SysMessage.PleaseInputFill;
                UCModalPopupError.ShowModalError();
                UpdatePanelForgetPassword.Update();
            }
        }
Exemplo n.º 13
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            MoveFileResponse response = new MoveFileResponse();

            try
            {
                using (svc = new FileService.FileTransferServiceClient())
                {
                    IList <DTO.AttachFile> attachFiles = ((IList <DTO.AttachFile>)Session["AttachFiles"]);

                    foreach (DTO.AttachFile item in attachFiles)
                    {
                        String target = AttachFileContainer + @"\" + item.ID;
                        response = svc.MoveFile(new MoveFileRequest()
                        {
                            CurrentContainer = "",
                            CurrentFileName  = CryptoBase64.Decryption(item.TargetFullName),
                            TargetContainer  = target,
                            TargetFileName   = item.TargetFileName
                        });

                        if (response.Code != "0000")
                        {
                            throw new ApplicationException(response.Message);
                        }

                        item.TargetFullName = response.TargetFullName;
                    }

                    gv.DataSource = attachFiles;
                    gv.DataBind();
                }
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
                response.Code    = "0001";
            }



            //IList<DTO.AttachFile> attachFiles = ((IList<DTO.AttachFile>)Session["AttechFiles"]).ToList();
            //foreach (DTO.AttachFile item in AttachFiles)
            //{
            ////svc = new FileService.FileTransferServiceClient();
            //svc = new FileService.FileTransferServiceClient();
            //UploadFileResponse response = new UploadFileResponse();

            //string res = svc.UploadFile(item.TargetFolder, item.ID, item.DataStream, out response.Code, out response.Message, out response.Certificate);
            //BLL.FileBiz biz = new BLL.FileBiz();
            //string targetFolder = IAS.BLL.Helpers.GenerateIdHelper.GetGenAutoId();
            ////biz.UploadToTemp(fUpload.PostedFile.InputStream, fUpload.FileName, targetFolder, fUpload.FileName);
            //biz.UploadToTemp(item.DataStream, item.FileName, item.TargetFolder, item.FileName);
            //Response.Write("Success");

            //IAS.FileService.FileUploadMessage fileUploadMessage = new IAS.FileService.FileUploadMessage();

            //var res = new DTO.ResponseService<string>();
            //var resMsg = new FileService.FileUploadMessage();
            //try
            //{
            //    resMsg.FileByteStream = item.DataStream;
            //    resMsg.Metadata = new FileMetaData
            //    {
            //        localFilename = item.FileName,
            //        remoteFilename = item.ID,
            //        targetFolder = string.Format(item.FileName + @"\{0}\", item.ID),
            //    };

            //    svc.UploadFile(ref resMsg.Metadata, ref resMsg.FileByteStream);
            //    res.DataResponse = resMsg.Metadata.resMsg;
            //}
            //catch (Exception ex)
            //{
            //    res.ErrorMsg = "กรุณาติดต่อผู้ดูแลระบบ"; // +resMsg.Metadata.resMsg;
            //}

            //}
        }