Exemplo n.º 1
0
        /// <summary>增加一条数据
        ///
        /// </summary>
        public int Add(Nikita.Assist.WcfConfiguration.Model.WcfConfigInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into WcfConfigInfo(");
            strSql.Append("WcfServiceName, WcfServiceClassName, WcfServiceInterfaceName, WcfServiceNameSpace, BseUrl, EnpointBindUrl, WcfType, Percentage, WcfGroup, Remark, State  )");
            strSql.Append(" values (");
            strSql.Append("@WcfServiceName, @WcfServiceClassName, @WcfServiceInterfaceName, @WcfServiceNameSpace, @BseUrl, @EnpointBindUrl, @WcfType, @Percentage, @WcfGroup, @Remark, @State  )");
            strSql.Append(";select @@IDENTITY");
            MSSQLHelper h = new MSSQLHelper(GlobalHelp.WcfConfigDbConnstr);

            h.CreateCommand(strSql.ToString());
            if (model.WcfServiceName == null)
            {
                h.AddParameter("@WcfServiceName", DBNull.Value);
            }
            else
            {
                h.AddParameter("@WcfServiceName", model.WcfServiceName);
            }
            if (model.WcfServiceClassName == null)
            {
                h.AddParameter("@WcfServiceClassName", DBNull.Value);
            }
            else
            {
                h.AddParameter("@WcfServiceClassName", model.WcfServiceClassName);
            }
            if (model.WcfServiceInterfaceName == null)
            {
                h.AddParameter("@WcfServiceInterfaceName", DBNull.Value);
            }
            else
            {
                h.AddParameter("@WcfServiceInterfaceName", model.WcfServiceInterfaceName);
            }
            if (model.WcfServiceNameSpace == null)
            {
                h.AddParameter("@WcfServiceNameSpace", DBNull.Value);
            }
            else
            {
                h.AddParameter("@WcfServiceNameSpace", model.WcfServiceNameSpace);
            }
            if (model.BseUrl == null)
            {
                h.AddParameter("@BseUrl", DBNull.Value);
            }
            else
            {
                h.AddParameter("@BseUrl", model.BseUrl);
            }
            if (model.EnpointBindUrl == null)
            {
                h.AddParameter("@EnpointBindUrl", DBNull.Value);
            }
            else
            {
                h.AddParameter("@EnpointBindUrl", model.EnpointBindUrl);
            }
            if (model.WcfType == null)
            {
                h.AddParameter("@WcfType", DBNull.Value);
            }
            else
            {
                h.AddParameter("@WcfType", model.WcfType);
            }
            if (model.Percentage == null)
            {
                h.AddParameter("@Percentage", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Percentage", model.Percentage);
            }
            if (model.WcfGroup == null)
            {
                h.AddParameter("@WcfGroup", DBNull.Value);
            }
            else
            {
                h.AddParameter("@WcfGroup", model.WcfGroup);
            }
            if (model.Remark == null)
            {
                h.AddParameter("@Remark", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Remark", model.Remark);
            }
            if (model.State == null)
            {
                h.AddParameter("@State", DBNull.Value);
            }
            else
            {
                h.AddParameter("@State", model.State);
            }

            int    result;
            string obj = h.ExecuteScalar();

            if (!int.TryParse(obj, out result))
            {
                return(0);
            }
            return(result);
        }
Exemplo n.º 2
0
        /// <summary>更新一条数据
        ///
        /// </summary>
        public bool Update(Nikita.Assist.WcfConfiguration.Model.WcfConfigInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update WcfConfigInfo set ");
            strSql.Append("WcfServiceName=@WcfServiceName, WcfServiceClassName=@WcfServiceClassName, WcfServiceInterfaceName=@WcfServiceInterfaceName, WcfServiceNameSpace=@WcfServiceNameSpace, BseUrl=@BseUrl, EnpointBindUrl=@EnpointBindUrl, WcfType=@WcfType, Percentage=@Percentage, WcfGroup=@WcfGroup, Remark=@Remark, State=@State  ");
            strSql.Append(" where id=@id ");
            MSSQLHelper h = new MSSQLHelper(GlobalHelp.WcfConfigDbConnstr);

            h.CreateCommand(strSql.ToString());
            if (model.id == null)
            {
                h.AddParameter("@id", DBNull.Value);
            }
            else
            {
                h.AddParameter("@id", model.id);
            }
            if (model.WcfServiceName == null)
            {
                h.AddParameter("@WcfServiceName", DBNull.Value);
            }
            else
            {
                h.AddParameter("@WcfServiceName", model.WcfServiceName);
            }
            if (model.WcfServiceClassName == null)
            {
                h.AddParameter("@WcfServiceClassName", DBNull.Value);
            }
            else
            {
                h.AddParameter("@WcfServiceClassName", model.WcfServiceClassName);
            }
            if (model.WcfServiceInterfaceName == null)
            {
                h.AddParameter("@WcfServiceInterfaceName", DBNull.Value);
            }
            else
            {
                h.AddParameter("@WcfServiceInterfaceName", model.WcfServiceInterfaceName);
            }
            if (model.WcfServiceNameSpace == null)
            {
                h.AddParameter("@WcfServiceNameSpace", DBNull.Value);
            }
            else
            {
                h.AddParameter("@WcfServiceNameSpace", model.WcfServiceNameSpace);
            }
            if (model.BseUrl == null)
            {
                h.AddParameter("@BseUrl", DBNull.Value);
            }
            else
            {
                h.AddParameter("@BseUrl", model.BseUrl);
            }
            if (model.EnpointBindUrl == null)
            {
                h.AddParameter("@EnpointBindUrl", DBNull.Value);
            }
            else
            {
                h.AddParameter("@EnpointBindUrl", model.EnpointBindUrl);
            }
            if (model.WcfType == null)
            {
                h.AddParameter("@WcfType", DBNull.Value);
            }
            else
            {
                h.AddParameter("@WcfType", model.WcfType);
            }
            if (model.Percentage == null)
            {
                h.AddParameter("@Percentage", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Percentage", model.Percentage);
            }
            if (model.WcfGroup == null)
            {
                h.AddParameter("@WcfGroup", DBNull.Value);
            }
            else
            {
                h.AddParameter("@WcfGroup", model.WcfGroup);
            }
            if (model.Remark == null)
            {
                h.AddParameter("@Remark", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Remark", model.Remark);
            }
            if (model.State == null)
            {
                h.AddParameter("@State", DBNull.Value);
            }
            else
            {
                h.AddParameter("@State", model.State);
            }

            return(h.ExecuteNonQuery());
        }