private static void UploadAndMoveUnused(string[] accountTemplates, string[] groupTemplates, string[] publicTemplates, string[] wwwTemplates) { string[] accountUnusedFiles = null; if (accountTemplates != null) { accountUnusedFiles = FileSystemSupport.UploadTemplateContent(accountTemplates, TBSystem.CurrSystem, RenderWebSupport.DefaultAccountTemplates, true); } string[] groupUnusedFiles = null; if (groupTemplates != null) { groupUnusedFiles = FileSystemSupport.UploadTemplateContent(groupTemplates, TBSystem.CurrSystem, RenderWebSupport.DefaultGroupTemplates, true); } string[] publicUnusedFiles = null; if (publicTemplates != null) { publicUnusedFiles = FileSystemSupport.UploadTemplateContent(publicTemplates, TBSystem.CurrSystem, RenderWebSupport.DefaultPublicGroupTemplates, true); } string[] wwwUnusedFiles = null; if (wwwTemplates != null) { wwwUnusedFiles = FileSystemSupport.UploadTemplateContent(wwwTemplates, TBSystem.CurrSystem, RenderWebSupport.DefaultPublicWwwTemplates, true); } if (accountTemplates != null && groupTemplates != null && publicTemplates != null && wwwUnusedFiles != null) { string[] everyWhereUnusedFiles = accountUnusedFiles.Intersect(groupUnusedFiles).Intersect(publicUnusedFiles).Intersect(wwwUnusedFiles).ToArray(); //FileSystemSupport.MoveUnusedTxtFiles(everyWhereUnusedFiles); } }
/// <summary> /// Runs the data pump. /// </summary> public void Run() { string protocolsFile = Path.Combine(OutputPath, "TShark.protocols"); string fieldsFile = Path.Combine(OutputPath, "TShark.fields"); string valuesFile = Path.Combine(OutputPath, "TShark.values"); string decodesFile = Path.Combine(OutputPath, "TShark.decodes"); Log.WriteInfo("Generated schema file paths.\nProtocols: {0}\nFields: {1}\nValues: {2}\nDecodes: {3}", protocolsFile, fieldsFile, valuesFile, decodesFile); Log.WriteInfo("Writing protocols file."); TSharkInvoker.Invoke(TSharkPath, string.Format("-G protocols {0}", TSharkParams), protocolsFile); Log.WriteInfo("Writing fields file."); TSharkInvoker.Invoke(TSharkPath, string.Format("-G fields3 {0}", TSharkParams), fieldsFile); Log.WriteInfo("Writing values file."); TSharkInvoker.Invoke(TSharkPath, string.Format("-G values {0}", TSharkParams), valuesFile); Log.WriteInfo("Writing decodes file."); TSharkInvoker.Invoke(TSharkPath, string.Format("-G decodes {0}", TSharkParams), decodesFile); TSharkDataSchema schema; Log.WriteInfo("Reading TShark schema."); schema = TSharkSchemaReader.Read(protocolsFile, fieldsFile, valuesFile, decodesFile); Log.WriteInfo("Installing fixups."); TSharkFixups fixups = new TSharkFixups(); if (!string.IsNullOrEmpty(FixupsPath)) { fixups.LoadExternalFixups(FixupsPath); } using (DataWriter writer = CreateDataWriter()) { DataFilter filter = new DataFilter(DataFilterPreset); if (!string.IsNullOrEmpty(DataFilterPath)) { filter.LoadExternalFilter(DataFilterPath); } writer.Filter = filter; TSharkDataReaderCallback callback = writer.WriteRow; Log.WriteInfo("Starting data pump."); foreach (string file in FileSystemSupport.RecursiveScan(InputPath, null)) { Log.WriteInfo("Processing: {0}", file); string dataFile = GenerateOutputFile(file); TSharkInvoker.Invoke(TSharkPath, string.Format("-r \"{0}\" -n -T pdml -V {1}", file.Replace("\"", "\\\""), TSharkParams), dataFile); Log.WriteInfo("Reading TShark data file: {0}", dataFile); TSharkDataReader.Read(file, schema, dataFile, callback, fixups); } } }
static string GetTemplateContent(string fileName) { List <ErrorItem> errorList = new List <ErrorItem>(); Dictionary <string, bool> processedDict = new Dictionary <string, bool>(); var fixedContent = FileSystemSupport.GetFixedContent(fileName, errorList, processedDict); if (fixedContent == null) { return(null); } return(Encoding.UTF8.GetString(fixedContent)); }
/// <summary> /// Called to perform the main body of work for the application after command line arguments have been parsed. /// </summary> /// <param name="commandLine">Command line arguments.</param> protected override void Run(Arguments commandLine) { Log.WriteInfo("Starting up.\nUTC time: {0}\nLocal time: {1}\nVersion: {2}", DateTime.UtcNow, DateTime.Now, Assembly.GetExecutingAssembly().GetName().Version); Log.WriteInfo("Input directory: {0}", commandLine.InputPath); Log.WriteInfo("Output directory: {0}", commandLine.OutputPath); string fixupsFilePath = Path.Combine(commandLine.OutputPath, "Fixups.xml"); string traceFilePath = Path.Combine(commandLine.OutputPath, "Fixups.trace"); using (StreamWriter fixups = new StreamWriter(fixupsFilePath, false, Encoding.UTF8)) using (StreamWriter trace = new StreamWriter(traceFilePath, false, Encoding.UTF8)) { fixups.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\" ?>"); fixups.WriteLine("<fixups>"); HashSet <string> constantFixups = new HashSet <string>(); HashSet <string> prefixFixups = new HashSet <string>(); HashSet <string> speculativeFixups = new HashSet <string>(); string fullPath = Path.GetFullPath(commandLine.InputPath); string dissectorPath = Path.Combine(fullPath, @"epan\dissectors"); string pluginPath = Path.Combine(fullPath, @"plugins"); if (!Directory.Exists(dissectorPath)) { throw new Exception(string.Format("Directory not found: {0}", dissectorPath)); } if (!Directory.Exists(pluginPath)) { throw new Exception(string.Format("Directory not found: {0}", pluginPath)); } List <string> paths = new List <string>(); paths.Add(dissectorPath); paths.Add(pluginPath); foreach (string path in paths) { foreach (string file in FileSystemSupport.RecursiveScan(path, "*.c")) { ProcessSourceFile(file, fixups, trace, constantFixups, prefixFixups, speculativeFixups); } } fixups.WriteLine("</fixups>"); } }
private static void Main(string[] args) { try { //Console.WriteLine("Running test EKE..."); //TheBallEKE.TestExecution(); //Console.WriteLine("Running test EKE complete."); ////return; ////SecurityNegotiationManager.EchoClient().Wait(); //SecurityNegotiationManager.EchoClient(); //Console.ReadLine(); // Enter to exit //return; //return; if (args.Length != 4 || args[0].Length != 4) { Console.WriteLine("Usage: WebTemplateManager.exe <-pub name/-pri name> grp<groupID>/acc<acctID> <connection string>"); return; } //Debugger.Launch(); string pubPriPrefixWithDash = args[0]; string templateName = args[1]; if (String.IsNullOrWhiteSpace(templateName)) { throw new ArgumentException("Template name must be given"); } string connStr = args[3]; string grpacctID = args[2]; if (pubPriPrefixWithDash != "-pub" && pubPriPrefixWithDash != "-pri") { throw new ArgumentException("-pub or -pri misspelled or missing"); } string pubPriPrefix = pubPriPrefixWithDash.Substring(1); string ownerPrefix = grpacctID.Substring(0, 3); string ownerID = grpacctID.Substring(3); VirtualOwner owner = VirtualOwner.FigureOwner(ownerPrefix + "/" + ownerID); //string connStr = String.Format("DefaultEndpointsProtocol=http;AccountName=theball;AccountKey={0}", // args[0]); //connStr = "UseDevelopmentStorage=true"; bool debugMode = false; StorageSupport.InitializeWithConnectionString(connStr, debugMode); InformationContext.InitializeFunctionality(3, true); InformationContext.Current.InitializeCloudStorageAccess( Properties.Settings.Default.CurrentActiveContainerName); string directory = Directory.GetCurrentDirectory(); if (directory.EndsWith("\\") == false) { directory = directory + "\\"; } string[] allFiles = Directory.GetFiles(directory, "*", SearchOption.AllDirectories) .Select(str => str.Substring(directory.Length)) .ToArray(); if (pubPriPrefix == "pub" && templateName == "legacy") { FileSystemSupport.UploadTemplateContent(allFiles, owner, RenderWebSupport.DefaultPublicWwwTemplateLocation, true, Preprocessor, ContentFilterer, InformationTypeResolver); RenderWebSupport.RenderWebTemplate(owner.LocationPrefix, true, "AaltoGlobalImpact.OIP.Blog", "AaltoGlobalImpact.OIP.Activity"); } else { FileSystemSupport.UploadTemplateContent(allFiles, owner, templateName, true); } } catch (Exception exception) { Console.WriteLine("EXCEPTION: " + exception.ToString()); } Console.WriteLine("DONE"); }
public static string Output(this FPdf document, string name, OutputDevice destination) { // Output PDF to some destination if (document.State < 3) { document.Close(); } if (destination == OutputDevice.Default) { if (string.IsNullOrEmpty(name)) { name = "doc.pdf"; destination = OutputDevice.StandardOutput; } else { destination = OutputDevice.SaveToFile; } } switch (destination) { case OutputDevice.StandardOutput: HttpContext.Current.Response.AppendHeader("Content-Type: application/pdf", ""); HttpContext.Current.Response.AppendHeader("Content-Disposition: inline; filename=\"" + name + "\"", ""); HttpContext.Current.Response.AppendHeader("Cache-Control: private, max-age=0, must-revalidate", ""); HttpContext.Current.Response.AppendHeader("Pragma: public", ""); HttpContext.Current.Response.Write(document.Buffer); break; case OutputDevice.Download: // Download file HttpContext.Current.Response.AppendHeader("Content-Type: application/x-download", ""); HttpContext.Current.Response.AppendHeader( "Content-Disposition: attachment; filename=\"" + name + "\"", ""); HttpContext.Current.Response.AppendHeader("Cache-Control: private, max-age=0, must-revalidate", ""); HttpContext.Current.Response.AppendHeader("Pragma: public", ""); HttpContext.Current.Response.Write(document.Buffer); break; case OutputDevice.SaveToFile: // Save to local file FileStream f = FileSystemSupport.FileOpen(name, "wb"); if (!TypeSupport.ToBoolean(f)) { throw new InvalidOperationException("Unable to create output file: " + name); } var writer = new StreamWriter(f, FPdf.PrivateEncoding); writer.Write(document.Buffer); writer.Close(); break; case OutputDevice.ReturnAsString: return(document.Buffer); default: throw new InvalidOperationException("Incorrect output destination: " + destination); break; } return(string.Empty); }