public short Open(String xlName) { this.fileName = xlName; if (document != null && closed) { document = null; } if (!string.IsNullOrEmpty(xlName) && checkExcelDocument()) { closed = false; try { if (GXServices.Instance == null || GXServices.Instance.Get(GXServices.STORAGE_SERVICE) == null) { if (!Path.IsPathRooted(this.fileName)) { this.fileName = Path.Combine(GxContext.StaticPhysicalPath(), this.fileName); } } else { this.fileName = this.fileName.Replace("\\", "/"); } } catch (Exception e) { GXLogging.Warn(log, "Setting Rooted Path on " + this.fileName, e); } return(document.Open(this.fileName)); } else { return(document.ErrCode); } }
public void ToFile(string fileName) { FileStream fs; string pathName = fileName; #if !NETCORE if (HttpContext.Current != null) #endif if (fileName.IndexOfAny(new char[] { '\\', ':' }) == -1) { pathName = Path.Combine(GxContext.StaticPhysicalPath(), fileName); } #pragma warning disable SCS0018 // Path traversal: injection possible in {1} argument passed to '{0}' using (fs = new FileStream(pathName, FileMode.Create, FileAccess.Write)) #pragma warning restore SCS0018 // Path traversal: injection possible in {1} argument passed to '{0}' { ReceiveStream.Seek(0, SeekOrigin.Begin); Byte[] Buffer = new Byte[1024]; int BytesRead = ReceiveStream.Read(Buffer, 0, 1024); while (BytesRead > 0) { fs.Write(Buffer, 0, BytesRead); BytesRead = ReceiveStream.Read(Buffer, 0, 1024); } ReceiveStream.Seek(0, SeekOrigin.Begin); } }
public static String FindResources(string resourcesFile) { ArrayList file = new ArrayList(); string fileName = null; file.Add(Path.Combine(GxContext.StaticPhysicalPath(), resourcesFile)); file.Add(Path.Combine(Path.Combine(GxContext.StaticPhysicalPath(), "bin"), resourcesFile)); try { file.Add(Path.Combine(FileUtil.UriToPath(FileUtil.GetStartupDirectory()), resourcesFile)); } catch {} file.Add(Path.Combine(FileUtil.GetStartupDirectory(), resourcesFile)); foreach (string f in file) { if (File.Exists(f)) { GXLogging.Debug(log, "FindResources " + f); fileName = f; break; } } if (fileName != null) { return(fileName); } else { throw new FileNotFoundException("File " + resourcesFile + " not found"); } }
public short dfwopen(string fileName, string fldDelimiter, string strDelimiter, int append, string encoding) { if (_writeStatus != FileIOStatus.Closed) { GXLogging.Error(log, "Error ADF0005: open function in use"); return(GX_ASCDEL_INVALIDSEQUENCE); } try { FileMode mode = FileMode.Create; if (append == 1) { mode = FileMode.Append; } fileName = Path.Combine(GxContext.StaticPhysicalPath(), fileName); #pragma warning disable SCS0018 // Path traversal: injection possible in {1} argument passed to '{0}' _fsw = new FileStream(fileName, mode, FileAccess.Write, FileShare.ReadWrite, 1024); #pragma warning restore SCS0018 // Path traversal: injection possible in {1} argument passed to '{0}' } catch (DirectoryNotFoundException e) { GXLogging.Error(log, "Error ADF0001", e); return(GX_ASCDEL_OPENERROR); } _fldDelimiterW = CleanDelimiter(fldDelimiter); _strDelimiterW = strDelimiter; _encodingW = encoding; _sw = new StreamWriter(_fsw, GXUtil.GxIanaToNetEncoding(encoding, false)); _currentLineW = null; _writeStatus = FileIOStatus.Open; return(GX_ASCDEL_SUCCESS); }
public short dfropen(string fileName, int recSize, string fldDelimiter, string strDelimiter, string encoding) { if (_readStatus != FileIOStatus.Closed) { GXLogging.Error(log, "Error ADF0005: open function in use"); return(GX_ASCDEL_INVALIDSEQUENCE); } fileName = Path.Combine(GxContext.StaticPhysicalPath(), fileName); try { _fsr = new FileStream(Path.GetFullPath(fileName), FileMode.Open, FileAccess.Read, FileShare.ReadWrite, 1024); } catch (FileNotFoundException fe) { GXLogging.Error(log, "Error ADF0001", fe); return(GX_ASCDEL_OPENERROR); } catch (DirectoryNotFoundException de) { GXLogging.Error(log, "Error ADF0001", de); return(GX_ASCDEL_OPENERROR); } _fldDelimiterR = CleanDelimiter(fldDelimiter); _strDelimiterR = strDelimiter; _encodingR = encoding; _sr = new StreamReader(_fsr, GXUtil.GxIanaToNetEncoding(encoding, false)); _lastPos = 0; _readStatus = FileIOStatus.Open; return(GX_ASCDEL_SUCCESS); }
public static int Main(string [] args) { try { string dynTrnInitializerFile = "DynTrnInitializers.xml"; if (args != null && args.Length > 0) { dynTrnInitializerFile = args[0]; } else { if (!File.Exists(dynTrnInitializerFile)) { dynTrnInitializerFile = Path.Combine(GxContext.StaticPhysicalPath(), dynTrnInitializerFile); } } List <DynTrnInitializer> dataproviders = GXXmlSerializer.Deserialize <List <DynTrnInitializer> >(typeof(List <DynTrnInitializer>), File.ReadAllText(dynTrnInitializerFile), "Objects", string.Empty, out List <string> errors); GXDataInitialization dataInitilization = new GXDataInitialization(); int result = dataInitilization.ExecDataInitialization(dataproviders); if (result == 0) { File.Delete(dynTrnInitializerFile); } return(result); } catch (Exception ex) { Console.WriteLine(ex.Message); GXLogging.Error(log, ex); return(1); } }
internal static List <string> GetGxNamespaces(HttpContext context, string mainNamespace) { if (GxNamespaces == null) { GxNamespaces = new List <string>(); try { string binPath = GxContext.StaticPhysicalPath(); if (context != null && !binPath.EndsWith("bin")) { binPath = Path.Combine(binPath, "bin"); } string[] files = Directory.GetFiles(binPath, "*.Common.dll", SearchOption.TopDirectoryOnly); if (files == null || files.Length == 0) { binPath = Path.Combine(binPath, "bin"); files = Directory.GetFiles(binPath, "*.Common.dll", SearchOption.TopDirectoryOnly); } foreach (string file in files) { try { Assembly commonAsmb = Assembly.LoadFile(file); if (IsGxCommonAssembly(commonAsmb)) { Type[] types = commonAsmb.GetTypes(); foreach (Type type in types) { if (type.Name == "GxModelInfoProvider" && type.Namespace != mainNamespace) { GxNamespaces.Add(type.Namespace); break; } if (type.Name == "GxModelInfoProvider" && type.Namespace == mainNamespace) { break; } } } } catch (Exception e) { GXLogging.Error(log, "GxNamespaces Load Exception #2", e); } } } catch (Exception e) { GXLogging.Error(log, "GxNamespaces Load Exception #1", e); } } return(GxNamespaces); }
private static string ServicesFilePath(string file) { string path = GxContext.StaticPhysicalPath(); if (path.EndsWith("\\bin")) { return(Path.Combine(path.Substring(0, path.LastIndexOf("\\bin")), file)); } else { return(Path.Combine(path, file)); } }
private static void Load(string resourcePattern) { string[] files = Directory.GetFiles(GxContext.StaticPhysicalPath(), resourcePattern); foreach (string resourceName in files) { foreach (string line in File.ReadLines(resourceName, Encoding.UTF8)) { string[] map = line.Split(new char[] { '=' }, 2); if (map.Length == 2) { string objectName = map[0]; string url = map[1]; url = url.Replace(@"\=", "=").Replace(@"\\", @"\"); routerList[$"{NormalizedUrlObjectName(objectName)}.aspx"] = url; } } } }
private GXFileWatcher() { webappTmpFiles = new Dictionary <string, List <GxFile> >(); string fwTimeout = string.Empty; long result = 0; string delete; if (Config.GetValueOf("DELETE_ALL_TEMP_FILES", out delete) && (delete.Equals("0") || delete.StartsWith("N", StringComparison.OrdinalIgnoreCase))) { DISABLED = true; } if (Config.GetValueOf("FILEWATCHER_TIMEOUT", out fwTimeout) && Int64.TryParse(fwTimeout, out result)) { TIMEOUT = TimeSpan.FromSeconds(result); GXLogging.Debug(log, "TIMEOUT (from FILEWATCHER_TIMEOUT)", () => TIMEOUT.TotalSeconds + " seconds"); } else { var webconfig = Path.Combine(GxContext.StaticPhysicalPath(), "web.config"); if (File.Exists(webconfig)) { XmlDocument inventory = new XmlDocument(); inventory.Load(webconfig); double secondsTime; XmlNode element = inventory.SelectSingleNode("//configuration/system.web/httpRuntime/@executionTimeout"); if (element != null) { if (!string.IsNullOrEmpty(element.Value) && double.TryParse(element.Value, out secondsTime)) { TIMEOUT = TimeSpan.FromSeconds(secondsTime); GXLogging.Debug(log, "TIMEOUT (from system.web/httpRuntime ExecutionTimeout)", () => TIMEOUT.TotalSeconds + " seconds"); } } } } if (TIMEOUT.TotalSeconds == 0) { TIMEOUT = TimeSpan.FromSeconds(110); } TIMEOUT_TICKS = TIMEOUT.Ticks; }
static void loadQueryTables() { string basePath = Path.Combine(GxContext.StaticPhysicalPath(), "Metadata\\TableAccess"); queryTables = new ConcurrentDictionary <string, List <string> >(); if (Directory.Exists(basePath)) { foreach (string file in Directory.GetFiles(basePath, "*.xml")) { string objname = Path.GetFileNameWithoutExtension(file); List <string> lst = new List <string>(); lst.Add(FORCED_INVALIDATE); bool readingTables = false; using (XmlTextReader tr = new XmlTextReader(Path.Combine(basePath, file))) { while (tr.Read()) { if (tr.Name == "Dependencies" && !readingTables) { readingTables = true; continue; } if (tr.Name == "Dependencies" && readingTables) { readingTables = false; queryTables[NormalizeKey(objname)] = lst; continue; } if (tr.HasAttributes) { string nme = tr.GetAttribute("name"); if (tr.Name == "Table" && readingTables && nme != null && !lst.Contains(nme)) { lst.Add(NormalizeKey(nme)); } } } } } } }
private static ThemeData GetThemeData(string themeName) { if (!m_themes.ContainsKey(themeName)) { string path = Path.Combine(GxContext.StaticPhysicalPath(), "themes", $"{themeName}.json"); ThemeData themeData; try { #pragma warning disable SCS0018 // Path traversal: injection possible in {1} argument passed to '{0}' string json = File.ReadAllText(path); #pragma warning restore SCS0018 // Path traversal: injection possible in {1} argument passed to '{0}' themeData = JSONHelper.Deserialize <ThemeData>(json); } catch (Exception ex) { GXLogging.Warn(log, $"Unable to load theme metadata ({themeName}). Using an empty default one.", ex); themeData = CreateDefaultThemeData(themeName); } m_themes[themeName] = themeData; } return(m_themes[themeName]); }
public bool DownloadPrivate(string storageobjectfullname, GxFile localFile, GXBaseCollection <SdtMessages_Message> messages) { try { ValidProvider(); string destFileName; if (Path.IsPathRooted(localFile.GetAbsoluteName())) { destFileName = localFile.GetAbsoluteName(); } else { destFileName = Path.Combine(GxContext.StaticPhysicalPath(), localFile.Source); } provider.Download(storageobjectfullname, destFileName, GxFileType.Private); return(true); } catch (Exception ex) { StorageMessages(ex, messages); return(false); } }
//Insert image from local file in web transacion, storage enabled, image_gxi = myimage.jpg, image = http://amazon...s3./PrivateTempStorage/myimage.jpg (after a getMultimediaValue(imgTransaction003Image_Internalname, ref A175TransactionImage, ref A40000TransactionImage_GXI); //Update image from dataprovider (KB image object), storage enabled, image_gxi = "file:///C:/Models/Cahttea/Data017/web/Resources/Carmine/myimage.png", image: ".\\Resources/Carmine/myimage.png" //Insert KB image from Dataprovider in dynamic transaction image_gxi vacio, image= .\Resources\myimage.png, //Second execution of Dataprovider that updates images, CategoryImage = calendar.Link(), image_gxi=https://chatteatest.s3.amazonaws.com/TestPGXReleased/Category/CategoryImage/calendar_dc0ca2d9335a484cbdc2d21fc7568af7.png, copy falla, multimediaUri = image_gxi; #pragma warning disable SCS0018 // Path traversal: injection possible in {1} argument passed to '{0}' public void SetParameterMultimedia(int id, string image_gxi, string image, string tableName, string fieldName) { bool storageServiceEnabled = !string.IsNullOrEmpty(tableName) && !string.IsNullOrEmpty(fieldName) && (GXServices.Instance != null && GXServices.Instance.Get(GXServices.STORAGE_SERVICE) != null); if (GxRestUtil.IsUpload(image)) { image = GxRestUtil.UploadPath(image); } if (GxRestUtil.IsUpload(image_gxi)) { image_gxi = GxRestUtil.UploadPath(image_gxi); } if (String.IsNullOrEmpty(image)) { _gxDbCommand.SetParameter(id - 1, image_gxi); } else { string multimediaUri = string.Empty; if (storageServiceEnabled) { //image_gxi not empty => process image_gxi if (!String.IsNullOrEmpty(image_gxi)) { if (PathUtil.IsAbsoluteUrl(image_gxi)) //http://, https://, ftp:// { string objectName; //file is already on the cloud p.e. https://s3.amazonaws.com/Test/PublicTempStorage/multimedia/Image_ad013b5b050c4bf199f544b5561d9b92.png //Must be copied to https://s3.amazonaws.com/Test/TableName/FieldName/Image_ad013b5b050c4bf199f544b5561d9b92.png if (ServiceFactory.GetExternalProvider().GetObjectNameFromURL(image_gxi, out objectName)) { try { multimediaUri = ServiceFactory.GetExternalProvider().Copy(image_gxi, GXDbFile.GenerateUri(image_gxi, !GXDbFile.HasToken(image_gxi), false), tableName, fieldName, GxFileType.PublicAttribute); GXLogging.Debug(log, "Copy file already in ExternalProvider:", multimediaUri); } catch (Exception ex) { multimediaUri = image_gxi; //it is trying to copy an object to itself without changing the object's metadata GXLogging.Warn(log, ex, "Copy file to itself filed in ExternalProvider:", image_gxi); } } else //image_gxi url is in another cloud { try { using (var fileStream = new MemoryStream(new WebClient().DownloadData(image_gxi))) { //Cannot pass Http Stream directly, because some Providers (AWS S3) does not support Http Stream. multimediaUri = ServiceFactory.GetExternalProvider().Save(fileStream, GXDbFile.GenerateUri(image_gxi, !GXDbFile.HasToken(image_gxi), false), tableName, fieldName, GxFileType.Public); GXLogging.Debug(log, "Upload external file to ExternalProvider:", multimediaUri); } } catch (WebException) { multimediaUri = image_gxi; } } } else { Uri uri; string fileFullName = string.Empty; if (Uri.TryCreate(image_gxi, UriKind.Absolute, out uri)) //file:// { fileFullName = uri.AbsolutePath; Stream fileStream = new FileStream(fileFullName, FileMode.Open, FileAccess.Read); String fileName = PathUtil.GetValidFileName(fileFullName, "_"); using (fileStream) { multimediaUri = ServiceFactory.GetExternalProvider().Save(fileStream, GXDbFile.GenerateUri(fileName, !GXDbFile.HasToken(fileName), false), tableName, fieldName, GxFileType.Public); GXLogging.Debug(log, "Upload file (_gxi) to ExternalProvider:", multimediaUri); } } else //relative image name=> Assume it is a local file on the cloud, because storageService is Enabled. { try { multimediaUri = ServiceFactory.GetExternalProvider().Copy(image, GXDbFile.GenerateUri(image_gxi, !GXDbFile.HasToken(image_gxi), false), tableName, fieldName, GxFileType.Public); GXLogging.Debug(log, "Copy external file in ExternalProvider:", multimediaUri); } catch (Exception e) { GXLogging.Warn(log, e, "Could not copy external file in ExternalProvider:", image); //If Image is not in Cloud Storage, then we look if we can find it in the hard drive. This is the case for Relative paths using Image.FromImage() //If file is not available, exception must be thrown multimediaUri = PushToExternalProvider(new FileStream(image, FileMode.Open, FileAccess.Read), GXDbFile.GenerateUri(image_gxi, !GXDbFile.HasToken(image_gxi), false), tableName, fieldName); GXLogging.Debug(log, "Upload file to ExternalProvider:", multimediaUri); } } } } //image_gxi is empty => process image else if (!String.IsNullOrEmpty(image)) { var fileName = PathUtil.GetValidFileName(image, "_"); try { Stream fileStream; if (!PathUtil.IsAbsoluteUrl(image)) //Assume it is a local file { image = Path.Combine(GxContext.StaticPhysicalPath(), image); fileStream = new FileStream(image, FileMode.Open, FileAccess.Read); } else { WebClient c = new WebClient(); fileStream = new MemoryStream(c.DownloadData(image)); //Cannot pass Http Stream directly, because some Providers (AWS S3) does not support Http Stream. } string externalFileName = GXDbFile.GenerateUri(fileName, !GXDbFile.HasToken(fileName), false); multimediaUri = PushToExternalProvider(fileStream, externalFileName, tableName, fieldName); } catch (WebException) //403 forbidden, parm = url in external provider that has been deleted { multimediaUri = image_gxi; } } } //image_gxi not empty => process image_gxi else if (!String.IsNullOrEmpty(image_gxi)) { multimediaUri = GXDbFile.GenerateUri(PathUtil.GetValidFileName(image_gxi, "_"), !GXDbFile.HasToken(image_gxi), true); } //image_gxi is empty => process image else if (!String.IsNullOrEmpty(image)) { multimediaUri = GXDbFile.GenerateUri(PathUtil.GetValidFileName(image, "_"), !GXDbFile.HasToken(image), true); } _gxDbCommand.SetParameter(id - 1, multimediaUri); } }
public short Init(string previousMsgError) { try { GXLogging.Debug(log, "Init"); if (ass == null) { if (nmspace == null) { ass = loadAssembly(Path.Combine(GxContext.StaticPhysicalPath(), "GemBox.Spreadsheet.dll")); if (ass == null) { ass = loadAssembly(Path.Combine(GxContext.StaticPhysicalPath(), @"bin\GemBox.Spreadsheet.dll")); } if (ass != null) { nmspace = "GemBox.Spreadsheet"; } else { if (ass == null) { ass = loadAssembly(Path.Combine(GxContext.StaticPhysicalPath(), @"GemBox.ExcelLite.dll")); } if (ass == null) { ass = loadAssembly(Path.Combine(GxContext.StaticPhysicalPath(), @"bin\GemBox.ExcelLite.dll")); } if (ass != null) { nmspace = "GemBox.ExcelLite"; } } } else { ass = loadAssembly(Path.Combine(GxContext.StaticPhysicalPath(), nmspace + ".dll")); if (ass == null) { ass = loadAssembly(Path.Combine(GxContext.StaticPhysicalPath(), @"bin\" + nmspace + ".dll")); } } GXLogging.Debug(log, "nmspace:" + nmspace); if (ass == null) { errCod = 99; errDescription = previousMsgError + "Error Loading GemBox.ExcelLite.dll, GemBox.Spreadsheet.dll"; return(errCod); } else if (license != null) { try { GxExcelUtils.InvokeStatic(ass, nmspace + ".SpreadsheetInfo", "SetLicense", new object[] { license }); } catch (Exception e) { GXLogging.Error(log, @"Error setting license.", e); } } } return(0); } catch (FileNotFoundException fe) { GXLogging.Error(log, "Error Loading " + fe.FileName, fe); errCod = 99; errDescription = fe.Message; return(errCod); } }
private static string GetTemplateFile(string type) { return(Path.Combine(GxContext.StaticPhysicalPath(), $"gxusercontrols\\{type}.view")); }
public static int Main(string[] args) { #if NETCORE var configFilePath = Path.Combine(FileUtil.GetStartupDirectory(), CLIENT_EXE_CONFIG); if (File.Exists(configFilePath)) { GeneXus.Configuration.Config.ConfigFileName = configFilePath; } #else string parentConfigFile = Path.Combine("..", CLIENT_EXE_CONFIG); if (File.Exists(CLIENT_EXE_CONFIG)) { GeneXus.Configuration.Config.ConfigFileName = CLIENT_EXE_CONFIG; } else if (File.Exists(parentConfigFile)) { GeneXus.Configuration.Config.ConfigFileName = parentConfigFile; } else { string configPath = Path.Combine(GxContext.StaticPhysicalPath(), CLIENT_EXE_CONFIG); if (File.Exists(configPath)) { GeneXus.Configuration.Config.ConfigFileName = configPath; } } bool nogui = false; #endif bool notexecute = false; foreach (string sw in args) { if (sw.ToLower().StartsWith("\\config:") || sw.ToLower().StartsWith("-config:")) { string configFile = sw.Substring(8); GeneXus.Configuration.Config.ConfigFileName = configFile; REORG_FILE_3 = Path.Combine(Path.GetDirectoryName(configFile), REORGPGM_GEN); } #if !NETCORE else if (sw.ToLower().Trim() == "-nogui") { nogui = true; } #endif else if (sw.ToLower().Trim() == "-force") { force = true; } else if (sw.ToLower().Trim() == "-recordcount") { onlyRecordCount = true; } else if (sw.ToLower().Trim() == "-ignoreresume") { ignoreresume = true; } else if (sw.ToLower().Trim() == "-noverifydatabaseschema") { noprecheck = true; } else if (sw.ToLower().Trim() == "-donotexecute") { notexecute = true; } } if (notexecute) { SetStatus(GXResourceManager.GetMessage("GXM_dbnotreorg")); errorCode = 0; } else { try { GxContext.isReorganization = true; gxReorganization = GetReorgProgram(); #if !NETCORE if (nogui) { try { Console.OutputEncoding = Encoding.Default; } catch (IOException) //Docker: System.IO.IOException: The parameter is incorrect. { try { Console.OutputEncoding = Encoding.UTF8; } catch (IOException) { } } #endif GXReorganization._ReorgReader = new NoGuiReorg(); GXReorganization.printOnlyRecordCount = onlyRecordCount; GXReorganization.ignoreResume = ignoreresume; GXReorganization.noPreCheck = noprecheck; if (gxReorganization.GetCreateDataBase()) { GXReorganization.SetCreateDataBase(); } if (ReorgStartup.reorgPending()) { if (gxReorganization.BeginResume()) { gxReorganization.ExecForm(); } if (GXReorganization.Error) { SetStatus(GXResourceManager.GetMessage("GXM_reorgnotsuccess")); if (GXReorganization.ReorgLog != null && GXReorganization.ReorgLog.Count > 0) { SetStatus((string)GXReorganization.ReorgLog[GXReorganization.ReorgLog.Count - 1]); } errorCode = -1; } else { SetStatus(GXResourceManager.GetMessage("GXM_reorgsuccess")); errorCode = 0; } } else { SetStatus(GXResourceManager.GetMessage("GXM_ids_noneeded")); errorCode = 0; } #if !NETCORE } else { FreeConsole(); System.Windows.Forms.Application.Run(new GuiReorg()); } #endif } catch (Exception ex) { #if !NETCORE if (GXUtil.IsBadImageFormatException(ex) && !GXUtil.ExecutingRunX86()) { GXReorganization.CloseResumeFile(); int exitCode; if (GXUtil.RunAsX86(GXUtil.REOR, args, DataReceived, out exitCode)) { return(exitCode); } else { SetStatus(GXResourceManager.GetMessage("GXM_reorgnotsuccess")); SetStatus(GXResourceManager.GetMessage("GXM_callerr", GXUtil.RUN_X86)); errorCode = -1; } } else #endif { SetStatus(GXResourceManager.GetMessage("GXM_reorgnotsuccess")); SetStatus(ex.Message); errorCode = -1; } } } return(errorCode); }
public int Shell(string commandString, int modal) { try { GXLogging.Debug(log, "Shell commandString:'", commandString, "',modal:'", modal.ToString(), "'"); int startArgs; string file, args; commandString = commandString.TrimStart(); file = ""; args = ""; bool in_string = false; startArgs = -1; for (int i = 0; i < commandString.Length; i++) { if (commandString[i] == '"' || commandString[i] == '\'') { if (in_string) { in_string = false; } else { in_string = true; } } if (in_string) { continue; } if (commandString[i] == ' ') { startArgs = i; break; } } if (startArgs == -1) { file = commandString; args = ""; } else { file = commandString.Substring(0, startArgs); args = commandString.Substring(startArgs + 1); } file = file.Replace("\'", "").Replace("\"", ""); //If the file name was delimited with 'it is changed to ". Process p = new Process(); p.StartInfo.Arguments = args; p.StartInfo.CreateNoWindow = true; p.StartInfo.UseShellExecute = true; //When UseShellExecute is true, the WorkingDirectory property specifies the location of the executable. //If WorkingDirectory is an empty string, the current directory is understood to contain the executable. try { p.StartInfo.FileName = "\"" + file + "\""; } catch (Exception e) { GXLogging.Warn(log, "Setting Path Rooted", e); } try { if (Path.IsPathRooted(file)) { p.StartInfo.WorkingDirectory = "\"" + Path.GetDirectoryName(file) + "\""; } else { p.StartInfo.WorkingDirectory = GxContext.StaticPhysicalPath(); } } catch (Exception e) { GXLogging.Warn(log, "Setting Working Directory", e); } GXLogging.Debug(log, "Shell FileName:'" + p.StartInfo.FileName + "',Arguments:'" + p.StartInfo.Arguments + "'"); GXLogging.Debug(log, "Shell Working directory:'" + p.StartInfo.WorkingDirectory + "'"); bool res = p.Start(); GXLogging.Debug(log, "Shell new process resource is started:" + res); if (modal > 0) { p.WaitForExit(); GXLogging.Debug(log, "Shell ExitCode:" + p.ExitCode); return(p.ExitCode); } return(0); } catch (Exception e) { GXLogging.Error(log, "Shell Error", e); throw e; } }
public GxFile() : this(GxContext.StaticPhysicalPath()) { }
public static string getTMP_MEDIA_PATH() { bool defaultPath = true; if (mediaPath == null) { lock (syncRoot) { if (mediaPath == null) { if (Config.GetValueOf("TMPMEDIA_DIR", out mediaPath)) { mediaPath = mediaPath.Trim(); if (!String.IsNullOrEmpty(mediaPath) && !mediaPath.EndsWith("\\") && !mediaPath.EndsWith("/")) { mediaPath += Path.DirectorySeparatorChar; } if (mediaPath.StartsWith("http")) { return(mediaPath); } } else { mediaPath = ""; } if (!String.IsNullOrEmpty(mediaPath)) { defaultPath = false; } if (GXServices.Instance == null || GXServices.Instance.Get(GXServices.STORAGE_SERVICE) == null) { if (defaultPath || !Path.IsPathRooted(mediaPath)) { mediaPath = Path.Combine(GxContext.StaticPhysicalPath(), mediaPath) + Path.DirectorySeparatorChar; } } else { mediaPath = mediaPath.Replace("\\", "/"); } try { GxDirectory directory = new GxDirectory(GxContext.StaticPhysicalPath(), mediaPath); if (!defaultPath) { GXFileWatcher.Instance.AsyncDeleteFiles(directory); } if (!directory.Exists()) { directory.Create(); } } catch (Exception ex) { GXLogging.Error(log, "Error creating TMPMEDIA_DIR " + mediaPath, ex); } GXLogging.Debug(log, "TMP_MEDIA_PATH:", mediaPath); } } } return(mediaPath); }
public static string getBLOB_PATH() { bool defaultPath = true; if (blobPath == null) { lock (syncRoot) { if (blobPath == null) { if (Config.GetValueOf("CS_BLOB_PATH", out blobPath)) { blobPath = blobPath.Trim(); if (!String.IsNullOrEmpty(blobPath) && !blobPath.EndsWith("\\") && !blobPath.EndsWith("/")) { blobPath += Path.DirectorySeparatorChar; } if (blobPath.StartsWith("http")) { return(blobPath); } } else { blobPath = ""; } if (!String.IsNullOrEmpty(blobPath)) { defaultPath = false; } if (String.IsNullOrEmpty(blobPath) || !Path.IsPathRooted(blobPath)) { blobPathFolderName = String.IsNullOrEmpty(blobPath) ? blobPath : blobPath.TrimEnd('/', '\\').TrimStart('/', '\\'); if (GXServices.Instance == null || GXServices.Instance.Get(GXServices.STORAGE_SERVICE) == null) { blobPath = Path.Combine(GxContext.StaticPhysicalPath(), blobPath); if (blobPath[blobPath.Length - 1] != Path.DirectorySeparatorChar) { blobPath += Path.DirectorySeparatorChar; } } else { blobPath = blobPath.Replace("\\", "/"); } } try { GxDirectory directory = new GxDirectory(GxContext.StaticPhysicalPath(), blobPath); if (!defaultPath) { GXFileWatcher.Instance.AsyncDeleteFiles(directory); } if (!directory.Exists()) { directory.Create(); } string multimediaPath = Path.Combine(blobPath, GXDbFile.MultimediaDirectory); GxDirectory multimediaDirectory = new GxDirectory(GxContext.StaticPhysicalPath(), multimediaPath); if (!multimediaDirectory.Exists()) { multimediaDirectory.Create(); } } catch (Exception ex) { GXLogging.Error(log, "Error creating CS_BLOB_PATH " + blobPath, ex); } GXLogging.Debug(log, "BLOB_PATH:", blobPath); } } } return(blobPath); }