コード例 #1
0
ファイル: Global.cs プロジェクト: SDRC-India/sdrcdevinfo
    public static DIConnectionDetails GetMapServerConnectionDetails()
    {
        //ServerType||ServerName||Database||User||Pasword

        DIConnectionDetails RetVal = new DIConnectionDetails();
        List<string> connectionDetailsWS;

        //GetConnection from web service
        connectionDetailsWS = new List<string>(DIMapServer.WebServiceInstance.GetMapServerConnection().Split("||".ToCharArray(), StringSplitOptions.RemoveEmptyEntries));

        RetVal.ServerType = (DIServerType)Convert.ToInt32(connectionDetailsWS[0]);
        //RetVal.ServerName = "localhost";
        RetVal.ServerName = connectionDetailsWS[1];
        RetVal.DbName = connectionDetailsWS[2];
        RetVal.UserName = connectionDetailsWS[3];
        RetVal.Password = Global.DecryptString(connectionDetailsWS[4]);

        //RetVal.ServerName = "dgps2";
        //RetVal.DbName = "DI7_MDG_r12";
        //RetVal.UserName = "******";
        //RetVal.Password = "******";

        return RetVal;
    }
コード例 #2
0
 /// <summary>
 /// Reset the selected connection details.
 /// </summary>
 private void ResetDefaultConnection()
 {
     this._SelectedConnectionDetail = null;
     this._SelectedConnectionName = string.Empty;
     this._SelectedDatasetName = string.Empty;
 }
コード例 #3
0
 /// <summary>
 /// constructor to save the database information
 /// </summary>
 /// <param name="connectionDetails">Connection Details</param>
 /// <param name="datasetInfo">Dataset information</param>         
 public OnlineConnectionDetail(DIConnectionDetails connectionDetails, OnlineDataSets datasetInfo, string connection)
 {
     this._DIConnectionDetails = connectionDetails;
     this._OnlineDatasetInfo = datasetInfo;
     this._Connection = connection;
 }
コード例 #4
0
ファイル: DICommon.cs プロジェクト: SDRC-India/sdrcdevinfo
        /// <summary>
        /// Returns true if template or database is DevInfo compatible
        /// </summary>
        /// <param name="dbConnection"></param>
        /// <param name="isForOnlineDB"></param>
        /// <returns></returns>
        /// <remarks>It will validate on the basis of default langauge and dataset</remarks>
        public static bool ISVaildDevInfoDatabase(DIConnectionDetails connectionDetails)
        {
            bool RetVal = false;
            bool IsForOnlineDB;
            DIConnection DBConnection = null;
            DIQueries DbQueries;
            DI5SP2DBConverter SP2Converter = null;
            try
            {
                DBConnection = new DIConnection(connectionDetails);
                //AvailableDB
                DbQueries = new DIQueries(DBConnection.DIDataSetDefault(), DBConnection.DILanguageCodeDefault(DBConnection.DIDataSetDefault()));

                // check DB_Available_Databases table exists
                if (!string.IsNullOrEmpty(DBConnection.DIDataSetDefault()))
                {
                    RetVal = true;

                    ////// if exists then check for SP2 database
                    ////SP2Converter = new DI5SP2DBConverter(DBConnection, DbQueries);

                    ////switch (connectionDetails.ServerType)
                    ////{
                    ////    case DIServerType.Excel:
                    ////    case DIServerType.MsAccess:
                    ////        IsForOnlineDB = false;
                    ////        break;
                    ////    default:
                    ////        IsForOnlineDB = true;
                    ////        break;
                    ////}
                    ////RetVal = SP2Converter.IsValidDB(IsForOnlineDB);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Print(ex.Message);
                RetVal = false;
            }
            finally
            {
                if (DBConnection != null)
                {
                    DBConnection.Dispose();
                }
            }

            return RetVal;
        }
コード例 #5
0
 /// <summary>
 /// Add the access database in the collection
 /// </summary>
 /// <param name="dataFolderPath"></param>
 private void OfflineDbCollection(string dataFolderPath)
 {
     string[] DbFiles = new string[0];
     DbFiles = Directory.GetFiles(dataFolderPath, "*.mdb");
     foreach (string OfflineDatabase in DbFiles)
     {
         //-- Offline database not exists in the collection.
         if (!IsOfflineDatabaseExists(OfflineDatabase))
         {
             DIConnectionDetails OfflineConnectionDetail = new DIConnectionDetails(DIServerType.MsAccess, "", "", OfflineDatabase, USERNAME, PASSWORD);
             //-- Set the connection
             DIConnection DIConnection = new DIConnection(OfflineConnectionDetail);
             //-- Get all the datasets.
             DataTable DataSetTable = DIConnection.DIDataSets();
             DatabasePreference.OnlineConnectionDetail.OnlineDataSets OfflineDataSets = new OnlineConnectionDetail.OnlineDataSets();
             //-- add all datasets into the collection.
             foreach (DataRow Row in DataSetTable.Rows)
             {
                 OfflineDataSets.Add(new DatabasePreference.OnlineConnectionDetail.OnlineDataSet(Row[DBAvailableDatabases.AvlDBPrefix].ToString(), Row[DBAvailableDatabases.AvlDBName].ToString()));
             }
             DatabasePreference.OnlineConnectionDetail ConnectionDetail = new OnlineConnectionDetail(OfflineConnectionDetail, OfflineDataSets, Path.GetFileName(OfflineDatabase));
             //-- add the offline database details.
             this.OnlineDatabaseDetails.Add(ConnectionDetail);
         }
     }
 }
コード例 #6
0
ファイル: DIMapServer.cs プロジェクト: SDRC-India/sdrcdevinfo
        public static DIConnectionDetails GetMapServerConnectionDetails()
        {
            //ServerType||ServerName||Database||User||Pasword

            DIConnectionDetails RetVal = new DIConnectionDetails();
            List<string> connectionDetailsWS;

            //GetConnection from web service
            connectionDetailsWS = new List<string>(DIMapServer.WebServiceInstance.GetMapServerConnection().Split("||".ToCharArray(), StringSplitOptions.RemoveEmptyEntries));

            RetVal.ServerType = (DIServerType)Convert.ToInt32(connectionDetailsWS[0]);

            if (!string.IsNullOrEmpty(DIMapServer.MapServerName))
            {
                RetVal.ServerName = DIMapServer.MapServerName;
            }
            else
            {
                RetVal.ServerName = connectionDetailsWS[1];
            }

            RetVal.DbName = connectionDetailsWS[2];
            RetVal.UserName = connectionDetailsWS[3];
            RetVal.Password = DIMapServer.DecryptStringForMapServer(connectionDetailsWS[4]);

            //RetVal.ServerName = "dgps2";
            //RetVal.DbName = "DI7_MDG_r12";
            //RetVal.UserName = "******";
            //RetVal.Password = "******";

            //RetVal.ServerName = "23.23.128.77";
            //RetVal.DbName = "DI7_ChildProtection";
            //RetVal.UserName = "******";
            //RetVal.Password = "******";

            return RetVal;
        }
コード例 #7
0
        /// <summary>
        /// Determines whether the specified DIConnectionDetails instances are considered equal. 
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        /// <remarks>
        /// It is also recommended that in addition to implementing Equals(object), 
        /// any class also implement Equals(type) for their own type, to enhance performance
        /// </remarks>
        public bool Equals(DIConnectionDetails p)
        {
            bool RetVal = false;

            // If parameter is null return false:
            if ((System.Object)p == null)
            {
                RetVal = false;
            }
            else
            {
                // Return true if all field values match:
                if (this._ServerType == p.ServerType && string.Compare(this._ServerName, p.ServerName, true) == 0 && string.Compare(this._DbName, p.DbName, true) == 0 && string.Compare(this._UserName, p.UserName, true) == 0 && string.Compare(this._Password, p.Password, true) == 0 && string.Compare(this._PortNo, p.PortNo, true) == 0)
                {
                    RetVal = true;
                }
                else
                {
                    RetVal = false;
                }
            }

            return RetVal;
        }
コード例 #8
0
        /// <summary>
        /// Check the existing connection details with presentation database details
        /// </summary>
        /// <param name="workingDbConnection"></param>
        /// <param name="presentationPath"></param>
        /// <returns>False, if the working and presentation database connection details are different</returns>
        public static bool ValidateConnection(DIConnection workingDbConnection, string presentationPath, bool showExcel)
        {
            bool Retval = true;
            try
            {
                DIConnectionDetails PresentationDbDetails = new DIConnectionDetails();
                PresentationType PresentationType = GetPresentationType(presentationPath);
                string SerializedXML = GetSerializedPresentationText(presentationPath, PresentationType, showExcel);

                switch (PresentationType)
                {
                    case PresentationType.Table:
                        TablePresentation TablePresentation = TablePresentation.LoadFromSerializeText(SerializedXML);
                        PresentationDbDetails = TablePresentation.UserPreference.Database.SelectedConnectionDetail;
                        break;
                    case PresentationType.Graph:
                        GraphPresentation GraphPresentation = GraphPresentation.LoadFromSerializeText(SerializedXML);
                        PresentationDbDetails = GraphPresentation.TablePresentation.UserPreference.Database.SelectedConnectionDetail;
                        break;
                    case PresentationType.Map:
                        Map.Map MapPresentation = Map.Map.LoadFromSerializeText(SerializedXML);
                        PresentationDbDetails = MapPresentation.UserPreference.Database.SelectedConnectionDetail;
                        break;
                    case PresentationType.None:
                        break;
                    default:
                        break;
                }

                Retval = Presentation.ValidateConnection(workingDbConnection, PresentationDbDetails);

            }
            catch (Exception)
            {
                Retval = true;
            }
            return Retval;
        }
コード例 #9
0
        /// <summary>
        /// Check the existing connection details with proposed database details
        /// </summary>
        /// <param name="workingDbConnection"></param>
        /// <param name="proposedDBConnectionDetail"></param>
        /// <returns>False, if the working and new proposed database connection details are different</returns>
        public static bool ValidateConnection(DIConnection workingDbConnection, DIConnectionDetails proposedDBConnectionDetail)
        {
            bool Retval = true;
            try
            {
                //-- ServerType
                if (workingDbConnection.ConnectionStringParameters.ServerType != proposedDBConnectionDetail.ServerType)
                {
                    Retval = false;
                }

                //-- Database name
                if (workingDbConnection.ConnectionStringParameters.DbName.Trim().ToLower() != proposedDBConnectionDetail.DbName.Trim().ToLower())
                {
                    Retval = false;
                }

                //-- user name
                if (workingDbConnection.ConnectionStringParameters.UserName.Trim() != proposedDBConnectionDetail.UserName.Trim())
                {
                    Retval = false;
                }

                //-- Password
                if (workingDbConnection.ConnectionStringParameters.Password.Trim() != proposedDBConnectionDetail.Password.Trim())
                {
                    Retval = false;
                }

                //-- Port number
                if (workingDbConnection.ConnectionStringParameters.PortNo.Trim() != proposedDBConnectionDetail.PortNo.Trim())
                {
                    Retval = false;
                }

                if (!Retval)
                {
                    //-- IF the existing connection is different from presentation database details
                    DIConnection TestConnection = new DIConnection(proposedDBConnectionDetail);
                    if (TestConnection == null)
                    {
                        Retval = true;
                    }
                }
            }
            catch (Exception)
            {
                Retval = true;
            }

            return Retval;
        }
コード例 #10
0
        /// <summary>
        /// Returns object of DIConnection
        /// </summary>
        /// <param name="connection">Object of DIConnectionString</param>
        public DIConnection(DIConnectionDetails connection)
        {
            // create connection string
            this._ConnectionStringParameters = connection;
            this.ConnectionString = connection.GetConnectionString();

            // get provider
            this.DBType = connection.ServerType;
            this.DBProvider = this.GetProviderInstance(this.DBType);

            //create connnection
            this.InitializeConnectionObject();
        }
コード例 #11
0
 /// <summary>
 /// Sets  the server type into connection parameter object which can be used in Sql queries.
 /// </summary>
 public void SetSeverTypeInConnectionParams()
 {
     this._ConnectionStringParameters = new DIConnectionDetails();
     this._ConnectionStringParameters.ServerType = this.DBType;
 }
コード例 #12
0
        /// <summary>
        /// Returns object of DIConnection
        /// </summary>
        /// <param name="serverType">Server Type :SQL, Oracel, MySql, MsAccess, etc </param>
        /// <param name="serverName">Name of the server to connect to the database. Optional for MsAccess</param>
        /// <param name="portNo">Port No. Required for MySql(default portNo: 3306). </param>
        /// <param name="databaseName">Database name.Set full file path for MsAccess </param>
        /// <param name="userName">User name to access database.Optional for MsAccess</param>
        /// <param name="password">Password to access database</param>
        public DIConnection(DIServerType serverType, string serverName, string portNo, string databaseName, string userName, string password)
        {
            // Extract Port Number from the Server Name if available
            if (serverName.Contains(":"))
            {
                portNo = serverName.Substring(serverName.IndexOf(":") + 1);
                serverName = serverName.Substring(0, serverName.IndexOf(":"));
            }

            // create connection string
            this._ConnectionStringParameters = new DIConnectionDetails(serverType, serverName, portNo, databaseName, userName, password);
            this.ConnectionString = this._ConnectionStringParameters.GetConnectionString();

            // get provider
            this.DBType = this._ConnectionStringParameters.ServerType;
            this.DBProvider = this.GetProviderInstance(this.DBType);

            //create connnection
            this.InitializeConnectionObject();
        }
コード例 #13
0
 /// <summary>
 /// Creates the connection with  source database
 /// </summary>
 /// <param name="fileNameWPath"></param>
 public void ConnectToSQLDatabase(DIConnectionDetails connectionDetails)
 {
     this.SourceDBConnection = new DIConnection(connectionDetails);
     this.DataPrefix = this.SourceDBConnection.DIDataSetDefault();
     this.LanguageCode = this.TargetDBQueries.LanguageCode;
     this.SourceDBQueries = new DIQueries(this.DataPrefix, this.LanguageCode);
 }
コード例 #14
0
ファイル: DIData.cs プロジェクト: SDRC-India/sdrcdevinfo
        /// <summary>
        /// Updates specified DataBase name as parameter, in DB_Available Table.
        /// </summary>
        /// <param name="availableDbName"></param>
        public void UpdateAvialableDBInSavedFile(string availableDbWName)
        {
            DIConnectionDetails ConnectionDetails;
            DIConnection AvailableDBConnection;
            string DatasetPrefix;
            string LanguageCode;
            DIQueries AvailableDBQuery;
            ImportQueries Query;

            //' --Create connection with saved file
            ConnectionDetails = new DIConnectionDetails(DIServerType.MsAccess, string.Empty, string.Empty, availableDbWName, string.Empty, DAImportCommon.Constants.DBPassword);

            AvailableDBConnection = new DIConnection(ConnectionDetails);
            DatasetPrefix = AvailableDBConnection.DIDataSetDefault();
            LanguageCode = AvailableDBConnection.DILanguageCodeDefault(DatasetPrefix);
            AvailableDBQuery = new DIQueries(DatasetPrefix, LanguageCode);
            Query = new ImportQueries(AvailableDBQuery);

            //' - Update Avialble DB fileName in DB_Available_Database table.
            AvailableDBConnection.ExecuteNonQuery(Query.UpdateDB_Available_DatabaseTable(Path.GetFileNameWithoutExtension(availableDbWName)));

            //' -- Dispose Connection
            AvailableDBConnection.Dispose();
            AvailableDBQuery = null;
            Query = null;
        }