コード例 #1
0
ファイル: FileCustomInfo.cs プロジェクト: zhitian/3P
        public static void SetFileTags(string filename, string nb, string date, string text, string nomAppli, string version, string chantier, string jira)
        {
            if (string.IsNullOrWhiteSpace(filename))
            {
                return;
            }
            var obj = new FileTagObject {
                CorrectionNumber     = nb,
                CorrectionDate       = date,
                CorrectionDecription = text,
                ApplicationName      = nomAppli,
                ApplicationVersion   = version,
                WorkPackage          = chantier,
                BugId = jira
            };

            // filename exists
            if (Contains(filename))
            {
                if (filename == LastTag || filename == DefaultTag)
                {
                    _filesCustomInfo[filename].Clear();
                }

                // modif number exists
                _filesCustomInfo[filename].RemoveAll(o => o.CorrectionNumber == nb);
                _filesCustomInfo[filename].Add(obj);
            }
            else
            {
                _filesCustomInfo.Add(filename, new List <FileTagObject> {
                    obj
                });
            }
        }
コード例 #2
0
ファイル: ModificationTag.cs プロジェクト: zhitian/3P
        /// <summary>
        /// Call this method to replace the variables inside your tags template (e.g. ${a }) to their actual values
        /// </summary>
        public static string ReplaceTokens(FileTagObject fileTagObject, string tagString)
        {
            var output = tagString;

            foreach (var tuple in new List <Tuple <string, string> > {
                new Tuple <string, string>(@"(\${a\s*})", fileTagObject.ApplicationName),
                new Tuple <string, string>(@"(\${v\s*})", fileTagObject.ApplicationVersion),
                new Tuple <string, string>(@"(\${b\s*})", fileTagObject.BugId),
                new Tuple <string, string>(@"(\${da\s*})", fileTagObject.CorrectionDate),
                new Tuple <string, string>(@"(\${de\s*})", fileTagObject.CorrectionDecription),
                new Tuple <string, string>(@"(\${n\s*})", fileTagObject.CorrectionNumber),
                new Tuple <string, string>(@"(\${w\s*})", fileTagObject.WorkPackage),
                new Tuple <string, string>(@"(\${u\s*})", Config.Instance.UserName)
            })
            {
                var regex = new Regex(tuple.Item1);
                var match = regex.Match(output);
                if (match.Success)
                {
                    var matchedStr = match.Groups[1].Value;
                    if (matchedStr.Contains(' '))
                    {
                        // need to replace the same amount of char
                        output = output.Replace(matchedStr, string.Format("{0,-" + matchedStr.Length + @"}", tuple.Item2 ?? ""));
                    }
                    else
                    {
                        output = output.Replace(matchedStr, tuple.Item2 ?? "");
                    }
                }
            }
            return(output);
        }
コード例 #3
0
ファイル: FileCustomInfo.cs プロジェクト: zhitian/3P
        /// <summary>
        /// Load the dictionary of file info
        /// </summary>
        public static void Import()
        {
            _filesCustomInfo.Clear();

            Utils.ForEachLine(Config.FileFilesInfo, new byte[0], (i, line) => {
                var items = line.Split('\t');
                if (items.Count() == 8)
                {
                    var fileName = items[0].Trim();
                    var fileInfo = new FileTagObject {
                        CorrectionNumber     = items[1],
                        CorrectionDate       = items[2],
                        CorrectionDecription = items[3].Replace("~n", "\n"),
                        ApplicationName      = items[4],
                        ApplicationVersion   = items[5],
                        WorkPackage          = items[6],
                        BugId = items[7]
                    };
                    // add to dictionary
                    if (_filesCustomInfo.ContainsKey(fileName))
                    {
                        _filesCustomInfo[fileName].Add(fileInfo);
                    }
                    else
                    {
                        _filesCustomInfo.Add(fileName, new List <FileTagObject> {
                            fileInfo
                        });
                    }
                }
            },
                              Encoding.Default);

            if (!_filesCustomInfo.ContainsKey(DefaultTag))
            {
                SetFileTags(DefaultTag, "", "", "", "", "", "", "");
            }
            if (!_filesCustomInfo.ContainsKey(LastTag))
            {
                SetFileTags(LastTag, "", "", "", "", "", "", "");
            }
        }