Ejemplo n.º 1
0
        public virtual FillResult FillData(FillDataMode mode, DataTable rawData, Rule rule, int modifierId, DateTime modified, int maximumErrors)
        {
            MetaDataContext.Current.BeginTransaction();
            try
            {
                FillResult retVal = FillData(mode, rawData, rule, modifierId, modified);
                if (maximumErrors == -1)
                {
                    MetaDataContext.Current.Commit();
                }
                else if (retVal.ErrorRows <= maximumErrors)
                {
                    MetaDataContext.Current.Commit();
                }
                else
                {
                    MetaDataContext.Current.Rollback();
                }

                return(retVal);
            }
            catch
            {
                MetaDataContext.Current.Rollback();
                throw;
            }
        }
Ejemplo n.º 2
0
        public virtual FillResult FillData(FillDataMode mode, DataTable rawData, Rule rule, int modifierId, DateTime modified)
        {
            if (rawData == null)
            {
                throw new ArgumentNullException("rawData");
            }

            FillResult retVal = new FillResult(rawData.Rows.Count);

            Validate(rule, rawData);

            int RowIndex = 0;

            foreach (DataRow Row in rawData.Rows)
            {
                try
                {
                    int ObjectId = CreateSystemRow(mode, FillItemList(SystemColumnInfos, Row, RowIndex, rule, retVal.warningList));

                    if (UserColumnInfos.Length != 0)
                    {
                        MetaObject Object = MetaObject.Load(ObjectId, _innerMetaClassName, modifierId, modified);
                        if (Object == null)
                        {
                            Object = MetaObject.NewObject(ObjectId, _innerMetaClassName, modifierId, modified);
                        }
                        CreateUserRow(Object, rule, FillItemList(UserColumnInfos, Row, RowIndex, rule, retVal.warningList));

                        Object.AcceptChanges();
                    }
                    else if (ObjectId == -1)
                    {
                        throw new IdleOperationException();
                    }

                    retVal.SuccessfulRow();
                }
                catch (AlreadyExistException)
                {
                }
                catch (MdpImportException ex)
                {
                    retVal.ErrorRow();
                    ex.setRowInfo(Row, RowIndex);
                    retVal.ErrorException(ex);
                }
                catch (Exception ex)
                {
                    retVal.ErrorRow();
                    retVal.ErrorException(ex);
                }
                RowIndex++;
            }
            return(retVal);
        }
Ejemplo n.º 3
0
        public virtual FillResult FillData(FillDataMode mode, DataTable rawData, Rule rule, int modifierId, DateTime modified, SqlTransaction tran)
        {
            MetaDataContext.Current.Transaction = tran;

            FillResult retVal = null;

            try
            {
                retVal = FillData(mode, rawData, rule, modifierId, modified);
            }
            finally
            {
                MetaDataContext.Current.Transaction = null;
            }

            return(retVal);
        }
Ejemplo n.º 4
0
        public virtual FillResult FillData(FillDataMode mode, DataTable rawData, Rule rule, int modifierId, DateTime modified)
        {
            if (rawData == null)
                throw new ArgumentNullException("rawData");

            FillResult retVal = new FillResult(rawData.Rows.Count);

            Validate(rule, rawData);

            int RowIndex = 0;
            foreach (DataRow Row in rawData.Rows)
            {
                try
                {
                    int ObjectId = CreateSystemRow(mode, FillItemList(SystemColumnInfos, Row, RowIndex, rule, retVal.warningList));

                    if (UserColumnInfos.Length != 0)
                    {
                        MetaObject Object = MetaObject.Load(ObjectId, _innerMetaClassName, modifierId, modified);
                        if (Object == null)
                        {
                            Object = MetaObject.NewObject(ObjectId, _innerMetaClassName, modifierId, modified);
                        }
                        CreateUserRow(Object, rule, FillItemList(UserColumnInfos, Row, RowIndex, rule, retVal.warningList));

                        Object.AcceptChanges();
                    }
                    else if (ObjectId == -1)
                        throw new IdleOperationException();

                    retVal.SuccessfulRow();
                }
                catch (AlreadyExistException)
                {
                }
                catch (MdpImportException ex)
                {
                    retVal.ErrorRow();
                    ex.setRowInfo(Row, RowIndex);
                    retVal.ErrorException(ex);
                }
                catch (Exception ex)
                {
                    retVal.ErrorRow();
                    retVal.ErrorException(ex);
                }
                RowIndex++;
            }
            return retVal;
        }