public void SetByModel(TenantModel tenantModel) { TenantName = tenantModel.TenantName; Title = tenantModel.Title; Body = tenantModel.Body; ContractSettings = tenantModel.ContractSettings; ContractDeadline = tenantModel.ContractDeadline; DisableAllUsersPermission = tenantModel.DisableAllUsersPermission; DisableStartGuide = tenantModel.DisableStartGuide; LogoType = tenantModel.LogoType; HtmlTitleTop = tenantModel.HtmlTitleTop; HtmlTitleSite = tenantModel.HtmlTitleSite; HtmlTitleRecord = tenantModel.HtmlTitleRecord; Comments = tenantModel.Comments; Creator = tenantModel.Creator; Updator = tenantModel.Updator; CreatedTime = tenantModel.CreatedTime; UpdatedTime = tenantModel.UpdatedTime; VerUp = tenantModel.VerUp; Comments = tenantModel.Comments; ClassHash = tenantModel.ClassHash; NumHash = tenantModel.NumHash; DateHash = tenantModel.DateHash; DescriptionHash = tenantModel.DescriptionHash; CheckHash = tenantModel.CheckHash; AttachmentsHash = tenantModel.AttachmentsHash; }
public void SetByApi(IContext context, SiteSettings ss) { var data = context.RequestDataString.Deserialize <TenantApiModel>(); if (data == null) { return; } if (data.TenantName != null) { TenantName = data.TenantName.ToString().ToString(); } if (data.Title != null) { Title = new Title(data.Title.ToString()); } if (data.Body != null) { Body = data.Body.ToString().ToString(); } if (data.ContractDeadline != null) { ContractDeadline = data.ContractDeadline.ToDateTime().ToDateTime().ToUniversal(context: context); } if (data.LogoType != null) { LogoType = (LogoTypes)data.LogoType.ToInt().ToInt(); } if (data.HtmlTitleTop != null) { HtmlTitleTop = data.HtmlTitleTop.ToString().ToString(); } if (data.HtmlTitleSite != null) { HtmlTitleSite = data.HtmlTitleSite.ToString().ToString(); } if (data.HtmlTitleRecord != null) { HtmlTitleRecord = data.HtmlTitleRecord.ToString().ToString(); } if (data.Comments != null) { Comments.Prepend(context: context, ss: ss, body: data.Comments); } if (data.VerUp != null) { VerUp = data.VerUp.ToBool(); } }
public void SetByForm(IContext context, SiteSettings ss) { context.Forms.Keys.ForEach(controlId => { switch (controlId) { case "Tenants_TenantName": TenantName = context.Forms.Data(controlId).ToString(); break; case "Tenants_Title": Title = new Title(TenantId, context.Forms.Data(controlId)); break; case "Tenants_Body": Body = context.Forms.Data(controlId).ToString(); break; case "Tenants_ContractDeadline": ContractDeadline = context.Forms.Data(controlId).ToDateTime().ToUniversal(context: context); break; case "Tenants_LogoType": LogoType = (LogoTypes)context.Forms.Data(controlId).ToInt(); break; case "Tenants_HtmlTitleTop": HtmlTitleTop = context.Forms.Data(controlId).ToString(); break; case "Tenants_HtmlTitleSite": HtmlTitleSite = context.Forms.Data(controlId).ToString(); break; case "Tenants_HtmlTitleRecord": HtmlTitleRecord = context.Forms.Data(controlId).ToString(); break; case "Tenants_Timestamp": Timestamp = context.Forms.Data(controlId).ToString(); break; case "Comments": Comments.Prepend(context: context, ss: ss, body: context.Forms.Data("Comments")); break; case "VerUp": VerUp = context.Forms.Data(controlId).ToBool(); break; default: if (controlId.RegexExists("Comment[0-9]+")) { Comments.Update( context: context, ss: ss, commentId: controlId.Substring("Comment".Length).ToInt(), body: context.Forms.Data(controlId)); } break; } }); if (context.Action == "deletecomment") { DeleteCommentId = context.Forms.ControlId().Split(',')._2nd().ToInt(); Comments.RemoveAll(o => o.CommentId == DeleteCommentId); } }
public void SetByModel(TenantModel tenantModel) { TenantName = tenantModel.TenantName; Title = tenantModel.Title; Body = tenantModel.Body; ContractSettings = tenantModel.ContractSettings; ContractDeadline = tenantModel.ContractDeadline; LogoType = tenantModel.LogoType; HtmlTitleTop = tenantModel.HtmlTitleTop; HtmlTitleSite = tenantModel.HtmlTitleSite; HtmlTitleRecord = tenantModel.HtmlTitleRecord; Comments = tenantModel.Comments; Creator = tenantModel.Creator; Updator = tenantModel.Updator; CreatedTime = tenantModel.CreatedTime; UpdatedTime = tenantModel.UpdatedTime; VerUp = tenantModel.VerUp; Comments = tenantModel.Comments; }
private void Set(Context context, SiteSettings ss, DataRow dataRow, string tableAlias = null) { AccessStatus = Databases.AccessStatuses.Selected; foreach (DataColumn dataColumn in dataRow.Table.Columns) { var column = new ColumnNameInfo(dataColumn.ColumnName); if (column.TableAlias == tableAlias) { switch (column.Name) { case "TenantId": if (dataRow[column.ColumnName] != DBNull.Value) { TenantId = dataRow[column.ColumnName].ToInt(); SavedTenantId = TenantId; } break; case "Ver": Ver = dataRow[column.ColumnName].ToInt(); SavedVer = Ver; break; case "TenantName": TenantName = dataRow[column.ColumnName].ToString(); SavedTenantName = TenantName; break; case "Title": Title = new Title(dataRow, "TenantId"); SavedTitle = Title.Value; break; case "Body": Body = dataRow[column.ColumnName].ToString(); SavedBody = Body; break; case "ContractSettings": ContractSettings = GetContractSettings(dataRow); SavedContractSettings = ContractSettings?.RecordingJson(); break; case "ContractDeadline": ContractDeadline = dataRow[column.ColumnName].ToDateTime(); SavedContractDeadline = ContractDeadline; break; case "DisableAllUsersPermission": DisableAllUsersPermission = dataRow[column.ColumnName].ToBool(); SavedDisableAllUsersPermission = DisableAllUsersPermission; break; case "DisableStartGuide": DisableStartGuide = dataRow[column.ColumnName].ToBool(); SavedDisableStartGuide = DisableStartGuide; break; case "LogoType": LogoType = (LogoTypes)dataRow[column.ColumnName].ToInt(); SavedLogoType = LogoType.ToInt(); break; case "HtmlTitleTop": HtmlTitleTop = dataRow[column.ColumnName].ToString(); SavedHtmlTitleTop = HtmlTitleTop; break; case "HtmlTitleSite": HtmlTitleSite = dataRow[column.ColumnName].ToString(); SavedHtmlTitleSite = HtmlTitleSite; break; case "HtmlTitleRecord": HtmlTitleRecord = dataRow[column.ColumnName].ToString(); SavedHtmlTitleRecord = HtmlTitleRecord; break; case "Comments": Comments = dataRow[column.ColumnName].ToString().Deserialize <Comments>() ?? new Comments(); SavedComments = Comments.ToJson(); break; case "Creator": Creator = SiteInfo.User(context: context, userId: dataRow.Int(column.ColumnName)); SavedCreator = Creator.Id; break; case "Updator": Updator = SiteInfo.User(context: context, userId: dataRow.Int(column.ColumnName)); SavedUpdator = Updator.Id; break; case "CreatedTime": CreatedTime = new Time(context, dataRow, column.ColumnName); SavedCreatedTime = CreatedTime.Value; break; case "UpdatedTime": UpdatedTime = new Time(context, dataRow, column.ColumnName); Timestamp = dataRow.Field <DateTime>(column.ColumnName).ToString("yyyy/M/d H:m:s.fff"); SavedUpdatedTime = UpdatedTime.Value; break; case "IsHistory": VerType = dataRow.Bool(column.ColumnName) ? Versions.VerTypes.History : Versions.VerTypes.Latest; break; default: switch (Def.ExtendedColumnTypes.Get(column.Name)) { case "Class": Class( columnName: column.Name, value: dataRow[column.ColumnName].ToString()); SavedClass( columnName: column.Name, value: Class(columnName: column.Name)); break; case "Num": Num( columnName: column.Name, value: dataRow[column.ColumnName].ToDecimal()); SavedNum( columnName: column.Name, value: Num(columnName: column.Name)); break; case "Date": Date( columnName: column.Name, value: dataRow[column.ColumnName].ToDateTime()); SavedDate( columnName: column.Name, value: Date(columnName: column.Name)); break; case "Description": Description( columnName: column.Name, value: dataRow[column.ColumnName].ToString()); SavedDescription( columnName: column.Name, value: Description(columnName: column.Name)); break; case "Check": Check( columnName: column.Name, value: dataRow[column.ColumnName].ToBool()); SavedCheck( columnName: column.Name, value: Check(columnName: column.Name)); break; case "Attachments": Attachments( columnName: column.Name, value: dataRow[column.ColumnName].ToString() .Deserialize <Attachments>() ?? new Attachments()); SavedAttachments( columnName: column.Name, value: Attachments(columnName: column.Name).ToJson()); break; } break; } } } }
public void SetByApi(Context context, SiteSettings ss) { var data = context.RequestDataString.Deserialize <TenantApiModel>(); if (data == null) { return; } if (data.TenantName != null) { TenantName = data.TenantName.ToString().ToString(); } if (data.Title != null) { Title = new Title(data.Title.ToString()); } if (data.Body != null) { Body = data.Body.ToString().ToString(); } if (data.ContractDeadline != null) { ContractDeadline = data.ContractDeadline.ToDateTime().ToDateTime().ToUniversal(context: context); } if (data.DisableAllUsersPermission != null) { DisableAllUsersPermission = data.DisableAllUsersPermission.ToBool().ToBool(); } if (data.DisableStartGuide != null) { DisableStartGuide = data.DisableStartGuide.ToBool().ToBool(); } if (data.LogoType != null) { LogoType = (LogoTypes)data.LogoType.ToInt().ToInt(); } if (data.HtmlTitleTop != null) { HtmlTitleTop = data.HtmlTitleTop.ToString().ToString(); } if (data.HtmlTitleSite != null) { HtmlTitleSite = data.HtmlTitleSite.ToString().ToString(); } if (data.HtmlTitleRecord != null) { HtmlTitleRecord = data.HtmlTitleRecord.ToString().ToString(); } if (data.Comments != null) { Comments.Prepend(context: context, ss: ss, body: data.Comments); } if (data.VerUp != null) { VerUp = data.VerUp.ToBool(); } data.ClassHash.ForEach(o => Class( columnName: o.Key, value: o.Value)); data.NumHash.ForEach(o => Num( columnName: o.Key, value: o.Value)); data.DateHash.ForEach(o => Date( columnName: o.Key, value: o.Value.ToUniversal(context: context))); data.DescriptionHash.ForEach(o => Description( columnName: o.Key, value: o.Value)); data.CheckHash.ForEach(o => Check( columnName: o.Key, value: o.Value)); data.AttachmentsHash.ForEach(o => Attachments( columnName: o.Key, value: o.Value)); }
public void SetByForm( Context context, SiteSettings ss, IDictionary <string, string> formData) { formData.ForEach(data => { var key = data.Key; var value = data.Value ?? string.Empty; switch (key) { case "Tenants_TenantName": TenantName = value.ToString(); break; case "Tenants_Title": Title = new Title(TenantId, value); break; case "Tenants_Body": Body = value.ToString(); break; case "Tenants_ContractDeadline": ContractDeadline = value.ToDateTime().ToUniversal(context: context); break; case "Tenants_DisableAllUsersPermission": DisableAllUsersPermission = value.ToBool(); break; case "Tenants_DisableStartGuide": DisableStartGuide = value.ToBool(); break; case "Tenants_LogoType": LogoType = (LogoTypes)value.ToInt(); break; case "Tenants_HtmlTitleTop": HtmlTitleTop = value.ToString(); break; case "Tenants_HtmlTitleSite": HtmlTitleSite = value.ToString(); break; case "Tenants_HtmlTitleRecord": HtmlTitleRecord = value.ToString(); break; case "Tenants_Timestamp": Timestamp = value.ToString(); break; case "Comments": Comments.Prepend( context: context, ss: ss, body: value); break; case "VerUp": VerUp = value.ToBool(); break; default: if (key.RegexExists("Comment[0-9]+")) { Comments.Update( context: context, ss: ss, commentId: key.Substring("Comment".Length).ToInt(), body: value); } else { var column = ss.GetColumn( context: context, columnName: key.Split_2nd('_')); switch (Def.ExtendedColumnTypes.Get(column?.ColumnName)) { case "Class": Class( columnName: column.ColumnName, value: value); break; case "Num": Num( columnName: column.ColumnName, value: column.Round(value.ToDecimal( cultureInfo: context.CultureInfo()))); break; case "Date": Date( columnName: column.ColumnName, value: value.ToDateTime().ToUniversal(context: context)); break; case "Description": Description( columnName: column.ColumnName, value: value); break; case "Check": Check( columnName: column.ColumnName, value: value.ToBool()); break; case "Attachments": Attachments( columnName: column.ColumnName, value: value.Deserialize <Attachments>()); break; } } break; } }); if (context.QueryStrings.ContainsKey("ver")) { Ver = context.QueryStrings.Int("ver"); } if (context.Action == "deletecomment") { DeleteCommentId = formData.Get("ControlId")? .Split(',') ._2nd() .ToInt() ?? 0; Comments.RemoveAll(o => o.CommentId == DeleteCommentId); } }
public void SetByApi(Context context, SiteSettings ss) { var data = context.RequestDataString.Deserialize <TenantApiModel>(); if (data == null) { return; } if (data.TenantName != null) { TenantName = data.TenantName.ToString().ToString(); } if (data.Title != null) { Title = new Title(data.Title.ToString()); } if (data.Body != null) { Body = data.Body.ToString().ToString(); } if (data.ContractDeadline != null) { ContractDeadline = data.ContractDeadline.ToDateTime().ToDateTime().ToUniversal(context: context); } if (data.DisableAllUsersPermission != null) { DisableAllUsersPermission = data.DisableAllUsersPermission.ToBool().ToBool(); } if (data.DisableStartGuide != null) { DisableStartGuide = data.DisableStartGuide.ToBool().ToBool(); } if (data.LogoType != null) { LogoType = (LogoTypes)data.LogoType.ToInt().ToInt(); } if (data.HtmlTitleTop != null) { HtmlTitleTop = data.HtmlTitleTop.ToString().ToString(); } if (data.HtmlTitleSite != null) { HtmlTitleSite = data.HtmlTitleSite.ToString().ToString(); } if (data.HtmlTitleRecord != null) { HtmlTitleRecord = data.HtmlTitleRecord.ToString().ToString(); } if (data.Comments != null) { Comments.Prepend(context: context, ss: ss, body: data.Comments); } if (data.VerUp != null) { VerUp = data.VerUp.ToBool(); } data.ClassHash?.ForEach(o => Class( columnName: o.Key, value: o.Value)); data.NumHash?.ForEach(o => Num( columnName: o.Key, value: o.Value)); data.DateHash?.ForEach(o => Date( columnName: o.Key, value: o.Value.ToUniversal(context: context))); data.DescriptionHash?.ForEach(o => Description( columnName: o.Key, value: o.Value)); data.CheckHash?.ForEach(o => Check( columnName: o.Key, value: o.Value)); data.AttachmentsHash?.ForEach(o => { string columnName = o.Key; Attachments newAttachments = o.Value; Attachments oldAttachments = AttachmentsHash.Get(columnName); if (oldAttachments != null) { var newGuidSet = new HashSet <string>(newAttachments.Select(x => x.Guid).Distinct()); newAttachments.AddRange(oldAttachments.Where((oldvalue) => !newGuidSet.Contains(oldvalue.Guid))); } Attachments(columnName: columnName, value: newAttachments); }); }
public void SetByApi(Context context, SiteSettings ss) { var data = context.RequestDataString.Deserialize <TenantApiModel>(); if (data == null) { context.InvalidJsonData = !context.RequestDataString.IsNullOrEmpty(); return; } if (data.TenantName != null) { TenantName = data.TenantName.ToString().ToString(); } if (data.Title != null) { Title = new Title(data.Title.ToString()); } if (data.Body != null) { Body = data.Body.ToString().ToString(); } if (data.ContractDeadline != null) { ContractDeadline = data.ContractDeadline.ToDateTime().ToDateTime().ToUniversal(context: context); } if (data.DisableAllUsersPermission != null) { DisableAllUsersPermission = data.DisableAllUsersPermission.ToBool().ToBool(); } if (data.DisableStartGuide != null) { DisableStartGuide = data.DisableStartGuide.ToBool().ToBool(); } if (data.LogoType != null) { LogoType = (LogoTypes)data.LogoType.ToInt().ToInt(); } if (data.HtmlTitleTop != null) { HtmlTitleTop = data.HtmlTitleTop.ToString().ToString(); } if (data.HtmlTitleSite != null) { HtmlTitleSite = data.HtmlTitleSite.ToString().ToString(); } if (data.HtmlTitleRecord != null) { HtmlTitleRecord = data.HtmlTitleRecord.ToString().ToString(); } if (data.TopStyle != null) { TopStyle = data.TopStyle.ToString().ToString(); } if (data.TopScript != null) { TopScript = data.TopScript.ToString().ToString(); } if (data.Comments != null) { Comments.Prepend(context: context, ss: ss, body: data.Comments); } if (data.VerUp != null) { VerUp = data.VerUp.ToBool(); } data.ClassHash?.ForEach(o => GetClass( columnName: o.Key, value: o.Value)); data.NumHash?.ForEach(o => GetNum( columnName: o.Key, value: new Num( context: context, column: ss.GetColumn( context: context, columnName: o.Key), value: o.Value.ToString()))); data.DateHash?.ForEach(o => GetDate( columnName: o.Key, value: o.Value.ToDateTime().ToUniversal(context: context))); data.DescriptionHash?.ForEach(o => GetDescription( columnName: o.Key, value: o.Value)); data.CheckHash?.ForEach(o => GetCheck( columnName: o.Key, value: o.Value)); data.AttachmentsHash?.ForEach(o => { string columnName = o.Key; Attachments newAttachments = o.Value; Attachments oldAttachments; if (columnName == "Attachments#Uploading") { var kvp = AttachmentsHash .FirstOrDefault(x => x.Value .Any(att => att.Guid == newAttachments.FirstOrDefault()?.Guid?.Split_1st())); columnName = kvp.Key; oldAttachments = kvp.Value; var column = ss.GetColumn( context: context, columnName: columnName); if (column.OverwriteSameFileName == true) { var oldAtt = oldAttachments .FirstOrDefault(att => att.Guid == newAttachments.FirstOrDefault()?.Guid?.Split_1st()); if (oldAtt != null) { oldAtt.Deleted = true; oldAtt.Overwritten = true; } } newAttachments.ForEach(att => att.Guid = att.Guid.Split_2nd()); } else { oldAttachments = AttachmentsHash.Get(columnName); } if (oldAttachments != null) { var column = ss.GetColumn( context: context, columnName: columnName); var newGuidSet = new HashSet <string>(newAttachments.Select(x => x.Guid).Distinct()); var newNameSet = new HashSet <string>(newAttachments.Select(x => x.Name).Distinct()); newAttachments.ForEach(newAttachment => { newAttachment.AttachmentAction( context: context, column: column, oldAttachments: oldAttachments); }); if (column.OverwriteSameFileName == true) { newAttachments.AddRange(oldAttachments. Where((oldvalue) => !newGuidSet.Contains(oldvalue.Guid) && !newNameSet.Contains(oldvalue.Name))); } else { newAttachments.AddRange(oldAttachments. Where((oldvalue) => !newGuidSet.Contains(oldvalue.Guid))); } } GetAttachments(columnName: columnName, value: newAttachments); }); }
private void Set(IContext context, SiteSettings ss, DataRow dataRow, string tableAlias = null) { AccessStatus = Databases.AccessStatuses.Selected; foreach (DataColumn dataColumn in dataRow.Table.Columns) { var column = new ColumnNameInfo(dataColumn.ColumnName); if (column.TableAlias == tableAlias) { switch (column.Name) { case "TenantId": if (dataRow[column.ColumnName] != DBNull.Value) { TenantId = dataRow[column.ColumnName].ToInt(); SavedTenantId = TenantId; } break; case "Ver": Ver = dataRow[column.ColumnName].ToInt(); SavedVer = Ver; break; case "TenantName": TenantName = dataRow[column.ColumnName].ToString(); SavedTenantName = TenantName; break; case "Title": Title = new Title(dataRow, "TenantId"); SavedTitle = Title.Value; break; case "Body": Body = dataRow[column.ColumnName].ToString(); SavedBody = Body; break; case "ContractSettings": ContractSettings = GetContractSettings(dataRow); SavedContractSettings = ContractSettings?.RecordingJson(); break; case "ContractDeadline": ContractDeadline = dataRow[column.ColumnName].ToDateTime(); SavedContractDeadline = ContractDeadline; break; case "LogoType": LogoType = (LogoTypes)dataRow[column.ColumnName].ToInt(); SavedLogoType = LogoType.ToInt(); break; case "HtmlTitleTop": HtmlTitleTop = dataRow[column.ColumnName].ToString(); SavedHtmlTitleTop = HtmlTitleTop; break; case "HtmlTitleSite": HtmlTitleSite = dataRow[column.ColumnName].ToString(); SavedHtmlTitleSite = HtmlTitleSite; break; case "HtmlTitleRecord": HtmlTitleRecord = dataRow[column.ColumnName].ToString(); SavedHtmlTitleRecord = HtmlTitleRecord; break; case "Comments": Comments = dataRow[column.ColumnName].ToString().Deserialize <Comments>() ?? new Comments(); SavedComments = Comments.ToJson(); break; case "Creator": Creator = SiteInfo.User(context: context, userId: dataRow.Int(column.ColumnName)); SavedCreator = Creator.Id; break; case "Updator": Updator = SiteInfo.User(context: context, userId: dataRow.Int(column.ColumnName)); SavedUpdator = Updator.Id; break; case "CreatedTime": CreatedTime = new Time(context, dataRow, column.ColumnName); SavedCreatedTime = CreatedTime.Value; break; case "UpdatedTime": UpdatedTime = new Time(context, dataRow, column.ColumnName); Timestamp = dataRow.Field <DateTime>(column.ColumnName).ToString("yyyy/M/d H:m:s.fff"); SavedUpdatedTime = UpdatedTime.Value; break; case "IsHistory": VerType = dataRow[column.ColumnName].ToBool() ? Versions.VerTypes.History : Versions.VerTypes.Latest; break; } } } }