当前位置: 首页>>代码示例>>C#>>正文


C# SessionScopeWrapper.CreateQuery方法代码示例

本文整理汇总了C#中SessionScopeWrapper.CreateQuery方法的典型用法代码示例。如果您正苦于以下问题:C# SessionScopeWrapper.CreateQuery方法的具体用法?C# SessionScopeWrapper.CreateQuery怎么用?C# SessionScopeWrapper.CreateQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SessionScopeWrapper的用法示例。


在下文中一共展示了SessionScopeWrapper.CreateQuery方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RetrieveAuthenticationData

 public static AuthenticationData RetrieveAuthenticationData(String providerName)
 {
     using (var sess = new SessionScopeWrapper())
     {
         var prov = sess.CreateQuery("from OAuthProvider where ProviderName=?")
             .SetString(0, providerName)
             .List<IOAuthProvider>().FirstOrDefault();
         if (prov == null)
         {
             throw new Exception(String.Format("Unable to locate {0} provider in the configured OAuth providers", providerName));
         }
         var userToken = sess.CreateQuery("from UserOAuthToken where OAuthProvider.Id=? and User.Id=?")
             .SetString(0, prov.Id.ToString())
             .SetString(1, ApplicationContext.Current.Services.Get<IUserService>().UserId)
             .List<IUserOAuthToken>()
             .FirstOrDefault();
         if (userToken == null || userToken.AccessToken == null)
         {
             throw new Exception(String.Format("Unable to locate authorization token for current user under {0} provider", providerName));
         }
         if (userToken.ExpirationDate != null && userToken.ExpirationDate < DateTime.Now)
         {
             // TODO: refresh, if possible??  (Not applicable to either Twitter or Linked in, though)
             throw new Exception(String.Format("Authentication token for {0} provider has expired", providerName));
         }
         return new AuthenticationData
         {
             ConsumerKey = prov.ClientId,
             ConsumerSecret = prov.Secret,
             Token = userToken.AccessToken,
             TokenSecret = userToken.AccessTokenSecret,
             RefreshToken = userToken.RefreshToken
         };
     }
 }
开发者ID:Saleslogix,项目名称:SLXSocial,代码行数:35,代码来源:AuthenticationData.cs

示例2: Read

 public IEnumerable<IRecord> Read()
 {
     using (var sess = new SessionScopeWrapper())
     {
         var qry = sess.CreateQuery(_query);
         IList lst = qry.List();
         foreach (object o in lst)
             yield return new HqlRecordWrapper(o);
     }
 }
开发者ID:PmeyerSwiftpage,项目名称:NotificationEngine,代码行数:10,代码来源:HqlDataSource.cs

示例3: Read

        public IEnumerable<IRecord> Read(WorkItem workItem)
        {
            String query = String.Format("from {0} where {1}", _entity, workItem.EvaluateLiterals(_where, this));

            using (var sess = new SessionScopeWrapper())
            {
                var qry = sess.CreateQuery(query);
                IList lst = qry.List();
                foreach (object o in lst)
                    yield return new EntityRecordWrapper(o);
            }
        }
开发者ID:nicocrm,项目名称:NotificationEngine,代码行数:12,代码来源:EntityDataSource.cs

示例4: GetPasswordHint_Click

 /// <summary>
 /// Handles the Click event of the GetPasswordHint control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 protected void GetPasswordHint_Click(object sender, EventArgs e)
 {
     if (String.IsNullOrEmpty(slxLogin.UserName))
     {
         HintText.Text = GetLocalResourceObject("PasswordHintUserNameRequired").ToString();
     }
     else
     {
         IList<IContact> contacts = null;
         using (ISession session = new SessionScopeWrapper())
         {
             contacts = session.CreateQuery("from Contact c where c.WebUserName = :value")
                .SetAnsiString("value", slxLogin.UserName)
                .List<IContact>();
         }
         if ((contacts != null) && (contacts.Count > 0))
         {
             HintText.Text = (contacts[0].WebPasswordHint);
         }
     }
     HintTextDiv.Style.Add(HtmlTextWriterStyle.Display, "inline");
 }
开发者ID:ssommerfeldt,项目名称:TAC_MAT,代码行数:27,代码来源:Login.aspx.cs

示例5: ExportPickListData

    private void ExportPickListData(IList<string> selections, string format)
    {
        if (selections == null)
        {
            using (ISession session = new SessionScopeWrapper())
            {
                IQuery query = session.CreateQuery("select P.ItemId from PickList P where P.PickListId = :id order by P.Text");
                query
                    .SetAnsiString("id", "PICKLISTLIST")
                    .SetCacheable(true);
                selections = query.List<string>();
            }
        }

        DataTable dt = new DataTable("PickLists");
        DataColumn dc = dt.Columns.Add();
        dc.ColumnName = "PickListName";
        dc.DataType = typeof(string);
        dc.AllowDBNull = true;

        dc = dt.Columns.Add();
        dc.ColumnName = "Text";
        dc.DataType = typeof(string);
        dc.AllowDBNull = true;

        dc = dt.Columns.Add();
        dc.ColumnName = "Code";
        dc.DataType = typeof(string);
        dc.AllowDBNull = true;

        dc = dt.Columns.Add();
        dc.ColumnName = "Order";
        dc.DataType = typeof(int);
        dc.AllowDBNull = true;

        dc = dt.Columns.Add();
        dc.ColumnName = "IsDefault";
        dc.DataType = typeof(bool);
        dc.AllowDBNull = true;

        dc = dt.Columns.Add();
        dc.ColumnName = "PickListId";
        dc.DataType = typeof(string);
        dc.AllowDBNull = true;

        dc = dt.Columns.Add();
        dc.ColumnName = "ItemId";
        dc.DataType = typeof(string);
        dc.AllowDBNull = true;

        IDictionary<string, Layout> layout = new Dictionary<string, Layout>();

        Layout item = new Layout();
        item = new Layout();
        item.ColumnName = "PickListName";
        item.ColumnCaption = "PickListName";
        item.Visible = true;
        item.FormatType = string.Empty;
        item.FormatString = string.Empty;
        item.Width = 64;
        layout.Add(item.ColumnName, item);

        item = new Layout();
        item.ColumnName = "Text";
        item.ColumnCaption = "Text";
        item.Visible = true;
        item.FormatType = string.Empty;
        item.FormatString = string.Empty;
        item.Width = 64;
        layout.Add(item.ColumnName, item);

        item = new Layout();
        item.ColumnName = "Code";
        item.ColumnCaption = "Code";
        item.Visible = true;
        item.FormatType = string.Empty;
        item.FormatString = string.Empty;
        item.Width = 64;
        layout.Add(item.ColumnName, item);

        item = new Layout();
        item.ColumnName = "Order";
        item.ColumnCaption = "Order";
        item.Visible = true;
        item.FormatType = string.Empty;
        item.FormatString = string.Empty;
        item.Width = 64;
        layout.Add(item.ColumnName, item);

        item = new Layout();
        item.ColumnName = "IsDefault";
        item.ColumnCaption = "IsDefault";
        item.Visible = true;
        item.FormatType = string.Empty;
        item.FormatString = string.Empty;
        item.Width = 64;
        layout.Add(item.ColumnName, item);

        item = new Layout();
        item.ColumnName = "PickListId";
//.........这里部分代码省略.........
开发者ID:pebre77,项目名称:PrxS2,代码行数:101,代码来源:CommonTasksTasklet.ascx.cs

示例6: LoadUrls

    protected void LoadUrls()
    {
        ddlUrls.Items.Clear();

        IUserService userService = Sage.Platform.Application.ApplicationContext.Current.Services.Get<Sage.Platform.Security.IUserService>();
        string currentUserId = userService.UserId;

        using (NHibernate.ISession session = new SessionScopeWrapper())
        {
            StringBuilder hql = new StringBuilder();
            hql.Append("select w.Name, w.Id, w.CreateUser from WebInfo w ");
            hql.Append("where w.CreateUser = :cUser ");
            hql.Append("and w.Entity = 'Account' ");
            hql.Append("or w.Share = 'Y' ");
            hql.Append("and w.Entity = 'Account' ");
            hql.Append("order by w.Name");

            NHibernate.IQuery newQuery = session.CreateQuery(hql.ToString());
            newQuery.SetAnsiString("cUser", currentUserId);

            System.Collections.IList tempList = newQuery.List();
            ArrayList results = new ArrayList();

            foreach (object data in tempList)
            {
                Array al = (Array)data;
                ArrayList fields = new ArrayList();
                foreach (object field in al)
                {
                    fields.Add((string)field);
                }
                results.Add(fields);
            }

            for (int i = 0; i < results.Count; i++)
            {
                ArrayList itemList = new ArrayList();

                itemList = results[i] as ArrayList;

                ListItem listItem = new ListItem();

                if (currentUserId == itemList[2].ToString())
                {
                    listItem.Text = itemList[0].ToString() + "*";
                }
                else
                {
                    listItem.Text = itemList[0].ToString();
                }

                listItem.Value = itemList[1].ToString();
                ddlUrls.Items.Add(listItem);
            }
        }

        if (ddlUrls.Items.Count > 0)
        {
            SetDisplay(ddlUrls.Items[0].Value);
        }
    }
开发者ID:ssommerfeldt,项目名称:TAC_WWW,代码行数:61,代码来源:WebInfoDotNet.ascx.cs

示例7: IsUserInTeam

 /// <summary>
 /// True if specified user is in specified team (or department).
 /// Note that this will return true whether the user is a direct member of the team,
 /// or manager of someone who is.
 /// </summary>
 /// <param name="userId"></param>
 /// <param name="teamName"></param>
 /// <returns></returns>
 public static bool IsUserInTeam(String userId, String teamName)
 {
     using (var sess = new SessionScopeWrapper())
     {
         return 0 < sess.CreateQuery("select count(*) from OwnerRights sr where sr.User.Id=? and sr.Owner.OwnerDescription=?")
             .SetString(0, userId)
             .SetString(1, teamName)
             .SetCacheable(true)
             .UniqueResult<long>();
     }
 }
开发者ID:nicocrm,项目名称:OpenSlx,代码行数:19,代码来源:SecUtils.cs

示例8: GetPickListView

 private IPickListView GetPickListView()
 {
     IPickListView plv =  this.BindingSource.Current as IPickListView;
     using (ISession session = new SessionScopeWrapper(true))
     {
         IQuery query = session.CreateQuery("select p1 from PickListView p1 where p1.Id = :PickListId");
         query
             .SetAnsiString("PickListId", plv.Id.ToString())
             .SetCacheable(false);
         return query.UniqueResult<IPickListView>();
     }
 }
开发者ID:pebre77,项目名称:PrxS2,代码行数:12,代码来源:PickListItems.ascx.cs

示例9: GetItems

    private IList<IPickListItemView> GetItems(IPickListView pickList)
    {
        using (ISession session = new SessionScopeWrapper(true))
        {

            if(string.IsNullOrEmpty(_sortExpression))
            {
               _sortExpression = "OrderSeq";
            }
            if(string.IsNullOrEmpty(_sortDirection))
            {
              _sortDirection = "Asc";
            }

                string hql = string.Format("select P1 from PickListItemView P1 where (P1.UserId =:UserId And P1.PickListId = :PickListId) order by {0} {1} ", _sortExpression, _sortDirection);
                //string hql = string.Format("select P1 from PickListItemView P1 where (P1.PickListId = :PickListId) order by {0} {1} ", _sortExpression, _sortDirection);
                IQuery query = session.CreateQuery(hql);
                query
                    .SetAnsiString("PickListId", pickList.Id.ToString())
                    .SetAnsiString("UserId", "ADMIN")
                    .SetCacheable(false);
                return query.List<IPickListItemView>();

        }
    }
开发者ID:pebre77,项目名称:PrxS2,代码行数:25,代码来源:PickListItems.ascx.cs

示例10: AddAction

    private void AddAction(string actionName, string desription, IRole role)
    {
        using (ISession session = new SessionScopeWrapper())
        {

            IList<ISecuredAction> actions = null;

            IQuery query = session.CreateQuery("from SecuredAction s where s.Name = :name");
            query
             .SetAnsiString("name", actionName);
            actions = query.List<ISecuredAction>();
            if (actions.Count < 1)
            {

                ISecuredAction newAction = Sage.Platform.EntityFactory.Create<ISecuredAction>();
                newAction.Name = actionName;
                newAction.Description = desription;
                newAction.Save();
                ISecuredActionRole newActionRole = Sage.Platform.EntityFactory.Create<ISecuredActionRole>();
                newActionRole.Role = role;
                newActionRole.SecuredAction = newAction;
                newActionRole.Save();
            }
            else
            { }

        }
    }
开发者ID:ssommerfeldt,项目名称:TAC_GWC,代码行数:28,代码来源:AnalyticsSystemDetail.ascx.cs


注:本文中的SessionScopeWrapper.CreateQuery方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。