Ejemplo n.º 1
0
        public static void SendReportMail(string attachmentPath, ContractUser user)
        {
            dynamic email = new Email("ReportMail");

            email.to   = user.Email;
            email.from = applicationEmail;

            email.Attach(new Attachment(attachmentPath));
            email.Send();
        }
Ejemplo n.º 2
0
        public static void SendReportMail(List<string> attachmentPaths, ContractUser user)
        {
            dynamic email = new Email("ReportMail");
            email.to = user.Email;
            email.from = applicationEmail;

            foreach(string path in attachmentPaths)
            {
                email.Attach(new Attachment(path));
            }
            email.Send();
        }
Ejemplo n.º 3
0
        public static void OnDispatcherSet(object source, EventArgs e)
        {
            MyDbContext db = new MyDbContext();

            Contract tempContract = (Contract)source;

            //The dispatcher has to be loaded here because the nav property is not set at this point yet
            ContractUser dispatcher = db.Users.Find(tempContract.DispatcherId);

            //Notify Dispatcher
            dynamic email = new Email("DispatcherMail");

            email.to = dispatcher.Email;

            email.from       = applicationEmail;
            email.contractId = tempContract.Id;

            email.Send();
            System.Diagnostics.Debug.WriteLine("Email wurde abgeschickt");
        }
Ejemplo n.º 4
0
        protected override void Seed(WebApplication1.Models.MyDbContext context)
        {
            var store   = new RoleStore <IdentityRole>(context);
            var manager = new RoleManager <IdentityRole>(store);

            if (!context.Roles.Any(r => r.Name == "Administrator"))
            {
                manager.Create(new IdentityRole {
                    Name = "Administrator"
                });
            }
            if (!context.Roles.Any(r => r.Name == "Dispatcher"))
            {
                manager.Create(new IdentityRole {
                    Name = "Dispatcher"
                });
            }
            if (!context.Roles.Any(r => r.Name == "Coordinator"))
            {
                manager.Create(new IdentityRole {
                    Name = "Coordinator"
                });
            }


            //Ober: Fixed initialized User with Password-Hash
            //var hasher = new PasswordHasher();
            string password = "******";
            //string hashedPassword = hasher.HashPassword(password);

            ContractUser admin, coord1, coord2, dis1, dis2;

            var userStore   = new UserStore <ContractUser>(context);
            var userManager = new UserManager <ContractUser>(userStore); //UserMaager hashes passwords and updates Database with Create-Method.

            context.Users.AddOrUpdate(
                u => u.UserName,
                coord1 = new ContractUser {
                Email = "*****@*****.**", UserName = "******"
            },
                coord2 = new ContractUser {
                Email = "*****@*****.**", UserName = "******"
            },
                dis1 = new ContractUser {
                Email = "*****@*****.**", UserName = "******"
            },
                dis2 = new ContractUser {
                Email = "*****@*****.**", UserName = "******"
            }
                );
            admin = new ContractUser {
                Email = "*****@*****.**", UserName = "******"
            };

            userManager.Create(admin, password);
            //Not possible for Users with Space in Username

            /*userManager.Create(coord1, password);
             * userManager.Create(coord2, password);
             * userManager.Create(dis1, password);
             * userManager.Create(dis2, password);*/

            context.SaveChanges();
            //Ober:end

            userManager.AddToRole(admin.Id, "Administrator");
            userManager.AddToRole(coord1.Id, "Coordinator");
            userManager.AddToRole(coord2.Id, "Coordinator");
            userManager.AddToRole(dis1.Id, "Dispatcher");
            userManager.AddToRole(dis2.Id, "Dispatcher");

            context.SaveChanges();

            context.Mandants.AddOrUpdate(
                p => p.MandantName,
                new Mandant {
                MandantName = "Augsburg", BuchungsKreis = 11
            },
                new Mandant {
                MandantName = "Günzburg", BuchungsKreis = 21
            },
                new Mandant {
                MandantName = "Donauwörth", BuchungsKreis = 24
            },
                new Mandant {
                MandantName = "Kaufbeuren", BuchungsKreis = 31
            },
                new Mandant {
                MandantName = "Kempten", BuchungsKreis = 33
            },
                new Mandant {
                MandantName = "Memmingen", BuchungsKreis = 35
            },
                new Mandant {
                MandantName = "Lindau", BuchungsKreis = 37
            },
                new Mandant {
                MandantName = "Obergünzburg", BuchungsKreis = 39
            },
                new Mandant {
                MandantName = "Zentralverwaltung", BuchungsKreis = 51
            },
                new Mandant {
                MandantName = "DLZ", BuchungsKreis = 61
            },
                new Mandant {
                MandantName = "W+F Zusmarshausen", BuchungsKreis = 81
            },
                new Mandant {
                MandantName = "W+F Günzburg", BuchungsKreis = 82
            },
                new Mandant {
                MandantName = "W+F Kaufbeuren", BuchungsKreis = 83
            }
                );
            context.SaveChanges();

            context.MU_Relations.AddOrUpdate(
                p => p.MandantID,
                new MU_Relation {
                UserID = context.Users.Single(i => i.UserName == "Carl Maier").Id, MandantID = context.Mandants.Single(i => i.MandantName == "DLZ").Id
            },
                new MU_Relation {
                UserID = context.Users.Single(i => i.UserName == "Carina Krumbold").Id, MandantID = context.Mandants.Single(i => i.MandantName == "Augsburg").Id
            }
                );
            context.SaveChanges();

            context.Departments.AddOrUpdate(
                p => p.DepartmentName,
                new Department {
                DepartmentName = "Apotheke", Dispatcher = context.Users.Single(i => i.UserName == "Daniel Aminati"), StvDispatcher = context.Users.Single(i => i.UserName == "Dixi Aiman"), Mandant = context.Mandants.Single(i => i.MandantName == "DLZ")
            },
                new Department {
                DepartmentName = "Bertriebstechnik", Dispatcher = context.Users.Single(i => i.UserName == "Daniel Aminati"), StvDispatcher = context.Users.Single(i => i.UserName == "Dixi Aiman"), Mandant = context.Mandants.Single(i => i.MandantName == "DLZ")
            },
                new Department {
                DepartmentName = "Bertriebstechnik Energieversorgung", Dispatcher = context.Users.Single(i => i.UserName == "Daniel Aminati"), StvDispatcher = context.Users.Single(i => i.UserName == "Dixi Aiman"), Mandant = context.Mandants.Single(i => i.MandantName == "DLZ")
            },
                new Department {
                DepartmentName = "Bertriebstechnik Leitung", Dispatcher = context.Users.Single(i => i.UserName == "Daniel Aminati"), StvDispatcher = context.Users.Single(i => i.UserName == "Dixi Aiman"), Mandant = context.Mandants.Single(i => i.BuchungsKreis == 61)
            },
                new Department {
                DepartmentName = "Bertriebstechnik Mechatronik", Dispatcher = context.Users.Single(i => i.UserName == "Daniel Aminati"), StvDispatcher = context.Users.Single(i => i.UserName == "Dixi Aiman"), Mandant = context.Mandants.Single(i => i.BuchungsKreis == 61)
            },
                new Department {
                DepartmentName = "Betriebstechnik Sekretariat", Dispatcher = context.Users.Single(i => i.UserName == "Daniel Aminati"), StvDispatcher = context.Users.Single(i => i.UserName == "Dixi Aiman"), Mandant = context.Mandants.Single(i => i.BuchungsKreis == 61)
            },
                new Department {
                DepartmentName = "DLZ Leitung", Dispatcher = context.Users.Single(i => i.UserName == "Daniel Aminati"), StvDispatcher = context.Users.Single(i => i.UserName == "Dixi Aiman"), Mandant = context.Mandants.Single(i => i.BuchungsKreis == 61)
            },
                //new Department { DepartmentName = "EDV/IT", Dispatcher = null, StvDispatcher = null, Mandant = context.Mandants.Single(i => i.BuchungsKreis == 61) },

                new Department {
                DepartmentName = "Haustechnik BKH Kempten", Dispatcher = context.Users.Single(i => i.UserName == "Daniel Aminati"), StvDispatcher = context.Users.Single(i => i.UserName == "Dixi Aiman"), Mandant = context.Mandants.Single(i => i.MandantName == "Kempten")
            },
                new Department {
                DepartmentName = "Regionalleitung Mitte", Dispatcher = context.Users.Single(i => i.UserName == "Daniel Aminati"), StvDispatcher = context.Users.Single(i => i.UserName == "Dixi Aiman"), Mandant = context.Mandants.Single(i => i.MandantName == "Augsburg")
            }


                );
            context.SaveChanges();

            context.ContractKinds.AddOrUpdate(
                p => p.Description,
                new ContractKind {
                Description = "Kaufverträge"
            },
                new ContractKind {
                Description = "Mietverträge"
            },
                new ContractKind {
                Description = "Leasingverträge"
            },
                new ContractKind {
                Description = "Dienstleistungsvertrag"
            },
                new ContractKind {
                Description = "Kooperationsvereinbarungen"
            },
                new ContractKind {
                Description = "Konsiliarverträge"
            }
                );

            context.ContractStatuses.AddOrUpdate(
                p => p.Description,
                new ContractStatus {
                Description = "incomplete"
            },
                new ContractStatus {
                Description = "activ"
            },
                new ContractStatus {
                Description = "repealed"
            },
                new ContractStatus {
                Description = "closed"
            },
                new ContractStatus {
                Description = "deleted"
            }
                );

            context.ContractTypes.AddOrUpdate(
                p => p.Description,
                new ContractType {
                Description = "IT-Verträge"
            },
                new ContractType {
                Description = "Telekommunikation"
            },
                new ContractType {
                Description = "Liegenschaftsverwaltung"
            },
                new ContractType {
                Description = "Fahrzeuge"
            },
                new ContractType {
                Description = "Versicherungen"
            }
                );


            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data. E.g.
            //
            //    context.People.AddOrUpdate(
            //      p => p.FullName,
            //      new Person { FullName = "Andrew Peters" },
            //      new Person { FullName = "Brice Lambson" },
            //      new Person { FullName = "Rowan Miller" }
            //    );
            //
        }