Example #1
0
        private async Task Handle_DriverProfiles(LogicParameter lp)
        {
            bool bUpdateProfiles =
                (lp.Session.MetaData().IsTableEnabled("DriverProfile")
                 &&
                 (
                     lp.Entity.Columns["Ident_Driver"].IsDifferent ||
                     lp.Entity.Columns["Ident_Language"].IsDifferent ||
                     lp.Entity.Columns["Ident_Sectionname"].IsDifferent ||
                     lp.Entity.Columns["Version"].IsDifferent ||
                     lp.Entity.Columns["Ident_OS"].IsDifferent
                 )
                );

            if (!bUpdateProfiles)
            {
                return;
            }

            ISqlFormatter fSQL = lp.SqlFormatter;

            string strWhereClause = fSQL.AndRelation(
                fSQL.UidComparison("UID_Driver", lp.Entity.GetValue <string>("UID_Driver")),
                fSQL.OrRelation(
                    fSQL.Comparison("UpdatePathVII", false, ValType.Bool),
                    fSQL.Comparison("UpdateProfileVII", false, ValType.Bool))

                );

            Query qDriverProfile = Query.From("DriverProfile")
                                   .Where(strWhereClause)
                                   .SelectAll();

            IEntityCollection colDriverProfile = await lp.Session.Source().GetCollectionAsync(qDriverProfile, EntityCollectionLoadType.Bulk, lp.CancellationToken).ConfigureAwait(false);

            foreach (IEntity eDriverProfile in colDriverProfile)
            {
                // set the flags
                eDriverProfile.SetValue("UpdatePathVII", true);
                eDriverProfile.SetValue("UpdateProfileVII", true);

                // and save
                await lp.UnitOfWork.PutAsync(eDriverProfile).ConfigureAwait(false);
            }
        }