Beispiel #1
0
        /// <summary>
        /// Handles the message.
        /// </summary>
        /// <param name="message">The message.</param>
        public void HandleMessage(ICarryChangeStateMessage message)
        {
            var stateChange = message.Payload;

            if (stateChange == BusyState.IsBusy)
            {
                _interactionStack.Push(CurrentState);
                CurrentState = InteractionState.IsBusy;
                return;
            }

            if (stateChange == BusyState.ClearState)
            {
                _interactionStack.Clear();
                CurrentState = InteractionState.Idle;
                return;
            }

            if (It.HasValues(_interactionStack))
            {
                var lastState = _interactionStack.Pop();
                CurrentState = lastState;
            }
        }
Beispiel #2
0
 /// <summary>
 /// Condition met.
 /// </summary>
 /// <param name="learnerHE">The learner he.</param>
 /// <param name="learningDeliveries">The learning deliveries.</param>
 /// <returns>true if any any point the conditions are met</returns>
 public bool ConditionMet(ILearnerHE learnerHE, IReadOnlyCollection <ILearningDelivery> learningDeliveries)
 {
     return(It.Has(learnerHE)
         ? It.HasValues(learningDeliveries) && learningDeliveries.Any(d => It.Has(d.LearningDeliveryHEEntity))
         : true);
 }
 /// <summary>
 /// Condition met.
 /// </summary>
 /// <param name="financialSupport">The financial support.</param>
 /// <returns>
 /// true if any any point the conditions are met
 /// </returns>
 public bool ConditionMet(IReadOnlyCollection <ILearnerHEFinancialSupport> financialSupport)
 {
     return(It.HasValues(financialSupport)
         ? financialSupport.All(x => _lookupDetails.Contains(LookupSimpleKey.FINTYPE, x.FINTYPE))
         : true);
 }
        //public SQLTable(string name, SQLTable parent)//, SQLSchema schema)
        //{
        //    Name = name;
        //    Parent = parent;
        //    //Schema = schema;
        //}

        //public string GetCreateTableSQL()
        //{
        //    string tableName = Name;// Schema.TableNamePrefix + Name;
        //    string sql = $"create table [{tableName}] (";
        //    //if (Schema.IncludeFileId && Name != "__File")
        //    //    sql += "[PK_File] int,";
        //    sql += "[PK_" + Name + "] int,";
        //    if (It.Has(Parent))
        //        sql += "[FK_" + Parent.Name + "] int not null,";
        //    sql += string.Join(",", Columns.Select(x => x.GetCreateColumnSQL()));
        //    sql += $" constraint {tableName}_PK primary key ([PK_{Name}]))";

        //    return sql;
        //}

        //public string GetCreateTableWithIdentitySQL()
        //{
        //    string tableName = Name; // Schema.TableNamePrefix + Name;
        //    string sql = "create table [" + tableName + "] (";
        //    //if (Schema.IncludeFileId && Name != "__File")
        //    //    sql += "[PK_File] int,";
        //    sql += "[PK_" + Name + "] int identity,";
        //    if (It.Has(Parent))
        //    {
        //        sql += "[FK_" + Parent.Name + "] int not null,";
        //    }
        //    sql += string.Join(",", Columns.Select(x => x.GetCreateColumnSQL()));
        //    sql += $" constraint {tableName}_PK primary key ([PK_{Name}]))";

        //    return sql;
        //}

        public string GetParentForeignKeyPart(SQLTable parent)
        {
            return(It.Has(Parent) && It.HasValues(Parent.Columns)
                ? $"[FK_{Parent.Name}] int not null,"
                : string.Empty);
        }
        //public string CreateMainIndexSQL()
        //{
        //    string tableName = Schema.TableNamePrefix + Name;
        //    string sql = "create index [IDX_" + tableName + "] on [" + tableName + "] (";
        //    if (Schema.IncludeFileId)
        //        sql += "[PK_File] asc,";
        //    if (Parent != null)
        //        sql += "[FK_" + Parent.Name + "] asc,";
        //    sql += "[PK_" + Name + "] asc)";

        //    return sql;
        //}

        public string GetParentIndexPart(SQLTable parent)
        {
            return(It.Has(Parent) && It.HasValues(Parent.Columns)
                ? $"[FK_{Parent.Name}] asc,"
                : string.Empty);
        }
Beispiel #6
0
 /// <summary>
 /// Condition met.
 /// </summary>
 /// <param name="thisDelivery">this learning delivery.</param>
 /// <returns>
 /// true if any any point the conditions are met
 /// </returns>
 public bool ConditionMet(ILearningDelivery thisDelivery)
 {
     return(It.Has(thisDelivery)
         ? It.HasValues(thisDelivery.AppFinRecords)
         : true);
 }
 /// <summary>
 /// Condition met.
 /// </summary>
 /// <param name="thisDelivery">this delivery.</param>
 /// <returns>
 /// true if any any point the conditions are met
 /// </returns>
 public bool ConditionMet(ILearningDelivery thisDelivery)
 {
     return(It.Has(thisDelivery)
         ? It.HasValues(thisDelivery.LearningDeliveryWorkPlacements)
         : true);
 }
Beispiel #8
0
 /// <summary>
 /// Determines whether [has qualifying eligibility] [the specified postcode].
 /// </summary>
 /// <param name="delivery">The latest learnstartdate delivery.</param>
 /// <param name="postcodes">The postcode.</param>
 /// <param name="eligibilities">The eligibilities.</param>
 /// <returns>
 ///   <c>true</c> if [has qualifying eligibility] [the specified postcode]; otherwise, <c>false</c>.
 /// </returns>
 public bool HasQualifyingEligibility(ILearningDelivery delivery, IReadOnlyCollection <IONSPostcode> postcodes, IReadOnlyCollection <TEligibilityItem> eligibilities) =>
 It.HasValues(postcodes) &&
 It.HasValues(eligibilities) &&
 It.Has(delivery) &&
 HasAnyQualifyingEligibility(delivery, postcodes, eligibilities.Select(x => x.Code).AsSafeDistinctKeySet());
Beispiel #9
0
 /// <summary>
 /// Condition met.
 /// </summary>
 /// <param name="financialSupport">The financial support.</param>
 /// <returns>
 /// true if any any point the conditions are met
 /// </returns>
 public bool ConditionMet(IReadOnlyCollection <ILearnerHEFinancialSupport> financialSupport)
 {
     return(It.HasValues(financialSupport)
         ? _lookupDetails.Get(TypeOfIntegerCodedLookup.FINTYPE).All(x => financialSupport.Count(y => y.FINTYPE == x) <= 1)
         : true);
 }
 /// <summary>
 /// Determines whether [has completed course] [the specified learner].
 /// </summary>
 /// <param name="learner">The learner.</param>
 /// <returns>
 ///   <c>true</c> if [has completed course] [the specified learner]; otherwise, <c>false</c>.
 /// </returns>
 public bool HasCompletedCourse(ILearner learner) =>
 It.HasValues(learner.LearningDeliveries) &&
 learner.LearningDeliveries.SafeAll(HasCompletedCourse);
 /// <summary>
 /// Condition met.
 /// </summary>
 /// <param name="financialSupport">The financial support.</param>
 /// <returns>
 /// true if any any point the conditions are met
 /// </returns>
 public bool ConditionMet(IReadOnlyCollection <ILearnerHEFinancialSupport> financialSupport)
 {
     return(It.HasValues(financialSupport)
         ? _lookupDetails.AsASet(LookupSimpleKey.FINTYPE).All(x => financialSupport.Count(y => y.FINTYPE == x) <= 1)
         : true);
 }
Beispiel #12
0
        private void AddTablesToBulkLoadSchemaWithIdentity(XmlNode currentSchemaNode, XmlNode currentTableNode, Dictionary <string, string> tableRelationships)
        {
            foreach (XmlElement tableElement in currentTableNode.ChildNodes)
            {
                var schemaElement = currentSchemaNode.OwnerDocument.CreateElement("xsd", "element", "http://www.w3.org/2001/XMLSchema");
                schemaElement.SetAttribute("name", tableElement.Name);
                if (!Tables.Get(tableElement.Name).Columns.Any())
                {
                    var isConstant = currentSchemaNode.OwnerDocument.CreateAttribute("sql", "is-constant", "urn:schemas-microsoft-com:mapping-schema");
                    isConstant.Value = "1";
                    schemaElement.Attributes.Append(isConstant);
                }
                else
                {
                    var sqlRelation = currentSchemaNode.OwnerDocument.CreateAttribute("sql", "relation", "urn:schemas-microsoft-com:mapping-schema");
                    sqlRelation.Value = tableElement.Name;
                    schemaElement.Attributes.Append(sqlRelation);

                    if (tableRelationships.ContainsKey(tableElement.Name))
                    {
                        var sqlRelationship = currentSchemaNode.OwnerDocument.CreateAttribute("sql", "relationship", "urn:schemas-microsoft-com:mapping-schema");
                        sqlRelationship.Value = tableRelationships[tableElement.Name];
                        schemaElement.Attributes.Append(sqlRelationship);
                    }
                }

                currentSchemaNode.AppendChild(schemaElement);

                var complexType = currentSchemaNode.OwnerDocument.CreateElement("xsd", "complexType", "http://www.w3.org/2001/XMLSchema");
                schemaElement.AppendChild(complexType);
                var sequence = currentSchemaNode.OwnerDocument.CreateElement("xsd", "sequence", "http://www.w3.org/2001/XMLSchema");
                complexType.AppendChild(sequence);

                var thisTable = Tables.Get(tableElement.Name);

                if (It.HasValues(thisTable.Columns))
                {
                    var primaryKeyElement = currentSchemaNode.OwnerDocument.CreateElement("xsd", "element", "http://www.w3.org/2001/XMLSchema");
                    primaryKeyElement.SetAttribute("name", "PK_" + thisTable.Name);
                    primaryKeyElement.SetAttribute("type", "xsd:int");
                    var sqlTypeAttribute = currentSchemaNode.OwnerDocument.CreateAttribute("sql", "datatype", "urn:schemas-microsoft-com:mapping-schema");
                    sqlTypeAttribute.Value = "int";
                    primaryKeyElement.Attributes.Append(sqlTypeAttribute);
                    sequence.AppendChild(primaryKeyElement);

                    if (thisTable.Parent != null && thisTable.Parent.Columns.Any())
                    {
                        var parentKeyElement = currentSchemaNode.OwnerDocument.CreateElement("xsd", "element", "http://www.w3.org/2001/XMLSchema");
                        parentKeyElement.SetAttribute("name", "FK_" + thisTable.Parent.Name);
                        parentKeyElement.SetAttribute("type", "xsd:int");
                        sqlTypeAttribute       = currentSchemaNode.OwnerDocument.CreateAttribute("sql", "datatype", "urn:schemas-microsoft-com:mapping-schema");
                        sqlTypeAttribute.Value = "int";
                        parentKeyElement.Attributes.Append(sqlTypeAttribute);
                        sequence.AppendChild(parentKeyElement);
                    }
                }

                thisTable.Columns.ForEach(column => sequence.AppendChild(ConvertColumnToElement(column, currentSchemaNode)));

                AddTablesToBulkLoadSchemaWithIdentity(sequence, tableElement, tableRelationships);
            }
        }