/// <getLimitProfilesOfUser> /// Get Limit Profiles Of User /// </summary> /// <param name="userid">User id.(Guid)</param> /// <param name="limit">Limit of Required Data. (int)</param> /// <param name="maxResult">Get Maximum results.(int)</param> /// <returns>Return Array list with value.(ArrayList)</returns> public ArrayList getLimitProfilesOfUser(Guid userid, int limit, int maxResult) { //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 get user records. NHibernate.IQuery query = session.CreateQuery("from SocialProfile where UserId = :userid"); query.SetFirstResult(limit); query.SetMaxResults(maxResult); query.SetParameter("userid", userid); ArrayList alst = new ArrayList(); foreach (var item in query.Enumerable()) { alst.Add(item); } return(alst); } //End Transaction } //End Session }
public int UpdateIsEmailKeyUsed(Guid Id, string ChangeEmailKey) { int i = 0; using (NHibernate.ISession session = SessionFactory.GetNewSession()) { using (NHibernate.ITransaction transaction = session.BeginTransaction()) { try { int IsEmailKey = 1; i = session.CreateQuery("Update User set IsEmailKeyUsed=:IsEmailKey where Id = :Id and ChangeEmailKey =:ChangeEmailKey") .SetParameter("IsEmailKey", IsEmailKey) .SetParameter("Id", Id) .SetParameter("ChangeEmailKey", ChangeEmailKey) .ExecuteUpdate(); transaction.Commit(); } catch { } } } return(i); }
/// <summary> /// Delete TaskComment By TaskId. /// </summary> /// <param name="userid"></param> /// <returns></returns> public int DeleteTaskCommentByTaskId(Guid TaskId) { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { using (NHibernate.ITransaction transaction = session.BeginTransaction()) { try { //Proceed action, to Delete specific data by user id. NHibernate.IQuery query = session.CreateQuery("delete from TaskComment where TaskId = :taskid") .SetParameter("taskid", TaskId); int isUpdated = query.ExecuteUpdate(); transaction.Commit(); return(isUpdated); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(0); } } //End Transaction } //End Session }
public void UpdateStatus2(int id) { //Creates a database connection and opens up a session using (NHibernate.ISession session = SocioBoardInvitationMailSenderSessionFactory.GetNewSession()) { //Begin session trasaction and opens up. using (NHibernate.ITransaction transaction = session.BeginTransaction()) { try { session.CreateQuery("Update Mantaemail set Status =2 where Id =:id") .SetParameter("id", id) .ExecuteUpdate(); transaction.Commit(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); // return 0; } } //End Trasaction } //End session }
/// <GetAllCoupon> /// Get the all Coupons /// </summary> /// <returns>List of coupons.(List<Domain.Coupon>)</returns> public List <MandrillAccount> GetAllMandrillAccount() { List <MandrillAccount> res = new List <MandrillAccount>(); try { //Creates a database connection and opens up a session using (NHibernate.ISession session = SessionFactory.GetNewSession()) { //Begin trasaction and opens up a trasaction. using (NHibernate.ITransaction transaction = session.BeginTransaction()) { //Proceed action to get all coupons. res = session.CreateQuery("from MandrillAccount").List <MandrillAccount>().ToList <MandrillAccount>(); } //End transaction } //End session } catch (Exception ex) { Console.WriteLine("Error : " + ex.StackTrace); } return(res); }
public int updateTwitterStats(Domain.Socioboard.Domain.TwitterStats TwtStats) { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { using (NHibernate.ITransaction transaction = session.BeginTransaction()) { try { int i = session.CreateQuery("Update from TwitterStats where TwitterId = :twtuserid and UserId = :userid") .SetParameter("twtuserid", TwtStats.TwitterId) .SetParameter("userid", TwtStats.UserId) .ExecuteUpdate(); transaction.Commit(); return(i); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(0); } } } }
public int UpdateEwalletAmount(Guid userid, string amount) { int i = 0; using (NHibernate.ISession session = SessionFactory.GetNewSession()) { using (NHibernate.ITransaction transaction = session.BeginTransaction()) { try { i = session.CreateQuery("Update User set Ewallet=:ewallet where Id = :Id") .SetParameter("ewallet", amount) .SetParameter("Id", userid) .ExecuteUpdate(); transaction.Commit(); } catch (Exception ex) { i = 0; } } } return(i); }
public int changePaymentStatus(Guid UserId, string status) { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { using (NHibernate.ITransaction transaction = session.BeginTransaction()) { try { int i = session.CreateQuery("Update User set PaymentStatus =:status, Ewallet=:0 where Id=:userid") .SetParameter("status", status) .SetParameter("userid", UserId) .ExecuteUpdate(); transaction.Commit(); return(i); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(0); } } } }
/// <summary> /// 查询数据条数 /// </summary> /// <param name="searchExpression"></param> /// <param name="session"></param> /// <returns></returns> private int GetCount(ISearchExpression searchExpression, NHibernate.ISession session) { Dictionary <string, object> paramNames = new Dictionary <string, object>(); string q = CreateQueryCountString(searchExpression, session.SessionFactory, paramNames); NHibernate.IQuery query = session.CreateQuery(q); foreach (KeyValuePair <string, object> kvp in paramNames) { IList arr = kvp.Value as IList; if (arr == null) { query.SetParameter(kvp.Key, kvp.Value); } else { query.SetParameterList(kvp.Key, arr); } } IList list = query.List(); return(Feng.Utils.ConvertHelper.ToInt(list[0]).Value); }
public Domain.Socioboard.Domain.Groups getGroupById(Guid GroupId) { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { //After Session creation, start Transaction. using (NHibernate.ITransaction transaction = session.BeginTransaction()) { try { NHibernate.IQuery query = session.CreateQuery("from Groups where Id=:GroupId"); query.SetParameter("GroupId", GroupId); Domain.Socioboard.Domain.Groups grou = query.UniqueResult <Domain.Socioboard.Domain.Groups>(); return(grou); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(null); } } //End Transaction } //End Session }
public void updateLinkedinPostCommentofPage(Domain.Socioboard.Domain.LinkedinCompanyPagePosts lipost) { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { using (NHibernate.ITransaction transaction = session.BeginTransaction()) { try { session.CreateQuery("Update LinkedinCompanyPagePosts set Comments =:Comments where PostId = :PostId and UserId = :UserId") .SetParameter("PostId", lipost.PostId) .SetParameter("UserId", lipost.UserId) .SetParameter("Comments", lipost.Comments) .ExecuteUpdate(); transaction.Commit(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); // return 0; } } } }
/// <getAllAds> /// get all existing Ads. /// </summary> /// <returns>return all advertisement from Ads Table of Database</returns> public List <Ads> getAllAds() { //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 to get all data. List <Ads> alstFBAccounts = session.CreateQuery("from Ads").List <Ads>().ToList <Ads>(); return(alstFBAccounts); #region oldmethod //List<Ads> alstFBAccounts = new List<Ads>(); //foreach (Ads item in query.Enumerable()) //{ // alstFBAccounts.Add(item); //} #endregion } //End using transaction. } //End using session. }
public int DeleteDraftByGroupId(Guid groupId) { //Creates a database connection and opens up a session using (NHibernate.ISession session = SessionFactory.GetNewSession()) { //Begin session trasaction and opens up. using (NHibernate.ITransaction transaction = session.BeginTransaction()) { try { NHibernate.IQuery query = session.CreateQuery("delete from Drafts where GroupId = :GroupId") .SetParameter("GroupId", groupId); int isUpdated = query.ExecuteUpdate(); transaction.Commit(); return(isUpdated); } catch (Exception ex) { return(0); } } } }
public Domain.Socioboard.Domain.FacebookReport_90 GetFacebookReport_90(string FbProfileId) { Domain.Socioboard.Domain.FacebookReport_90 fbreport = new Domain.Socioboard.Domain.FacebookReport_90(); //Creates a database connection and opens up a session using (NHibernate.ISession session = SessionFactory.GetNewSession()) { try { NHibernate.IQuery result = session.CreateQuery("from FacebookReport_90 f where FacebookId = : FacebookId").SetParameter("FacebookId", FbProfileId); fbreport = (Domain.Socioboard.Domain.FacebookReport_90)result.UniqueResult(); if (fbreport == null) { fbreport = new Domain.Socioboard.Domain.FacebookReport_90(); } } catch (Exception ex) { fbreport = new Domain.Socioboard.Domain.FacebookReport_90(); } } return(fbreport); }
public TumblrFeed getFeedOfProfilebyIdProfileId(string profileid, Guid id) { TumblrFeed result = new TumblrFeed(); //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 get all Facebook Account of User by UserId(Guid) and FbUserId(string). List <TumblrFeed> objlstfb = session.CreateQuery("from TumblrFeed where ProfileId = :profid and Id=:id ") .SetParameter("profid", profileid) .SetParameter("id", id) .List <TumblrFeed>().ToList <TumblrFeed>(); if (objlstfb.Count > 0) { result = objlstfb[0]; } return(result); } //End Transaction } //End session }
public int ResetPassword(Guid id, string password) { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { using (NHibernate.ITransaction transaction = session.BeginTransaction()) { try { int i = session.CreateQuery("Update User set Password =:pass where Id = :userid") .SetParameter("userid", id) .SetParameter("pass", password) .ExecuteUpdate(); transaction.Commit(); return(i); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(0); } } } }
/// <getTeamById> /// Get Team By Id /// </summary> /// <param name="Id">Team id.(Guid)</param> /// <returns>Return the object of Team class with value.(Domain.Team)</returns> public Domain.Socioboard.Domain.Team getTeamById(Guid Id) { //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()) { try { NHibernate.IQuery query = session.CreateQuery("from Team where Id =:memberId"); query.SetParameter("memberId", Id); Domain.Socioboard.Domain.Team alstFBAccounts = query.UniqueResult <Domain.Socioboard.Domain.Team>(); return(alstFBAccounts); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(null); } } //End Transaction } //End Session }
private void button1_Click(object sender, EventArgs e) { User user = null; NHibernate.ISession session = SessionFactory.GetNewSession(); string login = this.textBox1.Text.ToString(); string pass = UserFactory.EncodePassword(textBox2.Text.ToString()); user = session.CreateQuery("from User u WHERE login=:login AND password=:password").SetParameter("login", login).SetParameter("password", pass).List <User>().FirstOrDefault(); if (user != null) { AuthAdapter adapter = AuthAdapter.GetInstance(); adapter.WriteIdentity(user); new UserEditorForm().Visible = true; this.Visible = false; label3.Text = ""; } else { label3.Text = "Nie poprawny login lub hasło"; } }
/// <updateTeamStatus> /// Update Team Status /// </summary> /// <param name="ID">Id of team.(Guid)</param> public void updateTeamStatus(Guid ID) { //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()) { try { //Update status session.CreateQuery("Update Team set InviteStatus = 2 where Id = :userid") .SetParameter("userid", ID) .ExecuteUpdate(); transaction.Commit(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } //End Transaction } //End Session }
/// <getFacebookAccountsOfUser> /// Get all Facebook Account of User by UserId(Guid) /// </summary> /// <param name="UserId">UserId of User(Guid)</param> /// <returns>Retutn all FacebookAccount in form of ArrayList</returns> public ArrayList getFacebookAccountsOfUser(Guid UserId) { //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()) { // NHibernate.IQuery query = session.CreateQuery("from FacebookAccount where UserId = :userid and Type='account'"); //Proceed action, to Get all FacebookAccount by UserId(Guid). NHibernate.IQuery query = session.CreateQuery("from FacebookAccount where UserId = :userid"); query.SetParameter("userid", UserId); ArrayList alstFBAccounts = new ArrayList(); foreach (var item in query.Enumerable()) { alstFBAccounts.Add(item); } return(alstFBAccounts); } //End Transaction } //End session }
public void UpdateInstagramAccountFollowerSecond(Domain.Socioboard.Domain.InstagramUserDetails insert) { //Domain.Socioboard.Domain.InstagramUserDetails insert = (Domain.Socioboard.Domain.InstagramUserDetails)new JavaScriptSerializer().Deserialize(_Insta, typeof(Domain.Socioboard.Domain.InstagramUserDetails)); //Creates a database connection and opens up a session using (NHibernate.ISession session = SessionFactory.GetNewSession()) { //Begin session trasaction and opens up. using (NHibernate.ITransaction transaction = session.BeginTransaction()) { string str = "Update InstagramUserDetails set Follower=:FollowingsCount, Following=:FollowersCount,Media_Count=:MediaCount where Profile_Id=:ProfileId and Created_Time>=:EntryDate1 and Created_Time<=:EntryDate2"; int i = session.CreateQuery(str) .SetParameter("FollowingsCount", insert.Follower) .SetParameter("FollowersCount", insert.Following) .SetParameter("MediaCount", insert.Media_Count) .SetParameter("ProfileId", insert.Profile_Id) .SetParameter("EntryDate1", DateTime.Now.Date.AddHours(12).AddSeconds(1)) .SetParameter("EntryDate2", DateTime.Now.AddDays(1).Date.AddSeconds(-1)) .ExecuteUpdate(); transaction.Commit(); } } }
public int deleteFacebookStats(string FBuserid, Guid userid) { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { using (NHibernate.ITransaction transaction = session.BeginTransaction()) { try { NHibernate.IQuery query = session.CreateQuery("delete from FacebookStats where FbUserId = :twtuserid and UserId = :userid") .SetParameter("twtuserid", FBuserid) .SetParameter("userid", userid); int isUpdated = query.ExecuteUpdate(); transaction.Commit(); return(isUpdated); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(0); } } } }
public void UpdateCaptchaStatusForOtherService(faceboardpro.Domain.Captcha Captchasetting) { try { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { using (NHibernate.ITransaction transaction = session.BeginTransaction()) { var query = session.CreateQuery("Update Captcha set Status= :status where CaptchaService!= :captchaservice"); query.SetParameter("status", "False"); query.SetParameter("captchaservice", Captchasetting.CaptchaService); int res = query.ExecuteUpdate(); transaction.Commit(); //return res; } } } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } }
public Domain.Socioboard.Domain.BusinessSetting GetDetailsofBusinessOwner(Guid groupId) { // bool flag = 0; using (NHibernate.ISession session = SessionFactory.GetNewSession()) { using (NHibernate.ITransaction transaction = session.BeginTransaction()) { List <Domain.Socioboard.Domain.BusinessSetting> lstdetails = session.CreateQuery("from BusinessSetting where groupId=:groupId") .SetParameter("groupId", groupId).List <Domain.Socioboard.Domain.BusinessSetting>().ToList <Domain.Socioboard.Domain.BusinessSetting>(); Domain.Socioboard.Domain.BusinessSetting objBsnsStng = new Domain.Socioboard.Domain.BusinessSetting(); if (lstdetails.Count > 0) { objBsnsStng = lstdetails[0]; } else { objBsnsStng = null; } return(objBsnsStng); } } }
public int DeleteUserByAdmin(Guid id) { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { using (NHibernate.ITransaction transaction = session.BeginTransaction()) { try { int i = session.CreateQuery("Update User set ActivationStatus=:status where Id = :userid") .SetParameter("userid", id) .SetParameter("status", "2") .ExecuteUpdate(); transaction.Commit(); return(i); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(0); } } } }
/// <updateMessage> /// Update Message status by id. /// </summary> /// <param name="id">Id of scheduler. (Guid)</param> public void updateMessage(Guid id) { //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()) { try { //Proceed action, to Update status of scheduled message. NHibernate.IQuery query = session.CreateQuery("update ScheduledMessage set Status = 1 where Id = :id"); query.SetParameter("id", id); query.ExecuteUpdate(); transaction.Commit(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } //End Transaction } //End Session }
public bool updateAccount(Domain.Socioboard.Domain.CompanyProfiles compnayProfiles) { bool IsUpdated = false; using (NHibernate.ISession session = SessionFactory.GetNewSession()) { //After Session creation, start Transaction. using (NHibernate.ITransaction transaction = session.BeginTransaction()) { try { // Proceed action to Update Data. // And Set the reuired paremeters to find the specific values. session.CreateQuery("Update companyprofiles set CompanyName =:CompanyName,FbProfileId =:FbProfileId,TwitterProfileId =:TwitterProfileId,LinkedinProfileId=:LinkedinProfileId,InstagramProfileId=:InstagramProfileId,YoutubeProfileId=:YoutubeProfileId,GPlusProfileId=:GPlusProfileId,TumblrProfileId=:TumblrProfileId,UserId=:UserId where Id = :Id ") .SetParameter("CompanyName", compnayProfiles.Companyname) .SetParameter("FbProfileId", compnayProfiles.Fbprofileid) .SetParameter("TwitterProfileId", compnayProfiles.Twitterprofileid) .SetParameter("LinkedinProfileId", compnayProfiles.Linkedinprofileid) .SetParameter("InstagramProfileId", compnayProfiles.Instagramprofileid) .SetParameter("YoutubeProfileId", compnayProfiles.Youtubeprofileid) .SetParameter("GPlusProfileId", compnayProfiles.Gplusprofileid) .SetParameter("TumblrProfileId", compnayProfiles.Tumblrprofileid) .SetParameter("UserId", compnayProfiles.Userid) .SetParameter("Id", compnayProfiles.Id) .ExecuteUpdate(); transaction.Commit(); IsUpdated = true; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); // return 0; } return(IsUpdated); } //End Transaction } //End session }
/// <getAllInstagramFeedsOfUser> /// Get all instagram feeds of user. /// </summary> /// <param name="UserId">userid(Guid)</param> /// <param name="profileid">Profile id of instagram(String)</param> /// <param name="count">Get the toral numbert of data(int)</param> /// <returns>Return a object of InstagramFeed Class with value of each member in form of List type.(List<InstagramFeed>)</returns> public List <Domain.Socioboard.Domain.InstagramFeed> getAllInstagramFeedsOfUser(Guid UserId, string profileid, int noOfDataToSkip, int noOfDataFromTop) { //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()) { try { //Proceed action, to get feeds List <Domain.Socioboard.Domain.InstagramFeed> alst = session.CreateQuery("from InstagramFeed where UserId = :userid and InstagramId = :profileId Order By FeedDate DESC") .SetParameter("userid", UserId) .SetParameter("profileId", profileid) .SetFirstResult(noOfDataToSkip) .SetMaxResults(noOfDataFromTop) .List <Domain.Socioboard.Domain.InstagramFeed>() .ToList <Domain.Socioboard.Domain.InstagramFeed>(); #region oldcode //List<InstagramFeed> alst = new List<InstagramFeed>(); //foreach (InstagramFeed item in query.Enumerable()) //{ // alst.Add(item); //} #endregion return(alst); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(null); } } //End Transaction } //End Session }
/// <getAllgoogleplusActivityOfUser> /// Get the details of all google plus activity for a user. /// </summary> /// <param name="UserId">User id (Guid).</param> /// <param name="profileId">Profile id.(string)</param> /// <returns>List of Google plus activities. (List<Domain.GooglePlusActivities>)</returns> public List <GooglePlusActivities> getAllgoogleplusActivityOfUser(Guid UserId, string profileId) { //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()) { try { //Proceed action, to get all google plus activities. List <GooglePlusActivities> alst = session.CreateQuery("from GooglePlusActivities where UserId = :userid and GpUserId = :profileId") .SetParameter("userid", UserId) .SetParameter("profileId", profileId) .List <GooglePlusActivities>() .ToList <GooglePlusActivities>(); #region oldcode //List<GooglePlusActivities> alst = new List<GooglePlusActivities>(); //foreach (GooglePlusActivities item in query.Enumerable<GooglePlusActivities>().OrderByDescending(x => x.PublishedDate)) //{ // alst.Add(item); //} #endregion return(alst); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(null); } } //End Transaction } //End session }
/// <UpdateLDAccessTokenByLDUserId> /// Update Linkedin access token of account by user id. /// </summary> /// <param name="LDUserId">linkedin account id(string)</param> /// <param name="accessToken">New access token of account(String)</param> /// <returns>Return integer 1 for true and 0 for false.</returns> public int UpdateLDAccessTokenByLDUserId(string LDUserId, string accessToken) { int update = 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()) { try { update = session.CreateQuery("Update LinkedInAccount set OAuthToken = :accessToken where UserId = :LDUserId") .SetParameter("accessToken", accessToken) .SetParameter("LDUserId", LDUserId) .ExecuteUpdate(); transaction.Commit(); update = 1; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); // return 0; } } //End Transaction } //End Session } catch (Exception ex) { Console.WriteLine("Error : " + ex.StackTrace); } return(update); }