/// <summary>
        /// 设备关闭
        /// </summary>
        public override void Close()
        {
            if (Device == null || Device.Parts.Count == 0)
            {
                return;
            }

            try
            {
                // 卸载装载分区句柄
                foreach (var part in Device.Parts)
                {
                    var fpart = (FileSystemPartition)part;
                    if (fpart.Mount != IntPtr.Zero)
                    {
                        IntPtr mount    = fpart.Mount;
                        var    nodelist = fpart.NodeLinkList;
                        FileServiceCoreDll.DisposeLinkTableRoom(mount, ref nodelist);
                        MirrorCoreDll.UnmountPartitionHandle(ref mount);
                        fpart.Mount = IntPtr.Zero;

                        LoggerManagerSingle.Instance.Info(string.Format("卸载分区并释放节点链表空间(名称:{0},描述:{1},大小:{2},Mount:{3})", fpart.Name, fpart.Discription, fpart.Size, fpart.Mount));
                    }
                }
                // 释放设备打开句柄
                MirrorCoreDll.CloseDevice(Device.Handle);
                LoggerManagerSingle.Instance.Info(string.Format("关闭设备(名称:{0},大小:{1},Handle:{2})成功", Device.Name, Device.Size, Device.Handle));
            }
            catch (Exception ex)
            {
                LoggerManagerSingle.Instance.Error(string.Format("关闭设备时出错(名称:{0},大小:{1},Handle:{2})时出现错误, 信息:{3}", Device.Name, Device.Size, Device.Handle, ex.Message));
            }
        }
示例#2
0
        /// <summary>
        /// 设备关闭
        /// </summary>
        public override void Close()
        {
            if (null == this.Device || null == this.Device.Parts || this.Device.Parts.Count == 0)
            {
                return;
            }
            // 卸载装载分区句柄
            foreach (var part in this.Device.Parts)
            {
                var fpart = (FileSystemPartition)part;
                if (fpart.Mount != IntPtr.Zero)
                {
                    //LogHelper.Info(string.Format(LanguageHelper.Get("LANGKEY_XieZaiFenQuBingShiFangJieDianL_04948"), fpart.Name, fpart.Discription, fpart.Size, fpart.Mount));
                    IntPtr mount    = fpart.Mount;
                    var    nodelist = fpart.NodeLinkList;
                    FileServiceCoreDll.DisposeLinkTableRoom(mount, ref nodelist);
                    MirrorCoreDll.UnmountPartitionHandle(ref mount);
                    fpart.Mount = IntPtr.Zero;
                }
            }
            // 卸载设备句柄
            IntPtr handle = this.Device.Handle_Flsh;

            FileServiceCoreDll.UnmountDeviceHandle(ref handle);
            //LogHelper.Info(string.Format(LanguageHelper.Get("LANGKEY_XieZaiSheBeiJuBingMingChengDaX_04949"), Device.Name, Device.Size, Device.Handle_Flsh));
            // 释放设备句柄
            MirrorCoreDll.CloseDevice(this.Device.Handle);
            //LogHelper.Info(string.Format(LanguageHelper.Get("LANGKEY_ShiFangSheBeiJuBingMingChengDa_04950"), Device.Name, Device.Size, Device.Handle));
        }
        /// <summary>
        /// 停止当前工作
        /// </summary>
        public override void Stop()
        {
            base.Stop();
            if (RunPartition == null)
            {
                return;
            }
            try
            {
                FileServiceCoreDll.Stop(RunPartition.Mount);
                if (RunPartition.Mount != IntPtr.Zero)
                {
                    LoggerManagerSingle.Instance.Error(string.Format("停止操作并卸载分区(名称:{0},描述:{1},大小:{2},Mount:{3})", RunPartition.Name,
                                                                     RunPartition.Discription, RunPartition.Size, RunPartition.Mount));

                    IntPtr mount    = RunPartition.Mount;
                    var    nodelist = RunPartition.NodeLinkList;
                    int    result   = FileServiceCoreDll.DisposeLinkTableRoom(mount, ref nodelist);
                    MirrorCoreDll.UnmountPartitionHandle(ref mount);
                    if (result == 0)
                    {
                        LoggerManagerSingle.Instance.Error(string.Format("释放目录文件节点链表空间(不会释放自己定义的顶层节点空间)(名称:{0},描述:{1},大小:{2},Mount:{3})成功,错误码:{4},卸载分区", RunPartition.Name, RunPartition.Discription, RunPartition.Size, RunPartition.Mount, result));
                    }
                    else
                    {
                        LoggerManagerSingle.Instance.Error(string.Format("释放目录文件节点链表空间(不会释放自己定义的顶层节点空间)(名称:{0},描述:{1},大小:{2},Mount:{3})失败,错误码:{4},卸载分区", RunPartition.Name, RunPartition.Discription, RunPartition.Size, RunPartition.Mount, result));
                    }
                }
            }
            catch (Exception ex)
            {
                LoggerManagerSingle.Instance.Error(string.Format("停止分区(名称:{0},描述:{1},大小:{2},Mount:{3})时出现错误, 信息:{4}", RunPartition.Name, RunPartition.Discription, RunPartition.Size, RunPartition.Mount, ex.Message));
            }
            finally
            {
                RunPartition.Mount = IntPtr.Zero;
                _isStop            = true;
            }
        }