Exemplo n.º 1
0
        public void Export(Site site, IEnumerable <Label> labels, IEnumerable <string> categories, Stream outputStream)
        {
            if ((labels == null || labels.Count() == 0) && (categories == null || categories.Count() == 0))
            {
                this.ExportLabelsToDisk(site);

                using (ZipFile zipFile = new ZipFile())
                {
                    zipFile.AddSelectedFiles("*.json", new LabelPath(site).PhysicalPath, "");

                    zipFile.Save(outputStream);
                }
            }
            else
            {
                var tempFolder = GetImportExportTempFolder(site);
                Kooboo.IO.IOUtility.DeleteDirectory(tempFolder, true);

                if (labels != null)
                {
                    foreach (var item in labels)
                    {
                        var label = _rawLabelProvider.Get(item);
                        if (label != null)
                        {
                            var storage = GetStorage(GetImportExportLabelFile(site, label.Category));
                            storage.Add(label);
                        }
                    }
                }

                if (categories != null)
                {
                    foreach (var item in categories)
                    {
                        foreach (var label in _rawLabelProvider.GetLabels(site, item).ToArray())
                        {
                            var storage = GetStorage(GetImportExportLabelFile(site, label.Category));
                            storage.Add(label);
                        }
                    }
                }

                using (ZipFile zipFile = new ZipFile())
                {
                    zipFile.AddSelectedFiles("*.json", tempFolder, "");

                    zipFile.Save(outputStream);
                }
                Kooboo.IO.IOUtility.DeleteDirectory(tempFolder, true);
            }
        }
Exemplo n.º 2
0
        private void Compress(string destinationFile, BackupModel model)
        {
            using (ZipFile zip = new ZipFile(destinationFile))
            {
                if (!String.IsNullOrEmpty(_password))
                {
                    zip.Password = _password;
                }

                zip.Encryption = EncryptionAlgorithm.WinZipAes256;
                zip.AddSelectedFiles(SelectedFileQuery(model.BackupFiles), model.SourceDir, model.Name, true);
                zip.Save();
            }
        }
Exemplo n.º 3
0
        public bool ImportApp(string zipPath, MFilesVault vault)
        {
            var zipDirectory = new DirectoryInfo(zipPath);
            var ovault       = MFServerUtility.GetVault(vault);

            foreach (var di in zipDirectory.GetDirectories())
            {
                var targetPath = Path.Combine(Path.GetTempPath(), di.Name + ".zip");
                var zip        = new ZipFile();
                zip.AddSelectedFiles("name!=*.zip and name!=*.pdb and name!=*.log", di.FullName, di.Name, true);
                zip.Save(targetPath);
                ImportApp(targetPath, ovault);
            }
            return(true);
        }
Exemplo n.º 4
0
        public void Export(Kooboo.CMS.Membership.Models.Membership membership, Stream outputStream)
        {
            var physicalPath = _membershipPath.GetMembershipPath(membership);

            using (ZipFile zipFile = new ZipFile(Encoding.UTF8))
            {
                //zipFile.ZipError += new EventHandler<ZipErrorEventArgs>(zipFile_ZipError);

                zipFile.ZipErrorAction = ZipErrorAction.Skip;


                zipFile.AddSelectedFiles("name != *\\~versions\\*.* and name != *\\.svn\\*.* and name != *\\_svn\\*.*", physicalPath, "", true);

                zipFile.Save(outputStream);
            }
        }
Exemplo n.º 5
0
        /// <summary>フォルダ以下を圧縮</summary>
        /// <param name="zipFileToCreate">圧縮ファイル名(zip、exe)</param>
        /// <param name="directoryToZip">圧縮対象フォルダ</param>
        /// <param name="selectionCriteriaString">ファイル選択基準文字列</param>
        /// <param name="rootPathInArchive">書庫内ルートフォルダ</param>
        /// <param name="enc">エンコーディング</param>
        /// <param name="cyp">暗号化</param>
        /// <param name="zipPassword">パスワード</param>
        /// <param name="cmpLv">圧縮レベル</param>
        /// <param name="selfEx">書庫形式(zip形式はnullを指定)</param>
        public void CreateZipFromFolder(
            string zipFileToCreate,
            string directoryToZip,
            string selectionCriteriaString,
            string rootPathInArchive,
            Encoding enc,
            EncryptionAlgorithm cyp,
            string zipPassword,
            CompressionLevel cmpLv,
            SelfExtractorFlavor?selfEx)
        {
            // ZipFileを取得
            ZipFile zip = this.GetZipFile(
                enc, cyp, zipPassword, cmpLv, selfEx);

            using (zip)
            {
                // フィルタ条件を確認
                if (selectionCriteriaString == null || selectionCriteriaString == "")
                {
                    // ● フォルダのアーカイブ
                    zip.AddDirectory(directoryToZip, rootPathInArchive);
                }
                else
                {
                    // ● フォルダのアーカイブ
                    //    ファイルをフィルタして追加
                    //    selectionCriteriaがファイル選択基準文字列
                    zip.AddSelectedFiles(selectionCriteriaString, directoryToZip, rootPathInArchive, true);
                }

                if (selfEx == null)
                {
                    // ZIPファイル
                    zip.Save(zipFileToCreate + ".zip");
                }
                else
                {
                    // 自動解凍書庫
                    zip.SaveSelfExtractor(
                        zipFileToCreate + ".exe",
                        (SelfExtractorFlavor)selfEx);
                }
            }
        }
Exemplo n.º 6
0
    protected void dataGridResults_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int         index = 0;
        GridViewRow row;
        GridView    grid = sender as GridView;

        index = Convert.ToInt32(e.CommandArgument);
        row   = grid.Rows[index];
        string CompanyCode  = "";
        string ClientID     = row.Cells[1].Text;
        string CustomerName = row.Cells[2].Text;
        string PhoneNumber  = row.Cells[4].Text;
        string IDNumber     = row.Cells[6].Text;
        string status       = row.Cells[11].Text;
        Label  lblmsg       = (Label)Master.FindControl("lblmsg");

        if (e.CommandName.Equals("Approve"))
        {
            if (IDNumber != "")
            {
                Server.Transfer("~/AddClientDetails.aspx?CompanyCode=" + CompanyCode + "&ClientID=" + ClientID + "&PhoneNo=" + PhoneNumber + "&Action=" + "Verify");
                //return;
            }
            else
            {
                bll.ShowMessage(lblmsg, "Client Missing details", true, Session);
            }
        }
        if (e.CommandName.Equals("Download"))
        {
            string OutPutFileName = CustomerName + ".zip";
            Response.Clear();
            Response.ContentType = "application/zip";
            Response.AddHeader("Content-Disposition", "attachment; filename=" + OutPutFileName);
            using (ZipFile zipfile = new ZipFile())
            {
                zipfile.AddSelectedFiles("*.*", Server.MapPath("Images"), false);
                zipfile.Save(Response.OutputStream);
            }
            Response.Close();
        }
    }
Exemplo n.º 7
0
    //private void Toggle(string listCode, string prefix, string message)
    //{

    //    MultiView1.ActiveViewIndex = 2;

    //    string contactsToDisplay = "";
    //    var listName = ddlists.SelectedItem.ToString();
    //    var enteredNumber = txtPhones.Text.Trim();

    //    var receipientType = ddlReceipient.SelectedValue;

    //    //User entered a list of numbers comma separated
    //    if (receipientType == RECEIPTION_TYPE_PHONE_NO) {
    //        contactsToDisplay = txtPhones.Text.Trim();
    //    }

    //    //User selected a list to send to
    //    else if (receipientType == RECEIPTION_TYPE_LIST)
    //    {
    //        contactsToDisplay = listName;
    //    }

    //    //User uploaded a file
    //    else {
    //        contactsToDisplay = FileUpload1.FileName;
    //        uploadedFile = FileUpload1;
    //        Session["uploadedFile"] = uploadedFile;

    //    }

    //    ////Not a receiption type list so we the phone numbers
    //    //if (listName.Trim().Equals("Select List"))
    //    //{
    //    //    listName = "";
    //    //    //Get the list of phone numbers
    //    //    txtviewlistname.Text = enteredNumber;
    //    //}
    //    //else if (enteredNumber.Equals(""))
    //    //{
    //    //    //No phone numbers input
    //    //    txtviewlistname.Text = listName;
    //    //}
    //    //else
    //    //{
    //    //    txtviewlistname.Text = listName + ", " + enteredNumber;
    //    //}


    //    txtviewlistname.Text = contactsToDisplay;
    //    txtviewprefix.Text = prefix;
    //    txtViewMessage.Text = message;
    //    Label1.Text = "Please Confirm Details Below";
    //    ShowMessage("Please Confirm and Continue", false);

    //}

    //protected void ddlists_DataBound(object sender, EventArgs e)
    //{
    //    ddlists.Items.Insert(0, new ListItem(" Select Group ", "0"));
    //}

    //protected void Button1_Click(object sender, EventArgs e)
    //{
    //    try
    //    {
    //var Receipient = ddlReceipient.SelectedItem.ToString();
    //var ReceipientType = ddlReceipient.SelectedValue;

    //var Phones = txtPhones.Text;
    //var ContactGroup = ddlists.SelectedValue;
    //var FileUpload = FileUpload1.FileName;
    //var message = txtViewMessage.Text.Trim();
    //var VendorCode = Session["VendorCode"].ToString();


    //if (Receipient.Equals(""))
    //{
    //    ShowMessage("Please Select a contact group To Send to", true);
    //    MultiView1.ActiveViewIndex = 0;
    //}else
    //if (txtMessage.Equals(""))
    //{
    //    ShowMessage("Please type a message to send", true);
    //    MultiView1.ActiveViewIndex = 0;
    //}
    //else
    //{
    //    var resLog = "";

    //    if (ReceipientType.Equals(RECEIPTION_TYPE_PHONE_NO) && (txtPhones.Text != null || txtPhones.Text != ""))
    //    {

    //        String[] phoneNumberArr = Phones.Split(',');
    //        resLog = _processFile.LogSMSCommaSeparatedList(phoneNumberArr, message, VendorCode);

    //    }

    //    else if (ReceipientType.Equals(RECEIPTION_TYPE_LIST) && (ddlists.SelectedValue.ToString() != null || ddlists.SelectedValue.ToString() != ""))
    //    {
    //        string listId = ddlists.SelectedValue.ToString();
    //        string user = Session["Username"].ToString();
    //        string mask = Session["Mask"].ToString();
    //        string SenderId = Session["SenderId"].ToString();
    //        string filepath = "";
    //        resLog = _processFile.LogSMSFileUpload(listId, filepath, message, VendorCode, user, mask, SenderId, "ListSMS");

    //    }

    //    else if (ReceipientType.Equals(RECEIPTION_TYPE_FILE))

    //    {

    //          uploadedFile = Session["uploadedFile"] as FileUpload;
    //        //string filename = Path.GetFileName(FileUpload1.FileName);
    //        string filename = Path.GetFileName(uploadedFile.FileName);
    //        string extension = Path.GetExtension(filename);

    //        string pathToFile = @"E:\SMSUploads\FilessToSend";
    //        DateTime todaydate = DateTime.Now;
    //        string datetoday = todaydate.ToString().Replace("/", "-").Replace(":", "-").Replace(" ", "-");
    //        string filepath = pathToFile + filename + "_" + datetoday + extension;
    //        if (!Directory.Exists(pathToFile))
    //            Directory.CreateDirectory(pathToFile);

    //        uploadedFile.SaveAs(filepath);
    //        //FileUpload1.SaveAs(filepath);

    //        var user = HttpContext.Current.Session["Username"].ToString();
    //        var mask = HttpContext.Current.Session["Mask"].ToString();
    //        var SenderId = HttpContext.Current.Session["SenderId"].ToString();
    //        var listId = "";

    //        resLog = _processFile.LogSMSFileUpload(listId, filepath, message, VendorCode, user, mask, SenderId, "FileSMS");

    //    }


    //    if (resLog.Contains("Successfully"))
    //    {
    //        ShowMessage(resLog, false);
    //        Clear_contrls();
    //    }
    //    else
    //    {
    //        ShowMessage(resLog, true);
    //    }

    //    MultiView1.ActiveViewIndex = 0;
    //}
    //    }
    //    catch (Exception ex)
    //    {
    //        ShowMessage(ex.Message, true);
    //    }
    //}

    //private void Clear_contrls()
    //{
    //    ddlists.SelectedIndex = ddlists.Items.IndexOf(ddlists.Items.FindByValue("0"));
    //    ddlReceipient.SelectedIndex = ddlReceipient.Items.IndexOf(ddlReceipient.Items.FindByValue("0"));
    //    txtMessage.Text = "";
    //}

    //protected void Button2_Click(object sender, EventArgs e)
    //{
    //    MultiView1.ActiveViewIndex = 0;
    //    ShowMessage(".", true);
    //}


    protected void dataGridResults_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int         index = 0;
        GridViewRow row;
        GridView    grid = sender as GridView;

        index = Convert.ToInt32(e.CommandArgument);
        row   = grid.Rows[index];
        string ClientID       = row.Cells[2].Text;
        string LoanID         = row.Cells[3].Text;
        string AmountPerMonth = row.Cells[9].Text;
        Label  lblmsg         = (Label)Master.FindControl("lblmsg");

        if (e.CommandName.Equals("ViewPayments"))
        {
            if (LoanID != "")
            {
                Server.Transfer("~/ViewLoanPayments.aspx?ClientID=" + ClientID + "&LoanID=" + LoanID + "&AmountPerMonth=" + AmountPerMonth);
                //return;
            }
            else
            {
                bll.ShowMessage(lblmsg, "Loan Missing details", true, Session);
            }
        }
        if (e.CommandName.Equals("Download"))
        {
            string OutPutFileName = LoanID + ".zip";
            Response.Clear();
            Response.ContentType = "application/zip";
            Response.AddHeader("Content-Disposition", "attachment; filename=" + OutPutFileName);
            using (ZipFile zipfile = new ZipFile())
            {
                zipfile.AddSelectedFiles("*.*", Server.MapPath("Images"), false);
                zipfile.Save(Response.OutputStream);
            }
            Response.Close();
        }
    }
        public ActionResult DownloadPoFile(HttpPostedFileBase postedFile, string pagename)
        {
            ViewBag.errormsgexport = "";
            if (postedFile != null)
            {
                string fileextension = System.IO.Path.GetExtension(postedFile.FileName);
                if (fileextension != ".po")
                {
                    ViewBag.errormsgexport = "File format is not .po";
                }
                else
                {
                    string path = System.IO.Path.Combine(Server.MapPath("~/Content/Export/"));
                    System.IO.Directory.CreateDirectory(path);
                    string filepath = path + postedFile.FileName;
                    var    filename = System.IO.Path.GetFileNameWithoutExtension(filepath);
                    if (System.IO.File.Exists(filepath))
                    {
                        System.IO.File.Delete(filepath);
                    }
                    postedFile.SaveAs(filepath);
                    List <Language> list = new List <Language>();
                    list = ILanguages.GetAll().ToList();
                    for (int i = 0; i < list.Count; i++)
                    {
                        var Languagecode = list[i].LanguageCode;

                        var input = System.IO.File.ReadAllText(filepath);
                        sbPo = new StringBuilder();
                        using (var sr = new StreamReader(filepath, Encoding.UTF8))
                            this.LoadFromReader(sr, "Export", Languagecode, filename);
                    }
                    string SourceFolderPath = System.IO.Path.Combine(path, "Initial");

                    Response.Clear();
                    Response.ContentType = "application/zip";
                    Response.AddHeader("Content-Disposition", String.Format("attachment; filename={0}", "Languages" + ".zip"));

                    bool recurseDirectories = true;
                    using (ZipFile zip = new ZipFile())
                    {
                        zip.AddSelectedFiles("*", path, string.Empty, recurseDirectories);
                        zip.Save(Response.OutputStream);
                    }
                    Response.End();

                    System.IO.Directory.Delete(path, true);
                    ViewBag.errormsgexport = "File downloaded successfully.";
                }
            }
            else
            {
                ViewBag.errormsgexport = "Please Select File";
            }

            if (pagename == "Index")
            {
                ViewBag.pageName = "Index";
                return(View("Index", "_AdminLayout"));
            }
            else
            {
                ViewBag.pageName = "embeded";
                return(View("Index", "_LayoutEmbedAdmin"));
            }
        }
Exemplo n.º 9
0
        // These two data types are supported in DotNetZip, but only if .NET Framework is targeted.
        //private SelfExtractorFlavor _selfExtractorFlavor;
        //private SelfExtractorSaveOptions _selfExtractorSaveOptions;

        public void CallAll()
        {
            // These two apis are supported in DotNetZip, but only if .NET Framework is targeted.
            //_zipFile.SaveSelfExtractor(_string, _selfExtractorFlavor);
            //_zipFile.SaveSelfExtractor(_string, _selfExtractorSaveOptions);

            //Project: Ionic.Zip
            _bZip2InputStream.Close();
            _bZip2InputStream.Flush();
            _int  = _bZip2InputStream.Read(_bytes, _int, _int);
            _int  = _bZip2InputStream.ReadByte();
            _long = _bZip2InputStream.Seek(_long, _seekOrigin);
            _bZip2InputStream.SetLength(_long);
            _bZip2InputStream.Write(_bytes, _int, _int);
            _bZip2OutputStream.Close();
            _bZip2OutputStream.Flush();
            _int  = _bZip2OutputStream.Read(_bytes, _int, _int);
            _long = _bZip2OutputStream.Seek(_long, _seekOrigin);
            _bZip2OutputStream.SetLength(_long);
            _bZip2OutputStream.Write(_bytes, _int, _int);
            _parallelBZip2OutputStream.Close();
            _parallelBZip2OutputStream.Flush();
            _int  = _parallelBZip2OutputStream.Read(_bytes, _int, _int);
            _long = _parallelBZip2OutputStream.Seek(_long, _seekOrigin);
            _parallelBZip2OutputStream.SetLength(_long);
            _parallelBZip2OutputStream.Write(_bytes, _int, _int);
            _crc32.Combine(_int, _int);
            _int = _crc32.ComputeCrc32(_int, _byte);
            _int = _crc32.GetCrc32(_stream);
            _int = _crc32.GetCrc32AndCopy(_stream, _stream);
            _crc32.Reset();
            _crc32.SlurpBlock(_bytes, _int, _int);
            _crc32.UpdateCRC(_byte);
            _crc32.UpdateCRC(_byte, _int);
            _crcCalculatorStream.Close();
            _crcCalculatorStream.Flush();
            _int  = _crcCalculatorStream.Read(_bytes, _int, _int);
            _long = _crcCalculatorStream.Seek(_long, _seekOrigin);
            _crcCalculatorStream.SetLength(_long);
            _crcCalculatorStream.Write(_bytes, _int, _int);
            _zipEntriesCollection = _fileSelector.SelectEntries(_zipFile);
            _zipEntriesCollection = _fileSelector.SelectEntries(_zipFile, _string);
            _stringsCollection    = _fileSelector.SelectFiles(_string);
            _stringsReadOnly      = _fileSelector.SelectFiles(_string, _bool);
            _string = _fileSelector.ToString();
            _bool   = _comHelper.CheckZip(_string);
            _bool   = _comHelper.CheckZipPassword(_string, _string);
            _comHelper.FixZipDirectory(_string);
            _string = _comHelper.GetZipLibraryVersion();
            _bool   = _comHelper.IsZipFile(_string);
            _bool   = _comHelper.IsZipFileWithExtract(_string);
            _countingStream.Adjust(_long);
            _countingStream.Flush();
            _int  = _countingStream.Read(_bytes, _int, _int);
            _long = _countingStream.Seek(_long, _seekOrigin);
            _countingStream.SetLength(_long);
            _countingStream.Write(_bytes, _int, _int);
            _zipEntry.Extract();
            _zipEntry.Extract(_extractExistingFileAction);
            _zipEntry.Extract(_string);
            _zipEntry.Extract(_string, _extractExistingFileAction);
            _zipEntry.Extract(_stream);
            _zipEntry.ExtractWithPassword(_extractExistingFileAction, _string);
            _zipEntry.ExtractWithPassword(_string);
            _zipEntry.ExtractWithPassword(_string, _extractExistingFileAction, _string);
            _zipEntry.ExtractWithPassword(_string, _string);
            _zipEntry.ExtractWithPassword(_stream, _string);
            _crcCalculatorStream = _zipEntry.OpenReader();
            _crcCalculatorStream = _zipEntry.OpenReader(_string);
            _zipEntry.SetEntryTimes(_datetime, _datetime, _datetime);
            _string   = _zipEntry.ToString();
            _zipEntry = _zipFile.AddDirectory(_string);
            _zipEntry = _zipFile.AddDirectory(_string, _string);
            _zipEntry = _zipFile.AddDirectoryByName(_string);
            _zipEntry = _zipFile.AddEntry(_string, _bytes);
            _zipEntry = _zipFile.AddEntry(_string, _openDelegate, _closeDelegate);
            _zipEntry = _zipFile.AddEntry(_string, _writeDelegate);
            _zipEntry = _zipFile.AddEntry(_string, _string);
            _zipEntry = _zipFile.AddEntry(_string, _string, _encoding);
            _zipEntry = _zipFile.AddEntry(_string, _stream);
            _zipEntry = _zipFile.AddFile(_string);
            _zipEntry = _zipFile.AddFile(_string, _string);
            _zipFile.AddFiles(_strings);
            _zipFile.AddFiles(_strings, _bool, _string);
            _zipFile.AddFiles(_strings, _string);
            _zipEntry = _zipFile.AddItem(_string);
            _zipEntry = _zipFile.AddItem(_string, _string);
            _zipFile.AddSelectedFiles(_string);
            _zipFile.AddSelectedFiles(_string, _bool);
            _zipFile.AddSelectedFiles(_string, _string);
            _zipFile.AddSelectedFiles(_string, _string, _bool);
            _zipFile.AddSelectedFiles(_string, _string, _string);
            _zipFile.AddSelectedFiles(_string, _string, _string, _bool);
            _bool = _zipFile.ContainsEntry(_string);
            _zipFile.Dispose();
            _zipFile.ExtractAll(_string);
            _zipFile.ExtractAll(_string, _extractExistingFileAction);
            _zipFile.ExtractSelectedEntries(_string);
            _zipFile.ExtractSelectedEntries(_string, _extractExistingFileAction);
            _zipFile.ExtractSelectedEntries(_string, _string);
            _zipFile.ExtractSelectedEntries(_string, _string, _string);
            _zipFile.ExtractSelectedEntries(_string, _string, _string, _extractExistingFileAction);
            _enumerator = _zipFile.GetNewEnum();
            _zipFile.Initialize(_string);
            _zipFile.RemoveEntries(_zipEntriesCollection);
            _zipFile.RemoveEntries(_stringsCollection);
            _zipFile.RemoveEntry(_zipEntry);
            _zipFile.RemoveEntry(_string);
            _int = _zipFile.RemoveSelectedEntries(_string);
            _int = _zipFile.RemoveSelectedEntries(_string, _string);
            _zipFile.Save();
            _zipFile.Save(_string);
            _zipFile.Save(_stream);
            _zipEntriesCollection = _zipFile.SelectEntries(_string);
            _zipEntriesCollection = _zipFile.SelectEntries(_string, _string);
            _string   = _zipFile.ToString();
            _zipEntry = _zipFile.UpdateDirectory(_string);
            _zipEntry = _zipFile.UpdateDirectory(_string, _string);
            _zipEntry = _zipFile.UpdateEntry(_string, _bytes);
            _zipEntry = _zipFile.UpdateEntry(_string, _openDelegate, _closeDelegate);
            _zipEntry = _zipFile.UpdateEntry(_string, _writeDelegate);
            _zipEntry = _zipFile.UpdateEntry(_string, _string);
            _zipEntry = _zipFile.UpdateEntry(_string, _string, _encoding);
            _zipEntry = _zipFile.UpdateEntry(_string, _stream);
            _zipEntry = _zipFile.UpdateFile(_string);
            _zipFile.UpdateFile(_string, _string);
            _zipFile.UpdateFiles(_strings);
            _zipFile.UpdateFiles(_strings, _string);
            _zipFile.UpdateItem(_string);
            _zipFile.UpdateItem(_string, _string);
            _zipFile.UpdateSelectedFiles(_string, _string, _string, _bool);
            _zipInputStream.Flush();
            _zipEntry = _zipInputStream.GetNextEntry();
            _int      = _zipInputStream.Read(_bytes, _int, _int);
            _long     = _zipInputStream.Seek(_long, _seekOrigin);
            _zipInputStream.SetLength(_long);
            _string = _zipInputStream.ToString();
            _zipInputStream.Write(_bytes, _int, _int);
            _bool = _zipOutputStream.ContainsEntry(_string);
            _zipOutputStream.Flush();
            _zipEntry = _zipOutputStream.PutNextEntry(_string);
            _int      = _zipOutputStream.Read(_bytes, _int, _int);
            _long     = _zipOutputStream.Seek(_long, _seekOrigin);
            _zipOutputStream.SetLength(_long);
            _string = _zipOutputStream.ToString();
            _zipOutputStream.Write(_bytes, _int, _int);
            _deflateStream.Flush();
            _int  = _deflateStream.Read(_bytes, _int, _int);
            _long = _deflateStream.Seek(_long, _seekOrigin);
            _deflateStream.SetLength(_long);
            _deflateStream.Write(_bytes, _int, _int);
            _gZipStream.Flush();
            _int  = _gZipStream.Read(_bytes, _int, _int);
            _long = _gZipStream.Seek(_long, _seekOrigin);
            _gZipStream.SetLength(_long);
            _gZipStream.Write(_bytes, _int, _int);
            _parallelDeflateOutputStream.Close();
            _parallelDeflateOutputStream.Flush();
            _int = _parallelDeflateOutputStream.Read(_bytes, _int, _int);
            _parallelDeflateOutputStream.Reset(_stream);
            _long = _parallelDeflateOutputStream.Seek(_long, _seekOrigin);
            _parallelDeflateOutputStream.SetLength(_long);
            _parallelDeflateOutputStream.Write(_bytes, _int, _int);

            // Static
            _bool = ZipFile.CheckZip(_string);
            _bool = ZipFile.CheckZip(_string, _bool, _textWriter);
            _bool = ZipFile.CheckZipPassword(_string, _string);
            ZipFile.FixZipDirectory(_string);
            _bool    = ZipFile.IsZipFile(_string);
            _bool    = ZipFile.IsZipFile(_string, _bool);
            _bool    = ZipFile.IsZipFile(_stream, _bool);
            _zipFile = ZipFile.Read(_string);
            _zipFile = ZipFile.Read(_string, _readOptions);
            _zipFile = ZipFile.Read(_stream);
            _zipFile = ZipFile.Read(_stream, _readOptions);
            _uint    = Adler.Adler32(_uint, _bytes, _int, _int);
            _bytes   = DeflateStream.CompressBuffer(_bytes);
            _bytes   = DeflateStream.CompressString(_string);
            _bytes   = DeflateStream.UncompressBuffer(_bytes);
            _string  = DeflateStream.UncompressString(_bytes);
            _bytes   = GZipStream.CompressBuffer(_bytes);
            _bytes   = GZipStream.CompressString(_string);
            _bytes   = GZipStream.UncompressBuffer(_bytes);
            _string  = GZipStream.UncompressString(_bytes);
            _bytes   = ZlibStream.CompressBuffer(_bytes);
            _bytes   = ZlibStream.CompressString(_string);
            _bytes   = ZlibStream.UncompressBuffer(_bytes);
            _string  = ZlibStream.UncompressString(_bytes);
        }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            Dictionary <string, string> paths = new Dictionary <string, string>();

            paths.Add("minecraft", "Minecraft");
            paths.Add("cache", "Cache");
            paths.Add("c10t", "C10t");
            paths.Add("overviewer", "Overviewer");
            paths.Add("backups", "Backups");
            paths.Add("maps", "Maps");
            paths.Add("biomeextractor", "BiomeExtractor");

            // The base-path is the location of the current executable
            string buildRoot   = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase.Substring(8));
            string projectRoot = Path.GetDirectoryName(buildRoot);
            string deployRoot  = Path.Combine(projectRoot, "Deploy");
            string sourceRoot  = Path.Combine(projectRoot, "Solution");
            string stagingRoot = Path.Combine(deployRoot, "staging");

            // Clean and create the deployment root
            if (Directory.Exists(deployRoot))
            {
                Directory.Delete(deployRoot, true);
            }
            Directory.CreateDirectory(deployRoot);
            Directory.CreateDirectory(stagingRoot);

            // Create the empty directories
            foreach (KeyValuePair <string, string> p in paths)
            {
                if (!Directory.Exists(p.Value))
                {
                    Directory.CreateDirectory(Path.Combine(stagingRoot, p.Value));
                }
            }

            // Copy the main deployment files
            CopyFiles(buildRoot, stagingRoot, "Server.exe");
            CopyFiles(buildRoot, stagingRoot, "LibNbt.dll");
            CopyFiles(buildRoot, stagingRoot, "Ionic.Zip.Reduced.dll");

            // Copy the default scheduler config
            CopyFiles(Path.Combine(sourceRoot, "Server", "Engine", "Scheduler"), stagingRoot, "sample.scheduler.xml");

            // Build the monolithic license readme
            string readme = File.ReadAllText(Path.Combine(projectRoot, "readme.txt"));
            string nbtLic = File.ReadAllText(Path.Combine(sourceRoot, "LibNbt", "libnbt.txt"));
            string ionLic = File.ReadAllText(Path.Combine(sourceRoot, "Server", "Engine", "Ionic.txt"));

            StringBuilder finalReadme = new StringBuilder();

            finalReadme.AppendLine("##### Contents");
            finalReadme.AppendLine("##1## Readme");
            finalReadme.AppendLine("##2## LibNbt License");
            finalReadme.AppendLine("##3## Ionic Zip License");
            finalReadme.AppendLine("#####");
            finalReadme.AppendLine("");
            finalReadme.AppendLine("");
            finalReadme.AppendLine("################################################################################");
            finalReadme.AppendLine("##1## Readme");
            finalReadme.AppendLine("################################################################################");
            finalReadme.AppendLine(File.ReadAllText(Path.Combine(projectRoot, "readme.txt")));
            finalReadme.AppendLine("");
            finalReadme.AppendLine("");
            finalReadme.AppendLine("################################################################################");
            finalReadme.AppendLine("##2## LibNbt License");
            finalReadme.AppendLine("################################################################################");
            finalReadme.AppendLine(File.ReadAllText(Path.Combine(sourceRoot, "LibNbt", "libnbt.txt")));
            finalReadme.AppendLine("");
            finalReadme.AppendLine("");
            finalReadme.AppendLine("################################################################################");
            finalReadme.AppendLine("##3## Ionic Zip License");
            finalReadme.AppendLine("################################################################################");
            finalReadme.AppendLine(File.ReadAllText(Path.Combine(sourceRoot, "Server", "Engine", "Ionic.txt")));

            using (StreamWriter file = new System.IO.StreamWriter(Path.Combine(stagingRoot, "readme.txt")))
            {
                file.WriteLine(finalReadme.ToString());
            }

            // zip everything up
            using (ZipFile zip = new ZipFile())
            {
                zip.CompressionLevel = Ionic.Zlib.CompressionLevel.BestCompression;
                zip.AddSelectedFiles("*", stagingRoot, "", true);
                zip.Save(Path.Combine(deployRoot, "Enigma-MM.zip"));
            }
        }
Exemplo n.º 11
0
        private void collectCpuStacks(string dataFileName, int bufferSizeMb)
        {
            const KernelTraceEventParser.Keywords kernelKeywords =
                KernelTraceEventParser.Keywords.ImageLoad |
                KernelTraceEventParser.Keywords.Process |
                KernelTraceEventParser.Keywords.Thread |
                KernelTraceEventParser.Keywords.Profile;

            // To support Windows 7 and earlier, we need a separate session for kernel and CLR events
            string sessionName        = "CPUStacksSession";
            string kernelDataFileName = Path.ChangeExtension(dataFileName, ".kernel.etl");

            using (var session = new TraceEventSession(sessionName, dataFileName)
            {
                BufferSizeMB = bufferSizeMb
            })
            {
                using (var kernelSession = new TraceEventSession(KernelTraceEventParser.KernelSessionName, kernelDataFileName))
                {
                    kernelSession.EnableKernelProvider(kernelKeywords, KernelTraceEventParser.Keywords.Profile);
                    session.EnableProvider(ClrTraceEventParser.ProviderGuid, TraceEventLevel.Verbose,
                                           (ulong)(ClrTraceEventParser.Keywords.Default | ClrTraceEventParser.Keywords.StartEnumeration));

                    m_collectionToken.WaitHandle.WaitOne();

                    generateJitRundownEvents(dataFileName, sessionName, bufferSizeMb);

                    var kernelEventsLost = kernelSession.EventsLost;
                    Dispatcher.BeginInvoke(
                        new Action(() =>
                    {
                        EventsLostKernelLabel.Content = kernelEventsLost;
                    }));
                }

                var sessionEventsLost = session.EventsLost;
                Dispatcher.BeginInvoke(
                    new Action(() =>
                {
                    EventsLostTraceLabel.Content = sessionEventsLost;
                }));
            }

            var p = new Process
            {
                StartInfo = new ProcessStartInfo("xperf")
                {
                    Arguments        = string.Format("-merge {0}.etl {0}.clrRundown.etl {0}.kernel.etl {0}_merged.etl", Path.GetFileNameWithoutExtension(dataFileName)),
                    CreateNoWindow   = true,
                    WindowStyle      = ProcessWindowStyle.Hidden,
                    WorkingDirectory = Environment.CurrentDirectory
                }
            };

            try
            {
                p.Start();
            }
            catch (Exception)
            {
            }
            p.WaitForExit();

            using (var zipped = new ZipFile(Path.ChangeExtension(dataFileName, ".zip"))
            {
                CompressionLevel = CompressionLevel.BestCompression
            })
            {
                zipped.AddSelectedFiles(string.Format("name = {0}*.etl", Path.GetFileNameWithoutExtension(dataFileName)));
                zipped.Save();
            }
        }