Пример #1
0
        private async Task FillInProgressProperties(BuildInformation buildInformation, dynamic jsonItem, BuildResult buildResult,
                                                    string webLinkUri)
        {
            await GetInProgressBuildDetails(buildInformation, jsonItem, buildResult);

            buildResult.IsRunning = true;
            var buildReason = string.Format("{0}", jsonItem.reason);

            buildResult.IsGatedCheckin = string.Equals(buildReason, "checkInShelveset",
                                                       StringComparison.InvariantCultureIgnoreCase);
            buildResult.RunningTfsUri           = webLinkUri;
            buildResult.RunningBuildId          = jsonItem.id;
            buildResult.RunningBuildRequestedBy = jsonItem.requestedFor.displayName;
            buildResult.RunningBuildNumber      = jsonItem.buildNumber;
            buildResult.RunningBuildTfsUri      = webLinkUri;
            string sourceVersion = jsonItem.sourceVersion;

            try
            {
                buildResult.RunningBuildSourceVersion = Convert.ToInt32(sourceVersion.Replace("C", string.Empty));
            }
            catch (FormatException)
            {
                // for git repositories there is a guid for the source version -> cannot be converted to int
            }

            var runningStartTimeString = string.Format("{0}", jsonItem.startTime);

            if (!string.IsNullOrEmpty(runningStartTimeString))
            {
                buildResult.RunningStartTime = DateTime.Parse(runningStartTimeString, CultureInfo.CurrentCulture,
                                                              DateTimeStyles.AssumeUniversal);
            }
        }
Пример #2
0
        private async Task FillInProgressBuild(BuildInformation buildInformation, dynamic jsonItem, BuildResult buildResult)
        {
            string response2;

            using (
                var httpClient = WebClientFactory.CreateHttpClient(buildInformation.DomainName, buildInformation.Login,
                                                                   buildInformation.CryptedPassword))
            {
                var buildIdUri    = string.Format(buildInformation.TestResultUrl, jsonItem.id);
                var responseMsgs2 = await httpClient.GetAsync(buildIdUri);

                response2 = await responseMsgs2.Content.ReadAsStringAsync();
            }

            UpdateProperties(response2, buildResult);
            buildResult.IsRunning = true;
            var buildReason = string.Format("{0}", jsonItem.reason);

            buildResult.IsGatedCheckin = string.Equals(buildReason, "checkInShelveset",
                                                       StringComparison.InvariantCultureIgnoreCase);
            buildResult.RunningTfsUri           = jsonItem.uri;
            buildResult.RunningBuildId          = jsonItem.id;
            buildResult.RunningBuildRequestedBy = jsonItem.requests[0].requestedFor.displayName;
            buildResult.RunningBuildNumber      = jsonItem.buildNumber;
            buildResult.RunningBuildTfsUri      = jsonItem.uri;
            var runningStartTimeString = string.Format("{0}", jsonItem.startTime);

            if (!string.IsNullOrEmpty(runningStartTimeString))
            {
                buildResult.RunningStartTime = DateTime.Parse(runningStartTimeString, CultureInfo.CurrentCulture,
                                                              DateTimeStyles.AssumeUniversal);
            }
        }
Пример #3
0
        /// <summary>
        /// Method for generating all D-students names from all of the groups
        /// </summary>
        /// <param name="university">DBContext</param>
        /// <param name="filepath">Where to save</param>
        /// <param name="TypeOfOrder">Sorting type</param>
        public void WriteAllDStudents(string filepath, string TypeOfOrder = "OrderBy")
        {
            using (UniversityClassesDataContext db = new UniversityClassesDataContext(connectString))
            {
                BuildInformation building = new BuildInformation();
                Dictionary <string, List <string> > ordered_group = building.GetAllDStudents(db, TypeOfOrder);

                Application excelApp  = new Application();
                Workbook    workBook  = excelApp.Workbooks.Add();
                Worksheet   workSheet = workBook.ActiveSheet;
                workSheet.Cells[1, "A"] = "Group";
                workSheet.Cells[1, "B"] = "Allocated students";
                int i = 2;
                foreach (var group in ordered_group)
                {
                    workSheet.Cells[i, "A"] = $"{group.Key}";
                    foreach (var student in group.Value)
                    {
                        workSheet.Cells[i, "B"] = student;
                        i++;
                    }
                }
                workBook.Close(true, filepath);
                excelApp.Quit();
            }
        }
        private static IEnumerable <BuildInformation> GetBuildsTfs2015(BuildServer buildServer)
        {
            var apiIndex = buildServer.Url.IndexOf("_apis", StringComparison.OrdinalIgnoreCase);

            foreach (var buildDefinition in buildServer.BuildDefinitions)
            {
                var urlNoApi           = apiIndex < 0 ? string.Concat(buildServer.Url, "/", buildDefinition.ProjectId, "/") : buildServer.Url.Substring(0, apiIndex);
                var buildDefinitionUrl = string.Concat(urlNoApi, "_apis/build/Builds?api-version=2.0&definitions=");
                var stopBuildUrl       = string.Concat(urlNoApi, "_apis/build/builds/{0}?api-version=2.0");
                var requestBuildUrl    = string.Concat(urlNoApi, "_apis/build/builds?api-version=2.0");
                var testRunUrl         = string.Concat(urlNoApi, "_apis/test/Runs/Query?includeRunDetails=true&api-version=2.2-preview.2");
                var changesetUrl       = string.Concat(urlNoApi, "_apis/tfvc/changesets/{0}?api-version=1.0");
                var build = new BuildInformation
                {
                    DomainName         = buildServer.DomainName,
                    Login              = buildServer.Login,
                    CryptedPassword    = buildServer.PasswordBytes,
                    BuildDefinitionUrl = string.Concat(buildDefinitionUrl, buildDefinition.Id),
                    BuildDefinitionId  = buildDefinition.Id,
                    StopBuildUrl       = stopBuildUrl,
                    RequestBuildUrl    = requestBuildUrl,
                    TfsVersion         = buildServer.TfsVersion,
                    TestRunUrl         = testRunUrl,
                    ChangesetUrl       = changesetUrl,
                    Tags = buildDefinition.Tags
                };
                yield return(build);
            }
        }
Пример #5
0
        protected override void Build()
        {
            var type = this.__CLRType;

            m_BuildInformation = new BuildInformation(type.Assembly, throwError: false);
            m_IsValueType      = type.IsValueType;
            m_IsVisible        = type.IsVisible;
            m_IsArray          = type.IsArray;
            m_IsAbstract       = type.IsAbstract;

            if (m_IsArray)
            {
                m_ArrayRank             = type.GetArrayRank();
                m_ArrayElementTypeIndex = MetaType.GetExistingOrNewMetaTypeIndex(m_Document, type.GetElementType());
            }

            m_Fields = new List <MetaField>();

            var fields = SerializationUtils.GetSerializableFields(type);

            foreach (var fld in fields)
            {
                var mf = new MetaField(this, fld);
                m_Fields.Add(mf);
                mf.m_Index = m_Fields.Count - 1;
            }

            m_MethodsOnSerializing = SerializationUtils.FindSerializationAttributedMethods(type, typeof(OnSerializingAttribute));
            m_MethodsOnSerialized  = SerializationUtils.FindSerializationAttributedMethods(type, typeof(OnSerializedAttribute));
        }
        private static IEnumerable <BuildInformation> GetBuildsTfs2013(BuildServer buildServer)
        {
            var apiIndex           = buildServer.Url.IndexOf("_apis", StringComparison.OrdinalIgnoreCase);
            var urlNoApi           = buildServer.Url.Substring(0, apiIndex);
            var buildDefinitionUrl = string.Concat(urlNoApi, "_apis/build/Builds?api-version=1.0&definition=");
            var stopBuildUrl       = string.Concat(urlNoApi, "_apis/build/builds/{0}?api-version=1.0");
            var requestBuildUrl    = string.Concat(urlNoApi, "_apis/build/requests?api-version=1.0");
            var testResutlUri      = string.Concat(urlNoApi, "_api/_build/build?__v=5&uri=vstfs:///Build/Build/{0}&includeTestRuns=true&includeCoverage=true");

            foreach (var buildDefinition in buildServer.BuildDefinitions)
            {
                var build = new BuildInformation
                {
                    DomainName         = buildServer.DomainName,
                    Login              = buildServer.Login,
                    CryptedPassword    = buildServer.PasswordBytes,
                    BuildDefinitionUrl = string.Concat(buildDefinitionUrl, buildDefinition.Uri),
                    BuildDetailUrl     = buildServer.DetailBuildUrl,
                    BuildDefinitionId  = buildDefinition.Id,
                    StopBuildUrl       = stopBuildUrl,
                    RequestBuildUrl    = requestBuildUrl,
                    TestResultUrl      = testResutlUri,
                    TfsVersion         = buildServer.TfsVersion,
                    Tags = buildDefinition.Tags
                };
                yield return(build);
            }
        }
Пример #7
0
        public static Localization GetLocalization(RomVersion v)
        {
            return(BuildInformation.GetLocalization(v));

            //switch (v)
            //{
            //    case Build.N0: return Localization.NTSC; //NTSC 1.0
            //    case Build.N1: return Localization.NTSC; //NTSC 1.1
            //    case Build.N2: return Localization.NTSC; //NTSC 1.2

            //    case Build.P0: return Localization.PAL; //PAL 1.0
            //    case Build.P1: return Localization.PAL; //PAL 1.1

            //    case Build.GCNJ: return Localization.NTSC;
            //    case Build.GCNP: return Localization.PAL;

            //    case Build.MQP: return Localization.PAL;
            //    case Build.MQJ: return Localization.NTSC;
            //    case Build.DBGMQ: return Localization.PAL;

            //    //non-official builds
            //    //case Build.DUNGRUSH: return Localization.NTSC;
            //    //case Build.DUNGRUSH2: return Localization.NTSC;
            //    default: return Localization.UNKNOWN;
            //}
        }
Пример #8
0
        public async Task <Changeset> GetChangesetAsync(BuildInformation buildInformation, int sourceVersion)
        {
            string response;

            using (var httpClient = WebClientFactory.CreateHttpClient(buildInformation.DomainName, buildInformation.Login, buildInformation.CryptedPassword))
            {
                HttpResponseMessage responseMessage;
                try
                {
                    responseMessage = await httpClient.GetAsync(string.Format(buildInformation.ChangesetUrl, sourceVersion));
                }
                catch (Exception ex)
                {
                    return(null);
                }

                if (!responseMessage.IsSuccessStatusCode)
                {
                    return(null);
                }

                response = await responseMessage.Content.ReadAsStringAsync();
            }

            var changeset = JsonConvert.DeserializeObject <Changeset>(response);

            return(changeset);
        }
Пример #9
0
 public UserController(ApplicationConfiguration applicationConfiguration,
                       BuildInformation buildInformation,
                       UserAuthenticationManager authenticationManager) :
     base(applicationConfiguration, buildInformation)
 {
     this._authenticationManager = authenticationManager;
 }
Пример #10
0
    public void HideBuildInfo()
    {
        CurrentInfo = null;

        BuildingInfo.SetActive(false);
        _visualizer.SetActive(false);
    }
Пример #11
0
        /// <summary>Initializes a new instance of the <see cref="StopBuildCommand"/> class.</summary>
        /// <param name="buildAdapter">The build adapter.</param>
        /// <param name="buildInformation">The build information.</param>
        public StopBuildCommand(BuildAdapter buildAdapter, BuildInformation buildInformation)
        {
            buildExplorer = BuildExplorerFactory.CreateBuildExplorer(buildInformation.TfsVersion);
            buildAdapter.PropertyChanged += buildAdapter_PropertyChanged;

            this.buildAdapter     = buildAdapter;
            this.buildInformation = buildInformation;
        }
Пример #12
0
    ////////////////////////////////////////////////////////////////////////////
    void ShowDebugPanelWindow()
    {
        Vector2 CharSize       = GUI.skin.label.CalcSize(new GUIContent("M"));
        var     LabelMinHeight = GUILayout.MinHeight(CharSize.y);
        var     DisableExtend  = GUILayout.ExpandWidth(false);

        GUILayout.BeginHorizontal();
        {
            GUILayout.Label("屏幕:" + Screen.width + "X" + Screen.height, LabelMinHeight);
            if (GUILayout.Button("×", GUILayout.MinWidth(CharSize.x * 1.5f), DisableExtend))
            {
                m_ShowDebugPanel = false;
            }
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        {
            GUILayout.Label(
                "质量:" + QualitySettings.names[QualitySettings.GetQualityLevel()],
                LabelMinHeight,
                GUILayout.MinWidth(CharSize.x * 10),
                DisableExtend
                );

            /*
             * if (GUILayout.Button(" - ", DisableExtend))
             *  QualitySettings.DecreaseLevel();
             *
             * if (GUILayout.Button(" + ", DisableExtend))
             *  QualitySettings.IncreaseLevel();
             */
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginVertical();
        if (m_GlowEffectScript)
        {
            m_GlowEffectScript.enabled = GUILayout.Toggle(m_GlowEffectScript.enabled, "Glow Effect");
        }
        GUILayout.EndVertical();

        GUILayout.BeginVertical();
        GUILayout.Label("编译时间:" + BuildInformation.GetBuildTimestamp(), LabelMinHeight);
        GUILayout.EndVertical();

        if (m_ShowDetailInfo == false && m_UpdateStatisticsCount > 0)
        {
            GUILayout.BeginVertical();
            GUILayout.Label("详细统计信息:", LabelMinHeight);
            GUILayout.Label("   平均FPS:" + m_averageFps, LabelMinHeight);
            GUILayout.Label("   最低FPS:" + m_MinFps, LabelMinHeight);
            GUILayout.Label("   最高FPS:" + m_MaxFps, LabelMinHeight);
            GUILayout.Label("   最大帧间隔时间:" + m_MaxPerFrameTime + "ms", LabelMinHeight);
            GUILayout.Label("   测试持续时间:" + m_TestTime + "s", LabelMinHeight);
            GUILayout.EndVertical();
        }
    }
Пример #13
0
    public void ShowInfo(BuildInformation info)
    {
        BuildingInfo.SetActive(info != null);
        CurrentInfo = info;

        _visualizer.transform.localScale = Vector3.one * (info.Radius.radius * 2);
        _visualizer.transform.position   = info.transform.position + info.Radius.center;
        _visualizer.SetActive(true);
    }
Пример #14
0
 public static void ConsolePrintSupportedVersions()
 {
     Console.WriteLine("Ocarina of Time: use GameId 'oot'");
     Console.WriteLine("Version:");
     foreach (var item in GetSupportedBuilds())
     {
         var info = BuildInformation.Get(item);
         Console.WriteLine($" {info.Version + ":",-5} {info.Name}");
     }
 }
Пример #15
0
        /// <summary>
        /// Generates report about speciality results in one session in XLXS file
        /// </summary>
        /// <param name="id">Session ID</param>
        /// <param name="filepath">filepath to save</param>
        public void WriteSpecialityGrade(int id, string filepath, string TypeOfOrder)
        {
            using (UniversityClassesDataContext db = new UniversityClassesDataContext(connectString))
            {
                BuildInformation buildInformation = new BuildInformation();

                Dictionary <string, float> examiner_marks;
                Dictionary <string, float> group_ordered;
                Dictionary <string, float> spec_marks;

                buildInformation.GetSpecialitySessionResults(id, db, out group_ordered, out spec_marks, out examiner_marks, TypeOfOrder);

                Application excelApp  = new Application();
                Workbook    workBook  = excelApp.Workbooks.Add();
                Worksheet   workSheet = workBook.ActiveSheet;

                Session session = db.Session.Where(p => p.ID == id).FirstOrDefault();

                workSheet.Cells[1, "A"] = "Session";
                workSheet.Cells[1, "B"] = "Group";
                workSheet.Cells[1, "C"] = "Average Mark";
                workSheet.Cells[2, "A"] = $"{session.StartDate} - {session.EndDate}";


                int i = 2;

                foreach (var group in group_ordered)
                {
                    workSheet.Cells[i, "B"] = group.Key;
                    workSheet.Cells[i, "C"] = group.Value;
                    i++;
                }

                workSheet.Cells[i, "A"] = "Specialization mark";

                foreach (var spec in spec_marks)
                {
                    workSheet.Cells[i, "B"] = spec.Key;
                    workSheet.Cells[i, "C"] = spec.Value;
                    i++;
                }

                workSheet.Cells[i, "A"] = "Examiner mark";

                foreach (var examiner in examiner_marks)
                {
                    workSheet.Cells[i, "B"] = examiner.Key;
                    workSheet.Cells[i, "C"] = examiner.Value;
                    i++;
                }

                workBook.Close(true, filepath);
                excelApp.Quit();
            }
        }
Пример #16
0
        private IDictionary <string, object> CreateVariables(Mapping mapToRun, BuildInformation buildInfo)
        {
            var dict = CreateCommonVariables(mapToRun, buildInfo);

            foreach (ScriptParameter parameter in mapToRun.ScriptParameters)
            {
                dict.Add(parameter.name, parameter.value);
            }

            return(dict);
        }
Пример #17
0
        public bool Execute(string directory, Mapping mapToRun, BuildInformation buildInfo)
        {
            var    variables = CreateVariables(mapToRun, buildInfo);
            string command   = this.GeneratePipelineCommand(directory, mapToRun);

            this._scriptRun = command;

            ExecuteCommand(command, variables);

            return(this.ErrorOccurred);
        }
Пример #18
0
        private static async Task GetInProgressBuildDetails(BuildInformation buildInformation, dynamic jsonItem,
                                                            BuildResult buildResult)
        {
            if (jsonItem._links.details == null)
            {
                // details link not provided by current version of api in VSTS
                return;
            }

            string response;

            try
            {
                using (
                    var httpClient = WebClientFactory.CreateHttpClient(buildInformation.DomainName, buildInformation.Login,
                                                                       buildInformation.CryptedPassword))
                {
                    string buildIdUri    = jsonItem._links.details.href;
                    var    responseMsgs2 = await httpClient.GetAsync(buildIdUri);

                    response = await responseMsgs2.Content.ReadAsStringAsync();
                }
            }
            catch
            {
                return;
            }

            dynamic jsonObject = JsonConvert.DeserializeObject(response);

            foreach (var item in jsonObject.value)
            {
                if (item.type == "BuildError")
                {
                    buildResult.TestsFailed = true;
                    string message = item.fields.Message;
                    buildResult.FailingDetails.Add(message);
                }

                if (item.type == "ActivityTracking")
                {
                    string displayText = item.fields.DisplayText;
                    if (displayText.StartsWith("Run MSTest"))
                    {
                        buildResult.TestsRunning = true;
                    }

                    if (displayText == "Copy Files to Drop Location")
                    {
                        buildResult.TestsFinished = true;
                    }
                }
            }
        }
Пример #19
0
        private IDictionary <string, object> CreateCommonVariables(Mapping mapToRun, BuildInformation buildInfo)
        {
            var dict = new Dictionary <string, object>();

            dict.Add("TfsDeployerComputer", mapToRun.Computer);
            dict.Add("TfsDeployerNewQuality", mapToRun.NewQuality);
            dict.Add("TfsDeployerOriginalQuality", mapToRun.OriginalQuality);
            dict.Add("TfsDeployerScript", mapToRun.Script);
            dict.Add("TfsDeployerBuildData", buildInfo.Data);
            dict.Add("TfsDeployerBuildDetail", buildInfo.Detail);
            return(dict);
        }
Пример #20
0
        /// <summary>Requests the build.</summary>
        /// <param name="buildInformation">The build information.</param>
        /// <returns>The <see cref="BuildResult"/>.</returns>
        public async Task <BuildResult> RequestBuild(BuildInformation buildInformation)
        {
            string response;

            try
            {
                using (var httpClient = WebClientFactory.CreateHttpClient(buildInformation.DomainName, buildInformation.Login, buildInformation.CryptedPassword))
                {
                    httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    var json    = string.Format("{{ \"definition\": {{ \"id\": {0} }}, \"reason\": \"Manual\", \"priority\": \"Normal\" }}", buildInformation.BuildDefinitionId);
                    var request = new HttpRequestMessage(HttpMethod.Post, buildInformation.RequestBuildUrl)
                    {
                        Content = new StringContent(json, Encoding.UTF8, "application/json")
                    };

                    var responseMessage = await httpClient.SendAsync(request);

                    if (responseMessage.StatusCode != HttpStatusCode.OK)
                    {
                        return(new BuildResult {
                            Name = responseMessage.StatusCode.ToString("G")
                        });
                    }

                    response = await responseMessage.Content.ReadAsStringAsync();
                }
            }
            catch (Exception ex)
            {
                return(new BuildResult {
                    Name = ex.Message
                });
            }

            dynamic jsonObject        = JsonConvert.DeserializeObject(response);
            var     buildstatusString = string.Format("{0}", jsonObject.status);

            if (buildStatusReplacement.ContainsKey(buildstatusString))
            {
                buildstatusString = buildStatusReplacement[buildstatusString];
            }

            var    buildStatus = (BuildStatus)Enum.Parse(typeof(BuildStatus), buildstatusString, true);
            string buildId     = jsonObject.uri;

            return(new BuildResult
            {
                Name = jsonObject.definition.name,
                Status = buildStatus,
                RequestedBy = jsonObject.requestedBy.displayName,
                TfsUri = buildId
            });
        }
Пример #21
0
        public BuildInformation GetBuildInformation(string assemblyID)
        {
            BuildInformation buildInformation = new BuildInformation();

            DbDataReader reader = database.ExecuteReader("SELECT * FROM Builds WHERE AssemblyID=@1", new System.Guid(assemblyID));

            if (reader.Read())
            {
                buildInformation = new BuildInformation(reader);
            }
            reader.Close();

            return(buildInformation);
        }
Пример #22
0
        protected override int Execute(BuildCommandArgs args, ChangeObservable observable)
        {
            string buildProperties = string.Join(" ", args.BuildProperties.Select(Unescape));

            Entity rootEntity = entityFactory.Create(Guid.NewGuid().ToByteString(), args).Root;

            BuildInformation buildInfo = new BuildInformation(rootEntity, args.BuildType, args.Configure, args.NoConfigure, buildProperties, args.Output);

            builder.Build(buildInfo, observable, args.Target);

            return(0);

            string Unescape(string arg)
            {
                return(arg.Replace("%22", "\""));
            }
        }
Пример #23
0
        private void GetBuildsClick(object sender, EventArgs e)
        {
            m_ListView2.Items.Clear();

            string[] allBuilds = m_Database.Builds.GetAllBuilds();
            for (int index = 0; index < allBuilds.Length && index < c_Limit; index++)
            {
                string           assemblyId       = allBuilds[index];
                BuildInformation buildInformation = m_Database.Builds.GetBuildInformation(assemblyId);
                string           projectName      = m_Database.Projects.GetProjectInformation(buildInformation.ProjectID).Name;
                m_ListView2.Items.Add(
                    new ListViewItem(new[]
                {
                    projectName, buildInformation.BuildDate.ToString("g")
                }));
            }
        }
Пример #24
0
        public async Task GetTestResultAsync(BuildInformation buildInformation, BuildResult result)
        {
            string response;

            using (var httpClient = WebClientFactory.CreateHttpClient(buildInformation.DomainName, buildInformation.Login, buildInformation.CryptedPassword))
            {
                var postString = string.Format("{{ \"query\":\"SELECT * FROM TestRun WHERE buildUri='vstfs:///Build/Build/{0}'\"}}", result.Id);
                HttpResponseMessage responseMessage;
                try
                {
                    responseMessage = await httpClient.PostAsync(buildInformation.TestRunUrl,
                                                                 new StringContent(postString, Encoding.UTF8, "application/json"));
                }
                catch
                {
                    return;
                }

                if (!responseMessage.IsSuccessStatusCode)
                {
                    return;
                }

                response = await responseMessage.Content.ReadAsStringAsync();
            }

            var     testRuns   = new List <TestRun>();
            dynamic jsonObject = JsonConvert.DeserializeObject(response);

            foreach (var item in jsonObject.value)
            {
                var testRun         = new TestRun();
                int incompletTests  = item.incompleteTests;
                int unanalyzedTests = item.unanalyzedTests;
                testRun.Id          = item.id;
                testRun.TotalTests  = item.totalTests;
                testRun.PassedTests = item.passedTests;
                testRun.FailedTests = incompletTests + unanalyzedTests;
                testRuns.Add(testRun);
            }

            result.TotalTests  = testRuns.Sum(x => x.TotalTests);
            result.PassedTests = testRuns.Sum(x => x.PassedTests);
            result.FailedTests = testRuns.Sum(x => x.FailedTests);
        }
Пример #25
0
        /// <summary>Stops the build.</summary>
        /// <param name="buildInformation">The build information.</param>
        /// <param name="buildId">The build identifier.</param>
        /// <returns>True if stopping the build succeed; otherwise false.</returns>
        public async Task <BuildResult> StopBuild(BuildInformation buildInformation, string buildId)
        {
            string response;

            try
            {
                using (var httpClient = WebClientFactory.CreateHttpClient(buildInformation.DomainName, buildInformation.Login, buildInformation.CryptedPassword))
                {
                    httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    var requestUri = string.Format(buildInformation.StopBuildUrl, buildId);
                    var request    = new HttpRequestMessage(new HttpMethod("PATCH"), requestUri)
                    {
                        Content = new StringContent("{ \"status\": \"Stopped\" }", Encoding.UTF8, "application/json")
                    };

                    var responseMessage = await httpClient.SendAsync(request);

                    if (responseMessage.StatusCode != HttpStatusCode.OK)
                    {
                        return(new BuildResult {
                            Name = responseMessage.StatusCode.ToString("G")
                        });
                    }

                    response = await responseMessage.Content.ReadAsStringAsync();
                }
            }
            catch (Exception ex)
            {
                return(new BuildResult {
                    Name = ex.Message
                });
            }

            dynamic jsonObject        = JsonConvert.DeserializeObject(response);
            var     buildstatusString = string.Format("{0}", jsonObject.status);
            var     buildStatus       = (BuildStatus)Enum.Parse(typeof(BuildStatus), buildstatusString, true);

            return(new BuildResult {
                Name = jsonObject.buildNumber, Status = buildStatus, RequestedBy = jsonObject.lastChangedBy.displayName, TfsUri = jsonObject.uri
            });
        }
Пример #26
0
        private void ctor()
        {
            foreach (var action in GetActions())
            {
                m_Actions.Register(action);
            }

            var assembly = this.GetType().Assembly;

            try
            {
                var bi = new BuildInformation(assembly);
                m_LastModifiedDate = bi.DateStampUTC.DateTimeToHTTPCookieDateTime();
            }
            catch (Exception err)
            {
                //no build info
                WriteLog(Log.MessageType.Warning, "ctor", "Assembly '{0}' has no BUILD_INFO".Args(assembly.FullName), error:  err);
                m_LastModifiedDate = App.TimeSource.UTCNow.DateTimeToHTTPCookieDateTime();
            }
        }
Пример #27
0
        public override string Execute()
        {
            var result = new StringBuilder(0xff);

            result.AppendLine("Server Version/Build information:");
            result.AppendLine(" App:       [{0}] {1}".Args(App.AppId.IsZero ? "#" : App.AppId.Value, App.Name));
            result.AppendLine(" Azos Core: " + BuildInformation.ForFramework);
            result.AppendLine(" Azos Sky:  " + new BuildInformation(typeof(Azos.Sky.SkySystem).Assembly));

            string host = "n/a";

            try
            {
                host = new BuildInformation(Assembly.GetEntryAssembly()).ToString();
            }
            catch { }

            result.AppendLine(" Host:      " + host);

            return(result.ToString());
        }
Пример #28
0
        /// <summary>
        /// Gets all type declarations made in the current codebase that is being compiled.
        /// This is a tool method to be used in more complex achievements.
        /// This method is caching and can be called without discretion, and is thread safe.
        /// </summary>
        /// <param name="buildInformation">BuildInformation object used to locate the codebase</param>
        /// <returns>Cached collection of TypeDeclarationInfo</returns>
        public IEnumerable <TypeDeclarationInfo> GetCodebaseTypeDeclarations(BuildInformation buildInformation)
        {
            lock (codebaseTypeDefinitionPadLock)
            {
                if (codebaseTypeDefinitions == null)
                {
                    codebaseTypeDefinitions = new List <TypeDeclarationInfo>();

                    foreach (var filename in buildInformation.CodeFiles)
                    {
                        var parser = GetParser(filename);
                        var typeDeclarationInfoVisitor = new TypeDeclarationVisitor();
                        parser.CompilationUnit.AcceptVisitor(typeDeclarationInfoVisitor, null);

                        codebaseTypeDefinitions.AddRange(typeDeclarationInfoVisitor.TypeDeclarations);
                    }
                }

                return(codebaseTypeDefinitions);
            }
        }
Пример #29
0
        private void serveSite(WorkContext work, string sitePath)
        {
            if (sitePath.IsNullOrWhiteSpace())
            {
                sitePath = DefaultSitePath;
            }

            var assembly = this.GetType().Assembly;

            //Cut the surrogate out of path, i.e. '/static/img/@@767868768768/picture.png' -> '/static/img/picture.png'
            sitePath = FileDownloadHandler.CutVersionSegment(sitePath, m_VersionSegmentPrefix);

            var resName = getResourcePath(sitePath);

            var bi           = new BuildInformation(assembly);
            var lastModified = bi.DateStampUTC.DateTimeToHTTPCookieDateTime();

            var ifModifiedSince = work.Request.Headers[SysConsts.HEADER_IF_MODIFIED_SINCE];

            if (ifModifiedSince.IsNotNullOrWhiteSpace() && lastModified.EqualsOrdIgnoreCase(ifModifiedSince))
            {
                SetResourceCacheHeader(work, sitePath, resName);
                work.Response.Redirect(null, WebConsts.RedirectCode.NotModified_304);
                return;
            }
            using (var stream = assembly.GetManifestResourceStream(resName))
                if (stream != null)
                {
                    work.Response.Headers.Set(HttpResponseHeader.LastModified, lastModified);
                    SetResourceCacheHeader(work, sitePath, resName);
                    work.Response.ContentType = mapContentType(resName);

                    stream.Seek(0, SeekOrigin.Begin);
                    work.Response.WriteStream(stream);
                }
                else
                {
                    throw new HTTPStatusException(WebConsts.STATUS_404, WebConsts.STATUS_404_DESCRIPTION, StringConsts.NOT_FOUND_ERROR + resName);
                }
        }
Пример #30
0
        public bool Execute(string workingDirectory, Mapping mapToRun, BuildInformation buildInfo)
        {
            _scriptRun = Path.Combine(workingDirectory, mapToRun.Script);

            if (!File.Exists(_scriptRun))
            {
                TraceHelper.TraceWarning(TraceSwitches.TfsDeployer, "BatchRunner - Could not find script: {0}", _scriptRun);
                _commandOutput = string.Format("BatchRunner - Could not find script: {0}", _scriptRun);
                _errorOccurred = true;
            }
            else
            {
                // Create the ProcessInfo object
                ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(_scriptRun);
                psi.UseShellExecute        = false;
                psi.RedirectStandardOutput = true;
                psi.RedirectStandardInput  = true;
                psi.RedirectStandardError  = true;
                psi.WorkingDirectory       = workingDirectory;
                psi.Arguments = CreateArguments(mapToRun, buildInfo.Data);

                TraceHelper.TraceInformation(TraceSwitches.TfsDeployer, "BatchRunner - Executing Scripts: {0} with arguments {1} in working directory {2}", _scriptRun, psi.Arguments, psi.WorkingDirectory);

                // Start the process
                Process proc = Process.Start(psi);
                using (StreamReader sOut = proc.StandardOutput)
                {
                    proc.WaitForExit();
                    // Read the sOut to a string.
                    _commandOutput = sOut.ReadToEnd().Trim();
                    TraceHelper.TraceInformation(TraceSwitches.TfsDeployer, "BatchRunner - Output From Command: {0}", _commandOutput);
                }

                _errorOccurred = false;
            }

            return(!_errorOccurred);
        }