예제 #1
0
        public Error.Types Update(
            Context context,
            SiteSettings ss,
            IEnumerable <string> permissions = null,
            bool permissionChanged           = false,
            bool extendedSqls                  = true,
            bool synchronizeSummary            = true,
            bool forceSynchronizeSourceSummary = false,
            bool notice = false,
            SqlParamCollection param = null,
            List <SqlStatement> additionalStatements = null,
            bool otherInitValue = false,
            bool setBySession   = true,
            bool get            = true)
        {
            if (context.ContractSettings.Notice != false && notice)
            {
                CheckNotificationConditions(context: context, ss: ss, before: true);
            }
            if (setBySession)
            {
                SetBySession(context: context);
            }
            var timestamp  = Timestamp.ToDateTime();
            var statements = new List <SqlStatement>();

            if (extendedSqls)
            {
                statements.OnUpdatingExtendedSqls(SiteId, WikiId, timestamp);
            }
            UpdateStatements(
                context: context,
                ss: ss,
                statements: statements,
                timestamp: timestamp,
                param: param,
                otherInitValue: otherInitValue,
                additionalStatements: additionalStatements);
            if (permissionChanged)
            {
                statements.UpdatePermissions(context, ss, WikiId, permissions);
            }
            var response = Rds.ExecuteScalar_response(
                context: context,
                transactional: true,
                statements: statements.ToArray());

            if (response.Count == 0)
            {
                return(Error.Types.UpdateConflicts);
            }
            if (Title_Updated(context: context))
            {
                Rds.ExecuteNonQuery(
                    context: context,
                    statements: new SqlStatement[]
                {
                    Rds.UpdateSites(
                        where : Rds.SitesWhere()
                        .TenantId(context.TenantId)
                        .SiteId(SiteId),
                        param: Rds.SitesParam().Title(Title.Value),
                        addUpdatedTimeParam: false,
                        addUpdatorParam: false),
                    StatusUtilities.UpdateStatus(
                        tenantId: context.TenantId,
                        type: StatusUtilities.Types.SitesUpdated)
                });
            }
            if (context.ContractSettings.Notice != false && notice)
            {
                CheckNotificationConditions(context: context, ss: ss);
                Notice(context: context, ss: ss, type: "Updated");
            }
            if (get)
            {
                Get(context: context, ss: ss);
            }
            UpdateRelatedRecords(context: context, ss: ss, extendedSqls: extendedSqls);
            if (get && Rds.ExtendedSqls(SiteId, WikiId)?.Any(o => o.OnUpdated) == true)
            {
                Get(context: context, ss: ss);
            }
            SiteInfo.Reflesh(context: context);
            return(Error.Types.None);
        }