本文整理汇总了C#中UnitOfWork.GetClassInfo方法的典型用法代码示例。如果您正苦于以下问题:C# UnitOfWork.GetClassInfo方法的具体用法?C# UnitOfWork.GetClassInfo怎么用?C# UnitOfWork.GetClassInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnitOfWork
的用法示例。
在下文中一共展示了UnitOfWork.GetClassInfo方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RefsAndImports
IEnumerable<KeyValuePair<InputMemberInfo, FillRefList>> RefsAndImports(UnitOfWork outputUow) {
foreach (KeyValuePair<InputMemberInfo, FillRefList> pair in _fillRefsDictionary) {
XPMemberInfo memberInfo = pair.Key;
FillRefList fillRefsList = pair.Value;
Type memberType = memberInfo.IsAssociationList ? memberInfo.CollectionElementType.ClassType : memberInfo.ReferenceType.ClassType;
var objects = outputUow.GetObjectsByKey(outputUow.GetClassInfo(memberType), fillRefsList.RefKeyList, false);
int counter = 0;
var memberObjectDictionary = GetObjectDictionary(memberType);
foreach (object obj in objects) {
object owner = fillRefsList.OwnerList[counter];
object refKey = fillRefsList.RefKeyList[counter];
counter++;
AddObjectToCache(memberObjectDictionary, refKey, obj);
if (memberInfo.IsAssociationList) {
var list = memberInfo.GetValue(owner) as IList;
if (list == null) continue;
list.Add(obj);
} else {
memberInfo.SetValue(owner, obj);
}
}
}
_fillRefsDictionary.Clear();
List<KeyValuePair<InputMemberInfo, FillRefList>> refsAndImports = _fillRefsAndImportDictionary.ToList();
_fillRefsAndImportDictionary.Clear();
return refsAndImports;
}
示例2: GetDictProdOrderQty
private Dictionary<string, float> GetDictProdOrderQty(UnitOfWork uow)
{
string key = "";
Dictionary<string, float> dictProdOrderQty = new Dictionary<string, float>();
#region Get Waiting Qty
XPCollection<ProdOrder> prodOrders = new XPCollection<ProdOrder>(uow, CriteriaOperator.Parse(string.Format("OrderStatus = '{0}' || OrderStatus = '{1}'", ProdOrder.ProdOrderStatus.Waiting, ProdOrder.ProdOrderStatus.Calculated)));
foreach (ProdOrder prodOrder in prodOrders)
{
ProdRoute pRoute = prodOrder.GetFirstProdRoute();
if (pRoute != null)
{
key = pRoute.WorkCenter.WorkCenterNo + "-" + prodOrder.Item.ItemNo + "-" + ProdOrder.ProdOrderStatus.Waiting;
if (dictProdOrderQty.ContainsKey(key))
dictProdOrderQty[key] = dictProdOrderQty[key] + prodOrder.NeedQty;
else
dictProdOrderQty.Add(key, prodOrder.NeedQty);
}
}
#endregion
#region Get Active Qty
XPClassInfo prodRouteClass;
CriteriaOperator criteria;
SortingCollection sortProps;
prodRouteClass = uow.GetClassInfo(typeof(ProdRoute));
criteria = CriteriaOperator.Parse(string.Format("ProdOrder.OrderStatus = '{0}'", ProdOrder.ProdOrderStatus.Active));
sortProps = new SortingCollection(null);
ICollection prodRoutes = uow.GetObjects(prodRouteClass, criteria, sortProps, int.MaxValue, false, true);
foreach (ProdRoute prodRoute in prodRoutes)
{
key = prodRoute.WorkCenter.WorkCenterNo + "-" + prodRoute.Item.ItemNo + "-" + ProdOrder.ProdOrderStatus.Active;
if (dictProdOrderQty.ContainsKey(key))
dictProdOrderQty[key] = dictProdOrderQty[key] + prodRoute.WipQty;
else
dictProdOrderQty.Add(key, prodRoute.WipQty);
}
#endregion
return dictProdOrderQty;
}
示例3: InitLUE
private void InitLUE()
{
UnitOfWork uow = new UnitOfWork();
XPCollection<Customer> customers = new XPCollection<Customer>(uow);
SortingCollection sortProps3 = new SortingCollection(null);
sortProps3.Add(new SortProperty("No", SortingDirection.Descending));
customers.Sorting = sortProps3;
lueCustomer.Properties.DataSource = customers;
lueCustomer.Properties.ValueMember = "No";
lueCustomer.Properties.DisplayMember = "No";
XPClassInfo classInfo = uow.GetClassInfo(typeof(Item));
XPServerCollectionSource items = new XPServerCollectionSource(uow, classInfo);
SortingCollection sortProps2 = new SortingCollection(null);
sortProps2.Add(new SortProperty("ItemNo", SortingDirection.Descending));
//items.Sorting = sortProps2;
lueItem1.Properties.DataSource = items;
lueItem1.Properties.ValueMember = "This";
lueItem1.Properties.DisplayMember = "ItemNo";
lueItem2.Properties.DataSource = items;
lueItem2.Properties.ValueMember = "This";
lueItem2.Properties.DisplayMember = "ItemNo";
lueItem3.Properties.DataSource = items;
lueItem3.Properties.ValueMember = "This";
lueItem3.Properties.DisplayMember = "ItemNo";
lueItem4.Properties.DataSource = items;
lueItem4.Properties.ValueMember = "This";
lueItem4.Properties.DisplayMember = "ItemNo";
lueItem5.Properties.DataSource = items;
lueItem5.Properties.ValueMember = "This";
lueItem5.Properties.DisplayMember = "ItemNo";
lueItem6.Properties.DataSource = items;
lueItem6.Properties.ValueMember = "This";
lueItem6.Properties.DisplayMember = "ItemNo";
lueItem7.Properties.DataSource = items;
lueItem7.Properties.ValueMember = "This";
lueItem7.Properties.DisplayMember = "ItemNo";
lueItem8.Properties.DataSource = items;
lueItem8.Properties.ValueMember = "This";
lueItem8.Properties.DisplayMember = "ItemNo";
lueItem9.Properties.DataSource = items;
lueItem9.Properties.ValueMember = "This";
lueItem9.Properties.DisplayMember = "ItemNo";
XPCollection<OrderType> orderTypes = new XPCollection<OrderType>(uow);
SortingCollection sortProps = new SortingCollection(null);
sortProps.Add(new SortProperty("Name", SortingDirection.Ascending));
orderTypes.Sorting = sortProps;
lueOrderType1.Properties.DataSource = orderTypes;
lueOrderType1.Properties.ValueMember = "Name";
lueOrderType1.Properties.DisplayMember = "Name";
lueOrderType2.Properties.DataSource = orderTypes;
lueOrderType2.Properties.ValueMember = "Name";
lueOrderType2.Properties.DisplayMember = "Name";
lueOrderType3.Properties.DataSource = orderTypes;
lueOrderType3.Properties.ValueMember = "Name";
lueOrderType3.Properties.DisplayMember = "Name";
lueOrderType4.Properties.DataSource = orderTypes;
lueOrderType4.Properties.ValueMember = "Name";
lueOrderType4.Properties.DisplayMember = "Name";
lueOrderType5.Properties.DataSource = orderTypes;
lueOrderType5.Properties.ValueMember = "Name";
lueOrderType5.Properties.DisplayMember = "Name";
lueOrderType6.Properties.DataSource = orderTypes;
lueOrderType6.Properties.ValueMember = "Name";
lueOrderType6.Properties.DisplayMember = "Name";
lueOrderType7.Properties.DataSource = orderTypes;
lueOrderType7.Properties.ValueMember = "Name";
lueOrderType7.Properties.DisplayMember = "Name";
lueOrderType8.Properties.DataSource = orderTypes;
lueOrderType8.Properties.ValueMember = "Name";
lueOrderType8.Properties.DisplayMember = "Name";
lueOrderType9.Properties.DataSource = orderTypes;
lueOrderType9.Properties.ValueMember = "Name";
lueOrderType9.Properties.DisplayMember = "Name";
}
示例4: GetObject
XPBaseObject GetObject(UnitOfWork unitOfWork, ITypeInfo typeInfo, CriteriaOperator criteriaOperator) {
var xpBaseObject = unitOfWork.FindObject(PersistentCriteriaEvaluationBehavior.InTransaction, unitOfWork.GetClassInfo(typeInfo.Type),
criteriaOperator,true) as XPBaseObject ??
unitOfWork.FindObject(unitOfWork.GetClassInfo(typeInfo.Type), criteriaOperator,true) as XPBaseObject;
return xpBaseObject ?? (XPBaseObject)ReflectionHelper.CreateObject(typeInfo.Type, unitOfWork);
}
示例5: TransferFile
/// <summary>
/// Метод принимает поток из модулей IDynamicModule
/// </summary>
/// <param name="context">Идентификатор обследования связанного с файлом</param>
/// <param name="fileName">Имя файла</param>
/// <param name="dataStream">Файловый поток</param>
/// <param name="initialSize">Размер файла</param>
public void TransferFile(Guid context, String fileName, Stream dataStream, long initialSize)
{
// Получаем объект для работы с данными БД
UnitOfWork uow = new UnitOfWork((this.Application.CreateObjectSpace() as XPObjectSpace).Session.DataLayer);
if (uow == null)
throw new Exception("Error occurred while creating UnitOfWork object.");
// Находим обследование по ИД
IExamination examination = uow.GetObjectByKey<IExamination>(context);
if (examination == null)
{
DevExpress.Persistent.Base.Tracing.Tracer.LogError("TransferFile({0}, {1}, {2}, {3}) Examination [id={0}] is not found in the database",
context, fileName, "dataStream", initialSize);
return;
//throw new Exception("The examination is not found in the database.");
}
if (String.IsNullOrEmpty(fileName) == true || initialSize <= 0)
throw new Exception("Invalid file transfer params.");
//...
//XtraMessageBox.Show(String.Format("TransferFile: {0}, {1}", context, fileName));
Guid owner = (examination as DevExpress.ExpressApp.DC.DCBaseObject).Oid;
CriteriaOperator criteria = uow.ParseCriteria(String.Format("[OwnerId]= '{0}'", owner));
XPClassInfo info = uow.GetClassInfo(typeof(FileSystemStoreObject));
// находим отображаемые имена файлов данного обследования
var ownerFiles = uow.GetObjects(info, criteria, null, int.MaxValue, false, true).Cast<FileSystemStoreObject>().Select(x => x.FileName).ToList<String>();
FileSystemStoreObject fileStoreObject = new FileSystemStoreObject(uow)
{
OwnerId = owner,//((DevExpress.ExpressApp.DC.DCBaseObject)examination).Oid, // ИД владелеца файла
FileName = GetDatabaseFileName(fileName, ownerFiles),// Path.GetFileName(fileName),
};
uow.CommitChanges(); // создаем в базе новый объект FileSystemStoreObject
// пытаемся записать полученный файл
if (FileProcessor.TryToWriteTransferredFile(fileStoreObject.RealFileName, dataStream) == false)//|| new FileInfo(fileStoreObject.RealFileName).Length != initialSize)
{
//XtraMessageBox.Show(String.Format("File transfer error !!!\n {0}, {1}", context, fileName));
uow.Delete(fileStoreObject); // если записать файл не удалось, то удаляем из базы ссылку на файл
}
uow.CommitChanges();
// Обновляем главное окно
//UpdateWindow(context);
OnViewUpdate();
}