Ejemplo n.º 1
0
        public bool ConfirmSentSuccess(List <string> userMessaeQueueItemIDs)
        {
            if (userMessaeQueueItemIDs == null)
            {
                throw new ArgumentNullException("userMessaeQueueItemIDs");
            }
            var db = new MongoDbProvider <UserMessageQueueItem>();

            db.Delete(n => userMessaeQueueItemIDs.Any(m => n.Id == m) && n.State == AppSyncDataStateEnum.Sent);
            return(true);
        }
        public bool DeleteSceneItem(string sceneItemID)
        {
            try
            {
                if (string.IsNullOrEmpty(sceneItemID))
                {
                    throw new KnownException("id为空,无法删除!");
                }
                var mgdb      = new MongoDbProvider <SceneItem>();
                var sceneItem = mgdb.GetAll(o => o.Id == sceneItemID).FirstOrDefault();
                if (null == sceneItem)
                {
                    return(true);
                }
                else if (sceneItem.Status == ItemStatus.Final)
                {
                    throw new KnownException("已经归档,不能删除!");
                }

                //  如果有图片,需要删除图片
                if (null != sceneItem.Images)
                {
                    foreach (var image in sceneItem.Images)
                    {
                        mgdb.DeleteFileByName(image.OriginalPicture, PictureDbName);
                        mgdb.DeleteFileByName(image.ThumbnailPicture, PictureDbName);
                    }
                }
                mgdb.Delete(sceneItemID);

                using (var db = new BCEnterpriseContext())
                {
                    var scene = db.Scenes.First(o => o.SceneID == sceneItem.SceneID);
                    if (scene.HasData && (null == mgdb.GetByCondition(o => o.SceneID == sceneItem.SceneID)))
                    {
                        scene.HasData = false;
                    }
                    db.SaveChanges();
                }
                return(Send2MsmqAsDelete(sceneItemID, OperationEnum.Deleted, sceneItem.SceneID));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }