private void button2_Click(object sender, EventArgs e) { GenerateType generateType = GenerateType.Null; if (checkBox2.CheckState == CheckState.Checked && checkBox3.CheckState == CheckState.Checked) { generateType = GenerateType.Client | GenerateType.Server; } else if (checkBox2.CheckState == CheckState.Checked) { generateType = GenerateType.Client; } else if (checkBox3.CheckState == CheckState.Checked) { generateType = GenerateType.Server; } else if (checkBox2.CheckState == CheckState.Unchecked && checkBox3.CheckState == CheckState.Unchecked && checkBox4.CheckState == CheckState.Unchecked) { MessageBox.Show("请选择导出"); return; } AgainCheckExeclData(); richTextBox1.AppendText("导表进程:\n"); ExecleManager.Instance.Generate(GenerateProgress, generateType, GenerateComplete, SerializableProgress); }
public GenDataTransfer(GenerateType type, int quantity, TitleOptions options, TextOutput output) { Type = type; Quantity = quantity; TitleOption = options; Output = output; }
public TypeConfiguratorResult(GenerateType generateType, string typeName, Type originType, ClassDeclarationSyntax syntax) { GenerateType = generateType; TypeName = typeName; OriginType = originType; Syntax = syntax; }
public BaseState GenerateState(GenerateType _type, string _clipname, AudioClip _clip) { if (_type == GenerateType.NUMSTATE) { GenerateType g = (GenerateType)Random.Range((int)GenerateType.BASESTATE, (int)GenerateType.NUMSTATE); print(g); return(_GenerateDictionary[g](_clipname, _clip)); } return(_GenerateDictionary[_type](_clipname, _clip)); }
// 顶点动画纹理 public void generate_verticesAnim(string parentFolder, string savePath, string dataFileName, string matFileName, string prefabFileName, string mainTexPath, GenerateType generateType) { genType = generateType; // 生成纹理数据 generateTexAndMesh_verticesAnim(parentFolder, savePath, dataFileName); // 生成材质 generateMaterial(savePath, matFileName, mainTexPath); // 生成prefab generatePrefab(savePath, prefabFileName, dataFileName, parentFolder); }
public ISMSGenerating CreateGeneratingType(GenerateType type) { switch (type) { case GenerateType.smsGeneratingThread: return(new SMSGeneratingThread(richTextBox)); case GenerateType.smsGeneratingTask: return(new SMSGeneratingTask(richTextBox)); default: return(new SMSGeneratingThread(richTextBox)); } }
// 骨骼动画纹理 public void generate(string parentFolder, string savePath, string dataFileName, string matFileName, string prefabFileName, string mainTexPath, GenerateType generateType) { genType = generateType; // 生成纹理数据 generateTexAndMesh(parentFolder, savePath, dataFileName); // 生成材质 generateMaterial(savePath, matFileName, mainTexPath); // 生成prefab generatePrefab(savePath, prefabFileName, dataFileName, parentFolder); AssetDatabase.Refresh(); AssetDatabase.SaveAssets(); }
public void GenerateSlots(GenerateType inType, Vector2Int inDimension) { _dimension = inDimension; ClearMachine(); switch (inType) { case GenerateType.Asynchronous: _size = _dimension.x * _dimension.y; SpawnSlotAsync(0); break; case GenerateType.Synchronous: var loader = new AssetsLoader(); loader.Load <GameObject>(slotReference, GenerateSlotSync); break; } }
// 设置选中的模型 public void setSelectedModel(GameObject obj, GenerateType type, List <AnimationClip> clips, SkinnedMeshRenderer skinnedMeshRenderer) { if (obj == null) { Debug.LogError("select obj is null!!"); animData = null; return; } if (curGameObject != obj || animData == null || genType != type || skinnedMeshRenderer != selectedSkinnedMeshRenderer) { genType = type; curGameObject = obj; clipList = clips; selectedSkinnedMeshRenderer = skinnedMeshRenderer; refreshGeneratorInfo(); } }
private string GetProperties(GenerateType type) { string[] _childs = this.GetFileNames(this.JsonConfigurationPath, "*.cs") .OrderBy(or => or) .ToArray(); StringBuilder _dbSets = new StringBuilder(); foreach (var child in _childs.Select((Value, i) => new { Value, i })) { _dbSets.AppendFormat("{0}{1}DbSet<{2}> {3} {{get;set;}}\n", (child.i > 0) ? "\t\t" : string.Empty, (type == GenerateType.Class) ? "public " : string.Empty, child.Value, (child.Value.EndsWith("Y")) ? child.Value.Remove(child.Value.Length - 1, 1) + "ies" : child.Value + "s"); } return(_dbSets.ToString()); }
private IEnumerator GenerateRoutine(GenerateType generateType) { _generatePanelButton.gameObject.SetActive(false); yield return(FileExplorer.Instance.SaveFile("Сгенерировать Отчеты", null, "xlsx", "reports.xlsx")); if (FileExplorer.Instance.LastResult == null) { yield break; } string[] points = { }; string[] wires = { }; switch (generateType) { case GenerateType.Points: points = CalculationsManager.Instance.ElectricFieldStrenght.Points.Select(p => p.Code).ToArray(); break; case GenerateType.Wires: wires = WiringManager.Instance.Wiring.Wires.Select(w => w.Name).ToArray(); break; case GenerateType.All: points = CalculationsManager.Instance.ElectricFieldStrenght.Points.Select(p => p.Code).ToArray(); wires = WiringManager.Instance.Wiring.Wires.Select(w => w.Name).ToArray(); break; case GenerateType.Selected: points = _kvid6.SelectedElements.Select(el => el.Name).ToArray(); wires = _kvid3.SelectedElements.Select(el => el.Name).ToArray(); break; } DatabaseManager.Instance.SetProgress("ожидание"); ProgressDialog.Instance.Show("Генерация отчета"); Meth(points, wires).WrapErrors(); Close(); }
/// <summary> /// 历史记录显示 /// </summary> /// <param name="path"></param> /// <param name="type"></param> private void HistoryLogItem(string path, GenerateType type) { if (string.IsNullOrEmpty(path)) { return; } GUIStyle labelSty = new GUIStyle("HeaderLabel"); labelSty.fontSize = 12; EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(path, labelSty, GUILayout.MaxWidth(350))) { if (type == GenerateType.Single_File) { filePath = path; PlayerPrefs.SetString("FilePath", filePath); } else if (type == GenerateType.Folder_Files) { folderPath = path; PlayerPrefs.SetString("FoldPath", folderPath); } } GUILayout.FlexibleSpace(); EditorGUILayout.BeginVertical(); GUILayout.Space(8); if (GUILayout.Button("X")) { if (type == GenerateType.Single_File) { fileRecordPaths = RemoveString(fileRecordPaths, path); PlayerPrefs.SetString("FileRecordPath", fileRecordPaths); } else if (type == GenerateType.Folder_Files) { foldRecordPaths = RemoveString(foldRecordPaths, path); PlayerPrefs.SetString("FoldRecordPath", fileRecordPaths); } } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); }
public static string GenerteName(Worksheet sheet, GenerateType type) { if (sheet == null) { return(null); } while (true) { for (int i = 1; i < 0x7fffffff; i++) { if (type == GenerateType.Chart) { string name = "Chart" + ((int)i); if (sheet.FindChart(name) == null) { return(name); } } else if (type == GenerateType.Picture) { string str2 = "Picture" + ((int)i); if (sheet.FindPicture(str2) == null) { return(str2); } } else if (type == GenerateType.FloatingObject) { string str3 = "FloatingObject" + ((int)i); if (sheet.FindFloatingObject(str3) == null) { return(str3); } } else { return(string.Empty); } } } }
public static string GenerateName(int count = 6, GenerateType type = GenerateType.TextNum) { string chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; if (type == GenerateType.Text) { chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; } else if (type == GenerateType.Num) { chars = "1234567890"; } string res = ""; Random rd = new Random(); for (int i = 0; i < count; i++) { res += chars[rd.Next(0, chars.Length)]; } return(res); }
public static int Count(string text, GenerateType type) { int cnt = 0; switch (type) { case GenerateType.Lists: cnt = CountLines(text); return(cnt); case GenerateType.Letters: cnt = text.Length; return(cnt); case GenerateType.Paragraphs: cnt = CountParagraphs(text); return(cnt); default: cnt = CountWords(text); return(cnt); } }
private static void InitPath() { if (PlayerPrefs.HasKey("GenerateType")) { generateType = (GenerateType)Enum.Parse(typeof(GenerateType), PlayerPrefs.GetString("GenerateType")); } if (PlayerPrefs.HasKey("CSOutPath")) { csOutPath = PlayerPrefs.GetString("CSOutPath"); } if (PlayerPrefs.HasKey("ObjOutPath")) { objOutPath = PlayerPrefs.GetString("ObjOutPath"); } if (PlayerPrefs.HasKey("FilePath")) { filePath = PlayerPrefs.GetString("FilePath"); } if (PlayerPrefs.HasKey("FoldPath")) { folderPath = PlayerPrefs.GetString("FoldPath"); } if (PlayerPrefs.HasKey("FileRecordPath")) { fileRecordPaths = PlayerPrefs.GetString("FileRecordPath"); } if (PlayerPrefs.HasKey("FoldRecordPath")) { foldRecordPaths = PlayerPrefs.GetString("FoldRecordPath"); } }
/// <summary> /// Harvest a directory. /// </summary> /// <param name="path">The path of the directory.</param> /// <param name="relativePath">The relative path that will be used when harvesting.</param> /// <param name="harvestParent">The directory for this path.</param> /// <param name="generateType"></param> /// <returns>The number of files harvested.</returns> private int HarvestDirectory(string path, string relativePath, Wix.IParentElement harvestParent, GenerateType generateType) { int fileCount = 0; Wix.Directory directory = generateType != GenerateType.PayloadGroup ? (Wix.Directory)harvestParent : null; // harvest the child directories foreach (string childDirectoryPath in Directory.GetDirectories(path)) { var childDirectoryName = Path.GetFileName(childDirectoryPath); Wix.IParentElement newParent; Wix.Directory childDirectory = null; if (generateType == GenerateType.PayloadGroup) { newParent = harvestParent; } else { childDirectory = new Wix.Directory(); newParent = childDirectory; childDirectory.Name = childDirectoryName; childDirectory.FileSource = childDirectoryPath; if (this.SetUniqueIdentifiers) { childDirectory.Id = this.Core.GenerateIdentifier(DirectoryPrefix, directory.Id, childDirectory.Name); } } int childFileCount = this.HarvestDirectory(childDirectoryPath, String.Concat(relativePath, childDirectoryName, "\\"), newParent, generateType); if (generateType != GenerateType.PayloadGroup) { // keep the directory if it contained any files (or empty directories are being kept) if (0 < childFileCount || this.KeepEmptyDirectories) { directory.AddChild(childDirectory); } } fileCount += childFileCount; } // harvest the files string[] files = Directory.GetFiles(path); if (0 < files.Length) { foreach (string filePath in Directory.GetFiles(path)) { string fileName = Path.GetFileName(filePath); string source = String.Concat(relativePath, fileName); Wix.ISchemaElement newChild; if (generateType == GenerateType.PayloadGroup) { Wix.Payload payload = new Wix.Payload(); newChild = payload; payload.SourceFile = source; } else { Wix.Component component = new Wix.Component(); newChild = component; Wix.File file = this.fileHarvester.HarvestFile(filePath); file.Source = source; if (this.SetUniqueIdentifiers) { file.Id = this.Core.GenerateIdentifier(FilePrefix, directory.Id, fileName); component.Id = this.Core.GenerateIdentifier(ComponentPrefix, directory.Id, file.Id); } component.AddChild(file); } harvestParent.AddChild(newChild); } } else if (generateType != GenerateType.PayloadGroup && 0 == fileCount && this.KeepEmptyDirectories) { Wix.Component component = new Wix.Component(); component.KeyPath = Wix.YesNoType.yes; if (this.SetUniqueIdentifiers) { component.Id = this.Core.GenerateIdentifier(ComponentPrefix, directory.Id); } Wix.CreateFolder createFolder = new Wix.CreateFolder(); component.AddChild(createFolder); directory.AddChild(component); } return(fileCount + files.Length); }
/// <summary> /// Harvest a directory. /// </summary> /// <param name="path">The path of the directory.</param> /// <param name="harvestChildren">The option to harvest child directories and files.</param> /// <param name="generateType">The type to generate.</param> /// <returns>The harvested directory.</returns> private Wix.IParentElement HarvestDirectory(string path, bool harvestChildren, GenerateType generateType) { if (File.Exists(path)) { throw new WixException(ErrorMessages.ExpectedDirectoryGotFile("dir", path)); } if (null == this.RootedDirectoryRef) { this.RootedDirectoryRef = "TARGETDIR"; } // use absolute paths path = Path.GetFullPath(path); // Remove any trailing separator to ensure Path.GetFileName() will return the directory name. path = path.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); Wix.IParentElement harvestParent; if (generateType == GenerateType.PayloadGroup) { harvestParent = new Wix.PayloadGroup(); } else { Wix.Directory directory = new Wix.Directory(); directory.Name = Path.GetFileName(path); directory.FileSource = path; if (this.SetUniqueIdentifiers) { if (this.SuppressRootDirectory) { directory.Id = this.Core.GenerateIdentifier(DirectoryPrefix, this.RootedDirectoryRef); } else { directory.Id = this.Core.GenerateIdentifier(DirectoryPrefix, this.RootedDirectoryRef, directory.Name); } } harvestParent = directory; } if (harvestChildren) { try { int fileCount = this.HarvestDirectory(path, "SourceDir\\", harvestParent, generateType); if (generateType != GenerateType.PayloadGroup) { // its an error to not harvest anything with the option to keep empty directories off if (0 == fileCount && !this.KeepEmptyDirectories) { throw new WixException(HarvesterErrors.EmptyDirectory(path)); } } } catch (DirectoryNotFoundException) { throw new WixException(HarvesterErrors.DirectoryNotFound(path)); } } return(harvestParent); }
/// <summary> /// Parse the command line options for this extension. /// </summary> /// <param name="type">The active harvester type.</param> /// <param name="args">The option arguments.</param> public override void ParseOptions(string type, string[] args) { if ("project" == type) { string[] allOutputGroups = VSProjectHarvester.GetOutputGroupNames(); bool suppressUniqueId = false; bool generateWixVars = false; GenerateType generateType = GenerateType.Components; string directoryIds = null; string projectName = null; string configuration = null; string platform = null; ArrayList outputGroups = new ArrayList(); for (int i = 0; i < args.Length; i++) { if ("-configuration" == args[i]) { configuration = args[++i]; } else if ("-directoryid" == args[i]) { if (!CommandLine.IsValidArg(args, ++i)) { throw new WixException(VSErrors.InvalidDirectoryId(args[i])); } directoryIds = args[i]; } else if ("-generate" == args[i]) { if (!CommandLine.IsValidArg(args, ++i)) { throw new WixException(VSErrors.InvalidOutputType(args[i])); } string genType = args[i].ToUpperInvariant(); switch (genType) { case "LAYOUT": generateType = GenerateType.Layout; break; case "CONTAINER": generateType = GenerateType.Container; break; case "COMPONENTS": generateType = GenerateType.Components; break; case "PACKAGEGROUP": generateType = GenerateType.PackageGroup; break; case "PAYLOADGROUP": generateType = GenerateType.PayloadGroup; break; default: throw new WixException(VSErrors.InvalidOutputType(genType)); } } else if ("-platform" == args[i]) { platform = args[++i]; } else if ("-pog" == args[i]) { if (!CommandLine.IsValidArg(args, ++i)) { throw new WixException(VSErrors.InvalidOutputGroup(args[i])); } string pogName = args[i]; bool found = false; foreach (string availableOutputGroup in allOutputGroups) { if (String.Equals(pogName, availableOutputGroup, StringComparison.Ordinal)) { outputGroups.Add(availableOutputGroup); found = true; break; } } if (!found) { throw new WixException(VSErrors.InvalidOutputGroup(pogName)); } } else if (args[i].StartsWith("-pog:", StringComparison.Ordinal)) { this.MessageHandler.Display(this, WixWarnings.DeprecatedCommandLineSwitch("pog:", "pog")); string pogName = args[i].Substring(5); bool found = false; foreach (string availableOutputGroup in allOutputGroups) { if (String.Equals(pogName, availableOutputGroup, StringComparison.Ordinal)) { outputGroups.Add(availableOutputGroup); found = true; break; } } if (!found) { throw new WixException(VSErrors.InvalidOutputGroup(pogName)); } } else if ("-projectname" == args[i]) { if (!CommandLine.IsValidArg(args, ++i)) { throw new WixException(VSErrors.InvalidProjectName(args[i])); } projectName = args[i]; } else if ("-suid" == args[i]) { suppressUniqueId = true; } else if ("-wixvar" == args[i]) { generateWixVars = true; } } if (outputGroups.Count == 0) { throw new WixException(VSErrors.NoOutputGroupSpecified()); } VSProjectHarvester harvester = new VSProjectHarvester( (string[])outputGroups.ToArray(typeof(string))); harvester.SetUniqueIdentifiers = !suppressUniqueId; harvester.GenerateWixVars = generateWixVars; harvester.GenerateType = generateType; harvester.DirectoryIds = directoryIds; harvester.ProjectName = projectName; harvester.Configuration = configuration; harvester.Platform = platform; this.Core.Harvester.Extension = harvester; } }
internal TypeConfigurator AppendGenerateType(GenerateType type) { _types.Add(type); return(this); }
public static void Generate(List <string> xpaths, string outname, long sizeoutput, long rowsize, GenerateType type, int writersCount, GenerateRandom genrand) { int RecordLength = -1; if (outname.StartsWith("dfs://", StringComparison.OrdinalIgnoreCase)) { outname = outname.Substring(6); } { int iat = outname.IndexOf('@'); if (-1 != iat) { try { RecordLength = Surrogate.GetRecordSize(outname.Substring(iat + 1)); } catch (Exception e) { Console.Error.WriteLine(e.Message); SetFailure(); return; } outname = outname.Substring(0, iat); } } string reason = ""; if (dfs.IsBadFilename(outname, out reason)) { Console.Error.WriteLine("Invalid output-dfsfile: {0}", reason); SetFailure(); return; } dfs dc = LoadDfsConfig(); if (null != DfsFindAny(dc, outname)) { Console.Error.WriteLine("Output file already exists in DFS: {0}", outname); SetFailure(); return; } if (RecordLength > 0) { if (rowsize < 0) { rowsize = RecordLength; } else { if (rowsize > RecordLength) { Console.Error.WriteLine("Row data cannot be greater than DFS record length"); SetFailure(); return; } } if (type != GenerateType.BINARY) { Console.Error.WriteLine("Error: must specify type=bin when generating a rectangular binary DFS file"); SetFailure(); return; } } else { if (rowsize < 1) { rowsize = 100; } } string tempfnpost = "." + Guid.NewGuid().ToString() + "." + System.Diagnostics.Process.GetCurrentProcess().Id.ToString(); string jobsfn = "gen-jobs.xml" + tempfnpost; string rnd = ""; string nextrandBin = ""; string nextrandAscii = ""; string nextrandLen = ""; string nextrandLower = ""; string nextrandUpper = ""; if (genrand == GenerateRandom.RANDOM) { rnd = "Random rnd = new Random(unchecked(System.DateTime.Now.Millisecond + System.Diagnostics.Process.GetCurrentProcess().Id + DSpace_BlockID));"; nextrandBin = "rnd.Next()"; nextrandAscii = "rnd.Next((int)' ' + 1, (int)'~' + 1)"; nextrandLen = "rnd.Next(3, 9 + 1)"; nextrandLower = "rnd.Next((int)'a', (int)'z' + 1)"; nextrandUpper = "rnd.Next((int)'A', (int)'Z' + 1)"; } else if (genrand == GenerateRandom.FRANDOM) { rnd = "FRandom.Seed(unchecked(System.DateTime.Now.Millisecond + System.Diagnostics.Process.GetCurrentProcess().Id + DSpace_BlockID));"; nextrandBin = "FRandom.Next()"; nextrandAscii = "FRandom.Next((int)' ' + 1, (int)'~' + 1)"; nextrandLen = "FRandom.Next(3, 9 + 1)"; nextrandLower = "FRandom.Next((int)'a', (int)'z' + 1)"; nextrandUpper = "FRandom.Next((int)'A', (int)'Z' + 1)"; } else if (genrand == GenerateRandom.DRANDOM) { if (GenerateType.ASCII == type) { rnd = @"DRandom rnd = new DRandom(false, true, (int)' ' + 1, (int)'~' + 1); DRandom rndLen = null; DRandom rndLower = null; DRandom rndUpper = null;"; nextrandBin = "rnd.Next()"; } else if (GenerateType.WORDS == type) { rnd = @"DRandom rndLen = new DRandom(false, true, 3, 9 + 1); DRandom rndLower = new DRandom(false, true, (int)'a', (int)'z' + 1); DRandom rndUpper = new DRandom(false, true, (int)'A', (int)'Z' + 1); DRandom rnd = null;"; } else { rnd = @"DRandom rnd = new DRandom(); DRandom rndLen = null; DRandom rndLower = null; DRandom rndUpper = null;"; } nextrandBin = "rnd.Next()"; nextrandAscii = "rnd.Next()"; nextrandLen = "rndLen.Next()"; nextrandLower = "rndLower.Next()"; nextrandUpper = "rndUpper.Next()"; } try { string dline = ""; string drline = ""; #if DEBUG dline = "#line 1 \"GEN.ds\"" + Environment.NewLine; drline = "#line default" + Environment.NewLine; #endif string outsuffix = ""; if (RecordLength > 0) { outsuffix = "@" + RecordLength; } string[] slaves = dc.Slaves.SlaveList.Split(';'); int maxWriters = (writersCount > 0) ? writersCount : Surrogate.NumberOfProcessors * slaves.Length; using (System.IO.StreamWriter sw = System.IO.File.CreateText(jobsfn)) { sw.Write(@"<SourceCode> <Jobs> <Job> <Narrative> <Name>Generate Data</Name> <Custodian></Custodian> <email></email> </Narrative> <IOSettings> <JobType>remote</JobType>"); for (int si = 0; si < maxWriters; si++) { sw.WriteLine(@" <DFS_IO> <DFSReader></DFSReader> <DFSWriter>dfs://" + outname + ".gen" + si.ToString() + tempfnpost + outsuffix + @"</DFSWriter> </DFS_IO>"); } sw.WriteLine((@" </IOSettings> <Remote> <![CDATA[ " + dline + @" public virtual void Remote(RemoteInputStream dfsinput, RemoteOutputStream dfsoutput) { const bool IS_RBIN_FILE = " + ((RecordLength > 0) ? "true" : "false") + @"; // Is rectangular binary output file? const bool IS_ASCII = " + ((GenerateType.ASCII == type) ? "true" : "false") + @"; const bool IS_WORDS = " + ((GenerateType.WORDS == type) ? "true" : "false") + @"; const long size = " + sizeoutput.ToString() + @"; const long rowsize = " + rowsize.ToString() + @"; long fullrecordsize = rowsize + " + Environment.NewLine.Length + @"; if(IS_RBIN_FILE) { fullrecordsize = Qizmt_OutputRecordLength; } long numrows = size / fullrecordsize; if((size % fullrecordsize) != 0) { numrows++; } " + rnd + @" List<byte> onerow = new List<byte>((rowsize > 16777216) ? 16777216 : (int)rowsize); long numrowsPART = numrows / DSpace_BlocksTotalCount; if(IS_RBIN_FILE) { if(DSpace_BlockID < (numrows % DSpace_BlocksTotalCount)) { numrowsPART++; } } else { if(0 == DSpace_BlockID) { numrowsPART += numrows % DSpace_BlocksTotalCount; } } for(long rn = 0; rn < numrowsPART; rn++) { onerow.Clear(); byte b; if(IS_WORDS) { bool fupper = true; long remain = rowsize - 1; // Don't count trailing dot. while(remain - 1 >= 3) // -1 here for word separator space. { if(onerow.Count > 0) { onerow.Add((byte)' '); remain--; } long wlen = " + nextrandLen + @"; if(wlen > remain - 1) { wlen = remain - 1; } for(int wi = 0; wi < wlen; wi++) { if(fupper) { fupper = false; b = (byte)" + nextrandUpper + @"; } else { b = (byte)" + nextrandLower + @"; } onerow.Add(b); } remain -= wlen; } onerow.Add((byte)'.'); // Don't count trailing dot. while(remain > 0) { onerow.Add((byte)' '); remain--; } } else { for(int nb = 0; nb < rowsize; nb++) { if(IS_ASCII) { b = (byte)" + nextrandAscii + @"; } else // Binary. { for(;;) { b = (byte)" + nextrandBin + @"; if(!IS_RBIN_FILE) { if(b == 0 || b == '\n' || b == '\r') { continue; } } break; } } onerow.Add(b); } } if(IS_RBIN_FILE) { while(onerow.Count < DSpace_OutputRecordLength) { if(IS_ASCII || IS_WORDS) { //onerow.Add((byte)' '); throw new NotImplementedException(); } else { onerow.Add((byte)0); } } dfsoutput.WriteRecord(onerow); } else { dfsoutput.WriteLine(onerow); } } } " + drline + @" ]]> </Remote> </Job> </Jobs> </SourceCode> ").Replace("`", "\"")); /* * //dfsoutput.Write(onerow); * //dfsoutput.Write(`" + rowsep.Replace("\\", "\\\\").Replace("\n", "\\n").Replace("\r", "\\r").Replace("\"", "\\\"") + @"`); * */ } { // File jobsfn exists. Console.WriteLine("Generating data..."); Exec("", LoadConfig(xpaths, jobsfn), new string[] { }, false, false); if (null != DfsFindAny(dc, outname)) { SetFailure(); return; } Shell("DSpace -dfs combine \"dfs://" + outname + ".gen*" + tempfnpost + "\" + \"" + outname + "\""); if (RecordLength > 0) { Console.WriteLine("Done; file '{0}' written into DFS with {1} of random data per {2} record", outname, GetFriendlyByteSize(rowsize), GetFriendlyByteSize(RecordLength)); } else { Console.WriteLine("Done; file '{0}' written into DFS with {1} rows", outname, GetFriendlyByteSize(rowsize)); } } } finally { try { System.IO.File.Delete(jobsfn); } catch { } } }
public TypeBuilderResult(GenerateType generateType, Type originType, Type generatedType) { GenerateType = generateType; OriginType = originType; GeneratedType = generatedType; }
public override void OnInspectorGUI() { EditorGUILayout.HelpBox("This object will create new game objects and parent them to this game object", MessageType.Warning); splineMesh = target as SplineMesh; SplineWindow splineWindow = splineMesh.spline; GenerateType type = splineMesh.type; splineMesh.spline = EditorGUILayout.ObjectField(new GUIContent("Spline", "spline from the scene"), splineWindow, typeof(SplineWindow), true) as SplineWindow; splineMesh.prefab = EditorGUILayout.ObjectField(new GUIContent("Prefab", "Game object to spawn"), splineMesh.prefab, typeof(GameObject), false) as GameObject; splineMesh.UseLookAtRotation = EditorGUILayout.Toggle(new GUIContent("Use look at rotation", "Rotate the object to face the next point"), splineMesh.UseLookAtRotation); splineMesh.update = EditorGUILayout.Toggle(new GUIContent("Update", "when this is checked the spline mesh will be updated whenever it can (not in game)"), splineMesh.update); splineMesh.offsetPosition = EditorGUILayout.Vector3Field(new GUIContent("Offset position", "offset the position of all objects spawned"), splineMesh.offsetPosition); splineMesh.offsetRotation = EditorGUILayout.Vector3Field(new GUIContent("Offset rotation", "offset the rotation of all objects spawned"), splineMesh.offsetRotation); splineMesh.scale = EditorGUILayout.Vector3Field(new GUIContent("Scale", "Scale all objects spawned"), splineMesh.scale); splineMesh.type = (GenerateType)EditorGUILayout.EnumPopup(new GUIContent("Type", "Generat type"), splineMesh.type); if (splineMesh.type == GenerateType.GenerateByDistance) { splineMesh.distance = EditorGUILayout.FloatField(new GUIContent("Distance", "The distance between objects"), splineMesh.distance); EditorGUILayout.HelpBox("Max number of objects depends on the resolution of the spline", MessageType.Info); } if (splineMesh == null || splineWindow == null || splineWindow.spline == null) { return; } if (splineMesh.prefab == null) { EditorGUILayout.HelpBox("Please assign a prefab", MessageType.Info); } realTime = EditorGUILayout.Toggle(new GUIContent("Real time", "Update the mesh real time"), realTime); if (splineMesh.type != type) { splineMesh.ClearAll(); } splineMesh.UpdatePosition(); if (realTime) { if (GUI.changed) { splineMesh.ReGenerate(); } } else { if (GUILayout.Button("Generate")) { splineMesh.ReGenerate(); } } if (GUILayout.Button("Clear")) { splineMesh.ClearAll(); } }
public void Generate(Action <ISheet> progressCalback, GenerateType generateType, Action completeCallback, Action <string> serializableProgress) { if (!PathManager01.Instance.CheckConfigPath()) { completeCallback(); return; } var loopCount = 1; var fieldType = string.Empty; if ((int)generateType == 3) { loopCount = 2; fieldType = "1&2"; PathManager01.Instance._filesPath.Add("1", new List <string>()); PathManager01.Instance._filesPath.Add("2", new List <string>()); } else if ((int)generateType == 2) { fieldType = "2"; PathManager01.Instance._filesPath.Add("2", new List <string>()); } else if ((int)generateType == 1) { fieldType = "1"; PathManager01.Instance._filesPath.Add("1", new List <string>()); } var spiltFied = fieldType.Split('&'); if (!PathManager01.Instance.LoadBaseTable(spiltFied)) { PathManager01.Instance._filesPath.Clear(); completeCallback(); return; } for (var i = 0; i < loopCount; i++) { if (spiltFied[i].Equals("1"))//客户端 { //生成cs文件 GenerateTableStruct(progressCalback, spiltFied[i]); //生成TableEntity文件 GenerateRunTimeTable(spiltFied[i]); //编译 string dllOutPath = CompileCode(spiltFied[i], serializableProgress);//, Serializeble); //客户端结构文件 if (PathManager01.Instance._configPathNew.ContainsKey(ConfigConst.ClientDllOutPath)) { foreach (var s in PathManager01.Instance._configPathNew[ConfigConst.ClientDllOutPath]) { File.Copy(dllOutPath, s + "\\DMNTableData.dll", true); } } //客户端Bin if (PathManager01.Instance._configPathNew.ContainsKey(ConfigConst.ClientBinOutPath)) { Assembly ab = Assembly.Load(File.ReadAllBytes(dllOutPath)); foreach (var s in PathManager01.Instance._configPathNew[ConfigConst.ClientBinOutPath]) { Serializeble(ab, s, serializableProgress); } } } else if (spiltFied[i].Equals("2"))//战斗服务器 { ////生成结构文件 //if (PathManager.Instance._configPathNew.ContainsKey(ConfigConst.BattleConfigFileOutPath)) //{ // foreach (var s in PathManager.Instance._configPathNew[ConfigConst.BattleConfigFileOutPath]) // { // ExcelConvter.ConvterAllFileCsharp(PathManager.Instance._configPath[ConfigConst.InputPath], s, System.Windows.Forms.Application.StartupPath + "\\ServerDepend", serializableProgress); // } //} ////生成Bin文件 //if (PathManager.Instance._configPathNew.ContainsKey(ConfigConst.BattleBinOutPath)) //{ // foreach (var s in PathManager.Instance._configPathNew[ConfigConst.BattleBinOutPath]) // { // ExcelConvter.ReadExcelToCsharp(PathManager.Instance._configPath[ConfigConst.InputPath], s, serializableProgress); // } //} } } if (PathManager01.Instance.GenerateProtobuf) { if (PathManager01.Instance._configPath.ContainsKey(ConfigConst.ProtoBuffPath)) { string batPath = PathManager01.Instance._configPath[ConfigConst.ProtoBuffPath]; string eBatPath = Path.GetDirectoryName(batPath); Environment.CurrentDirectory = eBatPath; Process.Start(batPath); Environment.CurrentDirectory = System.Windows.Forms.Application.StartupPath; } } completeCallback(); PathManager01.Instance._filesPath.Clear(); }
void OnGUI() { var tab = (int)generateType; var type = generateType.ToString(); var dataDirectory = Application.dataPath; var dirLength = dataDirectory.Length; var baseDirectory = GetBaseDirectory(); currentNamespace = GetBaseNamespaceFromDirectory(baseDirectory); GUILayout.Space(4); DrawBasePath(baseDirectory); CheckPaths(baseDirectory); if (!componentsDirectoryExists || !systemsDirectoryExists || !jobsDirectoryExists ) { return; } // GUILayout.Space (8); string[] types = GetValidTypes(); CheckBootstrap(baseDirectory); var tempFileDirectory = baseDirectory; var selectedTab = GUILayout.SelectionGrid(tab, types, 2); if (selectedTab != tab) { tab = selectedTab; generateType = (GenerateType)selectedTab; } switch ((GenerateType)selectedTab) { // case GenerateType.Bootstrap: // secondaryNamespace = ""; // break; case GenerateType.ComponentData: case GenerateType.SharedComponentData: tempFileDirectory = componentsDirectory; secondaryNamespace = "Components."; break; case GenerateType.ComponentSystem: case GenerateType.JobComponentSystem: tempFileDirectory = systemsDirectory; secondaryNamespace = "Systems."; break; case GenerateType.BasicJob: case GenerateType.ParallelJob: case GenerateType.NativeMultiHashMapJob: case GenerateType.ComponentDataJob: tempFileDirectory = jobsDirectory; secondaryNamespace = "Jobs."; break; } GUILayout.Space(8); var rect = EditorGUILayout.BeginVertical(); var prefixNamespace = currentNamespace + "." + secondaryNamespace; EditorGUILayout.LabelField($"Create New {type}:"); EditorGUILayout.BeginHorizontal(); GUI.enabled = false; EditorGUILayout.TextField(prefixNamespace, GUILayout.MaxWidth(Mathf.RoundToInt(prefixNamespace.Length * 7f))); GUI.enabled = true; fileNameInput = EditorGUILayout.TextField(fileNameInput, GUILayout.ExpandWidth(true)); showNameHelp = GUILayout.Toggle(showNameHelp, EditorGUIUtility.IconContent("_Help"), EditorStyles.label, GUILayout.Width(18)); EditorGUILayout.EndHorizontal(); if (showNameHelp) { EditorGUILayout.HelpBox("Name with namespace but without extension. For example if you want to create a " + type + " file of Ball in the namespace " + prefixNamespace + "Items, input: Items.Ball", MessageType.Info); } EditorGUILayout.EndVertical(); if (string.IsNullOrEmpty(fileNameInput.Trim())) { return; } var tempTypeName = StringUtils.ValidClassName(fileNameInput.Trim()); tempTypeName = StringUtils.CreateFileName(tempTypeName); fullName = prefixNamespace; var fileSubDirectory = ""; if (tempTypeName.IndexOf('.') > -1) { var subNamespaces = tempTypeName.Split('.'); for (int i = 0; i < subNamespaces.Length - 1; i++) { fullName += subNamespaces[i] + "."; fileSubDirectory += "/" + subNamespaces[i]; } tempTypeName = subNamespaces[subNamespaces.Length - 1]; } if ( ( generateType == GenerateType.ComponentData || generateType == GenerateType.SharedComponentData ) && !tempTypeName.ToLowerInvariant().EndsWith("component") ) { tempTypeName = tempTypeName + "Component"; } if ( ( generateType == GenerateType.ComponentSystem || generateType == GenerateType.JobComponentSystem ) && !tempTypeName.ToLowerInvariant().EndsWith("system")) { tempTypeName = tempTypeName + "System"; } if ( ( generateType == GenerateType.BasicJob || generateType == GenerateType.ParallelJob || generateType == GenerateType.NativeMultiHashMapJob || generateType == GenerateType.ComponentDataJob ) && !tempTypeName.ToLowerInvariant().EndsWith("job")) { tempTypeName = tempTypeName + "Job"; } fileName = tempTypeName + ".cs"; typeName = tempTypeName; typeNamespace = fullName.Substring(0, fullName.Length - 1); fullName += typeName; fileDirectory = tempFileDirectory + fileSubDirectory + "/"; EditorGUILayout.LabelField("Full Name: " + fullName); var horizontalRect = GUILayoutUtility.GetLastRect(); GUILayout.Space(4); if (string.IsNullOrEmpty(typeName)) { return; } if (string.IsNullOrEmpty(typeNamespace)) { return; } if (string.IsNullOrEmpty(fullName)) { return; } if (string.IsNullOrEmpty(fileDirectory)) { return; } if (string.IsNullOrEmpty(fileName)) { return; } GUILayout.Label(ShortenPath(fileDirectory + fileName, horizontalRect.width)); if (GUILayout.Button("Create " + type)) { Create(); } if (GUILayout.Button("Create " + type + " Then Open Editor")) { Create(true); } }
public static Core.DatabaseGeneratorResult Generate(string databaseName, RobotBlocks.Core.DatabaseGeneratorInput <T> generatorInput, string[] arguments, GenerateType generateType = GenerateType.PATH) { databaseName = databaseName.ToSafeString(); switch (generateType) { case GenerateType.FILES: return(GenerateFromFiles(databaseName, generatorInput, arguments)); case GenerateType.SOURCE: return(GenerateFromSource(databaseName, generatorInput, arguments)); case GenerateType.PATH: default: return(GenerateFromPath(databaseName, generatorInput, arguments)); } }
private void OnGUI() { if (!EasyARController.Initialized || !string.IsNullOrEmpty(Engine.errorMessage())) { if (GUI.Button(new Rect(20, 20, position.width - 40, 30), "Apply License Key Change")) { Selection.SetActiveObjectWithContext(EasyARController.Settings, null); EasyARController.GlobalInitialization(); } var textStyle = new GUIStyle(EditorStyles.label); textStyle.normal.textColor = Color.red; EditorGUI.LabelField(new Rect(20, 60, position.width - 40, 20), Engine.errorMessage(), textStyle); return; } if (generateType == GenerateType.Image || generateType == GenerateType.ImageList) { if (Event.current.type == EventType.DragUpdated) { foreach (var path in DragAndDrop.paths) { var ext = Path.GetExtension(path).ToLower(); if (ext == ".jpg" || ext == ".png" || ext == ".bmp") { DragAndDrop.visualMode = DragAndDropVisualMode.Generic; break; } } } } var yPosition = 20; EditorGUI.LabelField(new Rect(20, yPosition, 100, 30), "Generate From"); generateType = (GenerateType)EditorGUI.EnumPopup(new Rect(120, yPosition, 100, 30), generateType); yPosition += 30; switch (generateType) { case GenerateType.Image: if (Event.current.type == EventType.DragExited) { imagePaths = string.Empty; foreach (var path in DragAndDrop.paths) { var ext = Path.GetExtension(path).ToLower(); if (ext == ".jpg" || ext == ".png" || ext == ".bmp") { imagePaths = path; if (File.Exists(path)) { targetName = GetNameFromPath(path); } break; } } Repaint(); } GUI.Label(new Rect(20, yPosition, 120, 20), "Image Path"); yPosition += 20; imagePaths = EditorGUI.TextArea(new Rect(20, yPosition, position.width - 40, 30), imagePaths); yPosition += 30 + 30; if (string.IsNullOrEmpty(targetName)) { foreach (var path in imagePaths.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) { if (File.Exists(path)) { targetName = GetNameFromPath(path); } break; } } targetName = EditorGUI.TextField(new Rect(20, yPosition, position.width - 40, 20), "Name:", targetName); yPosition += 20; targetScale = EditorGUI.FloatField(new Rect(20, yPosition, position.width - 40, 20), "Scale (m):", targetScale); break; case GenerateType.ImageList: if (Event.current.type == EventType.DragExited) { imagePaths = string.Empty; foreach (var path in DragAndDrop.paths) { var ext = Path.GetExtension(path).ToLower(); if (ext == ".jpg" || ext == ".png" || ext == ".bmp") { imagePaths += path + Environment.NewLine; } } Repaint(); } GUI.Label(new Rect(20, yPosition, 120, 20), "Image Paths"); yPosition += 20; imagePaths = EditorGUI.TextArea(new Rect(20, yPosition, position.width - 40, 100), imagePaths); yPosition += 100 + 30; EditorGUI.LabelField(new Rect(20, yPosition, position.width - 40, 20), "Name: (Filename is Used)"); yPosition += 20; targetScale = EditorGUI.FloatField(new Rect(20, yPosition, position.width - 40, 20), "Scale (m):", targetScale); break; case GenerateType.Texture: GUI.Label(new Rect(20, yPosition, 120, 20), "Texture"); yPosition += 20; texture = EditorGUI.ObjectField(new Rect(20, yPosition, 80, 80), texture, typeof(Texture2D), false) as Texture2D; yPosition += 80 + 30; if (!string.IsNullOrEmpty(AssetDatabase.GetAssetPath(texture))) { targetName = GetNameFromPath(AssetDatabase.GetAssetPath(texture)); } targetName = EditorGUI.TextField(new Rect(20, yPosition, position.width - 40, 20), "Name:", targetName); yPosition += 20; targetScale = EditorGUI.FloatField(new Rect(20, yPosition, position.width - 40, 20), "Scale (m):", targetScale); break; default: break; } EditorGUI.LabelField(new Rect(20, position.height - 50 - 40 - 20, 160, 20), "Generate To"); outputPathDir = EditorGUI.TextArea(new Rect(20, position.height - 50 - 40, position.width - 40, 20), outputPathDir); if (GUI.Button(new Rect(20, position.height - 50, position.width - 40, 30), "Generate")) { try { switch (generateType) { case GenerateType.Image: foreach (var path in imagePaths.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) { CreateTargetFileByByteArray(File.ReadAllBytes(path), targetName); break; } break; case GenerateType.ImageList: foreach (var path in imagePaths.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) { if (!File.Exists(path)) { continue; } var ext = Path.GetExtension(path).ToLower(); if (ext == ".jpg" || ext == ".png" || ext == ".bmp") { CreateTargetFileByByteArray(File.ReadAllBytes(path), GetNameFromPath(path)); } } break; case GenerateType.Texture: var filePath = AssetDatabase.GetAssetPath(texture); if (filePath.StartsWith("Assets/")) { filePath = filePath.Substring(6); } else { throw new Exception("invalid image file: " + filePath); } var texturePath = Application.dataPath + filePath; CreateTargetFileByByteArray(File.ReadAllBytes(texturePath), targetName); break; default: break; } } catch (Exception e) { Debug.LogError(e.Message); } } }
private void OnGUI() { if (generateType == GenerateType.None) { InitPath(); } #region Title //Title Label GUILayout.Space(20); GUIStyle centeredStyle = new GUIStyle(GUI.skin.GetStyle("Label")); centeredStyle.alignment = TextAnchor.UpperCenter; centeredStyle.fontSize = 20; GUILayout.Label(new GUIContent("Select Excel Files To ScriptableObj"), centeredStyle); GUILayout.Space(20); #endregion GUILayout.BeginVertical(); #region GenerateType //GenerateType GenerateType type = (GenerateType)EditorGUILayout.EnumPopup(new GUIContent("GenerateType", "Choose target type to generate for."), generateType); if (type != generateType) { generateType = type; PlayerPrefs.SetString("GenerateType", type.ToString()); } #endregion GUILayout.Space(5); #region CSOutputPath EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); GUILayout.Space(5); //CS Output Path csOutPath = EditorGUILayout.TextField("CS Output Path:", csOutPath, GUILayout.MaxWidth(900)); EditorGUILayout.EndVertical(); //Browse "Output Path" GUILayout.FlexibleSpace(); if (GUILayout.Button("Browse", GUILayout.MaxWidth(80))) { BrowseForFolder(ref csOutPath); PlayerPrefs.SetString("CSOutPath", csOutPath); } EditorGUILayout.EndHorizontal(); #endregion GUILayout.Space(5); #region ObjOutputPath EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); GUILayout.Space(5); //Obj Output Path objOutPath = EditorGUILayout.TextField("Obj Output Path:", objOutPath, GUILayout.MaxWidth(900)); EditorGUILayout.EndVertical(); //Browse "Output Path" GUILayout.FlexibleSpace(); if (GUILayout.Button("Browse", GUILayout.MaxWidth(80))) { BrowseForFolder(ref objOutPath); PlayerPrefs.SetString("ObjOutPath", objOutPath); } EditorGUILayout.EndHorizontal(); #endregion GUILayout.Space(20); DrawLine(new Vector3(0, 180), new Vector3(400, 180), Color.gray); DrawLine(new Vector3(400, 180), new Vector3(400, 1000), Color.gray); EditorGUILayout.BeginHorizontal(); #region LeftChooseArea //Left Choose Area GUILayout.BeginArea(new Rect(0, 180, 400, 1000)); GUIStyle labelSty = new GUIStyle("HeaderLabel"); labelSty.fontSize = 15; GUILayout.Label("History Log:", labelSty); GUILayout.Space(5); if (generateType == GenerateType.Single_File) { string[] records = fileRecordPaths.Split(';'); for (int i = 0; i < records.Length; i++) { HistoryLogItem(records[i], generateType); } } else if (generateType == GenerateType.Folder_Files) { string[] records = foldRecordPaths.Split(';'); for (int i = 0; i < records.Length; i++) { HistoryLogItem(records[i], generateType); } } GUILayout.EndArea(); #endregion #region Right Generate Area //Right Generate Area GUILayout.BeginArea(new Rect(400, 180, 600, 1000)); if (generateType == GenerateType.Single_File) { filePath = EditorGUILayout.TextField("SelectExcel:", filePath); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Browse", GUILayout.MaxWidth(80))) { BrowseForFiles(ref filePath); PlayerPrefs.SetString("FilePath", filePath); } EditorGUILayout.EndHorizontal(); GUILayout.Space(20); if (GUI.Button(new Rect(130, 200, 150, 20), "Generate CS")) { GenerateCSFile(); } if (GUI.Button(new Rect(330, 200, 150, 20), "Create Obj")) { GenerateAsset(); } } else if (generateType == GenerateType.Folder_Files) { folderPath = EditorGUILayout.TextField("SelectFolder:", folderPath); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Browse", GUILayout.MaxWidth(80))) { BrowseForFolder(ref folderPath); PlayerPrefs.SetString("FoldPath", folderPath); } EditorGUILayout.EndHorizontal(); GUILayout.Space(20); if (GUI.Button(new Rect(130, 200, 150, 20), "Generate CS")) { GenerateCSFile(); } if (GUI.Button(new Rect(330, 200, 150, 20), "Generate Obj")) { GenerateAsset(); } } GUILayout.EndArea(); #endregion EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); }
/// <summary> /// /// </summary> /// <param name="excelName">文件名.表名 格式, 文件名不包含路径和后缀</param> /// <param name="genType">excel中每行对应一个so文件还是整表对应一个so</param> public ExcelBindAttribute(string excelName, GenerateType genType = GenerateType.Row) { ExcelName = excelName; GenType = genType; }
/// <summary> /// Parse the command line options for this extension. /// </summary> /// <param name="type">The active harvester type.</param> /// <param name="args">The option arguments.</param> public override void ParseOptions(string type, string[] args) { bool active = false; IHarvesterExtension harvesterExtension = null; bool suppressHarvestingRegistryValues = false; UtilFinalizeHarvesterMutator utilFinalizeHarvesterMutator = new UtilFinalizeHarvesterMutator(); UtilMutator utilMutator = new UtilMutator(); List <UtilTransformMutator> transformMutators = new List <UtilTransformMutator>(); GenerateType generateType = GenerateType.Components; // select the harvester switch (type) { case "dir": harvesterExtension = new DirectoryHarvester(); active = true; break; case "file": harvesterExtension = new FileHarvester(); active = true; break; case "exepackagepayload": harvesterExtension = new PayloadHarvester(this.PayloadHarvester, WixBundlePackageType.Exe); active = true; break; case "msupackagepayload": harvesterExtension = new PayloadHarvester(this.PayloadHarvester, WixBundlePackageType.Msu); active = true; break; case "perf": harvesterExtension = new PerformanceCategoryHarvester(); active = true; break; case "reg": harvesterExtension = new RegFileHarvester(); active = true; break; } // set default settings utilMutator.CreateFragments = true; utilMutator.SetUniqueIdentifiers = true; // parse the options for (int i = 0; i < args.Length; i++) { string commandSwitch = args[i]; if (null == commandSwitch || 0 == commandSwitch.Length) // skip blank arguments { continue; } if ('-' == commandSwitch[0] || '/' == commandSwitch[0]) { string truncatedCommandSwitch = commandSwitch.Substring(1); if ("ag" == truncatedCommandSwitch) { utilMutator.AutogenerateGuids = true; } else if ("cg" == truncatedCommandSwitch) { utilMutator.ComponentGroupName = this.GetArgumentParameter(args, i); if (this.Core.Messaging.EncounteredError) { return; } } else if ("dr" == truncatedCommandSwitch) { string dr = this.GetArgumentParameter(args, i); if (this.Core.Messaging.EncounteredError) { return; } if (harvesterExtension is DirectoryHarvester) { ((DirectoryHarvester)harvesterExtension).RootedDirectoryRef = dr; } else if (harvesterExtension is FileHarvester) { ((FileHarvester)harvesterExtension).RootedDirectoryRef = dr; } } else if ("gg" == truncatedCommandSwitch) { utilMutator.GenerateGuids = true; } else if ("g1" == truncatedCommandSwitch) { utilMutator.GuidFormat = "D"; } else if ("ke" == truncatedCommandSwitch) { if (harvesterExtension is DirectoryHarvester) { ((DirectoryHarvester)harvesterExtension).KeepEmptyDirectories = true; } else if (active) { // TODO: error message - not applicable to file harvester } } else if ("scom" == truncatedCommandSwitch) { if (active) { utilFinalizeHarvesterMutator.SuppressCOMElements = true; } else { // TODO: error message - not applicable } } else if ("svb6" == truncatedCommandSwitch) { if (active) { utilFinalizeHarvesterMutator.SuppressVB6COMElements = true; } else { // TODO: error message - not applicable } } else if ("sfrag" == truncatedCommandSwitch) { utilMutator.CreateFragments = false; } else if ("srd" == truncatedCommandSwitch) { if (harvesterExtension is DirectoryHarvester) { ((DirectoryHarvester)harvesterExtension).SuppressRootDirectory = true; } else if (harvesterExtension is FileHarvester) { ((FileHarvester)harvesterExtension).SuppressRootDirectory = true; } } else if ("sreg" == truncatedCommandSwitch) { suppressHarvestingRegistryValues = true; } else if ("suid" == truncatedCommandSwitch) { utilMutator.SetUniqueIdentifiers = false; if (harvesterExtension is DirectoryHarvester) { ((DirectoryHarvester)harvesterExtension).SetUniqueIdentifiers = false; } else if (harvesterExtension is FileHarvester) { ((FileHarvester)harvesterExtension).SetUniqueIdentifiers = false; } } else if (truncatedCommandSwitch.StartsWith("t:", StringComparison.Ordinal) || "t" == truncatedCommandSwitch) { string xslFile; if (truncatedCommandSwitch.StartsWith("t:", StringComparison.Ordinal)) { this.Core.Messaging.Write(WarningMessages.DeprecatedCommandLineSwitch("t:", "t")); xslFile = truncatedCommandSwitch.Substring(2); } else { xslFile = this.GetArgumentParameter(args, i, true); } if (0 <= xslFile.IndexOf('\"')) { this.Core.Messaging.Write(ErrorMessages.PathCannotContainQuote(xslFile)); return; } try { xslFile = Path.GetFullPath(xslFile); } catch (Exception e) { this.Core.Messaging.Write(ErrorMessages.InvalidCommandLineFileName(xslFile, e.Message)); return; } transformMutators.Add(new UtilTransformMutator(xslFile, transformMutators.Count)); } else if (truncatedCommandSwitch.StartsWith("template:", StringComparison.Ordinal) || "template" == truncatedCommandSwitch) { string template; if (truncatedCommandSwitch.StartsWith("template:", StringComparison.Ordinal)) { this.Core.Messaging.Write(WarningMessages.DeprecatedCommandLineSwitch("template:", "template")); template = truncatedCommandSwitch.Substring(9); } else { template = this.GetArgumentParameter(args, i); } switch (template) { case "fragment": utilMutator.TemplateType = TemplateType.Fragment; break; case "module": utilMutator.TemplateType = TemplateType.Module; break; case "product": utilMutator.TemplateType = TemplateType.Package; break; default: // TODO: error break; } } else if ("var" == truncatedCommandSwitch) { if (active) { utilFinalizeHarvesterMutator.PreprocessorVariable = this.GetArgumentParameter(args, i); if (this.Core.Messaging.EncounteredError) { return; } } } else if ("generate" == truncatedCommandSwitch) { if (harvesterExtension is DirectoryHarvester) { string genType = this.GetArgumentParameter(args, i).ToUpperInvariant(); switch (genType) { case "COMPONENTS": generateType = GenerateType.Components; break; case "PAYLOADGROUP": generateType = GenerateType.PayloadGroup; break; default: throw new WixException(HarvesterErrors.InvalidDirectoryOutputType(genType)); } } else { // TODO: error message - not applicable } } } } // set the appropriate harvester extension if (active) { this.Core.Harvester.Extension = harvesterExtension; if (!suppressHarvestingRegistryValues) { this.Core.Mutator.AddExtension(new UtilHarvesterMutator()); } this.Core.Mutator.AddExtension(utilFinalizeHarvesterMutator); if (harvesterExtension is DirectoryHarvester directoryHarvester) { directoryHarvester.GenerateType = generateType; this.Core.Harvester.Core.RootDirectory = this.Core.Harvester.Core.ExtensionArgument; } else if (harvesterExtension is FileHarvester) { if (((FileHarvester)harvesterExtension).SuppressRootDirectory) { this.Core.Harvester.Core.RootDirectory = Path.GetDirectoryName(Path.GetFullPath(this.Core.Harvester.Core.ExtensionArgument)); } else { this.Core.Harvester.Core.RootDirectory = Path.GetDirectoryName(Path.GetDirectoryName(Path.GetFullPath(this.Core.Harvester.Core.ExtensionArgument))); // GetDirectoryName() returns null for root paths such as "c:\", so make sure to support that as well if (null == this.Core.Harvester.Core.RootDirectory) { this.Core.Harvester.Core.RootDirectory = Path.GetPathRoot(Path.GetDirectoryName(Path.GetFullPath(this.Core.Harvester.Core.ExtensionArgument))); } } } } // set the mutator this.Core.Mutator.AddExtension(utilMutator); // add the transforms foreach (UtilTransformMutator transformMutator in transformMutators) { this.Core.Mutator.AddExtension(transformMutator); } }
public static void Generate(List<string> xpaths, string outname, long sizeoutput, long rowsize, GenerateType type, int writersCount, GenerateRandom genrand) { int RecordLength = -1; if (outname.StartsWith("dfs://", StringComparison.OrdinalIgnoreCase)) { outname = outname.Substring(6); } { int iat = outname.IndexOf('@'); if (-1 != iat) { try { RecordLength = Surrogate.GetRecordSize(outname.Substring(iat + 1)); } catch (Exception e) { Console.Error.WriteLine(e.Message); SetFailure(); return; } outname = outname.Substring(0, iat); } } string reason = ""; if (dfs.IsBadFilename(outname, out reason)) { Console.Error.WriteLine("Invalid output-dfsfile: {0}", reason); SetFailure(); return; } dfs dc = LoadDfsConfig(); if (null != DfsFindAny(dc, outname)) { Console.Error.WriteLine("Output file already exists in DFS: {0}", outname); SetFailure(); return; } if (RecordLength > 0) { if (rowsize < 0) { rowsize = RecordLength; } else { if (rowsize > RecordLength) { Console.Error.WriteLine("Row data cannot be greater than DFS record length"); SetFailure(); return; } } if (type != GenerateType.BINARY) { Console.Error.WriteLine("Error: must specify type=bin when generating a rectangular binary DFS file"); SetFailure(); return; } } else { if (rowsize < 1) { rowsize = 100; } } string tempfnpost = "." + Guid.NewGuid().ToString() + "." + System.Diagnostics.Process.GetCurrentProcess().Id.ToString(); string jobsfn = "gen-jobs.xml" + tempfnpost; string rnd = ""; string nextrandBin = ""; string nextrandAscii = ""; string nextrandLen = ""; string nextrandLower = ""; string nextrandUpper = ""; if (genrand == GenerateRandom.RANDOM) { rnd = "Random rnd = new Random(unchecked(System.DateTime.Now.Millisecond + System.Diagnostics.Process.GetCurrentProcess().Id + DSpace_BlockID));"; nextrandBin = "rnd.Next()"; nextrandAscii = "rnd.Next((int)' ' + 1, (int)'~' + 1)"; nextrandLen = "rnd.Next(3, 9 + 1)"; nextrandLower = "rnd.Next((int)'a', (int)'z' + 1)"; nextrandUpper = "rnd.Next((int)'A', (int)'Z' + 1)"; } else if (genrand == GenerateRandom.FRANDOM) { rnd = "FRandom.Seed(unchecked(System.DateTime.Now.Millisecond + System.Diagnostics.Process.GetCurrentProcess().Id + DSpace_BlockID));"; nextrandBin = "FRandom.Next()"; nextrandAscii = "FRandom.Next((int)' ' + 1, (int)'~' + 1)"; nextrandLen = "FRandom.Next(3, 9 + 1)"; nextrandLower = "FRandom.Next((int)'a', (int)'z' + 1)"; nextrandUpper = "FRandom.Next((int)'A', (int)'Z' + 1)"; } else if (genrand == GenerateRandom.DRANDOM) { if (GenerateType.ASCII == type) { rnd = @"DRandom rnd = new DRandom(false, true, (int)' ' + 1, (int)'~' + 1); DRandom rndLen = null; DRandom rndLower = null; DRandom rndUpper = null;"; nextrandBin = "rnd.Next()"; } else if (GenerateType.WORDS == type) { rnd = @"DRandom rndLen = new DRandom(false, true, 3, 9 + 1); DRandom rndLower = new DRandom(false, true, (int)'a', (int)'z' + 1); DRandom rndUpper = new DRandom(false, true, (int)'A', (int)'Z' + 1); DRandom rnd = null;"; } else { rnd = @"DRandom rnd = new DRandom(); DRandom rndLen = null; DRandom rndLower = null; DRandom rndUpper = null;"; } nextrandBin = "rnd.Next()"; nextrandAscii = "rnd.Next()"; nextrandLen = "rndLen.Next()"; nextrandLower = "rndLower.Next()"; nextrandUpper = "rndUpper.Next()"; } try { string dline = ""; string drline = ""; #if DEBUG dline = "#line 1 \"GEN.ds\"" + Environment.NewLine; drline = "#line default" + Environment.NewLine; #endif string outsuffix = ""; if (RecordLength > 0) { outsuffix = "@" + RecordLength; } string[] slaves = dc.Slaves.SlaveList.Split(';'); int maxWriters = (writersCount > 0) ? writersCount : Surrogate.NumberOfProcessors * slaves.Length; using (System.IO.StreamWriter sw = System.IO.File.CreateText(jobsfn)) { sw.Write(@"<SourceCode> <Jobs> <Job> <Narrative> <Name>Generate Data</Name> <Custodian></Custodian> <email></email> </Narrative> <IOSettings> <JobType>remote</JobType>"); for (int si = 0; si < maxWriters; si++) { sw.WriteLine(@" <DFS_IO> <DFSReader></DFSReader> <DFSWriter>dfs://" + outname + ".gen" + si.ToString() + tempfnpost + outsuffix + @"</DFSWriter> </DFS_IO>"); } sw.WriteLine((@" </IOSettings> <Remote> <![CDATA[ " + dline + @" public virtual void Remote(RemoteInputStream dfsinput, RemoteOutputStream dfsoutput) { const bool IS_RBIN_FILE = " + ((RecordLength > 0) ? "true" : "false") + @"; // Is rectangular binary output file? const bool IS_ASCII = " + ((GenerateType.ASCII == type) ? "true" : "false") + @"; const bool IS_WORDS = " + ((GenerateType.WORDS == type) ? "true" : "false") + @"; const long size = " + sizeoutput.ToString() + @"; const long rowsize = " + rowsize.ToString() + @"; long fullrecordsize = rowsize + " + Environment.NewLine.Length + @"; if(IS_RBIN_FILE) { fullrecordsize = Qizmt_OutputRecordLength; } long numrows = size / fullrecordsize; if((size % fullrecordsize) != 0) { numrows++; } " + rnd + @" List<byte> onerow = new List<byte>((rowsize > 16777216) ? 16777216 : (int)rowsize); long numrowsPART = numrows / DSpace_BlocksTotalCount; if(IS_RBIN_FILE) { if(DSpace_BlockID < (numrows % DSpace_BlocksTotalCount)) { numrowsPART++; } } else { if(0 == DSpace_BlockID) { numrowsPART += numrows % DSpace_BlocksTotalCount; } } for(long rn = 0; rn < numrowsPART; rn++) { onerow.Clear(); byte b; if(IS_WORDS) { bool fupper = true; long remain = rowsize - 1; // Don't count trailing dot. while(remain - 1 >= 3) // -1 here for word separator space. { if(onerow.Count > 0) { onerow.Add((byte)' '); remain--; } long wlen = " + nextrandLen + @"; if(wlen > remain - 1) { wlen = remain - 1; } for(int wi = 0; wi < wlen; wi++) { if(fupper) { fupper = false; b = (byte)" + nextrandUpper + @"; } else { b = (byte)" + nextrandLower + @"; } onerow.Add(b); } remain -= wlen; } onerow.Add((byte)'.'); // Don't count trailing dot. while(remain > 0) { onerow.Add((byte)' '); remain--; } } else { for(int nb = 0; nb < rowsize; nb++) { if(IS_ASCII) { b = (byte)" + nextrandAscii + @"; } else // Binary. { for(;;) { b = (byte)" + nextrandBin + @"; if(!IS_RBIN_FILE) { if(b == 0 || b == '\n' || b == '\r') { continue; } } break; } } onerow.Add(b); } } if(IS_RBIN_FILE) { while(onerow.Count < DSpace_OutputRecordLength) { if(IS_ASCII || IS_WORDS) { //onerow.Add((byte)' '); throw new NotImplementedException(); } else { onerow.Add((byte)0); } } dfsoutput.WriteRecord(onerow); } else { dfsoutput.WriteLine(onerow); } } } " + drline + @" ]]> </Remote> </Job> </Jobs> </SourceCode> ").Replace("`", "\"")); /* //dfsoutput.Write(onerow); //dfsoutput.Write(`" + rowsep.Replace("\\", "\\\\").Replace("\n", "\\n").Replace("\r", "\\r").Replace("\"", "\\\"") + @"`); * */ } { // File jobsfn exists. Console.WriteLine("Generating data..."); Exec("", LoadConfig(xpaths, jobsfn), new string[] { }, false, false); if (null != DfsFindAny(dc, outname)) { SetFailure(); return; } Shell("DSpace -dfs combine \"dfs://" + outname + ".gen*" + tempfnpost + "\" + \"" + outname + "\""); if (RecordLength > 0) { Console.WriteLine("Done; file '{0}' written into DFS with {1} of random data per {2} record", outname, GetFriendlyByteSize(rowsize), GetFriendlyByteSize(RecordLength)); } else { Console.WriteLine("Done; file '{0}' written into DFS with {1} rows", outname, GetFriendlyByteSize(rowsize)); } } } finally { try { System.IO.File.Delete(jobsfn); } catch { } } }