Beispiel #1
0
        void addInterface(Type type1, IPersistentClassInfo persistentClassInfo1)
        {
            var t1InterfaceInfo = (IInterfaceInfo)_XPObjectSpace.CreateObject(typeof(InterfaceInfo));

            t1InterfaceInfo.Name     = type1.FullName;
            t1InterfaceInfo.Assembly = new AssemblyName(type1.Assembly.FullName + "").Name;
            persistentClassInfo1.Interfaces.Add(t1InterfaceInfo);
        }
Beispiel #2
0
        static XDocument ExportRecords(XPObjectSpace XPObjectSpace)
        {
            ISerializationConfiguration serializationConfiguration = XPObjectSpace.CreateObject <SerializationConfiguration>();

            serializationConfiguration.TypeToSerialize = typeof(PEnumClass);
            serializationConfiguration.SerializationConfigurationGroup =
                XPObjectSpace.CreateObject <SerializationConfigurationGroup>();
            new ClassInfoGraphNodeBuilder().Generate(serializationConfiguration);
            XDocument document = new ExportEngine().Export(new[] { _pEnumClass }, serializationConfiguration.SerializationConfigurationGroup);

            return(document);
        }
Beispiel #3
0
        public TController Create(ViewType viewType)
        {
            XafTypesInfo.Instance.RegisterEntity(typeof(TObject));

            _controller = new TController();
            _controller.Active[STR_ControllerFactory] = false;

            var unitOfWork    = new UnitOfWork(Session.DefaultSession.DataLayer);
            var XPObjectSpace = new XPObjectSpace(unitOfWork, XafTypesInfo.Instance);

            var xafApplication = Isolate.Fake.Instance <XafApplication>();

            Isolate.WhenCalled(() => _controller.Application).WillReturn(xafApplication);
            Isolate.WhenCalled(() => xafApplication.CreateObjectSpace()).WillReturn(XPObjectSpace);

            var  currentObject = (TObject)XPObjectSpace.CreateObject(typeof(TObject));
            View view          = viewType == ViewType.DetailView ? (View)createDetailView(XPObjectSpace, currentObject) : createListView(XPObjectSpace);

            view.CurrentObject = currentObject;
            _controller.SetView(view);

            var frame = new Frame(_controller.Application, TemplateContext.View);

            frame.SetView(_controller.View);
            Isolate.WhenCalled(() => _controller.Frame).WillReturn(frame);
            return(_controller);
        }
Beispiel #4
0
        protected override void ViewCreated(DetailView detailView)
        {
            base.ViewCreated(detailView);
            var xpandJobTrigger = XPObjectSpace.CreateObject <XpandSimpleTrigger>();

            xpandJobTrigger.Name = "trigger";
            Object.JobTriggers.Add(xpandJobTrigger);
        }
Beispiel #5
0
 protected override void ViewCreated(DetailView detailView)
 {
     base.ViewCreated(detailView);
     XPObjectSpace           = detailView.ObjectSpace;
     Object.Job              = XPObjectSpace.CreateObject <XpandJob>();
     Object.Job.JobType      = typeof(DummyJob);
     Object.JobDetailDataMap = XPObjectSpace.CreateObject <DummyDetailDataMap>();
     Object.Name             = "name";
 }
Beispiel #6
0
        private object CreateObject(TeamEmployeeDisplay Item, object CurrentObjectValue)
        {
            object obj = null;

            obj = _ObjectSpace.CreateObject(MemberInfo.ListElementTypeInfo.Type);

            if (Item.Employee != null)
            {
                obj.SetPropertyValue("Employee", _ObjectSpace.FindObject <Employee>(new BinaryOperator("Oid", Item.ID)));
            }
            else
            {
                obj.SetPropertyValue("Team", _ObjectSpace.FindObject <Team>(new BinaryOperator("Oid", Item.ID)));
            }

            obj.SetPropertyValue(CurrentObject.GetType().BaseType.Name, _ObjectSpace.FindObject(CurrentObject.GetType(), new BinaryOperator("Oid", ((BaseObject)CurrentObject).Oid)));

            return(obj);
        }
Beispiel #7
0
        public void CreateExtraInfos(Table table, IPersistentClassInfo persistentClassInfo, IMapperInfo mapperInfo)
        {
            var persistentAttributeInfos = _attributeMapper.Create(table, persistentClassInfo, mapperInfo);

            foreach (var persistentAttributeInfo in persistentAttributeInfos)
            {
                persistentClassInfo.TypeAttributes.Add(persistentAttributeInfo);
            }
            var count = table.Columns.OfType <Column>().Count(column => column.InPrimaryKey);

            if (count > 0)
            {
                if (persistentClassInfo.TemplateInfos.FirstOrDefault(info => info.Name == SupportPersistentObjectsAsAPartOfACompositeKey) == null)
                {
                    var templateInfo = (ITemplateInfo)_objectSpace.CreateObject(WCTypesInfo.Instance.FindBussinessObjectType(typeof(ITemplateInfo)));
                    templateInfo.Name = SupportPersistentObjectsAsAPartOfACompositeKey;
                    persistentClassInfo.TemplateInfos.Add(templateInfo);
                }
            }
        }
Beispiel #8
0
        private IXPSimpleObject GetExistingOrCreateNewObject(XPObjectSpace objectSpace, string keyPropertyName,
                                                             Row excelRow, Type type)
        {
            Mapping         idMapping = ImportMap.Mappings.SingleOrDefault(p => p.MapedTo == keyPropertyName);
            IXPSimpleObject newObj    = null;

            if (idMapping != null && ImportUtils.GetQString(excelRow[idMapping.Column].Value) != string.Empty)
            {
                try{
                    //find existing object
                    Cell val  = excelRow[idMapping.Column];
                    var  gwid = new Guid(ImportUtils.GetQString(val.Value));
                    newObj =
                        objectSpace.FindObject(type, new BinaryOperator(keyPropertyName, gwid), true) as IXPSimpleObject;
                }
                catch {
                }
            }
            return(newObj ?? (objectSpace.CreateObject(type) as IXPSimpleObject));
        }
 private IXPSimpleObject GetExistingOrCreateNewObject(XPObjectSpace objectSpace, string keyPropertyName,
     Row excelRow, Type type){
     Mapping idMapping = ImportMap.Mappings.SingleOrDefault(p => p.MapedTo == keyPropertyName);
     IXPSimpleObject newObj = null;
     if (idMapping != null && ImportUtils.GetQString(excelRow[idMapping.Column].Value) != string.Empty){
         try{
             //find existing object
             Cell val = excelRow[idMapping.Column];
             var gwid = new Guid(ImportUtils.GetQString(val.Value));
             newObj =
                 objectSpace.FindObject(type, new BinaryOperator(keyPropertyName, gwid), true) as IXPSimpleObject;
         }
         catch{
         }
     }
     return newObj ?? (objectSpace.CreateObject(type) as IXPSimpleObject);
 }
Beispiel #10
0
        public void ProccesExcellRows(IEnumerable records, XPObjectSpace objectSpace, DoWorkEventArgs e) {

            var i = 0;

            //for every row in excell sheet
            foreach (Row record in records) {
                ++i;
                if (i == 1) continue;
                if (_BgWorker.CancellationPending) { e.Cancel = true; break; }

                //var os = new ObjectSpace(objectSpace, XafTypesInfo.Instance);
                object newObj = null;

                //chech if row contains Oid

                //get key property name of the object type being imported
                var kp = objectSpace.GetKeyPropertyName(Type);
                //check if it exists in excel and is mapped ?
                var idMapping = ImportMap.Mappings.FirstOrDefault(p => p.MapedTo == kp);
                if (idMapping != null && GetQString(record[idMapping.Column].Value) != string.Empty) {
                    try {
                        //find existing object
                        var val = record[idMapping.Column];
                        var gwid = new Guid(GetQString(val.Value));
                        newObj = objectSpace.FindObject(Type, new BinaryOperator(kp, gwid), true);
                    } catch {

                    }
                }
                if (newObj == null) //create a new instance
                    newObj = objectSpace.CreateObject(Type) as IXPSimpleObject;

                string message;
                if (newObj != null) {
                    var props = ((IXPSimpleObject)newObj).ClassInfo.PersistentProperties
                        .OfType<XPMemberInfo>().ToList();


                    foreach (var mapping in ImportMap.Mappings) {
                        if (_BgWorker.CancellationPending) { e.Cancel = true; break; }
                        Application.DoEvents();

                        var mapping1 = mapping;
                        var prop = props.FirstOrDefault(p => p.Name == mapping1.MapedTo);

                        try {
                            var val = record[mapping.Column];
                            // continue;

                            if (val != null) {
                                //if simple property
                                if (prop.ReferenceType == null && !prop.MemberType.IsEnum) {
                                    var isNullable = prop.MemberType.IsGenericType && prop.MemberType.GetGenericTypeDefinition() == typeof(Nullable<>);
                                    object convertedValue = null;

                                    if (prop.MemberType == null) return;

                                    if (isNullable) {
                                        if (prop.StorageType == typeof(int)) {
                                            int number;
                                            if (val.Value != String.Empty && Int32.TryParse(val.Value, out number))
                                                convertedValue = number;

                                        } else if (prop.StorageType == typeof(DateTime)) {
                                            if (val.Value != string.Empty) {
                                                //Include validate
                                                var dt = DateTime.FromOADate(Convert.ToDouble(val.Value));
                                                convertedValue = dt;
                                            }
                                        } else if (prop.StorageType == typeof(double)) {
                                            double number;
                                            var rez = Double.TryParse(val.Value, out number);
                                            if (rez) convertedValue = number;
                                        }
                                    } else {
                                        if (prop.MemberType.IsEnum) {
                                            prop.SetValue(newObj, Enum.Parse(prop.MemberType, val.Value));
                                        } else if (prop.MemberType == typeof(char))
                                            convertedValue = Convert.ChangeType(GetQString(val.Value), prop.MemberType);
                                        else if (prop.StorageType == typeof(int)) {
                                            int number;
                                            if (val.Value != String.Empty && Int32.TryParse(val.Value, out number))
                                                convertedValue = number;
                                            else
                                                convertedValue = 0;
                                        } else if (prop.MemberType == typeof(Guid))
                                            convertedValue = new Guid(GetQString(val.Value));
                                        else if (prop.StorageType == typeof(DateTime)) {
                                            if (val.Value != string.Empty) {
                                                //Include validate
                                                var dt = DateTime.FromOADate(Convert.ToDouble(val.Value));
                                                convertedValue = dt;
                                            }
                                        } else if (prop.MemberType == typeof(double)) {
                                            double number;
                                            //  Application.CurrentCulture.NumberFormat.NumberDecimalSeparator = ".";
                                            var rez = Double.TryParse(val.Value, NumberStyles.Number, new NumberFormatInfo { NumberDecimalSeparator = "." }, out number);
                                            if (rez) convertedValue = number;
                                        } else if (prop.MemberType == typeof(bool)) {
                                            if (val.Value != string.Empty && (val.Value.Length == 1 || val.Value.ToLower() == "true" || val.Value.ToLower() == "false")) {
                                                bool truefalse;
                                                if (val.Value.ToLower() == "true" || val.Value.ToLower() == "false")
                                                    truefalse = Convert.ToBoolean(val.Value);
                                                else
                                                    truefalse = Convert.ToBoolean(Convert.ToInt32(val.Value));
                                                convertedValue = truefalse;
                                            }
                                        } else
                                            convertedValue = Convert.ChangeType(val.Value, prop.MemberType);
                                    }

                                    if (convertedValue != null) {
                                        if (convertedValue is double)
                                            convertedValue = Math.Round((double)convertedValue, 2, MidpointRounding.ToEven);

                                        prop.SetValue(newObj, convertedValue);
                                    }
                                }
                                //if referenced property
                                if (prop.ReferenceType != null) {

                                    //if other referenced type
                                    if (prop.MemberType.IsSubclassOf(typeof(XPBaseObject))) {
                                        var text = val.Value;
                                        var typ = prop.MemberType;
                                        var mval = ImportWizard.Helper.GetXpObjectByKeyValue(objectSpace, text, typ);
                                        prop.SetValue(newObj, objectSpace.GetObject(mval));
                                    }
                                }

                            }

                        } catch (Exception ee) {
                            message = string.Format(Resources.ExcelImportWizard_ProccesExcellRows_Error_processing_record__0____1_, i - 1, ee);
                            _BgWorker.ReportProgress(0, message);
                        }

                        if (CurrentCollectionSource != null)
                            AddNewObjectToCollectionSource(CurrentCollectionSource, newObj, ObjectSpace);
                        ObjectSpace.Session.Save(newObj);
                    }
                }

                objectSpace.CommitChanges();
                message = string.Format(Resources.ExcelImportWizard_ProccesExcellRows_Importing_record__0__succesfull_, i - 1);
                _BgWorker.ReportProgress(1, message);
                Application.DoEvents();
            }
        }
Beispiel #11
0
        public void ProccesExcellRows(IEnumerable records, XPObjectSpace objectSpace, DoWorkEventArgs e)
        {
            var i = 0;

            //for every row in excell sheet
            foreach (Row record in records)
            {
                ++i;
                if (i == 1)
                {
                    continue;
                }
                if (_BgWorker.CancellationPending)
                {
                    e.Cancel = true; break;
                }

                //var os = new ObjectSpace(objectSpace, XafTypesInfo.Instance);
                object newObj = null;

                //chech if row contains Oid

                //get key property name of the object type being imported
                var kp = objectSpace.GetKeyPropertyName(Type);
                //check if it exists in excel and is mapped ?
                var idMapping = ImportMap.Mappings.FirstOrDefault(p => p.MapedTo == kp);
                if (idMapping != null && GetQString(record[idMapping.Column].Value) != string.Empty)
                {
                    try {
                        //find existing object
                        var val  = record[idMapping.Column];
                        var gwid = new Guid(GetQString(val.Value));
                        newObj = objectSpace.FindObject(Type, new BinaryOperator(kp, gwid), true);
                    } catch {
                    }
                }
                if (newObj == null) //create a new instance
                {
                    newObj = objectSpace.CreateObject(Type) as IXPSimpleObject;
                }

                string message;
                if (newObj != null)
                {
                    var props = ((IXPSimpleObject)newObj).ClassInfo.PersistentProperties
                                .OfType <XPMemberInfo>().ToList();


                    foreach (var mapping in ImportMap.Mappings)
                    {
                        if (_BgWorker.CancellationPending)
                        {
                            e.Cancel = true; break;
                        }
                        Application.DoEvents();

                        var mapping1 = mapping;
                        var prop     = props.FirstOrDefault(p => p.Name == mapping1.MapedTo);

                        try {
                            var val = record[mapping.Column];
                            // continue;

                            if (val != null)
                            {
                                //if simple property
                                if (prop.ReferenceType == null && !prop.MemberType.IsEnum)
                                {
                                    var    isNullable     = prop.MemberType.IsGenericType && prop.MemberType.GetGenericTypeDefinition() == typeof(Nullable <>);
                                    object convertedValue = null;

                                    if (prop.MemberType == null)
                                    {
                                        return;
                                    }

                                    if (isNullable)
                                    {
                                        if (prop.StorageType == typeof(int))
                                        {
                                            int number;
                                            if (val.Value != String.Empty && Int32.TryParse(val.Value, out number))
                                            {
                                                convertedValue = number;
                                            }
                                        }
                                        else if (prop.StorageType == typeof(DateTime))
                                        {
                                            if (val.Value != string.Empty)
                                            {
                                                //Include validate
                                                var dt = DateTime.FromOADate(Convert.ToDouble(val.Value));
                                                convertedValue = dt;
                                            }
                                        }
                                        else if (prop.StorageType == typeof(double))
                                        {
                                            double number;
                                            var    rez = Double.TryParse(val.Value, out number);
                                            if (rez)
                                            {
                                                convertedValue = number;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (prop.MemberType.IsEnum)
                                        {
                                            prop.SetValue(newObj, Enum.Parse(prop.MemberType, val.Value));
                                        }
                                        else if (prop.MemberType == typeof(char))
                                        {
                                            convertedValue = Convert.ChangeType(GetQString(val.Value), prop.MemberType);
                                        }
                                        else if (prop.StorageType == typeof(int))
                                        {
                                            int number;
                                            if (val.Value != String.Empty && Int32.TryParse(val.Value, out number))
                                            {
                                                convertedValue = number;
                                            }
                                            else
                                            {
                                                convertedValue = 0;
                                            }
                                        }
                                        else if (prop.MemberType == typeof(Guid))
                                        {
                                            convertedValue = new Guid(GetQString(val.Value));
                                        }
                                        else if (prop.StorageType == typeof(DateTime))
                                        {
                                            if (val.Value != string.Empty)
                                            {
                                                //Include validate
                                                var dt = DateTime.FromOADate(Convert.ToDouble(val.Value));
                                                convertedValue = dt;
                                            }
                                        }
                                        else if (prop.MemberType == typeof(double))
                                        {
                                            double number;
                                            //  Application.CurrentCulture.NumberFormat.NumberDecimalSeparator = ".";
                                            var rez = Double.TryParse(val.Value, NumberStyles.Number, new NumberFormatInfo {
                                                NumberDecimalSeparator = "."
                                            }, out number);
                                            if (rez)
                                            {
                                                convertedValue = number;
                                            }
                                        }
                                        else if (prop.MemberType == typeof(bool))
                                        {
                                            if (val.Value != string.Empty && (val.Value.Length == 1 || val.Value.ToLower() == "true" || val.Value.ToLower() == "false"))
                                            {
                                                bool truefalse;
                                                if (val.Value.ToLower() == "true" || val.Value.ToLower() == "false")
                                                {
                                                    truefalse = Convert.ToBoolean(val.Value);
                                                }
                                                else
                                                {
                                                    truefalse = Convert.ToBoolean(Convert.ToInt32(val.Value));
                                                }
                                                convertedValue = truefalse;
                                            }
                                        }
                                        else
                                        {
                                            convertedValue = Convert.ChangeType(val.Value, prop.MemberType);
                                        }
                                    }

                                    if (convertedValue != null)
                                    {
                                        if (convertedValue is double)
                                        {
                                            convertedValue = Math.Round((double)convertedValue, 2, MidpointRounding.ToEven);
                                        }

                                        prop.SetValue(newObj, convertedValue);
                                    }
                                }
                                //if referenced property
                                if (prop.ReferenceType != null)
                                {
                                    //if other referenced type
                                    if (prop.MemberType.IsSubclassOf(typeof(XPBaseObject)))
                                    {
                                        var text = val.Value;
                                        var typ  = prop.MemberType;
                                        var mval = ImportWizard.Helper.GetXpObjectByKeyValue(objectSpace, text, typ);
                                        prop.SetValue(newObj, objectSpace.GetObject(mval));
                                    }
                                }
                            }
                        } catch (Exception ee) {
                            message = string.Format(Resources.ExcelImportWizard_ProccesExcellRows_Error_processing_record__0____1_, i - 1, ee);
                            _BgWorker.ReportProgress(0, message);
                        }

                        if (CurrentCollectionSource != null)
                        {
                            AddNewObjectToCollectionSource(CurrentCollectionSource, newObj, ObjectSpace);
                        }
                        ObjectSpace.Session.Save(newObj);
                    }
                }

                objectSpace.CommitChanges();
                message = string.Format(Resources.ExcelImportWizard_ProccesExcellRows_Importing_record__0__succesfull_, i - 1);
                _BgWorker.ReportProgress(1, message);
                Application.DoEvents();
            }
        }
Beispiel #12
0
        public static void CalculateCashFlow(XPObjectSpace objSpace, DateTime fromDate, DateTime toDate, IList <CashFlowSnapshot> snapshots)
        {
            // delete cash flows within the date range
            CriteriaOperator deleteCriteria = CriteriaOperator.Parse("TranDate Between (?, ?) And LineType = ?",
                                                                     fromDate, toDate, AccountSummaryLineType.Flow);
            var snapshotOids = GetOidsFromSnapshots(snapshots);

            deleteCriteria = deleteCriteria & new InOperator("Snapshot.Oid", snapshotOids);
            objSpace.Session.Delete(objSpace.GetObjects <AccountSummary>(deleteCriteria));

            // get currenet snapshot GUID
            var curSnapshotOid = SetOfBooks.CachedInstance.CurrentCashFlowSnapshot.Oid;

            // add cash flows to AccountSummary
            var maxActualDate            = CashFlow.GetMaxActualTranDate(objSpace.Session); // TODO: why default(DateTime)?
            XPQuery <CashFlow> cashFlows = new XPQuery <CashFlow>(((XPObjectSpace)objSpace).Session);

            foreach (Guid snapshotOid in snapshotOids)
            {
                IQueryable <CashFlowGrouped> cfQuery = null;
                if (snapshotOid != curSnapshotOid)
                {
                    // previous snapshot
                    if (maxActualDate == default(DateTime))
                    {
                        // exclude max actual date from query
                        cfQuery = from c in cashFlows
                                  where c.TranDate >= fromDate && c.TranDate <= toDate &&
                                  (c.Snapshot.Oid == curSnapshotOid &&
                                   c.Status == CashFlowStatus.Actual
                                   ||
                                   c.Snapshot.Oid == snapshotOid
                                   // && c.TranDate > maxActualDate
                                  )
                                  orderby c.TranDate ascending
                                  group c by new { c.TranDate, c.Account } into grp
                            select new CashFlowGrouped(
                            grp.Key.TranDate,
                            grp.Key.Account,
                            (decimal)grp.Sum(c => c.AccountCcyAmt)
                            );
                    }
                    else
                    {
                        cfQuery = from c in cashFlows
                                  where c.TranDate >= fromDate && c.TranDate <= toDate &&
                                  (c.Snapshot.Oid == curSnapshotOid &&
                                   c.Status == CashFlowStatus.Actual
                                   ||
                                   c.Snapshot.Oid == snapshotOid &&
                                   c.TranDate > maxActualDate
                                  )
                                  orderby c.TranDate ascending
                                  group c by new { c.TranDate, c.Account } into grp
                            select new CashFlowGrouped(
                            grp.Key.TranDate,
                            grp.Key.Account,
                            (decimal)grp.Sum(c => c.AccountCcyAmt)
                            );
                    }
                }
                else
                {
                    // current snapshot
                    cfQuery = from c in cashFlows
                              where c.TranDate >= fromDate && c.TranDate <= toDate &&
                              c.Snapshot.Oid == snapshotOid
                              orderby c.TranDate ascending
                              group c by new { c.TranDate, c.Account } into grp
                        select new CashFlowGrouped(
                        grp.Key.TranDate,
                        grp.Key.Account,
                        (decimal)grp.Sum(c => c.AccountCcyAmt)
                        );
                }

                foreach (var cfItem in cfQuery)
                {
                    var summary = objSpace.CreateObject <AccountSummary>();
                    summary.Snapshot      = objSpace.GetObjectByKey <CashFlowSnapshot>(snapshotOid);
                    summary.TranDate      = cfItem.TranDate;
                    summary.Account       = cfItem.Account;
                    summary.AccountCcyAmt = cfItem.AccountCcyAmt;
                    summary.LineType      = AccountSummaryLineType.Flow;
                }
            }
            objSpace.CommitChanges();
        }
Beispiel #13
0
        public static void CalculateBalance(XPObjectSpace objSpace, DateTime atDate, IList <CashFlowSnapshot> snapshots)
        {
            // delete balances matching the specified date
            CriteriaOperator deleteCriteria = Fields.TranDate == atDate & Fields.LineType == new OperandValue(AccountSummaryLineType.Balance);
            var snapshotOids = GetOidsFromSnapshots(snapshots);

            deleteCriteria = deleteCriteria & new InOperator(AccountSummary.Fields.SnapshotOid.PropertyName, snapshotOids);
            objSpace.Session.Delete(objSpace.GetObjects <AccountSummary>(deleteCriteria));

            // get currenet snapshot GUID
            var curSnapshotOid = SetOfBooks.CachedInstance.CurrentCashFlowSnapshot.Oid;

            // add balances to Account Summary
            var maxActualDate            = CashFlow.GetMaxActualTranDate(objSpace.Session);
            XPQuery <CashFlow> cashFlows = new XPQuery <CashFlow>(((XPObjectSpace)objSpace).Session);

            foreach (Guid snapshotOid in snapshotOids)
            {
                IQueryable <CashBalanceGrouped> cfGrouped = null;

                if (snapshotOid != curSnapshotOid)
                {
                    // previous snapshot
                    if (maxActualDate == default(DateTime))
                    {
                        cfGrouped = from c in cashFlows
                                    where c.TranDate <= atDate &&
                                    (
                            c.Snapshot.Oid == snapshotOid
                            //&& c.TranDate > maxActualDate
                            || c.Snapshot.Oid == curSnapshotOid &&
                            c.Status == CashFlowStatus.Actual
                                    )
                                    group c by new { c.Account } into grp
                            select new CashBalanceGrouped(
                            grp.Key.Account,
                            (decimal)grp.Sum(c => c.AccountCcyAmt)
                            );
                    }
                    else
                    {
                        cfGrouped = from c in cashFlows
                                    where c.TranDate <= atDate &&
                                    (
                            c.Snapshot.Oid == snapshotOid &&
                            c.TranDate > maxActualDate ||
                            c.Snapshot.Oid == curSnapshotOid &&
                            c.Status == CashFlowStatus.Actual
                                    )
                                    group c by new { c.Account } into grp
                            select new CashBalanceGrouped(
                            grp.Key.Account,
                            (decimal)grp.Sum(c => c.AccountCcyAmt)
                            );
                    }
                }
                else
                {
                    // current snapshot

                    cfGrouped = from c in cashFlows
                                where c.TranDate <= atDate && c.Snapshot.Oid == snapshotOid
                                group c by new { c.Account } into grp
                        select new CashBalanceGrouped(
                        grp.Key.Account,
                        (decimal)grp.Sum(c => c.AccountCcyAmt)
                        );
                }

                if (cfGrouped == null)
                {
                    return;
                }
                foreach (var cfItem in cfGrouped)
                {
                    var summary = objSpace.CreateObject <AccountSummary>();
                    summary.Snapshot      = objSpace.GetObjectByKey <CashFlowSnapshot>(snapshotOid);
                    summary.TranDate      = atDate;
                    summary.Account       = cfItem.Account;
                    summary.AccountCcyAmt = cfItem.AccountCcyAmt;
                    summary.LineType      = AccountSummaryLineType.Balance;
                }
            }
            objSpace.CommitChanges();
        }
        private void CreateProdOrderFinish(SimpleActionExecuteEventArgs e)
        {
            objectSpace =  (XPObjectSpace)Application.CreateObjectSpace();
            objectSpace.Committed += new EventHandler(ObjectSpace_Committed);
            //ObjectSpace objectSpace = View.ObjectSpace;

            ProdOrder prodOrder = objectSpace.Session.FindObject<ProdOrder>(new DevExpress.Data.Filtering.BinaryOperator("Oid", rListTransfer.ProdOrder.Oid));
            prodOrderFinish = objectSpace.CreateObject<ProdOrderFinish>();

            prodOrderFinish.ProdOrder = prodOrder;
            prodOrderFinish.Qty = rListTransfer.Qty;
            prodOrderFinish.Warehouse = prodOrder.Warehouse;
            prodOrderFinish.ScrapQty = rListTransfer.ScrapQty;
            prodOrderFinish.ScrapWarehouse = prodOrder.ScrapWareHouse;
            e.ShowViewParameters.CreatedView = Application.CreateDetailView(objectSpace, prodOrderFinish);
            e.ShowViewParameters.TargetWindow = TargetWindow.NewModalWindow;
            e.ShowViewParameters.Context = TemplateContext.PopupWindow;
            e.ShowViewParameters.CreateAllControllers = true;

            DialogController dialogController = new DialogController();
            e.ShowViewParameters.Controllers.Add(dialogController);
            dialogController.Accepting += new EventHandler<DialogControllerAcceptingEventArgs>(dialogController_Accepting);
        }
Beispiel #15
0
 static XDocument ExportRecords(XPObjectSpace XPObjectSpace) {
     ISerializationConfiguration serializationConfiguration = XPObjectSpace.CreateObject<SerializationConfiguration>();
     serializationConfiguration.TypeToSerialize = typeof(PEnumClass);
     serializationConfiguration.SerializationConfigurationGroup =
         XPObjectSpace.CreateObject<SerializationConfigurationGroup>();
     new ClassInfoGraphNodeBuilder().Generate(serializationConfiguration);
     XDocument document = new ExportEngine().Export(new[] { _pEnumClass }, serializationConfiguration.SerializationConfigurationGroup);
     return document;
 }