Ejemplo n.º 1
0
        /// <summary>
        /// 获取当前连接的参数。
        /// </summary>
        /// <returns></returns>
        public override ConnectionParameter GetConnectionParameter(ConnectionString connectionString)
        {
            var provider = connectionString.Properties["provider"];

            var parameter = new ConnectionParameter
            {
                Database = connectionString.Properties["data source"],
                UserId   = connectionString.Properties["user id"],
                Password = connectionString.Properties["password"]
            };

            switch (provider.ToUpper())
            {
            case "SQLOLEDB":
                parameter.Schema = "dbo";
                break;

            case "MSDAORA":
            case "MSDAORA.1":
                parameter.Schema = connectionString.Properties["user id"].ToUpper();
                break;
            }

            return(parameter);
        }
Ejemplo n.º 2
0
        static void OnSocket(NktHook hook, NktProcess process, NktHookCallInfo callInfo)
        {
            APIUnit report = Base(APIType.Simple, APICategory.Simple, APIID.SocketConnect, hook, process, callInfo);

            if (report == null)
            {
                return;
            }
            var param = new ConnectionParameter();
            int len   = callInfo.Params().GetAt(2).LongVal;

            byte[]            buf = new byte[len];
            GCHandle          h   = GCHandle.Alloc(buf, GCHandleType.Pinned);
            IntPtr            p   = h.AddrOfPinnedObject();
            var               add = callInfo.Params().GetAt(1);
            INktProcessMemory mem = add.Memory();

            mem.ReadMem(p, add.PointerVal, (IntPtr)len);
            h.Free();
            report.ID        = hook.FunctionName.Contains("bind") ? APIID.SocketBind : APIID.SocketConnect;
            param.Port       = (ushort)(buf[2] * 256 + buf[3]);
            param.IP         = String.Format("{0}.{1}.{2}.{3}", buf[4].ToString("D3"), buf[5].ToString("D3"), buf[6].ToString("D3"), buf[7].ToString("D3"));
            param.Server     = hook.FunctionName.Contains("bind") ? true : false;
            report.ID        = param.Server ? APIID.SocketBind : APIID.SocketConnect;
            report.Parameter = param;
            Reports.Enqueue(report);
        }
Ejemplo n.º 3
0
 public ConnectionViewModel()
 {
     _connectionParameter = new ConnectionParameter
     {
         Login    = "******",
         Password = string.Empty,
         Port     = 1235,
         ServerIp = "91.230.153.2"
     };
 }
Ejemplo n.º 4
0
 public PrintCommanderMainForm()
 {
     InitializeComponent();
     printGroups = new PrintGroupItemList();
     conParm     = new ConnectionParameter();
     manageToolStripMenuItem1.Enabled            = false;
     disablePrinterPoolToolStripMenuItem.Enabled = false;
     removePrinterPoolToolStripMenuItem1.Enabled = false;
     manageToolStripMenuItem.Enabled             = false;
     removePrinterPoolToolStripMenuItem.Enabled  = false;
     setAsDefaToolStripMenuItem.Enabled          = false;
 }
Ejemplo n.º 5
0
 // Validate the connection when connector endpoints are dragged
 protected override void ValidateConnection(ConnectionParameter args)
 {
     if (args.TargetPort is PortVM)
     {
         var port = args.TargetPort as PortVM;
         if (!port.CanCreateConnection(args.Connector as IConnector))
         {
             args.TargetPort = null;
         }
     }
     base.ValidateConnection(args);
 }
Ejemplo n.º 6
0
        public static void ConnectionParams(string connectionString)
        {
            SqlConnectionStringBuilder decoder = new SqlConnectionStringBuilder(connectionString);

            string UserID   = decoder.UserID;
            string Password = decoder.Password;

            ConnectionParameter oConnectionParameter = new ConnectionParameter();

            oConnectionParameter.username           = decoder.UserID;
            oConnectionParameter.password           = decoder.Password;
            oConnectionParameter.catalog            = decoder.InitialCatalog;
            oConnectionParameter.integratedSecurity = decoder.IntegratedSecurity;
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Override the validate connection
 /// </summary>
 /// <param name="args">Gets args value</param>
 protected override void ValidateConnection(ConnectionParameter args)
 {
     // set the target node and target port
     if (args.TargetPort == null && args.TargetNode != null)
     {
         if (args.TargetNode is NodeViewModel)
         {
             NodeViewModel node = args.TargetNode as NodeViewModel;
             if (node.Ports != null && (node.Ports as ObservableCollection <IPort>).Count() > 0)
             {
                 args.TargetPort = (node.Ports as ObservableCollection <IPort>)[0];
             }
         }
     }
 }
Ejemplo n.º 8
0
        protected override void ValidateConnection(ConnectionParameter args)
        {
            var isSourceAction = args.ConnectorEnd == ConnectorEnd.Source;

            if ((isSourceAction && args.SourcePort != null) || (!isSourceAction && args.TargetPort != null))
            {
                //To change the connection indicator style of the port connection.
                this.ConnectionIndicatorStyle = Application.Current.Resources["PortConnectorIndicatorstyle"] as Style;
            }
            else if ((isSourceAction && args.SourceNode != null) || (!isSourceAction && args.TargetNode != null))
            {
                this.ConnectionIndicatorStyle = Application.Current.Resources["NodeConnectorIndicatorstyle"] as Style;
            }

            base.ValidateConnection(args);
        }
Ejemplo n.º 9
0
 /// <summary>
 /// 使用参数更新指定的连接。
 /// </summary>
 /// <param name="connectionString">连接字符串对象。</param>
 /// <param name="parameter"></param>
 public override void UpdateConnectionString(ConnectionString connectionString, ConnectionParameter parameter)
 {
     connectionString.Properties.TrySetValue(parameter.Server, "data source")
     .TrySetValue(parameter.Database, "database")
     .TrySetValue(parameter.UserId, "user id")
     .TrySetValue(parameter.Password, "password")
     .Update();
 }
        public static void Run()
        {
            //Source directory
            string sourceDir = RunExamples.Get_SourceDirectory();

            // Create a workbook object from source file
            Workbook workbook = new Workbook(sourceDir + "sampleRetrievingSQLConnectionData.xlsx");

            // Access the external collections
            ExternalConnectionCollection connections = workbook.DataConnections;

            int connectionCount = connections.Count;

            ExternalConnection connection = null;

            for (int i = 0; i < connectionCount; i++)
            {
                connection = connections[i];

                // Check if the Connection is DBConnection, then retrieve its various properties
                if (connection is DBConnection)
                {
                    DBConnection dbConn = (DBConnection)connection;

                    // Retrieve DB Connection Command
                    Console.WriteLine("Command: " + dbConn.Command);

                    // Retrieve DB Connection Command Type
                    Console.WriteLine("Command Type: " + dbConn.CommandType);

                    // Retrieve DB Connection Description
                    Console.WriteLine("Description: " + dbConn.ConnectionDescription);

                    // Retrieve DB Connection ID
                    Console.WriteLine("Id: " + dbConn.ConnectionId);

                    // Retrieve DB Connection Info
                    Console.WriteLine("Info: " + dbConn.ConnectionInfo);

                    // Retrieve DB Connection Credentials
                    Console.WriteLine("Credentials: " + dbConn.CredentialsMethodType);

                    // Retrieve DB Connection Name
                    Console.WriteLine("Name: " + dbConn.Name);

                    // Retrieve DB Connection ODC File
                    Console.WriteLine("OdcFile: " + dbConn.OdcFile);

                    // Retrieve DB Connection Source File
                    Console.WriteLine("Source file: " + dbConn.SourceFile);

                    // Retrieve DB Connection Type
                    Console.WriteLine("Type: " + dbConn.Type);

                    // Retrieve DB Connection Parameters Collection
                    ConnectionParameterCollection paramCollection = dbConn.Parameters;

                    int paramCount = paramCollection.Count;

                    // Iterate the Parameter Collection
                    for (int j = 0; j < paramCount; j++)
                    {
                        ConnectionParameter param = paramCollection[j];

                        // Retrieve Parameter Cell Reference
                        Console.WriteLine("Cell reference: " + param.CellReference);

                        // Retrieve Parameter Name
                        Console.WriteLine("Parameter name: " + param.Name);

                        // Retrieve Parameter Prompt
                        Console.WriteLine("Prompt: " + param.Prompt);

                        // Retrieve Parameter SQL Type
                        Console.WriteLine("SQL Type: " + param.SqlType);

                        // Retrieve Parameter Type
                        Console.WriteLine("Param Type: " + param.Type);

                        // Retrieve Parameter Value
                        Console.WriteLine("Param Value: " + param.Value);
                    } // End for
                }     // End if
            }         // End for

            Console.WriteLine("RetrievingSQLConnectionData executed successfully.");
        }
Ejemplo n.º 11
0
 /// <summary>
 /// 使用参数更新指定的连接。
 /// </summary>
 /// <param name="connectionString">连接字符串对象。</param>
 /// <param name="parameter"></param>
 /// <returns></returns>
 public abstract string UpdateConnectionString(ConnectionString connectionString, ConnectionParameter parameter);
Ejemplo n.º 12
0
 public override string UpdateConnectionString(ConnectionString connectionString, ConnectionParameter parameter)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 13
0
        /// <summary>
        /// 使用参数更新指定的连接。
        /// </summary>
        /// <param name="connectionString">连接字符串对象。</param>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public override string UpdateConnectionString(ConnectionString connectionString, ConnectionParameter parameter)
        {
            connectionString.Properties
            .TrySetValue(parameter.Database, "data source");

            return(connectionString.Update());
        }
Ejemplo n.º 14
0
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Create a workbook object from source file
            Workbook workbook = new Workbook(dataDir + "connection.xlsx");

            // Access the external collections
            ExternalConnectionCollection connections = workbook.DataConnections;

            int connectionCount = connections.Count;

            ExternalConnection connection = null;

            for (int i = 0; i < connectionCount; i++)
            {
                connection = connections[i];

                // Check if the Connection is DBConnection, then retrieve its various properties
                if (connection is DBConnection)
                {
                    DBConnection dbConn = (DBConnection)connection;

                    // Retrieve DB Connection Command
                    Console.WriteLine("Command: " + dbConn.Command);

                    // Retrieve DB Connection Command Type
                    Console.WriteLine("Command Type: " + dbConn.CommandType);

                    // Retrieve DB Connection Description
                    Console.WriteLine("Description: " + dbConn.ConnectionDescription);

                    // Retrieve DB Connection ID
                    Console.WriteLine("Id: " + dbConn.ConnectionId);

                    // Retrieve DB Connection Info
                    Console.WriteLine("Info: " + dbConn.ConnectionInfo);

                    // Retrieve DB Connection Credentials
                    Console.WriteLine("Credentials: " + dbConn.Credentials);

                    // Retrieve DB Connection Name
                    Console.WriteLine("Name: " + dbConn.Name);

                    // Retrieve DB Connection ODC File
                    Console.WriteLine("OdcFile: " + dbConn.OdcFile);

                    // Retrieve DB Connection Source File
                    Console.WriteLine("Source file: " + dbConn.SourceFile);

                    // Retrieve DB Connection Type
                    Console.WriteLine("Type: " + dbConn.Type);

                    // Retrieve DB Connection Parameters Collection
                    ConnectionParameterCollection paramCollection = dbConn.Parameters;

                    int paramCount = paramCollection.Count;

                    // Iterate the Parameter Collection
                    for (int j = 0; j < paramCount; j++)
                    {
                        ConnectionParameter param = paramCollection[j];

                        // Retrieve Parameter Cell Reference
                        Console.WriteLine("Cell reference: " + param.CellReference);

                        // Retrieve Parameter Name
                        Console.WriteLine("Parameter name: " + param.Name);

                        // Retrieve Parameter Prompt
                        Console.WriteLine("Prompt: " + param.Prompt);

                        // Retrieve Parameter SQL Type
                        Console.WriteLine("SQL Type: " + param.SqlType);

                        // Retrieve Parameter Type
                        Console.WriteLine("Param Type: " + param.Type);

                        // Retrieve Parameter Value
                        Console.WriteLine("Param Value: " + param.Value);
                    } // End for
                }     // End if
            }         // End for
             // ExEnd:1
        }
Ejemplo n.º 15
0
 /// <summary>
 /// 使用参数更新指定的连接。
 /// </summary>
 /// <param name="connectionString">连接字符串对象。</param>
 /// <param name="parameter"></param>
 public override void UpdateConnectionString(ConnectionString connectionString, ConnectionParameter parameter)
 {
     connectionString.Properties.TrySetValue(parameter.Server, "server")
     .TrySetValue(parameter.Database, "database")
     .Update();
 }
Ejemplo n.º 16
0
        /// <summary>
        /// 使用参数更新指定的连接。
        /// </summary>
        /// <param name="connectionString">连接字符串对象。</param>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public override string UpdateConnectionString(ConnectionString connectionString, ConnectionParameter parameter)
        {
            connectionString.Properties.TrySetValue(parameter.Server, "data source", "server")
            .TrySetValue(parameter.Database, "initial catalog", "database")
            .TrySetValue(parameter.UserId, "user id", "uid")
            .TrySetValue(parameter.Password, "password", "pwd");

            return(connectionString.Update());
        }
Ejemplo n.º 17
0
 public frmServer()
 {
     InitializeComponent();
     Param = new ConnectionParameter(Connection.Instance.ConnectionParameter);
     FillControls();
 }