Example #1
0
 protected void integrator_OnNotificationListChanged(DXCCTrayIntegrator integrator)
 {
     lock (integrator.Notifications) {
         foreach (BuildNotification bn in integrator.Notifications)
         {
             bool bnExists = false;
             lock (buildNotifications) {
                 foreach (BuildNotificationViewInfo bnOld in buildNotifications)
                 {
                     if (bnOld.Notification.BuildUrl == bn.BuildUrl && bnOld.Notification.CreateTime == bn.CreateTime)
                     {
                         bnExists = true;
                         break;
                     }
                 }
             }
             if (bnExists)
             {
                 continue;
             }
             buildNotifications.Insert(0, new BuildNotificationViewInfo(bn));
             RaiseRefreshed(new NotificationReceivedEventArgs(bn));
         }
         integrator.Notifications.Clear();
     }
     lock (buildNotifications) {
         while (buildNotifications.Count > NotificationsMaxCount)
         {
             buildNotifications.RemoveAt(NotificationsMaxCount);
         }
     }
 }
Example #2
0
        private void UpdateCurrentSubProjects(DXCCTrayIntegrator integrator)
        {
            if (skipUpdateControllerProjects.SkipUpdate())
            {
                return;
            }
            Dictionary <ProjectTagI, List <ProjectI> > currentChilds = new Dictionary <ProjectTagI, List <ProjectI> >();

            foreach (ProjectInfo info in integrator.ProjectList)
            {
                ProjectI row;
                if (projectDict.TryGetValue(new ProjectKey(integrator.Name, info.Name), out row))
                {
                    ProjectI parentRow;
                    if (!string.IsNullOrEmpty(row.forcer) && projectDict.TryGetValue(new ProjectKey(integrator.Name, row.forcer), out parentRow) && parentRow.projectChilds.Count == 0)
                    {
                        if (!currentChilds.ContainsKey(parentRow))
                        {
                            currentChilds[parentRow] = new List <ProjectI>();
                        }
                        currentChilds[parentRow].Add(row);
                    }
                }
            }
            foreach (ProjectInfo info in integrator.ProjectList)
            {
                ProjectI parentRow;
                if (projectDict.TryGetValue(new ProjectKey(integrator.Name, info.Name), out parentRow))
                {
                    if (!currentChilds.ContainsKey(parentRow))
                    {
                        if (parentRow.currentProjectChilds.Count > 0)
                        {
                            parentRow.currentProjectChilds.Clear();
                            CollapsDetail(parentRow.farm, parentRow.name);
                        }
                    }
                    else
                    {
                        for (int i = 0; i < parentRow.currentProjectChilds.Count; i++)
                        {
                            if (!currentChilds[parentRow].Contains(parentRow.currentProjectChilds[i]))
                            {
                                parentRow.currentProjectChilds.RemoveAt(i--);
                            }
                        }
                        for (int i = 0; i < currentChilds[parentRow].Count; i++)
                        {
                            if (!parentRow.currentProjectChilds.Contains(currentChilds[parentRow][i]))
                            {
                                parentRow.currentProjectChilds.Insert(0, currentChilds[parentRow][i]);
                                currentChilds[parentRow][i].Parent = parentRow;
                                i++;
                            }
                        }
                    }
                }
            }
        }
Example #3
0
 private bool UpdateRemainedServerTime(ServerInfo newInfo, ServerI row, DXCCTrayIntegrator integrator)
 {
     //if (IsServerForUser(row) && newInfo.RemainedTime > 0) {
     //    row.Details = String.Format("Remained {0} min", newInfo.RemainedTime);
     //    if (newInfo.Creator.Equals(DXCCTrayConfiguration.WorkUserName, StringComparison.InvariantCultureIgnoreCase) && newInfo.RemainedTime < minimumRemainedTime && row.Remained > 0 && row.Remained == minimumRemainedTime) {
     //        row.Remained = newInfo.RemainedTime;
     //        if (XtraMessageBox.Show(String.Format("Do you want to prolong server \"{0}\" for 1 hour?", row.Server), "DXCCTray", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) {
     //            integrator.UpdateServerTime(row.Server, 60);
     //        }
     //    }
     //    return true;
     //}
     return(false);
 }
Example #4
0
 void integrator_OnProjectDetailsAndForcerUpdated(DXCCTrayIntegrator integrator)
 {
     try {
         UpdateProjectsDetails(integrator);
         UpdateForcers(integrator);
         UpdateCurrentSubProjects(integrator);
         SinchronizeProjectTagsTable();
         //gridControlProjects.RefreshDataSource();
         //projectTable.FireChanged();
         //projectTagTable.FireChanged();
     }
     catch (Exception ex) {
         Log.Error("error", ex);
         throw;
     }
 }
Example #5
0
        private void UpdateProjectsDetails(DXCCTrayIntegrator integrator)
        {
            object updated = new object();

            foreach (ProjectInfo info in integrator.ProjectList)
            {
                ProjectI row;
                if (projectDict.TryGetValue(new ProjectKey(integrator.Name, info.Name), out row))
                {
                    row.details = info.Details;
                    ServerI serverRow;
                    if (serverDict.TryGetValue(new ProjectKey(row.farm, row.server), out serverRow))
                    {
                        if (string.IsNullOrEmpty(row.details))
                        {
                            serverRow.Details = row.activity;
                        }
                        else
                        {
                            serverRow.Details = row.details;
                        }
                        serverRow.Update = updated;
                    }
                }
            }
            lock (integrator.ServerList) {
                foreach (ServerI serverRow in serverTable)
                {
                    foreach (ServerInfo newInfo in integrator.ServerList)
                    {
                        if (newInfo.Name == serverRow.Server)
                        {
                            if (UpdateRemainedServerTime(newInfo, serverRow, integrator))
                            {
                                serverRow.Update   = updated;
                                serverRow.Remained = newInfo.RemainedTime;
                            }
                        }
                    }
                    if (serverRow.Farm == integrator.Name && serverRow.Update != updated)
                    {
                        serverRow.Details = string.Empty;
                    }
                }
            }
        }
Example #6
0
        private void Integrator_OnChanged(DXCCTrayIntegrator sender, bool servers, bool projects, bool queue, bool notification)
        {
            UpdateDelegate update = delegate() {
                //ToolTipControlInfo tip = toolTipController.ActiveObjectInfo;
                if (servers)
                {
                    integrator_OnServersChanged(sender);
                }
                if (projects)
                {
                    integrator_OnProjectListChanged(sender);
                }
                if (queue)
                {
                }
                if (notification)
                {
                    integrator_OnNotificationListChanged(sender);
                }
                integrator_OnProjectDetailsAndForcerUpdated(sender);

                if (projects)
                {
                    RaiseRefreshed();
                }
                //if (tip != null) {
                //ToolTipControllerGetActiveObjectInfoEventArgs newArgs = new ToolTipControllerGetActiveObjectInfoEventArgs((Control)toolTipController.ActiveControlClient,
                //    null, null, ((Control)toolTipController.ActiveControlClient).PointToClient(Cursor.Position));
                //toolTipController_GetActiveObjectInfo(null, newArgs);
                //if (newArgs.Info != null && newArgs.Info.Object == tip.Object) {
                //    toolTipController.ShowHint((ToolTipControlInfo)null);
                //    toolTipController.ShowHint(newArgs.Info);
                //}
                //}
            };

            try {
                lock (this.syncLocker) {
                    update();
                }
            }
            catch {
            }
        }
Example #7
0
 private void UpdateForcers(DXCCTrayIntegrator integrator)
 {
     if (skipUpdateControllerProjects.SkipUpdate())
     {
         return;
     }
     foreach (ProjectInfo info in integrator.ProjectList)
     {
         ProjectI row;
         if (projectDict.TryGetValue(new ProjectKey(integrator.Name, info.Name), out row))
         {
             if (integrator.CCServerAdditionalInfo.ProjectForcer.ContainsKey(row.name))
             {
                 row.forcer = integrator.CCServerAdditionalInfo.ProjectForcer[row.name];
             }
             else
             {
                 row.forcer = string.Empty;
             }
         }
     }
 }
Example #8
0
 private void ReloadProjectChilds(DXCCTrayIntegrator integrator, List <ProjectI> projectsWithChildsToReload)
 {
     foreach (ProjectI parentProject in projectsWithChildsToReload)
     {
         ProjectInfo parentProjectInfo = null;
         foreach (ProjectInfo info in integrator.ProjectList)
         {
             if (info.Name == parentProject.name)
             {
                 parentProjectInfo = info;
                 break;
             }
         }
         List <ProjectI> projectsToAddToParentList = new List <ProjectI>(parentProject.projectChilds);
         parentProject.projectChilds.Clear();
         foreach (string childName in parentProjectInfo.ProjectsChilds)
         {
             ProjectI child;
             projectDict.TryGetValue(new ProjectKey(integrator.Name, childName), out child);
             if (projectsToAddToParentList.Contains(child))
             {
                 projectsToAddToParentList.Remove(child);
             }
             parentProject.projectChilds.Add(child);
             child.Parent = parentProject;
             projectTable.Remove(child);
         }
         foreach (ProjectI parentProjectToAdd in projectsToAddToParentList)
         {
             parentProjectToAdd.Parent = null;
             projectTable.Add(parentProjectToAdd);
         }
         if (parentProject.projectChilds.Count == 0)
         {
             CollapsDetail(parentProject.farm, parentProject.name);
         }
     }
 }
Example #9
0
 void integrator_OnProjectListChanged(DXCCTrayIntegrator integrator)
 {
     try {
         object          update = new object();
         List <ProjectI> projectsWithChildsToReload = new List <ProjectI>();
         foreach (ProjectInfo info in integrator.ProjectList)
         {
             ProjectI row;
             if (!projectDict.TryGetValue(new ProjectKey(integrator.Name, info.Name), out row))
             {
                 row      = new ProjectI();
                 row.name = info.Name;
                 ProjectTagCollection ptc = new ProjectTagCollection(info.Tags.ToArray());
                 row.tags = ptc;
                 row.tag  = info.TagsString;
                 projectTable.Add(row);
                 projectDict.Add(new ProjectKey(integrator.Name, info.Name), row);
             }
             else
             {
                 if (row.tag != info.TagsString)
                 {
                     ProjectTagCollection ptc = new ProjectTagCollection(info.Tags.ToArray());
                     row.tags = ptc;
                     row.tag  = info.TagsString;
                 }
             }
             row.farm                  = integrator.Name;
             row.server                = info.Server;
             row.activity              = info.Activity.ToString();
             row.queuename             = info.QueueName;
             row.weburl                = info.WebURL;
             row.buildstage            = info.BuildStage;
             row.buildstatus           = info.BuildStatus;
             row.status                = GetStatus(info.Status);
             row.lastbuilddate         = info.LastBuildDate;
             row.lastbuildlabel        = info.LastBuildLabel;
             row.nextbuildtime         = info.NextBuildTime;
             row.types                 = info.TypesString;
             row.IsBuildIfModification = info.IsBuildIfModification;
             if (row.projectChilds.Count == info.ProjectsChilds.Count)
             {
                 foreach (ProjectI child in row.projectChilds)
                 {
                     if (!info.ProjectsChilds.Contains(child.name))
                     {
                         projectsWithChildsToReload.Add(row);
                         break;
                     }
                 }
             }
             else
             {
                 projectsWithChildsToReload.Add(row);
             }
             row.Update = update;
         }
         ReloadProjectChilds(integrator, projectsWithChildsToReload);
         for (int i = 0; i < projectTable.Count; i++)
         {
             ProjectI row = projectTable[i];
             if (row.farm == integrator.Name && row.Update != update)
             {
                 projectDict.Remove(new ProjectKey(row.farm, row.name));
                 projectTable.RemoveAt(i);
                 i--;
             }
         }
     }
     catch (Exception ex) {
         Log.Error("error", ex);
         throw;
     }
 }
Example #10
0
 void integrator_OnServersChanged(DXCCTrayIntegrator integrator)
 {
     try {
         if (skipUpdateControllerServers.SkipUpdate())
         {
             return;
         }
         object update = new object();
         lock (integrator.ServerList) {
             foreach (ServerInfo newInfo in integrator.ServerList)
             {
                 ServerI row;
                 if (!serverDict.TryGetValue(new ProjectKey(integrator.Name, newInfo.Name), out row))
                 {
                     row        = new ServerI();
                     row.Farm   = integrator.Name;
                     row.Server = newInfo.Name;
                     serverTable.Add(row);
                     serverDict.Add(new ProjectKey(row.Farm, row.Server), row);
                 }
                 row.Farm    = integrator.Name;
                 row.Types   = new List <string>(newInfo.Types);
                 row.Running = newInfo.IsRunning;
                 row.Host    = newInfo.Host;
                 row.Vmid    = newInfo.VMID;
                 row.Status  = newInfo.Status;
                 //row.Project = (string.IsNullOrEmpty(newInfo.ProjectName)) ? newInfo.Creator == null ? "Free" : GetPersonalServerTitle(newInfo.Creator) : newInfo.ProjectName;
                 UpdateRemainedServerTime(newInfo, row, integrator);
                 row.Remained = newInfo.RemainedTime;
                 row.Update   = update;
                 //if (IsServerForUser(row)) {
                 //    CustomServerProcess(newInfo, integrator, newServer);
                 //}
                 row.Remained = newInfo.RemainedTime;
             }
         }
         for (int i = 0; i < serverTable.Count; i++)
         {
             ServerI row = serverTable[i];
             if (row.Farm == integrator.Name && row.Update != update)
             {
                 serverDict.Remove(new ProjectKey(row.Farm, row.Server));
                 serverTable.RemoveAt(i);
                 i--;
             }
         }
         //if (!focusedGroupped && serverTable.Contains(focusedRow)) {
         //    int focusedRowHandle = gridViewServers.GetRowHandle(serverTable.IndexOf(focusedRow));
         //    gridViewServers.FocusedRowHandle = focusedRowHandle;
         //}
         //gridViewServers.ClearSelection();
         //foreach (ServerI selected in selectedRows) {
         //    if (serverTable.Contains(selected)) {
         //        gridViewServers.SelectRow(gridViewServers.GetRowHandle(serverTable.IndexOf(selected)));
         //    }
         //}
     }
     catch (Exception ex) {
         Log.Error("error", ex);
         throw;
     }
 }