Exemplo n.º 1
0
        internal void AddInitPs1LoadData(bool isPMC, SolutionData vsSolutionData)
        {
            lock (_lock)
            {
                if (isPMC && (!vsSolutionData.FirstTimeLoadedFromPmc && !vsSolutionData.FirstTimeLoadedFromPmui))
                {
                    vsSolutionData.InitPs1LoadedFromPmcFirst = true;
                }

                if (isPMC)
                {
                    vsSolutionData.InitPs1LoadPmc = true;

                    if (!vsSolutionData.LoadedFromPmc)
                    {
                        vsSolutionData.FirstTimeLoadedFromPmc = true;
                        _vsInstanceData.PmcLoadedSolutionCount++;
                    }

                    vsSolutionData.LoadedFromPmc = true;
                }
                else
                {
                    vsSolutionData.InitPs1LoadPmui = true;

                    if (!vsSolutionData.LoadedFromPmui)
                    {
                        vsSolutionData.FirstTimeLoadedFromPmui = true;
                        _vsInstanceData.PmuiLoadedSolutionCount++;
                    }

                    vsSolutionData.LoadedFromPmui = true;
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取解决方案数据信息
        /// </summary>
        /// <returns></returns>
        public SolutionData GetAll()
        {
            SolutionData result   = null;
            var          type     = typeof(SolutionData);
            var          cacheKey = CacheKeyPrefix + type.FullName;

            if (CacheHelper.GetCache(cacheKey) == null)
            {
                string content  = string.Empty;
                string filePath = HttpContext.Current.Server.MapPath("~/App_Data/Data.xml");
                if (File.Exists(filePath))
                {
                    content = File.ReadAllText(filePath);
                }
                if (!string.IsNullOrEmpty(content))
                {
                    result = XmlHelper.DeserializeXML <SolutionData>(content);
                    CacheHelper.SetCache(cacheKey, result);
                }
            }
            else
            {
                result = (SolutionData)CacheHelper.GetCache(cacheKey);
            }
            return(result);
        }
Exemplo n.º 3
0
    public void Status()
    {
        GameObject   go = UnityEngine.EventSystems.EventSystem.current.currentSelectedGameObject;
        SolutionData sd = go.GetComponent <SolutionData>();

        if (sd != null)
        {
            //Debug.Log(sd.ishit);

            sd.ishit = sd.ishit == false ? true : false;
            if (sd.ishit)
            {
                if (temp != null)
                {
                    temp.color = Color.white;
                    temp.GetComponentInChildren <SolutionData>().ishit = false;
                }
                so.tec  = go.transform.GetComponent <Image>().mainTexture;
                so.name = go.transform.parent.parent.Find("ProductNameText").GetComponent <Text>().text;
                go.transform.parent.GetComponent <Image>().color = Color.blue;
            }
            else
            {
                go.transform.parent.GetComponent <Image>().color = Color.white;
            }
        }
        else
        {
            Debug.Log("没有SolutionData脚本");
        }
        temp = go.transform.parent.GetComponent <Image>();
    }
Exemplo n.º 4
0
        internal Server(string modelfile, string solutionfile)
        {
            mfile = modelfile;
            sfile = solutionfile;
            try {
                FileStream mstream = new FileStream(mfile, FileMode.Open);
                FileStream sstream = new FileStream(sfile, FileMode.Create);

                Cplex     cplex = new Cplex();
                ModelData data  = null;

                BinaryFormatter formatter = new BinaryFormatter();
                data = (ModelData)formatter.Deserialize(mstream);
                mstream.Close();


                cplex.SetModel(data.model);

                SolutionData sol = new SolutionData();
                if (cplex.Solve())
                {
                    sol.obj  = cplex.ObjValue;
                    sol.vals = cplex.GetValues(data.vars);
                }
                sol.status = cplex.GetCplexStatus();

                formatter.Serialize(sstream, sol);
                sstream.Close();

                cplex.End();
            }
            catch (System.Exception t) {
                System.Console.WriteLine("server terminates due to " + t);
            }
        }
Exemplo n.º 5
0
 internal void AddNuGetCmdletExecutedData(SolutionData vsSolutionData)
 {
     lock (_lock)
     {
         vsSolutionData.NuGetCommandUsed = true;
     }
 }
Exemplo n.º 6
0
        internal void AddPowerShellLoadedData(bool isPMC, SolutionData vsSolutionData)
        {
            lock (_lock)
            {
                if (isPMC)
                {
                    if (!vsSolutionData.LoadedFromPmc)
                    {
                        vsSolutionData.FirstTimeLoadedFromPmc = true;
                        _vsInstanceData.PmcLoadedSolutionCount++;
                    }

                    vsSolutionData.LoadedFromPmc = true;
                }
                else
                {
                    if (!vsSolutionData.LoadedFromPmui)
                    {
                        vsSolutionData.FirstTimeLoadedFromPmui = true;
                        _vsInstanceData.PmuiLoadedSolutionCount++;
                    }

                    vsSolutionData.LoadedFromPmui = true;
                }
            }
        }
Exemplo n.º 7
0
    private void Start()
    {
        data = GetComponent <SolutionData>();

        StartCoroutine(LifeTime());
        meshRenderer = GetComponentInChildren <MeshRenderer>();
        meshRenderer.material.color = targetTask.GetComponent <Task>().GetColor();
    }
Exemplo n.º 8
0
        public TaskResultResponse(dynamic json)
        {
            ErrorId = JsonHelper.ExtractInt(json, "errorId");

            if (ErrorId != null)
            {
                if (ErrorId.Equals(0))
                {
                    Status = ParseStatus(JsonHelper.ExtractStr(json, "status"));

                    if (Status.Equals(StatusType.Ready))
                    {
                        Cost       = JsonHelper.ExtractDouble(json, "cost");
                        Ip         = JsonHelper.ExtractStr(json, "ip", null, true);
                        SolveCount = JsonHelper.ExtractInt(json, "solveCount", null, true);
                        CreateTime = UnixTimeStampToDateTime(JsonHelper.ExtractDouble(json, "createTime"));
                        EndTime    = UnixTimeStampToDateTime(JsonHelper.ExtractDouble(json, "endTime"));

                        Solution = new SolutionData
                        {
                            Token = JsonHelper.ExtractStr(json, "solution", "token", true),
                            GRecaptchaResponse =
                                JsonHelper.ExtractStr(json, "solution", "gRecaptchaResponse", silent: true),
                            GRecaptchaResponseMd5 =
                                JsonHelper.ExtractStr(json, "solution", "gRecaptchaResponseMd5", silent: true),
                            Text = JsonHelper.ExtractStr(json, "solution", "text", silent: true),
                            Url  = JsonHelper.ExtractStr(json, "solution", "url", silent: true)
                        };

                        try
                        {
                            Solution.Answers = json.solution.answers;
                        }
                        catch
                        {
                            Solution.Answers = null;
                        }

                        if (Solution.GRecaptchaResponse == null && Solution.Text == null && Solution.Answers == null &&
                            Solution.Token == null)
                        {
                            DebugHelper.Out("Got no 'solution' field from API", DebugHelper.Type.Error);
                        }
                    }
                }
                else
                {
                    ErrorCode        = JsonHelper.ExtractStr(json, "errorCode");
                    ErrorDescription = JsonHelper.ExtractStr(json, "errorDescription") ?? "(no error description)";

                    DebugHelper.Out(ErrorDescription, DebugHelper.Type.Error);
                }
            }
            else
            {
                DebugHelper.Out("Unknown error", DebugHelper.Type.Error);
            }
        }
Exemplo n.º 9
0
        public void ShouldGetAllReferencedProjects(int skip, int take, int resultStart)
        {
            var sln = testData.GetLinearSolution(5).CurrentSolution;

            var allProjects = SolutionData.GetAllProjectsByFile(sln.Projects.Reverse().Skip(skip).Take(take).ToArray(), sln, true);

            allProjects.Select(p => p.Value.Name)
            .ShouldBeEquivalentTo(sln.Projects.Reverse().Skip(resultStart).Select(p => p.Name));
        }
Exemplo n.º 10
0
    private bool IsWin(SolutionData pSolution)
    {
        if (pSolution.pointDatas.Count >= m_CurPointCount)
        {
            return(true);
        }

        return(false);
    }
Exemplo n.º 11
0
        // If open new solution then need to clear previous solution events. But powershell remain loaded in memory.
        private void ClearSolutionData()
        {
            bool pmcPowershellLoad  = _vsSolutionData.LoadedFromPmc;
            bool pmuiPowershellLoad = _vsSolutionData.LoadedFromPmui;

            _vsSolutionData = new SolutionData();

            _vsSolutionData.LoadedFromPmc  = pmcPowershellLoad;
            _vsSolutionData.LoadedFromPmui = pmuiPowershellLoad;
        }
Exemplo n.º 12
0
        public void ShouldGetAllProjects()
        {
            var sln = testData.GetLinearSolution(5).CurrentSolution;

            var allProjects = SolutionData.GetAllProjectsByFile(new Project[0], sln, false);

            allProjects.Select(p => p.Value.Name)
            .ShouldBeEquivalentTo(sln.Projects.Reverse().Select(p => p.Name));
            allProjects.Select(p => p.Key.Info.FullName).ShouldAllBeEquivalentTo(sln.Projects.Select(p => p.FilePath));
        }
            internal Task <(MonoDevelop.Projects.Solution, SolutionInfo)> CreateSolutionInfo(MonoDevelop.Projects.Solution sol, CancellationToken ct)
            {
                return(Task.Run(delegate {
                    return CreateSolutionInfoInternal(sol, ct);
                }));

                async Task <(MonoDevelop.Projects.Solution, SolutionInfo)> CreateSolutionInfoInternal(MonoDevelop.Projects.Solution solution, CancellationToken token)
                {
                    using (var timer = Counters.AnalysisTimer.BeginTiming()) {
                        projections.ClearOldProjectionList();

                        solutionData = new SolutionData();

                        var projectInfos = await CreateProjectInfos(solution.GetAllProjects(), token).ConfigureAwait(false);

                        if (IsModifiedWhileLoading(solution))
                        {
                            return(await CreateSolutionInfoInternal(solution, token).ConfigureAwait(false));
                        }

                        if (token.IsCancellationRequested)
                        {
                            return(solution, null);
                        }

                        var solutionId   = GetSolutionId(solution);
                        var solutionInfo = SolutionInfo.Create(solutionId, VersionStamp.Create(), solution.FileName, projectInfos);

                        lock (addLock) {
                            if (!added)
                            {
                                added = true;
                                workspace.OnSolutionAdded(solutionInfo);
                                var service = (MonoDevelopPersistentStorageLocationService)workspace.Services.GetService <IPersistentStorageLocationService> ();
                                service.SetupSolution(workspace);
                                lock (workspace.generatedFiles) {
                                    foreach (var generatedFile in workspace.generatedFiles)
                                    {
                                        if (!workspace.IsDocumentOpen(generatedFile.Key.Id))
                                        {
                                            workspace.OnDocumentOpened(generatedFile.Key.Id, generatedFile.Value);
                                        }
                                    }
                                }
                            }
                        }
                        // Check for modified projects here after the solution has been added to the workspace
                        // in case a NuGet package restore finished after the IsModifiedWhileLoading check. This
                        // ensures the type system does not have missing references that may have been added by
                        // the restore.
                        ReloadModifiedProjects();
                        return(solution, solutionInfo);
                    }
                }
            }
Exemplo n.º 14
0
        private void SetData()
        {
            var x2 = _mathProvider.Subtract(InputData.X2, InputData.X1);
            var x3 = _mathProvider.Subtract(InputData.X3, InputData.X1);
            var y2 = _mathProvider.Subtract(InputData.Y2, InputData.Y1);
            var y3 = _mathProvider.Subtract(InputData.Y3, InputData.Y1);
            var k2 = _mathProvider.Add(_mathProvider.Multiply(x2, x2), _mathProvider.Multiply(y2, y2));
            var k3 = _mathProvider.Add(_mathProvider.Multiply(x3, x3), _mathProvider.Multiply(y3, y3));

            SolutionData = new SolutionData <double>(x2, x3, y2, y3, k2, k3);
        }
Exemplo n.º 15
0
 public SolutionData Analyze(string solutionFileName)
 {
     if (!File.Exists(solutionFileName))
     {
         throw new Exception("File " + solutionFileName + " is not found.");
     }
     _solutionData = new SolutionData();
     _solutionData.SolutionFileName   = Path.GetFileName(solutionFileName);
     _solutionData.SolutionName       = Path.GetFileNameWithoutExtension(solutionFileName);
     _solutionData.SolutionFolderName = Path.GetDirectoryName(solutionFileName);
     _solutionData.Projects           = GetProjectListFromSolutionFile(solutionFileName);
     return(_solutionData);
 }
Exemplo n.º 16
0
        public void OpenPackage()
        {
            var deSerializer = new XmlSerializer(new QuickPublish().GetType());

            using (var reader = new StreamReader(PathPackage))
            {
                var quickPublish = (QuickPublish)deSerializer.Deserialize(reader);
                Solution = new SolutionData
                {
                    SolutionId = quickPublish.SolutionGuid
                };
                WebResourcesObjects = quickPublish.WebResourceObjects;
            }
        }
Exemplo n.º 17
0
        public void ShouldReturnProjectsFromOptionsIfInSln()
        {
            var sln       = testData.GetLinearSolution(5).CurrentSolution;
            var projFiles = sln.Projects.Select(p => new FileInfo(p.FilePath)).ToArray();

            var(files, projects) = SolutionData.GetProjectsFromOptions(new CmdOptions
            {
                PublishedProject = projFiles.First(), ProjectsToTest = projFiles.Skip(1).Append(new FileInfo("notinsolution.csproj"))
            }, sln);


            projects.Select(p => p.Name).Should().BeEquivalentTo(sln.Projects.Select(f => f.Name));
            files.Select(f => f.Info.Name).Should().BeEquivalentTo(projFiles.Skip(1).Select(f => f.Name));
        }
Exemplo n.º 18
0
        public static void Main(string[] args)
        {
            try
            {
                // setup files to transfer model to server
                string mfile = "Model.dat";
                string sfile = "Solution.dat";


                // build model
                INumVar[][] var = new INumVar[1][];
                IRange[][]  rng = new IRange[1][];

                CplexModeler model = new CplexModeler();
                PopulateByRow(model, var, rng);

                FileStream      mstream   = new FileStream(mfile, FileMode.Create);
                BinaryFormatter formatter = new BinaryFormatter();
                formatter.Serialize(mstream, new ModelData(model, var[0]));
                mstream.Close();

                // start server
                Server server = new Server(mfile, sfile);

                SolutionData sol     = null;
                FileStream   sstream = new FileStream(sfile, FileMode.Open);
                sol = (SolutionData)formatter.Deserialize(sstream);
                sstream.Close();

                System.Console.WriteLine("Solution status = " + sol.status);

                if (sol.status.Equals(Cplex.CplexStatus.Optimal))
                {
                    System.Console.WriteLine("Solution value = " + sol.obj);
                    int ncols = var[0].Length;
                    for (int j = 0; j < ncols; ++j)
                    {
                        System.Console.WriteLine("Variable " + j + ": Value = " + sol.vals[j]);
                    }
                }
            }
            catch (ILOG.Concert.Exception e)
            {
                System.Console.WriteLine("Concert exception '" + e + "' caught");
            }
            catch (System.Exception t)
            {
                System.Console.WriteLine("terminating due to exception " + t);
            }
        }
Exemplo n.º 19
0
        public NuGetPowerShellUsageCollector()
        {
            _vsSolutionData = new SolutionData();
            _vsInstanceData = new InstanceData();

            NuGetPowerShellUsage.PowerShellLoadEvent           += NuGetPowerShellUsage_PMCLoadEventHandler;
            NuGetPowerShellUsage.PowerShellCommandExecuteEvent += NuGetPowerShellUsage_PowerShellCommandExecuteEventHandler;
            NuGetPowerShellUsage.NuGetCmdletExecutedEvent      += NuGetPowerShellUsage_NuGetCmdletExecutedEventHandler;
            NuGetPowerShellUsage.InitPs1LoadEvent     += NuGetPowerShellUsage_InitPs1LoadEventHandler;
            NuGetPowerShellUsage.PmcWindowsEvent      += NuGetPowerShellUsage_PMCWindowsEventHandler;
            NuGetPowerShellUsage.SolutionOpenEvent    += NuGetPowerShellUsage_SolutionOpenHandler;
            NuGetPowerShellUsage.SolutionCloseEvent   += NuGetPowerShellUsage_SolutionCloseHandler;
            NuGetPowerShellUsage.VSInstanceCloseEvent += NuGetPowerShellUsage_VSInstanseCloseHandler;
        }
Exemplo n.º 20
0
        static DocumentInfo CreateDocumentInfo(SolutionData data, string projectName, ProjectData id, MonoDevelop.Projects.ProjectFile f)
        {
            var filePath       = f.FilePath;
            var sourceCodeKind = filePath.Extension == ".sketchcs" ? SourceCodeKind.Script : SourceCodeKind.Regular;

            return(DocumentInfo.Create(
                       id.GetOrCreateDocumentId(filePath),
                       f.FilePath,
                       new [] { projectName }.Concat(f.ProjectVirtualPath.ParentDirectory.ToString().Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar)),
                       sourceCodeKind,
                       CreateTextLoader(data, f.Name),
                       f.Name,
                       false
                       ));
        }
Exemplo n.º 21
0
            static DocumentInfo CreateDocumentInfo(SolutionData data, string projectName, ProjectData id, MonoDevelop.Projects.ProjectFile f)
            {
                var filePath = f.FilePath.ResolveLinks();
                var folders  = GetFolders(projectName, f);

                return(DocumentInfo.Create(
                           id.DocumentData.GetOrCreate(filePath),
                           Path.GetFileName(filePath),
                           folders,
                           f.SourceCodeKind,
                           CreateTextLoader(filePath),
                           filePath,
                           isGenerated: false
                           ));

                TextLoader CreateTextLoader(string fileName) => data.Files.GetOrAdd(fileName, a => new MonoDevelopTextLoader(a));
            }
Exemplo n.º 22
0
            internal Task <SolutionInfo> CreateSolutionInfo(MonoDevelop.Projects.Solution sol, CancellationToken ct)
            {
                return(Task.Run(delegate {
                    return CreateSolutionInfoInternal(sol, ct);
                }));

                async Task <SolutionInfo> CreateSolutionInfoInternal(MonoDevelop.Projects.Solution solution, CancellationToken token)
                {
                    using (var timer = Counters.AnalysisTimer.BeginTiming()) {
                        projections.ClearOldProjectionList();

                        solutionData = new SolutionData();

                        var projectInfos = await CreateProjectInfos(solution.GetAllProjects(), token).ConfigureAwait(false);

                        if (IsModifiedWhileLoading(solution))
                        {
                            return(await CreateSolutionInfoInternal(solution, token).ConfigureAwait(false));
                        }

                        var solutionId   = GetSolutionId(solution);
                        var solutionInfo = SolutionInfo.Create(solutionId, VersionStamp.Create(), solution.FileName, projectInfos);

                        lock (addLock) {
                            if (!added)
                            {
                                added              = true;
                                solution.Modified += OnSolutionModified;
                                NotifySolutionModified(solution, solutionId, workspace);
                                workspace.OnSolutionAdded(solutionInfo);
                                lock (workspace.generatedFiles) {
                                    foreach (var generatedFile in workspace.generatedFiles)
                                    {
                                        if (!workspace.IsDocumentOpen(generatedFile.Key.Id))
                                        {
                                            workspace.OnDocumentOpened(generatedFile.Key.Id, generatedFile.Value);
                                        }
                                    }
                                }
                            }
                        }
                        return(solutionInfo);
                    }
                }
            }
Exemplo n.º 23
0
        async Task <SolutionInfo> CreateSolutionInfo(MonoDevelop.Projects.Solution solution, CancellationToken token)
        {
            var projects   = new ConcurrentBag <ProjectInfo> ();
            var mdProjects = solution.GetAllProjects();

            projectionList.Clear();
            solutionData = new SolutionData();

            List <Task> allTasks = new List <Task> ();

            foreach (var proj in mdProjects)
            {
                if (token.IsCancellationRequested)
                {
                    return(null);
                }
                if (!SupportsRoslyn(proj))
                {
                    continue;
                }
                var tp = LoadProject(proj, token).ContinueWith(t => {
                    if (!t.IsCanceled)
                    {
                        projects.Add(t.Result);
                    }
                });
                allTasks.Add(tp);
            }
            await Task.WhenAll(allTasks.ToArray());

            if (token.IsCancellationRequested)
            {
                return(null);
            }
            var solutionInfo = SolutionInfo.Create(GetSolutionId(solution), VersionStamp.Create(), solution.FileName, projects);

            lock (addLock) {
                if (!added)
                {
                    added = true;
                    OnSolutionAdded(solutionInfo);
                }
            }
            return(solutionInfo);
        }
Exemplo n.º 24
0
        public TaskResultResponse(dynamic json)
        {
            ErrorId = JsonHelper.ExtractInt(json, "errorId");

            if (ErrorId != null)
            {
                if (ErrorId.Equals(0))
                {
                    Status = ParseStatus(JsonHelper.ExtractStr(json, "status"));

                    if (Status.Equals(StatusType.Ready))
                    {
                        Cost       = JsonHelper.ExtractDouble(json, "cost");
                        Ip         = JsonHelper.ExtractStr(json, "ip");
                        SolveCount = JsonHelper.ExtractInt(json, "solveCount");
                        CreateTime = UnixTimeStampToDateTime(JsonHelper.ExtractDouble(json, "createTime"));
                        EndTime    = UnixTimeStampToDateTime(JsonHelper.ExtractDouble(json, "endTime"));

                        Solution = new SolutionData
                        {
                            GRecaptchaResponse =
                                JsonHelper.ExtractStr(json, "solution", "gRecaptchaResponse"),
                            GRecaptchaResponseMd5 =
                                JsonHelper.ExtractStr(json, "solution", "gRecaptchaResponseMd5"),
                            Text = JsonHelper.ExtractStr(json, "solution", "text"),
                            Url  = JsonHelper.ExtractStr(json, "solution", "url")
                        };

                        if (Solution.GRecaptchaResponse == null && Solution.Text == null)
                        {
                            throw new Exception("Got no 'solution' field from API");
                        }
                    }
                }
                else
                {
                    ErrorCode        = JsonHelper.ExtractStr(json, "errorCode");
                    ErrorDescription = JsonHelper.ExtractStr(json, "errorDescription") ?? "(no error description)";
                }
            }
            else
            {
                throw new Exception("Unknown error");
            }
        }
Exemplo n.º 25
0
            internal Task <(MonoDevelop.Projects.Solution, SolutionInfo)> CreateSolutionInfoFromCache(MonoDevelop.Projects.Solution sol, CancellationToken ct)
            {
                return(Task.Run(delegate {
                    return CreateSolutionInfoFromCacheInternal(sol, ct);
                }));

                async Task <(MonoDevelop.Projects.Solution, SolutionInfo)> CreateSolutionInfoFromCacheInternal(MonoDevelop.Projects.Solution solution, CancellationToken token)
                {
                    projections.ClearOldProjectionList();
                    solutionData = new SolutionData();

                    workspaceCache.Load(solution);

                    var projectInfos = await CreateProjectInfosFromCache(solution.GetAllProjects(), token).ConfigureAwait(false);

                    if (projectInfos == null)
                    {
                        return(solution, null);
                    }

                    if (token.IsCancellationRequested)
                    {
                        return(solution, null);
                    }

                    var solutionId   = GetSolutionId(solution);
                    var solutionInfo = SolutionInfo.Create(solutionId, VersionStamp.Create(), solution.FileName, projectInfos);

                    lock (addLock) {
                        if (!added)
                        {
                            added = true;
                            OnSolutionOpened(workspace, solutionInfo);
                        }
                    }

                    // Clear modified projects during load. The projects will be loaded later.
                    lock (workspace.projectModifyLock) {
                        workspace.modifiedProjects.RemoveAll(p => p.ParentSolution == solution);
                    }

                    return(solution, solutionInfo);
                }
            }
Exemplo n.º 26
0
        internal static SolutionData CreateSolutionData(Solution solution, SolutionConfiguration configuration,
                                                        CancellationToken cancellationToken = default(CancellationToken))
        {
            var solutionData = new SolutionData(solution, configuration);

            var projects = solution.Projects.ToDictionary(o => o.Name);

            foreach (var config in configuration.ProjectConfigurations)
            {
                if (!projects.ContainsKey(config.Name))
                {
                    throw new InvalidOperationException($"Project '{config.Name}' does not exist in solution '{solution.FilePath}'");
                }
                var project     = projects[config.Name];
                var projectData = CreateProjectData(project, config, solutionData);
                solutionData.ProjectData.Add(project.Id, projectData);
            }
            return(solutionData);
        }
Exemplo n.º 27
0
 internal void AddPowerShellCommandExecuteData(bool isPMC, SolutionData vsSolutionData)
 {
     lock (_lock)
     {
         // Please note: Direct PMC and PMUI don't share same code path for installing packages with *.ps1 files
         if (isPMC)
         {
             // For PMC all installation done in one pass so no double counting.
             vsSolutionData.PmcExecuteCommandCount++;
             _vsInstanceData.PmcExecuteCommandCount++;
         }
         else
         {
             // This one is called for both init.ps1 and install.ps1 seperately.
             // install.ps1 running inside MSBuildNuGetProject.cs (InstallPackageAsync method) may result in duplicate counting.
             // Also this concern valid for dependent packages (of installing package) with *.ps1 files.
             vsSolutionData.PmuiExecuteCommandCount++;
             _vsInstanceData.PmuiExecuteCommandCount++;
         }
     }
 }
Exemplo n.º 28
0
        public IActionResult AddQuestion(SolutionData value)
        {
            var NewSolution = new Solution
            {
                Id          = Guid.NewGuid(),
                DateAdded   = value.DateAdded,
                Description = value.Description,
                QuestionId  = value.QuestionId
            };

            _solutionRepository.AddEntity(NewSolution);
            if (value.Images != null)
            {
                _imageRepository.AddImageToSolution(value.Images, NewSolution.Id);
            }
            return(Ok(new
            {
                QuestionId = value.QuestionId,
                SolutionId = NewSolution.Id
            }));
        }
Exemplo n.º 29
0
        private async Task <SolutionData> CreateSolutionData(SolutionConfiguration configuration)
        {
            var props = new Dictionary <string, string>
            {
                ["CheckForSystemRuntimeDependency"] = "true"                 // needed in order that project references are loaded
            };
            var workspace = MSBuildWorkspace.Create(props);
            var solution  = await workspace.OpenSolutionAsync(configuration.Path).ConfigureAwait(false);

            var solutionData = new SolutionData(solution, workspace, configuration);

            var projectConfigs = configuration.ProjectConfigurations.ToDictionary(o => o.Name);

            foreach (var project in solution.Projects.Where(o => projectConfigs.ContainsKey(o.Name)))
            {
                var config      = projectConfigs[project.Name];
                var projectData = new ProjectData(solutionData, project.Id, config);
                RemoveGeneratedDocuments(projectData);
                solutionData.ProjectData.AddOrUpdate(project.Id, projectData, (id, data) => projectData);
            }
            return(solutionData);
        }
Exemplo n.º 30
0
            static DocumentInfo CreateDocumentInfo(
                SolutionData data,
                string projectName,
                ProjectData id,
                FilePath filePath,
                FilePath projectVirtualPath,
                SourceCodeKind sourceCodeKind = SourceCodeKind.Regular)
            {
                var folders = GetFolders(projectName, projectVirtualPath);

                return(DocumentInfo.Create(
                           id.DocumentData.GetOrCreate(filePath),
                           Path.GetFileName(filePath),
                           folders,
                           sourceCodeKind,
                           CreateTextLoader(filePath),
                           filePath,
                           isGenerated: false
                           ));

                TextLoader CreateTextLoader(string fileName) => data.Files.GetOrAdd(fileName, a => new MonoDevelopTextLoader(a));
            }
Exemplo n.º 31
0
        private static void addContentToProject(SolutionData solutionData, Project project, DTE2 dte2)
        {
            #region CPP Writing
            if (solutionData.projectType == ProjectType.CppEmpty) //CPP Example
            {
                Directory.CreateDirectory(solutionData.directoryPath + "\\Source Files");
                Directory.CreateDirectory(solutionData.directoryPath + "\\Header Files");

                foreach (ClassData classData in solutionData.classes)
                {
                    #region Class
                    if (classData.classType == ClassType.Class)
                    {
                        Document doc = dte2.ItemOperations.NewFile("General\\Text File", classData.className).Document;
                        TextSelection txtsel = (TextSelection)doc.Selection;
                        txtsel.Text = "";
                        txtsel.Insert("#include \"" + classData.className + ".h\"\n\n" + classData.className + "::" + classData.className + "()\n{\n}\n\n" + classData.className + "::~" + classData.className + "()\n{\n}");
                        doc.Save(solutionData.directoryPath + "\\Source Files\\" + classData.className + ".cpp");
                        project.ProjectItems.AddFromFile(solutionData.directoryPath + "\\Source Files\\" + classData.className + ".cpp");

                        Document doc2 = dte2.ItemOperations.NewFile("General\\Text File", classData.className).Document;
                        TextSelection txtsel2 = (TextSelection)doc2.Selection;
                        txtsel2.Text = "";
                        txtsel2.Insert("#pragma once");
                        if (classData.superClassName != "")
                        {
                            txtsel2.Insert("\n#include \"" + classData.superClassName + "\"");
                        }
                        foreach (string interfaceName in classData.interfaceNames)
                        {
                            txtsel2.Insert("\n#include \"" + interfaceName + "\"");
                        }
                        txtsel2.Insert("\n\nclass " + classData.className);
                        if (classData.superClassName != "")
                        {
                            txtsel2.Insert(" : public " + classData.superClassName);

                            foreach (string interfaceName in classData.interfaceNames)
                            {
                                txtsel2.Insert(", " + interfaceName);
                            }
                        }
                        else if (classData.interfaceNames.Count != 0)
                        {
                            txtsel2.Insert(" : " + classData.interfaceNames[0]);

                            for (int i = 1; i < classData.interfaceNames.Count; ++i)
                            {
                                txtsel2.Insert(", " + classData.interfaceNames[i]);
                            }
                        }
                        txtsel2.Insert("\n{\npublic:\n\t" + classData.className + "();\n\t~" + classData.className + "();\n\nprivate:\n\n};");
                        doc2.Save(solutionData.directoryPath + "\\Header Files\\" + classData.className + ".h");
                        project.ProjectItems.AddFromFile(solutionData.directoryPath + "\\Header Files\\" + classData.className + ".h");
                    }
                    #endregion
                    #region Enum
                    else if (classData.classType == ClassType.Enum)
                    {
                        EnvDTE.Document doc2 = dte2.ItemOperations.NewFile("General\\Text File", classData.className).Document;
                        TextSelection txtsel2 = (TextSelection)doc2.Selection;
                        txtsel2.Text = "";
                        txtsel2.Insert("#pragma once\n\nenum " + classData.className + "\n{\n\n};");
                        doc2.Save(solutionData.directoryPath + "\\Header Files\\" + classData.className + ".h");
                        project.ProjectItems.AddFromFile(solutionData.directoryPath + "\\Header Files\\" + classData.className + ".h");
                    }
                    #endregion
                }
            }
            #endregion
            #region C# Writing
            else //C# Example
            {
                foreach (ProjectItem pItem in project.ProjectItems)
                {
                    if (pItem.Name == "Form1.cs")
                    {
                        pItem.Remove();
                    }
                }

                foreach (ClassData classData in solutionData.classes)
                {
                    if (classData.classType == ClassType.Enum || classData.classType == ClassType.Class || classData.classType == ClassType.Interface)
                        project.ProjectItems.AddFromTemplate(@"C:\Program Files (x86)\Microsoft Visual Studio " + dte2.Version + @"\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class\Class.vstemplate", classData.className + ".cs");
                    else if (classData.classType == ClassType.Form)
                        project.ProjectItems.AddFromTemplate(@"c:\Program Files (x86)\Microsoft Visual Studio " + dte2.Version + @"\Common7\IDE\ItemTemplates\CSharp\Windows Forms\1033\Form\windowsform.vstemplate", classData.className + ".cs");

                    ProjectItem projectItem = null;
                    foreach (ProjectItem pItem in project.ProjectItems)
                    {
                        if (pItem.Name == classData.className + ".cs")
                        {
                            projectItem = pItem;
                            break;
                        }
                    }

                    projectItem.Save();
                    TextSelection txtsel = (TextSelection)projectItem.Document.Selection;

                    #region Class
                    if (classData.classType == ClassType.Class)
                    {
                        txtsel.GotoLine(9);
                        txtsel.EndOfLine();
                        if (classData.superClassName != "")
                        {
                            txtsel.Insert(" : " + classData.superClassName);

                            foreach (string interfaceName in classData.interfaceNames)
                            {
                                txtsel.Insert(", " + interfaceName);
                            }
                        }
                        else if (classData.interfaceNames.Count != 0)
                        {
                            txtsel.Insert(" : " + classData.interfaceNames[0]);

                            for (int i = 1; i < classData.interfaceNames.Count; ++i)
                            {
                                txtsel.Insert(", " + classData.interfaceNames[i]);
                            }
                        }
                    }
                    #endregion
                    #region Enum
                    else if (classData.classType == ClassType.Enum)
                    {
                        txtsel.GotoLine(9);
                        txtsel.StartOfLine();
                        txtsel.CharRight(false, 4);
                        txtsel.DestructiveInsert("enum");
                        txtsel.Delete();
                    }
                    #endregion
                    #region Interface
                    else if (classData.classType == ClassType.Interface)
                    {
                        txtsel.GotoLine(9);
                        txtsel.StartOfLine();
                        txtsel.CharRight(false, 4);
                        txtsel.Insert("interface");
                        txtsel.Delete(5);
                    }
                    #endregion
                }
            }
            #endregion
        }
Exemplo n.º 32
0
        internal Server(string modelfile, string solutionfile)
        {
            mfile = modelfile;
             sfile = solutionfile;
             try {
            FileStream mstream = new FileStream(mfile, FileMode.Open);
            FileStream sstream = new FileStream(sfile, FileMode.Create);

            Cplex     cplex = new Cplex();
            ModelData data  = null;

            BinaryFormatter formatter = new BinaryFormatter ();
            data = (ModelData) formatter.Deserialize(mstream);
            mstream.Close();

            cplex.SetModel(data.model);

            SolutionData sol = new SolutionData();
            if ( cplex.Solve() ) {
               sol.obj  = cplex.ObjValue;
               sol.vals = cplex.GetValues(data.vars);
            }
            sol.status = cplex.GetCplexStatus();

            formatter.Serialize(sstream, sol);
            sstream.Close();

            cplex.End();
             }
             catch (System.Exception t) {
            System.Console.WriteLine("server terminates due to " + t);
             }
        }
Exemplo n.º 33
0
        private static void createProject(SolutionData solutionData, Solution2 solution, DTE dte)
        {
            switch (solutionData.projectType)
            {
                case ProjectType.CsConsole:
                    solution.AddFromTemplate(solution.GetProjectTemplate("ConsoleApplication.zip", "CSharp"),
                        solutionData.directoryPath + "\\" + solutionData.projectName, solutionData.projectName);
                    break;

                case ProjectType.CsForms:
                    solution.AddFromTemplate(solution.GetProjectTemplate("WindowsApplication.zip", "CSharp"),
                        solutionData.directoryPath + "\\" + solutionData.projectName, solutionData.projectName);
                    break;

                case ProjectType.CppEmpty:
                    object[] contextParams = { "{66bb5dd8-bf70-4784-be56-2273124f2638}",
                                               solutionData.projectName,
                                               solutionData.directoryPath + "\\"
                                               };
                    dte.LaunchWizard(@"c:\Program Files (x86)\Microsoft Visual Studio " + dte.Version + @"\VC\vcprojects\emptyproj.vsz", contextParams);
                    break;
            }
        }
Exemplo n.º 34
0
		Task<SolutionInfo> CreateSolutionInfo (MonoDevelop.Projects.Solution solution, CancellationToken token)
		{
			return Task.Run (async delegate {
				var projects = new ConcurrentBag<ProjectInfo> ();
				var mdProjects = solution.GetAllProjects ();
				projectionList.Clear ();
				solutionData = new SolutionData ();
				List<Task> allTasks = new List<Task> ();
				foreach (var proj in mdProjects) {
					if (token.IsCancellationRequested)
						return null;
					var netProj = proj as MonoDevelop.Projects.DotNetProject;
					if (netProj != null && !netProj.SupportsRoslyn)
						continue;
					var tp = LoadProject (proj, token).ContinueWith (t => {
						if (!t.IsCanceled)
							projects.Add (t.Result);
					});
					allTasks.Add (tp);
				}
				await Task.WhenAll (allTasks.ToArray ());
				if (token.IsCancellationRequested)
					return null;
				var modifiedWhileLoading = modifiedProjects = new List<MonoDevelop.Projects.DotNetProject> ();
				var solutionInfo = SolutionInfo.Create (GetSolutionId (solution), VersionStamp.Create (), solution.FileName, projects);
				foreach (var project in modifiedWhileLoading) {
					if (solution.ContainsItem (project)) {
						return await CreateSolutionInfo (solution, token).ConfigureAwait (false);
					}
				}

				lock (addLock) {
					if (!added) {
						added = true;
						OnSolutionAdded (solutionInfo);
					}
				}
				return solutionInfo;
			});
		}
Exemplo n.º 35
0
        public static SolutionData ReadSolutionData()
        {
            SolutionData solutionData = new SolutionData();

            OpenFileDialog ofd = new OpenFileDialog();
            ofd.InitialDirectory = "C:\\";
            ofd.Filter = "Text Files (.txt)|*.txt";
            ofd.Multiselect = false;

            DialogResult result = ofd.ShowDialog();

            if (result == DialogResult.OK)
            {
                solutionData.directoryPath = Path.GetDirectoryName(ofd.FileName);
            }
            else
            {
                ErrorHandling.handleWrongUsage();
                return solutionData;
            }

            string[] lines = null;
            try
            {
                lines = File.ReadAllLines(ofd.FileName);

                foreach (string line in lines)
                {
                    string[] parts = line.Trim().Split(' ');

                    if (parts.Length == 0)
                        continue;

                    if (parts[0] == "SOLUTION_NAME")
                    {
                        solutionData.solutionName = parts[1];
                    }
                    else if (parts[0] == "CS_FORMS")
                    {
                        solutionData.projectType = ProjectType.CsForms;
                        solutionData.projectName = parts[1];
                    }
                    else if (parts[0] == "CS_CONSOLE")
                    {
                        solutionData.projectType = ProjectType.CsConsole;
                        solutionData.projectName = parts[1];
                    }
                    else if (parts[0] == "CPP_EMPTY")
                    {
                        solutionData.projectType = ProjectType.CppEmpty;
                        solutionData.projectName = parts[1];
                    }
                    else if (parts[0] == "CLASS")
                    {
                        ClassData classData = new ClassData();
                        classData.className = parts[1];
                        for (int i = 2; i < parts.Length; i += 2)
                        {
                            if (parts[i] == ":")
                            {
                                classData.superClassName = parts[i + 1];
                            }
                            else
                            {
                                classData.interfaceNames.Add(parts[i + 1]);
                            }
                        }
                        solutionData.classes.Add(classData);
                    }
                    else if (parts[0] == "ENUM")
                    {
                        ClassData classData = new ClassData();
                        classData.classType = ClassType.Enum;
                        classData.className = parts[1];
                        solutionData.classes.Add(classData);
                    }
                    else if (parts[0] == "FORM")
                    {
                        ClassData classData = new ClassData();
                        classData.classType = ClassType.Form;
                        classData.className = parts[1];
                        solutionData.classes.Add(classData);
                    }
                    else if (parts[0] == "INTERFACE")
                    {
                        ClassData classData = new ClassData();
                        classData.classType = ClassType.Interface;
                        classData.className = parts[1];
                        solutionData.classes.Add(classData);
                    }
                }
            }
            catch
            {
                ErrorHandling.handleWrongUsage();
            }

            return solutionData;
        }
		async Task<SolutionInfo> CreateSolutionInfo (MonoDevelop.Projects.Solution solution, CancellationToken token)
		{
			var projects = new ConcurrentBag<ProjectInfo> ();
			var mdProjects = solution.GetAllProjects ().OfType<MonoDevelop.Projects.DotNetProject> ();
			projectionList.Clear ();
			solutionData = new SolutionData ();

			List<Task> allTasks = new List<Task> ();
			foreach (var proj in mdProjects) {
				if (token.IsCancellationRequested)
					return null;
				if (!SupportsRoslyn (proj))
					continue;
				var tp = LoadProject (proj, token).ContinueWith (t => {
					if (!t.IsCanceled)
						projects.Add (t.Result);
				});
				allTasks.Add (tp);
			}
			await Task.WhenAll (allTasks.ToArray ());
			if (token.IsCancellationRequested)
				return null;
			var solutionInfo = SolutionInfo.Create (GetSolutionId (solution), VersionStamp.Create (), solution.FileName, projects);
			lock (addLock) {
				if (!added) {
					added = true;
					OnSolutionAdded (solutionInfo);
				}
			}
			return solutionInfo;
		}
Exemplo n.º 37
0
		static DocumentInfo CreateDocumentInfo (SolutionData data, string projectName, ProjectData id, MonoDevelop.Projects.ProjectFile f, SourceCodeKind sourceCodeKind)
		{
			var filePath = f.FilePath;
			return DocumentInfo.Create (
				id.GetOrCreateDocumentId (filePath),
				filePath,
				new [] { projectName }.Concat (f.ProjectVirtualPath.ParentDirectory.ToString ().Split (Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar)),
				sourceCodeKind,
				CreateTextLoader (data, f.Name),
				f.Name,
				false
			);
		}
Exemplo n.º 38
0
        private static void GenerateSolution(SolutionData solutionData)
        {
            try
            {
                MessageFilter.Register();
                System.Type type = System.Type.GetTypeFromProgID("VisualStudio.DTE");
                Object obj = System.Activator.CreateInstance(type, true);
                EnvDTE.DTE dte = (EnvDTE.DTE)obj;
                dte.MainWindow.Visible = false;

                // create a new solution
                dte.Solution.Create(solutionData.directoryPath + "\\", solutionData.solutionName);
                dte.ExecuteCommand("File.SaveAll");

                Solution2 solution = (Solution2)dte.Solution;
                createProject(solutionData, solution, dte);

                EnvDTE.Project project = solution.Projects.Item(1);
                DTE2 dte2 = (DTE2)dte;

                addContentToProject(solutionData, project, dte2);

                // save and quit
                dte.ExecuteCommand("File.SaveAll");
                dte.Quit();
                MessageFilter.Revoke();
            }
            catch
            {
                ErrorHandling.handleWrongUsage();
            }
        }