Ejemplo n.º 1
0
        public Group()
        {
            InstanceId = IDUtils.NewGuid();
            Id         = IDUtils.NewGuid();
            this.studyUnitRelPathNames = new List <string>();
            ConceptSchemeCompareTable  = new CompareTable()
            {
                CompareType = CompareTable.CompareTypes.ConceptScheme
            };
            ConceptCompareTable = new CompareTable()
            {
                CompareType = CompareTable.CompareTypes.Concept
            };
            VariableCompareTable = new CompareTable()
            {
                CompareType = CompareTable.CompareTypes.Variable
            };
            PurposeId       = IDUtils.NewGuid();
            ComparisonId    = IDUtils.NewGuid();
            SharedStudyUnit = new StudyUnit(); //Variables to be shared within the group
            SharedStudyUnit.Abstract.Title = SHARED_STUDY_UNIT_TITLE;
            Organization organization = new Organization();
            Member       member       = new Member();

            member.OrganizationId = organization.Id;
            SharedStudyUnit.AddMember(member);
            SharedStudyUnit.AddOrganization(organization);

            SharedStudyUnit.Samplings.Add(new Sampling());
            SharedStudyUnit.Samplings[0].MemberId  = member.Id;
            SharedStudyUnit.Samplings[0].DateRange = new DateRange(DateTime.Today, DateTime.Today);
        }
Ejemplo n.º 2
0
    public EntityChange(
        string auditLogId,
        EntityChangeInfo entityChangeInfo,
        string tenantId = null)
    {
        Id                 = IDUtils.NewIdString();
        AuditLogId         = auditLogId;
        TenantId           = tenantId;
        ChangeTime         = entityChangeInfo.ChangeTime;
        ChangeType         = entityChangeInfo.ChangeType;
        EntityId           = entityChangeInfo.EntityId.Truncate(EntityChangeConsts.MaxEntityTypeFullNameLength);
        EntityTypeFullName = entityChangeInfo.EntityTypeFullName.TruncateFromBeginning(EntityChangeConsts.MaxEntityTypeFullNameLength);

        PropertyChanges = entityChangeInfo
                          .PropertyChanges?
                          .Select(p => new EntityPropertyChange(Id, p, tenantId))
                          .ToList()
                          ?? new List <EntityPropertyChange>();

        ExtraProperties = new ExtraPropertyDictionary();
        if (entityChangeInfo.ExtraProperties != null)
        {
            foreach (var pair in entityChangeInfo.ExtraProperties)
            {
                ExtraProperties.Add(pair.Key, pair.Value);
            }
        }
    }
Ejemplo n.º 3
0
        public async Task IndexAsync()
        {
            //var post = new Post
            //{
            //    Title = "Hello World"
            //};
            //var request = new IndexRequest<Post>(post);
            //var response = _client.Index(post, idx => idx.Index("post"));

            var collection = new string[] { "A", "B", "C", "D" };

            foreach (var item in collection)
            {
                var user = new User
                {
                    Id   = IDUtils.NewId(),
                    Name = item
                };

                var request  = new IndexRequest <User>(user);
                var response = await _client.IndexAsync(user, idx => idx.Index(nameof(User).ToLower()));

                Assert.True(response.ApiCall.Success);
            }
        }
Ejemplo n.º 4
0
        public async Task <Tenant> CreateAsync(string name)
        {
            Check.NotNull(name, nameof(name));

            await ValidateNameAsync(name);

            return(new Tenant(IDUtils.NewId().ToString(), name));
        }
Ejemplo n.º 5
0
 public Response(Option type)
 {
     Id            = IDUtils.NewGuid();
     TypeCode      = type.Code;
     MissingValues = new List <MissingValue>();
     Layout        = null;
     Scale         = EDOConstants.DEF_SCALE;
 }
Ejemplo n.º 6
0
        public Response Dup()
        {
            Response newResponseModel = Clone() as Response;

            //replicate new answers itself
            newResponseModel.Id = IDUtils.NewGuid();
            return(newResponseModel);
        }
Ejemplo n.º 7
0
    protected virtual void TrySetGuidId(IEntity <Guid> entity)
    {
        if (entity.Id != default)
        {
            return;
        }

        EntityHelper.TrySetId(entity, IDUtils.NewIdString(), true);
    }
Ejemplo n.º 8
0
 protected virtual void SetId <TEntity>(TEntity entity)
 {
     if (entity is IEntity <string> entityWithStringId)
     {
         if (string.IsNullOrWhiteSpace(entityWithStringId.Id))
         {
             entityWithStringId.Id = IDUtils.NewId().ToString();
         }
     }
 }
Ejemplo n.º 9
0
 public ControlConstructScheme()
 {
     Id = IDUtils.NewGuid();
     QuestionConstructs      = new List <QuestionConstruct>();
     QuestionGroupConstructs = new List <QuestionGroupConstruct>();
     Statements         = new List <Statement>();
     IfThenElses        = new List <IfThenElse>();
     Sequence           = new Sequence();
     RenumberQuestionNo = true;
 }
Ejemplo n.º 10
0
 public DataFile()
 {
     Id = IDUtils.NewGuid();
     GrossRecordStructureId   = IDUtils.NewGuid();
     RecordLayoutId           = IDUtils.NewGuid();
     PhysicalRecordSegment    = "Segment_" + IDUtils.NewGuid();
     PhysicalInstanceId       = IDUtils.NewGuid();
     DataFileIdentificationId = IDUtils.NewGuid();
     GrossFileStructureId     = IDUtils.NewGuid();
 }
Ejemplo n.º 11
0
        /// <summary>
        /// 授权
        /// </summary>
        /// <param name="name"></param>
        /// <param name="providerKey"></param>
        /// <returns></returns>
        protected virtual async Task GrantAsync(string name, string providerKey)
        {
            var permissionGrant = await PermissionGrantRepository.FindAsync(name, Name, providerKey);

            if (permissionGrant != null)
            {
                return;
            }

            await PermissionGrantRepository.InsertAsync(new PermissionGrant(IDUtils.NewId(), name, Name, providerKey, CurrentTenant.Id));
        }
Ejemplo n.º 12
0
        public async Task SeedAsync(string providerName, string providerKey, IEnumerable <string> grantedPermissions, string tenantId = default)
        {
            foreach (var permissionName in grantedPermissions)
            {
                if (await PermissionGrantRepository.FindAsync(permissionName, providerName, providerKey) != null)
                {
                    continue;
                }

                await PermissionGrantRepository.InsertAsync(new PermissionGrant(IDUtils.NewId(), permissionName, providerName, providerKey, tenantId));
            }
        }
Ejemplo n.º 13
0
        public Sampling()
        {
            Id                    = IDUtils.NewGuid();
            DateRange             = new DateRange();
            CollectionEventId     = IDUtils.NewGuid();
            ModeOfCollectionId    = IDUtils.NewGuid();
            CollectionSituationId = IDUtils.NewGuid();

            Universes         = new List <Universe>();
            SamplingNumbers   = new List <SamplingNumber>();
            CollectorTypeCode = DefaultCollectorType;
        }
Ejemplo n.º 14
0
 public EntityPropertyChange(
     string entityChangeId,
     EntityPropertyChangeInfo entityChangeInfo,
     string tenantId = null)
 {
     Id                   = IDUtils.NewIdString();
     TenantId             = tenantId;
     EntityChangeId       = entityChangeId;
     NewValue             = entityChangeInfo.NewValue.Truncate(EntityPropertyChangeConsts.MaxNewValueLength);
     OriginalValue        = entityChangeInfo.OriginalValue.Truncate(EntityPropertyChangeConsts.MaxOriginalValueLength);
     PropertyName         = entityChangeInfo.PropertyName.TruncateFromBeginning(EntityPropertyChangeConsts.MaxPropertyNameLength);
     PropertyTypeFullName = entityChangeInfo.PropertyTypeFullName.TruncateFromBeginning(EntityPropertyChangeConsts.MaxPropertyTypeFullNameLength);
 }
Ejemplo n.º 15
0
        public async Task SearchAsync()
        {
            var user = new User
            {
                Id = IDUtils.NewId(),
            };


            var request  = new SearchRequest <User>();
            var response = await _client.SearchAsync <User>();

            Assert.True(response.ApiCall.Success);
        }
Ejemplo n.º 16
0
        public void CreateDocument()
        {
            var user = new User
            {
                Id   = IDUtils.NewId(),
                Name = DateTimeOffset.Now.ToString("yyyyMMddHHmmssfff")
            };

            var request = new CreateRequest <User>(user.Id);

            var response = _client.CreateDocument(user);

            Assert.True(response.ApiCall.Success);
        }
Ejemplo n.º 17
0
 public Coverage()
 {
     Id = IDUtils.NewGuid();
     TopicalCoverageId  = IDUtils.NewGuid();
     TemporalCoverageId = IDUtils.NewGuid();
     SpatialCoverageId  = IDUtils.NewGuid();
     //it is not possible to be managed by List <string> since memo and code must be stored in a set
     Topics    = new List <CheckOption>();
     Keywords  = new List <Keyword>();
     DateRange = new DateRange();
     Areas     = new List <CheckOption>();
     GeographicStructureIdSuffix = IDUtils.NewGuid();
     GeographicIdSuffix          = IDUtils.NewGuid();
 }
Ejemplo n.º 18
0
    /// <summary>
    /// Creates a new Edge between the given from- and to-node and adds it to the edges-list
    /// </summary>
    /// <param name="from">The start-node of the new edge</param>
    /// <param name="to">The end-node of the new edge</param>
    /// <returns>The newly created edge.</returns>
    public Edge CreateEdge(Node from, Node to)
    {
        //Debug.Log("Graph: Create Edge for From-Node " + from.Id + " and To-Node " + to.Id);
        // Declare and instantiate a new Edge between the given nodes with a unique ID...
        Edge newEdge = new Edge(
            this,
            IDUtils.GetUniqueID("Edge", string.Empty, this.edges, 10000),
            from, to);

        // ... add the new edge to the edges-list...
        AddEdge(newEdge);

        // ...and return the new edge.
        return(newEdge);
    }
Ejemplo n.º 19
0
        private static RenameResult RenameId(IIDPropertiesProvider obj, string propertyName, List <string> ids)
        {
            RenameResult result = new RenameResult(propertyName);
            string       id     = (string)PropertyPathHelper.GetValue(obj, propertyName);

            if (ids.Contains(id))
            {
                string newId = IDUtils.NewGuid();
                PropertyPathHelper.SetValue(obj, propertyName, newId);
                result.OldId = id;
                result.NewId = newId;
                return(result);
            }
            return(result);
        }
Ejemplo n.º 20
0
    /// <summary>
    /// Creates a new Node with the given position, generating a unique ID
    /// </summary>
    /// <param name="position"></param>
    /// <returns></returns>
    public Node CreateNode(Vector3 position)
    {
        //Debug.Log("Graph: Create Node at Position " + position);
        // Declare and instantiate a new node with a unique ID...
        Node newNode = new Node(
            this,
            IDUtils.GetUniqueID("Node", string.Empty, this.nodes, 10000),
            position);

        // ... add the node to the nodes-list...
        AddNode(newNode);

        // ... and return the new node.
        return(newNode);
    }
Ejemplo n.º 21
0
        public virtual async Task SetAsync(string name, string value, string providerName, string providerKey)
        {
            var setting = await SettingRepository.FindAsync(name, providerName, providerKey);

            if (setting == null)
            {
                setting = new Setting(IDUtils.NewIdString(), name, value, providerName, providerKey);
                await SettingRepository.InsertAsync(setting);
            }
            else
            {
                setting.Value = value;
                await SettingRepository.UpdateAsync(setting);
            }

            await Cache.SetAsync(CalculateCacheKey(name, providerName, providerKey), new SettingCacheItem(setting?.Value), considerUow : true);
        }
Ejemplo n.º 22
0
        public StudyUnit()
        {
            this.Id = IDUtils.NewGuid();                                        //1

            this.Events                  = new List <Event>();                  //*1
            this.Members                 = new List <Member>();                 //*2
            this.Organizations           = new List <Organization>();           //*3
            this.Abstract                = new Abstract();                      //*4
            this.Coverage                = new Coverage();                      //*5
            this.FundingInfos            = new List <FundingInfo>();            //*6
            this.Universes               = new List <Universe>();               //*7
            this.Samplings               = new List <Sampling>();               //*8
            this.ConceptSchemes          = new List <ConceptScheme>();          //*9
            this.Questions               = new List <Question>();               //*10
            this.CategorySchemes         = new List <CategoryScheme>();         //*11
            this.CodeSchemes             = new List <CodeScheme>();             //*12
            this.VariableScheme          = new VariableScheme();                //*13
            this.Variables               = new List <Variable>();               //*14
            this.DataSets                = new List <DataSet>();                //*15
            this.DataFiles               = new List <DataFile>();               //*16
            this.ControlConstructSchemes = new List <ControlConstructScheme>(); //*17
            this.QuestionGroups          = new List <QuestionGroup>();
            this.Books           = new List <Book>();
            this.StatisticsInfos = new List <StatisticsInfo>();

            this.InstanceId                  = IDUtils.NewGuid(); //2
            this.UniverseSchemeId            = IDUtils.NewGuid(); //3
            this.ConceptualComponentId       = IDUtils.NewGuid(); //4
            this.GeographicStructureSchemeId = IDUtils.NewGuid(); //5
            this.DataCollectionId            = IDUtils.NewGuid(); //6
            this.QuestionSchemeId            = IDUtils.NewGuid(); //7
            this.LogicalProductId            = IDUtils.NewGuid(); //8
            this.DataRelationshipId          = IDUtils.NewGuid(); //9
            this.PhysicalDataProductId       = IDUtils.NewGuid(); //10
            this.PhysicalStructureSchemeId   = IDUtils.NewGuid(); //11
            this.RecordLayoutSchemeId        = IDUtils.NewGuid(); //12
            this.ArchiveId            = IDUtils.NewGuid();        //13
            this.OrganizationSchemeId = IDUtils.NewGuid();        //14
            this.MethodologyId        = IDUtils.NewGuid();        //15
            this.ProcessingEventId    = IDUtils.NewGuid();        //16
        }
Ejemplo n.º 23
0
 public Sequence()
 {
     Id = IDUtils.NewGuid();
     ControlConstructIds = new List <string>();
 }
Ejemplo n.º 24
0
 public Universe()
 {
     IsMain = false;
     Id     = IDUtils.NewGuid();
     SamplingProcedureId = IDUtils.NewGuid();
 }
Ejemplo n.º 25
0
 public IfThenElse()
 {
     Id          = IDUtils.NewGuid();
     IfCondition = new IfCondition();
     ElseIfs     = new List <ElseIf>();
 }
Ejemplo n.º 26
0
 public QuestionConstruct()
 {
     Id = IDUtils.NewGuid();
 }
Ejemplo n.º 27
0
 public new void PickID()
 {
     ID = IDUtils.PickID <Quest>();
 }
Ejemplo n.º 28
0
 public IntegrationEvent()
 {
     Id        = IDUtils.GenerateId();
     Timestamp = DateTime.UtcNow.ToUnixTimeSeconds();
 }
Ejemplo n.º 29
0
 public Node(Graph graph, Vector3 position)
     : this(graph)
 {
     this.id        = IDUtils.GetUniqueID("Node", string.Empty, this.graph.Nodes, 10000);
     this._position = position;
 }
Ejemplo n.º 30
0
 public Statement()
 {
     Id = IDUtils.NewGuid();
 }