本文整理汇总了C#中Asset.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Asset.Save方法的具体用法?C# Asset.Save怎么用?C# Asset.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Asset
的用法示例。
在下文中一共展示了Asset.Save方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveToDb
//数据持久化
internal static void SaveToDb(AssetInfo pAssetInfo, Asset pAsset,bool pIsNew)
{
pAsset.AssetId = pAssetInfo.assetId;
pAsset.AssetName = pAssetInfo.assetName;
pAsset.Type = pAssetInfo.type;
pAsset.DepartName = pAssetInfo.departName;
pAsset.SiteName = pAssetInfo.siteName;
pAsset.UnitName = pAssetInfo.unitName;
pAsset.Amount = pAssetInfo.amount;
pAsset.Price = pAssetInfo.price;
pAsset.Memo = pAssetInfo.memo;
pAsset.IsNew=pIsNew;
string UserName = SubsonicHelper.GetUserName();
try
{
pAsset.Save(UserName);
}
catch(Exception ex)
{
LogManager.getInstance().getLogger(typeof(AssetInfo)).Error(ex);
if(ex.Message.Contains("插入重复键"))//违反了唯一键
{
throw new AppException("此对象已经存在");//此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示
}
throw new AppException("保存失败");
}
pAssetInfo.assetId = pAsset.AssetId;
//如果缓存存在,更新缓存
if (CachedEntityCommander.IsTypeRegistered(typeof(AssetInfo)))
{
ResetCache();
}
}
示例2: Test_GetBusinessObjectCollection_CriteriaString_LoadThroughSelfReferencingRelationship_TwoLevels
public virtual void Test_GetBusinessObjectCollection_CriteriaString_LoadThroughSelfReferencingRelationship_TwoLevels()
{
//---------------Set up test pack-------------------
Asset.LoadClassDef();
Asset grandparentAsset = new Asset();
grandparentAsset.Save();
Asset parentAsset = new Asset();
parentAsset.Parent = grandparentAsset;
parentAsset.Save();
Asset asset = new Asset();
asset.Parent = parentAsset;
asset.Save();
string criteria = string.Format("Parent.Parent.AssetID = '{0}'", grandparentAsset.AssetID);
//---------------Execute Test ----------------------
BusinessObjectCollection<Asset> col =
BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObjectCollection<Asset>(criteria);
//---------------Test Result -----------------------
Assert.AreEqual(1, col.Count);
Assert.Contains(asset, col);
}
开发者ID:kevinbosman,项目名称:habanero,代码行数:21,代码来源:TestBusinessObjectLoader_GetBusinessObjectCollection.cs
示例3: Test_GetBusinessObjectCollection_CriteriaObject_LoadThroughSelfReferencingRelationship_ThreeLevels
public virtual void Test_GetBusinessObjectCollection_CriteriaObject_LoadThroughSelfReferencingRelationship_ThreeLevels()
//Modified from Test_GetBusinessObjectCollection_CriteriaString_LoadThroughSelfReferencingRelationship_ThreeLevels
{
//---------------Set up test pack-------------------
Asset.LoadClassDef();
Asset greatgrandparentAsset = new Asset();
greatgrandparentAsset.Save();
Asset grandparentAsset = new Asset();
grandparentAsset.Parent = greatgrandparentAsset;
grandparentAsset.Save();
Asset parentAsset = new Asset();
parentAsset.Parent = grandparentAsset;
parentAsset.Save();
Asset asset = new Asset();
asset.Parent = parentAsset;
asset.Save();
Criteria criteria = new Criteria("Parent.Parent.Parent.AssetID", Criteria.ComparisonOp.Equals, greatgrandparentAsset.AssetID);
//---------------Execute Test ----------------------
BusinessObjectCollection<Asset> col =
BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObjectCollection<Asset>(criteria);
//---------------Test Result -----------------------
Assert.AreEqual(1, col.Count);
Assert.Contains(asset, col);
}
开发者ID:kevinbosman,项目名称:habanero,代码行数:25,代码来源:TestBusinessObjectLoader_GetBusinessObjectCollection.cs
示例4: AssetAttachmentContentIsLoadedIfContentIsUsed
public void AssetAttachmentContentIsLoadedIfContentIsUsed()
{
// Arrange.
Attachment file = CreateAttachment();
var asset = new Asset { Title = "The Title", File = file };
asset.Save();
// Act.
Asset theAsset = Asset.Find(asset.ID);
Stream content = theAsset.File.Content;
// Assert.
Assert.That(theAsset.File.IsContentLoaded, Is.True);
}
示例5: AssetAttachmentIsLoadedIfContentIsUsed
public void AssetAttachmentIsLoadedIfContentIsUsed()
{
// Arrange.
Attachment file = CreateAttachment();
var asset = new Asset { Title = "The Title", File = file };
asset.Save();
// Act.
Asset theAsset = Asset.Find(asset.ID);
Stream content = theAsset.File.Content;
// Assert.
Assert.That(content, Is.Not.Null);
Assert.That(theAsset.File.IsLoaded, Is.True);
Assert.That(theAsset.File.FileName, Is.EqualTo("Koala.jpg"));
Assert.That(theAsset.File.ContentType, Is.EqualTo("image/jpg"));
}
示例6: AssetAttachmentContentIsNotLoadedIfContentTypeIsUsed
public void AssetAttachmentContentIsNotLoadedIfContentTypeIsUsed()
{
// Arrange.
Attachment file = CreateAttachment();
var asset = new Asset { Title = "The Title", File = file };
asset.Save();
// Act.
Asset theAsset = Asset.Find(asset.ID);
string contentType = theAsset.File.ContentType;
// Assert.
Assert.That(theAsset.File.IsContentLoaded, Is.False);
}
示例7: AssetAttachmentIsNotLoadedIfNotUsed
public void AssetAttachmentIsNotLoadedIfNotUsed()
{
// Arrange.
Attachment file = CreateAttachment();
var asset = new Asset { Title = "The Title", File = file };
asset.Save();
// Act.
Asset theAsset = Asset.Find(asset.ID);
// Assert.
Assert.That(theAsset.File.IsLoaded, Is.False);
}
示例8: CanSaveAsset
public void CanSaveAsset()
{
// Arrange.
Attachment file = CreateAttachment();
// Act.
var asset = new Asset { Title = "The Title", File = file };
asset.Save();
// Assert.
var assetDoc = Asset.GetCollection().FindOneByIdAs<BsonDocument>(asset.ID);
Assert.That(assetDoc["File"].AsObjectId, Is.EqualTo(file.ID));
}