Exemplo n.º 1
0
 public override void EditorShutdown()
 {
     if (_sourceControl != null)
     {
         _sourceControl.Dispose();
         _sourceControl = null;
     }
 }
Exemplo n.º 2
0
        public SourceControlComponent(GUIController guiController, AGSEditor agsEditor)
            : base(guiController, agsEditor)
        {
            _sourceControl = _agsEditor.SourceControlProvider;

            try
            {
                if (!_sourceControl.Initialize(_guiController.TopLevelWindowHandle))
                {
                    _guiController.ShowMessage("Your source code control provider '" + _sourceControl.ProviderName + "' failed to initialize.", MessageBoxIcon.Warning);
                }
                if (_sourceControl.Available)
                {
                    _menuCommands.Commands.Add(new MenuCommand(ADD_TO_SOURCE_CONTROL_COMMAND, "Add to source control"));
                    _guiController.AddMenuItems(this, _menuCommands);
                }
            }
            catch (Exception ex)
            {
                _guiController.ShowMessage("A serious error occurred attempting to connect to your source control provider. Please ensure that '" + _sourceControl.ProviderName + "' is properly installed.\n\nError details: " + ex.ToString(), MessageBoxIcon.Stop);
            }
        }
Exemplo n.º 3
0
        public SourceControlComponent(GUIController guiController, AGSEditor agsEditor)
            : base(guiController, agsEditor)
        {
            _sourceControl = _agsEditor.SourceControlProvider;

            try
            {
                if (!_sourceControl.Initialize(_guiController.TopLevelWindowHandle))
                {
                    _guiController.ShowMessage("Your source code control provider '" + _sourceControl.ProviderName + "' failed to initialize.", MessageBoxIcon.Warning);
                }
                if (_sourceControl.Available)
                {
                    _menuCommands.Commands.Add(new MenuCommand(ADD_TO_SOURCE_CONTROL_COMMAND, "Add to source control"));
                    _guiController.AddMenuItems(this, _menuCommands);
                }
            }
            catch (Exception ex)
            {
                _guiController.ShowMessage("A serious error occurred attempting to connect to your source control provider. Please ensure that '" + _sourceControl.ProviderName + "' is properly installed.\n\nError details: " + ex.ToString(), MessageBoxIcon.Stop);
            }
        }
Exemplo n.º 4
0
        public SolutionService(IServiceProvider serviceProvider, SourceControlProvider sourceControlProvider)
        {
            _serviceProvider = serviceProvider;
            _vsSolution = serviceProvider.GetService<SVsSolution, IVsSolution>();
            _isRefreshEnabled = true;

            sourceControlProvider.Activated += (sender, e) =>
            {
                string directory, fileName, userFile;
                _vsSolution.GetSolutionInfo(out directory, out fileName, out userFile);

                _vsSolution.AdviseSolutionEvents(this, out _cookieSolutionEvents);
                if (string.IsNullOrEmpty(directory))
                    _repositoryService.CloseRepository();
                else
                    _repositoryService.OpenRepositoryAt(directory);
            };

            sourceControlProvider.Deactivated += (sender, e) =>
            {
                StopListeningToSolutionEvents();
                _repositoryService.CloseRepository();
            };
        }
Exemplo n.º 5
0
        public ActionResult Authenticate(SourceControlProvider provider)
        {
            //Authentication
            string username = Request["username"] ?? string.Empty;

            string password = Request["password"] ?? string.Empty;

            string repositoryUrl = Request["repositoryurl"] ?? string.Empty;

            string filename = Request["filename"] ?? string.Empty;

            string message = string.Empty; //Commit message

            bool success = true;

            string extraData = string.Empty;

            if (username.IsEmpty() || password.IsEmpty() || provider.ToString().IsEmpty() || repositoryUrl.IsEmpty())
            {
                message = "Please make sure Username, Password are not empty";

                success = false;
            }

            if (success)
            {
                UserWidgetDataDetails userData = new UserWidgetDataDetails();

                userData.Username = username.Trim();

                userData.Password = SecretsHelper.Encrypt(password.Trim(), SecretsHelper.EncryptionKey);

                userData.Provider = provider;

                userData.RepositoryUrl = repositoryUrl.Trim();

                userData.AccessToken = string.Empty;

                if (provider == SourceControlProvider.SVN)
                {
                    SVN svn = new SVN();

                    svn.SaveLoginDetails(CurrentUser, userData, GeminiContext);
                }
                else if (provider == SourceControlProvider.GitHub)
                {
                    GitHub github = new GitHub();

                    github.SaveLoginDetails(CurrentUser, userData, GeminiContext);

                    extraData = string.Format("https://github.com/login/oauth/authorize?client_id={0}&redirect_uri={1}apps/saucery/github/authenticate?state={2}&scope=repo", username, UserContext.Url, CurrentUser.Entity.Id);
                }
                else if (provider == SourceControlProvider.TFS2012)
                {
                    TFS2012 tfs2012 = new TFS2012();

                    tfs2012.SaveLoginDetails(CurrentUser, userData, GeminiContext);
                }
                else if (provider == SourceControlProvider.TFS2010)
                {
                    TFS2010 tfs2010 = new TFS2010();

                    tfs2010.SaveLoginDetails(CurrentUser, userData, GeminiContext);
                }
                else if (provider == SourceControlProvider.Git)
                {
                    Git git = new Git();
                    git.SaveLoginDetails(CurrentUser, userData, GeminiContext);
                }
                else if (provider == SourceControlProvider.Bitbucket)
                {
                    Bitbucket bitbucket = new Bitbucket();
                    bitbucket.SaveLoginDetails(CurrentUser, userData, GeminiContext);
                }
            }

            return(JsonSuccess(new { success = success, message = message, extraData = extraData }));
        }
Exemplo n.º 6
0
 public override void EditorShutdown()
 {
     if (_sourceControl != null)
     {
         _sourceControl.Dispose();
         _sourceControl = null;
     }
 }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            NameValueCollection appSettings = System.Configuration.ConfigurationManager.AppSettings;

            _mainFilePath = appSettings["MainFolderPath"];

            _emailOnError = bool.Parse(appSettings["EmailOnError"]);
            _emailServer  = appSettings["EmailServer"];
            _emailFrom    = appSettings["EmailFrom"];
            _emailTo      = appSettings["EmailTo"];

            System.Console.WriteLine("Config Ok");

            SourceControlProvider scp = (SourceControlProvider)System.Enum.Parse(typeof(SourceControlProvider), appSettings["SourceControl"]);

            SourceControl.ISourceControl sourceControl;

            if (scp == SourceControlProvider.git)
            {
                sourceControl = new SourceControl.git();
            }
            else if (scp == SourceControlProvider.SVN)
            {
                sourceControl = new SourceControl.SVN();
            }
            else
            {
                throw new Exception("Bad SourceControlProvider");
            }

            try
            {
                XDocument runSteps = XDocument.Load(ConfigurationManager.AppSettings["RunStepsPath"].ToString());

                var LogJobServers = from c in runSteps.Elements("LogServers").Elements("LogJobs").Elements("server")
                                    select(string) c.Attribute("serverName");


                foreach (string serverName in LogJobServers)
                {
                    string srvPath = _mainFilePath + "\\" + serverName;

                    Database.IDatabase db = new Database.SqlServer2008(serverName);

                    NameValueCollection nv;
                    nv = db.GetConfiguration();
                    if (nv != null)
                    {
                        sourceControl.LogObjects(srvPath, "Configuration", nv);
                    }
                    sourceControl.LogObjects(srvPath, "Databases", db.GetDatabases());
                    sourceControl.LogObjects(srvPath, "Logins", db.GetLogins());
                    sourceControl.LogObjects(srvPath, "Jobs", db.GetJobs());
                }

                var LogObjectServers = from c in runSteps.Elements("LogServers").Elements("LogObjects").Elements("server")
                                       select c;


                foreach (var logObjectServer in LogObjectServers)
                {
                    string serverName = (string)logObjectServer.Attribute("serverName");
                    //switch to regex match on database name - need to select
                    Database.IDatabase db        = new Database.SqlServer2008(serverName);
                    List <string>      databases = db.ListDatabasesForPattern((string)logObjectServer.Attribute("databaseName"));
                    foreach (string dbName in databases)
                    {
                        string dbPath = _mainFilePath + "\\" + serverName + @"\" + dbName;
                        bool   newDb  = false;

                        if (!Directory.Exists(dbPath))
                        {
                            newDb = true;
                        }

                        if (db.SelectDatabase(dbName))
                        {
                            Console.WriteLine(DateTime.Now.ToString() + " Object Log Start for server " + serverName +
                                              " database " + dbName);

                            try
                            {
                                sourceControl.LogObjects(dbPath, "StoredProcedures", db.GetStoredProcedures());
                                sourceControl.LogObjects(dbPath, "Functions", db.GetFunctions());
                                sourceControl.LogObjects(dbPath, "Views", db.GetViews());
                                sourceControl.LogObjects(dbPath, "Tables", db.GetTables());
                                sourceControl.LogObjects(dbPath, "PartitionFunctions", db.GetPartitionFunctions());
                                sourceControl.LogObjects(dbPath, "PartitionSchemes", db.GetPartitionSchemes());
                                sourceControl.LogObjects(dbPath, "Indexes", db.GetIndexes());
                                sourceControl.LogObjects(dbPath, "Users", db.GetUsers());
                                if (newDb)
                                {
                                    sourceControl.Add(dbPath);
                                }
                            }
                            catch
                            {
                                // eh.  db is usually unavailable.
                            }
                        }
                    }
                }


                //git is one giant repo.  SVN is usually one working copy per "server"
                if (scp == SourceControlProvider.git)
                {
                    sourceControl.Commit("");
                }
                else if (scp == SourceControlProvider.SVN)
                {
                    // loop through all dirs in main folder and commit..
                    string[] dirs = Directory.GetDirectories(_mainFilePath);

                    foreach (string dir in dirs)
                    {
                        sourceControl.Commit(dir);
                    }
                }

                Console.WriteLine("done");
                //Console.ReadLine();
            }
            catch (Exception ex)
            {
                if (_emailOnError)
                {
                    string MailServer = _emailServer;
                    string From       = _emailFrom;
                    string To         = _emailTo;
                    string Subject    = "SQLSchemaSourceControl Failed";
                    string Body       = ex.Message + " " + ex.InnerException + " " + ex.StackTrace;
                    bool   IsHtml     = true;
                    SendMail(MailServer, From, To, Subject, Body, IsHtml);
                }
                else
                {
                    Console.WriteLine(ex.Message + " " + ex.InnerException + " " + ex.StackTrace);
                    throw ex;
                }
            }
        }