public void UpdateRelatedRecords( SiteSettings ss, RdsUser rdsUser = null, bool addUpdatedTimeParam = true, bool addUpdatorParam = true, bool updateItems = true) { Rds.ExecuteNonQuery( rdsUser: rdsUser, transactional: true, statements: new SqlStatement[] { Rds.UpdateItems( where : Rds.ItemsWhere().ReferenceId(WikiId), param: Rds.ItemsParam() .SiteId(SiteId) .Title(WikiUtilities.TitleDisplayValue(ss, this)), addUpdatedTimeParam: addUpdatedTimeParam, addUpdatorParam: addUpdatorParam, _using: updateItems), Rds.PhysicalDeleteLinks( where : Rds.LinksWhere().SourceId(WikiId)), InsertLinks(ss), Rds.UpdateSites( where : Rds.SitesWhere().SiteId(SiteId), param: Rds.SitesParam().Title(Title.Value)) }); Libraries.Search.Indexes.Create(ss, this); }
public Error.Types Create( SiteSettings ss, RdsUser rdsUser = null, Sqls.TableTypes tableType = Sqls.TableTypes.Normal, SqlParamCollection param = null, bool notice = false, bool paramAll = false) { var statements = CreateStatements(ss, tableType, param, paramAll); var newId = Rds.ExecuteScalar_long( rdsUser: rdsUser, transactional: true, statements: statements.ToArray()); WikiId = newId != 0 ? newId : WikiId; if (Contract.Notice() && notice) { CheckNotificationConditions(ss); Notice(ss, "Created"); } Get(ss); Rds.ExecuteNonQuery( rdsUser: rdsUser, statements: Rds.UpdateItems( param: Rds.ItemsParam() .Title(WikiUtilities.TitleDisplayValue(ss, this)), where : Rds.ItemsWhere().ReferenceId(WikiId))); Libraries.Search.Indexes.Create(ss, this); return(Error.Types.None); }
private void Notice(SiteSettings ss, string type) { var title = WikiUtilities.TitleDisplayValue(ss, this); var url = Url.AbsoluteUri().Replace( Url.AbsolutePath(), Locations.ItemEdit(WikiId)); ss.Notifications.Where(o => o.Enabled).ForEach(notification => { if (notification.HasRelatedUsers()) { var users = new List <long>(); Rds.ExecuteTable(statements: Rds.SelectWikis( tableType: Sqls.TableTypes.All, distinct: true, column: Rds.WikisColumn() .Creator() .Updator(), where : Rds.WikisWhere().WikiId(WikiId))) .AsEnumerable() .ForEach(dataRow => { users.Add(dataRow["Creator"].ToLong()); users.Add(dataRow["Updator"].ToLong()); }); notification.ReplaceRelatedUsers(users); } switch (type) { case "Created": notification.Send( Displays.Created(title).ToString(), url, NoticeBody(ss, notification)); break; case "Updated": var body = NoticeBody(ss, notification, update: true); if (body.Length > 0) { notification.Send( Displays.Updated(title).ToString(), url, body); } break; case "Deleted": notification.Send( Displays.Deleted(title).ToString(), url, NoticeBody(ss, notification)); break; } }); }
private void Set(SiteSettings ss, DataRow dataRow) { AccessStatus = Databases.AccessStatuses.Selected; foreach (DataColumn dataColumn in dataRow.Table.Columns) { var name = dataColumn.ColumnName; switch (name) { case "SiteId": if (dataRow[name] != DBNull.Value) { SiteId = dataRow[name].ToLong(); SavedSiteId = SiteId; } break; case "UpdatedTime": if (dataRow[name] != DBNull.Value) { UpdatedTime = new Time(dataRow, "UpdatedTime"); Timestamp = dataRow.Field <DateTime>("UpdatedTime").ToString("yyyy/M/d H:m:s.fff"); SavedUpdatedTime = UpdatedTime.Value; } break; case "WikiId": if (dataRow[name] != DBNull.Value) { WikiId = dataRow[name].ToLong(); SavedWikiId = WikiId; } break; case "Ver": Ver = dataRow[name].ToInt(); SavedVer = Ver; break; case "Title": Title = new Title(dataRow, "WikiId"); SavedTitle = Title.Value; break; case "Body": Body = dataRow[name].ToString(); SavedBody = Body; break; case "Comments": Comments = dataRow["Comments"].ToString().Deserialize <Comments>() ?? new Comments(); SavedComments = Comments.ToJson(); break; case "Creator": Creator = SiteInfo.User(dataRow.Int(name)); SavedCreator = Creator.Id; break; case "Updator": Updator = SiteInfo.User(dataRow.Int(name)); SavedUpdator = Updator.Id; break; case "CreatedTime": CreatedTime = new Time(dataRow, "CreatedTime"); SavedCreatedTime = CreatedTime.Value; break; case "IsHistory": VerType = dataRow[name].ToBool() ? Versions.VerTypes.History : Versions.VerTypes.Latest; break; } } if (ss != null) { Title.DisplayValue = WikiUtilities.TitleDisplayValue(ss, this); } }