Ejemplo n.º 1
0
        public static AspdnsfEventHandler Create(string EventName, string CalloutURL, string XmlPackage, bool Active, bool Debug)
        {
            var EventID = 0;

            if (EventName.Trim().Length == 0)
            {
                return(null);
            }

            if (CalloutURL.Trim().Length == 0)
            {
                return(null);
            }

            if (XmlPackage.Trim().Length == 0)
            {
                return(null);
            }

            using (var cn = new SqlConnection(DB.GetDBConn()))
            {
                cn.Open();
                using (var cmd = new SqlCommand())
                {
                    cmd.Connection  = cn;
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = "dbo.aspdnsf_insEventHandler";

                    cmd.Parameters.Add(new SqlParameter("@EventName", SqlDbType.NVarChar, 20));
                    cmd.Parameters.Add(new SqlParameter("@CalloutURL", SqlDbType.VarChar, 200));
                    cmd.Parameters.Add(new SqlParameter("@XmlPackage", SqlDbType.VarChar, 100));
                    cmd.Parameters.Add(new SqlParameter("@Active", SqlDbType.Bit));
                    cmd.Parameters.Add(new SqlParameter("@Debug", SqlDbType.Bit));
                    cmd.Parameters.Add(new SqlParameter("@EventID", SqlDbType.Int, 4)).Direction = ParameterDirection.Output;

                    cmd.Parameters["@EventName"].Value  = EventName;
                    cmd.Parameters["@CalloutURL"].Value = CalloutURL;
                    cmd.Parameters["@XmlPackage"].Value = XmlPackage;
                    cmd.Parameters["@Active"].Value     = Active;
                    cmd.Parameters["@Debug"].Value      = Debug;

                    try
                    {
                        cmd.ExecuteNonQuery();
                        EventID = Int32.Parse(cmd.Parameters["@EventID"].Value.ToString());
                    }
                    catch (Exception ex)
                    {
                        SysLog.LogException(ex, MessageTypeEnum.DatabaseException, MessageSeverityEnum.Error);
                    }
                }
            }

            if (EventID > 0)
            {
                AspdnsfEventHandler a = new AspdnsfEventHandler(EventID);
                return(a);
            }
            return(null);
        }
Ejemplo n.º 2
0
 public string Update(SqlParameter[] spa)
 {
     return(AspdnsfEventHandler.Update(this.EventID, spa));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a new EventHandler record and adds it to the collection
 /// </summary>
 public void Add(string EventName, string CalloutURL, string XmlPackage, bool Active, bool Debug)
 {
     this.Add(AspdnsfEventHandler.Create(EventName, CalloutURL.Trim(), XmlPackage.Trim(), Active, Debug));
 }
Ejemplo n.º 4
0
        public static AspdnsfEventHandler Create(string EventName, string CalloutURL, string XmlPackage, bool Active, bool Debug)
        {
            int EventID = 0;

            if (EventName.Trim().Length == 0)
            {
                return(null);
            }

            if (CalloutURL.Trim().Length == 0)
            {
                return(null);
            }

            if (XmlPackage.Trim().Length == 0)
            {
                return(null);
            }

            string        err = String.Empty;
            SqlConnection cn  = new SqlConnection(DB.GetDBConn());

            cn.Open();
            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = cn;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "dbo.aspdnsf_insEventHandler";

            cmd.Parameters.Add(new SqlParameter("@EventName", SqlDbType.NVarChar, 20));
            cmd.Parameters.Add(new SqlParameter("@CalloutURL", SqlDbType.VarChar, 200));
            cmd.Parameters.Add(new SqlParameter("@XmlPackage", SqlDbType.VarChar, 100));
            cmd.Parameters.Add(new SqlParameter("@Active", SqlDbType.Bit));
            cmd.Parameters.Add(new SqlParameter("@Debug", SqlDbType.Bit));
            cmd.Parameters.Add(new SqlParameter("@EventID", SqlDbType.Int, 4)).Direction = ParameterDirection.Output;

            cmd.Parameters["@EventName"].Value  = EventName;
            cmd.Parameters["@CalloutURL"].Value = CalloutURL;
            cmd.Parameters["@XmlPackage"].Value = XmlPackage;
            cmd.Parameters["@Active"].Value     = Active;
            cmd.Parameters["@Debug"].Value      = Debug;

            try
            {
                cmd.ExecuteNonQuery();
                EventID = Int32.Parse(cmd.Parameters["@EventID"].Value.ToString());
            }
            catch (Exception ex)
            {
                err = ex.Message;
            }

            cn.Close();
            cmd.Dispose();
            cn.Dispose();

            if (EventID > 0)
            {
                AspdnsfEventHandler a = new AspdnsfEventHandler(EventID);
                return(a);
            }
            return(null);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Adds an existing EventHandlerClass object to the collection
 /// </summary>
 public void Add(AspdnsfEventHandler eventhandler)
 {
     m_EventHandlers.Add(eventhandler.EventName.ToLowerInvariant(), eventhandler);
 }