예제 #1
0
 /// <summary>
 /// 检查是否重复
 /// </summary>
 /// <param name="Model.Project"></param>
 /// <returns></returns>
 public static bool CheckRepeat(Model.Project model)
 {
     try
     {
         string         sql  = "select * from Project where Name = @Name and Id <> @Id";
         SqlParameter[] para = new SqlParameter[]
         {
             new SqlParameter("@Name", model.Name.Trim()),
             new SqlParameter("@Id", model.Id)
         };
         DataTable temp = DBHelper.ExecuteGetDataTable(CommandType.Text, sql, para);
         if (temp.Rows.Count > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         ErrorLog e = new ErrorLog();
         e.TargetIds = model.Id.ToString();
         e.CodeTag   = "CheckRepeat";
         e.LogName   = "检查是否重复-ForProject";
         e.ErrorMsg  = ex.Message.ToString();
         ErrorLogService.AddErrorLog <Model.Project>(e, model);
         return(true);
     }
 }
예제 #2
0
        public static void Generate(Project project)
        {
            Flush();
            Init(project.Settings.SafeDistance + project.Settings.Height);

            foreach (var iter in project.Operations)
            {
                if (iter.Shape.Name.Substring(0, 6) == "BoltHo") GBoltHole(project, iter);
                if (iter.Shape.Name.Substring(0, 6) == "Pocket") GPocket(project, iter);
            }

            EndMills(project.Settings.SafeDistance + project.Settings.Height);
        }
예제 #3
0
        private bool tryPut(ref Model.Project model, out string errMsg)
        {
            errMsg = "";
            bool re = false;

            model.Modifier     = this.auth.UserId;
            model.ModifiedDate = DateTime.Now;
            if (ProjectManager.ModifyProjectById(ref model, out errMsg))
            {
                re = true;
            }
            return(re);
        }
예제 #4
0
 /// <summary>
 /// 添加项目
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static bool AddProject(ref Model.Project model, out string errMsg)
 {
     errMsg = "";
     try
     {
         model.Name        = model.Name.Trim();
         model.Description = model.Description.Trim();
         SqlParameter[] para = new SqlParameter[]
         {
             new SqlParameter("@Name", model.Name),
             new SqlParameter("@IsEnable", model.IsEnable),
             new SqlParameter("@Description", model.Description),
             new SqlParameter("@Creater", model.Creater),
             new SqlParameter("@CreatedDate", model.CreatedDate),
             new SqlParameter("@Modifier", model.Modifier),
             new SqlParameter("@ModifiedDate", model.ModifiedDate),
             new SqlParameter("@return", SqlDbType.Int)
         };
         para[7].Direction = ParameterDirection.ReturnValue;
         int i = DBHelper.ExecuteNonQuery(CommandType.StoredProcedure, "proc_ProjectInsert", para);
         if (i > 0)
         {
             model.Id = int.Parse(para[7].Value.ToString());
             EventLog e = new EventLog();
             e.TargetIds = para[7].Value.ToString();
             e.CodeTag   = "AddProject";
             e.LogName   = "添加项目";
             EventLogService.AddEventLog <Model.Project>(e, model);
             return(true);
         }
         else
         {
             errMsg = "添加记录失败,受影响行数为0";
             return(false);
         }
     }
     catch (Exception ex)
     {
         errMsg = ex.Message;
         ErrorLog e = new ErrorLog();
         e.TargetIds = "0";
         e.CodeTag   = "AddProject";
         e.LogName   = "添加项目";
         e.ErrorMsg  = ex.Message.ToString();
         ErrorLogService.AddErrorLog <Model.Project>(e, model);
         return(false);
     }
 }
예제 #5
0
 /// <summary>
 /// 根据id修改项目
 /// </summary>
 /// <param name="Model.Project"></param>
 /// <returns></returns>
 public static bool ModifyProjectById(ref Model.Project model, out string errMsg)
 {
     errMsg = "";
     try
     {
         model.Name        = model.Name.Trim();
         model.Description = model.Description.Trim();
         SqlParameter[] para = new SqlParameter[]
         {
             new SqlParameter("@Id", model.Id),
             new SqlParameter("@Name", model.Name),
             new SqlParameter("@IsEnable", model.IsEnable),
             new SqlParameter("@Description", model.Description),
             new SqlParameter("@Modifier", model.Modifier),
             new SqlParameter("@ModifiedDate", model.ModifiedDate)
         };
         int i = DBHelper.ExecuteNonQuery(CommandType.StoredProcedure, "proc_ProjectByIdUpdate", para);
         if (i > 0)
         {
             EventLog e = new EventLog();
             e.TargetIds = model.Id.ToString();
             e.CodeTag   = "ModifyProjectById";
             e.LogName   = "修改项目";
             EventLogService.AddEventLog <Model.Project>(e, model);
             return(true);
         }
         else
         {
             errMsg = "该记录已被删除,不能修改!";
             return(false);
         }
     }
     catch (Exception ex)
     {
         errMsg = ex.Message;
         ErrorLog e = new ErrorLog();
         e.TargetIds = model.Id.ToString();
         e.CodeTag   = "ModifyProjectById";
         e.LogName   = "修改项目";
         e.ErrorMsg  = ex.Message.ToString();
         ErrorLogService.AddErrorLog <Model.Project>(e, model);
         return(false);
     }
 }
예제 #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int          ProjectId    = int.Parse(Request.QueryString["Id"]);
            int          UserId       = int.Parse(((Session["user"] as User).Id).ToString());
            LikesManager likesManager = new LikesManager();

            Model.Likes likes = likesManager.GetModelByUserIdAndProjectId(UserId, ProjectId);
            //判断用户是否关注有该项目
            if (likes == null)
            {
                this.like.Text = "关注";
            }
            else
            {
                this.like.Text = "取消关注";
            }
            //获取项目数据
            ProjectManager projectManager = new ProjectManager();

            project = projectManager.GetModel(ProjectId);
            UserManager userManager = new UserManager();

            User = userManager.GetModel(project.OwnerId);
            SupportProject supportProject = new SupportProject();
            //获取评论
            CommentManager commentManager = new CommentManager();

            this.RepeaterComment.DataSource = commentManager.GetModelLinkUsers(UserId, ProjectId);
            this.RepeaterComment.DataBind();
            //获取回报内容
            Session["Return"]       = project.Return;
            Session["ReturnMiddle"] = project.ReturnMiddle;
            Session["ReturnMax"]    = project.ReturnMax;
            Session["ReturnTime"]   = project.ReturnTime;
            Session["Freight"]      = project.Freight;
            //获取支持者
            CalculationManager calculationManager = new CalculationManager();

            Session["Small"]          = calculationManager.CountSupportPeopleSmall(ProjectId);
            Session["Middle"]         = calculationManager.CountSupportPeopleMiddle(ProjectId);
            Session["Max"]            = calculationManager.CountSupportPeopleMax(ProjectId);
            Session["CountOfSupport"] = calculationManager.CountSupportWhereProjectId(ProjectId);
        }
예제 #7
0
        private bool tryValidate(Model.Project model, out string errMsg)
        {
            errMsg = "";
            bool re = true;

            if (model.Name == null || model.Name.Length == 0 || model.Name.Length > 20 ||
                model.Description.Length > 200)
            {
                errMsg = "输入数据不合法";
                re     = false;
            }
            if (re && ProjectManager.CheckRepeat(model))
            {
                errMsg = "不能重复";
                re     = false;
            }
            if (re && model.Modifier != auth.UserId)
            {
                errMsg = "登录信息异常,请刷新浏览器以重启应用(APP请退出应用后重新打开)";
                re     = false;
            }
            return(re);
        }
예제 #8
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Projects EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToProjects(Project project)
 {
     base.AddObject("Projects", project);
 }
예제 #9
0
 partial void UpdateProject(Project instance);
예제 #10
0
 partial void DeleteProject(Project instance);
예제 #11
0
 /// <summary>
 /// Sets the parent child relationship in the deserialized model
 /// TODO: Could be more elegant
 /// </summary>
 /// <param name="xmlData">The deserialized <see cref="Project"/></param>
 private static void SetParentChildRelationship(Project xmlData)
 {
     foreach (var package in xmlData.Packages)
     {
         package.Parent = xmlData;
         foreach (var container in package.Containers)
         {
             container.Parent = package;
             foreach (var key in container.Keys)
             {
                 key.Parent = container;
             }
         }
     }
 }
예제 #12
0
 partial void InsertProject(Project instance);
예제 #13
0
        // X ~ width ; Y ~ length
        private static void GPocket(Project project, Operation iter)
        {
            var list = new List<ExtendedOpenGlPoint>();
            var enumerator = iter.Location.LocationsList.GetEnumerator();
            var length = ((Pocket)iter.Shape).Length;
            var height = ((Pocket)iter.Shape).Height;
            var width = ((Pocket)iter.Shape).Width;
            enumerator.MoveNext();
            var origin = new Point(
                enumerator.Current.X - width / 2,
                enumerator.Current.Y - length / 2);       // для обычного покета, не матрично/радиально расположенных
            var x = origin.X;
            var y = origin.Y;

            const double stepY = 1;
            var toolDiam = project.Settings.ToolDiam;
            var toolRadius = toolDiam / 2;

            GSetFeedRate(180);      // Стандартная скорость подачи пока нет такого поля в проекте
            G00X(x + toolRadius);
            G00Y(y + toolRadius);
            G01Z(project.Settings.Height);

            double temp = 0;

            list.Add(new ExtendedOpenGlPoint(
                    x + toolRadius,
                    project.Settings.Height + project.Settings.SafeDistance,
                    y + toolRadius,
                    0,
                    new float[] { 0, 0, 0 }));
            list.Add(new ExtendedOpenGlPoint(
                        x + toolRadius,
                        project.Settings.Height,
                        y + toolRadius,
                        0,
                        new float[] { 0, 0, 0 }));
            for (var i = project.Settings.Height; i >= project.Settings.Height - height; i -= stepY)         // дописать именно генерацию кодов...
            {
                G01Z(i);
                for (double j = 1; j <= width / toolDiam; j++)
                {
                    list.Add(new ExtendedOpenGlPoint(
                            x + toolRadius + temp,
                            i,
                            y + toolRadius + ((j * length) % (length * 2)) - toolDiam * (j % 2),
                            0,
                            new float[] { 0, 0, 0 }));
                    G01Xy(x + toolRadius + temp, y + toolRadius + ((j * length) % (length * 2)) - toolDiam * (j % 2));
                    if (toolRadius + temp + toolDiam < width)
                    {
                        temp += toolDiam;
                        list.Add(new ExtendedOpenGlPoint(
                                x + toolRadius + temp,
                                i,
                                y + toolRadius + ((j * length) % (length * 2)) - toolDiam * (j % 2),
                                0,
                                new float[] { 0, 0, 0 }));
                        G01Xy(x + toolRadius + temp, y + toolRadius + ((j * length) % (length * 2)) - toolDiam * (j % 2));
                    }
                }
                temp = 0;
                list.Add(new ExtendedOpenGlPoint(x + toolRadius, i, y + toolRadius, 0, new float[] { 0, 0, 0 }));
                G01Xy(x + toolRadius, y + toolRadius);
                list.Add(new ExtendedOpenGlPoint(x + width - toolRadius, i, y + toolRadius, 0, new float[] { 0, 0, 0 }));                // Периметр
                G01Xy(x + width - toolRadius, y + toolRadius);
                list.Add(new ExtendedOpenGlPoint(x + width - toolRadius, i, y + length - toolRadius, 0, new float[] { 0, 0, 0 }));
                G01Xy(x + width - toolRadius, y + length - toolRadius);
                list.Add(new ExtendedOpenGlPoint(x + toolRadius, i, y + length - toolRadius, 0, new float[] { 0, 0, 0 }));
                G01Xy(x + toolRadius, y + length - toolRadius);
                list.Add(new ExtendedOpenGlPoint(x + toolRadius, i, y + toolRadius, 0, new float[] { 0, 0, 0 }));
                G01Xy(x + toolRadius, y + toolRadius);

                Separator();
            }
            list.Add(new ExtendedOpenGlPoint(x + toolRadius, project.Settings.Height + project.Settings.SafeDistance, y + toolRadius, 0, new float[] { 0, 0, 0 }));
            TrajectoryStor.AddModel(list);
            G01Z(project.Settings.Height + 2);
            G00Z(project.Settings.Height + project.Settings.SafeDistance);
            Separator();
        }
예제 #14
0
        /// <summary>
        /// Parses a given folder into a Project
        /// </summary>
        /// <param name="folderPath">The path to a csv file</param>
        /// <param name="sourceAction">The action to be performed on the source files</param>
        /// <param name="fillMissing">Whether to fill the missing values</param>
        /// <returns>
        /// A <see cref="Project"/> containing a <see cref="Package"/> per found string table csv file.
        /// </returns>
        public static Project ParseProject(string folderPath, SourceAction sourceAction = SourceAction.Nothing, bool fillMissing = false)
        {
            if (!Directory.Exists(folderPath))
                throw new ApplicationException(string.Format("The specified folder does not exist: {0}", folderPath));

            var project = new Project()
            {
                Name = new DirectoryInfo(folderPath).Name
            };

            // get all stringtables
            foreach (var stringtablefile in Directory.EnumerateFiles(folderPath, "*.csv", SearchOption.AllDirectories))
            {
                try
                {
                    var package = Parse(stringtablefile, fillMissing);
                    project.Packages.Add(package);

                    // perform action on the source files
                    switch (sourceAction)
                    {
                        case SourceAction.Delete:
                            File.Delete(stringtablefile);
                            break;

                        case SourceAction.Rename:
                            File.Move(stringtablefile, string.Format("{0}.bkup", stringtablefile));
                            break;

                        case SourceAction.Nothing:
                            break;
                    }
                }
                catch (Exception ex)
                {
                    throw new ApplicationException(string.Format("Failed parsing file: {0} Error: {1}", stringtablefile, ex.Message));
                }
            }

            return project;
        }
예제 #15
0
        private static void GBoltHole(Project project, Operation iter)
        {
            var externalRadius = ((BoltHole)iter.Shape).Radius;
            var internalRadius = ((BoltHole)iter.Shape).InternalRadius;
            var lenAll = ((BoltHole)iter.Shape).LenAll;
            var len = ((BoltHole)iter.Shape).Length;
            var tooldiam = project.Settings.ToolDiam;
            const double stepY = 1;

            var stepR = (externalRadius - internalRadius) / ((lenAll - len) / stepY); // рассчитываем шаг для радиуса

            var enumerator = iter.Location.LocationsList.GetEnumerator();
            while (enumerator.MoveNext())
            {
                var list = new List<ExtendedOpenGlPoint>();
                var color = new float[] { 0, 0, 0 };
                //                GCodeGenerator.Add_Model(list);

                var center = new Point(enumerator.Current.X, enumerator.Current.Y);
                list.Add(
                    new ExtendedOpenGlPoint
                    (
                        center.X,
                        project.Settings.Height + project.Settings.SafeDistance,
                        center.Y,
                        0,
                        new float[] { 0, 0, 0 }
                    )
                );

                G00Z(project.Settings.SafeDistance);
                G00X(center.X);
                G00Y(center.Y);
                G01Z(project.Settings.Height);

                var stR = externalRadius;

                if (externalRadius >= tooldiam)
                {
                    for (var i = 0; i <= (lenAll - len) / stepY; i++, stR -= stepR)
                    {
                        for (var j = 0; j < stR / tooldiam; j++)
                        {
                            Circle(list, j * tooldiam, project.Settings.Height - i * stepY, center);
                            G02(j * tooldiam, center);
                            if (!(j + 1 < externalRadius / (2 * tooldiam))) continue;
                            list.Add(new ExtendedOpenGlPoint(
                                    center.X,
                                    project.Settings.Height - i * stepY,
                                    center.Y + j * tooldiam,
                                    0,
                                    new float[] { 0, 0, 0 }));
                            G01Xy(center.X, center.Y + j * tooldiam);
                        }
                        /* Сюда надо вставить заключительный проход по окружности */
                        list.Add(new ExtendedOpenGlPoint(
                                center.X,
                                project.Settings.Height - i * stepY,
                                center.Y,
                                0,
                                new float[] { 0, 0, 0 }));
                        G01Xy(center.X, center.Y);
                        Separator();
                        if (!(i + 1 < len)) continue;
                        list.Add(
                            new ExtendedOpenGlPoint(
                                center.X,
                                project.Settings.Height - (i + 1) * stepY,
                                center.Y,
                                0,
                                new float[] { 0, 0, 0 }));
                        G01Z(project.Settings.Height - (i + 1) * stepY);
                    }

                    for (var i = len; i <= lenAll / stepY; i++)
                    {
                        for (var j = 0; j < internalRadius / tooldiam; j++)
                        {
                            Circle(list, j * tooldiam, project.Settings.Height - i * stepY, center);
                            G02(j * tooldiam, center);
                            if (!(j + 1 < internalRadius / (2 * tooldiam))) continue;
                            list.Add(new ExtendedOpenGlPoint(
                                    center.X,
                                    project.Settings.Height - i * stepY,
                                    center.Y + j * tooldiam,
                                    0,
                                    new float[] { 0, 0, 0 }));
                            G01Xy(center.X, center.Y + j * tooldiam);
                        }
                        /* Сюда надо вставить заключительный проход по окружности */
                        list.Add(new ExtendedOpenGlPoint(
                                    center.X,
                                    project.Settings.Height - i * stepY,
                                    center.Y,
                                    0,
                                    new float[] { 0, 0, 0 }));
                        G01Xy(center.X, center.Y);
                        Separator();
                        if (!(i + 1 < len)) continue;
                        list.Add(new ExtendedOpenGlPoint(
                                center.X,
                                project.Settings.Height - (i + 1) * stepY,
                                center.Y,
                                0,
                                new float[] { 0, 0, 0 }));
                        G01Z(project.Settings.Height - (i + 1) * stepY);
                    }
                    list.Add(new ExtendedOpenGlPoint(
                                center.X,
                                project.Settings.Height + project.Settings.SafeDistance,
                                center.Y,
                                0,
                                new float[] { 0, 0, 0 }));
                    G01Z(project.Settings.Height + 2);
                    G00Z(project.Settings.Height + project.Settings.SafeDistance);
                    Separator();
                }
                TrajectoryStor.AddModel(list);
            }
        }
예제 #16
0
 /// <summary>
 /// 检查是否重复
 /// </summary>
 /// <param name="Model.Project"></param>
 /// <returns></returns>
 public static bool CheckRepeat(Model.Project model)
 {
     return(ProjectService.CheckRepeat(model));
 }
예제 #17
0
 /// <summary>
 /// 根据id修改项目
 /// </summary>
 /// <param name="Model.Project"></param>
 /// <returns></returns>
 public static bool ModifyProjectById(ref Model.Project model, out string errMsg)
 {
     return(ProjectService.ModifyProjectById(ref model, out errMsg));
 }
예제 #18
0
 /// <summary>
 /// 添加项目
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static bool AddProject(ref Model.Project model, out string errMsg)
 {
     return(ProjectService.AddProject(ref model, out errMsg));
 }
예제 #19
0
 /// <summary>
 /// Create a new Project object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="startDate">Initial value of the StartDate property.</param>
 /// <param name="endDate">Initial value of the EndDate property.</param>
 /// <param name="status">Initial value of the Status property.</param>
 /// <param name="description">Initial value of the Description property.</param>
 /// <param name="addDate">Initial value of the AddDate property.</param>
 public static Project CreateProject(global::System.Int32 id, global::System.String name, global::System.DateTime startDate, global::System.DateTime endDate, global::System.String status, global::System.String description, global::System.Int32 addDate)
 {
     Project project = new Project();
     project.Id = id;
     project.Name = name;
     project.StartDate = startDate;
     project.EndDate = endDate;
     project.Status = status;
     project.Description = description;
     project.AddDate = addDate;
     return project;
 }
예제 #20
0
        public static void DrawOperation(OpenGL gl, Project testProject, Vector rotation, List<List<double[]>> detailCache)
        {
            var bill = testProject.Settings;

            gl.Translate(bill.Length / 2, bill.Height / 2, bill.Width / 2);//высчитывается из размера заготовки
            gl.Rotate((float)rotation.Y, (float)rotation.X, 0); // вращение с зажатой средней кнопкой мыши
            gl.Translate(-bill.Length / 2, -bill.Height / 2, -bill.Width / 2);

            //var Bill = this.testProject.Settings;
            Billet.Draw(gl, bill.Height, bill.Length, bill.Width); // заготовка

            var operations = testProject.Operations;//колличество операций

            var boltReg = new Regex("BoltHole");
            var pocketReg = new Regex("Pocket");
            if (detailCache.Count != operations.Count) detailCache.Clear();

            for (var i = 0; i < operations.Count; i++)//главный цикл отрисовки
            {
                var shapeName = operations[i].Shape.Name;

                if (boltReg.IsMatch(shapeName))
                {
                    var bolt = (Model.Primitives.BoltHole)operations[i].Shape;
                    var boltlocation = operations[i].Location.LocationsList.GetEnumerator();
                    while (boltlocation.MoveNext())
                    {
                        if (bolt.Modified || boltlocation.Current.Modified || detailCache.Count<=i)
                        {

                            try
                            {
                                detailCache.RemoveAt(i);
                            }
                            catch{}
                            var location = new Point(boltlocation.Current.X, boltlocation.Current.Y);
                            detailCache.Insert(i, BoltHole.ReCalc(bolt, 0.5, location)); //здесь уже всё ок, кроме величины шага
                            boltlocation.Current.IsDrawn();
                            bolt.IsDrawn();//значит в кэше лежит актуальная информация
                        }
                        else
                        {
                            var location = new Point(boltlocation.Current.X, boltlocation.Current.Y);
                            BoltHole.Draw(gl, detailCache[i]); //здесь уже всё ок, кроме величины шага
                        }
                    }
                }

                if (!pocketReg.IsMatch(shapeName)) continue;
                var poc = (Model.Primitives.Pocket)operations[i].Shape;
                var poclocation = operations[i].Location.LocationsList.GetEnumerator();
                while (poclocation.MoveNext())
                {
                    if (poc.Modified || poclocation.Current.Modified || detailCache.Count <= i)
                    {
                        try
                        {
                            detailCache.RemoveAt(i);
                        }
                        catch { }
                        var location = new Point(poclocation.Current.X, poclocation.Current.Y);
                        var p = Pocket.ReCalc(poc, 0.5, location);
                        detailCache.Insert(i, p); //здесь уже всё ок, кроме величины шага
                        poclocation.Current.IsDrawn();
                        poc.IsDrawn();//значит в кэше лежит актуальная информация
                    }
                    else
                    {
                        var location = new Point(poclocation.Current.X, poclocation.Current.Y);
                        Pocket.Draw(gl, detailCache[i]); //здесь уже всё ок, кроме величины шага
                    }
                }
            }

            //отрисовщик траекторий
            gl.Begin(OpenGL.GL_LINE_STRIP);
            gl.Color(1f, 0, 0);

            var trajectorys = GCodeGenerator.TrajectoryStor.GetTrajectorys();
            foreach (var point in trajectorys.SelectMany(operation => operation))
            {
                gl.Vertex(point.GetCoordinates());
            }
        }
예제 #21
0
        /// <summary>
        /// Writes a <see cref="Project"/> to file.
        /// </summary>
        /// <param name="project">The <see cref="Project"/> to be written to file.</param>
        /// <param name="path">The path to the xml file.</param>
        public static void WriteXml(Project project, string path)
        {
            // create the directories of the path if they dont exist
            Directory.CreateDirectory(Path.GetDirectoryName(path));

            // remove default namespace information
            var ns = new XmlSerializerNamespaces();
            ns.Add("", "");

            var serializer = new XmlSerializer(typeof(Project));
            using (TextWriter writer = new StreamWriter(path))
            {
                serializer.Serialize(writer, project, ns);
            }

            // assign path to the project
            project.FileName = path;
        }