Exemplo n.º 1
0
        /// <summary>
        /// Save changes of exsiting Repository Item to file system
        /// </summary>
        /// <param name="repositoryItem"></param>
        public void SaveRepositoryItem(RepositoryItemBase repositoryItem)
        {
            if (String.IsNullOrEmpty(repositoryItem.ContainingFolder))
            {
                throw new Exception("Cannot save item, there is no containing folder defined - " + repositoryItem.GetType().FullName + ", " + repositoryItem.GetNameForFileName());
            }

            repositoryItem.UpdateBeforeSave();

            string txt              = RepositorySerializer.SerializeToString(repositoryItem);
            string filePath         = CreateRepositoryItemFileName(repositoryItem);
            RepositoryFolderBase rf = GetItemRepositoryFolder(repositoryItem);

            rf.SaveRepositoryItem(filePath, txt);
            repositoryItem.FileName = filePath;
            repositoryItem.FilePath = filePath;
            repositoryItem.RefreshSourceControlStatus();
            RefreshParentFoldersSoucerControlStatus(Path.GetDirectoryName(repositoryItem.FilePath));

            if (repositoryItem.DirtyStatus != Common.Enums.eDirtyStatus.NoTracked)
            {
                repositoryItem.SetDirtyStatusToNoChange();
            }
            repositoryItem.CreateBackup();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Checks the Ginger version in the file and compare it to current Ginger version.
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="fileGingerVersion"></param>
        /// <returns></returns>
        public static eGingerVersionComparisonResult CompareSolutionFileGingerVersionToCurrent(string filePath, ref string fileGingerVersion)
        {
            fileGingerVersion = GetSolutonFileGingerVersion(filePath);
            if (fileGingerVersion == null)
            {
                Reporter.ToLog(eLogLevel.WARN, string.Format("Failed to read and compare the Ginger version for the file: '{0}'", filePath));
                return(eGingerVersionComparisonResult.ComparisonFailed);//failed to identify and compare the version
            }

            long fileVersionAsLong    = GingerCoreNET.GeneralLib.General.GetGingerVersionAsLong(fileGingerVersion);
            long currentVersionAsLong = RepositorySerializer.GetCurrentGingerVersionAsLong();

            if (fileVersionAsLong == 0)
            {
                Reporter.ToLog(eLogLevel.WARN, string.Format("Failed to read and compare the Ginger version for the file: '{0}'", filePath));
                return(eGingerVersionComparisonResult.ComparisonFailed);;//failed to identify and compare the version
            }
            else if (currentVersionAsLong == fileVersionAsLong)
            {
                return(eGingerVersionComparisonResult.SameVersion); //same version
            }
            else if (currentVersionAsLong > fileVersionAsLong)
            {
                return(eGingerVersionComparisonResult.LowerVersion); //File is from lower version
            }
            else if (currentVersionAsLong < fileVersionAsLong)
            {
                return(eGingerVersionComparisonResult.HigherVersion); //File is from newer version
            }
            else
            {
                Reporter.ToLog(eLogLevel.WARN, string.Format("Failed to read and compare the Ginger version for the file: '{0}'", filePath));
                return(eGingerVersionComparisonResult.ComparisonFailed);//failed to identify and compart the version
            }
        }
Exemplo n.º 3
0
        public void RepositorySerializerTest(string cryptoCode)
        {
            var networkProvider = new NRustLightningNetworkProvider(NetworkType.Regtest);
            var ser             = new RepositorySerializer(networkProvider.GetByCryptoCode(cryptoCode));
            // utxo response
            var resp        = new UTXOChangesWithMetadata();
            var confirmed   = new UTXOChangeWithSpentOutput();
            var unconfirmed = new UTXOChangeWithSpentOutput();

            confirmed.SpentOutPoint = new List <OutPoint>()
            {
                OutPoint.Zero
            };
            var coinBaseTx =
                Transaction.Parse(
                    "020000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff0401750101ffffffff0200f2052a0100000017a914d4bb8bf5f987cd463a2f5e6e4f04618c7aaed1b5870000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf90120000000000000000000000000000000000000000000000000000000000000000000000000", Network.RegTest);
            var utxo = new UTXO(new NBXplorer.Models.UTXO(coinBaseTx.Outputs.AsCoins().First()));

            Assert.NotNull(JsonSerializer.Serialize(utxo, ser.Options));
            confirmed.UTXO = new List <UTXOChangeWithMetadata>()
            {
                new UTXOChangeWithMetadata(utxo, UTXOKind.UserDeposit, new AddressTrackedSource(coinBaseTx.Outputs[0].ScriptPubKey.GetDestinationAddress(Network.RegTest)))
            };
            resp.Confirmed   = confirmed;
            resp.UnConfirmed = unconfirmed;
            var res = JsonSerializer.Serialize(resp, ser.Options);

            Assert.NotNull(res);
        }
Exemplo n.º 4
0
        public RepositoryItemBase CreateCopy(bool setNewGUID = true)
        {
            // Create a copy by serailized and load from the text, it will not copy all atrs only the one which are saved to XML
            string s = RepositorySerializer.SerializeToString(this);
            // TODO: fixme not good practice and not safe, add param to handle in function or another solution...
            RepositoryItemBase duplicatedItem = (RepositoryItemBase)RepositorySerializer.DeserializeFromText(this.GetType(), s, filePath: this.FilePath);

            //change the GUID of duplicated item
            if (setNewGUID && duplicatedItem != null)
            {
                duplicatedItem.ParentGuid = Guid.Empty;
                duplicatedItem.ExternalID = string.Empty;
                duplicatedItem.Guid       = Guid.NewGuid();


                List <GuidMapper> guidMappingList = new List <GuidMapper>();

                //set new GUID also to child items
                UpdateRepoItemGuids(duplicatedItem, guidMappingList);
                duplicatedItem = duplicatedItem.GetUpdatedRepoItem(guidMappingList);
            }



            return(duplicatedItem);
        }
Exemplo n.º 5
0
        public static void ObjectsDeepCopy(RepositoryItem sourceObj, RepositoryItem targetObj)
        {
            RepositorySerializer repoSer = new RepositorySerializer();
            string sourceObjXml          = repoSer.SerializeToString(sourceObj);

            GingerCore.Repository.RepositorySerializer RS = new RepositorySerializer();
            RS.DeserializeFromTextWithTargetObj(sourceObj.GetType(), sourceObjXml, targetObj);
        }
Exemplo n.º 6
0
        public static object LoadFromFile(string FileName)
        {
            GingerCore.Repository.RepositorySerializer RS = new RepositorySerializer();
            RepositoryItemBase ri = (RepositoryItemBase)RS.DeserializeFromFile(FileName);

            ri.FileName = FileName;
            return(ri);
        }
Exemplo n.º 7
0
        public void SaveUserProfile()
        {
            try
            {
                SaveRecentAppAgentsMapping();
            }
            catch (Exception ex) { Reporter.ToLog(eAppReporterLogLevel.ERROR, $"Method - {MethodBase.GetCurrentMethod().Name}, Error - {ex.Message}", ex); }

            RepositorySerializer.SaveToFile(this, UserProfileFilePath);
        }
Exemplo n.º 8
0
 public void UpdateXMLVersion(string newGingerVersion)
 {
     if (RepositorySerializer.IsLegacyXmlType(xmlDoc.ToString()) == true)
     {
         RepositorySerializer.UpdateXMLGingerVersion(xmlDoc, newGingerVersion);
     }
     else
     {
         NewRepositorySerializer.UpdateXMLGingerVersion(xmlDoc, newGingerVersion);//New XML type
     }
 }
Exemplo n.º 9
0
        /// <summary>
        /// Pull and return the Ginger Version (in String format) which the Solution file was created with
        /// </summary>
        /// <param name="xmlFilePath"></param>
        /// <param name="xml"></param>
        /// <returns></returns>
        public static string GetSolutonFileGingerVersion(string xmlFilePath, string xml = "")
        {
            string fileVersion;

            //get the XML if needed
            if (string.IsNullOrEmpty(xml))
            {
                using (StreamReader reader = new StreamReader(xmlFilePath))
                {
                    //get XML
                    reader.ReadLine();//no need first line
                    xml = reader.ReadLine();
                    if (xml != null)
                    {
                        if (xml.ToLower().Contains("version") == false)//to handle new line gap in some old xml's
                        {
                            xml = reader.ReadLine();
                        }
                    }
                    else
                    {
                        Reporter.ToLog(eLogLevel.WARN, string.Format("Failed to get the Ginger Version of the file: '{0}'", xmlFilePath));
                    }
                }
            }

            //get the version based on XML type (new/old repository item type)
            if (string.IsNullOrEmpty(xml) == false)
            {
                if (RepositorySerializer.IsLegacyXmlType(xml) == true)
                {
                    fileVersion = RepositorySerializer.GetXMLGingerVersion(xml, xmlFilePath);
                    if (fileVersion == "3.0.0.0")
                    {
                        fileVersion = fileVersion + "Beta";
                    }
                }
                else
                {
                    fileVersion = NewRepositorySerializer.GetXMLGingerVersion(xml, xmlFilePath);//New XML type
                }

                if (fileVersion == null)
                {
                    Reporter.ToLog(eLogLevel.WARN, string.Format("Failed to get the Ginger Version of the file: '{0}'", xmlFilePath));
                }
                return(fileVersion);
            }
            else
            {
                Reporter.ToLog(eLogLevel.WARN, string.Format("Failed to get the Ginger Version of the file: '{0}'", xmlFilePath));
                return(null);
            }
        }
Exemplo n.º 10
0
        private RepositoryItemBase GetUpdatedRepoItem(List <GuidMapper> list)
        {
            string s = RepositorySerializer.SerializeToString(this);

            foreach (GuidMapper mapper in list)
            {
                s = s.Replace(mapper.Original.ToString(), mapper.newGuid.ToString());
            }

            return((RepositoryItemBase)RepositorySerializer.DeserializeFromText(this.GetType(), s, filePath: this.FilePath));
        }
Exemplo n.º 11
0
 public void SaveUserProfile()
 {
     try
     {
         SaveRecentAppAgentsMapping();
     }
     catch (Exception ex)
     {
         Reporter.ToLog(eLogLevel.ERROR, "Error occurred while saving Recent App-Agents Mapping for User Profile save", ex);
     }
     RepositorySerializer.SaveToFile(this, UserProfileFilePath);
 }
Exemplo n.º 12
0
        /// <summary>
        /// Update flow control and other places with new guid of entities.
        /// If FC is GoTo action and action got a new guid this method update flow control value with new guid
        /// </summary>
        /// <param name="list">mapping of old and new guids</param>
        /// <returns></returns>
        private RepositoryItemBase ReplaceOldGuidUsages(List <GuidMapper> list)
        {
            string s = RepositorySerializer.SerializeToString(this);

            foreach (GuidMapper mapper in list)
            {
                s = s.Replace(mapper.Original.ToString(), mapper.newGuid.ToString());
                s = s.Replace("ParentGuid=" + "\"" + mapper.newGuid.ToString() + "\"", "ParentGuid=" + "\"" + mapper.Original.ToString() + "\"");
            }

            return((RepositoryItemBase)RepositorySerializer.DeserializeFromText(this.GetType(), s, filePath: string.Empty));
        }
Exemplo n.º 13
0
        public void BusinessFlowDeserializationTest()
        {
            //Arrange
            RepositorySerializer RepositorySerializer = new RepositorySerializer();
            string sFileName = TestResources.GetTestResourcesFile(@"Converter\IPDLSAM.Ginger.BusinessFlow.xml");

            //Act
            BusinessFlow BF = (BusinessFlow)RepositorySerializer.DeserializeFromFile(typeof(BusinessFlow), sFileName);

            //Assert
            //TODO: add more asserts
            Assert.AreEqual(BF.Activities.Count(), 14);
        }
Exemplo n.º 14
0
        public void AgentDeserializationTest()
        {
            //Arrange
            RepositorySerializer RepositorySerializer = new RepositorySerializer();
            string sFileName = TestResources.GetTestResourcesFile(@"Converter" + Path.DirectorySeparatorChar + "IB1.Ginger.Agent.xml");

            //Act
            Agent agent = (Agent)RepositorySerializer.DeserializeFromFile(typeof(Agent), sFileName);

            //Assert
            //TODO: add more asserts
            Assert.AreEqual(agent.Name, "IB1");
            Assert.AreEqual(agent.DriverType, Agent.eDriverType.InternalBrowser);
        }
Exemplo n.º 15
0
        public void EnvironmentDeserializationTest()
        {
            //Arrange
            RepositorySerializer RepositorySerializer = new RepositorySerializer();
            string sFileName = TestResources.GetTestResourcesFile(@"Converter" + Path.DirectorySeparatorChar + "CMI.Ginger.Environment.xml");

            //Act
            ProjEnvironment env = (ProjEnvironment)RepositorySerializer.DeserializeFromFile(typeof(ProjEnvironment), sFileName);

            //Assert
            Assert.AreEqual(env.Name, "CMI IIS test server");
            Assert.AreEqual(env.Applications.Count, 2);
            //TODO: add more asserts
        }
Exemplo n.º 16
0
        public void SaveToFile(string fileName, bool FlagToUpdateFileName = true)
        {
            this.Version++;
            this.LastUpdate   = DateTime.UtcNow;
            this.LastUpdateBy = Environment.UserName;
            if (FlagToUpdateFileName)
            {
                this.FileName = fileName;
            }
            this.ClearBackup();

            RepositorySerializer rs = new RepositorySerializer();

            rs.SaveToFile(this, fileName);
        }
Exemplo n.º 17
0
        public void SaveUserProfile()
        {
            if (mSharedUserProfileBeenUsed)
            {
                Reporter.ToLog(eLogLevel.INFO, string.Format("Not performing User Profile Save because Shared User Profile is been used"));
                return;
            }

            try
            {
                SaveRecentAppAgentsMapping();
            }
            catch (Exception ex)
            {
                Reporter.ToLog(eLogLevel.ERROR, "Error occurred while saving Recent App-Agents Mapping for User Profile save", ex);
            }
            RepositorySerializer.SaveToFile(this, UserProfileFilePath);
        }
Exemplo n.º 18
0
        public NRustLightningClient(string baseUrl, NRustLightningNetwork network, X509Certificate2?certificate = null)
        {
            var handler = new HttpClientHandler()
            {
                ClientCertificateOptions = ClientCertificateOption.Automatic,
            };

            if (certificate != null)
            {
                handler.ClientCertificates.Add(certificate);
            }

            cryptoCode = network.CryptoCode;
            var ser = new RepositorySerializer(network);

            ser.ConfigureSerializer(jsonSerializerOptions);
            HttpClient = new HttpClient(handler);
            _baseUri   = new Uri(baseUrl);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Save changes of exsiting Repository Item to file system
        /// </summary>
        /// <param name="repositoryItem"></param>
        public void SaveRepositoryItem(RepositoryItemBase repositoryItem)
        {
            if (String.IsNullOrEmpty(repositoryItem.ContainingFolder))
            {
                throw new Exception("Cannot save item, there is no containing folder defined - " + repositoryItem.GetType().FullName + ", " + repositoryItem.GetNameForFileName());
            }

            repositoryItem.UpdateBeforeSave();

            string txt              = RepositorySerializer.SerializeToString(repositoryItem);
            string filePath         = CreateRepositoryItemFileName(repositoryItem);
            RepositoryFolderBase rf = GetItemRepositoryFolder(repositoryItem);

            rf.SaveRepositoryItem(filePath, txt);
            repositoryItem.FileName = filePath;
            repositoryItem.FilePath = filePath;
            //RI.isDirty = false;  //TODO: make is dirty to work
            SetDirtyStatusToNoChange(repositoryItem);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Save changes of exsiting Repository Item to file system
        /// </summary>
        /// <param name="repositoryItem"></param>
        public void SaveRepositoryItem(RepositoryItemBase repositoryItem)
        {
            if (String.IsNullOrEmpty(repositoryItem.ContainingFolder))
            {
                throw new Exception("Cannot save item, there is no containing folder defined - " + repositoryItem.GetType().FullName + ", " + repositoryItem.GetNameForFileName());
            }

            repositoryItem.UpdateBeforeSave();

            string txt              = RepositorySerializer.SerializeToString(repositoryItem);
            string filePath         = CreateRepositoryItemFileName(repositoryItem);
            RepositoryFolderBase rf = GetItemRepositoryFolder(repositoryItem);

            rf.SaveRepositoryItem(filePath, txt);
            repositoryItem.FileName = filePath;
            repositoryItem.FilePath = filePath;
            //RI.isDirty = false;  //TODO: make is dirty to work
            if (repositoryItem.DirtyStatus == Common.Enums.eDirtyStatus.Modified)
            {
                repositoryItem.DirtyStatus = Common.Enums.eDirtyStatus.NoChange;
            }
            repositoryItem.OnPropertyChanged(nameof(RepositoryItemBase.SourceControlStatus));
        }
Exemplo n.º 21
0
        public static string UpgradeSolutionXMLFileIfNeeded(string xmlFilePath, string xml = "")
        {
            if (string.IsNullOrEmpty(xml))
            {
                xml = File.ReadAllText(xmlFilePath);
            }

            long xmlGingerVersion = SolutionUpgrade.GetSolutonFileGingerVersionAsLong(xmlFilePath, xml);

            if (xmlGingerVersion <= 0)
            {
                return(null);                      //failed to get the version
            }
            if (RepositorySerializer.GetCurrentGingerVersionAsLong() > xmlGingerVersion)
            {
                //upgrade
                GingerCore.XMLConverters.XMLConverterBase.eGingerFileType FileType = XMLConverterBase.GetGingerFileTypeFromFilename(xmlFilePath);
                return(Upgrade(FileType, xml, xmlGingerVersion, xmlFilePath));
            }
            else
            {
                return(xml);
            }
        }
Exemplo n.º 22
0
        public void SaveSolution(bool showWarning = true, eSolutionItemToSave solutionItemToSave = eSolutionItemToSave.GeneralDetails)
        {
            bool doSave = false;

            if (!showWarning)
            {
                doSave = true;
            }
            else
            {
                Solution      lastSavedSolution    = LoadSolution(FilePath, false);
                string        extraChangedItems    = "";
                StringBuilder bldExtraChangedItems = new StringBuilder();

                if (solutionItemToSave != eSolutionItemToSave.GeneralDetails)
                {
                    if (this.Name != lastSavedSolution.Name || this.Account != lastSavedSolution.Account)
                    {
                        bldExtraChangedItems.Append("Solution General Details, ");
                    }
                }
                if (solutionItemToSave != eSolutionItemToSave.ALMSettings)
                {
                    if (!this.ALMConfigs.Equals(lastSavedSolution.ALMConfigs))
                    {
                        bldExtraChangedItems.Append("ALM Details, ");
                    }
                }
                if (solutionItemToSave != eSolutionItemToSave.SourceControlSettings)
                {
                    if (this.SourceControl != lastSavedSolution.SourceControl)
                    {
                        bldExtraChangedItems.Append("Source Control Details, ");
                    }
                }
                if (solutionItemToSave != eSolutionItemToSave.LoggerConfiguration)
                {
                    if (LoggerConfigurations != null)
                    {
                        if (LoggerConfigurations.DirtyStatus == Amdocs.Ginger.Common.Enums.eDirtyStatus.Modified || LoggerConfigurations.DirtyStatus == Amdocs.Ginger.Common.Enums.eDirtyStatus.NoTracked)
                        {
                            bldExtraChangedItems.Append("Execution Logger configuration, ");
                        }
                    }
                }
                if (solutionItemToSave != eSolutionItemToSave.ReportConfiguration)
                {
                    if (HTMLReportsConfigurationSetList != null && lastSavedSolution.HTMLReportsConfigurationSetList.Count != 0)
                    {
                        foreach (HTMLReportsConfiguration config in HTMLReportsConfigurationSetList)
                        {
                            if (config.DirtyStatus == Amdocs.Ginger.Common.Enums.eDirtyStatus.Modified || config.DirtyStatus == Amdocs.Ginger.Common.Enums.eDirtyStatus.NoTracked)
                            {
                                bldExtraChangedItems.Append("Report configuration");
                                break;
                            }
                        }
                    }
                }

                if (solutionItemToSave != eSolutionItemToSave.GlobalVariabels)
                {
                    if (Variables.Count != lastSavedSolution.Variables.Count)
                    {
                        bldExtraChangedItems.Append(GingerDicser.GetTermResValue(eTermResKey.Variables, "Global ", ", "));
                    }
                    else
                    {
                        foreach (VariableBase var in Variables)
                        {
                            if (var.DirtyStatus == Amdocs.Ginger.Common.Enums.eDirtyStatus.Modified || var.DirtyStatus == Amdocs.Ginger.Common.Enums.eDirtyStatus.NoTracked)
                            {
                                bldExtraChangedItems.Append(GingerDicser.GetTermResValue(eTermResKey.Variables, "Global ", ", "));
                                break;
                            }
                        }
                    }
                }
                if (solutionItemToSave != eSolutionItemToSave.TargetApplications)
                {
                    if (ApplicationPlatforms.Count != lastSavedSolution.ApplicationPlatforms.Count)
                    {
                        bldExtraChangedItems.Append("Target Applications, ");
                    }
                    else
                    {
                        foreach (ApplicationPlatform app in ApplicationPlatforms)
                        {
                            if (app.DirtyStatus == Amdocs.Ginger.Common.Enums.eDirtyStatus.Modified || app.DirtyStatus == Amdocs.Ginger.Common.Enums.eDirtyStatus.NoTracked)
                            {
                                bldExtraChangedItems.Append("Target Applications, ");
                                break;
                            }
                        }
                    }
                }
                if (solutionItemToSave != eSolutionItemToSave.Tags)
                {
                    if (Tags.Count != lastSavedSolution.Tags.Count)
                    {
                        bldExtraChangedItems.Append("Tags, ");
                    }
                    else
                    {
                        foreach (RepositoryItemTag tag in Tags)
                        {
                            if (tag.DirtyStatus == Amdocs.Ginger.Common.Enums.eDirtyStatus.Modified || tag.DirtyStatus == Amdocs.Ginger.Common.Enums.eDirtyStatus.NoTracked)
                            {
                                bldExtraChangedItems.Append("Tags, ");
                                break;
                            }
                        }
                    }
                }
                extraChangedItems = bldExtraChangedItems.ToString();
                if (string.IsNullOrEmpty(extraChangedItems))
                {
                    doSave = true;
                }
                else
                {
                    extraChangedItems = extraChangedItems.TrimEnd();
                    extraChangedItems = extraChangedItems.TrimEnd(new char[] { ',' });
                    if (Reporter.ToUser(eUserMsgKey.SolutionSaveWarning, extraChangedItems) == eUserMsgSelection.Yes)
                    {
                        doSave = true;
                    }
                }
            }

            if (doSave)
            {
                Reporter.ToStatus(eStatusMsgKey.SaveItem, null, "Solution Configurations", "item");
                RepositorySerializer.SaveToFile(this, FilePath);
                this.SetDirtyStatusToNoChange();
                Reporter.HideStatusMessage();
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// Update XML from old version to current version.
        /// </summary>
        /// <param name="GingerFileType"></param>
        /// <param name="xml"></param>
        /// <param name="xmlVersion"></param>
        /// <returns></returns>
        public static string Upgrade(XMLConverterBase.eGingerFileType GingerFileType, string xml, long xmlVersion, string xmlFilePath)
        {
            try
            {
                long currentXmlVersion   = xmlVersion;
                long latestGingerVersion = RepositorySerializer.GetCurrentGingerVersionAsLong();

                string updatedXML = null;
                string inputXML   = xml;

                // Need to repeat until we upgrade to latest version
                while (currentXmlVersion < latestGingerVersion)
                {
                    switch (currentXmlVersion)
                    {
                    case 10203:      // v 0.1.2.3
                        v10203_TO_v1020000 v1 = new v10203_TO_v1020000();
                        v1.Init(GingerFileType, inputXML, xmlFilePath);
                        v1.Convert();
                        updatedXML = v1.UpdatedXML;
                        inputXML   = updatedXML;
                        break;

                    case 1020000:      // v 1.2.2
                        v1020000_to_V1030000 v2 = new v1020000_to_V1030000();
                        v2.Init(GingerFileType, inputXML, xmlFilePath);
                        v2.Convert();
                        updatedXML = v2.UpdatedXML;
                        inputXML   = updatedXML;
                        break;

                    case 1030000:
                        v1030000_to_V1040000 v3 = new v1030000_to_V1040000();
                        v3.Init(GingerFileType, inputXML, xmlFilePath);
                        v3.Convert();
                        updatedXML = v3.UpdatedXML;
                        inputXML   = updatedXML;
                        break;

                    case 1040000:
                        v1040000_to_V1050000 v4 = new v1040000_to_V1050000();
                        v4.Init(GingerFileType, inputXML, xmlFilePath);
                        v4.Convert();
                        updatedXML = v4.UpdatedXML;
                        inputXML   = updatedXML;
                        break;

                    case 1050000:
                        v1050000_to_V1060000 v5 = new v1050000_to_V1060000();
                        v5.Init(GingerFileType, inputXML, xmlFilePath);
                        v5.Convert();
                        updatedXML = v5.UpdatedXML;
                        inputXML   = updatedXML;
                        break;

                    case 1060000:
                        v1060000_to_V1070000 v6 = new v1060000_to_V1070000();
                        v6.Init(GingerFileType, inputXML, xmlFilePath);
                        v6.Convert();
                        updatedXML = v6.UpdatedXML;
                        inputXML   = updatedXML;
                        break;

                    case 1070000:
                        v1070000_to_V1080000 v7 = new v1070000_to_V1080000();
                        v7.Init(GingerFileType, inputXML, xmlFilePath);
                        v7.Convert();
                        updatedXML = v7.UpdatedXML;
                        inputXML   = updatedXML;
                        break;

                    case 1080000:
                        v1080000_to_V1090000 v8 = new v1080000_to_V1090000();
                        v8.Init(GingerFileType, inputXML, xmlFilePath);
                        v8.Convert();
                        updatedXML = v8.UpdatedXML;
                        inputXML   = updatedXML;
                        break;

                    case 1090000:
                        v1090000_to_V2000000 v9 = new v1090000_to_V2000000();
                        v9.Init(GingerFileType, inputXML, xmlFilePath);
                        v9.Convert();
                        updatedXML = v9.UpdatedXML;
                        inputXML   = updatedXML;
                        break;

                    case 2000000:
                        v2000000_to_V2010000 v200 = new v2000000_to_V2010000();
                        v200.Init(GingerFileType, inputXML, xmlFilePath);
                        v200.Convert();
                        updatedXML = v200.UpdatedXML;
                        inputXML   = updatedXML;
                        break;

                    case 2010000:
                        v2010000_to_V2020000 v210 = new v2010000_to_V2020000();
                        v210.Init(GingerFileType, inputXML, xmlFilePath);
                        v210.Convert();
                        updatedXML = v210.UpdatedXML;
                        inputXML   = updatedXML;
                        break;

                    case 2020000:
                        v2020000_to_V2030000 v220 = new v2020000_to_V2030000();
                        v220.Init(GingerFileType, inputXML, xmlFilePath);
                        v220.Convert();
                        updatedXML = v220.UpdatedXML;
                        inputXML   = updatedXML;
                        break;

                    case 2030000:
                        v2030000_to_V2040000 v230 = new v2030000_to_V2040000();
                        v230.Init(GingerFileType, inputXML, xmlFilePath);
                        v230.Convert();
                        updatedXML = v230.UpdatedXML;
                        inputXML   = updatedXML;
                        break;

                    case 2040000:
                        v2040000_to_V2050000 v240 = new v2040000_to_V2050000();
                        v240.Init(GingerFileType, inputXML, xmlFilePath);
                        v240.Convert();
                        updatedXML = v240.UpdatedXML;
                        inputXML   = updatedXML;
                        break;

                    case 2050000:
                        v2050000_to_V2060000 v250 = new v2050000_to_V2060000();
                        v250.Init(GingerFileType, inputXML, xmlFilePath);
                        v250.Convert();
                        updatedXML = v250.UpdatedXML;
                        inputXML   = updatedXML;
                        break;

                    case 2060000:
                        v2060000_to_V2070000 v260 = new v2060000_to_V2070000();
                        v260.Init(GingerFileType, inputXML, xmlFilePath);
                        v260.Convert();
                        updatedXML = v260.UpdatedXML;
                        inputXML   = updatedXML;
                        break;

                    case 2070000:
                        v2070000_to_V3000000 v270 = new v2070000_to_V3000000();
                        v270.Init(GingerFileType, inputXML, xmlFilePath);
                        v270.Convert();
                        updatedXML = v270.UpdatedXML;
                        inputXML   = updatedXML;
                        break;

                    default:
                        Reporter.ToLog(eLogLevel.WARN, string.Format("Failed to upgrade the XML of the file '{0}' due to unknown version", xmlFilePath));
                        return(null);
                    }

                    if (string.IsNullOrEmpty(updatedXML) || currentXmlVersion < 0)
                    {
                        Reporter.ToLog(eLogLevel.WARN, string.Format("Failed to upgrade the XML of the file '{0}'", xmlFilePath));
                        return(null);
                    }

                    currentXmlVersion = SolutionUpgrade.GetSolutonFileGingerVersionAsLong(xmlFilePath, updatedXML);
                    if (currentXmlVersion <= 0)
                    {
                        return(null);                       //failed to get the version
                    }
                }

                return(updatedXML);
            }
            catch (Exception ex)
            {
                Reporter.ToLog(eLogLevel.WARN, string.Format("Failed to upgrade the XML of the file '{0}'", xmlFilePath), ex);
                return(null);
            }
        }
Exemplo n.º 24
0
        private void SetControls()
        {
            switch (mViewMode)
            {
            case SolutionUpgradePageViewMode.UpgradeSolution:
                ExplanationLable.Text = @"The Solution '" + mSolutionName + "' contains items which were created with older version/s of Ginger (see below), it is recommended to upgrade them to current version (" + RepositorySerializer.GetCurrentGingerVersion() + ") before continuing.";

                string BackupFolder = Path.Combine(mSolutionFolder, @"Backups\Backup_" + DateTime.Now.ToString("MM_dd_yyyy_HH_mm"));
                BackupFolderTextBox.Text = BackupFolder;
                FilesListBox.ItemsSource = mFilesToShow;
                App.ObjFieldBinding(DoNotAskAgainChkbox, CheckBox.IsCheckedProperty, App.UserProfile, nameof(UserProfile.DoNotAskToUpgradeSolutions));
                break;

            case SolutionUpgradePageViewMode.FailedUpgradeSolution:
                ExplanationLable.Text          = @"Upgrade failed for below files so they were not changed.";
                ExplanationLable.Foreground    = Brushes.Red;
                BackupFolderTextBox.Visibility = Visibility.Collapsed;
                BackupFolderPanel.Visibility   = Visibility.Collapsed;
                FilesListLable.Content         = "Items which Failed to be Upgraded:";
                FilesListBox.ItemsSource       = mFailedFiles;
                break;

            case SolutionUpgradePageViewMode.UpgradeGinger:
                ExplainRow.Height              = new GridLength(80);
                ExplanationLable.Text          = @"The Solution in '" + mSolutionFolder + "' contains items which were created with higher Ginger version/s (see below), for loading this Solution you must upgrade Ginger version to the highest version which was used.";
                BackupFolderPanel.Visibility   = System.Windows.Visibility.Collapsed;
                DoNotAskAgainChkbox.Visibility = System.Windows.Visibility.Collapsed;
                FilesListLable.Content         = "Items Created with Higher Version:";
                FilesListBox.ItemsSource       = mFilesToShow;
                break;
            }
        }
Exemplo n.º 25
0
 public void SaveToFile(string FilePath)
 {
     RepositorySerializer.SaveToFile(this, FilePath);
 }
Exemplo n.º 26
0
 public string FileExt(Type T)
 {
     return(RepositorySerializer.GetShortType(T));
 }