コード例 #1
0
        private void btnConvertSelection_Click(object sender, EventArgs e)
        {
            var resp = MetroMessageBox.Show(this, "This action can´t will generate an backup of selected files on the root selected folder! \n Do you want to continue with this action?", "Converting files character set", MessageBoxButtons.YesNo);

            if (resp != DialogResult.Yes)
            {
                return;
            }

            var dstCharset     = Charsets.GetEncoding(cboDestinationEncode.SelectedItem.ToString());
            var parentBasePath = new DirectoryInfo(txtBaseDirectory.Text).Parent;
            var zipFileName    = Path.Combine(parentBasePath.FullName, DateTime.Now.ToString("yyyy-MM-dd HHmmss") + ".zip");

            MetroMessageBox.Show(this, string.Format("Right!, Your backup file wil be saved on \"{0}\"", zipFileName), "Converting files character set", MessageBoxButtons.OK);

            var fz = new ICSharpCode.SharpZipLib.Zip.FastZip();

            fz.CreateZip(zipFileName, txtBaseDirectory.Text, true, null);

            foreach (ListViewItem item in lstResults.SelectedItems)
            {
                var srcCharset = Charsets.GetEncoding(item.SubItems[0].Text);

                var srcFileName      = item.SubItems[1].Text;
                var srcDirectoryName = item.SubItems[2].Text;
                var srcFullName      = Path.Combine(srcDirectoryName, srcFileName);
                var dstFullName      = srcFullName;
                var srcContent       = File.ReadAllText(Path.Combine(srcDirectoryName, srcFileName), srcCharset);

                File.WriteAllText(dstFullName, srcContent, dstCharset);
            }

            MetroMessageBox.Show(this, "The selected files has ben converted!\n You have refresh view to see changes", "Right!");
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            StringWriter output = new StringWriter();

            Server.Execute("MotdTemplate.aspx?lobbyID=" + LobbyID, output);

            string tempDirectory = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

            Directory.CreateDirectory(tempDirectory);

            string tempFile = Path.Combine(tempDirectory, "publicmessageoftheday.mdl");

            File.WriteAllText(tempFile, output.ToString());

            ICSharpCode.SharpZipLib.Zip.FastZip fastZip = new ICSharpCode.SharpZipLib.Zip.FastZip();

            string zipFilename = Path.GetTempFileName();

            fastZip.CreateZip(zipFilename, tempDirectory, false, String.Empty);

            byte[] outputBytes = File.ReadAllBytes(zipFilename);

            Directory.Delete(tempDirectory, true);

            File.Delete(zipFilename);

            Response.ContentType = "application/zip";
            Response.AddHeader("Content-Disposition", "attachment; filename=publicmessageoftheday.zip");
            Response.AddHeader("ContentLength", outputBytes.Length.ToString());

            Response.BinaryWrite(outputBytes);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            StringWriter output = new StringWriter();

            Server.Execute("MotdTemplate.aspx?lobbyID=" + LobbyID, output);

            string tempDirectory = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
            Directory.CreateDirectory(tempDirectory);

            string tempFile = Path.Combine(tempDirectory, "publicmessageoftheday.mdl");
            File.WriteAllText(tempFile, output.ToString());

            ICSharpCode.SharpZipLib.Zip.FastZip fastZip = new ICSharpCode.SharpZipLib.Zip.FastZip();

            string zipFilename = Path.GetTempFileName();

            fastZip.CreateZip(zipFilename, tempDirectory, false, String.Empty);

            byte[] outputBytes = File.ReadAllBytes(zipFilename);

            Directory.Delete(tempDirectory, true);

            File.Delete(zipFilename);

            Response.ContentType = "application/zip";
            Response.AddHeader("Content-Disposition", "attachment; filename=publicmessageoftheday.zip");
            Response.AddHeader("ContentLength", outputBytes.Length.ToString());

            Response.BinaryWrite(outputBytes);
        }
コード例 #4
0
ファイル: SharpZipLib.cs プロジェクト: ststeiger/NancyHub
        public static void DownloadSimpleZip()
        {
            string path = @"D:\Stefan.Steiger\Documents\Visual Studio 2013\Projects\NancyHub\NancyHub\EmbeddedResources";

            System.Web.HttpResponse Response = System.Web.HttpContext.Current.Response;

            Response.ContentType = "application/zip";
            Response.AddHeader("content-disposition", "filename=" + "Download.zip");


            ICSharpCode.SharpZipLib.Zip.FastZip fastZip = new ICSharpCode.SharpZipLib.Zip.FastZip();

            fastZip.CreateEmptyDirectories = true;
            // fastZip.Password = "******";


            // Include all files by recursing through the directory structure
            bool recurse = true;

            // Dont filter any files at all
            string filter = null;


            fastZip.CreateZip(Response.OutputStream, path, true, null, null);

            // fastZip.CreateZip("fileName.zip", @"C:\SourceDirectory", recurse, filter);
        } // End Sub DownloadSimpleZip
コード例 #5
0
ファイル: Program.cs プロジェクト: decay88/pyDotexe
        /// <summary>
        /// Create any files
        /// </summary>
        private static void create_file()
        {
            // Get zip file data by this application and create zip file.
            load_create_zip();
            if (found_process_name())
            {
                bset.change_extract_path();
                bset.folder_active = true;
            }
            else if (Directory.Exists(bset.extract_path))
            {
                Directory.Delete(bset.extract_path, true);
            }

            // Extract zip file.
            ICSharpCode.SharpZipLib.Zip.FastZip fastZip = new ICSharpCode.SharpZipLib.Zip.FastZip();
            fastZip.ExtractZip(bset.zip_path, Path.GetDirectoryName(bset.extract_path), "");

            File.Delete(bset.zip_path);

            // Copy python library file.
            if (File.Exists(Path.GetDirectoryName(pathApp) + @"\python" + bset.python_ver + ".dll"))
            {
                File.Copy(Path.GetDirectoryName(pathApp) + @"\python" + bset.python_ver + ".dll",
                          bset.extract_path + @"\" + @"\python" + bset.python_ver + ".dll", true);
            }
        }
コード例 #6
0
ファイル: Properties.cs プロジェクト: bangush/csharp
        void lv3_DoubleClick(object sender, EventArgs e)
        {
            ListViewItem lvi = lv3.SelectedItems[0];
            ArrayList    al  = (ArrayList)lvi.Tag;
            FileInfo     fi  = (FileInfo)al[0];

            zip.Zip.ZipFile  zf = (zip.Zip.ZipFile)al[1];
            zip.Zip.ZipEntry ze = (zip.Zip.ZipEntry)al[2];

            string strFName = fi.FullName;

            string strName   = ze.Name;
            string strParent = "";

            if (strName.IndexOf("/") != -1)
            {
                string[] strNameArr = strName.Split(Encoding.Default.GetChars(Encoding.Default.GetBytes("/")));
                strName = strNameArr[strNameArr.Length - 1];
                for (int i = 0; i < strNameArr.Length - 2; i++)
                {
                    strParent += "\\" + strNameArr[i];
                }
            }

            if (isZip(strFName))
            {
                zip.Zip.FastZip fz = new ICSharpCode.SharpZipLib.Zip.FastZip();
                fz.ExtractZip(strFName, Application.UserAppDataPath + strParent, ze.Name);

                FileInfo[] fins = new FileInfo[1];
                fins.SetValue(new FileInfo(Application.UserAppDataPath + "\\" + ze.Name), 0);
                PropForm pf = new PropForm(fins);
                pf.Show();
            }
        }
コード例 #7
0
ファイル: ZipHelper.cs プロジェクト: attsion/dotnetvue
 public static void CreatZipPassword(string desFile, string SourcePath, string password = "******")
 {
     ICSharpCode.SharpZipLib.Zip.FastZip fastzip = new ICSharpCode.SharpZipLib.Zip.FastZip();
     fastzip.Password = password;
     fastzip.UseZip64 = ICSharpCode.SharpZipLib.Zip.UseZip64.Off;
     fastzip.CreateZip(desFile, SourcePath, true, "");
 }
コード例 #8
0
ファイル: Dados.cs プロジェクト: cleocomprazer/ops.net.br
        public Boolean CarregaDadosReceitaEleicao(String atualDir, String ano)
        {
            using (Banco banco = new Banco())
            {
                DirectoryInfo dir = new DirectoryInfo(atualDir);

                foreach (FileInfo fileZip in dir.GetFiles("*.zip"))
                {
                    ICSharpCode.SharpZipLib.Zip.FastZip zip = new ICSharpCode.SharpZipLib.Zip.FastZip();
                    zip.ExtractZip(fileZip.FullName, fileZip.DirectoryName, null);

                    File.Delete(fileZip.FullName);

                    foreach (FileInfo fileTxt in dir.GetFiles("*.txt", SearchOption.AllDirectories))
                    {
                        if (ProcessaDadosReceitaEleicao(fileTxt.FullName, banco, ano) == false)
                        {
                            return(false);
                        }

                        File.Delete(fileTxt.FullName);
                    }
                }

                AtualizaFornecedorDoador(banco);
            }

            return(true);
        }
コード例 #9
0
ファイル: Hook.cs プロジェクト: decay88/pyDotexe
        /// <summary>
        /// Download module-hooks by Github
        /// </summary>
        /// <param name="path">Save path</param>
        public static bool Upgrade(string path, bool clean = false)
        {
            try
            {
                if (clean)
                {
                    Directory.Delete(path + @"\module-hooks", true);
                }
                string url = "https://github.com/betacode-projects/pyDotexe/raw/master/Binary/Latest/module-hooks.zip";
                Console.WriteLine("[+] Downloading module-hooks data...");
                Console.WriteLine("[+] " + url);
                string zip_path = path + @"\update-hooks.zip";
                // Download module-hooks.
                System.Net.WebClient wc = new System.Net.WebClient();
                wc.DownloadFile(url, zip_path);
                wc.Dispose();

                delete_tmp_upgrade(path, zip_path, false); // Delete tmp folder.
                Console.WriteLine("[+] Extracting module-hooks data...");
                ICSharpCode.SharpZipLib.Zip.FastZip fastZip = new ICSharpCode.SharpZipLib.Zip.FastZip();
                fastZip.ExtractZip(zip_path, path + @"\update_tmp", "");

                //System.IO.Compression.ZipFile.ExtractToDirectory(zip_path, path + @"\update_tmp"); // Extract downloaded zip file.
                // Start Update.
                Update(path + @"\update_tmp\module-hooks", path);
                delete_tmp_upgrade(path, zip_path);

                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine("[!] " + ex.Message);
                return(false);
            }
        }
コード例 #10
0
ファイル: CCCDataProvider.cs プロジェクト: qwdingyu/C-
        private void GetAllFilesFromDirectory(string directory)
        {
            ICSharpCode.SharpZipLib.Zip.FastZip zip = new ICSharpCode.SharpZipLib.Zip.FastZip();
            string[]      files    = Directory.GetFiles(directory);
            List <string> fileList = null;

            foreach (var file in files)
            {
                string extension = Path.GetExtension(file);
                if (extension == ".zip")
                {
                    string temp = Path.GetTempFileName();
                    File.Delete(temp);
                    Directory.CreateDirectory(temp);
                    zip.ExtractZip(file, temp, ICSharpCode.SharpZipLib.Zip.FastZip.Overwrite.Always, null, "", "", false);
                    tempDir.Add(Path.GetFileName(file), temp);
                }
            }
            files = Directory.GetFiles(directory);
            foreach (var file in files)
            {
                string name = Path.GetFileNameWithoutExtension(file);
                if (this.files.ContainsKey(name))
                {
                    fileList = this.files[name] as List <string>;
                }
                else
                {
                    fileList = new List <string>();
                    this.files.Add(name, fileList);
                }
                fileList.Add(file);
            }
        }
コード例 #11
0
 private void freeZip()
 {
     if (avaZip)
     {
         myZip = null;
     }
 }
コード例 #12
0
        public void ACTest()
        {
            Guid.NewGuid().ToString().Replace("-", string.Empty);

            ICSharpCode.SharpZipLib.Zip.FastZip fz = new ICSharpCode.SharpZipLib.Zip.FastZip();
            fz.CreateZip(@"C:\123.zip", @"C:\Users\0115289\Desktop\becky", true, string.Empty, string.Empty);
        }
コード例 #13
0
ファイル: Git.cs プロジェクト: ststeiger/NancyHub
 public static void ZipRepository(string path, System.IO.Stream strm)
 {
     // http://community.sharpdevelop.net/forums/t/2842.aspx
     // Added CreateExe to FastZip
     ICSharpCode.SharpZipLib.Zip.FastZip fz = new ICSharpCode.SharpZipLib.Zip.FastZip();
     // fz.CreateZip("zipfilename", "sourceDir", true, null);
     fz.CreateZip(strm, path, true, null, null);
 }         // End Sub xxx
コード例 #14
0
        /// <summary>
        /// 解压
        /// </summary>
        public static void decompress(string _localPath, string _zipFileName)
        {
            string zipFileName = _zipFileName; //待解压的目录文件
            string localPath   = _localPath;   //解压后的目录
            // Zip it into a memory stream.
            var zip = new ICSharpCode.SharpZipLib.Zip.FastZip();

            zip.ExtractZip(zipFileName, localPath, string.Empty);
        }
コード例 #15
0
        protected void ButtonSenadores_Click(object sender, EventArgs e)
        {
            String atualDir = Server.MapPath("Upload");

            if (FileUpload.FileName != "")
            {
                FileUpload.SaveAs(atualDir + "//" + FileUpload.FileName);

                ICSharpCode.SharpZipLib.Zip.ZipFile file = null;

                try
                {
                    file = new ICSharpCode.SharpZipLib.Zip.ZipFile(atualDir + "//" + FileUpload.FileName);

                    if (file.TestArchive(true) == false)
                    {
                        Response.Write("<script>alert('Erro no Zip. Faça o upload novamente.')</script>");
                        return;
                    }
                }
                finally
                {
                    if (file != null)
                    {
                        file.Close();
                    }
                }

                ICSharpCode.SharpZipLib.Zip.FastZip zip = new ICSharpCode.SharpZipLib.Zip.FastZip();
                zip.ExtractZip(atualDir + "//" + FileUpload.FileName, Server.MapPath("Upload"), null);

                File.Delete(atualDir + "//" + FileUpload.FileName);

                CarregarSenadores(atualDir);
            }
            else
            {
                DirectoryInfo dir = new DirectoryInfo(atualDir);

                foreach (FileInfo file in dir.GetFiles("*.zip"))
                {
                    ICSharpCode.SharpZipLib.Zip.FastZip zip = new ICSharpCode.SharpZipLib.Zip.FastZip();
                    zip.ExtractZip(file.FullName, file.DirectoryName, null);

                    File.Delete(file.FullName);

                    CarregarSenadores(file.DirectoryName);
                }
            }

            Cache.Remove("menorAnoSenadores");
            Cache.Remove("ultimaAtualizacaoSenadores");
            Cache.Remove("tableSenadores");
            Cache.Remove("tableDespesaSenadores");
            Cache.Remove("tablePartidoSenadores");
        }
コード例 #16
0
ファイル: SystemController.cs プロジェクト: honj51/EAP
        public ActionResult RestoreDB(string db, string zipfilePath)
        {
            string bakPath = "";
            ICSharpCode.SharpZipLib.Zip.FastZip fz = new ICSharpCode.SharpZipLib.Zip.FastZip();
            // fz.ExtractZip(zipfilePath, )
            string sqlStr = "restore database " + db + " from disk='" + bakPath + "' with format";
            Zippy.Data.StaticDB.DB.ExecuteNonQuery(sqlStr);

            return View();
        }
コード例 #17
0
ファイル: Zip.cs プロジェクト: TUSB/TUSBCommandEditor
        /// <summary>
        /// データをZip圧縮する
        /// </summary>
        /// <param name="saveFolder">Zip書庫を格納するフォルダのパス</param>
        /// <param name="zipFileName">圧縮したデータのパス</param>
        /// <param name="sourceDirectory">圧縮するデータのパス</param>
        public void DataZip(string saveFolder, string zipFileName, string sourceDirectory)
        {
            Directory.CreateDirectory(saveFolder);
            var fastZip = new ICSharpCode.SharpZipLib.Zip.FastZip();

            //空のフォルダも書庫に入れるか
            fastZip.CreateEmptyDirectories = true;

            fastZip.CreateZip(zipFileName, sourceDirectory, true, null);
        }
コード例 #18
0
 public async Task DepressFile(string sourceFileName, string targetPath, CancellationToken cancelToken)
 {
     await Task.Run(() =>
     {
         string root    = System.Configuration.ConfigurationManager.AppSettings["AppRootPath"];
         sourceFileName = Path.Combine(root, sourceFileName);
         targetPath     = Path.Combine(root, targetPath);
         ICSharpCode.SharpZipLib.Zip.FastZip fZip = new ICSharpCode.SharpZipLib.Zip.FastZip();
         fZip.ExtractZip(sourceFileName, targetPath, "");
     });
 }
コード例 #19
0
ファイル: Zip.cs プロジェクト: scholtz/FastZep
 /// <summary>
 /// Extract [zipFileName] to [destinationPath]
 /// </summary>
 /// <param name="zipFileName"></param>
 /// <param name="destinationPath"></param>
 /// <param name="fileNameToExtract">need to be the relative path in the zip file</param>
 public static void ExtractSingleFile(string zipFileName, string destinationPath, string fileNameToExtract)
 {
     try
     {
         ICSharpCode.SharpZipLib.Zip.FastZip fz = new ICSharpCode.SharpZipLib.Zip.FastZip();
         fz.ExtractZip(zipFileName, destinationPath, fileNameToExtract);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #20
0
        public ActionResult RestoreDB(string db, string zipfilePath)
        {
            string bakPath = "";

            ICSharpCode.SharpZipLib.Zip.FastZip fz = new ICSharpCode.SharpZipLib.Zip.FastZip();
            // fz.ExtractZip(zipfilePath, )
            string sqlStr = "restore database " + db + " from disk='" + bakPath + "' with format";

            Zippy.Data.StaticDB.DB.ExecuteNonQuery(sqlStr);

            return(View());
        }
コード例 #21
0
        //
        // =======================================================================================
        public static void UnzipFile(CPBaseClass cp, string PathFilename)
        {
            try {
                //
                ICSharpCode.SharpZipLib.Zip.FastZip fastZip = new ICSharpCode.SharpZipLib.Zip.FastZip();
                string fileFilter = null;

                fastZip.ExtractZip(PathFilename, getPath(cp, PathFilename), fileFilter);                //
            } catch (Exception ex) {
                cp.Site.ErrorReport(ex, "UnzipFile");
            }
        }        //
コード例 #22
0
 /// <summary>
 /// Extract [zipFileName] to [destinationPath]
 /// </summary>
 /// <param name="zipFileName"></param>
 /// <param name="destinationPath"></param>
 public static void Extract(string zipFileName, string destinationPath)
 {
     try
     {
         ICSharpCode.SharpZipLib.Zip.FastZip fz = new ICSharpCode.SharpZipLib.Zip.FastZip();
         fz.ExtractZip(zipFileName, destinationPath, "");
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #23
0
        /// <summary>
        /// 压缩
        /// </summary>
        /// <param name="_localPath">待压缩的目录或文件</param>
        /// <param name="_zipFileName">压缩后的目录文件</param>
        public static void compress(string _localPath, string _zipFileName)
        {
            string localPath   = _localPath;   //待压缩的目录或文件
            string zipFileName = _zipFileName; //压缩后的目录文件
            // Export the directory tree from SVN server.
            //localPath = System.IO.Path.Combine(localPath, Guid.NewGuid().ToString());
            // Zip it into a memory stream.

            var zip = new ICSharpCode.SharpZipLib.Zip.FastZip();

            zip.CreateZip(zipFileName, localPath, true, string.Empty, string.Empty);
        }
コード例 #24
0
        /// <summary>
        /// 壓縮檔案
        /// </summary>
        /// <param name="strSourceFilePath">來源檔案路徑</param>
        /// <param name="strDesFileName">目的檔名</param>
        /// <param name="SourceFileReg">需要壓縮的檔案</param>
        public void Compress(string strSourceFilePath, 
                             string strDesFileName,
                             string SourceFileReg
                             )
        {
            ICSharpCode.SharpZipLib.Zip.FastZip fz = new ICSharpCode.SharpZipLib.Zip.FastZip();

            fz.CreateZip(strDesFileName,
                         strSourceFilePath, 
                         true, 
                         SourceFileReg
                         );
        }
コード例 #25
0
        public static void Unzip(string path, string unzippath)
        {
            string fileFilter = "";
            var    fastZip    =
                new ICSharpCode.SharpZipLib.Zip.FastZip
            {
                RestoreAttributesOnExtract = true,
                RestoreDateTimeOnExtract   = true,
                CreateEmptyDirectories     = true
            };

            fastZip.ExtractZip(path, unzippath, fileFilter);
        }
コード例 #26
0
 private static PluginExtractionResult UnzipPlugin(FileInfo plugin)
 {
     if (plugin.Extension != ".zip") throw new Exception(string.Format("The {0} extention is not recognized as valid plugin repository item extention. Default extention is .zip",plugin.Extension));
     try {
         ICSharpCode.SharpZipLib.Zip.FastZip zip = new ICSharpCode.SharpZipLib.Zip.FastZip();
         zip.ExtractZip(plugin.FullName, Path.Combine(_pluginsDirectory, plugin.Name), string.Empty);
         return new PluginExtractionResult(ExtractionResult.OK, string.Format("Plugin {0} successfully ",plugin.Name));
     }
     catch (Exception ex)
     {
         return new PluginExtractionResult(ExtractionResult.Error, string.Format("Error while extract {0} plugin from archive",plugin.Name), ex);
     }
 }
コード例 #27
0
ファイル: Transmitter.cs プロジェクト: theill/transmit
        private string Pack()
        {
            string zippedSourceFolder = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
            Directory.CreateDirectory(zippedSourceFolder);
            foreach (var f in files) {
                File.Copy(f, Path.Combine(zippedSourceFolder, Path.GetFileName(f)), true);
            }

            string zippedArchive = Path.GetTempFileName();
            ICSharpCode.SharpZipLib.Zip.FastZip fz = new ICSharpCode.SharpZipLib.Zip.FastZip();
            fz.CreateZip(zippedArchive, zippedSourceFolder, true, "", "");
            return zippedArchive;
        }
コード例 #28
0
ファイル: FileStorage_Libraries.cs プロジェクト: rbg13/Master
        public static bool xmlDB_Libraries_ImportFromZip(this TM_FileStorage tmFileStorage, string zipFileToImport, string unzipPassword)
        {
            UserRole.Admin.demand();

            var result = false;

            try
            {
                var currentLibraryPath = tmFileStorage.Path_XmlLibraries;
                if (currentLibraryPath.isNull())
                {
                    return(false);
                }
                if (zipFileToImport.isUri())
                {
                    "[xmlDB_Libraries_ImportFromZip] provided value was an URL so, downloading it: {0}".info(zipFileToImport);
                    zipFileToImport = new Web().downloadBinaryFile(zipFileToImport);
                }
                "[xmlDB_Libraries_ImportFromZip] importing library from: {0}".info(zipFileToImport);
                if (zipFileToImport.fileExists().isFalse())
                {
                    "[xmlDB_Libraries_ImportFromZip] could not find file to import".error(zipFileToImport);
                }
                else
                {
                    // handle the zips we get from GitHub

                    var tempDir = @"..\_".add_RandomLetters(3).tempDir(false).fullPath(); //trying to make the unzip path as small as possible
                    var fastZip = new ICSharpCode.SharpZipLib.Zip.FastZip {
                        Password = unzipPassword ?? ""
                    };

                    fastZip.ExtractZip(zipFileToImport, tempDir, "");

                    Files.copyFolder(tempDir, currentLibraryPath, true, true, "");          // just copy all files into Library path
                    Files.deleteFolder(tempDir, true);                                      // delete tmp folder created
                    result = true;
                }
            }
            catch (Exception ex)
            {
                ex.log("[xmlDB_Libraries_ImportFromZip]");
            }

            if (result)
            {
                tmFileStorage.reloadGuidanceExplorerObjects();
            }

            return(result);
        }
コード例 #29
0
ファイル: SystemController.cs プロジェクト: honj51/EAP
 public ActionResult BackupDB(string db)
 {
     if (db.IsNullOrEmpty()) db = System.Configuration.ConfigurationManager.AppSettings["DBName"];
     if (db.IsNullOrEmpty()) db = "EAP";
     string fileDir = Server.MapPath("~/db.bak/");
     string fileName = db + "-" + DateTime.Now.ToString("yyyyMMddHHmmss");
     string filePath = System.IO.Path.Combine(fileDir, fileName + ".bak");
     string sqlStr = "backup database " + db + " to disk='" + filePath + "' with format";
     Zippy.Data.StaticDB.DB.ExecuteNonQuery(sqlStr);
     ICSharpCode.SharpZipLib.Zip.FastZip fz = new ICSharpCode.SharpZipLib.Zip.FastZip();
     fz.CreateZip(System.IO.Path.Combine(fileDir, fileName + ".zip"), fileDir, false, fileName + ".bak");
     System.IO.File.Delete(filePath);
     return Redirect("/System/Database/");
 }
コード例 #30
0
 private void allocZip()
 {
     if (avaZip)
     {
         //FastZipオブジェクトの作成
         myZip = new ICSharpCode.SharpZipLib.Zip.FastZip();
         //属性を復元
         myZip.RestoreAttributesOnExtract = true;
         //ファイル日時を復元
         myZip.RestoreDateTimeOnExtract = true;
         //空のフォルダも作成
         myZip.CreateEmptyDirectories = true;
     }
 }
コード例 #31
0
        private bool UnzipOSA(string PluginPackagePath)
        {
            string exePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            if (Directory.Exists(exePath + "/tempDir/"))
            {
                Directory.Delete(exePath + "/tempDir/", true);
            }

            string tempfolder = exePath + "/tempDir/";
            string zipFileName = System.IO.Path.GetFullPath(PluginPackagePath);
            string DescPath = null;

            ICSharpCode.SharpZipLib.Zip.FastZip fastZip = new ICSharpCode.SharpZipLib.Zip.FastZip();

            fastZip.ExtractZip(zipFileName, tempfolder, null);
            // find all included plugin descriptions and install the plugins
            List<string> osapdFiles = new List<string>();
            List<string> sqlFiles = new List<string>();

            string[] pluginFile = Directory.GetFiles(tempfolder, "*.osapd", SearchOption.TopDirectoryOnly);
            osapdFiles.AddRange(pluginFile);
            string[] sqlFile = Directory.GetFiles(tempfolder, "*.sql", SearchOption.TopDirectoryOnly);
            sqlFiles.AddRange(sqlFile);

            if (osapdFiles.Count == 0)
            {
                MessageBox.Show("No plugin description files found.");
                return false;
            }

            if (osapdFiles.Count > 1)
            {
                MessageBox.Show("More than one plugin description file found.");
                return false;
            }
            if (osapdFiles.Count == 1)
            {

                DescPath = osapdFiles[0];
            }


            if (!string.IsNullOrEmpty(DescPath))
            {
                desc.Deserialize(DescPath);
                return true;
            }
            return false;
        }
コード例 #32
0
        private bool UnzipOSA(string PluginPackagePath)
        {
            string exePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

            if (Directory.Exists(exePath + "/tempDir/"))
            {
                Directory.Delete(exePath + "/tempDir/", true);
            }

            string tempfolder  = exePath + "/tempDir/";
            string zipFileName = System.IO.Path.GetFullPath(PluginPackagePath);
            string DescPath    = null;

            ICSharpCode.SharpZipLib.Zip.FastZip fastZip = new ICSharpCode.SharpZipLib.Zip.FastZip();

            fastZip.ExtractZip(zipFileName, tempfolder, null);
            // find all included plugin descriptions and install the plugins
            List <string> osapdFiles = new List <string>();
            List <string> sqlFiles   = new List <string>();

            string[] pluginFile = Directory.GetFiles(tempfolder, "*.osapd", SearchOption.TopDirectoryOnly);
            osapdFiles.AddRange(pluginFile);
            string[] sqlFile = Directory.GetFiles(tempfolder, "*.sql", SearchOption.TopDirectoryOnly);
            sqlFiles.AddRange(sqlFile);

            if (osapdFiles.Count == 0)
            {
                MessageBox.Show("No plugin description files found.");
                return(false);
            }

            if (osapdFiles.Count > 1)
            {
                MessageBox.Show("More than one plugin description file found.");
                return(false);
            }
            if (osapdFiles.Count == 1)
            {
                DescPath = osapdFiles[0];
            }


            if (!string.IsNullOrEmpty(DescPath))
            {
                desc.Deserialize(DescPath);
                return(true);
            }
            return(false);
        }
コード例 #33
0
 /// <summary>
 /// Compress list of files [sourceFiles] to [zipFileName]
 /// </summary>
 /// <param name="zipFileName"></param>
 /// <param name="sourceFiles"></param>
 public static void Zip(string zipFileName, FileInfo[] sourceFiles)
 {
     try
     {
         // get the root folder. NOTE: it assums that the first file is at the root.
         string rootFolder = Path.GetDirectoryName(sourceFiles[0].FullName);
         // compress
         ICSharpCode.SharpZipLib.Zip.FastZip fz = new ICSharpCode.SharpZipLib.Zip.FastZip();
         fz.CreateZip(zipFileName, rootFolder, true, "");
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #34
0
ファイル: DescargarEpos.cs プロジェクト: dmendozaperez/FePeru
        private string descomprimir(string _rutazip, string _destino)
        {
            string _error = "";

            try
            {
                ICSharpCode.SharpZipLib.Zip.FastZip fZip = new ICSharpCode.SharpZipLib.Zip.FastZip();
                fZip.ExtractZip(@_rutazip, @_destino, "");
            }
            catch (Exception exc)
            {
                _error = exc.Message;
            }
            return(_error);
        }
コード例 #35
0
ファイル: Program.cs プロジェクト: s7loves/mypowerscgl
 static void Main()
 {
     ICSharpCode.SharpZipLib.Zip.FastZip fz=new ICSharpCode.SharpZipLib.Zip.FastZip();
     string direct = AppDomain.CurrentDomain.BaseDirectory + "\\msg";
     string zipFile = AppDomain.CurrentDomain.BaseDirectory+"\\msg\\msg.zip";
     if (System.IO.File.Exists(zipFile)) {
         killmsg();
         try {
             fz.ExtractZip(zipFile, direct, ICSharpCode.SharpZipLib.Zip.FastZip.Overwrite.Always, null, null, null, false);
             if(!zipFile.Contains("output"))
                 System.IO.File.Delete(zipFile);
         } catch { }
     }
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     DevExpress.UserSkins.OfficeSkins.Register();
     DevExpress.UserSkins.BonusSkins.Register();
     DevExpress.Skins.SkinManager.EnableFormSkins();
     DevExpress.LookAndFeel.UserLookAndFeel.Default.SkinName = "Xmas 2008 Blue";
     //DevExpress.Utils.Localization.AccLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressUtilsLocalizationCHS();
     DevExpress.XtraBars.Localization.BarLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraBarsLocalizationCHS();
     //DevExpress.XtraCharts.Localization.ChartLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraChartsLocalizationCHS();
     DevExpress.XtraEditors.Controls.Localizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraEditorsLocalizationCHS();
     DevExpress.XtraGrid.Localization.GridLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraGridLocalizationCHS();
     DevExpress.XtraLayout.Localization.LayoutLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraLayoutLocalizationCHS();
     DevExpress.XtraNavBar.NavBarLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraNavBarLocalizationCHS();
     //DevExpress.XtraPivotGrid.Localization.PivotGridLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraPivotGridLocalizationCHS();
     DevExpress.XtraPrinting.Localization.PreviewLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraPrintingLocalizationCHS();
     DevExpress.XtraReports.Localization.ReportLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraReportsLocalizationCHS();
     //DevExpress.XtraRichTextEdit.Localization.XtraRichTextEditLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraRichTextEditLocalizationCHS();
     //DevExpress.XtraRichEdit.Localization.XtraRichEditLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraRichEditLocalizationCHS();
     DevExpress.XtraScheduler.Localization.SchedulerLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraSchedulerLocalizationCHS();
     DevExpress.XtraScheduler.Localization.SchedulerExtensionsLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraSchedulerExtensionsLocalizationCHS();
     DevExpress.XtraSpellChecker.Localization.SpellCheckerLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraSpellCheckerLocalizationCHS();
     DevExpress.XtraTreeList.Localization.TreeListLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraTreeListLocalizationCHS();
     //DevExpress.XtraVerticalGrid.Localization.VGridLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraVerticalGridLocalizationCHS();
     //DevExpress.XtraWizard.Localization.WizardLocalizer.Active = new DevExpress.LocalizationCHS.DevExpressXtraWizardLocalizationCHS();
     //frmLogin dlg = new frmLogin(); 
     //if (dlg.ShowDialog() == DialogResult.OK)
     Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
     Application.ApplicationExit += new EventHandler(Application_ApplicationExit);
     Application.ThreadExit += new EventHandler(Application_ThreadExit);
     //Application.Run(new frmMain2());
     string uc= ConfigurationManager.AppSettings["usercompany"];
     if (!string.IsNullOrEmpty(uc))
         Ebada.Client.Platform.MainHelper.UserCompany = uc;
     Application.Run(new FrmSystem());
 }
コード例 #36
0
        protected void btnAddFile_Click(object sender, EventArgs e)
        {
            if (fuFileUpload.HasFile == true)
            {
                if (Path.GetExtension(fuFileUpload.FileName).ToLower() != ".zip")
                {
                    lblUploadStatus.Text = "Upload failed: please upload .zip files only! Use the File Manager to upload single files.";
                    return;
                }


                string tempFile = Path.GetTempFileName();
                fuFileUpload.SaveAs(tempFile);

                ICSharpCode.SharpZipLib.Zip.FastZip fastZip = new ICSharpCode.SharpZipLib.Zip.FastZip();

                string tempDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

                fastZip.ExtractZip(tempFile, tempDirectory, "");

                if (ValidateZipFileContainsOnlyOneLauncher(tempDirectory) == false)
                {
                    lblUploadStatus.Text = "Upload failed: upload package contains multiple launcher.exe files.";
                    return;
                }

                if (ValidateCombinedPackageAndZipFileContainOnlyOneLauncher(this.Target, tempDirectory) == false)
                {
                    lblUploadStatus.Text = "Upload failed: the package contains a launcher.exe that is in a different location in the zip file.";
                    return;
                }

                AutoUpdateManager.CreateBackup("AutoBackup - Uploading " + fuFileUpload.FileName + " to " + this.Target);

                AddUploadedFilesToPackage(this.Target, tempDirectory, tempDirectory);

                File.Delete(tempFile);
                Directory.Delete(tempDirectory, true);

                lblUploadStatus.Text = "Upload for " + fuFileUpload.FileName + " complete.";

                BindData();

                ucPackageContents.BindData();

                CheckPackageForUpdatedLauncher();
            }
        }
コード例 #37
0
ファイル: SharpZipLib.cs プロジェクト: ststeiger/NancyHub
        } // End Sub DownloadSimpleZip

        public static void CreateSimpleZip()
        {
            ICSharpCode.SharpZipLib.Zip.FastZip fastZip = new ICSharpCode.SharpZipLib.Zip.FastZip();

            fastZip.CreateEmptyDirectories = true;
            // fastZip.Password = "******";


            // Include all files by recursing through the directory structure
            bool recurse = true;

            // Dont filter any files at all
            string filter = null;

            fastZip.CreateZip(@"D:\fileName.zip", @"D:\Stefan.Steiger\Documents\Visual Studio 2013\Projects\NancyHub\NancyHub\EmbeddedResources", recurse, filter);
        }
コード例 #38
0
        private void InstallModButton_Click(object sender, RoutedEventArgs e)
        {
            var openFileDialog = new Microsoft.Win32.OpenFileDialog()
            {
                Filter = "Mod Archive (*.zip)|*.zip",
                Title  = "Install Mod..."
            };

            if ((bool)openFileDialog.ShowDialog())
            {
                try
                {
                    NodeTree testTree = new NodeTree(this.NodeTree);

                    //note that the elements are not copied
                    //suspose let testTree.RootNodes[0].Childs[0].MainExecutable = ""
                    //then this.NodeTree.RootNodes[0].Childs[0].MainExecutable=="" is true!
                    //be careful
                    var fastZip = new ICSharpCode.SharpZipLib.Zip.FastZip();

                    // Will always overwrite if target filenames already exist
                    fastZip.ExtractZip(
                        openFileDialog.FileName,
                        System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Incoming"),
                        String.Empty);

                    testTree.AddNodes(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Incoming"));

                    if (testTree.Count() == this.NodeTree.Count())
                    {
                        throw new Exception("This archive doesn't contain any nodes.");
                    }

                    IO.CreateHardLinksOfFiles(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Incoming"), System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Mods"));

                    this.BuildTreeView();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                finally
                {
                    IO.ClearDirectory(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Incoming"));
                }
            }
        }
        protected void btnAddFile_Click(object sender, EventArgs e)
        {
            if (fuFileUpload.HasFile == true)
            {
                if (Path.GetExtension(fuFileUpload.FileName).ToLower() != ".zip")
                {
                    lblUploadStatus.Text = "Upload failed: please upload .zip files only! Use the File Manager to upload single files.";
                    return;
                }

                string tempFile = Path.GetTempFileName();
                fuFileUpload.SaveAs(tempFile);

                ICSharpCode.SharpZipLib.Zip.FastZip fastZip = new ICSharpCode.SharpZipLib.Zip.FastZip();

                string tempDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

                fastZip.ExtractZip(tempFile, tempDirectory, "");

                if (ValidateZipFileContainsOnlyOneLauncher(tempDirectory) == false)
                {
                    lblUploadStatus.Text = "Upload failed: upload package contains multiple launcher.exe files.";
                    return;
                }

                if (ValidateCombinedPackageAndZipFileContainOnlyOneLauncher(this.Target, tempDirectory) == false)
                {
                    lblUploadStatus.Text = "Upload failed: the package contains a launcher.exe that is in a different location in the zip file.";
                    return;
                }

                AutoUpdateManager.CreateBackup("AutoBackup - Uploading " + fuFileUpload.FileName + " to " + this.Target);

                AddUploadedFilesToPackage(this.Target, tempDirectory, tempDirectory);

                File.Delete(tempFile);
                Directory.Delete(tempDirectory, true);

                lblUploadStatus.Text = "Upload for " + fuFileUpload.FileName + " complete.";

                BindData();

                ucPackageContents.BindData();

                CheckPackageForUpdatedLauncher();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            List <FileCollision>            fileCollisions     = new List <FileCollision>();
            Dictionary <string, UpdateItem> filesInPublication = new Dictionary <string, UpdateItem>();

            AutoUpdateManager.TryGetPublicationFiles(PublicationID, out filesInPublication, out fileCollisions);

            string publicationName = AutoUpdateManager.GetPublicationName(PublicationID);

            string tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

            Directory.CreateDirectory(tempPath);

            foreach (string filename in filesInPublication.Keys)
            {
                string targetFile = Path.Combine(tempPath, filename);

                if (Directory.Exists(Path.GetDirectoryName(targetFile)) == false)
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(targetFile));
                }


                File.Copy(filesInPublication[filename].FileInfo.FullName, targetFile, true);
            }

            ICSharpCode.SharpZipLib.Zip.FastZip fastZip = new ICSharpCode.SharpZipLib.Zip.FastZip();

            string zipFilename = Path.GetTempFileName();

            fastZip.CreateZip(zipFilename, tempPath, true, String.Empty);

            byte[] outputBytes = File.ReadAllBytes(zipFilename);

            Directory.Delete(tempPath, true);

            File.Delete(zipFilename);


            Response.ContentType = "application/zip";
            Response.AddHeader("Content-Disposition", "attachment; filename=" + publicationName + ".zip");
            Response.AddHeader("ContentLength", outputBytes.Length.ToString());


            Response.BinaryWrite(outputBytes);
        }
コード例 #41
0
ファイル: Zip.cs プロジェクト: scholtz/FastZep
 /// <summary>
 /// Extract [zipFileName] to [destinationPath] recursively
 /// </summary>
 /// <param name="zipFileName"></param>
 public static void ExtractRecursively(string zipFileName)
 {
     try
     {
         ICSharpCode.SharpZipLib.Zip.FastZip fz = new ICSharpCode.SharpZipLib.Zip.FastZip();
         fz.ExtractZip(zipFileName, Path.GetDirectoryName(zipFileName) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(zipFileName), "");
         DirectoryInfo diInputDir = new DirectoryInfo(Path.GetDirectoryName(zipFileName) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(zipFileName));
         FileInfo[] fiInfoArr = diInputDir.GetFiles("*.zip", SearchOption.AllDirectories);
         foreach (FileInfo fiInfo in fiInfoArr)
         {
             if (string.Compare(Path.GetExtension(fiInfo.FullName), ".zip", true) == 0)
             {
                 ExtractRecursively(fiInfo.FullName);
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            List<FileCollision> fileCollisions = new List<FileCollision>();
            Dictionary<string, UpdateItem> filesInPublication = new Dictionary<string, UpdateItem>();

            AutoUpdateManager.TryGetPublicationFiles(PublicationID, out filesInPublication, out fileCollisions);

            string publicationName = AutoUpdateManager.GetPublicationName(PublicationID);

            string tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
            Directory.CreateDirectory(tempPath);

            foreach (string filename in filesInPublication.Keys)
            {
                string targetFile = Path.Combine(tempPath, filename);

                if(Directory.Exists(Path.GetDirectoryName(targetFile)) == false)
                    Directory.CreateDirectory(Path.GetDirectoryName(targetFile));

                File.Copy(filesInPublication[filename].FileInfo.FullName, targetFile, true);
            }

            ICSharpCode.SharpZipLib.Zip.FastZip fastZip = new ICSharpCode.SharpZipLib.Zip.FastZip();

            string zipFilename = Path.GetTempFileName();

            fastZip.CreateZip(zipFilename, tempPath, true, String.Empty);

            byte[] outputBytes = File.ReadAllBytes(zipFilename);

            Directory.Delete(tempPath, true);

            File.Delete(zipFilename);

            Response.ContentType = "application/zip";
            Response.AddHeader("Content-Disposition", "attachment; filename=" + publicationName + ".zip");
            Response.AddHeader("ContentLength", outputBytes.Length.ToString());

            Response.BinaryWrite(outputBytes);
        }
コード例 #43
0
ファイル: ConsoleCommands.cs プロジェクト: fizikci/Cinar
        public static string Backup(
            [Description("choose one of data, uploadedFiles, both")] string backup_what)
        {
            Provider.Server.ScriptTimeout = 300;

            if (string.IsNullOrEmpty(backup_what))
                backup_what = "data";

            // 1. create backup_yyyy_MM_dd folder
            string userFilesPath = Provider.MapPath("UserFiles");
            string backupName = "backup_" + DateTime.Now.ToString("yyyy_MM_dd");
            string backupFilesFolder = userFilesPath.Substring(0, userFilesPath.Length - "UserFiles".Length) + "Backup";
            string newBackupFolder = backupFilesFolder + "\\" + backupName;
            if (Directory.Exists(newBackupFolder)) Directory.Delete(newBackupFolder, true);
            Directory.CreateDirectory(newBackupFolder);

            // 2. create data sql dump into the backup folder
            if (backup_what == "data" || backup_what == "both")
            {
                string newBackupPath = newBackupFolder + "\\dump.sql";
                using (StreamWriter sw = new StreamWriter(newBackupPath, false, Encoding.UTF8))
                {
                    textWriterForDump = sw;
                    sw.WriteLine();
                    Dump("both", "MySQL", "all");
                    sw.Close();
                }
            }

            // 3. copy diff of UserFiles(default) folder into the backup folder,
            // Attention: This process assumes existance of a file is within Cinar.CMS by default, UserFiles.txt file,
            //   containing the default SVN file paths of the /UserFiles directory and it's sub directories.
            // Check Utility.cs for more information. GetFileNames();
            string result = "";
            // changed "image" to user "uploadedFiles", which is more useful for taking backups.
            if (backup_what == "uploadedFiles" || backup_what == "both")
            {

                List<string> fileNames = Regex.Split(Utility.GetFileNames(userFilesPath, "UserFiles"), "\r\n").ToList();
                List<string> defaultFileNames = new List<string>();
                try
                {
                    defaultFileNames = Regex.Split(File.ReadAllText(userFilesPath + ".txt"), "\r\n").ToList();
                }
                catch
                {
                }

                string[] diff = fileNames.Select((name, index) => new { name, index })
                    .Where(x => !defaultFileNames.Contains(x.name))
                    .Select(x => x.name).ToArray();

                foreach (var item in diff)
                {
                    string path = newBackupFolder + "\\" + item.Substring("UserFiles\\".Length);
                    FileInfo fi = new FileInfo(path);
                    if (!Directory.Exists(fi.DirectoryName)) Directory.CreateDirectory(fi.DirectoryName);
                    File.Copy(Provider.MapPath(item), path);
                }

                if (diff.Length == 0) result += "No uploaded file was found!\n";
            }
            // 4. zip the backup folder
            ICSharpCode.SharpZipLib.Zip.FastZip zip = new ICSharpCode.SharpZipLib.Zip.FastZip();
            string zipUrl = newBackupFolder + ".zip";
            zip.CreateZip(zipUrl, newBackupFolder, true, null);
            // 5. delete the backup folder
            Directory.Delete(newBackupFolder, true);
            // write download link
            return result + "Download backup file from : http://" + Provider.Configuration.SiteAddress + zipUrl.Substring(zipUrl.IndexOf("\\Backup")).Replace("\\", "/");
        }
コード例 #44
0
        public static bool xmlDB_Libraries_ImportFromZip(this TM_FileStorage tmFileStorage, string zipFileToImport, string unzipPassword)
        {
            UserRole.Admin.demand();

            var result = false;
            try
            {
                var currentLibraryPath = tmFileStorage.Path_XmlLibraries;
                if (currentLibraryPath.isNull())
                    return false;
                if (zipFileToImport.isUri())
                {
                    "[xmlDB_Libraries_ImportFromZip] provided value was an URL so, downloading it: {0}".info(zipFileToImport);
                    zipFileToImport = new Web().downloadBinaryFile(zipFileToImport);
                }
                "[xmlDB_Libraries_ImportFromZip] importing library from: {0}".info(zipFileToImport);
                if (zipFileToImport.fileExists().isFalse())
                    "[xmlDB_Libraries_ImportFromZip] could not find file to import".error(zipFileToImport);
                else
                {
                    // handle the zips we get from GitHub

                    var tempDir = @"..\_".add_RandomLetters(3).tempDir(false).fullPath(); //trying to make the unzip path as small as possible
                    var fastZip = new ICSharpCode.SharpZipLib.Zip.FastZip {Password = unzipPassword ?? ""};

                    fastZip.ExtractZip(zipFileToImport, tempDir, "");

                    Files.copyFolder(tempDir, currentLibraryPath, true, true,"");          // just copy all files into Library path
                    Files.deleteFolder(tempDir,true);                                      // delete tmp folder created
                    result = true;

                }
            }
            catch (Exception ex)
            {
                ex.log("[xmlDB_Libraries_ImportFromZip]");
            }

            if (result)
                tmFileStorage.reloadGuidanceExplorerObjects();

            return result;
        }
コード例 #45
0
ファイル: MasterHooker.cs プロジェクト: chantsunman/Scutex
		internal static void HookSharpZipLib()
		{
			ICSharpCode.SharpZipLib.Zip.FastZip fz = new ICSharpCode.SharpZipLib.Zip.FastZip();
		}
        public static bool xmlDB_Libraries_ImportFromZip(this TM_Xml_Database tmDatabase, string zipFileToImport, string unzipPassword)
        {
            try
            {
                 if (zipFileToImport.isUri())
                {
                    "[xmlDB_Libraries_ImportFromZip] provided value was an URL so, downloading it: {0}".info(zipFileToImport);
                    zipFileToImport = new Web().downloadBinaryFile(zipFileToImport);
                    //zipFileToImport =  zipFileToImport.uri().download();
                }
                "[xmlDB_Libraries_ImportFromZip] importing library from: {0}".info(zipFileToImport);
                if (zipFileToImport.fileExists().isFalse())
                    "[xmlDB_Libraries_ImportFromZip] could not find file to import".error(zipFileToImport);
                else
                {
                    var currentLibraryPath = TM_Xml_Database.Path_XmlLibraries;
                    // handle the zips we get from GitHub

                    var tempDir = "_unzip".tempDir();
                    var fastZip = new ICSharpCode.SharpZipLib.Zip.FastZip();
                    fastZip.Password = unzipPassword ?? unzipPassword;
                    fastZip.ExtractZip(zipFileToImport, tempDir, "");

                    var gitZipFolderName = tempDir.folders().first().folderName();				// the first folder should be the one created by gitHub's zip
                    var xmlFile_location1 = tempDir.pathCombine(gitZipFolderName + ".xml");
                    var xmlFile_location2 = tempDir.pathCombine(gitZipFolderName).pathCombine(gitZipFolderName + ".xml");
                    if (xmlFile_location1.fileExists() || xmlFile_location2.fileExists())		// if these exists here, just copy the unziped files directly
                    {
                        Files.copyFolder(tempDir,currentLibraryPath,true,true,".git");
                        if (xmlFile_location1.fileExists())
                            Files.copy(xmlFile_location1, currentLibraryPath.pathCombine(gitZipFolderName));
                        return true;
                    }
                    //if (zipFileToImport.extension() == ".master")
                    else
                    {

                        var gitZipDir = tempDir.pathCombine(gitZipFolderName);
                        foreach (var libraryFolder in gitZipDir.folders())
                        {
                            var libraryName = libraryFolder.folderName();
                            var targetFolder = currentLibraryPath.pathCombine(libraryName);

                            //default behaviour is to override the existing libraries
                            /*if (targetFolder.dirExists())
                            {
                                "[xmlDB_Libraries_ImportFromZip] [from Git zip] could not import library with name {0} since there was already one with that name".error(libraryFolder.folderName());
                                return false;
                            }*/
                            Files.copyFolder(libraryFolder, currentLibraryPath);

                            //handle the case where the xml file is located outside the library folder
                            var libraryXmlFile = gitZipDir.pathCombine("{0}.xml".format(libraryName));
                            if (libraryXmlFile.fileExists())
                                Files.copy(libraryXmlFile, targetFolder);			// put it in the Library folder which is where it really should be
                        }
                        var virtualMappings = gitZipDir.pathCombine("Virtual_Articles.xml");
                        if (virtualMappings.fileExists())
                        {
                            Files.copy(virtualMappings, currentLibraryPath);			// copy virtual mappings if it exists
                            tmDatabase.mapVirtualArticles();
                        }
                        return true;
                    }
                    /*else
                    {
                        //if it is a normal zip, the expectation is that the zip is the library name
                        var libraryName = Path.GetFileNameWithoutExtension(zipFileToImport);
                        var libraryFilePath = tmDatabase.xmlDB_LibraryPath(libraryName);
                        var guidanceItemsPath = tmDatabase.xmlDB_LibraryPath_GuidanceItems(libraryName);

                        //default behaviour is to override the existing libraries

                        //if (libraryFilePath.fileExists() && libraryFilePath.fileInfo().size() == 0 ||
                        //	libraryFilePath.fileExists().isFalse() && guidanceItemsPath.dirExists().isFalse())
                        //{
                            var fastZip = new ICSharpCode.SharpZipLib.Zip.FastZip();
                            fastZip.Password = unzipPassword ?? unzipPassword;
                            fastZip.ExtractZip(zipFileToImport, currentLibraryPath, "");

                            //zipFileToImport.unzip_File(currentLibraryPath);
                            return true;
                        //}
                        //else
                        //	"[xmlDB_Libraries_ImportFromZip] could not import library with name {0} since there was already one with that name".error(libraryName);

                    } */
                }
            }
            catch (Exception ex)
            {
                ex.log("[xmlDB_Libraries_ImportFromZip]");
            }
            return false;
        }
コード例 #47
0
ファイル: Zip.cs プロジェクト: scholtz/FastZep
 /// <summary>
 /// Zips the folder name to create a zip file
 /// </summary>
 /// <param name="folderName"></param>
 /// <param name="zipFileName"></param>
 public static void Zip(string folderName, string zipFileName)
 {
     try
     {
         ICSharpCode.SharpZipLib.Zip.FastZip fz = new ICSharpCode.SharpZipLib.Zip.FastZip();
         fz.CreateZip(zipFileName, folderName, true, "");
     }
     catch (ICSharpCode.SharpZipLib.SharpZipBaseException)
     {
         //Fail silently on cancel
         if (Directory.Exists(folderName))
         {
             Directory.Delete(folderName, true);
         }
         if (System.IO.File.Exists(zipFileName))
         {
             System.IO.File.Delete(zipFileName);
         }
     }
     catch
     {
         //Close silently
     }
 }
コード例 #48
0
ファイル: VersionHelper.cs プロジェクト: Apache553/BMCL
 public static void ImportOldMc(string importName, string importFrom, Delegate callback = null)
 {
     var thread = new Thread(() =>
     {
         OnImportProgressChangeEvent(LangManager.GetLangFromResource("ImportMain"));
         Directory.CreateDirectory(".minecraft\\versions\\" + importName);
         File.Copy(importFrom + "\\bin\\minecraft.jar",
             ".minecraft\\versions\\" + importName + "\\" + importName + ".jar");
         OnImportProgressChangeEvent(LangManager.GetLangFromResource("ImportCreateJson"));
         var info = new gameinfo {id = importName};
         string timezone = DateTimeOffset.Now.Offset.ToString();
         if (timezone[0] != '-')
         {
             timezone = "+" + timezone;
         }
         info.time = DateTime.Now.GetDateTimeFormats('s')[0] + timezone;
         info.releaseTime = DateTime.Now.GetDateTimeFormats('s')[0] + timezone;
         info.type = "Port By BMCL";
         info.minecraftArguments = "${auth_player_name}";
         info.mainClass = "net.minecraft.client.Minecraft";
         OnImportProgressChangeEvent(LangManager.GetLangFromResource("ImportSolveNative"));
         var libs = new ArrayList();
         var bin = new DirectoryInfo(importFrom + "\\bin");
         foreach (FileInfo file in bin.GetFiles("*.jar"))
         {
             var libfile = new libraries.libraryies();
             if (file.Name == "minecraft.jar")
                 continue;
             if (
                 !Directory.Exists(".minecraft\\libraries\\" + importName + "\\" +
                                   file.Name.Substring(0, file.Name.Length - 4) + "\\BMCL\\"))
             {
                 Directory.CreateDirectory(".minecraft\\libraries\\" + importName + "\\" +
                                           file.Name.Substring(0, file.Name.Length - 4) + "\\BMCL\\");
             }
             File.Copy(file.FullName,
                 ".minecraft\\libraries\\" + importName + "\\" + file.Name.Substring(0, file.Name.Length - 4) +
                 "\\BMCL\\" + file.Name.Substring(0, file.Name.Length - 4) + "-BMCL.jar");
             libfile.name = importName + ":" + file.Name.Substring(0, file.Name.Length - 4) + ":BMCL";
             libs.Add(libfile);
         }
         var nativejar = new ICSharpCode.SharpZipLib.Zip.FastZip();
         if (!Directory.Exists(".minecraft\\libraries\\" + importName + "\\BMCL\\"))
         {
             Directory.CreateDirectory(".minecraft\\libraries\\" + importName + "\\native\\BMCL\\");
         }
         nativejar.CreateZip(
             ".minecraft\\libraries\\" + importName + "\\native\\BMCL\\native-BMCL-natives-windows.jar",
             importFrom + "\\bin\\natives", false, @"\.dll");
         var nativefile = new libraries.libraryies {name = importName + ":native:BMCL"};
         var nativeos = new libraries.OS {windows = "natives-windows"};
         nativefile.natives = nativeos;
         nativefile.extract = new libraries.extract();
         libs.Add(nativefile);
         info.libraries = (libraries.libraryies[]) libs.ToArray(typeof (libraries.libraryies));
         OnImportProgressChangeEvent(LangManager.GetLangFromResource("ImportWriteJson"));
         var wcfg = new FileStream(".minecraft\\versions\\" + importName + "\\" + importName + ".json",
             FileMode.Create);
         var infojson = new DataContractJsonSerializer(typeof (gameinfo));
         infojson.WriteObject(wcfg, info);
         wcfg.Close();
         OnImportProgressChangeEvent(LangManager.GetLangFromResource("ImportSolveLib"));
         if (Directory.Exists(importFrom + "\\lib"))
         {
             if (!Directory.Exists(".minecraft\\lib"))
             {
                 Directory.CreateDirectory(".minecraft\\lib");
             }
             foreach (
                 string libfile in Directory.GetFiles(importFrom + "\\lib", "*", SearchOption.AllDirectories))
             {
                 if (!File.Exists(".minecraft\\lib\\" + System.IO.Path.GetFileName(libfile)))
                 {
                     File.Copy(libfile, ".minecraft\\lib\\" + System.IO.Path.GetFileName(libfile));
                 }
             }
         }
         OnImportProgressChangeEvent(LangManager.GetLangFromResource("ImportSolveMod"));
         if (Directory.Exists(importFrom + "\\mods"))
             util.FileHelper.dircopy(importFrom + "\\mods", ".minecraft\\versions\\" + importName + "\\mods");
         else
             Directory.CreateDirectory(".minecraft\\versions\\" + importName + "\\mods");
         if (Directory.Exists(importFrom + "\\coremods"))
             util.FileHelper.dircopy(importFrom + "\\coremods",
                 ".minecraft\\versions\\" + importName + "\\coremods");
         else
             Directory.CreateDirectory(".minecraft\\versions\\" + importName + "\\coremods");
         if (Directory.Exists(importFrom + "\\config"))
             util.FileHelper.dircopy(importFrom + "\\config", ".minecraft\\versions\\" + importName + "\\config");
         else
             Directory.CreateDirectory(".minecraft\\versions\\" + importName + "\\configmods");
         OnImportFinish();
         if (callback != null)
         {
             BmclCore.Invoke(callback);
         }
     });
     thread.Start();
 }
コード例 #49
0
ファイル: Dados.cs プロジェクト: ops-org/ops.net.br
		public Boolean CarregaDadosReceitaEleicao(String atualDir, String ano)
		{
			using (Banco banco = new Banco())
			{
				DirectoryInfo dir = new DirectoryInfo(atualDir);

				foreach (FileInfo fileZip in dir.GetFiles("*.zip"))
				{
					ICSharpCode.SharpZipLib.Zip.FastZip zip = new ICSharpCode.SharpZipLib.Zip.FastZip();
					zip.ExtractZip(fileZip.FullName, fileZip.DirectoryName, null);

					File.Delete(fileZip.FullName);

					foreach (FileInfo fileTxt in dir.GetFiles("*.txt", SearchOption.AllDirectories))
					{
						if (ProcessaDadosReceitaEleicao(fileTxt.FullName, banco, ano) == false)
						{
							return false;
						}

						File.Delete(fileTxt.FullName);
					}
				}

				AtualizaFornecedorDoador(banco);
			}

			return true;
		}
コード例 #50
0
		//protected void Page_Load(object sender, EventArgs e)
		//{
		//    //CifrarStringConexao();
		//    GridViewAcerto.PreRender += GridViewAcerto_PreRender;
		//    GridViewPrevia.PreRender += GridViewPrevia_PreRender;
		//}

		//private void GridViewPrevia_PreRender(object sender, EventArgs e)
		//{
		//    try
		//    {
		//        GridViewPrevia.HeaderRow.TableSection = TableRowSection.TableHeader;
		//    }
		//    catch (Exception)
		//    { }
		//}

		//private void GridViewAcerto_PreRender(object sender, EventArgs e)
		//{
		//    try
		//    {
		//        GridViewAcerto.HeaderRow.TableSection = TableRowSection.TableHeader;
		//    }
		//    catch (Exception)
		//    { }
		//}

		protected void ButtonEnviar_Click(object sender, EventArgs e)
		{
			Cache.Remove("menorAno");
			Cache.Remove("ultima_atualizacao");
			Cache.Remove("tableParlamentar");
			Cache.Remove("tableDespesa");
			Cache.Remove("tablePartido");

			String atualDir = Server.MapPath("Upload");

			if (FileUpload.FileName != "")
			{
				//string ftpUrl = ConfigurationManager.AppSettings["ftpAddress"];
				//string ftpUsername = ConfigurationManager.AppSettings["ftpUsername"];
				//string ftpPassword = ConfigurationManager.AppSettings["ftpPassword"];
				//FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftpUrl + "Transactions.zip");
				//request.Proxy = new WebProxy(); //-----The requested FTP command is not supported when using HTTP proxy.
				//request.Method = WebRequestMethods.Ftp.UploadFile;
				//request.Credentials = new NetworkCredential(ftpUsername, ftpPassword);
				//StreamReader sourceStream = new StreamReader(fileToBeUploaded);
				//byte[] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
				//sourceStream.Close();
				//request.ContentLength = fileContents.Length;
				//Stream requestStream = request.GetRequestStream();
				//requestStream.Write(fileContents, 0, fileContents.Length);
				//requestStream.Close();
				//FtpWebResponse response = (FtpWebResponse)request.GetResponse();
				//Console.WriteLine("Upload File Complete, status {0}", response.StatusDescription);
				//response.Close();

				//using (var requestStream = request.GetRequestStream())
				//{
				//    using (var input = File.OpenRead(fileToBeUploaded))
				//    {
				//        input.CopyTo(requestStream);
				//    }
				//}

				if (!Directory.Exists(atualDir))
					Directory.CreateDirectory(atualDir);

				FileUpload.SaveAs(atualDir + "\\" + FileUpload.FileName);

				ICSharpCode.SharpZipLib.Zip.ZipFile file = null;

				try
				{
					file = new ICSharpCode.SharpZipLib.Zip.ZipFile(atualDir + "\\" + FileUpload.FileName);

					if (file.TestArchive(true) == false)
					{
						Response.Write("<script>alert('Erro no Zip. Faça o upload novamente.')</script>");
						return;
					}
				}
				finally
				{
					if (file != null)
						file.Close();
				}

				ICSharpCode.SharpZipLib.Zip.FastZip zip = new ICSharpCode.SharpZipLib.Zip.FastZip();
				zip.ExtractZip(atualDir + "//" + FileUpload.FileName, Server.MapPath("Upload"), null);

				File.Delete(atualDir + "//" + FileUpload.FileName);

				Carregar(atualDir);
			}
			else
			{
				DirectoryInfo dir = new DirectoryInfo(atualDir);

				foreach (FileInfo file in dir.GetFiles("*.zip"))
				{
					ICSharpCode.SharpZipLib.Zip.FastZip zip = new ICSharpCode.SharpZipLib.Zip.FastZip();
					zip.ExtractZip(file.FullName, file.DirectoryName, null);

					File.Delete(file.FullName);

					Carregar(file.DirectoryName);
				}
			}
		}
コード例 #51
0
		protected void ButtonSenadores_Click(object sender, EventArgs e)
		{
			String atualDir = Server.MapPath("Upload");

			if (FileUpload.FileName != "")
			{
				FileUpload.SaveAs(atualDir + "//" + FileUpload.FileName);

				ICSharpCode.SharpZipLib.Zip.ZipFile file = null;

				try
				{
					file = new ICSharpCode.SharpZipLib.Zip.ZipFile(atualDir + "//" + FileUpload.FileName);

					if (file.TestArchive(true) == false)
					{
						Response.Write("<script>alert('Erro no Zip. Faça o upload novamente.')</script>");
						return;
					}
				}
				finally
				{
					if (file != null)
						file.Close();
				}

				ICSharpCode.SharpZipLib.Zip.FastZip zip = new ICSharpCode.SharpZipLib.Zip.FastZip();
				zip.ExtractZip(atualDir + "//" + FileUpload.FileName, Server.MapPath("Upload"), null);

				File.Delete(atualDir + "//" + FileUpload.FileName);

				CarregarSenadores(atualDir);
			}
			else
			{
				DirectoryInfo dir = new DirectoryInfo(atualDir);

				foreach (FileInfo file in dir.GetFiles("*.zip"))
				{
					ICSharpCode.SharpZipLib.Zip.FastZip zip = new ICSharpCode.SharpZipLib.Zip.FastZip();
					zip.ExtractZip(file.FullName, file.DirectoryName, null);

					File.Delete(file.FullName);

					CarregarSenadores(file.DirectoryName);
				}
			}

			Cache.Remove("menorAnoSenadores");
			Cache.Remove("ultimaAtualizacaoSenadores");
			Cache.Remove("tableSenadores");
			Cache.Remove("tableDespesaSenadores");
			Cache.Remove("tablePartidoSenadores");
		}
コード例 #52
0
ファイル: Program.cs プロジェクト: timotei/InfoCenter
 /// <summary>
 /// Extrage fisierele din fisierul .zip specificat in destinatia specificata.
 /// </summary>
 /// <param name="filePath">Locatia fisierului .zip</param>
 /// <param name="destPath">Destinatia</param>
 /// <param name="errorMessage">Mesajul de eroare in cazul negasirii fisierului</param>
 private static void Unzip(string filePath, string destPath, string errorMessage)
 {
     if (System.IO.File.Exists(filePath))
     {
         try
         {
             var zip = new ICSharpCode.SharpZipLib.Zip.FastZip();
             zip.ExtractZip(filePath, destPath, "");
             Console.WriteLine("\tOK");
         }
         catch (System.Exception e)
         {
             Console.WriteLine("EROARE {0}", e.Message);
         }
     }
     else
         Console.WriteLine("\tEroare - {0}", errorMessage);
 }
コード例 #53
0
ファイル: ZipCacher.cs プロジェクト: tiloc/fhir-net-api
        public void Refresh()
        {
            Clear();

            var dir = getCachedZipDirectory();

            dir.Create();

#if NET40
            ICSharpCode.SharpZipLib.Zip.FastZip  zf = new ICSharpCode.SharpZipLib.Zip.FastZip();
            zf.ExtractZip(_zipPath, dir.FullName, "*.*");
#else
            ZipFile.ExtractToDirectory(_zipPath, dir.FullName);
#endif

            // Set the last write time to be equal to the write time of the zip file,
            // this way, we can compare this time to the write times of newer zips and
            // detect we need a refresh
            Directory.SetCreationTimeUtc(dir.FullName, File.GetLastWriteTimeUtc(_zipPath));
        }
コード例 #54
0
ファイル: Properties.cs プロジェクト: Hagser/csharp
        void lv3_DoubleClick(object sender, EventArgs e)
        {
            ListViewItem lvi = lv3.SelectedItems[0];
            ArrayList al = (ArrayList)lvi.Tag;
            FileInfo fi=(FileInfo)al[0];
            zip.Zip.ZipFile zf=(zip.Zip.ZipFile)al[1];
            zip.Zip.ZipEntry ze=(zip.Zip.ZipEntry)al[2];

            string strFName = fi.FullName;

            string strName = ze.Name;
            string strParent = "";

            if (strName.IndexOf("/") != -1)
            {
                string[] strNameArr = strName.Split(Encoding.Default.GetChars(Encoding.Default.GetBytes("/")));
                strName = strNameArr[strNameArr.Length - 1];
                for (int i = 0; i < strNameArr.Length - 2; i++)
                {
                    strParent += "\\" + strNameArr[i];
                }
            }

            if (isZip(strFName))
            {
                zip.Zip.FastZip fz = new ICSharpCode.SharpZipLib.Zip.FastZip();
                fz.ExtractZip(strFName, Application.UserAppDataPath + strParent, ze.Name);
                
                FileInfo[] fins = new FileInfo[1];
                fins.SetValue(new FileInfo(Application.UserAppDataPath + "\\" + ze.Name), 0);
                PropForm pf = new PropForm(fins);
                pf.Show();
            }            
        }
コード例 #55
0
        /*  void FncSetInnerCanvas()
        {
            //cnvPaint.Height = 280;
            //cnvPaint.Width = 700;

            Label lblHeader = new Label();
            lblHeader.Content = "CRM Designer";
            lblHeader.PreviewMouseDown += new MouseButtonEventHandler(lblDrag_PreviewMouseDown);
            lblHeader.FontSize = 19;

            ctlPOD objPOD1 = new ctlPOD();
            objPOD1.AllowDrop = true;
            objPOD1.Height = 45;
            objPOD1.Width = 700;
            objPOD1.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
            objPOD1.SetValue(Canvas.LeftProperty, 25.0);
            objPOD1.SetValue(Canvas.TopProperty, 0.0);
            MyPropGrid.ControlToBind = objPOD1;
            objPOD1.cnvPOD.Children.Add(lblHeader);
            currentControl = objPOD1;
            cnvPaint.Children.Add(objPOD1);

            Label lblQuestion = new Label();
            lblQuestion.Content = "CRM Designer2";
            lblQuestion.PreviewMouseDown += new MouseButtonEventHandler(lblDrag_PreviewMouseDown);
            lblQuestion.FontSize = 17;

            ctlPOD objPOD2 = new ctlPOD();
            objPOD2.AllowDrop = true;
            objPOD2.Height = 45;
            objPOD2.Width = 700;
            objPOD2.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
            objPOD2.SetValue(Canvas.LeftProperty, 0.0);
            objPOD2.SetValue(Canvas.TopProperty, 60.0);
            MyPropGrid.ControlToBind = objPOD2;
            objPOD2.cnvPOD.Children.Add(lblQuestion);
            currentControl = objPOD2;
            cnvPaint.Children.Add(objPOD2);

            ClsOptionCollection objOptCollection = ClsOptionCollection.GetAll(objQueCollection[CurrentQueCount].ID);

            varType = objQueCollection[CurrentQueCount].Category;

            if (varType == "CheckBox")
            {
                for (int i = 0; i < objOptCollection.Count; i++)
                {
                    CheckBox chk = new CheckBox();
                    chk.Content = objOptCollection[i].Options;
                    chk.Tag = objOptCollection[i].ActionQueueID.ToString() + "," + objOptCollection[i].ID.ToString();
                    chk.PreviewMouseDown += new MouseButtonEventHandler(chkDrag999_PreviewMouseDown);
                    chk.Height = 18;
                    chk.FontSize = 14;
                    varTop = 120 + (30 * i);

                    ctlPOD objPOD = new ctlPOD();
                    objPOD.AllowDrop = true;
                    objPOD.Height = 25;
                    objPOD.Width = 700;
                    objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                    objPOD.SetValue(Canvas.LeftProperty, 25.0);
                    objPOD.SetValue(Canvas.TopProperty, varTop);
                    MyPropGrid.ControlToBind = objPOD;
                    objPOD.cnvPOD.Children.Add(chk);
                    currentControl = objPOD;
                    cnvPaint.Children.Add(objPOD);
                }
            }
            else if (varType == "RadioButton")
            {
                for (int i = 0; i < objOptCollection.Count; i++)
                {
                    RadioButton chk = new RadioButton();
                    chk.Content = objOptCollection[i].Options;
                    chk.Tag = objOptCollection[i].ActionQueueID.ToString() + "," + objOptCollection[i].ID.ToString();
                    chk.PreviewMouseDown += new MouseButtonEventHandler(radDrag999_PreviewMouseDown);
                    chk.Height = 18;
                    chk.FontSize = 14;
                    varTop = 120 + (30 * i);

                    ctlPOD objPOD = new ctlPOD();
                    objPOD.AllowDrop = true;
                    objPOD.Height = 25;
                    objPOD.Width = 700;
                    objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                    objPOD.SetValue(Canvas.LeftProperty, 25.0);
                    objPOD.SetValue(Canvas.TopProperty, varTop);
                    MyPropGrid.ControlToBind = objPOD;
                    objPOD.cnvPOD.Children.Add(chk);
                    currentControl = objPOD;
                    cnvPaint.Children.Add(objPOD);
                }
            }
            else if (varType == "ListBox")
            {
                ListBox lst = new ListBox();
                lst.Height = 250;
                lst.Width = 700;
                lst.Tag = "code";
                lst.SetValue(Canvas.LeftProperty, 0.0);
                lst.SetValue(Canvas.TopProperty, 0.0);
                lst.PreviewMouseDown += new MouseButtonEventHandler(lstDrag999_PreviewMouseDown);
                //cnvMain.Children.Add(lst);

                for (int i = 0; i < objOptCollection.Count; i++)
                {
                    ListBoxItem lbi = new ListBoxItem();
                    //lbi.IsEnabled = false;
                    lbi.Content = objOptCollection[i].Options;
                    lbi.Tag = objOptCollection[i].ActionQueueID.ToString() + "," + objOptCollection[i].ID.ToString();
                    lst.Items.Add(lbi);
                }

                ctlPOD objPOD = new ctlPOD();
                objPOD.AllowDrop = true;
                objPOD.Height = 250;
                objPOD.Width = 700;
                objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                objPOD.SetValue(Canvas.LeftProperty, 25.0);
                objPOD.SetValue(Canvas.TopProperty, 120.0);
                MyPropGrid.ControlToBind = objPOD;
                objPOD.cnvPOD.Children.Add(lst);
                currentControl = objPOD;
                cnvPaint.Children.Add(objPOD);
            }
            else if (varType == "ComboBox")
            {
                ComboBox cmb = new ComboBox();
                cmb.Height = 25;
                cmb.Width = 700;
                cmb.Tag = "code";
                cmb.PreviewMouseDown += new MouseButtonEventHandler(cmbDrag999_PreviewMouseDown);
                //lst.PreviewMouseDown += new MouseButtonEventHandler(lstDrag999_PreviewMouseDown);
                //cnvMain.Children.Add(lst);

                for (int i = 0; i < objOptCollection.Count; i++)
                {
                    ComboBoxItem cbi = new ComboBoxItem();
                    //cbi.IsEnabled = false;
                    cbi.Content = objOptCollection[i].Options;
                    cbi.Tag = objOptCollection[i].ActionQueueID.ToString() + "," + objOptCollection[i].ID.ToString();
                    cmb.Items.Add(cbi);
                }

                ctlPOD objPOD = new ctlPOD();
                objPOD.AllowDrop = true;
                objPOD.Height = 25;
                objPOD.Width = 700;
                objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                objPOD.SetValue(Canvas.LeftProperty, 25.0);
                objPOD.SetValue(Canvas.TopProperty, 120.0);
                MyPropGrid.ControlToBind = objPOD;
                objPOD.cnvPOD.Children.Add(cmb);
                currentControl = objPOD;
                cnvPaint.Children.Add(objPOD);
            }

            Button btnNext = new Button();
            btnNext.Content = "Next >> ";
            // To Identify That is has some coding and it's Next Button //
            btnNext.Tag = varType.ToString().ToLower();
            btnNext.PreviewMouseDown += new MouseButtonEventHandler(btnDrag_PreviewMouseDown);
            btnNext.FontSize = 16;

            ctlPOD objPOD3 = new ctlPOD();
            objPOD3.AllowDrop = true;
            objPOD3.Height = 35;
            objPOD3.Width = 100;
            objPOD3.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
            objPOD3.SetValue(Canvas.LeftProperty, 25.0);

            if (varType.ToLower() != "listbox" && varType.ToLower() != "combobox")
            {
                objPOD3.SetValue(Canvas.TopProperty, varTop + 35.0);
            }
            else if (varType.ToLower() == "listbox")
            {
                objPOD3.SetValue(Canvas.TopProperty, 400.0);
            }
            else if (varType.ToLower() == "combobox")
            {
                objPOD3.SetValue(Canvas.TopProperty, 200.0);
            }

            MyPropGrid.ControlToBind = objPOD3;
            objPOD3.cnvPOD.Children.Add(btnNext);
            currentControl = objPOD3;
            cnvPaint.Children.Add(objPOD3);
            varTop = 0;
        }*/

        /*   void btnYes_Click(object sender, RoutedEventArgs e)
           {
               btnPrev.IsEnabled = true;

               Canvas c = new Canvas();
               int count = cnvPaint.Children.Count - 1;

               for (int i = count; i >= 0; i--)
               {
                   if (cnvPaint.Children[i].GetType() != typeof(Expander) && cnvPaint.Children[i].GetType() != typeof(Rectangle))
                   {
                       object o = cnvPaint.Children[i];
                       cnvPaint.Children.Remove(cnvPaint.Children[i]);
                       c.Children.Add((UIElement)o);
                   }
               }

               c.Background = cnvPaint.Background;
               c.Height = cnvPaint.Height;
               c.Width = cnvPaint.Width;

               if (GeneratedQuestions > CurrentQueCount)
               {
                   lstCanvas[CurrentQueCount] = c;
                   CurrentQueCount++;
               }
               else
               {
                   GeneratedQuestions++;
                   CurrentQueCount++;
                   lstCanvas.Add(c);
               }

               if (btnNext.Content.ToString() == "Finished")
               {
                   MessageBox.Show("Script Generated");
                   FncSaveFiles();
                   goto rax;
               }

               if (CurrentQueCount == lstCanvas.Count)
               {
                   FncSetInnerCanvas();
               }
               else
               {
                   FncListToCanvas();
               }

               if (CurrentQueCount + 1 == objQueCollection.Count)
               {
                   btnNext.Content = "Finished";
               }

               //cnvPaint.Children.Clear();
           rax: ;
           }*/
        #endregion

        void FncSaveFiles()
        {

            if (startQuestion == "")
            {
                startQuestion = "CRMDesigner";
                startQuestionID = 1;
            }

            #region Saving Files

            CurrentQueCount = -1;
            
            for (int j = 0; j < 1; j++)
            {
                CurrentQueCount++;
                int Counter = 0;
                string strCode = "";
                

                #region Creating .XAML File
            
                string strXML = "";
                strXML = "<UserControl x:Class=\"CRM.Presentation.UserControl" +  Convert.ToString(1) + "\" xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" Height=\"300\" Width=\"300\"  VerticalAlignment=\"Top\">";
                strXML = strXML + char.ConvertFromUtf32(13) + "<Canvas Name=\"cnvPaint" + "\" Height=\"" + (tbcMain.Height + 5).ToString() + "\" Width=\"" + (tbcMain.Width + 5).ToString() + "\" Background=\"Transparent\">";
                strXML = strXML + char.ConvertFromUtf32(13) + "<TabControl Name=\"tbcMain" + "\" Height=\"" + tbcMain.Height + "\" Width=\"" + tbcMain.Width + "\" Canvas.Left=\"0\" Canvas.Top=\"0\">";
                foreach (TabItem t in tbcMain.Items)
                {
                    pageCount++;
                    strXML = strXML + char.ConvertFromUtf32(13) + "<TabItem Header=\"" + t.Header.ToString() +"\">";
                    strXML = strXML + char.ConvertFromUtf32(13) + "<Canvas Name=\"cnvPaint" + pageCount.ToString() + "\" Height=\"" + tbcMain.Height + "\" Width=\"" + tbcMain.Width + "\" Background=\"Transparent\">";
                    
                foreach (object o in ((Canvas)t.Content).Children)
                {
                    if (o.GetType() == typeof(ctlPOD))
                    {
                        foreach (object chl in ((ctlPOD)o).cnvPOD.Children)
                        {
                            Counter++;
                            if (chl.GetType() == typeof(TextBox))
                            {
                               strXML = strXML + char.ConvertFromUtf32(13) + "<TextBox Name=\"control" + Counter.ToString() + "\" Height=\"" + ((ctlPOD)o).Height + "\" Width=\"" + ((ctlPOD)o).Width + "\" Canvas.Left=\"" + ((ctlPOD)o).GetValue(Canvas.LeftProperty) + "\" Canvas.Top=\"" + ((ctlPOD)o).GetValue(Canvas.TopProperty) + "\" Background=\"" + ((TextBox)chl).Background + "\" Foreground=\"" + ((TextBox)chl).Foreground + "\" Tag=\"" + ((TextBox)chl).Tag + "\" Text=\"" + ((TextBox)chl).Text + "\" FontFamily=\"" + ((TextBox)chl).FontFamily + "\" FontSize=\"" + ((TextBox)chl).FontSize + "\" IsEnabled=\"" + ((ctlPOD)o).IsEnabled + "\" FontWeight=\"" + ((TextBox)chl).FontWeight + "\" FontStyle=\"" + ((TextBox)chl).FontStyle + "\"/>";
                            }


                            else if (chl.GetType() == typeof(Label))
                            {
                                strXML = strXML + char.ConvertFromUtf32(13) + "<Label Name=\"control" + Counter.ToString() + "\" Height=\"" + ((ctlPOD)o).Height + "\" Width=\"" + ((ctlPOD)o).Width + "\" Canvas.Left=\"" + ((ctlPOD)o).GetValue(Canvas.LeftProperty) + "\" Canvas.Top=\"" + ((ctlPOD)o).GetValue(Canvas.TopProperty) + "\" Background=\"" + ((Label)chl).Background + "\" Foreground=\"" + ((Label)chl).Foreground + "\" Tag=\"" + ((Label)chl).Tag + "\" Content=\"" + ((Label)chl).Content + "\" FontFamily=\"" + ((Label)chl).FontFamily + "\" FontSize=\"" + ((Label)chl).FontSize + "\" FontWeight=\"" + ((Label)chl).FontWeight + "\" FontStyle=\"" + ((Label)chl).FontStyle + "\"/>";
                            }

                        }
                    }
                }
                strXML = strXML + char.ConvertFromUtf32(13) + "</Canvas></TabItem>";
                }
                strXML = strXML + "</TabControl>";
                strXML = strXML + " <Button Name=\"btnSave\" Height=\"25\" Width=\"70\" Canvas.Top=\"" + int.Parse((int.Parse(tbcMain.Height.ToString()) + 5).ToString()).ToString() + "\" Canvas.Left=\"100\" Content=\"Save\" Click=\"btnSave_Click\" /> <Button Name=\"btnCancel\" Height=\"25\" Width=\"70\" Canvas.Top=\"" + int.Parse((int.Parse(tbcMain.Height.ToString()) + 5).ToString()).ToString() + "\" Canvas.Left=\"200\" Content=\"Cancel\" Click=\"btnCancel_Click\" /> </Canvas></UserControl>";

                TextWriter tw = new StreamWriter(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "\\CRM_src\\CRM.Presentation\\" + startQuestion.ToString() + ".Xaml"));
                tw.WriteLine(strXML);
                tw.Close();

                TextReader tr101 = new StreamReader(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll","\\CRMPages\\Binded Data.txt"));
                string str101 = tr101.ReadToEnd();
                tr101.Close();


                strXML = "using System;" + char.ConvertFromUtf32(13) +
                         "using System.Collections.Generic;" + char.ConvertFromUtf32(13) +
                         "using System.Linq;" + char.ConvertFromUtf32(13) +
                         "using System.Text;" + char.ConvertFromUtf32(13) +
                         "using System.Windows;" + char.ConvertFromUtf32(13) +
                         "using System.Windows.Controls;" + char.ConvertFromUtf32(13) +
                         "using System.Windows.Data;" + char.ConvertFromUtf32(13) +
                         "using System.Windows.Documents;" + char.ConvertFromUtf32(13) +
                         "using System.Windows.Input;" + char.ConvertFromUtf32(13) +
                         "using System.Windows.Media;" + char.ConvertFromUtf32(13) +
                         "using System.Windows.Media.Imaging;" + char.ConvertFromUtf32(13) +
                         "using System.Windows.Navigation;" + char.ConvertFromUtf32(13) +
                         "using System.Windows.Shapes;" + char.ConvertFromUtf32(13) +
                         "using CRM.Business;" + char.ConvertFromUtf32(13) +
                         char.ConvertFromUtf32(13) +

                         "namespace CRM.Presentation" + char.ConvertFromUtf32(13) +
                         "{" + char.ConvertFromUtf32(13) + 
                          "" + char.ConvertFromUtf32(13) +
                            "public partial class UserControl" + Convert.ToString(1) + ": UserControl" + char.ConvertFromUtf32(13) +
                                "{" + char.ConvertFromUtf32(13) + "" + char.ConvertFromUtf32(13) +
                                    "public UserControl" + Convert.ToString(1) + "()" + char.ConvertFromUtf32(13) +
                                     "{" + char.ConvertFromUtf32(13) +
                                     "InitializeComponent();" + char.ConvertFromUtf32(13)  + char.ConvertFromUtf32(13) +
                                     "VMuktiAPI.VMuktiHelper.RegisterEvent(\"SetLeadIDCRM\").VMuktiEvent += new VMuktiAPI.VMuktiEvents.VMuktiEventHandler(SetLeadIDCRM_VMuktiEvent);" + char.ConvertFromUtf32(13) +
                                     "}" + str101 + char.ConvertFromUtf32(13) + char.ConvertFromUtf32(13) + strCode + char.ConvertFromUtf32(13) +
                                     "}" + char.ConvertFromUtf32(13) +
                                     "}"; 

                TextWriter tw1 = new StreamWriter(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "\\CRM_src\\CRM.Presentation\\" + startQuestion.ToString() + ".Xaml.Cs"));
                tw1.WriteLine(strXML);
                tw1.Close();

                AddRef1_2 = AddRef1_2 + char.ConvertFromUtf32(13) + "<Page Include=\"" + startQuestion.ToString() + ".xaml\">"
                + char.ConvertFromUtf32(13) + "<Generator>MSBuild:Compile</Generator>"
                + char.ConvertFromUtf32(13) + "<SubType>Designer</SubType>"
                + char.ConvertFromUtf32(13) + "</Page>";

                AddRef2_3 = AddRef2_3 + char.ConvertFromUtf32(13) + "<Compile Include=\"" + startQuestion.ToString() + ".Xaml.Cs\">"
                + char.ConvertFromUtf32(13) + "<DependentUpon>" + startQuestion.ToString() + ".Xaml</DependentUpon>"
                + char.ConvertFromUtf32(13) + "<SubType>Code</SubType>"
                + char.ConvertFromUtf32(13) + "</Compile>";


                #endregion
            }

            #region Create Project File


            TextWriter tw11 = new StreamWriter(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "\\CRM_src\\CRM.Presentation\\CRM.Presentation.csproj"));

            TextReader tr1 = new StreamReader(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "\\CRMPages\\1.txt"));
            string str1 = tr1.ReadToEnd();
            tr1.Close();

            TextReader tr2 = new StreamReader(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "\\CRMPages\\2.txt"));
            string str2 = tr2.ReadToEnd();
            tr2.Close();

            TextReader tr3 = new StreamReader(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "\\CRMPages\\3.txt"));
            string str3 = tr3.ReadToEnd();
            tr3.Close();

            tw11.WriteLine(str1 + AddRef2_3 + str2 + AddRef1_2 + str3);
            str1 = "";
            str2 = "";
            str3 = "";
            AddRef1_2 = "";
            AddRef2_3 = "";
            tw11.Close();

            TextWriter twStart = new StreamWriter(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "\\CRM_src\\CRM.Presentation\\clsStartClass.cs"));
            TextReader trClassRead = new StreamReader(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "\\CRMPages\\ClassRead.txt"));
            string strClassRead = trClassRead.ReadToEnd();
            trClassRead.Close();

            string strBetween = char.ConvertFromUtf32(13) + "public static string strStartQuesion = \"UserControl" + startQuestionID.ToString() + "\";" + char.ConvertFromUtf32(13) + "public static int LeadID = 1;" + char.ConvertFromUtf32(13) + "public static int CallID;" + char.ConvertFromUtf32(13) + "public static string StateName = null;" + char.ConvertFromUtf32(13) + "public static string ZipCode = null;" + char.ConvertFromUtf32(13) + "}" + char.ConvertFromUtf32(13) + "}";

            twStart.WriteLine(strClassRead + strBetween);
            twStart.Close();

            #endregion


            #region After Integration
            //if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + "CRM_src\\Script.DataAccess\\ReferencedAssemblies"))
            //{
            //    Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "CRM_src\\Script.DataAccess\\ReferencedAssemblies");
            //}

            //File.Copy(Assembly.GetAssembly(typeof(VMuktiAPI.ClsPeer)).Location, Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", @"\Script_src\Script.DataAccess\ReferencedAssemblies\VMuktiAPI.dll"));
            
            #endregion

            
            //#region Building the solution File

            //TextWriter tw1111 = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "\\Script\\Build.bat");
            //tw1111.WriteLine("cd\\");
            //tw1111.WriteLine("C:");
            //tw1111.WriteLine("cd \"C:\\WINDOWS\\Microsoft.NET\\Framework\\v3.5\"");
            //tw1111.WriteLine("msbuild \"" + AppDomain.CurrentDomain.BaseDirectory + "\\Script\\Script.sln\" /t:Rebuild /p:Configuration=Debug");
            //tw1111.Close();

            //System.Diagnostics.Process.Start(AppDomain.CurrentDomain.BaseDirectory + "\\Script\\Build.bat");

            //#endregion

            //MessageBox.Show("Working Till Now");

            #region DLL File Naming

            if (cmbCRM.SelectedIndex < 0)
            {
                MessageBox.Show("Please select a CRM Name");
            }
            else
            {
                string crmName = ((ComboBoxItem)cmbCRM.SelectedItem).Content.ToString();

                TextReader txtReader = new StreamReader(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "\\CRM_src\\CRM.Presentation\\CRM.Presentation.csproj"));
                string txtString = txtReader.ReadToEnd();
                txtReader.Close();

                txtString = txtString.Replace("<AssemblyName>CRM.Presentation</AssemblyName>", "<AssemblyName>" + crmName + "_CRM.Presentation</AssemblyName>");

                TextWriter txtWriter = new StreamWriter(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "\\CRM_src\\CRM.Presentation\\CRM.Presentation.csproj"));
                txtWriter.WriteLine(txtString);
                txtWriter.Close();



                TextReader txtReader1 = new StreamReader(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "\\CRM_src\\CRM.Business\\CRM.Business.csproj"));
                string txtString1 = txtReader1.ReadToEnd();
                txtReader1.Close();

                txtString1 = txtString1.Replace("<AssemblyName>CRM.Business</AssemblyName>", "<AssemblyName>" + crmName + "_CRM.Business</AssemblyName>");

                TextWriter txtWriter1 = new StreamWriter(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "\\CRM_src\\CRM.Business\\CRM.Business.csproj"));
                txtWriter1.WriteLine(txtString1);
                txtWriter1.Close();



                TextReader txtReader2 = new StreamReader(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "\\CRM_src\\CRM.Common\\CRM.Common.csproj"));
                string txtString2 = txtReader2.ReadToEnd();
                txtReader2.Close();

                txtString2 = txtString2.Replace("<AssemblyName>CRM.Common</AssemblyName>", "<AssemblyName>" + crmName + "_CRM.Common</AssemblyName>");

                TextWriter txtWriter2 = new StreamWriter(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "\\CRM_src\\CRM.Common\\CRM.Common.csproj"));
                txtWriter2.WriteLine(txtString2);
                txtWriter2.Close();

                TextReader txtReader3 = new StreamReader(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "\\CRM_src\\CRM.DataAccess\\CRM.DataAccess.csproj"));
                string txtString3 = txtReader3.ReadToEnd();
                txtReader3.Close();

                txtString3 = txtString3.Replace("<AssemblyName>CRM.DataAccess</AssemblyName>", "<AssemblyName>" + crmName + "_CRM.DataAccess</AssemblyName>");

                TextWriter txtWriter3 = new StreamWriter(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "\\CRM_src\\CRM.DataAccess\\CRM.DataAccess.csproj"));
                txtWriter3.WriteLine(txtString3);
                txtWriter3.Close();

            #endregion

                #region Building the solution File

                string winDir = Environment.GetFolderPath(Environment.SpecialFolder.System);
                winDir = winDir.Substring(0, winDir.LastIndexOf(@"\"));

                Process buildProcess = new Process();

                File.Copy(Assembly.GetAssembly(typeof(VMuktiAPI.ClsPeer)).Location, Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", @"\CRM_src\CRM.DataAccess\ReferencedAssemblies\VMuktiAPI.dll"));
                //MessageBox.Show(Assembly.GetAssembly(typeof(VMuktiAPI.ClsPeer)).Location);
                //MessageBox.Show(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", @"Script_src\Script.Presentation\ReferencedAssemblies\VMuktiAPI.dll"));
                File.Copy(Assembly.GetAssembly(typeof(VMuktiAPI.ClsPeer)).Location, Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", @"CRM_src\CRM.Presentation\ReferencedAssemblies\VMuktiAPI.dll"));

                buildProcess.OutputDataReceived += new DataReceivedEventHandler(buildProcess_OutputDataReceived);
                //TextWriter tw1111 = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "\\Script\\Build.bat");
                //tw1111.WriteLine("cd\\");
                //tw1111.WriteLine("C:");
                //tw1111.WriteLine("cd \"C:\\WINDOWS\\Microsoft.NET\\Framework\\v3.5\"");
                //tw1111.WriteLine("msbuild \"" + AppDomain.CurrentDomain.BaseDirectory + "\\Script\\Script.sln\" /t:Rebuild /p:Configuration=Debug");
                //tw1111.Close();
                //System.Diagnostics.Process.Start(AppDomain.CurrentDomain.BaseDirectory + "\\Script\\Build.bat");

                try
                {

                    if (System.IO.Directory.Exists(winDir + @"\Microsoft.NET\Framework\v3.5\"))
                    {
                        //buildProcess.StartInfo.UseShellExecute = false;
                        buildProcess.StartInfo.WorkingDirectory = winDir + @"\Microsoft.NET\Framework\v3.5\";
                        buildProcess.StartInfo.FileName = "msbuild";
                        buildProcess.StartInfo.Arguments = @" """ + Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "") + @"\CRM_src\CRM.sln"" /t:Rebuild /p:Configuration=Debug";
                        buildProcess.Start();
                        buildProcess.WaitForExit();
                    }
                    else
                    {
                        MessageBox.Show("Microsoft .Net framework is not installed at --> \" " + winDir + @"\Microsoft.NET\Framework\v3.5\" + " \"!!");
                    }
                }
                catch (Exception exp)
                {
                    MessageBox.Show(exp.Message.ToString());
                }

                #endregion

                try
                {

                    if (Directory.Exists(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "") + crmName + "_CRM"))
                    {
                        Directory.Delete(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "") + crmName + "_CRM", true);
                    }
                    Directory.CreateDirectory(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "") + crmName + "_CRM");
                    Directory.CreateDirectory(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "") + crmName + "_CRM" + "\\" + crmName + "_CRM");
                    Directory.CreateDirectory(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "") + crmName + "_CRM" + "\\" + crmName + "_CRM" + @"\BAL");
                    Directory.CreateDirectory(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "") + crmName + "_CRM" + "\\" + crmName + "_CRM" + @"\DAL");
                    Directory.CreateDirectory(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "") + crmName + "_CRM" + "\\" + crmName + "_CRM" + @"\Control");


                }
                catch (Exception exp)
                {
                    MessageBox.Show("Creating Directories" + exp.Message);
                }

                try
                {
                    copyDirectory(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "") + @"CRM_src\CRM.Presentation\bin\Debug", Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "") + @"CRM");
                }
                catch (Exception exp)
                {
                    MessageBox.Show("Creating Directories" + exp.Message);
                }

                try
                {
                    string[] filesToDelete = Directory.GetFiles(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "") + @"CRM", "*.pdb");
                    for (int i = 0; i < filesToDelete.Length; i++)
                    {
                        File.Delete(filesToDelete[i]);
                    }
                }
                catch (Exception exp)
                {
                    MessageBox.Show("Deleting Files" + exp.Message);
                }

                try
                {

                    string[] filesToMove = Directory.GetFiles(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "") + @"CRM", "*.dll");
                    for (int i = 0; i < filesToMove.Length; i++)
                    {
                        if (filesToMove[i].Substring(filesToMove[i].LastIndexOf(@"\")).Contains("Business"))
                        {
                            File.Move(filesToMove[i], Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "") + crmName + "_CRM" + "\\" + crmName + "_CRM" + @"\BAL" + filesToMove[i].Substring(filesToMove[i].LastIndexOf(@"\")));
                        }
                        else if (filesToMove[i].Substring(filesToMove[i].LastIndexOf(@"\")).Contains("Common"))
                        {
                            File.Move(filesToMove[i], Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "") + crmName + "_CRM" + "\\" + crmName + "_CRM" + @"\BAL" + filesToMove[i].Substring(filesToMove[i].LastIndexOf(@"\")));
                        }
                        else if (filesToMove[i].Substring(filesToMove[i].LastIndexOf(@"\")).Contains("DataAccess"))
                        {
                            File.Move(filesToMove[i], Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "") + crmName + "_CRM" + "\\" + crmName + "_CRM" + @"\DAL" + filesToMove[i].Substring(filesToMove[i].LastIndexOf(@"\")));
                        }
                        else if (filesToMove[i].Substring(filesToMove[i].LastIndexOf(@"\")).Contains("Presentation"))
                        {
                            File.Move(filesToMove[i], Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "") + crmName + "_CRM" + "\\" + crmName + "_CRM" + @"\Control" + filesToMove[i].Substring(filesToMove[i].LastIndexOf(@"\")));
                        }
                        else if (filesToMove[i].Substring(filesToMove[i].LastIndexOf(@"\")).Contains("VMuktiAPI"))
                        {

                            File.Delete(filesToMove[i]);

                            //File.Move(filesToMove[i], Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + @"Script\Control\" + filesToMove[i].Substring(filesToMove[i].LastIndexOf(@"\")));
                        }
                    }

                }
                catch (Exception exp)
                {
                    MessageBox.Show("Move Files" + exp.Message);
                }

                try
                {

                    Directory.Delete(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "") + @"CRM_src\CRM.Presentation\bin", true);
                    Directory.Delete(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "") + @"CRM_src\CRM.Presentation\obj", true);
                    Directory.Delete(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "") + @"CRM_src\CRM.Business\bin", true);
                    Directory.Delete(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "") + @"CRM_src\CRM.Business\obj", true);
                    Directory.Delete(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "") + @"CRM_src\CRM.Common\bin", true);
                    Directory.Delete(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "") + @"CRM_src\CRM.Common\obj", true);
                    Directory.Delete(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "") + @"CRM_src\CRM.DataAccess\bin", true);
                    Directory.Delete(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "") + @"CRM_src\CRM.DataAccess\obj", true);
                }
                catch (Exception exp)
                {
                    MessageBox.Show("Deleting Files" + exp.Message);
                }

                ICSharpCode.SharpZipLib.Zip.FastZip fz = new ICSharpCode.SharpZipLib.Zip.FastZip();
                try
                {
                    fz.CreateZip(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "") + @"CRM_src.zip", Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "") + @"CRM_src", true, "");
                    //fz.CreateZip(AppDomain.CurrentDomain.BaseDirectory + @"CRM_src.zip", AppDomain.CurrentDomain.BaseDirectory + @"CRM_src", true, "");
                }
                catch (Exception exp)
                {
                    MessageBox.Show("Create Zip" + exp.Message);
                }

                try
                {
                    fz.CreateZip(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "") + crmName + "_CRM" + @".zip", Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "") + crmName + "_CRM", true, "");
                    //fz.CreateZip(AppDomain.CurrentDomain.BaseDirectory + @"CRM.zip", AppDomain.CurrentDomain.BaseDirectory + @"CRM", true, "");
                }
                catch (Exception exp)
                {
                    MessageBox.Show("Create Zip" + exp.Message);
                }

                try
                {
                    Directory.Delete(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "") + @"CRM_src", true);
                    //Directory.Delete(AppDomain.CurrentDomain.BaseDirectory + @"CRM_src", true);
                }
                catch (Exception exp)
                {
                    MessageBox.Show("Delete Directory" + exp.Message);
                }

                try
                {
                    Directory.Delete(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "") + crmName + "_CRM", true);
                    //Directory.Delete(AppDomain.CurrentDomain.BaseDirectory + @"CRM", true);
                }
                catch (Exception exp)
                {
                    MessageBox.Show("Delete Directory" + exp.Message);
                }

                try
                {
                    System.Windows.Forms.DialogResult sfdRes;
                    System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog();
                    sfd.Filter = "Zip file(s) (*.zip)|*.zip";
                    sfd.Title = "Save the source file of script to edit manualy!!";
                    sfd.FileName = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\CRM_src.zip";
                    sfdRes = sfd.ShowDialog();

                    if (sfdRes == System.Windows.Forms.DialogResult.OK)
                    {
                        if (File.Exists(sfd.FileName))
                        {
                            File.Delete(sfd.FileName);
                        }
                        File.Move(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "") + @"CRM_src.zip", sfd.FileName);
                    }

                    //sfd.Title = "Save the file of script to add as a module in VMukti plateform!!";
                    //sfd.FileName = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\" + crmName + @".zip";
                    //sfdRes = sfd.ShowDialog();
                    //if (sfdRes == System.Windows.Forms.DialogResult.OK)
                    //{
                    //    if (File.Exists(sfd.FileName))
                    //    {
                    //        File.Delete(sfd.FileName);
                    //    }

                    #region UploadFile

                    System.IO.FileInfo fileInfo = new System.IO.FileInfo(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "") + crmName + "_CRM" + @".zip");
                    System.IO.FileStream stream = new System.IO.FileStream(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "") + crmName + "_CRM" + @".zip", System.IO.FileMode.Open, System.IO.FileAccess.Read);
                    RemoteFileInfo rfi = new RemoteFileInfo();
                    rfi.FileName = fileInfo.Name;
                    rfi.Length = fileInfo.Length;
                    rfi.FileByteStream = stream;
                    rfi.FolderNameToStore = "CRMs";
                    clientHttpFileTransfer.svcHTTPFileTransferServiceUploadFileToInstallationDirectory(rfi);
                    stream.Close();
                    if (File.Exists(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "") + crmName + "_CRM" + @".zip"))
                    {
                        File.Delete(Assembly.GetAssembly(this.GetType()).Location.Replace("CRMDesigner.Presentation.dll", "") + crmName + "_CRM" + @".zip");
                    }


                    #endregion

                }
                catch (Exception exp)
                {
                }

            #endregion
            }
        }
コード例 #56
0
ファイル: DeployController.cs プロジェクト: lgadi/ZeeBi
        public ActionResult Deploy(string payload)
        {
            var sentPayload = JsonConvert.DeserializeObject<JObject>(payload);

            var head = GetHead(sentPayload);
            var commits = GetCommits(sentPayload);

            var sourcesUrl = "https://github.com/lgadi/ZeeBi/zipball/master";
            var logFile = @"C:\ZeeBi\deploy.log";

            System.IO.File.AppendAllText(logFile, "\r\nDeploying starts at " + DateTime.UtcNow);

            var t = Task.Factory.StartNew(() =>
            {
                var client = new WebClient();
                client.DownloadDataCompleted += (s, e) =>
                {
                    System.IO.File.AppendAllText(logFile, "sources arrived\r\n");
                    var output = new StringBuilder();
                    try
                    {
                        var sourcesDir = @"C:\ZeeBi\sources";
                        var sourcesZip = @"C:\ZeeBi\sources.zip";
                        System.IO.File.WriteAllBytes(sourcesZip, e.Result);

                        if (Directory.Exists(sourcesDir)) Directory.Delete(sourcesDir, true);

                        var zip = new ICSharpCode.SharpZipLib.Zip.FastZip();
                        zip.ExtractZip(sourcesZip, sourcesDir, string.Empty);
                        System.IO.File.AppendAllText(logFile, "sources unzipped\r\n");

                        // the data is actually in a sub-folder:
                        sourcesDir = Directory.GetDirectories(sourcesDir)[0];

                        var startInfo = new ProcessStartInfo(Path.Combine(sourcesDir,"deploy.bat"))
                        {
                            CreateNoWindow = true,
                            WorkingDirectory = sourcesDir,
                            RedirectStandardOutput = true,
                            RedirectStandardError = true,
                            UseShellExecute = false,
                            ErrorDialog = false,
                        };
                        startInfo.EnvironmentVariables.Add("GIT_COMMIT_HEAD", head);
                        startInfo.EnvironmentVariables.Add("GIT_COMMITS", commits);
                        var p = Process.Start(startInfo);
                        p.OutputDataReceived += (proc, data) => output.AppendLine(data.Data);
                        p.BeginOutputReadLine();
                        p.ErrorDataReceived += (proc, data) => output.AppendLine(data.Data);
                        p.BeginErrorReadLine();
                        p.WaitForExit();
                    }
                    catch (Exception ex)
                    {
                        System.IO.File.AppendAllText(logFile, "\r\n");
                        System.IO.File.AppendAllText(logFile, "EXCEPTION:\r\n");
                        System.IO.File.AppendAllText(logFile, ex.ToString());
                        System.IO.File.AppendAllText(logFile, "\r\n");
                    }
                    finally
                    {
                        System.IO.File.AppendAllText(logFile, "deploy output:\r\n");
                        System.IO.File.AppendAllText(logFile, output + "\r\n");
                        System.IO.File.AppendAllText(logFile, "==============\r\n");
                    }
                };

                client.DownloadDataAsync(new Uri(sourcesUrl));
            });
            System.IO.File.AppendAllText(logFile, "\r\nDownloading sources ... ");

            return Content("OK");
        }
コード例 #57
0
        public bool InstallPlugin(string PluginPackagePath, ref string ErrorText)
        {
            string exePath = Path.GetDirectoryName(Application.ExecutablePath);
            if (Directory.Exists(exePath + "/tempDir/"))
            {
                Directory.Delete(exePath + "/tempDir/", true);
            }

            PluginDescription desc = new PluginDescription();
            string tempfolder = exePath + "/tempDir/";
            string zipFileName = Path.GetFullPath(PluginPackagePath);
            string DescPath = null;

            bool NoError = true;

            ICSharpCode.SharpZipLib.Zip.FastZip fastZip = new ICSharpCode.SharpZipLib.Zip.FastZip();
            try
            {
                fastZip.ExtractZip(zipFileName, tempfolder, null);
                // find all included plugin descriptions and install the plugins
                List<string> osapdFiles = new List<string>();
                List<string> sqlFiles = new List<string>();

                string[] pluginFile = Directory.GetFiles(tempfolder, "*.osapd", SearchOption.TopDirectoryOnly);
                osapdFiles.AddRange(pluginFile);
                string[] sqlFile = Directory.GetFiles(tempfolder, "*.sql", SearchOption.TopDirectoryOnly);
                sqlFiles.AddRange(sqlFile);

                if (osapdFiles.Count == 0)
                {
                    MessageBox.Show("No plugin description files found.");
                    return false;
                }

                if (osapdFiles.Count > 1)
                {
                    MessageBox.Show("More than one plugin description file found.");
                    return false;
                }
                if (osapdFiles.Count == 1)
                {

                    DescPath = osapdFiles[0];
                }

                if (!string.IsNullOrEmpty(DescPath))
                {
                    desc.Deserialize(DescPath);

                    //NoError = desc.VerifyInstall(ref ErrorText);

                    //uninstall previous plugin and delete the folder
                    if (UninstallPlugin(desc))
                    {

                        // get the plugin folder path
                        string pluginFolder = desc.Path;
                        if (!string.IsNullOrEmpty(pluginFolder))  //only extract valid plugins
                        {
                            string[] files = System.IO.Directory.GetFiles(tempfolder);

                            string ConnectionString = string.Format("Uid={0};Pwd={1};Server={2};Port={3};Database={4};allow user variables=true",
                                Common.DBUsername, Common.DBPassword, Common.DBConnection, Common.DBPort, Common.DBName);
                            MySql.Data.MySqlClient.MySqlConnection connection = new MySql.Data.MySqlClient.MySqlConnection(ConnectionString);
                            connection.Open();
                            foreach (string s in sqlFile)
                            {
                                try
                                {

                                    MySql.Data.MySqlClient.MySqlScript script = new MySql.Data.MySqlClient.MySqlScript(connection, File.ReadAllText(s));
                                    script.Execute();
                                }
                                catch (Exception ex)
                                {
                                    this.Log.Error("Error running sql script: " + s, ex);
                                }
                            }

                            System.IO.Directory.Move(tempfolder, exePath + "/Plugins/" + pluginFolder);

                            //Check if we are running a x64 bit architecture (This is a silly way to do it since I am not sure if every 64 bit machine has this directory...)
                            bool is64bit = Environment.Is64BitOperatingSystem;

                            //Do a check for any x64 assemblies, and prompt the user to install them if they are running a 64 bit machine
                            if (is64bit && (desc.x64Assemblies.Count > 0))
                            {
                                /* x64 assemblies generally have the same name as their x32 counterparts when referenced by the OSA app
                                 * however they are packaged as "filename.ext.x64" so we will replace the 32bit file which is installed by
                                 * default with the 64bit versioin with the same filename.ext
                                 */

                                if (MessageBox.Show(
                                    "You are running an x64 architecture and this plugin has specific assemblies built for 64bit machines." +
                                    " It is highly recommended that you install the 64bit versions to ensure proper compatibility",
                                    "Install 64bit Assemblies?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                                {
                                    //Install the 64bit assemblies over the 32 bit ones...
                                    string[] x64files = System.IO.Directory.GetFiles(exePath + "/Plugins/" + pluginFolder, "*.x64");

                                    foreach (string str in x64files)
                                    {
                                        string destFile = System.IO.Path.Combine(exePath + "/Plugins/" + pluginFolder + "/", System.IO.Path.GetFileNameWithoutExtension(str));
                                        //Copy it to the new destination overwriting the old file if it exists
                                        System.IO.File.Copy(str, destFile, true);
                                    }
                                }
                            }

                            //Delete all the files with .x64 extensions since they aren't needed anymore
                            string[] delfiles = System.IO.Directory.GetFiles(exePath + "/Plugins/" + pluginFolder, "*.x64");
                            foreach (string str in delfiles)
                                System.IO.File.Delete(str);

                            this.Log.Info("Sending message to service to load plugin.");

                        }
                    }
                    else
                        return false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("catch: " + ex.Message);
                return false;
            }
                if (Directory.Exists(exePath + "/tempDir/"))
                {
                    deleteFolder(exePath + "/tempDir/");
                }

                OSAEMethodManager.MethodQueueAdd("SERVICE-" + Common.ComputerName, "RELOAD PLUGINS", "", "", "Plugin Installer");
            return NoError;
        }
コード例 #58
0
        void FncSaveFiles()
        {
            g = 0;
            try
            {
                Assembly ass2 = Assembly.GetEntryAssembly();

                strModPath = ass2.Location.Replace("VMukti.Presentation.exe", @"ScriptModules");

                DirectoryInfo d = new DirectoryInfo(strModPath);


                //  MessageBox.Show(strModPath);
                foreach (DirectoryInfo subDir in d.GetDirectories())
                {
                    // ShowDirectory(subDir);
                    // MessageBox.Show(subDir.Name);
                    foreach (DirectoryInfo subDir2 in subDir.GetDirectories())
                    {
                        string[] del = { str };
                        if (subDir2.Name.Contains(str))
                        {
                            string[] name = null;
                            name = subDir2.Name.Split(del, StringSplitOptions.None);

                            //  MessageBox.Show(name[1]+"   b");
                            if (name[1].Trim().Equals(""))
                            {
                                //do nothing

                            }
                            else
                            {
                                if (Int32.Parse(name[1]) > g)
                                    g = Int32.Parse(name[1]);


                            }

                        }
                    }
                }
                g++;
               // MessageBox.Show(g + "");
                if (g != 0)
                {
                    str += g.ToString();
                   // MessageBox.Show(g.ToString());
                    //if (!Directory.Exists(strModPath + "\\" + str, true))
                    //{
                    //    Directory.CreateDirectory(strModPath+"\\"+str , true);
                    //}
                }
                else
                {


                }
            }
            catch(Exception e)
            {
                VMuktiAPI.VMuktiHelper.ExceptionHandler(e, "FncSaveFiles", "ctlScriptdesigner.xaml.cs");
                g++;
            }
            if (flag == false)
            {
                _ScriptName += "_Script";  //Extending _Script with the script name so that it doesn't create conflicts with CRM with same name.
               server = ScriptName;
                
                _ScriptName += g.ToString();

                
                flag = true;
            }

           #region Create Base Solution

            try
            {
                if (Directory.Exists(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "SS")))
                {
                    Directory.Delete(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", @"SS"), true);
                }
                Directory.CreateDirectory(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "SS"));
            }
            catch (Exception exp)
            {
                VMuktiAPI.VMuktiHelper.ExceptionHandler(exp, "FncSaveFiles", "ctlScriptdesigner.xaml.cs");
            }

            //MessageBox.Show(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "ScriptBase"));
            //MessageBox.Show(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "SS"));

            copyDirectory(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "ScriptBase"), Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "SS"));
            if (!Directory.Exists(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", @"SS\Script.DataAccess\ReferencedAssemblies")))
            {
                Directory.CreateDirectory(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", @"SS\Script.DataAccess\ReferencedAssemblies"));
            }

            if (!Directory.Exists(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", @"SS\Script.Presentation\ReferencedAssemblies")))
            {
                Directory.CreateDirectory(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", @"SS\Script.Presentation\ReferencedAssemblies"));
            }
            
           #endregion



            if (startQuestion == "")
            {
                startQuestion = objQueCollection[CurrentQueCount - 1].QuestionName;
                startQuestionID = objQueCollection[CurrentQueCount - 1].ID;
            }

            #region Saving Files

            CurrentQueCount = -1;

            //MessageBox.Show(lstCanvas.Count.ToString());

            for (int j = 0; j < lstCanvas.Count; j++)
            {
                CurrentQueCount++;
                int Counter = 0;
                string strCode = "";
                pageCount++;

                #region Creating .XAML File

                string strXML = "";
                strXML = "<UserControl x:Class=\"Script.Presentation.UserControl" + objQueCollection[CurrentQueCount].ID.ToString() + "\" xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" Height=\"" + lstCanvas[j].Height + "\" Width=\"" + lstCanvas[j].Width + "\">";
                strXML = strXML + char.ConvertFromUtf32(13) + "<Canvas Name=\"cnvPaint" + "\" Height=\"" + lstCanvas[j].Height + "\" Width=\"" + lstCanvas[j].Width + "\" Background=\"" + lstCanvas[j].Background + "\">";

                foreach (object o in lstCanvas[j].Children)
                {
                    if (o.GetType() == typeof(ctlPOD))
                    {
                        foreach (object chl in ((ctlPOD)o).cnvPOD.Children)
                        {
                            Counter++;
                            if (chl.GetType() == typeof(Button))
                            {
                                if (((Button)chl).Tag != null)
                                {
                                   // if (((Button)chl).Tag.ToString().ToLower() != "")
                                    {
                                     //   MessageBox.Show(((Button)chl).Content.ToString() + "     1");
                                        string[] chkStr = ((Button)chl).Tag.ToString().Split('-');

                                        if (chkStr[0] == "DISPOSITION")
                                        {
                                            strCode = strCode + char.ConvertFromUtf32(13) + " void control" + Counter.ToString() + "_Click(object sender, RoutedEventArgs e)" + char.ConvertFromUtf32(13) +
                                                "{" + char.ConvertFromUtf32(13) +
                                                "clsStartClass.sCurrentDispositionID = \"" + chkStr[1] + "\";" +
                                                char.ConvertFromUtf32(13) +
                                                //"VMuktiAPI.VMuktiHelper.CallEvent(\"HangUp\", this, new VMuktiAPI.VMuktiEventArgs(\"ScriptRender\", int.Parse(clsStartClass.sCurrentChannelID) + 1));" + char.ConvertFromUtf32(13) +
                                                "((MainPage)((Canvas)((Canvas)((Canvas)this.Parent).Parent).Parent).Parent).SetDispositionCanvas();" + char.ConvertFromUtf32(13) +
                                                char.ConvertFromUtf32(13) +
                                                "}";
                                        }
                                        else
                                        {

                                            TextReader tr = new StreamReader(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "\\ScriptPages\\FixedCode.txt"));
                                            string abc = tr.ReadToEnd();
                                            tr.Close();

                                            strCode = strCode + char.ConvertFromUtf32(13) + " void control" + Counter.ToString() + "_Click(object sender, RoutedEventArgs e)" + char.ConvertFromUtf32(13) +
                                                "{" + char.ConvertFromUtf32(13) +
                                                "ClsQuestionCollectionR objQueCollection = ClsQuestionCollectionR.GetAll(int.Parse(\"" + _ScriptID.ToString() + "\"));" + char.ConvertFromUtf32(13) +
                                                abc + char.ConvertFromUtf32(13) +
                                                "}";
                                        }
                                        string strContent = ((Button)chl).Content.ToString();
                                        strContent = strContent.Replace("&", "&amp;");
                                        strContent = strContent.Replace("\"", "&quot;");
                                        strContent = strContent.Replace("<", "&lt;");
                                        strContent = strContent.Replace(">", "&gt;");

                                        strXML = strXML + char.ConvertFromUtf32(13) + "<Button Name=\"control" + Counter.ToString() + "\" Height=\"" + ((ctlPOD)o).Height + "\" Width=\"" + ((ctlPOD)o).Width + "\" Canvas.Left=\"" + ((ctlPOD)o).GetValue(Canvas.LeftProperty) + "\" Canvas.Top=\"" + ((ctlPOD)o).GetValue(Canvas.TopProperty) + "\" Background=\"" + ((Button)chl).Background + "\" Foreground=\"" + ((Button)chl).Foreground + "\" Tag=\"" + ((Button)chl).Tag + "\" Content=\"" + strContent + "\" FontFamily=\"" + ((Button)chl).FontFamily + "\" FontSize=\"" + ((Button)chl).FontSize + "\" FontWeight=\"" + ((Button)chl).FontWeight + "\" FontStyle=\"" + ((Button)chl).FontStyle + "\" Click=\"control" + Counter.ToString() + "_Click" + "\"/>";
                                    }
                                    //else
                                    {
                                     //   MessageBox.Show(((Button)chl).Content.ToString() + "     2");
                                    }
                                }
                                else
                                {
                                   // MessageBox.Show(((Button)chl).Content.ToString() + "     3");
                                    string strContent = ((Button)chl).Content.ToString();
                                    strContent = strContent.Replace("&", "&amp;");
                                    strContent = strContent.Replace("\"", "&quot;");
                                    strContent = strContent.Replace("<", "&lt;");
                                    strContent = strContent.Replace(">", "&gt;");

                                    strXML = strXML + char.ConvertFromUtf32(13) + "<Button Name=\"control" + Counter.ToString() + "\" Height=\"" + ((ctlPOD)o).Height + "\" Width=\"" + ((ctlPOD)o).Width + "\" Canvas.Left=\"" + ((ctlPOD)o).GetValue(Canvas.LeftProperty) + "\" Canvas.Top=\"" + ((ctlPOD)o).GetValue(Canvas.TopProperty) + "\" Background=\"" + ((Button)chl).Background + "\" Foreground=\"" + ((Button)chl).Foreground + "\" Tag=\"" + ((Button)chl).Tag + "\" Content=\"" + strContent + "\" FontFamily=\"" + ((Button)chl).FontFamily + "\" FontSize=\"" + ((Button)chl).FontSize + "\" FontWeight=\"" + ((Button)chl).FontWeight + "\" FontStyle=\"" + ((Button)chl).FontStyle + "\"/>";
                                }
                            }

                            else if (chl.GetType() == typeof(TextBox))
                            {
                                string strContent = ((TextBox)chl).Text.ToString();
                                strContent = strContent.Replace("&", "&amp;");
                                strContent = strContent.Replace("\"", "&quot;");
                                strContent = strContent.Replace("<", "&lt;");
                                strContent = strContent.Replace(">", "&gt;");

                                strXML = strXML + char.ConvertFromUtf32(13) + "<TextBox Name=\"control" + Counter.ToString() + "\" Height=\"" + ((ctlPOD)o).Height + "\" Width=\"" + ((ctlPOD)o).Width + "\" Canvas.Left=\"" + ((ctlPOD)o).GetValue(Canvas.LeftProperty) + "\" Canvas.Top=\"" + ((ctlPOD)o).GetValue(Canvas.TopProperty) + "\" Background=\"" + ((TextBox)chl).Background + "\" Foreground=\"" + ((TextBox)chl).Foreground + "\" Tag=\"" + ((TextBox)chl).Tag + "\" Text=\"" + strContent + "\" FontFamily=\"" + ((TextBox)chl).FontFamily + "\" FontSize=\"" + ((TextBox)chl).FontSize + "\" FontWeight=\"" + ((TextBox)chl).FontWeight + "\" FontStyle=\"" + ((TextBox)chl).FontStyle + "\"/>";
                            }

                            else if (chl.GetType() == typeof(TextBlock))
                            {
                                string strContent = ((TextBlock)chl).Text.ToString();
                                strContent = strContent.Replace("&", "&amp;");
                                strContent = strContent.Replace("\"", "&quot;");
                                strContent = strContent.Replace("<", "&lt;");
                                strContent = strContent.Replace(">", "&gt;");

                                strXML = strXML + char.ConvertFromUtf32(13) + "<TextBlock Name=\"control" + Counter.ToString() + "\" Height=\"" + ((ctlPOD)o).Height + "\" Width=\"" + ((ctlPOD)o).Width + "\" Canvas.Left=\"" + ((ctlPOD)o).GetValue(Canvas.LeftProperty) + "\" Canvas.Top=\"" + ((ctlPOD)o).GetValue(Canvas.TopProperty) + "\" Background=\"" + ((TextBlock)chl).Background + "\" Foreground=\"" + ((TextBlock)chl).Foreground + "\" Tag=\"" + ((TextBlock)chl).Tag + "\" Text=\"" + strContent + "\" FontFamily=\"" + ((TextBlock)chl).FontFamily + "\" FontSize=\"" + ((TextBlock)chl).FontSize + "\" FontWeight=\"" + ((TextBlock)chl).FontWeight + "\" FontStyle=\"" + ((TextBlock)chl).FontStyle + "\" TextWrapping=\"Wrap\" />";
                            }

                            else if (chl.GetType() == typeof(Label))
                            {
                                string strContent = ((Label)chl).Content.ToString();
                                strContent = strContent.Replace("&", "&amp;");
                                strContent = strContent.Replace("\"", "&quot;");
                                strContent = strContent.Replace("<", "&lt;");
                                strContent = strContent.Replace(">", "&gt;");

                                strXML = strXML + char.ConvertFromUtf32(13) + "<Label Name=\"control" + Counter.ToString() + "\" Height=\"" + ((ctlPOD)o).Height + "\" Width=\"" + ((ctlPOD)o).Width + "\" Canvas.Left=\"" + ((ctlPOD)o).GetValue(Canvas.LeftProperty) + "\" Canvas.Top=\"" + ((ctlPOD)o).GetValue(Canvas.TopProperty) + "\" Background=\"" + ((Label)chl).Background + "\" Foreground=\"" + ((Label)chl).Foreground + "\" Tag=\"" + ((Label)chl).Tag + "\" Content=\"" + strContent + "\" FontFamily=\"" + ((Label)chl).FontFamily + "\" FontSize=\"" + ((Label)chl).FontSize + "\" FontWeight=\"" + ((Label)chl).FontWeight + "\" FontStyle=\"" + ((Label)chl).FontStyle + "\"/>";
                            }

                            else if (chl.GetType() == typeof(ComboBox))
                            {
                                strXML = strXML + char.ConvertFromUtf32(13) + "<ComboBox Name=\"control" + Counter.ToString() + "\" Height=\"" + ((ctlPOD)o).Height + "\" Width=\"" + ((ctlPOD)o).Width + "\" Canvas.Left=\"" + ((ctlPOD)o).GetValue(Canvas.LeftProperty) + "\" Canvas.Top=\"" + ((ctlPOD)o).GetValue(Canvas.TopProperty) + "\" Background=\"" + ((ComboBox)chl).Background + "\" Foreground=\"" + ((ComboBox)chl).Foreground + "\" Tag=\"" + ((ComboBox)chl).Tag + "\" FontFamily=\"" + ((ComboBox)chl).FontFamily + "\" FontSize=\"" + ((ComboBox)chl).FontSize + "\" FontWeight=\"" + ((ComboBox)chl).FontWeight + "\" FontStyle=\"" + ((ComboBox)chl).FontStyle + "\">";
                                for (int i = 0; i < ((ComboBox)chl).Items.Count; i++)
                                {
                                    Counter++;

                                    string strContent = ((ComboBoxItem)((ComboBox)chl).Items[i]).Content.ToString();
                                    strContent = strContent.Replace("&", "&amp;");
                                    strContent = strContent.Replace("\"", "&quot;");
                                    strContent = strContent.Replace("<", "&lt;");
                                    strContent = strContent.Replace(">", "&gt;");

                                    strXML = strXML + char.ConvertFromUtf32(13) + "<ComboBoxItem Name=\"control" + Counter.ToString() + "\" Background=\"" + ((ComboBoxItem)((ComboBox)chl).Items[i]).Background + "\" Foreground=\"" + ((ComboBoxItem)((ComboBox)chl).Items[i]).Foreground + "\" Tag=\"" + ((ComboBoxItem)((ComboBox)chl).Items[i]).Tag + "\" Content=\"" + strContent + "\" FontFamily=\"" + ((ComboBoxItem)((ComboBox)chl).Items[i]).FontFamily + "\" FontSize=\"" + ((ComboBoxItem)((ComboBox)chl).Items[i]).FontSize + "\" FontWeight=\"" + ((ComboBoxItem)((ComboBox)chl).Items[i]).FontWeight + "\" FontStyle=\"" + ((ComboBoxItem)((ComboBox)chl).Items[i]).FontStyle + "\"/>";
                                }
                                strXML = strXML + char.ConvertFromUtf32(13) + "</ComboBox>";
                            }

                            else if (chl.GetType() == typeof(ListBox))
                            {
                                strXML = strXML + char.ConvertFromUtf32(13) + "<ListBox Name=\"control" + Counter.ToString() + "\" Height=\"" + ((ctlPOD)o).Height + "\" Width=\"" + ((ctlPOD)o).Width + "\" Canvas.Left=\"" + ((ctlPOD)o).GetValue(Canvas.LeftProperty) + "\" Canvas.Top=\"" + ((ctlPOD)o).GetValue(Canvas.TopProperty) + "\" Background=\"" + ((ListBox)chl).Background + "\" Foreground=\"" + ((ListBox)chl).Foreground + "\" Tag=\"" + ((ListBox)chl).Tag + "\" FontFamily=\"" + ((ListBox)chl).FontFamily + "\" FontSize=\"" + ((ListBox)chl).FontSize + "\" FontWeight=\"" + ((ListBox)chl).FontWeight + "\" FontStyle=\"" + ((ListBox)chl).FontStyle + "\">";
                                for (int i = 0; i < ((ListBox)chl).Items.Count; i++)
                                {
                                    Counter++;

                                    string strContent = ((ListBoxItem)((ListBox)chl).Items[i]).Content.ToString();
                                    strContent = strContent.Replace("&", "&amp;");
                                    strContent = strContent.Replace("\"", "&quot;");
                                    strContent = strContent.Replace("<", "&lt;");
                                    strContent = strContent.Replace(">", "&gt;");

                                    strXML = strXML + char.ConvertFromUtf32(13) + "<ListBoxItem Name=\"control" + Counter.ToString() + "\" Background=\"" + ((ListBoxItem)((ListBox)chl).Items[i]).Background + "\" Foreground=\"" + ((ListBoxItem)((ListBox)chl).Items[i]).Foreground + "\" Tag=\"" + ((ListBoxItem)((ListBox)chl).Items[i]).Tag + "\" Content=\"" + strContent + "\" FontFamily=\"" + ((ListBoxItem)((ListBox)chl).Items[i]).FontFamily + "\" FontSize=\"" + ((ListBoxItem)((ListBox)chl).Items[i]).FontSize + "\" FontWeight=\"" + ((ListBoxItem)((ListBox)chl).Items[i]).FontWeight + "\" FontStyle=\"" + ((ListBoxItem)((ListBox)chl).Items[i]).FontStyle + "\"/>";
                                }
                                strXML = strXML + char.ConvertFromUtf32(13) + "</ListBox>";
                            }

                            else if (chl.GetType() == typeof(RadioButton))
                            {
                                string strContent = ((RadioButton)chl).Content.ToString();
                                strContent = strContent.Replace("&", "&amp;");
                                strContent = strContent.Replace("\"", "&quot;");
                                strContent = strContent.Replace("<", "&lt;");
                                strContent = strContent.Replace(">", "&gt;");

                                strXML = strXML + char.ConvertFromUtf32(13) + "<RadioButton Name=\"control" + Counter.ToString() + "\" Height=\"" + ((ctlPOD)o).Height + "\" Width=\"" + ((ctlPOD)o).Width + "\" Canvas.Left=\"" + ((ctlPOD)o).GetValue(Canvas.LeftProperty) + "\" Canvas.Top=\"" + ((ctlPOD)o).GetValue(Canvas.TopProperty) + "\" Background=\"" + ((RadioButton)chl).Background + "\" Foreground=\"" + ((RadioButton)chl).Foreground + "\" Tag=\"" + ((RadioButton)chl).Tag + "\" Content=\"" + strContent + "\" FontFamily=\"" + ((RadioButton)chl).FontFamily + "\" FontSize=\"" + ((RadioButton)chl).FontSize + "\" FontWeight=\"" + ((RadioButton)chl).FontWeight + "\" FontStyle=\"" + ((RadioButton)chl).FontStyle + "\"/>";
                            }

                            else if (chl.GetType() == typeof(CheckBox))
                            {
                                string strContent = ((CheckBox)chl).Content.ToString();
                                strContent = strContent.Replace("&", "&amp;");
                                strContent = strContent.Replace("\"", "&quot;");
                                strContent = strContent.Replace("<", "&lt;");
                                strContent = strContent.Replace(">", "&gt;");

                                strXML = strXML + char.ConvertFromUtf32(13) + "<CheckBox Name=\"control" + Counter.ToString() + "\" Height=\"" + ((ctlPOD)o).Height + "\" Width=\"" + ((ctlPOD)o).Width + "\" Canvas.Left=\"" + ((ctlPOD)o).GetValue(Canvas.LeftProperty) + "\" Canvas.Top=\"" + ((ctlPOD)o).GetValue(Canvas.TopProperty) + "\" Background=\"" + ((CheckBox)chl).Background + "\" Foreground=\"" + ((CheckBox)chl).Foreground + "\" Tag=\"" + ((CheckBox)chl).Tag + "\" Content=\"" + strContent + "\" FontFamily=\"" + ((CheckBox)chl).FontFamily + "\" FontSize=\"" + ((CheckBox)chl).FontSize + "\" FontWeight=\"" + ((CheckBox)chl).FontWeight + "\" FontStyle=\"" + ((CheckBox)chl).FontStyle + "\"/>";
                            }

                        }
                    }
                }
                strXML = strXML + "</Canvas></UserControl>";

                //TextWriter tw = new StreamWriter(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "\\SS\\Script.Presentation\\" + objQueCollection[CurrentQueCount].QuestionName.ToString() + ".Xaml"));
                TextWriter tw = new StreamWriter(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "\\SS\\Script.Presentation\\" + objQueCollection[CurrentQueCount].ID.ToString() + ".Xaml"));
                tw.WriteLine(strXML);
                tw.Close();

                TextReader tr101 = new StreamReader(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll","\\ScriptPages\\Binded Data.txt"));
                string str101 = tr101.ReadToEnd();
                tr101.Close();


                strXML = "using System;" + char.ConvertFromUtf32(13) +
                         "using System.Collections.Generic;" + char.ConvertFromUtf32(13) +
                         "using System.Linq;" + char.ConvertFromUtf32(13) +
                         "using System.Text;" + char.ConvertFromUtf32(13) +
                         "using System.Windows;" + char.ConvertFromUtf32(13) +
                         "using System.Windows.Controls;" + char.ConvertFromUtf32(13) +
                         "using System.Windows.Data;" + char.ConvertFromUtf32(13) +
                         "using System.Windows.Documents;" + char.ConvertFromUtf32(13) +
                         "using System.Windows.Input;" + char.ConvertFromUtf32(13) +
                         "using System.Windows.Media;" + char.ConvertFromUtf32(13) +
                         "using System.Windows.Media.Imaging;" + char.ConvertFromUtf32(13) +
                         "using System.Windows.Navigation;" + char.ConvertFromUtf32(13) +
                         "using System.Windows.Shapes;" + char.ConvertFromUtf32(13) +
                         "using Script.Business;" + char.ConvertFromUtf32(13) +
                         char.ConvertFromUtf32(13) +

                         "namespace Script.Presentation" + char.ConvertFromUtf32(13) +
                         "{" + char.ConvertFromUtf32(13) + char.ConvertFromUtf32(13) + "public partial class UserControl" + objQueCollection[CurrentQueCount].ID.ToString() + ": UserControl" + char.ConvertFromUtf32(13) +
                           "{" + char.ConvertFromUtf32(13) +
                               "public UserControl" + objQueCollection[CurrentQueCount].ID.ToString() + "()" + char.ConvertFromUtf32(13) +
                                   "{" + char.ConvertFromUtf32(13) +
                                   "InitializeComponent();" + char.ConvertFromUtf32(13) +
                    //"VMuktiAPI.VMuktiHelper.RegisterEvent(\"SetLeadIDCRM\").VMuktiEvent += new VMuktiAPI.VMuktiEvents.VMuktiEventHandler(SetLeadIDCRM_VMuktiEvent);" + char.ConvertFromUtf32(13) +
                                   "FncRefresh();" + char.ConvertFromUtf32(13) +
                                   "}" + char.ConvertFromUtf32(13) +
                                   "public Canvas GetCanvas()" + char.ConvertFromUtf32(13) +
                                   "{" + char.ConvertFromUtf32(13) +
                                        "return this.cnvPaint;" +
                                    "}" + char.ConvertFromUtf32(13) +
                                     str101 + char.ConvertFromUtf32(13) +
                                     strCode + char.ConvertFromUtf32(13) +
                                     //char.ConvertFromUtf32(13) + "}" + char.ConvertFromUtf32(13) + str101 + char.ConvertFromUtf32(13) + strCode + char.ConvertFromUtf32(13) +
                           
                            "}" + char.ConvertFromUtf32(13) +
                            "}";
                //}
                //else {

                    //strXML = strXML + char.ConvertFromUtf32(13) +
                    //   "public partial class UserControl" + objQueCollection[CurrentQueCount].ID.ToString() + ": UserControl" + char.ConvertFromUtf32(13) +
                    //       "{"  + char.ConvertFromUtf32(13) + "ModulePermissions[] _MyPermissions;" + char.ConvertFromUtf32(13) +
                    //           "public UserControl" + objQueCollection[CurrentQueCount].ID.ToString() + "()" + char.ConvertFromUtf32(13) +
                    //               "{" + char.ConvertFromUtf32(13) +
                    //               "InitializeComponent();" + char.ConvertFromUtf32(13) +
                    //               "VMuktiAPI.VMuktiHelper.RegisterEvent(\"SetLeadIDScript\").VMuktiEvent += new VMuktiAPI.VMuktiEvents.VMuktiEventHandler(Script_VMuktiEvent);" + char.ConvertFromUtf32(13) +
                    //               "}" + char.ConvertFromUtf32(13) + str101 + char.ConvertFromUtf32(13) + strCode + char.ConvertFromUtf32(13) +
                    //       "}" + char.ConvertFromUtf32(13) +
                    //        "}";
                //}
                TextWriter tw1 = new StreamWriter(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "\\SS\\Script.Presentation\\" + objQueCollection[CurrentQueCount].ID.ToString() + ".Xaml.Cs"));
                //TextWriter tw1 = new StreamWriter(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "\\SS\\Script.Presentation\\" + objQueCollection[CurrentQueCount].QuestionName.ToString() + ".Xaml.Cs"));
                tw1.WriteLine(strXML);
                tw1.Close();

                AddRef1_2 = AddRef1_2 + char.ConvertFromUtf32(13) + "<Page Include=\"" + objQueCollection[CurrentQueCount].ID.ToString() + ".xaml\">"
                + char.ConvertFromUtf32(13) + "<Generator>MSBuild:Compile</Generator>"
                + char.ConvertFromUtf32(13) + "<SubType>Designer</SubType>"
                + char.ConvertFromUtf32(13) + "</Page>";

                AddRef2_3 = AddRef2_3 + char.ConvertFromUtf32(13) + "<Compile Include=\"" + objQueCollection[CurrentQueCount].ID.ToString() + ".Xaml.Cs\">"
                + char.ConvertFromUtf32(13) + "<DependentUpon>" + objQueCollection[CurrentQueCount].ID.ToString() + ".Xaml</DependentUpon>"
                + char.ConvertFromUtf32(13) + "<SubType>Code</SubType>"
                + char.ConvertFromUtf32(13) + "</Compile>";

                #endregion
            }

            //MessageBox.Show("Now Creating Project Files");

            #region Create Project File

            TextWriter tw11 = new StreamWriter(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll","\\SS\\Script.Presentation\\Script.Presentation.csproj"));

            TextReader tr1 = new StreamReader(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "\\ScriptPages\\1.txt"));
            string str1 = tr1.ReadToEnd();
            tr1.Close();

            TextReader tr2 = new StreamReader(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll",  "\\ScriptPages\\2.txt"));
            string str2 = tr2.ReadToEnd();
            tr2.Close();

            TextReader tr3 = new StreamReader(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "\\ScriptPages\\3.txt"));
            string str3 = tr3.ReadToEnd();
            tr3.Close();

            tw11.WriteLine(str1 + AddRef2_3 + str2 + AddRef1_2 + str3);
            str1 = "";
            str2 = "";
            str3 = "";
            AddRef1_2 = "";
            AddRef2_3 = "";
            tw11.Close();

            TextWriter twStart = new StreamWriter(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll",  "\\SS\\Script.Presentation\\clsStartClass.cs"));
            TextReader trClassRead = new StreamReader(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll","\\ScriptPages\\ClassRead.txt"));
            string strClassRead = trClassRead.ReadToEnd();
            trClassRead.Close();

            string strBetween = char.ConvertFromUtf32(13) + "public static string strStartQuesion = \"UserControl" + startQuestionID.ToString() + "\";" + char.ConvertFromUtf32(13) + "public static int LeadID = 0;" + char.ConvertFromUtf32(13) + "public static string sCurrentChannelID  = \"\";" + char.ConvertFromUtf32(13) + "public static string sCurrentDispositionID  = \"\";" + char.ConvertFromUtf32(13) + "public static string sCallingType  = \"\";" + char.ConvertFromUtf32(13) + "public static int CallID;" + char.ConvertFromUtf32(13) + "public static string StateName = null;" + char.ConvertFromUtf32(13) + "public static string ZipCode = null;" + char.ConvertFromUtf32(13) + "public static string sPhoneNumber = null;" + char.ConvertFromUtf32(13) + "}" + char.ConvertFromUtf32(13) + "}";

            twStart.WriteLine(strClassRead + strBetween);
            twStart.Close();

            #endregion


            #region DLL File Naming

            TextReader txtReader = new StreamReader(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "\\SS\\Script.Presentation\\Script.Presentation.csproj"));
            string txtString = txtReader.ReadToEnd();
            txtReader.Close();

            txtString = txtString.Replace("<AssemblyName>Script.Presentation</AssemblyName>", "<AssemblyName>" + _ScriptName + ".Presentation</AssemblyName>");

            TextWriter txtWriter = new StreamWriter(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "\\SS\\Script.Presentation\\Script.Presentation.csproj"));
            txtWriter.WriteLine(txtString);
            txtWriter.Close();



            TextReader txtReader1 = new StreamReader(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "\\SS\\Script.Business\\Script.Business.csproj"));
            string txtString1 = txtReader1.ReadToEnd();
            txtReader1.Close();

            txtString1 = txtString1.Replace("<AssemblyName>Script.Business</AssemblyName>", "<AssemblyName>" + _ScriptName + ".Business</AssemblyName>");

            TextWriter txtWriter1 = new StreamWriter(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "\\SS\\Script.Business\\Script.Business.csproj"));
            txtWriter1.WriteLine(txtString1);
            txtWriter1.Close();



            TextReader txtReader2 = new StreamReader(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "\\SS\\Script.Common\\Script.Common.csproj"));
            string txtString2 = txtReader2.ReadToEnd();
            txtReader2.Close();

            txtString2 = txtString2.Replace("<AssemblyName>Script.Common</AssemblyName>", "<AssemblyName>" + _ScriptName + ".Common</AssemblyName>");

            TextWriter txtWriter2 = new StreamWriter(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "\\SS\\Script.Common\\Script.Common.csproj"));
            txtWriter2.WriteLine(txtString2);
            txtWriter2.Close();

            TextReader txtReader3 = new StreamReader(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "\\SS\\Script.DataAccess\\Script.DataAccess.csproj"));
            string txtString3 = txtReader3.ReadToEnd();
            txtReader3.Close();

            txtString3 = txtString3.Replace("<AssemblyName>Script.DataAccess</AssemblyName>", "<AssemblyName>" + _ScriptName + ".DataAccess</AssemblyName>");

            TextWriter txtWriter3 = new StreamWriter(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "\\SS\\Script.DataAccess\\Script.DataAccess.csproj"));
            txtWriter3.WriteLine(txtString3);
            txtWriter3.Close();

            #endregion

            //#region Building the solution File

            //TextWriter tw1111 = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "\\Script\\Build.bat");
            //tw1111.WriteLine("cd\\");
            //tw1111.WriteLine("C:");
            //tw1111.WriteLine("cd \"C:\\WINDOWS\\Microsoft.NET\\Framework\\v3.5\"");
            //tw1111.WriteLine("msbuild \"" + AppDomain.CurrentDomain.BaseDirectory + "\\Script\\Script.sln\" /t:Rebuild /p:Configuration=Debug");
            //tw1111.Close();

            //System.Diagnostics.Process.Start(AppDomain.CurrentDomain.BaseDirectory + "\\Script\\Build.bat");

            //#endregion

            #region Building the solution File

            string winDir = Environment.GetFolderPath(Environment.SpecialFolder.System);
            winDir = winDir.Substring(0, winDir.LastIndexOf(@"\"));

            Process buildProcess = new Process();

            //TextWriter tw1111 = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "\\Script\\Build.bat");
            //tw1111.WriteLine("cd\\");
            //tw1111.WriteLine("C:");
            //tw1111.WriteLine("cd \"C:\\WINDOWS\\Microsoft.NET\\Framework\\v3.5\"");
            //tw1111.WriteLine("msbuild \"" + AppDomain.CurrentDomain.BaseDirectory + "\\Script\\Script.sln\" /t:Rebuild /p:Configuration=Debug");
            //tw1111.Close();
            //System.Diagnostics.Process.Start(AppDomain.CurrentDomain.BaseDirectory + "\\Script\\Build.bat");

            if (!File.Exists(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", @"\SS\Script.DataAccess\ReferencedAssemblies\VMuktiAPI.dll")))
                 File.Copy(Assembly.GetAssembly(typeof(VMuktiAPI.ClsPeer)).Location, Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", @"\SS\Script.DataAccess\ReferencedAssemblies\VMuktiAPI.dll"));
            //MessageBox.Show(Assembly.GetAssembly(typeof(VMuktiAPI.ClsPeer)).Location);
            //MessageBox.Show(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", @"SS\Script.Presentation\ReferencedAssemblies\VMuktiAPI.dll"));
            if (!File.Exists(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", @"SS\Script.Presentation\ReferencedAssemblies\VMuktiAPI.dll")))
            File.Copy(Assembly.GetAssembly(typeof(VMuktiAPI.ClsPeer)).Location, Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", @"SS\Script.Presentation\ReferencedAssemblies\VMuktiAPI.dll"));
            if (!File.Exists(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", @"SS\Script.Presentation\ReferencedAssemblies\VMukti.CtlDatePicker.Presentation.dll")))
                File.Copy(Assembly.GetExecutingAssembly().Location.Replace("ScriptDesigner.Presentation.dll", "VMukti.CtlDatePicker.Presentation.dll"), Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", @"SS\Script.Presentation\ReferencedAssemblies\VMukti.CtlDatePicker.Presentation.dll"));
                //File.Copy(Assembly.GetAssembly(typeof(VMuktiAPI.ClsPeer)).Location, Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", @"SS\Script.Presentation\ReferencedAssemblies\VMukti.CtlDatePicker.Presentation.dll"));
            

            if (System.IO.Directory.Exists(winDir + @"\Microsoft.NET\Framework\v3.5\"))
            {
                buildProcess.StartInfo.WorkingDirectory = winDir + @"\Microsoft.NET\Framework\v3.5\";
                buildProcess.StartInfo.FileName = "msbuild";
                buildProcess.StartInfo.Arguments = @" """ + Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll","") + @"\SS\Script.sln"" /t:Rebuild /p:Configuration=Debug";
                buildProcess.Start();
                
                buildProcess.WaitForExit();
            }
            else
            {
                MessageBox.Show("Microsoft .Net framework is not installed at --> \" " + winDir + @"\Microsoft.NET\Framework\v3.5\" + " \"!!");
            }


            #endregion

            try
            {
                if (Directory.Exists(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + ScriptName))
                {
                    Directory.Delete(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + ScriptName, true);
                }
                Directory.CreateDirectory(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + ScriptName);
                Directory.CreateDirectory(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + ScriptName + "\\" + ScriptName);
                Directory.CreateDirectory(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + ScriptName + "\\" + ScriptName + "\\BAL");
                Directory.CreateDirectory(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + ScriptName + "\\" + ScriptName + "\\DAL");
                Directory.CreateDirectory(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + ScriptName + "\\" + ScriptName + "\\Control");
                //Directory.CreateDirectory(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + @"Script\Common");
            }
            catch (Exception exp)
            {
                VMuktiAPI.VMuktiHelper.ExceptionHandler(exp, "FncSaveFiles", "ctlScriptdesigner.xaml.cs");
            }

            try
            {
                copyDirectory(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + @"SS\Script.Presentation\bin\Debug", Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + ScriptName);
            }
            catch (Exception exp)
            {
                VMuktiAPI.VMuktiHelper.ExceptionHandler(exp, "FncsaveFiles", "ctlScriptdesigner.xaml.cs");
            }

            try
            {
                string[] filesToDelete = Directory.GetFiles(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + ScriptName, "*.pdb");
                for (int i = 0; i < filesToDelete.Length; i++)
                {
                    File.Delete(filesToDelete[i]);
                }
            }
            catch (Exception exp)
            {
                VMuktiAPI.VMuktiHelper.ExceptionHandler(exp, "FncSaveFiles", "ctlScriptdesigner.xaml.cs");
            }

            try
            {
                string[] filesToMove = Directory.GetFiles(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + ScriptName, "*.dll");
                for (int i = 0; i < filesToMove.Length; i++)
                {
                    if (filesToMove[i].Substring(filesToMove[i].LastIndexOf(@"\")).Contains("Business"))
                    {
                        File.Move(filesToMove[i], Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + ScriptName + "\\" + ScriptName +  "\\BAL\\" + filesToMove[i].Substring(filesToMove[i].LastIndexOf(@"\")));
                    }
                    else if (filesToMove[i].Substring(filesToMove[i].LastIndexOf(@"\")).Contains("Common"))
                    {
                        File.Move(filesToMove[i], Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + ScriptName + "\\" + ScriptName + "\\BAL\\" + filesToMove[i].Substring(filesToMove[i].LastIndexOf(@"\")));
                    }
                    else if (filesToMove[i].Substring(filesToMove[i].LastIndexOf(@"\")).Contains("DataAccess"))
                    {
                        File.Move(filesToMove[i], Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + ScriptName + "\\" + ScriptName + "\\DAL\\" + filesToMove[i].Substring(filesToMove[i].LastIndexOf(@"\")));
                    }
                    else if (filesToMove[i].Substring(filesToMove[i].LastIndexOf(@"\")).Contains("Presentation"))
                    {
                        if (filesToMove[i].Substring(filesToMove[i].LastIndexOf(@"\")).Contains("CtlDatePicker"))
                        {
                            File.Delete(filesToMove[i]);
                        }
                        else
                        {
                        File.Move(filesToMove[i], Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + ScriptName + "\\" + ScriptName + "\\Control\\" + filesToMove[i].Substring(filesToMove[i].LastIndexOf(@"\")));
                        }
                    }
                    else if (filesToMove[i].Substring(filesToMove[i].LastIndexOf(@"\")).Contains("VMuktiAPI"))
                    {

                        File.Delete(filesToMove[i]);

                        //File.Move(filesToMove[i], Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + @"Script\Control\" + filesToMove[i].Substring(filesToMove[i].LastIndexOf(@"\")));
                    }
                }
            }
            catch (Exception exp)
            {
                VMuktiAPI.VMuktiHelper.ExceptionHandler(exp, "FncSaveFiles", "ctlScriptdesigner.xaml.cs");
            }

            try
            {
                Directory.Delete(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + @"SS\Script.Presentation\bin", true);
                Directory.Delete(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + @"SS\Script.Presentation\obj", true);
                Directory.Delete(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + @"SS\Script.Business\bin", true);
                Directory.Delete(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + @"SS\Script.Business\obj", true);
                Directory.Delete(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + @"SS\Script.Common\bin", true);
                Directory.Delete(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + @"SS\Script.Common\obj", true);
                Directory.Delete(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + @"SS\Script.DataAccess\bin", true);
                Directory.Delete(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + @"SS\Script.DataAccess\obj", true);
            }
            catch (Exception exp)
            {
                VMuktiAPI.VMuktiHelper.ExceptionHandler(exp, "FncSaveFiles", "ctlScriptdesigner.xaml.cs");
            }

            ICSharpCode.SharpZipLib.Zip.FastZip fz = new ICSharpCode.SharpZipLib.Zip.FastZip();
            try
            {
                //MessageBox.Show("File Name - " + Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + @"SS.zip");
                //MessageBox.Show("Source - " + Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + @"SS");
                fz.CreateZip(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + @"SS.zip", Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + @"SS", true, "");
                
                
            }
            catch (Exception exp)
            {
                VMuktiAPI.VMuktiHelper.ExceptionHandler(exp, "FncSaveFiles", "ctlScriptdesigner.xaml.cs");
            }

            try
            {
                fz.CreateZip(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + server + @".zip", Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + ScriptName, true, "");
            }
            catch (Exception exp)
            {
                VMuktiAPI.VMuktiHelper.ExceptionHandler(exp, "FncSaveFiles", "ctlScriptdesigner.xaml.cs");
            }

            try
            {
                Directory.Delete(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + @"SS", true);
            }
            catch (Exception exp)
            {
                VMuktiAPI.VMuktiHelper.ExceptionHandler(exp, "FncSaveFiles", "ctlScriptdesigner.xaml.cs");
            }

            try
            {
                Directory.Delete(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + ScriptName, true);
            }
            catch (Exception exp)
            {
                VMuktiAPI.VMuktiHelper.ExceptionHandler(exp, "FncSaveFiles", "ctlScriptdesigner.xaml.cs");
            }
            
            try
            {
                System.Windows.Forms.DialogResult sfdRes;
                System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog();
                sfd.Filter = "Zip file(s) (*.zip)|*.zip";
                sfd.Title = "Save the source file of script to edit manualy!!";
                sfd.FileName = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\SS.zip";
                sfdRes = sfd.ShowDialog();
                if (sfdRes == System.Windows.Forms.DialogResult.OK)
                {
                    if (File.Exists(sfd.FileName))
                    {
                        File.Delete(sfd.FileName);
                    }
                    File.Move(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + @"SS.zip", sfd.FileName);
                }

                //sfd.Title = "Save the file of script to add as a module in VMukti plateform!!";
                //sfd.FileName = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\ScriptRender.zip";
                //sfdRes = sfd.ShowDialog();
                //if (sfdRes == System.Windows.Forms.DialogResult.OK)
                //{
                //    if (File.Exists(sfd.FileName))
                //    {
                //        File.Delete(sfd.FileName);
                //    }
                //    File.Move(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + @"ScriptRender.zip", sfd.FileName);
                //}

                
                
                #region UploadFile
                try
                {
                    System.IO.FileInfo fileInfo = new System.IO.FileInfo(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + server + @".zip");
                    System.IO.FileStream stream = new System.IO.FileStream(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + server + @".zip", System.IO.FileMode.Open, System.IO.FileAccess.Read);
                RemoteFileInfo rfi = new RemoteFileInfo();
                rfi.FileName = fileInfo.Name;
                rfi.Length = fileInfo.Length;
                rfi.FileByteStream = stream;
                rfi.FolderNameToStore = "Scripts";
                clientHttpFileTransfer.svcHTTPFileTransferServiceUploadFileToInstallationDirectory(rfi);
                stream.Close();
                    if (File.Exists(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + server + @".zip"))
                    {
                        File.Delete(Assembly.GetAssembly(this.GetType()).Location.Replace("ScriptDesigner.Presentation.dll", "") + server + @".zip");
                    }
                }
                catch (Exception er)
                {
                    MessageBox.Show(er.Message);
                }
                #endregion
            }
            catch (Exception exp)
            {
                VMuktiAPI.VMuktiHelper.ExceptionHandler(exp, "FncSaveFiles", "ctlScriptdesigner.xaml.cs");
            }
            


            #endregion
        }
コード例 #59
0
ファイル: Zip.cs プロジェクト: scholtz/FastZep
 /// <summary>
 /// Compress list of files [sourceFiles] to [zipFileName]
 /// </summary>
 /// <param name="zipFileName"></param>
 /// <param name="sourceFiles"></param>
 public static void Zip(string zipFileName, FileInfo[] sourceFiles)
 {
     try
     {
         // get the root folder. NOTE: it assums that the first file is at the root.
         string rootFolder = Path.GetDirectoryName(sourceFiles[0].FullName);
         // compress
         ICSharpCode.SharpZipLib.Zip.FastZip fz = new ICSharpCode.SharpZipLib.Zip.FastZip();
         fz.CreateZip(zipFileName, rootFolder, true, "");
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #60
0
        int DownloadAndExtractZipFile()
        {
            #region Download and Extract Zip file
            try
            {





                str = ScriptName;
                str += "_Script";

                Assembly ass = Assembly.GetEntryAssembly();
                // this maybe something like "using Vmuktiapi"
                filename = str + ".zip";

                #region Download Zip File using WCF FileTranserService

                try
                {
                    BasicHttpClient bhcFts = new BasicHttpClient();
                    clientHttpFileTransfer = (IHTTPFileTransferService)bhcFts.OpenClient<IHTTPFileTransferService>("http://" + VMuktiInfo.BootStrapIPs[0] + ":80/VMukti/HttpFileTransferService");
                    clientHttpFileTransfer.svcHTTPFileTransferServiceJoin();
                    DownloadRequest request = new DownloadRequest();
                    RemoteFileInfo rfi = new RemoteFileInfo();

                    request.FileName = filename;
                    request.FolderWhereFileIsStored = "Scripts";
                    rfi = clientHttpFileTransfer.svcHTTPFileTransferServiceDownloadFile(request);

                

                    if (!Directory.Exists(ass.Location.Replace("VMukti.Presentation.exe", @"Scripts")))
                    {
                        Directory.CreateDirectory(ass.Location.Replace("VMukti.Presentation.exe", @"Scripts"));
                    }
                    destination = ass.Location.Replace("VMukti.Presentation.exe", @"Scripts");

                 
                    filePath = destination + "\\" + filename;

                    System.IO.Stream inputStream = rfi.FileByteStream;


                    using (System.IO.FileStream writeStream = new System.IO.FileStream(filePath, System.IO.FileMode.Create, System.IO.FileAccess.Write, FileShare.ReadWrite))
                    {
                        int chunkSize = 2048;
                        byte[] buffer = new byte[chunkSize];

                        do
                        {
                            // read bytes from input stream
                            int bytesRead = inputStream.Read(buffer, 0, chunkSize);
                            if (bytesRead == 0) break;

                            // write bytes to output stream
                            writeStream.Write(buffer, 0, bytesRead);

                        } while (true);
                        writeStream.Close();
                    }
                    //}
                }
                catch (Exception ex)
                {
                   
                    VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "DownloadAndExtractZipFile", "ctlScriptdesigner.xaml.cs");
                    return -1;
                }

                #endregion

                #region Downloading ZipFile Using WebClient  -----Commented


                #endregion

                #region Extracting

                if (!Directory.Exists(ass.Location.Replace("VMukti.Presentation.exe", @"ScriptModules")))
                {
                    Directory.CreateDirectory(ass.Location.Replace("VMukti.Presentation.exe", @"ScriptModules"));
                }



              
                try
                {
                    str = ScriptName;
                    str += "_Script";

                    Assembly ass2 = Assembly.GetEntryAssembly();

                    strModPath = ass2.Location.Replace("VMukti.Presentation.exe", @"ScriptModules");

                
                    
                  
                   
                }
                catch (Exception e)
                {
                    VMuktiAPI.VMuktiHelper.ExceptionHandler(e, "DownloadAndExtractZipFile", "ctlScriptdesigner.xaml.cs");
                }





            
                ICSharpCode.SharpZipLib.Zip.FastZip fz = new ICSharpCode.SharpZipLib.Zip.FastZip();

               // if (!Directory.Exists(strModPath + "\\" + str  ))
                {
                    fz.ExtractZip(destination + "\\" + filename, strModPath+ "\\"+str, null);
                   
                }
                
              

                #endregion
            }
            catch (Exception ex)
            {
                VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "DownloadAndExtractZipFile", "ctlScriptdesigner.xaml.cs");
                return -1;
            }
            #endregion
            return 0;
        }