/// <summary>
        /// Action when user upload a solution to analyze
        /// </summary>
        /// <param name="forms"></param>
        /// <returns></returns>
        public ActionResult UploadSolution(FormCollection forms)
        {
            var file = Request.Files["Solution"];
            _userID = forms.GetValues("UserID")[0];
            var result = true;
            var errorText = "";
            var view = "Index";
            EnumViewModel viewModel = EnumViewModel.HOME_UPLOAD;

            if (file.ContentLength != 0)
            {
                // Upload solution to host
                result = UploadFile(file, "/Content/Projects/" + _userID + "/", ref errorText);
            }

            if (result)
            {
                view = "DanhSachSoln";
                viewModel = EnumViewModel.HOME_UPLOAD_SUCCESSFULL;
                // Analyze project
                lstSol = new List<string>();
                var solnName = file.FileName.Split(new char[] { '.' })[0];
                GetFiles(Server.MapPath("/Content/Projects/" + _userID + "/" + solnName), WebConfiguration.ProjectType, ref lstSol);
                _solnPath = this.lstSol[0];
                // Init Solution
                _solStructure = new SolnStructure
                {
                    Name = solnName,
                    Projects = new List<ProjStructure>(),
                    Path = Path.GetDirectoryName(_solnPath)
                };
                // Analyze other projects in solution
                result = Analyzeprojects(ref errorText);
                if (result)
                {
                    Insert_Soln();
                }
            }
            
            var data = new DataTransferViewModel
            {
                IDNguoiDang = Guid.Parse(_userID),
                Added = result,
                ErrorText = errorText,
                EnumViewModelType = viewModel
            };
            return View(view, CreateViewModel(data));
        }
 public SolnStructure BuildSolStructure(int solnID)
 {
     var solnDB = _repSOLUTIONS.RetrieveByID(solnID)[0];
     // Build solution
     var solnStr = new SolnStructure
     {
         Name = solnDB.TenSolution,
         Projects = new List<ProjStructure>(),
         Path = solnDB.Path
     };
     // Build projects belong to solution
     foreach (var _proj in solnDB.PROJECTS)
     {
         var projStr = BuildProject(_proj);
         solnStr.Projects.Add(projStr);
     }
     return solnStr;
 }
        public void BuildDirectoryStructure(SolnStructure solnStr, ref string generatedSolnPath)
        {
            // Create copying solution directory
            generatedSolnPath = solnStr.Path + "_Conditions";
            if (System.IO.Directory.Exists(generatedSolnPath))
                System.IO.Directory.Delete(generatedSolnPath, true);
            System.IO.Directory.CreateDirectory(generatedSolnPath);
            foreach (var _proj in solnStr.Projects)
            {
                foreach (var _class in _proj.Classes)
                {
                    if (NeedCreateClassFile(_class))
                    {
                        var classFileName = _class.ClassPath.Substring(_class.ClassPath.LastIndexOf("\\"));
                        var classPath = _class.ClassPath;
                        classPath = classPath.Replace(solnStr.Path, generatedSolnPath);
                        var classDir = classPath.Substring(0, classPath.LastIndexOf("\\"));
                        System.IO.Directory.CreateDirectory(classDir);
                        if (System.IO.Directory.Exists(classDir))
                        {
                            System.IO.File.Copy(_class.ClassPath, classDir + classFileName, true);
                            if (System.IO.File.Exists(classDir + classFileName))
                            {
                                var insertedInvariant = false;
                                foreach (var _method in _class.Methods)
                                {
                                    var codeGenerated = "";
                                    var callInvariant= "";

                                    if (_class.Invariant != null)
                                    {
                                        if (!insertedInvariant)
                                        {
                                            codeGenerated += GenerateInvariant(_class, ref callInvariant);
                                            insertedInvariant = true;
                                        }
                                    }
                                    if (_method.Require != null || _method.Ensure != null)
                                    {
                                        var callPreCondition = "";
                                        var callPosCondition = "";
                                        var callOriginMethod = "";
                                        var originMethod = GetOriginMethod(classDir + classFileName, _method);
                                        var methodHeader = GetHeaderOfMethod(originMethod);
                                        // Get list params is transfered to method
                                        var lstParams = GetListParamsOfMethod(methodHeader);
                                        _method.LstParams = lstParams;

                                        if (_method.Require != null)
                                        {
                                            codeGenerated += GeneratePreCondition(_method, ref callPreCondition);
                                        }
                                        if (_method.Ensure != null)
                                        {
                                            codeGenerated += GeneratePosCondition(_method, ref callPosCondition);
                                        }

                                        codeGenerated += CreateNewOriginMethod(originMethod, ref callOriginMethod);
                                        codeGenerated += BuildNewMethod(methodHeader, callInvariant, callPreCondition, callPosCondition, callOriginMethod);
                                        ReplaceInFile(classDir + classFileName, originMethod, codeGenerated);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }