public bool RemoveFile(DataAccess.IVersionControlled domainObject, DataAccess.Domain.Application application, out string errorMessage) { string parentPath = System.IO.Path.Combine(_workspacePath, application.Name + (application.IsFrontend.Value ? "_Frontend" : "_Backend")); string filePath = System.IO.Path.Combine(parentPath, NHibernate.Proxy.NHibernateProxyHelper.GetClassWithoutInitializingProxy(domainObject).Name); string fileName = domainObject.RepositoryFileName + ".xml"; string fullPath = System.IO.Path.Combine(filePath, fileName); errorMessage = string.Empty; try { if (_versionControlServer.ServerItemExists(_workspace.GetServerItemForLocalItem(fullPath), ItemType.Any)) { _workspace.PendDelete(fullPath); CheckIn(domainObject, fullPath); return(true); } else { errorMessage = string.Format("File \"{0}\" is not under source control.", fullPath); return(false); } } catch (Exception ex) { errorMessage = ex.ToString(); return(false); } }
private void BackendApptextBox_DragDrop(object sender, DragEventArgs e) { DataAccess.Domain.Application draggedApp = ((DataAccess.Domain.Application)((ListViewItem)e.Data.GetData(typeof(ListViewItem))).Tag); BackendApptextBox.Text = draggedApp.Name; BackendApptextBox.Tag = draggedApp; if (DeployGrpNametextBox.Tag == null) { DeployGrpNametextBox.Tag = new DataAccess.Domain.DeploymentGroup(); } ((DataAccess.Domain.DeploymentGroup)DeployGrpNametextBox.Tag).BackendApplication = draggedApp; }
private void FrontendApptextBox_DragEnter(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(typeof(ListViewItem))) { if (typeof(DataAccess.Domain.Application).IsAssignableFrom(((ListViewItem)e.Data.GetData(typeof(ListViewItem))).Tag.GetType())) { DataAccess.Domain.Application draggedApp = ((DataAccess.Domain.Application)((ListViewItem)e.Data.GetData(typeof(ListViewItem))).Tag); if (draggedApp.IsFrontend.Value) { e.Effect = DragDropEffects.Move; } } } }
private void undoCheckoutButton_Click(object sender, EventArgs e) { try { progressTextBox.Text = ""; if (resultListView.CheckedItems.Count > 0) { Cursor = Cursors.WaitCursor; searchButton.Enabled = false; progressBar.Maximum = resultListView.CheckedItems.Count; progressBar.Minimum = 0; progressBar.Value = 0; foreach (ListViewItem item in resultListView.CheckedItems) { System.Windows.Forms.Application.DoEvents(); //Do check in IVersionControlled domainObject = ((KeyValuePair <IVersionControlled, DataAccess.Domain.Application>)item.Tag).Key; DataAccess.Domain.Application application = ((KeyValuePair <IVersionControlled, DataAccess.Domain.Application>)item.Tag).Value; AddToProgressText(string.Format("Undoing check out for \"{0}\".", domainObject.ToString())); MetaManagerServices.GetConfigurationManagementService().UndoCheckOutDomainObject(domainObject.Id, domainObject.GetType(), application); progressBar.Value++; System.Windows.Forms.Application.DoEvents(); } AddToProgressText("Undo check out completed successfully."); } } catch (Exception ex) { AddToProgressText("Undo check out failed."); AddToProgressText(ex.ToString()); } finally { Cursor = Cursors.Default; searchButton.Enabled = true; searchButton_Click(sender, e); } }
private DataAccess.Domain.Application GetApplicationForDomainObject(IDomainObject domainObject) { Type classType = NHibernate.Proxy.NHibernateProxyHelper.GetClassWithoutInitializingProxy(domainObject); if (domainObject is DataAccess.Domain.Application) { return((DataAccess.Domain.Application)domainObject); } List <System.Reflection.PropertyInfo> api = classType.GetProperties().Where(p => p.PropertyType == typeof(DataAccess.Domain.Application)).ToList(); if (api.Count() > 0) { return((DataAccess.Domain.Application)api[0].GetValue(domainObject, null)); } IEnumerable <System.Reflection.PropertyInfo> pis = classType.GetProperties().Where(p => typeof(IDomainObject).IsAssignableFrom(p.PropertyType)); DataAccess.Domain.Application parentApp = null; foreach (System.Reflection.PropertyInfo pi in pis) { if (pi.PropertyType.GetProperties().Where(p => p.PropertyType.IsGenericType && p.PropertyType.GetGenericTypeDefinition() == typeof(IList <>) && p.PropertyType.GetGenericArguments()[0] == classType).ToList().Count > 0) { IDomainObject parent = (IDomainObject)pi.GetValue(domainObject, null); object refObj = DomainXmlSerializationHelper.GetObjectFromRef(parent.Id, NHibernate.Proxy.NHibernateProxyHelper.GetClassWithoutInitializingProxy(parent)); if (refObj != null) { parent = (IDomainObject)refObj; } if (parent != null) { parentApp = GetApplicationForDomainObject(parent); } } if (parentApp != null) { return(parentApp); } } return(null); }
private void AddAppListItem(DataAccess.Domain.Application app) { ListViewItem newItem = new ListViewItem(); newItem.Text = app.Name; newItem.Tag = app; if (app.IsFrontend.Value) { newItem.SubItems.Add("X"); newItem.SubItems.Add(""); } else { newItem.SubItems.Add(""); newItem.SubItems.Add("X"); } allAppListView.Items.Add(newItem); }
public bool RemoveFile(DataAccess.IVersionControlled domainObject, DataAccess.Domain.Application application, out string errorMessage) { _checkInCount++; UpdateDeployInfo(_checkInCount, _totalCheckIns); System.Configuration.AppSettingsReader appReader = new System.Configuration.AppSettingsReader(); string rootPath = appReader.GetValue("RepositoryPath", typeof(System.String)).ToString(); string parentPath = System.IO.Path.Combine(rootPath, application.Name + (application.IsFrontend.Value ? "_Frontend" : "_Backend")); string filePath = System.IO.Path.Combine(parentPath, NHibernate.Proxy.NHibernateProxyHelper.GetClassWithoutInitializingProxy(domainObject).Name); string fileName = domainObject.RepositoryFileName + ".xml"; string fullPath = System.IO.Path.Combine(filePath, fileName); bool success = false; errorMessage = string.Empty; if (IsFileInClearCase(fullPath)) { errorMessage = ExecuteClearCaseCommand(ClearCaseCommands.CHECK_OUT, filePath).Error; if (string.IsNullOrEmpty(errorMessage)) { errorMessage = ExecuteClearCaseCommand(ClearCaseCommands.REMOVE_FILE, fullPath).Error; if (string.IsNullOrEmpty(errorMessage)) { errorMessage = ExecuteClearCaseCommandCheckin(ClearCaseCommands.CHECK_IN, filePath).Error; success = string.IsNullOrEmpty(errorMessage); } } } else { errorMessage = string.Format("File \"{0}\" is not under source control.", fullPath); } return(success); }
private void FrontendApptextBox_DragDrop(object sender, DragEventArgs e) { if (DeployGrpNametextBox.Text == FrontendApptextBox.Text) { DeployGrpNametextBox.Text = string.Empty; } DataAccess.Domain.Application draggedApp = ((DataAccess.Domain.Application)((ListViewItem)e.Data.GetData(typeof(ListViewItem))).Tag); if (FrontendApptextBox.Tag is DataAccess.Domain.Application) { if (((DataAccess.Domain.Application)FrontendApptextBox.Tag).Id != draggedApp.Id) { AddAppListItem(((DataAccess.Domain.Application)FrontendApptextBox.Tag)); } } FrontendApptextBox.Text = draggedApp.Name; FrontendApptextBox.Tag = draggedApp; if (DeployGrpNametextBox.Text == string.Empty) { DeployGrpNametextBox.Text = FrontendApptextBox.Text; } if (DeployGrpNametextBox.Tag == null) { DeployGrpNametextBox.Tag = new DataAccess.Domain.DeploymentGroup(); } ((DataAccess.Domain.DeploymentGroup)DeployGrpNametextBox.Tag).FrontendApplication = draggedApp; RemoveAppListItem(((ListViewItem)e.Data.GetData(typeof(ListViewItem)))); }
public bool CheckInFile(DataAccess.IVersionControlled domainObject, DataAccess.Domain.Application application, out string errorMessage) { _checkInCount++; UpdateDeployInfo(_checkInCount, _totalCheckIns); System.Configuration.AppSettingsReader appReader = new System.Configuration.AppSettingsReader(); string rootPath = appReader.GetValue("RepositoryPath", typeof(System.String)).ToString(); string parentPath = System.IO.Path.Combine(rootPath, application.Name + (application.IsFrontend.Value ? "_Frontend" : "_Backend")); string filePath = System.IO.Path.Combine(parentPath, NHibernate.Proxy.NHibernateProxyHelper.GetClassWithoutInitializingProxy(domainObject).Name); string fileName = domainObject.RepositoryFileName + ".xml"; string fullPath = System.IO.Path.Combine(filePath, fileName); bool success = false; errorMessage = string.Empty; if (IsFileInPrivateView(fullPath)) { errorMessage = ExecuteClearCaseCommand(ClearCaseCommands.CHECK_OUT, filePath).Error; if (string.IsNullOrEmpty(errorMessage)) { errorMessage = ExecuteClearCaseCommandCheckin(ClearCaseCommands.MAKE_ELEMENT, fullPath).Error; // As long as filesize is zero, sleep 100 ms. If sleeping, log this to file int n; FileInfo fi = new FileInfo(fullPath); for (n = 0; n < 100; n++) { if (fi.Length > 0) { break; } Thread.Sleep(100); // Logging this to file String uriPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\TmpLogfile.txt"; string localPath = new Uri(uriPath).LocalPath; using (StreamWriter sw = File.AppendText(localPath)) { sw.WriteLine(DateTime.Now.ToString() + ": CheckInFile(): Slept for 100 ms. n = " + n.ToString()); } } if (string.IsNullOrEmpty(errorMessage)) { errorMessage = ExecuteClearCaseCommandCheckin(ClearCaseCommands.CHECK_IN, filePath).Error; success = string.IsNullOrEmpty(errorMessage); } } } else if (IsFileInClearCase(fullPath)) { errorMessage = ExecuteClearCaseCommandCheckin(ClearCaseCommands.CHECK_IN, fullPath).Error; success = string.IsNullOrEmpty(errorMessage); } else { errorMessage = string.Format("File \"{0}\" is not under source control.", fullPath); } return(success); }
private void addObjectsToListView(Guid applicationId, string applicationName, DataAccess.Domain.Application application) { List <IVersionControlled> checkedOutObjectsList = new List <IVersionControlled>(); checkedOutObjectsList.Clear(); checkedOutObjectsList.AddRange(_modelService.GetAllVersionControlledObjectsInApplication(applicationId)); checkedOutObjectsList.RemoveAll(item => item == null); checkedOutObjectsList = checkedOutObjectsList.OrderBy(o => _modelService.GetDomainObjectType(o).Name).ToList(); if (checkedOutObjectsList != null && checkedOutObjectsList.Count > 0) { foreach (IVersionControlled vobj in checkedOutObjectsList) { if (vobj != null) { Boolean addToList = false; if (checkoutComboBox.SelectedItem.ToString() == "My" && vobj.IsLocked && vobj.LockedBy == Environment.UserName) { addToList = true; } if (checkoutComboBox.SelectedItem.ToString() == "All" && vobj.IsLocked) { addToList = true; } if (checkoutComboBox.SelectedItem.ToString() == "Users" && vobj.IsLocked && vobj.LockedBy == UserNameTextBox.Text) { addToList = true; } if (addToList) { ListViewItem item = null; IDomainObject theObject = null; theObject = _modelService.GetDomainObject(vobj.Id, _modelService.GetDomainObjectType(vobj)); Dictionary <string, System.Reflection.PropertyInfo> propertyDic = theObject.GetType().GetProperties().ToDictionary(o => o.Name.ToUpper(), o => o); item = resultListView.Items.Add(applicationName); item.SubItems.Add(_modelService.GetDomainObjectType(theObject).Name); item.SubItems.Add(theObject.Id.ToString()); if (propertyDic.ContainsKey("NAME") && propertyDic["NAME"].GetValue(theObject, null) != null) { item.SubItems.Add(propertyDic["NAME"].GetValue(theObject, null).ToString()); } else { item.SubItems.Add("<Noname>"); } item.SubItems.Add(vobj.LockedBy); if (vobj.State.ToString() == "New") { item.SubItems.Add("Yes"); } else { item.SubItems.Add("No"); } item.Tag = new KeyValuePair <IVersionControlled, DataAccess.Domain.Application>(vobj, application); } } } } }