public void ProccesExcellRows(IEnumerable<Row> records, XPObjectSpace objectSpace, DoWorkEventArgs e, Type type){ int i = 0; List<XPMemberInfo> props = objectSpace.FindXPClassInfo(type).PersistentProperties .OfType<XPMemberInfo>().ToList(); //get key property name of the object type being imported string keyPropertyName = objectSpace.GetKeyPropertyName(type); //for every row in excel sheet foreach (Row excelRow in records){ ++i; if (i == 1) continue; if (_bgWorker.CancellationPending){ e.Cancel = true; break; } string message; ProcessSingleRow(objectSpace, e, type, keyPropertyName, excelRow, props, i, out message); if (i%50 == 0) objectSpace.CommitChanges(); _bgWorker.ReportProgress(1, message); Application.DoEvents(); } objectSpace.CommitChanges(); }
public void ProccesExcellRows(XPObjectSpace objectSpace, Row[] rows, Type type, int?headerRows, CancellationToken token, Utils.Threading.IProgress <string> progress) { var records = rows; int i = 0; var props = objectSpace.FindXPClassInfo(type).PersistentProperties.OfType <XPMemberInfo>().ToList(); string keyPropertyName = objectSpace.GetKeyPropertyName(type); foreach (Row excelRow in records) { ++i; if (i <= headerRows) { continue; } token.ThrowIfCancellationRequested(); string message; ProcessSingleRow(objectSpace, type, keyPropertyName, excelRow, props, i, out message, progress.Report); if (i % TransactionSize == 0) { objectSpace.CommitChanges(); progress.Report(string.Format(Resources.SuccessProcessingRecord, i - 1)); } } progress.Report(string.Format(Resources.SuccessProcessingRecord, i - 1)); objectSpace.CommitChanges(); }
public void ProccesExcellRows( XPObjectSpace objectSpace, DoWorkEventArgs e, Type type){ var workerArgs = ((WorkerArgs) e.Argument); var records = workerArgs.Rows; int i = 0; var props = objectSpace.FindXPClassInfo(type).PersistentProperties.OfType<XPMemberInfo>().ToList(); string keyPropertyName = objectSpace.GetKeyPropertyName(type); foreach (Row excelRow in records){ ++i; if (i <= workerArgs.HeaderRows) continue; if (_bgWorker.CancellationPending){ e.Cancel = true; break; } string message; ProcessSingleRow(objectSpace, e, type, keyPropertyName, excelRow, props, i, out message); if (i%50 == 0) objectSpace.CommitChanges(); _bgWorker.ReportProgress(1, message); Application.DoEvents(); } objectSpace.CommitChanges(); }
public void ProccesExcellRows(IEnumerable <Row> records, XPObjectSpace objectSpace, DoWorkEventArgs e, Type type) { int i = 0; List <XPMemberInfo> props = objectSpace.FindXPClassInfo(type).PersistentProperties .OfType <XPMemberInfo>().ToList(); //get key property name of the object type being imported string keyPropertyName = objectSpace.GetKeyPropertyName(type); //for every row in excel sheet foreach (Row excelRow in records) { ++i; if (i == 1) { continue; } if (_bgWorker.CancellationPending) { e.Cancel = true; break; } string message; ProcessSingleRow(objectSpace, e, type, keyPropertyName, excelRow, props, i, out message); if (i % 50 == 0) { objectSpace.CommitChanges(); } _bgWorker.ReportProgress(1, message); Application.DoEvents(); } objectSpace.CommitChanges(); }
public static Type GetObjectKeyType(this XPObjectSpace objectSpace, Type objectType) { Type result = null; var xpClassInfo = objectSpace.FindXPClassInfo(objectType); if (xpClassInfo != null) { Type queryableType = xpClassInfo.ClassType; if (queryableType.IsInterface) { queryableType = PersistentInterfaceHelper.GetPersistentInterfaceDataType(queryableType); xpClassInfo = objectSpace.Session.GetClassInfo(queryableType); } XPMemberInfo keyMember = xpClassInfo.KeyProperty; if (keyMember != null) { if (!keyMember.IsStruct) { if (keyMember.ReferenceType != null) { result = objectSpace.GetObjectKeyType(keyMember.ReferenceType.ClassType); } else { return(keyMember.MemberType); } } else { throw new NotImplementedException(); } } } return(result); }
public void ProccesExcellRows(XPObjectSpace objectSpace, DoWorkEventArgs e, Type type) { var workerArgs = ((WorkerArgs)e.Argument); var records = workerArgs.Rows; int i = 0; var props = objectSpace.FindXPClassInfo(type).PersistentProperties.OfType <XPMemberInfo>().ToList(); string keyPropertyName = objectSpace.GetKeyPropertyName(type); foreach (Row excelRow in records) { ++i; if (i <= workerArgs.HeaderRows) { continue; } if (_bgWorker.CancellationPending) { e.Cancel = true; break; } string message; ProcessSingleRow(objectSpace, e, type, keyPropertyName, excelRow, props, i, out message); if (i % 50 == 0) { objectSpace.CommitChanges(); } _bgWorker.ReportProgress(1, message); Application.DoEvents(); } objectSpace.CommitChanges(); }