public void Test_autoSelect_2() { // page 32 例子 Assert.AreEqual( CompactionScheme.Integer, Compress.AutoSelectCompressMethod("1203")); }
public int addDespatchFromServiceAndSaveContentOnDisk(DESPATCHADVICE[] despatchArr, string direction) { DespatchAdvices despatchAdvice; using (DatabaseContext databaseContext = new DatabaseContext()) { foreach (var despatch in despatchArr) { despatchAdvice = new DespatchAdvices(); despatchAdvice.ID = despatch.ID; despatchAdvice.uuid = despatch.UUID; despatchAdvice.direction = direction; despatchAdvice.issueDate = Convert.ToDateTime(despatch.DESPATCHADVICEHEADER.ISSUE_DATE); despatchAdvice.profileId = despatch.DESPATCHADVICEHEADER.PROFILEID; despatchAdvice.senderVkn = despatch.DESPATCHADVICEHEADER.SENDER.VKN; despatchAdvice.cDate = despatch.DESPATCHADVICEHEADER.CDATE; despatchAdvice.envelopeIdentifier = despatch.DESPATCHADVICEHEADER.ENVELOPE_IDENTIFIER; despatchAdvice.status = despatch.DESPATCHADVICEHEADER.STATUS; despatchAdvice.gibStatusCode = despatch.DESPATCHADVICEHEADER.GIB_STATUS_CODE; despatchAdvice.gibStatusDescription = despatch.DESPATCHADVICEHEADER.GIB_STATUS_DESCRIPTION; despatchAdvice.folderPath = FolderControl.createDespatchDocPath(despatch.ID, direction, nameof(EI.DocumentType.XML)); despatchAdvice.issueTime = despatch.DESPATCHADVICEHEADER.ISSUE_TIME; despatchAdvice.shipmentDate = despatch.DESPATCHADVICEHEADER.ACTUAL_SHIPMENT_DATE; despatchAdvice.shipmentTime = despatch.DESPATCHADVICEHEADER.ACTUAL_SHIPMENT_TIME; despatchAdvice.typeCode = despatch.DESPATCHADVICEHEADER.TYPE_CODE; despatchAdvice.statusCode = despatch.DESPATCHADVICEHEADER.STATUS_CODE; FolderControl.writeFileOnDiskWithString(Encoding.UTF8.GetString(Compress.UncompressFile(despatch.CONTENT.Value)), despatchAdvice.folderPath); databaseContext.despatchAdvices.Add(despatchAdvice); } return(databaseContext.SaveChanges()); } }
public void PrepareData() { // full dataset https://github.com/le-scientifique/torchDatasets/raw/master/dbpedia_csv.tar.gz var url = "https://raw.githubusercontent.com/SciSharp/TensorFlow.NET/master/data/dbpedia_subset.zip"; Web.Download(url, dataDir, "dbpedia_subset.zip"); Compress.UnZip(Path.Combine(dataDir, "dbpedia_subset.zip"), Path.Combine(dataDir, "dbpedia_csv")); Console.WriteLine("Building dataset..."); var(x, y) = (new int[0][], new int[0]); if (ModelName == "char_cnn") { (x, y, alphabet_size) = DataHelpers.build_char_dataset(TRAIN_PATH, "char_cnn", CHAR_MAX_LEN); } else { var word_dict = DataHelpers.build_word_dict(TRAIN_PATH); vocabulary_size = len(word_dict); (x, y) = DataHelpers.build_word_dataset(TRAIN_PATH, word_dict, WORD_MAX_LEN); } Console.WriteLine("\tDONE "); var(train_x, valid_x, train_y, valid_y) = train_test_split(x, y, test_size: 0.15f); Console.WriteLine("Training set size: " + train_x.shape[0]); Console.WriteLine("Test set size: " + valid_x.shape[0]); }
public void ApiTest() { Hashtable Parameters = new Hashtable(); Parameters.Add("channel", "qupiaowang"); Parameters.Add("source", "WECHAT"); Parameters.Add("key", "BEE5390FB3054D6503F4CF9EB5E77039"); StringBuilder sb = new StringBuilder(); ArrayList akeys = new ArrayList(Parameters.Keys); akeys.Sort(); foreach (string k in akeys) { string v = (string)Parameters[k]; sb.Append(k + "=" + v + "&"); } sb.Remove(sb.Length - 1, 1); string sign = Encrypt.Md5(sb.ToString()); HttpClient client = new HttpClient(); var result = client .AddHeader("OpenRu", "qupiaowang") .AddHeader("OpenRs", "WECHAT") .AddHeader("Authorization", "basic " + sign.ToUpper()) .AddHeader("req-source", "qupiao") .Get("http://120.76.163.32:9013/api/order/5EB71B97-D3E1-49E8-95D2-A82D0147BD0A/1/10") .ToString(); var json = Compress.GZipDecompress(result); }
public void CompressGivenStringTestWithLowerAndUpperCaseLetters() { string s = "aaabbFFFAAABBB"; Compress c = new Compress(); c.CompressGivenString(s).Should().Be("a3b2F3A3B3"); }
public int addCreditNoteToDbAndSaveContentOnDisk(CREDITNOTE[] creditNoteArr, string isDraft) { CreditNotes CreditNote; using (DatabaseContext databaseContext = new DatabaseContext()) { foreach (var creditNotes in creditNoteArr) { CreditNote = new CreditNotes(); CreditNote.CreditNoteID = creditNotes.ID; CreditNote.uuid = creditNotes.UUID; CreditNote.customerTitle = creditNotes.HEADER.CUSTOMER.NAME; CreditNote.customerIdentifier = creditNotes.HEADER.CUSTOMER.IDENTIFIER; CreditNote.profileID = creditNotes.HEADER.PROFILE_ID.ToString(); CreditNote.status = creditNotes.HEADER.STATUS; CreditNote.statusCode = creditNotes.HEADER.STATUS_CODE; CreditNote.statusDesc = creditNotes.HEADER.STATUS_DESCRIPTION; CreditNote.cDate = creditNotes.HEADER.CDATE; CreditNote.issueDate = creditNotes.HEADER.ISSUE_DATE; CreditNote.email = creditNotes.HEADER.EMAIL != null?creditNotes.HEADER.EMAIL.First() : null; CreditNote.emailStatusCode = creditNotes.HEADER.EMAIL_STATUS_CODE; CreditNote.isDraft = isDraft; CreditNote.folderPath = FolderControl.CreditNoteFolderPath + CreditNote.CreditNoteID + "." + nameof(EI.DocumentType.XML); FolderControl.writeFileOnDiskWithString(Encoding.UTF8.GetString(Compress.UncompressFile(creditNotes.CONTENT.Value)), CreditNote.folderPath); databaseContext.creditNotes.Add(CreditNote); } return(databaseContext.SaveChanges()); } }
public void CompressGivenStringTestWithUniqueChars() { string s = "abcdefgh"; Compress c = new Compress(); c.CompressGivenString(s).Should().Be("abcdefgh"); }
public void CompressGivenStringTest() { string s = "aaabbbccddeeeffff"; Compress c = new Compress(); c.CompressGivenString(s).Should().Be("a3b3c2d2e3f4"); }
public void Write() { if (compressed) { // compress data byte[] uncompData = Arrays.UshortToByte(data); byte[] compData = Compress.CompLZ77(uncompData); int newLen = compData.Length; // write new data if (newLen <= origLen) { int offset = rom.ReadPtr(pointer); rom.ArrayToRom(compData, 0, offset, newLen); } else { int offset = rom.WriteToEnd(compData); rom.WritePtr(pointer, offset); } origLen = newLen; } else { byte[] bytes = Arrays.UshortToByte(data); int offset = rom.ReadPtr(pointer); rom.ArrayToRom(bytes, 0, offset, bytes.Length); } }
public void PrepareData() { if (UseSubset) { var url = "https://raw.githubusercontent.com/SciSharp/TensorFlow.NET/master/data/dbpedia_subset.zip"; Web.Download(url, dataDir, "dbpedia_subset.zip"); Compress.UnZip(Path.Combine(dataDir, "dbpedia_subset.zip"), Path.Combine(dataDir, "dbpedia_csv")); } else { string url = "https://github.com/le-scientifique/torchDatasets/raw/master/dbpedia_csv.tar.gz"; Web.Download(url, dataDir, dataFileName); Compress.ExtractTGZ(Path.Join(dataDir, dataFileName), dataDir); } if (IsImportingGraph) { // download graph meta data var meta_file = model_name + ".meta"; var meta_path = Path.Combine("graph", meta_file); if (File.GetLastWriteTime(meta_path) < new DateTime(2019, 05, 11)) { // delete old cached file which contains errors Console.WriteLine("Discarding cached file: " + meta_path); File.Delete(meta_path); } var url = "https://raw.githubusercontent.com/SciSharp/TensorFlow.NET/master/graph/" + meta_file; Web.Download(url, "graph", meta_file); } }
/// <summary> /// 压缩文件并输出 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnCompress_Click(object sender, EventArgs e) { if (txtFile.Text != "") { if (txtE.Text != "") { double temp; if (double.TryParse(txtE.Text, out temp)) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "Generate Files (*.gen)|*.gen|" + "All files (*.*)|*.*"; sfd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); if (sfd.ShowDialog() == DialogResult.OK) { Compress c = new Compress(txtFile.Text, sfd.FileName, temp); } } else { MessageBox.Show("请输入数字!"); } } else { MessageBox.Show("请输入数字!"); } } else { MessageBox.Show("请选择文件!"); } }
public byte[] getCreditNoteWithType(string uuid, CONTENT_TYPE type) { using (new OperationContextScope(CreditNotePortClient.InnerChannel)) { var req = new GetCreditNoteRequest(); //sistemdeki gelen efatura listesi için request parametreleri req.REQUEST_HEADER = RequestHeader.getRequestHeaderCreditNotes; req.CREDITNOTE_SEARCH_KEY = new GetCreditNoteRequestCREDITNOTE_SEARCH_KEY(); req.CREDITNOTE_SEARCH_KEY.UUID = uuid; req.CONTENT_TYPE = type; var response = CreditNotePortClient.GetCreditNote(req); if (response.ERROR_TYPE != null) //error message varsa { return(null); } else //servisten smm getırme islemi basarılıysa { if (response.CREDITNOTE != null && response.CREDITNOTE.Length > 0) //getırılen smm varsa { return(Compress.UncompressFile(response.CREDITNOTE[0].CONTENT.Value)); } return(null);//smm sayısı 0 ancak hata yok } } }
bool hasNextPage; //每一章是否分页 /// <summary> /// 获取章节内容 /// </summary> private void GetContent(bool forceRefresh = false) { //章节页地址 page = textBox_page.Text.Trim(); //非空判断 if (string.IsNullOrEmpty(page)) { return; } //不是强制刷新,如果本地有文件,则读取 if (!forceRefresh) { List <Chapter> tmpList = chapters.Where(c => c.site == page).ToList(); if (tmpList.Count > 0) //寻找一样的章节,根据网址寻找 { string chapter1 = tmpList[0].chapter; string path = Application.StartupPath + "\\SavedNovels\\" + novelName + "\\" + chapter1 + ".novel"; if (File.Exists(path)) //读取本地内容 { label_book.Text = "《" + novelName + "》 " + chapter1; richTextBox1.Focus(); richTextBox1.SelectionStart = 0; //将当期页的信息存入数据库 Chapter chapter = new Chapter(novelName, chapter1, page); UpdateData(chapter); int index = chapters.IndexOf(tmpList[0]); if (index < chapters.Count - 1) //下一章地址 { next_page = chapters[index + 1].site; } if (index > 0) //上一章地址 { preview_page = chapters[index - 1].site; } byte[] bytes = File.ReadAllBytes(path); string text = Compress.DecompressString(bytes); if (text != null) { richTextBox1.Text = text; } else //解压失败,有可能是未压缩,也有可能是数据损坏 { richTextBox1.Text = Encoding.UTF8.GetString(bytes); } return; } } } richTextBox1.Text = ""; label_book.Text = "获取中……"; textBox_page.Enabled = false; button1.Enabled = false; button_next.Enabled = false; button_pre.Enabled = false; string url = GetContentPage(page); //章节页面地址 tools.GetHtmlByThread(url, GetContentCode); }
public int addSmmToDbAndSaveContentOnDisk(SMM[] smmArr) { SelfEmploymentReceipts selfEmployment; using (DatabaseContext databaseContext = new DatabaseContext()) { foreach (var smm in smmArr) { selfEmployment = new SelfEmploymentReceipts(); selfEmployment.smmID = smm.ID; selfEmployment.uuid = smm.UUID; selfEmployment.customerTitle = smm.HEADER.CUSTOMER.NAME; selfEmployment.customerID = smm.HEADER.CUSTOMER.IDENTIFIER; selfEmployment.profileID = smm.HEADER.PROFILE_ID.ToString(); selfEmployment.status = smm.HEADER.STATUS; selfEmployment.statusCode = smm.HEADER.STATUS_CODE; selfEmployment.statusDesc = smm.HEADER.STATUS_DESCRIPTION; selfEmployment.cDate = smm.HEADER.CDATE; selfEmployment.issueDate = smm.HEADER.ISSUE_DATE; selfEmployment.email = smm.HEADER.EMAIL != null?smm.HEADER.EMAIL.First() : null; selfEmployment.emailStatusCode = smm.HEADER.EMAIL_STATUS_CODE; selfEmployment.folderPath = FolderControl.smmFolderPath + smm.ID + "." + nameof(EI.DocumentType.XML); FolderControl.writeFileOnDiskWithString(Encoding.UTF8.GetString(Compress.UncompressFile(smm.CONTENT.Value)), selfEmployment.folderPath); databaseContext.selfEmployments.Add(selfEmployment); } return(databaseContext.SaveChanges()); } }
private void UploadBidFile() { try { string sourcePath = AppDirectory.Temp_Dir(this.gptp.gpId); string destPath = Path.Combine(AppDirectory.Temp(), this.gptp.gpId + ".zip"); Compress.CreateZipFile(sourcePath, destPath); baseUserWebDO loginResponse = Cache.GetInstance().GetValue <baseUserWebDO>("login"); bool result = gpTenderFileService.UploadFile(destPath, loginResponse.auID, this.gptp.gtpId, this.gptp.gpId); if (result) { MetroMessageBox.Show(this, "上传成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MetroMessageBox.Show(this, "上传失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { log.Error(ex); MetroMessageBox.Show(this, "上传失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// basarılıysa ınv content doner degılse null /// </summary> public byte[] getInvoiceType(string invoiceUuid, string documentType, string direction) { using (new OperationContextScope(eInvoiceOIBPortClient.InnerChannel)) { GetInvoiceWithTypeRequest req = new GetInvoiceWithTypeRequest(); req.REQUEST_HEADER = RequestHeader.getRequestHeaderOib; req.REQUEST_HEADER.COMPRESSED = nameof(EI.ActiveOrPasive.Y); req.INVOICE_SEARCH_KEY = InvoiceSearchKey.invoiceSearchKeyGetInvoiceWithType; req.INVOICE_SEARCH_KEY.READ_INCLUDED = true; req.INVOICE_SEARCH_KEY.READ_INCLUDEDSpecified = true; req.INVOICE_SEARCH_KEY.UUID = invoiceUuid; req.INVOICE_SEARCH_KEY.TYPE = documentType;//XML,PDF req.HEADER_ONLY = EI.ActiveOrPasive.N.ToString(); req.INVOICE_SEARCH_KEY.DIRECTION = direction; if (direction == nameof(EI.Direction.DRAFT)) { req.INVOICE_SEARCH_KEY.DIRECTION = nameof(EI.Direction.OUT); req.INVOICE_SEARCH_KEY.DRAFT_FLAG = nameof(EI.ActiveOrPasive.Y); } INVOICE[] invoice = eInvoiceOIBPortClient.GetInvoiceWithType(req); if (invoice == null || invoice.Length != 0) { return(Compress.UncompressFile(invoice[0].CONTENT.Value)); } return(null); } }
private static IList Pr(string targetFile, PreHandler preHandler) { Compress compress = (Compress)preHandler; compress.Process(targetFile); return(new List <object>()); }
/// <summary> /// 下载完成 /// </summary> void DownloadSucceed(string file_name) { lock (lock_obj_) { bool is_compress = Compress.IsCompressFile(file_name); string assetbundle = is_compress ? Compress.GetDefaultFileName(file_name) : file_name; if (ImcompleteDownloads.Contains(assetbundle)) { ImcompleteDownloads.Remove(assetbundle); } CompleteDownloads.Add(assetbundle); //判断是否需要解压文件 if (is_compress) { // 解压文件 string in_file = Root + "/" + file_name; string out_file = Root + "/" + assetbundle; Compress.DecompressFile(in_file, out_file); // 删除压缩包 System.IO.File.Delete(in_file); } } }
public override void PrepareData() { Directory.CreateDirectory(dir); // get model file string url = "https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip"; Web.Download(url, dir, "inception5h.zip"); Compress.UnZip(Path.Join(dir, "inception5h.zip"), dir); // download sample picture Directory.CreateDirectory(Path.Join(dir, "img")); url = $"https://raw.githubusercontent.com/tensorflow/tensorflow/master/tensorflow/examples/label_image/data/grace_hopper.jpg"; Web.Download(url, Path.Join(dir, "img"), "grace_hopper.jpg"); url = $"https://raw.githubusercontent.com/SciSharp/TensorFlow.NET/master/data/shasta-daisy.jpg"; Web.Download(url, Path.Join(dir, "img"), "shasta-daisy.jpg"); // load image file var files = Directory.GetFiles(Path.Join(dir, "img")); for (int i = 0; i < files.Length; i++) { var nd = ReadTensorFromImageFile(files[i]); file_ndarrays.Add(nd); } }
public void TestCompress() { Random rand = new Random(); int[] sizes = new int[1000]; for (int i = 0; i < sizes.Length; ++i) { sizes[i] = rand.Next(10 * 1024); } foreach (int size in sizes) { BufferCodec bufcp = new BufferCodec(); Compress cp = new Compress(bufcp); byte[] buffer = new byte[size]; rand.NextBytes(buffer); cp.update(buffer, 0, buffer.Length); cp.flush(); BufferCodec bufdp = new BufferCodec(); Decompress dp = new Decompress(bufdp); dp.update(bufcp.Buffer.Bytes, bufcp.Buffer.ReadIndex, bufcp.Buffer.Size); dp.flush(); Assert.AreEqual(ByteBuffer.Wrap(buffer), bufdp.Buffer); } }
public byte[] getReadFromEArchive(string uuid, string docType) { using (new OperationContextScope(eArchiveInvoicePortClient.InnerChannel)) { ArchiveInvoiceReadRequest req = new ArchiveInvoiceReadRequest(); req.REQUEST_HEADER = RequestHeader.getRequestHeaderArchive; req.INVOICEID = uuid; req.PORTAL_DIRECTION = nameof(EI.Direction.OUT); req.PROFILE = docType; if (docType == nameof(EI.DocumentType.XML)) { req.PROFILE = "EA_CUST_XML_SIGNED";//İmzalı XML indirir } var res = eArchiveInvoicePortClient.ReadFromArchive(req); if (res.REQUEST_RETURN != null && res.REQUEST_RETURN.RETURN_CODE == 0) { if (res.INVOICE.Length != 0) { //contentı yazdır //xml olarak ındırde ıkı kere ziplenmıs bu yuzden ıkı kere cmpres cagırmamız gerewk if (docType != nameof(EI.DocumentType.PDF)) { return(Compress.UncompressFile(Compress.UncompressFile(res.INVOICE[0].Value))); } return(Compress.UncompressFile(res.INVOICE[0].Value)); } } //servisten uuid aıt content getırılemedıyse null doner return(null); } }
public void testZipMsg() { byte[] outBytes = null; uint outSize = 0; byte[] inBytes = null; uint inSize = 0; ByteBuffer pByteBuffer = new ByteBuffer(); UnitTestStrCmd pUnitTestCmd = new UnitTestStrCmd(); // 发送第一个数据包 pUnitTestCmd.testStr = "测试数据"; pByteBuffer.clear(); pUnitTestCmd.serialize(pByteBuffer); Compress.CompressData(pByteBuffer.dynBuff.buff, 0, pByteBuffer.length, ref outBytes, ref outSize); Compress.DecompressData(outBytes, 0, outSize, ref inBytes, ref inSize); pByteBuffer.clear(); pByteBuffer.writeBytes(inBytes, 0, inSize); pByteBuffer.position = 0; pUnitTestCmd.derialize(pByteBuffer); UAssert.DebugAssert(pUnitTestCmd.testStr != "测试数据"); }
public void Test_autoSelect_1() { // page 31 例子 Assert.AreEqual( CompactionScheme.Integer, Compress.AutoSelectCompressMethod("123456789012")); }
static public void Insert <T>(string key, T value, string filelocation) { Interlocked.Increment(ref Cache.counter); SimpleObject simpleObject = new SimpleObject { Key = key, Value = value, FileLocation = filelocation }; sendQueue.Add(simpleObject); var data = sendQueue.Take(); //this blocks if there are no items in the queue. //Add to cache lock (Cache.LockObject) { Cache.CacheDic[filelocation + key] = simpleObject; } ThreadPool.QueueUserWorkItem(state => { lock (Cache.LockObject) { Storage.WritetoStorage(data.Key, Compress.CompressGZip(ConvertHelper.ObjectToByteArray(value)), data.FileLocation); } }); }
/// <summary> /// basarılısa ırsalıye contentı doner, basarısızsa null /// </summary> /// <returns></returns> public string getDespatchXmlContentFromService(string uuid, string direction) { using (new OperationContextScope(eDespatchPortClient.InnerChannel)) { GetDespatchAdviceRequest req = new GetDespatchAdviceRequest(); req.HEADER_ONLY = EI.ActiveOrPasive.N.ToString(); req.REQUEST_HEADER = RequestHeader.getRequestHeaderDespatch; req.SEARCH_KEY = SearchKey.getSearchKeyDespatch; req.SEARCH_KEY.READ_INCLUDED = true; //okunmus olabilir req.SEARCH_KEY.READ_INCLUDEDSpecified = true; req.SEARCH_KEY.UUID = uuid; req.SEARCH_KEY.DIRECTION = direction; GetDespatchAdviceResponse response = eDespatchPortClient.GetDespatchAdvice(req); if (response.ERROR_TYPE == null) { if (response.DESPATCHADVICE != null && response.DESPATCHADVICE.Length > 0 && response.DESPATCHADVICE[0].CONTENT != null && response.DESPATCHADVICE[0].CONTENT.Value != null) //getırılen ırsalıye varsa { return(Encoding.UTF8.GetString(Compress.UncompressFile(response.DESPATCHADVICE[0].CONTENT.Value))); } } return(null); } }
public void PrepareData() { string url = "https://github.com/le-scientifique/torchDatasets/raw/master/dbpedia_csv.tar.gz"; Web.Download(url, dataDir, dataFileName); Compress.ExtractTGZ(Path.Join(dataDir, dataFileName), dataDir); }
public override void PrepareData() { string url = "https://github.com/SciSharp/SciSharp-Stack-Examples/raw/master/data/data_CnnInYourOwnData.zip"; Directory.CreateDirectory(Config.Name); Web.Download(url, Config.Name, "data_CnnInYourOwnData.zip"); Compress.UnZip(Config.Name + "\\data_CnnInYourOwnData.zip", Config.Name); FillDictionaryLabel(Config.Name + "\\train"); ArrayFileName_Train = Directory.GetFiles(Config.Name + "\\train", "*.*", SearchOption.AllDirectories); ArrayLabel_Train = GetLabelArray(ArrayFileName_Train); ArrayFileName_Validation = Directory.GetFiles(Config.Name + "\\validation", "*.*", SearchOption.AllDirectories); ArrayLabel_Validation = GetLabelArray(ArrayFileName_Validation); ArrayFileName_Test = Directory.GetFiles(Config.Name + "\\test", "*.*", SearchOption.AllDirectories); ArrayLabel_Test = GetLabelArray(ArrayFileName_Test); //shuffle array (ArrayFileName_Train, ArrayLabel_Train) = ShuffleArray(ArrayLabel_Train.Length, ArrayFileName_Train, ArrayLabel_Train); (ArrayFileName_Validation, ArrayLabel_Validation) = ShuffleArray(ArrayLabel_Validation.Length, ArrayFileName_Validation, ArrayLabel_Validation); (ArrayFileName_Test, ArrayLabel_Test) = ShuffleArray(ArrayLabel_Test.Length, ArrayFileName_Test, ArrayLabel_Test); LoadImagesToNDArray(); }
public void addContentPropertiesToList(ArchiveContentPropertiesModel propertiesModel) { EARSIV_PROPERTIES archiveProperties = new EARSIV_PROPERTIES(); archiveProperties.SUB_STATUS = SUB_STATUS_VALUE.NEW; // archiveProperties.SERI = seriName; //burayı dıkkate almıyor neden ? if (propertiesModel.mail != null) //null degılse maıl gonderılmek ıstıyoddur,nullsa ıstemıyo { archiveProperties.EARSIV_EMAIL_FLAG = FLAG_VALUE.Y; archiveProperties.EARSIV_EMAIL = new string[] { propertiesModel.mail }; } if (propertiesModel.archiveType == EARSIV_TYPE_VALUE.NORMAL.ToString()) { archiveProperties.EARSIV_TYPE = EARSIV_TYPE_VALUE.NORMAL; } else { archiveProperties.EARSIV_TYPE = EARSIV_TYPE_VALUE.INTERNET; } ArchiveInvoiceExtendedContentINVOICE_PROPERTIES contentProps = new ArchiveInvoiceExtendedContentINVOICE_PROPERTIES(); contentProps.EARSIV_PROPERTIES = archiveProperties; contentProps.EARSIV_FLAG = FLAG_VALUE.Y; contentProps.INVOICE_CONTENT = new base64Binary { Value = Compress.compressFile(propertiesModel.content) }; contentPropsList.Add(contentProps); }
/// <summary> /// 下载 /// </summary> bool Download(string assetbundlename) { lock (lock_obj_) { var ab = resources_manifest_.Find(assetbundlename); if (ab == null) { Debug.LogWarning("AssetBundleDownloader.Download - AssetBundleName is invalid."); return(true); } string file_name = ab.IsCompress ? Compress.GetCompressFileName(assetbundlename) : assetbundlename; if (!IsDownLoading(file_name)) { HttpAsyDownload d = GetIdleDownload(true); if (d == null) { return(false); } d.Start(Root, file_name, _DownloadNotify, _DownloadError); } return(true); } }
/// <summary> /// basarılıysa ınvoice content doner basarısızsa null doner /// </summary> public string getInvoiceWithUuidOnService(string uuid, string direction) { using (new OperationContextScope(eInvoiceOIBPortClient.InnerChannel)) { GetInvoiceRequest req = new GetInvoiceRequest(); //sistemdeki gelen efatura listesi için request parametreleri req.REQUEST_HEADER = RequestHeader.getRequestHeaderOib; req.REQUEST_HEADER.COMPRESSED = EI.ActiveOrPasive.Y.ToString(); req.INVOICE_SEARCH_KEY = InvoiceSearchKey.invoiceSearchKeyGetInvoice; req.INVOICE_SEARCH_KEY.UUID = uuid; req.INVOICE_SEARCH_KEY.READ_INCLUDED = true; req.INVOICE_SEARCH_KEY.READ_INCLUDEDSpecified = true; req.HEADER_ONLY = EI.ActiveOrPasive.N.ToString(); if (direction.Equals(nameof(EI.Direction.DRAFT))) //direction taslak fatura ıse { req.INVOICE_SEARCH_KEY.DIRECTION = EI.Direction.OUT.ToString(); req.INVOICE_SEARCH_KEY.DRAFT_FLAG = EI.ActiveOrPasive.Y.ToString(); } else { req.INVOICE_SEARCH_KEY.DIRECTION = direction; } INVOICE[] invoiceArray = eInvoiceOIBPortClient.GetInvoice(req); if (invoiceArray != null && invoiceArray.Length != 0) { //getirilen faturanın contentını zipten cıkar , string halınde dondur return(Encoding.UTF8.GetString(Compress.UncompressFile(invoiceArray[0].CONTENT.Value))); } return(null); } }
static void Main(string[] args) { try { if (args.Length == 0) { throw new Exception("syntax: compress [path]"); } string[] files = Directory.GetFiles(args[0], "*.*", SearchOption.AllDirectories); Console.WriteLine("Embedding {0} files.", files.Length); ArrayList filesArray = new ArrayList(files.Length); foreach (string file in files) { string relativePath = file.Replace(args[0], "").TrimStart('\\'); Console.WriteLine(relativePath); filesArray.Add(new string[] { file, relativePath}); } string cabname = Path.Combine(Environment.CurrentDirectory, "DEMO_%d.CAB"); Console.WriteLine("Writing {0} file(s) to {1}", files.Length, cabname); Compress cab = new Compress(); long totalSize = 0; long totalFiles = 0; cab.evFilePlaced += delegate(string s_File, int s32_FileSize, bool bContinuation) { if (!bContinuation) { totalFiles++; totalSize += s32_FileSize; Console.WriteLine(String.Format(" {0} - {1}", s_File, s32_FileSize)); } return 0; }; cab.CompressFileList(filesArray, cabname, true, true, 64 * 1024 * 1024); Console.WriteLine("Compressed {0} files, {1} byte(s)", totalFiles, totalSize); } catch (Exception ex) { Console.Error.WriteLine("ERROR: {0}", ex.Message); } }
public MessageInspector(Compress compress) { _compress = compress; _compressionProvider = new SharpCompressionProvider(); }
/// <summary> /// </summary> /// <param name="blobData"></param> /// <param name="appContentType"></param> /// <param name="Base64TokenApplication"></param> /// <returns></returns> public OperationResult AssembleTokenApplication(byte[] blobData, out string appContentType, out string Base64TokenApplication) { appContentType = null; Base64TokenApplication = null; string _tempFolder = null; Extract _cabExtract = new Extract(); Compress _cabCompress = new Compress(); try { _tempFolder = _getTempFolder(); _cabExtract.ExtractFile(_getTemplateFile(), _tempFolder); _writeBlobFile(_tempFolder, blobData); _cabCompress.SwitchCompression(false); // pocket´s withdout compression //_cabCompress.SetEncryptionKey(""); _cabCompress.CompressFolder(_tempFolder, _tempFolder + cAPPFILESYSTEM_NAME, "", true, true, 0x7FFFFFFF); using (Stream st = File.Open(_tempFolder + cAPPFILESYSTEM_NAME, FileMode.Open, FileAccess.Read)) { using (BinaryReader br = new BinaryReader(st, Encoding.Default)) { Base64TokenApplication = Convert.ToBase64String(br.ReadBytes(Convert.ToInt32(br.BaseStream.Length))); appContentType = cCONTENT_TYPE_NAME; } } return OperationResult.Success; } catch { Base64TokenApplication = null; return OperationResult.Error; } finally { _cabExtract = null; _cabCompress = null; if (Directory.Exists(_tempFolder)) Directory.Delete(_tempFolder, true); } }
public MessageCompressionAttribute(Compress compress) { _compress = compress; }
public Object Clone() { Compress o = new Compress(); o.histptr = histptr; o.legacy_in = legacy_in; Array.Copy(history, o.history, history.Length); Array.Copy(hash, o.hash, hash.Length); return o; }
public static void CreateInstaller(InstallerLinkerArguments args) { args.Validate(); args.WriteLine(string.Format("Creating \"{0}\" from \"{1}\"", args.output, args.template)); System.IO.File.Copy(args.template, args.output, true); System.IO.File.SetAttributes(args.output, System.IO.FileAttributes.Normal); string configFilename = args.config; #region Version Information ConfigFile configfile = new ConfigFile(); configfile.Load(configFilename); // \todo: check XML with XSD, warn if nodes are being dropped // filter the configuration string configTemp = null; if (!string.IsNullOrEmpty(args.processorArchitecture)) { int configurationCount = configfile.ConfigurationCount; int componentCount = configfile.ComponentCount; args.WriteLine(string.Format("Applying processor architecture filter \"{0}\"", args.processorArchitecture)); ProcessorArchitectureFilter filter = new ProcessorArchitectureFilter(args.processorArchitecture); XmlDocument filteredXml = configfile.GetXml(filter); configTemp = configFilename = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); filteredXml.Save(configTemp); configfile.LoadXml(filteredXml); args.WriteLine(string.Format(" configurations: {0} => {1}", configurationCount, configfile.ConfigurationCount)); args.WriteLine(string.Format(" components: {0} => {1}", componentCount, configfile.ComponentCount)); } args.WriteLine(string.Format("Updating binary attributes in \"{0}\"", args.output)); VersionResource rc = new VersionResource(); rc.LoadFrom(args.output); // version information StringFileInfo stringFileInfo = (StringFileInfo)rc["StringFileInfo"]; if (!string.IsNullOrEmpty(configfile.productversion)) { rc.ProductVersion = configfile.productversion; stringFileInfo["ProductVersion"] = configfile.productversion; } if (!string.IsNullOrEmpty(configfile.fileversion)) { rc.FileVersion = configfile.fileversion; stringFileInfo["FileVersion"] = configfile.fileversion; } foreach (FileAttribute attr in configfile.fileattributes) { args.WriteLine(string.Format(" {0}: {1}", attr.name, attr.value)); stringFileInfo[attr.name] = attr.value; } rc.Language = ResourceUtil.NEUTRALLANGID; rc.SaveTo(args.output); #endregion #region Optional Icon // optional icon if (!string.IsNullOrEmpty(args.icon)) { args.WriteLine(string.Format("Embedding icon \"{0}\"", args.icon)); IconFile iconFile = new IconFile(args.icon); List<string> iconSizes = new List<string>(); foreach (IconFileIcon icon in iconFile.Icons) iconSizes.Add(icon.ToString()); args.WriteLine(string.Format(" {0}", string.Join(", ", iconSizes.ToArray()))); IconDirectoryResource iconDirectory = new IconDirectoryResource(iconFile); iconDirectory.Name = new ResourceId(128); iconDirectory.Language = ResourceUtil.NEUTRALLANGID; iconDirectory.SaveTo(args.output); } #endregion #region Manifest if (!string.IsNullOrEmpty(args.manifest)) { args.WriteLine(string.Format("Embedding manifest \"{0}\"", args.manifest)); ManifestResource manifest = new ManifestResource(); manifest.Manifest.Load(args.manifest); manifest.SaveTo(args.output); } #endregion string supportdir = string.IsNullOrEmpty(args.apppath) ? Environment.CurrentDirectory : args.apppath; string templatepath = Path.GetDirectoryName(Path.GetFullPath(args.template)); // create a temporary directory for CABs string cabtemp = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); Directory.CreateDirectory(cabtemp); args.WriteLine(string.Format("Writing CABs to \"{0}\"", cabtemp)); try { #region Prepare CABs long totalSize = 0; List<String> allFilesList = new List<string>(); // embedded files if (args.embed) { args.WriteLine(string.Format("Compressing files in \"{0}\"", supportdir)); Dictionary<string, EmbedFileCollection> all_files = configfile.GetFiles(string.Empty, supportdir); // ensure at least one for additional command-line parameters if (all_files.Count == 0) all_files.Add(string.Empty, new EmbedFileCollection(supportdir)); Dictionary<string, EmbedFileCollection>.Enumerator enumerator = all_files.GetEnumerator(); while (enumerator.MoveNext()) { EmbedFileCollection c_files = enumerator.Current.Value; // add additional command-line files to the root CAB if (string.IsNullOrEmpty(enumerator.Current.Key)) { if (args.embedFiles != null) { foreach (string filename in args.embedFiles) { string fullpath = Path.Combine(args.apppath, filename); c_files.Add(new EmbedFilePair(fullpath, filename)); } } if (args.embedFolders != null) { foreach (string folder in args.embedFolders) { c_files.AddDirectory(folder); } } } if (c_files.Count == 0) continue; c_files.CheckFilesExist(args); c_files.CheckFileAttributes(args); ArrayList files = c_files.GetFilePairs(); // compress new CABs string cabname = string.IsNullOrEmpty(enumerator.Current.Key) ? Path.Combine(cabtemp, "SETUP_%d.CAB") : Path.Combine(cabtemp, string.Format("SETUP_{0}_%d.CAB", enumerator.Current.Key)); Compress cab = new Compress(); long currentSize = 0; cab.evFilePlaced += delegate(string s_File, int s32_FileSize, bool bContinuation) { if (!bContinuation) { totalSize += s32_FileSize; currentSize += s32_FileSize; args.WriteLine(String.Format(" {0} - {1}", s_File, EmbedFileCollection.FormatBytes(s32_FileSize))); } return 0; }; cab.CompressFileList(files, cabname, true, true, args.embedResourceSize); StringBuilder fileslist = new StringBuilder(); fileslist.AppendLine(string.Format("{0} CAB size: {1}", string.IsNullOrEmpty(enumerator.Current.Key) ? "*" : enumerator.Current.Key, EmbedFileCollection.FormatBytes(currentSize))); fileslist.Append(" " + String.Join("\r\n ", c_files.GetFileValuesWithSize(2))); allFilesList.Add(fileslist.ToString()); } } #endregion #region Resources // embed resources IntPtr h = ResourceUpdate.BeginUpdateResource(args.output, false); if (h == IntPtr.Zero) { throw new Win32Exception(Marshal.GetLastWin32Error()); } if (!string.IsNullOrEmpty(args.banner)) { args.WriteLine(string.Format("Embedding banner \"{0}\"", args.banner)); ResourceUpdate.WriteFile(h, new ResourceId("CUSTOM"), new ResourceId("RES_BANNER"), ResourceUtil.NEUTRALLANGID, args.banner); } if (!string.IsNullOrEmpty(args.splash)) { args.WriteLine(string.Format("Embedding splash screen \"{0}\"", args.splash)); ResourceUpdate.WriteFile(h, new ResourceId("CUSTOM"), new ResourceId("RES_SPLASH"), ResourceUtil.NEUTRALLANGID, args.splash); } args.WriteLine(string.Format("Embedding configuration \"{0}\"", configFilename)); ResourceUpdate.WriteFile(h, new ResourceId("CUSTOM"), new ResourceId("RES_CONFIGURATION"), ResourceUtil.NEUTRALLANGID, configFilename); #region Embed Resources EmbedFileCollection html_files = new EmbedFileCollection(args.apppath); if (args.htmlFiles != null) { foreach (string filename in args.htmlFiles) { string fullpath = Path.GetFullPath(filename); if (Directory.Exists(fullpath)) { html_files.AddDirectory(fullpath); } else { html_files.Add(new EmbedFilePair(fullpath, Path.GetFileName(filename))); } } } IEnumerator<EmbedFilePair> html_files_enumerator = html_files.GetEnumerator(); while (html_files_enumerator.MoveNext()) { EmbedFilePair pair = html_files_enumerator.Current; String id = ""; for (int i = 0; i < pair.relativepath.Length; i++) { id += Char.IsLetterOrDigit(pair.relativepath[i]) ? pair.relativepath[i] : '_'; } args.WriteLine(string.Format("Embedding HTML resource \"{0}\": {1}", id, pair.fullpath)); ResourceUpdate.WriteFile(h, new ResourceId("HTM"), new ResourceId(id.ToUpper()), ResourceUtil.NEUTRALLANGID, pair.fullpath); } #endregion #region Embed CABs if (args.embed) { args.WriteLine("Embedding CABs"); foreach (string cabfile in Directory.GetFiles(cabtemp)) { args.WriteLine(string.Format(" {0} - {1}", Path.GetFileName(cabfile), EmbedFileCollection.FormatBytes(new FileInfo(cabfile).Length))); ResourceUpdate.WriteFile(h, new ResourceId("RES_CAB"), new ResourceId(Path.GetFileName(cabfile)), ResourceUtil.NEUTRALLANGID, cabfile); } // cab directory args.WriteLine("Embedding CAB directory"); StringBuilder filesDirectory = new StringBuilder(); filesDirectory.AppendLine(string.Format("Total CAB size: {0}\r\n", EmbedFileCollection.FormatBytes(totalSize))); filesDirectory.AppendLine(string.Join("\r\n\r\n", allFilesList.ToArray())); byte[] filesDirectory_b = Encoding.Unicode.GetBytes(filesDirectory.ToString()); ResourceUpdate.Write(h, new ResourceId("CUSTOM"), new ResourceId("RES_CAB_LIST"), ResourceUtil.NEUTRALLANGID, filesDirectory_b); } #endregion // resource files ResourceFileCollection resources = configfile.GetResources(supportdir); foreach (ResourceFilePair r_pair in resources) { args.WriteLine(string.Format("Embedding resource \"{0}\": {1}", r_pair.id, r_pair.path)); ResourceUpdate.WriteFile(h, new ResourceId("CUSTOM"), new ResourceId(r_pair.id), ResourceUtil.NEUTRALLANGID, r_pair.path); } if (args.mslu) { args.WriteLine("Embedding MSLU unicows.dll"); string unicowsdll = Path.Combine(templatepath, "unicows.dll"); if (! File.Exists(unicowsdll)) unicowsdll = Path.Combine(supportdir, "unicows.dll"); if (! File.Exists(unicowsdll)) unicowsdll = Path.Combine(Environment.CurrentDirectory, "unicows.dll"); if (! File.Exists(unicowsdll)) { throw new Exception(string.Format("Error locating \"{0}\\unicows.dll\"", templatepath)); } ResourceUpdate.WriteFile(h, new ResourceId("CUSTOM"), new ResourceId("RES_UNICOWS"), ResourceUtil.NEUTRALLANGID, unicowsdll); } args.WriteLine(string.Format("Writing {0}", EmbedFileCollection.FormatBytes(totalSize))); if (!ResourceUpdate.EndUpdateResource(h, false)) throw new Win32Exception(Marshal.GetLastWin32Error()); #endregion } finally { if (Directory.Exists(cabtemp)) { args.WriteLine(string.Format("Cleaning up \"{0}\"", cabtemp)); Directory.Delete(cabtemp, true); } if (!string.IsNullOrEmpty(configTemp)) { args.WriteLine(string.Format("Cleaning up \"{0}\"", configTemp)); File.Delete(configTemp); } } args.WriteLine(string.Format("Successfully created \"{0}\" ({1})", args.output, EmbedFileCollection.FormatBytes(new FileInfo(args.output).Length))); }