Beispiel #1
0
        private void GenerateTabDiffOutput(string dir, string outFolder)
        {
            string dir1 = Path.Combine(leftFolder, dir);

            DirectoryInfo leftDirInfo = new DirectoryInfo(dir1);

            foreach (FileInfo fi in leftDirInfo.GetFiles())
            {
                if (fi.Extension.ToLower() == ".tab" || fi.Extension.ToLower() == ".txt")
                {
                    string rightFileName = fi.FullName.Replace(leftFolder, rightFolder);
                    if (!File.Exists(rightFileName))
                    {
                        continue;
                    }

                    if (FileFolderHelper.FileToString(fi.FullName) == FileFolderHelper.FileToString(rightFileName))
                    {
                        continue;
                    }

                    DiffColInfo info = FindDiffColInfo(fi.Name);

                    string        postfix      = "tab";
                    string        keys         = string.Empty;
                    string        namefield    = string.Empty;
                    string        rowcondition = string.Empty;
                    string        content      = string.Empty;
                    string        outputbasic  = string.Empty;
                    List <string> diffCols1    = new List <string>();
                    List <string> diffCols2    = new List <string>();

                    if (info != null)
                    {
                        keys      = info.keys;
                        namefield = info.displays;
                        if (keys == "$" || namefield == "$") // ignore this file
                        {
                            continue;
                        }
                    }
                    else
                    {
                        if (!AnynalizeTabKeysAndNameField(fi.FullName, ref keys, ref namefield))
                        {
                            continue;
                        }
                    }

                    // try here
                    try
                    {
                        DiffGenerator.DiffGen(fi.FullName, rightFileName, postfix, keys, namefield, rowcondition, ref content, ref outputbasic, ref diffCols1, ref diffCols2);
                    }
                    catch (System.Exception e)
                    {
                        string strThisLog = string.Format("文件{0}的差异结果生成有误:{1}。\r\n", fi.FullName, e.Message);
                        m_diffLog += strThisLog;
                    }

                    string destFilename = fi.FullName.Replace(leftFolder, outFolder);
                    FileFolderHelper.CreatePath(destFilename);
                    FileFolderHelper.StringToFile(content, destFilename);
                }
            }

            foreach (DirectoryInfo di in leftDirInfo.GetDirectories())
            {
                if (di.Name.ToLower().Contains("svn"))
                {
                    continue;
                }

                GenerateTabDiffOutput(di.FullName, outFolder);
            }
        }