Ejemplo n.º 1
0
        private void CheckOutInObject(DataAccess.IVersionControlled checkOutObject, bool trueCheckOut_falseCheckIn)
        {
            DataAccess.IVersionControlled domainObject = null;
            domainObject = checkOutObject;

            if (typeof(DataAccess.IVersionControlled).IsAssignableFrom(domainObject.GetType()))
            {
                if (trueCheckOut_falseCheckIn)
                {
                    try
                    {
                        MetaManagerServices.GetConfigurationManagementService().CheckOutDomainObject(domainObject.Id, domainObject.GetType());
                    }
                    catch (ConfigurationManagementException ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                else
                {
                    try
                    {
                        Cursor.Current = Cursors.WaitCursor;
                        MetaManagerServices.GetConfigurationManagementService().CheckInDomainObject(domainObject.Id, domainObject.GetType(), FrontendApplication);
                        Cursor.Current = Cursors.Default;
                    }
                    catch (ConfigurationManagementException ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }
        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 CheckIn(DataAccess.IVersionControlled domainObject, string fullPath)
 {
     if (_isAtomicCheckInEnabled)
     {
         _pendingCheckIns.Add(domainObject, fullPath.ToLower());
     }
     else
     {
         ExecuteCheckin(new string[1] {
             fullPath
         });
     }
 }
Ejemplo n.º 4
0
        private void CheckOutInObject(DataAccess.IVersionControlled checkOutObject, bool trueCheckOut_falseCheckIn, Application backendApplication)
        {
            DataAccess.IVersionControlled domainObject = null;
            domainObject = checkOutObject;

            if (typeof(DataAccess.IVersionControlled).IsAssignableFrom(domainObject.GetType()))
            {
                if (trueCheckOut_falseCheckIn)
                {
                    MetaManagerServices.GetConfigurationManagementService().CheckOutDomainObject(domainObject.Id, domainObject.GetType());
                }
                else
                {
                    MetaManagerServices.GetConfigurationManagementService().CheckInDomainObject(domainObject.Id, domainObject.GetType(), backendApplication);
                }
            }
        }
        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);
        }
Ejemplo n.º 6
0
        private void DoDeleteCustomDialog()
        {
            if (SelectedDialog != null)
            {
                DataAccess.IVersionControlled domainObject = SelectedDialog;

                domainObject = (DataAccess.IVersionControlled)modelService.GetInitializedDomainObject(domainObject.Id, modelService.GetDomainObjectType(domainObject));

                if (domainObject.IsLocked && domainObject.LockedBy == Environment.UserName)
                {
                    try
                    {
                        Cursor.Current = Cursors.WaitCursor;
                        modelService.DeleteDomainObject(domainObject);
                        ReadFromDBAndShowList();
                        Cursor.Current = Cursors.Default;
                    }
                    catch (Exception ex)
                    {
                        Cursor.Current = Cursors.Default;
                        string mess = ex.Message;

                        if (ex is ModelAggregatedException)
                        {
                            string ids = string.Empty;
                            foreach (string id in ((ModelAggregatedException)ex).Ids)
                            {
                                ids += id + "\r\n";
                            }

                            Clipboard.SetText(ids);
                            mess += "\r\n\r\nThe Ids has been copied to the clipboard";
                        }

                        MessageBox.Show(mess);
                    }
                }
            }
        }
        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 importBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (ResultlistView.CheckedItems.Count > 0)
                {
                    Cursor = Cursors.WaitCursor;
                    addFilesBtn.Enabled       = false;
                    StatusprogressBar.Maximum = ResultlistView.CheckedItems.Count * 2;
                    StatusprogressBar.Minimum = 0;
                    StatusprogressBar.Value   = 0;
                    Boolean stopped = false;

                    foreach (ListViewItem item in ResultlistView.CheckedItems)
                    {
                        AddToProgressText("\nCotrolls if the object is available: " + item.SubItems[0].Text);
                        System.Windows.Forms.Application.DoEvents();

                        Type classType = MetaManagerServices.GetConfigurationManagementService().GetClassTypeAndIdForXML(item.SubItems[0].Text).Key;
                        Guid id        = MetaManagerServices.GetConfigurationManagementService().GetClassTypeAndIdForXML(item.SubItems[0].Text).Value;

                        DataAccess.IVersionControlled readDomainObjectfromDB = ((DataAccess.IVersionControlled)modelService.GetDomainObject(id, classType));


                        if (readDomainObjectfromDB != null)
                        {
                            if (readDomainObjectfromDB.IsLocked && readDomainObjectfromDB.LockedBy != Environment.UserName)
                            {
                                MessageBox.Show("The selected object " + item.SubItems[0].Text + "is checked out by another user it is not possible import this");
                                AddToProgressText("\nImport stopped. The selected object " + item.SubItems[0].Text + "is checked out by another user. It is not possible import this.\n");
                                stopped = true;
                            }
                            if (stopped)
                            {
                                break;
                            }

                            StatusprogressBar.Value++;
                            System.Windows.Forms.Application.DoEvents();
                        }
                    }

                    if (stopped)
                    {
                        return;
                    }

                    List <string> existingObjectsPaths = new List <string>();
                    List <string> newObjectsPaths      = new List <string>();


                    foreach (ListViewItem item in ResultlistView.CheckedItems)
                    {
                        Type classType = MetaManagerServices.GetConfigurationManagementService().GetClassTypeAndIdForXML(item.SubItems[0].Text).Key;
                        Guid id        = MetaManagerServices.GetConfigurationManagementService().GetClassTypeAndIdForXML(item.SubItems[0].Text).Value;

                        DataAccess.IVersionControlled readDomainObjectfromDB = ((DataAccess.IVersionControlled)modelService.GetDomainObject(id, classType));


                        if (readDomainObjectfromDB != null)
                        {
                            //Existing object
                            AddToProgressText("\nCheck out the object: " + item.SubItems[0].Text);
                            System.Windows.Forms.Application.DoEvents();

                            try
                            {
                                MetaManagerServices.GetConfigurationManagementService().CheckOutDomainObject(readDomainObjectfromDB.Id, readDomainObjectfromDB.GetType());
                            }

                            catch (ConfigurationManagementException ex)
                            {
                                MessageBox.Show(ex.Message);
                                AddToProgressText("\nImport stopped. The selected object " + item.SubItems[0].Text + "is checked out by another user. It is not possible import this.\n");
                                stopped = true;
                            }
                            if (stopped)
                            {
                                break;
                            }
                            AddToProgressText("\nChecked out the selected object " + item.SubItems[0].Text);

                            existingObjectsPaths.Add(item.SubItems[0].Text);
                        }
                        else
                        {
                            //New object
                            AddToProgressText("\nFound new object: " + item.SubItems[0].Text);
                            System.Windows.Forms.Application.DoEvents();
                            newObjectsPaths.Add(item.SubItems[0].Text);
                        }

                        StatusprogressBar.Value++;
                        System.Windows.Forms.Application.DoEvents();
                    }

                    if (stopped == false)
                    {
                        List <string>[] pathLists = new List <string> [2];

                        pathLists[0] = newObjectsPaths;
                        pathLists[1] = existingObjectsPaths;

                        System.Threading.ThreadPool.QueueUserWorkItem(ThreadWork, pathLists);
                    }
                }
            }

            catch (BusinessLogic.ConfigurationManagementException ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Cursor = Cursors.Default;
                addFilesBtn.Enabled = true;
            }
        }