Пример #1
0
        public static void CopyAndReplace(string srcPath, string dstPath
            , string srcName, string dstName
            , System.Text.RegularExpressions.Regex ignoreFile
            , System.Text.RegularExpressions.Regex ignoreDirectory)
        {
            // if the directory already exists, delete it
            Delete(dstPath);
            Directory.CreateDirectory(dstPath);

            // copy files
            foreach (var file in Directory.GetFiles(srcPath))
            {
                if (!ignoreFile.IsMatch(file))
                {
                    bool isRename = false;
                    foreach (string s in RenameExtensions)
                    {
                        if (Path.GetFileName(file) == srcName + s)
                        {
                            File.Copy(file, Path.Combine(dstPath, dstName + s));
                            isRename = true;
                            break;
                        }
                    }
                    if (!isRename)
                    {
                        File.Copy(file, Path.Combine(dstPath, Path.GetFileName(file)));
                    }
                }
            }
            // copy directory recursively
            foreach (var dir in Directory.GetDirectories(srcPath))
            {
                if (!ignoreDirectory.IsMatch(dir))
                {
                    if (Path.GetFileName(dir) == srcName)
                    {
                        CopyAndReplace(dir, Path.Combine(dstPath, Path.GetFileName(dstName)),
                            srcName, dstName, ignoreFile, ignoreDirectory);
                    }
                    else
                    {
                        CopyAndReplace(dir, Path.Combine(dstPath, Path.GetFileName(dir)),
                            srcName, dstName, ignoreFile, ignoreDirectory);
                    }
                }
            }
        }
Пример #2
0
		public static bool op_Match(string input, System.Text.RegularExpressions.Regex pattern)
		{
			return pattern.IsMatch(input);
		}
Пример #3
0
    /// <summary>
    /// Based on filter and channel selections, should this log be shown?
    /// </summary>
    bool ShouldShowLog(System.Text.RegularExpressions.Regex regex, LogInfo log)
    {
        if(log.Channel==CurrentChannel || CurrentChannel=="All" || (CurrentChannel=="No Channel" && String.IsNullOrEmpty(log.Channel)))
        {
            if((log.Severity==LogSeverity.Message && ShowMessages)
               || (log.Severity==LogSeverity.Warning && ShowWarnings)
               || (log.Severity==LogSeverity.Error && ShowErrors))
            {
                if(regex==null || regex.IsMatch(log.Message))
                {
                    return true;
                }
            }
        }

        return false;
    }
            /// <summary>
            /// Return multiple text files embed as a resource in a dictionary.
            /// The key in the resource name, the value is the text data
            /// The function takes care of finding the fully qualify name, in the passed
            /// assembly.
            /// </summary>
            /// <param name="regex">The regular expression to filter the resource by name. The file system '\' are replaced with '.'</param>
            /// <returns></returns>
            public static Dictionary<string, string> GetTextResource(System.Text.RegularExpressions.Regex regex , Assembly assembly, bool gzip = false, TextResourceEncoding encoding = TextResourceEncoding.Unicode)
            {
                var dic   = new Dictionary<string, string> ();
                var names = new List<string>();

                foreach (var resource in assembly.GetManifestResourceNames())
                    if (regex.IsMatch(resource))
                        names.Add(resource);

                foreach(var name in names)
                       dic.Add(name, GetTextResource(name, assembly, gzip, encoding));

                return dic;
            }
Пример #5
0
 public static bool Kiemtrchuoi(string s, System.Text.RegularExpressions.Regex r)
 {
     bool b = r.IsMatch(s);
     if (b)
     {
         return true;
     }
     else return false;
 }
Пример #6
0
        private void getBuildsInFolder(IList<Build> builds, string rootFolder, string branchFolder, System.Text.RegularExpressions.Regex buildFolderPattern)
        {
            foreach (string d in System.IO.Directory.GetDirectories(rootFolder))
            {
                System.IO.DirectoryInfo info = new System.IO.DirectoryInfo(d);

                string buildName = info.Name;

                if (buildFolderPattern.IsMatch(buildName))
                {

                    string releaseName = buildName.Substring(0, buildName.LastIndexOf('.'));

                    string number = info.Name.Substring(buildName.LastIndexOf('.') + 1);

                    System.IO.DirectoryInfo remoteInfo = new System.IO.DirectoryInfo(d.Replace(localMapFolder, Path));

                    Branch tempBranch = new Branch
                    {
                        Name = branchFolder,
                        Path = string.Empty,
                        Description = branchFolder,
                        Type = (int)SyncSourceType.FromBuildServer,
                        ProductId = Product.GetProductByName(ProductName).ProductId,
                    };

                    Branch branch = Branch.AddOrUpdateBranch(tempBranch);

                    Release tempRelease = new Release
                    {
                        Name = releaseName,
                        Description = releaseName,
                        Type = (int)SyncSourceType.FromBuildServer,
                        Path = string.Empty,
                        ProductId = Product.GetProductByName(ProductName).ProductId,
                    };

                    Release release = Release.AddOrUpdateRelease(tempRelease);

                    if (IsBuildFinished(info))
                    {
                        Build b = new Build
                        {
                            Name = info.Name,
                            Description = info.Name,
                            Location = remoteInfo.FullName,
                            BranchId = branch.BranchId,
                            ReleaseId = release.ReleaseId,
                            Number = number,
                            BuildType = BuildType.BuildMachine,
                            ProductId = Product.GetProductByName("Common Index Search").ProductId,
                            BuildStatus = BuildStatus.Success,
                        };

                        builds.Add(b);
                    }
                }
                else
                {
                    string tempBranchFolder = string.IsNullOrEmpty(branchFolder) ? info.Name : branchFolder + @"\" + info.Name;

                    getBuildsInFolder(builds, d, tempBranchFolder, buildFolderPattern);
                }
            }
        }
Пример #7
0
        public bool IsMatch(System.Text.RegularExpressions.Regex regex)
        {
            if (regex != null)
            {
                if (regex.IsMatch(Nickname) || regex.IsMatch(TextFromApi) || regex.IsMatch(ScreenName))
                {
                    return true;
                }
            }

            return false;
        }
Пример #8
0
 public virtual ISection FindSection(System.Text.RegularExpressions.Regex r)
 {
     foreach (ISection sect in sections)
     {
         if ((sect != null) && (r.IsMatch(sect.Name)))
             return sect;
     }
     return null;
 }