Exemplo n.º 1
0
        private void LoadHistory()
        {
            string strfile    = Path.Combine(Application.StartupPath, "history.txt");
            string strHistory = FileFolderHelper.FileToString(strfile);

            if (strHistory.Length == 0)
            {
                return;
            }

            string[] historys = strHistory.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string history in historys)
            {
                DevComponents.DotNetBar.ButtonItem newitemLeft = new DevComponents.DotNetBar.ButtonItem();
                newitemLeft.ImagePaddingHorizontal = 8;
                newitemLeft.Name   = history;
                newitemLeft.Text   = history;
                newitemLeft.Click += new System.EventHandler(this.historyItem_Click_Left);
                this.bOpenFolder1.SubItems.Add(newitemLeft);

                DevComponents.DotNetBar.ButtonItem newitemRight = new DevComponents.DotNetBar.ButtonItem();
                newitemRight.ImagePaddingHorizontal = 8;
                newitemRight.Name   = history;
                newitemRight.Text   = history;
                newitemRight.Click += new System.EventHandler(this.historyItem_Click_Right);
                this.bOpenFolder2.SubItems.Add(newitemRight);
            }
        }
Exemplo n.º 2
0
        private void CopyDiffFiles(string CurPathL, string CurPathR, string clientL, string clientR, string target)
        {
            DirectoryInfo leftDI = new DirectoryInfo(CurPathL);

            foreach (FileInfo fi1 in leftDI.GetFiles())
            {
                if (FileExtensionNeedCompare(fi1.Extension))
                {
                    string   filename2 = fi1.FullName.Replace(clientL, clientR);
                    FileInfo fi2       = new FileInfo(filename2);
                    if (fi2.Exists)
                    {
                        string content1 = FileFolderHelper.FileToString(fi1.FullName);
                        string content2 = FileFolderHelper.FileToString(filename2);
                        if (content1 != content2)
                        {
                            string targetL = fi1.FullName.Replace(clientL, target + "\\左");
                            string targetR = fi2.FullName.Replace(clientR, target + "\\右");

                            string targetDIRL = targetL.Substring(0, targetL.LastIndexOf('\\'));
                            string targetDIRR = targetR.Substring(0, targetR.LastIndexOf('\\'));

                            if (!Directory.Exists(targetDIRL))
                            {
                                Directory.CreateDirectory(targetDIRL);
                            }
                            if (!Directory.Exists(targetDIRR))
                            {
                                Directory.CreateDirectory(targetDIRR);
                            }

                            fi1.CopyTo(targetL);
                            fi2.CopyTo(targetR);

                            copyedFileCount++;
                            string strStatus = string.Format("复制文件数:{0}   当前处理文件:{1}", copyedFileCount, fi1.FullName.Replace(clientL, string.Empty));
                            this.Invoke(new ThreadUIDelegate(DelegateMethod), new object[] { strStatus });
                            //this.labelStatus.Text = strStatus;
                        }
                    }
                }
            }

            foreach (DirectoryInfo di1 in leftDI.GetDirectories())
            {
                if (!DirectoryNeedCompare(di1.FullName))
                {
                    continue;
                }

                DirectoryInfo di2 = new DirectoryInfo(di1.FullName.Replace(clientL, clientR));
                if (di2.Exists)
                {
                    CopyDiffFiles(di1.FullName, di2.FullName, clientL, clientR, target);
                }
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 更新配置信息
 /// </summary>
 /// <param name="cForm">配置窗体对象</param>
 private void UpdateConfigInfo(ConfigForm cForm)
 {
     compareApplicationPath = cForm.FilePath;
     compareTabFile         = cForm.CompareTabFile;
     compareTxtFile         = cForm.CompareTxtFile;
     compareIniFile         = cForm.CompareIniFile;
     compareLuaFile         = cForm.CompareLuaFile;
     compareLSFile          = cForm.CompareLSFile;
     compareLHFile          = cForm.CompareLHFile;
     compareLogicalFile     = cForm.CompareLogicalFile;
     compareOtherFile       = cForm.CompareOtherFile;
     FileFolderHelper.WriteIniFile("General", "compareApplicationPath", compareApplicationPath, Application.StartupPath + "/config.ini");
 }
Exemplo n.º 4
0
        public MainForm()
        {
            InitializeComponent();

            this.Text += " - " + Application.ProductVersion.ToString();

            string        strIniFile = Application.StartupPath + "/config.ini";
            StringBuilder sb         = new StringBuilder(255);

            FileFolderHelper.ReadIniFile("General", "compareApplicationPath", "", sb, 255, strIniFile);
            compareApplicationPath = sb.ToString();
            Init();
            LoadHistory();
        }
Exemplo n.º 5
0
        private void buttonGenAllDiff_Click(object sender, EventArgs e) // 批量生成差异结果
        {
            string outFolder = FileFolderHelper.BrowserFolder("请选择输出路径。");

            if (outFolder.Length == 0)
            {
                MessageBox.Show("你取消了此次命令。");
                return;
            }

            string        strIniFile = Application.StartupPath + "/config_public.ini";
            StringBuilder sb         = new StringBuilder(255);

            FileFolderHelper.ReadIniFile("DiffDirList", "Count", "", sb, 255, strIniFile);
            int pathCount = Convert.ToInt32(sb.ToString());

            string[] paths = new string[pathCount];

            for (int i = 1; i <= pathCount; i++)
            {
                FileFolderHelper.ReadIniFile("DiffDirList", "Dir" + i.ToString(), "", sb, 255, strIniFile);
                paths[i - 1] = sb.ToString();
            }

            m_diffColInfo = new Hashtable();
            FileFolderHelper.ReadIniFile("DiffColumns", "Count", "", sb, 255, strIniFile);
            int diffColDescCount = Convert.ToInt32(sb.ToString());

            for (int i = 1; i <= diffColDescCount; i++)
            {
                FileFolderHelper.ReadIniFile("DiffColumns", "Table" + i.ToString(), "", sb, 255, strIniFile);
                string      tblname = sb.ToString();
                DiffColInfo dci     = new DiffColInfo();
                FileFolderHelper.ReadIniFile("DiffColumns", "Keys" + i.ToString(), "", sb, 255, strIniFile);
                dci.keys = sb.ToString();
                FileFolderHelper.ReadIniFile("DiffColumns", "Display" + i.ToString(), "", sb, 255, strIniFile);
                dci.displays = sb.ToString();
                m_diffColInfo.Add(tblname.ToLower(), dci);
            }

            m_diffLog = string.Empty;
            foreach (string dir in paths)
            {
                GenerateTabDiffOutput(dir, outFolder);
            }
            FileFolderHelper.StringToFile(m_diffLog, Path.Combine(Application.StartupPath, "diff.log"));
        }
Exemplo n.º 6
0
        private void UpdateHistory(string filename)
        {
            string strfile    = Path.Combine(Application.StartupPath, "history.txt");
            string strHistory = FileFolderHelper.FileToString(strfile);

            string[] historys = strHistory.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            if (historys.Length < 4)
            {
                bool bHistoryContainsThisDoc = false;
                foreach (string history in historys)
                {
                    if (history == filename)
                    {
                        bHistoryContainsThisDoc = true;
                        break;
                    }
                }

                if (!bHistoryContainsThisDoc)
                {
                    string strContent = strHistory + (historys.Length == 0 ? string.Empty : "\r\n") + filename;
                    FileFolderHelper.StringToFile(strContent, strfile);
                }
            }
            else
            {
                bool bHistoryContainsThisDoc = false;
                foreach (string history in historys)
                {
                    if (history == filename)
                    {
                        bHistoryContainsThisDoc = true;
                        break;
                    }
                }

                if (!bHistoryContainsThisDoc)
                {
                    string[] newhistorys = new string[] { historys[1], historys[2], historys[3], filename };
                    string   content     = newhistorys[0] + "\r\n" + newhistorys[1] + "\r\n" + newhistorys[2] + "\r\n" + newhistorys[3];
                    FileFolderHelper.StringToFile(content, strfile);
                }
            }
        }
Exemplo n.º 7
0
        private bool AnynalizeTabKeysAndNameField(string filename, ref string keys, ref string names)
        {
            string content = FileFolderHelper.FileToString(filename);

            string[] lines    = content.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            string[] colnames = lines[0].Split(new char[] { '\t' });
            keys = colnames[0];
            int keyindex = 0;

            //for (int i = colnames.Length - 1; i >= 0; i--)
            //{
            //    string col = colnames[i].ToLower();
            //    if (col.Contains("id"))
            //    {
            //        keys = colnames[i];
            //        keyindex = i;
            //    }
            //}

            string[] firstRowCols = lines[1].Split(new char[] { '\t' });
            int      dummi        = 0;

            return(Int32.TryParse(firstRowCols[keyindex], out dummi));
        }
Exemplo n.º 8
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);
            }
        }