private void SetBySession() { if (!Forms.HasData("Binaries_BinarySettings")) { BinarySettings = Session_BinarySettings(); } }
public void SetByModel(BinaryModel binaryModel) { TenantId = binaryModel.TenantId; ReferenceId = binaryModel.ReferenceId; Guid = binaryModel.Guid; BinaryType = binaryModel.BinaryType; Title = binaryModel.Title; Body = binaryModel.Body; Bin = binaryModel.Bin; Thumbnail = binaryModel.Thumbnail; Icon = binaryModel.Icon; FileName = binaryModel.FileName; Extension = binaryModel.Extension; Size = binaryModel.Size; ContentType = binaryModel.ContentType; BinarySettings = binaryModel.BinarySettings; Comments = binaryModel.Comments; Creator = binaryModel.Creator; Updator = binaryModel.Updator; CreatedTime = binaryModel.CreatedTime; UpdatedTime = binaryModel.UpdatedTime; VerUp = binaryModel.VerUp; Comments = binaryModel.Comments; ClassHash = binaryModel.ClassHash; NumHash = binaryModel.NumHash; DateHash = binaryModel.DateHash; DescriptionHash = binaryModel.DescriptionHash; CheckHash = binaryModel.CheckHash; AttachmentsHash = binaryModel.AttachmentsHash; }
private void SetBySession(Context context) { if (!context.Forms.Exists("Binaries_BinarySettings")) { BinarySettings = Session_BinarySettings(context: context); } }
private void SetBySession(Context context) { if (!Forms.HasData("Binaries_BinarySettings")) { BinarySettings = Session_BinarySettings(context: context); } }
private void Set(DataRow dataRow) { AccessStatus = Databases.AccessStatuses.Selected; foreach (DataColumn dataColumn in dataRow.Table.Columns) { var name = dataColumn.ColumnName; switch (name) { case "ReferenceId": if (dataRow[name] != DBNull.Value) { ReferenceId = dataRow[name].ToLong(); SavedReferenceId = ReferenceId; } break; case "BinaryId": if (dataRow[name] != DBNull.Value) { BinaryId = dataRow[name].ToLong(); SavedBinaryId = BinaryId; } break; case "Ver": Ver = dataRow[name].ToInt(); SavedVer = Ver; break; case "BinaryType": BinaryType = dataRow[name].ToString(); SavedBinaryType = BinaryType; break; case "Title": Title = new Title(dataRow, "BinaryId"); SavedTitle = Title.Value; break; case "Body": Body = dataRow[name].ToString(); SavedBody = Body; break; case "Bin": Bin = dataRow.Bytes("Bin"); SavedBin = Bin; break; case "Thumbnail": Thumbnail = dataRow.Bytes("Bin"); SavedThumbnail = Thumbnail; break; case "Icon": Icon = dataRow.Bytes("Bin"); SavedIcon = Icon; break; case "FileName": FileName = dataRow[name].ToString(); SavedFileName = FileName; break; case "Extension": Extension = dataRow[name].ToString(); SavedExtension = Extension; break; case "Size": Size = dataRow[name].ToInt(); SavedSize = Size; break; case "BinarySettings": BinarySettings = dataRow.String("BinarySettings").Deserialize <BinarySettings>() ?? new BinarySettings(); SavedBinarySettings = BinarySettings.ToJson(); 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 "UpdatedTime": UpdatedTime = new Time(dataRow, "UpdatedTime"); Timestamp = dataRow.Field <DateTime>("UpdatedTime").ToString("yyyy/M/d H:m:s.fff"); SavedUpdatedTime = UpdatedTime.Value; break; case "IsHistory": VerType = dataRow[name].ToBool() ? Versions.VerTypes.History : Versions.VerTypes.Latest; break; } } }
public void SetByModel(BinaryModel binaryModel) { TenantId = binaryModel.TenantId; ReferenceId = binaryModel.ReferenceId; Guid = binaryModel.Guid; BinaryType = binaryModel.BinaryType; Title = binaryModel.Title; Body = binaryModel.Body; Bin = binaryModel.Bin; Thumbnail = binaryModel.Thumbnail; Icon = binaryModel.Icon; FileName = binaryModel.FileName; Extension = binaryModel.Extension; Size = binaryModel.Size; ContentType = binaryModel.ContentType; BinarySettings = binaryModel.BinarySettings; Comments = binaryModel.Comments; Creator = binaryModel.Creator; Updator = binaryModel.Updator; CreatedTime = binaryModel.CreatedTime; UpdatedTime = binaryModel.UpdatedTime; VerUp = binaryModel.VerUp; Comments = binaryModel.Comments; }
private void Set(Context context, 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 "BinaryId": if (dataRow[column.ColumnName] != DBNull.Value) { BinaryId = dataRow[column.ColumnName].ToLong(); SavedBinaryId = BinaryId; } break; case "TenantId": TenantId = dataRow[column.ColumnName].ToInt(); SavedTenantId = TenantId; break; case "ReferenceId": ReferenceId = dataRow[column.ColumnName].ToLong(); SavedReferenceId = ReferenceId; break; case "Guid": Guid = dataRow[column.ColumnName].ToString(); SavedGuid = Guid; break; case "Ver": Ver = dataRow[column.ColumnName].ToInt(); SavedVer = Ver; break; case "BinaryType": BinaryType = dataRow[column.ColumnName].ToString(); SavedBinaryType = BinaryType; break; case "Title": Title = new Title(dataRow, "BinaryId"); SavedTitle = Title.Value; break; case "Body": Body = dataRow[column.ColumnName].ToString(); SavedBody = Body; break; case "Bin": Bin = dataRow.Bytes("Bin"); SavedBin = Bin; break; case "Thumbnail": Thumbnail = dataRow.Bytes("Bin"); SavedThumbnail = Thumbnail; break; case "Icon": Icon = dataRow.Bytes("Bin"); SavedIcon = Icon; break; case "FileName": FileName = dataRow[column.ColumnName].ToString(); SavedFileName = FileName; break; case "Extension": Extension = dataRow[column.ColumnName].ToString(); SavedExtension = Extension; break; case "Size": Size = dataRow[column.ColumnName].ToLong(); SavedSize = Size; break; case "ContentType": ContentType = dataRow[column.ColumnName].ToString(); SavedContentType = ContentType; break; case "BinarySettings": BinarySettings = dataRow[column.ColumnName].ToString().Deserialize <BinarySettings>() ?? new BinarySettings(); SavedBinarySettings = BinarySettings.ToJson(); 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; } } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Output a list of mappings to the blob /// </summary> /// <param name="blob">The settings blob</param> /// <param name="fParatext">true if this is for Paratext</param> /// <param name="mappings">A collection of mappings that belong together in the blob (there /// are three such globs in a well-formed blob)</param> /// ------------------------------------------------------------------------------------ private void OutputMappings(BinarySettings blob, bool fParatext, ArrayList mappings) { if (mappings == null) { blob.AddInt(0); return; } blob.AddInt(mappings.Count); foreach (MappingInfo mapping in mappings) { blob.AddString(mapping.beginMarker); blob.AddString(mapping.endMarker); blob.AddIntShort(mapping.isInline ? 1 : 0); // inline blob.AddString(string.Empty); // marker encoding blob.AddString(mapping.dataEncoding); blob.AddIntShort((int)mapping.domain); blob.AddString(mapping.styleName); blob.AddString(mapping.ws); // writing system blob.AddIntShort(1); // confirmed // Looks like we accidentally got these two parameters in opposite order for // Paratext and ECProject - ugh! if (fParatext) { blob.AddIntShort((int)mapping.mappingTarget); blob.AddIntShort(mapping.isExcluded ? 1 : 0); } else { blob.AddIntShort(mapping.isExcluded ? 1 : 0); blob.AddIntShort((int)mapping.mappingTarget); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes the settings from a byte array or gets the settings into a byte array. /// </summary> /// ------------------------------------------------------------------------------------ private byte[] GetParatextSettingsArray(ArrayList vernMappingList, ArrayList backMappingList, ArrayList notesMappingList, string vernProj, string backProj, string notesProj) { BinarySettings blob = new BinarySettings("PTProject"); // Mapping set count (3 sets for vern, back, and notes) blob.AddInt(3); // We store the mappings in three different parts of the blob because the source P6 project // often determines the domain. It's possible for users to use the same markers in different // projects to mean different things. The domain + the marker serve as the "key". OutputMappings(blob, true, vernMappingList); OutputMappings(blob, true, backMappingList); OutputMappings(blob, true, notesMappingList); blob.AddString(vernProj); blob.AddString(backProj); blob.AddString(notesProj); return blob.Finalize(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Return a binary blob representing "ECProject" values /// </summary> /// <returns>a byte array containing the settings</returns> /// ------------------------------------------------------------------------------------ private byte[] GetEcProjectSettingsArray(ArrayList mappingList, ArrayList fileList) { BinarySettings blob = new BinarySettings("ECProject"); // stuff at the start of the file blob.AddString(@"\id"); blob.AddString(string.Empty); // data encoding blob.AddString(string.Empty); // marker encoding blob.AddString(string.Empty); // binary directory blob.AddString(string.Empty); // SSF file name blob.AddString(string.Empty); // STY file name // Marker mappings OutputMappings(blob, false, mappingList); // file list blob.AddInt(fileList.Count); foreach (string fileName in fileList) { blob.AddString(fileName); blob.AddIntShort(1); // file encoding (dummy value) blob.AddIntShort(1); // file encoding source (dummy value) blob.AddIntShort(100); // percent certain } return blob.Finalize(); }