Example #1
0
        public static PackageLicenseDefinition[] GetLicenseDefinitions(Guid productId)
        {
            var result = new List <PackageLicenseDefinition>();

            foreach (var file in C1Directory.GetFiles(_packageLicenseDirectory, "*" + LicenseFileExtension, SearchOption.TopDirectoryOnly))
            {
                var license = TryLoadLicenseFile(file);

                if (license != null && license.ProductId == productId)
                {
                    result.Add(license);
                }
            }

            string obsoloteFilename = GetObsoleteLicenseFilename(productId);

            if (C1File.Exists(obsoloteFilename))
            {
                var license = TryLoadLicenseFile(obsoloteFilename);

                if (license != null)
                {
                    if (license.ProductId == productId)
                    {
                        result.Add(license);
                    }
                    else
                    {
                        Log.LogError(LogTitle, "The license for the product '{0}' does not match the product in the license file '{1}'", productId, license.ProductId);
                    }
                }
            }

            return(result.ToArray());
        }
Example #2
0
        private static void Initialize()
        {
            if (_dataTypeDescriptorCache != null)
            {
                return;
            }

            lock (_lock)
            {
                _dataTypeDescriptorCache           = new Dictionary <Guid, DataTypeDescriptor>();
                _dataTypeDescriptorFilesnamesCache = new Dictionary <Guid, string>();


                string[] filepaths = C1Directory.GetFiles(_metaDataPath, "*.xml");

                foreach (string filepath in filepaths)
                {
                    var dataTypeDescriptor = LoadFromFile(filepath);

                    Verify.That(!_dataTypeDescriptorCache.ContainsKey(dataTypeDescriptor.DataTypeId),
                                "Data type with id '{0}' is already added. File: '{1}'", dataTypeDescriptor.DataTypeId, filepath);

                    _dataTypeDescriptorCache.Add(dataTypeDescriptor.DataTypeId, dataTypeDescriptor);
                    _dataTypeDescriptorFilesnamesCache.Add(dataTypeDescriptor.DataTypeId, filepath);
                }
            }
        }
        private static void MoveRenderingLayoutToFormsFolder(string baseFolder)
        {
            var layoutsFolder = Path.Combine(baseFolder, "FormRenderingLayouts");

            if (!C1Directory.Exists(layoutsFolder))
            {
                return;
            }

            foreach (var file in C1Directory.GetFiles(layoutsFolder, "*.xml"))
            {
                var fileName = Path.GetFileNameWithoutExtension(file);
                if (fileName == null)
                {
                    continue;
                }

                var folder = Path.Combine(baseFolder, fileName);
                if (!C1Directory.Exists(folder))
                {
                    C1Directory.CreateDirectory(folder);
                }

                var newFilePath = Path.Combine(folder, "RenderingLayout.xml");
                File.Move(file, newFilePath);
            }

            C1Directory.Delete(layoutsFolder);
        }
Example #4
0
        private IEnumerable <PackageFragmentValidationResult> LoadPackageFragmentInstallerBinaries()
        {
            string binariesDirectory = Path.Combine(this.PackageInstallationDirectory, PackageSystemSettings.BinariesDirectoryName);

            if (!C1Directory.Exists(binariesDirectory))
            {
                yield break;
            }

            foreach (string filename in C1Directory.GetFiles(binariesDirectory))
            {
                string newFilename = Path.Combine(this.TempDirectory, Path.GetFileName(filename));
                C1File.Copy(filename, newFilename);

                Log.LogVerbose("PackageUninstaller", "Loading package uninstaller fragment assembly '{0}'", newFilename);

                Exception exception = null;
                try
                {
                    PackageAssemblyHandler.AddAssembly(newFilename);
                }
                catch (Exception ex)
                {
                    exception = ex;
                }

                if (exception != null)
                {
                    yield return(new PackageFragmentValidationResult(PackageFragmentValidationResultType.Fatal, exception));
                }
            }
        }
        private void DeleteOldWorkflows()
        {
            using (GlobalInitializerFacade.CoreIsInitializedScope)
            {
                foreach (string filename in C1Directory.GetFiles(SerializedWorkflowsDirectory))
                {
                    DateTime creationTime = C1File.GetLastWriteTime(filename);

                    if (DateTime.Now.Subtract(creationTime) > OldFileExistenceTimeout)
                    {
                        Guid instanceId = new Guid(Path.GetFileNameWithoutExtension(filename));

                        if (Path.GetExtension(filename) == "bin")
                        {
                            try
                            {
                                WorkflowRuntime.GetWorkflow(instanceId);
                                AbortWorkflow(instanceId);
                            }
                            catch (Exception)
                            {
                            }
                        }

                        C1File.Delete(filename);

                        Log.LogVerbose(LogTitle, $"Old workflow instance file deleted {filename}");
                    }
                }
            }
        }
Example #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var xsdFiles = C1Directory.GetFiles(this.MapPath(""), "*.xsd");

        XElement xsdFilesTable = new XElement("table",
                                              new XElement("tr",
                                                           new XElement("td", "Namespace"),
                                                           new XElement("td", "Last generated")));

        foreach (string xsdFile in xsdFiles)
        {
            DateTime lastWrite = C1File.GetLastWriteTime(xsdFile);

            XDocument schemaDocument  = XDocumentUtils.Load(xsdFile);
            string    targetNamespace = schemaDocument.Root.Attribute("targetNamespace").Value;

            xsdFilesTable.Add(
                new XElement("tr",
                             new XElement("td",
                                          new XElement("a",
                                                       new XAttribute("href", Path.GetFileName(xsdFile)),
                                                       targetNamespace)),
                             new XElement("td", lastWrite)));
        }

        XsdTable.Controls.Add(new LiteralControl(xsdFilesTable.ToString()));

        GenerateButton.Click += new EventHandler(GenerateButton_Click);
    }
Example #7
0
        private static void CompressFolder(string absolutePath, ZipArchive zipArchive, int folderOffset)
        {
            var files = C1Directory.GetFiles(absolutePath);

            foreach (string filename in files)
            {
                try
                {
                    using (var streamReader = File.OpenRead(filename))
                    {
                        var fi = new FileInfo(filename);

                        var entryName = filename.Remove(0, folderOffset);
                        var zipEntry  = zipArchive.CreateEntry(entryName, CompressionLevel.Fastest);

                        zipEntry.LastWriteTime = fi.LastWriteTime;

                        using (var stream = zipEntry.Open())
                        {
                            streamReader.CopyTo(stream, 4096);
                        }
                    }
                }
                catch (IOException) { }
            }

            var folders = C1Directory.GetDirectories(absolutePath);

            foreach (var folder in folders)
            {
                CompressFolder(folder, zipArchive, folderOffset);
            }
        }
Example #8
0
        /// <summary>
        /// Gets the Composite.Generated assembly from the  "~/Bin" folder
        /// </summary>
        /// <exclude />
        public static Assembly GetGeneratedAssemblyFromBin()
        {
            foreach (string binFilePath in C1Directory.GetFiles(PathUtil.Resolve(GlobalSettingsFacade.BinDirectory), "*.dll"))
            {
                string assemblyFileName = Path.GetFileName(binFilePath);

                if (assemblyFileName.IndexOf(CodeGenerationManager.CompositeGeneratedFileName, StringComparison.OrdinalIgnoreCase) < 0)
                {
                    continue;
                }

                try
                {
                    return(Assembly.LoadFrom(binFilePath));
                }
                catch (Exception ex)
                {
                    if (!_compositeGeneratedErrorLogged)
                    {
                        Log.LogInformation(LogTitle, "Failed to load ~/Bin/Composite.Generated.dll ");
                        Log.LogWarning(LogTitle, ex);

                        _compositeGeneratedErrorLogged = true;
                    }
                }
            }

            return(null);
        }
Example #9
0
        private IQueryable <T> GetFiles <T>() where T : class, IData
        {
            var result =
                from file in C1Directory.GetFiles(_resolvedRootDirectory, _fileSearchPattern, _fileSearchOptions)
                select BuildNewFileSystemFile <T>(file);

            return(result.AsQueryable());
        }
Example #10
0
        /// <summary>
        /// Used for processing xml/sql data providers configuration build by C1 vesrion older than 3.0
        /// </summary>
        internal static Dictionary <string, Guid> GetTypeManagerTypeNameToTypeIdMap()
        {
            string metaDataFolderPath = PathUtil.Resolve(GlobalSettingsFacade.DataMetaDataDirectory);

            List <string> filepaths = C1Directory.GetFiles(metaDataFolderPath, "*.xml").ToList();

            var result = new Dictionary <string, Guid>();

            foreach (string filepath in filepaths)
            {
                try
                {
                    XDocument doc = XDocumentUtils.Load(filepath);

                    XAttribute dataTypeIdAttr          = doc.Root.Attribute("dataTypeId");
                    XAttribute typeManagerTypeNameAttr = doc.Root.Attribute("typeManagerTypeName");

                    if (dataTypeIdAttr == null || typeManagerTypeNameAttr == null)
                    {
                        continue;
                    }

                    string typeManagerTypeName = typeManagerTypeNameAttr.Value;
                    Guid   dataTypeId          = new Guid(dataTypeIdAttr.Value);

                    const string redundantSuffix = ",Composite.Generated";
                    if (typeManagerTypeName.EndsWith(redundantSuffix, StringComparison.OrdinalIgnoreCase))
                    {
                        typeManagerTypeName = typeManagerTypeName.Substring(0, typeManagerTypeName.Length - redundantSuffix.Length);
                    }

                    if (!result.ContainsKey(typeManagerTypeName))
                    {
                        result.Add(typeManagerTypeName, dataTypeId);
                    }

                    if (!typeManagerTypeName.Contains(",") && !typeManagerTypeName.StartsWith("DynamicType:"))
                    {
                        string fixedTypeManagerTypeName = "DynamicType:" + typeManagerTypeName;

                        if (!result.ContainsKey(fixedTypeManagerTypeName))
                        {
                            result.Add(fixedTypeManagerTypeName, dataTypeId);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.LogWarning(LogTitle, "Error while parsing meta data file '{0}'".FormatWith(filepath));
                    Log.LogWarning(LogTitle, ex);
                }
            }

            // Backward compatibility for configuraiton files. (Breaking change C1 3.2 -> C1 4.0)
            result["Composite.Data.Types.IPageTemplate,Composite"] = new Guid("7b54d7d2-6be6-48a6-9ae1-2e0373073d1d");

            return(result);
        }
 private void LoadPersistedFormData()
 {
     using (_resourceLocker.Locker)
     {
         foreach (string filename in C1Directory.GetFiles(SerializedWorkflowsDirectory, "*.xml"))
         {
             TryLoadPersistedFormData(filename);
         }
     }
 }
        internal static void DeleteEmptyAncestorFolders(string filePath)
        {
            string folder = Path.GetDirectoryName(filePath);

            while (!C1Directory.GetFiles(folder).Any() && !C1Directory.GetDirectories(folder).Any())
            {
                C1Directory.Delete(folder);

                folder = folder.Substring(0, folder.LastIndexOf('\\'));
            }
        }
 public IEnumerable <Guid> GetPersistedWorkflows()
 {
     foreach (string filePath in C1Directory.GetFiles(_baseDirectory, "*.bin"))
     {
         Guid workflowId;
         if (TryParseWorkflowId(filePath, out workflowId))
         {
             yield return(workflowId);
         }
     }
 }
Example #14
0
        private State Initialize()
        {
            var sections = new Dictionary <string, Dictionary <CultureInfo, LocalizationFile> >();

            if (C1Directory.Exists(_directory))
            {
                foreach (string xmlFile in C1Directory.GetFiles(_directory, "*.xml", SearchOption.AllDirectories))
                {
                    // File names have format <section name>.<culture name>.xml

                    string fileName = Path.GetFileName(xmlFile);

                    fileName = fileName.Substring(0, fileName.Length - 4); // removing ".xml";

                    if (!fileName.Contains("."))
                    {
                        continue;
                    }

                    string cultureName = fileName.Substring(fileName.LastIndexOf(".", StringComparison.Ordinal) + 1);

                    CultureInfo cultureInfo;
                    try
                    {
                        cultureInfo = CultureInfo.GetCultureInfo(cultureName);
                    }
                    catch (CultureNotFoundException)
                    {
                        Log.LogInformation(LogTitle, "Skipping file '{0}' as '{1}' is not a valid culture name",
                                           Path.GetFileName(xmlFile), cultureName);
                        continue;
                    }

                    string sectionName = fileName.Substring(0, fileName.Length - cultureName.Length - 1);

                    if (!sections.ContainsKey(sectionName))
                    {
                        sections.Add(sectionName, new Dictionary <CultureInfo, LocalizationFile>());
                    }

                    var localizationFile = new LocalizationFile(xmlFile);
                    sections[sectionName].Add(cultureInfo, localizationFile);
                }
            }

            return(new State {
                Sections = sections
            });
        }
        private static void ClearCacheInt(string folder)
        {
            foreach (var file in C1Directory.GetFiles(folder, "*.*"))
            {
                try
                {
                    C1File.Delete(file);
                }
                catch
                {
                }
            }

            C1Directory.SetCreationTime(folder, DateTime.Now);
        }
        private void FileExist(object sender, ConditionalEventArgs e)
        {
            UploadedFile file = this.GetBinding <UploadedFile>("UploadedFile");

            if (file.HasFile)
            {
                string currentPath = GetCurrentPath();

                e.Result = C1Directory.GetFiles(currentPath, file.FileName).Length > 0;
            }
            else
            {
                e.Result = false;
            }
        }
        public static IEnumerable <IDynamicDefinition> GetDefinitions()
        {
            var files = C1Directory.GetFiles(ModelsFacade.RootPath, "DynamicDefinition.xml", SearchOption.AllDirectories);

            foreach (var file in files)
            {
                var folder = Path.GetDirectoryName(file);
                var name   = new C1DirectoryInfo(folder).Name;
                var xml    = XElement.Load(file);

                var serializer = XmlDefinitionSerializer.GetSerializer(xml);

                yield return(serializer.Load(name, xml));
            }
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        string size = Request.QueryString["size"];

        if (String.IsNullOrEmpty(size))
        {
            size = "24";
        }

        string path = Path.Combine(PathUtil.Resolve(PathUtil.BaseDirectory), "Composite\\images\\icons\\harmony");

        string[] dirEntries = C1Directory.GetDirectories(path);

        StringBuilder builder = new StringBuilder();

        foreach (string dirName in dirEntries)
        {
            int index  = dirName.LastIndexOf("\\");
            int length = dirName.Length - index;

            builder.AppendLine(
                "<ui:pageheading>" +
                dirName.Substring(index + 1, length - 1) +
                "</ui:pageheading>"
                );

            string[] fileEntries = C1Directory.GetFiles(dirName);
            foreach (string fileName in fileEntries)
            {
                if (fileName.Contains("_" + size))
                {
                    string url = fileName.Remove(0, PathUtil.Resolve(PathUtil.BaseDirectory).Length).Replace("\\", "/");

                    url = Composite.Core.WebClient.UrlUtils.ResolvePublicUrl(url);

                    string s = url.Substring(url.LastIndexOf("/") + 1);
                    s = s.Substring(0, (s.LastIndexOf("_")));



                    builder.AppendLine("<div class=\"img\"><img src=\"" + url + "\"/><span>" + s + "</span></div>");
                }
            }
        }

        dynamicOutputPlaceHolder.Controls.Add(new LiteralControl(builder.ToString()));
    }
Example #19
0
        private static void UpdateFilenames()
        {
            List <string> filepaths = C1Directory.GetFiles(_metaDataPath, "*.xml").ToList();

            var ids = new Dictionary <Guid, string>();

            foreach (string filepath in filepaths)
            {
                Guid id = GetGuidFromFilename(filepath);
                if (!ids.ContainsKey(id))
                {
                    ids.Add(id, filepath);
                }
                else // This should never happen, but is here to be robust
                {
                    if (!IsMetaDataFileName(Path.GetFileNameWithoutExtension(filepath))) // Old version of the file, delete it
                    {
                        FileUtils.Delete(filepath);
                    }
                    else // Old version is stored in ids, delete it and change the value to new version
                    {
                        FileUtils.Delete(ids[id]);
                        ids[id] = filepath;
                    }
                }
            }

            foreach (var kvp in ids)
            {
                string filepath = kvp.Value;
                if (!IsMetaDataFileName(Path.GetFileNameWithoutExtension(filepath)))
                {
                    continue;
                }

                var    dataTypeDescriptor = LoadFromFile(filepath);
                string newFilepath        = CreateFilename(dataTypeDescriptor);

                FileUtils.RemoveReadOnly(filepath);

                Func <string, string> normalizeFileName = f => f.Replace('_', ' ').ToLowerInvariant();
                if (normalizeFileName(filepath) != normalizeFileName(newFilepath))
                {
                    C1File.Move(filepath, newFilepath);
                }
            }
        }
        private static void ClearOldTempFiles()
        {
            DateTime yesterday = DateTime.Now.AddDays(-1);
            var      oldFiles  = C1Directory.GetFiles(TempAssemblyFolderPath, "*.*").Where(filePath => C1File.GetCreationTime(filePath) < yesterday).ToArray();

            foreach (var file in oldFiles)
            {
                try
                {
                    C1File.Delete(file);
                }
                catch
                {
                    // Silent
                }
            }
        }
        /// <summary>
        /// Fetches a list of files that contain data - both the stable file and tmp files.
        /// List is ordered with newest files first.
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        private static IList <C1FileInfo> GetCandidateFiles(string filePath)
        {
            List <C1FileInfo> files = new List <C1FileInfo>();

            if (C1File.Exists(filePath))
            {
                files.Add(new C1FileInfo(filePath));
            }

            var tmpFilePaths = C1Directory.GetFiles(Path.GetDirectoryName(filePath), string.Format("{0}.*.tmp", Path.GetFileName(filePath)));

            foreach (string tmpFilePath in tmpFilePaths)
            {
                files.Add(new C1FileInfo(tmpFilePath));
            }

            return(files.OrderByDescending(f => f.LastWriteTime).ToList());
        }
        public T GetData <T>(IDataId dataId) where T : class, IData
        {
            if (dataId == null)
            {
                throw new ArgumentNullException("dataId");
            }
            CheckInterface(typeof(T));
            MediaDataId mediaDataId = dataId as MediaDataId;

            if (mediaDataId == null)
            {
                return(null);
            }

            if (mediaDataId.MediaType == _folderType)
            {
                if (typeof(T) != typeof(IMediaFileFolder))
                {
                    throw new ArgumentException("The dataId specifies a IMediaFileFolder, but the generic method was invoked with different type");
                }

                FileSystemMediaFileFolder folder = (from dirInfo in C1Directory.GetDirectories(_rootDir, "*", SearchOption.AllDirectories)
                                                    where GetRelativePath(dirInfo) == mediaDataId.Path
                                                    select CreateFolder(dirInfo)).FirstOrDefault();
                return(folder as T);
            }
            else if (mediaDataId.MediaType == _fileType)
            {
                if (typeof(T) != typeof(IMediaFile))
                {
                    throw new ArgumentException("The dataId specifies a IMediaFile, but the generic method was invoked with different type");
                }

                FileSystemMediaFile file = (from fileInfo in C1Directory.GetFiles(_rootDir, "*", SearchOption.AllDirectories)
                                            where GetRelativePath(Path.GetDirectoryName(fileInfo)) == mediaDataId.Path && Path.GetFileName(fileInfo) == mediaDataId.FileName
                                            select CreateFile(fileInfo)).FirstOrDefault();

                return(file as T);
            }
            else
            {
                return(Store as T);
            }
        }
        public IEnumerable <Guid> GetPersistedWorkflows()
        {
            foreach (string filePath in C1Directory.GetFiles(_baseDirectory, "*.bin"))
            {
                string guidString = Path.GetFileNameWithoutExtension(filePath);

                Guid guid = Guid.Empty;
                try
                {
                    guid = new Guid(guidString);
                }
                catch { }

                if (guid != Guid.Empty)
                {
                    yield return(guid);
                }
            }
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        string size = Request.QueryString ["size"];

        if (String.IsNullOrEmpty(size))
        {
            size = "24";
        }

        string path = Server.MapPath("../../../../../images/icons/republic");

        string [] dirEntries = C1Directory.GetDirectories(path);

        StringBuilder builder = new StringBuilder();

        foreach (string dirName in dirEntries)
        {
            // do something with fileName
            if (dirName.Contains("republic_"))
            {
                string [] fileEntries = C1Directory.GetFiles(dirName);
                foreach (string fileName in fileEntries)
                {
                    if (fileName.Contains("_" + size + "px_"))
                    {
                        string string1 = fileName.Replace("\\", "/").ToLowerInvariant();
                        string string2 = string1.Substring(
                            string1.IndexOf("images")                                // Website
                            );
                        string string3 = string1.Substring(
                            string1.LastIndexOf("/") + 1
                            );
                        string3 = string3.Substring(0, 4);

                        builder.AppendLine(string.Format(@"<div class=""img""><img src=""{0}/{1}"" /><span>{2}</span></div>", Composite.Core.WebClient.UrlUtils.AdminRootPath, HttpUtility.HtmlAttributeEncode(string2), HttpUtility.HtmlEncode(string3)));
                    }
                }
            }
        }

        dynamicOutputPlaceHolder.Controls.Add(new LiteralControl(builder.ToString()));
    }
Example #25
0
        /// <exclude />
        public static void OnApplicationEnd()
        {
            // Deleting everything that is older than 24 hours
            string tempDirectoryName = TempDirectoryPath;

            if (!C1Directory.Exists(tempDirectoryName))
            {
                return;
            }



            foreach (string filename in C1Directory.GetFiles(tempDirectoryName))
            {
                try
                {
                    if (DateTime.Now > C1File.GetLastWriteTime(filename) + TemporaryFileExpirationTimeSpan)
                    {
                        C1File.Delete(filename);
                    }
                }
                catch
                {
                }
            }

            foreach (string directoryPath in C1Directory.GetDirectories(tempDirectoryName))
            {
                try
                {
                    if (DateTime.Now > C1Directory.GetCreationTime(directoryPath) + TemporaryFileExpirationTimeSpan)
                    {
                        C1Directory.Delete(directoryPath, true);
                    }
                }
                catch
                {
                }
            }
        }
        public IQueryable <T> GetData <T>() where T : class, IData
        {
            CheckInterface(typeof(T));

            if (typeof(T) == typeof(IMediaFile))
            {
                var excludePaths =
                    (from dir in _excludedDirs
                     select PathUtil.Resolve(_rootDir + dir.Replace('/', '\\')) + @"\").ToList();

                var matches =
                    from filePath in C1Directory.GetFiles(_rootDir, "*", SearchOption.AllDirectories)
                    where excludePaths.Where(f => filePath.StartsWith(f)).Count() == 0
                    select CreateFile(filePath);

                return(matches.Cast <T>().AsQueryable());
            }
            else if (typeof(T) == typeof(IMediaFileFolder))
            {
                var excludePaths =
                    (from dir in _excludedDirs
                     select PathUtil.Resolve(_rootDir + dir.Replace('/', '\\')) + @"\").ToList();

                var matches =
                    from dirPath in C1Directory.GetDirectories(_rootDir, "*", SearchOption.AllDirectories)
                    where excludePaths.Where(f => (dirPath + @"\").StartsWith(f)).Count() == 0
                    select CreateFolder(dirPath);

                return(matches.Cast <T>().AsQueryable());
            }
            else
            {
                return(new List <T>()
                {
                    Store as T
                }.AsQueryable <T>());
            }
        }
        public IEnumerable <SiteUpdateInformation> GetUpdateSummaries(Guid installationId)
        {
            var basePath = PathUtil.Resolve(_location);
            var folder   = Path.Combine(basePath, installationId.ToString());

            var list = new List <SiteUpdateInformation>();

            if (!Directory.Exists(folder))
            {
                return(list);
            }

            var files = C1Directory.GetFiles(folder, "*.zip");

            foreach (var f in files)
            {
                try
                {
                    var fi = new C1FileInfo(f);
                    var packageInformation = PackageSystemServices.GetPackageInformationFromZipfile(f);
                    var changelog          = ZipFileHelper.GetContentFromFile(f, "changelog.txt");

                    list.Add(new SiteUpdateInformation
                    {
                        Id             = packageInformation.Id,
                        InstallationId = installationId,
                        FileName       = fi.Name,
                        Name           = packageInformation.Name,
                        Version        = packageInformation.Version,
                        ReleasedDate   = fi.CreationTime,
                        ChangeLog      = changelog
                    });
                }
                catch { }
            }

            return(list);
        }
Example #28
0
 protected void Page_PreRender(object sender, EventArgs e)
 {
     if (IsPostBack && Validators.Count == 0)
     {
         Response.Redirect(Request.Url.ToString());
     }
     try
     {
         BackupList.DataSource = from f in C1Directory.GetFiles(BackupDirectory, "*.zip")
                                 orderby f
                                 select new
         {
             Filename    = Path.GetFileName(f),
             DateCreated = C1File.GetCreationTime(f),
             Filepath    = string.Format("?{0}={1}", BackupFilename, Path.GetFileName(f)),
             Filesize    = ((int)((new C1FileInfo(f).Length) / 1000)).ToString("N0")
         };
         BackupList.DataBind();
     }
     catch
     {
     }
 }
Example #29
0
        internal static bool IsAllowedDataTypeAssembly(Type dataType)
        {
            string assemblyPath = dataType.Assembly.Location;

            if (assemblyPath.StartsWith(CodeGenerationManager.TempAssemblyFolderPath, StringComparison.InvariantCultureIgnoreCase))
            {
                return(true);
            }
            if (assemblyPath.StartsWith(CodeGenerationManager.BinFolder, StringComparison.InvariantCultureIgnoreCase))
            {
                return(true);
            }

            string assemblyFileName   = Path.GetFileName(assemblyPath);
            bool   locatedInBinFolder = C1Directory.GetFiles(CodeGenerationManager.BinFolder).Any(f => Path.GetFileName(f).Equals(assemblyFileName, StringComparison.InvariantCultureIgnoreCase));

            if (locatedInBinFolder)
            {
                return(true);
            }


            return(false);
        }
Example #30
0
    public List <string> GetFilesRecursive(string rootDirectory)
    {
        List <string>  result = new List <string>();
        Stack <string> stack  = new Stack <string>();

        stack.Push(rootDirectory);
        while (stack.Count > 0)
        {
            string dir = stack.Pop();
            try
            {
                result.AddRange(C1Directory.GetFiles(dir, "*.*"));
                foreach (string dn in C1Directory.GetDirectories(dir))
                {
                    stack.Push(dn);
                }
            }
            catch (Exception e)
            {
                this.Validators.Add(new ErrorSummary(e.Message));
            }
        }
        return(result);
    }