예제 #1
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="ApplicationId"></param>
        /// <returns></returns>
        public AjaxResult Delete(string ApplicationId)
        {
            AjaxResult msg = new AjaxResult();

            DataTable dt = SqlHelper.ExecuteDataTable("select * from C_S_Application where ApplicationId = @ApplicationId", new SqlParameter[] { new SqlParameter("ApplicationId", ApplicationId) });

            //删除应用的时候,连同应用的版本号一起删除
            string sqlStr = "delete C_S_AppVersion where ApplicationId = @ApplicationId;";

            sqlStr += "delete C_S_Application where ApplicationId = @ApplicationId";
            SqlParameter[] parameter = { new SqlParameter("ApplicationId", ApplicationId) };

            int result = SqlHelper.ExecuteNonQuery(sqlStr, parameter);

            if (result > 0)
            {
                msg.data    = "";
                msg.state   = "success";
                msg.message = "删除成功!";

                #region ===========记录操作日志=================
                C_S_Log log = new C_S_Log()
                {
                    OperateType     = 3,    //移除
                    OperateUserId   = OperatorProvider.Provider.GetCurrent().UserName,
                    ApplicationId   = ApplicationId,
                    Content         = "删除应用",
                    ApplicationCode = "",
                    IPAddress       = Net.Ip,
                    MachineName     = Net.Host
                };

                if (dt.Rows.Count > 0)
                {
                    log.ApplicationCode = dt.Rows[0]["ApplicationCode"].ToString();
                }
                CSLog_BLL.Add(log);
                #endregion ======================================
            }
            else
            {
                msg.data    = "";
                msg.state   = "error";
                msg.message = "删除失败!";
            }
            return(msg);
        }
예제 #2
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public AjaxResult Add(C_S_Application entity)
        {
            AjaxResult          msg       = new AjaxResult();
            List <SqlParameter> parameter = new List <SqlParameter>();

            parameter.Add(new SqlParameter("ApplicationName", entity.ApplicationName));
            parameter.Add(new SqlParameter("ApplicationCode", entity.ApplicationCode));
            parameter.Add(new SqlParameter("Company", entity.Company));

            string sqlStr = "select * from C_S_Application where (ApplicationName = @ApplicationName or ApplicationCode=@ApplicationCode) and Company = @Company";

            DataTable dt = SqlHelper.ExecuteDataTable(sqlStr, parameter.ToArray());

            if (dt.Rows.Count > 0)
            {
                msg.data    = "";
                msg.state   = "error";
                msg.message = "新增失败,该应用已经存在!";
            }
            else
            {
                sqlStr = @"INSERT INTO dbo.C_S_Application (ApplicationId,ApplicationName,ApplicationCode,
                                 Company,SortCode,Remark,CreateBy,CreateTime,StartFileName)
                                VALUES  ( @ApplicationId ,@ApplicationName ,
                                          @ApplicationCode ,  @Company, @SortCode ,                                      
                                          @Remark ,  @CreateBy , @CreateTime,@StartFileName) ";
                parameter.Clear();
                parameter.Add(new SqlParameter("ApplicationId", entity.ApplicationId));
                parameter.Add(new SqlParameter("ApplicationName", entity.ApplicationName));
                parameter.Add(new SqlParameter("ApplicationCode", entity.ApplicationCode));
                parameter.Add(new SqlParameter("SortCode", entity.SortCode));
                parameter.Add(new SqlParameter("Company", entity.Company));
                parameter.Add(new SqlParameter("Remark", entity.ApplicationName));
                parameter.Add(new SqlParameter("CreateBy", entity.CreateBy));
                parameter.Add(new SqlParameter("CreateTime", entity.CreateTime));
                parameter.Add(new SqlParameter("StartFileName", entity.StartFileName));

                int result = SqlHelper.ExecuteNonQuery(sqlStr, parameter.ToArray());

                if (result == 1)
                {
                    msg.data    = "";
                    msg.state   = "success";
                    msg.message = "新增成功!";


                    #region =====================写操作日志======================
                    C_S_Log log = new C_S_Log()
                    {
                        OperateType     = 4,        //新增
                        OperateUserId   = entity.CreateBy,
                        ApplicationId   = entity.ApplicationId,
                        ApplicationCode = entity.ApplicationCode,
                        Content         = "新增应用",
                        IPAddress       = Net.Ip,
                        MachineName     = Net.Host
                    };

                    CSLog_BLL.Add(log);
                    #endregion =================================================
                }
                else
                {
                    msg.data    = "";
                    msg.state   = "error";
                    msg.message = "新增失败!";
                }
            }
            return(msg);
        }
예제 #3
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public AjaxResult Add(C_S_AppVersion entity)
        {
            DataTable dt = SqlHelper.ExecuteDataTable("select * from C_S_Application where ApplicationId = @ApplicationId", new SqlParameter[] { new SqlParameter("ApplicationId", entity.ApplicationId) });

            entity.Create();
            AjaxResult msg    = new AjaxResult();
            string     sqlStr = @"INSERT INTO dbo.C_S_AppVersion(AppVersionId,ApplicationId,VersionCode,AppFileName,
                                     AppDirectory,AppSize,Remark,CreateBy,CreateTime)
                                VALUES  ( @AppVersionId , @ApplicationId , 
                                          @VersionCode ,  @AppFileName , 
                                          @AppDirectory ,  @AppSize , 
                                          @Remark ,  @CreateBy ,  @CreateTime)";

            SqlParameter[] parameter =
            {
                new SqlParameter("AppVersionId",  entity.AppVersionId),
                new SqlParameter("ApplicationId", entity.ApplicationId),
                new SqlParameter("VersionCode",   entity.VersionCode),
                new SqlParameter("AppFileName",   entity.AppFileName),
                new SqlParameter("AppDirectory",  entity.AppDirectory),
                new SqlParameter("AppSize",       entity.AppSize),
                new SqlParameter("Remark",        entity.Remark),
                new SqlParameter("CreateBy",      entity.CreateBy),
                new SqlParameter("CreateTime",    entity.CreateTime)
            };
            int result = SqlHelper.ExecuteNonQuery(sqlStr, parameter);

            if (result == 1)
            {
                msg.data    = "";
                msg.state   = "success";
                msg.message = "新增成功!";

                #region ===========记录操作日志=============
                C_S_Log log = new C_S_Log()
                {
                    OperateType     = 0,//上传
                    OperateUserId   = entity.CreateBy,
                    ApplicationId   = entity.ApplicationId,
                    Content         = "上传应用",
                    ApplicationCode = "",
                    IPAddress       = Net.Ip,
                    MachineName     = Net.Host
                };

                if (dt.Rows.Count > 0)
                {
                    log.ApplicationCode = dt.Rows[0]["ApplicationCode"].ToString();
                }

                CSLog_BLL.Add(log);
                #endregion =================================
            }
            else
            {
                msg.data    = "";
                msg.state   = "error";
                msg.message = "新增失败!";
            }
            return(msg);
        }
예제 #4
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="appVersionId"></param>
        /// <returns></returns>
        public AjaxResult Delete(string appVersionId)
        {
            AjaxResult msg = new AjaxResult();

            try
            {
                string         sqlStr1   = "select * from C_S_AppVersion where AppVersionId = @AppVersionId";
                SqlParameter[] parameter = { new SqlParameter("AppVersionId", appVersionId) };
                DataTable      dt        = SqlHelper.ExecuteDataTable(sqlStr1, parameter);

                if (dt.Rows.Count > 0)
                {
                    string applicationId = dt.Rows[0]["ApplicationId"].ToString();


                    DataTable dt_app = SqlHelper.ExecuteDataTable("select * from C_S_Application where ApplicationId = @ApplicationId", new SqlParameter[] { new SqlParameter("ApplicationId", applicationId) });

                    //先删除版本文件数据再删除应用版本数据
                    string sqlStr = @"delete C_S_VersionFile where AppVersionId = @AppVersionId
                                      ;delete C_S_AppVersion where AppVersionId = @AppVersionId";

                    string path = dt.Rows[0]["AppDirectory"].ToString();

                    SqlParameter[] parameter1 = { new SqlParameter("AppVersionId", appVersionId) };

                    int result = SqlHelper.ExecuteNonQuery(sqlStr, parameter1);

                    if (result > 0)
                    {
                        msg.data    = "";
                        msg.state   = "success";
                        msg.message = "删除成功!";

                        #region ===========记录操作日志=================
                        C_S_Log log = new C_S_Log()
                        {
                            OperateType     = 3,//移除
                            OperateUserId   = OperatorProvider.Provider.GetCurrent().UserName,
                            ApplicationId   = applicationId,
                            Content         = "删除版本",
                            ApplicationCode = "",
                            IPAddress       = Net.Ip,
                            MachineName     = Net.Host
                        };

                        if (dt.Rows.Count > 0)
                        {
                            log.ApplicationCode = dt_app.Rows[0]["ApplicationCode"].ToString();
                        }
                        CSLog_BLL.Add(log);
                        #endregion ======================================
                    }
                    else
                    {
                        msg.data    = "";
                        msg.state   = "error";
                        msg.message = "删除失败!";
                    }
                }
                else
                {
                    msg.data    = "";
                    msg.state   = "success";
                    msg.message = "已删除";
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
                msg.data    = "";
                msg.state   = "error";
                msg.message = "删除失败,程序发生异常!";
            }

            return(msg);
        }