Exemple #1
0
 public IObjectSpace GetObjectSpace(Type type)
 {
     if (objectSpace == null)
     {
         objectSpace = objectSpaceProvider.CreateObjectSpace();
     }
     return(objectSpace);
 }
 private void EmployeeListForm_Load(object sender, EventArgs e)
 {
     securedObjectSpace       = objectSpaceProvider.CreateObjectSpace();
     employeeGrid.DataSource  = securedObjectSpace.GetBindingList <Employee>();
     newBarButtonItem.Enabled = security.CanCreate <Employee>();
     protectedContentTextEdit = new RepositoryItemProtectedContentTextEdit();
 }
Exemple #3
0
        public async Task TesteImportacaoPieceAndJoints()
        {
            var application = new Application(false);
            IObjectSpaceProvider objectSpaceProvider = application.serverApplication.ObjectSpaceProvider;
            var          objectSpace = objectSpaceProvider.CreateObjectSpace();
            var          parametros  = objectSpace.CreateObject <ParametrosImportComponentEJunta>();
            MemoryStream stream      = new MemoryStream();

            stream.Seek(0, SeekOrigin.Begin);
            var arquivo = parametros.Padrao;

            arquivo.SaveToStream(stream);
            stream.Seek(0, SeekOrigin.Begin);

            using (var excelReader = new Module.ExcelDataReaderHelper.Excel.Reader(stream))
            {
                var dtcollectionImport = excelReader.CreateDataTableCollection(false);

                var piecejoints = new ImportComponentEJunta(objectSpaceProvider, parametros);
                var progress    = new Progress <ImportProgressReport>(piecejoints.LogTrace);

                await Task.Run(() => piecejoints.ImportarComponente(dtcollectionImport["Piece"], progress));

                //await Observable.Start(() => piecejoints.ImportarJuntas(dtcollectionImport["Joints"], progress));

                objectSpace.CommitChanges();
            }
        }
        public static async Task Populate_All <TEntity>(this IObjectSpace objectSpace, string syncToken,
                                                        Func <CloudOfficeTokenStorage, IObservable <TEntity> > listEvents, TimeSpan timeout, Action <IObservable <TEntity> > assert, IObjectSpaceProvider assertTokenStorageProvider = null)
        {
            var tokenStorage = objectSpace.CreateObject <CloudOfficeTokenStorage>();

            tokenStorage.Token      = syncToken;
            tokenStorage.EntityName = typeof(TEntity).FullName;
            objectSpace.CommitChanges();
            var storageOid = tokenStorage.Oid;
            var events     = listEvents(tokenStorage).SubscribeReplay();

            await events.Timeout(timeout);

            if (assertTokenStorageProvider != null)
            {
                using (var space = assertTokenStorageProvider.CreateObjectSpace()){
                    tokenStorage = space.GetObjectsQuery <CloudOfficeTokenStorage>()
                                   .First(storage => storage.Oid == storageOid);
                    tokenStorage.Token.ShouldNotBeNull();
                    tokenStorage.Token.ShouldNotBe(syncToken);
                }
            }

            assert(events);
        }
Exemple #5
0
        public async Task TesteImportacaoSpoolEJunta()
        {
            var application = new Application(false);
            IObjectSpaceProvider objectSpaceProvider = application.serverApplication.ObjectSpaceProvider;
            var          objectSpace = objectSpaceProvider.CreateObjectSpace();
            var          parametros  = objectSpace.CreateObject <ParametrosImportSpoolJuntaExcel>();
            MemoryStream stream      = new MemoryStream();

            stream.Seek(0, SeekOrigin.Begin);
            var arquivo = parametros.Padrao;

            arquivo.SaveToStream(stream);
            stream.Seek(0, SeekOrigin.Begin);

            using (var excelReader = new Module.ExcelDataReaderHelper.Excel.Reader(stream))
            {
                var dtcollectionImport = excelReader.CreateDataTableCollection(false);

                var itba     = new ImportSpoolEJunta(objectSpace, parametros);
                var progress = new Progress <ImportProgressReport>(itba.LogTrace);

                await Observable.Start(() => itba.ImportarSpools(dtcollectionImport["SGS"], progress));

                await Observable.Start(() => itba.ImportarJuntas(dtcollectionImport["SGJ"], progress));

                objectSpace.CommitChanges();
            }
        }
Exemple #6
0
 private void EmployeeListForm_Load(object sender, EventArgs e)
 {
     security            = ((MainForm)MdiParent).Security;
     objectSpaceProvider = ((MainForm)MdiParent).ObjectSpaceProvider;
     securedObjectSpace  = objectSpaceProvider.CreateObjectSpace();
     employeeBindingSource.DataSource = securedObjectSpace.GetObjects <Employee>();
     newBarButtonItem.Enabled         = security.IsGranted(new PermissionRequest(securedObjectSpace, typeof(Employee), SecurityOperations.Create));
 }
Exemple #7
0
        protected void Init()
        {
            Security = ConnectionHelper.GetSecurity(typeof(IdentityAuthenticationProvider).Name, HttpContext?.User?.Identity);
            string connectionString = Config.GetConnectionString("XafApplication");
            IObjectSpaceProvider objectSpaceProvider = ConnectionHelper.GetObjectSpaceProvider(Security, XpoDataStoreProviderService, connectionString);

            ConnectionHelper.Login(Security, objectSpaceProvider);
            ObjectSpace = objectSpaceProvider.CreateObjectSpace();
        }
Exemple #8
0
 private void EmployeeListForm_Load(object sender, EventArgs e)
 {
     security            = ((MainForm)MdiParent).Security;
     objectSpaceProvider = ((MainForm)MdiParent).ObjectSpaceProvider;
     securedObjectSpace  = objectSpaceProvider.CreateObjectSpace();
     employeeBindingSource.DataSource = securedObjectSpace.GetObjects <Employee>();
     newBarButtonItem.Enabled         = security.CanCreate <Employee>();
     protectedContentTextEdit         = new RepositoryItemProtectedContentTextEdit();
 }
Exemple #9
0
        public SecuredController(XpoDataStoreProviderService xpoDataStoreProviderService, IConfiguration config, SecurityProvider securityHelper, IHttpContextAccessor contextAccessor)
            : base(xpoDataStoreProviderService, config, securityHelper)
        {
            Security = SecurityProvider.GetSecurity(typeof(IdentityAuthenticationProvider).Name, contextAccessor.HttpContext.User.Identity);
            string connectionString = Config.GetConnectionString("XafApplication");
            IObjectSpaceProvider objectSpaceProvider = SecurityProvider.GetObjectSpaceProvider(Security, XpoDataStoreProviderService, connectionString);

            SecurityProvider.Login(Security, objectSpaceProvider);
            ObjectSpace = objectSpaceProvider.CreateObjectSpace();
        }
        public static UnitOfWork CreateUnitOfWork(this IObjectSpaceProvider objectSpaceProvider)
        {
            var os = objectSpaceProvider.CreateObjectSpace();

            if (os is XPObjectSpace)
            {
                return((os as XPObjectSpace).Session as UnitOfWork);
            }

            return(null);
        }
 private void Login(SecurityStrategyComplex security, IObjectSpaceProvider objectSpaceProvider)
 {
     try
     {
         IObjectSpace objectSpace = objectSpaceProvider.CreateObjectSpace();
         security.Logon(objectSpace);
     }
     catch (Exception ex)
     {
     }
 }
Exemple #12
0
        public async Task <ActionResult> Index()
        {
            using (var os = _OsProvider.CreateObjectSpace())
            {
                var users = await os.GetSession().GetObjectsAsync <User>(CriteriaOperator.Parse("1=1"));

                return(View(users.Select(m => new DTO.Security.User {
                    Username = m.Username,
                    IsActive = m.IsActive,
                    PasswordHash = m.PasswordHash
                })));
            }
        }
 private void EmployeeDetailForm_Load(object sender, EventArgs e)
 {
     securedObjectSpace = objectSpaceProvider.CreateObjectSpace();
     if (employee == null)
     {
         employee = securedObjectSpace.CreateObject <Employee>();
     }
     else
     {
         employee = securedObjectSpace.GetObject(employee);
         deleteBarButtonItem.Enabled = security.CanDelete(employee);
     }
     AddControls();
 }
        public void Execute(IJobExecutionContext context)
        {
            _log.Info("EXECUTING:ThresholdCalculationJob");
            var application = ((IXpandScheduler)context.Scheduler).Application;
            IObjectSpaceProvider objectSpaceProvider = application.ObjectSpaceProvider;
            var    jobDataMap = context.JobDetail.JobDataMap;
            var    typeInfo   = objectSpaceProvider.TypesInfo.FindTypeInfo((Type)jobDataMap.Get <ThresholdJobDetailDataMap>(map => map.DataType));
            object count;

            using (var objectSpace = objectSpaceProvider.CreateObjectSpace()){
                count = objectSpace.GetObjectsCount(typeInfo.Type, CriteriaOperator.Parse(jobDataMap.GetString <ThresholdJobDetailDataMap>(map => map.Criteria)));
            }
            jobDataMap.Put <ThresholdJobDetailDataMap>(ThresholdCalcCount, count);
        }
Exemple #15
0
        public void CheckAndUpdateDB(bool fullUpdate)
        {
            Console.WriteLine($"-----------------------{nameof(CheckAndUpdateDB)}-----------------------");
            Stopwatch sw = new Stopwatch();

            sw.Start();
            using (IObjectSpace updatingObjectSpace = updatingObjectSpaceProvider.CreateObjectSpace()) {
                if (!TestDataSetIsActual(updatingObjectSpace))
                {
                    CleanupAllTestData(updatingObjectSpace);
                    updatingObjectSpace.CommitChanges();

                    CreateSecurityObjects(updatingObjectSpace);
                    if (fullUpdate)
                    {
                        TemporaryTestObjectsHelper.CreateTestDataSet(CreateUpdatingObjectHelper(updatingObjectSpace));
                    }

                    updatingObjectSpace.CommitChanges();
                }
            }
            sw.Stop();
            Console.WriteLine($"----------------End-of-{nameof(CheckAndUpdateDB)}--Time:{sw.Elapsed}");
        }
        private void Login_button_Click(object sender, EventArgs e)
        {
            IObjectSpace logonObjectSpace = objectSpaceProvider.CreateObjectSpace();
            string       userName         = userNameEdit.Text;
            string       password         = passwordEdit.Text;

            security.Authentication.SetLogonParameters(new AuthenticationStandardLogonParameters(userName, password));
            try {
                security.Logon(logonObjectSpace);
                DialogResult = DialogResult.OK;
                Close();
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public static void NewAuthentication <TAuth>(this IObjectSpaceProvider objectSpaceProvider, Action <TAuth, byte[]> saveToken, string serviceName, Platform platform = Platform.Win) where TAuth : CloudOfficeBaseObject
        {
            using var manifestResourceStream = File.OpenRead($"{AppDomain.CurrentDomain.ApplicationPath()}\\{serviceName}AuthenticationData{platform}.json");
            var token = Encoding.UTF8.GetBytes(new StreamReader(manifestResourceStream).ReadToEnd());

            using var objectSpace = objectSpaceProvider.CreateObjectSpace();
            var authenticationOid = (Guid)objectSpace.GetKeyValue(SecuritySystem.CurrentUser);

            if (objectSpace.GetObjectByKey <TAuth>(authenticationOid) == null)
            {
                var authentication = objectSpace.CreateObject <TAuth>();
                authentication.Oid = authenticationOid;
                saveToken(authentication, token);
                objectSpace.CommitChanges();
            }
        }
Exemple #18
0
        public static void AssertTask(this IObjectSpaceProvider objectSpaceProvider, Type cloudEntityType, Task task,
                                      string title, string notes, DateTime?due, string expectedStatus, string actualStatus, string taskId,
                                      string localTaskSubject)
        {
            title.ShouldBe(localTaskSubject);
            notes.ShouldBe(task.Description);
            due.ShouldNotBeNull();
            actualStatus.ShouldBe(expectedStatus);

            using (var space = objectSpaceProvider.CreateObjectSpace()){
                var cloudObjects = space.QueryCloudOfficeObject(cloudEntityType, task).ToArray();
                cloudObjects.Length.ShouldBe(1);
                var cloudObject = cloudObjects.First();
                cloudObject.LocalId.ShouldBe(task.Oid.ToString());
                cloudObject.CloudId.ShouldBe(taskId);
            }
        }
 private void EmployeeDetailForm_Load(object sender, EventArgs e)
 {
     security            = ((MainForm)MdiParent).Security;
     objectSpaceProvider = ((MainForm)MdiParent).ObjectSpaceProvider;
     securedObjectSpace  = objectSpaceProvider.CreateObjectSpace();
     if (employee == null)
     {
         employee = securedObjectSpace.CreateObject <Employee>();
     }
     else
     {
         employee = securedObjectSpace.GetObject(employee);
         deleteBarButtonItem.Enabled = security.CanDelete(employee);
     }
     employeeBindingSource.DataSource = employee;
     AddControls();
 }
 private void EmployeeDetailForm_Load(object sender, EventArgs e)
 {
     security            = ((MainForm)MdiParent).Security;
     objectSpaceProvider = ((MainForm)MdiParent).ObjectSpaceProvider;
     securedObjectSpace  = objectSpaceProvider.CreateObjectSpace();
     if (employee == null)
     {
         employee = securedObjectSpace.CreateObject <Employee>();
     }
     else
     {
         employee = securedObjectSpace.GetObject(employee);
         deleteBarButtonItem.Enabled = security.IsGranted(new PermissionRequest(securedObjectSpace, typeof(Employee), SecurityOperations.Delete, employee));
     }
     employeeBindingSource.DataSource = employee;
     AddControls();
 }
        public static void NewMicrosoftAuthentication(this IObjectSpaceProvider objectSpaceProvider, Platform platform = Platform.Win)
        {
            using (var manifestResourceStream = File.OpenRead($"{AppDomain.CurrentDomain.ApplicationPath()}\\AuthenticationData{platform}.json")){
                var token = Encoding.UTF8.GetBytes(new StreamReader(manifestResourceStream).ReadToEnd());
                using (var objectSpace = objectSpaceProvider.CreateObjectSpace()){
                    var authenticationOid = (Guid)objectSpace.GetKeyValue(SecuritySystem.CurrentUser);
                    if (objectSpace.GetObjectByKey <MSAuthentication>(authenticationOid) == null)
                    {
                        var authentication = objectSpace.CreateObject <MSAuthentication>();

                        authentication.Oid   = authenticationOid;
                        authentication.Token = token.GetString();
                        objectSpace.CommitChanges();
                    }
                }
            }
        }
Exemple #22
0
        public static void AssertEvent(this IObjectSpaceProvider objectSpaceProvider, Type cloudEntityType, Event @event,
                                       string title, DateTime?due, string taskId, string localEventSubject)
        {
            title.ShouldBe(localEventSubject);

            due.ShouldNotBeNull();


            using var space = objectSpaceProvider.CreateObjectSpace();
            var cloudObjects = space.QueryCloudOfficeObject(cloudEntityType, @event).ToArray();

            cloudObjects.Length.ShouldBe(1);
            var cloudObject = cloudObjects.First();

            cloudObject.LocalId.ShouldBe(@event.Oid.ToString());
            cloudObject.CloudId.ShouldBe(taskId);
        }
        public static async Task Populate_Modified <TEntity>(this IObjectSpaceProvider objectSpaceProvider,
                                                             Func <ICloudOfficeToken, IObservable <TEntity> > listEntities, IObservable <Unit> modified, TimeSpan timeout, Action <IObservable <TEntity> > assert)
        {
            using var objectSpace = objectSpaceProvider.CreateObjectSpace();
            var tokenStorage = objectSpace.CreateObject <CloudOfficeToken>();
            var storageToken = tokenStorage.Token;
            await Observable.Start(() => listEntities(tokenStorage).ToTask()).Merge().ToTaskWithoutConfigureAwait();

            await modified.Timeout(timeout);

            var entities = listEntities(tokenStorage).SubscribeReplay().Do(entity => { });
            await entities.Timeout(timeout);

            tokenStorage.Token.ShouldNotBeNull();
            tokenStorage.Token.ShouldNotBe(storageToken);

            assert(entities);
        }
        public static async Task Map_Two_New_Entity <TCloudEntity, TLocalEntity>(this IObjectSpaceProvider objectSpaceProvider, Func <IObjectSpace, TLocalEntity> localEntityFactory, TimeSpan timeout,
                                                                                 Func <IObjectSpace, IObservable <TCloudEntity> > synchronize, Action <TLocalEntity, TCloudEntity> assert)
        {
            var objectSpace  = objectSpaceProvider.CreateObjectSpace();
            var map          = synchronize(objectSpace).SubscribeReplay();
            var localEntity1 = localEntityFactory(objectSpace);

            objectSpace.CommitChanges();
            var localEntity2 = localEntityFactory(objectSpace);

            objectSpace.CommitChanges();

            await map.Take(2).Select((cloudEntity, i) => {
                var localEntity = i == 0 ? localEntity1 : localEntity2;
                assert(localEntity, cloudEntity);
                return(Unit.Default);
            }).Timeout(timeout);

            objectSpace.Dispose();
        }
Exemple #25
0
        public static Guid NewMicrosoftAuthentication(this IObjectSpaceProvider objectSpaceProvider)
        {
            var type = typeof(TodoServiceTests);

            using (var manifestResourceStream = type.Assembly.GetManifestResourceStream(type, "AuthenticationData.json")){
                var token = Encoding.UTF8.GetBytes(new StreamReader(manifestResourceStream ?? throw new InvalidOperationException()).ReadToEnd());
                using (var objectSpace = objectSpaceProvider.CreateObjectSpace()){
                    var authenticationOid = (Guid)objectSpace.GetKeyValue(SecuritySystem.CurrentUser);
                    if (objectSpace.GetObjectByKey <MSAuthentication>(authenticationOid) == null)
                    {
                        var authentication = objectSpace.CreateObject <MSAuthentication>();

                        authentication.Oid   = authenticationOid;
                        authentication.Token = token;
                        objectSpace.CommitChanges();
                    }

                    return(authenticationOid);
                }
            }
        }
Exemple #26
0
        public async Task TesteImportacaoTabelaAuxiliar()
        {
            var application = new Application(false);
            IObjectSpaceProvider objectSpaceProvider = application.serverApplication.ObjectSpaceProvider;
            var          objectSpace = objectSpaceProvider.CreateObjectSpace();
            var          parametros  = objectSpace.CreateObject <ParametrosAtualizacaoTabelasAuxiliares>();
            MemoryStream stream      = new MemoryStream();

            stream.Seek(0, SeekOrigin.Begin);
            var arquivo = parametros.Padrao;

            arquivo.SaveToStream(stream);
            stream.Seek(0, SeekOrigin.Begin);

            using (var excelReader = new Module.ExcelDataReaderHelper.Excel.Reader(stream))
            {
                var dtcollectionImport = excelReader.CreateDataTableCollection(false);

                var itba     = new ImportTabelaAuxiliares(objectSpace, parametros);
                var progress = new Progress <ImportProgressReport>(itba.LogTrace);

                await Observable.Start(() => itba.ImportarDiametro(dtcollectionImport["TabDiametro"], progress));

                await Observable.Start(() => itba.ImportarSchedule(dtcollectionImport["Schedule"], progress));

                await Observable.Start(() => itba.ImportarPercInspecao(dtcollectionImport["PercInspecao"], progress));

                await Observable.Start(() => itba.ImportarProcessoSoldagem(dtcollectionImport["ProcessoSoldagem"], progress));

                await Observable.Start(() => itba.ImportarContrato(dtcollectionImport["Contrato"], progress));

                await Observable.Start(() => itba.ImportarEAP(dtcollectionImport["EAPPipe"], progress));

                objectSpace.CommitChanges();
            }
        }
        public void ImportarComponente(DataTable dtSpoolsImport, IProgress <ImportProgressReport> progress)
        {
            var objectSpace   = _objectSpaceProvider.CreateObjectSpace();
            var TotalDeJuntas = dtSpoolsImport.Rows.Count;

            var oldComponets = Utils.GetOldDatasForCheck <Componente>(((XPObjectSpace)objectSpace).Session);

            progress.Report(new ImportProgressReport
            {
                TotalRows     = TotalDeJuntas,
                CurrentRow    = 0,
                MessageImport = "Inicializando importação"
            });

            for (int i = 0; i < TotalDeJuntas; i++)
            {
                if (i >= 3)
                {
                    var linha = dtSpoolsImport.Rows[i];
                    var documentoReferencia = linha[1].ToString();
                    var desenhoMontagem     = linha[2].ToString();
                    var transmital          = linha[3].ToString();
                    var peca = linha[4].ToString();

                    var criteriaOperator = CriteriaOperator.Parse("DesenhoMontagem = ? And Peca = ?",
                                                                  desenhoMontagem, peca);

                    var componente = objectSpace.FindObject <Componente>(criteriaOperator);

                    if (componente == null)
                    {
                        componente = objectSpace.CreateObject <Componente>();
                    }
                    else
                    {
                        oldComponets.FirstOrDefault(x => x.Oid == componente.Oid).DataExist = true;
                    }

                    //Mapear campos aqui
                    //componente.Contrato = contrato;

                    componente.Modulo = linha[0].ToString();
                    componente.DocumentoReferencia = documentoReferencia;
                    componente.DesenhoMontagem     = desenhoMontagem;
                    componente.Transmital          = transmital;
                    componente.Peca                 = peca;
                    componente.Revisao              = linha[5].ToString();
                    componente.TipoEstrutura        = linha[6].ToString();
                    componente.Posicao              = linha[7].ToString();
                    componente.Dwg                  = linha[8].ToString();
                    componente.Elevacao             = linha[9].ToString();
                    componente.PesoTotal            = Convert.ToDouble(linha[10]);
                    componente.AreaPintura          = Convert.ToDouble(linha[11]);
                    componente.RelatorioRecebimento = linha[14].ToString();
                    componente.DataRecebimento      = Utils.ConvertDateTime(linha[15]);
                    componente.ProgFitup            = linha[16].ToString();
                    componente.ProgWeld             = linha[17].ToString();
                    componente.ProgNdt              = linha[18].ToString();
                    componente.DataPosicionamento   = Utils.ConvertDateTime(linha[19]);
                    componente.RelatorioDimensional = linha[26].ToString();
                    componente.DataDimensional      = Utils.ConvertDateTime(linha[27]);
                    componente.ProgPintura          = linha[28].ToString();
                    componente.RelPintura           = linha[29].ToString();
                    componente.InspPintura          = linha[30].ToString();
                    componente.DataPintura          = Utils.ConvertDateTime(linha[31]);
                    componente.StatusPeca           = linha[32].ToString();
                }

                if (i % 1000 == 0)
                {
                    try
                    {
                        objectSpace.CommitChanges();
                    }
                    catch
                    {
                        objectSpace.Rollback();
                        throw new Exception("Process aborted by system");
                    }
                }

                progress.Report(new ImportProgressReport
                {
                    TotalRows     = TotalDeJuntas,
                    CurrentRow    = i + 1,
                    MessageImport = $"Importando linha {i}/{TotalDeJuntas}"
                });
            }

            objectSpace.CommitChanges();
            objectSpace.Dispose();

            progress.Report(new ImportProgressReport
            {
                TotalRows     = TotalDeJuntas,
                CurrentRow    = TotalDeJuntas,
                MessageImport = $"Gravando Alterações no Banco"
            });


            // Implatar funcionalidade
            //var excluirSpoolsNaoImportado = oldSpools.Where(x => x.DataExist = false);
        }
Exemple #28
0
 public IObjectSpace CreateObjectSpace()
 {
     return(_ObjectSpaceProvider.CreateObjectSpace());
 }
Exemple #29
0
 private IObjectSpace CreateObjectSpace()
 {
     return(_ObjectSpaceProvider.CreateObjectSpace());
 }
        private void Login(SecurityStrategyComplex security, IObjectSpaceProvider objectSpaceProvider)
        {
            IObjectSpace objectSpace = objectSpaceProvider.CreateObjectSpace();

            security.Logon(objectSpace);
        }