public void Run(AppContext context)
 {
     string entranceNumber = context.Session.GetVariable("parking_lot_entrance_number");
     string firstSpace = context.Session.GetVariable("parking_lot_first_space");
     string spacesCount = context.Session.GetVariable("parking_lot_spaces_count");
     string destinationNumber = context.Session.GetVariable("destination_number");
     if (entranceNumber == destinationNumber)
     {
         foreach (string key in ParkingLot.ParkedCalls.Keys)
         {
             Log.WriteLine(LogLevel.Info, string.Format("{0}: {1}", key, ParkingLot.ParkedCalls[key]));
         }
         Log.WriteLine(LogLevel.Info, "Park.");
         ParkCall(context.Session, FirstAvailableSpace(firstSpace, spacesCount));
     }
     else
     {
         if (ParkingLot.ParkedCalls.ContainsKey(destinationNumber))
         {
             Log.WriteLine(LogLevel.Info, "Unpark.");
             UnParkCall(context.Session);
         }
         return;
     }
 }
Пример #2
0
        private static void InitCustomers(AppContext context)
        {
            var customer = new Customer()
            {
                CompanyName = "My Rental Pos",
                Email = "*****@*****.**",
                //Password = "******",
                FirstName = "Guest",
                LastName = "User",
                StoreId=1,
                ZipCode = "",
                Address = "",
                City = "",
                PhoneNumber = "",
                State = "",
                CreatedDate = DateTime.UtcNow
            };

            if (context.Set<Customer>().Any())
                return;

            context.Set<Customer>().AddOrUpdate(customer);

            context.SaveChanges();
        }
Пример #3
0
        internal GameDeviceContext(AppContext context) 
		{
			SwapChain defaultSwapChain;

			SlimDX.Direct3D11.Device.CreateWithSwapChain(SlimDX.Direct3D11.DriverType.Hardware, GameConfiguration.CreationFlags, context[0].SwapChainDescription, out m_Device, out defaultSwapChain);
			
			m_Factory = m_Device.Factory;

			int numberOfAdditionalWindows = m_Factory.GetAdapter(GameConfiguration.AdapterOrdinal).GetOutputCount() - 1;

			if (numberOfAdditionalWindows > 0)
			{
				context.CreateAdditionalForms(numberOfAdditionalWindows);
			}

			context[0].SwapChain = defaultSwapChain; 

			m_Factory.SetWindowAssociation(context[0].Form.Handle, WindowAssociationFlags.IgnoreAll | WindowAssociationFlags.IgnoreAltEnter);
			
			for (int i = 1; i < context.Count; i++)
			{				
				context[i].SwapChain = new SlimDX.DXGI.SwapChain(m_Factory, m_Device, context[i].SwapChainDescription);

				m_Device.Factory.SetWindowAssociation(context[i].Form.Handle, WindowAssociationFlags.IgnoreAll | WindowAssociationFlags.IgnoreAltEnter);
			}

			for (int i = 0; i < context.Count; i++)
			{
				context[i].Form.Location = m_Factory.GetAdapter(GameConfiguration.AdapterOrdinal).GetOutput(i).Description.DesktopBounds.Location; 
			}
        }
Пример #4
0
        private static void InitCustomers(AppContext context)
        {
            var customer = new Customer()
            {
                UserName = "******",
                Email = "*****@*****.**",
                Password = "******",

                FirstName = "unigo",
                LastName = "unigo",
                Active = true,
                Deleted = false,
                CreatedOnUtc = DateTime.UtcNow,
                LastActivityDateUtc = DateTime.UtcNow
            };

            if (context.Set<Customer>().Any())
                return;

            var customrole = context.Set<CustomerRole>().FirstOrDefault(x => x.SystemName == "Admin");

            customer.CustomerRoles.Add(customrole);

            context.Set<Customer>().AddOrUpdate(customer);

            context.SaveChanges();
        }
Пример #5
0
 public MessageRepository(IMapper<Message, MessageDocument> messageDocumentMapper)
 {
     this.messageDocumentMapper = messageDocumentMapper;
     mappingSource = new AttributeMappingSource();
     connectionString = ConfigurationManager.ConnectionStrings["SqlConnectionString"].ConnectionString;
     context = new AppContext(connectionString);
 }
Пример #6
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ApplicationContext appcontext = new AppContext();
            Application.Run(appcontext);
        }
Пример #7
0
 /// <summary>
 /// Since each task execution runs in an background thread, set up container lifetime and provide context.
 /// </summary>
 private void Send(object command, AppContext context)
 {
     using (_container.BeginLifetimeScope())
     {
         _container.GetInstance<ExecutionEnvironment>().AppContext = context;
         _commander.Send(command).Wait();
     }
 }
Пример #8
0
 public static void Seed(AppContext context)
 {
     /*  InitPermissions(context);
     InitRoles(context);
     InitCustomers(context);
        */
     InitEmailAccount(context);
     InitScheduleTask(context);
 }
Пример #9
0
 static void Main(string[] args)
 {
     var db = new AppContext();
     System.Console.WriteLine("States: ");
     System.Console.WriteLine(db.StateProvinces.Count().ToString());
     System.Console.WriteLine("Counties: ");
     System.Console.WriteLine(db.Counties.Count().ToString());
     var s = System.Console.ReadKey();
 }
Пример #10
0
        public FeatureContext(AppContext appContext, Feature feature)
        {
            if (appContext == null) throw new ArgumentNullException(nameof(appContext));
            if (feature == null) throw new ArgumentNullException(nameof(feature));

            this.AppContext = appContext;
            this.Feature = feature;
            this.DbContext = appContext.DbContextCreator();
        }
Пример #11
0
 /// <summary>
 /// Instanciranje novog modela prema traženom kontekstu.
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 public static Model NewModelInstance(AppContext context)
 {
     if (context == AppContext.Login || context == AppContext.Students || context == AppContext.Teachers)
         return new UsersModel();
     else if (context == AppContext.StudentGrading || context == AppContext.Grades)
         return new GradesModel();
     else if (context == AppContext.ClassAdministration)
         return new ClassesInSchoolsModel();
     return null;
 }
Пример #12
0
        public static void Seed(AppContext context)
        {
            InitStore(context);
            InitEmployee(context);
            InitPermissions(context);
            InitCustomers(context);

            InitEmailAccount(context);
            InitScheduleTask(context);
        }
 static void Main()
 {
     Log.InitLog();
     Log.SetLogLevel(Log.LogLevel.Debug);
     Log.Information("Application start",CallerInfo.Create(),"");
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     var appContext = new AppContext(typeof(FrmSendPOCView), typeof(eZustellSendPOC.ViewModels.SendPOCController),RegisterUnity.RegisterContainer);
     Application.Run(appContext);
 }
 public DatabaseController()
 {
     Database = new AppContext();
     //Fast track to dropping the table for a new seed
     //Database.Database.ExecuteSqlCommand("delete from users");
     if (Database.Users.Any())
     {
         return;
     }
     SeedDatabase();
 }
Пример #15
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            //Database.SetInitializer<AppContext>(new MyDbInitializer());
            Database.SetInitializer<AppContext>(new CreateDatabaseIfNotExists<AppContext>());
            AppContext context = new AppContext();
            context.Database.Initialize(true);
        }
Пример #16
0
        public CreateUser(AppContext app, string opName, AccessType opAccess)
        {
            InitializeComponent();

            App = app;
            Context = app.Context;
            OpName = opName.Replace("deops://", "");
            OpAccess = opAccess;

            OpNameLabel.Text = OpName;

            BrowseLink.Text = (Context.Sim == null) ? Application.StartupPath : Context.Sim.Internet.LoadedPath;
        }
Пример #17
0
        private void initPrivate( MvcContext ctx )
        {
            IAppContext context = new AppContext();

            long appId = ctx.route.appId;
            context.Id = appId; // ID

            Type appType = ctx.controller.utils.getAppType();
            if (appType == null) {
                ctx.utils.setAppContext( context );
                return;
            }

            if (appId <= 0) {

                context.setAppType( appType );
                ctx.utils.setAppContext( context );
                return;
            }

            IApp app = getAppById( appType, appId, ctx.owner.obj );
            if (app == null) {

                if (appId == 1) {

                    context.setAppType( appType );
                    ctx.utils.setAppContext( context );
                    return;

                }
                else {

                    ctx.utils.setAppContext( context );
                    ctx.utils.endMsg( lang.get( "exAppNotFound" ) + ": appType=" + appType, HttpStatus.NotFound_404 );
                }
            }
            else {

                context.obj = app; // objApp
                context.setAppType( app.GetType() ); // type
                ctx.utils.setAppContext( context );

                IAppStats stats = app as IAppStats;
                if (stats != null) {
                    refreshStats( stats );
                }

            }
        }
Пример #18
0
        public LoginForm(AppContext app, string arg)
        {
            App = app;
            Context = app.Context;
            Arg = arg;

            InitializeComponent();

            Text = "DeOps Alpha v" + DeOpsContext.CoreVersion; //+ app.Context.LocalSeqVersion.ToString();

            //SplashBox.Image = InterfaceRes.splash;

            if (Context.Sim != null) // prevent sim recursion
                EnterSimLink.Visible = false;

            LastBrowse = Application.StartupPath;

            LastOpened = (arg != "") ? arg : App.Settings.LastOpened;

            // each profile (.rop) is in its own directory
            // /root/profiledirs[]/profile.rop
            if (App.Context.Sim == null)
            {
                LoadProfiles(Application.StartupPath);

                // if started with file argument, load profiles around the same location
                if (File.Exists(arg))
                    LoadProfiles(Path.GetDirectoryName(Path.GetDirectoryName(arg)));
            }
            else
                LoadProfiles(App.Context.Sim.Internet.LoadedPath);

            OpComboItem select = null;
            if(LastOpened != null)
                foreach (OpComboItem item in OpCombo.Items)
                    if (item.Fullpath == LastOpened)
                        select = item;

            if (select != null)
                OpCombo.SelectedItem = select;

            else if (OpCombo.Items.Count > 0)
                OpCombo.SelectedIndex = 0;

            OpCombo.Items.Add("Browse...");

            if (OpCombo.SelectedItem != null)
                TextPassword.Select();
        }
Пример #19
0
        public CreateUser(AppContext app, InvitePackage invite)
        {
            InitializeComponent();

            App = app;
            Context = app.Context;
            Invite = invite;
            OpName = invite.Info.OpName;
            OpAccess = invite.Info.OpAccess;

            OpNameLabel.Text = OpName;
            TextName.Text = invite.Info.UserName;

            BrowseLink.Text = (Context.Sim == null) ? Application.StartupPath : Context.Sim.Internet.LoadedPath;
        }
Пример #20
0
        // Program entry point
        static void Main(string[] args)
        {
            using (var db = new AppContext())
            {
                // Create the query
                var query = new GetUsersOfGenderQuery(db, Gender.Female);

                // Excecute the query (the sproc)
                var users = query.Execute();

                // Output the results to the console
                foreach (var user in users)
                {
                    Console.WriteLine(user.Name);
                }
            }
        }
Пример #21
0
        private static void InitPermissions(AppContext context)
        {
            var settings = new List<PermissionRecord>
                               {
                                   new PermissionRecord
                                       {
                                           Name = "Access admin area",
                                           SystemName = "AccessAdminPanel",
                                           Category = "Standard"
                                       }
                               };
            if (!context.Set<PermissionRecord>().Any())
            {
                settings.ForEach(x => context.Set<PermissionRecord>().Add(x));
            }

            context.SaveChanges();
        }
Пример #22
0
        public UnitOfWork(AppContext context)
        {
            //TODO: Tutaj nie tworzyłbym klas "ręcznie" ale zrobił to za pomocą kontenera. W kontenarze ustalił jeden kontekst dla wszystkich repository.
            this._context = context;

            this._ADUser = new GenericRepository<ADUser>(_context);
            this._CallTariff = new GenericRepository<CallTariff>(_context);
            this._CallTariffItems =  new GenericRepository<CallTariffItem>(_context);
            this._DomainNames =  new GenericRepository<DomainNames>(_context);
            this._PhoneNumbers = new GenericRepository<PhoneNumbers>(_context);
            this._PriceList =  new GenericRepository<PriceList>(_context);
            this._PriceListItem = new GenericRepository<PriceListItem>(_context);
            this._ServicePlan =  new GenericRepository<ServicePlan>(_context);
            this._Vendor =  new GenericRepository<Vendor>(_context);
            this._Partner =  new GenericRepository<Partner>(_context);
            this._Status = new GenericRepository<Status>(_context);
            this._HostedOrganisations =new GenericRepository<HostedOrganisation>(_context);
            this.AppRoles = new GenericRepository<IdentityRole>(_context);
        }
Пример #23
0
        static void Main()
        {
            System.Windows.Forms.Application.EnableVisualStyles();
            System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);
            System.Windows.Forms.Application.DoEvents();
            using (var appContext = new AppContext())
            {
                // Globaler Context
                AppContext = appContext;

                // Initialisierung
                using (var splash = new SplashForm())
                {
                    if (splash.ShowDialog() == DialogResult.OK)
                    {
                        System.Windows.Forms.Application.Run(new FrameForm());
                    }
                }
            }
        }
Пример #24
0
        public TaskRegistry(Container container)
        {
            _container = container;
            _commander = _container.GetInstance<Commander>();

            var settings = _container.GetInstance<Settings>();
            if (settings.IsDisabled)
            {
                TaskManager.Stop();
                return;
            }

            TaskManager.UnobservedTaskException += TaskManager_UnobservedTaskException;

            //We'll run our system tasks as Admin
            _system = new AppContext { Username = "******" };

            Schedule(StartQueueInfiniteLoop).ToRunOnceIn(5).Seconds();
            Schedule(PingMe).ToRunNow().AndEvery(5).Seconds();
        }
Пример #25
0
 static void Main(string[] args)
 {
     using (var appContext = new AppContext())
     {
         var securityServ = appContext.GetObject<ISecurityService>();
         using (var uow = appContext.GetObject<IUnitOfWork>())
         {
             using (var uow1 = appContext.GetObject<IUnitOfWork>())
             {
                 securityServ.CreateAccount(new CreateAccountInfo() { Name = "Michael", Password = "******" });
                 securityServ.CreateAccount(new CreateAccountInfo() { Name = "Roland", Password = "******" });
                 uow1.Complete();
             }
             using (var uow2 = appContext.GetObject<IUnitOfWork>())
             {
                 securityServ.CreateAccount(new CreateAccountInfo() { Name = "Steffen", Password = "******" });
                 securityServ.CreateAccount(new CreateAccountInfo() { Name = "Erik", Password = "******" });
                 securityServ.CreateAccount(new CreateAccountInfo() { Name = "Frank", Password = "******" });
                 using (var uow21 = appContext.GetObject<IUnitOfWork>())
                 {
                     securityServ.CreateAccount(new CreateAccountInfo() { Name = "Dennis", Password = "******" });
                     securityServ.CreateAccount(new CreateAccountInfo() { Name = "Dimitri", Password = "******" });
                     securityServ.CreateAccount(new CreateAccountInfo() { Name = "Christian", Password = "******" });
                     uow21.Complete();
                 }
                 uow2.Complete();
             }
             using (var uow3 = appContext.GetObject<IUnitOfWork>())
             {
                 securityServ.CreateAccount(new CreateAccountInfo() { Name = "Robert", Password = "******" });
                 uow3.Complete();
             }
             uow.Complete();
         }
         foreach (var item in appContext.GetObject<IUserRepository>())
         {
             Console.WriteLine(item);
         }
     }
     PressAnyKeyToExit();
 }
        public ActionResult Login(string username, string password, string returnUrl)
        {
            ViewBag.ReturnUrl = returnUrl;

            var appContext = new AppContext();
            var userStore = new UserStore<AppUser>(appContext);
            var userManager = new UserManager<AppUser>(userStore);
            var authenticationManager = HttpContext.GetOwinContext().Authentication;
            var signInManager = new SignInManager<AppUser, string>(userManager, authenticationManager);

            var result = signInManager.PasswordSignIn(username, password, 
                isPersistent: false, shouldLockout:false);

            switch (result)
            {
                case SignInStatus.Success:
                    return RedirectToLocal(returnUrl); 
                default:
                    ModelState.AddModelError("", "Invalid login attempt.");
                    return View();
            }
        }
Пример #27
0
 private static void InitEmailAccount(AppContext context)
 {
     var settings = new List<EmailAccount>
                        {
                            new EmailAccount
                                {
                                    DisplayName = "Tool Depot",
                                    Email = "*****@*****.**",
                                    Host = "127.0.0.1",
                                    Port = 25,
                                    EnableSsl = false,
                                    IsDefault = true,
                                    Username = "******",
                                    Password = "******",
                                    UseDefaultCredentials = true
                                }
                        };
     if (!context.Set<EmailAccount>().Any())
     {
         settings.ForEach(x => context.Set<EmailAccount>().Add(x));
     }
     context.SaveChanges();
 }
Пример #28
0
        public TestSaveContact()
        {
            var contacts = new[]
            {
                new Contact
                {
                    Id = 1,
                    FirstName = "First",
                    LastName = "Last",
                    Email = "*****@*****.**",
                    PhoneNumber = "555-1212"
                },
            }.ToDbSet();

            _db = A.Fake<ContactDb>();
            A.CallTo(() => _db.Contacts).Returns(contacts);

            _appContext = A.Fake<AppContext>();
            _queue = A.Fake<IQueueService>();
            _mediator = A.Fake<IMediator>();

            _handler = new SaveContact.Handler(_db, _appContext, _queue, _mediator);
        }
Пример #29
0
 private static void InitEmployee(AppContext context)
 {
     var settings = new List<Employee>
                        {
                            new Employee
                                {
                                    StoreId = 1,
                                    UserName = "******",
                                    Active = true,
                                    CreatedDate = DateTime.UtcNow,
                                    Email = "*****@*****.**",
                                    FirstName = "John",
                                    LastName = "Smith",
                                    LastActivityDateUtc = DateTime.UtcNow,
                                    LastLoginDateUtc = DateTime.UtcNow,
                                    Password = "******"
                                }
                        };
     if (!context.Set<Employee>().Any())
     {
         settings.ForEach(x=>context.Set<Employee>().AddOrUpdate(x));
     }
     context.SaveChanges();
 }
 public DictionaryRepository(AppContext context)
 {
     this._context = context;
 }
Пример #31
0
        private static void ProcessStartupHooks()
        {
            // Initialize tracing before any user code can be called.
            System.Diagnostics.Tracing.EventPipeController.Initialize();

            string?startupHooksVariable = (string?)AppContext.GetData("STARTUP_HOOKS");

            if (startupHooksVariable == null)
            {
                return;
            }

            char[] disallowedSimpleAssemblyNameChars = new char[]
            {
                Path.DirectorySeparatorChar,
                Path.AltDirectorySeparatorChar,
                ' ',
                ','
            };

            // Parse startup hooks variable
            string[] startupHookParts            = startupHooksVariable.Split(Path.PathSeparator);
            StartupHookNameOrPath[] startupHooks = new StartupHookNameOrPath[startupHookParts.Length];
            for (int i = 0; i < startupHookParts.Length; i++)
            {
                string startupHookPart = startupHookParts[i];
                if (string.IsNullOrEmpty(startupHookPart))
                {
                    // Leave the slot in startupHooks empty (nulls for everything). This is simpler than shifting and resizing the array.
                    continue;
                }

                if (Path.IsPathFullyQualified(startupHookPart))
                {
                    startupHooks[i].Path = startupHookPart;
                }
                else
                {
                    // The intent here is to only support simple assembly names, but AssemblyName .ctor accepts
                    // lot of other forms (fully qualified assembly name, strings which look like relative paths and so on).
                    // So add a check on top which will disallow any directory separator, space or comma in the assembly name.
                    for (int j = 0; j < disallowedSimpleAssemblyNameChars.Length; j++)
                    {
                        if (startupHookPart.Contains(disallowedSimpleAssemblyNameChars[j]))
                        {
                            throw new ArgumentException(SR.Format(SR.Argument_InvalidStartupHookSimpleAssemblyName, startupHookPart));
                        }
                    }

                    if (startupHookPart.EndsWith(DisallowedSimpleAssemblyNameSuffix, StringComparison.OrdinalIgnoreCase))
                    {
                        throw new ArgumentException(SR.Format(SR.Argument_InvalidStartupHookSimpleAssemblyName, startupHookPart));
                    }

                    try
                    {
                        // This will throw if the string is not a valid assembly name.
                        startupHooks[i].AssemblyName = new AssemblyName(startupHookPart);
                    }
                    catch (Exception assemblyNameException)
                    {
                        throw new ArgumentException(SR.Format(SR.Argument_InvalidStartupHookSimpleAssemblyName, startupHookPart), assemblyNameException);
                    }
                }
            }

            // Call each hook in turn
            foreach (StartupHookNameOrPath startupHook in startupHooks)
            {
                CallStartupHook(startupHook);
            }
        }
 internal static bool GetSwitchValue(string switchName, ref bool switchValue) =>
 AppContext.TryGetSwitch(switchName, out switchValue);
Пример #33
0
 public object GetData(string name) => AppContext.GetData(name);
Пример #34
0
 public void SetData(string name, object data) => AppContext.SetData(name, data);
Пример #35
0
        public bool?IsCompatibilitySwitchSet(string value)
        {
            bool result;

            return(AppContext.TryGetSwitch(value, out result) ? result : default(bool?));
        }
Пример #36
0
 internal static bool GetBooleanConfig(string configName, bool defaultValue) =>
 AppContext.TryGetSwitch(configName, out bool value) ? value : defaultValue;