Ejemplo n.º 1
0
        private void deletePicture()
        {
            if (listview_TFS_uploads.SelectedItems != null && listview_TFS_uploads.SelectedItems.Count > 0)
            {
                for (int i = 0; i < listview_TFS_uploads.SelectedItems.Count; i++)
                {
                    TFSInfo      imgurInfo = (TFSInfo)listview_TFS_uploads.SelectedItems[i].Tag;
                    DialogResult result    = MessageBox.Show(Language.GetFormattedString(LangKey.delete_question, imgurInfo.Title), Language.GetFormattedString(LangKey.delete_title, imgurInfo.ID), MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {
                        BackgroundForm backgroundForm = BackgroundForm.ShowAndWait(TFSPlugin.Attributes.Name, Language.GetString("tfs", LangKey.communication_wait));
                        try
                        {
                            TFSUtils.DeleteTfsWorkItem(imgurInfo);
                        }
                        catch (Exception ex)
                        {
                            LOG.Warn("Problem communicating with TFS: ", ex);
                        }
                        finally
                        {
                            backgroundForm.CloseDialog();
                        }

                        imgurInfo.Dispose();
                    }
                }
            }
            redraw();
        }
Ejemplo n.º 2
0
        public override DataChangesResult MakeDataChanges()
        {
            //System.Diagnostics.Debugger.Launch();

            try
            {
                if (_adapterState != AdapterState.Stopped)
                {
                    return(DataChangesResult.NoChangesPending);
                }

                if (IsWarehouseHostCancelled || IsWarehouseSchemaLockRequested)
                {
                    return(ChangeAdapterState(DataChangesResult.DataChangesPending));
                }

                using (var dac = WarehouseContext.CreateWarehouseDataAccessComponent())
                {
                    if (_warehouseVersion.NeedSchemaChanges(dac))
                    {
                        return(ChangeAdapterState(DataChangesResult.SchemaChangesPending));
                    }

                    TFSUsersLogUpdater.UpdateTFSUsersLog(TFSUtils.ReturnDataFromWarehousePropertyBag <DateTime>(dac, dateOfLastCommandSavedProperty), _tpcDatabase.ConnectionString, _tfsLogUsageConnString);
                }

                return(ChangeAdapterState(DataChangesResult.NoChangesPending));
            }
            catch (Exception err)
            {
                Utils.Log.LogEvent(RequestContext, err.Message, Utils.Log.LogEventInformationLevel.Error);
                throw;
            }
        }
Ejemplo n.º 3
0
            protected virtual void CheckInClientScripts(string[] schemas, string[] specialschemas)
            {
                if (!checkInStampedScripts)
                {
                    return;
                }

                LogMsg(MessageImportance.High, "CheckInClientScripts() called.");

                // TFS Add Files to installer area
                TFSUtils.tfsAdd(string.Format(@"{0}\..\Setup\DbUpgrade\DBScripts\{1}\*.*", BasePath, newDBVersion), TFS_User, TFS_Pass);
                foreach (var specialschema in specialschemas)
                {
                    foreach (var schema in schemas)
                    {
                        TFSUtils.tfsAdd(string.Format(@"{0}\..\Setup\DbUpgrade\DBScripts\{1}\{2}\*.sql", BasePath, specialschema, schema), TFS_User, TFS_Pass);
                    }
                }

                TFSUtils.tfsCheckin(string.Format(@"{0}\..\Setup\DbUpgrade\DBScripts", BasePath), "CreateAll script: Checking in moved scripts", TFS_User, TFS_Pass);

                foreach (var schema in schemas)
                {
                    // Remove old SQL files from TFS
                    TFSUtils.tfsDelete(string.Format(@"{0}\{1}\UpdateScripts\Approved\*.approved", BasePath, schema), TFS_User, TFS_Pass);
                    foreach (var specialschema in specialschemas)
                    {
                        TFSUtils.tfsDelete(string.Format(@"{0}\{1}\Data\{2}\Approved\*.approved", BasePath, schema, specialschema), TFS_User, TFS_Pass);
                    }
                }

                TFSUtils.tfsCheckin(BasePath, "CreateAll script: Deleting old approved scripts", TFS_User, TFS_Pass);
            }
Ejemplo n.º 4
0
            public override bool Execute()
            {
                try
                {
                    Initialize(base.Log, this.ProgramFiles, this.TFExePath);

                    string labelText = null;
                    if (!string.IsNullOrEmpty(Version) && !string.IsNullOrEmpty(Label))
                    {
                        labelText = Label.Replace("${LastVersion}", Version);
                    }
                    else
                    {
                        string lastVersionText = FileUtils.GetValueFromVersionFile(VersionXmlFile, "//LastVersion");
                        labelText = FileUtils.GetValueFromVersionFile(VersionXmlFile, "//Label");
                        labelText = labelText.Replace("${LastVersion}", lastVersionText);
                    }
                    TFSUtils.tfsLabel(ProjectRoot, labelText, TFS_User, TFS_Pass);
                }
                catch (Exception ex)
                {
                    Log.LogErrorFromException(ex, true, true, null);
                    return(false);
                }
                return(true);
            }
Ejemplo n.º 5
0
        private void btnTest_Click(object sender, EventArgs e)
        {
            LoginInfo info = GetLoginInfo();

            bool result = TFSUtils.TestConnection(info);

            MessageBox.Show(string.Format("Connection test {0}", result ? "passed." : "failed."));
        }
Ejemplo n.º 6
0
            private Dictionary <string, string> AddComments(string dbscript)
            {
                LogMsg(MessageImportance.High, "AddComments() called.");

                //var dbscriptparts = dbscript.Split('\\');
                //var scriptname = dbscriptparts[dbscriptparts.Length - 1];
                //string objectname = null;
                //if (scriptname.Split('.').Length == 4)
                //{
                //    // Some of our db files now store the file with funny names now so that the filenames will sort in the order they need to execute.
                //    // The object name is still in the filename, but we have to pick it out differently than before.
                //    // example: D:\tfs\Integration\Main 6.2\Integration\CreateCI_DB\CI_CENTRAL\DatabaseObjects\Tables\000.50.APPLICATION_SETTINGS.sql
                //    // The desired object is simply APPLICATION_SETTINGS.
                //    objectname = scriptname.Split('.')[2];
                //}
                //else
                //{
                //    // if the filename does NOT have three "." then assume it's in the file name minus the path and extension.
                //    // example:  d:\folder1\folder2\MyTable.sql = object name MyTable.
                //    objectname = Path.GetFileNameWithoutExtension(scriptname);
                //}

                var icMainTokenList       = new[] { "${Version}", "${ClientICMainVersion}", "${Changeset}", "${LastModifiedDate}" };
                var icMainClientTokenList = new[] { "${Version}", "${ClientICMainVersion}", "${Changeset}", "${LastModifiedDate}", "${ClientVersion}" };

                var tokenList = IsIcMainClient ? icMainClientTokenList : icMainTokenList;
                var tokens    = tokenList.ToDictionary(token => token, token => string.Empty);

                tokens["${Version}"] = newDBVersion;

                if (IsIcMainClient)
                {
                    tokens["${ClientVersion}"] = newDBVersion;
                }

                if (checkInStampedScripts)
                {
                    // Add comment to database object
                    TFSUtils.tfsCheckout(dbscript, TFS_User, TFS_Pass);
                }
                else
                {
                    FileUtils.UnsetReadOnly(Path.GetDirectoryName(dbscript), Path.GetFileName(dbscript),
                                            SearchOption.TopDirectoryOnly);
                }
                TokenUtils.ReplaceTokens(dbscript, dbscript, tokens);
                return(tokens);
            }
Ejemplo n.º 7
0
            private void checkoutVersionFiles()
            {
                if (string.IsNullOrEmpty(Version))
                {
                    TFSUtils.tfsGet(VersionXmlFile, TFS_User, TFS_Pass);
                }
                TFSUtils.tfsGet(VersionCsFile, TFS_User, TFS_Pass);
                if (string.IsNullOrEmpty(Version))
                {
                    TFSUtils.tfsCheckout(VersionXmlFile, TFS_User, TFS_Pass);
                }
                TFSUtils.tfsCheckout(VersionCsFile, TFS_User, TFS_Pass);

                // TODO: Remove Telenor-specific logic
                // For Telenor builds only, check out config files
                if (VersionXmlFile.Contains("Telenor"))
                {
                    configFile = ProjectRoot + @"\Applications\WindowsService\App.config";
                    TFSUtils.tfsGet(configFile, TFS_User, TFS_Pass);
                    TFSUtils.tfsCheckout(configFile, TFS_User, TFS_Pass);
                }
            }
Ejemplo n.º 8
0
            private void checkinVersionfiles()
            {
                string tfscheckincomment;

                if (string.IsNullOrEmpty(Version))
                {
                    tfscheckincomment =
                        string.Format("IncrementVersion script: Incremented {0} IC version to {1}", projectName,
                                      newVersion);
                    TFSUtils.tfsCheckin(VersionXmlFile, tfscheckincomment, TFS_User, TFS_Pass);
                }

                tfscheckincomment = string.Format("IncrementVersion script: Updated {0} IC version.cs to {1}", projectName, newVersion);
                TFSUtils.tfsCheckin(VersionCsFile, tfscheckincomment, TFS_User, TFS_Pass);

                // TODO: Remove Telenor-specific logic
                // For Telenor builds only, check in config files
                if (VersionXmlFile.Contains("Telenor"))
                {
                    tfscheckincomment = string.Format("IncrementVersion script: Updated {0} {1} to {2}", projectName, configFile.Substring(configFile.LastIndexOf('\\') + 1), newVersion);
                    TFSUtils.tfsCheckin(configFile, tfscheckincomment, TFS_User, TFS_Pass);
                }
            }
Ejemplo n.º 9
0
            public override bool Execute()
            {
                try
                {
                    Initialize(base.Log, this.ProgramFiles, this.TFExePath);

                    string lastVersionText  = Version ?? FileUtils.GetValueFromVersionFile(VersionXmlFile, "//LastVersion");
                    string labelText        = FileUtils.GetValueFromVersionFile(VersionXmlFile, "//Label").Replace("${LastVersion}", lastVersionText);
                    string targetBranchText = FileUtils.GetValueFromVersionFile(VersionXmlFile, "//TargetTFSBranchPath").Replace("${LastVersion}", lastVersionText)
                                              .Replace("${Year}", DateTime.Now.Year.ToString());
                    string serverBranchText = FileUtils.GetValueFromVersionFile(VersionXmlFile, "//LocalBranchPath").Replace("${LastVersion}", lastVersionText)
                                              .Replace("${Year}", DateTime.Now.Year.ToString()).Replace("${Integration_Root}", IntegrationRoot);
                    bool   isICMainBuild      = false;
                    string isICMainBuildValue = FileUtils.GetValueFromVersionFile(VersionXmlFile, "//IsICMainBuild");
                    if (!string.IsNullOrEmpty(isICMainBuildValue))
                    {
                        switch (isICMainBuildValue)
                        {
                        case "0":
                            isICMainBuild = false;
                            break;

                        case "1":
                            isICMainBuild = true;
                            break;

                        default:
                            isICMainBuild = bool.Parse(isICMainBuildValue);
                            break;
                        }
                    }
                    string buildsFolderText = FileUtils.GetValueFromVersionFile(VersionXmlFile, "//BuildsFolder").Replace("${Integration_Root}", IntegrationRoot);

                    string[] schemas = new string[] { "CI_CENTRAL", "CI_BUSINESSDATA", "CI_QUEUEDATA" };

                    string tfscheckincomment = string.Format("CreateBranch script: Creating branch from label '{0}'", labelText);

                    // Decloak build folders
                    foreach (string folder in TFSUtils.tfsDir(buildsFolderText, TFS_User, TFS_Pass))
                    {
                        TFSUtils.tfsDecloak(string.Format(@"{0}\{1}", buildsFolderText, folder.Split(new char[] { '$' })[1]), TFS_User, TFS_Pass);
                    }

                    if (isICMainBuild)
                    {
                        // Generate full padded IC main version string
                        string[] versionparts  = lastVersionText.Split(new char[] { '.' });
                        string   icmainversion = string.Format("{0}.{1}.{2}.{3}", versionparts[0].PadLeft(2, '0'), versionparts[1].PadLeft(2, '0'),
                                                               versionparts[2].PadLeft(2, '0'), versionparts[3].PadLeft(2, '0'));

                        // Actually create the branch
                        TFSUtils.tfsBranch(labelText, ProjectRoot, targetBranchText, true, TFS_User, TFS_Pass);

                        string[] icMainSubDirs = new string[] { "Schemas", "es", "Oracle DLL", "Templates",
                                                                @"Transformers\ConditionalAccess\Common", @"Transformers\ConditionalAccess\Nagra\Aladin.1.4",
                                                                @"Transformers\ConditionalAccess\Nagra\Common", @"Transformers\ConditionalAccess\Nagra\Merlin.2.1",
                                                                @"Transformers\ConditionalAccess\Control.6.14", @"Transformers\ConditionalAccess\Control.6.14\Common" };

                        // Create the IC Main DLL folders
                        foreach (string icMainSubDir in icMainSubDirs)
                        {
                            Directory.CreateDirectory(string.Format(@"{0}\IC Main DLL\{1}", serverBranchText, icMainSubDir));
                        }

                        // Copy the IC Main DLLs over
                        FileUtils.CopyDirectory(string.Format(@"{0}\IC Main DLL", ProjectRoot), string.Format(@"{0}\IC Main DLL", serverBranchText), true);

                        foreach (string schema in schemas)
                        {
                            // Create the IC Main Scripts folders
                            Directory.CreateDirectory(string.Format(@"{0}\IC Main Scripts\{1}\{2}", serverBranchText, schema, icmainversion));

                            // Move the DatabaseObjects folders
                            Directory.Move(string.Format(@"{0}\CreateCI_DB\{1}\UpdateScripts\{2}\DatabaseObjects", ProjectRoot, schema, icmainversion),
                                           string.Format(@"{0}\IC Main Scripts\{1}\{2}\DatabaseObjects", serverBranchText, schema, icmainversion));

                            // Copy ad-hoc scripts
                            FileUtils.CopyDirectory(string.Format(@"{0}\CreateCI_DB\{1}\UpdateScripts", ProjectRoot, schema),
                                                    string.Format(@"{0}\IC Main Scripts\{1}\{2}", serverBranchText, schema, icmainversion), true);

                            // Delete ad-hoc scripts from TFS
                            TFSUtils.tfsDelete(string.Format(@"{0}\CreateCI_DB\{1}\UpdateScripts\*.*", ProjectRoot, schema), TFS_User, TFS_Pass);

                            // Delete intermediary files
                            Directory.Delete(string.Format(@"{0}\CreateCI_DB\{1}\UpdateScripts\{2}", ProjectRoot, schema, icmainversion), true);
                        }

                        // Add branch DLLs and scripts to TFS
                        TFSUtils.tfsAdd(string.Format(@"{0}\IC Main DLL", serverBranchText), TFS_User, TFS_Pass);
                        TFSUtils.tfsAdd(string.Format(@"{0}\IC Main Scripts", serverBranchText), TFS_User, TFS_Pass);

                        // Check in files
                        TFSUtils.tfsCheckin(string.Format(@"{0}\CreateCI_DB", ProjectRoot), "CreateBranch script: Deleting IC Main update scripts", TFS_User, TFS_Pass);
                    }
                    else
                    {
                        TFSUtils.tfsBranch(labelText, ProjectRoot, targetBranchText, false, TFS_User, TFS_Pass);
                    }

                    TFSUtils.tfsCheckin(serverBranchText, tfscheckincomment, TFS_User, TFS_Pass);

                    // Cloak builds folders
                    foreach (string folder in TFSUtils.tfsDir(buildsFolderText, TFS_User, TFS_Pass))
                    {
                        TFSUtils.tfsCloak(string.Format(@"{0}\{1}", buildsFolderText, folder), TFS_User, TFS_Pass);
                    }
                }
                catch (Exception ex)
                {
                    Log.LogErrorFromException(ex, true, true, null);
                    return(false);
                }
                return(true);
            }
Ejemplo n.º 10
0
            private void CopyICMainClientScripts(string schema, string[] databaseobjectfolders)
            {
                LogMsg(MessageImportance.High, "CopyICMainClientScripts() called.");

                LogMsg(MessageImportance.High, "Getting directory listing of {0}", string.Format(@"{0}\..\IC Main Scripts\{1}", BasePath, schema));

                // Copy IC Main scripts to setup folder
                var icMainFolders = Directory.GetDirectories(string.Format(@"{0}\..\IC Main Scripts\{1}", BasePath, schema), "*", SearchOption.TopDirectoryOnly);

                LogMsg(MessageImportance.High, GetLogMessage("icMainFolders", icMainFolders));

                if (icMainFolders.Length <= 0)
                {
                    LogMsg(MessageImportance.High, "No IC Main folders found, so exiting CopyICMainClientScripts() method.");
                    return;
                }

                var icMainFolderVersions = new SortedList <string, string>();

                foreach (var icMainFolder in icMainFolders)
                {
                    // Check out destination scripts if they exist
                    var tempDestPath = string.Format(@"{0}\..\Setup\DbUpgrade\DBScripts\{1}\{2}", BasePath, newDBVersion, schema);
                    if (checkInStampedScripts)
                    {
                        TFSUtils.tfsCheckout(tempDestPath, TFS_User, TFS_Pass);
                    }

                    // Copy scripts
                    LogMsg(MessageImportance.High, "Copying files matching '*.*' from '{0}' to '{1}'.", icMainFolder, tempDestPath);
                    FileUtils.CopyFiles(icMainFolder, "*.*", tempDestPath);

                    // Add folder to sorted list
                    var icMainFolderNameParts = icMainFolder.Split('\\');
                    var icMainFolderName      = icMainFolderNameParts[icMainFolderNameParts.Length - 1];
                    icMainFolderVersions.Add(icMainFolderName, icMainFolder);
                }

                LogMsg(MessageImportance.High, GetLogMessage("icMainFolderVersions", icMainFolderVersions));

                var latestICMainFolder = string.Format(@"{0}\..\IC Main Scripts\{1}\{2}", BasePath, schema,
                                                       icMainFolderVersions.Last().Key);

                LogMsg(MessageImportance.High, "latestICMainFolder = {0}", latestICMainFolder);

                LogMsg(MessageImportance.High, GetLogMessage("databaseobjectfolders", databaseobjectfolders));

                // Copy IC Main DB objects to setup folder
                foreach (var tempLatestICMainDatabaseObjectFolder in databaseobjectfolders.Select(
                             databaseobjectfolder => string.Format(@"{0}\DatabaseObjects\{1}", latestICMainFolder,
                                                                   databaseobjectfolder)))
                {
                    if (checkInStampedScripts)
                    {
                        // Check out script
                        TFSUtils.tfsCheckout(tempLatestICMainDatabaseObjectFolder, TFS_User, TFS_Pass);
                    }

                    // Determine output path
                    var destscriptfolder = string.Format(@"{0}\..\Setup\DbUpgrade\DBScripts\_PreProcess\{1}", BasePath, schema);

                    if (checkInStampedScripts)
                    {
                        // Check out destination scripts
                        TFSUtils.tfsCheckout(destscriptfolder, TFS_User, TFS_Pass);
                    }

                    if (Directory.Exists(tempLatestICMainDatabaseObjectFolder))
                    {
                        foreach (var dbscript in Directory.GetFiles(tempLatestICMainDatabaseObjectFolder, "*.sql", SearchOption.TopDirectoryOnly))
                        {
                            // Add comments to script
                            var tokens = AddComments(dbscript);

                            // Determine output path
                            var scriptpathparts = dbscript.Split('\\');
                            var destscriptpath  = string.Format(@"{0}\{1}", destscriptfolder, scriptpathparts[scriptpathparts.Length - 1]);

                            if (!checkInStampedScripts)
                            {
                                FileUtils.UnsetReadOnly(destscriptfolder, Path.GetFileName(destscriptpath), SearchOption.TopDirectoryOnly);
                            }

                            // Perform token replacement on script and copy to destination folder
                            TokenUtils.ReplaceTokens(dbscript, destscriptpath, tokens);
                        }
                    }
                    else
                    {
                        LogMsg(MessageImportance.High, "Directory not found: {0}", tempLatestICMainDatabaseObjectFolder);
                    }

                    if (checkInStampedScripts)
                    {
                        // Undo original script (template)
                        TFSUtils.tfsUndo(tempLatestICMainDatabaseObjectFolder, TFS_User, TFS_Pass);
                    }
                }
            }
Ejemplo n.º 11
0
            private void CopyDatabaseObjects(IEnumerable <string> databaseobjectfolders, string schema, string newICMainVersion)
            {
                LogMsg(MessageImportance.High, "CopyDatabaseObjects() called.");

                // Copy database objects
                foreach (var databaseobjectfolder in databaseobjectfolders)
                {
                    // determine the dbscript folder
                    var dbscriptpath = string.Format(@"{0}\{1}\DatabaseObjects\{2}", BasePath, schema, databaseobjectfolder);

                    if (checkInStampedScripts)
                    {
                        // check out everything in the dbscript folder
                        TFSUtils.tfsCheckout(dbscriptpath, TFS_User, TFS_Pass);
                    }

                    // Determine output folder
                    var destscriptfolder = IsIcMain ? string.Format(@"{0}\{1}\UpdateScripts\{2}\DatabaseObjects\{3}", BasePath, schema, newICMainVersion, databaseobjectfolder) :
                                           string.Format(@"{0}\..\Setup\DbUpgrade\DBScripts\_PreProcess\{1}", BasePath, schema);

                    if (checkInStampedScripts)
                    {
                        // check out everything in the destination folder.
                        TFSUtils.tfsCheckout(destscriptfolder, TFS_User, TFS_Pass);
                    }

                    LogMsg("Inside CopyDatabaseObjects(), checking if path '{0}' exists.", dbscriptpath);
                    if (Directory.Exists(dbscriptpath))
                    {
                        LogMsg("Inside CopyDatabaseObjects(), directory exists.  Looping through SQL files in this directory.");

                        var dbscripts = Directory.GetFiles(dbscriptpath, "*.sql", SearchOption.TopDirectoryOnly);

                        LogMsg(MessageImportance.High, GetLogMessage("dbscripts", dbscripts));

                        foreach (var dbscript in dbscripts)
                        {
                            LogMsg("Inside CopyDatabaseObjects().  Adding comments to script '{0}'.", dbscript);

                            // Add comments to script
                            var tokens = AddComments(dbscript);

                            var scriptpathparts = dbscript.Split('\\');
                            var destscriptpath  = string.Format(@"{0}\{1}", destscriptfolder, scriptpathparts[scriptpathparts.Length - 1]);

                            var tokenString = tokens.Aggregate("", (current, token) => current + string.Format("key: {0}; value={1}\r\n", token.Key, token.Value));

                            LogMsg("Inside CopyDatabaseObjects().  Calling ReplaceTokens() with dbscript '{0}', destscriptpath '{1}', tokens '{2}'.", dbscript, destscriptpath, tokenString);

                            if (!checkInStampedScripts)
                            {
                                FileUtils.UnsetReadOnly(destscriptfolder, Path.GetFileName(destscriptpath), SearchOption.TopDirectoryOnly);
                            }

                            // Perform token replacement on script and copy to destination folder
                            TokenUtils.ReplaceTokens(dbscript, destscriptpath, tokens);
                        }
                    }

                    if (checkInStampedScripts)
                    {
                        // Undo original script (template)
                        TFSUtils.tfsUndo(dbscriptpath, TFS_User, TFS_Pass);
                    }
                }
            }