Beispiel #1
0
    //if there is icon/icon.ico, it will be use into public target.exe
    //-exe target.exe -dir AppFolder -run ToExcuteExe.exe -args arg1 arg2 ..
    public static void Main(string[] args)
    {
        var    ZipFile   = "data.mhx";
        string key       = "HinxCor.EncrytoPass";
        string tmpCsFile = "se.cs";
        string passwd    = "F41E6-F565-41F1F-C1DR5-6QW";

        ZipHelper.CompressFolder(args[3], ZipFile, 5, passwd);
        Thread.Sleep(20);

        string csFile = "code.depub";
        var    bytes  = File.ReadAllBytes(csFile);
        string csCode = "";

        var coder = Encoding.UTF8.GetBytes(key);

        using (var decrytor = new RC4(coder))
        {
            var decodeData = decrytor.Decrypt((RC4.ByteArray)bytes);
            csCode = Encoding.UTF8.GetString(decodeData);
        }
        csCode = Regex.Replace(csCode, "exeFile", args[5]);
        csCode = Regex.Replace(csCode, "passwd", passwd);
        File.WriteAllText(tmpCsFile, csCode);
        new FileInfo(tmpCsFile).Attributes = FileAttributes.Hidden;
        Thread.Sleep(25);

        string batCmd = string.Format(@"@echo off csc -out:{0} {1}  -win32icon:{2}  -resource:{3},{4}", args[1], tmpCsFile, "icon/icon.ico", "HinxCor.CompressionDot45.dll", ZipFile);

        Windows.ExecuteCommand(batCmd);
    }
Beispiel #2
0
        public void ExportDictionaries(string processId, PrcSettingsElastic settings, List <string> tagIdList, CancellationToken token, string hostUrl)
        {
            try
            {
                var service = serviceQuery.Get(settings.ServiceId);

                var dataSet     = GlobalStore.DataSets.Get(settings.DataSetName).DataSet;
                var allDicCount = tagIdList.Count;
                /*ZIP time*/
                allDicCount += (allDicCount / 10);
                var progress = new Progress(allDicCount);

                var dictionariesPath = string.Format("{0}/{1}", _dictionaryRootPath, settings.ServiceId);

                var tempDirectoryPath = string.Format("{0}/{1}", siteConfig.Directory.Temp, processId);
                System.IO.Directory.CreateDirectory(tempDirectoryPath);

                foreach (var tagId in tagIdList)
                {
                    if (token.IsCancellationRequested)
                    {
                        processHandler.Cancelled(processId);
                        return;
                    }
                    var filePath    = $"{dictionariesPath}/{DictionaryProtoBuf.GetFileName(tagId)}";
                    var dicProtoBuf = BaseProtoBuf.DeSerialize <DictionaryProtoBuf>(filePath);

                    var csvPath = $"{tempDirectoryPath}/{tagId}.csv";
                    if (dicProtoBuf.Dictionary != null)
                    {
                        CsvHelper.CreateCsv(csvPath, dicProtoBuf.Dictionary.Select(d => new List <string> {
                            d.Key, d.Value.ToString()
                        }).ToList());
                    }
                    else
                    {
                        CsvHelper.CreateCsv(csvPath, new List <List <string> >());
                    }

                    progress.Step();
                    processHandler.Changed(processId, progress.Percent.Round(2));
                }
                /*time to ZIP the results*/
                var zipFileName   = string.Format("{0}.zip", processId);
                var dirToZipPath  = string.Format("{0}/{1}", siteConfig.Directory.Temp, processId);
                var resultZipPath = string.Format("{0}/{1}", siteConfig.Directory.User, zipFileName);
                ZipHelper.CompressFolder(dirToZipPath, resultZipPath);

                var zipUrl = string.Format("{0}{1}/{2}", hostUrl, Common.Constants.FilesPath, zipFileName);

                processHandler.Finished(processId,
                                        string.Format("{0}\n{1}",
                                                      string.Format(ServiceResources.SuccessfullyExportedDictionariesFrom_0_Service_1, ServiceTypeEnum.Prc, service.Name),
                                                      string.Format(ServiceResources.ExportFileCanBeDownloadFromHere_0, zipUrl)));
            }
            catch (Exception ex)
            {
                processHandler.Interrupted(processId, ex);
            }
        }