void Awake() { try { NetworkTransport.Init(); serverConfig = new ConnectionConfig(); serverChannelId = serverConfig.AddChannel(QosType.StateUpdate); // QosType.UnreliableFragmented serverConfig.MaxSentMessageQueueSize = 2048; // 128 by default serverTopology = new HostTopology(serverConfig, maxConnections); serverHostId = NetworkTransport.AddHost(serverTopology, listenOnPort); liRelTime = 0; fCurrentTime = Time.time; System.DateTime dtNow = System.DateTime.UtcNow; Debug.Log("Kinect data server started at " + dtNow.ToString() + " - " + dtNow.Ticks); if(statusText) { statusText.text = "Server running: 0 connection(s)"; } } catch (System.Exception ex) { Debug.LogError(ex.Message + "\n" + ex.StackTrace); if(statusText) { statusText.text = ex.Message; } } }
// Use this for initialization void Start() { GlobalConfig globalConfig = new GlobalConfig(); // Set the Global Config to receive data in fixed 10ms intervals. globalConfig.ReactorModel = ReactorModel.FixRateReactor; globalConfig.ThreadAwakeTimeout = INTERVAL_TIME; ConnectionConfig connectionConfig = new ConnectionConfig(); // Add data channels to the network reliableChannelID = connectionConfig.AddChannel(QosType.ReliableSequenced); unreliableChannelID = connectionConfig.AddChannel(QosType.UnreliableSequenced); // Combine channels with the maximum number of connections HostTopology hostTopology = new HostTopology(connectionConfig, maxConnections); // Initialize the Network NetworkTransport.Init(globalConfig); // Open the network socket serverSocketID = NetworkTransport.AddHost(hostTopology, DEFAULT_PORT); if (serverSocketID < 0) Debug.Log("Server socket creation failed"); else Debug.Log("Server socket creation successful"); // Note that the server is running serverInitialized = true; DontDestroyOnLoad(this); }
public async Task Should_send_encrypted_message_and_wait_for_response() { IServiceLocator serviceLocator = TestRig.CreateTestServiceLocator(); var config = new ConnectionConfig(TestRig.AuthKey, 100500) {SessionId = 2}; var messageProcessor = serviceLocator.ResolveType<IMessageCodec>(); var request = new TestRequest {TestId = 9}; var expectedResponse = new TestResponse {TestId = 9, TestText = "Number 1"}; byte[] expectedResponseMessageBytes = messageProcessor.EncodeEncryptedMessage( new Message(0x0102030405060708, 3, expectedResponse), config.AuthKey, config.Salt, config.SessionId, Sender.Server); SetupMockTransportWhichReturnsBytes(serviceLocator, expectedResponseMessageBytes); using (var connection = serviceLocator.ResolveType<IMTProtoClientConnection>()) { connection.Configure(config); await connection.Connect(); TestResponse response = await connection.RequestAsync<TestResponse>(request, MessageSendingFlags.EncryptedAndContentRelated, TimeSpan.FromSeconds(5)); response.Should().NotBeNull(); response.Should().Be(expectedResponse); await connection.Disconnect(); } }
public async Task Should_send_Rpc_and_receive_response() { IServiceLocator serviceLocator = TestRig.CreateTestServiceLocator(); var config = new ConnectionConfig(TestRig.AuthKey, 100500) {SessionId = 2}; var messageProcessor = serviceLocator.ResolveType<IMessageCodec>(); var request = new TestRequest {TestId = 9}; var expectedResponse = new TestResponse {TestId = 9, TestText = "Number 1"}; var rpcResult = new RpcResult {ReqMsgId = TestMessageIdsGenerator.MessageIds[0], Result = expectedResponse}; byte[] expectedResponseMessageBytes = messageProcessor.EncodeEncryptedMessage( new Message(0x0102030405060708, 3, rpcResult), config.AuthKey, config.Salt, config.SessionId, Sender.Server); SetupMockTransportWhichReturnsBytes(serviceLocator, expectedResponseMessageBytes); using (var connection = serviceLocator.ResolveType<IMTProtoClientConnection>()) { connection.Configure(config); await connection.Connect(); TestResponse response = await connection.RpcAsync<TestResponse>(request); response.Should().NotBeNull(); response.Should().Be(expectedResponse); await connection.Disconnect(); } }
void Start() { DontDestroyOnLoad(this); //Build the global config GlobalConfig clientGlobalConfig = new GlobalConfig(); clientGlobalConfig.ReactorModel = ReactorModel.FixRateReactor; clientGlobalConfig.ThreadAwakeTimeout = 10; //Build the channel config ConnectionConfig clientConnectionConfig = new ConnectionConfig(); reliableChannelID = clientConnectionConfig.AddChannel(QosType.ReliableSequenced); unreliableChannelID = clientConnectionConfig.AddChannel(QosType.UnreliableSequenced); //Create the host topology HostTopology hostTopology = new HostTopology(clientConnectionConfig, maxConnections); //Initialize the network transport NetworkTransport.Init(clientGlobalConfig); //Open a socket for the client //Make sure the client created the socket successfully //Create a byte to store a possible error byte possibleError; //Connect to the server using //int NetworkTransport.Connect(int socketConnectingFrom, string ipAddress, int port, 0, out byte possibleError) //Store the ID of the connection in clientServerConnectionID NetworkTransport.Connect(clientSocketID, " ", 7777, 0, out possibleError); //Display the error (if it did error out) Debug.Log("Connection Failed"); }
void Start() { GlobalConfig globalConfig = new GlobalConfig(); globalConfig.ReactorModel = ReactorModel.FixRateReactor; globalConfig.ThreadAwakeTimeout = 10; ConnectionConfig connectionConfig = new ConnectionConfig(); reliableChannelID = connectionConfig.AddChannel(QosType.ReliableSequenced); unreliableChannelID = connectionConfig.AddChannel(QosType.UnreliableSequenced); HostTopology hostTopology = new HostTopology(connectionConfig, maxConnections); NetworkTransport.Init(globalConfig); serverSocketID = NetworkTransport.AddHost(hostTopology, 7777); if(serverSocketID < 0) { Debug.Log("Server socket creation failed!"); } else { Debug.Log("Server socket creation success."); } serverInitialized = true; DontDestroyOnLoad(this); }
public bool Initialize() { if (m_BroadcastData.Length >= kMaxBroadcastMsgSize) { Debug.LogError("NetworkDiscovery Initialize - data too large. max is " + kMaxBroadcastMsgSize); return false; } if (!NetworkTransport.IsStarted) { NetworkTransport.Init(); } if (NetworkManager.singleton != null) { m_BroadcastData = "NetworkManager:"+NetworkManager.singleton.networkAddress + ":" + NetworkManager.singleton.networkPort; } msgOutBuffer = StringToBytes(m_BroadcastData); msgInBuffer = new byte[kMaxBroadcastMsgSize]; ConnectionConfig cc = new ConnectionConfig(); cc.AddChannel(QosType.Unreliable); defaultTopology = new HostTopology(cc, 1); if (m_IsServer) StartAsServer(); if (m_IsClient) StartAsClient(); return true; }
public void CreateSocket() { if (_hostID > -1) return; if (inputIP.text.Length == 0 || inputPort.text.Length == 0) { errorField.text = "IP Address or Port Error"; return; } _port = int.Parse (inputPort.text); _address = inputIP.text; //http://docs.unity3d.com/Manual/UNetUsingTransport.html NetworkTransport.Init (); ConnectionConfig config = new ConnectionConfig (); _unreliableID = config.AddChannel (QosType.Unreliable); // http://blogs.unity3d.com/2014/06/11/all-about-the-unity-networking-transport-layer/ int maxConnections = 10; HostTopology topology = new HostTopology (config, maxConnections); _hostID = NetworkTransport.AddHost (topology, _port); Debug.Log ("Socket Open. _hostID: " + _hostID); if (_hostID > -1) { errorField.text = "Socket Connected!"; } }
void StartClient() { ConnectionConfig config = new ConnectionConfig(); config.AddChannel(QosType.Unreliable); HostTopology topology = new HostTopology(config, 10); localSocketId = NetworkTransport.AddHost(topology, 8888); byte err; NetworkTransport.SetBroadcastCredentials(localSocketId, 1000, 1, 1, out err); }
void StartServer() { ConnectionConfig config = new ConnectionConfig(); config.AddChannel(QosType.Unreliable); HostTopology topology = new HostTopology(config, 10); localSocketId = NetworkTransport.AddHost(topology, 0); byte err; NetworkTransport.StartBroadcastDiscovery(localSocketId, 8888, 1000, 1, 1, StringToBytes("Hello World"), 1024, 1000, out err); }
void Awake() { myClient = new NetworkClient (); ConnectionConfig config = new ConnectionConfig (); config.AddChannel (QosType.ReliableFragmented); myClient.Configure (config, 1); myClient.Connect (IP, 7777); myClient.RegisterHandler (MyMsgType.Info, OnInfoMessage); }
private void init() { NetworkTransport.Init(); ConnectionConfig config = new ConnectionConfig(); mReliableChannelId = config.AddChannel(QosType.Reliable); HostTopology topology = new HostTopology(config, MAX_CONNECTIONS); mHostId = NetworkTransport.AddHost(topology, PORT); }
public virtual void SetupAsServer(int socketId, int maxConnections) { ConnectionConfig config = new ConnectionConfig(); reliableChannelId = config.AddChannel(QosType.Reliable); unreliableChannelId = config.AddChannel(QosType.Unreliable); topology = new HostTopology(config, maxConnections); localSocketId = NetworkTransport.AddHost(topology, socketId); Debug.Log ("Set up server at port: " + socketId + " With a maximum of " + maxConnections + " Connections"); }
// Use this for initialization void Start() { NetworkTransport.Init (); ConnectionConfig config = new ConnectionConfig(); reiliableChannelId = config.AddChannel(QosType.Reliable); HostTopology topology = new HostTopology(config, 5); hostId = NetworkTransport.AddWebsocketHost(topology, 8081, null); }
public LLApiClient (string endPoint, int port, GameClient gameClient) { Config = new ConnectionConfig(); int ReliableChannelId = Config.AddChannel(QosType.Reliable); int NonReliableChannelId = Config.AddChannel(QosType.Unreliable); Topology = new HostTopology(Config, 10); EndPoint = endPoint; Port = port; GameClient = gameClient; isConnected = false; }
public void Host() { //initialize and configure stuff ConnectionConfig config = new ConnectionConfig(); reliableChannelID = config.AddChannel(QosType.Reliable); HostTopology topology = new HostTopology(config, maxConnections); //open up a socket socketID = NetworkTransport.AddHost(topology, port); outputText.text = "opened socket: " + socketID; Debug.Log(outputText.text); }
void Start() { NetworkTransport.Init(); ConnectionConfig config = new ConnectionConfig(); reliableChannelId = config.AddChannel(QosType.Reliable); HostTopology topology = new HostTopology(config, maxConnections); socketId = NetworkTransport.AddHost(topology, socketPort); Debug.Log("Socket Open. SocketId is: " + socketId + " ChannelID is: " + reliableChannelId); }
// Use this for initialization void Start() { UnityEngine.Networking.NetworkTransport.Init (); ConnectionConfig connConf = new ConnectionConfig (); HostTopology hostTopology = new HostTopology (connConf, 1024); int hostId = NetworkTransport.AddHost (hostTopology, Port, Interface); print ("Now listening on " + Interface + ":" + Port); }
public LLApiServer(GameServer gameServer, int port, ushort maxConnections, ushort maxMessages) { GameServer = gameServer; Port = port; MaxConnections = maxConnections; MaxMessages = maxMessages; isConnected = false; Config = new ConnectionConfig(); int ReliableChannelId = Config.AddChannel(QosType.Reliable); int NonReliableChannelId = Config.AddChannel(QosType.Unreliable); Topology = new HostTopology(Config, MaxConnections); }
static void ExecCreateConnectConfig() { ConnectionConfig config=new ConnectionConfig(); System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(ConnectionConfig)); System.IO.StreamWriter file = new System.IO.StreamWriter( @"C:\_AssetBundles\config.xml"); writer.Serialize(file, config); file.Close(); }
public MutliplayerManager() { // Packet config GlobalConfig gConfig = new GlobalConfig(); gConfig.MaxPacketSize = 500; NetworkTransport.Init( gConfig ); // Connection config ConnectionConfig config = new ConnectionConfig(); int mainChannel = config.AddChannel(QosType.Unreliable); topology = new HostTopology( config, 10 ); }
void Start () { NetworkTransport.Init(); ConnectionConfig config = new ConnectionConfig(); int myReiliableChannelId = config.AddChannel(QosType.Reliable); int myUnreliableChannelId = config.AddChannel(QosType.Unreliable); HostTopology topology = new HostTopology(config, 10); int hostId = NetworkTransport.AddHost(topology, 8888); int bufferLength = buffer.Length; int connectionId = NetworkTransport.Connect(hostId, "192.16.7.21", 8888, 0, out error); NetworkTransport.Disconnect(hostId, connectionId, out error); NetworkTransport.Send(hostId, connectionId, myReiliableChannelId, buffer, bufferLength, out error); }
void Start() { DontDestroyOnLoad(this); //Build the global config GlobalConfig globalConfig = new GlobalConfig (); globalConfig.ReactorModel = ReactorModel.FixRateReactor; globalConfig.ThreadAwakeTimeout = 10; //Build the channel config ConnectionConfig connectionConfig = new ConnectionConfig (); reliableChannelID = connectionConfig.AddChannel (QosType.ReliableSequenced); unreliableChannelID = connectionConfig.AddChannel (QosType.UnreliableSequenced); //Create the host topology HostTopology hostTopology = new HostTopology (connectionConfig, maxConnections); //Initialize the network transport NetworkTransport.Init (globalConfig); //Open a socket for the client clientSocketID = NetworkTransport.AddHost (hostTopology, 7777); //Make sure the client created the socket successfully if (clientSocketID < 0) { Debug.Log ("Client socket creation failed!"); } else { Debug.Log ("Client socket creation success"); } //Create a byte to store a possible error byte error; //Connect to the server using //int NetworkTransport.Connect(int socketConnectingFrom, string ipAddress, int port, 0, out byte possibleError) //Store the ID of the connection in clientServerConnectionID clientServerConnectionID = NetworkTransport.Connect(clientSocketID, Network.player.ipAddress.ToString(), 7777, 0, out error); //Display the error (if it did error out) if(error != (byte)NetworkError.Ok) { NetworkError networkError = (NetworkError)error; Debug.Log ("Error: " + networkError.ToString()); } }
protected override void ConfigureHosts(ConnectionConfig config) { HostTopology topology = new HostTopology(config, 5); if (hostID != -1) return; #if UNITY_EDITOR // Listen on port 25000 if(simulatedNetworking) hostID = NetworkTransport.AddHost(topology, 25000); else hostID = NetworkTransport.AddHostWithSimulator(topology, 200, 400, 25000); #else hostID = NetworkTransport.AddHost(topology, 25000); #endif Debug.Log(Format.localIPAddress()); }
protected override void ConfigureHosts(ConnectionConfig config) { HostTopology topology = new HostTopology(config, 1); if (hostID != -1) return; #if UNITY_EDITOR if(simulatedNetworking) hostID = NetworkTransport.AddHostWithSimulator(topology, 200, 400); else hostID = NetworkTransport.AddHost(topology); #else hostID = NetworkTransport.AddHost(topology); #endif byte error; // Cannot tell we're connected until we receive the event at later time NetworkTransport.Connect(hostID, serverIP, 25000, 0, out error); }
// Update is called once per frame void ConnectClient () { byte error; NetworkTransport.Init(); ConnectionConfig config = new ConnectionConfig(); myReliableChannelId = config.AddChannel(QosType.Reliable); HostTopology topology = new HostTopology(config, 1); hostId = NetworkTransport.AddHost(topology, Port); connectionId = NetworkTransport.Connect(hostId, ServerIP, Server.Port, 0, out error); if (error != (byte)NetworkError.Ok) { Debug.LogError("Client: error: " + (NetworkError)error); //not good return; } Debug.Log ("Client: connection succed"); SendSocketMessage (); }
// Use this for initialization void Start() { GlobalConfig globalConfig = new GlobalConfig(); //Stores information such as packet sizes globalConfig.ReactorModel = ReactorModel.FixRateReactor; //Determines how the network reacts to incoming packets globalConfig.ThreadAwakeTimeout = 10; //Amount of time in milliseconds between updateing packets ConnectionConfig connectionConfig = new ConnectionConfig(); //Stores all channels reliableChannelID = connectionConfig.AddChannel(QosType.ReliableSequenced); //TCP Channel unreliableChannelID = connectionConfig.AddChannel(QosType.UnreliableSequenced); //UDP Channel HostTopology hostTopology = new HostTopology(connectionConfig, maxConnections); NetworkTransport.Init(globalConfig); serverSocketID = NetworkTransport.AddHost(hostTopology, 7777); Debug.Log(serverSocketID); serverInitialized = true; }
// Use this for initialization void Start() { // Don't destroy the scene DontDestroyOnLoad(this); // Creates a new GlobalConfig that determines how it will react when receiving packets GlobalConfig globalConfig = new GlobalConfig(); // Fixed rate makes it so it handles packets periodically (ie every 100 ms) globalConfig.ReactorModel = ReactorModel.FixRateReactor; // Sets so it deals with packets every 10 ms globalConfig.ThreadAwakeTimeout = 10; // Create a channel for packets to be sent across ConnectionConfig connectionConfig = new ConnectionConfig(); // Create and set the reliable and unreliable channels reliableChannelID = connectionConfig.AddChannel(QosType.ReliableSequenced); unreliableChannelID = connectionConfig.AddChannel(QosType.UnreliableSequenced); // Create a host topology that determines the maximum number of clients the server can have HostTopology hostTopology = new HostTopology(connectionConfig, maxConnections); // Initialize the server NetworkTransport.Init(globalConfig); // Open the socket on your network serverSocketID = NetworkTransport.AddHost(hostTopology, 7777); // Check to see that the socket (and server) was successfully initialized if (serverSocketID < 0) { Debug.Log("Server socket creation failed!"); } else { Debug.Log("Server socket creation success"); } // Set server initialized to true serverInitialized = true; }
void Awake() { ConnectionConfig config = new ConnectionConfig (); config.AddChannel (QosType.ReliableFragmented); NetworkServer.Configure (config, 65534); NetworkServer.Listen (7777); Debug.Log (NetworkServer.active.ToString ()); try { // setup the connection element con = new MySqlConnection(constr); // lets see if we can open the connection con.Open(); Debug.Log("Connection State: " + con.State); } catch (Exception ex) { Debug.Log(ex.ToString()); } NetworkServer.RegisterHandler (MsgType.Connect, OnConnected); NetworkServer.RegisterHandler (MyMsgType.Info, OnInfo); NetworkServer.RegisterHandler (MsgType.Disconnect, OnDisconnected); }
/// <summary> /// Creates and SDK connection using the specified connection configuration /// </summary> /// <param name="config">The connection configuration to use</param> /// <returns>a usable connection or null if an error occurred</returns> public static SDKConnection GetConnection(ConnectionConfig config) { if (_thisApplication == null) { throw new Exception("Application ID is not set"); } try { var cn = new SDKConnection(_thisApplication, config); if (config.ConnectionType != FCConnectionType.Online) { cn.QueryDesktopVersion(); } lock (_connections) { _connections.Add(cn); } return cn; } catch (SDKException sdkex) { var entry = new StatusEntry() { TypeOfEntry = StatusEntry.EntryType.Error, Summary = sdkex.Message, Details = sdkex.ProblemDetail }; StatusMgr.LogEntry(entry); return null; } }
public MySqlSugarClient(ConnectionConfig config) : base(config) { }
public override NetworkClient StartHost(ConnectionConfig config, int maxConnections) { LogEntry(); return(base.StartHost(config, maxConnections)); }
public void SetConnectionConfig(ConnectionConfig config) { this.config = (WebSocketConnectionConfig)config; }
/// <summary> /// Adds an instance of Azure Blob storage as a singleton, using connection string config to setup. /// </summary> /// <param name="services">The services to extend.</param> /// <param name="config">The configuration to initialise with.</param> /// <returns>IServiceCollection.</returns> public static IServiceCollection AddBlobStorageSingleton(this IServiceCollection services, ConnectionConfig config) { services.AddSingleton <IBlobStorage>(new BlobStorage(config)); services.AddFactoryIfNotAdded <IBlobStorage>(); return(services); }
/// <summary> /// 功能描述:获取一个自定义的DB /// 作 者:Blog.Core /// </summary> /// <param name="config">config</param> /// <returns>返回值</returns> public static SqlSugarScope GetCustomDB(ConnectionConfig config) { return(new SqlSugarScope(config)); }
public static ConnectionConfig with_hasher(this ConnectionConfig config, IHasher hasher) { config.Hasher = hasher; return(config); }
/// <summary> /// 功能描述:获取一个自定义的DB /// 作 者:Blog.Core /// </summary> /// <param name="config">config</param> /// <returns>返回值</returns> public static SqlSugarClient GetCustomDB(ConnectionConfig config) { return(new SqlSugarClient(config)); }
/// <summary> /// Adds the service bus singleton instance and NamedInstanceFactory{ServiceBusInstance} configured. /// Uses ConnectionConfig to setup configuration. /// </summary> /// <param name="services">Service collection to extend.</param> /// <param name="config">The configuration.</param> /// <returns>Modified service collection with the ServiceBusMessenger and NamedInstanceFactory{ServiceBusMessenger} configured.</returns> public static IServiceCollection AddServiceBusSingleton(this IServiceCollection services, ConnectionConfig config) { return(AddNamedInstance <ServiceBusMessenger>(services, null, new ServiceBusMessenger(config))); }
private void Awake() { //setup: broadcastPort = broadcastingPort; broadcastData = ServerPort.ToString(); //set device id: if (string.IsNullOrEmpty(customDeviceId)) { GenerateID(); DeviceId = PlayerPrefs.GetString(_randomIdKey); broadcastData += "_" + DeviceId; } else { broadcastData += "_" + customDeviceId; } //HACK: this is a fix for the broadcastData bug where Unity will combine different //data if the length is different because they internally reuse this object broadcastData += "~!~"; Init(); //configurations: ConnectionConfig config = new ConnectionConfig(); PrimaryChannel = config.AddChannel(primaryQualityOfService); SecondaryChannel = config.AddChannel(secondaryQualityOfService); config.InitialBandwidth = initialBandwidth; HostTopology topology = new HostTopology(config, maxConnections); _server.Listen(ServerPort, topology); //event hooks: _server.RegisterHandler(MsgType.Connect, HandleConnect); _server.RegisterHandler(MsgType.Disconnect, HandleDisconnect); _server.RegisterHandler((short)NetworkMsg.FloatMsg, HandleFloat); _server.RegisterHandler((short)NetworkMsg.FloatArrayMsg, HandleFloatArray); _server.RegisterHandler((short)NetworkMsg.IntMsg, HandleInt); _server.RegisterHandler((short)NetworkMsg.IntArrayMsg, HandleIntArray); _server.RegisterHandler((short)NetworkMsg.Vector2Msg, HandleVector2); _server.RegisterHandler((short)NetworkMsg.Vector2ArrayMsg, HandleVector2Array); _server.RegisterHandler((short)NetworkMsg.Vector3Msg, HandleVector3); _server.RegisterHandler((short)NetworkMsg.Vector3ArrayMsg, HandleVector3Array); _server.RegisterHandler((short)NetworkMsg.Vector4Msg, HandleVector4); _server.RegisterHandler((short)NetworkMsg.Vector4ArrayMsg, HandleVector4Array); _server.RegisterHandler((short)NetworkMsg.RectMsg, HandleRect); _server.RegisterHandler((short)NetworkMsg.RectArrayMsg, HandleRectArray); _server.RegisterHandler((short)NetworkMsg.StringMsg, HandleString); _server.RegisterHandler((short)NetworkMsg.StringArrayMsg, HandleStringArray); _server.RegisterHandler((short)NetworkMsg.ByteMsg, HandleByte); _server.RegisterHandler((short)NetworkMsg.ByteArrayMsg, HandleByteArray); _server.RegisterHandler((short)NetworkMsg.ColorMsg, HandleColor); _server.RegisterHandler((short)NetworkMsg.ColorArrayMsg, HandleColorArray); _server.RegisterHandler((short)NetworkMsg.Color32Msg, HandleColor32); _server.RegisterHandler((short)NetworkMsg.Color32ArrayMsg, HandleColor32Array); _server.RegisterHandler((short)NetworkMsg.RectByteArrayMsg, HandleRectByteArray); _server.RegisterHandler((short)NetworkMsg.BoolMsg, HandleBool); _server.RegisterHandler((short)NetworkMsg.BoolArrayMsg, HandleBoolArray); //dont destroy: transform.parent = null; DontDestroyOnLoad(gameObject); }
public QrfSqlSugarClient(ConnectionConfig config) : base(config) { DbName = string.Empty; Default = true; }
public QrfSqlSugarClient(ConnectionConfig config, string dbName) : base(config) { DbName = dbName; Default = true; }
/// <summary> /// Add service bus singleton of type T, using connection string configuration. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="services">Service collection to extend</param> /// <param name="key">Key to identify the named instance of the service bus singleton.</param> /// <param name="config">The connection string configuration</param> /// <returns>Modified service collection with the IReactiveMessenger or IMessenger instance and NamedInstanceFactory{T} configured.</returns> public static IServiceCollection AddServiceBusSingletonNamed <T>(this IServiceCollection services, string key, ConnectionConfig config) where T : IMessageOperations { return(AddNamedInstance <T>(services, key, new ServiceBusMessenger(config))); }
/// <summary> /// Initializes a new instance of the <see cref="CosmosStorage" /> class with a Connection String. /// </summary> /// <param name="config">The Connection String information for connecting to Storage.</param> /// <param name="logger">The Logger?.</param> public CosmosStorage([NotNull] ConnectionConfig config, [MaybeNull] ILogger logger = null) : base(config, logger) { }
/// <summary> /// 初始化 /// </summary> /// <param name="config"></param> /// <returns></returns> public static SqlSugarClient ConfigInit(ConnectionConfig config) { return(new SqlSugarClient(config)); }
/* * // get and set the printdriver * public DeviceDriver[] DriverProjector * { * get { return m_lstprojectors[]; } * set * { * if (m_lstprojectors != null) * { * DeviceDriver olddriver = m_lstprojectors; * if(olddriver.Connected == true) * olddriver.Disconnect(); // disconnect the old driver * //remove the old device driver delegates * olddriver.DataReceived -= new DeviceDriver.DataReceivedEvent(DriverDataReceivedEvent); * olddriver.DeviceStatus -= new DeviceDriver.DeviceStatusEvent(DriverDeviceStatusEvent); * } * //set the new driver * m_lstprojectors = value; * //and bind the delegates to listen to events * m_lstprojectors.DataReceived += new DeviceDriver.DataReceivedEvent(DriverDataReceivedEvent); * m_lstprojectors.DeviceStatus += new DeviceDriver.DeviceStatusEvent(DriverDeviceStatusEvent); * } * } */ public void Configure(ConnectionConfig cc) { Driver.Configure(cc); }
public AllenBradleyControl() { InitializeComponent(); Size = new Size(880, 450); groupBox2.Location = new Point(13, 5); groupBox2.Size = new Size(855, 50); groupBox1.Location = new Point(13, 55); groupBox1.Size = new Size(855, 50); groupBox3.Location = new Point(13, 105); groupBox3.Size = new Size(855, 50); txt_content.Location = new Point(13, 160); lab_address.Location = new Point(9, 22); txt_address.Location = new Point(39, 18); txt_address.Size = new Size(88, 21); but_read.Location = new Point(132, 17); lab_value.Location = new Point(227, 22); txt_value.Location = new Point(249, 18); txt_value.Size = new Size(74, 21); but_write.Location = new Point(328, 17); txt_dataPackage.Location = new Point(430, 18); txt_dataPackage.Size = new Size(186, 21); but_sendData.Location = new Point(620, 17); chb_show_package.Location = new Point(776, 19); but_read.Enabled = false; but_write.Enabled = false; but_close_server.Enabled = false; but_close.Enabled = false; but_sendData.Enabled = false; //this.version = version; var config = ConnectionConfig.GetConfig(); if (!string.IsNullOrWhiteSpace(config.AllenBradley_IP)) { txt_ip.Text = config.AllenBradley_IP; } if (!string.IsNullOrWhiteSpace(config.AllenBradley_Port)) { txt_port.Text = config.AllenBradley_Port; } if (!string.IsNullOrWhiteSpace(config.AllenBradley_Address)) { txt_address.Text = config.AllenBradley_Address; } if (!string.IsNullOrWhiteSpace(config.AllenBradley_Value)) { txt_value.Text = config.AllenBradley_Value; } if (!string.IsNullOrWhiteSpace(config.AllenBradley_Slot)) { txt_slot.Text = config.AllenBradley_Slot; } chb_show_package.Checked = config.AllenBradley_ShowPackage; switch (config.AllenBradley_Datatype) { case "rd_bit": rd_bit.Checked = true; break; case "rd_short": rd_short.Checked = true; break; case "rd_ushort": rd_ushort.Checked = true; break; case "rd_int": rd_int.Checked = true; break; case "rd_uint": rd_uint.Checked = true; break; case "rd_long": rd_long.Checked = true; break; case "rd_ulong": rd_ulong.Checked = true; break; case "rd_float": rd_float.Checked = true; break; case "rd_double": rd_double.Checked = true; break; } ; }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllersWithViews(); services.AddAuthentication("CookieAuthentication").AddCookie("CookieAuthentication", c => { c.Cookie.Name = "ShuAdminCookie"; c.LoginPath = "/Home/Logindata"; }); services.AddSession(options => { var sessionTimeout = Convert.ToInt32(Configuration.GetSection("SessionTimeout")?.Value ?? "30"); // 设置 Session 过期时间15分钟 options.IdleTimeout = TimeSpan.FromMinutes(sessionTimeout); }); var config = new ConnectionConfig { ConnectionString = Configuration.GetSection("ConnectionString").Value, DbType = (DbType)Enum.Parse(typeof(DbType), Configuration.GetSection("DbType").Value), IsAutoCloseConnection = true }; services.AddTransient <IHospitalReportDbContext>(s => new HospitalReportDbContext(config)); services.AddTransient(typeof(IRepository <,>), typeof(Repository <,>)); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); var assemblys = Assembly.Load("HospitalReport.Service").GetTypes(); var interfaceAssemblys = assemblys.Where(t => t.FullName.StartsWith("HospitalReport.Service.Interface")).ToList(); var implementAssemblys = assemblys.Where(t => t.FullName.StartsWith("HospitalReport.Service.Implement")).ToList(); foreach (var item in implementAssemblys) { var interfaceType = interfaceAssemblys.FirstOrDefault(t => t.FullName.EndsWith($"I{item.Name}")); if (interfaceType != null) { services.AddTransient(interfaceType, item); } } services.AddMvc().AddJsonOptions(json => { json.JsonSerializerOptions.Converters.Add(new DateTimeConverter()); json.JsonSerializerOptions.Converters.Add(new IntToStringConverter()); json.JsonSerializerOptions.Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping; json.JsonSerializerOptions.IgnoreNullValues = true; json.JsonSerializerOptions.PropertyNamingPolicy = null; //允许额外符号 json.JsonSerializerOptions.AllowTrailingCommas = true; //反序列化过程中属性名称是否使用不区分大小写的比较 json.JsonSerializerOptions.PropertyNameCaseInsensitive = false; }); //根据属性注入来配置全局拦截器 services.ConfigureDynamicProxy(config1 => { config1.Interceptors.AddTyped <ErrorTryCatchAttribute>();//Attribute.ErrorTryCatchAttribute这个是需要全局拦截的拦截器 }); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0).AddControllersAsServices(); //Scoped 1 //指定将为每个作用域创建服务的新实例。 //Singleton 0 //指定将创建该服务的单个实例。 //Transient 2 //指定每次请求服务时,将创建该服务的新实例。 }
private void but_read_Click(object sender, EventArgs e) { try { if (string.IsNullOrWhiteSpace(txt_address.Text)) { MessageBox.Show("请输入地址"); return; } dynamic result = null; if (rd_bit.Checked) { result = client.ReadBoolean(txt_address.Text); } else if (rd_short.Checked) { result = client.ReadInt16(txt_address.Text); } else if (rd_ushort.Checked) { result = client.ReadUInt16(txt_address.Text); } else if (rd_int.Checked) { result = client.ReadInt32(txt_address.Text); } else if (rd_uint.Checked) { result = client.ReadUInt32(txt_address.Text); } else if (rd_long.Checked) { result = client.ReadInt64(txt_address.Text); } else if (rd_ulong.Checked) { result = client.ReadUInt64(txt_address.Text); } else if (rd_float.Checked) { result = client.ReadFloat(txt_address.Text); } else if (rd_double.Checked) { result = client.ReadDouble(txt_address.Text); } if (result.IsSucceed) { AppendText($"[读取 {txt_address.Text?.Trim()} 成功]:{result.Value}\t\t耗时:{result.TimeConsuming}ms"); } else { AppendText($"[读取 {txt_address.Text?.Trim()} 失败]:{result.Err}\t\t耗时:{result.TimeConsuming}ms"); } if (chb_show_package.Checked || (ModifierKeys & Keys.Control) == Keys.Control) { AppendText($"[请求报文]{result.Requst}"); AppendText($"[响应报文]{result.Response}\r\n"); } var config = ConnectionConfig.GetConfig(); config.AllenBradley_IP = txt_ip.Text; config.AllenBradley_Port = txt_port.Text; config.AllenBradley_Address = txt_address.Text; config.AllenBradley_Value = txt_value.Text; config.AllenBradley_Slot = txt_slot.Text; config.AllenBradley_ShowPackage = chb_show_package.Checked; config.AllenBradley_Datatype = string.Empty; if (rd_bit.Checked) { config.AllenBradley_Datatype = "rd_bit"; } else if (rd_short.Checked) { config.AllenBradley_Datatype = "rd_short"; } else if (rd_ushort.Checked) { config.AllenBradley_Datatype = "rd_ushort"; } else if (rd_int.Checked) { config.AllenBradley_Datatype = "rd_int"; } else if (rd_uint.Checked) { config.AllenBradley_Datatype = "rd_uint"; } else if (rd_long.Checked) { config.AllenBradley_Datatype = "rd_long"; } else if (rd_ulong.Checked) { config.AllenBradley_Datatype = "rd_ulong"; } else if (rd_float.Checked) { config.AllenBradley_Datatype = "rd_float"; } else if (rd_double.Checked) { config.AllenBradley_Datatype = "rd_double"; } config.SaveConfig(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public static ConnectionConfig easy_money_domain_api_() { var config = new ConnectionConfig(); return(config); }
async void Start() { bool argsExist = false; string address = "127.0.0.1"; int listeningPort = 7777; string roomKey = "MultiplayerRoom"; string[] args = System.Environment.GetCommandLineArgs(); for (int i = 0; i < args.Length; i++) { if (args[i] == "--address") { address = args[i + 1]; argsExist = true; } if (args[i] == "--port") { listeningPort = int.Parse(args[i + 1]); argsExist = true; } } #if !UNITY_EDITOR if (!argsExist) { Debug.LogError($"Usage: UnityApp.exe --address <IP Address> --port <Port Number>"); await UniTask.Delay(TimeSpan.FromSeconds(5)); Application.Quit(); return; } #endif _networkClient = _networkClientObject.GetComponent <NetworkClient>(); _networkClient.Initialize(); ConnectionConfig connectionConfig = ConnectionConfig.GetDefault(); connectionConfig.Address = address; connectionConfig.Port = listeningPort; connectionConfig.Key = roomKey; Observable.Timer(TimeSpan.FromSeconds(_ConnectionDueTime), TimeSpan.FromSeconds(_ConnectionInterval)) .Where(_ => !_IsConnected) .Subscribe(_ => UniTask.Void(async() => { Debug.Log($"Connecting to server."); _IsConnected = await _networkClient.Connect(connectionConfig); Debug.Log($"IsConnected: " + _IsConnected); })) .AddTo(this); _networkClient.OnClientConnectedAsObservable() .Subscribe(_ => { Debug.Log($"Connected to server."); }) .AddTo(this); _networkClient.OnClientDisconnectedAsObservable() .Subscribe(_ => { _IsConnected = false; Debug.Log("Disconnected from server."); }) .AddTo(this); }
public static ConnectionConfig with_unit_of_work(this ConnectionConfig config, IForumUnitOfWork unitOfWork) { config.UnitOfWork = unitOfWork; return(config); }
private async Task CreateAcceptPdf(int id, string notes) { ConnectionConfig connection = new ConnectionConfig(); FirestoreDb db = connection.GetFirestoreDb(); QuerySnapshot snapshot = await db .Collection("service-repairs") .WhereEqualTo("RepairId", id) .GetSnapshotAsync(); Repair repair = snapshot .FirstOrDefault() .ConvertTo <Repair>(); PdfDocument document = new PdfDocument(); document.Info.Title = "Created with PdfSharp"; PdfPage page = document.AddPage(); page.Size = PageSize.A4; XGraphics gfx = XGraphics.FromPdfPage(page); XFont font = new XFont("Times New Roman", 36, XFontStyle.Bold); gfx.DrawString("Сервизна карта", font, XBrushes.Black, new XRect(0, 94, page.Width, page.Height), XStringFormats.TopCenter); string reclaim = "A"; for (int i = 0; i < 8 - repair.RepairId.ToString().Length; i++) { reclaim += "0"; } reclaim += repair.RepairId.ToString(); gfx.DrawString($"{reclaim} / {repair.CreatedAt.ToString("dd.MM.yyyy")}", new XFont("Times New Roman", 20, XFontStyle.Bold), XBrushes.Black, new XRect(0, 140, page.Width, page.Height), XStringFormats.TopCenter); gfx.DrawString("Издадена от: сервиз Бай Пешо", new XFont("Times New Roman", 14, XFontStyle.Bold), XBrushes.Black, new XRect(0, 170, page.Width, page.Height), XStringFormats.TopCenter); gfx.DrawString("Клиент:", new XFont("Times New Roman", 14, XFontStyle.Bold), XBrushes.Black, new XRect(96, -190, page.Width, page.Height), XStringFormats.CenterLeft); gfx.DrawString(repair.CustomerName, new XFont("Times New Roman", 14, XFontStyle.Regular), XBrushes.Black, new XRect(96, -170, page.Width, page.Height), XStringFormats.CenterLeft); gfx.DrawString("Марка:", new XFont("Times New Roman", 14, XFontStyle.Bold), XBrushes.Black, new XRect(347.5, -190, page.Width, page.Height), XStringFormats.CenterLeft); gfx.DrawString(repair.ApplianceBrand, new XFont("Times New Roman", 14, XFontStyle.Regular), XBrushes.Black, new XRect(347.5, -170, page.Width, page.Height), XStringFormats.CenterLeft); gfx.DrawString("Адрес:", new XFont("Times New Roman", 14, XFontStyle.Bold), XBrushes.Black, new XRect(96, -150, page.Width, page.Height), XStringFormats.CenterLeft); gfx.DrawString(repair.CustomerAddress, new XFont("Times New Roman", 14, XFontStyle.Regular), XBrushes.Black, new XRect(96, -130, page.Width, page.Height), XStringFormats.CenterLeft); gfx.DrawString("Модел:", new XFont("Times New Roman", 14, XFontStyle.Bold), XBrushes.Black, new XRect(347.5, -150, page.Width, page.Height), XStringFormats.CenterLeft); gfx.DrawString(repair.ApplianceModel, new XFont("Times New Roman", 14, XFontStyle.Regular), XBrushes.Black, new XRect(347.5, -130, page.Width, page.Height), XStringFormats.CenterLeft); gfx.DrawString("Телефон:", new XFont("Times New Roman", 14, XFontStyle.Bold), XBrushes.Black, new XRect(96, -110, page.Width, page.Height), XStringFormats.CenterLeft); gfx.DrawString(repair.CustomerPhoneNumber, new XFont("Times New Roman", 14, XFontStyle.Regular), XBrushes.Black, new XRect(96, -90, page.Width, page.Height), XStringFormats.CenterLeft); gfx.DrawString("Сериен номер:", new XFont("Times New Roman", 14, XFontStyle.Bold), XBrushes.Black, new XRect(347.5, -110, page.Width, page.Height), XStringFormats.CenterLeft); gfx.DrawString(repair.ApplianceSerialNumber, new XFont("Times New Roman", 14, XFontStyle.Regular), XBrushes.Black, new XRect(347.5, -90, page.Width, page.Height), XStringFormats.CenterLeft); gfx.DrawString("Дефект според клиента:", new XFont("Times New Roman", 14, XFontStyle.Bold), XBrushes.Black, new XRect(96, -70, page.Width, page.Height), XStringFormats.CenterLeft); gfx.DrawString(repair.DefectByCustomer, new XFont("Times New Roman", 14, XFontStyle.Regular), XBrushes.Black, new XRect(96, -50, page.Width, page.Height), XStringFormats.CenterLeft); gfx.DrawString("IMEI:", new XFont("Times New Roman", 14, XFontStyle.Bold), XBrushes.Black, new XRect(347.5, -70, page.Width, page.Height), XStringFormats.CenterLeft); gfx.DrawString(repair.ApplianceProductCodeOrImei, new XFont("Times New Roman", 14, XFontStyle.Regular), XBrushes.Black, new XRect(347.5, -50, page.Width, page.Height), XStringFormats.CenterLeft); gfx.DrawString("Комплектация:", new XFont("Times New Roman", 14, XFontStyle.Bold), XBrushes.Black, new XRect(96, -30, page.Width, page.Height), XStringFormats.CenterLeft); gfx.DrawString(repair.ApplianceEquipment, new XFont("Times New Roman", 14, XFontStyle.Regular), XBrushes.Black, new XRect(96, -10, page.Width, page.Height), XStringFormats.CenterLeft); gfx.DrawString("Дата на покупка:", new XFont("Times New Roman", 14, XFontStyle.Bold), XBrushes.Black, new XRect(347.5, -30, page.Width, page.Height), XStringFormats.CenterLeft); gfx.DrawString($"{repair.BoughtAt.ToString("dd.MM.yyyy hh:MM:ss")}", new XFont("Times New Roman", 14, XFontStyle.Regular), XBrushes.Black, new XRect(347.5, -10, page.Width, page.Height), XStringFormats.CenterLeft); gfx.DrawString("Доп. информация:", new XFont("Times New Roman", 14, XFontStyle.Bold), XBrushes.Black, new XRect(96, 10, page.Width, page.Height), XStringFormats.CenterLeft); gfx.DrawString(repair.AdditionalInformation, new XFont("Times New Roman", 14, XFontStyle.Regular), XBrushes.Black, new XRect(96, 30, page.Width, page.Height), XStringFormats.CenterLeft); gfx.DrawString("Гаранционен период/месеци/:", new XFont("Times New Roman", 14, XFontStyle.Bold), XBrushes.Black, new XRect(347.5, 10, page.Width, page.Height), XStringFormats.CenterLeft); gfx.DrawString(repair.WarrantyPeriod.ToString(), new XFont("Times New Roman", 14, XFontStyle.Regular), XBrushes.Black, new XRect(347.5, 30, page.Width, page.Height), XStringFormats.CenterLeft); gfx.DrawString("Забележки външен вид:", new XFont("Times New Roman", 14, XFontStyle.Bold), XBrushes.Black, new XRect(96, 50, page.Width, page.Height), XStringFormats.CenterLeft); gfx.DrawString(notes, new XFont("Times New Roman", 14, XFontStyle.Regular), XBrushes.Black, new XRect(96, 70, page.Width, page.Height), XStringFormats.CenterLeft); gfx.DrawString("Покупка от:", new XFont("Times New Roman", 14, XFontStyle.Bold), XBrushes.Black, new XRect(347.5, 50, page.Width, page.Height), XStringFormats.CenterLeft); gfx.DrawString(repair.BoughtFrom, new XFont("Times New Roman", 14, XFontStyle.Regular), XBrushes.Black, new XRect(347.5, 70, page.Width, page.Height), XStringFormats.CenterLeft); gfx.DrawString("Приел в сервиза: ……………", new XFont("Times New Roman", 14, XFontStyle.Bold), XBrushes.Black, new XRect(0, 170, page.Width - 94, page.Height), XStringFormats.CenterRight); gfx.DrawString("/ Бай Пешо /", new XFont("Times New Roman", 14, XFontStyle.Bold), XBrushes.Black, new XRect(0, 190, page.Width - 94, page.Height), XStringFormats.CenterRight); gfx.DrawString("Предал: ………………………", new XFont("Times New Roman", 14, XFontStyle.Bold), XBrushes.Black, new XRect(0, 210, page.Width - 94, page.Height), XStringFormats.CenterRight); gfx.DrawString($"/ {repair.CustomerName} /", new XFont("Times New Roman", 14, XFontStyle.Bold), XBrushes.Black, new XRect(0, 230, page.Width - 94, page.Height), XStringFormats.CenterRight); string path = @$ "C:\Users\aleks\Desktop\Приемане-{repair.RepairId}.pdf";
/// <summary> /// 功能描述:获取一个自定义的数据库处理对象 /// 作 者:Blog.Core /// </summary> /// <param name="config">config</param> /// <returns>返回值</returns> public static SimpleClient <T> GetCustomEntityDB <T>(ConnectionConfig config) where T : class, new() { SqlSugarScope sugarClient = GetCustomDB(config); return(GetCustomEntityDB <T>(sugarClient)); }
public NetworkClient StartClient(ConnectionConfig config, int hostPort) { LogFilter.currentLogLevel = 0; // InitializeSingleton(); // // matchInfo = info; // if (m_RunInBackground) Application.runInBackground = true; isNetworkActive = true; // if (m_GlobalConfig != null) // { // NetworkTransport.Init(m_GlobalConfig); // } client = new MyNetClient(); client.hostPort = hostPort; // config = new ConnectionConfig(); // byte clientChannelId = config.AddChannel(QosType.StateUpdate); // QosType.UnreliableFragmented // // // add client host // HostTopology topology = new HostTopology(config, 1); // client.Configure(topology); // if (config != null) // { // if ((config.UsePlatformSpecificProtocols) && (UnityEngine.Application.platform != RuntimePlatform.PS4) && (UnityEngine.Application.platform != RuntimePlatform.PSP2)) // throw new System.ArgumentOutOfRangeException("Platform specific protocols are not supported on this platform"); // // client.Configure(config, 1); // } // else // { // if (m_CustomConfig && m_ConnectionConfig != null) // { // m_ConnectionConfig.Channels.Clear(); // for (int i = 0; i < m_Channels.Count; i++) // { // m_ConnectionConfig.AddChannel(m_Channels[i]); // } // if ((m_ConnectionConfig.UsePlatformSpecificProtocols) && (UnityEngine.Application.platform != RuntimePlatform.PS4) && (UnityEngine.Application.platform != RuntimePlatform.PSP2)) // throw new ArgumentOutOfRangeException("Platform specific protocols are not supported on this platform"); // client.Configure(m_ConnectionConfig, m_MaxConnections); // } // } RegisterClientMessages(client); // if (matchInfo != null) // { // if (LogFilter.logDebug) { Debug.Log("NetworkManager StartClient match: " + matchInfo); } // client.Connect(matchInfo); // } // else if (m_EndPoint != null) // { // if (LogFilter.logDebug) { Debug.Log("NetworkManager StartClient using provided SecureTunnel"); } // client.Connect(m_EndPoint); // } // else { if (string.IsNullOrEmpty(m_NetworkAddress)) { if (LogFilter.logError) { Debug.LogError("Must set the Network Address field in the manager"); } return(null); } if (LogFilter.logDebug) { Debug.Log("NetworkManager StartClient address:" + m_NetworkAddress + " port:" + m_NetworkPort); } // if (m_UseSimulator) // { // client.ConnectWithSimulator(m_NetworkAddress, m_NetworkPort, m_SimulatedLatency, m_PacketLossPercentage); // } // else { client.Connect(m_NetworkAddress, m_NetworkPort); client.PrepareNetClient(); } } // OnStartClient(client); // s_Address = m_NetworkAddress; return(client); }
/// <summary> /// GetInstallConfig - Returns configuration stored in DotNetNuke.Install.Config. /// </summary> /// <returns>ConnectionConfig object. Null if information is not present in the config file.</returns> public InstallConfig GetInstallConfig() { var installConfig = new InstallConfig(); // Load Template var installTemplate = new XmlDocument { XmlResolver = null }; Upgrade.GetInstallTemplate(installTemplate); // Parse the root node XmlNode rootNode = installTemplate.SelectSingleNode("//dotnetnuke"); if (rootNode != null) { installConfig.Version = XmlUtils.GetNodeValue(rootNode.CreateNavigator(), "version"); installConfig.SupportLocalization = XmlUtils.GetNodeValueBoolean(rootNode.CreateNavigator(), "supportLocalization"); installConfig.InstallCulture = XmlUtils.GetNodeValue(rootNode.CreateNavigator(), "installCulture") ?? Localization.SystemLocale; } // Parse the scripts node XmlNode scriptsNode = installTemplate.SelectSingleNode("//dotnetnuke/scripts"); if (scriptsNode != null) { foreach (XmlNode scriptNode in scriptsNode) { if (scriptNode != null) { installConfig.Scripts.Add(scriptNode.InnerText); } } } // Parse the connection node XmlNode connectionNode = installTemplate.SelectSingleNode("//dotnetnuke/connection"); if (connectionNode != null) { var connectionConfig = new ConnectionConfig(); // Build connection string from the file connectionConfig.Server = XmlUtils.GetNodeValue(connectionNode.CreateNavigator(), "server"); connectionConfig.Database = XmlUtils.GetNodeValue(connectionNode.CreateNavigator(), "database"); connectionConfig.File = XmlUtils.GetNodeValue(connectionNode.CreateNavigator(), "file"); connectionConfig.Integrated = XmlUtils.GetNodeValue(connectionNode.CreateNavigator(), "integrated").ToLowerInvariant() == "true"; connectionConfig.User = XmlUtils.GetNodeValue(connectionNode.CreateNavigator(), "user"); connectionConfig.Password = XmlUtils.GetNodeValue(connectionNode.CreateNavigator(), "password"); connectionConfig.RunAsDbowner = XmlUtils.GetNodeValue(connectionNode.CreateNavigator(), "runasdbowner").ToLowerInvariant() == "true"; connectionConfig.Qualifier = XmlUtils.GetNodeValue(connectionNode.CreateNavigator(), "qualifier"); connectionConfig.UpgradeConnectionString = XmlUtils.GetNodeValue(connectionNode.CreateNavigator(), "upgradeconnectionstring"); installConfig.Connection = connectionConfig; } // Parse the superuser node XmlNode superUserNode = installTemplate.SelectSingleNode("//dotnetnuke/superuser"); if (superUserNode != null) { var superUserConfig = new SuperUserConfig(); superUserConfig.FirstName = XmlUtils.GetNodeValue(superUserNode.CreateNavigator(), "firstname"); superUserConfig.LastName = XmlUtils.GetNodeValue(superUserNode.CreateNavigator(), "lastname"); superUserConfig.UserName = XmlUtils.GetNodeValue(superUserNode.CreateNavigator(), "username"); superUserConfig.Password = XmlUtils.GetNodeValue(superUserNode.CreateNavigator(), "password"); superUserConfig.Email = XmlUtils.GetNodeValue(superUserNode.CreateNavigator(), "email"); superUserConfig.Locale = XmlUtils.GetNodeValue(superUserNode.CreateNavigator(), "locale"); superUserConfig.UpdatePassword = XmlUtils.GetNodeValue(superUserNode.CreateNavigator(), "updatepassword").ToLowerInvariant() == "true"; installConfig.SuperUser = superUserConfig; } // Parse the license node XmlNode licenseNode = installTemplate.SelectSingleNode("//dotnetnuke/license"); if (licenseNode != null) { var licenseConfig = new LicenseConfig(); licenseConfig.AccountEmail = XmlUtils.GetNodeValue(licenseNode.CreateNavigator(), "accountEmail"); licenseConfig.InvoiceNumber = XmlUtils.GetNodeValue(licenseNode.CreateNavigator(), "invoiceNumber"); licenseConfig.WebServer = XmlUtils.GetNodeValue(licenseNode.CreateNavigator(), "webServer"); licenseConfig.LicenseType = XmlUtils.GetNodeValue(licenseNode.CreateNavigator(), "licenseType"); if (!string.IsNullOrEmpty(XmlUtils.GetNodeValue(licenseNode.CreateNavigator(), "trial"))) { licenseConfig.TrialRequest = bool.Parse(XmlUtils.GetNodeValue(licenseNode.CreateNavigator(), "trial")); } installConfig.License = licenseConfig; } // Parse the settings node XmlNode settingsNode = installTemplate.SelectSingleNode("//dotnetnuke/settings"); if (settingsNode != null) { foreach (XmlNode settingNode in settingsNode.ChildNodes) { if (settingNode != null && !string.IsNullOrEmpty(settingNode.Name)) { bool settingIsSecure = false; if (settingNode.Attributes != null) { XmlAttribute secureAttrib = settingNode.Attributes["Secure"]; if (secureAttrib != null) { if (secureAttrib.Value.ToLowerInvariant() == "true") { settingIsSecure = true; } } } installConfig.Settings.Add(new HostSettingConfig { Name = settingNode.Name, Value = settingNode.InnerText, IsSecure = settingIsSecure }); } } } var folderMappingsNode = installTemplate.SelectSingleNode("//dotnetnuke/" + FolderMappingsConfigController.Instance.ConfigNode); installConfig.FolderMappingsSettings = (folderMappingsNode != null) ? folderMappingsNode.InnerXml : string.Empty; // Parse the portals node XmlNodeList portalsNode = installTemplate.SelectNodes("//dotnetnuke/portals/portal"); if (portalsNode != null) { foreach (XmlNode portalNode in portalsNode) { if (portalNode != null) { var portalConfig = new PortalConfig(); portalConfig.PortalName = XmlUtils.GetNodeValue(portalNode.CreateNavigator(), "portalname"); XmlNode adminNode = portalNode.SelectSingleNode("administrator"); if (adminNode != null) { portalConfig.AdminFirstName = XmlUtils.GetNodeValue(adminNode.CreateNavigator(), "firstname"); portalConfig.AdminLastName = XmlUtils.GetNodeValue(adminNode.CreateNavigator(), "lastname"); portalConfig.AdminUserName = XmlUtils.GetNodeValue(adminNode.CreateNavigator(), "username"); portalConfig.AdminPassword = XmlUtils.GetNodeValue(adminNode.CreateNavigator(), "password"); portalConfig.AdminEmail = XmlUtils.GetNodeValue(adminNode.CreateNavigator(), "email"); } portalConfig.Description = XmlUtils.GetNodeValue(portalNode.CreateNavigator(), "description"); portalConfig.Keywords = XmlUtils.GetNodeValue(portalNode.CreateNavigator(), "keywords"); portalConfig.TemplateFileName = XmlUtils.GetNodeValue(portalNode.CreateNavigator(), "templatefile"); portalConfig.IsChild = XmlUtils.GetNodeValue(portalNode.CreateNavigator(), "ischild").ToLowerInvariant() == "true"; portalConfig.HomeDirectory = XmlUtils.GetNodeValue(portalNode.CreateNavigator(), "homedirectory"); // Get the Portal Alias XmlNodeList portalAliases = portalNode.SelectNodes("portalaliases/portalalias"); if (portalAliases != null) { foreach (XmlNode portalAliase in portalAliases) { if (!string.IsNullOrEmpty(portalAliase.InnerText)) { portalConfig.PortAliases.Add(portalAliase.InnerText); } } } installConfig.Portals.Add(portalConfig); } } } return(installConfig); }
public static void Test1_OldVersionTest() { string filename; filename = "TestMe.png";//216,362 bytes //filename = "Colorful.jpg";//885,264 bytes //filename = "TestJpg.jpg";//2,066 bytes byte[] buffer; buffer = File.ReadAllBytes("D:\\[]Photo\\" + filename); //buffer = new byte[500500]; //Stream stReader = new Stream("D:\\[]Photo\\TestJpg.jpg"); //BinaryReader binaryReader = new BinaryReader(stReader); var ss = new System.Diagnostics.Stopwatch(); ss.Start(); string sql; string sql2; //please note the //field or column binding is extension, must start with ?? //sql = "INSERT INTO ??t1 (??c1, ??c2) VALUES (?n1 , ?buffer1)"; sql = "INSERT INTO ??t1 SET ??c2 = ?buffer1"; //sql = "select * from ??t1 where ??c1 > ?n1 and ?c1 < ?n2"; //sql = "select * from ??t1 where ??c1 = 4579"; //sql = "select 1+?n3 as test1"; //sql = "select concat(?s1,?s2,?s1,?s2,?s1,?s2,?s1,?s2,?s1,?s2) as test1"; //sql = "select concat(?s1,?s2,?s1,?s2) as test1"; //sql = "SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate" // + " FROM Orders INNER JOIN Customers" // + " ON Orders.CustomerID = Customers.CustomerID;"; //sql2 = "select * from ?t1 where ?c1 > ?n1 and ?c1 < ?n2"; //sql = "INSERT INTO ?t1 ( ?c2, ?c3) VALUES ( ?s1, ?s2)"; //sql = "DELETE FROM ?t1 WHERE ?c1=?n1"; //sql = "UPDATE ?t1 SET ?c2=?s1 WHERE ?c1=?n1"; //CommandParameters cmdValues = new CommandParameters(); //sql = "select ?n1+?n2 as test1"; int testN1 = 4520; int testN2 = 4530; sql = "select * from ??t1 where ??c1 > ?n1 and ??c1 < ?n2"; //sql = "select * from ?t1 where ?c1 = ?n2"; //sql = "select ?n1+?n2 as test1"; CommandParams cmd2Values = new CommandParams(); cmd2Values.SetSqlPart("??t1", "saveimage"); cmd2Values.SetSqlPart("??c1", "idsaveImage"); //cmd2Values.AddField("c2", "saveImagecol"); cmd2Values.AddWithValue("?n1", testN1); cmd2Values.AddWithValue("?n2", testN2); //cmd2Values.AddValue("n3", 29.5); //cmd2Values.AddValue("s1", "foo"); //cmd2Values.AddValue("s2", "bar"); //cmd2Values.AddValue("buffer1", buffer); ConnectionConfig config = new ConnectionConfig("root", "root"); config.database = "test"; //MySqlConnection sqlConn = new MySqlConnection(config.host, config.user, config.password, config.database); //sqlConn.UseConnectionPool = true; //sqlConn.Open(); //MySqlCommand command = new MySqlCommand(sql, sqlConn); //command.Parameters.AddTable("t1", "saveimage"); //command.Parameters.AddField("c1", "idsaveImage"); //command.Parameters.AddValue("n1", testN1); //command.Parameters.AddValue("n2", testN2); //var reader = command.ExecuteReader(); //reader.Read(); //Connection connection = sqlConn.Conn;/*ConnectionPool.GetConnection(new MySqlConnectionString(config.host, config.user, config.password, config.database));*/ Connection connection = new Connection(config); if (connection == null) { connection = new Connection(config); connection.IsStoredInConnPool = false; connection.Connect(); } int count = 3; int fCase = 1; for (int i = 0; i < count; i++) { int j = 0; //query = connection.CreateQuery(sql, cmdValues); //query = connection.CreateQuery(cmd2Values); //query.ExecutePrepareQuery(cmd2Values); var query = new Query(connection, sql, cmd2Values); query.SetResultListener(tableResult => { if (query.LoadError != null) { Console.WriteLine("Error : " + query.LoadError.message); } else if (query.OkPacket != null) { Console.WriteLine("i : " + i + ", OkPacket : [affectedRow] >> " + query.OkPacket.affectedRows); Console.WriteLine("i : " + i + ", OkPacket : [insertId] >> " + query.OkPacket.insertId); } else { var thead = tableResult.tableHeader; int col_idsaveImage = thead.GetFieldIndex("idsaveImage"); int col_saveImageCol = thead.GetFieldIndex("saveImagecol"); int col_test = thead.GetFieldIndex("test1"); //if (col_idsaveImage < 0 || col_saveImageCol < 0) //{ // throw new Exception(); //} Console.WriteLine("Result : "); //while (query.ReadRow()) //{ // if (col_test == 0) // { // Console.WriteLine("Result of " + "test1 : >> " + query.Cells[col_test] + " <<"); // } // else // { // Console.WriteLine("Id : " + query.Cells[col_idsaveImage]); // Console.WriteLine("Buffer size : " + query.Cells[col_saveImageCol].myBuffer.Length); // } // //Console.WriteLine(query.GetFieldData("myusercol1")); // if (++j > 3) // { // break; // } //} } }); testN1 += 10; testN2 += 10; cmd2Values.AddWithValue("?n1", testN1); cmd2Values.AddWithValue("?n2", testN2); query.Execute(true); //*** query.Close(); connection.Disconnect(); connection = new Connection(config); connection.Connect(); //j = 0; //query = connection.CreateQuery(sql2, prepare); //query.ExecuteQuery(); //if (query.loadError != null) //{ // Console.WriteLine("Error : " + query.loadError.message); //} //else //{ // while (query.ReadRow() && j < 3) // { // Console.WriteLine(query.GetFieldData("idsaveImage")); // Console.WriteLine(query.GetFieldData("saveImagecol")); // //Console.WriteLine(query.GetFieldData("myusercol1")); // j++; // } //} //query.Close(); } ss.Stop(); long avg = ss.ElapsedMilliseconds / count; Console.WriteLine("Counting : " + count + " rounds. \r\nAverage Time : " + avg + " ms"); connection.Disconnect(); }
/// <summary> /// 添加 SqlSugar 拓展 /// </summary> /// <param name="services"></param> /// <param name="config"></param> /// <param name="buildAction"></param> /// <returns></returns> public static IServiceCollection AddSqlSugar(this IServiceCollection services, ConnectionConfig config, Action <ISqlSugarClient> buildAction = default) { return(services.AddSqlSugar(new ConnectionConfig[] { config }, buildAction)); }
public QrfSqlSugarClient(ConnectionConfig config, string dbName, bool isDefault) : base(config) { DbName = dbName; Default = isDefault; }
void Awake() { instance = this; try { NetworkTransport.Init(); clientConfig = new ConnectionConfig(); clientChannelId = clientConfig.AddChannel(QosType.StateUpdate); // QosType.UnreliableFragmented // add client host clientTopology = new HostTopology(clientConfig, 1); clientHostId = NetworkTransport.AddHost(clientTopology, clientPort); if (clientHostId < 0) { throw new UnityException("AddHost failed for client port " + clientPort); } if (broadcastPort > 0) { // add broadcast host bcastHostId = NetworkTransport.AddHost(clientTopology, broadcastPort); if (bcastHostId < 0) { throw new UnityException("AddHost failed for broadcast port " + broadcastPort); } // start broadcast discovery byte error = 0; NetworkTransport.SetBroadcastCredentials(bcastHostId, 8888, 1, 0, out error); } // construct keep-alive data keepAliveData[0] = "ka,kb,km,kh"; // index 0 sendKeepAlive[0] = true; // faceManager = GetComponent<FacetrackingManager>(); // if(faceManager != null && faceManager.isActiveAndEnabled) // { // keepAliveData[1] = "ka,fp,"; // index 1 // sendKeepAlive[1] = true; // // if(faceManager.getFaceModelData) // { // keepAliveData[2] = "ka,fv,"; // index 2 // sendKeepAlive[2] = true; // // if(faceManager.texturedModelMesh == FacetrackingManager.TextureType.FaceRectangle) // { // keepAliveData[2] += "fu,"; // request uvs // } // // keepAliveData[3] = "ka,ft,"; // index 3 // sendKeepAlive[3] = true; // } // } keepAliveCount = keepAliveData.Length; } catch (System.Exception ex) { Debug.LogError(ex.Message + "\n" + ex.StackTrace); if (statusText) { statusText.text = ex.Message; } } }
/// <summary> /// Connects to host using a local IP /// If a source IP is given then use it for the local IP /// </summary> /// <param name="audit">IAudit interface to post debug/tracing to</param> /// <param name="localIP">ip to use for local end point</param> /// <param name="host">host ip/name</param> /// <param name="port">port to use</param> /// <param name="config">configuration parameters</param> /// <returns></returns> public bool Connect(IAudit audit, string localIP, string host, int port, ConnectionConfig config) { sourceIP = localIP; return(Connect(audit, host, port, string.Empty, config)); }