Ejemplo n.º 1
0
        private EntityExists IsClientRegistered()
        {
            var crit = new FilterExpression(LogicalOperator.And);

            crit.AddCondition(ClientIdentitiferAttributeName, ConditionOperator.Equal, ClientIdentifier);

            var existingClient = _OrganizationService.RetrieveMultiple(new QueryExpression(EntityName)
            {
                ColumnSet = new ColumnSet(NameAttributeName),
                Criteria  = crit
            });

            if (existingClient != null && existingClient.Entities != null && existingClient.Entities.Any())
            {
                if (existingClient.Entities.Count > 1)
                {
                    throw new Exception("There is more than 1 CrmSync client registered with the same server using the exact same client id. Each client should be registered using its own id.");
                }
                var client = existingClient.Entities[0];
                return(EntityExists.Yes(new EntityReference(EntityName, client.Id)));
            }
            else
            {
                return(EntityExists.No());
            }
        }
Ejemplo n.º 2
0
        public void NotesSlideExistsStorage()
        {
            TestUtils.Upload(c_fileName, c_folderName + "/" + c_fileName);
            EntityExists exists = TestUtils.SlidesApi.NotesSlideExists(c_fileName, c_slideIndex, c_password, c_folderName);

            Assert.IsTrue(exists.Exists.Value);
        }
Ejemplo n.º 3
0
        public void NotesSlideExistsRequest()
        {
            Stream       document = File.OpenRead(Path.Combine(TestUtils.TestDataPath, c_fileName));
            EntityExists exists   = TestUtils.SlidesApi.NotesSlideExistsOnline(document, c_slideIndex, c_password);

            Assert.IsTrue(exists.Exists.Value);
        }
        public override void Create(AbstractConnection connection, Process process, Entity entity)
        {
            if (EntityExists != null && EntityExists.Exists(connection, entity))
            {
                process.Logger.EntityWarn(entity.Name, "Trying to create entity that already exists! {0}", entity.Name);
                return;
            }

            var keyType = entity.IsMaster() ? FieldType.MasterKey : FieldType.PrimaryKey;

            var writer = process.StarEnabled && keyType == FieldType.MasterKey ?
                         new FieldSqlWriter(entity.Fields, entity.CalculatedFields, process.CalculatedFields, GetRelationshipFields(process.Relationships, entity)) :
                         new FieldSqlWriter(entity.Fields, entity.CalculatedFields);

            var primaryKey = writer.FieldType(keyType).Alias(connection.L, connection.R).Asc().Values();
            var defs       = new List <string>();

            defs.AddRange(writer
                          .Reload()
                          .AddBatchId(entity.Index)
                          .AddDeleted(entity)
                          .AddSurrogateKey(entity.Index)
                          .Output()
                          .Alias(connection.L, connection.R)
                          .DataType(new SqlServerDataTypeService())
                          .AppendIf(" NOT NULL", keyType)
                          .Values());

            var rowVersion = entity.Fields.WithSimpleType("rowversion").WithoutInput().WithoutOutput();

            if (rowVersion.Any())
            {
                var alias = rowVersion.First().Alias;
                defs.Add(connection.Enclose(alias) + " [ROWVERSION] NOT NULL");
            }

            var createSql = connection.TableQueryWriter.CreateTable(entity.OutputName(), defs);

            _logger.EntityDebug(entity.Name, createSql);

            var indexSql = connection.TableQueryWriter.AddUniqueClusteredIndex(entity.OutputName());

            _logger.EntityDebug(entity.Name, indexSql);

            var keySql = connection.TableQueryWriter.AddPrimaryKey(entity.OutputName(), primaryKey);

            _logger.EntityDebug(entity.Name, keySql);

            using (var cn = connection.GetConnection()) {
                cn.Open();
                cn.Execute(createSql);
                cn.Execute(indexSql);
                cn.Execute(keySql);
                _logger.EntityInfo(entity.Name, "Initialized {0} in {1} on {2}.", entity.OutputName(), connection.Database, connection.Server);
            }
        }