public void It_should_rollback_first_command()
        {
            // ARRANGE
            IUnitOfWork uow = null;
            var repository = Fixture.CreateRepository(out uow);

            // reset this test
            repository.Delete<Customer>(c => c.FirstName == "Joe" && c.LastName == "Jellybean");

            // ACT
            using (var transaction = new TransactionContext().Begin())
            {
                try
                {
                    repository.Add<Customer>(new Customer { FirstName = "Joe", LastName = "Jellybean" });
                    uow.SaveChanges();

                    //	ProductName is required.  force a failure.
                    repository.Add<Product>(new Product { ProductName = null });
                    uow.SaveChanges();

                    //	should cause a rollback on customer insert (above)
                    transaction.Commit();
                }
                catch (DbEntityValidationException)
                {
                }
            }

            // ASSERT
            var customer = repository.Find<Customer>(c => c.FirstName == "Joe" && c.LastName == "Jellybean");
            Assert.IsNull(customer);
        }
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     MessageTextBlock.Text = "Created Transaction Context";
     _context = _context ?? CreateTxContext(decimal.Parse(amountField.Text));
     _context.Completed += context_Completed;
     _context.Begin(true);
 }
        public void It_should_persist_the_changes_to_the_database()
        {
            // ARRANGE
            IUnitOfWork uow = null;
            var repository = Fixture.CreateRepository(out uow);

            // ACT
            using (var transaction = new TransactionContext().Begin())
            {
                repository.Add<Customer>(new Customer { FirstName = "Joe", LastName = "Jellybean" });
                uow.SaveChanges();

                repository.Add<Product>(new Product { ProductName = "Logitech Mouse" });
                uow.SaveChanges();

                transaction.Commit();
            }

            // ASSERT
            var customer = repository.Find<Customer>(c => c.FirstName == "Joe" && c.LastName == "Jellybean");
            var product = repository.Find<Product>(p => p.ProductName == "Logitech Mouse");

            Assert.IsNotNull(customer);
            Assert.IsNotNull(product);
        }
Example #4
0
		public static async Task SimpleTest()
		{
			const string TraceFileName = "Transactions.TransactionHandlerTest.SimpleTest.log.csv";

			try
			{
				Trace.AutoFlush = true;
				Trace.Listeners.Add(new TextWriterTraceListener(new StreamWriter(TraceFileName, false)));

				using (var dataSource = new MockDataSource("ds", "tx"))
				using (var context = new TransactionContext(TransactionContextAffinity.RequiresNew))
				{
					var command = new MockDataCommand();
					await dataSource.ExecuteNonQuery(command).ConfigureAwait(false);

					context.VoteCommit();
				}
			}
			finally
			{
				Trace.Close();
			}

			CheckTraceLog(TraceFileName);
		}
Example #5
0
		public void CreateTransactionContextTest(TransactionContextAffinity affinity)
		{
			using (var context = new TransactionContext(affinity))
			{
				Assert.AreEqual(affinity, context.Affinity);
				Assert.AreEqual(TransactionContextState.Entered, context.State);
				Assert.AreEqual(IsolationLevel.ReadCommitted, context.IsolationLevel);
			}
		}
 void context_Completed(TransactionContext sender, RetailSDKException error, TransactionRecord record)
 {
     var errorMsg = (error != null ? error.ToString() : "no error");
     Dispatcher.BeginInvoke(new Action(() =>
     {
         MessageTextBlock.Text = "Transaction Completed " + errorMsg;
     }));
     _context = null;
 }
Example #7
0
 private void RemoveId(TransactionContext context)
 {
     var referenceSystem = context._transaction.ReferenceSystem();
     var reference = referenceSystem.ReferenceForId(((int) context._object)
         );
     if (reference != null)
     {
         referenceSystem.RemoveReference(reference);
     }
 }
        private ServiceConfig CreateServiceConfig(TransactionContext trCtx)
        {
            ServiceConfig config = new ServiceConfig();

            TransactionOption transactionOption =
                (TransactionOption)Enum.Parse(typeof(TransactionOption), trCtx.Affinity.ToString());
            config.Transaction = transactionOption;
            System.EnterpriseServices.TransactionIsolationLevel isolationLevel =
                (System.EnterpriseServices.TransactionIsolationLevel)Enum.Parse(typeof(System.EnterpriseServices.TransactionIsolationLevel), trCtx.IsolationLevel.ToString());
            config.IsolationLevel = isolationLevel;

            return config;
        }
        public void OnRequest(IHttpServerTransaction transaction, HttpRequestHead request, bool shouldKeepAlive)
        {
            AddXFF(request, transaction.RemoteEndPoint);

            var expectContinue = request.IsContinueExpected();
            var ignoreResponseBody = request.Method != null && request.Method.ToUpperInvariant() == "HEAD";

            currentContext = new TransactionContext(expectContinue, ignoreResponseBody, shouldKeepAlive);

            if (lastSegment == null)
                currentContext.Segment.AttachTransaction(transaction);

            QueueSegment(currentContext.Segment);
            requestDelegate.OnRequest(request, currentContext.RequestBody, currentContext);
        }
        public TakePayment()
        {
            InitializeComponent();
            RetailSDK.SetNetworkHandler(new CustomNetworkHandler());
            RetailSDK.Initialize();
            ChargeButton.IsEnabled = false;
            MessageTextBlock.Text = "SDK Initialized";
            InitializeMerchant();

            //Synchronizing amount field to terminal display
            amountField.TextChanged += (sender, args) =>
            {
                decimal amount;
                if (_context != null && _context.Invoice != null && decimal.TryParse(amountField.Text, out amount))
                {
                    //This would pump the updated total to the payment device
                    _context.Invoice.Items[0].UnitPrice = amount;
                }
            };

            RetailSDK.DeviceDiscovered += (sender, device) =>
            {
                device.Connected += pd =>
                {
                    try
                    {
                        var deviceId = pd.Id;
                        Dispatcher.BeginInvoke(new Action(() =>
                        {
                            MessageTextBlock.Text = string.Format("{0}Connected to {1}", merchantStatus, deviceId);
                            ChargeButton.IsEnabled = true;
                            const decimal serviceFee = 2.7m;
                            var total = decimal.Parse(amountField.Text);
                            _context = CreateTxContext(total);
                            _context.TotalDisplayFooter = string.Format("\n+${0}% fee\n${1}", serviceFee, decimal.Round(total * (1 + serviceFee/100), 2));
                        }));
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex);
                    }
                };
            };
        }
Example #11
0
        public IOperationResult CreatePackage(Package package)
        {
            //check if package already exist!
               // return new OperationResult() { Result = false, Message = "Package already exist!", Data = new List<object> { Package.Id } };

            bool result;

            using (var transactionContext = new TransactionContext())
            {
                result = cdDataProvider.CreatePackage(package, transactionContext);

                if (result)
                {
                    transactionContext.Commit();
                }
            }

            return new OperationResult() { Result = result, Data = new List<object> {  } };
        }
        internal override EntityDesignerViewModel LoadModel(
            SerializationResult serializationResult, Partition partition, string fileName, ISchemaResolver schemaResolver,
            ValidationController validationController, ISerializerLocator serializerLocator)
        {
            var docData = VSHelpers.GetDocData(PackageManager.Package, fileName) as IEntityDesignDocData;
            docData.CreateAndLoadBuffer();

            EntityDesignerViewModel evm = null;

            var serializationContext = new SerializationContext(GetDirectory(partition.Store), fileName, serializationResult);
            var transactionContext = new TransactionContext();
            transactionContext.Add(SerializationContext.TransactionContextKey, serializationContext);

            using (var t = partition.Store.TransactionManager.BeginTransaction("Load Model from " + fileName, true, transactionContext))
            {
                var uri = Tools.XmlDesignerBase.Base.Util.Utils.FileName2Uri(fileName);
                var context = PackageManager.Package.DocumentFrameMgr.EditingContextManager.GetNewOrExistingContext(uri);
                evm =
                    ModelTranslatorContextItem.GetEntityModelTranslator(context).TranslateModelToDslModel(null, partition) as
                    EntityDesignerViewModel;

                if (evm == null)
                {
                    serializationResult.Failed = true;
                }
                else
                {
                    if (t.IsActive)
                    {
                        t.Commit();
                    }
                }
            }

            // Validate imported model
            if (!serializationResult.Failed
                && (validationController != null))
            {
                validationController.Validate(partition, ValidationCategories.Load);
            }
            return evm;
        }
        public void It_should_not_persist_to_the_database()
        {
            // ARRANGE
            IUnitOfWork uow = null;
            var repository = Fixture.CreateRepository(out uow);

            // reset this test
            repository.Delete<Customer>(c => c.FirstName == "Joe" && c.LastName == "Jellybean");

            // ACT
            using (var transaction = new TransactionContext().Begin())
            {
                repository.Add<Customer>(new Customer { FirstName = "Joe", LastName = "Jellybean" });

                //transaction.Commit();		// ommit for this test
            }

            // ASSERT
            var customer = repository.Find<Customer>(c => c.FirstName == "Joe" && c.LastName == "Jellybean");
            Assert.IsNull(customer);
        }
            public SimpleMembershipInitializer()
            {
                Database.SetInitializer<TransactionContext>(null);

                try
                {
                    using (var context = new TransactionContext())
                    {
                        if (!context.Database.Exists())
                        {
                            // Create the SimpleMembership database without Entity Framework migration schema
                            ((IObjectContextAdapter)context).ObjectContext.CreateDatabase();
                        }
                    }

                    WebSecurity.InitializeDatabaseConnection("TransactionContext", "UserProfile", "UserId", "UserName", autoCreateTables: true);
                }
                catch (Exception ex)
                {
                    throw new InvalidOperationException("The Membership database could not be initialized. For more information, please see http://go.microsoft.com/fwlink/?LinkId=256588", ex);
                }
            }
        /// <summary>
        ///     This method loads the DSL view model with the items in the artifact's C-Model.
        /// </summary>
        internal void ReloadModel(EntityDesignerViewModel viewModel)
        {
            var diagram = viewModel.GetDiagram();
            if (diagram == null)
            {
                // empty DSL diagram
                return;
            }

            // get our artifact
            var artifact = EditingContextManager.GetArtifact(viewModel.EditingContext) as EntityDesignArtifact;
            Debug.Assert(artifact != null);

            var serializationResult = new SerializationResult();

            var serializationContext = new SerializationContext(GetDirectory(viewModel.Store), artifact.Uri.LocalPath, serializationResult);
            var transactionContext = new TransactionContext();
            transactionContext.Add(SerializationContext.TransactionContextKey, serializationContext);

            var workaroundFixSerializationTransactionValue = false;
            if (viewModel.Store.PropertyBag.ContainsKey("WorkaroundFixSerializationTransaction"))
            {
                workaroundFixSerializationTransactionValue = (bool)viewModel.Store.PropertyBag["WorkaroundFixSerializationTransaction"];
            }

            try
            {
                // To fix performance issue during reload, we turn-off layout during "serialization".
                viewModel.Store.PropertyBag["WorkaroundFixSerializationTransaction"] = true;

                using (var t = viewModel.Store.TransactionManager.BeginTransaction("ReloadModel", true, transactionContext))
                {
                    if (artifact.ConceptualModel() == null)
                    {
                        return;
                    }

                    DesignerModel.Diagram diagramModel = null;

                    // If DiagramId is not string empty, try to get the diagram from the artifact. 
                    // There is a situation where we could not find the diagram given an ID (for example: EDMX Model's Diagram that is created by VS before SQL 11; 
                    // In that case, we assign temporary ID to the diagram and a new ID will be generated every time the model is reloaded.)
                    // We could safely choose the first diagram since multiple diagrams feature didn't exist in VS prior to SQL11 release.
                    if (!string.IsNullOrEmpty(diagram.DiagramId))
                    {
                        diagramModel = artifact.DesignerInfo.Diagrams.GetDiagram(diagram.DiagramId);
                    }

                    if (diagramModel == null)
                    {
                        diagramModel = artifact.DesignerInfo.Diagrams.FirstDiagram;
                    }

                    if (diagramModel != null)
                    {
                        // Re-establish the xref between Escher conceptual model and DSL root model.
                        // and between Escher Diagram model and DSL diagram model.

                        Debug.Assert(viewModel.ModelXRef != null, "Why ModelXRef is null?");
                        if (viewModel.ModelXRef != null)
                        {
                            viewModel.ModelXRef.Add(artifact.ConceptualModel(), viewModel, viewModel.EditingContext);
                            viewModel.ModelXRef.Add(diagramModel, diagram, viewModel.EditingContext);
                            ModelTranslatorContextItem.GetEntityModelTranslator(viewModel.EditingContext)
                                .TranslateModelToDslModel(diagramModel, viewModel.Partition);
                        }
                    }

                    if (t.IsActive)
                    {
                        t.Commit();
                    }
                }
            }
            finally
            {
                viewModel.Store.PropertyBag["WorkaroundFixSerializationTransaction"] = workaroundFixSerializationTransactionValue;
            }
        }
Example #16
0
        public virtual TransactionContext Enter()
        {
            if(_state != TransactionContextState.Created
                && _state != TransactionContextState.Exitted)
                throw new InvalidContextStateException(_state, new TransactionContextState[] { TransactionContextState.Created, TransactionContextState.Exitted }, "Context should be in one of the following states in Enter - {Created, Exitted}.");

            TransactionContextState fromState = _state;

            parentContext = CallContext.GetData(THREAD_CURRENT_CONTEXT__KEY) as TransactionContext;
            CallContext.SetData(THREAD_CURRENT_CONTEXT__KEY, this);
            _state = TransactionContextState.Entered;

            RaiseStateChangedEvent(fromState);

            return this;
        }
        public static void Initialize(string dataPath, string virtualPath)
        {
            Licensing.ActivateLicense(
                @"<License>
                <Field name='Name'>Daniel Honaker</Field>
                <Field name='sfId'>003j000000RSOxBAAX</Field>
                <Component name='Dynamic Geometry Library' expiration='2015/11/18' />
                <Component name='Navigation Accuracy Library' expiration='2015/11/18' />
                <Component name='Terrain Analysis Library' expiration='2015/11/18' />
                <Component name='Spatial Analysis Library' expiration='2015/11/18' />
                <Component name='Communications Library' expiration='2015/11/18' />
                <Component name='Insight3D' expiration='2015/11/18' />
                <Component name='Tracking Library' expiration='2015/11/18' />
                <Component name='Route Design Library' expiration='2015/11/18' />
                <Component name='Orbit Propagation Library' expiration='2015/11/18' />
                <Component name='Auto-Routing Library' expiration='2015/11/18' />
                <Signature>SJH4qBqzoL2HKM+Q9TbP7NkFk56vYPoroBRERMWikQum8SQF9bBL35E4N0JUCxpIdMVETg2l3JSd4ddGUHmm33+r6Iamau3SYhzyZsk4dmeEztt3HpZiKZsxr4bcEuLSpCe/8qMXxoJUrbr0K34fELpeOSb5FIGHjxdExsafF1E=</Signature>
                </License>");
            m_virtualPath = virtualPath;

            m_earth = CentralBodiesFacet.GetFromContext().Earth;

            //Make sure the default descriptor for the ExampleEntity class is set.
            ExampleEntity.RegisterEntityClass();

            //Create the primary TransactionContext that will be used throughout the application.
            TransactionContext context = new TransactionContext();
            context.Committed += context_Committed;

            //Create the master entity set that will be populated by our data feed.
            m_entities = new EntitySet<ExampleEntity>(context);
            m_entities.Changed += m_entities_Changed;

            //Create and start the data feed.
            m_provider = new ExampleEntityProvider(dataPath, m_entities);
            m_provider.Start();
        }
        public override ValueObject Execute(TransactionContext trxContext, ValueObject vo)
        {
            AccountMainVo inVo = (AccountMainVo)vo;
            StringBuilder sql  = new StringBuilder();
            ValueObjectList <AccountMainVo> voList = new ValueObjectList <AccountMainVo>();
            //create command
            DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString());

            //create parameter
            DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList();

            sql.Append(@"select * from (
select tam.rank_name as Account_Name,sum(tam.acquistion_cost) as Total_AcquisitionCose,sum(tam.current_depreciation) as Total_CurrentDepreication,
        sum(tam.monthly_depreciation) as Total_MonthlyDepreication,sum(tam.accum_depreciation_now) as Total_AccumDepreication,sum(tam.net_value) as Total_NetBook
 from (select a.account_code_name, f.rank_name,g.account_main_id,c.location_cd,e.asset_cd, e.asset_no, e.asset_name, e.asset_model, e.asset_serial, e.asset_supplier, 
 g.qty, a.account_code_cd, b.account_location_cd, f.rank_cd, b.account_location_name, g.comment_data, e.asset_life, e.acquistion_date, e.acquistion_cost, 
 g.depreciation_start, g.depreciation_end, g.current_depreciation,g.monthly_depreciation, g.accum_depreciation_now, g.net_value, e.asset_invoice, 
 g.registration_date_time, g.registration_user_cd from t_account_main g
                           left join m_account_code a on a.account_code_id = g.account_code_id
                           left join m_account_location b on b.account_location_id = g.account_location_id
                            left join m_location c on c.location_id = g.location_id
                            left join m_user_location d on d.user_location_id = g.user_location_id
                            left join m_asset e on e.asset_id = g.asset_id
                            left join m_rank f on f.rank_id = g.rank_id) tam group by tam.rank_name 

                        union
                            select Case when sum(tam.acquistion_cost) > -1 then 'Total' else 'Total'
	end codename,  sum(tam.acquistion_cost) as Total_AcquisitionCose,sum(tam.current_depreciation) as Total_CurrentDepreication,
        sum(tam.monthly_depreciation) as Total_MonthlyDepreication,sum(tam.accum_depreciation_now) as Total_AccumDepreication,sum(tam.net_value) as Total_NetBook
 from (select a.account_code_name, f.rank_name,g.account_main_id,c.location_cd,e.asset_cd, e.asset_no, e.asset_name, e.asset_model, e.asset_serial, e.asset_supplier, 
 g.qty, a.account_code_cd, b.account_location_cd, f.rank_cd, b.account_location_name, g.comment_data, e.asset_life, e.acquistion_date, e.acquistion_cost, 
 g.depreciation_start, g.depreciation_end, g.current_depreciation,g.monthly_depreciation, g.accum_depreciation_now, g.net_value, e.asset_invoice, 
 g.registration_date_time, g.registration_user_cd from t_account_main g
                           left join m_account_code a on a.account_code_id = g.account_code_id
                           left join m_account_location b on b.account_location_id = g.account_location_id
                            left join m_location c on c.location_id = g.location_id
                            left join m_user_location d on d.user_location_id = g.user_location_id
                            left join m_asset e on e.asset_id = g.asset_id
                            left join m_rank f on f.rank_id = g.rank_id) tam ) tbl order by account_name = 'Total'
");

            sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString());


            //execute SQL
            IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter);

            while (dataReader.Read())
            {
                AccountMainVo outVo = new AccountMainVo
                {
                    //  , h., i., k., o.prodution_work_content_name


                    TotalAccumDepreication   = double.Parse(dataReader["Total_AccumDepreication"].ToString()),
                    TotalAcquisitionCose     = double.Parse(dataReader["Total_AcquisitionCose"].ToString()),
                    TotalCurrentDepreication = double.Parse(dataReader["Total_CurrentDepreication"].ToString()),
                    TotalMonthlyDepreication = double.Parse(dataReader["Total_MonthlyDepreication"].ToString()),
                    TotalNetBook             = double.Parse(dataReader["Total_NetBook"].ToString()),
                    AccountCodeName          = dataReader["Account_Name"].ToString(),
                };
                voList.add(outVo);
            }
            dataReader.Close();
            return(voList);
        }
 protected override SqlTransactionalCommandsContext CreateSqlTransactionalCommandsContext(IDbConnection connection, TransactionContext transactionContext)
 {
     return(new MySqlSqlTransactionalCommandsContext(this, connection, transactionContext));
 }
Example #20
0
 public ValueObject Execute(TransactionContext trxContext, ValueObject vo)
 {
     if (vo == null)
         return null;
     return getDao.Execute(trxContext, vo);
 }
 public ValueObject Execute(TransactionContext trxContext, ValueObject vo)
 {
     return(CheckBuildingRelationDao.Execute(trxContext, vo));
 }
Example #22
0
        public bool HasChildren(TransactionContext transactionContext, byte[] parent)
        {
            var hashSet = transactionContext.Transaction.SelectHashSet <byte[], byte[]>(CHILDREN, parent, 0);

            return(hashSet.Count() > 0);
        }
Example #23
0
 public ValueObject Execute(TransactionContext trxContext, ValueObject vo)
 {
     return(addProcessWorkDao.Execute(trxContext, vo));
 }
Example #24
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject vo)
        {
            WareHouseMainVo inVo = (WareHouseMainVo)vo;
            StringBuilder   sql  = new StringBuilder();
            ValueObjectList <WareHouseMainVo> voList = new ValueObjectList <WareHouseMainVo>();
            //create command
            DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString());

            //create parameter
            DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList();

            sql.Append(@"select m.invertory_time_cd,  m.invertory_time_id,  k.unit_name, d.user_location_name,c.location_cd as before, j.location_cd as after, h.detail_postion_cd, g.warehouse_main_id,c.location_cd,e.asset_cd, e.asset_no, e.asset_name, e.asset_model, e.asset_serial, e.asset_supplier, e.asset_invoice, e.label_status, e.asset_po, g.qty, a.account_code_cd, b.account_location_cd, f.rank_cd, b.account_location_name, g.comment_data, e.asset_life, e.acquistion_date, e.acquistion_cost,e.asset_type, g.depreciation_start, g.depreciation_end, g.current_depreciation,g.monthly_depreciation, g.accum_depreciation_now, g.net_value, g.registration_date_time, g.registration_user_cd from t_warehouse_main g
                           left join m_account_code a on a.account_code_id = g.account_code_id
                           left join m_account_location b on b.account_location_id = g.account_location_id
                            left join m_location c on c.location_id = g.before_location_id
                            left join m_location j on j.location_id = g.after_location_id
                            left join m_user_location d on d.user_location_id = g.user_location_id
                            left join m_asset e on e.asset_id = g.asset_id
                            left join m_rank f on f.rank_id = g.rank_id
                            left join m_detail_postion h on h.detail_postion_id = g.detail_position_id
                            left join m_unit k on k.unit_id = g.unit_id
                            left join t_invertory_equipments l on l.warehouse_main_id = g.warehouse_main_id
                            left join m_invertory_time m on m.invertory_time_id = l.invertory_time_id
                            where 1=1  ");


            if (!String.IsNullOrEmpty(inVo.AssetCode))
            {
                sql.Append(@" and e.asset_cd  =:asset_cd");
                sqlParameter.AddParameterString("asset_cd", inVo.AssetCode);
            }
            if (!String.IsNullOrEmpty(inVo.RankCode))
            {
                sql.Append(" and f.rank_cd  =:rank_cd");
                sqlParameter.AddParameterString("rank_cd", inVo.RankCode);
            }

            if (!String.IsNullOrEmpty(inVo.AssetModel))
            {
                sql.Append(" and e.asset_model =:asset_model");
                sqlParameter.AddParameterString("asset_model", inVo.AssetModel);
            }
            if (!String.IsNullOrEmpty(inVo.AssetName))
            {
                sql.Append(" and e.asset_name =:asset_name");
                sqlParameter.AddParameterString("asset_name", inVo.AssetName);
            }
            if (!String.IsNullOrEmpty(inVo.AssetType))
            {
                sql.Append(" and e.asset_type =:asset_type");
                sqlParameter.AddParameterString("asset_type", inVo.AssetType);
            }
            if (!String.IsNullOrEmpty(inVo.AssetInvoice))
            {
                sql.Append(" and e.asset_invoice =:asset_invoice");
                sqlParameter.AddParameterString("asset_invoice", inVo.AssetInvoice);
            }

            if (!String.IsNullOrEmpty(inVo.AfterLocationCd))
            {
                sql.Append(" and j.location_cd =:location_cd");
                sqlParameter.AddParameterString("location_cd", inVo.AfterLocationCd);
            }
            if (!String.IsNullOrEmpty(inVo.DetailPositionCd))
            {
                sql.Append(" and h.detail_postion_cd =:detail_postion_cd");
                sqlParameter.AddParameterString("detail_postion_cd", inVo.DetailPositionCd);
            }
            if (!String.IsNullOrEmpty(inVo.LabelStatus))//label status
            {
                sql.Append(" and e.label_status =:label_status");
                sqlParameter.AddParameterString("label_status", inVo.LabelStatus);
            }
            if (!String.IsNullOrEmpty(inVo.AssetPO))//label status
            {
                sql.Append(" and e.asset_po =:asset_po");
                sqlParameter.AddParameterString("asset_po", inVo.AssetPO);
            }

            if (!String.IsNullOrEmpty(inVo.Net_Value))//search theo net value
            {
                if (inVo.Net_Value == "0$")
                {
                    sql.Append(" and g.net_value = 0");
                }
                else if (inVo.Net_Value == "1$")
                {
                    sql.Append(" and g.net_value > 0 and g.net_value <2 ");
                }
            }
            sql.Append(" and l.invertory_equipments_id in (select max(invertory_equipments_id) from t_invertory_equipments group by warehouse_main_id) ");
            sql.Append(" order by g.registration_date_time desc");
            sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sql.ToString());


            //execute SQL
            IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter);

            while (dataReader.Read())
            {
                WareHouseMainVo outVo = new WareHouseMainVo
                {
                    //  , h., i., k., o.prodution_work_content_name
                    WareHouseMainId  = int.Parse(dataReader["warehouse_main_id"].ToString()),
                    AfterLocationCd  = dataReader["after"].ToString(),
                    BeforeLocationCd = dataReader["before"].ToString(),
                    DetailPositionCd = dataReader["detail_postion_cd"].ToString(),
                    AssetCode        = dataReader["asset_cd"].ToString(),
                    AssetNo          = int.Parse(dataReader["asset_no"].ToString()),
                    AssetName        = dataReader["asset_name"].ToString(),
                    AssetModel       = dataReader["asset_model"].ToString(),
                    AssetSerial      = dataReader["asset_serial"].ToString(),
                    AssetSupplier    = dataReader["asset_supplier"].ToString(),
                    QTY                  = int.Parse(dataReader["qty"].ToString()),
                    UnitName             = dataReader["unit_name"].ToString(),
                    UserLocationName     = dataReader["user_location_name"].ToString(),
                    AccountCodeCode      = dataReader["account_code_cd"].ToString(),
                    AccountLocationCode  = dataReader["account_location_cd"].ToString(),
                    RankCode             = dataReader["rank_cd"].ToString(),
                    AccountLocationName  = dataReader["account_location_name"].ToString(),
                    CommnetsData         = dataReader["comment_data"].ToString(),
                    AssetLife            = int.Parse(dataReader["asset_life"].ToString()),
                    AcquisitionDate      = DateTime.Parse(dataReader["acquistion_date"].ToString()),
                    AcquisitionCost      = double.Parse(dataReader["acquistion_cost"].ToString()),
                    StartDepreciation    = DateTime.Parse(dataReader["depreciation_start"].ToString()),
                    EndDepreciation      = DateTime.Parse(dataReader["depreciation_end"].ToString()),
                    CurrentDepreciation  = double.Parse(dataReader["current_depreciation"].ToString()),
                    MonthlyDepreciation  = double.Parse(dataReader["monthly_depreciation"].ToString()),
                    AccumDepreciation    = double.Parse(dataReader["accum_depreciation_now"].ToString()),
                    NetValue             = double.Parse(dataReader["net_value"].ToString()),
                    AssetInvoice         = (dataReader["asset_invoice"].ToString()),
                    AssetType            = dataReader["asset_type"].ToString(),
                    LabelStatus          = (dataReader["label_status"].ToString()),
                    AssetPO              = dataReader["asset_po"].ToString(),
                    Invertory            = dataReader["invertory_time_cd"].ToString(),
                    InvertoryId          = int.Parse(dataReader["invertory_time_id"].ToString()),
                    RegistrationDateTime = DateTime.Parse(dataReader["registration_date_time"].ToString()),
                    RegistrationUserCode = (dataReader["registration_user_cd"].ToString()),
                };
                voList.add(outVo);
            }
            dataReader.Close();
            return(voList);
        }
 public ValueObject Execute(TransactionContext trxContext, ValueObject vo)
 {
     return(updateCavityDao.Execute(trxContext, vo));
 }
 public TransactionRepository(TransactionContext context)
 {
     _context      = context;
     _transactions = _context.Transactions;
 }
Example #27
0
 public ValueObject Execute(TransactionContext trxContext, ValueObject vo)
 {
     return(deleteCustomerLineMasterMntDao.Execute(trxContext, vo));
 }
        private static void CreateDeductibleDefinitionIfEnabled(TransactionContext transactionContext, bool isClaimDetailLevelDeductible, List<DeductibleDefinition> deductibles, decimal? amount, bool? isDeductiblePaidByInsurer, string nonFundedMovementType, string fundedMovementType, string productCode, IBusinessComponent context)
        {
            if (!amount.HasValue)
            {
                return;
            }

            var deductibleDefinition = new DeductibleDefinition { Amount = amount.Value, NonFundedMovementType = nonFundedMovementType };
            deductibleDefinition.IsClaimDetailDeductible = isClaimDetailLevelDeductible;

            if (isDeductiblePaidByInsurer.GetValueOrDefault(false))
            {
                if (string.IsNullOrEmpty(fundedMovementType))
                {
                    throw new InvalidOperationException(MessageServiceFactory.GetMessageBody(MessageConstants.NoFundedMovementType, nonFundedMovementType));
                }

                deductibleDefinition.FundedMovementType = fundedMovementType;
            }

            PopulateRecoveryMovementType(transactionContext, deductibleDefinition, productCode, context);
            deductibles.Add(deductibleDefinition);
        }
Example #29
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject vo)
        {
            MaterialInVo inVo = (MaterialInVo)vo;

            //create command
            SAPCommandAdapter sapCommandAdapter = base.GetSAPCommandAdaptor(trxContext, SAPRFCNameEnum.RFC_MATERIAL.GetValue());

            //create parameter
            SAPParameterList sapParameter = sapCommandAdapter.CreateParameterList();

            sapParameter.AddParameter("IM_WERKS", inVo.ImWerks);                // "1100");
            sapParameter.AddParameter("IM_PERIOD_FROM", inVo.ImPeriodFrom);     // "20160323");
            sapParameter.AddParameter("IM_PERIOD_TO", inVo.ImPeriodTo);         // "20160323");
            sapParameter.AddParameter("IM_MATERIAL_FROM", inVo.ImMaterialFrom); // "ZP01");
            sapParameter.AddParameter("IM_MATERIAL_TO", inVo.ImMaterialTo);     // "ZP01");
            sapParameter.AddParameter("IM_SOURCE", inVo.ImSource);              // "1");

            SAPFunction sapFuntion = sapCommandAdapter.Execute(trxContext, sapParameter);

            DataTable sapMaterial = sapFuntion.GetSAPTable("TB_MATERIAL_DATA");

            DataTable sapVendor = sapFuntion.GetSAPTable("TB_VENDOR_DATA");

            DataTable sapReturn = sapFuntion.GetSAPTable("TB_RETURN");

            MaterialOutVo outVo = new MaterialOutVo();


            ////getting material detail
            outVo.MaterialListVo = new List <Vo.MaterialOutVo>();

            foreach (DataRow dr in sapMaterial.Rows)
            {
                MaterialOutVo currOutVo = new MaterialOutVo();

                currOutVo.outmatnr = ConvertNull <string>(dr, "OUT_MATNR");
                currOutVo.outmaktx = ConvertNull <string>(dr, "OUT_MAKTX");
                currOutVo.outmtart = ConvertNull <string>(dr, "OUT_MTART");
                if (IsValid(ConvertNull <string>(dr, "OUT_ERSDA")))
                {
                    currOutVo.outersda = Convert.ToDateTime(ConvertNull <string>(dr, "OUT_ERSDA"));
                }
                if (IsValid(ConvertNull <string>(dr, "OUT_LAEDA")))
                {
                    currOutVo.outlaeda = Convert.ToDateTime(ConvertNull <string>(dr, "OUT_LAEDA"));
                }

                currOutVo.outlvorm1 = ConvertNull <string>(dr, "OUT_LVORM1");
                currOutVo.outxchpf  = ConvertNull <string>(dr, "OUT_XCHPF");
                currOutVo.outmeins  = ConvertNull <string>(dr, "OUT_MEINS");
                currOutVo.outbismt  = ConvertNull <string>(dr, "OUT_BISMT");
                currOutVo.outmatkl  = ConvertNull <string>(dr, "OUT_MATKL");
                currOutVo.outspart  = ConvertNull <string>(dr, "OUT_SPART");
                currOutVo.outprdha  = ConvertNull <string>(dr, "OUT_PRDHA");
                currOutVo.outmstae  = ConvertNull <string>(dr, "OUT_MSTAE");
                currOutVo.outmtpos  = ConvertNull <string>(dr, "OUT_MTPOS");
                currOutVo.outntgew  = Convert.ToDecimal(ConvertNull <string>(dr, "OUT_NTGEW"));
                currOutVo.outgewei  = ConvertNull <string>(dr, "OUT_GEWEI");
                currOutVo.outvolum  = Convert.ToDecimal(ConvertNull <string>(dr, "OUT_VOLUM"));
                currOutVo.outvoleh  = ConvertNull <string>(dr, "OUT_VOLEH");
                currOutVo.outgroes  = ConvertNull <string>(dr, "OUT_GROES");
                currOutVo.outzeinr  = ConvertNull <string>(dr, "OUT_ZEINR");
                currOutVo.outwerks  = ConvertNull <string>(dr, "OUT_WERKS");
                currOutVo.outlvorm2 = ConvertNull <string>(dr, "OUT_LVORM2");
                currOutVo.outdisgr  = ConvertNull <string>(dr, "OUT_DISGR");
                currOutVo.outekgrp  = ConvertNull <string>(dr, "OUT_EKGRP");
                currOutVo.outmmsta  = ConvertNull <string>(dr, "OUT_MMSTA");
                currOutVo.outdismm  = ConvertNull <string>(dr, "OUT_DISMM");
                currOutVo.outminbe  = Convert.ToDecimal(ConvertNull <string>(dr, "OUT_MINBE"));
                currOutVo.outfxhor  = Convert.ToInt32(ConvertNull <string>(dr, "OUT_FXHOR"));
                currOutVo.outdispo  = ConvertNull <string>(dr, "OUT_DISPO");
                currOutVo.outdsnam  = ConvertNull <string>(dr, "OUT_DSNAM");
                currOutVo.outdisls  = ConvertNull <string>(dr, "OUT_DISLS");
                currOutVo.outbstmi  = Convert.ToDecimal(ConvertNull <string>(dr, "OUT_BSTMI"));
                currOutVo.outbstma  = Convert.ToDecimal(ConvertNull <string>(dr, "OUT_BSTMA"));
                currOutVo.outbstfe  = Convert.ToDecimal(ConvertNull <string>(dr, "OUT_BSTFE"));
                currOutVo.outmabst  = Convert.ToDecimal(ConvertNull <string>(dr, "OUT_MABST"));
                currOutVo.outrdprf  = ConvertNull <string>(dr, "OUT_RDPRF");
                currOutVo.outbstrf  = Convert.ToDecimal(ConvertNull <string>(dr, "OUT_BSTRF"));
                currOutVo.outbeskz  = ConvertNull <string>(dr, "OUT_BESKZ");
                currOutVo.outsobsl  = ConvertNull <string>(dr, "OUT_SOBSL");
                currOutVo.outlgpro  = ConvertNull <string>(dr, "OUT_LGPRO");
                currOutVo.outusequ  = ConvertNull <string>(dr, "OUT_USEQU");
                currOutVo.outvspvb  = ConvertNull <string>(dr, "OUT_VSPVB");
                currOutVo.outrgekz  = ConvertNull <string>(dr, "OUT_RGEKZ");
                currOutVo.outlgfsb  = ConvertNull <string>(dr, "OUT_LGFSB");
                currOutVo.outdzeit  = Convert.ToInt32(ConvertNull <string>(dr, "OUT_DZEIT"));
                currOutVo.outplifz  = Convert.ToInt32(ConvertNull <string>(dr, "OUT_PLIFZ"));
                currOutVo.outwebaz  = Convert.ToInt32(ConvertNull <string>(dr, "OUT_WEBAZ"));
                currOutVo.outmrppp  = ConvertNull <string>(dr, "OUT_MRPPP");
                currOutVo.outfhori  = ConvertNull <string>(dr, "OUT_FHORI");
                currOutVo.outeisbe  = Convert.ToDecimal(ConvertNull <string>(dr, "OUT_EISBE"));
                currOutVo.outlgrad  = Convert.ToDecimal(ConvertNull <string>(dr, "OUT_LGRAD"));
                currOutVo.outeislo  = Convert.ToDecimal(ConvertNull <string>(dr, "OUT_EISLO"));
                currOutVo.outrwpro  = ConvertNull <string>(dr, "OUT_RWPRO");
                currOutVo.outshflg  = ConvertNull <string>(dr, "OUT_SHFLG");
                currOutVo.outshzet  = Convert.ToInt32(ConvertNull <string>(dr, "OUT_SHZET"));
                currOutVo.outshpro  = ConvertNull <string>(dr, "OUT_SHPRO");
                currOutVo.outstrgr  = ConvertNull <string>(dr, "OUT_STRGR");
                currOutVo.outvrmod  = ConvertNull <string>(dr, "OUT_VRMOD");
                currOutVo.outvint1  = Convert.ToInt32(ConvertNull <string>(dr, "OUT_VINT1"));
                currOutVo.outvint2  = Convert.ToInt32(ConvertNull <string>(dr, "OUT_VINT2"));
                currOutVo.outmiskz  = ConvertNull <string>(dr, "OUT_MISKZ");
                currOutVo.outmtvfp  = ConvertNull <string>(dr, "OUT_MTVFP");
                currOutVo.outaltsl  = ConvertNull <string>(dr, "OUT_ALTSL");
                currOutVo.outkausf  = Convert.ToDecimal(ConvertNull <string>(dr, "OUT_KAUSF"));
                currOutVo.outkzaus  = ConvertNull <string>(dr, "OUT_KZAUS");
                if (IsValid(ConvertNull <string>(dr, "OUT_AUSDT")))
                {
                    currOutVo.outausdt = Convert.ToDateTime(ConvertNull <string>(dr, "OUT_AUSDT"));
                }
                currOutVo.outnfmat = ConvertNull <string>(dr, "OUT_NFMAT");

                outVo.MaterialListVo.Add(currOutVo);
            }

            ////getting supplier detail
            outVo.SupplierListVo = new List <Vo.SupplierVo>();

            foreach (DataRow dr in sapVendor.Rows)
            {
                SupplierVo currVo = new SupplierVo();
                currVo.OutMatnr = ConvertNull <string>(dr, "OUT_MATNR");
                currVo.OutWerks = ConvertNull <string>(dr, "OUT_WERKS");
                currVo.OutEkorg = ConvertNull <string>(dr, "OUT_EKORG");
                if (IsValid(ConvertNull <string>(dr, "OUT_VALID_FROM")))
                {
                    currVo.OutValidFrom = Convert.ToDateTime(ConvertNull <string>(dr, "OUT_VALID_FROM"));
                }
                if (IsValid(ConvertNull <string>(dr, "OUT_VALID_TO")))
                {
                    currVo.OutValidTo = Convert.ToDateTime(ConvertNull <string>(dr, "OUT_VALID_TO"));
                }

                currVo.OutVendor = ConvertNull <string>(dr, "OUT_VENDOR");
                currVo.OutName   = ConvertNull <string>(dr, "OUT_NAME");

                outVo.SupplierListVo.Add(currVo);
            }


            outVo.SapMessageListVo = new List <SapMessageVo>();

            foreach (DataRow dr in sapReturn.Rows)
            {
                SapMessageVo message = new SapMessageVo();

                message.MessageType      = ConvertNull <string>(dr, "TYPE");
                message.MessageCode      = ConvertNull <string>(dr, "CODE");
                message.Message          = ConvertNull <string>(dr, "MESSAGE");
                message.LogNumber        = ConvertNull <string>(dr, "LOG_NO");
                message.LogMessageNumber = ConvertNull <string>(dr, "LOG_MSG_NO");
                message.MessageVariable1 = ConvertNull <string>(dr, "MESSAGE_V1");
                message.MessageVariable2 = ConvertNull <string>(dr, "MESSAGE_V2");
                message.MessageVariable3 = ConvertNull <string>(dr, "MESSAGE_V3");
                message.MessageVariable4 = ConvertNull <string>(dr, "MESSAGE_V4");

                outVo.SapMessageListVo.Add(message);
            }
            return(outVo);
        }
Example #30
0
 public ValueObject Execute(TransactionContext trxContext, ValueObject vo)
 {
     return(addRoleDao.Execute(trxContext, vo));
 }
 public ProposalResponse(TransactionContext transactionContext, int status, string message) : base(transactionContext.TxID, transactionContext.ChannelID, status, message)
 {
     TransactionContext      = transactionContext;
     proposalResponsePayload = new WeakItem <ProposalResponsePayloadDeserializer, Protos.Peer.FabricProposalResponse.ProposalResponse>((pr) => new ProposalResponsePayloadDeserializer(pr.Payload), () => ProtoProposalResponse);
 }
Example #32
0
		private static async Task ExecuteNode(TransactionContextTestNode node)
		{
			if (node.Parent == null)
				Assert.That(TransactionContext.CurrentTransactionContext, Is.Null);

			var tcs = new TaskCompletionSource<TransactionContextState>();

			using (var tx = new TransactionContext(node.Affinity))
			{
				Assert.That(TransactionContext.CurrentTransactionContext, Is.EqualTo(tx));
				Assert.That(tx.IsController, Is.EqualTo(node.IsController));

				if (node.IsController)
				{
					tx.StateChanged +=
						(s, e) =>
						{
							if (e.NewState == TransactionContextState.Exited)
								tcs.SetResult(e.OldState);
						};
				}

				await node.ExecuteOperation().ConfigureAwait(false);

				if (node.Children != null)
				{
					foreach (var child in node.Children)
						await ExecuteNode(child).ConfigureAwait(false);
				}

				if (node.VoteAction == VoteAction.VoteCommit)
					tx.VoteCommit();
				else if (node.VoteAction == VoteAction.VoteRollback)
					tx.VoteRollback();
			}

			if (node.Parent == null)
				Assert.That(TransactionContext.CurrentTransactionContext, Is.Null);

			if (node.IsController)
			{
				var actualCommitState = await tcs.Task.ConfigureAwait(false);
				Assert.That(actualCommitState, Is.EqualTo(node.GetExpectedCommitState()));
			}
		}
Example #33
0
 public ValueObject Execute(TransactionContext trxContext, ValueObject vo)
 {
     return(deleteLocalSupplierCavityDao.Execute(trxContext, vo));
 }
Example #34
0
        public Transaction()
        {
            AccessedKeys = new List<string>();
            NodesLocation = new Dictionary<string, List<Node>>();
            Nodes = new List<Node>();
            Central = (ICentralDirectory)Activator.GetObject(
              typeof(ICentralDirectory),
              "tcp://localhost:9090/CentralDirectory");
            while (true)
            {
                Tctx = Central.BeginTx();
                if (Tctx.Txid != -1)
                    break;

                Thread.Sleep(500);

            }
            Console.WriteLine(Tctx);
        }
 public BankController(TransactionContext tcontext, UserContext ucontext, BankContext bcontext)
 {
     _tcontext = tcontext;
     _ucontext = ucontext;
     _bcontext = bcontext;
 }
        public override ValueObject Execute(TransactionContext trxContext, ValueObject vo)
        {
            DeliveryOrderVo inVo = (DeliveryOrderVo)vo;

            //create command
            SAPCommandAdapter sapCommandAdapter = base.GetSAPCommandAdaptor(trxContext, "Z_GTSDFG7301_DELIVERY_RFC"); // SAPRFCNameEnum.RFC_DELIVERY_ORDER.GetValue());

            //create parameter for table IT_WERKS
            SAPParameterList sapParameterTable1 = sapCommandAdapter.CreateParameterList();

            sapParameterTable1.AddParameter("SIGN", "I"); //value set from invo
            sapParameterTable1.AddParameter("OPTION", "EQ");
            sapParameterTable1.AddParameter("PLANT_LOW", "1100");
            sapParameterTable1.AddParameter("PLANT_HIGH", "");

            //create parameter for table IT_VBELN
            SAPParameterList sapParameterTable2 = sapCommandAdapter.CreateParameterList();

            sapParameterTable2.AddParameter("SIGN", "I");                  //value set from invo
            sapParameterTable2.AddParameter("OPTION", "EQ");
            sapParameterTable2.AddParameter("DELIV_NUMB_LOW", inVo.DoNo);  //"0081110720"
            sapParameterTable2.AddParameter("DELIV_NUMB_HIGH", inVo.DoNo); //"0081110720"

            //create parameter for table Z_GTSDFG7301_DELIVERY_RFC
            SAPParameterList sapParameter = sapCommandAdapter.CreateParameterList();

            sapParameter.AddParameter("IT_WERKS", sapParameterTable1);
            sapParameter.AddParameter("IT_VBELN", sapParameterTable2);

            SAPFunction sapFuntion = sapCommandAdapter.ExecuteTable(trxContext, sapParameter);

            //Header table data
            DataTable headerTable = sapFuntion.GetSAPTable("ET_HEADER");

            //detail table data
            DataTable itemTable = sapFuntion.GetSAPTable("ET_ITEM");

            // result message table data
            DataTable resultMessageTable = sapFuntion.GetSAPTable("ET_RETURN");

            DeliveryOrderVo outVo = new DeliveryOrderVo();

            // get the Header data
            foreach (DataRow dr in headerTable.Rows)
            {
                outVo.CreationDate     = DateTime.ParseExact(ConvertNull <string>(dr, "ERDAT"), "yyyy-mm-dd", null);
                outVo.DoumentDate      = DateTime.ParseExact(ConvertNull <string>(dr, "AUDAT"), "yyyy-mm-dd", null);
                outVo.Status           = ConvertNull <string>(dr, "GBSTK");
                outVo.PickedQuantity   = (int)double.Parse(ConvertNull <string>(dr, "PIKMG"));
                outVo.DoNo             = ConvertNull <string>(dr, "VBELN");
                outVo.CustomerPoNumber = ConvertNull <string>(dr, "BSTNK");
                outVo.CustomerNumber   = ConvertNull <string>(dr, "KUNNR").TrimStart('0');
                outVo.CustomerName     = ConvertNull <string>(dr, "NAME1");
                outVo.SoNo             = ConvertNull <string>(dr, "VBELN_SALES").TrimStart('0');
                outVo.Amount           = (int)double.Parse(ConvertNull <string>(dr, "MENGE"));
                outVo.DeliveryDate     = DateTime.ParseExact(ConvertNull <string>(dr, "BLDAT"), "yyyy-mm-dd", null);
                outVo.DocumentType     = ConvertNull <string>(dr, "AUART");
            }

            //get the Item data
            outVo.DeliveryOrderDtlList = new List <DeliveryOrderDtlVo>();
            foreach (DataRow dr in itemTable.Rows)
            {
                DeliveryOrderDtlVo dtlOutVo = new DeliveryOrderDtlVo();

                dtlOutVo.SoNumber                    = ConvertNull <string>(dr, "VGBEL");
                dtlOutVo.SoItem                      = ConvertNull <string>(dr, "VGPOS");
                dtlOutVo.OrderQuantity               = (int)double.Parse(ConvertNull <string>(dr, "KWMENG"));
                dtlOutVo.QuantityStock               = (int)double.Parse(ConvertNull <string>(dr, "LGMNG"));
                dtlOutVo.DoNo                        = ConvertNull <string>(dr, "VBELN");
                dtlOutVo.DeliveryItemNumber          = ConvertNull <string>(dr, "POSNR");
                dtlOutVo.BatchNo                     = ConvertNull <string>(dr, "CHARG");
                dtlOutVo.MaterialNumber              = ConvertNull <string>(dr, "MATNR");
                dtlOutVo.MaterialType                = ConvertNull <string>(dr, "MTART");
                dtlOutVo.MaterialTypeDesc            = ConvertNull <string>(dr, "MTBEZ");
                dtlOutVo.MaterialDesc                = ConvertNull <string>(dr, "MAKTX");
                dtlOutVo.MaterialStatisticsGroup     = ConvertNull <string>(dr, "VERSG");
                dtlOutVo.MaterialStatisticsGroupDesc = ConvertNull <string>(dr, "BEZEI20");
                dtlOutVo.MaterialGroup               = ConvertNull <string>(dr, "MATKL");
                dtlOutVo.MaterialGroupDesc           = ConvertNull <string>(dr, "WGBEZ");
                dtlOutVo.QuantitySales               = (int)double.Parse(ConvertNull <string>(dr, "LFIMG"));
                if (!string.Equals(ConvertNull <string>(dr, "ERDAT"), "0000-00-00"))
                {
                    dtlOutVo.PickingDate = DateTime.ParseExact(ConvertNull <string>(dr, "ERDAT"), "yyyy-mm-dd", null);
                }

                //dtlOutVo.PickingTime = DateTime.ParseExact(ConvertNull<string>(dr, "ERZET"), "HH:mm:ss", null);
                dtlOutVo.StorageLocation = ConvertNull <string>(dr, "LGORT");

                outVo.DeliveryOrderDtlList.Add(dtlOutVo);
            }

            //get the Return Message data
            outVo.DeliveryOrderResultMessageList = new List <SapMessageVo>();
            foreach (DataRow dr in resultMessageTable.Rows)
            {
                SapMessageVo message = new SapMessageVo();
                message.MessageType      = ConvertNull <string>(dr, "TYPE");
                message.MessageClassId   = ConvertNull <string>(dr, "ID");
                message.MessageNumber    = ConvertNull <string>(dr, "NUMBER");
                message.Message          = ConvertNull <string>(dr, "MESSAGE");
                message.LogNumber        = ConvertNull <string>(dr, "LOG_NO");
                message.LogMessageNumber = ConvertNull <string>(dr, "LOG_MSG_NO");
                message.MessageVariable1 = ConvertNull <string>(dr, "MESSAGE_V1");
                message.MessageVariable2 = ConvertNull <string>(dr, "MESSAGE_V2");
                message.MessageVariable3 = ConvertNull <string>(dr, "MESSAGE_V3");
                message.MessageVariable4 = ConvertNull <string>(dr, "MESSAGE_V4");

                outVo.DeliveryOrderResultMessageList.Add(message);
            }
            return(outVo);
        }
 private void CommitTransactions(TransactionContext trCtx)
 {
     Hashtable transactionsByDataSourceToCommit =
         dataSourceTransactionsByTrCtx[trCtx] as Hashtable;
     if(transactionsByDataSourceToCommit != null)
     {
         foreach(DictionaryEntry entry in transactionsByDataSourceToCommit)
         {
             DataSession ds = (DataSession)entry.Value;
             ds.Transaction.Commit();
             ds.Connection.Close();
         }
         transactionsByDataSourceToCommit.Clear();
     }
 }
Example #38
0
 public TransactionDetailsRepository(TransactionContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
Example #39
0
 public LocationEnum GetLocation(TransactionContext transactionContext, byte[] item)
 {
     return((LocationEnum)transactionContext.Transaction.Select <byte[], int>(LOCATIONS, item).Value);
 }
 public MockBusinessTransaction(TransactionContext transactionContext)
 {
     SetContext(transactionContext);
 }
Example #41
0
        public IOperationResult DeleteTemplateByName(string templateName)
        {
            // var template=null;//GetTemplateByName(templateName);

            if (GetTemplateByName(templateName) == null)
                return new OperationResult() { Result = false, Message = "template Name does not exist!", Data = new List<object> { templateName } };

            bool IsCommandScheduledAgainstTemplate = false;
            using (var dbContext = new DbContext())
            {
                IsCommandScheduledAgainstTemplate = cdDataProvider.IsCommandScheduledAgainstTemplate(templateName, dbContext);
            }

            if (IsCommandScheduledAgainstTemplate)
            {
                return new OperationResult() { Result = false, Message = "Template could not be deleted because there are commands scheduled against this template.Please delete scheduled commands against this template!", Data = new List<object> { templateName } };
            }

            bool result;

            using (var transactionContext = new TransactionContext())
            {
                // result = cdDataProvider.DeleteTemplateByName(template, transactionContext);
                result = cdDataProvider.DeleteTemplateByName(templateName, transactionContext);

                if (result)
                {
                    transactionContext.Commit();
                }
            }

            return new OperationResult() { Result = result, Data = new List<object> { templateName } };
        }
Example #42
0
 public ValueObject Execute(TransactionContext trxContext, ValueObject vo)
 {
     return(getMoldDao.Execute(trxContext, vo));
 }
Example #43
0
        public IOperationResult UpdatePackage(string id, Package package)
        {
            //check if package exist!
            //return new OperationResult() { Result = false, Message = "Package does not exist!", Data = new List<object> { id } };

            bool result;

            using (var transactionContext = new TransactionContext())
            {
                result = cdDataProvider.UpdatePackage(id, package, transactionContext);

                if (result)
                {
                    transactionContext.Commit();
                }
            }

            return new OperationResult() { Result = result, Data = new List<object> {id} };
        }
Example #44
0
 public ValueObject Execute(TransactionContext trxContext, ValueObject vo)
 {
     return(addProcessDefectiveReasonNewDao.Execute(trxContext, vo));
 }
Example #45
0
        public IOperationResult UpdateTemplateByName(string templateName, Template template)
        {
            if (GetTemplateByName(templateName) == null)
                return new OperationResult() { Result = false, Message = "template Name does not exist!", Data = new List<object> { template.Name } };

            template.Params = GetParam(template);
            bool result;

            using (var transactionContext = new TransactionContext())
            {
                result = cdDataProvider.UpdateTemplateByName(templateName, template, transactionContext);

                if (result)
                {
                    transactionContext.Commit();
                }
            }

            return new OperationResult() { Result = result, Data = new List<object> { template.Name } };
        }
        private static void PopulateRecoveryMovementType(TransactionContext transactionContext, DeductibleDefinition definition, string productCode, IBusinessComponent context)
        {
            string movementType;
            if (definition.FundedMovementType != null && ClaimsBusinessLogicHelper.TryGetRecoveryReserveMovementType(transactionContext, definition.FundedMovementType, productCode, context, out movementType))
            {
                definition.RecoveryFundedMovementType = movementType;
            }

            if (definition.FundedMovementType != null && ClaimsBusinessLogicHelper.TryGetRecoveryReserveMovementType(transactionContext, definition.FundedMovementType, productCode, context, out movementType))
            {
                definition.RecoveryNonFundedMovementType = movementType;
            }
        }
Example #47
0
        public IOperationResult UpdateTerminalFilter(string filterId, FilterDefs terminalFilter)
        {
            if (!GetTerminalFilters().Any(c => c.FilterId == Convert.ToInt32(filterId)))
                return new OperationResult() { Result = false, Message = "Terminal Filter does not exist!", Data = new List<object> { filterId } };

            bool result;

            using (var transactionContext = new TransactionContext())
            {
                result = cdDataProvider.UpdateTerminalFilter(filterId, terminalFilter, transactionContext);

                if (result)
                {
                    transactionContext.Commit();
                }
            }
            return new OperationResult() { Result = result, Data = new List<object> { terminalFilter.FilterId } };
        }
Example #48
0
        public override ValueObject Execute(TransactionContext trxContext, ValueObject arg)
        {
            BuildingVo inVo = (BuildingVo)arg;

            StringBuilder sqlQuery = new StringBuilder();

            //create SQL
            sqlQuery.Append("Select ct.building_id, ct.building_cd, ct.building_name, ");
            sqlQuery.Append(" ct.factory_cd from m_building ct ");

            sqlQuery.Append(" where ct.factory_cd = :faccd ");

            if (inVo.BuildingCode != null)
            {
                sqlQuery.Append(" and ct.building_cd like :buildingcd ");
            }

            if (inVo.BuildingName != null)
            {
                sqlQuery.Append(" and ct.building_name like :buildingname ");
            }

            if (inVo.BuildingId > 0)
            {
                sqlQuery.Append(" and ct.building_id = :buildingid ");
            }

            if (inVo.FactoryCode != null)
            {
                sqlQuery.Append(" and factory_cd = :factorycd ");
            }

            sqlQuery.Append(" order by ct.building_cd");

            //create command
            DbCommandAdaptor sqlCommandAdapter = base.GetDbCommandAdaptor(trxContext, sqlQuery.ToString());

            //create parameter
            DbParameterList sqlParameter = sqlCommandAdapter.CreateParameterList();

            sqlParameter.AddParameterString("faccd", UserData.GetUserData().FactoryCode);
            if (inVo.BuildingCode != null)
            {
                sqlParameter.AddParameterString("buildingcd", inVo.BuildingCode + "%");
            }
            if (inVo.BuildingId > 0)
            {
                sqlParameter.AddParameterInteger("buildingid", inVo.BuildingId);
            }
            if (inVo.BuildingName != null)
            {
                sqlParameter.AddParameterString("buildingname", inVo.BuildingName + "%");
            }
            if (inVo.FactoryCode != null)
            {
                sqlParameter.AddParameterString("factorycd", inVo.FactoryCode);
            }

            //execute SQL
            IDataReader dataReader = sqlCommandAdapter.ExecuteReader(trxContext, sqlParameter);

            BuildingVo outVo = new BuildingVo();

            while (dataReader.Read())

            {
                BuildingVo currOutVo = new BuildingVo
                {
                    BuildingId   = Convert.ToInt32(dataReader["building_id"]),
                    BuildingCode = dataReader["building_cd"].ToString(),
                    BuildingName = dataReader["building_name"].ToString(),
                    FactoryCode  = dataReader["factory_cd"].ToString()
                };
                outVo.BuildingListVo.Add(currOutVo);
            }
            dataReader.Close();

            return(outVo);
        }
Example #49
0
 public ValueObject Execute(TransactionContext trxContext, ValueObject vo)
 {
     return(updateInspectionTestInstructionDao.Execute(trxContext, vo));
 }
Example #50
0
 public double TotalWork(TransactionContext transactionContext, byte[] item)
 {
     return(transactionContext.Transaction.Select <byte[], double>(TOTAL_WORK, item).Value);
 }
Example #51
0
        public IOperationResult CreateTemplate(Template template)
        {
            if (GetTemplate(template.TemplateId.ToString()) != null)
                return new OperationResult() { Result = false, Message = "template id already exist!", Data = new List<object> { template.TemplateId } };

            if (GetTemplateByName(template.Name) != null)
                return new OperationResult() { Result = false, Message = "template name already exist!", Data = new List<object> { template.Name } };

            // Get param
            template.Params = GetParam(template);

            bool result;

            using (var transactionContext = new TransactionContext())
            {
                result = cdDataProvider.CreateTemplate(template, transactionContext);

                if (result)
                {
                    transactionContext.Commit();
                }
            }

            return new OperationResult() { Result = result, Data = new List<object> { template.TemplateId } };
        }
Example #52
0
        public IOperationResult CreateTerminalFilter(FilterDefs terminalFilter)
        {
            if (GetTerminalFilters().Any(c => c.FilterId == terminalFilter.FilterId || c.FilterName == terminalFilter.FilterName))
                return new OperationResult() { Result = false, Message = "Terminal Filter already exist!", Data = new List<object> { terminalFilter.FilterId, terminalFilter.FilterName } };

            bool result;

            using (var transactionContext = new TransactionContext())
            {
                result = cdDataProvider.CreateTerminalFilter(terminalFilter, transactionContext);

                if (result)
                {
                    transactionContext.Commit();
                }
            }

            return new OperationResult() { Result = result, Data = new List<object> { terminalFilter.FilterId } };
        }
        public async Task Invoke(IAddressable target, IInvokable invokable, Message message)
        {
            try
            {
                // Don't process messages that have already timed out
                if (message.IsExpired)
                {
                    message.DropExpiredMessage(MessagingStatisticsGroup.Phase.Invoke);
                    return;
                }

                RequestContext.Import(message.RequestContextData);
                if (Config.Globals.PerformDeadlockDetection && !message.TargetGrain.IsSystemTarget)
                {
                    UpdateDeadlockInfoInRequestContext(new RequestInvocationHistory(message.TargetGrain, message.TargetActivation, message.DebugContext));
                    // RequestContext is automatically saved in the msg upon send and propagated to the next hop
                    // in RuntimeClient.CreateMessage -> RequestContext.ExportToMessage(message);
                }

                bool            startNewTransaction = false;
                TransactionInfo transactionInfo     = message.TransactionInfo;

                if (message.IsTransactionRequired && transactionInfo == null)
                {
                    // TODO: this should be a configurable parameter
                    var transactionTimeout = Debugger.IsAttached ? TimeSpan.FromMinutes(30) : TimeSpan.FromSeconds(10);

                    // Start a new transaction
                    transactionInfo = await this.transactionAgent.Value.StartTransaction(message.IsReadOnly, transactionTimeout);

                    startNewTransaction = true;
                }

                if (transactionInfo != null)
                {
                    TransactionContext.SetTransactionInfo(transactionInfo);
                }

                object resultObject;
                try
                {
                    var request = (InvokeMethodRequest)message.GetDeserializedBody(this.SerializationManager);
                    if (request.Arguments != null)
                    {
                        CancellationSourcesExtension.RegisterCancellationTokens(target, request, this.loggerFactory, logger, this, this.cancellationTokenRuntime);
                    }

                    var invoker = invokable.GetInvoker(typeManager, request.InterfaceId, message.GenericGrainType);

                    if (invoker is IGrainExtensionMethodInvoker &&
                        !(target is IGrainExtension))
                    {
                        // We are trying the invoke a grain extension method on a grain
                        // -- most likely reason is that the dynamic extension is not installed for this grain
                        // So throw a specific exception here rather than a general InvalidCastException
                        var error = String.Format(
                            "Extension not installed on grain {0} attempting to invoke type {1} from invokable {2}",
                            target.GetType().FullName, invoker.GetType().FullName, invokable.GetType().FullName);
                        var    exc            = new GrainExtensionNotInstalledException(error);
                        string extraDebugInfo = null;
#if DEBUG
                        extraDebugInfo = Utils.GetStackTrace();
#endif
                        logger.Warn(ErrorCode.Stream_ExtensionNotInstalled,
                                    string.Format("{0} for message {1} {2}", error, message, extraDebugInfo), exc);

                        throw exc;
                    }

#pragma warning disable 618
                    var invokeInterceptor = this.CurrentStreamProviderRuntime?.GetInvokeInterceptor();
#pragma warning restore 618
                    var requestInvoker = new GrainMethodInvoker(target, request, invoker, siloInterceptors, interfaceToImplementationMapping, invokeInterceptor);
                    await requestInvoker.Invoke();

                    resultObject = requestInvoker.Result;
                }
                catch (Exception exc1)
                {
                    if (invokeExceptionLogger.IsEnabled(LogLevel.Debug) || message.Direction == Message.Directions.OneWay)
                    {
                        invokeExceptionLogger.Warn(ErrorCode.GrainInvokeException,
                                                   "Exception during Grain method call of message: " + message, exc1);
                    }

                    transactionInfo = TransactionContext.GetTransactionInfo();
                    if (transactionInfo != null)
                    {
                        // Must abort the transaction on exceptions
                        transactionInfo.IsAborted = true;
                        if (startNewTransaction)
                        {
                            var abortException = (exc1 as OrleansTransactionAbortedException) ??
                                                 new OrleansTransactionAbortedException(transactionInfo.TransactionId, exc1);
                            this.transactionAgent.Value.Abort(transactionInfo, abortException);
                            exc1 = abortException;
                        }
                    }

                    // If a grain allowed an inconsistent state exception to escape and the exception originated from
                    // this activation, then deactivate it.
                    var ise = exc1 as InconsistentStateException;
                    if (ise != null && ise.IsSourceActivation)
                    {
                        // Mark the exception so that it doesn't deactivate any other activations.
                        ise.IsSourceActivation = false;

                        var activation = (target as Grain)?.Data;
                        if (activation != null)
                        {
                            invokeExceptionLogger.Info($"Deactivating {activation} due to inconsistent state.");
                            this.DeactivateOnIdle(activation.ActivationId);
                        }
                    }

                    if (message.Direction != Message.Directions.OneWay)
                    {
                        SafeSendExceptionResponse(message, exc1);
                    }
                    return;
                }

                transactionInfo = TransactionContext.GetTransactionInfo();
                if (transactionInfo != null && transactionInfo.ReconcilePending() > 0)
                {
                    var abortException = new OrleansOrphanCallException(transactionInfo.TransactionId, transactionInfo.PendingCalls);
                    // Can't exit before the transaction completes.
                    TransactionContext.GetTransactionInfo().IsAborted = true;
                    if (startNewTransaction)
                    {
                        this.transactionAgent.Value.Abort(TransactionContext.GetTransactionInfo(), abortException);
                    }


                    if (message.Direction != Message.Directions.OneWay)
                    {
                        SafeSendExceptionResponse(message, abortException);
                    }

                    return;
                }

                if (startNewTransaction)
                {
                    // This request started the transaction, so we try to commit before returning.
                    await this.transactionAgent.Value.Commit(transactionInfo);
                }

                if (message.Direction == Message.Directions.OneWay)
                {
                    return;
                }

                SafeSendResponse(message, resultObject);
            }
            catch (Exception exc2)
            {
                logger.Warn(ErrorCode.Runtime_Error_100329, "Exception during Invoke of message: " + message, exc2);
                if (message.Direction != Message.Directions.OneWay)
                {
                    SafeSendExceptionResponse(message, exc2);
                }

                if (exc2 is OrleansTransactionInDoubtException)
                {
                    // TODO: log an error message?
                }
                else if (TransactionContext.GetTransactionInfo() != null)
                {
                    // Must abort the transaction on exceptions
                    TransactionContext.GetTransactionInfo().IsAborted = true;
                    var abortException = (exc2 as OrleansTransactionAbortedException) ??
                                         new OrleansTransactionAbortedException(TransactionContext.GetTransactionInfo().TransactionId, exc2);
                    this.transactionAgent.Value.Abort(TransactionContext.GetTransactionInfo(), abortException);
                }
            }
            finally
            {
                TransactionContext.Clear();
            }
        }
 private void RollbackTransactions(TransactionContext trCtx)
 {
     Hashtable transactionsByDataSourceToRollback =
         dataSourceTransactionsByTrCtx[trCtx] as Hashtable;
     if(transactionsByDataSourceToRollback != null)
     {
         foreach(DictionaryEntry entry in transactionsByDataSourceToRollback)
         {
             DataSession ds = (DataSession)entry.Value;
             ds.Transaction.Rollback();
             ds.Connection.Close();
         }
         transactionsByDataSourceToRollback.Clear();
     }
 }
Example #55
0
 public bool IsLocation(TransactionContext transactionContext, byte[] item, LocationEnum location)
 {
     return(transactionContext.Transaction.Select <byte[], int>(LOCATIONS, item).Value == (int)location);
 }