예제 #1
0
        public IActionResult RegisterNamedSearchCondition(SearchConditionInModel scm, string searchConditionName)
        {
            string scjson = scm.ToString();
            string schash = HashUtil.CalcCRC32(scjson);

            var sc = _context.SearchCondition.Where(sc => sc.SearchConditionKey == schash).SingleOrDefault();

            if (sc != null)
            {
                sc.SearchConditionName = searchConditionName;
            }
            else
            {
                sc = new SearchCondition
                {
                    SearchConditionKey  = schash,
                    SearchConditionJson = scjson,
                    SearchConditionName = searchConditionName,
                    SearchCount         = 0
                };
                _context.SearchCondition.Add(sc);
            }

            _context.SaveChanges();
            MasterManager.ReloadNamedSearchCondition(_context);
            _ = Task.Run(() => { LineUtil.PushMe($"検索条件が登録されました。\n{searchConditionName}\n{scjson}", HttpClientManager.GetInstance()); });

            return(Content(sc.SearchConditionKey));
        }
예제 #2
0
        //------------------------------------------------------
        //
        //  Public Properties
        //
        //------------------------------------------------------

        //------------------------------------------------------
        //
        //  Public Events
        //
        //------------------------------------------------------

        //------------------------------------------------------
        //
        //  Internal Methods
        //
        //------------------------------------------------------

        #region Internal Methods

        // NOTE: Geometry3D hit testing takes the rayParams in the outer space of the
        //       Geometry3D.  That is, RayHitTest() will apply this geometry's
        //       transform to the ray for the caller.
        //
        //       This is different than Visual hit testing which does not transform
        //       the hit testing parameters by the Visual's transform.
        internal void RayHitTest(RayHitTestParameters rayParams, FaceType facesToHit)
        {
            Debug.Assert(facesToHit != FaceType.None,
                         "Caller should make sure we're trying to hit something");

            Rect3D bounds = Bounds;

            if (bounds.IsEmpty)
            {
                return;
            }

            //



            Point3D  origin;
            Vector3D direction;

            rayParams.GetLocalLine(out origin, out direction);

            if (LineUtil.ComputeLineBoxIntersection(ref origin, ref direction, ref bounds, rayParams.IsRay))
            {
                RayHitTestCore(rayParams, facesToHit);
            }

            //
        }
예제 #3
0
        //------------------------------------------------------
        //
        //  Public Properties
        //
        //------------------------------------------------------

        //------------------------------------------------------
        //
        //  Public Events
        //
        //------------------------------------------------------

        //------------------------------------------------------
        //
        //  Internal Methods
        //
        //------------------------------------------------------

        #region Internal Methods

        // NOTE: Geometry3D hit testing takes the rayParams in the outer space of the
        //       Geometry3D.  That is, RayHitTest() will apply this geometry's
        //       transform to the ray for the caller.
        //
        //       This is different than Visual hit testing which does not transform
        //       the hit testing parameters by the Visual's transform.
        internal void RayHitTest(RayHitTestParameters rayParams, FaceType facesToHit)
        {
            Debug.Assert(facesToHit != FaceType.None,
                         "Caller should make sure we're trying to hit something");

            Rect3D bounds = Bounds;

            if (bounds.IsEmpty)
            {
                return;
            }

            // Geometry3D's do not yet support a Transform property
            //
            // Transform3D transform = Transform;
            // rayParams.PushTransform(transform);


            Point3D  origin;
            Vector3D direction;

            rayParams.GetLocalLine(out origin, out direction);

            if (LineUtil.ComputeLineBoxIntersection(ref origin, ref direction, ref bounds, rayParams.IsRay))
            {
                RayHitTestCore(rayParams, facesToHit);
            }

            // Geometry3D's do not yet support a Transform property
            //
            // rayParams.PopTransform(transform);
        }
예제 #4
0
        public IActionResult WorkingCheck(int?interval)
        {
            if (!CookieUtil.IsAdmin(HttpContext))
            {
                return(NotFound());
            }

            if (jafleet.WorkingCheck.Processing)
            {
                LineUtil.PushMe("WorkingCheck 二重起動を検出", HttpClientManager.GetInstance());
                return(Content("Now Processing!!"));
            }

            _ = Task.Run(() =>
            {
                using (var serviceScope = _services.CreateScope())
                {
                    IEnumerable <AircraftView> targetReg;
                    using (var context = serviceScope.ServiceProvider.GetService <jafleetContext>())
                    {
#if DEBUG
                        targetReg = context.AircraftView.Where(a => a.RegistrationNumber == "JA26LR").AsNoTracking().ToArray();
#else
                        targetReg = context.AircraftView.Where(a => a.OperationCode != OperationCode.RETIRE_UNREGISTERED).AsNoTracking().ToArray().OrderBy(r => Guid.NewGuid());
#endif
                        var check = new WorkingCheck(targetReg, interval ?? 15);
                        _         = check.ExecuteCheckAsync();
                    }
                }
            });

            return(Content("WorkingCheck Launch!"));
        }
예제 #5
0
 public IActionResult Send(MessageModel model)
 {
     LineUtil.PushMe("【JA-Fleet from web】\n" +
                     $"名前:{model.Name}\n" +
                     $"返信先:{model.Replay}\n" +
                     $"{model.Message}", HttpClientManager.GetInstance());
     Task.Run(() => {
         using (var serviceScope = _services.CreateScope())
         {
             using (var context = serviceScope.ServiceProvider.GetService <jafleetContext>())
             {
                 var m = new Message
                 {
                     Sender        = model.Name,
                     MessageDetail = model.Message,
                     ReplayTo      = model.Replay,
                     MessageType   = Commons.Constants.MessageType.WEB,
                     RecieveDate   = DateTime.Now
                 };
                 context.Messages.Add(m);
                 context.SaveChanges();
             }
         }
     });
     return(Content("OK"));
 }
예제 #6
0
        public IActionResult Error()
        {
            var            ex    = HttpContext.Features.Get <IExceptionHandlerPathFeature>().Error;
            ErrorViewModel model = new ErrorViewModel {
                RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier
            };

            model.IsAdmin = CookieUtil.IsAdmin(HttpContext);
            model.Ex      = ex;

            LineUtil.PushMe($"【エラー発生】\n" +
                            $"{ex.ToString().Split(Environment.NewLine)[0]}\n" +
                            $"{ex.ToString().Split(Environment.NewLine)[1]}", HttpClientManager.GetInstance());

            Log log = new Log
            {
                LogDate     = DateTime.Now
                , LogType   = LogType.EXCEPTION
                , LogDetail = ex.ToString()
                , UserId    = CookieUtil.IsAdmin(HttpContext).ToString()
            };

            _context.Log.Add(log);
            _context.SaveChanges();

            return(View(model));
        }
예제 #7
0
        public void TestGetEmptyListsDifference()
        {
            List <string> list1 = new List <string>();
            List <string> list2 = new List <string>();
            List <string> diff  = LineUtil.GetLineListsDifference(list1, list2);

            Assert.IsNotNull(diff);
            Assert.AreEqual(0, diff.Count);
        }
예제 #8
0
        public void TestGetLineListSingleLineWithWhitespaceBeforeNewLine()
        {
            List <string>        lines = LineUtil.GetLineList("hello    \r\n");
            IEnumerator <string> iter  = lines.GetEnumerator();

            iter.MoveNext();
            string line = (string)iter.Current;

            Assert.AreEqual("hello    ", line);
        }
예제 #9
0
파일: FileRead.cs 프로젝트: zhifu10001/YAGP
        /// <summary>
        /// Deal with a single line. It either starts with '0' and is to be a new record,
        /// or is accumulated into a record.
        /// </summary>
        /// <param name="line"></param>
        /// <param name="lineNum"></param>
        private bool ProcessLine(char [] line, int lineNum)
        {
            int len = line.Length;
            int dex = LineUtil.FirstChar(line, 0, len);

            if (dex < 0)
            {
                if (_emptyLineSeen == 0)
                {
                    DoError(UnkRec.ErrorCode.EmptyLine, lineNum);
                }
                _emptyLineSeen++;
                return(true); // empty line
            }
            if (len > 255)    // TODO anything special for UTF-16?
            {
                DoError(UnkRec.ErrorCode.LineTooLong, lineNum);
                // proceed anyway
            }

            char level = line[dex];

            if (level < '0' || level > '9')
            {
                DoError(UnkRec.ErrorCode.InvLevel, lineNum);
                return(false); // cannot proceed
            }

            // NOTE: do NOT warn about leading spaces "GEDCOM readers should ignore it when it occurs".

            if (level == '0' && _currRec.LineCount > 0)
            {
                // start of a new record. deal with the previous record first

                // TODO records should go into a 'to parse' list and asynchronously turned into head/indi/fam/etc
                var parsed = Parser.Parse(_currRec);
                if (parsed == null)
                {
                    return(false);
                }

                Data.Add(parsed);
                _currRec = new GedRecord(lineNum, line);
            }
            else
            {
                _currRec.AddLine(line);
            }

            return(true);
        }
예제 #10
0
        /// <summary>
        /// Parse all tags from the ctags output.
        /// </summary>
        public List <Tag> ParseCtagsOutput(string inCtagsOutput)
        {
            List <Tag>    tags  = new List <Tag>();
            List <string> lines = LineUtil.GetLineList(inCtagsOutput);

            foreach (string line in lines)
            {
                Tag tag = GetTag(line);
                if (tag.GetTagType() != Tag.EType.EUnknown)
                {
                    tags.Add(tag);
                }
            }
            return(tags);
        }
예제 #11
0
        // Gets the hit testing line/ray specified as an origin and direction in
        // the current local space.
        internal void GetLocalLine(out Point3D origin, out Vector3D direction)
        {
            origin    = _origin;
            direction = _direction;

            bool isRay = true;

            if (HasWorldTransformMatrix)
            {
                LineUtil.Transform(WorldTransformMatrix, ref origin, ref direction, out isRay);
            }

            // At any point along the tree walk we may encounter a transform that turns the ray into
            // a line and if so we must stay a line
            _isRay &= isRay;
        }
예제 #12
0
        private void AddLine(Order order, int row)
        {
            Line line = new Line();

            if (ErrorUtil.IsInvoiceNumberOk(monthlyExcelFile.linesRange, row, ColumnsLines.InvoiceNumber))
            {
                line.InvoiceNumber = ExcelUtil.GetStringValue(monthlyExcelFile.linesRange, row, ColumnsLines.InvoiceNumber);
            }

            if (ErrorUtil.CheckRecordType(monthlyExcelFile.linesRange, row, RecordType.line))
            {
                line.RecordType = ExcelUtil.GetStringValue(monthlyExcelFile.linesRange, row, ColumnsLines.RecordType);
            }

            if (LineUtil.CheckUnitPrice(monthlyExcelFile.linesRange, row))
            {
                line.UnitPriceTI = ExcelUtil.GetStringValue(monthlyExcelFile.linesRange, row, ColumnsLines.UnitPriceTI);
            }

            if (LineUtil.CheckQuantity(monthlyExcelFile.linesRange, row))
            {
                line.Quantity = ExcelUtil.GetStringValue(monthlyExcelFile.linesRange, row, ColumnsLines.Quantity);
            }

            if (LineUtil.CheckProductTypeExist(monthlyExcelFile.linesRange, row, catalogExcelFile.range))
            {
                line.ProductCode = ExcelUtil.GetStringValue(monthlyExcelFile.linesRange, row, ColumnsLines.Product);
            }

            line.AMZProductCode             = ExcelUtil.GetStringValue(monthlyExcelFile.linesRange, row, ColumnsLines.AMZProductCode);
            line.SaleUnitType               = ExcelUtil.GetStringValue(monthlyExcelFile.linesRange, row, ColumnsLines.SaleUnitType);
            line.BoxesQuantity              = ExcelUtil.GetStringValue(monthlyExcelFile.linesRange, row, ColumnsLines.BoxesQuantity);
            line.PackageQuantity            = ExcelUtil.GetStringValue(monthlyExcelFile.linesRange, row, ColumnsLines.PackageQuantity);
            line.Discount                   = ExcelUtil.GetStringValue(monthlyExcelFile.linesRange, row, ColumnsLines.Discount);
            line.DiscountPrecent            = ExcelUtil.GetStringValue(monthlyExcelFile.linesRange, row, ColumnsLines.DiscountPrecent);
            line.SaleDiscount               = ExcelUtil.GetStringValue(monthlyExcelFile.linesRange, row, ColumnsLines.SaleDiscount);
            line.SaleDiscountPrecent        = ExcelUtil.GetStringValue(monthlyExcelFile.linesRange, row, ColumnsLines.SaleDiscountPrecent);
            line.DistrbutionDiscount        = ExcelUtil.GetStringValue(monthlyExcelFile.linesRange, row, ColumnsLines.DistrbutionDiscount);
            line.DistrbutionDiscountPrecent = ExcelUtil.GetStringValue(monthlyExcelFile.linesRange, row, ColumnsLines.DistrbutionDiscountPrecent);

            order.Lines.Add(line);
            recordsToBeDeleted.Add(new RecordToBeDeleted {
                Record = row, Sheet = Sheets.LinesSheetNumber
            });
        }
예제 #13
0
        /// <summary>
        /// Determine the level value for a line.
        /// </summary>
        /// <param name="linedex">Index in the record for the line in question</param>
        /// <param name="sublinedex">The index WITHIN the line for the first character. non-zero if leading spaces.</param>
        /// <returns>Space on error; otherwise the level as a character</returns>
        public char GetLevel(int linedex, out int sublinedex)
        {
            sublinedex = -1;
            if (linedex >= Max)
            {
                return(' ');
            }
            var line = _lines[linedex];
            int dex  = LineUtil.FirstChar(line, 0, line.Length);

            // Can't happen? empty lines stripped earlier...
            //if (dex < 0)
            //    return ' '; // empty line
            sublinedex = dex;
            return(line[dex]);

            // TODO can level values exceed 9 ???
        }
예제 #14
0
        public void TestGetLineList()
        {
            List <string>        lines      = null;
            IEnumerator <string> enumerator = null;

            lines = LineUtil.GetLineList("");
            Assert.AreEqual(0, lines.Count);

            lines = LineUtil.GetLineList("hello\r\nworld\r\n");
            Assert.AreEqual(3, lines.Count);
            enumerator = lines.GetEnumerator();
            enumerator.MoveNext();
            Assert.AreEqual("hello", (string)enumerator.Current);
            enumerator.MoveNext();
            Assert.AreEqual("world", (string)enumerator.Current);
            enumerator.MoveNext();
            Assert.AreEqual("", (string)enumerator.Current);
        }
예제 #15
0
        private void PassLinesLeft()
        {
            Excel.Range range  = monthlyExcelFile.linesRange;
            int         length = ExcelUtil.GetLastRow(range.Worksheet);

            for (int row = 2; row < length; row++)
            {
                if (IsAnyCellContainsValue(range, row))
                {
                    ErrorUtil.IsInvoiceNumberOk(range, row, ColumnsLines.InvoiceNumber);

                    ErrorUtil.CheckRecordType(range, row, RecordType.line);

                    LineUtil.CheckUnitPrice(range, row);

                    LineUtil.CheckQuantity(range, row);

                    LineUtil.CheckProductTypeExist(range, row, catalogExcelFile.range);
                }
            }
        }
예제 #16
0
        public void TestGetNonEmptyListsDifference()
        {
            List <string> list1 = new List <string>();

            list1.Add("hello");
            list1.Add("hi");
            List <string> list2 = new List <string>();

            list2.Add("hello");
            list2.Add("world");

            List <string> diff = LineUtil.GetLineListsDifference(list1, list2);

            Assert.IsNotNull(diff);
            Assert.AreEqual(1, diff.Count);

            IEnumerator <string> iter = diff.GetEnumerator();

            iter.MoveNext();
            Assert.AreEqual("world", (string)iter.Current);
        }
예제 #17
0
        /// <summary>
        /// Remove #include statements from C++ source.
        /// </summary>
        /// <param name="ioContents"></param>
        public void RemoveIncludes(ref string ioContents)
        {
            List <string> lines       = LineUtil.GetLineList(ioContents);
            StringBuilder output      = new StringBuilder();
            bool          add_newline = false;

            foreach (string line in lines)
            {
                if (add_newline)
                {
                    output.Append("\r\n");
                }
                add_newline = true;

                string trimmed_line = line.Trim();
                if (!IncludeFinder.IsInclude(line))
                {
                    output.Append(line);
                }
            }
            ioContents = output.ToString();
        }
예제 #18
0
        //
        // Hits the ray against the mesh
        //
        internal override void RayHitTestCore(
            RayHitTestParameters rayParams,
            FaceType hitTestableFaces)
        {
            Debug.Assert(hitTestableFaces != FaceType.None,
                         "Caller should make sure we're trying to hit something");

            Point3DCollection positions = Positions;

            if (positions == null)
            {
                return;
            }

            Point3D  origin;
            Vector3D direction;

            rayParams.GetLocalLine(out origin, out direction);

            Int32Collection indices = TriangleIndices;

            // In the line case, we want to hit test all faces because we don't
            // have a direction. This may differ from what faces we want to
            // accept.
            FaceType facesToHit;

            if (rayParams.IsRay)
            {
                facesToHit = hitTestableFaces;
            }
            else
            {
                facesToHit = FaceType.Front | FaceType.Back;
            }


            //
            // This code duplication is unfortunate but necessary. Breaking it down into methods
            // further significantly impacts performance. About 5% improvement could be made
            // by unrolling this code below even more.
            //
            // If futher perf investigation is done with this code, be sure to test NGEN assemblies only
            // as JIT produces different, faster code than NGEN.
            //

            if (indices == null || indices.Count == 0)
            {
                FrugalStructList <Point3D> ps = positions._collection;
                int count = ps.Count - (ps.Count % 3);

                for (int i = count - 1; i >= 2; i -= 3)
                {
                    int i0 = i - 2;
                    int i1 = i - 1;
                    int i2 = i;

                    Point3D v0 = ps[i0];
                    Point3D v1 = ps[i1];
                    Point3D v2 = ps[i2];

                    double hitTime;
                    Point  barycentric;

                    // The line hit test is equivalent to a double sided
                    // triangle hit because it doesn't cull triangles based
                    // on winding
                    if (LineUtil.ComputeLineTriangleIntersection(
                            facesToHit,
                            ref origin,
                            ref direction,
                            ref v0,
                            ref v1,
                            ref v2,
                            out barycentric,
                            out hitTime
                            )
                        )
                    {
                        if (rayParams.IsRay)
                        {
                            ValidateRayHit(
                                rayParams,
                                ref origin,
                                ref direction,
                                hitTime,
                                i0,
                                i1,
                                i2,
                                ref barycentric
                                );
                        }
                        else
                        {
                            ValidateLineHit(
                                rayParams,
                                hitTestableFaces,
                                i0,
                                i1,
                                i2,
                                ref v0,
                                ref v1,
                                ref v2,
                                ref barycentric
                                );
                        }
                    }
                }
            }
            else // indexed mesh
            {
                FrugalStructList <Point3D> ps   = positions._collection;
                FrugalStructList <int>     idcs = indices._collection;

                int count = idcs.Count;
                int limit = ps.Count;

                for (int i = 2; i < count; i += 3)
                {
                    int i0 = idcs[i - 2];
                    int i1 = idcs[i - 1];
                    int i2 = idcs[i];

                    // Quit if we encounter an index out of range.
                    // This is okay because the triangles we ignore are not rendered.
                    //  (see: CMilMeshGeometry3DDuce::Realize)
                    if ((0 > i0 || i0 >= limit) ||
                        (0 > i1 || i1 >= limit) ||
                        (0 > i2 || i2 >= limit))
                    {
                        break;
                    }

                    Point3D v0 = ps[i0];
                    Point3D v1 = ps[i1];
                    Point3D v2 = ps[i2];

                    double hitTime;
                    Point  barycentric;

                    if (LineUtil.ComputeLineTriangleIntersection(
                            facesToHit,
                            ref origin,
                            ref direction,
                            ref v0,
                            ref v1,
                            ref v2,
                            out barycentric,
                            out hitTime
                            )
                        )
                    {
                        if (rayParams.IsRay)
                        {
                            ValidateRayHit(
                                rayParams,
                                ref origin,
                                ref direction,
                                hitTime,
                                i0,
                                i1,
                                i2,
                                ref barycentric
                                );
                        }
                        else
                        {
                            ValidateLineHit(
                                rayParams,
                                hitTestableFaces,
                                i0,
                                i1,
                                i2,
                                ref v0,
                                ref v1,
                                ref v2,
                                ref barycentric
                                );
                        }
                    }
                }
            }
        }
예제 #19
0
        public void CreateCut(int segmentID, Plane jointPlane0, Plane jointPlane1, double length_, ref Panel jointPanel, bool bake = false)  //, ref Panel neiPanel,) {
        //jointPlane0.Bake(40);

        //jointPlane1.Bake(40);

        {
            double e = 0;


            Polyline cut = new Polyline();

            Line segment0 = contourNoJoints[0].SegmentAt(segmentID);
            Line segment1 = contourNoJoints[1].SegmentAt(segmentID);

            double dist   = this.plane.Origin.DistanceTo(segment0.PointAt(0.5));
            double length = length_;// * dist * 0.01;


            //Rhino.RhinoApp.WriteLine(dist.ToString());

            //Intersect plate edge line and joint plane offsets
            Point3d edgePoint00 = PlaneUtil.LinePlane(segment0, jointPlane0);
            Point3d edgePoint01 = PlaneUtil.LinePlane(segment0, jointPlane1);
            Point3d edgePoint10 = PlaneUtil.LinePlane(segment1, jointPlane0);
            Point3d edgePoint11 = PlaneUtil.LinePlane(segment1, jointPlane1);

            //Get direction of a cut
            Vector3d v00 = PlaneUtil.PlanePlaneVec(planeOffset0, jointPlane0).Unit();
            Vector3d v01 = PlaneUtil.PlanePlaneVec(planeOffset0, jointPlane1).Unit();
            Vector3d v10 = PlaneUtil.PlanePlaneVec(planeOffset1, jointPlane0).Unit();
            Vector3d v11 = PlaneUtil.PlanePlaneVec(planeOffset1, jointPlane1).Unit();


            //Really f****d up way of checking which direction plane must be offseted for correct cut direction
            Point3d p0 = mesh.ClosestPoint((segment0.PointAt(0.5) + v00 * 10));
            Point3d p1 = mesh.ClosestPoint((segment0.PointAt(0.5) - v00 * 10));
            //bool moveFlag = (segment0.PointAt(0.5) + v00*10).DistanceTo(planeOffset0.Origin) < (segment0.PointAt(0.5) - v00*10).DistanceTo(planeOffset0.Origin);
            bool moveFlag = p0.DistanceToSquared((segment0.PointAt(0.5) + v00 * 10)) < p1.DistanceToSquared((segment0.PointAt(0.5) - v00 * 10));


            //if (bake) {


            //Rhino.RhinoDoc.ActiveDoc.Objects.AddPoint(planeOffset0.Origin);
            //Rhino.RhinoDoc.ActiveDoc.Objects.AddPoint(segment0.PointAt(0.5) + v00*100);
            //Rhino.RhinoDoc.ActiveDoc.Objects.AddPoint(segment0.PointAt(0.5) - v00*100);

            //}

            //Moved Points
            Point3d innerPoint00     = (moveFlag) ? edgePoint00 + (v00 * length) : edgePoint00 - (v00 * length);
            Point3d innerPoint01     = (moveFlag) ? edgePoint01 + (v01 * length) : edgePoint01 - (v01 * length);
            Point3d innerPoint10     = (moveFlag) ? edgePoint10 + (v10 * length) : edgePoint10 - (v10 * length);
            Point3d innerPoint11     = (moveFlag) ? edgePoint11 + (v11 * length) : edgePoint11 - (v11 * length);
            Point3d innerPointCenter = (innerPoint00 + innerPoint01 + innerPoint10 + innerPoint11) * 0.25;
            //Plane perpPlane = new Plane(innerPointCenter, jointPlane0.Normal, Vector3d.CrossProduct(planeOffset0.Normal, v00));
            Plane perpPlane = new Plane(innerPointCenter, jointPlane0.Normal, planeOffset0.Normal);

            //perpPlane = perpPlane.Switch("XZ");

            //if (planeOffset0.IsValid)
            //    planeOffset0.Bake(40);

            //if (jointPlane0.IsValid)
            //    jointPlane0.Bake(40);

            //if (perpPlane.IsValid)
            //    perpPlane.Bake(40);

            innerPoint00 = perpPlane.RayPlane(edgePoint00, v00);
            innerPoint01 = perpPlane.RayPlane(edgePoint01, v01);
            innerPoint10 = perpPlane.RayPlane(edgePoint10, v10);
            innerPoint11 = perpPlane.RayPlane(edgePoint11, v11);



            //Middle points and projection to plane
            Point3d innerPointMid00 = (moveFlag) ? edgePoint00 + (v00 * length * 0.5) : edgePoint00 - (v00 * length * 0.5);
            Point3d innerPointMid01 = (moveFlag) ? edgePoint01 + (v01 * length * 0.5) : edgePoint01 - (v01 * length * 0.5);
            Point3d innerPointMid10 = (moveFlag) ? edgePoint10 + (v10 * length * 0.5) : edgePoint10 - (v10 * length * 0.5);
            Point3d innerPointMid11 = (moveFlag) ? edgePoint11 + (v11 * length * 0.5) : edgePoint11 - (v11 * length * 0.5);
            Point3d innerPointMid   = (innerPointMid00 + innerPointMid01 + innerPointMid10 + innerPointMid11) * 0.25;
            Plane   perpPlaneMid    = new Plane(innerPointMid, jointPlane0.Normal, perpPlane.YAxis);


            //if (planeOffset0.IsValid)
            //    planeOffset0.Bake(40);


            //if(perpPlaneMid.IsValid)
            //perpPlaneMid.Bake(40);

            innerPointMid00 = perpPlaneMid.RayPlane(edgePoint00, v00);
            innerPointMid01 = perpPlaneMid.RayPlane(edgePoint01, v01);
            innerPointMid10 = perpPlaneMid.RayPlane(edgePoint10, v10);
            innerPointMid11 = perpPlaneMid.RayPlane(edgePoint11, v11);



            //It is not closest point because the connection is not perpendicular to two adjacent plates
            //It might be close to perpendicular but not possible

            //edgePoint00.Bake();
            //innerPointMid00.Bake();
            //innerPointMid01.Bake();
            //edgePoint01.Bake();

            //edgePoint10.Bake();
            //innerPointMid10.Bake();
            //innerPointMid11.Bake();
            //edgePoint11.Bake();

            Polyline cut0 = new Polyline(new Point3d[] { edgePoint00, innerPointMid00 + v00 * e, innerPointMid01 + v01 * e, edgePoint01 });//perpPlane.ClosestPoint
            Polyline cut1 = new Polyline(new Point3d[] { edgePoint10, innerPointMid10 + v10 * e, innerPointMid11 + v11 * e, edgePoint11 });

            this.cuts.Add(cut0);
            this.cuts.Add(cut1);



            Polyline cutNei0 = new Polyline(new Point3d[] { innerPoint00, innerPointMid00 + v00 * -e, innerPointMid10 + v01 * -e, innerPoint10 });//perpPlane.ClosestPoint
            Polyline cutNei1 = new Polyline(new Point3d[] { innerPoint01, innerPointMid01 + v10 * -e, innerPointMid11 + v11 * -e, innerPoint11 });

            jointPanel.cuts.Add(cutNei0);
            jointPanel.cuts.Add(cutNei1);


            contour[0].InsertPolyline(cut0);
            contour[1].InsertPolyline(cut1);


            double additionalExtend = 20;

            //if (additionalExtend > 0) {
            //    Vector3d v0 = (cutNei0[0] - cutNei0[1]).UnitVector() * additionalExtend;
            //    Vector3d v1 = (cutNei0[3] - cutNei0[2]).UnitVector() * additionalExtend;
            //    cutNei0[0] += v0;
            //    cutNei0[0] += v1;

            //    v0 = (cutNei1[0] - cutNei1[1]).UnitVector() * additionalExtend;
            //    v1 = (cutNei1[3] - cutNei1[2]).UnitVector() * additionalExtend;
            //    cutNei1[0] += v0;
            //    cutNei1[0] += v1;
            //}


            cutNei0[0] = LineUtil.LineLine(cutNei0.SegmentAt(0), jointPanel.contour[0].SegmentAt((int)Math.Floor(jointPanel.contour[0].ClosestParameter(cutNei0[0]))));
            cutNei0[3] = LineUtil.LineLine(cutNei0.SegmentAt(2), jointPanel.contour[0].SegmentAt((int)Math.Floor(jointPanel.contour[0].ClosestParameter(cutNei0[3]))));

            cutNei1[0] = LineUtil.LineLine(cutNei1.SegmentAt(0), jointPanel.contour[1].SegmentAt((int)Math.Floor(jointPanel.contour[1].ClosestParameter(cutNei1[0]))));
            cutNei1[3] = LineUtil.LineLine(cutNei1.SegmentAt(2), jointPanel.contour[1].SegmentAt((int)Math.Floor(jointPanel.contour[1].ClosestParameter(cutNei1[3]))));
            jointPanel.contour[0].InsertPolyline(cutNei0);
            jointPanel.contour[1].InsertPolyline(cutNei1);

            //cutNei0.Bake();
            //cutNei1.Bake();

            //if (bake) {
            //    Rhino.RhinoDoc.ActiveDoc.Objects.AddPolyline(cut0);
            //    Rhino.RhinoDoc.ActiveDoc.Objects.AddPolyline(cut1);
            //}

            //Rhino.RhinoDoc.ActiveDoc.Objects.AddPolyline(cutNei0);
            //Rhino.RhinoDoc.ActiveDoc.Objects.AddPolyline(cutNei1);
        }
예제 #20
0
        public void TestGetLineListSingleLineWithNewLine()
        {
            List <string> lines = LineUtil.GetLineList("hello\r\n");

            Assert.AreEqual(2, lines.Count);
        }
예제 #21
0
        protected virtual Geometry GetDefiningGeometry()
        {
            bool isStartVisible = IsStartVisible;
            bool isEndVisible   = IsEndVisible;

            double radius    = Radius;
            double thickness = GetThickness();

            double sx = X1;
            double sy = Y1;
            double ex = X2;
            double ey = Y2;

            double zet    = LineUtil.Zet(sx, sy, ex, ey);
            double width  = LineUtil.Width(radius, thickness, zet);
            double height = LineUtil.Height(radius, thickness, zet);

            bool shortenStart = GetShortenStart(this);
            bool shortenEnd   = GetShortenEnd(this);
            bool isStartIO    = GetStartIO();
            bool isEndIO      = GetEndIO();

            // shorten start
            if (isStartIO == true && isEndIO == false && shortenStart == true)
            {
                if (Math.Round(sy, 1) == Math.Round(ey, 1))
                {
                    sx = ex - ShortenLineSize;
                }
            }

            // shorten end
            if (isStartIO == false && isEndIO == true && shortenEnd == true)
            {
                if (Math.Round(sy, 1) == Math.Round(ey, 1))
                {
                    ex = sx + ShortenLineSize;
                }
            }

            // get ellipse position
            IPoint ellipseStart = LineUtil.EllipseStart(sx, sy, width, height, isStartVisible);
            IPoint ellipseEnd   = LineUtil.EllipseEnd(ex, ey, width, height, isEndVisible);

            // get line position
            IPoint lineStart = LineUtil.LineStart(sx, sy, width, height, isStartVisible);
            IPoint lineEnd   = LineUtil.LineEnd(ex, ey, width, height, isEndVisible);

            var g = new GeometryGroup()
            {
                FillRule = FillRule.Nonzero
            };

            if (isStartVisible == true)
            {
                var startEllipse = new EllipseGeometry(
                    new Point(ellipseStart.X, ellipseStart.Y),
                    radius, radius);

                g.Children.Add(startEllipse);
            }

            if (isEndVisible == true)
            {
                var endEllipse = new EllipseGeometry(
                    new Point(ellipseEnd.X, ellipseEnd.Y),
                    radius, radius);

                g.Children.Add(endEllipse);
            }

            var line = new LineGeometry(
                new Point(lineStart.X, lineStart.Y),
                new Point(lineEnd.X, lineEnd.Y));

            g.Children.Add(line);

            g.Freeze();
            return(g);
        }
예제 #22
0
        public void TestGetLineListSingleLine()
        {
            List <string> lines = LineUtil.GetLineList("hello");

            Assert.AreEqual(1, lines.Count);
        }
예제 #23
0
        public async System.Threading.Tasks.Task <IActionResult> Photo(string id, [FromQuery] bool force)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(BadRequest());
            }

            var      photo = _context.AircraftPhoto.Where(p => p.RegistrationNumber == id).SingleOrDefault();
            Aircraft a     = null;

            if (photo != null && DateTime.Now.Date == photo.LastAccess.Date && !force)
            {
                if (photo.PhotoUrl != null)
                {
                    //1日以内のキャッシュがあれば、キャッシュから返す
                    return(Redirect($"https://www.jetphotos.com{photo.PhotoUrl}"));
                }
                else
                {
                    //キャッシュがNULLの場合は、リンクURLもNULLの場合のみnophotoを返す
                    //そうしないとキャッシュがNULLで、あとからLinkUrlを登録した場合に最大1日待つ必要が出る。
                    a = _context.Aircraft.Where(p => p.RegistrationNumber == id.ToUpper()).FirstOrDefault();
                    if (string.IsNullOrEmpty(a.LinkUrl))
                    {
                        return(Redirect("/nophoto.html"));
                    }
                    else
                    {
                        return(ReturnLinkUrl(a.LinkUrl));
                    }
                }
            }

            string jetphotoUrl = string.Format("https://www.jetphotos.com/showphotos.php?keywords-type=reg&keywords={0}&search-type=Advanced&keywords-contain=0&sort-order=2", id);

            if (a == null)
            {
                a = _context.Aircraft.Where(p => p.RegistrationNumber == id.ToUpper()).FirstOrDefault();
            }
            var parser = new HtmlParser();

            try
            {
                var htmlDocument = parser.ParseDocument(await HttpClientManager.GetInstance().GetStringAsync(jetphotoUrl));
                var photos       = htmlDocument.GetElementsByClassName("result__photoLink");
                if (photos.Length != 0)
                {
                    //Jetphotosに写真があった場合
                    string newestPhotoLink = photos[0].GetAttribute("href");
                    var    photoTag        = htmlDocument.GetElementsByClassName("result__photo");
                    string directUrl       = null;
                    if (photoTag.Length != 0)
                    {
                        directUrl = photoTag[0].GetAttribute("src").Replace("//cdn.jetphotos.com/400", string.Empty);
                    }

                    _ = Task.Run(() =>
                    {
                        //写真をキャッシュに登録する
                        using var serviceScope = _services.CreateScope();
                        using var context      = serviceScope.ServiceProvider.GetService <jafleetContext>();
                        if (!string.IsNullOrEmpty(a.LinkUrl))
                        {
                            //Jetphotosから取得できるのにDBにも登録されている場合は、DBから消す
                            a.LinkUrl          = null;
                            a.ActualUpdateTime = DateTime.Now;
                            context.Aircraft.Update(a);
                            LineUtil.PushMe($"{id}のLinkUrlを削除しました", HttpClientManager.GetInstance());
                        }
                        StoreAircraftPhoto(context, photo, newestPhotoLink, id, directUrl);
                    });
                    return(Redirect($"https://www.jetphotos.com{newestPhotoLink}"));
                }
                else
                {
                    if (string.IsNullOrEmpty(a?.LinkUrl))
                    {
                        //Jetphotosに写真がなかった場合
                        _ = Task.Run(() =>
                        {
                            //写真がないという情報を登録する
                            using var serviceScope = _services.CreateScope();
                            using var context      = serviceScope.ServiceProvider.GetService <jafleetContext>();
                            StoreAircraftPhoto(context, photo, null, id, null);
                        });
                        return(Redirect("/nophoto.html"));
                    }
                    else
                    {
                        return(ReturnLinkUrl(a.LinkUrl));
                    }
                }
            }
            catch
            {
                return(Redirect($"/failphotoload.html?reg={id}"));
            }
        }
예제 #24
0
        public void TestGetLineListEmptyString()
        {
            List <string> lines = LineUtil.GetLineList("");

            Assert.AreEqual(0, lines.Count);
        }