コード例 #1
0
 public bool Create(LookupTableModel model)
 {
     if (model == null)
     {
         throw new ArgumentException("The LookupTableModel is null.");
     }
     else
     {
         if (GetEntities().Any(item => item.Name == model.Name))
         {
             // No need to do anything currently
         }
         else
         {
             IEnumerable <LookupEntryCreationInformation> lstLookupEntry = CreateLookupEntry(model);
             IEnumerable <LookupMask>       lstLookupMask  = CreateLookupMask(model);
             LookupTableCreationInformation newLookupTable = new LookupTableCreationInformation()
             {
                 Id        = Guid.NewGuid(),
                 Name      = model.Name,
                 SortOrder = LookupTableSortOrder.Ascending,
                 Masks     = lstLookupMask,
                 Entries   = lstLookupEntry
             };
             bool result = ExcuteJobWithRetries(() =>
             {
                 LoggerHelper.Instance.Comment("About to Create LookupTable with Name: " + newLookupTable.Name);
                 LookupTable table = BaseProjectContext.LookupTables.Add(newLookupTable);
                 BaseProjectContext.LookupTables.Update();
                 BaseProjectContext.ExecuteQuery();
                 LoggerHelper.Instance.Comment("Finish Creating LookupTable with Name: " + newLookupTable.Name);
             },
                                                "Create LookupTable");
             return(result);
         }
     }
     return(true);
 }
コード例 #2
0
        private void CreateLookupTables()
        {
            for (int lookupTableCount = 1; lookupTableCount <= Convert.ToInt32(NUD_LTNumber.Value); lookupTableCount++)
            {
                List <LookupMask> masks = new List <LookupMask>();
                for (int levelCount = 0; levelCount <= Convert.ToInt32(NUD_Levels.Value); levelCount++)
                {
                    LookupMask lkm = new LookupMask
                    {
                        Length    = 0,
                        MaskType  = LookupTableMaskSequence.CHARACTERS,
                        Separator = "."
                    };
                    masks.Add(lkm);
                }

                List <LookupEntryCreationInformation> lookupEntry = new List <LookupEntryCreationInformation>();
                for (int levelCount = 1; levelCount <= Convert.ToInt32(NUD_Levels.Value); levelCount++)
                {
                    //creating the parent level
                    LookupEntryCreationInformation parentCi = new LookupEntryCreationInformation
                    {
                        Id        = Guid.NewGuid(),
                        SortIndex = 0,
                        Value     =
                            new LookupEntryValue {
                            TextValue = RandomEx.RandomString(Convert.ToInt32(NUD_Length.Value))
                        }
                    };
                    lookupEntry.Add(parentCi);

                    //creating the child levels
                    for (int subLevel = 1; subLevel <= Convert.ToInt32(NUD_ValuePerLevel.Value); subLevel++)
                    {
                        LookupEntryCreationInformation childCi = new LookupEntryCreationInformation
                        {
                            Id        = Guid.NewGuid(),
                            ParentId  = parentCi.Id,
                            SortIndex = 0,
                            Value     =
                                new LookupEntryValue
                            {
                                TextValue = RandomEx.RandomString(Convert.ToInt32(NUD_Length.Value))
                            }
                        };
                        lookupEntry.Add(childCi);
                    }
                }

                LookupTableSortOrder lookupTableSortOrder = LookupTableSortOrder.Ascending;
                CB_Sort.InvokeIfRequired(cb => lookupTableSortOrder = (LookupTableSortOrder)cb.SelectedValue);

                LookupTableCreationInformation ltCi = new LookupTableCreationInformation
                {
                    Name      = TB_Name.Text + lookupTableCount,
                    Masks     = masks,
                    SortOrder = lookupTableSortOrder,
                    Entries   = lookupEntry
                };
                Log.WriteVerbose(new SourceInfo(), TB_Status, "Creating lookup field with name {0}", ltCi.Name);
                ProjContext.LookupTables.Add(ltCi);
            }
            ProjContext.LookupTables.Update();
            ProjContext.ExecuteQuery();
        }
コード例 #3
0
        private void CreateLookupTables()
        {
            for (int lookupTableCount = 1; lookupTableCount <= Convert.ToInt32(NUD_LTNumber.Value); lookupTableCount++)
            {
                List<LookupMask> masks = new List<LookupMask>();
                for (int levelCount = 0; levelCount <= Convert.ToInt32(NUD_Levels.Value); levelCount++)
                {
                    LookupMask lkm = new LookupMask
                    {
                        Length = 0,
                        MaskType = LookupTableMaskSequence.CHARACTERS,
                        Separator = "."
                    };
                    masks.Add(lkm);
                }

                List<LookupEntryCreationInformation> lookupEntry = new List<LookupEntryCreationInformation>();
                for (int levelCount = 1; levelCount <= Convert.ToInt32(NUD_Levels.Value); levelCount++)
                {
                    //creating the parent level
                    LookupEntryCreationInformation parentCi = new LookupEntryCreationInformation
                    {
                        Id = Guid.NewGuid(),
                        SortIndex = 0,
                        Value =
                            new LookupEntryValue { TextValue = RandomEx.RandomString(Convert.ToInt32(NUD_Length.Value)) }
                    };
                    lookupEntry.Add(parentCi);

                    //creating the child levels
                    for (int subLevel = 1; subLevel <= Convert.ToInt32(NUD_ValuePerLevel.Value); subLevel++)
                    {
                        LookupEntryCreationInformation childCi = new LookupEntryCreationInformation
                        {
                            Id = Guid.NewGuid(),
                            ParentId = parentCi.Id,
                            SortIndex = 0,
                            Value =
                                new LookupEntryValue
                                {
                                    TextValue = RandomEx.RandomString(Convert.ToInt32(NUD_Length.Value))
                                }
                        };
                        lookupEntry.Add(childCi);
                    }
                }

                LookupTableSortOrder lookupTableSortOrder = LookupTableSortOrder.Ascending;
                CB_Sort.InvokeIfRequired(cb => lookupTableSortOrder = (LookupTableSortOrder)cb.SelectedValue);

                LookupTableCreationInformation ltCi = new LookupTableCreationInformation
                {
                    Name = TB_Name.Text + lookupTableCount,
                    Masks = masks,
                    SortOrder = lookupTableSortOrder,
                    Entries = lookupEntry
                };
                Log.WriteVerbose(new SourceInfo(), TB_Status, "Creating lookup field with name {0}", ltCi.Name);
                ProjContext.LookupTables.Add(ltCi);
            }
            ProjContext.LookupTables.Update();
            ProjContext.ExecuteQuery();
        }