public void ReCreateContext()
        {
            if (Context == null) return;

            Context.Dispose();
            Context = new SystemContext();
        }
示例#2
0
 public UserRepository(
     IIdGenerator idGenerator,
     SystemContext systemContext,
     DomainContext domainContext)
 {
     _idGenerator   = idGenerator;
     _systemContext = systemContext;
     _domainContext = domainContext;
 }
示例#3
0
 public Provision(Configuration configuration)
 {
     this.configuration = configuration;
     using (var db = new SystemContext())
     {
         tables  = db.MatchingTableNames.Where(m => m.ScopeIgnore == null || m.ScopeIgnore.Value == 0).OrderBy(m => m.Index).ToList();
         columns = db.MatchingColumnNames.OrderBy(m => m.CreatedOn).ToList();
     }
 }
示例#4
0
 private static void ImportJson()
 {
     using (var context = new SystemContext())
     {
         //ImportAstronomers(context);
         //ImportTelescopes(context);
         //ImportPlanets(context);
     }
 }
        private void RunDiagnostics()
        {
            RefreshData();

            try
            {
                var assemblyName = Assembly.GetExecutingAssembly().GetName().ToString();
                var system       = new SystemContext(assemblyName);
                var packages     = Source.Packages
                                   .Select(package => new SupportPackageDataProvider(ParseFileSystemEntry(package.Path), package.Roles, null))
                                   .ToArray();

                try
                {
                    var resultsFile = TestRunner.RunTests(packages, system, (test, index, count) => OnTestRun(index));

                    if (tokenSource.IsCancellationRequested)
                    {
                        return;
                    }

                    try
                    {
                        var path = GetReportPath();
                        File.WriteAllText(path, ReportBuilder.GenerateReport(resultsFile));
                        reportPath = path;
                    }
                    catch
                    {
                        Source.ErrorMessage = Strings.ReportError;
                    }
                }
                finally
                {
                    foreach (var package in packages)
                    {
                        try
                        {
                            package.Dispose();
                        }
                        catch
                        {
                        }
                    }
                }
            }
            catch
            {
                IsThreadAborted     = true;
                Source.ErrorMessage = Strings.DiagnosticsError;
            }
            finally
            {
                IsThreadRunning = false;
                Thread.Sleep(50);
            }
        }
示例#6
0
 public ActionResult Log()
 {
     CreateDatabase();
     using (var db = new SystemContext())
     {
         UsersList = db.Users.ToList();
     }
     return(View());
 }
示例#7
0
 public List <Model.Task> GetAll()
 {
     using (var db = new SystemContext())
     {
         List <Model.Task> tasks = (from t in db.Tasks
                                    select t).ToList <Model.Task>();
         return(tasks);
     }
 }
 public UseCase_SearchProduct
 (
     SystemContext systemContext,
     UserInfo buyerUser,
     Func <ShopImage[]> marketImageFactory
 ) : base(systemContext, buyerUser)
 {
     MarketImageFactory = marketImageFactory;
 }
        public static void Config(string overridingCulture)
        {
            if (!string.IsNullOrEmpty(overridingCulture))
            {
                SettingProvider.Instance.SetCurrentCulture(new CultureInfo(overridingCulture));
            }

            SystemContext.SetCulture(SettingProvider.Instance.GetCurrentCulture());
        }
示例#10
0
 public void Deletar(int id)
 {
     using (var ctx = new SystemContext())
     {
         Dentist obj = ctx.Dentists.Find(id);
         ctx.Dentists.Remove(obj);
         ctx.SaveChanges();
     }
 }
示例#11
0
 public Synchronize(Configuration configuration)
 {
     this.configuration = configuration;
     using (var db = new SystemContext())
     {
         tables  = db.MatchingTableNames.Where(m => m.ScopeIgnore == null || m.ScopeIgnore.Value == 0).ToList();
         columns = db.MatchingColumnNames.ToList();
     }
 }
示例#12
0
 static void Main(string[] args)
 {
     using (var context = new SystemContext())
     {
         // ClearDatabase(context);
         // FillDatabase(context);    // seeding needs fixing
         Tasks(context);
     }
 }
示例#13
0
 public ActionResult UsersTable()
 {
     using (var db = new SystemContext())
     {
         UsersList = db.Users.ToList();
     }
     ViewBag.usery = UsersList;
     return(View());
 }
示例#14
0
 internal void LogOut(int id)
 {
     using (var db = new SystemContext())
     {
         Employee e = db.Employees.First(i => i.Id == id);
         e.Logged = "no";
         db.SaveChanges();
     }
 }
示例#15
0
 static void Main(string[] args)
 {
     using (var context = new SystemContext())
     {
         context.Database.EnsureDeleted();
         context.Database.EnsureCreated();
         //context.Database.Migrate();
     }
 }
示例#16
0
 public void UpdateTask(Model.Task task)
 {
     using (var db = new SystemContext())
     {
         Model.Task t = db.Tasks.First(i => i.Id == task.Id);
         t.Status = task.Status;
         db.SaveChanges();
     }
 }
示例#17
0
        public async Task <IActionResult> Download(Guid keyPairSysid, [FromServices] SystemContext adminDbContext)
        {
            var keyPairEntity = adminDbContext.KeyPairs.SingleOrDefault(x => x.Sysid == keyPairSysid);

            Response.Headers.Add("Content-Disposition", $"attachment;filename={keyPairSysid}.key");
            //content type get from: https://www.thoughtco.com/mime-types-by-content-type-3469108
            await Task.CompletedTask;

            return(File(Encoding.UTF8.GetBytes(keyPairEntity.PrivateKey.ConvertBase64ToUTF8()), "text/plain"));
        }
 public UseCase_RemoveProductFromCart_TestLogic
 (
     SystemContext systemContext,
     IEnumerable <ProductIdentifiable> productsRemove,
     IEnumerable <ProductForCart> productsForCart
 ) : base(systemContext)
 {
     ProductsRemove  = productsRemove;
     ProductsForCart = productsForCart;
 }
示例#19
0
 internal List <Employee> GetLoggedUsers()
 {
     using (var db = new SystemContext())
     {
         List <Employee> employees = (from emp in db.Employees
                                      where emp.Logged.Equals("yes")
                                      select emp).ToList <Employee>();
         return(employees);
     }
 }
示例#20
0
 internal List <User> GetAllUsers()
 {
     using (var db = new SystemContext())
     {
         List <User> users = (from user in db.Employees
                              select user).ToList <User>();
         Console.WriteLine("Len:: " + users.Count);
         return(users);
     }
 }
示例#21
0
 public UseCase_RemoveProductFromShop
 (
     SystemContext systemContext,
     ShopImage shopImage,
     Func <ShopImage, IEnumerable <ProductIdentifiable> > productsProviderRemove
 ) : base(systemContext, shopImage.OwnerUser)
 {
     ShopImage = shopImage;
     ProductsProviderRemove = productsProviderRemove;
 }
示例#22
0
        /// <summary>
        /// Shut down the system.
        /// </summary>
        public void Shutdown()
        {
            Context.Actor.StopChildren();

            Context.Stop();

            SystemContext.Actor.StopChildren();

            SystemContext.Stop();
        }
示例#23
0
        private void DisplayRefreshTimer_Tick(object?sender, EventArgs e)
        {
            bool isSecondaryTimeVisible = secondaryTime is { IsVisible : true };

            if (primaryTimeStartedAt != null && !isSecondaryTimeVisible)
            {
                TimeSpan timePassed = SystemContext.UtcNow() - primaryTimeStartedAt.Value;
                UpdatePrimaryTime(timePassed, false);
            }
        }
示例#24
0
 internal object GetTasks(Employee e)
 {
     using (var db = new SystemContext())
     {
         List <Model.Task> tasks = (from task in db.Tasks
                                    where task.Employee.Id == e.Id
                                    select task).ToList <Model.Task>();
         return(tasks);
     }
 }
示例#25
0
 public void CreateDatabase()
 {
     using (var db = new SystemContext())
     {
         db.Database.CreateIfNotExists();
         var r = db.Users.FirstOrDefault();
         UsersList = db.Users.ToList();
         db.SaveChanges();
     }
 }
示例#26
0
 public List <Model.Task> GetEmployeeTask(int id)
 {
     using (var db = new SystemContext())
     {
         List <Task> tasks = (from t in db.Tasks
                              where t.Employee.Id == id
                              select t).ToList <Task>();
         return(tasks);
     }
 }
示例#27
0
        public Dentist Buscar(int id)
        {
            Dentist obj = new Dentist();

            using (var ctx = new SystemContext())
            {
                obj = ctx.Dentists.Find(id);
            }
            return(obj);
        }
示例#28
0
 public ActionResult Register(User model)
 {
     using (var db = new SystemContext())
     {
         db.Users.Add(model);
         db.SaveChanges();
     }
     // return RedirectToAction("Index", "Home");
     return(RedirectToAction("Log", "Start"));
 }
 private UserBridgeAdapter
 (
     SystemContext systemContext,
     UserService userService,
     MarketUserService marketService
 )
     : base(systemContext)
 {
     this.userService       = userService;
     this.marketUserService = marketService;
 }
示例#30
0
    private static void ClearDatabase(SystemContext context)
    {
        Console.WriteLine($"Deleting database...");
        context.Database.EnsureDeleted();

        Console.WriteLine($"Creating database...");
        context.Database.EnsureCreated();

        // Console.WriteLine($"Migrating database...");
        // context.Database.Migrate();
    }
 public void Cancel()
 {
     if (!isCompleted)
     {
         // Immediately fade out now, unless already fading out.
         if (directionIsUp)
         {
             holdStartedAt = SystemContext.UtcNow().AddHours(-1);
         }
     }
 }
 protected RepositoryBase()
 {
     Context = new SystemContext();
     Context.Configuration.AutoDetectChangesEnabled = false;
     Context.Configuration.ValidateOnSaveEnabled = false;
 }
示例#33
0
        /// <summary>
        /// Indexes the well known subtypes.
        /// </summary>
        private void IndexWellKnownTypes()
        {
            SystemContext context = new SystemContext();
            context.EncodeableFactory = m_session.MessageContext.Factory;
            context.NamespaceUris = m_session.NamespaceUris;
            context.ServerUris = m_session.ServerUris;

            NodeStateCollection predefinedNodes = new NodeStateCollection();
            predefinedNodes.LoadFromBinaryResource(context, "Opc.Ua.Stack.Generated.Opc.Ua.PredefinedNodes.uanodes", typeof(NodeState).Assembly, true);
            
            NodeIdDictionary<BaseTypeState> types = new NodeIdDictionary<BaseTypeState>();

            // collect the instance declarations for all types.
            for (int ii = 0; ii < predefinedNodes.Count; ii++)
            {
                BaseTypeState type = predefinedNodes[ii] as BaseTypeState;

                if (type != null)
                {
                    types.Add(type.NodeId, type);
                }
            }

            // index only those types which are subtypes of BaseEventType.
            foreach (BaseTypeState type in types.Values)
            {
                BaseTypeState subType = type;
                BaseTypeState superType = null;

                int eventType = 0;

                while (subType != null)
                {
                    if (subType.NodeId == Opc.Ua.ObjectTypeIds.ConditionType || subType.SuperTypeId == Opc.Ua.ObjectTypeIds.ConditionType)
                    {
                        eventType = OpcRcw.Ae.Constants.CONDITION_EVENT;
                    }

                    else if (subType.NodeId == Opc.Ua.ObjectTypeIds.AuditEventType || subType.SuperTypeId == Opc.Ua.ObjectTypeIds.AuditEventType)
                    {
                        eventType = OpcRcw.Ae.Constants.TRACKING_EVENT;
                    }

                    else if (subType.NodeId == Opc.Ua.ObjectTypeIds.BaseEventType || subType.SuperTypeId == Opc.Ua.ObjectTypeIds.BaseEventType)
                    {
                        eventType = OpcRcw.Ae.Constants.SIMPLE_EVENT;
                    }

                    // found an event, collect the attribute and index it.
                    if (eventType != 0)
                    {
                        List<AeEventAttribute> declarations = new List<AeEventAttribute>();
                        Dictionary<string, AeEventAttribute> map = new Dictionary<string, AeEventAttribute>();

                        ComAeUtils.CollectInstanceDeclarations(
                            m_session,
                            this,
                            type,
                            null,
                            declarations,
                            map);

                        AeEventCategory declaration = new AeEventCategory();
                        declaration.TypeId = type.NodeId;
                        declaration.SuperTypeId = type.SuperTypeId;
                        declaration.EventType = eventType;
                        declaration.Description = (LocalizedText.IsNullOrEmpty(type.DisplayName))?type.BrowseName.Name:type.DisplayName.Text;
                        declaration.Attributes = declarations;
                        m_eventTypes[declaration.TypeId] = declaration;
                        break;
                    }

                    // follow the tree to the parent.
                    if (!types.TryGetValue(subType.SuperTypeId, out superType))
                    {
                        break;
                    }

                    subType = superType;
                }
            }

            // hide the built in attributes.
            AeEventCategory category = GetCategory(Opc.Ua.ObjectTypeIds.BaseEventType);

            if (category != null)
            {
                for (int ii = 0; ii < category.Attributes.Count; ii++)
                {
                    switch (category.Attributes[ii].BrowsePathDisplayText)
                    {
                        case Opc.Ua.BrowseNames.Message:
                        case Opc.Ua.BrowseNames.Severity:
                        case Opc.Ua.BrowseNames.SourceName:
                        case Opc.Ua.BrowseNames.Time:
                        case Opc.Ua.BrowseNames.ReceiveTime:
                        case Opc.Ua.BrowseNames.LocalTime:
                        {
                            category.Attributes[ii].Hidden = true;
                            break;
                        }
                    }
                }
            }
        }
 public CommercialRepository(SystemContext context)
 {
     Context = context;
 }
示例#35
0
        /// <summary>
        /// Initializes the channel.
        /// </summary>
        private void Initialize(
            ITransportChannel        channel, 
            ApplicationConfiguration configuration, 
            ConfiguredEndpoint       endpoint,
            X509Certificate2         clientCertificate)
        {
            Initialize();

            // save configuration information.
            m_configuration = configuration;
            m_endpoint = endpoint;
            
            // update the default subscription. 
            m_defaultSubscription.MinLifetimeInterval = (uint)configuration.ClientConfiguration.MinSubscriptionLifetime;

            if (m_endpoint.Description.SecurityPolicyUri != SecurityPolicies.None)
            {
                // update client certificate.
                m_instanceCertificate = clientCertificate;

                if (clientCertificate == null)
                {
                    // load the application instance certificate.
                    if (m_configuration.SecurityConfiguration.ApplicationCertificate == null)
                    {
                        throw new ServiceResultException(
                            StatusCodes.BadConfigurationError,
                            "The client configuration does not specify an application instance certificate.");
                    }

                    m_instanceCertificate = m_configuration.SecurityConfiguration.ApplicationCertificate.Find(true);
                }

                // check for valid certificate.
                if (m_instanceCertificate == null)
                {
                    throw ServiceResultException.Create(
                        StatusCodes.BadConfigurationError,
                        "Cannot find the application instance certificate. Store={0}, SubjectName={1}, Thumbprint={2}.",
                        m_configuration.SecurityConfiguration.ApplicationCertificate.StorePath,
                        m_configuration.SecurityConfiguration.ApplicationCertificate.SubjectName,
                        m_configuration.SecurityConfiguration.ApplicationCertificate.Thumbprint);
                }

                // check for private key.
                if (!m_instanceCertificate.HasPrivateKey)
                {
                    throw ServiceResultException.Create(
                        StatusCodes.BadConfigurationError,
                        "Do not have a privat key for the application instance certificate. Subject={0}, Thumbprint={1}.",
                        m_instanceCertificate.Subject,
                        m_instanceCertificate.Thumbprint);
                }

                //load certificate chain
                /*m_instanceCertificateChain = new X509Certificate2Collection(m_instanceCertificate);
                List<CertificateIdentifier> issuers = new List<CertificateIdentifier>();
                configuration.CertificateValidator.GetIssuers(m_instanceCertificate, issuers);
                for (int i = 0; i < issuers.Count; i++)
                {
                    m_instanceCertificateChain.Add(issuers[i].Certificate);
                }*/
            }

            // initialize the message context.
            ServiceMessageContext messageContext = channel.MessageContext;

            if (messageContext != null)
            {
                m_namespaceUris = messageContext.NamespaceUris;
                m_serverUris    = messageContext.ServerUris;
                m_factory       = messageContext.Factory;
            }    
            else
            {
                m_namespaceUris = new NamespaceTable();
                m_serverUris    = new StringTable();
                m_factory       = ServiceMessageContext.GlobalContext.Factory;
            }

            // set the default preferred locales.
            m_preferredLocales = new string[] { CultureInfo.CurrentCulture.Name };

            // create a context to use.
            m_systemContext = new SystemContext();

            m_systemContext.SystemHandle = this;
            m_systemContext.EncodeableFactory = m_factory;
            m_systemContext.NamespaceUris = m_namespaceUris;
            m_systemContext.ServerUris = m_serverUris;
            m_systemContext.TypeTable = this.TypeTree;
            m_systemContext.PreferredLocales = null;
            m_systemContext.SessionId = null;
            m_systemContext.UserIdentity = null;
        }