Exemple #1
0
        private async Task CallHook(String hookName, AppUser user)
        {
            var hooks = ConfigurationManager.AppSettings["accountHooks"];

            if (hooks == null || hooks != "enable")
            {
                return;
            }

            var rm = await RequestModel.CreateFromUrl(_host, RequestUrlKind.Simple, "_hooks");

            if (rm == null)
            {
                return;
            }
            var cmd = rm.GetCommand(hookName);

            if (cmd == null)
            {
                return;
            }
            var dbEvent = new DbEvent()
            {
                Source  = _host.CatalogDataSource,
                ItemId  = user.Id,
                Command = hookName,
                Path    = "/_hooks"
            };

            /* add record to a2sys.DbEvents */
            await _dbContext.ExecuteAsync <DbEvent>(_host.CatalogDataSource, "a2sys.[DbEvent.Add]", dbEvent);

            /* and handle it */
            await _host.ProcessDbEvents(_dbContext, _host.CatalogDataSource);
        }
Exemple #2
0
 public EventResult(DbEvent dbEvent)
 {
     EventName = dbEvent.EventName;
     User      = dbEvent.User;
     TimeStamp = dbEvent.TimeStamp;
     Data      = dbEvent.Data;
 }
        public IActionResult Post([FromBody] EventCreateModel request)
        {
            var api = Api.INSTANCE;

            api.DemandModerator(Request);

            using (var da = api.DAFactory.Get())
            {
                DbEventType type;
                try
                {
                    type = Enum.Parse <DbEventType>(request.type);
                }
                catch
                {
                    return(BadRequest("Event type must be one of:" + string.Join(", ", Enum.GetNames(typeof(DbEventType)))));
                }
                var model = new DbEvent()
                {
                    title            = request.title,
                    description      = request.description,
                    start_day        = request.start_day,
                    end_day          = request.end_day,
                    type             = type,
                    value            = request.value,
                    value2           = request.value2,
                    mail_subject     = request.mail_subject,
                    mail_message     = request.mail_message,
                    mail_sender      = request.mail_sender,
                    mail_sender_name = request.mail_sender_name
                };
                return(new JsonResult(new { id = da.Events.Add(model) }));
            }
        }
Exemple #4
0
        public void Setup()
        {
            myEvent = new Event
            {
                Title            = "This is a Test Event",
                Description      = "Thsi is the description of the test event",
                Gate             = "FB22",
                GateOpens        = new DateTime(2018, 11, 20, 12, 00, 00),
                StartTime        = new DateTime(2018, 11, 20, 12, 15, 00),
                Date             = DateTime.Now.Date,
                AvailableTickets = 20,
                TicketPrice      = 10
            };



            eventDb = new DbEvent();
            orderDb = new DbOrder();
            string customerId = orderDb.GetRandomUser();

            myOrder = new Order
            {
                Quantity   = 3,
                Date       = DateTime.Now.Date,
                CustomerId = customerId
            };

            myOrder.TotalPrice = myOrder.Quantity * myEvent.TicketPrice;
        }
Exemple #5
0
 public void CleanUp()
 {
     db.Delete(IdOfMyEvent);
     myEvent     = null;
     db          = null;
     IdOfMyEvent = 0;
 }
Exemple #6
0
        public void UserJoinedEvent(IVoltronSession session, DbEvent evt, bool alreadyOnline)
        {
            try
            {
                var needsParticipation = evt.mail_message != null || ParticipationType(evt.type);
                if (!needsParticipation)
                {
                    return;
                }
                using (var db = DA.Get)
                {
                    var user          = session.UserId;
                    var participation = db.Events.TryParticipate(new DbEventParticipation()
                    {
                        event_id = evt.event_id, user_id = user
                    });
                    if (participation)
                    {
                        if (evt.mail_message != null)
                        {
                            Mail.SendEmail(new Files.Formats.tsodata.MessageItem()
                            {
                                Subject    = evt.mail_subject ?? "Event",
                                Body       = evt.mail_message,
                                SenderID   = (uint)(evt.mail_sender ?? (int.MinValue)),
                                SenderName = evt.mail_sender_name ?? "The Sims Online",
                                TargetID   = session.AvatarId,
                                Type       = 4,
                                Subtype    = 0
                            }, alreadyOnline);
                        }
                        switch (evt.type)
                        {
                        case DbEventType.free_object:
                            for (int i = 0; i < Math.Max(1, evt.value2); i++)
                            {
                                db.Objects.Create(new Database.DA.Objects.DbObject()
                                {
                                    type         = (uint)evt.value,
                                    shard_id     = Context.ShardId,
                                    owner_id     = session.AvatarId,
                                    lot_id       = null, //to inventory
                                    dyn_obj_name = ""
                                });
                            }
                            break;

                        case DbEventType.free_money:
                            db.Avatars.Transaction(uint.MaxValue, session.AvatarId, evt.value, 0);
                            break;
                        }
                    }
                }
            } catch
            {
            }
        }
Exemple #7
0
        public void create_db_event_from_event()
        {
            var id      = Guid.Parse("A761A9C5-DC6A-4CF2-A75C-228D64553BA7");
            var dbEvent = new DbEvent(new SqlTestEvent(id, 1, "ESSAI"), new DomainEventJsonEventSerializer(), new FakeEventStamping());

            dbEvent.AggregateId.Should().Be(id);
            dbEvent.EventName.Should().Be(nameof(SqlTestEvent));
            dbEvent.Sequence.Should().Be(1);
            dbEvent.Data.Should().Be(@"{""$type"":""SqlTestEvent"",""Label"":""ESSAI"",""AggregateId"":""a761a9c5-dc6a-4cf2-a75c-228d64553ba7"",""Sequence"":1}");
            dbEvent.TimeStamp.Should().BeBefore(DateTime.Now);
        }
Exemple #8
0
 public void CleanUp()
 {
     dbSeat.Delete(IdOfSeat);
     dbEvent.Delete(IdOfMyEvent);
     myEvent     = null;
     mySeat      = null;
     dbSeat      = null;
     dbEvent     = null;
     IdOfMyEvent = 0;
     IdOfSeat    = 0;
 }
        public void CreateDatabase(Dictionary <string, string> providers)
        {
            var set = _db.GetCollection <Settings>("Settings");

            _db.GetCollection <Manga>("Manga");
            _db.GetCollection <Manga>("History");
            _db.GetCollection <Manga>("NewManga");
            var ver = _db.GetCollection <Versions>("Versions");

            ver.Insert(new Versions {
                Name    = "db",
                Version = DatabaseVersion
            });

            foreach (var sites in providers)
            {
                set.Insert(new Settings {
                    Setting = sites.Key,
                    Link    = sites.Value,
                    Active  = 0,
                    Created = DateTime.Now
                });
            }
            if (set.FindOne(s => s.Setting == "Refresh Time") == null)
            {
                set.Insert(new Settings {
                    Setting = "Refresh Time",
                    Link    = "/",
                    Active  = 300,
                    Created = DateTime.Now
                });
            }
            if (set.FindOne(s => s.Setting == "Open Links") == null)
            {
                set.Insert(new Settings {
                    Setting = "Open Links",
                    Link    = "/",
                    Active  = 300,
                    Created = DateTime.Now
                });
            }
            if (set.FindOne(s => s.Setting == "Batoto Rss") == null)
            {
                set.Insert(new Settings {
                    Setting = "Batoto Rss",
                    Link    = "/",
                    Active  = 0,
                    Created = DateTime.Now
                });
            }
            DbEvent?.Invoke(null, DatabaseEnum.Create);
        }
Exemple #10
0
        public void Setup()
        {
            myEvent = new Event
            {
                Title            = "This is a Test Event",
                Description      = "Thsi is the description of the test event",
                Gate             = "FB22",
                GateOpens        = new DateTime(2018, 11, 20, 12, 00, 00),
                StartTime        = new DateTime(2018, 11, 20, 12, 15, 00),
                Date             = DateTime.Now.Date,
                AvailableTickets = 20,
                TicketPrice      = 10
            };

            db = new DbEvent();
        }
        public void AddNewEvent(Event newEvent)
        {
            var connection = this.CreateNewConnection();

            var dbEvent = new DbEvent
            {
                Name     = newEvent.Name,
                Visitors = newEvent.Visitors.Select(v => new DbPlayerInEvent
                {
                    Name      = v.Name,
                    CanBeHost = v.CanBeHost,
                    IsVip     = v.IsVip,
                    Number    = v.Number
                }).ToList()
            };

            connection.InsertWithChildren(dbEvent);
        }
        public async Task ProcessNewhireEvent(string eventId, string personName, string personId, string personNumber)
        {
            Console.WriteLine($"Processing new hire event: EventId: {eventId}, PersonName: {personName}, PersonId: {personId}, PersonNumber: {personNumber}");

            var employeeToAdd = new DbEmployee()
            {
                PersonName   = personName,
                PersonId     = personId,
                PersonNumber = personNumber
            };

            var eventToAdd = new DbEvent()
            {
                UniqueEventId = eventId
            };

            try
            {
                //Default transaction level is read committed
                using (var trans = await _dbContext.Database.BeginTransactionAsync().ConfigureAwait(false))
                {
                    _dbContext.Employees.Add(employeeToAdd);
                    _dbContext.Events.Add(eventToAdd);

                    //Read Committed transaction will fail once this event ID has been added already. ReadCommitted is the default transaction level
                    await _dbContext.SaveChangesAsync().ConfigureAwait(false);

                    await trans.CommitAsync().ConfigureAwait(false);
                }

                Console.WriteLine("Completed successfully :)");
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.InnerException.Message);
            }
        }
Exemple #13
0
        public async Task <ApiResult> Handle(InsertEvent request, CancellationToken cancellationToken)
        {
            var item = request.Item ?? throw new ArgumentNullException(nameof(request.Item));

            using (var scope = _unitOfWorkFactory.Create())
            {
                using (var db = _dbContextFactory.Create())
                {
                    DbEvent template = null;

                    if (item.TemplateUid != null)
                    {
                        template = await db.GetTable <DbEvent>()
                                   .Where(x => x.Uid == item.TemplateUid)
                                   .SingleOrDefaultAsync(cancellationToken);
                    }

                    var uid = Guid.NewGuid();

                    // todo: use number generation service
                    var id = db.SelectSequenceNextValue <long>("event_id_seq");

                    await db.GetTable <DbEvent>()
                    .Value(x => x.Uid, uid)
                    .Value(x => x.Id, id)
                    .Value(x => x.CompanyUid, request.CompanyUid)
                    .Value(x => x.IsTemplate, false)
                    .Value(x => x.TemplateUid, template?.Uid)
                    .Value(x => x.Name, template?.Name)
                    .Value(x => x.Description, template?.Description)
                    .Value(x => x.ConfigCode, template?.ConfigCode)                             // todo: remove
                    .Value(x => x.StatusCode, EventStatusCode.Draft)
                    .InsertAsync(cancellationToken);

                    if (template != null)
                    {
                        var invitations = await db.GetTable <DbInvitation>()
                                          .Where(x => x.EventUid == template.Uid)
                                          .Select(x => new DbInvitation
                        {
                            Uid             = Guid.NewGuid(),
                            EventUid        = uid,
                            StatusCode      = InvitationStatusCode.Draft,
                            CounterpartyUid = x.CounterpartyUid,
                            Email           = x.Email
                        }).ToListAsync(cancellationToken);

                        if (invitations.Count > 0)
                        {
                            await db.BulkCopyAsync(invitations, cancellationToken);
                        }
                    }

                    scope.Commit();

                    return(new ApiResult {
                        Uid = uid
                    });
                }
            }
        }
        public void UpdateDatabase(Versions dbv, Dictionary <string, string> providers)
        {
            var set = _db.GetCollection <Settings>("Settings");

            _db.GetCollection <Manga>("History");
            _db.GetCollection <Manga>("NewManga");
            _db.GetCollection <Manga>("Manga");
            var ver = _db.GetCollection <Versions>("Versions");

            var setting  = set.FindAll().Select(s => s.Setting).ToArray();
            var versions = ver.FindAll().Select(v => v.Name).ToArray();

            foreach (var defaultSetting in providers)
            {
                if (!setting.Contains(defaultSetting.Key))
                {
                    set.Insert(new Settings {
                        Setting = defaultSetting.Key,
                        Link    = defaultSetting.Value,
                        Active  = 0,
                        Created = DateTime.Now
                                  //OpenLinks = true
                    });
                }
            }
            if (!setting.Contains("Refresh Time"))
            {
                set.Insert(new Settings {
                    Setting = "Refresh Time",
                    Link    = "/",
                    Active  = 300,
                    Created = DateTime.Now
                });
            }
            if (!setting.Contains("Open Links"))
            {
                set.Insert(new Settings {
                    Setting = "Open Links",
                    Link    = "/",
                    Active  = 0,
                    Created = DateTime.Now
                });
            }
            if (!setting.Contains("Batoto Rss"))
            {
                set.Insert(new Settings {
                    Setting = "Batoto Rss",
                    Link    = "/",
                    Active  = 0,
                    Created = DateTime.Now
                });
            }
            foreach (var defaultver in _defaultVersions)
            {
                if (!versions.Contains(defaultver.Key))
                {
                    ver.Insert(new Versions {
                        Name    = defaultver.Key,
                        Version = defaultver.Key
                    });
                }
            }
            ver.Update(dbv);
            DbEvent?.Invoke(dbv, DatabaseEnum.Update);
        }
Exemple #15
0
 public Option(DbEvent dbEvent)
 {
     Name = dbEvent.Name;
 }
        public static void Main(string[] args)
        {
            

            Console.WriteLine("Emailservice has been started. Press any key to stop the service.");
            while (!Console.KeyAvailable)
            {
                // Empty the List for Mails to send
                scheduledMailList = new List<DbScheduledEmail>();
                eventList = new List<DbEvent>();

                Console.WriteLine("Looping...");
                using (SqlConnection connection = new SqlConnection())
                {
                    connection.ConnectionString =
                        "Server=MSCHIESERVER\\SQLEXPRESS;Database = lionsEventManagement;User Id = lionsEventManagement;Password = ******;Trusted_Connection = True;Persist Security Info = True;Integrated Security = False";

                    connection.Open();

                    // Get the scheduled email
                    SqlCommand commandMails = new SqlCommand("SELECT mail.EmailId, mail.EventId, mail.MemberId, mail.EmailText, mail.AnswerCode, mail.ParticipantId, mail.EmailSent, mail.ScheduledDate, member.MemberId, member.Email " +
                                                             "FROM dbo.ScheduledEmail AS mail " +
                                                             "INNER JOIN member " +
                                                             "ON (mail.MemberId = member.MemberId) " +
                                                             "WHERE EmailSent = 'false' " +
                                                             "AND (ScheduledDate < GETDATE())", connection);

                    SqlCommand commandMember = new SqlCommand("SELECT FirstName, LastName, Email, " +
                                                              "FROM dbo.Member", connection);

                    
                    // Get all scheduled mails which are not sent already and where the ScheduledDate is before now
                    using (SqlDataReader reader = commandMails.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            DbScheduledEmail dbMail = new DbScheduledEmail();
                            dbMail.EmailId = (int) reader[0];
                            dbMail.EventId = (int) reader[1];
                            dbMail.MemberId = (int) reader[2];
                            dbMail.Emailtext = (String) reader[3];
                            dbMail.Answercode = (String) reader[4];
                            dbMail.ParticipantId = (int) reader[5];
                            dbMail.EmailAddress = (String) reader[9];
                            
                            scheduledMailList.Add(dbMail);
                        }
                        
                        reader.Close();
                    }

                    // Get all event data for the events in the scheduled mails
                    foreach (var scheduledMail in scheduledMailList)
                    {
                        SqlCommand commandEvent = new SqlCommand("SELECT EventId, Title, Description, Date " +
                                                                 "FROM dbo.Event " +
                                                                 "WHERE EventId = "+scheduledMail.EventId, connection);

                        using (SqlDataReader reader = commandEvent.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                var e = new DbEvent();
                                e.EventId = (int) reader[0];
                                e.Title = (String) reader[1];
                                e.Description = (String) reader[2];
                                e.Date = (DateTime) reader[3];

                                // Do not add duplicate Events to the event list
                                var duplicate = false;
                                foreach (var dbEvent in eventList)
                                {
                                    if (dbEvent.EventId == e.EventId) duplicate = true;
                                }
                                if(!duplicate) eventList.Add(e);
                            }

                            reader.Close();
                        }

                        // Send the scheduledMail -----------------------------------------------------------------------------

                        // Get the Event
                        var emailEvent = eventList.SingleOrDefault(ev => ev.EventId == scheduledMail.EventId);
                        if(emailEvent == null) continue;

                        // Create Mail Links
                        var acceptLink = "<a href=\"http://*****:*****@googlemail.com", scheduledMail.EmailAddress);
                        SmtpClient client = new SmtpClient();
                        client.Port = 25;
                        client.DeliveryMethod = SmtpDeliveryMethod.Network;
                        client.UseDefaultCredentials = false;
                        client.Host = "localhost";
                        mail.IsBodyHtml = true;
                        mail.Subject = "lionsEventManagement - " + emailEvent.Title;
                        mail.Body = emailEvent.Description + "<br /> <br />" + acceptLink + "<br />" + acceptWithFamilyLink + "<br />" + declineLink + "<br />";

                        client.Send(mail);

                        // Update Database -> Mail sent
                        SqlCommand command = new SqlCommand("UPDATE ScheduledEmail SET EmailSent = 'true' " +
                                                            "WHERE EmailId = "+scheduledMail.EmailId, connection);

                        command.ExecuteReader();
                    }
                    
                }
                Thread.Sleep(1 * 60 * 1000);
            }
        }
Exemple #17
0
        public void LogString(DbEvent dbEvent, string identificator)
        {
            string logString = string.Format("{0}__{1}", dbEvent, identificator);

            logger.Info(logString);
        }