private void checkinButton_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; System.Windows.Forms.Application.DoEvents(); IList <IVersionControlled> selectedObjects = new List <IVersionControlled>(); foreach (ListViewItem item in resultListView.CheckedItems) { IVersionControlled domainObject = ((KeyValuePair <IVersionControlled, DataAccess.Domain.Application>)item.Tag).Key; if (GetChildFormsForDomainObject(domainObject).Count > 0) { MessageBox.Show("You must close all windows handling the " + _modelService.GetDomainObjectType(domainObject).Name + " before checking in.", System.Windows.Forms.Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } foreach (ListViewItem item in resultListView.CheckedItems) { IVersionControlled domainObject = ((KeyValuePair <IVersionControlled, DataAccess.Domain.Application>)item.Tag).Key; selectedObjects.Add(domainObject); } MetaManagerServices.GetConfigurationManagementService().CheckInDomainObjects(selectedObjects); } } catch (Exception ex) { progressBar.Value = 0; AddToProgressText("Check in failed."); AddToProgressText(ex.ToString()); } finally { Cursor = Cursors.Default; searchButton.Enabled = true; searchButton_Click(sender, e); } }
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); } }
public void RemoveMappedProperty(MappedProperty mappedProperty) { mappedProperty = ModelService.GetDomainObject <MappedProperty>(mappedProperty.Id); PropertyMap map = new PropertyMap(); map.Id = mappedProperty.PropertyMap.Id; map.IsCollection = mappedProperty.PropertyMap.IsCollection; map.MappedProperties = new List <MappedProperty>(mappedProperty.PropertyMap.MappedProperties); map.MappedProperties.Remove(mappedProperty); List <IDomainObject> mpToDelete = new List <IDomainObject>(); mpToDelete.Add(mappedProperty); ModelService.SynchronizePropertyMapChain(map, mpToDelete); Dictionary <string, object> criteria = new Dictionary <string, object>(); criteria.Add("RequestMappedProperty.Id", mappedProperty.Id); IList <MappedProperty> requestMappedProperties = ModelService.GetAllDomainObjectsByPropertyValues <MappedProperty>(criteria); foreach (MappedProperty refObj in requestMappedProperties) { List <IDomainObject> parents; IVersionControlled vcParent = refObj as IVersionControlled; if (vcParent == null) { vcParent = ModelService.GetVersionControlledParent(refObj, out parents).First(); } ConfigurationManagementService.CheckOutDomainObject(vcParent.Id, ModelService.GetDomainObjectType(vcParent)); refObj.RequestMappedProperty = null; ModelService.SaveDomainObject(refObj); } mappedProperty.PropertyMap = null; ModelService.MergeSaveDomainObject(map); }
private void FindDependencies(IDomainObject currentObject, IDomainObject child, bool halt = false) { if (abort || currentObject == null) { return; } if (graph.ContainsVertex(currentObject)) { if (child != null) { graph.AddEdge(new Edge <IDomainObject>(currentObject, child)); } return; } statusLabel.Invoke(new System.Action(() => { statusLabel.Text = string.Format("Analyzing {0}...", currentObject.ToString()); })); NHibernateUtil.Initialize(currentObject); graph.AddVertex(currentObject); if (child != null) { graph.AddEdge(new Edge <IDomainObject>(currentObject, child)); } if (currentObject is Cdc.MetaManager.DataAccess.Domain.Application || halt) { return; } List <IDomainObject> list = modelService.GetReferencingObjects(currentObject) as List <IDomainObject>; if (currentObject is ServiceMethod || (currentObject is Dialog && ((Dialog)currentObject).Type == DialogType.Find)) { statusLabel.Invoke(new System.Action(() => { statusLabel.Text = string.Format("Finding XML references for {0}...", currentObject.ToString()); })); string query = "select v from View v where v.VisualTreeXml like '%" + currentObject.Id + "%'"; IList <IDomainObject> xmlReferences = modelService.GetDomainObjectsByQuery <IDomainObject>(query); list.AddRange(xmlReferences); } IList <IVersionControlled> vcParents = new List <IVersionControlled>(); foreach (IDomainObject domainObject in list) { halt = false; ViewAction vc = domainObject as ViewAction; if (vc != null && vc.Type == ViewActionType.JumpTo) { halt = true; } IVersionControlled vcObject = domainObject as IVersionControlled; if (vcObject == null) { List <IDomainObject> allParents; vcObject = modelService.GetVersionControlledParent(domainObject, out allParents).LastOrDefault(); } if (!vcParents.Contains(vcObject)) { vcParents.Add(vcObject); FindDependencies(vcObject, currentObject, halt); } } }
private bool GetLatestStateFromConfigurationManagement(object entity, object[] state, string[] propertyNames) { bool?appFrontend = false; Type classType; Domain.Application application; classType = NHibernate.Proxy.NHibernateProxyHelper.GetClassWithoutInitializingProxy(entity); if (typeof(IVersionControlled).IsAssignableFrom(classType)) { if (((bool)state[propertyNames.ToList().IndexOf("IsLocked")]) && ((string)state[propertyNames.ToList().IndexOf("LockedBy")]) != Environment.UserName) { IVersionControlled dbobject = (IVersionControlled)GetObjectFromState(classType, state, propertyNames); dbobject.Id = ((IVersionControlled)entity).Id; application = GetApplicationForDomainObject(dbobject); appFrontend = application.IsFrontend.Value; if (appFrontend == null) { return(false); } Spring.Context.IApplicationContext ctx = Spring.Context.Support.ContextRegistry.GetContext(); NHibernate.ISessionFactory sessionFactory = ((NHibernate.ISessionFactory)ctx["SessionFactory"]); NHibernate.ISession session = Spring.Data.NHibernate.SessionFactoryUtils.GetSession(sessionFactory, false); 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 + (appFrontend.Value ? "_Frontend" : "_Backend")); string filePath = System.IO.Path.Combine(parentPath, classType.Name); string fileName = ((IVersionControlled)dbobject).RepositoryFileName + ".xml"; string fullPath = System.IO.Path.Combine(filePath, fileName); System.IO.FileInfo fi = new System.IO.FileInfo(fullPath); if (fi.Exists) { System.Xml.Serialization.XmlSerializer xmlSerie = new System.Xml.Serialization.XmlSerializer(classType); System.Xml.XmlReader reader = System.Xml.XmlReader.Create(new System.IO.StringReader(fi.OpenText().ReadToEnd())); DataAccess.DomainXmlSerializationHelper.VisualComponentRefObjects.Clear(); object domainObject = xmlSerie.Deserialize(reader); foreach (IDomainObject obj in DataAccess.DomainXmlSerializationHelper.VisualComponentRefObjects) { session.Merge(obj); } ((IVersionControlled)domainObject).IsLocked = true; ((IVersionControlled)domainObject).LockedBy = dbobject.LockedBy; ((IVersionControlled)domainObject).LockedDate = dbobject.LockedDate; ((IDomainObject)domainObject).IsTransient = false; SetStateFromObject(domainObject, classType, state, propertyNames); return(true); } } } return(true); }