コード例 #1
0
        public UdpListenerTest()
        {
            _listener = new RxUdpListener();
            _listener.Received.Subscribe(e => Log.AddOnScheduler($"Receive (from {e.From}).\n{e.Data.ToDumpString()}"));

            Listen.Subscribe(_ =>
            {
                try
                {
                    if (Multicast.Value)
                    {
                        _listener.Listen(Address.Value, Port.Value);
                    }
                    else
                    {
                        _listener.Listen(Port.Value);
                    }
                    Log.Add($"Listen {(Multicast.Value ? Address.Value + " : " : "")}{Port.Value}");
                }
                catch (Exception exp)
                {
                    Log.Add($"Listen error.{exp.Message}");
                }
            });

            Close.Subscribe(_ => _listener.Close());
        }
コード例 #2
0
ファイル: Insights.cs プロジェクト: Jaminima/Spotter-Azure
            public InsightData(Listen listen, Track track, Spotify sp, SpotterAzure_dbContext dbContext)
            {
                this.listen = listen;
                this.track  = track;

                Task <Features> f = this.track.GetFeatures(sp, dbContext);
                Task <Artist>   a = this.track.GetArtist(sp, dbContext);

                if (!f.IsCompleted)
                {
                    f.Start(); f.Wait();
                }
                if (!a.IsCompleted)
                {
                    a.Start(); a.Wait();
                }

                this.features = f.Result;
                this.artist   = a.Result;

                if (this.artist.Details != null)
                {
                    this.genres = this.artist._artistDetails.genres.SelectMany(x => x.Split(' ')).Distinct().ToArray();
                }
            }
コード例 #3
0
        public Series(Pair n)
        {
            Listen Test = new Listen(this);

            Arr    = new Pair[1];
            Arr[0] = n.DeepCopy();
        }
コード例 #4
0
 public net_driver_t(string name,
                     bool initialized,
                     Init delegate_Init,
                     Listen delegate_Listen,
                     SearchForHosts delegate_SearchForHosts,
                     Connect delegate_Connect,
                     CheckNewConnections delegate_CheckNewConnections,
                     QGetMessage delegate_QGetMessage,
                     QSendMessage delegate_QSendMessage,
                     SendUnreliableMessage delegate_SendUnreliableMessage,
                     CanSendMessage delegate_CanSendMessage,
                     CanSendUnreliableMessage delegate_CanSendUnreliableMessage,
                     Close delegate_Close,
                     Shutdown delegate_Shutdown)
 {
     this.name                              = name;
     this.initialized                       = initialized;
     this.delegate_Init                     = delegate_Init;
     this.delegate_Listen                   = delegate_Listen;
     this.delegate_SearchForHosts           = delegate_SearchForHosts;
     this.delegate_Connect                  = delegate_Connect;
     this.delegate_CheckNewConnections      = delegate_CheckNewConnections;
     this.delegate_QGetMessage              = delegate_QGetMessage;
     this.delegate_QSendMessage             = delegate_QSendMessage;
     this.delegate_SendUnreliableMessage    = delegate_SendUnreliableMessage;
     this.delegate_CanSendMessage           = delegate_CanSendMessage;
     this.delegate_CanSendUnreliableMessage = delegate_CanSendUnreliableMessage;
     this.delegate_Close                    = delegate_Close;
     this.delegate_Shutdown                 = delegate_Shutdown;
 }
コード例 #5
0
        static void Scrape(string input)
        {
            var str = new AntlrInputStream(input);
            //System.Console.WriteLine(input);
            var lexer  = new ScrapeDartLexer(str);
            var tokens = new CommonTokenStream(lexer);
            var parser = new ScrapeDartParser(tokens);

            lexer.Mode(ScrapeDartLexer.Search);
            var listener_lexer  = new ErrorListener <int>();
            var listener_parser = new ErrorListener <IToken>();

            lexer.AddErrorListener(listener_lexer);
            parser.AddErrorListener(listener_parser);
            var tree = parser.file();

            if (listener_lexer.had_error || listener_parser.had_error)
            {
                System.Console.WriteLine("error in parse.");
                throw new Exception();
            }
            else
            {
                System.Console.WriteLine("parse completed.");
            }
            var walker   = new ParseTreeWalker();
            var listener = new Listen();

            walker.Walk(listener, tree);
            var code = listener.sb.ToString();

            System.Console.WriteLine(code);
        }
コード例 #6
0
        public async Task MultipleModifiedListeners_TestInheritance()
        {
            MockListener.Reset();
            MockListener2.Reset();
            ObjectListener.Reset();

            await Listen.ModifiedAsync(new object(), new { sajt = true }, ctx);

            Assert.IsFalse(MockListener.WasOnCreatedCalled);
            Assert.IsFalse(MockListener.WasOnCreationValidationFailedCalled);
            Assert.IsFalse(MockListener.WasOnModifiedCalled);
            Assert.IsFalse(MockListener.WasOnModificationFailedCalled);
            Assert.IsFalse(MockListener.WasOnDeletedCalled);
            Assert.IsFalse(MockListener.WasOnDeletionFailedCalled);

            Assert.IsFalse(MockListener2.WasOnCreatedCalled);
            Assert.IsFalse(MockListener2.WasOnCreationValidationFailedCalled);
            Assert.IsFalse(MockListener2.WasOnModifiedCalled);
            Assert.IsFalse(MockListener2.WasOnModificationFailedCalled);
            Assert.IsFalse(MockListener2.WasOnDeletedCalled);
            Assert.IsFalse(MockListener2.WasOnDeletionFailedCalled);

            Assert.IsFalse(ObjectListener.WasOnCreatedCalled);
            Assert.IsFalse(ObjectListener.WasOnCreationValidationFailedCalled);
            Assert.IsTrue(ObjectListener.WasOnModifiedCalled);
            Assert.IsFalse(ObjectListener.WasOnModificationFailedCalled);
            Assert.IsFalse(ObjectListener.WasOnDeletedCalled);
            Assert.IsFalse(ObjectListener.WasOnDeletionFailedCalled);

            Assert.IsNull(MockListener.EntitesWereNotTheSameOnCalling);
            Assert.IsNull(MockListener2.EntitesWereNotTheSameOnCalling);
            Assert.IsTrue(ObjectListener.EntitesWereNotTheSameOnCalling.HasValue && ObjectListener.EntitesWereNotTheSameOnCalling.Value);
        }
コード例 #7
0
        public async Task DistributeToListenersAsync(List <object> added, EfContextInfo contextInfo, List <Tuple <object, object> > modified, List <object> removed, bool isChildRepository = false)
        {
            if (!isChildRepository)
            {
                List <Type> otherTypes = added.Where(a => !(a is T)).Select(a => a.GetType()).ToList();
                otherTypes.AddRange(modified.Where(a => !(a.Item1 is T)).Select(a => a.Item1.GetType()));
                otherTypes.AddRange(removed.Where(a => !(a is T)).Select(a => a.GetType()));
                foreach (var otherType in otherTypes.Distinct())
                {
                    var repo = GetChildRepositoryFor(otherType);
                    await repo.DistributeToListenersAsync(added, contextInfo, modified, removed, true);
                }
            }


            /* from the same type */
            //added.Where(a=>(a) is T).Cast<T>().Select(async a => await Listen.CreatedAsync(a, contextInfo));
            foreach (var addedEntry in added.Where(a => (a) is T).Cast <T>())
            {
                await Listen.CreatedAsync(addedEntry, contextInfo);
            }
            //var t2 = modified.Where(a => a is Tuple<T,T>).Cast<Tuple<T,T>>().Select(async a =>await Listen.ModifiedAsync((a).Item1, (a).Item2, contextInfo));
            foreach (var modifiedEntry in modified.Where(a => a.Item1 is T && a.Item2 is T).Cast <Tuple <object, object> >())
            {
                await Listen.ModifiedAsync(modifiedEntry.Item1 as T, modifiedEntry.Item2 as T, contextInfo);
            }

            //var t3 = removed.Where(a => a is T).Cast<T>().Select(async a => await Listen.RemovedAsync((a), contextInfo));
            foreach (var removedEntry in removed.Where(a => a is T).Cast <T>())
            {
                await Listen.RemovedAsync(removedEntry, contextInfo);
            }
        }
コード例 #8
0
ファイル: net.cs プロジェクト: sbrown345/quakejs
 public net_driver_t(string name,
                     bool initialized,
                     Init delegate_Init,
                     Listen delegate_Listen,
                     SearchForHosts delegate_SearchForHosts,
                     Connect delegate_Connect,
                     CheckNewConnections delegate_CheckNewConnections,
                     QGetMessage delegate_QGetMessage,
                     QSendMessage delegate_QSendMessage,
                     SendUnreliableMessage delegate_SendUnreliableMessage,
                     CanSendMessage delegate_CanSendMessage,
                     CanSendUnreliableMessage delegate_CanSendUnreliableMessage,
                     Close delegate_Close,
                     Shutdown delegate_Shutdown)
 {
     this.name = name;
     this.initialized = initialized;
     this.delegate_Init = delegate_Init;
     this.delegate_Listen = delegate_Listen;
     this.delegate_SearchForHosts = delegate_SearchForHosts;
     this.delegate_Connect = delegate_Connect;
     this.delegate_CheckNewConnections = delegate_CheckNewConnections;
     this.delegate_QGetMessage = delegate_QGetMessage;
     this.delegate_QSendMessage = delegate_QSendMessage;
     this.delegate_SendUnreliableMessage = delegate_SendUnreliableMessage;
     this.delegate_CanSendMessage = delegate_CanSendMessage;
     this.delegate_CanSendUnreliableMessage = delegate_CanSendUnreliableMessage;
     this.delegate_Close = delegate_Close;
     this.delegate_Shutdown = delegate_Shutdown;
 }
コード例 #9
0
        public TcpServerTest()
        {
            _server = new RxTcpServer();

            _server.Error.Subscribe(e => Log.AddOnScheduler($"Error.{e.Method} - {e.Exception?.Message}"));
            _server.Accepted.Subscribe(e => Log.AddOnScheduler($"Accept. from {e.Client.RemoteEndPoint}"));
            _server.Closed.Subscribe(e => Log.AddOnScheduler($"Closed.{e}"));
            _server.Received.Subscribe(e => Log.AddOnScheduler($"Receive (from {e.From.Client.RemoteEndPoint}).\n{e.Data.ToDumpString()}"));

            Listen.Subscribe(_ =>
            {
                try
                {
                    _server.Listen(Address.Value, Port.Value);
                    Log.Add($"Listen {Address.Value} : {Port.Value}");
                }
                catch (Exception exp)
                {
                    Log.Add($"Listen error.{exp.Message}");
                }
            });

            Close.Subscribe(_ => _server.Close());

            this.Broadcast.Subscribe(data => _server.Broadcast(data.ToSendData()));
        }
コード例 #10
0
        public async Task MultipleModifiedListeners()
        {
            MockListener.Reset();
            MockListener2.Reset();
            ObjectListener.Reset();

            await Listen.ModifiedAsync(ent, ent2, ctx);

            Assert.IsFalse(MockListener.WasOnCreatedCalled);
            Assert.IsFalse(MockListener.WasOnCreationValidationFailedCalled);
            Assert.IsTrue(MockListener.WasOnModifiedCalled);
            Assert.IsFalse(MockListener.WasOnModificationFailedCalled);
            Assert.IsFalse(MockListener.WasOnDeletedCalled);
            Assert.IsFalse(MockListener.WasOnDeletionFailedCalled);

            Assert.IsFalse(MockListener2.WasOnCreatedCalled);
            Assert.IsFalse(MockListener2.WasOnCreationValidationFailedCalled);
            Assert.IsTrue(MockListener2.WasOnModifiedCalled);
            Assert.IsFalse(MockListener2.WasOnModificationFailedCalled);
            Assert.IsFalse(MockListener2.WasOnDeletedCalled);
            Assert.IsFalse(MockListener2.WasOnDeletionFailedCalled);

            Assert.IsFalse(ObjectListener.WasOnCreatedCalled);
            Assert.IsFalse(ObjectListener.WasOnCreationValidationFailedCalled);
            Assert.IsTrue(ObjectListener.WasOnModifiedCalled);
            Assert.IsFalse(ObjectListener.WasOnModificationFailedCalled);
            Assert.IsFalse(ObjectListener.WasOnDeletedCalled);
            Assert.IsFalse(ObjectListener.WasOnDeletionFailedCalled);

            Assert.IsTrue(MockListener.EntitesWereNotTheSameOnCalling.HasValue && MockListener.EntitesWereNotTheSameOnCalling.Value);
            Assert.IsTrue(MockListener2.EntitesWereNotTheSameOnCalling.HasValue && MockListener2.EntitesWereNotTheSameOnCalling.Value);
            Assert.IsTrue(ObjectListener.EntitesWereNotTheSameOnCalling.HasValue && ObjectListener.EntitesWereNotTheSameOnCalling.Value);
        }
コード例 #11
0
 public void Stop()
 {
     foreach (var Listen in Listeners.Values)
     {
         Listen.Stop();
     }
 }
コード例 #12
0
        public async Task SaveChangesAsync(IIdentity user)
        {
            var contextInfo = GetContextInfo(user);

            _dbcontext.ChangeTracker.DetectChanges();
            var entries = _dbcontext.ChangeTracker.Entries().ToList();

            foreach (var entityChange in _dbcontext.ChangeTracker.Entries())
            {
                var authResult = await AuthorizeEntityChangeAsync(user, entityChange);

                if (!authResult.HasSucceed)
                {
                    if (entityChange.State == EntityState.Modified)
                    {
                        await Listen.ModificationFailedAsync(CreateWithValues(entityChange.OriginalValues),
                                                             entityChange.Entity as T, GetContextInfo(user));
                    }
                    else if (entityChange.State == EntityState.Deleted)
                    {
                        await Listen.RemoveFailedAsync(CreateWithValues(entityChange.OriginalValues), contextInfo);
                    }

                    throw new AuthorizationFailedException(authResult);
                }
            }

            // Added should be updated after saving changes for get the ID of the newly created entity
            var added    = entries.Where(a => a.State == EntityState.Added).Select(a => a.Entity).ToList();
            var modified = entries.Where(a => a.State == EntityState.Modified).Select(SelectBoth).ToList();
            var removed  = entries.Where(a => a.State == EntityState.Deleted).Select(a => SelectOriginal(a)).ToList();

            if (removed.Any())
            {
                if (GetLogicalDeleteProperty(_type) == null)
                {
                    if (!IgnoreLogicalDeleteError &&
                        removed.Any(entry => GetLogicalDeleteProperty(entry.GetType()) != null))
                    {
                        throw new LogicalSecurityRiskException(
                                  $"There are derived types in the deleted entries which have LogicalDeleteAttribute, but the base type does not use logical delete.");
                    }
                }
                else
                {
                    var logicalRemoved = entries.Where(a => a.State == EntityState.Deleted).ToList();
                    logicalRemoved.ForEach(entry =>
                    {
                        entry.Reload();
                        entry.State = EntityState.Modified;
                        entry.Property(GetLogicalDeleteProperty(_type).Name).CurrentValue = true;
                    });
                }
            }

            await _dbcontext.SaveChangesAsync();

            await DistributeToListenersAsync(added, contextInfo, modified, removed);
        }
コード例 #13
0
        public static float BerechneErgebnis(IEnumerable <string> eingaben)
        {
            var initialStack = Listen.Empty <float>();

            return(eingaben
                   .Aggregate(initialStack, EingabeVerarbeiten)
                   .Head());
        }
コード例 #14
0
        public async void HentDataFromDiskAsync()
        {
            this.Listen.Clear();
            StorageFile file = await localfolder.GetFileAsync(filnavn);

            string jsonText = await FileIO.ReadTextAsync(file);

            Listen.InsertJson(jsonText);
        }
コード例 #15
0
        public void Listen_ShouldSetEndPoint()
        {
            testWorld.Listen();
            Listen          listen   = testWorld.World.EntityManager.CreateEntityQuery(typeof(Listen)).GetSingleton <Listen>();
            NetworkEndPoint endPoint =
                NetworkEndPoint.Parse(serverOptions.Address, serverOptions.Port, serverOptions.NetworkFamily);

            Assert.AreEqual(listen.EndPoint, endPoint);
        }
コード例 #16
0
        private void button1_Click(object sender, EventArgs e)
        {
            Listen a = new Listen();
            var    s = a.output();

            Console.Out.Write(1);
            MessageBox.Show(s);
            // AnalyzeSocket.query();
        }
コード例 #17
0
 // Her laves først en midlertidig klasse, og så laves eleven, så man kan slette den elev man vælger under listen
 // så ikke den sletter den senest tilføjede. Derfor laves den midlertidige klasse så hvert nyt objekt sin egen værdi
 public void addnyelev()
 {
     Model.klasseinfo TempKlasseinfo = new Model.klasseinfo();
     TempKlasseinfo.ForNavn   = Nyelev.ForNavn;
     TempKlasseinfo.EfterNavn = Nyelev.EfterNavn;
     TempKlasseinfo.Email     = Nyelev.Email;
     TempKlasseinfo.GitNavn   = Nyelev.GitNavn;
     TempKlasseinfo.MobilNr   = Nyelev.MobilNr;
     Listen.Add(TempKlasseinfo);
 }
コード例 #18
0
    void Start()
    {
        Listen listen = new Listen();

        Debug.Log("i was started");
        listen.Register();
        //EventName += listen.OnEvent;
        OnEventName();
        StartCoroutine(Loop());
    }
コード例 #19
0
 private void dccSink_Listen()
 {
     if (Listen != null)
     {
         foreach (ListenHandler lh in Listen.GetInvocationList())
         {
             lh();
         }
     }
 }
コード例 #20
0
        //public RelayCommand AddElevCommand { get; set; }

        public void AddNyElev()
        {
            Model.KlasseInfo TempKlasseInfo = new Model.KlasseInfo();
            TempKlasseInfo.Fornavn   = nyElev.Fornavn;
            TempKlasseInfo.Efternavn = nyElev.Efternavn;
            TempKlasseInfo.Email     = nyElev.Email;
            TempKlasseInfo.GitNavn   = nyElev.GitNavn;
            TempKlasseInfo.MobilNr   = nyElev.MobilNr;
            Listen.Add(TempKlasseInfo);
        }
コード例 #21
0
ファイル: IDccMan.cs プロジェクト: jerry0914/usi_shd1_tools
        public int OnLogListen()
        {
            foreach (ListenHandler lh in Listen.GetInvocationList())
            {
                lh();
            }

            System.Diagnostics.Debug.WriteLine("Listen");
            return(0);
        }
コード例 #22
0
ファイル: Listen.aspx.cs プロジェクト: zhaoyingju/ccflow
        void btn_Del_Click(object sender, EventArgs e)
        {
            Listen li = new Listen();

            if (this.RefOID != 0)
            {
                li.OID = this.RefOID;
                li.Delete();
            }
            this.Response.Redirect("Listen.aspx?FK_Node=" + this.FK_Node + "&DoType=New&RefOID=0", true);
        }
コード例 #23
0
        void btn_Click(object sender, EventArgs e)
        {
            Listen li = new Listen();

            if (this.RefOID != 0)
            {
                li.OID = this.RefOID;
                li.Retrieve();
            }

            li     = this.Pub1.Copy(li) as Listen;
            li.OID = this.RefOID;

            BP.WF.Node  nd   = new BP.WF.Node(this.FK_Node);
            BP.WF.Nodes nds  = new BP.WF.Nodes(nd.FK_Flow);
            string      strs = "";

            foreach (BP.WF.Node en in nds)
            {
                if (en.NodeID == this.FK_Node)
                {
                    continue;
                }

                CheckBox cb = this.Pub1.GetCBByID("CB_" + en.NodeID);
                if (cb.Checked)
                {
                    strs += "@" + en.NodeID;
                }
            }

            li.Nodes   = strs;
            li.FK_Node = this.FK_Node;

            if (li.OID == 0)
            {
                li.Insert();
            }
            else
            {
                li.Update();
            }

            var btn = (LinkBtn)sender;

            if (btn.ID == NamesOfBtn.Save)
            {
                this.Response.Redirect("Listen.aspx?FK_Node=" + this.FK_Node + "&DoType=New&RefOID=" + li.OID, true);
            }
            else
            {
                this.Response.Redirect("Listen.aspx?FK_Node=" + this.FK_Node + "&DoType=New&RefOID=0", true);
            }
        }
コード例 #24
0
        /// <summary>
        /// Initialize plugin api calls listen server
        /// </summary>
        /// <returns>Plugin api calls server</returns>
        public Server InitServer()
        {
            var server = new Server();

            server.Services.Add(Plugin.BindService(new ChatBotPlugin()));
            var listenHost = Listen.Split(':')[0];
            var listenPort = int.Parse(Listen.Split(':')[1]);

            server.Ports.Add(new ServerPort(listenHost, listenPort, ServerCredentials.Insecure));
            server.Start();
            return(server);
        }
コード例 #25
0
        public async Task RemoveFailed()
        {
            MockListener.Reset();
            await Listen.RemoveFailedAsync(ent, ctx);

            Assert.IsFalse(MockListener.WasOnCreatedCalled);
            Assert.IsFalse(MockListener.WasOnCreationValidationFailedCalled);
            Assert.IsFalse(MockListener.WasOnModifiedCalled);
            Assert.IsFalse(MockListener.WasOnModificationFailedCalled);
            Assert.IsFalse(MockListener.WasOnDeletedCalled);
            Assert.IsTrue(MockListener.WasOnDeletionFailedCalled);
        }
コード例 #26
0
        // public RelayCommand addnyelevcommand { get; set; }
        #endregion

        #region Hent data fra disken
        public async void HentDataFraDiskAsync()
        {
            // her har jeg lavet en metode til at finde og loade data fra disken
            // Først clear den listen så derefter henter den det data den kan finde under fil navnet
            this.Listen.Clear();

            StorageFile file = await localfolder.GetFileAsync(filnavn);

            string jsonText = await FileIO.ReadTextAsync(file);

            Listen.IndsætJson(jsonText);
        }
コード例 #27
0
        public async Task SubscribeToChannel(Listen listen)
        {
            log.Info("subscribing to rabbit mq channel");

            var exchange = ConfigurationManager.AppSettings["Rabbit::Exchange"];
            var host     = ConfigurationManager.AppSettings["Rabbit::Host"];
            var user     = ConfigurationManager.AppSettings["Rabbit::User"];
            var pwd      = ConfigurationManager.AppSettings["Rabbit::Pwd"];

            var factory = new ConnectionFactory
            {
                HostName = host,
                UserName = user,
                Password = pwd,
                AutomaticRecoveryEnabled = true
            };

            using (var connection = factory.CreateConnection())
            {
                using (var channel = connection.CreateModel())
                {
                    channel.ExchangeDeclare(exchange, "direct");
                    var qName = channel.QueueDeclare(listen.Queue.ToString(), true, false, false, null);

                    channel.QueueBind(qName, exchange, listen.RoutingKey.ToString());

                    var consumer = new QueueingBasicConsumer(channel);
                    channel.BasicConsume(qName, true, consumer);

                    HookPipeline.RabbitChannel = channel;
                    HookPipeline.HttpClient    = new HttpClient();

                    log.Info("subscription to rabbit mq channel complete");
                    log.Info("initialization complete. billing is up and running");

                    while (true)
                    {
                        log.Debug("waiting for a job");
                        var obj = consumer.Queue.Dequeue();

                        if (obj == null)
                        {
                            return;
                        }
                        var body = obj.Body;

                        var job = Encoding.UTF8.GetString(body).FromJson <Job>();
                        await HookPipeline.Invoke(job);
                    }
                }
            }
        }
コード例 #28
0
        public void OnTlfListenChanged(object sender, EventArgs e)
        {
            Listen listen = _StateManager.Tlf.Listen;

            if (!string.IsNullOrEmpty(listen.PreviusStateDescription))
            {
                _MsgLB.Items.Remove(listen.PreviusStateDescription);
            }
            if (!string.IsNullOrEmpty(listen.StateDescription))
            {
                _MsgLB.Items.Add(listen.StateDescription);
            }
        }
コード例 #29
0
        private async Task <AuthorizationResult> AuthorizeAddAsync(IIdentity usr, T newEntity)
        {
            var authResult = (await Authorize.CreateAsync(newEntity, GetContextInfo(usr))).CreateAggregateResult();

            if (!authResult.HasSucceed)
            {
                await Listen.CreateFailedAsync(newEntity, GetContextInfo(usr));

                _dbcontext.Entry(newEntity).State = EntityState.Detached;
            }

            return(authResult);
        }
コード例 #30
0
        static async Task Main(string[] args)
        {
            Console.WriteLine("Program Started..");

            // First think we need to do is make sure the mic is working and on
            // for the duration of the app running

            var listen = new Listen();

            while (true)
            {
                var speech = new MainClass();
                speech.Main();
            }
        }
コード例 #31
0
ファイル: Dal.cs プロジェクト: aluhadora/ShipItBack
        private static void SaveListen(Listen listen)
        {
            using (var connection = OpenConnection())
            {
                using (var cmd = connection.SqlProc(@"dbo.Usersong_Save_Insert"))
                {
                    cmd.CommandTimeout = ContextFactory.CommandTimeout;

                    cmd.AddParam("SongId", listen.SongId);
                    cmd.AddParam("UserId", listen.UserId);
                    cmd.AddParam("PlayedOn", listen.PlayedOn);

                    cmd.ExecuteNonQuery();
                }
            }
        }
コード例 #32
0
ファイル: Sius.cs プロジェクト: ZacharyRead/sius-biller
        static void Main(string[] args)
        {
            try
            {
                // Add to the console
                Console.Title = "Sius";
                Console.WriteLine("Sius");
                Console.Write("Press any key to exit ..." + Environment.NewLine);

                Time = DateTime.Now;

                // Check if we are logging
                if (!string.IsNullOrEmpty(SiusConf.GetSetting.String("logging")))
                    SiusLog.Logging = true;

                // Check if we want to clear the log before starting
                if (SiusConf.GetSetting.Boolean("clearlog"))
                    SiusLog.ClearLogFile();

                // Create the SQLite database and tables
                SQLite.Connect();

                // Log that Sius has successfully started
                SiusLog.Log(SiusLog.INFORMATION, "server","Sius successfully started.");

                // Initialize the Transmission Control Protocol (TCP) connection
                Listen tcp = new Listen();
                tcp.StartListening();

                // Start the Ping timer
                System.Timers.Timer SendPing = new System.Timers.Timer();
                SendPing.Elapsed += new ElapsedEventHandler(Protocol.Ping.OnTimedEvent);

                if (SiusConf.GetSetting.Integer("ping") >= 10)
                    SendPing.Interval = SiusConf.GetSetting.Integer("ping") * 1000;
                else
                    SendPing.Interval = 150000; // 150 seconds

                SendPing.Enabled = true;
                SendPing.Start();

                // Start the Scorereset timer
                System.Timers.Timer Scorereset = new System.Timers.Timer();
                Scorereset.Elapsed += new ElapsedEventHandler(Protocol.Scorereset.OnTimedEvent);

                if (SiusConf.GetSetting.Integer("scorereset") >= 1)
                    Scorereset.Interval = SiusConf.GetSetting.Integer("scorereset") * 3600000;
                else
                    Scorereset.Interval = 1209600000; // 2 weeks

                Scorereset.Enabled = true;
                Scorereset.Start();

                // Wait until we're told to exit the program
                while (Running == true)
                {
                    // press any key to exit
                    Console.ReadKey(true);
                    Running = false;
                    SendPing.Close();
                    Scorereset.Close();
                }

                // Cleanup and end all TCP connections
                Sius.Connected = false;
                SiusLog.Log(SiusLog.INFORMATION, "server","Exiting");
                tcp.RequestStop();

                // Append a line to the log to mark the end of a run.
                SiusLog.DirectLogToFile("-----------------------------------------------------");
            }
            catch (Exception e)
            {
                // Log any unexpected errors
                SiusLog.Log(SiusLog.ERROR, "server", "Error: " + e.StackTrace);
            }
        }