コード例 #1
0
ファイル: CouchBaseConnection.cs プロジェクト: csuffyy/Ginger
 public bool OpenConnection(Dictionary <string, string> parameters)
 {
     KeyvalParamatersList = parameters;
     GetConnectionString(parameters);
     try
     {
         clusterCB = new Couchbase.Cluster(new ClientConfiguration
         {
             ViewRequestTimeout = 45000,
             Servers            = new List <Uri> {
                 new Uri(TNS)
             },
         });
         bool res = false;
         //TODO: need to decrypt the password in the Database->PassCalculated
         String deCryptValue = EncryptionHandler.DecryptString(Password, ref res, false);
         if (res == true)
         {
             clusterCB.Authenticate(User, deCryptValue);
         }
         else
         {
             clusterCB.Authenticate(User, Password);
         }
         return(true);
     }
     catch (Exception e)
     {
         Reporter.ToLog(eLogLevel.ERROR, "Failed to connect to Couchbase DB", e);
         return(false);
     }
 }
コード例 #2
0
ファイル: Database.cs プロジェクト: lanicon/Ginger
        public string GetConnectionString()
        {
            string connStr = null;
            bool   res;

            res = false;

            if (String.IsNullOrEmpty(ConnectionStringCalculated))
            {
                connStr = CreateConnectionString();
            }
            connStr = ConnectionStringCalculated.Replace("{USER}", UserCalculated);
            String deCryptValue = EncryptionHandler.DecryptString(PassCalculated, ref res, false);

            if (res == true)
            {
                connStr = connStr.Replace("{PASS}", deCryptValue);
            }
            else
            {
                connStr = connStr.Replace("{PASS}", PassCalculated);
            }

            return(connStr);
        }
コード例 #3
0
        public bool Connect()
        {
            try
            {
                clusterCB = new Couchbase.Cluster(new ClientConfiguration
                {
                    ViewRequestTimeout = 45000,
                    Servers            = new List <Uri> {
                        new Uri(Db.TNSCalculated.ToString())
                    },                                                               //http://incespr021:8091
                });
                bool   res          = false;
                String deCryptValue = EncryptionHandler.DecryptString(Db.PassCalculated.ToString(), ref res, false);
                if (res == true)
                {
                    Db.Pass = deCryptValue;
                }

                clusterCB.Authenticate(Db.UserCalculated.ToString(), Db.PassCalculated.ToString());
                return(true);
            }
            catch (Exception e)
            {
                Reporter.ToLog(eLogLevel.ERROR, "Failed to connect to Couchbase DB", e);
                throw (e);
            }
        }
コード例 #4
0
 private void param_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
 {
     if (e.PropertyName == GeneralParam.Fields.Encrypt)
     {
         GeneralParam param       = (GeneralParam)sender;
         String       intialValue = param.Value;
         bool         res         = false;
         if (!string.IsNullOrEmpty(intialValue))
         {
             if (param.Encrypt == true)
             {
                 if (!EncryptionHandler.IsStringEncrypted(intialValue))
                 {
                     param.Value = EncryptionHandler.EncryptString(intialValue, ref res);
                     if (res == false)
                     {
                         param.Value = null;
                     }
                 }
             }
             else
             {
                 if (EncryptionHandler.IsStringEncrypted(intialValue))
                 {
                     param.Value = EncryptionHandler.DecryptString(intialValue, ref res);
                     if (res == false)
                     {
                         param.Value = null;
                     }
                 }
             }
         }
     }
 }
コード例 #5
0
 public override bool Connect()
 {
     try
     {
         clusterCB = new Couchbase.Cluster(new ClientConfiguration
         {
             ViewRequestTimeout = 45000,
             Servers            = new List <Uri> {
                 new Uri(Db.TNSCalculated.ToString())
             },
         });
         bool res = false;
         //TODO: need to decrypt the password in the Database->PassCalculated
         String deCryptValue = EncryptionHandler.DecryptString(Db.PassCalculated.ToString(), ref res, false);
         if (res == true)
         {
             clusterCB.Authenticate(Db.UserCalculated.ToString(), deCryptValue);
         }
         else
         {
             clusterCB.Authenticate(Db.UserCalculated.ToString(), Db.PassCalculated.ToString());
         }
         return(true);
     }
     catch (Exception e)
     {
         Reporter.ToLog(eLogLevel.ERROR, "Failed to connect to Couchbase DB", e);
         return(false);
     }
 }
コード例 #6
0
ファイル: MSAccessDBCon.cs プロジェクト: csuffyy/Ginger
        public string GetConnectionString(Dictionary <string, string> parameters)
        {
            string connStr = null;
            bool   res;

            res = false;

            string ConnectionString = parameters.FirstOrDefault(pair => pair.Key == "ConnectionString").Value;
            string User             = parameters.FirstOrDefault(pair => pair.Key == "UserName").Value;
            string Password         = parameters.FirstOrDefault(pair => pair.Key == "Password").Value;
            string TNS = parameters.FirstOrDefault(pair => pair.Key == "TNS").Value;

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

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

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

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


                if (strConnString.Contains(".accdb"))
                {
                    strProvider = "Provider=Microsoft.ACE.OLEDB.12.0;";
                }
                else
                {
                    strProvider = "Provider=Microsoft.ACE.OLEDB.12.0;";
                }

                connStr = strProvider + connStr;
            }
            return(connStr);
        }
コード例 #7
0
        public void DecryptString()
        {
            //Arrange
            string decryptedString = string.Empty;
            bool   result          = false;

            //Act
            decryptedString = EncryptionHandler.DecryptString("mDL33JRKM3Zv1FdtGQMNZg==", ref result);

            //Assert
            Assert.AreEqual("ginger", decryptedString);
        }
コード例 #8
0
        private void txtPasswordValue_LostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
        {
            bool res, checkValueDecrypt;

            res = false;
            checkValueDecrypt = true;
            EncryptionHandler.DecryptString(txtPasswordValue.Text, ref checkValueDecrypt);

            if (!checkValueDecrypt)
            {
                txtPasswordValue.Text = EncryptionHandler.EncryptString(txtPasswordValue.Text, ref res);
            }
        }
コード例 #9
0
        private void grdMain_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
        {
            if (e.Column.Header.ToString() == GeneralParam.Fields.Name)
            {
                GeneralParam changedParam = (GeneralParam)grdAppParams.CurrentItem;
                if (changedParam.Name != changedParam.NameBeforeEdit)
                {
                    //ask user if want us to update the parameter name in all BF's
                    if (Reporter.ToUser(eUserMsgKeys.ChangingEnvironmentParameterValue) == MessageBoxResult.Yes)
                    {
                        UpdateVariableNameChange(changedParam);
                    }
                }
            }
            else if (e.Column.Header.ToString() == GeneralParam.Fields.Value)
            {
                GeneralParam selectedEnvParam = (GeneralParam)grdAppParams.CurrentItem;

                String intialValue = selectedEnvParam.Value;
                if (intialValue != null)
                {
                    if (selectedEnvParam.Encrypt == true)
                    {
                        bool   res   = false;
                        String value = selectedEnvParam.Value;
                        UpdateVariableNameChange(selectedEnvParam);
                        selectedEnvParam.Value = null;
                        selectedEnvParam.Value = EncryptionHandler.EncryptString(intialValue, ref res);
                    }
                    else if (selectedEnvParam.Encrypt == false)
                    {
                        bool res = false;


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

                        if (res == true)
                        {
                            selectedEnvParam.Value = null;
                        }

                        else
                        {
                            selectedEnvParam.Value = null;
                            selectedEnvParam.Value = intialValue;
                        }
                    }
                }
            }
        }
コード例 #10
0
        private void grdMain_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
        {
            if (e.Column.Header.ToString() == GeneralParam.Fields.Name)
            {
                GeneralParam changedParam = (GeneralParam)grdAppParams.CurrentItem;
                if (changedParam.Name != changedParam.NameBeforeEdit)
                {
                    //ask user if want us to update the parameter name in all BF's
                    if (Reporter.ToUser(eUserMsgKeys.ChangingEnvironmentParameterValue) == Amdocs.Ginger.Common.MessageBoxResult.Yes)
                    {
                        UpdateVariableNameChange(changedParam);
                    }
                }
            }
            else if (e.Column.Header.ToString() == GeneralParam.Fields.Value)
            {
                GeneralParam selectedEnvParam = (GeneralParam)grdAppParams.CurrentItem;

                String intialValue = selectedEnvParam.Value;
                bool   res         = false;
                if (!string.IsNullOrEmpty(intialValue))
                {
                    if (selectedEnvParam.Encrypt == true)
                    {
                        //UpdateVariableNameChange(selectedEnvParam); // why is that needed here?
                        if (!EncryptionHandler.IsStringEncrypted(intialValue))
                        {
                            selectedEnvParam.Value = EncryptionHandler.EncryptString(intialValue, ref res);
                            if (res == false)
                            {
                                selectedEnvParam.Value = null;
                            }
                        }
                    }
                    else
                    {
                        if (EncryptionHandler.IsStringEncrypted(intialValue))
                        {
                            selectedEnvParam.Value = EncryptionHandler.DecryptString(intialValue, ref res);
                            if (res == false)
                            {
                                selectedEnvParam.Value = null;
                            }
                        }
                    }
                }
            }
        }
コード例 #11
0
ファイル: MYSQLDBConnection.cs プロジェクト: csuffyy/Ginger
        public string GetConnectionString(Dictionary <string, string> parameters)
        {
            string connStr = null;
            bool   res;

            res = false;

            string ConnectionString = parameters.FirstOrDefault(pair => pair.Key == "ConnectionString").Value;
            string User             = parameters.FirstOrDefault(pair => pair.Key == "UserName").Value;
            string Password         = parameters.FirstOrDefault(pair => pair.Key == "Password").Value;
            string TNS  = parameters.FirstOrDefault(pair => pair.Key == "TNS").Value;
            string Name = parameters.FirstOrDefault(pair => pair.Key == "Name").Value;

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

                String deCryptValue = EncryptionHandler.DecryptString(Password, ref res, false);
                if (res == true)
                {
                    connStr = connStr.Replace("{PASS}", deCryptValue);
                }
                else
                {
                    connStr = connStr.Replace("{PASS}", Password);
                }
            }
            else
            {
                String strConnString = TNS;

                connStr = "Data Source=" + TNS + ";User Id=" + User + ";";

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

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

                connStr = "Server=" + TNS + ";Database=" + Name + ";UID=" + User + ";PWD=" + deCryptValue;
            }
            return(connStr);
        }
コード例 #12
0
        private void param_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName == GeneralParam.Fields.Name)
            {
                // loop
            }
            if (e.PropertyName == GeneralParam.Fields.Value)
            {
            }
            if (e.PropertyName == GeneralParam.Fields.Encrypt)
            {
                GeneralParam param   = (GeneralParam)sender;
                bool         Envalue = param.Encrypt;

                String intialValue = param.Value;

                if (intialValue != null)
                {
                    if (Envalue == true)
                    {
                        bool res = false;

                        param.Value = null;
                        param.Value = EncryptionHandler.EncryptString(intialValue, ref res);
                    }

                    else if (Envalue == false)
                    {
                        bool res = false;


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

                        if (res == true)
                        {
                            param.Value = null;
                        }

                        else
                        {
                            param.Value = null;
                            param.Value = intialValue;
                        }
                    }
                }
            }
        }
コード例 #13
0
        public string GetConnectionString(Dictionary <string, string> parameters)
        {
            string connStr = null;
            bool   res;

            res = false;
            string ConnectionString = parameters.FirstOrDefault(pair => pair.Key == "ConnectionString").Value;
            string User             = parameters.FirstOrDefault(pair => pair.Key == "UserName").Value;
            string Password         = parameters.FirstOrDefault(pair => pair.Key == "Password").Value;
            string TNS  = parameters.FirstOrDefault(pair => pair.Key == "TNS").Value;
            string Name = parameters.FirstOrDefault(pair => pair.Key == "Name").Value;

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

                String deCryptValue = EncryptionHandler.DecryptString(Password, ref res, false);
                if (res == true)
                {
                    connStr = connStr.Replace("{PASS}", deCryptValue);
                }
                else
                {
                    connStr = connStr.Replace("{PASS}", Password);
                }
            }
            else
            {
                String strConnString = TNS;

                connStr = "Data Source=" + TNS + ";User Id=" + User + ";";

                String   deCryptValue = EncryptionHandler.DecryptString(Password, ref res, false);
                string[] host         = TNS.Split(':');
                if (host.Length == 2)
                {
                    connStr = String.Format("Server ={0};Port={1};User Id={2}; Password={3};Database={4};", host[0], host[1], User, deCryptValue, Name);
                }
                else
                {
                    connStr = String.Format("Server ={0};User Id={1}; Password={2};Database={3};", TNS, User, deCryptValue, Name);
                }
            }

            return(connStr);
        }
コード例 #14
0
 private void grdMain_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
 {
     if (e.Column.Header.ToString() == "User Password")
     {
         Database selectedEnvDB = (Database)grdAppDbs.CurrentItem;
         String   intialValue   = selectedEnvDB.Pass;
         if (intialValue != null)
         {
             bool   res          = false;
             String deCryptValue = EncryptionHandler.DecryptString(intialValue, ref res);
             selectedEnvDB.Pass = null;
             if (res == false)
             {
                 selectedEnvDB.Pass = EncryptionHandler.EncryptString(intialValue, ref res);;
             }
         }
     }
 }
コード例 #15
0
        public override bool MakeSureConnectionIsOpen()
        {
            bool   res      = false;
            string password = string.Empty;
            string pass     = EncryptionHandler.DecryptString(Db.PassCalculated.ToString(), ref res, false);

            if (res)
            {
                password = pass;
            }
            else
            {
                password = Db.PassCalculated;
            }
            try
            {
                if (clusterCB != null)
                {
                    var clusterManager = clusterCB.CreateManager(Db.UserCalculated, password);
                    var buckets        = clusterManager.ListBuckets().Value;
                    if (buckets != null)
                    {
                        return(true);
                    }
                    else
                    {
                        return(Connect());
                    }
                }
                return(Connect());
            }
            catch (Exception ex)
            {
                return(Connect());
            }
        }
コード例 #16
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);
            }
        }
コード例 #17
0
ファイル: Database.cs プロジェクト: linuxerlj/Ginger
        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, false);
                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, false);

                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);
        }
コード例 #18
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);
            }
        }
コード例 #19
0
ファイル: Email.cs プロジェクト: zhaoshijian/Ginger
        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);
            }
        }