Ejemplo n.º 1
0
        public static PerCallContext Begin(IPerCallDataProvider provider, string operation, string input)
        {
            var ret = new PerCallContext();

            //We find the cost for this call
            decimal cost = provider.GetOperationCost(operation);


            //We put a row into the DataProviderCall table
            ret.Call = new DataProviderCall
            {
                DataProviderCallId = Guid.NewGuid(),
                ActivityId         = BrokerContext.Current.ActivityId,
                CallTime           = DateTime.Now,
                Cost             = cost,
                Input            = input,
                DataProviderType = provider.GetType().ToString(),
                Operation        = operation,
                Success          = null,
            };

            ret.DataContext = new ApplicationDataContext();
            ret.DataContext.DataProviderCalls.InsertOnSubmit(ret.Call);
            ret.DataContext.SubmitChanges();

            return(ret);
        }
Ejemplo n.º 2
0
        public static void LogAction(this IPerCallDataProvider provider, String operation, string input, Boolean success)
        {
            //We find the cost for this call
            decimal cost = provider.GetOperationCost(operation);

            //We put a row into the DataProviderCall table
            using (var dataContext = new ApplicationDataContext())
            {
                var call = new DataProviderCall
                {
                    DataProviderCallId = System.Guid.NewGuid(),
                    ActivityId         = BrokerContext.Current.ActivityId,
                    CallTime           = DateTime.Now,
                    Cost             = cost,
                    Input            = input,
                    DataProviderType = provider.GetType().ToString(),
                    Operation        = operation,
                    Success          = success,
                };
                dataContext.DataProviderCalls.InsertOnSubmit(call);
                dataContext.SubmitChanges();
            }
        }