public async Task <IActionResult> Post()
        {
            string jsonData;

            using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8))
            {
                jsonData = await reader.ReadToEndAsync();

                _logger.LogInformation($"Azure DevOps JSON data: {jsonData}");

                try
                {
                    BuildNotification buildNotification = ParseBuildNotificationJsonData(jsonData);
                    _repository.Add(buildNotification);

                    // Push via SignalR
                    await _hubContext.Clients.All.SendAsync("BuildCompleted", buildNotification);
                }
                catch (Exception ex)
                {
                    _logger.LogError($"Exception parsing JSON: {ex.Message}");
                }
            }

            return(Ok());
        }
Пример #2
0
 string CalcBalloonMessage(string projectName, BuildNotification bn)
 {
     if (IsServiceUser)
     {
         var bytes = Convert.FromBase64String(bn.Sender);
         return(Encoding.UTF8.GetString(bytes));
     }
     return($"{projectName} - {(bn.BuildChangeStatus == BuildChangeStatus.None ? bn.BuildStatus.ToString() : bn.BuildChangeStatus.ToString())}");
 }
Пример #3
0
 void ShowBalloonTip(string message, bool failState, BuildNotification singleNotification)
 {
     //notifyIcon.Tag = singleNotification;
     //notifyIcon.ShowBalloonTip(balloonShowTimeout, string.Empty, message, failState ? ToolTipIcon.Error : ToolTipIcon.Info);
     //notifyIcon.Visible = true;
     //if (!Active) {
     //    StartTrayNotificationAnimation();
     //}
 }
Пример #4
0
 public BuildNotificationViewInfo(BuildNotification notification)
 {
     this.notification = notification;
     read = false;
 }
Пример #5
0
 public BuildNotificationViewInfo(BuildNotification notification)
 {
     this.notification = notification;
     read = false;
 }
Пример #6
0
 public NotificationReceivedEventArgs(BuildNotification buildNotification)
 {
     this.buildNotification = buildNotification;
 }
 public async Task PushNotificationAsync(BuildNotification buildNotification)
 {
     await Clients.All.SendAsync("BuildCompleted", buildNotification);
 }
Пример #8
0
        public static void LoadConfiguration()
        {
            string fullFileName = Path.Combine(Assembly.GetExecutingAssembly().Location, fileName);

            if (!LocalConfig)
            {
                fullFileName = Path.Combine(GetLocalStoragePath(), fileName);
            }
            if (File.Exists(fullFileName))
            {
                try {
                    XmlDocument doc = new XmlDocument();
                    doc.Load(fullFileName);
                    LoadFarmList(doc);
                    buildNotifications.Clear();
                    foreach (XmlNode node in doc.GetElementsByTagName("buildNotifications"))
                    {
                        if (node != null)
                        {
                            foreach (XmlNode bnNode in node.ChildNodes)
                            {
                                BuildNotification         bn   = (BuildNotification)SmartCCNetHelper.GetSerializedObject(bnNode.InnerText);
                                BuildNotificationViewInfo bnvi = new BuildNotificationViewInfo(bn);
                                bnvi.Read = true;
                                buildNotifications.Add(bnvi);
                            }
                        }
                    }
                    trackedProjects.Clear();
                    foreach (XmlNode node in doc.GetElementsByTagName("trackedProject"))
                    {
                        if (node.ParentNode != null && node.ParentNode.Name == "trackedProjects")
                        {
                            ProjectShortInfo info = new ProjectShortInfo();
                            foreach (XmlAttribute attr in node.Attributes)
                            {
                                switch (attr.Name)
                                {
                                case "name":
                                    info.Name = attr.Value;
                                    break;

                                case "status":
                                    info.BuildStatus = attr.Value;
                                    break;
                                }
                            }
                            trackedProjects.Add(info);
                        }
                    }
                    powerShellScripts.Clear();
                    foreach (XmlNode node in doc.GetElementsByTagName("PowerShellScript"))
                    {
                        if (node != null)
                        {
                            foreach (XmlNode scriptNode in node.ChildNodes)
                            {
                                PSScript script = (PSScript)SmartCCNetHelper.GetSerializedObject(scriptNode.InnerText);
                                powerShellScripts.Add(script);
                            }
                        }
                    }
                    UsePowerShellScript = LoadBoolean(doc, "UsePowerShellScript", false);
                    LoadLayoutAndGrid(doc);
                    gridNotificationsXml = LoadString(doc, "gridNotificationsXml", string.Empty);
                    alwaysOnTop          = LoadBoolean(doc, "alwaysOnTop", defaultAlwaysOnTop);
                    minimized            = LoadBoolean(doc, "minimized", defaultMinimized);
                    formWidth            = LoadInt(doc, "formWidth", defaultFormWidth);
                    formHeight           = LoadInt(doc, "formHeight", defaultFormHeight);
                    formLeft             = LoadInt(doc, "formLeft", defaultFormLeft);
                    formTop     = LoadInt(doc, "formTop", defaultFormTop);
                    refreshTime = LoadInt(doc, "refreshTime", defaultRefreshTime);
                    LoadUpdateUrl(doc);
                    workUserName = LoadString(doc, "workUserName", string.Empty);
                    if (string.IsNullOrEmpty(workUserName))
                    {
                        workUserName = defaultUserName;
                    }
                    useSkin                      = LoadBoolean(doc, "useSkin", defaultUseSkin);
                    needAskForStutup             = LoadBoolean(doc, "needAskForStutup", true);
                    alreadyReloadGridTestsLayout = LoadBoolean(doc, "alreadyReloadGridTestsLayout", defaultAlreadyReloadGridTestsLayout);
                    skinName                     = LoadString(doc, "skinName", defaultSkinName);
                    popupHideTimeout             = LoadInt(doc, "popupHideTimeout", defaultPopupHideTimeout);
                    string tempString;
                    if (TryLoadString(doc, "volunteerColorString", out tempString))
                    {
                        VolunteerColorString = tempString;
                    }
                    else
                    {
                        LoadDefaultVolunteerColors();
                    }
                    byte[] lastProjectDurationDictionaryData = LoadBase64(doc, "lastProjectDurationDictionary", null);
                    ProjectInfo.LoadLastBuildDurationDict(lastProjectDurationDictionaryData);
                } catch (Exception exc) {
                    Log.Error("exception", exc);
                    LoadDefaultConfiguration();
                }
            }
            else
            {
                LoadDefaultConfiguration();
            }
            DXCCTrayConfiguration.CanSetConfig = false;
        }
Пример #9
0
        private void DrawWarnings()
        {
            int warningCount   = 0;
            int clearableCount = 0;

            for (int i = 0; i < BuildNotificationList.instance.warnings.Count; i++)
            {
                BuildNotification notification = BuildNotificationList.instance.warnings[i];

                if (notification.valid == null || notification.valid())
                {
                    ++warningCount;
                }
                if (notification.clearable)
                {
                    ++clearableCount;
                }
            }

            if (warningCount == 0)
            {
                return;
            }

            Color defaultBackgroundColor = GUI.backgroundColor;

            EditorGUILayout.BeginHorizontal();
            GUI.backgroundColor = Color.yellow;
            UnityBuildGUIUtility.DropdownHeader(
                "Warnings (" + warningCount + ")",
                ref show, true,
                GUILayout.ExpandWidth(true));

            if (clearableCount > 0)
            {
                if (GUILayout.Button(clearButtonContent, UnityBuildGUIUtility.helpButtonStyle))
                {
                    BuildNotificationList.instance.RefreshWarnings();
                }
            }

            GUI.backgroundColor = defaultBackgroundColor;
            EditorGUILayout.EndHorizontal();

            if (show)
            {
                EditorGUILayout.BeginVertical(UnityBuildGUIUtility.dropdownContentStyle);

                for (int i = 0; i < BuildNotificationList.instance.warnings.Count; i++)
                {
                    BuildNotification notification = BuildNotificationList.instance.warnings[i];

                    if (notification.valid == null || notification.valid())
                    {
                        EditorGUILayout.HelpBox(notification.title + "\n" + notification.details, MessageType.Warning);
                    }
                }

                EditorGUILayout.EndVertical();
            }
        }