Example #1
0
        /// <summary>
        /// 从字符串转换为对象
        /// </summary>
        /// <param name="str">字符串</param>
        public void FromString(String str)
        {
            String[] strs = str.Split(new String[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            m_files    = CStr.ConvertStrToInt(strs[0]);
            m_lines    = CStr.ConvertStrToInt(strs[1]);
            m_scores   = CStr.ConvertStrToInt(strs[2]);
            m_avgLevel = CStr.ConvertStrToInt(strs[3]);
            int strsSize = strs.Length;

            for (int i = 4; i < strsSize; i++)
            {
                FileJidian fileJidian = new FileJidian();
                fileJidian.FromString(strs[i]);
                m_fileJidians.Add(fileJidian);
            }
        }
Example #2
0
        /// <summary>
        /// 分析基点
        /// </summary>
        /// <param name="dir">目录</param>
        private void Analysis(String dir, ref ProjectJidian projectJidian)
        {
            List <String> dirs = new List <String>();

            CFileA.GetDirectories(dir, dirs);
            int dirsSize = dirs.Count;

            for (int i = 0; i < dirsSize; i++)
            {
                Analysis(dirs[i], ref projectJidian);
            }
            List <String> files = new List <String>();

            CFileA.GetFiles(dir, files);
            int filesSize = files.Count;

            for (int i = 0; i < filesSize; i++)
            {
                String file    = files[i];
                String content = "";
                CFileA.Read(file, ref content);
                String[] strs     = content.Split(new String[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
                int      strsSize = strs.Length;
                if (strsSize > 0)
                {
                    String fline = strs[0];
                    if (fline.StartsWith("//GAIA"))
                    {
                        FileJidian fileJidian = new FileJidian();
                        fileJidian.Lines     = strsSize;
                        projectJidian.Lines += strsSize;
                        fileJidian.Path      = file.Replace(m_dir + "\\", "");
                        String[] subStrs  = fline.Split(new String[] { ":" }, StringSplitOptions.RemoveEmptyEntries);
                        String[] subStrs2 = subStrs[0].Split(new String[] { "_" }, StringSplitOptions.RemoveEmptyEntries);
                        fileJidian.PID         = subStrs2[1];
                        fileJidian.CodeType    = subStrs2[2];
                        fileJidian.Level       = Convert.ToInt32(subStrs2[3].Replace("S", ""));
                        fileJidian.Scores      = fileJidian.Lines * fileJidian.Level;
                        projectJidian.Scores  += fileJidian.Scores;
                        projectJidian.AvgLevel = (double)(projectJidian.Files * projectJidian.AvgLevel + fileJidian.Level) / (projectJidian.Files + 1);
                        projectJidian.Files++;
                        String[] sunStrs = subStrs[1].Split(new String[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                        for (int j = 0; j < sunStrs.Length; j++)
                        {
                            String[] csunStrs = sunStrs[j].Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                            if (csunStrs.Length >= 2)
                            {
                                MemberJidian memberJidian = new MemberJidian();
                                memberJidian.Name  = csunStrs[0];
                                memberJidian.Rates = (double)Convert.ToInt32(csunStrs[1].Replace("%", "")) / 100;
                                memberJidian.Lines = (int)(strsSize * memberJidian.Rates);
                                fileJidian.MemberJidians.Add(memberJidian);
                            }
                        }
                        projectJidian.FileJidians.Add(fileJidian);
                    }
                }
            }
            dirs.Clear();
            files.Clear();
        }