コード例 #1
0
        public static List <HrbcOptionCreator.Spec> InitOptionCreator(HrbcOptionSearch phaseList, int numberOfOptions)
        {
            var specs = new List <HrbcOptionCreator.Spec>();

            foreach (var item in PhaseHelper.GetResourcesHavePhase())
            {
                for (int i = 0; i < numberOfOptions; i++)
                {
                    specs.Add(new HrbcOptionCreator.Spec
                    {
                        //Alias = $"Option.U_My{item}Phase{i}",
                        Name     = $"Test {item} phase {i}",
                        ParentId = GetParentOptionId(item, phaseList),
                        Key      = $"{item}{i}",
                        Type     = optionType[item],
                        Sort     = i + 1 + GetParentChildCount(item, phaseList),
                        Children = new List <HrbcOptionCreator.Spec>
                        {
                            new HrbcOptionCreator.Spec {
                                Name = $"Test {item} child 1 phase {i}", Key = $"{item}{i}child1", Type = optionType[item], Sort = 1
                            },
                            new HrbcOptionCreator.Spec {
                                Name = $"Test {item} child 2 phase {i}", Key = $"{item}{i}child2", Type = optionType[item], Sort = 2
                            },
                            new HrbcOptionCreator.Spec {
                                Name = $"Test {item} child 3 phase {i}", Key = $"{item}{i}child3", Type = optionType[item], Sort = 3
                            },
                        }
                    });
                }
            }
            return(specs);
        }
コード例 #2
0
        public static Dictionary <Enums.ResourceType, Dictionary <string, OptionSearchContent> > InitPhaseList(HrbcOptionSearch phaseSearcher)
        {
            //Dictionary -> key Phase Id, value Phase Alias
            var phaseDictionary = new Dictionary <Enums.ResourceType, Dictionary <string, OptionSearchContent> >();

            foreach (var resourceType in PhaseHelper.GetResourcesHavePhase())
            {
                var resourceRootPhase = phaseSearcher.Data.Options.SingleOrDefault(op => op.Alias == $"Option.P_{resourceType.ToResourceName()}Phase");
                Dictionary <string, OptionSearchContent> listIdAlias = GetChildPhaseList(resourceRootPhase);
                listIdAlias.Add(resourceRootPhase.Id.ToString(), resourceRootPhase);
                phaseDictionary.Add(resourceType, listIdAlias);
            }
            return(phaseDictionary);
        }
コード例 #3
0
 /// <summary>
 /// Update all records to last phase
 /// </summary>
 /// <param name="records">HrbcGetPhaseIdRecordCreator</param>
 /// <returns></returns>
 public static UpdateRecordRequest.IBuilderWithResource InitRecordsDefaultUpdater(HrbcGetPhaseIdRecordCreator records)
 {
     UpdateRecordRequest.IBuilder result = ResourceRequest.UpdateRecords();
     foreach (var value in records.Data.Values.Where(val => val.Records.ResourceType != Enums.ResourceType.Contract))
     {
         result.AddContent(value.Records.ResourceType.ToPrivateEnum(), value.Records.Id,
                           content => content.AddField(
                               new HrbcField(value.Records.ResourceType.ToPrivateEnum(), "P_PhaseDate", ResourceType.Standard), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                               ).
                           AddField(
                               new HrbcField(value.Records.ResourceType.ToPrivateEnum(), "P_Phase", ResourceType.Standard), PhaseHelper.GetLastPhaseOptionId(value.Records.ResourceType)
                               )
                           );
     }
     return(result as UpdateRecordRequest.IBuilderWithResource);
 }
コード例 #4
0
 /// <summary>
 /// Update record that specified resource type and hrbc record to index of phase list
 /// </summary>
 /// <param name="records">HrbcGetPhaseIdRecordCreator</param>
 /// <param name="resourceType">Resource type</param>
 /// <param name="resourceIndex">Resource index</param>
 /// <param name="index">Index of phase list</param>
 /// <returns></returns>
 public static UpdateRecordRequest.IBuilderWithResource InitRecordsUpdater(HrbcGetPhaseIdRecordCreator records, Enums.ResourceType resourceType, int resourceIndex = 0, int index = 0)
 {
     UpdateRecordRequest.IBuilder result = ResourceRequest.UpdateRecords();
     result.AddContent(resourceType.ToPrivateEnum(), records.Data[$"{resourceType.ToPrivateEnum()}{resourceIndex}"].Records.Id,
                       content => content.AddField(
                           new HrbcField(resourceType.ToPrivateEnum(), "P_PhaseDate", ResourceType.Standard), DateTime.Now.AddSeconds(index).ToString("yyyy-MM-dd HH:mm:ss")
                           ).
                       AddField(
                           new HrbcField(resourceType.ToPrivateEnum(), "P_Phase", ResourceType.Standard), PhaseHelper.GetLastPhaseOptionId(resourceType, index)
                           )
                       );
     return(result as UpdateRecordRequest.IBuilderWithResource);
 }