public void SetByApi(Context context, SiteSettings ss) { var data = context.RequestDataString.Deserialize <DeptApiModel>(); if (data == null) { return; } if (data.DeptCode != null) { DeptCode = data.DeptCode.ToString().ToString(); } if (data.DeptName != null) { DeptName = data.DeptName.ToString().ToString(); } if (data.Body != null) { Body = data.Body.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) { 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 <RegistrationApiModel>(); if (data == null) { return; } if (data.MailAddress != null) { MailAddress = data.MailAddress.ToString().ToString(); } if (data.Invitee != null) { Invitee = data.Invitee.ToInt().ToInt(); } if (data.InviteeName != null) { InviteeName = data.InviteeName.ToString().ToString(); } if (data.LoginId != null) { LoginId = data.LoginId.ToString().ToString(); } if (data.Name != null) { Name = data.Name.ToString().ToString(); } if (data.Password != null) { Password = data.Password.ToString().ToString().Sha512Cng(); } if (data.Language != null) { Language = data.Language.ToString().ToString(); } if (data.Passphrase != null) { Passphrase = data.Passphrase.ToString().ToString(); } if (data.Invitingflg != null) { Invitingflg = data.Invitingflg.ToString().ToString(); } if (data.UserId != null) { UserId = data.UserId.ToInt().ToInt(); } if (data.DeptId != null) { DeptId = data.DeptId.ToInt().ToInt(); } if (data.GroupId != null) { GroupId = data.GroupId.ToInt().ToInt(); } 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); }); }