Пример #1
0
        public override void Delete(long objectId)
        {
            using (IDAL dal = this.DAL)
            {
                dal.BeginTransaction();
                try
                {
                    ProductionOrder po = dal.Read <ProductionOrder>(objectId);

                    // Kill process via ProcessOperations
                    if (po.ProcessInstance != null)
                    {
                        ProcessOperations processOperations = new ProcessOperations(OTApplication.Context.User.Id);
                        if (processOperations.GetInstanceStatus(po.ProcessInstance.Value) != Overtech.Core.BPM.InstanceStatus.Canceled)
                        {
                            try
                            {
                                processOperations.Cancel(po.ProcessInstance.Value);
                            }
                            catch
                            {
                                throw;
                            }
                        }
                    }
                    dal.Delete <ProductionOrder>(objectId);
                    dal.CommitTransaction();
                }
                catch
                {
                    dal.RollbackTransaction();
                    throw;
                }
            }
        }
Пример #2
0
        public void DeleteNotificationUsers(IEnumerable <DataModels.Announcement.NotificationUser> notificationUsers, IDAL dal)
        {
            foreach (DataModels.Announcement.NotificationUser notUser in notificationUsers)
            {
                // Kill process via ProcessOperations
                if (notUser.ProcessInstance != null)
                {
                    ProcessOperations processOperations = new ProcessOperations(OTApplication.Context.User.Id);
                    if (processOperations.GetInstanceStatus(notUser.ProcessInstance.Value) != Overtech.Core.BPM.InstanceStatus.Canceled)
                    {
                        try
                        {
                            processOperations.Cancel(notUser.ProcessInstance.Value);
                        }
                        catch {}
                    }
                }

                // Delete NotificationUser
                IUniParameter prmNotification = dal.CreateParameter("Notification", notUser.Notification);
                IUniParameter prmUser         = dal.CreateParameter("User", notUser.User);
                dal.ExecuteNonQuery("ANN_DEL_NOTIFICATIONUSER_SP", prmNotification, prmUser);
            }
        }