Example #1
0
        public void MeasureTransactionProcessing()
        {
            #region Set up Publisher
            var keysPublisher = EncryptionHandler.GenerateNewKeys();

            TransactionGenerator transactionGeneratorPublisher = new TransactionGenerator(keysPublisher.PrivateKey);
            var registrationPublisher = transactionGeneratorPublisher.InitializeAsNewPublisher(keysPublisher.PublicKey, "Austria", "Vienna", "Publisher");
            var votePublisher         = transactionGeneratorPublisher.GenerateVotingTransaction(registrationPublisher.TransactionId, true);

            PublisherNode publisher = new PublisherNode();
            publisher.User = new NodeManagement.Entities.UserProperties()
            {
                Keys        = keysPublisher,
                UserAddress = registrationPublisher.TransactionId,
                Username    = "******"
            };

            publisher.InitializeEmptyChain(registrationPublisher, votePublisher);
            Assert.IsTrue(publisher.participantHandler.HasPublisher(registrationPublisher.TransactionId));
            #endregion

            var referencePhysicianKeys      = EncryptionHandler.GenerateNewKeys();
            var referencePhysicianGenerator = new TransactionGenerator(referencePhysicianKeys.PrivateKey);
            var referencePhysician          = referencePhysicianGenerator.InitializeAsNewPhysician(referencePhysicianKeys.PrivateKey, "Austria", "Vienna", "Physician");
            var referencePhysicianVote      = transactionGeneratorPublisher.GenerateVotingTransaction(referencePhysician.TransactionId, true);

            var referencePatient   = referencePhysicianGenerator.GeneratePatientRegistrationTransaction("Austria", "Vienna", "1990");
            var referenceTreatment = referencePhysicianGenerator.GenerateTreatmentTransaction(referencePhysician.TransactionId, referencePatient.TransactionId);

            publisher.OnReceiveTransaction(referencePhysician);
            publisher.OnReceiveTransaction(referencePhysicianVote);
            publisher.OnReceiveTransaction(referencePatient);
            publisher.OnReceiveTransaction(referenceTreatment);

            publisher.BundleOpenTransactionsManually();
            publisher.PublishOpenBlocks(publisher);

            Assert.AreEqual(1, publisher.GetChain().Blockhead.Index);

            Random random = new Random();

            for (int i = 0; i < 50000; i++)
            {
                int choice = random.Next(1, 6);

                switch (choice)
                {
                case 1:
                    var keysNewPhysician = EncryptionHandler.GenerateNewKeys();

                    TransactionGenerator transactionGeneratorNewPhysician = new TransactionGenerator(keysNewPhysician.PrivateKey);
                    var transaction = transactionGeneratorNewPhysician.InitializeAsNewPhysician(keysNewPhysician.PublicKey, "Austria", "Vienna", "Physician");

                    Stopwatch stopwatch = new Stopwatch();
                    stopwatch.Start();
                    publisher.OnReceiveTransaction(transaction);
                    stopwatch.Stop();

                    string log = "PHYSICIAN\t"
                                 + (i % maxBlockSize)
                                 + "\t" + maxBlockSize
                                 + "\t" + publisher.GetChain().Blockhead.Index
                                 + "\t" + publisher.GetChain().GetTransactions().Count
                                 + "\t" + stopwatch.ElapsedMilliseconds
                                 + "\t" + GetRAMUsage()
                                 + "\n";
                    FileHandler.Append("D:\\DiagnosticChain\\DiagnosticChain\\TransactionLog.txt", log);
                    break;

                case 2:
                    transaction = referencePhysicianGenerator.GeneratePatientRegistrationTransaction("Austria", "Vienna", "Patient");

                    stopwatch = new Stopwatch();
                    stopwatch.Start();
                    publisher.OnReceiveTransaction(transaction);
                    stopwatch.Stop();

                    log = "PATIENT\t"
                          + (i % maxBlockSize)
                          + "\t" + maxBlockSize
                          + "\t" + publisher.GetChain().Blockhead.Index
                          + "\t" + publisher.GetChain().GetTransactions().Count
                          + "\t" + stopwatch.ElapsedMilliseconds
                          + "\t" + GetRAMUsage()
                          + "\n";
                    FileHandler.Append("D:\\DiagnosticChain\\DiagnosticChain\\TransactionLog.txt", log);
                    break;

                case 3:
                    var patients = (from x in publisher.GetChain().GetTransactions()
                                    where x.GetType() == typeof(PatientRegistrationTransaction)
                                    select x.TransactionId).ToList();
                    var p = patients.Count() > 1 ? patients[random.Next(1, patients.Count()) - 1] : referencePatient.TransactionId;
                    transaction = referencePhysicianGenerator.GenerateTreatmentTransaction(referencePhysician.TransactionId, p);

                    stopwatch = new Stopwatch();
                    stopwatch.Start();
                    publisher.OnReceiveTransaction(transaction);
                    stopwatch.Stop();

                    log = "TREATMENT\t"
                          + (i % maxBlockSize)
                          + "\t" + maxBlockSize
                          + "\t" + publisher.GetChain().Blockhead.Index
                          + "\t" + publisher.GetChain().GetTransactions().Count
                          + "\t" + stopwatch.ElapsedMilliseconds
                          + "\t" + GetRAMUsage()
                          + "\n";
                    FileHandler.Append("D:\\DiagnosticChain\\DiagnosticChain\\TransactionLog.txt", log);
                    break;

                case 4:
                    var treatments = (from x in publisher.GetChain().GetTransactions()
                                      where x.GetType() == typeof(TreatmentTransaction)
                                      select x.TransactionId).ToList();
                    var t = treatments.Count() > 1 ? treatments[random.Next(1, treatments.Count()) - 1] : referenceTreatment.TransactionId;
                    transaction = referencePhysicianGenerator.GenerateSymptomTransaction(t, new List <string>()
                    {
                        "Symptom"
                    });

                    stopwatch = new Stopwatch();
                    stopwatch.Start();
                    publisher.OnReceiveTransaction(transaction);
                    stopwatch.Stop();

                    log = "SYMPTOM\t"
                          + (i % maxBlockSize)
                          + "\t" + maxBlockSize
                          + "\t" + publisher.GetChain().Blockhead.Index
                          + "\t" + publisher.GetChain().GetTransactions().Count
                          + "\t" + stopwatch.ElapsedMilliseconds
                          + "\t" + GetRAMUsage()
                          + "\n";
                    FileHandler.Append("D:\\DiagnosticChain\\DiagnosticChain\\TransactionLog.txt", log);
                    break;

                case 5:
                    transaction = transactionGeneratorPublisher.GenerateVotingTransaction(referencePhysician.TransactionId, true);

                    stopwatch = new Stopwatch();
                    stopwatch.Start();
                    publisher.OnReceiveTransaction(transaction);
                    stopwatch.Stop();

                    log = "VOTING\t"
                          + (i % maxBlockSize)
                          + "\t" + maxBlockSize
                          + "\t" + publisher.GetChain().Blockhead.Index
                          + "\t" + publisher.GetChain().GetTransactions().Count
                          + "\t" + stopwatch.ElapsedMilliseconds
                          + "\t" + GetRAMUsage()
                          + "\n";
                    FileHandler.Append("D:\\DiagnosticChain\\DiagnosticChain\\TransactionLog.txt", log);
                    break;

                default:
                    break;
                }

                publisher.participantHandler.EvaluateParkedTransactions();

                if (i % maxBlockSize == 0)
                {
                    Stopwatch stopwatch = new Stopwatch();
                    stopwatch.Start();
                    publisher.BundleOpenTransactionsManually();
                    publisher.PublishOpenBlocks(publisher);
                    stopwatch.Stop();

                    string log = "BLOCK\t"
                                 + (i % maxBlockSize)
                                 + "\t" + maxBlockSize
                                 + "\t" + publisher.GetChain().Blockhead.Index
                                 + "\t" + publisher.GetChain().GetTransactions().Count
                                 + "\t" + stopwatch.ElapsedMilliseconds
                                 + "\n";
                    FileHandler.Append("D:\\DiagnosticChain\\DiagnosticChain\\BlockLog.txt", log);

                    stopwatch = new Stopwatch();
                    stopwatch.Start();
                    publisher.ValidateChain();
                    stopwatch.Stop();

                    log = "VALIDATION\t"
                          + (i % maxBlockSize)
                          + "\t" + maxBlockSize
                          + "\t" + publisher.GetChain().Blockhead.Index
                          + "\t" + publisher.GetChain().GetTransactions().Count
                          + "\t" + stopwatch.ElapsedMilliseconds
                          + "\n";
                    FileHandler.Append("D:\\DiagnosticChain\\DiagnosticChain\\ValidationLog.txt", log);

                    QueryNode query = new QueryNode();
                    query.UpdateChain(publisher.GetChain());

                    stopwatch = new Stopwatch();
                    stopwatch.Start();
                    query.ExtractData((PatientRegistrationTransaction p) => true,
                                      (TreatmentTransaction t) => true,
                                      (SymptomsTransaction s) => true,
                                      (DiagnosesTransaction d) => true);
                    stopwatch.Stop();

                    log = "QUERY\t"
                          + (i % maxBlockSize)
                          + "\t" + maxBlockSize
                          + "\t" + publisher.GetChain().Blockhead.Index
                          + "\t" + publisher.GetChain().GetTransactions().Count
                          + "\t" + stopwatch.ElapsedMilliseconds
                          + "\n";
                    FileHandler.Append("D:\\DiagnosticChain\\DiagnosticChain\\QueryLog.txt", log);
                }
            }
        }
Example #2
0
        public void GetBusinessFlowDependacies()
        {
            //Arrange
            string filePath = TestResources.GetTestResourcesFile(@"Solutions" + Path.DirectorySeparatorChar + "GlobalCrossSolution" + Path.DirectorySeparatorChar + "BusinessFlows" + Path.DirectorySeparatorChar + "Flow 1.Ginger.BusinessFlow.xml");

            //Act
            GlobalSolutionItem item = new GlobalSolutionItem(GlobalSolution.eImportItemType.Environments, filePath, GlobalSolutionUtils.Instance.ConvertToRelativePath(filePath), true, GlobalSolutionUtils.Instance.GetRepositoryItemName(filePath), "");

            GlobalSolutionUtils.Instance.AddDependaciesForBusinessFlows(item, ref SelectedItemsListToImport, ref VariableListToImport, ref EnvAppListToImport);

            //Assert
            Assert.AreEqual(SelectedItemsListToImport.Count, 12);
            Assert.IsNotNull(SelectedItemsListToImport.Where(x => x.ItemExtraInfo == "~\\\\Applications Models\\POM Models\\SeleniumDemoValid.Ginger.ApplicationPOMModel.xml"));
            Assert.IsNotNull(SelectedItemsListToImport.Where(x => x.ItemExtraInfo == "~\\\\SharedRepository\\Actions\\Browser Action.Ginger.Action.xml"));
            Assert.IsNotNull(SelectedItemsListToImport.Where(x => x.ItemExtraInfo == "~\\\\SharedRepository\\Actions\\UIElement Action.Ginger.Action.xml"));
            Assert.IsNotNull(SelectedItemsListToImport.Where(x => x.ItemExtraInfo == "~\\\\SharedRepository\\Activities\\Activity 2.Ginger.Activity.xml"));
            Assert.IsNotNull(SelectedItemsListToImport.Where(x => x.ItemExtraInfo == "~\\\\DataSources\\AccessDS.Ginger.DataSource.xml"));
            Assert.IsNotNull(SelectedItemsListToImport.Where(x => x.ItemExtraInfo == "~\\\\Documents\\bankCode3.xml"));
            Assert.IsNotNull(SelectedItemsListToImport.Where(x => x.ItemExtraInfo == "~\\\\Documents\\Multiple Values.xlsx"));
            Assert.IsNotNull(SelectedItemsListToImport.Where(x => x.ItemExtraInfo == "~\\\\Environments\\Test.Ginger.Environment.xml"));
            Assert.IsNotNull(SelectedItemsListToImport.Where(x => x.ItemExtraInfo == "NewVarString"));
            Assert.IsNotNull(SelectedItemsListToImport.Where(x => x.ItemExtraInfo == "MyWebApp"));
            Assert.IsNotNull(SelectedItemsListToImport.Where(x => x.ItemExtraInfo == "MyWebServicesApp"));
            Assert.IsNotNull(SelectedItemsListToImport.Where(x => x.ItemExtraInfo == "MyWindowsApp"));

            Assert.AreEqual(VariableListToImport.Count, 2);
            Assert.IsNotNull(VariableListToImport.Where(x => x.Name == "NewVarString"));
            Assert.IsNotNull(VariableListToImport.Where(x => x.Name == "NewVarPasswordString"));
            string strValuetoPass = EncryptionHandler.DecryptwithKey(VariableListToImport.Where(x => x.Name == "NewVarPasswordString").FirstOrDefault().Value, EncryptionHandler.GetDefaultKey());

            Assert.AreEqual(strValuetoPass, "ABCD");

            Assert.AreEqual(EnvAppListToImport.Count, 1);
            Assert.IsNotNull(EnvAppListToImport.Where(x => x.Name == "MyWebApp"));
        }
Example #3
0
        public void GetDependaciesForGlobalVariableUsingRegex()
        {
            //Arrange
            string filePath = TestResources.GetTestResourcesFile(@"Solutions" + Path.DirectorySeparatorChar + "GlobalCrossSolution" + Path.DirectorySeparatorChar + "BusinessFlows" + Path.DirectorySeparatorChar + "Flow 1.Ginger.BusinessFlow.xml");

            //Act
            GlobalSolutionUtils.Instance.AddDependaciesForGlobalVariable(filePath, ref SelectedItemsListToImport, ref VariableListToImport);

            //Assert
            Assert.AreEqual(VariableListToImport.Count, 2);
            Assert.IsNotNull(VariableListToImport.Where(x => x.Name == "NewVarString"));
            Assert.IsNotNull(VariableListToImport.Where(x => x.Name == "NewVarPasswordString"));
            string strValuetoPass = EncryptionHandler.DecryptwithKey(VariableListToImport.Where(x => x.Name == "NewVarPasswordString").FirstOrDefault().Value, EncryptionHandler.GetDefaultKey());

            Assert.AreEqual(strValuetoPass, "ABCD");
        }
Example #4
0
        public static string CreateDynamicRunSetXML(Solution solution, RunsetExecutor runsetExecutor, CLIHelper cliHelper)
        {
            runsetExecutor.RunSetConfig.UpdateRunnersBusinessFlowRunsList();

            DynamicGingerExecution dynamicExecution = new DynamicGingerExecution();

            dynamicExecution.SolutionDetails = new SolutionDetails();
            if (cliHelper.DownloadUpgradeSolutionFromSourceControl == true)
            {
                dynamicExecution.SolutionDetails.SourceControlDetails      = new SourceControlDetails();
                dynamicExecution.SolutionDetails.SourceControlDetails.Type = solution.SourceControl.GetSourceControlType.ToString();
                if (solution.SourceControl.GetSourceControlType == SourceControlBase.eSourceControlType.SVN)//added for supporting Jenkins way of config creation- need to improve it
                {
                    string modifiedURI = solution.SourceControl.SourceControlURL.TrimEnd(new char[] { '/' });
                    int    lastSlash   = modifiedURI.LastIndexOf('/');
                    modifiedURI = (lastSlash > -1) ? modifiedURI.Substring(0, lastSlash) : modifiedURI;
                    dynamicExecution.SolutionDetails.SourceControlDetails.Url = modifiedURI;
                }
                else
                {
                    dynamicExecution.SolutionDetails.SourceControlDetails.Url = solution.SourceControl.SourceControlURL.ToString();
                }
                dynamicExecution.SolutionDetails.SourceControlDetails.User              = solution.SourceControl.SourceControlUser;
                dynamicExecution.SolutionDetails.SourceControlDetails.Password          = EncryptionHandler.EncryptwithKey(solution.SourceControl.SourceControlPass);
                dynamicExecution.SolutionDetails.SourceControlDetails.PasswordEncrypted = "Y";
                if (solution.SourceControl.GetSourceControlType == SourceControlBase.eSourceControlType.GIT && solution.SourceControl.SourceControlProxyAddress.ToLower().ToString() == "true")
                {
                    dynamicExecution.SolutionDetails.SourceControlDetails.ProxyServer = solution.SourceControl.SourceControlProxyAddress.ToString();
                    dynamicExecution.SolutionDetails.SourceControlDetails.ProxyPort   = solution.SourceControl.SourceControlProxyPort.ToString();
                }
            }
            dynamicExecution.SolutionDetails.Path = solution.Folder;
            dynamicExecution.ShowAutoRunWindow    = cliHelper.ShowAutoRunWindow;

            AddRunset addRunset = new AddRunset();

            addRunset.Name          = "Dynamic_" + runsetExecutor.RunSetConfig.Name;
            addRunset.Environment   = runsetExecutor.RunsetExecutionEnvironment.Name;
            addRunset.RunAnalyzer   = cliHelper.RunAnalyzer;
            addRunset.RunInParallel = runsetExecutor.RunSetConfig.RunModeParallel;

            foreach (GingerRunner gingerRunner in runsetExecutor.RunSetConfig.GingerRunners)
            {
                AddRunner addRunner = new AddRunner();
                addRunner.Name = gingerRunner.Name;
                if (gingerRunner.UseSpecificEnvironment == true && string.IsNullOrEmpty(gingerRunner.SpecificEnvironmentName))
                {
                    addRunner.Environment = gingerRunner.SpecificEnvironmentName;
                }
                if (gingerRunner.RunOption != GingerRunner.eRunOptions.ContinueToRunall)
                {
                    addRunner.RunMode = gingerRunner.RunOption.ToString();
                }

                foreach (ApplicationAgent applicationAgent in gingerRunner.ApplicationAgents)
                {
                    addRunner.SetAgents.Add(new SetAgent()
                    {
                        AgentName = applicationAgent.AgentName, ApplicationName = applicationAgent.AppName
                    });
                }

                foreach (BusinessFlowRun businessFlowRun in gingerRunner.BusinessFlowsRunList)
                {
                    AddBusinessFlow addBusinessFlow = new AddBusinessFlow();
                    addBusinessFlow.Name = businessFlowRun.BusinessFlowName;
                    if (businessFlowRun.BusinessFlowCustomizedRunVariables.Count > 0)
                    {
                        addBusinessFlow.InputVariables = new System.Collections.Generic.List <InputVariable>();
                        foreach (VariableBase variableBase in businessFlowRun.BusinessFlowCustomizedRunVariables)
                        {
                            InputVariable inputVar = new InputVariable();
                            if (variableBase.ParentType != "Business Flow")
                            {
                                inputVar.VariableParentType = variableBase.ParentType;
                                inputVar.VariableParentName = variableBase.ParentName;
                            }
                            inputVar.VariableName  = variableBase.Name;
                            inputVar.VariableValue = variableBase.Value;

                            addBusinessFlow.InputVariables.Add(inputVar);
                        }
                    }
                    addRunner.AddBusinessFlows.Add(addBusinessFlow);
                }
                addRunset.AddRunners.Add(addRunner);
            }

            foreach (RunSetActionBase runSetOperation in runsetExecutor.RunSetConfig.RunSetActions)
            {
                if (runSetOperation is RunSetActionHTMLReportSendEmail)
                {
                    RunSetActionHTMLReportSendEmail runsetMailReport = (RunSetActionHTMLReportSendEmail)runSetOperation;
                    MailReport dynamicMailReport = new MailReport();
                    dynamicMailReport.Condition = runsetMailReport.Condition.ToString();
                    dynamicMailReport.RunAt     = runsetMailReport.RunAt.ToString();

                    dynamicMailReport.MailFrom = runsetMailReport.MailFrom;
                    dynamicMailReport.MailTo   = runsetMailReport.MailTo;
                    dynamicMailReport.MailCC   = runsetMailReport.MailCC;

                    dynamicMailReport.Subject  = runsetMailReport.Subject;
                    dynamicMailReport.Comments = runsetMailReport.Comments;

                    if (runsetMailReport.Email.EmailMethod == GingerCore.GeneralLib.Email.eEmailMethod.OUTLOOK)
                    {
                        dynamicMailReport.SendViaOutlook = true;
                    }
                    else
                    {
                        dynamicMailReport.SmtpDetails           = new SmtpDetails();
                        dynamicMailReport.SmtpDetails.Server    = runsetMailReport.Email.SMTPMailHost;
                        dynamicMailReport.SmtpDetails.Port      = runsetMailReport.Email.SMTPPort.ToString();
                        dynamicMailReport.SmtpDetails.EnableSSL = runsetMailReport.Email.EnableSSL.ToString();
                        if (runsetMailReport.Email.ConfigureCredential)
                        {
                            dynamicMailReport.SmtpDetails.User     = runsetMailReport.Email.SMTPUser;
                            dynamicMailReport.SmtpDetails.Password = runsetMailReport.Email.SMTPPass;
                        }
                    }

                    if (runsetMailReport.EmailAttachments.Where(x => x.AttachmentType == EmailAttachment.eAttachmentType.Report).FirstOrDefault() != null)
                    {
                        dynamicMailReport.IncludeAttachmentReport = true;
                    }
                    else
                    {
                        dynamicMailReport.IncludeAttachmentReport = false;
                    }

                    addRunset.AddRunsetOperations.Add(dynamicMailReport);
                }
                else if (runSetOperation is RunSetActionJSONSummary)
                {
                    JsonReport dynamicJsonReport = new JsonReport();
                    addRunset.AddRunsetOperations.Add(dynamicJsonReport);
                }
            }
            dynamicExecution.AddRunsets.Add(addRunset);

            string content = ConvertDynamicExecutionToXML(dynamicExecution);

            return(content);
        }
        public void SolutionPomElementsLazyLoadTest_Loaded()
        {
            //Arrange
            WorkSpace.Instance.OpenSolution(Path.Combine(TestResources.GetTestResourcesFolder(@"Solutions"), "BasicSimple"), EncryptionHandler.GetDefaultKey());
            SolutionRepository SR = WorkSpace.Instance.SolutionRepository;

            //Act
            ObservableList <ApplicationPOMModel> poms     = SR.GetAllRepositoryItems <ApplicationPOMModel>();
            ObservableList <ElementInfo>         unMapped = poms[0].UnMappedUIElements;
            ObservableList <ElementInfo>         mapped   = poms[0].MappedUIElements;

            //Assert
            Assert.AreEqual(poms.Count, 1, "Validating POMs were loaded");
            Assert.AreEqual(poms[0].UnMappedUIElementsLazyLoad, false, "Validating POM Un Mappped Elements were loaded 1");
            //Assert.AreEqual(unMapped.Count, 1, "Validating POM Un Mappped Elements were loaded 2"); //TODO: move HtmlElementInfo to .NET core project for enabeling this Assert
            Assert.AreEqual(poms[0].MappedUIElementsLazyLoad, false, "Validating POM Mappped Elements were not loaded 1");
            //Assert.AreEqual(mapped.Count, 15, "Validating POM Mappped Elements were not loaded 2 "); //TODO: move HtmlElementInfo to .NET core project for enabeling this Assert
        }
Example #6
0
 private void LoadALMDetailsFromJSON(GingerExecConfig gingerExecConfig)
 {
     foreach (AlmDetails almDetails in gingerExecConfig.AlmsDetails)
     {
         ALMIntegration.eALMType almTypeToConfigure;
         if (Enum.TryParse <ALMIntegration.eALMType>(almDetails.ALMType, out almTypeToConfigure))
         {
             try
             {
                 ALMConfig solutionAlmConfig = WorkSpace.Instance.Solution.ALMConfigs.FirstOrDefault(x => x.AlmType == almTypeToConfigure);
                 if (solutionAlmConfig == null)
                 {
                     //ADD
                     solutionAlmConfig = new ALMConfig()
                     {
                         AlmType = almTypeToConfigure
                     };
                     WorkSpace.Instance.Solution.ALMConfigs.Add(solutionAlmConfig);
                 }
                 ALMUserConfig userProfileAlmConfig = WorkSpace.Instance.UserProfile.ALMUserConfigs.FirstOrDefault(x => x.AlmType == almTypeToConfigure);
                 if (userProfileAlmConfig == null)
                 {
                     //ADD
                     userProfileAlmConfig = new ALMUserConfig()
                     {
                         AlmType = almTypeToConfigure
                     };
                     WorkSpace.Instance.UserProfile.ALMUserConfigs.Add(userProfileAlmConfig);
                 }
                 if (almDetails.ALMSubType != null)
                 {
                     solutionAlmConfig.JiraTestingALM = (ALMIntegration.eTestingALMType)Enum.Parse(typeof(ALMIntegration.eTestingALMType), almDetails.ALMSubType);
                 }
                 if (almDetails.ServerURL != null)
                 {
                     solutionAlmConfig.ALMServerURL    = almDetails.ServerURL;
                     userProfileAlmConfig.ALMServerURL = almDetails.ServerURL;
                 }
                 if (almDetails.User != null)
                 {
                     solutionAlmConfig.ALMUserName    = almDetails.User;
                     userProfileAlmConfig.ALMUserName = almDetails.User;
                 }
                 if (almDetails.Password != null)
                 {
                     if (almDetails.PasswordEncrypted)
                     {
                         string pass = EncryptionHandler.DecryptwithKey(almDetails.Password);
                         solutionAlmConfig.ALMPassword    = pass;
                         userProfileAlmConfig.ALMPassword = pass;
                     }
                     else
                     {
                         solutionAlmConfig.ALMPassword    = almDetails.Password;
                         userProfileAlmConfig.ALMPassword = almDetails.Password;
                     }
                 }
                 if (almDetails.Domain != null)
                 {
                     solutionAlmConfig.ALMDomain = almDetails.Domain;
                 }
                 if (almDetails.Project != null)
                 {
                     solutionAlmConfig.ALMProjectName = almDetails.Project;
                 }
                 if (almDetails.ProjectKey != null)
                 {
                     solutionAlmConfig.ALMProjectKey = almDetails.ProjectKey;
                 }
                 if (almDetails.ConfigPackageFolderPath != null)
                 {
                     solutionAlmConfig.ALMConfigPackageFolderPath    = almDetails.ConfigPackageFolderPath;
                     userProfileAlmConfig.ALMConfigPackageFolderPath = almDetails.ConfigPackageFolderPath;
                 }
                 if (almDetails.UseRest != null)
                 {
                     solutionAlmConfig.UseRest = (bool)almDetails.UseRest;
                 }
                 if (almDetails.IsDefault != null)
                 {
                     if (almDetails.IsDefault == true)
                     {
                         //clear previous default
                         ALMConfig currentDefAlm = WorkSpace.Instance.Solution.ALMConfigs.Where(x => x.DefaultAlm == true).FirstOrDefault();
                         currentDefAlm.DefaultAlm = false;
                     }
                     solutionAlmConfig.DefaultAlm = (bool)almDetails.IsDefault;
                 }
             }
             catch (Exception ex)
             {
                 throw new Exception(string.Format("Failed to load the ALM type: '{0}' details, due to error: '{1}'", almDetails.ALMType, ex.Message), ex);
             }
         }
         else
         {
             throw new Exception(string.Format("Failed to find the ALM type: '{0}'", almDetails.ALMType));
         }
     }
 }
Example #7
0
        private bool ProcessCommandLineArgs()
        {
            // New option with one arg to config file
            // resole spaces and quotes mess in commnd arg + more user friednly to edit
            // We expect only AutoRun --> File location
            try
            {
                string[] Args = Environment.GetCommandLineArgs();

                // We xpect Autorun as arg[1]
                string[] arg1 = Args[1].Split('=');

                if (arg1[0] != "ConfigFile")
                {
                    Reporter.ToLog(eLogLevel.ERROR, "'ConfigFile' argument was not found.");
                    return(false);
                }

                string AutoRunFileName = arg1[1];

                Reporter.ToLog(eLogLevel.INFO, "Reading all arguments from the Config file placed at: '" + AutoRunFileName + "'");
                string[] lines = System.IO.File.ReadAllLines(AutoRunFileName);

                string scURL  = null;
                string scUser = null;
                string scPswd = null;

                foreach (string arg in lines)
                {
                    int    i     = arg.IndexOf('=');
                    string param = arg.Substring(0, i).Trim();
                    string value = arg.Substring(i + 1).Trim();

                    switch (param)
                    {
                    case "SourceControlType":
                        Reporter.ToLogAndConsole(eLogLevel.INFO, "Selected SourceControlType: '" + value + "'");
                        if (value.Equals("GIT"))
                        {
                            App.UserProfile.SourceControlType = SourceControlBase.eSourceControlType.GIT;
                        }
                        else if (value.Equals("SVN"))
                        {
                            App.UserProfile.SourceControlType = SourceControlBase.eSourceControlType.SVN;
                        }
                        else
                        {
                            App.UserProfile.SourceControlType = SourceControlBase.eSourceControlType.None;
                        }
                        break;

                    case "SourceControlUrl":
                        Reporter.ToLogAndConsole(eLogLevel.INFO, "Selected SourceControlUrl: '" + value + "'");
                        if (App.UserProfile.SourceControlType == SourceControlBase.eSourceControlType.SVN)
                        {
                            if (!value.ToUpper().Contains("/SVN") && !value.ToUpper().Contains("/SVN/"))
                            {
                                value = value + "svn/";
                            }
                            if (!value.ToUpper().EndsWith("/"))
                            {
                                value = value + "/";
                            }
                        }
                        App.UserProfile.SourceControlURL = value;
                        scURL = value;
                        break;

                    case "SourceControlUser":
                        Reporter.ToLogAndConsole(eLogLevel.INFO, "Selected SourceControlUser: '******'");
                        if (App.UserProfile.SourceControlType == SourceControlBase.eSourceControlType.GIT && value == "")
                        {
                            value = "Test";
                        }
                        App.UserProfile.SourceControlUser = value;
                        scUser = value;
                        break;

                    case "SourceControlPassword":
                        Reporter.ToLogAndConsole(eLogLevel.INFO, "Selected SourceControlPassword: '******'");
                        App.UserProfile.SourceControlPass = value;
                        scPswd = value;
                        break;

                    case "PasswordEncrypted":
                        Reporter.ToLogAndConsole(eLogLevel.INFO, "PasswordEncrypted: '" + value + "'");
                        string pswd = App.UserProfile.SourceControlPass;
                        if (value == "Y")
                        {
                            pswd = EncryptionHandler.DecryptwithKey(App.UserProfile.SourceControlPass, App.ENCRYPTION_KEY);
                        }
                        if (App.UserProfile.SourceControlType == SourceControlBase.eSourceControlType.GIT && pswd == "")
                        {
                            pswd = "Test";
                        }
                        App.UserProfile.SourceControlPass = pswd;
                        break;

                    case "SourceControlProxyServer":
                        Reporter.ToLogAndConsole(eLogLevel.INFO, "Selected SourceControlProxyServer: '" + value + "'");
                        if (value == "")
                        {
                            App.UserProfile.SolutionSourceControlConfigureProxy = false;
                        }
                        else
                        {
                            App.UserProfile.SolutionSourceControlConfigureProxy = true;
                        }
                        if (value != "" && !value.ToUpper().StartsWith("HTTP://"))
                        {
                            value = "http://" + value;
                        }
                        App.UserProfile.SolutionSourceControlProxyAddress = value;
                        break;

                    case "SourceControlProxyPort":
                        if (value == "")
                        {
                            App.UserProfile.SolutionSourceControlConfigureProxy = false;
                        }
                        else
                        {
                            App.UserProfile.SolutionSourceControlConfigureProxy = true;
                        }
                        Reporter.ToLogAndConsole(eLogLevel.INFO, "Selected SourceControlProxyPort: '" + value + "'");
                        App.UserProfile.SolutionSourceControlProxyPort = value;
                        break;

                    case "Solution":
                        if (scURL != null && scUser != "" && scPswd != null)
                        {
                            Reporter.ToLogAndConsole(eLogLevel.INFO, "Downloading Solution from source control");
                            if (value.IndexOf(".git") != -1)
                            {
                                App.DownloadSolution(value.Substring(0, value.IndexOf(".git") + 4));
                            }
                            else
                            {
                                App.DownloadSolution(value);
                            }
                        }
                        Reporter.ToLog(eLogLevel.INFO, "Loading the Solution: '" + value + "'");
                        try
                        {
                            if (App.SetSolution(value) == false)
                            {
                                Reporter.ToLog(eLogLevel.ERROR, "Failed to load the Solution");
                                return(false);
                            }
                        }
                        catch (Exception ex)
                        {
                            Reporter.ToLog(eLogLevel.ERROR, "Failed to load the Solution");
                            Reporter.ToLog(eLogLevel.ERROR, $"Method - {MethodBase.GetCurrentMethod().Name}, Error - {ex.Message}");
                            return(false);
                        }
                        break;

                    case "Env":
                        Reporter.ToLog(eLogLevel.INFO, "Selected Environment: '" + value + "'");
                        ProjEnvironment env = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <ProjEnvironment>().Where(x => x.Name.ToLower().Trim() == value.ToLower().Trim()).FirstOrDefault();
                        if (env != null)
                        {
                            RunsetExecutionEnvironment = env;
                        }
                        else
                        {
                            Reporter.ToLog(eLogLevel.ERROR, "Failed to find matching Environment in the Solution");
                            return(false);
                        }
                        break;

                    case "RunSet":
                        Reporter.ToLog(eLogLevel.INFO, string.Format("Selected {0}: '{1}'", GingerDicser.GetTermResValue(eTermResKey.RunSet), value));
                        ObservableList <RunSetConfig> RunSets = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <RunSetConfig>();
                        RunSetConfig runSetConfig             = RunSets.Where(x => x.Name.ToLower().Trim() == value.ToLower().Trim()).FirstOrDefault();
                        if (runSetConfig != null)
                        {
                            App.RunsetExecutor.RunSetConfig = runSetConfig;
                        }
                        else
                        {
                            Reporter.ToLog(eLogLevel.ERROR, string.Format("Failed to find matching {0} in the Solution", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
                            return(false);
                        }
                        break;

                    default:
                        Reporter.ToLog(eLogLevel.ERROR, "Un Known argument: '" + param + "'");
                        return(false);
                    }
                }

                if (RunSetConfig != null && RunsetExecutionEnvironment != null)
                {
                    return(true);
                }
                else
                {
                    Reporter.ToLog(eLogLevel.ERROR, "Missing key arguments which required for execution");
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Reporter.ToLog(eLogLevel.ERROR, "Exception occurred during command line arguments processing", ex);
                return(false);
            }
        }
Example #8
0
        static void Main(string[] args)
        {
            //Encrypt plain text in C# with a random password
            string plainText = "This is my secret text!";
            //You can also use the built in password generator!!
            string passPhrase = PasswordGenerator.GenerateRandomPassword(20);

            passPhrase = "This_is_my_password!";


            // Uses by default "Scrypt" as the Password Derivation method. If you want to change this, you have to set
            // EncryptionOptions (create an object of the class)
            var enc = EncryptionHandler.Encrypt(plainText, passPhrase);

            Console.WriteLine("Plaintext: 'This is my secret text' with password 'This_is_my_password!' results in ciphertext: " + enc);

            var dec3 = EncryptionHandler.Decrypt(enc, passPhrase);

            Console.WriteLine("And decrypting again: " + dec3);
            Console.WriteLine("Please start the index.html to see the same in Javascript. Encryption / Decryption run in both ways and can be interchanged between C# and JS!");

            /*
             * Testing binary encryption
             *
             */

            var file = File.ReadAllBytes(@"cartman.png");
            var iv   = Encoding.ASCII.GetBytes("iv_is_16_long___"); // Usually, don't produce your own IVs!
            var salt = Encoding.UTF8.GetBytes("This_is_my_salt");   // Usually, don't produce your own Salt!
            var enc2 = EncryptionHandler.BinaryEncryptWithStaticIv(file, "This_is_my_password!", new EncryptionOptions("scrypt", salt, iv));

            File.WriteAllBytes("cartman.enc", enc2.CipherOutput);
            enc2.CipherOutput = null;
            var enc3 = enc2.ConvertToCipherTextObject();
            var json = JsonConvert.SerializeObject(enc3, Formatting.None);

            File.WriteAllText("cartman-settings.txt", json);

            /*
             * Testing Scrypt
             * The recommended parameters for interactive logins as of 2009 are
             * iterationCount=16384, blockSize=8, threadCount=1, those are the default values.
             * They should be increased as memory latency and CPU parallelism increases.
             */

            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            // NOW RUNNING SCRYPT
            string hashString = ScryptHandler.Hash(passPhrase, "This_is_my_SALT!", 16384);

            stopWatch.Stop();

            Console.WriteLine("\r\nTesting Scrypt with the password 'This_is_my_password!': " + hashString);
            bool compare = ScryptHandler.ComparePasswordWithHash("This_is_my_password!", hashString);

            if (compare)
            {
                Console.WriteLine("The password matches with the stored hash!");
            }
            else
            {
                Console.WriteLine("The password does not match with the stored hash!");
            }

            // Get the elapsed time as a TimeSpan value.
            TimeSpan ts = stopWatch.Elapsed;

            // Format and display the TimeSpan value.
            string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                               ts.Hours, ts.Minutes, ts.Seconds,
                                               ts.Milliseconds / 10);

            Console.WriteLine("Time elapsed in HH:MM:SS (only for creating the hash, not checking): " + elapsedTime);
        }
Example #9
0
        public void RegistrateAndVotePublisher()
        {
            #region Set up Publisher A
            var keysA = EncryptionHandler.GenerateNewKeys();

            TransactionGenerator transactionGeneratorA = new TransactionGenerator(keysA.PrivateKey);
            var registrationA = transactionGeneratorA.InitializeAsNewPublisher(keysA.PublicKey, "Austria", "Vienna", "PublisherA");
            var voteA         = transactionGeneratorA.GenerateVotingTransaction(registrationA.TransactionId, true);

            PublisherNode publisherA = new PublisherNode();
            publisherA.User = new NodeManagement.Entities.UserProperties()
            {
                Keys        = keysA,
                UserAddress = registrationA.TransactionId,
                Username    = "******"
            };

            publisherA.InitializeEmptyChain(registrationA, voteA);

            Assert.IsTrue(publisherA.participantHandler.HasPublisher(registrationA.TransactionId));
            #endregion

            #region Set up Publisher B
            var keysB = EncryptionHandler.GenerateNewKeys();

            TransactionGenerator transactionGeneratorB = new TransactionGenerator(keysB.PrivateKey);
            var registrationB = transactionGeneratorB.InitializeAsNewPublisher(keysB.PublicKey, "Austria", "Vienna", "PublisherB");

            PublisherNode publisherB = new PublisherNode();
            publisherB.User = new NodeManagement.Entities.UserProperties()
            {
                Keys        = keysB,
                UserAddress = registrationB.TransactionId,
                Username    = "******"
            };

            publisherB.OnReceiveChain(publisherA.GetChain());

            publisherB.OnReceiveTransaction(registrationB);
            publisherB.BundleOpenTransactionsManually();
            publisherB.PublishOpenBlocks(publisherB);
            #endregion

            Assert.IsFalse(publisherA.participantHandler.HasPublisher(registrationB.TransactionId));
            Assert.IsFalse(publisherB.participantHandler.HasPublisher(registrationB.TransactionId));

            #region Authorize Publisher B
            publisherA.OnReceiveChain(publisherB.GetChainDelta(0));

            Assert.AreEqual(publisherA.GetChain().AsXML(), publisherB.GetChain().AsXML());

            var voteB = transactionGeneratorA.GenerateVotingTransaction(registrationB.TransactionId, true);
            publisherA.OnReceiveTransaction(voteB);
            publisherA.BundleOpenTransactionsManually();
            publisherA.PublishOpenBlocks(publisherA);
            publisherB.OnReceiveChain(publisherA.GetChainDelta(1));

            Assert.AreEqual(publisherA.GetChain().AsXML(), publisherB.GetChain().AsXML());
            #endregion

            Assert.IsTrue(publisherA.participantHandler.HasPublisher(registrationB.TransactionId));
            Assert.IsTrue(publisherB.participantHandler.HasPublisher(registrationB.TransactionId));
        }
 public void Sign(RSAParameters privateKey)
 {
     SenderVerification = EncryptionHandler.Sign(AsString(), privateKey);
 }
 public bool ValidateTransactionIntegrity(RSAParameters publicKey)
 {
     return(EncryptionHandler.VerifiySignature(AsString(), SenderVerification, publicKey));
 }
        public void RunsetRunnersLazyLoadTest_Loaded()
        {
            //Arrange
            WorkSpace.Instance.OpenSolution(Path.Combine(TestResources.GetTestResourcesFolder(@"Solutions"), "BasicSimple"), EncryptionHandler.GetDefaultKey());
            SolutionRepository SR = WorkSpace.Instance.SolutionRepository;

            //Act
            ObservableList <RunSetConfig> runSetConfigs = SR.GetAllRepositoryItems <RunSetConfig>();
            ObservableList <GingerRunner> runners       = runSetConfigs[0].GingerRunners;

            //Assert
            Assert.AreEqual(runSetConfigs.Count, 1, "Validating run sets were loaded");
            Assert.AreEqual(runSetConfigs[0].GingerRunnersLazyLoad, false, "Validating run set runners were loaded 1");
            Assert.AreEqual(runners.Count, 1, "Validating run set runners were loaded 2");
        }
        public void ActivityVariablesLazyLoadTest_Loaded()
        {
            //Arrange
            WorkSpace.Instance.OpenSolution(Path.Combine(TestResources.GetTestResourcesFolder(@"Solutions"), "BasicSimple"), EncryptionHandler.GetDefaultKey());
            SolutionRepository SR = WorkSpace.Instance.SolutionRepository;

            //Act
            ObservableList <BusinessFlow> bfs        = SR.GetAllRepositoryItems <BusinessFlow>();
            ObservableList <Activity>     activities = bfs[0].Activities;
            ObservableList <VariableBase> variables  = activities[0].Variables;

            //Assert
            Assert.AreEqual(bfs.Count, 1, "Validating Bfs were loaded");
            Assert.AreEqual(bfs[0].ActivitiesLazyLoad, false, "Validating Bf Activities were loaded 1");
            Assert.AreEqual(activities.Count, 1, "Validating Bf Activities were loaded 2");
            Assert.AreEqual(activities[0].VariablesLazyLoad, false, "Validating Activity variables were loaded 1");
            Assert.AreEqual(variables.Count, 1, "Validating Activity variables were loaded 2 ");
        }
        public void BFVariablesLazyLoadTest_NotLoaded()
        {
            //Arrange
            WorkSpace.Instance.OpenSolution(Path.Combine(TestResources.GetTestResourcesFolder(@"Solutions"), "BasicSimple"), EncryptionHandler.GetDefaultKey());
            SolutionRepository SR = WorkSpace.Instance.SolutionRepository;

            //Act
            ObservableList <BusinessFlow> bfs = SR.GetAllRepositoryItems <BusinessFlow>();

            //Assert
            Assert.AreEqual(bfs.Count, 1, "Validating Bfs were loaded");
            Assert.AreEqual(bfs[0].VariablesLazyLoad, true, "Validating Bf Variables were not loaded");
        }
Example #15
0
        public bool OpenConnection(Dictionary <string, string> parameters)
        {
            KeyvalParamatersList = parameters;
            GetConnectionString(parameters);
            try
            {
                ///
                /// ConnectionString format
                /// "mongodb://*****:*****@localhost/DB"
                ///
                if (ConnectionString != null && !string.IsNullOrEmpty(ConnectionString))
                {
                    var connectionString = ConnectionString;
                    DbName = MongoUrl.Create(ConnectionString).DatabaseName;
                    if (DbName == null)
                    {
                        return(false);
                    }
                    mMongoClient = new MongoClient(connectionString);
                }
                else
                {
                    ///
                    /// Host format
                    /// "mongodb://HostOrIP:27017/DBName"
                    ///
                    string TNS = parameters.FirstOrDefault(pair => pair.Key == "TNS").Value;

                    string[] HostPortDB = TNS.Split('/');

                    string[] HostPort = HostPortDB[0].Split(':');

                    //need to get db name

                    MongoCredential     mongoCredential     = null;
                    MongoClientSettings mongoClientSettings = null;
                    if (HostPort.Length == 2 && HostPortDB.Length == 2)
                    {
                        if (string.IsNullOrEmpty(HostPortDB[HostPortDB.Length - 1]))
                        {
                            Reporter.ToLog(eLogLevel.ERROR, "Database is not mentioned in the TNS/Host.");
                            return(false);
                        }

                        if (string.IsNullOrEmpty(Password) && string.IsNullOrEmpty(User))
                        {
                            mongoClientSettings = new MongoClientSettings
                            {
                                Server = new MongoServerAddress(HostPort[0], Convert.ToInt32(HostPort[1]))
                            };
                        }
                        else
                        {
                            bool   res          = false;
                            String deCryptValue = EncryptionHandler.DecryptString(Password, ref res, false);
                            if (res == true)
                            {
                                mongoCredential = MongoCredential.CreateCredential(HostPortDB[HostPortDB.Length - 1], User, deCryptValue);
                            }
                            else
                            {
                                mongoCredential = MongoCredential.CreateCredential(HostPortDB[HostPortDB.Length - 1], User, Password);
                            }
                            mongoClientSettings = new MongoClientSettings
                            {
                                Server = new MongoServerAddress(HostPort[0], Convert.ToInt32(HostPort[1])),
                                //UseSsl = true,
                                Credentials = new[] { mongoCredential }
                            };
                        }
                        DbName       = HostPortDB[HostPortDB.Length - 1];
                        mMongoClient = new MongoClient(mongoClientSettings);
                    }
                    else
                    {
                        return(false);
                    }
                }
                //check dbname is present in the dblist
                if (GetDatabaseList().Contains(DbName))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                Reporter.ToLog(eLogLevel.ERROR, "Failed to connect to Mongo DB", e);
                return(false);
            }
        }
Example #16
0
        public void ConsolidateChains()
        {
            #region Set up Publisher A
            var keysA = EncryptionHandler.GenerateNewKeys();

            TransactionGenerator transactionGeneratorA = new TransactionGenerator(keysA.PrivateKey);
            var registrationA = transactionGeneratorA.InitializeAsNewPublisher(keysA.PublicKey, "Austria", "Vienna", "PublisherA");
            var voteA         = transactionGeneratorA.GenerateVotingTransaction(registrationA.TransactionId, true);

            PublisherNode publisherA = new PublisherNode();
            publisherA.User = new NodeManagement.Entities.UserProperties()
            {
                Keys        = keysA,
                UserAddress = registrationA.TransactionId,
                Username    = "******"
            };

            publisherA.InitializeEmptyChain(registrationA, voteA);
            #endregion

            #region Set up Publisher B
            var keysB = EncryptionHandler.GenerateNewKeys();

            TransactionGenerator transactionGeneratorB = new TransactionGenerator(keysB.PrivateKey);
            var registrationB = transactionGeneratorB.InitializeAsNewPublisher(keysB.PublicKey, "Austria", "Vienna", "PublisherB");

            PublisherNode publisherB = new PublisherNode();
            publisherB.User = new NodeManagement.Entities.UserProperties()
            {
                Keys        = keysB,
                UserAddress = registrationB.TransactionId,
                Username    = "******"
            };

            publisherB.OnReceiveChain(publisherA.GetChain());

            publisherB.OnReceiveTransaction(registrationB);
            publisherB.BundleOpenTransactionsManually();
            publisherB.PublishOpenBlocks(publisherB);
            #endregion

            #region Authorize Publisher B
            publisherA.OnReceiveChain(publisherB.GetChainDelta(0));

            Assert.AreEqual(publisherA.GetChain().AsXML(), publisherB.GetChain().AsXML());

            var voteB = transactionGeneratorA.GenerateVotingTransaction(registrationB.TransactionId, true);
            publisherA.OnReceiveTransaction(voteB);
            publisherA.BundleOpenTransactionsManually();
            publisherA.PublishOpenBlocks(publisherA);
            publisherB.OnReceiveChain(publisherA.GetChainDelta(1));

            Assert.AreEqual(publisherA.GetChain().AsXML(), publisherB.GetChain().AsXML());
            #endregion

            var transactionA = transactionGeneratorA.GenerateVotingTransaction(registrationB.TransactionId, true);
            var transactionB = transactionGeneratorB.GenerateVotingTransaction(registrationA.TransactionId, true);
            var transactionC = transactionGeneratorB.GenerateVotingTransaction(registrationA.TransactionId, true);

            #region Send transactions to publishers
            publisherA.OnReceiveTransaction(transactionA);
            publisherA.BundleOpenTransactionsManually();
            publisherA.PublishOpenBlocks(publisherA);

            publisherB.OnReceiveTransaction(transactionB);
            publisherB.BundleOpenTransactionsManually();
            publisherB.PublishOpenBlocks(publisherB);

            publisherB.OnReceiveTransaction(transactionC);
            publisherB.BundleOpenTransactionsManually();
            publisherB.PublishOpenBlocks(publisherB);
            #endregion

            publisherA.OnReceiveChain(publisherB.GetChainDelta(2));

            var hit = from t in publisherA.GetChain().GetTransactions()
                      where t.TransactionId == transactionA.TransactionId
                      select t;
            Assert.AreEqual(hit.Count(), 0);

            publisherA.BundleOpenTransactionsManually();
            publisherA.PublishOpenBlocks(publisherA);

            hit = from t in publisherA.GetChain().GetTransactions()
                  where t.TransactionId == transactionA.TransactionId
                  select t;
            Assert.AreEqual(1, hit.Count());
        }
Example #17
0
        public override bool Connect()
        {
            try
            {
                ///
                /// ConnectionString format
                /// "mongodb://*****:*****@localhost/DB"
                ///
                if (Db.ConnectionString != null && !string.IsNullOrEmpty(Db.ConnectionString))
                {
                    var connectionString = Db.ConnectionStringCalculated.ToString();
                    DbName = MongoUrl.Create(Db.ConnectionStringCalculated.ToString()).DatabaseName;
                    if (DbName == null)
                    {
                        return(false);
                    }
                    mMongoClient = new MongoClient(connectionString);
                }
                else
                {
                    ///
                    /// Host format
                    /// "mongodb://HostOrIP:27017/DBName"
                    ///
                    string[] HostPortDB = Db.TNSCalculated.Split('/');
                    string[] HostPort   = HostPortDB[0].Split(':');
                    //need to get db name

                    MongoCredential     mongoCredential     = null;
                    MongoClientSettings mongoClientSettings = null;
                    if (HostPort.Length == 2 && HostPortDB.Length == 2)
                    {
                        if (string.IsNullOrEmpty(HostPortDB[HostPortDB.Length - 1]))
                        {
                            Reporter.ToLog(eLogLevel.ERROR, "Database is not mentioned in the TNS/Host.");
                            return(false);
                        }

                        if (string.IsNullOrEmpty(Db.Pass) && string.IsNullOrEmpty(Db.User))
                        {
                            mongoClientSettings = new MongoClientSettings
                            {
                                Server = new MongoServerAddress(HostPort[0], Convert.ToInt32(HostPort[1]))
                            };
                        }
                        else
                        {
                            bool   res          = false;
                            String deCryptValue = EncryptionHandler.DecryptString(Db.PassCalculated.ToString(), ref res, false);
                            if (res == true)
                            {
                                mongoCredential = MongoCredential.CreateCredential(HostPortDB[HostPortDB.Length - 1], Db.UserCalculated, deCryptValue);
                            }
                            else
                            {
                                mongoCredential = MongoCredential.CreateCredential(HostPortDB[HostPortDB.Length - 1], Db.UserCalculated, Db.PassCalculated.ToString());
                            }
                            mongoClientSettings = new MongoClientSettings
                            {
                                Server = new MongoServerAddress(HostPort[0], Convert.ToInt32(HostPort[1])),
                                //UseSsl = true,
                                Credentials = new[] { mongoCredential }
                            };
                        }
                        DbName       = HostPortDB[HostPortDB.Length - 1];
                        mMongoClient = new MongoClient(mongoClientSettings);
                    }
                    else
                    {
                        return(false);
                    }
                }
                //check dbname is present in the dblist
                if (GetDatabaseList().Contains(DbName))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                Reporter.ToLog(eLogLevel.ERROR, "Failed to connect to Mongo DB", e);
                return(false);
            }
        }
Example #18
0
        public void ProcessPatientData()
        {
            #region Set up Publisher
            var keysPublisher = EncryptionHandler.GenerateNewKeys();

            TransactionGenerator transactionGeneratorPublisher = new TransactionGenerator(keysPublisher.PrivateKey);
            var registrationPublisher = transactionGeneratorPublisher.InitializeAsNewPublisher(keysPublisher.PublicKey, "Austria", "Vienna", "Publisher");
            var votePublisher         = transactionGeneratorPublisher.GenerateVotingTransaction(registrationPublisher.TransactionId, true);

            PublisherNode publisher = new PublisherNode();
            publisher.User = new NodeManagement.Entities.UserProperties()
            {
                Keys        = keysPublisher,
                UserAddress = registrationPublisher.TransactionId,
                Username    = "******"
            };

            publisher.InitializeEmptyChain(registrationPublisher, votePublisher);
            Assert.IsTrue(publisher.participantHandler.HasPublisher(registrationPublisher.TransactionId));
            #endregion

            #region Register physician
            var keysPhysician = EncryptionHandler.GenerateNewKeys();

            TransactionGenerator transactionGeneratorPhyisician = new TransactionGenerator(keysPhysician.PrivateKey);
            var registrationPhysician = transactionGeneratorPhyisician.InitializeAsNewPhysician(keysPhysician.PublicKey, "Austria", "Vienna", "Physician");
            var votePhysician         = transactionGeneratorPublisher.GenerateVotingTransaction(registrationPhysician.TransactionId, true);

            publisher.OnReceiveTransaction(registrationPhysician);
            publisher.OnReceiveTransaction(votePhysician);

            publisher.BundleOpenTransactionsManually();
            publisher.PublishOpenBlocks(publisher);

            Assert.IsTrue(publisher.participantHandler.HasPhysician(registrationPhysician.TransactionId));
            #endregion

            var patientA = transactionGeneratorPhyisician.GeneratePatientRegistrationTransaction("Austria", "Vienna", "1990");

            publisher.OnReceiveTransaction(patientA);

            Assert.IsTrue(publisher.participantHandler.parkedPatients.Contains(patientA));
            Assert.IsFalse(publisher.participantHandler.HasPatient(patientA.TransactionId));

            publisher.BundleOpenTransactionsManually();
            publisher.PublishOpenBlocks(publisher);

            Assert.IsTrue(publisher.participantHandler.parkedPatients.Contains(patientA));
            Assert.IsFalse(publisher.participantHandler.HasPatient(patientA.TransactionId));

            for (int i = 0; i < 2; i++)
            {
                publisher.OnReceiveTransaction(
                    transactionGeneratorPhyisician.GeneratePatientRegistrationTransaction("Austria", "Vienna", "1990")
                    );
            }

            Assert.IsTrue(publisher.participantHandler.parkedPatients.Contains(patientA));
            Assert.IsFalse(publisher.participantHandler.HasPatient(patientA.TransactionId));

            publisher.EvaluateParkedTransactions();
            publisher.BundleOpenTransactionsManually();
            publisher.PublishOpenBlocks(publisher);

            Assert.IsFalse(publisher.participantHandler.parkedPatients.Contains(patientA));
            Assert.IsTrue(publisher.participantHandler.HasPatient(patientA.TransactionId));
        }
Example #19
0
        public string GetConnectionString()
        {
            string connStr = null;
            bool   res;

            res = false;

            if (String.IsNullOrEmpty(ConnectionStringCalculated) == false)
            {
                connStr = ConnectionStringCalculated.Replace("{USER}", UserCalculated);

                String deCryptValue = EncryptionHandler.DecryptString(PassCalculated, ref res);
                if (res == true)
                {
                    connStr = connStr.Replace("{PASS}", deCryptValue);
                }
                else
                {
                    connStr = connStr.Replace("{PASS}", PassCalculated);
                }
            }
            else
            {
                String strConnString = TNSCalculated;
                String strProvider;
                connStr = "Data Source=" + TNSCalculated + ";User Id=" + UserCalculated + ";";

                String deCryptValue = EncryptionHandler.DecryptString(PassCalculated, ref res);

                if (res == true)
                {
                    connStr = connStr + "Password="******";";
                }
                else
                {
                    connStr = connStr + "Password="******";";
                }

                if (DBType == eDBTypes.MSAccess)
                {
                    if (strConnString.Contains(".accdb"))
                    {
                        strProvider = "Provider=Microsoft.ACE.OLEDB.12.0;";
                    }
                    else
                    {
                        strProvider = "Provider=Microsoft.Jet.OLEDB.4.0;";
                    }

                    connStr = strProvider + connStr;
                }
                else if (DBType == eDBTypes.DB2)
                {
                    connStr = "Server=" + TNSCalculated + ";Database=" + Name + ";UID=" + UserCalculated + "PWD=" + deCryptValue;
                }
                else if (DBType == eDBTypes.PostgreSQL)
                {
                    string[] host = TNSCalculated.Split(':');
                    if (host.Length == 2)
                    {
                        connStr = String.Format("Server ={0};Port={1};User Id={2}; Password={3};Database={4};", host[0], host[1], UserCalculated, deCryptValue, Name);
                    }
                    else
                    {
                        //    connStr = "Server=" + TNS + ";Database=" + Name + ";UID=" + User + "PWD=" + deCryptValue;
                        connStr = String.Format("Server ={0};User Id={1}; Password={2};Database={3};", TNSCalculated, UserCalculated, deCryptValue, Name);
                    }
                }
                else if (DBType == eDBTypes.MySQL)
                {
                    connStr = "Server=" + TNSCalculated + ";Database=" + Name + ";UID=" + UserCalculated + ";PWD=" + deCryptValue;
                }
            }

            return(connStr);
        }
 public void Sign(RSAParameters privateKey)
 {
     Timestamp = DateTime.UtcNow;
     RecalculateHash();
     PublisherVerification = EncryptionHandler.Sign(AsString(includeHash: true), privateKey);
 }
Example #21
0
        public bool ProcessCommandLineArgs(string[] lines)
        {
            string scURL  = null;
            string scUser = null;
            string scPswd = null;

            foreach (string arg in lines)
            {
                int    i     = arg.IndexOf('=');
                string param = arg.Substring(0, i).Trim();
                string value = arg.Substring(i + 1).Trim();

                switch (param)
                {
                case "SourceControlType":
                    Reporter.ToLog(eLogLevel.DEBUG, "Selected SourceControlType: '" + value + "'");
                    if (value.Equals("GIT"))
                    {
                        WorkSpace.UserProfile.SourceControlType = SourceControlBase.eSourceControlType.GIT;
                    }
                    else if (value.Equals("SVN"))
                    {
                        WorkSpace.UserProfile.SourceControlType = SourceControlBase.eSourceControlType.SVN;
                    }
                    else
                    {
                        WorkSpace.UserProfile.SourceControlType = SourceControlBase.eSourceControlType.None;
                    }
                    break;

                case "SourceControlUrl":
                    Reporter.ToLog(eLogLevel.DEBUG, "Selected SourceControlUrl: '" + value + "'");
                    if (WorkSpace.UserProfile.SourceControlType == SourceControlBase.eSourceControlType.SVN)
                    {
                        if (!value.ToUpper().Contains("/SVN") && !value.ToUpper().Contains("/SVN/"))
                        {
                            value = value + "svn/";
                        }
                        if (!value.ToUpper().EndsWith("/"))
                        {
                            value = value + "/";
                        }
                    }
                    WorkSpace.UserProfile.SourceControlURL = value;
                    scURL = value;
                    break;

                case "SourceControlUser":
                    Reporter.ToLog(eLogLevel.DEBUG, "Selected SourceControlUser: '******'");
                    if (WorkSpace.UserProfile.SourceControlType == SourceControlBase.eSourceControlType.GIT && value == "")
                    {
                        value = "Test";
                    }
                    WorkSpace.UserProfile.SourceControlUser = value;
                    scUser = value;
                    break;

                case "SourceControlPassword":
                    Reporter.ToLog(eLogLevel.DEBUG, "Selected SourceControlPassword: '******'");
                    WorkSpace.UserProfile.SourceControlPass = value;
                    scPswd = value;
                    break;

                case "PasswordEncrypted":
                    Reporter.ToLog(eLogLevel.DEBUG, "PasswordEncrypted: '" + value + "'");
                    string pswd = WorkSpace.UserProfile.SourceControlPass;
                    if (value == "Y")
                    {
                        pswd = EncryptionHandler.DecryptwithKey(WorkSpace.UserProfile.SourceControlPass, App.ENCRYPTION_KEY);
                    }
                    if (WorkSpace.UserProfile.SourceControlType == SourceControlBase.eSourceControlType.GIT && pswd == "")
                    {
                        pswd = "Test";
                    }
                    WorkSpace.UserProfile.SourceControlPass = pswd;
                    break;

                case "SourceControlProxyServer":
                    Reporter.ToLog(eLogLevel.DEBUG, "Selected SourceControlProxyServer: '" + value + "'");
                    if (value == "")
                    {
                        WorkSpace.UserProfile.SolutionSourceControlConfigureProxy = false;
                    }
                    else
                    {
                        WorkSpace.UserProfile.SolutionSourceControlConfigureProxy = true;
                    }
                    if (value != "" && !value.ToUpper().StartsWith("HTTP://"))
                    {
                        value = "http://" + value;
                    }
                    WorkSpace.UserProfile.SolutionSourceControlProxyAddress = value;
                    break;

                case "SourceControlProxyPort":
                    if (value == "")
                    {
                        WorkSpace.UserProfile.SolutionSourceControlConfigureProxy = false;
                    }
                    else
                    {
                        WorkSpace.UserProfile.SolutionSourceControlConfigureProxy = true;
                    }
                    Reporter.ToLog(eLogLevel.INFO, "Selected SourceControlProxyPort: '" + value + "'");
                    WorkSpace.UserProfile.SolutionSourceControlProxyPort = value;
                    break;

                case "Solution":
                    if (scURL != null && scUser != "" && scPswd != null)
                    {
                        Reporter.ToLog(eLogLevel.DEBUG, "Downloading Solution from source control");
                        if (value.IndexOf(".git") != -1)
                        {
                            App.DownloadSolution(value.Substring(0, value.IndexOf(".git") + 4));
                        }
                        else
                        {
                            App.DownloadSolution(value);
                        }
                    }
                    Reporter.ToLog(eLogLevel.DEBUG, "Loading the Solution: '" + value + "'");
                    try
                    {
                        if (App.SetSolution(value) == false)
                        {
                            Reporter.ToLog(eLogLevel.ERROR, "Failed to load the Solution");
                            return(false);
                        }
                    }
                    catch (Exception ex)
                    {
                        Reporter.ToLog(eLogLevel.ERROR, "Failed to load the Solution");
                        Reporter.ToLog(eLogLevel.ERROR, $"Method - {MethodBase.GetCurrentMethod().Name}, Error - {ex.Message}", ex);
                        return(false);
                    }
                    break;

                case "Env":
                    Reporter.ToLog(eLogLevel.DEBUG, "Selected Environment: '" + value + "'");
                    ProjEnvironment env = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <ProjEnvironment>().Where(x => x.Name.ToLower().Trim() == value.ToLower().Trim()).FirstOrDefault();
                    if (env != null)
                    {
                        App.RunsetExecutor.RunsetExecutionEnvironment = env;
                    }
                    else
                    {
                        Reporter.ToLog(eLogLevel.ERROR, "Failed to find matching Environment in the Solution");
                        return(false);
                    }
                    break;

                case "RunSet":
                    Reporter.ToLog(eLogLevel.DEBUG, string.Format("Selected {0}: '{1}'", GingerDicser.GetTermResValue(eTermResKey.RunSet), value));
                    ObservableList <RunSetConfig> RunSets = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <RunSetConfig>();
                    RunSetConfig runSetConfig             = RunSets.Where(x => x.Name.ToLower().Trim() == value.ToLower().Trim()).FirstOrDefault();
                    if (runSetConfig != null)
                    {
                        WorkSpace.RunsetExecutor.RunSetConfig = runSetConfig;
                    }
                    else
                    {
                        Reporter.ToLog(eLogLevel.ERROR, string.Format("Failed to find matching {0} in the Solution", GingerDicser.GetTermResValue(eTermResKey.RunSet)));
                        return(false);
                    }
                    break;

                default:
                    Reporter.ToLog(eLogLevel.ERROR, "Un Known argument: '" + param + "'");
                    return(false);
                }
            }
            return(true);
        }
Example #22
0
        public bool OpenSolution(string solutionFolder, string encryptionKey = null)
        {
            try
            {
                Reporter.ToLog(eLogLevel.INFO, string.Format("Loading the Solution '{0}'", solutionFolder));
                LoadingSolution = true;

                //Cleaning previous Solution load
                Reporter.ToLog(eLogLevel.INFO, "Loading Solution- Cleaning previous Solution items");
                CloseSolution();

                //Load Solution file
                //Reporter.ToLog(eLogLevel.INFO, "Loading Solution- Opening Solution located at: " + solutionFolder);
                string solutionFile = System.IO.Path.Combine(solutionFolder, @"Ginger.Solution.xml");
                Reporter.ToLog(eLogLevel.INFO, string.Format("Loading Solution- Loading Solution File: '{0}'", solutionFile));
                if (System.IO.File.Exists(solutionFile))
                {
                    Reporter.ToLog(eLogLevel.DEBUG, "Loading Solution- Solution File exist");
                }
                else
                {
                    if (!File.Exists(Amdocs.Ginger.IO.PathHelper.GetLongPath(solutionFile)))
                    {
                        //Reporter.ToUser(eUserMsgKey.BeginWithNoSelectSolution);
                        Reporter.ToLog(eLogLevel.ERROR, "Loading Solution- Error: Solution File Not Found");
                        return(false);
                    }
                }

                //Checking if Ginger upgrade is needed
                Reporter.ToLog(eLogLevel.INFO, "Loading Solution- Checking if Ginger Solution items upgrade is needed");
                IEnumerable <string> solutionFiles = Solution.SolutionFiles(solutionFolder);
                SolutionUpgrade.ClearPreviousScans();
                if (SolutionUpgrade.IsGingerUpgradeNeeded(solutionFolder, solutionFiles))
                {
                    Reporter.ToLog(eLogLevel.WARN, "Loading Solution- Error: Current Ginger version can't load the Solution because it includes items from higher Ginger version");
                    return(false);
                }

                Reporter.ToLog(eLogLevel.INFO, "Loading Solution- Loading Solution file xml into object");
                Solution           solution           = SolutionOperations.LoadSolution(solutionFile, true, encryptionKey);
                SolutionOperations solutionOperations = new SolutionOperations(solution);
                solution.SolutionOperations = solutionOperations;

                if (solution == null)
                {
                    Reporter.ToUser(eUserMsgKey.SolutionLoadError, "Failed to load the Solution file");
                    Reporter.ToLog(eLogLevel.ERROR, "Loading Solution- Error: Failed to load the Solution file");
                    return(false);
                }

                EncryptionHandler.SetCustomKey(solution.EncryptionKey);
                if (!solution.SolutionOperations.ValidateKey())
                {
                    if (WorkSpace.Instance.RunningInExecutionMode == false && WorkSpace.Instance.RunningFromUnitTest == false)
                    {
                        if (string.IsNullOrEmpty(solution.EncryptedValidationString))
                        {
                            // To support existing solutions,
                            solution.EncryptionKey             = EncryptionHandler.GetDefaultKey();
                            solution.NeedVariablesReEncryption = true;
                            solution.SolutionOperations.SaveEncryptionKey();
                            solution.SolutionOperations.SaveSolution(false);
                        }
                        else if (!Instance.EventHandler.OpenEncryptionKeyHandler(solution))
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        Reporter.ToLog(eLogLevel.ERROR, "Loading Solution- Error: Encryption key validation failed");
                        return(false);
                    }
                }

                Reporter.ToLog(eLogLevel.INFO, "Loading Solution- Creating Items Repository");
                SolutionRepository = GingerSolutionRepository.CreateGingerSolutionRepository();
                SolutionRepository.Open(solutionFolder);

                Reporter.ToLog(eLogLevel.INFO, "Loading Solution- Loading needed Plugins");
                mPluginsManager = new PluginsManager();
                mPluginsManager.SolutionChanged(SolutionRepository);

                Reporter.ToLog(eLogLevel.INFO, "Loading Solution- Doing Source Control Configurations");
                try
                {
                    HandleSolutionLoadSourceControl(solution);
                }
                catch (Exception ex)
                {
                    Reporter.ToLog(eLogLevel.ERROR, "exception occured while doing Solution Source Control Configurations", ex);
                }

                Reporter.ToLog(eLogLevel.INFO, "Loading Solution- Updating Application Functionalities to Work with Loaded Solution");
                ValueExpression.SolutionFolder = solutionFolder;
                BusinessFlow.SolutionVariables = solution.Variables;
                solution.SolutionOperations.SetReportsConfigurations();
                Solution = solution;
                UserProfile.UserProfileOperations.LoadRecentAppAgentMapping();

                if (!RunningInExecutionMode)
                {
                    AppSolutionRecover.DoSolutionAutoSaveAndRecover();
                }

                //Solution items upgrade
                SolutionUpgrade.CheckSolutionItemsUpgrade(solutionFolder, solution.Name, solutionFiles.ToList());

                if (!RunningInExecutionMode && mSolution.NeedVariablesReEncryption)
                {
                    string msg = "Going forward each solution needs to have its own key for encrypting password values\n"
                                 + "Please make a note of Default key updated on Solution details page. This key is mandatory for accessing solution";

                    Reporter.ToUser(eUserMsgKey.SolutionEncryptionKeyUpgrade, msg);
                    Instance.EventHandler.OpenEncryptionKeyHandler(null);
                }

                // No need to add solution to recent if running from CLI
                if (!RunningInExecutionMode)
                {
                    ((UserProfileOperations)UserProfile.UserProfileOperations).AddSolutionToRecent(solution);
                }
                // PlugInsManager = new PluginsManager();
                // mPluginsManager.Init(SolutionRepository);

                Reporter.ToLog(eLogLevel.INFO, string.Format("Finished Loading successfully the Solution '{0}'", solutionFolder));
                return(true);
            }
            catch (Exception ex)
            {
                Reporter.ToLog(eLogLevel.ERROR, "Loading Solution- Unexpected Error occurred while loading the solution", ex);
                CloseSolution();
                throw ex;
            }
            finally
            {
                LoadingSolution = false;
            }
        }
Example #23
0
        public bool Send_SMTP()
        {
            try
            {
                if (string.IsNullOrEmpty(MailFrom))
                {
                    Event = "Failed: Please provide FROM email address.";
                    return(false);
                }
                if (string.IsNullOrEmpty(MailTo))
                {
                    Event = "Failed: Please provide TO email address.";
                    return(false);
                }
                if (string.IsNullOrEmpty(Subject))
                {
                    Event = "Failed: Please provide email subject.";
                    return(false);
                }

                if (string.IsNullOrEmpty(SMTPMailHost))
                {
                    Event = "Failed: Please provide Mail Host";
                    return(false);
                }
                mVE.Value = MailFrom;
                var fromAddress = new MailAddress(mVE.ValueCalculated, "_Amdocs Ginger Automation");

                mVE.Value = SMTPMailHost;
                string mailHost = mVE.ValueCalculated;

                if (this.SMTPPort == 0 || this.SMTPPort == null)
                {
                    this.SMTPPort = 25;
                }
                var smtp = new SmtpClient()
                {
                    Host                  = mailHost, // amdocs config
                    Port                  = (int)this.SMTPPort,
                    EnableSsl             = EnableSSL,
                    DeliveryMethod        = SmtpDeliveryMethod.Network,
                    UseDefaultCredentials = !ConfigureCredential
                };

                if (ConfigureCredential)
                {
                    bool checkValueDecrypt;
                    checkValueDecrypt = true;
                    string DecryptPass = EncryptionHandler.DecryptString(SMTPPass, ref checkValueDecrypt);
                    if (checkValueDecrypt)
                    {
                        smtp.Credentials = new NetworkCredential(SMTPUser, DecryptPass);
                    }
                    else
                    {
                        smtp.Credentials = new NetworkCredential(SMTPUser, SMTPPass);
                    }
                }
                mVE.Value = MailTo;
                string emails    = mVE.ValueCalculated;
                Array  arrEmails = emails.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                System.Net.Mail.MailMessage myMail = new System.Net.Mail.MailMessage();
                foreach (string email in arrEmails)
                {
                    myMail.To.Add(email);
                }

                //Add CC
                if (!String.IsNullOrEmpty(MailCC))
                {
                    Array arrCCEmails = MailCC.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string MailCC1 in arrCCEmails)
                    {
                        myMail.CC.Add(MailCC1);
                    }
                }

                mVE.Value = Subject;
                string subject = mVE.ValueCalculated;

                mVE.Value = Body;
                string body = mVE.ValueCalculated;

                myMail.From       = fromAddress;
                myMail.IsBodyHtml = IsBodyHTML;

                myMail.Subject = subject.Replace('\r', ' ').Replace('\n', ' ');
                myMail.Body    = body;

                foreach (string AttachmentFileName in Attachments)
                {
                    if (String.IsNullOrEmpty(AttachmentFileName) == false)
                    {
                        Attachment a = new Attachment(AttachmentFileName);
                        myMail.Attachments.Add(a);
                    }
                }
                if (alternateView != null)
                {
                    myMail.AlternateViews.Add(alternateView);
                }

                smtp.Send(myMail);

                return(true);
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("Mailbox unavailable"))
                {
                    Event = "Failed: Please provide correct FROM email address";
                }
                else if (ex.StackTrace.Contains("System.Runtime.InteropServices.Marshal.GetActiveObject"))
                {
                    Event = "Please make sure ginger/outlook opened in same security context (Run as administrator or normal user)";
                }
                else if (ex.StackTrace.Contains("System.Security.Authentication.AuthenticationException") || ex.StackTrace.Contains("System.Net.Sockets.SocketException"))
                {
                    Event = "Please check SSL configuration";
                }
                else
                {
                    Event = "Failed: " + ex.Message;
                }
                Reporter.ToLog(eLogLevel.ERROR, "Failed to send mail", ex);

                return(false);
            }
        }
        public void SolutionPomElementsLazyLoadTest_NotLoaded()
        {
            //Arrange
            WorkSpace.Instance.OpenSolution(Path.Combine(TestResources.GetTestResourcesFolder(@"Solutions"), "BasicSimple"), EncryptionHandler.GetDefaultKey());
            SolutionRepository SR = WorkSpace.Instance.SolutionRepository;

            //Act
            ObservableList <ApplicationPOMModel> poms = SR.GetAllRepositoryItems <ApplicationPOMModel>();

            //Assert
            Assert.AreEqual(poms.Count, 1, "Validating POMs were loaded");
            Assert.AreEqual(poms[0].UnMappedUIElementsLazyLoad, true, "Validating POM Un Mappped Elements were not loaded");
            Assert.AreEqual(poms[0].MappedUIElementsLazyLoad, true, "Validating POM Mappped Elements were not loaded");
        }