Ejemplo n.º 1
0
 public Transaction()
 {
     operationObj        = new Operation();
     lockTable           = new LockTable();
     detector            = new DeadlockDetector();
     logTable            = new List <string>();
     providerTransaction = new ProviderTransaction();
     this.id             = providerTransaction.GetNextIdTransacion();
     this.status         = "active";
 }
Ejemplo n.º 2
0
 internal void Handle()
 {
     try
     {
         Console.WriteLine("Begin resolving requests...");
         Message request = ReceiveRequest(clientSocket);
         string  methods = request.Content;
         Console.WriteLine("Methods");
         Console.WriteLine(request.Content);
         string             transResponses = "";
         string[]           transMeth      = methods.Split("&");
         List <Transaction> transactions   = new List <Transaction>();
         Console.WriteLine(transMeth.Length);
         foreach (string tranMeth in transMeth)
         {
             Transaction transaction = new Transaction();
             transactions.Add(transaction);
             transaction.SetOperations(tranMeth);
             ProviderTransaction providerTransaction = new ProviderTransaction();
             providerTransaction.StoreTransaction(transaction);
             System.Threading.Thread myThread = new System.Threading.Thread(new
                                                                            System.Threading.ThreadStart(transaction.Run));
             myThread.Start();
             //myThread.Join();
         }
         Exception     exception     = null;
         Message       response      = null;
         MethodHandler methodHandler = null;
         //tratare lista metode
         Thread.Sleep(2000);
         response = new Message();
         foreach (Transaction t in transactions)
         {
             response.Content = t.response;
             if (exception != null)
             {
                 response         = new Message();
                 response.Content = exception.Message;
             }
             SendResponse(clientSocket, response);
             Console.WriteLine("Response sent");
         }
     }
     catch (Exception serviceException)
     {
         Console.WriteLine("Service exception " + serviceException.Message);
     }
     finally
     {
         clientSocket.Shutdown(SocketShutdown.Both);
         clientSocket.Close();
     }
 }
Ejemplo n.º 3
0
        private void InitializeTransactionComponents()
        {
            this.db = new Models.V1.Database.CodeFirst();

            this.transaction = new Transaction()
            {
                Db = this.db
            };

            this.providerTransaction = new ProviderTransaction()
            {
                TransactionToDb = this.transaction
            };
        }