/// <summary>
        /// 创建报告
        /// </summary>
        /// <param name="tigerPath">目标路径</param>
        /// <returns></returns>
        public Result CreatReport(string tigerPath)
        {
            return(RunFun(logpath =>
            {
                tigerPath = ToolFile.GetAbsolutelyPath(tigerPath);

                string modthPath = ToolFile.GetUpIndex(base.ModelPath, 1) + "Custom\\宝龙-满意度版块PDF的副本.rdl";

                string sqlStr = @"
                     Select distinct r.FormReportItemID,c.Text
                    From AskForm_FormReportItemParam r 
                    INNER JOIN AskForm_Choice c ON c.ChoiceID = r.[Value]
                    Where 
	                    r.CompanyID=@CompanyID And r.FormApplicationID =@FormApplicationID
                      And r.IsDeleted=0";

                DataTable dt = DbContent.GetTable(GetSqlParam() + sqlStr);

                foreach (DataRow dr in dt.Rows)
                {
                    ReportParameterCollection reportParameters = new ReportParameterCollection
                    {
                        new ReportParameter("CompanyID", @CompanyID),
                        new ReportParameter("FormApplicationID", FormApplicationID),
                        new ReportParameter("FormID", FormID),
                        new ReportParameter("MinValue", "0"),
                        new ReportParameter("ReportTitle", "板块报告"),
                        new ReportParameter("FormReportItemID", dr["FormReportItemID"] + "")
                    };

                    ToolReport.GenerateLocalReport(modthPath, tigerPath, dr["Text"] + ".pdf", reportParameters, true);
                }
                return Res;
            }));
        }
Exemple #2
0
        /// <summary>
        /// 检查报告是否全部生成
        /// </summary>
        /// <param name="tigerPath"></param>
        /// <param name="formId"></param>
        /// <returns></returns>
        public Result CheckReportIsAll(string tigerPath, long formId)
        {
            return(RunFun(logPath =>
            {
                tigerPath = ToolFile.GetAbsolutelyPath(tigerPath);

                List <FileInfo> list = new DirectoryInfo(tigerPath).GetFiles().ToList();

                DataRow dr = GetFormInfo(formId);

                DataTable dt = DbContent.GetTable(string.Format(GetObservedList(), dr["CompanyID"] + "", dr["FormApplicationID"] + ""));

                WriteLog(logPath, "共" + dt.Rows.Count + "人");

                foreach (DataRow item in dt.Rows)
                {
                    string name = item["FullName"] + "_" + item["EntryID"];
                    if (!list.Exists(c => c.Name.Contains(name)))
                    {
                        WriteLog(logPath, name);
                    }
                }
                return Res;
            }));
        }
Exemple #3
0
        public override void ToMachining(double AssociatedDist, ToolFile toolFile)
        {
            Machinings.Sawing sawing = new Machinings.Sawing();

            sawing.Part = this.Part;

            if (this.FaceNumber == 5)
            {
                sawing.OnFace5 = true;
            }
            else if (this.FaceNumber == 6)
            {
                sawing.OnFace5 = false;
            }

            sawing.StartX     = this.StartX;
            sawing.StartY     = this.StartY;
            sawing.StartDepth = this.StartDepth;
            sawing.EndX       = this.EndX;
            sawing.EndY       = this.EndY;
            sawing.EndDepth   = this.EndDepth;
            sawing.ToolName   = this.ToolName;
            sawing.IsDrawOnly = this.IsDrawOnly;
            sawing.ToolComp   = this.ToolComp;

            Part.Sawings.Add(sawing);
        }
Exemple #4
0
        public override void ToMachining(double AssociatedDist, ToolFile toolFile)
        {
            //FindAssociatedFaces(AssociatedDist + this.GapDist);

            //PartFace pf = this.Part.GetPartFaceByNumber(FaceNumber);

            //if (pf.AssociatedPartFaces.Count != 0)//数量不为0,说明有关联的板件
            //{
            //    double totolDist = DistToBottom + DistToTop;
            //    int number = (int)(totolDist / DistBetweenTwoHoles);
            //    for (int i = 0; i < number; i++)
            //    {
            //        foreach (PartFace f in pf.AssociatedPartFaces)
            //        {
            //            if (f.IsHorizontalFace)//不对水平面处理
            //                continue;


            //            //TODO:关于生成的孔的排列
            //            /*
            //             * 1、无论层板如何旋转,计算上下时总是按未位移旋转时的下平面为基准
            //             * 2、排列时,无论本身如何旋转,在加工板件上总是竖直平行于板件的一边
            //             * 3、平行的难点:是平行于长边,还是平行于短边?
            //             *
            //             */


            //            double firstPointX = GetFirstPointX();
            //            double firstPointY = GetFirstPointY();
            //            double firstPointZ = DistToBottom - i * DistBetweenTwoHoles;
            //            //firstPointZ = -Part.Thickness - DistToBottom + i * DistBetweenTwoHoles;
            //            Point3d holeposition = new Point3d(firstPointX, firstPointY, firstPointZ);

            //            holeposition = holeposition.TransformBy(Matrix3d.AlignCoordinateSystem(new Point3d(),
            //                                                                                               Vector3d.XAxis,
            //                                                                                               Vector3d.YAxis,
            //                                                                                               Vector3d.ZAxis,
            //                                                                                               Part.MPPoint,
            //                                                                                               Part.MPXAxis,
            //                                                                                               Part.MPYAxis,
            //                                                                                               Part.MPZAxis));
            //            holeposition = Math.MathHelper.GetRotatedAndMovedPoint(holeposition, Part.TXRotation, Part.YRotation, Part.ZRotation, Part.CenterVector);
            //            holeposition = holeposition.TransformBy(Matrix3d.AlignCoordinateSystem(f.Part.MovedMPPoint,
            //                                                                                   f.Part.MovedMPXAxis,
            //                                                                                   f.Part.MovedMPYAxis,
            //                                                                                   f.Part.MovedMPZAxis,
            //                                                                                   new Point3d(),
            //                                                                                   Vector3d.XAxis,
            //                                                                                   Vector3d.YAxis,
            //                                                                                   Vector3d.ZAxis));
            //            double dimx = holeposition.X;
            //            double dimy = holeposition.Y;

            //            VDrilling vdrill = new VDrilling(f.FaceNumber, dimx, dimy, this.FaceHoleDiameter, this.FaceHoleDepth, f.Part);
            //            f.Part.VDrillings.Add(vdrill);
            //        }
            //    }
            //}
        }
        public override void ToMachining(double AssociatedDist, ToolFile toolFile)
        {
            //FindAssociatedFaces(AssociatedDist + this.GapDist);

            //PartFace pf = this.Part.GetPartFaceByNumber(FaceNumber);

            //if (pf.AssociatedPartFaces.Count != 0)//数量不为0,说明有关联的板件
            //{
            //    double totolDist = DistToBottom + DistToTop;
            //    int number = (int)(totolDist / DistBetweenTwoHoles);
            //    for (int i = 0; i < number; i++)
            //    {
            //        foreach (PartFace f in pf.AssociatedPartFaces)
            //        {
            //            if (f.IsHorizontalFace)//不对水平面处理
            //                continue;


            //            //TODO:关于生成的孔的排列
            //            /*
            //             * 1、无论层板如何旋转,计算上下时总是按未位移旋转时的下平面为基准
            //             * 2、排列时,无论本身如何旋转,在加工板件上总是竖直平行于板件的一边
            //             * 3、平行的难点:是平行于长边,还是平行于短边?
            //             * 
            //             */


            //            double firstPointX = GetFirstPointX();
            //            double firstPointY = GetFirstPointY();
            //            double firstPointZ = DistToBottom - i * DistBetweenTwoHoles;
            //            //firstPointZ = -Part.Thickness - DistToBottom + i * DistBetweenTwoHoles;
            //            Point3d holeposition = new Point3d(firstPointX, firstPointY, firstPointZ);

            //            holeposition = holeposition.TransformBy(Matrix3d.AlignCoordinateSystem(new Point3d(),
            //                                                                                               Vector3d.XAxis,
            //                                                                                               Vector3d.YAxis,
            //                                                                                               Vector3d.ZAxis,
            //                                                                                               Part.MPPoint,
            //                                                                                               Part.MPXAxis,
            //                                                                                               Part.MPYAxis,
            //                                                                                               Part.MPZAxis));
            //            holeposition = Math.MathHelper.GetRotatedAndMovedPoint(holeposition, Part.TXRotation, Part.YRotation, Part.ZRotation, Part.CenterVector);
            //            holeposition = holeposition.TransformBy(Matrix3d.AlignCoordinateSystem(f.Part.MovedMPPoint,
            //                                                                                   f.Part.MovedMPXAxis,
            //                                                                                   f.Part.MovedMPYAxis,
            //                                                                                   f.Part.MovedMPZAxis,
            //                                                                                   new Point3d(),
            //                                                                                   Vector3d.XAxis,
            //                                                                                   Vector3d.YAxis,
            //                                                                                   Vector3d.ZAxis));
            //            double dimx = holeposition.X;
            //            double dimy = holeposition.Y;

            //            VDrilling vdrill = new VDrilling(f.FaceNumber, dimx, dimy, this.FaceHoleDiameter, this.FaceHoleDepth, f.Part);
            //            f.Part.VDrillings.Add(vdrill);
            //        }
            //    }
            //}
        }
Exemple #6
0
        /// <summary>
        /// 生成报告
        /// </summary>
        /// <param name="modelPath">报告模板</param>
        /// <param name="tigerPath">生成地址</param>
        /// <param name="formId">问卷编号</param>
        /// <param name="entryId">被评估人编号</param>
        /// <param name="suffix">报告格式</param>
        /// <param name="maxLength">最多生成报告数,0为不限制</param>
        /// <returns></returns>
        public Result CreateReport(string modelPath, string tigerPath, long formId, long entryId, string suffix, int maxLength)
        {
            return(RunFun(logPath =>
            {
                tigerPath = ToolFile.GetAbsolutelyPath(tigerPath);

                modelPath = base.ModelPath + modelPath;

                DataRow dr = GetFormInfo(formId);

                if (entryId > 0)
                {
                    ReportParameterCollection col = new ReportParameterCollection
                    {
                        new ReportParameter("CompanyID", dr["CompanyID"] + ""),
                        new ReportParameter("FormApplicationID", dr["FormApplicationID"] + ""),
                        new ReportParameter("FormID", dr["FormID"] + ""),
                        new ReportParameter("ObservedID", entryId + ""),
                        new ReportParameter("EntryID", entryId + ""),
                        new ReportParameter("MinValue", "1")
                    };

                    col = ToolReport.BindPara(modelPath, col);

                    ToolReport.GenerateLocalReport(modelPath, tigerPath, entryId + "." + suffix, col, false);
                }
                else
                {
                    DataTable dt = DbContent.GetTable(string.Format(GetObservedList(), dr["CompanyID"] + "", dr["FormApplicationID"] + ""));

                    int con = 0;

                    foreach (DataRow item in dt.Rows)
                    {
                        if (maxLength > 0 && con >= maxLength)
                        {
                            break;
                        }

                        ReportParameterCollection col = new ReportParameterCollection
                        {
                            new ReportParameter("CompanyID", dr["CompanyID"] + ""),
                            new ReportParameter("FormApplicationID", dr["FormApplicationID"] + ""),
                            new ReportParameter("FormID", dr["FormID"] + ""),
                            new ReportParameter("ObservedID", item["EntryID"] + ""),
                            new ReportParameter("EntryID", item["EntryID"] + ""),
                            new ReportParameter("MinValue", "1")
                        };

                        col = ToolReport.BindPara(modelPath, col);
                        con++;
                        WriteLog(logPath, dt.Rows.IndexOf(item) + "\t" + item["FullName"] + "_" + item["EntryID"]);
                        ToolReport.GenerateLocalReport(modelPath, tigerPath, item["FullName"] + "_" + item["EntryID"] + "." + suffix, col, false);
                    }
                }
                return Res;
            }));
        }
Exemple #7
0
        public static void CreateText(string path, List <ExcelFormat> list)
        {
            List <string> conList = new List <string>();

            foreach (var item in list)
            {
                // 补充邮箱
                if (string.IsNullOrWhiteSpace(item.ObservedEmail))
                {
                    item.ObservedEmail = item.ObservedName + "@askform.cn";
                }
                if (string.IsNullOrWhiteSpace(item.ObserverEmail))
                {
                    item.ObserverEmail = item.ObserverName + "@askform.cn";
                }

                // 获取属性
                foreach (var pro in item.GetType().GetProperties())
                {
                    // 判断属性是否有值
                    if (!string.IsNullOrWhiteSpace(pro.GetValue(item) + ""))
                    {
                        // 判断属性是否已存
                        if (!conList.Contains(pro.Name))
                        {
                            conList.Add(pro.Name);
                        }
                    }
                }
            }

            ToolFile.CreatFile(path, string.Join("\t", conList), false);


            foreach (var item in list)
            {
                string line = "";
                Type   type = item.GetType();

                for (int i = 0; i < conList.Count; i++)
                {
                    if (i != 0)
                    {
                        line += "\t";
                    }
                    var val = type.GetProperty(conList[i]).GetValue(item) + "";
                    if (val == null)
                    {
                        val = " ";
                    }

                    line += val;
                }

                ToolFile.CreatFile(path, line, true);
            }
        }
Exemple #8
0
        //Se encarga de introducir a un nuevo usuario en la Base de datos.
        public Boolean Register(User user, String pass, String repPass, HttpPostedFileBase file, ref String error)
        {
            //Valida la existencia del email.
            if (!ExistsEmail(user.Email_User))
            {
                if (ValidatePassword(pass))
                {
                    if (EqualPassword(pass, repPass))
                    {
                        //Rellena los campos adicionales.
                        user.Image_User    = ToolFile.UploadImage(user.Image_User, file);
                        user.Password_User = Hashing.HashPassword(pass);
                        user.Created_User  = DateTime.Now;
                        user.Updated_User  = DateTime.Now;
                        user.Status_User   = 1;

                        //Inserta el usuario.
                        context.Users.Add(user);
                        context.SaveChanges();

                        //Generamos el Token de Confirmación de la cuenta.
                        Token token = new Token()
                        {
                            Id_User     = user.Id_User,
                            Value_Token = CreateToken(),
                            Start_Token = DateTime.Now,
                            End_Token   = DateTime.Now.AddMinutes(15)
                        };

                        //Inserta el token.
                        context.Tokens.Add(token);
                        context.SaveChanges();

                        //Enviamos el email de confirmación.
                        SMTPService smtp = new SMTPService();
                        smtp.SendEmail(user.Email_User, token.Value_Token);

                        return(true);
                    }
                    else
                    {
                        error = "Las contraseñas no coinciden.";
                    }
                }
                else
                {
                    error = "La Contraseña debe estar compuesta de entre 8 y 15 caracteres, por lo menos un digito y un alfanumérico, y un caracter espacial.";
                }
            }
            else
            {
                error = "El email ya se ha registrado.";
            }

            return(false);
        }
Exemple #9
0
        /// <summary>
        /// 写入日志
        /// </summary>
        /// <param name="logPath">日志路径</param>
        /// <param name="msg">日志消息</param>
        /// <param name="append">是否追加</param>
        /// <param name="hasDate">是否包含时间</param>
        protected void WriteLog(string logPath, string msg, bool append = true, bool hasDate = true)
        {
            logPath = ToolFile.GetAbsolutelyPath(logPath);
            if (File.Exists(logPath) && !append)
            {
                File.Delete(logPath);
            }

            ToolFile.CreatFile(logPath, (hasDate ? (DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffff")) + "\t\t" : "") + msg, true);
        }
        public override void ToMachining(double AssociatedDist, ToolFile toolFile)
        {
            Profile profile = new Profile();
            profile.IsSharpFromFile = true;
            profile.SharpFile = this.ProfileFile;

            profile.StartPointNumber = this.FaceNumber.ToString();
            profile.EndPointNumber = this.EdgeNumber.ToString();

            this.Part.Profiles.Add(profile);
        }
Exemple #11
0
        public override void ToMachining(double AssociatedDist, ToolFile toolFile)
        {
            Profile profile = new Profile();

            profile.IsSharpFromFile = true;
            profile.SharpFile       = this.ProfileFile;

            profile.StartPointNumber = this.FaceNumber.ToString();
            profile.EndPointNumber   = this.EdgeNumber.ToString();

            this.Part.Profiles.Add(profile);
        }
Exemple #12
0
        public override void ToMachining(double AssociatedDist, ToolFile toolFile)
        {
            //得到当前面的关联面
            AssociatedPartFaceList = base.FindAssociatedFacesOneTime(AssociatedDist, Penetration);

            //当前的face
            var currentFace = this.Part.GetPartFaceByNumber(this.FaceNumber);

            foreach (var f in AssociatedPartFaceList)
            {
                //得到一个转换矩阵,将
                var matrix = Matrix3d.AlignCoordinateSystem(f.Part.MovedMPPoint,
                                                            f.Part.MovedMPXAxis,
                                                            f.Part.MovedMPYAxis,
                                                            f.Part.MovedMPZAxis,
                                                            Point3d.Origin,
                                                            Vector3d.XAxis,
                                                            Vector3d.YAxis,
                                                            Vector3d.ZAxis);

                //将关联面的两个点作为铣型的起始
                var pt1 = currentFace.Point1.TransformBy(matrix);
                var pt2 = currentFace.Point4.TransformBy(matrix);


                //TODO:需要考虑的事情
                //1、LeadIn和LeadOut
                //2、铣型的方向
                //3、double/triple pass
                //4、刀补的方向如何偏移
                //5、宽度的方向如何偏移


                List <Point3d> points = new List <Point3d>()
                {
                    pt1, pt2
                };
                List <double> bulges = new List <double>()
                {
                    0, 0
                };
                Machinings.Routing route = new Machinings.Routing();
                route.Bulges   = bulges;
                route.Points   = points;
                route.ToolComp = ToolComp.None;
                route.Part     = f.Part;
                route.OnFace5  = (f.FaceNumber == 5) ? true : false;
                route.ToolName = this.ToolName;

                f.Part.Routings.Add(route);
            }
        }
Exemple #13
0
        /// <summary>
        /// 生成团队报告
        /// </summary>
        /// <param name="modelPath">报告模板</param>
        /// <param name="tigerPath">生成地址</param>
        /// <param name="formId">问卷编号</param>
        /// <param name="suffix">报告格式</param>
        /// <returns></returns>
        public Result CreateTeamReport(string modelPath, string tigerPath, long formId, string suffix)
        {
            return(RunFun(logPath =>
            {
                tigerPath = ToolFile.GetAbsolutelyPath(tigerPath);

                modelPath = base.ModelPath + modelPath;

                string sqlFilter = $"SELECT * FROM AskForm_FormFilter  ff WHERE ff.FormID = {formId} AND ff.Name LIKE '%FieldFilter%' AND ff.IsDeleted = 0";

                DataTable dtFilter = DbContent.GetTable(sqlFilter);

                // 循环过滤条件
                foreach (DataRow filter in dtFilter.Rows)
                {
                    ReportParameterCollection col = new ReportParameterCollection
                    {
                        new ReportParameter("CompanyID", filter["CompanyID"] + ""),
                        new ReportParameter("FormApplicationID", filter["FormApplicationID"] + ""),
                        new ReportParameter("FormID", filter["FormID"] + ""),
                        new ReportParameter("FormFilterID", filter["FormFilterID"] + ""),
                        new ReportParameter("MinValue", "1")
                    };

                    col = ToolReport.BindPara(modelPath, col);

                    // 获取过滤字段
                    string sqlField = $"SELECT f.FieldID,f.Title,fff.Content FROM AskForm_FormFilterField fff INNER JOIN AskForm_Field f ON f.FieldID = fff.FieldID WHERE FormFilterID = {filter["FormFilterID"]} AND fff.IsDeleted = 0";
                    DataTable dtField = DbContent.GetTable(sqlField);

                    // 循环字段
                    foreach (DataRow field in dtField.Rows)
                    {
                        string sqlContent = $"SELECT distinct [Value] FROM AskForm_EntryText et WHERE et.FieldID = {field["FieldID"]} AND et.IsDeleted = 0";
                        DataTable dtContent = DbContent.GetTable(sqlContent);

                        // 循环内容
                        foreach (DataRow content in dtContent.Rows)
                        {
                            // 修改内容
                            string sqlUpFilterField = $"UPDATE AskForm_FormFilterField SET Content='{content["Value"]}' WHERE FormFilterID = {filter["FormFilterID"]} AND FieldID ={field["FieldID"]} ";

                            WriteLog(logPath, "修改【" + field["Title"] + "】为【" + content["Value"] + "】," + DbContent.ExecuteNonQuery(sqlUpFilterField));
                            ToolReport.GenerateLocalReport(modelPath, tigerPath, field["Title"] + "_" + content["Value"] + "." + suffix, col, false);
                        }
                    }
                }
                return Res;
            }));
        }
        public override void ToMachining(double AssociatedDist, ToolFile toolFile)
        {
            //得到当前面的关联面
            AssociatedPartFaceList = base.FindAssociatedFacesOneTime(AssociatedDist, Penetration);

            //当前的face
            var currentFace = this.Part.GetPartFaceByNumber(this.FaceNumber);

            foreach (var f in AssociatedPartFaceList)
            {
                //得到一个转换矩阵,将
                var matrix = Matrix3d.AlignCoordinateSystem(f.Part.MovedMPPoint,
                                                            f.Part.MovedMPXAxis,
                                                            f.Part.MovedMPYAxis,
                                                            f.Part.MovedMPZAxis,
                                                            Point3d.Origin,
                                                            Vector3d.XAxis,
                                                            Vector3d.YAxis,
                                                            Vector3d.ZAxis);

                //将关联面的两个点作为铣型的起始
                var pt1 = currentFace.Point1.TransformBy(matrix);
                var pt2 = currentFace.Point4.TransformBy(matrix);


                //TODO:需要考虑的事情
                //1、LeadIn和LeadOut
                //2、铣型的方向
                //3、double/triple pass
                //4、刀补的方向如何偏移
                //5、宽度的方向如何偏移


                List<Point3d> points = new List<Point3d>() { pt1, pt2 };
                List<double> bulges = new List<double>() { 0, 0 };
                Machinings.Routing route = new Machinings.Routing();
                route.Bulges = bulges;
                route.Points = points;
                route.ToolComp = ToolComp.None;
                route.Part = f.Part;
                route.OnFace5 = (f.FaceNumber == 5) ? true : false;
                route.ToolName = this.ToolName;

                f.Part.Routings.Add(route);
            }
        }
        public override void ToMachining(double AssociatedDist, ToolFile toolFile)
        {
            //if (!toolFile.Tools.Any(it => it.ToolName == this.ToolName))
            //{
            //    this.writeError("未在刀具文件中找到铣刀:" + this.ToolName, false);
            //    return;
            //}

            Machinings.Routing route = new Machinings.Routing();
            route.ToolName = this.ToolName;
            route.ToolComp = this.ToolComp;
            route.Points = this.Points;
            route.Bulges = this.Bulges;
            //route.FeedSpeeds;
            route.OnFace5 = this.OnFace5;
            route.Part = this.Part;

            Part.Routings.Add(route);
        }
Exemple #16
0
        public override void ToMachining(double AssociatedDist, ToolFile toolFile)
        {
            //if (!toolFile.Tools.Any(it => it.ToolName == this.ToolName))
            //{
            //    this.writeError("未在刀具文件中找到铣刀:" + this.ToolName, false);
            //    return;
            //}

            Machinings.Routing route = new Machinings.Routing();
            route.ToolName = this.ToolName;
            route.ToolComp = this.ToolComp;
            route.Points   = this.Points;
            route.Bulges   = this.Bulges;
            //route.FeedSpeeds;
            route.OnFace5 = this.OnFace5;
            route.Part    = this.Part;

            Part.Routings.Add(route);
        }
Exemple #17
0
        /// <summary>
        /// 报告数据导入数据库
        /// </summary>
        /// <param name="dirPath"></param>
        /// <param name="formId"></param>
        /// <param name="reportId"></param>
        /// <returns></returns>
        public Result AddReportItem(string dirPath = "D:\\Shared\\弘阳报告", long formId = 8374570001, long reportId = 15581150001)
        {
            return(RunFun(logpath =>
            {
                string path = "\\Survey\\ExportReports\\";// 根目录
                // 获取表单GUID并拼接路径
                string sqlStr = "SELECT * FROM AskForm_Form WHERE FormID = " + formId;
                DataTable dt = DbContent.GetTable(sqlStr);
                string companyId = "";
                string appId = "";

                if (dt.HasItems(c => c.Columns.Contains("FormGuid")))
                {
                    path += dt.Rows[0]["FormGuid"] + "\\" + reportId + "\\";
                    companyId = dt.Rows[0]["CompanyID"] + "";
                    appId = dt.Rows[0]["FormApplicationID"] + "";
                }
                else
                {
                    return Res;
                }
                // 获取文件夹下所有文件
                if (Directory.Exists(dirPath))
                {
                    string[] pdfArr = Directory.GetFiles(dirPath);

                    foreach (var pdf in pdfArr)
                    {
                        string fileName = ToolFile.GetFileName(pdf, false);
                        string name = ToolFile.GetFileName(pdf);

                        sqlStr = string.Format(@"INSERT AskForm_FormReportItem SELECT {0},{1},'{2}','','{3}',0,{4},{5},{6},0,GETDATE(),GETDATE()"
                                               , reportId, ToolString.GetRandomStr(12, 6), name, path + fileName, companyId, appId, formId);
                        DbContent.ExecuteNonQuery(sqlStr);
                        WriteLog(logpath, sqlStr);
                    }
                }
                return Res;
            }));
        }
Exemple #18
0
        public override void ToMachining(double AssociatedDist, ToolFile toolFile)
        {
            double diameter = toolFile.GetRouteToolByName(this.ToolName).Diameter;

            if (diameter >= Radius)
            {
                throw new Exception("不支持加工圆半径小于铣刀半径的情况");
            }

            double smallRadius = (Radius < 12.7) ? Radius : 12.7;//TODO:MV里这是一个定制,如果大于大员的半径,就用大圆的半径

            List <Point3d> points = new List <Point3d>();
            List <double>  bulges = new List <double>();

            points.Add(new Point3d(StartX - Radius + smallRadius, StartY + smallRadius, 0));//下刀深度为0
            points.Add(new Point3d(StartX - Radius, StartY, Depth));
            points.Add(new Point3d(StartX, StartY - Radius, Depth));
            points.Add(new Point3d(StartX + Radius, StartY, Depth));
            points.Add(new Point3d(StartX, StartY + Radius, Depth));
            points.Add(new Point3d(StartX - Radius, StartY, Depth));
            points.Add(new Point3d(StartX - Radius + smallRadius, StartY - smallRadius, 0));
            bulges.AddRange(new double[] { -0.414214, -0.414214, -0.414214, -0.414214, -0.414214, -0.414214, -0.414214 });

            Machinings.Routing route = new Machinings.Routing();
            route.Bulges   = bulges;
            route.Points   = points;
            route.ToolComp = ToolComp.Left;
            route.Part     = this.Part;
            route.OnFace5  = this.OnFace5;
            route.ToolName = this.ToolName;

            Part.Routings.Add(route);

            if (IsPocket)
            {
                //TODO:这个未完成
                PocketMachining(diameter);
            }
        }
Exemple #19
0
        /// <summary>
        /// 提取日志文件
        /// </summary>
        /// <param name="path">日志文件路径</param>
        /// <param name="targetPath">日志提取路径</param>
        /// <param name="str">包含的字符串</param>
        /// <returns></returns>
        public Result FilterLog(string path, string targetPath, string str)
        {
            return(RunFun((logPath) =>
            {
                DirectoryInfo dirinfo = new DirectoryInfo(ToolFile.GetAbsolutelyPath(path));

                foreach (FileInfo file in dirinfo.GetFiles())
                {
                    List <string> list = File.ReadAllLines(file.FullName).ToList();
                    int count = 0;
                    foreach (var line in list)
                    {
                        if (line.ToUpper().IndexOf(str, StringComparison.InvariantCultureIgnoreCase) > 0)
                        {
                            WriteLog(ToolFile.GetAbsolutelyPath(targetPath) + "Res_" + file.Name, line, true);
                        }
                        count++;
                    }
                }
                return Res;
            }));
        }
Exemple #20
0
        /// <summary>
        /// 获取所有文件
        /// </summary>
        /// <param name="dirPath">文件夹路径</param>
        /// <param name="suffix">文件后缀</param>
        /// <returns></returns>
        public Result GetDirFileName(string dirPath, string suffix)
        {
            return(RunFun((logPath) =>
            {
                DirectoryInfo info = new DirectoryInfo(ToolFile.GetAbsolutelyPath(dirPath));

                if (info == null)
                {
                    Res.Msg = "文件夹不存在";
                    return Res;
                }

                if (string.IsNullOrWhiteSpace(suffix))
                {
                    suffix = "";
                }

                suffix = suffix.Replace(".", "").Trim().ToLower();
                string tmp = string.Format(SegmentingLine, "不包含的文件") + "\n";

                foreach (var item in info.GetFiles().OrderByDescending(c => c.FullName))
                {
                    if (string.IsNullOrWhiteSpace(suffix) || ToolFile.GetSuffix(item.FullName).ToLower() == suffix)
                    {
                        WriteLog(logPath, item.Name, true, false);
                    }
                    else
                    {
                        tmp += item.FullName + "\t" + item.CreationTime + "\n";
                    }
                }

                tmp += string.Format(SegmentingLine, "") + "\n";

                WriteLog(logPath, tmp, true, false);

                return Res;
            }));
        }
        public override void ToMachining(double AssociatedDist, ToolFile toolFile)
        {
            Machinings.Sawing sawing = new Machinings.Sawing();

            sawing.Part = this.Part;

            if (this.FaceNumber == 5)
                sawing.OnFace5 = true;
            else if (this.FaceNumber == 6)
                sawing.OnFace5 = false;

            sawing.StartX = this.StartX;
            sawing.StartY = this.StartY;
            sawing.StartDepth = this.StartDepth;
            sawing.EndX = this.EndX;
            sawing.EndY = this.EndY;
            sawing.EndDepth = this.EndDepth;
            sawing.ToolName = this.ToolName;
            sawing.IsDrawOnly = this.IsDrawOnly;
            sawing.ToolComp = this.ToolComp;

            Part.Sawings.Add(sawing);
        }
        public override void ToMachining(double AssociatedDist, ToolFile toolFile)
        {
            double diameter = toolFile.GetRouteToolByName(this.ToolName).Diameter;
            if (diameter >= Radius)
                throw new Exception("不支持加工圆半径小于铣刀半径的情况");

            double smallRadius = (Radius < 12.7) ? Radius : 12.7;//TODO:MV里这是一个定制,如果大于大员的半径,就用大圆的半径

            List<Point3d> points = new List<Point3d>();
            List<double> bulges = new List<double>();

            points.Add(new Point3d(StartX - Radius + smallRadius, StartY + smallRadius, 0));//下刀深度为0
            points.Add(new Point3d(StartX - Radius, StartY, Depth));
            points.Add(new Point3d(StartX, StartY - Radius, Depth));
            points.Add(new Point3d(StartX + Radius, StartY, Depth));
            points.Add(new Point3d(StartX, StartY + Radius, Depth));
            points.Add(new Point3d(StartX - Radius, StartY, Depth));
            points.Add(new Point3d(StartX - Radius + smallRadius, StartY - smallRadius, 0));
            bulges.AddRange(new double[] { -0.414214, -0.414214, -0.414214, -0.414214, -0.414214, -0.414214, -0.414214 });

            Machinings.Routing route = new Machinings.Routing();
            route.Bulges = bulges;
            route.Points = points;
            route.ToolComp = ToolComp.Left;
            route.Part = this.Part;
            route.OnFace5 = this.OnFace5;
            route.ToolName = this.ToolName;

            Part.Routings.Add(route);

            if (IsPocket)
            {
                //TODO:这个未完成
                PocketMachining(diameter);
            }
        }
Exemple #23
0
        /// <summary>
        /// 移动文件
        /// </summary>
        /// <param name="logFile">日志文件</param>
        /// <param name="filePath">原始文件夹路径</param>
        /// <param name="targetPath">目标文件夹</param>
        /// <returns></returns>
        public Result MoveFile(string logFile, string filePath, string targetPath)
        {
            return(RunFun((logPath) =>
            {
                List <FileInfo> fileList = new DirectoryInfo(filePath).GetFiles().ToList();

                List <string> lines = File.ReadAllLines(ToolFile.GetAbsolutelyPath(logFile)).ToList();

                foreach (var item in lines)
                {
                    FileInfo file = fileList.Where(c => item.ToLower().Contains(c.Name.ToLower())).FirstOrDefault();
                    if (file != null)
                    {
                        continue; //file.CopyTo(ToolFile.GetAbsolutelyPath(targetPath) + file.Name, true);
                    }
                    else
                    {
                        WriteLog(logPath, item, true, false);
                    }
                }

                return Res;
            }));
        }
        public Result GetFun()
        {
            return(RunFun((logPath, dataPath) =>
            {
                int max = 50;

                ToolFile.CreatFile(dataPath, "取整", true);

                string line = "";

                for (int i = 1; i <= max; i++)
                {
                    line = i + "\t";

                    for (int j = 1; j <= i; j++)
                    {
                        line += "";
                    }
                }


                return Res;
            }));
        }
Exemple #25
0
 public void setFileText(string path, string text)
 {
     ToolFile.writeAllText(getFullPath(path), text, false);
 }
Exemple #26
0
        /// <summary>
        /// 报告分组
        /// </summary>
        /// <param name="tigerPath">文件夹</param>
        /// <param name="group">分组条件,多个用','分割</param>
        /// <param name="max">文件夹最大占用</param>
        /// <returns></returns>
        public Result ReportGroup(string tigerPath, string group, double max)
        {
            return(RunFun(logpath =>
            {
                string res = "分组" + DateTime.Now.Millisecond + "\\";
                tigerPath = ToolFile.GetAbsolutelyPath(tigerPath);

                DirectoryInfo dir = new DirectoryInfo(tigerPath);

                // 移除所有文件夹
                while (dir.GetDirectories().Length > 0)
                {
                    Directory.Delete(dir.GetDirectories()[0].FullName, true);
                }

                List <string> groupList = group.Split(',').Where(c => !string.IsNullOrWhiteSpace(c)).ToList();

                Dictionary <string, long> dic = new Dictionary <string, long>();

                List <Task> taskList = new List <Task>();

                for (int i = 0; i < dir.GetFiles().Length; i++)
                {
                    WriteLog(logpath, i + "");

                    string path = tigerPath + res;
                    FileInfo field = dir.GetFiles()[i];

                    List <string> nameList = field.Name.Replace("." + ToolFile.GetSuffix(field.Name), "").Split('_').Where(c => !string.IsNullOrWhiteSpace(c)).ToList();

                    if (nameList.Count != 2)
                    {
                        WriteLog(logpath, field.Name);
                        continue;
                    }
                    DataRow dr = GetEntryInfo(nameList[1]);

                    foreach (var item in groupList)
                    {
                        if (dr.Table.Columns.Contains(item))
                        {
                            path += dr[item] + "\\";
                        }
                    }

                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    else
                    {
                        if (dic.Keys.Contains(path) && max > 0)
                        {
                            double memory = dic[path] * 1.0;
                            if (max * 1024 * 1024 < memory + field.Length)
                            {
                                path = ToolString.RemoveCharAfter(path, "\\", true) + "(" + dic.Keys.Where(c => c.Contains(path)).Count() + ")\\";
                                Directory.CreateDirectory(path);
                            }
                        }
                    }

                    if (dic.Keys.Contains(path))
                    {
                        dic[path] += field.Length;
                    }
                    else
                    {
                        dic.Add(path, field.Length);
                    }


                    taskList.Add(Task.Run(() =>
                    {
                        File.Copy(field.FullName, path + field.Name, true);
                    }));
                }

                Task.WaitAll(taskList.ToArray());

                dir = new DirectoryInfo(tigerPath + res);

                foreach (var key in dic.Keys)
                {
                    WriteLog(logpath, (dic[key] * 1.0 / 1020 / 1024) + "M\t" + key);
                }

                return Res;
            }));
        }
        /// <summary>
        /// 将指令转换为机加工
        /// </summary>
        /// <param name="AssociatedDist">关联值,关联面之间的可容纳距离</param>
        public virtual void ToMachining(double AssociatedDist, ToolFile toolFile)
        {

        }
Exemple #28
0
        /// <summary>
        /// 返回复原力数据
        /// </summary>
        /// <returns></returns>
        public Result GetResilienceData()
        {
            return(RunFun(logPath =>
            {
                List <GeelyField> list = (List <GeelyField>)GetAllPost(99999).Object;

                DataTable dicTable = new DataTable();
                dicTable.Columns.Add("cand");

                #region 获取用户数据

                foreach (var item in list)
                {
                    // 获取所有数据
                    Dictionary <string, string> tmp = ToolString.GetDiction(item.achievement);

                    // 添加表头
                    dicTable.Columns.AddRange(tmp.Keys.Where(c => !dicTable.Columns.Contains(c)).Select(c => new DataColumn(c)).ToArray());
                    // 添加一行数据
                    DataRow dr = dicTable.NewRow();
                    dr["cand"] = item.cand;// 添加唯一标识

                    // 添加数据
                    foreach (var key in tmp.Keys)
                    {
                        dr[key] = tmp[key];
                    }

                    dicTable.Rows.Add(dr);
                }

                #endregion


                DataTable dt = list.ToTable();

                #region 合并数据
                List <DataColumn> columnList = new List <DataColumn>
                {
                    dt.Columns["cand"]
                };

                dt.Union(dicTable, columnList);

                #endregion

                string resilience = "resilience";

                // 计算复原力
                foreach (DataRow dr in dt.Rows)
                {
                    dr[resilience] = GeelyField.Format((decimal.Parse(dr["自信"] + "") + decimal.Parse(dr["人际敏感"] + "") + decimal.Parse(dr["坚持不懈"] + "")) * 1.3M / 3);

                    if (!(dr["result"] + "").Contains(resilience))
                    {
                        string result = dr["result"] + "";

                        result = result.Substring(0, result.Length - 2);

                        result += $",\"{resilience}\":{dr[resilience]}" + "}}";
                        dr["result"] = result;
                    }
                    else
                    {
                        WriteLog(logPath, dr["cand"] + "");
                    }
                }

                dt.Columns.Remove("EntryID");
                dt.Columns.Remove("valid");
                dt.Columns.Remove("pid");
                dt.Columns.Remove("instr");
                dt.Columns.Remove("Speed");
                dt.Columns.Remove("isDown");
                dt.Columns.Remove("postT");
                dt.Columns.Remove("IsSend");
                dt.Columns.Remove("firstName");
                dt.Columns.Remove("email");
                dt.Columns.Remove("formula");
                dt.Columns.Remove("qualified");
                dt.Columns.Remove("createDate");
                dt.Columns.Remove("JobId");
                dt.Columns.Remove("Line178");
                dt.Columns.Remove("Line177");
                dt.Columns.Remove("Line175");
                dt.Columns.Remove("Line155");
                dt.Columns.Remove("Line110");
                dt.Columns.Remove("Line66");
                dt.Columns.Remove("Line11");

                ToolFile.TableToExcel(dt, @"C:\Users\mayn\Desktop\导出\Geely.xlsx");

                return Res;
            }));
        }
        public override void ToMachining(double AssociatedDist, ToolFile toolFile)
        {
            //由于这个指令是指定了板件的1-8个点进行定位的,所以要把空间的绝对坐标换算回机加工原点的相对坐标 
            //matrix1负责把所在点的坐标转换为板件中心的坐标
            //matrix2负责把板件中心的坐标,再转换为MP中心的坐标
            Point3d pt = Part.GetPartPointByNumber(EdgeNumber.ToString());
            Matrix3d matrix1 = Matrix3d.AlignCoordinateSystem(
                Point3d.Origin,
                Vector3d.XAxis,
                Vector3d.YAxis,
                Vector3d.ZAxis,
                pt,
                (Part.MachinePoint.IsRotated) ? this.GetPointYAxis(EdgeNumber) : this.GetPointXAxis(EdgeNumber),
                (Part.MachinePoint.IsRotated) ? this.GetPointXAxis(EdgeNumber) : this.GetPointYAxis(EdgeNumber),
                Vector3d.ZAxis);
            Matrix3d matrix2 = Matrix3d.AlignCoordinateSystem(
                Part.MPPoint,
                Part.MPXAxis,
                Part.MPYAxis,
                Part.MPZAxis,
                Point3d.Origin,
                Vector3d.XAxis,
                Vector3d.YAxis,
                Vector3d.ZAxis);

            if (LeadIn > 0)
            {
                double rRadius = LeadIn;
                Point3d firstPt = new Point3d(Radius + rRadius, -rRadius, Depth);
                Point3d secondPt = new Point3d(Radius, 0, Depth);
                Point3d thirdPt = new Point3d(0, Radius, Depth);
                Point3d forthPt = new Point3d(-rRadius, Radius + rRadius, Depth);

                firstPt = firstPt.TransformBy(matrix1).TransformBy(matrix2);
                secondPt = secondPt.TransformBy(matrix1).TransformBy(matrix2);
                thirdPt = thirdPt.TransformBy(matrix1).TransformBy(matrix2);
                forthPt = forthPt.TransformBy(matrix1).TransformBy(matrix2);

                double firstBulge = -0.414214;
                ToolComp comp = ToolComp.None;

                if (firstPt.X >= thirdPt.X && firstPt.Y >= thirdPt.Y)
                {
                    comp = ToolComp.Left;
                    firstBulge *= -1;
                }
                else if (firstPt.X >= thirdPt.X && firstPt.Y < thirdPt.Y)
                {
                    comp = ToolComp.Right;
                }
                else if (firstPt.X < thirdPt.X && firstPt.Y < thirdPt.Y)
                {
                    comp = ToolComp.Left;
                    firstBulge *= -1;
                }
                else if (firstPt.X < thirdPt.X && firstPt.Y >= thirdPt.Y)
                {
                    comp = ToolComp.Right;
                }

                Machinings.Routing route = new Machinings.Routing();
                route.ToolName = ToolName;
                route.Points = new List<Point3d>() { firstPt, secondPt, thirdPt, forthPt };
                route.Part = Part;
                route.ToolComp = comp;
                route.Bulges = (new double[] { 0, firstBulge, 0, 0 }).ToList();
                if (FaceNumber == 5) route.OnFace5 = true;
                else route.OnFace5 = false;

                Part.Routings.Add(route);
            }
        }
        /// <summary>
        /// 返回Excel文本
        /// </summary>
        /// <param name="dirPath"></param>
        /// <param name="length">被评估人信息长度</param>
        /// <returns></returns>
        public Result GetExcelTxt(string dirPath, int length)
        {
            return(RunFun(logPath =>
            {
                dirPath = ToolFile.GetAbsolutelyPath(dirPath);

                if (!Directory.Exists(dirPath))
                {
                    Res.Msg = "文件夹不存在";
                    return Res;
                }

                // 获取所有子文件夹
                List <DirectoryInfo> listDir = new DirectoryInfo(dirPath).GetDirectories().ToList();

                foreach (var dir in listDir)
                {
                    // 获取待整理的名单文件
                    List <FileInfo> fileList = dir.GetFiles().Where(c => c.Name.Contains("_") && c.Extension.ToLower().Contains("txt") && !c.Name.Contains("Res")).ToList();

                    // 循环名单文件
                    foreach (var file in fileList)
                    {
                        List <ExcelFormat> excelList = new List <ExcelFormat>();
                        //WriteLog(logPath, file.FullName);
                        // 循环行
                        foreach (var line in File.ReadAllLines(file.FullName))
                        {
                            List <ExcelFormat> tmpList = new List <ExcelFormat>();
                            // 获取被评估人信息
                            string[] edArr = line.Split('	').Where(c => !string.IsNullOrWhiteSpace(c)).Select(c => c.Replace(" ", "")).ToArray();

                            if (edArr.Length != length)
                            {
                                WriteLog(logPath, file.FullName + "\t" + "被评估人信息\t" + line);
                                continue;
                            }

                            string t = "名单";

                            if (edArr[4].Contains(t))
                            {
                                string name = ToolString.GetLetter(edArr[4]);

                                for (int i = 0; i < name.Length; i++)
                                {
                                    // 循环名单列表
                                    foreach (var nameLine in File.ReadAllLines(ToolFile.GetAbsolutelyPath(file.DirectoryName) + t + name[i] + ".txt"))
                                    {
                                        string[] nameArr = nameLine.Split('	').Where(c => !string.IsNullOrWhiteSpace(c)).Select(c => c.Replace(" ", "")).ToArray();

                                        if (nameArr.Length != 2)
                                        {
                                            WriteLog(logPath, file.FullName + "\t" + line + "\t" + "循环名单列表\t" + nameLine);
                                            continue;
                                        }

                                        if (edArr[1] == nameArr[1])
                                        {
                                            WriteLog(logPath, file.FullName + "\t" + edArr[1] + "\t" + "重名\t" + name[i] + ".txt");
                                            continue;
                                        }

                                        ExcelFormat excel = new ExcelFormat();
                                        // 基础信息
                                        excel.ObservedDepartment = edArr[0];
                                        excel.ObservedName = edArr[1];
                                        excel.Mapping = edArr[2];
                                        excel.Weight = edArr[3];
                                        excel.ObserverDepartment = nameArr[0];
                                        excel.ObserverName = nameArr[1];

                                        tmpList.Add(excel);
                                    }
                                }
                            }
                            else
                            {
                                // 添加分割属性
                                edArr[4] += "、";

                                // 获取多评估人信息,
                                string[] erArr = edArr[4].Split('、').Where(c => !string.IsNullOrWhiteSpace(c)).ToArray();

                                foreach (var er in erArr)
                                {
                                    ExcelFormat excel = new ExcelFormat();
                                    // 基础信息
                                    excel.ObservedDepartment = edArr[0];
                                    excel.ObservedName = edArr[1];
                                    excel.Mapping = edArr[2];
                                    excel.Weight = edArr[3];
                                    excel.ObserverName = er;
                                    tmpList.Add(excel);
                                }
                            }
                            excelList.AddRange(tmpList);
                        }
                        ExcelFormat.CreateText(ToolFile.GetAbsolutelyPath(file.DirectoryName) + "Res" + file.Name, excelList);
                    }
                }

                return Res;
            }));
        }
Exemple #31
0
        /// <summary>
        /// 返回所有请求成功的数据
        /// </summary>
        /// <param name="date">几天之内</param>
        /// <returns></returns>
        private Result GetAllPost(int date)
        {
            return(RunFun((logpath, dataPath) =>
            {
                string allSend = "AllSend.log";
                string notSend = "NotSend.json";

                List <GeelyField> notSendList;
                List <string> isSendList;

                // 读取数据库
                if (!File.Exists(dataPath + notSend))
                {
                    string sqlDeclares = GetSqlParam($"Declare @Date int = {date}");

                    notSendList = GeelyField.GetAllPost(sqlDeclares, DbContent);
                    // 初始化,将数据库中已经发送过请求的数据
                    notSendList = GeelyField.GetSendList(notSendList, c => true);
                    // 放入待重新请求文件
                    ToolFile.CreatFile(dataPath + notSend, ToolString.ConvertJson(notSendList), false);
                }
                // 读取文件
                else
                {
                    notSendList = ToolString.ConvertObject <List <GeelyField> >(File.ReadAllText(dataPath + notSend));
                }

                // 过滤已发送的数据
                if (File.Exists(dataPath + allSend))
                {
                    // 所有获取所有已发送列表
                    isSendList = File.ReadAllLines(dataPath + allSend).ToList();
                    foreach (var item in isSendList)
                    {
                        GeelyField geely = notSendList.FirstOrDefault(c => c.cand == item);
                        if (geely != null)
                        {
                            notSendList.Remove(geely);
                        }
                    }
                }

                // 已处理过的数据日志,用于更新
                Res.Msg = dataPath + allSend;
                // 待处理的数据集
                Res.Object = notSendList;

                //foreach (var item in notSendList)
                //{
                //    string url = "http://local.askform.cn/Custom/CampusRecruitment.aspx";
                //    url += "?name=" + item.firstName + "&cand=" + item.cand + "&instr=" + item.instr + "&pid=" + item.pid + "&valid=" + item.valid + "&keyword=" + item.EntryID;

                //    string log = item.cand;

                //    try
                //    {
                //        log += "\t发起请求";
                //        string res = ToolHttp.RequestUrl(url);

                //        log += "\t请求成功";
                //        ToolFile.CreatFile(dataPath + allSend, item.cand, true);
                //    }
                //    catch (Exception ex)
                //    {
                //        log += "\t请求失败:" + ex.Message;
                //    }

                //    WriteLog(logpath, log);
                //}

                return Res;
            }));
        }
Exemple #32
0
        public override void ToMachining(double AssociatedDist, ToolFile toolFile)
        {
            //由于这个指令是指定了板件的1-8个点进行定位的,所以要把空间的绝对坐标换算回机加工原点的相对坐标
            //matrix1负责把所在点的坐标转换为板件中心的坐标
            //matrix2负责把板件中心的坐标,再转换为MP中心的坐标
            Point3d  pt      = Part.GetPartPointByNumber(EdgeNumber.ToString());
            Matrix3d matrix1 = Matrix3d.AlignCoordinateSystem(
                Point3d.Origin,
                Vector3d.XAxis,
                Vector3d.YAxis,
                Vector3d.ZAxis,
                pt,
                (Part.MachinePoint.IsRotated) ? this.GetPointYAxis(EdgeNumber) : this.GetPointXAxis(EdgeNumber),
                (Part.MachinePoint.IsRotated) ? this.GetPointXAxis(EdgeNumber) : this.GetPointYAxis(EdgeNumber),
                Vector3d.ZAxis);
            Matrix3d matrix2 = Matrix3d.AlignCoordinateSystem(
                Part.MPPoint,
                Part.MPXAxis,
                Part.MPYAxis,
                Part.MPZAxis,
                Point3d.Origin,
                Vector3d.XAxis,
                Vector3d.YAxis,
                Vector3d.ZAxis);

            if (LeadIn > 0)
            {
                double  rRadius  = LeadIn;
                Point3d firstPt  = new Point3d(Radius + rRadius, -rRadius, Depth);
                Point3d secondPt = new Point3d(Radius, 0, Depth);
                Point3d thirdPt  = new Point3d(0, Radius, Depth);
                Point3d forthPt  = new Point3d(-rRadius, Radius + rRadius, Depth);

                firstPt  = firstPt.TransformBy(matrix1).TransformBy(matrix2);
                secondPt = secondPt.TransformBy(matrix1).TransformBy(matrix2);
                thirdPt  = thirdPt.TransformBy(matrix1).TransformBy(matrix2);
                forthPt  = forthPt.TransformBy(matrix1).TransformBy(matrix2);

                double   firstBulge = -0.414214;
                ToolComp comp       = ToolComp.None;

                if (firstPt.X >= thirdPt.X && firstPt.Y >= thirdPt.Y)
                {
                    comp        = ToolComp.Left;
                    firstBulge *= -1;
                }
                else if (firstPt.X >= thirdPt.X && firstPt.Y < thirdPt.Y)
                {
                    comp = ToolComp.Right;
                }
                else if (firstPt.X < thirdPt.X && firstPt.Y < thirdPt.Y)
                {
                    comp        = ToolComp.Left;
                    firstBulge *= -1;
                }
                else if (firstPt.X < thirdPt.X && firstPt.Y >= thirdPt.Y)
                {
                    comp = ToolComp.Right;
                }

                Machinings.Routing route = new Machinings.Routing();
                route.ToolName = ToolName;
                route.Points   = new List <Point3d>()
                {
                    firstPt, secondPt, thirdPt, forthPt
                };
                route.Part     = Part;
                route.ToolComp = comp;
                route.Bulges   = (new double[] { 0, firstBulge, 0, 0 }).ToList();
                if (FaceNumber == 5)
                {
                    route.OnFace5 = true;
                }
                else
                {
                    route.OnFace5 = false;
                }

                Part.Routings.Add(route);
            }
        }
Exemple #33
0
 /// <summary>
 /// 将指令转换为机加工
 /// </summary>
 /// <param name="AssociatedDist">关联值,关联面之间的可容纳距离</param>
 public virtual void ToMachining(double AssociatedDist, ToolFile toolFile)
 {
 }
Exemple #34
0
 public string getFileText(string path)
 {
     return(ToolFile.readAllText(getFullPath(path)));
 }
Exemple #35
0
        /// <summary>
        /// 返回选项列表
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public List <string> ItemList(string str, XWPFParagraph para, bool isCheck, int index, bool analysis)
        {
            List <string> list = new List <string>();

            string log = str;

            string t = "";

            if (isCheck)
            {
                t = (char)('A' + index) + "";
            }
            else
            {
                if (analysis)
                {
                    // 获取横排所有选项
                    List <string> tmp = ToolRegular.GetPoint(str, fun1Str5, 0).ToList();

                    for (int i = 0; i < tmp.Count; i++)
                    {
                        string str1 = tmp[i];
                        t = "";

                        str = str.Replace(str1, "灬").Trim();
                        // 获取选项字符
                        for (int j = 0; j < str1.Length; j++)
                        {
                            if ('A' <= str1[j] && str1[j] <= 'Z')
                            {
                                t += str1[j];
                            }
                        }

                        list.Add(t + ".");
                    }
                    tmp = str.Split('灬').Where(c => !string.IsNullOrWhiteSpace(c)).Select(c => c.Trim()).ToList();

                    try
                    {
                        for (int i = 0; i < tmp.Count; i++)
                        {
                            list[i] += tmp[i];
                        }
                        return(list);
                    }
                    catch (Exception)
                    {
                        ToolFile.CreatFile(@"D:\111.log", log + "\t" + para.ParagraphText, true);
                    }
                }
                else
                {
                    string tmp = ToolRegular.GetPoint(str, fun1Str5, 0).FirstOrDefault();

                    str = str.Replace(tmp, "").Trim();
                    for (int i = 0; i < tmp.Length; i++)
                    {
                        if ('A' <= tmp[i] && tmp[i] <= 'Z')
                        {
                            t += tmp[i];
                        }
                    }
                }
            }

            list.Add(t + "." + str);

            return(list);
        }
Exemple #36
0
        /// <summary>
        /// 解析题目
        /// </summary>
        /// <param name="file">文件路径</param>
        /// <param name="isCheck">是否检查段落</param>
        /// <param name="analysis">开启横向解析</param>
        /// <returns></returns>
        public Result Fun1(string file, bool isCheck, bool analysis)
        {
            return(RunFun(logPath =>
            {
                string path = allPath + @"" + file + ".docx";
                string tigerPath = allTiger + @"" + file + ".txt";

                WriteLog(logPath, file + "," + isCheck);

                string exclude = allPath + "ExcludeList.json";

                if (File.Exists(exclude))
                {
                    ExcludeList = ToolString.ConvertObject <List <string> >(File.ReadAllText(exclude));
                }

                XWPFDocument document = ToolFile.ReadWord(path);
                StringBuilder builder = new StringBuilder();

                string subject = "";

                List <string> answerList = new List <string>();
                List <string> itemList = new List <string>();

                string[] typeArr = new string[] { "单项选择", "多项选择", "判断" };
                int index = -1, nextIndex = -1; // 题目类型
                int itemIndex = 0;              // 答案索引
                int subjectIndex = 1;           // 题目索引

                if (analysis)
                {
                    fun1Str5 = @"[  ((]*[A-H]{1}[ .、.))::]+";
                }
                foreach (XWPFParagraph para in document.Paragraphs)
                {
                    string paragraphs = para.ParagraphText.Trim();//.Replace(" ", "");

                    for (int i = 0; i < typeArr.Length; i++)
                    {
                        if (ToolRegular.Contains(paragraphs, ".*" + typeArr[i] + @"题[((][\d]*.*[))]"))
                        {
                            nextIndex = i;
                            subjectIndex = 1;
                            if (index == -1)
                            {
                                index = i;
                            }
                        }
                    }

                    List <string> list = paragraphs.Split('\n').ToList();

                    foreach (var line in list)
                    {
                        // 判断是否是题目开头
                        Regex reg = new Regex(fun1Str1);
                        if (IsSubject(para, isCheck) || (reg.IsMatch(line) && !isCheck))
                        {
                            // 输出上一题
                            if (!string.IsNullOrWhiteSpace(subject))
                            {
                                subject = ReplaceSubject(subject, "、", isCheck);


                                if (!string.IsNullOrWhiteSpace(subject))
                                {
                                    answerList = AnswerList(subject);
                                    subject = answerList[0];
                                    answerList.Remove(subject);

                                    if (index == -1)
                                    {
                                        index = 0; nextIndex = 0;
                                    }

                                    subject += "[" + typeArr[index] + "题]\n";

                                    AnswerList(answerList, itemList, typeArr[index]);

                                    foreach (var item in itemList)
                                    {
                                        subject += item + "\n";
                                    }

                                    builder.AppendLine(subject);

                                    index = nextIndex;

                                    WriteLog(allTiger + @"" + file + ".log", "[" + typeArr[index] + "题]\t" + ToolString.AddStrByLength(subjectIndex + "", " ", 3) + "\t" + ToolString.AddStrByLength(string.Join(",", answerList), " ", 10) + "\t[" + string.Join(",", itemList.Select(c => c[0])) + "]", true);
                                    subjectIndex++;
                                }
                            }

                            // 开始下一题
                            itemList = new List <string>();
                            answerList = new List <string>();
                            subject = line;
                            itemIndex = 0;
                        }
                        else
                        {
                            if (string.IsNullOrWhiteSpace(subject))
                            {
                                continue;
                            }
                            // 判断是否是选项开头
                            else if (IsItem(para, isCheck) || new Regex(fun1Str3).IsMatch(line))
                            {
                                itemList.AddRange(ItemList(line, para, isCheck, itemIndex++, analysis));
                                continue;
                            }
                            // 判断是否是换行题目
                            else if (itemList.Count <= 0 && !string.IsNullOrWhiteSpace(line) && (!isCheck || para.GetNumFmt() != "lowerRoman"))
                            {
                                subject += Br + line;
                            }
                        }
                    }
                }

                // 输出最后一题
                if (!string.IsNullOrWhiteSpace(subject))
                {
                    subject = ReplaceSubject(subject, "、", isCheck);


                    if (!string.IsNullOrWhiteSpace(subject))
                    {
                        answerList = AnswerList(subject);
                        subject = answerList[0];
                        answerList.Remove(subject);

                        subject += "[" + typeArr[index] + "题]\n";

                        AnswerList(answerList, itemList, typeArr[index]);

                        foreach (var item in itemList)
                        {
                            subject += item + "\n";
                        }

                        builder.AppendLine(subject);

                        index = nextIndex;
                        WriteLog(allTiger + @"" + file + ".log", "[" + typeArr[index] + "题]\t" + ToolString.AddStrByLength(subjectIndex + "", " ", 3) + "\t" + ToolString.AddStrByLength(string.Join(",", answerList), " ", 10) + "\t[" + string.Join(",", itemList.Select(c => c[0])) + "]", true);
                    }
                }

                ToolFile.CreatFile(tigerPath, builder.ToString(), false);

                return Res;
            }));
        }