コード例 #1
0
 public bool CreateObject(StavkaProforme objekat)
 {
     try
     {
         _broker.OpenConnection();
         _broker.BeginTransaction();
         objekat.Lajsna = _broker.ReturnByCriteria($"WHERE NazivLajsne LIKE '{objekat.Lajsna.NazivLajsne}'", objekat.Lajsna).OfType <Lajsna>().ToList().FirstOrDefault();
         _broker.InsertObject(objekat);
         _broker.Commit();
         return(true);
     }
     catch (SqlException ex)
     {
         Debug.Write(">>>>>>>> " + ex.Message);
         _broker.Rollback();
         throw new Exception(ex.Message);
     }
     catch (Exception ex)
     {
         Debug.WriteLine(">>>> " + ex.Message);
         _broker.Rollback();
         throw new Exception(ex.Message);
     }
     finally
     {
         _broker.CloseConnection();
     }
 }
コード例 #2
0
 public List <Drzava> GetCountries()
 {
     try
     {
         _broker.OpenConnection();
         _broker.BeginTransaction();
         List <Drzava> list = _broker.SelectAll(new Drzava()).OfType <Drzava>().ToList();
         _broker.Commit();
         return(list);
     }
     catch (SqlException ex)
     {
         Debug.Write(">>>>>>>> " + ex.Message);
         _broker.Rollback();
         throw new Exception(ex.Message);
     }
     catch (Exception ex)
     {
         Debug.WriteLine(">>>> " + ex.Message);
         _broker.Rollback();
         throw new Exception(ex.Message);
     }
     finally
     {
         _broker.CloseConnection();
     }
 }
コード例 #3
0
 public Lajsna GetLajsna(string name)
 {
     try
     {
         _broker.OpenConnection();
         _broker.BeginTransaction();
         Lajsna lajsna = _broker.ReturnByCriteria($"WHERE NazivLajsne LIKE '{name}'", new Lajsna()).OfType <Lajsna>().ToList().FirstOrDefault();
         _broker.Commit();
         return(lajsna);
     }
     catch (SqlException ex)
     {
         Debug.Write(">>>>>>>> " + ex.Message);
         _broker.Rollback();
         throw new Exception(ex.Message);
     }
     catch (Exception ex)
     {
         Debug.WriteLine(">>>> " + ex.Message);
         _broker.Rollback();
         throw new Exception(ex.Message);
     }
     finally
     {
         _broker.CloseConnection();
     }
 }
コード例 #4
0
 public bool CreateObject(TipLajsne objekat)
 {
     try
     {
         _broker.OpenConnection();
         _broker.BeginTransaction();
         _broker.InsertObject(objekat);
         _broker.Commit();
         return(true);
     }
     catch (SqlException ex)
     {
         Debug.Write(">>>>>>>> " + ex.Message);
         _broker.Rollback();
         throw new Exception(ex.Message);
     }
     catch (Exception ex)
     {
         Debug.WriteLine(">>>> " + ex.Message);
         _broker.Rollback();
         throw new Exception(ex.Message);
     }
     finally
     {
         _broker.CloseConnection();
     }
 }
コード例 #5
0
 public bool CreateObject(NalogZaUtovar objekat)
 {
     try
     {
         _broker.OpenConnection();
         _broker.BeginTransaction();
         objekat.Prevoznik    = _broker.ReturnByCriteriaJoin($" WHERE NazivKompanije LIKE '{objekat.Prevoznik.NazivKompanije}'", objekat.Prevoznik).OfType <Prevoznik>().ToList().FirstOrDefault();
         objekat.CarinikIzvoz = _broker.ReturnByCriteriaJoin($" WHERE NazivKompanije LIKE '{objekat.CarinikIzvoz.NazivKompanije}'", objekat.CarinikIzvoz).OfType <Carinik>().ToList().FirstOrDefault();
         objekat.CarinikUvoz  = _broker.ReturnByCriteriaJoin($" WHERE NazivKompanije LIKE '{objekat.CarinikUvoz.NazivKompanije}'", objekat.CarinikUvoz).OfType <Carinik>().ToList().FirstOrDefault();
         _broker.InsertObject(objekat);
         _broker.Commit();
         return(true);
     }
     catch (SqlException ex)
     {
         Debug.Write(">>>>>>>> " + ex.Message);
         _broker.Rollback();
         throw new Exception(ex.Message);
     }
     catch (Exception ex)
     {
         Debug.WriteLine(">>>> " + ex.Message);
         _broker.Rollback();
         throw new Exception(ex.Message);
     }
     finally
     {
         _broker.CloseConnection();
     }
 }
コード例 #6
0
        public object ExecuteSO(DomenskiObjekat domenskiObjekat)
        {
            object res = null;

            try
            {
                Validate(domenskiObjekat);
                broker.OpenConnection();
                broker.BeginTransaction();

                res = Execute(domenskiObjekat);

                broker.Commit();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                broker.Rollback();
            }
            finally
            {
                broker.CloseConnection();
            }
            return(res);
        }
コード例 #7
0
        public object ExecuteSO(IDomainObject entity)
        {
            object res = null;

            try
            {
                Validate(entity);
                broker.OpenConnection();
                broker.BeginTransaction();

                res = Execute(entity);

                broker.CommitTransaction();
            }
            catch (Exception)
            {
                broker.RollbackTransaction();
            }
            finally
            {
                broker.CloseConnection();
            }

            return(res);
        }
コード例 #8
0
        public void ExecuteTemplate(IEntity entity = null, List <IEntity> entities = null)
        {
            try
            {
                broker.OpenConnection();
                broker.BeginTransaction();
                if (entities != null)
                {
                    foreach (IEntity e in entities)
                    {
                        ExecuteOperation(e);
                    }
                }
                if (entity != null)
                {
                    ExecuteOperation(entity);
                }

                broker.Commit();
                Successful = true;
            }
            catch (Exception)
            {
                Successful = false;
                broker.Rollback();
            }
            finally
            {
                broker.CloseConnection();
            }
        }
コード例 #9
0
 static void monitorPaymentQueue()
 {
     using (var broker = new Broker(ConfigurationManager.AppSettings["connectionString"]))
     {
         while (!stopping)
         {
             string message, messageType;
             Guid   dialogHandle, serviceInstance;
             broker.BeginTransaction();
             broker.Receive("PrintTargetQueue", out messageType, out message, out serviceInstance, out dialogHandle);
             if (message != null)
             {
                 switch (messageType)
                 {
                 case "PrintRequest":
                 {
                     var xml = new XmlDocument();
                     xml.LoadXml(message);
                     int BookingId = int.Parse(xml.DocumentElement.InnerText);
                     Console.Write(string.Format("Printing Tickets For Order : {0}... ", BookingId));
                     Thread.Sleep(3000);         /******CODE TO PRINT WOULD GO HERE*****/
                     Console.Write("Printed\n");
                     broker.Send(dialogHandle, "<Print><BookingId>" + BookingId + "</BookingId><PrintStatus>2</PrintStatus></Print>", "PrintResponse");
                     broker.EndDialog(dialogHandle);
                     break;
                 }
                 }
             }
             broker.Commit();
         }
     }
 }
コード例 #10
0
 public void SaveMoreDijagnoze(List <Dijagnoza> dijagnoze)
 {
     broker.OpenConnection();
     broker.BeginTransaction();
     try
     {
         int brojac = 0;
         foreach (Dijagnoza dijagnoza in dijagnoze)
         {
             if (brojac == dijagnoze.Count)
             {
                 break;
             }
             broker.InsertDijagnoza(dijagnoza);
         }
         broker.Commit();
     }
     catch
     {
         broker.Rollback();
     }
     finally
     {
         broker.CloseConnection();
     }
 }
コード例 #11
0
ファイル: Repository.cs プロジェクト: Saponja/PSSeminarski
 public void Delete(IEntity entity, int id)
 {
     try
     {
         broker.OpenConnection();
         broker.BeginTransaction();
         broker.Delete(entity, id);
         broker.Commit();
     }
     catch (Exception)
     {
         broker.Rollback();
         throw;
     }
     finally
     {
         broker.CloseConnection();
     }
 }
コード例 #12
0
 public bool CreateObject(Porudzbina objekat)
 {
     try
     {
         _broker.OpenConnection();
         _broker.BeginTransaction();
         objekat.Datum         = DateTime.Now;
         objekat.Katalog       = _broker.ReturnByCriteria($"WHERE Godina={DateTime.Today.Year}", new Katalog()).OfType <Katalog>().ToList().FirstOrDefault();
         objekat.Klijent       = _broker.ReturnByCriteriaJoin($" WHERE NazivKompanije LIKE '{objekat.Klijent.NazivKompanije}'", objekat.Klijent).OfType <Klijent>().ToList().FirstOrDefault();
         objekat.NacinIsporuke = _broker.ReturnByCriteria($" WHERE NazivIsporuke LIKE '{objekat.NacinIsporuke.NazivIsporuke}'", objekat.NacinIsporuke).OfType <NacinIsporuke>().ToList().FirstOrDefault();
         objekat.NacinPlacanja = _broker.ReturnByCriteria($" WHERE NazivPlacanja LIKE '{objekat.NacinPlacanja.NazivPlacanja}'", objekat.NacinPlacanja).OfType <NacinPlacanja>().ToList().FirstOrDefault();
         long id = _broker.InsertObject(objekat);
         foreach (var item in objekat.Stavke)
         {
             item.Porudzbina = new Porudzbina()
             {
                 Id = id
             };
             item.Lajsna = _broker.ReturnByCriteria($"WHERE NazivLajsne LIKE '{item.Lajsna.NazivLajsne}'", new Lajsna()).OfType <Lajsna>().ToList().FirstOrDefault();
             _broker.InsertObject(item);
         }
         _broker.Commit();
         return(true);
     }
     catch (SqlException ex)
     {
         Debug.Write(">>>>>>>> " + ex.Message);
         _broker.Rollback();
         throw new Exception(ex.Message);
     }
     catch (Exception ex)
     {
         Debug.WriteLine(">>>> " + ex.Message);
         _broker.Rollback();
         throw new Exception(ex.Message);
     }
     finally
     {
         _broker.CloseConnection();
     }
 }
コード例 #13
0
 public bool CreateObject(Adresa objekat)
 {
     try
     {
         _broker.OpenConnection();
         _broker.BeginTransaction();
         objekat.Kompanija = _broker.ReturnByCriteria($"WHERE NazivKompanije LIKE '{objekat.Kompanija.NazivKompanije}'", objekat.Kompanija).OfType <Kompanija>().ToList().FirstOrDefault();
         objekat.Grad      = _broker.ReturnByCriteriaJoin($"WHERE NazivGrada LIKE '{objekat.Grad.NazivGrada}'", objekat.Grad).OfType <Grad>().ToList().FirstOrDefault();
         _broker.InsertObject(objekat);
         _broker.Commit();
         return(true);
     }
     catch (SqlException ex)
     {
         Debug.Write(">>>>>>>> " + ex.Message);
         _broker.Rollback();
         throw new Exception(ex.Message);
     }
     catch (Exception ex)
     {
         Debug.WriteLine(">>>> " + ex.Message);
         _broker.Rollback();
         throw new Exception(ex.Message);
     }
     finally
     {
         _broker.CloseConnection();
     }
 }
コード例 #14
0
        public object ExecuteSO(DomenskiObjekat domenskiObjekat)
        {
            object rezultat = null;

            try
            {
                Validate(domenskiObjekat);
                broker.OtvoriKonekciju();
                broker.BeginTransaction();
                rezultat = Execute(domenskiObjekat);
                broker.Commit();
            }
            catch (Exception)
            {
                broker.RollBack();
            }
            finally
            {
                broker.ZatvoriKonekciju();
            }

            return(rezultat);
        }
コード例 #15
0
 public object ExecuteTemplate(IEntity entity)
 {
     try
     {
         broker.OpenConnection();
         broker.BeginTransaction();
         result = ExecuteSO(entity);
         broker.Commit();
     }
     catch (Exception)
     {
         broker.RollBack();
     }
     finally
     {
         broker.CloseConnection();
     }
     return(result);
 }
コード例 #16
0
 public void LetsDoIt(IDomainObject obj)
 {
     try
     {
         Validation(obj);
         broker.OpenConnection();
         broker.BeginTransaction();
         DoOperation(obj);
         broker.CommitTransaction();
     }
     catch (Exception)
     {
         broker.RollbackTransaction();
         throw;
     }
     finally
     {
         broker.CloseConnection();
     }
 }
コード例 #17
0
        public int DeleteObject(Lajsna objekat)
        {
            try
            {
                _broker.OpenConnection();
                _broker.BeginTransaction();
                Lajsna      lajsna = _broker.SelectObject(objekat) as Lajsna;
                List <Cena> cene   = _broker.ReturnByCriteria($"WHERE SifraLajsne={lajsna.Id}", new Cena()).OfType <Cena>().ToList();

                foreach (var cena in cene)
                {
                    _broker.DeleteObject(new Cena()
                    {
                        Lajsna = new Lajsna()
                        {
                            Id = objekat.Id
                        }, DatumOd = cena.DatumOd
                    });
                }
                _broker.DeleteObject(objekat);
                _broker.Commit();
                return(1);
            }
            catch (SqlException ex)
            {
                Debug.Write(">>>>>>>> " + ex.Message);
                _broker.Rollback();
                throw new Exception(ex.Message);
            }
            catch (Exception ex)
            {
                //_broker.Rollback();
                Debug.WriteLine(">>>> " + ex.Message);
                _broker.Rollback();
                throw new Exception(ex.Message);
            }
            finally
            {
                _broker.CloseConnection();
            }
        }
コード例 #18
0
        public object ExecuteSO(IGenericObject odo)
        {
            object result;

            _broker.OpenConnection();
            _broker.BeginTransaction();

            try
            {
                result = Execute(odo, _broker);
                _broker.Save();
            }
            catch (Exception ex)
            {
                _broker.Rollback();
                throw ex;
            }
            finally
            {
                _broker.CloseConnection();
            }

            return(result);
        }
コード例 #19
0
        //public List<DateTime> GetVremeTermina(Lekar lekar)
        //{
        //    try
        //    {
        //        broker.OpenConnection();
        //        return broker.GetWhere(lekar);

        //    }
        //    finally
        //    {
        //        broker.CloseConnection();
        //    }
        //}

        public void SaveMore(List <Termin> termini)
        {
            broker.OpenConnection();
            broker.BeginTransaction();

            try
            {
                foreach (Termin termin in termini)
                {
                    broker.SaveTermin(termin);
                }

                broker.Commit();
            }
            catch (Exception ex)
            {
                broker.Rollback();
                MessageBox.Show(ex.Message);
            }
            finally
            {
                broker.CloseConnection();
            }
        }
コード例 #20
0
 public void BeginTransaction()
 {
     broker.BeginTransaction();
 }