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


C# Result.SetFailed方法代码示例

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


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

示例1: InitialiseDatabase

		public void InitialiseDatabase(Result result)
		{
			if (!result.Succeeded)
				return;

			using (SQLiteConnection connection = new SQLiteConnection(DatabaseManager.DatabaseEngine.ConnectionString))
			{
				connection.Open();
				using (TransactionScope scope = new TransactionScope())
				{
					try
					{
						SQLiteCommand cmd = connection.CreateCommand();
						cmd.CommandText = GetSQL("SQLite Tables");
						cmd.ExecuteNonQuery();

						cmd.CommandText = GetSQL("Insert First ClientSpace");
						cmd.Parameters.Add(new SQLiteParameter("@ClientSpaceID", SecurityProvider.ClientSpaceID));
						int n = cmd.ExecuteNonQuery();

						if (n > 0) // then a new client was inserted, so insert accompanying data
						{
						}
						scope.Complete();
					}
					catch (Exception ex)
					{
						result.SetFailed("Unable to initialise SQLite database for SecurityProvider: " + ex.Message);
					}
				}
			}
			return;
		}
开发者ID:Erls-Corporation,项目名称:Sprocket.0.4-binaries-source,代码行数:33,代码来源:SQLiteSecurityProviderDataLayer.cs

示例2: Initialise

        public virtual void Initialise(Result result)
        {
            string ns = SchemaResourceNamespace;
            if (ns == null || ns == String.Empty)
                return;

            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    SQLiteConnection connection = (SQLiteConnection)DatabaseManager.DatabaseEngine.GetConnection();
                    SQLiteCommand cmd = connection.CreateCommand();
                    cmd.CommandText = ResourceLoader.LoadTextResource(asm, ns);
                    cmd.ExecuteNonQuery();
                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.SetFailed(SchemaResourceNamespace + ": " + Environment.NewLine + ex.Message);
            }
            finally
            {
                DatabaseManager.DatabaseEngine.ReleaseConnection();
            }
        }
开发者ID:priaonehaha,项目名称:sprocketcms,代码行数:26,代码来源:SQLiteDataProvider.cs

示例3: Instance_OnAjaxRequestAuthenticationCheck

 void Instance_OnAjaxRequestAuthenticationCheck(System.Reflection.MethodInfo source, Result result)
 {
     if (!AllowSimultaneousLogins)
         if (AjaxRequestHandler.AuthKey != GetAuthKey(CurrentUsername))
         {
             result.SetFailed("Authentication failed: your account details have been used to log in elsewhere. Please log in again.");
             System.Diagnostics.Trace.WriteLine(CurrentUsername + " / AjaxRequestHandler.AuthKey: " + AjaxRequestHandler.AuthKey + "; GetAuthKey: " + GetAuthKey(CurrentUsername));
         }
 }
开发者ID:priaonehaha,项目名称:sprocketcms,代码行数:9,代码来源:WebAuthentication.cs

示例4: OnAjaxRequestAuthenticationCheck

        void OnAjaxRequestAuthenticationCheck(System.Reflection.MethodInfo source, Result result)
        {
            if (!CurrentUser.Enabled)
            {
                result.SetFailed("Ajax method called failed because your account has been disabled.");
                return;
            }

            Attribute[] roleAttr = Attribute.GetCustomAttributes(source, typeof(RequiresRoleAttribute));
            Attribute[] permAttr = Attribute.GetCustomAttributes(source, typeof(RequiresPermissionAttribute));
            for (int i = 0; i < roleAttr.Length; i++)
                if (!CurrentUser.HasRole(((RequiresRoleAttribute)roleAttr[i]).RoleCode))
                {
                    result.SetFailed("Ajax method call failed because you do not have one or more required roles.");
                    return;
                }
            for (int i = 0; i < permAttr.Length; i++)
                if (!CurrentUser.HasPermission(((RequiresPermissionAttribute)permAttr[i]).PermissionTypeCode))
                {
                    result.SetFailed("Ajax method call failed because you do not have one or more required permissions.");
                    return;
                }
        }
开发者ID:priaonehaha,项目名称:sprocketcms,代码行数:23,代码来源:WebSecurity_Ajax.cs

示例5: InitialiseDatabase

        public void InitialiseDatabase(Result result)
        {
            if (!result.Succeeded)
                return;

            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    SQLiteConnection connection = (SQLiteConnection)DatabaseManager.DatabaseEngine.GetConnection();
                    SQLiteCommand cmd = connection.CreateCommand();
                    cmd.CommandText = ResourceLoader.LoadTextResource("Sprocket.Security.SQLite.schema.sql");
                    cmd.ExecuteNonQuery();

                    cmd.CommandText = procs["Insert First Client"];
                    cmd.Parameters.Add(new SQLiteParameter("@ClientSpaceID", SecurityProvider.ClientSpaceID));
                    int n = cmd.ExecuteNonQuery();

                    if (n > 0) // then a new client was inserted, so insert accompanying data
                    {
                        User user = new User(SecurityProvider.ClientSpaceID, "admin", "password", "System", "Administrator", "[email protected]", true, true, false, 0);
                        PermissionType pt1 = new PermissionType(DatabaseManager.DatabaseEngine.GetUniqueID(), PermissionType.SuperUser, "Unrestricted Access", false);
                        PermissionType pt2 = new PermissionType(DatabaseManager.DatabaseEngine.GetUniqueID(), PermissionType.AdministrativeAccess, "Access Admin Area", false);
                        PermissionType pt3 = new PermissionType(DatabaseManager.DatabaseEngine.GetUniqueID(), PermissionType.UserAdministrator, "Create/Modify Users", false);
                        PermissionType pt4 = new PermissionType(DatabaseManager.DatabaseEngine.GetUniqueID(), PermissionType.RoleAdministrator, "Create/Modify Roles", false);
                        user.UserID = DatabaseManager.DatabaseEngine.GetUniqueID();
                        user.Activated = true;
                        Result r = Store(user);
                        if (r.Succeeded)
                        {
                            r = Store(pt1); if (r.Succeeded)
                            {
                                r = Store(pt2); if (r.Succeeded)
                                {
                                    r = Store(pt3); if (r.Succeeded)
                                    {
                                        r = Store(pt4); if (r.Succeeded)
                                        {
                                            r = AssignPermissionToUser(user.UserID, PermissionType.SuperUser);
                                        }
                                    }
                                }
                            }
                        }
                        if (!r.Succeeded)
                            result.SetFailed(r.Message);
                    }
                    if (result.Succeeded)
                        scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.SetFailed("Unable to initialise SQLite database for SecurityProvider: " + ex.Message);
            }
            finally
            {
                DatabaseManager.DatabaseEngine.ReleaseConnection();
            }
        }
开发者ID:priaonehaha,项目名称:sprocketcms,代码行数:60,代码来源:SQLiteSecurityProviderDataLayer.cs

示例6: InitialiseDatabase

 public void InitialiseDatabase(Result result)
 {
     try
     {
         using (TransactionScope scope = new TransactionScope())
         {
             SQLiteConnection connection = (SQLiteConnection)DatabaseManager.DatabaseEngine.GetConnection();
             SQLiteCommand cmd = connection.CreateCommand();
             cmd.Connection = connection;
             cmd.CommandText = ResourceLoader.LoadTextResource("Sprocket.Web.FileManager.SQLite.schema.sql");
             cmd.ExecuteNonQuery();
             scope.Complete();
         }
     }
     catch (Exception ex)
     {
         result.SetFailed(ex.Message);
     }
     finally
     {
         DatabaseManager.DatabaseEngine.ReleaseConnection();
     }
 }
开发者ID:priaonehaha,项目名称:sprocketcms,代码行数:23,代码来源:SQLiteFileManagerDataLayer.cs


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