Skip to content

Commit

Permalink
Merge branch 'Releases/Beta' into Beta/BugFix/D37427_RQMActivityStatu…
Browse files Browse the repository at this point in the history
…sFixed
  • Loading branch information
Maheshkale447 authored Apr 11, 2024
2 parents d013895 + 63a59a1 commit 3c14847
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 19 deletions.
34 changes: 32 additions & 2 deletions Ginger/Ginger/Activities/ActivityDetailsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,13 @@ private void BindControls()


xTargetApplicationComboBox.ItemsSource = WorkSpace.Instance.Solution.GetSolutionTargetApplications();



if (WorkSpace.Instance!=null && WorkSpace.Instance.Solution!=null && WorkSpace.Instance.Solution.ApplicationPlatforms!=null)
{
WorkSpace.Instance.Solution.ApplicationPlatforms.CollectionChanged -= OnApplicationPlatformChanged;
WorkSpace.Instance.Solution.ApplicationPlatforms.CollectionChanged += OnApplicationPlatformChanged;
}

xTargetApplicationlbl.Content = $"{GingerDicser.GetTermResValue(eTermResKey.TargetApplication)}:";
xTargetApplicationComboBox.SelectedValuePath = nameof(TargetApplication.AppName);
xTargetApplicationComboBox.DisplayMemberPath = nameof(TargetApplication.AppName);
Expand Down Expand Up @@ -216,6 +221,31 @@ private void BindControls()
mActivity.DirtyTracking = Amdocs.Ginger.Common.Enums.eDirtyTracking.Started;
}

private void OnApplicationPlatformChanged(object? sender, NotifyCollectionChangedEventArgs e)
{
xTargetApplicationComboBox.ItemsSource = WorkSpace.Instance.Solution.GetSolutionTargetApplications();

if(xTargetApplicationComboBox.Items == null || mActivity == null || mActivity.TargetApplication == null)
{
return;
}

int pointer = 0;

foreach(TargetApplication targetApplication in xTargetApplicationComboBox.Items)
{

if (targetApplication.AppName.Equals(mActivity.TargetApplication))
{
xTargetApplicationComboBox.SelectedIndex = pointer;
}

pointer++;
}

TargetAppSelectedComboBox();
}

private void UserProfile_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if(string.Equals(e.PropertyName, nameof(UserProfile.ShowEnterpriseFeatures)))
Expand Down
1 change: 1 addition & 0 deletions Ginger/Ginger/SolutionWindows/AddApplicationPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ private void OKButton_Click(object sender, RoutedEventArgs e)

mSolution.ApplicationPlatforms.Add(selectedApp);


if (!msgSelection.Equals(eUserMsgSelection.Yes))
{
this.NewlyAddedApplicationPlatform = selectedApp;
Expand Down
97 changes: 82 additions & 15 deletions Ginger/GingerCoreNET/Database/NoSqlBase/GingerCassandra.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,18 @@ limitations under the License.
#endregion

using Amdocs.Ginger.Common;
using Amdocs.Ginger.CoreNET.RunLib.CLILib;
using Cassandra;
using GingerCore.Actions;
using GingerCore.NoSqlBase.DataAccess;
using HBaseNet.Const;
using Microsoft.Graph;
using Microsoft.Graph.SecurityNamespace;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Security.Authentication;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

Expand All @@ -37,32 +42,72 @@ public class GingerCassandra : NoSqlBase
dynamic myclass = null;
string mUDTName = null;



public override bool Connect()
{
try
{
string queryTimeoutString = "querytimeout=";
const string queryTimeoutString = "querytimeout=";
const string sslString = "ssl=";
int queryTimeout = 20000;//default timeout (20 seconds).
if (Db.DatabaseOperations.TNSCalculated.ToLower().Contains(queryTimeoutString.ToLower()))
string[] queryArray = Db.DatabaseOperations.TNSCalculated.ToLower().Split(';');
SSLOptions sslOptions = null;
for (int i = 1; i < queryArray.Length; i++)
{
string queryTimeoutValue = Db.DatabaseOperations.TNSCalculated.Substring(Db.DatabaseOperations.TNSCalculated.ToLower().IndexOf(queryTimeoutString.ToLower()) + queryTimeoutString.Length);
queryTimeout = Convert.ToInt32(queryTimeoutValue) * 1000;
switch (queryArray[i])
{
case var str when str.Contains(queryTimeoutString):
string queryTimeoutValue = str.Substring(str.IndexOf(queryTimeoutString) + queryTimeoutString.Length);
if (!int.TryParse(queryTimeoutValue, out int timeout))
{
throw new ArgumentException("Query timeout value is not a valid integer.");
}
queryTimeout = Convert.ToInt32(queryTimeoutValue) * 1000;
break;

case var str when str.Contains(sslString):
string sslValue = str.Substring(str.IndexOf(sslString) + sslString.Length);
sslOptions = SetupSslOptions(sslValue);
break;
default:
throw new ArgumentException("Please check connection string.");
}
}

string[] HostKeySpace = Db.DatabaseOperations.TNSCalculated.Split('/');
string[] HostKeySpace = queryArray[0].ToLower().Replace("http://", "").Replace("https://", "").Split('/');
string[] HostPort = HostKeySpace[0].Split(':');

if (HostPort.Length == 2)
{
if (string.IsNullOrEmpty(Db.Pass) && string.IsNullOrEmpty(Db.User))
{
cluster = Cluster.Builder().AddContactPoint(HostPort[0]).WithPort(Int32.Parse(HostPort[1])).WithQueryTimeout(queryTimeout).Build();
if (sslOptions ==null)
{
cluster = Cluster.Builder().AddContactPoint(HostPort[0]).WithPort(Int32.Parse(HostPort[1])).WithQueryTimeout(queryTimeout).Build();
}
else
{
cluster = Cluster.Builder()
.AddContactPoint(HostPort[0])
.WithPort(Int32.Parse(HostPort[1]))
.WithSSL(sslOptions)
.WithQueryTimeout(queryTimeout)
.Build();
}
}
else
{
cluster = Cluster.Builder().WithCredentials(Db.User.ToString(), Db.Pass.ToString()).AddContactPoint(HostPort[0]).WithPort(Int32.Parse(HostPort[1])).WithQueryTimeout(queryTimeout).Build();
if (sslOptions == null) {
cluster = Cluster.Builder().WithCredentials(Db.User.ToString(), Db.Pass.ToString()).AddContactPoint(HostPort[0]).WithPort(Int32.Parse(HostPort[1])).WithQueryTimeout(queryTimeout).Build();
}
else
{
cluster = Cluster.Builder()
.AddContactPoint(HostPort[0])
.WithPort(Int32.Parse(HostPort[1]))
.WithAuthProvider(new PlainTextAuthProvider(Db.User, Db.Pass))
.WithSSL(sslOptions)
.WithQueryTimeout(queryTimeout)
.Build();
}
}
}
else
Expand All @@ -85,16 +130,16 @@ public override bool Connect()
}
catch (Exception e)
{
Reporter.ToLog(eLogLevel.ERROR, "Failed to connect to Cassandra DB", e);
throw (e);
Reporter.ToLog(eLogLevel.ERROR, "Failed to connect to Cassandra DB. Please check Connection String", e);
throw;
}
}

public override bool MakeSureConnectionIsOpen()
{
try
{
if (session != null)
if (session != null && !session.IsDisposed)
{
Metadata m = cluster.Metadata;
ICollection<string> Keyspaces = m.GetKeyspaces();
Expand Down Expand Up @@ -182,8 +227,15 @@ public override Task<List<string>> GetColumnList(string tablename)

private void Disconnect()
{
session.Dispose();
cluster.Dispose();
try
{
session.Dispose();
cluster.Dispose();
}
finally
{
session = null;
}
}

public Type TypeConverter(RowSet RS, string Type1)
Expand Down Expand Up @@ -789,5 +841,20 @@ void UpdateOutValues(RowSet RS, Type t = null)
i++;
}
}

public static SSLOptions SetupSslOptions(string sslParamValue)
{
try
{
var sslProtocol = Enum.Parse<SslProtocols>(sslParamValue, ignoreCase: true);
return new SSLOptions(sslProtocol, false, (_, _, _, _) => true);
}
catch (ArgumentException e)
{
Reporter.ToLog(eLogLevel.ERROR, "SSL value not correct. Please enter SSL value like Default, None, Ssl2, Ssl3, Tls, Tls11, Tls12, Tls13", e);
Reporter.ToLog(eLogLevel.ERROR, "Note - Also try removing ssl= parameter from connection string", e);
throw new ArgumentException("SSL value not correct. Please enter SSL value like Default, None, Ssl2, Ssl3, Tls, Tls11, Tls12, Tls13.");
}
}
}
}
6 changes: 4 additions & 2 deletions Ginger/GingerCoreNET/Database/NoSqlBase/GingerCouchbase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ private string GetBucketName(string inputSQL)
{
string bucketName = string.Empty;
string[] bucketNameArray;
const string strUpdate = "update ";
const string strFrom = " from ";
if (Action == ActDBValidation.eDBValidationType.RecordCount)
{
bucketName = inputSQL.Replace("`", "");
Expand All @@ -164,11 +166,11 @@ private string GetBucketName(string inputSQL)
{
if (Action == ActDBValidation.eDBValidationType.UpdateDB)
{
bucketName = inputSQL.Substring(inputSQL.ToLower().IndexOf("Update ") + 7);
bucketName = inputSQL.Substring(inputSQL.IndexOf(strUpdate, StringComparison.OrdinalIgnoreCase) + strUpdate.Length);
}
else
{
bucketName = inputSQL.Substring(inputSQL.ToLower().IndexOf(" from ") + 6);
bucketName = inputSQL.Substring(inputSQL.IndexOf(strFrom, StringComparison.OrdinalIgnoreCase) + strFrom.Length);
}
bucketNameArray = bucketName.Split('.');
bucketName = bucketNameArray[0].Trim();
Expand Down

0 comments on commit 3c14847

Please sign in to comment.