Exemplo n.º 1
0
 public void AsyncDeleteFiles(GxDirectory directory)
 {
     GXLogging.Debug(log, "DeleteFiles ", directory.GetName());
     try
     {
         if (!DISABLED && directory.Exists())
         {
             Thread t = new Thread(new ParameterizedThreadStart(DeleteFiles));
             t.Priority     = ThreadPriority.BelowNormal;
             t.IsBackground = true;
             t.Start(directory);
         }
     }
     catch (Exception ex)
     {
         GXLogging.Error(log, "DeleteFiles error", ex);
     }
 }
Exemplo n.º 2
0
 private void DeleteFiles(object odirectory)
 {
     try
     {
         GxDirectory directory = (GxDirectory)odirectory;
         long        now       = DateTime.Now.Ticks;
         foreach (GxFile file in directory.GetFiles("*.*"))
         {
             if (ExpiredFile(file.GetAbsoluteName(), now))
             {
                 file.Delete();
             }
             GXLogging.Debug(log, "DeleteFiles ", file.GetName());
         }
     }
     catch (Exception ex)
     {
         GXLogging.Error(log, "DeleteFiles error", ex);
     }
 }
Exemplo n.º 3
0
 public bool GetDirectory(string directoryFullName, GxDirectory externalDirectory, GXBaseCollection <SdtMessages_Message> messages)
 {
     try
     {
         ValidProvider();
         string path = provider.GetDirectory(directoryFullName);
         if (String.IsNullOrEmpty(path))
         {
             GXUtil.ErrorToMessages("Get Error", "Directory doesn't exists", messages);
             return(false);
         }
         else
         {
             externalDirectory.DirectoryInfo = new GxExternalDirectoryInfo(directoryFullName, path, provider);
             return(true);
         }
     }
     catch (Exception ex)
     {
         StorageMessages(ex, messages);
         return(false);
     }
 }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }