private void buttonReadDB_Click(object sender, EventArgs e)
 {
     if (connection != null)
     {
         try
         {
             dataSet = new DataSet();
             IDbCommand command = connection.CreateCommand();
             command.CommandText = string.Format("SELECT ID, IDENTIFICATION, KEYS, EN as Description FROM SYS_LANGUAGE WHERE IDENTIFICATION = '{0}'", ID);
             adapter = CreateDbDataAdapter(command);
             adapter.FillSchema(dataSet, SchemaType.Mapped);
             adapter.Fill(dataSet);
             dataGridView.DataSource = dataSet;
             dataGridView.DataMember = dataSet.Tables[0].TableName;
             dataGridView.Columns[0].Visible = false;
             dataGridView.Columns[1].Visible = false;
             dataSet.Tables[0].TableNewRow += delegate(object table, DataTableNewRowEventArgs dre)
             {
                 dre.Row["IDENTIFICATION"] = ID;
             };
             buttonWriteDB.Enabled = true;
             buttonRefresh.Enabled = true;
         }
         catch (Exception ex)
         {
             MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Accept connection (just returns a default token)
        /// </summary>
        /// <param name="adapter">The server adapter</param>
        /// <param name="globalMeta"></param>
        /// <param name="meta"></param>
        /// <param name="service"></param>        
        /// <returns>The proxy token</returns>
        public override ProxyToken Accept(IDataAdapter adapter, MetaDictionary meta, MetaDictionary globalMeta, ProxyNetworkService service)
        {
            ProxyToken token = new PassThroughToken(adapter);
            token.Layers = _layers.CreateLayers(_logger);

            return token;
        }
Esempio n. 3
0
 public override void SetDataAdapterCommands(IDataAdapter da, IDbCommand select, IDbCommand update, IDbCommand insert, IDbCommand delete)
 {
     SqlDataAdapter sda = (SqlDataAdapter)da;
     sda.SelectCommand = (SqlCommand)select;
     sda.UpdateCommand = (SqlCommand)update;
     sda.InsertCommand = (SqlCommand)insert;
     sda.DeleteCommand = (SqlCommand)delete;
 }
Esempio n. 4
0
        protected override RequestErrorType RecievedRequest(IDataAdapter httpRequestLog, SPChannelWrapper channel, out bool requestOK, out string errorMessage)
        {
            RequestType requestType = channel.GetRequestType(httpRequestLog);

            RequestErrorType requestError = RequestErrorType.NoError;

            errorMessage = "";

            requestOK = false;

            int feetime = Convert.ToInt32(channel.GetFeetime(httpRequestLog));

            string linkid = channel.GetLinkID(httpRequestLog);

            bool statusOk = true;

            if (requestType == RequestType.DataStatusReport)
            {
                statusOk = channel.GetStatus(httpRequestLog);
            }

            if (statusOk == false)
            {
                requestOK = true;
                return requestError;
            }

            for (int i = 0; i < feetime; i++)
            {
                IDataAdapter request = new HttpGetPostAdapter(httpRequestLog);

                string linkidKey = channel.ChannelParams[DictionaryConst.Dictionary_SPField_LinkID_Key];

                if (request.RequestParams.ContainsKey(linkidKey))
                {
                    request.RequestParams[linkidKey] = linkid + "-" + i.ToString();
                }
                else
                {
                    request.RequestParams.Add(linkidKey, linkid + "-" + i.ToString());
                }

                string feeTimeKey = channel.ChannelParams[DictionaryConst.Dictionary_SPField_FeeTime_Key];

                if (request.RequestParams.ContainsKey(feeTimeKey))
                {
                    request.RequestParams[feeTimeKey] = feetime.ToString();
                }
                else
                {
                    request.RequestParams.Add(feeTimeKey, feetime.ToString());
                }

                requestOK = channel.ProcessRequest(request, statusOk, out requestError, out errorMessage);
            }

            return requestError;
        }
Esempio n. 5
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="da"></param>
        public void CreateConnection(IDataAdapter da)
        {
            if (ClientConnected != null)
            {
                _logger.LogVerbose(Properties.Resources.ManualNetworkListener_CreateLogString);

                ClientConnected.Invoke(this, new ClientConnectedEventArgs(da));
            }
        }
Esempio n. 6
0
    // Called when reading from server -> client
    protected override IEnumerable<DataFrame> ReadServerFrames(IDataAdapter client)
    {
        Logger.LogInfo("Starting to read server frames");
        DataFrame frame = client.Read();
        while (frame != null)
        {
             yield return XorFrame(frame, 88);

             frame = client.Read();
        }
    }
Esempio n. 7
0
 public ConsoleControl(IDataAdapter adapter, Color foreColor, Color backColor, Font consoleFont)
 {
     _adapter = adapter;
     InitializeComponent();
     if (consoleFont != null)
     {
         richTextBoxOutput.Font = consoleFont;
     }
     richTextBoxOutput.ForeColor = foreColor;
     richTextBoxOutput.BackColor = backColor;
     this.Disposed += ConsoleControl_Disposed;
 }
Esempio n. 8
0
 public DbContext(string cnsconfig, bool transaction, IsolationLevel il)
 {
     _cfg = GetConfiguration(cnsconfig);
     _cn = _cfg.GetConnection();
     _cmd = _cn.CreateCommand();
     _da = _cfg.GetDataAdapter(_cmd);
     if (transaction)
     {
         _trans = _cn.BeginTransaction(il);
         _cmd.Transaction = _trans;
     }
     else
     {
         _trans = null;
     }
 }
Esempio n. 9
0
    // Run method, should exit when finished
    public override void Run(IDataAdapter adapter, Logger logger)
    {
        // Write out a message on connection
        adapter.Write(new DataFrame("Hello There!\n"));

        DataFrame frame = adapter.Read();

        while (frame != null)
        {
            logger.LogInfo("Received {0}", frame);

            // Write it back out again reversed
            adapter.Write(new DataFrame(frame.ToArray().Reverse().ToArray()));

            frame = adapter.Read();
        }
    }
Esempio n. 10
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="adapter"></param>
        /// <param name="meta"></param>
        /// <param name="globalMeta"></param>
        /// <param name="service"></param>
        /// <returns></returns>
        public override ProxyToken Accept(IDataAdapter adapter, MetaDictionary meta, MetaDictionary globalMeta, ProxyNetworkService service)
        {
            ProxyToken token = null;

            TcpClientDataAdapter tcpAdapter = adapter as TcpClientDataAdapter;

            if (_config.SslConfig.Enabled)
            {
                IDataAdapter client = null;
                INetworkLayer ssl = new SslNetworkLayer(_config.SslConfig);

                ssl.Negotiate(ref adapter, ref client, null, _logger, null, null,
                      new PropertyBag("Root"), NetworkLayerBinding.Server);
            }

            DataAdapterToStream stm = new DataAdapterToStream(adapter);
            DataReader reader = new DataReader(stm);

            try
            {
                HttpRequestHeader header = HttpParser.ReadRequestHeader(reader, false, _logger);

                token = HandleOtherRequest(header, stm, tcpAdapter);
            }
            catch (HttpStreamParserException ex)
            {
                _logger.LogError(CANAPE.Net.Properties.Resources.HttpProxyServer_InvalidRequest, ex.Message);

                // TODO: Put in some decent error codes
                ReturnResponse(null, 400, "Bad Request", "GET", HttpVersion.Version11, stm);
            }
            catch (EndOfStreamException)
            {
                token = null;
            }

            return token;
        }
Esempio n. 11
0
 public string SPCodeFromRequset(IDataAdapter requestLog)
 {
     return GetRequsetValueByKey(requestLog, DictionaryConst.Dictionary_SPField_SpNumber_Key);
 }
Esempio n. 12
0
 public string LinkIDFromRequset(IDataAdapter requestLog)
 {
     return GetRequsetValueByKey(requestLog, DictionaryConst.Dictionary_SPField_LinkID_Key);
 }
Esempio n. 13
0
 public string GetRequsetValueByKey(IDataAdapter requestLog, string key)
 {
     if (requestLog.RequestParams.ContainsKey(this[key]))
         return requestLog.RequestParams[this[key]].ToString();
     else
         return "";
 }
Esempio n. 14
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="token">A cancellation token to use</param>
 public CoupledDataAdapter(CancellationToken token)
     : base(token)
 {
     Coupling = new QueuingDataAdapter(this);
 }
Esempio n. 15
0
 /// <summary>
 /// 利用 DataAdapter 填充 DataSet
 /// </summary>
 /// <param name="adapter">用于填充 DataSet 的 Adapter 对象</param>
 /// <returns>填充后的 DataSet 对象</returns>
 public static DataSet Fill( IDataAdapter adapter )
 {
     return Fill( adapter, null );
 }
Esempio n. 16
0
		protected void init(string TableName, Db Database)
		{
			//this.ConnStr = ConnStr;
			//BelongDbType = Type;
			this.Database = Database;
			ds = new DataSet();
			try
			{
				da = Database.GetAdapter("select top 1 * from " + TableName);
				//da = DbHelper.GetAdapter(`"select top 1 * from " + TableName, ConnStr, Type);
			}
			catch (Exception e)
			{
				Exceptions.LogOnly(e);
				throw e;
			}
			dt = da.FillSchema(ds, SchemaType.Source)[0];
			this.TableName = TableName;
			this.PrimaryField = dt.Columns[0].ColumnName;
		}
Esempio n. 17
0
        public void Save(IDataAdapter dataAdapter)
        {
            Verify.Argument.IsNotNull(dataAdapter, "dataAdapter");

            dataAdapter.Store(_rootSection);
        }
Esempio n. 18
0
 public ConfigurationManager(IDataAdapter dataAdapter)
 {
     Load(dataAdapter);
 }
Esempio n. 19
0
        /// <summary>
        /// Method to bind an endpoint
        /// </summary>
        /// <param name="id"></param>
        /// <param name="adapter"></param>
        public void BindEndpoint(Guid id, IDataAdapter adapter)
        {
            if (Nodes.ContainsKey(id) && (Nodes[id] is IPipelineEndpoint))
            {
                IPipelineEndpoint ep = Nodes[id] as IPipelineEndpoint;

                ep.Adapter = adapter;
            }
            else
            {
                throw new ArgumentException(String.Format(CANAPE.Properties.Resources.NetGraph_InvalidEndpointId, id));
            }
        }
Esempio n. 20
0
 public string CreateDateFromRequset(IDataAdapter requestLog)
 {
     return GetRequsetValueByKey(requestLog, DictionaryConst.Dictionary_SPField_CreateDate_Key);
 }
Esempio n. 21
0
 public string ExtendField4FromRequset(IDataAdapter requestLog)
 {
     return GetRequsetValueByKey(requestLog, DictionaryConst.Dictionary_SPField_ExtendField4_Key);
 }
 public DataRenderer(IDataAdapter dataAdapter)
 {
     _dataAdapter = dataAdapter;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SendGridQueueProcessor"/> class.
 /// </summary>
 /// <param name="logger">
 /// The logger.
 /// </param>
 /// <param name="dataAdapter">
 /// Data adapter
 /// </param>
 /// <param name="settings">
 /// Settings instance
 /// </param>
 public SendGridQueueProcessor(ILog logger, IDataAdapter dataAdapter, Settings settings)
     : base(logger, dataAdapter, settings)
 {
 }
Esempio n. 24
0
        /// <summary>
        /// Constructeur par défaut de la DalProxy
        /// </summary>
        public DalProxy()
	    {
            DalManager = new DalManager();
            DataAdapter = new DataAdapterSql();
	    }
Esempio n. 25
0
        public void Load(IDataAdapter dataAdapter)
        {
            Verify.Argument.IsNotNull(dataAdapter, "dataAdapter");

            _rootSection = dataAdapter.Load();
        }
Esempio n. 26
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="adapter"></param>
        /// <param name="globalMeta"></param>
        /// <param name="meta"></param>
        /// <param name="service"></param>
        /// <returns></returns>
        public override ProxyToken Accept(IDataAdapter adapter, MetaDictionary meta, MetaDictionary globalMeta, ProxyNetworkService service)
        {
            DataAdapterToStream stm = new DataAdapterToStream(adapter);

            return HandleConnectRequest(stm);
        }
Esempio n. 27
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="adapter">The data adapter to wrap</param>
 /// <param name="data">The prefix data to send</param>
 public PrefixedDataAdapter(IDataAdapter adapter, byte[] data)
 {
     _adapter = adapter;
     _data = data;
 }
Esempio n. 28
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="token"></param>
        /// <param name="client"></param>
        /// <param name="globalMeta"></param>
        /// <param name="meta"></param>
        /// <param name="service"></param>
        /// <returns></returns>
        public override IDataAdapter Complete(ProxyToken token, MetaDictionary meta, MetaDictionary globalMeta, ProxyNetworkService service, IDataAdapter client)
        {
            SocksProxyToken socksToken = (SocksProxyToken)token;

            if (IsSupported(socksToken.Version))
            {
                if (socksToken.Version == 4)
                {
                    return HandleSocksV4Response(socksToken);
                }
                else if (socksToken.Version == 5)
                {
                    return HandleSocksV5Response(socksToken);
                }
                else
                {
                    // We shouldn't get here
                    throw new InvalidOperationException(CANAPE.Net.Properties.Resources.SocksProxyServer_IsSupportedError);
                }
            }
            else
            {
                _logger.LogError(CANAPE.Net.Properties.Resources.SocksProxyServer_UnsupportedTokenVersion, socksToken.Version);
            }

            return null;
        }
Esempio n. 29
0
        /***********************************************************************
         *
         *  Database Definition Functions
         *
         *  This should be db agnostic as we define them in ADO.NET terms
         *
         **********************************************************************/

        protected void CreateDataSetMapping(IDataAdapter da, string tableName)
        {
            ITableMapping dbMapping = da.TableMappings.Add(tableName, tableName);
            foreach (DataColumn col in ds.Tables[tableName].Columns)
            {
                dbMapping.ColumnMappings.Add(col.ColumnName, col.ColumnName);
            }
        }
        protected void LoadFromDataAdapter(IDataAdapter dataAdapter)
        {
            var dataSet = new DataSet();
            dataAdapter.Fill(dataSet);
            Data = dataSet.Tables[0];

            Log.Info("Data loaded.");

            for (var i = 0; i < Data.Columns.Count; i++)
            {
                var columnName = Data.Columns[i].ColumnName;
                var dataType = Data.Columns[i].DataType;
                Log.Info("Loaded column '{0}', data type '{1}'.", columnName, dataType != null ? dataType.Name : "unknown");

            }

            Log.Info("Data load complete. {0} rows loaded.", Data.Rows.Count);
        }
Esempio n. 31
0
        /// <summary>
        /// 利用 DataAdapter 填充 DataSet
        /// </summary>
        /// <param name="adapter">用于填充 DataSet 的 Adapter 对象</param>
        /// <param name="dataSet">要被填充的 DataSet 对象</param>
        /// <returns>填充后的 DataSet 对象</returns>
        public static DataSet Fill( IDataAdapter adapter, DataSet dataSet )
        {
            if ( dataSet == null )
            dataSet = new DataSet();

              adapter.Fill( dataSet );

              return dataSet;
        }
Esempio n. 32
0
 public override void SetCommandToAdapter(IDataAdapter dataAdapter, DbCommand command)
 {
     ((SqlDataAdapter)dataAdapter).SelectCommand = (SqlCommand)command;
 }