public AddGuaranteeService(IConfiguration configuration, IMikroportalUOW mikroportalContext, IHostingEnvironment hostingEnvironment, SpDataContext dbContext)
 {
     _dbContext          = dbContext;
     _configuration      = configuration;
     context             = mikroportalContext;
     _hostingEnvironment = hostingEnvironment;
 }
Exemple #2
0
        private static void ImportData(SpDataContext spContext, bool clear)
        {
            if (clear)
            {
                //delete all items.
                while (spContext.List <Department>().Take(100).DeleteAll())
                {
                    spContext.SaveChanges();
                }
                while (spContext.List <Employee>().Take(100).DeleteAll())
                {
                    spContext.SaveChanges();
                }
            }


            //var dep = spContext.List<Department>().GetEntries().First().Entity;
            //dep.Title = "Warner Brothers";

            var department = spContext.List <Department>().AddOrUpdate(new Department()
            {
                Title     = "Warner Brothers",
                ShortName = "WB"
            }, 1, true);

            spContext.SaveChanges();

            //department = spContext.List<Department>().AddOrUpdate(dep);
            //spContext.SaveChanges();

            var manager = spContext.List <Employee>().AddOrUpdate(new Employee()
            {
                FirstName = "Emma",
                LastName  = "Stone",
                Phone     = "8-1111-999",
                Email     = "*****@*****.**",
                Position  = EmployeePosition.Manager | EmployeePosition.Specialist
            }, 1, true);

            // save lookups
            spContext.SaveChanges();

            var specialist = new Employee()
            {
                FirstName = "Will",
                LastName  = "Smith",
                Phone     = "7-1143-222",
                Email     = "*****@*****.**",
                Position  = EmployeePosition.Specialist
            };

            specialist.DepartmentLookup.SetEntity(department.Entity);

            specialist.ManagerLookup.SetEntities(new[] { manager.Entity });

            var entry = spContext.List <Employee>().AddOrUpdate(specialist, 2, true, true);

            spContext.SaveChanges();
        }
 public CallCenterService(IConfiguration configuration, IMikroportalUOW mikroportalContext, IHostingEnvironment hostingEnvironment, SpDataContext dbContext, IHttpContextAccessor iHttpContextAccessor)
 {
     _dbContext           = dbContext;
     _configuration       = configuration;
     context              = mikroportalContext;
     _hostingEnvironment  = hostingEnvironment;
     _httpContextAccessor = iHttpContextAccessor;
 }
Exemple #4
0
        private static void Deploy(SpDataContext spContext)
        {
            Console.WriteLine("Deploying...");
            var model = spContext.CreateModel <EmployeeProvisionModel <SpDataContext>, SpDataContext, Employee>();

            model.Provision();
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Done!");
            Console.ResetColor();
        }
Exemple #5
0
        private static void Deploy(SpDataContext spContext, bool overwrite)
        {
            Console.WriteLine("Deploying...");
            var model = new EmployeeProvisionModel <SpDataContext>(spContext);

            //if (overwrite)
            {
                model.UnProvision(true, ProvisionLevel.Web);
            }
            model.Provision(overwrite, ProvisionLevel.Web);
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Done!");
            Console.ResetColor();
        }
Exemple #6
0
        static void Main(string[] args)
        {
            string siteUrl = ConfigurationManager.AppSettings["siteUrl"];

            while (string.IsNullOrWhiteSpace(siteUrl))
            {
                Console.WriteLine("Enter Site Url: ");
                siteUrl = Console.ReadLine();
            }

            string userLogin = ConfigurationManager.AppSettings["userLogin"];

            while (string.IsNullOrWhiteSpace(userLogin))
            {
                Console.WriteLine("Enter User Login: "******"userPassword"];

            using (var ctx = new SpDataContext(siteUrl))
            {
                var clientContext = ctx.Context;
                clientContext.Credentials = new SharePointOnlineCredentials(userLogin, string.IsNullOrWhiteSpace(userPassword) ? GetPassword() : ConvertToSecureString(userPassword));

                Deploy(ctx);

                ImportData(ctx, false);

                var departments = ctx.List <Department>().ToArray();

                var employees = departments.First().Employees.ToArray();

                if (!employees.Any())
                {
                    employees = ctx.List <Employee>().ToArray();
                }

                var managers = employees.First().Managers.ToArray();

                Debugger.Break();
                Console.ForegroundColor = ConsoleColor.Green;
                //Console.WriteLine("Done!");
                Console.ResetColor();
            }

            Console.ReadKey();
        }
Exemple #7
0
        private static void ImportData(SpDataContext spContext, bool clear)
        {
            if (clear)
            {
                //delete all items.
                while (spContext.List <Department>().Take(100).DeleteAll())
                {
                    spContext.SaveChanges();
                }
                while (spContext.List <Employee>().Take(100).DeleteAll())
                {
                    spContext.SaveChanges();
                }
            }

            spContext.List <Department>().AddOrUpdate(new Department()
            {
                Title = "Warner Brothers"
            }, 1);

            spContext.List <Employee>().AddOrUpdate(new Employee()
            {
                FirstName = "Emma",
                LastName  = "Stone",
                Phone     = "11-1111-111",
                Email     = "*****@*****.**",
                Position  = EmployeePosition.Manager
            }, 1);

            var specialist = new Employee()
            {
                FirstName    = "Will",
                LastName     = "Smith",
                Phone        = "11-1143-222",
                Email        = "*****@*****.**",
                Position     = EmployeePosition.Specialist,
                DepartmentId = 1
            };

            specialist.Manager.EntityId = 1;
            //specialist.Department.EntityId = 1;

            spContext.List <Employee>().AddOrUpdate(specialist, 2);

            spContext.SaveChanges();
        }
Exemple #8
0
 public AndonService(SpDataContext dbContext)
 {
     _dbContext = dbContext;
 }
Exemple #9
0
 public PP_OTService(IConfiguration configuration, IMikroportalUOW mikroportalContext, SpDataContext dbContext)
 {
     _dbContext     = dbContext;
     _configuration = configuration;
     context        = mikroportalContext;
 }
Exemple #10
0
        static void Main(string[] args)
        {
            string siteUrl = ConfigurationManager.AppSettings["siteUrl"];

            while (string.IsNullOrWhiteSpace(siteUrl))
            {
                Console.WriteLine("Enter Site Url: ");
                siteUrl = Console.ReadLine();
            }

            string userPassword = ConfigurationManager.AppSettings["userPassword"];


            Department[] departments;
            Employee[]   employees;

            //using (var context = new MyContext())
            //{
            //  departments = context.Departments/*.AsNoTracking()*/.ToArray();
            //  employees = context.Employees/*.AsNoTracking()*/.ToArray();
            //}

            using (var clientContext = new ClientContext(siteUrl))
            {
                string userLogin = ConfigurationManager.AppSettings["userLogin"];
                while (string.IsNullOrWhiteSpace(userLogin))
                {
                    Console.WriteLine("Enter User Login: "******"Done!");
            Console.ResetColor();



            Console.ReadKey();
        }