Пример #1
0
        private LayoutProperty saveNewLayout(string layoutName, bool saveColumns, bool isDatabase, IDictionary <string, FormProperty> formProperties)
        {
            var tempLayout = new LayoutProperty
            {
                Name                    = layoutName,
                PaneLocations           = getPaneLocationXML(),
                HasCustomColumnSettings = saveColumns,
            };

            tempLayout.FormProperties = formProperties;

            if (isDatabase)
            {
                lock (_session)
                {
                    _session.Save(tempLayout);
                    _session.Flush();
                }
            }
            else
            {
                _userLayoutList.Add(tempLayout);
                SaveUserLayoutList();
            }

            return(tempLayout);
        }
Пример #2
0
        public async Task <ResponseApi> Init()
        {
            AdminInfo admin = base.Test ? null : GetAdminInfo();

            using NHibernate.ISession session = HttpContext.RequestServices.GetService <Utility.Nhibernate.Infrastructure.AppSessionFactory>().OpenSession();
            NHibernate.ITransaction transaction = session.BeginTransaction();
            foreach (var item in session.Query <AdminRoleInfo>().Select(it => it.Id))
            {
                //session.Query<MenuInfo>().Where(it => it.Menu.Role.Id != item && it.Id != it.Menu.Menu.Id &&
                //       it.Href != null).InsertInto(it => new UserMenuInfo()
                //       {
                //           Admin = admin,
                //           Menu = new MenuInfo() { Id = it.Id },
                //           Role = new AdminRoleInfo() { Id = item }
                //       });
                foreach (var menu in session.Query <MenuInfo>().Where(it => it.Href != null).Select(it => it.Id))
                {
                    if (session.Query <UserMenuInfo>().Where(it => it.Menu.Id == menu && it.Role.Id == item).ToFutureValue(it => it.Count()).Value == 0)
                    {
                        session.Save(new UserMenuInfo()
                        {
                            Admin = admin,
                            Menu  = new MenuInfo()
                            {
                                Id = menu
                            },
                            Role = new AdminRoleInfo()
                            {
                                Id = item
                            }
                        });
                    }
                }
            }
            foreach (var item in session.Query <UserLevelInfo>().Select(it => it.Id))
            {
                foreach (var menu in session.Query <MenuInfo>().Where(it => it.Href != null).Select(it => it.Id))
                {
                    if (session.Query <UserMenuInfo>().Where(it => it.Menu.Id == menu && it.Level.Id == item).ToFutureValue(it => it.Count()).Value == 0)
                    {
                        session.Save(new UserMenuInfo()
                        {
                            Admin = admin,
                            Menu  = new MenuInfo()
                            {
                                Id = menu
                            },
                            Level = new UserLevelInfo()
                            {
                                Id = item
                            }
                        });
                    }
                }
            }
            transaction.Commit();
            return(await Task.FromResult(ResponseApi.Create(GetLanguage(), Code.OperatorSuccess)));
        }
Пример #3
0
        public void Post([FromBody] Foo foo)
        {
            using (var transaction = _session.BeginTransaction())
            {
                _session.Save(foo);

                transaction.Commit();
            }
        }
Пример #4
0
 private void BatchSaveInTransaction(IList <AppAuditLog> logs)
 {
     logger.LogInformation($"Batch save {logs.Count} audit logs to db ...");
     session.SetBatchSize(logs.Count);
     using (var tx = session.BeginTransaction()) {
         try {
             session.SetBatchSize(logs.Count);
             foreach (var log in logs)
             {
                 session.Save(log);
             }
             session.Flush();
             session.Clear();
             tx.Commit();
         }
         catch (Exception ex) {
             tx?.Rollback();
             logger.LogError(ex, "Can not save audit logs with transactions.");
             foreach (var log in logs)
             {
                 logger.LogError(log.ToJson());
             }
         }
     }
 }
Пример #5
0
        public void RunWorker(BackgroundWorker worker, DoWorkEventArgs args)
        {
            var getProgress = args.Argument as Func <ProgressState>
                              ?? new Func <ProgressState>(() => ProgressState.Empty);

            CurrentProgress = getProgress() ?? ProgressState.Empty;
            ImportStarted(this, EventArgs.Empty);
            var type           = Type.GetType(DataContextObject.SelectedDataType.Target.ClrType);
            var sessionFactory = DataContextObject.ShellContext.SessionFactoryHolder.GetSessionFactory();

            CurrentProgress = new ProgressState(0, DataContextObject.TargetsToImport.Count);
            using (NHibernate.ISession session = sessionFactory.OpenSession())
            {
                var current   = 0;
                var total     = DataContextObject.TargetsToImport.Count;
                int batchSize = Settings.Default.BatchSize;
                using (var tx = session.BeginTransaction())
                {
                    while (current < total && !args.Cancel && !Cancelled)
                    {
                        if (worker.CancellationPending)
                        {
                            args.Cancel = true;
                        }
                        else
                        {
                            var target = DataContextObject.TargetsToImport[current];
                            (target as ContentPartRecord).ContentItemRecord = DataContextObject.CurrentContentItem;
                            try
                            {
                                session.Save(DataContextObject.TargetsToImport[current]);
                            }
                            catch (Exception ex)
                            {
                                GuardError(current, ex);
                            }
                            finally
                            {
                                if (current % batchSize == 0)
                                { //20, same as the ADO batch size
                                    session.Flush();
                                    session.Clear();
                                }
                                current++;
                                var progress = new ProgressState(current, total);
                                worker.ReportProgress((int)Math.Floor(progress.Ratio * 100d), progress);
                                if (current % 1000 == 0)
                                {
                                    Application.Current.DoEvents();
                                }
                            }
                        }
                    }
                    session.Flush();
                    session.Clear();
                    tx.Commit();
                }
                session.Close();
            }
        }
Пример #6
0
        public static Recapito Recapito_Create(
            String Indirizzo,
            String Localita,
            String Provincia
            )
        {
            try
            {
                Recapito aRecapito =
                    new Recapito();

                NHibernate.ISession aNHibernateSession = NHibernateHelper.GetOrCreateCurrentSession();

                aRecapito.Indirizzo = Indirizzo;
                aRecapito.Localita  = Localita;
                aRecapito.Provincia = Provincia;

                aNHibernateSession.Save(aRecapito);

                aNHibernateSession.Flush();

                return(aRecapito);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Пример #7
0
        public static SegnalazionePreliminareDanno SegnalazionePreliminareDanno_Create(
            Recapito Recapito,
            OggettoSegnalazionePreliminareDanno Oggetto
            )
        {
            try
            {
                SegnalazionePreliminareDanno aSegnalazionePreliminareDanno =
                    new SegnalazionePreliminareDanno();

                NHibernate.ISession aNHibernateSession = NHibernateHelper.GetOrCreateCurrentSession();

                aSegnalazionePreliminareDanno.Recapito      = Recapito;
                aSegnalazionePreliminareDanno.Oggetto       = Oggetto;
                aSegnalazionePreliminareDanno.DataCreazione = DateTime.Now;
                aSegnalazionePreliminareDanno.Definitivo    = false;

                aNHibernateSession.Save(aSegnalazionePreliminareDanno);

                aNHibernateSession.Flush();

                return(aSegnalazionePreliminareDanno);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Пример #8
0
        public string SaveFacebookId(string userId, string password)
        {
            Domain.Socioboard.Domain.FacebookLoginId _FacebookLoginId = new FacebookLoginId();
            _FacebookLoginId.UserId    = userId;
            _FacebookLoginId.Password  = password;
            _FacebookLoginId.UpdatedAt = DateTime.UtcNow;
            using (NHibernate.ISession session = SessionFactory.GetNewSession())
            {
                if (session.Query <FacebookLoginId>().Any(t => t.UserId == userId))
                {
                    using (NHibernate.ITransaction transaction = session.BeginTransaction())
                    {
                        int i = session.CreateQuery("Update FacebookLoginId set Password =: Password, UpdatedAt = : UpdatedAt where UserId =: UserId")
                                .SetParameter("UserId", _FacebookLoginId.UserId)
                                .SetParameter("Password", _FacebookLoginId.Password)
                                .SetParameter("UpdatedAt", DateTime.UtcNow)
                                .ExecuteUpdate();
                        transaction.Commit();
                    }
                }
                else
                {
                    using (NHibernate.ITransaction transaction = session.BeginTransaction())
                    {
                        session.Save(_FacebookLoginId);
                        transaction.Commit();
                    }
                }
            }

            return("success");
        }
        //public facebookpageinfo getfbpage()
        //{
        //    facebookpageinfo fbpginfo = null;
        //    if (this.facebookpageinfoID == null)
        //    {
        //        return fbpginfo;
        //    }
        //    else
        //    {
        //        using (NHibernate.ISession session = SessionFactory.GetNewSession())
        //        {
        //            //Begin session trasaction and opens up.
        //            using (NHibernate.ITransaction transaction = session.BeginTransaction())
        //            {
        //                try
        //                {
        //                    List<facebookpageinfo> alst = session.CreateQuery("from facebookpageinfo where Id = :fbpgid")
        //                .SetParameter("fbpgid", facebookpageinfoID)
        //                .List<facebookpageinfo>()
        //                .ToList<facebookpageinfo>();
        //                    fbpginfo = alst[0];
        //                }
        //                catch (Exception ex)
        //                {
        //                    Console.WriteLine(ex.StackTrace);
        //                    //return 0;
        //                }

        //            }//End Transaction
        //        }//End Session


        //    }
        //    return fbpginfo;
        //}
        //public googleplusinfo getgpulsinfo()
        //{
        //    googleplusinfo gpluspginfo = null;
        //    if (this.googleplusinfoID== null)
        //    {
        //        return gpluspginfo;
        //    }
        //    else
        //    {

        //        using (NHibernate.ISession session = SessionFactory.GetNewSession())
        //        {
        //            //Begin session trasaction and opens up.
        //            using (NHibernate.ITransaction transaction = session.BeginTransaction())
        //            {
        //                try
        //                {
        //                    List<googleplusinfo> alst = session.CreateQuery("from googleplusinfo where Id = :gpluspgid")
        //                .SetParameter("gpluspgid", this.googleplusinfoID)
        //                .List<googleplusinfo>()
        //                .ToList<googleplusinfo>();
        //                    gpluspginfo = alst[0];
        //                }
        //                catch (Exception ex)
        //                {
        //                    Console.WriteLine(ex.StackTrace);
        //                    //return 0;
        //                }

        //            }//End Transaction
        //        }//End Session


        //    }
        //    return gpluspginfo;
        //}
        //public instagrampage getinstagraminfo()
        //{
        //    instagrampage instpg = null;
        //    if (this.instagrampageID == null)
        //    {
        //        return instpg;
        //    }
        //    else
        //    {

        //        using (NHibernate.ISession session = SessionFactory.GetNewSession())
        //        {
        //            //Begin session trasaction and opens up.
        //            using (NHibernate.ITransaction transaction = session.BeginTransaction())
        //            {
        //                try
        //                {
        //                    List<instagrampage> alst = session.CreateQuery("from instagrampage where Id = :instpgid")
        //                .SetParameter("instpg", this.instagrampageID)
        //                .List<instagrampage>()
        //                .ToList<instagrampage>();
        //                    instpg = alst[0];
        //                }
        //                catch (Exception ex)
        //                {
        //                    Console.WriteLine(ex.StackTrace);
        //                    //return 0;
        //                }

        //            }//End Transaction
        //        }//End Session
        //    }
        //    return instpg;

        //}
        //public linkedinpage getlinkedinpageinfo()
        //{
        //    linkedinpage linkpg = null;
        //    if (this.linkedinpageID == null)
        //    {
        //        return linkpg;
        //    }
        //    else
        //    {

        //        using (NHibernate.ISession session = SessionFactory.GetNewSession())
        //        {
        //            //Begin session trasaction and opens up.
        //            using (NHibernate.ITransaction transaction = session.BeginTransaction())
        //            {
        //                try
        //                {
        //                    List<linkedinpage> alst = session.CreateQuery("from linkedinpage where Id = :linkpgid")
        //                .SetParameter("linkpgid", this.linkedinpageID)
        //                .List<linkedinpage>()
        //                .ToList<linkedinpage>();
        //                    linkpg = alst[0];
        //                }
        //                catch (Exception ex)
        //                {
        //                    Console.WriteLine(ex.StackTrace);
        //                    //return 0;
        //                }

        //            }//End Transaction
        //        }//End Session
        //    }
        //    return linkpg;
        //}
        //public twitterpage gettwitterpageinfo()
        //{
        //    twitterpage twitterpg = null;
        //    if (this.twitterpageID == null)
        //    {
        //        return twitterpg;
        //    }
        //    else
        //    {

        //        using (NHibernate.ISession session = SessionFactory.GetNewSession())
        //        {
        //            //Begin session trasaction and opens up.
        //            using (NHibernate.ITransaction transaction = session.BeginTransaction())
        //            {
        //                try
        //                {
        //                    List<twitterpage> alst = session.CreateQuery("from twitterpage where Id = :twitterpgid")
        //                .SetParameter("twitterpgid", this.twitterpageID)
        //                .List<twitterpage>()
        //                .ToList<twitterpage>();
        //                    twitterpg = alst[0];
        //                }
        //                catch (Exception ex)
        //                {
        //                    Console.WriteLine(ex.StackTrace);
        //                    //return 0;
        //                }

        //            }//End Transaction
        //        }//End Session
        //    }
        //    return twitterpg;
        //}
        //public youtubepage getyoutubepageinfo()
        //{
        //    youtubepage ytpg = null;
        //    if (this.twitterpageID == null)
        //    {
        //        return ytpg;
        //    }
        //    else
        //    {

        //        using (NHibernate.ISession session = SessionFactory.GetNewSession())
        //        {
        //            //Begin session trasaction and opens up.
        //            using (NHibernate.ITransaction transaction = session.BeginTransaction())
        //            {
        //                try
        //                {
        //                    List<youtubepage> alst = session.CreateQuery("from youtubepage where Id = :ytpgid")
        //                .SetParameter("ytpg", this.twitterpageID)
        //                .List<youtubepage>()
        //                .ToList<youtubepage>();
        //                    ytpg = alst[0];
        //                }
        //                catch (Exception ex)
        //                {
        //                    Console.WriteLine(ex.StackTrace);
        //                    //return 0;
        //                }

        //            }//End Transaction
        //        }//End Session
        //    }
        //    return ytpg;
        //}

        //public facebookpageinfo setfbpage()
        //{
        //    facebookpageinfo fbpginfo = null;
        //    return fbpginfo;
        //}
        //public googleplusinfo setgpulsinfo()
        //{
        //    googleplusinfo gplusinfo = null;
        //    return gplusinfo;
        //}
        //public instagrampage setinstagraminfo()
        //{
        //    instagrampage instpg = null;
        //    return instpg;
        //}
        //public linkedinpage setlinkedinpageinfo()
        //{
        //    linkedinpage linkpg = null;
        //    return linkpg;
        //}
        //public twitterpage settwitterpageinfo()
        //{
        //    twitterpage twitterpg = null;
        //    return twitterpg;
        //}
        //public youtubepage setyoutubepageinfo()
        //{
        //    youtubepage ytpg = null;
        //    return ytpg;
        //}
        #endregion
        public bool AddcompanyProfileName(Domain.Myfashion.Domain.CompanyProfiles companyProfiles)
        {
            bool IsSuccess = false;

            //Creates a database connection and opens up a session
            using (NHibernate.ISession session = SessionFactory.GetNewSession())
            {
                //After Session creation, start Transaction.
                using (NHibernate.ITransaction transaction = session.BeginTransaction())
                {
                    //Proceed action, to Save data.
                    try
                    {
                        session.Save(companyProfiles);
                        transaction.Commit();
                        IsSuccess = true;
                        return(IsSuccess);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                        return(IsSuccess);
                    }
                } //End Transaction
            }     //End Session
        }
        public void InsertTwitterRecentDetails(Domain.Socioboard.Domain.TwitterRecentDetails data)
        {
            bool exists = false;

            using (NHibernate.ISession session = SessionFactory.GetNewSession())
            {
                exists = session.Query <Domain.Socioboard.Domain.TwitterRecentDetails>()
                         .Any(x => x.TwitterId == data.TwitterId);
            }

            using (NHibernate.ISession session = SessionFactory.GetNewSession())
            {
                using (NHibernate.ITransaction transaction = session.BeginTransaction())
                {
                    if (exists)
                    {
                        session.CreateQuery("Update twitterrecentdetails set AccountCreationDate = : AccountCreationDate , LastActivityDate = : LastActivityDate , LastFeed = : LastFeed , FeedId = : FeedId , FeedRetweetCount = : FeedRetweetCount , FeedFavoriteCount = : FeedFavoriteCount where TwitterId = : TwitterId")
                        .SetParameter("AccountCreationDate", data.AccountCreationDate)
                        .SetParameter("LastActivityDate", data.LastActivityDate)
                        .SetParameter("LastFeed", data.LastFeed)
                        .SetParameter("FeedId", data.FeedId)
                        .SetParameter("FeedRetweetCount", data.FeedRetweetCount)
                        .SetParameter("FeedFavoriteCount", data.FeedFavoriteCount)
                        .ExecuteUpdate();
                        transaction.Commit();
                    }

                    else
                    {
                        session.Save(data);
                        transaction.Commit();
                    }
                }
            }
        }
Пример #11
0
 /// <AddLog>
 /// Add Log
 /// </AddLog>
 /// <param name="log">Set Values in a Log Class Property and Pass the Object of Log Class (SocioBoard.Domain.Log).</param>
 public void AddLog(Log log)
 {
     //Lock the functionality
     //When multiple users to access add data at same time.
     lock (LockAddLog)
     {
         try
         {
             //Creates a database connection and opens up a session
             using (NHibernate.ISession session = SessionFactory.GetNewSession())
             {
                 //After Session creation, start Transaction.
                 using (NHibernate.ITransaction transaction = session.BeginTransaction())
                 {
                     //Proceed action, to save new details
                     session.Save(log);
                     transaction.Commit();
                 } //End Transaction
             }     //End Session
         }
         catch (Exception ex)
         {
         }
     }//End Lock
 }
        public string Add(MandrillAccount MandrillAccount)
        {
            string res = null;

            try
            {
                //Creates a database connection and opens up a session
                using (NHibernate.ISession session = SessionFactory.GetNewSession())
                {
                    //After Session creation, start Transaction.
                    using (NHibernate.ITransaction transaction = session.BeginTransaction())
                    {
                        //Proceed action, to add new row.
                        session.Save(MandrillAccount);
                        transaction.Commit();
                        res = "Added";
                    } //End transaction
                }     //End session
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error : " + ex.StackTrace);
            }
            return(res);
        }
Пример #13
0
        public bool InsertCompaign(CmpFanPageLiker acc)
        {
            bool Flage = false;

            try
            {
                lock (lockerInsert)
                {
                    using (NHibernate.ISession session = SessionFactory.GetNewSession())
                    {
                        using (NHibernate.ITransaction transaction = session.BeginTransaction())
                        {
                            session.Save(acc);

                            transaction.Commit();
                            Flage = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
            }
            return(Flage);
        }
Пример #14
0
        public int Add <T>(T item) where T : class, new()
        {
            int result = 0;

            try
            {
                using (NHibernate.ISession session = SessionFactory.GetNewSession(_env))
                {
                    using (NHibernate.ITransaction transaction = session.BeginTransaction())
                    {
                        session.Save(item);
                        transaction.Commit();
                        result = 1;
                    }
                }
            }
            catch (Exception ex)
            {
                result = 0;
                _logger.LogCritical(ex.Message);
                _logger.LogError(ex.StackTrace);
                if (ex.InnerException != null)
                {
                    _logger.LogError(ex.InnerException.Message);
                    _logger.LogError(ex.InnerException.StackTrace);
                }
            }


            return(result);
        }
Пример #15
0
        public int Add <T>(IEnumerable <T> items) where T : class, new()
        {
            int result = 0;

            foreach (var item in items)
            {
                try
                {
                    using (NHibernate.ISession session = SessionFactory.GetNewSession(_env))
                    {
                        using (NHibernate.ITransaction transaction = session.BeginTransaction())
                        {
                            session.Save(item);
                            transaction.Commit();
                            result = 1;
                        }
                    }
                }
                catch (Exception ex)
                {
                    result = 0;
                    _logger.LogCritical(ex.Message);
                    _logger.LogError(ex.StackTrace);
                }
            }

            return(result);
        }
Пример #16
0
        public static Riferimento Riferimento_Create(
            String Nominativo,
            String Telefono,
            String EMail
            )
        {
            try
            {
                Riferimento aRiferimento =
                    new Riferimento();

                NHibernate.ISession aNHibernateSession = NHibernateHelper.GetOrCreateCurrentSession();

                aRiferimento.Nominativo = Nominativo;
                aRiferimento.Telefono   = Telefono;
                aRiferimento.EMail      = EMail;

                aNHibernateSession.Save(aRiferimento);

                aNHibernateSession.Flush();

                return(aRiferimento);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Пример #17
0
 public void AddGoogleAnalyticsReport(Domain.Socioboard.Domain.GoogleAnalyticsReport _GoogleAnalyticsReport)
 {
     //Creates a database connection and opens up a session
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         bool exist = session.Query <Domain.Socioboard.Domain.GoogleAnalyticsReport>().Any(t => t.GaProfileId == _GoogleAnalyticsReport.GaProfileId);
         //After Session creation, start Transaction.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             if (!exist)
             {
                 session.Save(_GoogleAnalyticsReport);
                 transaction.Commit();
             }
             else
             {
                 try
                 {
                     session.CreateQuery("Update GoogleAnalyticsReport set Visits=:Visits, Views=:Views,TwitterMention=:TwitterMention, Article_Blogs =: Article_Blogs where GaProfileId =: GaProfileId")
                     .SetParameter("Visits", _GoogleAnalyticsReport.Visits)
                     .SetParameter("Views", _GoogleAnalyticsReport.Views)
                     .SetParameter("GaProfileId", _GoogleAnalyticsReport.GaProfileId)
                     .SetParameter("TwitterMention", _GoogleAnalyticsReport.TwitterMention)
                     .SetParameter("Article_Blogs", _GoogleAnalyticsReport.Article_Blogs)
                     .ExecuteUpdate();
                     transaction.Commit();
                 }
                 catch (Exception ex)
                 {
                 }
             }
         }
     }
 }
Пример #18
0
        /// <Add>
        /// Add a new invitation in DataBase.
        /// </summary>
        /// <param name="user">Set Values in a invitation Class Property and Pass the Object of invitation Class (SocioBoard.Domain.Admin).</param>
        public int Add(Invitation invitation)
        {
            int res = 0;

            try
            {
                //Creates a database connection and opens up a session
                using (NHibernate.ISession session = SessionFactory.GetNewSession())
                {
                    //After Session creation, start Transaction.
                    using (NHibernate.ITransaction transaction = session.BeginTransaction())
                    {
                        //Proceed action to save data.
                        session.Save(invitation);
                        transaction.Commit();

                        res = 1;
                    } //End Using trasaction
                }     //End Using session
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }

            return(res);
        }
Пример #19
0
        public bool AddShareathonPost(SharethonGroupPost shareathon)
        {
            bool IsSuccess = false;

            //Creates a database connection and opens up a session
            using (NHibernate.ISession session = SessionFactory.GetNewSession())
            {
                //After Session creation, start Transaction.
                using (NHibernate.ITransaction transaction = session.BeginTransaction())
                {
                    //Proceed action, to Save data.
                    try
                    {
                        session.Save(shareathon);
                        transaction.Commit();
                        IsSuccess = true;
                        return(IsSuccess);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                        return(IsSuccess);
                    }
                } //End Transaction
            }     //End Session
        }
Пример #20
0
        /// <AddBusinessSetting>
        /// Check If User Id is exist or Not. If User Id is Exist then It will Update that same Users all Business Setting. Otherwise It add a new Business Setting Data.
        /// </summary>
        /// <param name="businessSetting">Set Values in a BusinessSetting Class Property and Pass the same Object of BusinessSetting Class.(Domain.BusinessSetting)</param>
        public void AddBusinessSetting(Domain.Socioboard.Domain.BusinessSetting businessSetting)
        {
            //Creates a database connection and opens up a session
            using (NHibernate.ISession session = SessionFactory.GetNewSession())
            {
                //After Session creation, start Transaction.
                using (NHibernate.ITransaction transaction = session.BeginTransaction())
                {
                    //Proceed action. to check if user is Exist or not.
                    List <Domain.Socioboard.Domain.BusinessSetting> lstBusinessSetting = CheckUserId(businessSetting.UserId, businessSetting.GroupId, businessSetting.BusinessName);

                    //if user is Exist the it update all BusinessSetting of the Same user,
                    //Otherwise it add New BusinessSetting.
                    if (lstBusinessSetting.Count > 0)
                    {
                        UpdateBusinessSetting(businessSetting);
                    }
                    else
                    {
                        session.Save(businessSetting);
                        transaction.Commit();
                    }
                } //End Transaction
            }     //End session
        }
Пример #21
0
        /// <Insert>
        /// Add a Blog_Comment in a Database
        /// </summary>
        /// <param name="blog_Comments">The object of the Blog_Comments class(Domain.Blog_Comments)</param>
        /// <returns>Return Integer</returns>
        public int Insert(Blog_Comments blog_Comments)
        {
            int insert = 0;

            try
            {
                //Creates a database connection and opens up a session
                using (NHibernate.ISession session = SessionFactory.GetNewSession())
                {
                    //After Session creation, start Transaction.
                    using (NHibernate.ITransaction transaction = session.BeginTransaction())
                    {
                        //Proceed action, to save data
                        session.Save(blog_Comments);
                        transaction.Commit();
                        insert = 1;
                    } //End Using trasaction
                }     //End using session
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error : " + ex.StackTrace);
            }
            return(insert);
        }
Пример #22
0
        public int AddUserRefRelation(UserRefRelation userRefRelation)
        {
            int res = 0;

            try
            {
                using (NHibernate.ISession session = SessionFactory.GetNewSession())
                {
                    using (NHibernate.ITransaction transaction = session.BeginTransaction())
                    {
                        session.Save(userRefRelation);
                        transaction.Commit();

                        res = 1;
                    }
                }
                logger.Error("Coming out of AddUserRefRelation");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error : " + ex.StackTrace);
                logger.Error("UserRefRelationRepository>>AddUserRefRelation" + ex.Message);
            }

            return(res);
        }
        public void AddStdout(string data)
        {
            using (NHibernate.ISession session = SessionFactory.OpenSession())
            {
                using (NHibernate.ITransaction trans = session.BeginTransaction())
                {
                    var process = session
                                  .CreateCriteria <SinterProcess>()
                                  .Add(Restrictions.Eq("Id", this.id))
                                  .UniqueResult <SinterProcess>();

                    if (process.stdout == null)
                    {
                        process.stdout = data;
                    }
                    else
                    {
                        process.stdout += data;
                    }

                    session.Save(process);
                    trans.Commit();
                }
            }
        }
Пример #24
0
        public void Post([FromBody] Contact contactUs)
        {
            using (var transaction = _session.BeginTransaction())
            {
                _session.Save(contactUs);

                transaction.Commit();
            }
        }
Пример #25
0
 public static void Add(Employee Employee)
 {
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             session.Save(Employee);
             transaction.Commit();
         }
     }
 }
Пример #26
0
 public static void addUsers(Users user)
 {
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             session.Save(user);
             transaction.Commit();
         }
     }
 }
 public void addFacebookStats(FacebookStats fbstats)
 {
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             session.Save(fbstats);
             transaction.Commit();
         }
     }
 }
Пример #28
0
 public void AddLikes(Domain.Socioboard.Domain.GoogleplusLike _GoogleplusLike)
 {
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             session.Save(_GoogleplusLike);
             transaction.Commit();
         }
     }
 }
Пример #29
0
 public void addTwitterStats(Domain.Socioboard.Domain.TwitterStats TwtStats)
 {
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             session.Save(TwtStats);
             transaction.Commit();
         }
     }
 }
Пример #30
0
 public static void Add(websitereviewdata user)
 {
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             session.Save(user);
             transaction.Commit();
         }
     }
 }
        //TODO:atrosin Revise where and how is used the method
        public static void LoadHibernateData(ISession session, HandlingEventFactory handlingEventFactory,
                                             IHandlingEventRepository handlingEventRepository)
        {
            Console.WriteLine("*** Loading Hibernate data ***");           

            foreach (Location location  in SampleLocations.GetAll())
            {
                session.Save(location);
            }

            foreach (Voyage voyage in SampleVoyages.GetAll())
            {
                session.Save(voyage);
            }

            /*session.Save(SampleVoyages.HONGKONG_TO_NEW_YORK);
            session.Save(SampleVoyages.NEW_YORK_TO_DALLAS);
            session.Save(SampleVoyages.DALLAS_TO_HELSINKI);
            session.Save(SampleVoyages.HELSINKI_TO_HONGKONG);
            session.Save(SampleVoyages.DALLAS_TO_HELSINKI_ALT);*/
             
            var routeSpecification = new RouteSpecification(SampleLocations.HONGKONG,
                                                            SampleLocations.HELSINKI,
                                                            DateUtil.ToDate("2009-03-15"));
            var trackingId = new TrackingId("ABC123");
            var abc123 = new Cargo(trackingId, routeSpecification);

            var itinerary = new Itinerary(
                new List<Leg>
                    {
                        new Leg(SampleVoyages.HONGKONG_TO_NEW_YORK, SampleLocations.HONGKONG, SampleLocations.NEWYORK,
                                DateUtil.ToDate("2009-03-02"), DateUtil.ToDate("2009-03-05")),
                        new Leg(SampleVoyages.NEW_YORK_TO_DALLAS, SampleLocations.NEWYORK, SampleLocations.DALLAS,
                                DateUtil.ToDate("2009-03-06"), DateUtil.ToDate("2009-03-08")),
                        new Leg(SampleVoyages.DALLAS_TO_HELSINKI, SampleLocations.DALLAS, SampleLocations.HELSINKI,
                                DateUtil.ToDate("2009-03-09"), DateUtil.ToDate("2009-03-12"))
                    });
            abc123.AssignToRoute(itinerary);

            session.Save(abc123);


            HandlingEvent event1 = handlingEventFactory.CreateHandlingEvent(
                new DateTime(), DateUtil.ToDate("2009-03-01"), trackingId, null, SampleLocations.HONGKONG.UnLocode,
                HandlingType.RECEIVE
                );
            session.Save(event1);

            HandlingEvent event2 = handlingEventFactory.CreateHandlingEvent(
                new DateTime(), DateUtil.ToDate("2009-03-02"), trackingId,
                SampleVoyages.HONGKONG_TO_NEW_YORK.VoyageNumber, SampleLocations.HONGKONG.UnLocode,
                HandlingType.LOAD
                );
            session.Save(event2);

            HandlingEvent event3 = handlingEventFactory.CreateHandlingEvent(
                new DateTime(), DateUtil.ToDate("2009-03-05"), trackingId,
                SampleVoyages.HONGKONG_TO_NEW_YORK.VoyageNumber, SampleLocations.NEWYORK.UnLocode,
                HandlingType.UNLOAD
                );
            session.Save(event3);


            HandlingHistory handlingHistory = handlingEventRepository.LookupHandlingHistoryOfCargo(trackingId);
            abc123.DeriveDeliveryProgress(handlingHistory);

            session.Update(abc123);

            // Cargo JKL567

            var routeSpecification1 = new RouteSpecification(SampleLocations.HANGZOU,
                                                             SampleLocations.STOCKHOLM,
                                                             DateUtil.ToDate("2009-03-18"));
            var trackingId1 = new TrackingId("JKL567");
            var jkl567 = new Cargo(trackingId1, routeSpecification1);

            var itinerary1 = new Itinerary(new List<Leg>
                                               {
                                                   new Leg(SampleVoyages.HONGKONG_TO_NEW_YORK,
                                                           SampleLocations.HANGZOU, SampleLocations.NEWYORK,
                                                           DateUtil.ToDate("2009-03-03"),
                                                           DateUtil.ToDate("2009-03-05")),
                                                   new Leg(SampleVoyages.NEW_YORK_TO_DALLAS,
                                                           SampleLocations.NEWYORK, SampleLocations.DALLAS,
                                                           DateUtil.ToDate("2009-03-06"),
                                                           DateUtil.ToDate("2009-03-08")),
                                                   new Leg(SampleVoyages.DALLAS_TO_HELSINKI,
                                                           SampleLocations.DALLAS, SampleLocations.STOCKHOLM,
                                                           DateUtil.ToDate("2009-03-09"),
                                                           DateUtil.ToDate("2009-03-11"))
                                               });
            jkl567.AssignToRoute(itinerary1);

            session.Save(jkl567);


            HandlingEvent event21 = handlingEventFactory.CreateHandlingEvent(
                new DateTime(), DateUtil.ToDate("2009-03-01"), trackingId1, null, SampleLocations.HANGZOU.UnLocode,
                HandlingType.RECEIVE);

            session.Save(event21);

            HandlingEvent event22 = handlingEventFactory.CreateHandlingEvent(
                new DateTime(), DateUtil.ToDate("2009-03-03"), trackingId1,
                SampleVoyages.HONGKONG_TO_NEW_YORK.VoyageNumber, SampleLocations.HANGZOU.UnLocode,
                HandlingType.LOAD
                );
            session.Save(event22);

            HandlingEvent event23 = handlingEventFactory.CreateHandlingEvent(
                new DateTime(), DateUtil.ToDate("2009-03-05"), trackingId1,
                SampleVoyages.HONGKONG_TO_NEW_YORK.VoyageNumber, SampleLocations.NEWYORK.UnLocode,
                HandlingType.UNLOAD
                );
            session.Save(event23);

            HandlingEvent event24 = handlingEventFactory.CreateHandlingEvent(
                new DateTime(), DateUtil.ToDate("2009-03-06"), trackingId1,
                SampleVoyages.HONGKONG_TO_NEW_YORK.VoyageNumber, SampleLocations.NEWYORK.UnLocode,
                HandlingType.LOAD
                );
            session.Save(event24);


            HandlingHistory handlingHistory1 = handlingEventRepository.LookupHandlingHistoryOfCargo(trackingId1);
            jkl567.DeriveDeliveryProgress(handlingHistory1);

            session.Update(jkl567);
        }