示例#1
0
        /// <summary>
        /// 删除RefTable表指定Article_Id的字段值记录
        /// </summary>
        /// <param name="page">当前页面指针</param>
        /// <param name="id">记录的主键值</param>
        public void DeleteByArticle_Id(Page page, int[] id)
        {
            if (id == null)
            {
                return;
            }
            //将数组转为逗号分隔的字串
            var str = string.Join(",", id);

            //设置Sql语句
            var sql = string.Format("delete from {0} where {1} in ({2})", RefTableTable.TableName, RefTableTable.Article_Id, id);

            //删除
            var delete = new DeleteHelper();

            delete.Delete(sql);

            //判断是否启用缓存
            if (CommonBll.IsUseCache())
            {
                var ids = id.ToList();
                foreach (var i in ids)
                {
                    //删除缓存
                    DelCache(x => x.Article_Id == i);
                }
            }

            //添加用户操作记录
            CommonBll.WriteLog("{0}删除了RefTable表Article_Id值为【" + str + "】的记录!");
            //UseLogBll.GetInstence().Save(page, "{0}删除了RefTable表Article_Id值为【" + str + "】的记录!");
        }
示例#2
0
        /// <summary>
        /// 删除ErrorLog表记录
        /// </summary>
        /// <param name="page">当前页面指针</param>
        /// <param name="id">记录的主键值</param>
        /// <param name="isAddUseLog">是否添加用户操作日志</param>
        public override void Delete(Page page, int[] id, bool isAddUseLog = true)
        {
            if (id == null)
            {
                return;
            }
            //将数组转为逗号分隔的字串
            var str = string.Join(",", id);

            //设置Sql语句
            var sql = string.Format("delete from {0} where {1} in ({2})", ErrorLogTable.TableName, ErrorLogTable.Id, str);

            //删除
            var delete = new DeleteHelper();

            delete.Delete(sql);

            //判断是否启用缓存
            if (CommonBll.IsUseCache())
            {
                //删除缓存
                DelCache(id.ToList());
            }

            if (isAddUseLog)
            {
                //添加用户操作记录
                UseLogBll.GetInstence().Save(page, "{0}删除了ErrorLog表id为【" + str + "】的记录!");
            }
        }
示例#3
0
        public void DeleteHelper_Delete_WhenNullPath_ExpectFalse()
        {
            //------------Setup for test--------------------------

            //------------Execute Test---------------------------
            var result = DeleteHelper.Delete(null);

            //------------Assert Results-------------------------
            Assert.IsFalse(result);
        }
示例#4
0
        public virtual void DeleteItem(object sender, EventArgs e)
        {
            if (ActiveHandler == null || ActiveHandler.TargetObject == null)
            {
                return;
            }

            DeleteHelper.Delete(ActiveHandler.TargetObject);
            ItemDeleted(this, EventArgs.Empty);
        }
        public void Delete(string order_id)
        {
            //设置Sql语句
            var sql = string.Format("delete from {0} where {1} = '{2}'", ORDER01Table.TableName, ORDER01Table.ORDER_ID, order_id);

            //删除
            var delete = new DeleteHelper();

            delete.Delete(sql);
        }
        /// <summary>
        /// Delete the current member
        /// </summary>
        /// <param name="sender">Event sender</param>
        /// <param name="e">Event parameters</param>
        protected virtual void DeleteMember(object sender, EventArgs e)
        {
            IHandler handler = PluginFactory.GetInstance().Package.ActiveHandler;

            if (handler != null && handler.TargetObject != null)
            {
                DeleteHelper.Delete(handler.TargetObject);
                OnItemDeleted();
            }
        }
示例#7
0
        public async Task <IActionResult> OnPostAsync()
        {
            MarkovModel = await MarkovModels.FindAsync(Id);

            if (MarkovModel == null)
            {
                return(NotFound());
            }

            await DeleteHelper.Delete(MarkovModel);

            return(RedirectToPage("/Analysis/Markov/Index", new { Id = MarkovModel.AssignmentId }));
        }
示例#8
0
        public void Delete(IToolContext context)
        {
            lock (context.Renderer.Selected)
            {
                DeleteHelper.Delete(context.CurrentContainer, context.Renderer);

                this.DeHover(context);
                context.Renderer.Selected.Clear();

                context.Invalidate?.Invoke();

                this.CurrentState = State.None;
            }
        }
        public async Task <IActionResult> OnPostAsync()
        {
            Assignment = await PreAssignments.FindAsync(Id);

            if (Assignment == null)
            {
                return(NotFound());
            }

            var courseId = Assignment.CourseClassId;

            await DeleteHelper.Delete(Assignment);

            return(RedirectToPage("/CourseClasses/Details", new { id = courseId }));
        }
示例#10
0
        public bool Delete(IActivityIOPath src)
        {
            bool result;

            try
            {
                if (!RequiresAuth(src))
                {
                    // We need sense check the value passed in ;)
                    result = DeleteHelper.Delete(src.Path);
                }
                else
                {
                    // handle UNC path
                    SafeTokenHandle safeTokenHandle;
                    bool            loginOk = LogonUser(ExtractUserName(src), ExtractDomain(src), src.Password, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, out safeTokenHandle);

                    if (loginOk)
                    {
                        using (safeTokenHandle)
                        {
                            WindowsIdentity newID = new WindowsIdentity(safeTokenHandle.DangerousGetHandle());
                            using (WindowsImpersonationContext impersonatedUser = newID.Impersonate())
                            {
                                // Do the operation here

                                result = DeleteHelper.Delete(src.Path);


                                // remove impersonation now
                                impersonatedUser.Undo();
                            }
                        }
                    }
                    else
                    {
                        // login failed
                        throw new Exception(string.Format(ErrorResource.FailedToAuthenticateUser, src.Username, src.Path));
                    }
                }
            }
            catch (Exception ex)
            {
                Dev2Logger.Error("Error getting file: " + src.Path, ex);
                result = false;
            }
            return(result);
        }
示例#11
0
        public bool Delete(IActivityIOPath src)
        {
            bool result;

            try
            {
                if (!RequiresAuth(src))
                {
                    // We need sense check the value passed in ;)
                    result = DeleteHelper.Delete(src.Path);
                }
                else
                {
                    // handle UNC path
                    SafeTokenHandle safeTokenHandle;
                    bool            loginOk = LogonUser(ExtractUserName(src), ExtractDomain(src), src.Password, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, out safeTokenHandle);

                    if (loginOk)
                    {
                        using (safeTokenHandle)
                        {
                            WindowsIdentity newID = new WindowsIdentity(safeTokenHandle.DangerousGetHandle());
                            using (WindowsImpersonationContext impersonatedUser = newID.Impersonate())
                            {
                                // Do the operation here

                                result = DeleteHelper.Delete(src.Path);


                                // remove impersonation now
                                impersonatedUser.Undo();
                            }
                        }
                    }
                    else
                    {
                        // login failed
                        throw new Exception("Failed to authenticate with user [ " + src.Username + " ] for resource [ " + src.Path + " ] ");
                    }
                }
            }
            catch (Exception)
            {
                //File is not found problem during delete
                result = false;
            }
            return(result);
        }
示例#12
0
 public override bool ExecuteOperation()
 {
     try
     {
         if (ImpersonatedUser != null)
         {
             return(ExecuteOperationWithAuth());
         }
         return(DeleteHelper.Delete(_path.Path));
     }
     catch (Exception exception)
     {
         Dev2Logger.Error("Error getting file: " + _path.Path, exception, GlobalConstants.WarewolfError);
         return(false);
     }
 }
示例#13
0
 public override bool ExecuteOperationWithAuth()
 {
     using (ImpersonatedUser)
     {
         try
         {
             return(DeleteHelper.Delete(_path.Path));
         }
         catch (Exception ex)
         {
             Dev2Logger.Error(ex.Message, GlobalConstants.Warewolf);
             return(false);
         }
         finally
         {
             ImpersonatedUser?.Undo();
         }
     }
 }
        /// <summary>
        /// 删除UseLog表指定MenuInfo_Id的字段值记录
        /// </summary>
        /// <param name="page">当前页面指针</param>
        /// <param name="id">记录的主键值</param>
        public void DeleteByMenuInfo_Id(Page page, int id)
        {
            //设置Sql语句
            var sql = string.Format("delete from {0} where {1} = {2}", UseLogTable.TableName, UseLogTable.MenuInfo_Id, id);

            //删除
            var delete = new DeleteHelper();

            delete.Delete(sql);

            //判断是否启用缓存
            if (CommonBll.IsUseCache())
            {
                //删除缓存
                DelCache(x => x.MenuInfo_Id == id);
            }

            //添加用户操作记录
            UseLogBll.GetInstence().Save(page, "{0}删除了UseLog表MenuInfo_Id值为【" + id + "】的记录!");
        }
示例#15
0
        /// <summary>
        /// 删除RefTable表指定Article_Id的字段值记录
        /// </summary>
        /// <param name="page">当前页面指针</param>
        /// <param name="id">记录的主键值</param>
        public void DeleteByArticle_Id(Page page, int id)
        {
            //设置Sql语句
            var sql = string.Format("delete from {0} where {1} = {2}", RefTableTable.TableName, RefTableTable.Article_Id, id);

            //删除
            var delete = new DeleteHelper();

            delete.Delete(sql);

            //判断是否启用缓存
            if (CommonBll.IsUseCache())
            {
                //删除缓存
                DelCache(x => x.Article_Id == id);
            }

            //添加用户操作记录
            CommonBll.WriteLog("{0}删除了RefTable表Article_Id值为【" + id + "】的记录!");
            //UseLogBll.GetInstence().Save(page, "{0}删除了RefTable表Article_Id值为【" + id + "】的记录!");
        }
		/// <summary>
		/// 删除V_TAKEIN11_PRODUCT00表记录
		/// </summary>
		/// <param name="page">当前页面指针</param>
		/// <param name="id">记录的主键值</param>
		/// <param name="isAddUseLog">是否添加用户操作日志</param>
		public override void Delete(Page page, int id, bool isAddUseLog = true) 
		{
			//设置Sql语句
			var sql = string.Format("delete from {0} where {1} = {2}", V_TAKEIN11_PRODUCT00Table.TableName,  V_TAKEIN11_PRODUCT00Table.Id, id);

			//删除
			var delete = new DeleteHelper();
		    delete.Delete(sql);
			
			//判断是否启用缓存
            if (CommonBll.IsUseCache())
            {
                //删除缓存
                DelCache(id);
            }
			
			if (isAddUseLog)
		    {
				//添加用户操作记录
				UseLogBll.GetInstence().Save(page, "{0}删除了V_TAKEIN11_PRODUCT00表id为【" + id + "】的记录!");
			}
		}
示例#17
0
        public void DeleteHelper_Delete_WhenPathContainsStar_ExpectTrue()
        {
            //------------Setup for test--------------------------
            var tmpPath = Path.GetTempPath() + Guid.NewGuid();

            Directory.CreateDirectory(tmpPath);
            File.Create(tmpPath + "\\a.txt").Close();
            Directory.CreateDirectory(tmpPath + "\\b");

            //------------Execute Test---------------------------
            var result = DeleteHelper.Delete(tmpPath + "\\*.*");

            var dirStillExit = Directory.Exists(tmpPath);
            var contents     = Directory.GetFiles(tmpPath);

            Cleanup(tmpPath);

            //------------Assert Results-------------------------
            Assert.IsTrue(result);
            Assert.IsTrue(dirStillExit);
            Assert.AreEqual(0, contents.Length);
        }
示例#18
0
        /// <summary>
        /// 删除WebConfig表所有记录
        /// </summary>
        /// <param name="page">当前页面指针</param>
        /// <param name="isAddUseLog">是否添加用户操作日志</param>
        public void DeleteAll(Page page, bool isAddUseLog = true)
        {
            //设置Sql语句
            var sql = string.Format("delete from {0}", WebConfigTable.TableName);

            //删除
            var delete = new DeleteHelper();

            delete.Delete(sql);

            //判断是否启用缓存
            if (CommonBll.IsUseCache())
            {
                //清空当前表所有缓存记录
                DelAllCache();
            }

            if (isAddUseLog)
            {
                //添加用户操作记录
                UseLogBll.GetInstence().Save(page, "{0}删除了WebConfig表所有记录!");
            }
        }
示例#19
0
        /// <summary>
        /// 删除Article表记录
        /// </summary>
        /// <param name="page">当前页面指针</param>
        /// <param name="id">记录的主键值</param>
        /// <param name="isAddUseLog">是否添加用户操作日志</param>
        public void Delete(Page page, int id, bool isAddUseLog = true)
        {
            //设置Sql语句
            var sql = string.Format("delete from {0} where {1} = {2}", ArticleTable.TableName, ArticleTable.Id, id);

            //删除
            var delete = new DeleteHelper();

            delete.Delete(sql);

            //判断是否启用缓存
            if (CommonBll.IsUseCache())
            {
                //删除缓存
                DelCache(id);
            }

            if (isAddUseLog)
            {
                //添加用户操作记录
                CommonBll.WriteLog("{0}删除了Article表id为【" + id + "】的记录!");
                //UseLogBll.GetInstence().Save(page, "{0}删除了Article表id为【" + id + "】的记录!");
            }
        }