Пример #1
0
    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");
    }
 protected GlobalConfig getConfig()
 {
     if (config == null) {
         config = FindObjectOfType<GlobalConfig>();
     }
     return config;
 }
Пример #3
0
    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);
    }
    // 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);
    }
Пример #5
0
        public void GlobalConfigInstanceTest()
        {
            var config = new GlobalConfig();

            Assert.IsNotNull(config.Connections);
            Assert.IsNotNullOrEmpty(config.Connections["Redis"]);
            Assert.IsTrue(config.Connections["Redis"].Contains(_testAddress));
        }
 public void LoadConfig(string path)
 {
     StreamReader reader = new StreamReader(path);
     string configStr = reader.ReadToEnd();
     GlobalConfig tempConfig = JsonConvert.DeserializeObject<GlobalConfig>(configStr);
     m_instance = tempConfig;
     reader.Close();
 }
Пример #7
0
    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 );
    }
Пример #8
0
	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());
		}
	}
Пример #9
0
    // 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;
    }
Пример #10
0
    // 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;
    }
Пример #11
0
        public MainViewModel(ITimeGenerator generator)
        {
            if (generator == null)
            {
                throw new ArgumentNullException(nameof(generator));
            }

            _words = new Dictionary<DateTime, string>(1440); // 24 часа * 60 минут
            _timeGenerator = generator;

            Configuration = new GlobalConfig();
            Configuration.Loaded += (sender, args) =>
                {
                    MultipleOfFive = Configuration.Settings.MinutesMultipleOfFive;
                    GenerateTime();
                    SettingsLoaded = true;
                };
            Configuration.LoadAsync();
        }
Пример #12
0
        //todo - make Exit wait until this returns
        private async void LoadingThread()
        {
            Logging.RecordLogEvent("Constructing rgatUI: Initing/Loading Config", Logging.LogFilterType.Debug);
            double currentUIProgress = rgatUI.StartupProgress;

            Stopwatch timer = new(), timerTotal = new();

            timer.Start();
            timerTotal.Start();

            float configProgress = 0, widgetProgress = 0;

            void UpdateProgressConfWidgets()
            {
                rgatUI.StartupProgress = Math.Max(rgatUI.StartupProgress, currentUIProgress + 0.2 * configProgress + 0.5 * widgetProgress);
            };

            Progress <float> IProgressConfig  = new(progress => { configProgress = progress; UpdateProgressConfWidgets(); });
            Progress <float> IProgressWidgets = new(progress => { widgetProgress = progress; UpdateProgressConfWidgets(); });

            Task confloader   = Task.Run(() => { GlobalConfig.LoadConfig(GUI: true, progress: IProgressConfig); }); // 900ms~ depending on themes
            Task widgetLoader = Task.Run(() => _rgatUI !.InitWidgets(IProgressWidgets));                            //2000ms~ fairly flat

            await Task.WhenAll(widgetLoader, confloader);

            if (GlobalConfig.Settings.UI.EnabledLanguageCount > 0)
            {
                _controller !.RebuildFonts();
            }

            InitEventHandlers();
            Logging.RecordLogEvent($"Startup: Widgets+config loaded in {timer.ElapsedMilliseconds} ms", Logging.LogFilterType.Debug);
            timer.Restart();

            rgatUI.StartupProgress = 0.85;
            currentUIProgress      = rgatUI.StartupProgress;

            rgatState.VideoRecorder.Load(); //0 ms
            _rgatUI !.InitSettingsMenu();   //50ms ish

            Logging.RecordLogEvent($"Startup: Settings menu loaded in {timer.ElapsedMilliseconds} ms", Logging.LogFilterType.Debug);
            timer.Restart();

            heatRankThreadObj = new HeatRankingThread();
            heatRankThreadObj.Begin();

            rgatState.processCoordinatorThreadObj = new ProcessCoordinatorThread();
            rgatState.processCoordinatorThreadObj.Begin();

            rgatUI.StartupProgress = 0.86;
            currentUIProgress      = rgatUI.StartupProgress;

            float apiProgress = 0, sigProgress = 0;

            void UpdateProgressAPISig()
            {
                rgatUI.StartupProgress = Math.Max(rgatUI.StartupProgress, currentUIProgress + 0.07 * sigProgress + 0.07f * apiProgress);
            };
            Progress <float> IProgressAPI  = new(progress => { apiProgress = progress; UpdateProgressAPISig(); });
            Progress <float> IProgressSigs = new(progress => { sigProgress = progress; UpdateProgressAPISig(); });

            Task sigsTask = Task.Run(() => rgatState.LoadSignatures(IProgressSigs));


            // api data is the startup item that can be loaded latest as it's only needed when looking at traces
            // we could load it in parallel with the widgets/config but if it gets big then it will be the limiting factor in start up speed
            // doing it last means the user can do stuff while it loads
            Task?apiTask = null;

            if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows))
            {
                string?datafile = APIDetailsWin.FindAPIDatafile();
                if (datafile is not null)
                {
                    apiTask = Task.Run(() => APIDetailsWin.Load(datafile, IProgressAPI));
                }
                else
                {
                    apiTask = Task.Delay(0);
                    Logging.RecordError("Failed to find API data file");
                }
            }
            else
            {
                apiTask = Task.Run(() => Logging.WriteConsole("TODO: linux API loading"));
            }

            if (GlobalConfig.Settings.Updates.DoUpdateCheck)
            {
                _ = Task.Run(() => Updates.CheckForUpdates()); //functionality does not depend on this so we don't wait for it
            }

            await Task.WhenAll(sigsTask, apiTask);

            timer.Stop();
            timerTotal.Stop();

            Logging.RecordLogEvent($"Startup: Signatures + API info inited in {timer.ElapsedMilliseconds} ms", Logging.LogFilterType.Debug);
            Logging.RecordLogEvent($"Startup: Loading thread took {timerTotal.ElapsedMilliseconds} ms", Logging.LogFilterType.Debug);
            rgatUI.StartupProgress = 1;
        }
 public GlobalConfig()
 {
     if (m_instance == null)
         m_instance = this;
 }
Пример #14
0
    void initNetworkConfig()
    {
        // Create global config
        GlobalConfig globalConfig = new GlobalConfig ();
        globalConfig.ReactorModel = ReactorModel.FixRateReactor;
        globalConfig.ThreadAwakeTimeout = 1;

        // Create connection config
        ConnectionConfig connectionConfig = new ConnectionConfig ();
        byte channelReliable = connectionConfig.AddChannel (QosType.Reliable);
        byte channelUnreliable = connectionConfig.AddChannel (QosType.Unreliable);

        // Create host config
        hostTopology = new HostTopology (connectionConfig, 10);

        // Init network
        NetworkTransport.Init (globalConfig);
    }
Пример #15
0
    private void SetupServer()
    {
        // global config
        GlobalConfig gconfig = new GlobalConfig();
        gconfig.ReactorModel = ReactorModel.FixRateReactor;
        gconfig.ThreadAwakeTimeout = 10;
        NetworkTransport.Init(gconfig);

        ConnectionConfig config = new ConnectionConfig();
        reliableChannelId = config.AddChannel(QosType.ReliableSequenced);
        unreliableChannelId = config.AddChannel(QosType.UnreliableSequenced);

        HostTopology topology = new HostTopology(config, GameData.GetInstance().MaxNumOfPlayers);
        hostId = NetworkTransport.AddHost(topology, port);

        StartBroadcast();
    }
Пример #16
0
    private void SetupClient()
    {
        // global config
        GlobalConfig gconfig = new GlobalConfig();
        gconfig.ReactorModel = ReactorModel.FixRateReactor;
        gconfig.ThreadAwakeTimeout = 1;

        // build ourselves a config with a couple of channels
        ConnectionConfig config = new ConnectionConfig();
        reliableChannelId = config.AddChannel(QosType.ReliableSequenced);
        unreliableChannelId = config.AddChannel(QosType.UnreliableSequenced);

        // create a host topology from the config
        HostTopology hostconfig = new HostTopology(config, 1);

        // initialise the transport layer
        NetworkTransport.Init(gconfig);
        hostId = NetworkTransport.AddHost(hostconfig, port);
        byte error;
        NetworkTransport.SetBroadcastCredentials(hostId, broadcastKey, broadcastVersion, broadcastSubversion, out error);
    }
        /// <summary>
        /// add a new member to the database.
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public void CreatePerson(PersonModel model)
        {
            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(db)))
            {
                // below is the code to connect with the sql server database.

                var p = new DynamicParameters();
                p.Add("@FirstName", model.FirstName);
                p.Add("@LastName", model.LastName);
                p.Add("@EmailAddress", model.EmailAddress);
                p.Add("@CellPhoneNumber", model.CellPhoneNumber);
                p.Add("@id", 0, dbType: DbType.Int32, direction: ParameterDirection.Output);

                connection.Execute("dbo.spPeople_Insert", p, commandType: CommandType.StoredProcedure);

                model.Id = p.Get <int>("@id");
            }
        }
        public List <TournamentModel> GetTournament_All()
        {
            List <TournamentModel> output;

            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(db)))
            {
                output = connection.Query <TournamentModel>("dbo.spTournament_GetAll").ToList();
                var p = new DynamicParameters();

                foreach (TournamentModel t in output)
                {
                    // Populate the Prizesp = new DynamicParameters();
                    p = new DynamicParameters();
                    p.Add("@TournamentId", t.Id);
                    t.Prizes = connection.Query <PrizeModel>("dbo.spPrizes_GetByTournament", p, commandType: CommandType.StoredProcedure).ToList();

                    // populate the teams
                    p = new DynamicParameters();
                    p.Add("@TournamentId", t.Id);
                    t.EnteredTeams = connection.Query <TeamModel>("dbo.spTeam_GetByTournament", p, commandType: CommandType.StoredProcedure).ToList();

                    foreach (TeamModel team in t.EnteredTeams)
                    {
                        p = new DynamicParameters();
                        p.Add("@TeamId", team.Id);

                        team.TeamMembers = connection.Query <PersonModel>("dbo.spTeamMembers_GetByTeam", p, commandType: CommandType.StoredProcedure).ToList();
                    }
                    p = new DynamicParameters();
                    p.Add("@TournamentId", t.Id);
                    // populate the rounds
                    List <MatchupModel> matchups = connection.Query <MatchupModel>("dbo.spMatchups_GetByTournament", p, commandType: CommandType.StoredProcedure).ToList();

                    foreach (MatchupModel m in matchups)
                    {
                        p = new DynamicParameters();
                        p.Add("@MatchupId", m.Id);


                        m.Entries = connection.Query <MatchupEntryModel>("dbo.spMatchupEntries_GetByMatchups", p, commandType: CommandType.StoredProcedure).ToList();
                        //Populate each entry
                        //populate each matchup
                        List <TeamModel> allTeams = GetTeam_All();

                        if (m.WinnerId > 0)
                        {
                            m.Winner = allTeams.Where(x => x.Id == m.WinnerId).First();
                        }

                        foreach (var me in m.Entries)
                        {
                            if (me.TeamCompetingId > 0)
                            {
                                me.TeamCompeting = allTeams.Where(x => x.Id == me.TeamCompetingId).First();
                            }

                            if (me.ParentMatchupId > 0)
                            {
                                me.ParentMatchup = matchups.Where(x => x.Id == me.ParentMatchupId).First();
                            }
                        }
                    }

                    List <MatchupModel> currRow = new List <MatchupModel>();
                    int currRound = 1;

                    foreach (MatchupModel m in matchups)
                    {
                        if (m.MatchupRound > currRound)
                        {
                            t.Rounds.Add(currRow);
                            currRow    = new List <MatchupModel>();
                            currRound += 1;
                        }

                        currRow.Add(m);
                    }

                    t.Rounds.Add(currRow);
                }
            }

            return(output);
        }
        /// <summary>
        /// to add the team model to the list from the dropdown box and add it to the list in create team form.
        /// </summary>
        /// <returns></returns>
        public List <TeamModel> GetTeam_All()
        {
            List <TeamModel> output;

            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(db)))
            {
                output = connection.Query <TeamModel>("dbo.spTeam_GetAll").ToList();

                foreach (TeamModel team in output)
                {
                    var p = new DynamicParameters();
                    p.Add("@TeamId", team.Id);

                    team.TeamMembers = connection.Query <PersonModel>("dbo.spTeamMembers_GetByTeam", p, commandType: CommandType.StoredProcedure).ToList();
                }
            }

            return(output);
        }
        /// <summary>
        /// to add a person model to the list from the dropdown box and add it to the list in creat team form.
        /// </summary>
        /// <returns></returns>
        public List <PersonModel> GetPerson_All()
        {
            List <PersonModel> output;

            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(db)))
            {
                output = connection.Query <PersonModel>("dbo.spPeople_GetAll").ToList();
            }

            return(output);
        }
 /// <summary>
 /// to create the database to create a tournament and save individual data to corresponding tables.
 /// </summary>
 /// <param name="model"></param>
 public void CreateTournament(TournamentModel model)
 {
     using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(db)))
     {
         // below is the code to connect with the sql server database.
         SaveTournament(connection, model);
         SaveTournamentPrizes(connection, model);
         SaveTournamentEntries(connection, model);
         SaveTournamentRounds(connection, model);
         TournamentLogic.UpdateTournamentResults(model);
     }
 }
Пример #22
0
        public override void OnLevelUnloading()
        {
            Log.Info("OnLevelUnloading");
            base.OnLevelUnloading();
            if (IsPathManagerReplaced)
            {
                CustomPathManager._instance.WaitForAllPaths();
            }

            try {
                var reverseManagers = new List <ICustomManager>(RegisteredManagers);
                reverseManagers.Reverse();

                foreach (ICustomManager manager in reverseManagers)
                {
                    Log.Info($"OnLevelUnloading: {manager.GetType().Name}");
                    manager.OnLevelUnloading();
                }

                Flags.OnLevelUnloading();
                GlobalConfig.OnLevelUnloading();

                var gameObject = UIView.GetAView().gameObject;

                void Destroy <T>() where T : MonoBehaviour
                {
                    Object obj = (Object)gameObject.GetComponent <T>();

                    if (obj != null)
                    {
                        Object.Destroy(obj);
                    }
                }

                Destroy <RoadSelectionPanels>();
                Destroy <RemoveVehicleButtonExtender>();
                Destroy <RemoveCitizenInstanceButtonExtender>();

                //It's MonoBehaviour - comparing to null is wrong
                if (TransportDemandUI)
                {
                    Object.Destroy(TransportDemandUI);
                    TransportDemandUI = null;
                }

                Log.Info("Removing Controls from UI.");
                if (ModUI.Instance != null)
                {
                    ModUI.Instance.CloseMainMenu(); // Hide the UI ASAP
                    ModUI.Instance.Destroy();
                    Log._Debug("removed UIBase instance.");
                }
            }
            catch (Exception e) {
                Log.Error("Exception unloading mod. " + e.Message);

                // ignored - prevents collision with other mods
            }

            Patcher.Instance?.Uninstall();
            IsGameLoaded = false;
        }
Пример #23
0
        /// <summary>
        /// Gets all tags from the database.
        /// </summary>
        /// <returns></returns>
        public List <TagModel> GetAllTags()
        {
            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(db)))
            {
                List <TagModel> tags = new List <TagModel>();

                tags = connection.Query <TagModel>("dbo.spGetTags", commandType: CommandType.StoredProcedure).ToList();

                return(tags);
            }
        }
Пример #24
0
        /// <summary>
        ///  Gets all products from the database.
        /// </summary>
        /// <returns></returns>
        public List <ProductModel> GetAllProducts()
        {
            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(db)))
            {
                List <ProductModel> products = new List <ProductModel>();

                products = connection.Query <ProductModel>("dbo.spGetAllProducts", commandType: CommandType.StoredProcedure).ToList();;

                return(products);
            }
        }
        public void UpdateMatchup(MatchupModel model)
        {
            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(db)))
            {
                var p = new DynamicParameters();
                if (model.Winner != null)
                {
                    p.Add("@id", model.Id);
                    p.Add("@WinnerId", model.Winner.Id);

                    connection.Execute("dbo.spMatchups_Update", p, commandType: CommandType.StoredProcedure);
                }

                foreach (MatchupEntryModel me in model.Entries)
                {
                    if (me.TeamCompeting != null)
                    {
                        p = new DynamicParameters();
                        p.Add("@id", me.Id);
                        p.Add("@TeamCompetingId", me.TeamCompeting.Id);
                        p.Add("@Score", me.Score);

                        connection.Execute("dbo.spMatchupEntries_Update", p, commandType: CommandType.StoredProcedure);
                    }
                }
            }
        }
Пример #26
0
 /// <summary>
 /// Constructs HTML to PDF converter instance from <code>GlobalConfig</code>.
 /// </summary>
 /// <param name="config">global configuration object</param>
 public SynchronizedPechkin(GlobalConfig config)
 {
     _converter = (IPechkin) _synchronizer.Invoke((Func<GlobalConfig, IPechkin>)(cfg => new SimplePechkin(cfg)), new[] { config });
 }
        public void CompleteTournament(TournamentModel model)
        {
            //dbo.spTournaments_Complete
            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(db)))
            {
                var p = new DynamicParameters();
                p.Add("@id", model.Id);

                connection.Execute("dbo.spTournaments_Complete", p, commandType: CommandType.StoredProcedure);
            }
        }
    public void Start()
    {
        Disconnect = false;
        GlobalConfig gConfig = new GlobalConfig();
        NetworkTransport.Init(gConfig);
        SocketId = NetworkTransport.AddHost(Topology, Port);
        ProcessWorkers = new Thread[workerProcessCount];

        // Create and start a separate thread for each worker
        for (int i = 0; i < workerProcessCount; i++)
        {
            ProcessWorkers[i] = new Thread(MessagesConsumer);
            ProcessWorkers[i].Name = "LLApi Process Thread " + i;
            ProcessWorkers[i].Start();

        }
    }
        // make the CreatePrize method actually save to the database
        /// <summary>
        /// Saves a new prize to the database
        /// </summary>
        /// <param name="model">The prize information</param>
        /// <returns>The prize information, including the unique identifier.</returns>
        public void CreatePrize(PrizeModel model)
        {
            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(db)))
            {
                // below is the code to connect with the sql server database.

                var p = new DynamicParameters();
                p.Add("@PlaceNumber", model.PlaceNumber);
                p.Add("@PlaceName", model.PlaceName);
                p.Add("@PrizeAmount", model.PrizeAmount);
                p.Add("@PrizePercentage", model.PrizePercentage);
                p.Add("@id", 0, dbType: DbType.Int32, direction: ParameterDirection.Output);

                connection.Execute("dbo.spPrizes_Insert", p, commandType: CommandType.StoredProcedure);

                model.Id = p.Get <int>("@id");
            }
        }
Пример #30
0
    /// <summary>
    /// Initialize our low level network APIs.
    /// </summary>
    public static void Init()
    {
        // Set up NetworkTransport
        GlobalConfig gc = new GlobalConfig();
        gc.ReactorModel = ReactorModel.FixRateReactor;
        gc.ThreadAwakeTimeout = 10;
        NetworkTransport.Init (gc);

        // Set up our channel configuration
        mConnectionConfig = new ConnectionConfig();
        mChannelReliable = mConnectionConfig.AddChannel (QosType.ReliableSequenced);
        mChannelUnreliable = mConnectionConfig.AddChannel(QosType.UnreliableSequenced);

        mIsInitialized = true;
    }
        /// <summary>
        /// to add a new team to the database.
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public void CreateTeam(TeamModel model)
        {
            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(db)))
            {
                // below is the code to connect with the sql server database.

                var p = new DynamicParameters();
                p.Add("@TeamName", model.TeamName);
                p.Add("@id", 0, dbType: DbType.Int32, direction: ParameterDirection.Output);

                connection.Execute("dbo.spTeams_Insert", p, commandType: CommandType.StoredProcedure);

                model.Id = p.Get <int>("@id");

                foreach (PersonModel tm in model.TeamMembers)
                {
                    p = new DynamicParameters();
                    p.Add("@TeamId", model.Id);
                    p.Add("@PersonId", tm.Id);

                    connection.Execute("dbo.spTeamMembers_Insert", p, commandType: CommandType.StoredProcedure);
                }
            }
        }
 void Awake()
 {
     m_config = new GlobalConfig();
     if (m_useConfigFile)
         m_config.LoadConfig(m_configFile);
 }
Пример #33
0
        /// <summary>
        /// Deletes the tag from the database.
        /// </summary>
        /// <param name="tagModel"></param>
        public void DeleteTag(TagModel tagModel)
        {
            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(db)))
            {
                var t = new DynamicParameters();
                t.Add("@id", tagModel.id);

                connection.Execute("dbo.spDeleteTag", t, commandType: CommandType.StoredProcedure);
            }
        }
    {   /// <summary>
        /// Using Dapper, Data is stored into database
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public SpecimenModel CreateSampleSubmission(SpecimenModel model)
        {
            try
            {                                       //download sqlcleint     //getting database name
                using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.GetConnectionString("GBAnalysisDB")))
                {
                    var val = new DynamicParameters();
                    val.Add("@UserId", model.UserId);
                    val.Add("@UserName", model.UserName);
                    val.Add("@GBLabel", model.GBLabel);
                    val.Add("@GBEnergy", model.GBEnergy);
                    val.Add("@SolidificationFactor", model.SolidificationFactor);
                    val.Add("@ThermalFactor", model.ThermalFactor);
                    val.Add("@id", 0, dbType: DbType.Int32, ParameterDirection.Output);

                    connection.Execute("dbo.spSpecimens_Insert", val, commandType: CommandType.StoredProcedure);//store procedure=dbo.spSpecimens_Insert

                    model.Id = val.Get <int>("@id");
                    return(model);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #35
0
        /// <summary>
        /// Gets all products that are connected to the specific tag.
        /// </summary>
        /// <param name="tagModel"></param>
        /// <returns></returns>
        public List <ProductModel> GetProductsFilteredByTag(TagModel tagModel)
        {
            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(db)))
            {
                List <ProductModel> products = new List <ProductModel>();

                var p = new DynamicParameters();
                p.Add("@Tag", tagModel.Name);

                products = connection.Query <ProductModel>("dbo.spGetProductsFilteredByTag", p, commandType: CommandType.StoredProcedure).ToList();

                return(products);
            }
        }
 public GlobalConfig()
 {
     myGlobalConfig = this;
 }
Пример #37
0
        /// <summary>
        /// Saves a new product to the database.
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public void AddProduct(ProductModel productModel)
        {
            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(db)))
            {
                var p = new DynamicParameters();
                p.Add("@Name", productModel.Name);
                p.Add("@id", 0, dbType: DbType.Int32, direction: ParameterDirection.Output);
                p.Add("@NeedsRefill", 0, dbType: DbType.Boolean, direction: ParameterDirection.Output);

                connection.Execute("dbo.spCreateProduct", p, commandType: CommandType.StoredProcedure);

                productModel.id          = p.Get <int>("@id");
                productModel.NeedsRefill = p.Get <bool>("@NeedsRefill");
            }
        }
    void Start()
    {
        DontDestroyOnLoad(this);

        //Build the global config
        GlobalConfig globalConfig = new GlobalConfig();
        globalConfig.ReactorModel = ReactorModel.FixRateReactor;
        globalConfig.ThreadAwakeTimeout = INTERVAL_TIME;
        //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, DEFAULT_PORT);
        //Make sure the client created the socket successfully
        if (clientSocketID < 0)
            Debug.Log("Client socket creation failed");
        else
            Debug.Log("Client socket creation successful");
        //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
        clientServerConnectionID = NetworkTransport.Connect(clientSocketID, "localhost", DEFAULT_PORT, 0, out possibleError);

        //Display the error (if it did error out)
        if (!possibleError.Equals((byte)NetworkError.Ok))
        {
            NetworkError error = (NetworkError)possibleError;
            Debug.Log("Error occurred: " + error.ToString());
        }
    }
Пример #39
0
        /// <summary>
        /// Adds a connection between tag and product if it doesn't exist.
        /// Removes the connection if it does exist.
        /// </summary>
        /// <param name="productModel"></param>
        /// <param name="tagModel"></param>
        public void ToggleProductTagRelation(ProductModel productModel, TagModel tagModel)
        {
            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(db)))
            {
                var p = new DynamicParameters();
                p.Add("@productId", productModel.id);
                p.Add("@tagId", tagModel.id);

                connection.Execute("dbo.spToggleProductTagRelation", p, commandType: CommandType.StoredProcedure);
            }
        }
Пример #40
0
        /// <summary>
        /// Deletes the product from the database.
        /// </summary>
        /// <param name="productModel"></param>
        public void DeleteProduct(ProductModel productModel)
        {
            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(db)))
            {
                var p = new DynamicParameters();
                p.Add("@id", productModel.id);

                connection.Execute("dbo.spDeleteProduct", p, commandType: CommandType.StoredProcedure);
            }
        }
Пример #41
0
    // Use this for initialization
    void Start()
    {
        var global = new GlobalConfig();
        global.MaxPacketSize = 300;

        NetworkTransport.Init();

        var config = new ConnectionConfig();
        reliableID = config.AddChannel(QosType.ReliableSequenced);
        stateID = config.AddChannel(QosType.Unreliable);

        var topology = new HostTopology(config, 200);
        myHostID = NetworkTransport.AddHost(topology, isClient ? 0 : 16688);

        Debug.Log("Host ID " + myHostID);

        if (isClient)
        {
            // pew.dk "188.226.164.147"
            // local "192.168.1.14"
            myConID = NetworkTransport.Connect(myHostID, "188.226.164.147", 16688, 0, out error);
        }

        if (!TestError("Connecting to host"))
        {
            Debug.Log("Connection established " + myConID);
        }
    }
        /// <summary>
        /// using store procedure
        /// </summary>
        /// <returns></returns>

        public List <SpecimenModel> GetSubmittedData()
        {
            List <SpecimenModel> availableSpecimens = new List <SpecimenModel>();

            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.GetConnectionString("GBAnalysisDB")))
            {
                availableSpecimens = connection.Query <SpecimenModel>("dbo.spSpecimens_GetALLData").ToList();
            }
            return(availableSpecimens);
        }
Пример #43
0
        /// <summary>
        ///  Saves a new tag to the database.
        /// </summary>
        /// <param name="tagModel"></param>
        /// <returns></returns>
        public TagModel AddTag(TagModel tagModel)
        {
            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(db)))
            {
                var t = new DynamicParameters();
                t.Add("@Name", tagModel.Name);
                t.Add("@id", 0, dbType: DbType.Int32, direction: ParameterDirection.Output);

                connection.Execute("dbo.spCreateTag", t, commandType: CommandType.StoredProcedure);

                tagModel.id = t.Get <int>("@id");
                return(tagModel);
            }
        }
        static OrmLiteRepository()
        {
            OrmLiteConfig.DialectProvider = MySqlDialect.Provider;

            dbFactory = new OrmLiteConnectionFactory();
            OrmLiteConnectionFactory.NamedConnections.Add(Read, new OrmLiteConnectionFactory(GlobalConfig.GetInstance().ConnectionString));
            OrmLiteConnectionFactory.NamedConnections.Add(Write, new OrmLiteConnectionFactory(GlobalConfig.GetInstance().ConnectionString));
        }
Пример #45
0
        /// <summary>
        /// Gets all the tags that are connected to a specific procuct.
        /// </summary>
        /// <param name="productModel"></param>
        /// <returns></returns>
        public List <TagModel> GetTagsBelongingToProduct(ProductModel productModel)
        {
            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(db)))
            {
                List <TagModel> tags = new List <TagModel>();

                var t = new DynamicParameters();
                t.Add("@id", productModel.id);

                tags = connection.Query <TagModel>("dbo.spGetTagsBelongingToProduct", t, commandType: CommandType.StoredProcedure).ToList();

                return(tags);
            }
        }