Exemple #1
0
        /// <summary>
        /// 删除文件夹
        /// </summary>
        /// <param name="motherPathName"></param>
        /// <returns></returns>
        public string DeleteFolder(string motherPathName)
        {
            string r = "无效操作";

            try
            {
                string iniPath  = System.AppDomain.CurrentDomain.BaseDirectory + "/HR_Models.ini";
                Ini    ini      = new Ini(iniPath);
                string tempPath = ini.ReadValue("root", "UserRootPath") + PublicClassRule.JieXiMuLu(motherPathName);//解析目录
                //已经有路径了,再查一下该文件夹是否正在使用中
                bool isUsing = false;
                for (int i = 0; i < YingHeXinList.Count; i++)
                {
                    if (YingHeXinList[i].CopyModel_To_TargetPath == tempPath)
                    {
                        isUsing = true;
                        break;
                    }
                }
                if (isUsing)
                {
                    r = "该模型正在被使用,请停止试验后再试。";
                }
                else
                {
                    r = PublicClassTools.Delete(tempPath);
                }
            }
            catch (Exception)
            {
                r = "文件夹名称解析异常";
            }

            return(r);
        }
Exemple #2
0
        /// <summary>
        /// 直接向文件夹中传文件
        /// </summary>
        /// <param name="motherPathName"></param>
        /// <param name="data"></param>
        /// <param name="fileName"></param>
        /// <returns></returns>
        //public string UpLoad_Mfile(string motherPathName, byte[] data, string fileName)
        //{
        //    string r = "无效操作";

        //    string iniPath = System.AppDomain.CurrentDomain.BaseDirectory + "/HR_Models.ini";
        //    Ini ini = new Ini(iniPath);
        //    string tempPath = ini.ReadValue("root", "UserRootPath") + PublicClassRule.JieXiMuLu(motherPathName);//解析目录

        //    string path = string.Format(@"{0}\{1}", tempPath/*,DateTime.Now.ToString("yyyyMMddHHmmss")*/, fileName);
        //    bool r2 = FileHelper.ByteToFile(data, path);
        //    if (r2)
        //    {
        //        r = "上传成功";

        //    }
        //    else
        //    {
        //        r = "上传失败";
        //    }

        //    return r;
        //}



        /// <summary>
        /// 下载文件
        /// </summary>
        /// <param name="motherPathName"></param>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public byte[] DownLoad_Mfile(string motherPathName, string fileName)
        {
            string r = "无效操作";

            try
            {
                string iniPath  = System.AppDomain.CurrentDomain.BaseDirectory + "/HR_Models.ini";
                Ini    ini      = new Ini(iniPath);
                string tempPath = ini.ReadValue("root", "UserRootPath") + PublicClassRule.JieXiMuLu(motherPathName);//解析目录
                //已经有路径了,再查一下该文件夹是否正在使用中
                //拼接文件完整路径
                string fullfilename = string.Format("{0}{1}", tempPath, fileName);
                return(FileHelper.FileToByte(fullfilename));
            }
            catch (Exception)
            {
                r = "文件夹名称解析异常";
            }

            return(null);
        }
Exemple #3
0
        /// <summary>
        /// 通过自身初始化设置,根据创建类型,分配相关路径
        /// 【注意】文件夹规则设计
        /// UID1336/1336_20191212131356NEW   这是某个用户的新建试验   也可以用这个复盘
        /// UID1336/1336_20191212131356From1222_20191111111213New  这是1336号用户从1222号用户拿取11月11日创建的试验
        /// </summary>
        /// <param name="self">一条消息</param>
        /// <param name="motherPathName">被查看的目录名称</param>
        public static void Self_Make_Path(ref ManagerMessage self, string motherPathName)
        {
            switch (self.CreateType)
            {
            case ShiYanCreateType.New:
            {
                self.SourceModelPath = ini.ReadValue(self.HR_Make_ID.ToString(), "path");        //从配置文件中读取
                if (self.SourceModelPath == "")
                {
                    //读出来是空格,说明没找到这个配置。如果这里不报错,下面就会把我们所有的试验都复制过去给这个用户了。
                    throw new Exception("无此试验模型配置");
                }
                self.CopyModel_To_TargetPath = string.Format("UID{0}/{0}_{1}New/", self.UID, DateTime.Now.ToString("yyyyMMddHHmmss"));         //文件夹copy规则
                //补充完成:
                self.SourceModelPath         = ini.ReadValue("root", "ModelRootPath") + self.SourceModelPath;
                self.CopyModel_To_TargetPath = ini.ReadValue("root", "UserRootPath") + self.CopyModel_To_TargetPath;


                //只有需要复制文件时做这个判断
                if (!System.IO.Directory.Exists(self.SourceModelPath))
                {
                    throw new Exception("没找到原模型路径");
                }
            }
            break;

            case ShiYanCreateType.ReView:
            {
                if (self.UID == self.Look_Other_UID)
                {
                    //自己看自己
                    if (motherPathName == "" || motherPathName == null)
                    {
                        throw new Exception("母文件夹无效");
                    }
                    self.CopyModel_To_TargetPath = JieXiMuLu(motherPathName);        //解析目录
                    //补充完成:
                    self.CopyModel_To_TargetPath = ini.ReadValue("root", "UserRootPath") + self.CopyModel_To_TargetPath;
                }
                else
                {
                    //不是自己看自己
                    throw new Exception("复盘试验时:UID与Look_Other_UID不一致");
                }

                //不需要复制,但要看看自己的文件在不在
                if (!System.IO.Directory.Exists(self.CopyModel_To_TargetPath))
                {
                    throw new Exception("没找到自己的试验模型数据路径");
                }
            }
            break;

            case ShiYanCreateType.LookOthers:
            {
                if (self.SourceModelPath == "" || self.SourceModelPath == null)
                {
                    throw new Exception("母文件夹无效");
                }
                self.SourceModelPath         = JieXiMuLu(motherPathName);//解析目录
                self.CopyModel_To_TargetPath = string.Format(@"UID{0}/{0}_{1}_From_{2}/", self.UID, DateTime.Now.ToString("yyyyMMddHHmmss"), self.SourceModelPath.Split('/')[1]);
                //补充完成:
                self.SourceModelPath         = ini.ReadValue("root", "UserRootPath") + self.SourceModelPath;
                self.CopyModel_To_TargetPath = ini.ReadValue("root", "UserRootPath") + self.CopyModel_To_TargetPath;

                //只有需要复制文件时做这个判断
                if (!System.IO.Directory.Exists(self.SourceModelPath))
                {
                    throw new Exception("没找到原模型路径");
                }
            }
            break;

            default:
                break;
            }
        }