public TotalDto GetTotal(bool isSearch, int rows, int page, string sortBy, string sortOrder, string filters)
        {
            TotalDto           total = new TotalDto();
            IEnumerable <Line> query = GetFilteredAll(isSearch, filters);

            Line[] filteredAll = query.ToArray();
            foreach (var line in filteredAll)
            {
                if (line.IsActive)
                {
                    var busesToLines = line.BusesToLines.FirstOrDefault();
                    if (busesToLines != null)
                    {
                        var bus = busesToLines.Bus;
                        DateHelper.IterDays(7, weekDay =>
                        {
                            if (LineHelper.IsLineActiveAtDay(line, (DayOfWeek)(weekDay - 1)))
                            {
                                total.Seats    += bus.seats.HasValue ? busesToLines.Bus.seats.Value : 0;
                                total.Students += line.totalStudents.HasValue ? line.totalStudents.Value : 0;
                                total.WeekDayPrices[weekDay - 1] += bus.price ?? 0;
                                total.Price += bus.price.HasValue ? busesToLines.Bus.price.Value : 0;
                            }
                        });
                    }
                }
            }
            return(total);
        }
 Vector2 InsertVectorToArray(Vector2 pos)
 {
     for (int i = 0; i < currentPosArray.Count - 1; i++)
     {
         if (pos.x >= currentPosArray[i].x - GameController.playerSpeed &&
             currentPosArray[i].x + GameController.playerSpeed >= pos.x &&
             pos.y >= currentPosArray[i].y - GameController.playerSpeed &&
             currentPosArray[i].y + GameController.playerSpeed >= pos.y)
         {
             return(currentPosArray[i]);
         }
     }
     for (int i = 0; i < currentPosArray.Count; i++)
     {
         int nextIndex = (i < currentPosArray.Count - 1) ? i + 1 : 0;
         if (LineHelper.isVectorIntersect(pos, new myLine()
         {
             StartPoint = currentPosArray[i], EndPoint = currentPosArray[nextIndex]
         }, GameController.playerSpeed * 1.2f))
         {
             pos.x = (currentPosArray[i].x == currentPosArray[nextIndex].x) ? currentPosArray[i].x : pos.x;
             pos.y = (currentPosArray[i].y == currentPosArray[nextIndex].y) ? currentPosArray[i].y : pos.y;
             currentPosArray.Insert(i + 1, pos);
             return(pos);
         }
     }
     return(Vector3.zero);
 }
Beispiel #3
0
        private void PointInternal(IToolContext context, double x, double y, Modifier modifier)
        {
            Filters?.Any(f => f.Process(context, ref x, ref y));

            CurrentState = State.StartPoint;

            context.Renderer.SelectedShapes.Remove(_line.StartPoint);
            context.Renderer.SelectedShapes.Remove(_line.Point);
            context.WorkingContainer.Shapes.Remove(_line);

            _line.Point = context.GetNextPoint(x, y, Settings?.ConnectPoints ?? false, Settings?.HitTestRadius ?? 0.0);

            Intersections?.ForEach(i => i.Clear(context));
            Intersections?.ForEach(i => i.Find(context, _line));

            if ((Settings?.SplitIntersections ?? false) && (Intersections?.Any(i => i.Intersections.Count > 0) ?? false))
            {
                LineHelper.SplitByIntersections(context, Intersections, _line);
            }
            else
            {
                context.CurrentContainer.Shapes.Add(_line);
            }

            _line = null;

            Intersections?.ForEach(i => i.Clear(context));
            Filters?.ForEach(f => f.Clear(context));

            context.Release?.Invoke();
            context.Invalidate?.Invoke();
        }
        public void ExcuteAnalyzeFile()
        {
            if (FilePath == "")
            {
                State = "请输入文件路径";
                return;
            }

            State = "解析中...";
            Task.Factory.StartNew(() =>
            {
                try
                {
                    HeapFileAnalyzer x = new HeapFileAnalyzer(FilePath);

                    x.DoWork();
                    Msgs  = LineHelper.GetMessages(x);
                    State = "解析完成!";
                }
                catch
                {
                    State = "解析出现异常";
                }
            });
        }
Beispiel #5
0
    public override void OnInspectorGUI()
    {
        UIManConfig config = target as UIManConfig;

        if (screenPath == null || dialogPath == null || bgPath == null)
        {
            screenPath = new PathBrowser(config.screenPrefabFolder, rootUrl);
            dialogPath = new PathBrowser(config.dialogPrefabFolder, rootUrl);
            bgPath     = new PathBrowser(config.backgroundRootFolder, rootUrl);
        }

        LableHelper.TitleLabel("UIMan Configuration");
        LineHelper.Draw(Color.blue);
        EditorGUILayout.Space();

        GUILayout.BeginVertical("Box");
        config.screenPrefabFolder   = screenPath.Draw(screenGUI);
        config.dialogPrefabFolder   = dialogPath.Draw(dialogGUI);
        config.backgroundRootFolder = bgPath.Draw(bgGUI);
        GUILayout.EndVertical();

        GUILayout.BeginHorizontal("Box");
        GUILayout.Label("<b>Warning:</b> This configuration use to set default path of prefabs/images for UI, all url must be child of Unity's Resources folder\n\n" +
                        "If you don't want to use this fault path for your Screen/Dialog, apply UIDescriptor to your class to define custom path", EditorGUIHelper.RichText(true));
        GUILayout.EndHorizontal();

        EditorUtility.SetDirty(target);
    }
Beispiel #6
0
    /// <summary>
    /// <para>计算子弹进行匀速圆周运动时的最大半径.</para>
    /// 子弹必须以不大于这个值的半径飞行, 不然会持续绕目标飞行而不会命中.
    /// </summary>
    float computeMaxRadius(float x1, float y1, float x2, float y2, float alpha)
    {
        LineHelper e1 = new LineHelper();

        e1.fromPoints(x1, y1, x2, y2);

        //Vector3 tmp = Utility.MoveVector3Towards(new Vector3(x1, 0, y1), alpha, 1f);
        //tmp -= new Vector3(x1, 0f, y1);
        //alpha = (float)Mathf.Atan2(tmp.z, tmp.x);

        LineHelper e2 = new LineHelper();

        if (alpha > Mathf.PI)
        {
            alpha -= Mathf.PI * 2f;
        }

        e2.fromSlopeAndPoint(Mathf.PI / 2f - alpha, x1, y1);

        Vector2 c = Vector2.zero;

        if (!e1.crossPoint(out c, e2))
        {
            return(float.NaN);
        }

        //float dbg1 = (c - (new Vector2(x1, y1))).sqrMagnitude;
        //float dbg2 = (c - (new Vector2(x2, y2))).sqrMagnitude;
        //if (!Utility.isZero(dbg1 - dbg2))
        //{
        //    ErrorHandler.Parse(ErrorCode.LogicError, "");
        //}

        return((c - (new Vector2(x1, y1))).magnitude);
    }
Beispiel #7
0
    public override void OnInspectorGUI()
    {
        var config = this.target as UIManConfig;

        if (this.namespaceField == null || this.screenPath == null || this.dialogPath == null || this.bgPath == null)
        {
            this.namespaceField = new TextFieldHelper(config.classNamespace);
            this.screenPath     = new PathBrowser(config.screenPrefabFolder, Application.dataPath);
            this.dialogPath     = new PathBrowser(config.dialogPrefabFolder, Application.dataPath);
            this.bgPath         = new PathBrowser(config.backgroundRootFolder, Application.dataPath);
            this.animPath       = new PathBrowser(config.animRootFolder, Application.dataPath);
        }

        LabelHelper.TitleLabel("UIMan Configuration");
        LineHelper.Draw(Color.blue);
        EditorGUILayout.Space();

        GUILayout.BeginVertical("Box");
        config.classNamespace       = this.namespaceField.Draw(this.namespaceGUI);
        config.screenPrefabFolder   = this.screenPath.Draw(this.screenGUI);
        config.dialogPrefabFolder   = this.dialogPath.Draw(this.dialogGUI);
        config.backgroundRootFolder = this.bgPath.Draw(this.bgGUI);
        config.animRootFolder       = this.animPath.Draw(this.animRootGUI);
        GUILayout.EndVertical();

        GUILayout.BeginHorizontal("Box");
        GUILayout.Label("<b>Warning:</b> This configuration use to set default path of prefabs/images for UI, destination folder must be child of Unity's Resources folder.\n\n" +
                        "If you don't want to use this default path for your Screen/Dialog, apply UIDescriptor to your class to define custom path.", EditorGUIHelper.RichText(true));
        GUILayout.EndHorizontal();

        EditorUtility.SetDirty(this.target);
    }
    Orientation isEnemyZoneCollide()
    {
        List <Vector2> pointsList = GameController.Inst.GetEnemyZone();

        for (int i = 0; i < pointsList.Count; i++)
        {
            int    nextIndex = (i < pointsList.Count - 1) ? i + 1 : 0;
            myLine line      = new myLine()
            {
                StartPoint = pointsList[i], EndPoint = pointsList[nextIndex]
            };
            if (LineHelper.isVectorIntersect(transform.position, line, 0.02f))
            {
                if ((line.StartPoint.x - line.EndPoint.x) < 0.2f && (line.StartPoint.x - line.EndPoint.x) > -0.2f)
                {
                    return(Orientation.Vertical);
                }
                else if ((line.StartPoint.y - line.EndPoint.y) < 0.2f && (line.StartPoint.y - line.EndPoint.y) > -0.2f)
                {
                    return(Orientation.Horizontal);
                }
            }
        }
        if (!LineHelper.IsPointInPolygon(pointsList, transform.position))
        {
            return(Orientation.Vertical);
        }
        return(Orientation.NONE);
    }
        public void UpdateDbModel(Line existingLine)
        {
            existingLine.LineName   = LineName;
            existingLine.LineNumber = LineNumber;
            existingLine.Direction  = (int)Direction;
            existingLine.IsActive   = IsActive;
            // existingLine.totalStudents = totalStudents; // Can not be modefied in lines grid
            // existingLine.Duration = Duration; // Can not be modefied in lines grid
            existingLine.Sun     = Sun;
            existingLine.SunTime = DateHelper.StringToTime(SunTime);
            existingLine.Mon     = Mon;
            existingLine.MonTime = DateHelper.StringToTime(MonTime);
            existingLine.Tue     = Tue;
            existingLine.TueTime = DateHelper.StringToTime(TueTime);
            existingLine.Wed     = Wed;
            existingLine.WedTime = DateHelper.StringToTime(WedTime);
            existingLine.Thu     = Thu;
            existingLine.ThuTime = DateHelper.StringToTime(ThuTime);
            existingLine.Fri     = Fri;
            existingLine.FriTime = DateHelper.StringToTime(FriTime);
            existingLine.Sut     = Sut;
            existingLine.SutTime = DateHelper.StringToTime(SutTime);

            LineHelper.RefreshActive(existingLine);
        }
Beispiel #10
0
    /// <summary>
    /// This Update is responsible for cheking is player in collider;
    /// </summary>
    void FixedUpdate()
    {
        Vector3 newPos = GetPlayerPos();

        if (playerPosition != newPos)
        {
            bool isInPoligon = LineHelper.IsPointInPolygon(zoneManager.currentPosArray, newPos);
            if (!isDrawingNewZone && isInPoligon)
            {
                isDrawingNewZone = true;

                if (onStartMoving != null)
                {
                    onStartMoving(newPos);
                }
            }
            if (isDrawingNewZone && !isInPoligon)
            {
                isDrawingNewZone = false;

                if (onEndMoving != null)
                {
                    onEndMoving(newPos);
                }
                player.StopMoving();
            }
            playerPosition = newPos;
        }
    }
Beispiel #11
0
        public void Draw(GraphicsDevice graphicsDevice, Matrix viewProjection, EffectParameter worldViewProjection, EffectPass vertexColorPass)
        {
            if (!GameSettings.d_drawlines)
            {
                return;
            }

            worldViewProjection.SetValue(viewProjection);

            for (int i = 0; i < Lines.Count; i++)
            {
                LineHelper line = Lines[i];
                if (line != null)
                {
                    vertexColorPass.Apply();

                    //Gather
                    graphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.LineList, line.Verts, 0, 2, LineHelper.Indices,
                                                             0,
                                                             1);

                    line.Timer--;
                    if (line.Timer <= 0)
                    {
                        Lines.RemoveAt(i);
                        i--;
                    }
                }
                else
                {
                    Lines.RemoveAt(i);
                }
            }
            AdjustTempVertsPoolSize();
        }
Beispiel #12
0
        public static List <ErrorLine> DetectErrorLines(TextDocument document)
        {
            List <ErrorLine> errorLines = new List <ErrorLine>();

            bool commandSectionCheckRequired = DocumentHelper.DocumentContainsSections(document);

            foreach (DocumentLine processedLine in document.Lines)
            {
                string processedLineText = document.GetText(processedLine.Offset, processedLine.Length);

                if (LineHelper.IsEmptyLine(processedLineText))
                {
                    continue;
                }

                ErrorLine error = FindErrorsInLine(document, processedLine, processedLineText, commandSectionCheckRequired);

                if (error != null)
                {
                    errorLines.Add(error);
                }
            }

            return(errorLines);
        }
Beispiel #13
0
        public static Condition SetWhileLoop(Condition condition)
        {
            int indent = LineHelper.GetIndent(condition.Prefix);

            condition.Prefix = LineHelper.GenerateIndent(indent) + "while ";
            condition.Suffix = " do";
            return(condition);
        }
Beispiel #14
0
        private static ErrorLine FindErrorsInCommandLine(TextDocument document, DocumentLine line, string lineText, bool commandSectionCheckRequired)
        {
            string commandKey = CommandHelper.GetCommandKey(document, line.Offset);

            if (!IsValidCommandKey(commandKey))
            {
                string errorSegmentText = Regex.Match(LineHelper.RemoveComments(lineText), "^.*=").Value.TrimEnd();

                if (errorSegmentText.Length == 0 && commandKey != null)
                {
                    return(null);
                }

                if (commandKey == null)
                {
                    errorSegmentText = lineText.TrimEnd();
                }

                return(new ErrorLine("Invalid command. Please check its spelling.",
                                     line.LineNumber, errorSegmentText));
            }

            if (commandSectionCheckRequired && !IsCommandLineInCorrectSection(document, line.LineNumber, commandKey))
            {
                return(new ErrorLine("Command is placed in the wrong section. Please check the command syntax.",
                                     line.LineNumber, LineHelper.RemoveComments(lineText)));
            }

            if (!IsArgumentCountValid(document, line.Offset))
            {
                string errorSegmentText = Regex.Match(LineHelper.RemoveComments(lineText), @"=\s*(\b.*)").Groups[1].Value;

                if (errorSegmentText.Length == 0)
                {
                    errorSegmentText = LineHelper.RemoveComments(lineText);
                }

                return(new ErrorLine("Invalid argument count. Please check the command syntax.",
                                     line.LineNumber, errorSegmentText));
            }

            if (ContainsEmptyArguments(document, line.Offset))
            {
                string errorSegmentText = Regex.Match(LineHelper.RemoveComments(lineText), @"=\s*(\b.*)").Groups[1].Value;

                if (errorSegmentText.Length == 0)
                {
                    errorSegmentText = LineHelper.RemoveComments(lineText);
                }

                return(new ErrorLine("Empty arguments were found.",
                                     line.LineNumber, errorSegmentText));
            }

            return(null);
        }
Beispiel #15
0
        private static ErrorLine FindErrorsInNGStringLine(DocumentLine line, string lineText)
        {
            if (!IsNGStringLineWellFormatted(lineText))
            {
                return(new ErrorLine("NG string must start with an index.\n\nExample:\n0: First String\n1: Second String",
                                     line.LineNumber, LineHelper.RemoveComments(lineText)));
            }

            return(null);
        }
Beispiel #16
0
        private static ErrorLine FindErrorsInSectionHeaderLine(DocumentLine line, string lineText)
        {
            if (!IsValidSectionName(lineText))
            {
                return(new ErrorLine("Invalid section name. Please check its spelling.",
                                     line.LineNumber, LineHelper.RemoveComments(lineText)));
            }

            return(null);
        }
 public static List <Point> GetIntersectionPoints(List <Line> lines1, List <Line> lines2)
 {
     return((from line1 in lines1
             from line2 in lines2
             where line1.Intersects(line2)
             select LineHelper.CalculateIntersectionPoint(line1, line2)
             into intersectionPoint
             where intersectionPoint.X != 0 || intersectionPoint.Y != 0
             select intersectionPoint).ToList());
 }
Beispiel #18
0
        private static bool IsArgumentCountValid(TextDocument document, int lineOffset)
        {
            string lineText = CommandHelper.GetWholeCommandLineText(document, lineOffset);

            if (lineText == null)
            {
                return(false);
            }

            if (lineText.StartsWith("#"))
            {
                return(true);
            }

            lineText = LineHelper.EscapeComments(lineText);

            if (!lineText.Contains("="))
            {
                return(false);
            }

            string command = CommandHelper.GetCommandKey(document, lineOffset);

            if (string.IsNullOrEmpty(command))
            {
                return(false);
            }

            int argumentCount = LineHelper.EscapeComments(lineText).Split('=')[1].Split(',').Length;

            if (argumentCount == 1 && string.IsNullOrWhiteSpace(lineText.Split('=')[1]))
            {
                argumentCount = 0;
            }

            foreach (DictionaryEntry entry in CommandHelper.GetCommandSyntaxResources())
            {
                if (command.Equals(entry.Key.ToString(), StringComparison.OrdinalIgnoreCase))
                {
                    int correctArgumentCount = entry.Value.ToString().Split(']')[1].Split(',').Length;

                    if (entry.Value.ToString().ToUpper().Contains("ARRAY"))
                    {
                        return(true);                        // Whatever.
                    }
                    else
                    {
                        return(argumentCount == correctArgumentCount);
                    }
                }
            }

            return(false);
        }
Beispiel #19
0
        private LineHelper GetIFLineHelper(List<vMeasureSluiceData> list)
        {
            LineHelper r = new LineHelper("瞬时流量", Color.Red, 1, SymbolType.Square);
            foreach ( vMeasureSluiceData item in list )
            {
                DateTime dt = (DateTime)item.DT;
                XDate xdt = XDate.DateTimeToXLDate(dt);
                float instantFlux= (float)item.InstantFlux;

                r.PointList.Add(xdt, instantFlux);
            }
            return r;
        }
Beispiel #20
0
    private Vector3[] GetLinePathOfType(ConnectionType t, Vector3 start, Vector3 end)
    {
        switch (t)
        {
        default:
            return(LineHelper.GetEasedLine(start, end, lineSegments, 2f));

        case ConnectionType.Default:
            return(LineHelper.GetEasedLine(start, end, lineSegments, 2f));

        case ConnectionType.Power:
            return(LineHelper.GetStraightLine(start, end));
        }
    }
 private ReplyModel GetTextReply(Event msg)
 {
     if (msg.source.userId.Contains("U179044b2c930e61e05385d00472ab2d8") ||
         msg.source.roomId.Contains("Raeb512df48290ba91140c8b14149ddd7") ||
         msg.source.roomId.Contains("R572d57860b132fd3feb78c480f338328") ||
         msg.source.groupId.Contains("C9bdac37aae9448daa2e7f866e1be439a")
         )
     {
         return(LineHelper.SamgoReply(msg));
     }
     else
     {
         return(LineHelper.SamgoReplyAddMe(msg));
     }
 }
Beispiel #22
0
 public void FillAllInfo()
 {
     IsValid = LineHelper.IsValid(Source);
     if (!IsValid)
     {
         return;
     }
     SourceValues = LineHelper.Separate(Source);
     if (SourceValues.Any())
     {
         ParsedValues = LineHelper.Parse(SourceValues).ToList();
     }
     if (ParsedValues.Any())
     {
         Sum = ParsedValues.Sum();
     }
 }
Beispiel #23
0
        private static string _getAffix(string value, string[] affixes, out string oAffix)
        {
            int indent = LineHelper.GetIndent(value);

            foreach (string affix in affixes)
            {
                if (value.Contains(affix))
                {
                    oAffix = LineHelper.GenerateIndent(indent) + affix;
                    value  = value.ReplaceOnce(oAffix, "");
                    return(value);
                }
            }

            oAffix = null;
            return(value);
        }
Beispiel #24
0
    /// <summary>
    /// 求两条直线的交点.
    /// 如果存在, 保存在point中, 并返回true; 否则为false, point为zero.
    /// </summary>
    public bool crossPoint(out Vector2 point, LineHelper other)
    {
        point = Vector2.zero;

        float d = other.a * k - a * other.k;

        // 两条直线无交点.
        if (Utility.isZero(d))
        {
            return(false);
        }

        float x = (a * other.b - other.a * b) / d;
        float y = (a == 0) ? (other.k * x + other.b) : (k * x + b);

        point.Set(x, y);
        return(true);
    }
        private ReplyModel GetJsonReply(WebhookModel value)
        {
            foreach (var daa in value.events)
            {
                try
                {
                    return(LineHelper.ReturnSingleSting(daa.replyToken, JsonConvert.SerializeObject(value)));
                }
                catch (Exception ex)
                {
                    return(LineHelper.ReturnSingleSting(daa.replyToken, JsonConvert.SerializeObject(ex)));
                }
            }



            return(null);
        }
    //	-----------------------------------
    //  Following method checks is currentLine(line drawn by last two points) collided with line
    //	-----------------------------------
    public static bool isVectorIntersectCollide(Vector2 vector, List <Vector2> pointsList)
    {
        if (pointsList.Count < 1 || vector == null)
        {
            return(false);
        }

        for (int i = 0; i < pointsList.Count; i++)
        {
            int nextIndex = (i < pointsList.Count - 1) ? i + 1 : 0;
            if (LineHelper.isVectorIntersect(vector, new myLine()
            {
                StartPoint = pointsList[i], EndPoint = pointsList[nextIndex]
            }, 0.04f))
            {
                return(true);
            }
        }
        return(false);
    }
Beispiel #27
0
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            foreach (DocumentLine line in _editor.Document.Lines)
            {
                string lineText = _editor.Document.GetText(line.Offset, line.Length);

                if (LineHelper.IsSectionHeaderLine(lineText))
                {
                    TextSegment segment = new TextSegment {
                        StartOffset = line.Offset, EndOffset = line.EndOffset
                    };
                    Pen border = new Pen(new SolidColorBrush(Color.FromRgb(220, 220, 220)), 0.5);

                    foreach (Rect rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, segment, true))
                    {
                        drawingContext.DrawLine(border, new Point(rect.Location.X, rect.Location.Y), new Point(textView.ActualWidth, rect.Location.Y));
                    }
                }
            }
        }
Beispiel #28
0
        private ReplyModel GetTextReply(string token, string text, Event msg = null)
        {
            return(LineHelper.NaNaSamgoReply(token, text, msg));

            //if (text.StartsWith("戰力"))
            //{
            //    var q = text.Split(' ')[1].Trim();
            //    var response = DapperHelper.Search<UserInfo>(
            //        connectionString,
            //        $" SELECT SamgoGame.[Role], SamgoGame.[Official], SamgoGame.[Legion], SamgoGamePower.[Power] , SamgoGamePower.[Time] FROM SamgoGame INNER JOIN SamgoGamePower ON SamgoGamePower.SeqNo = SamgoGame.SeqNo where SamgoGame.[Role] like N'%{q}%';"
            //        ).OrderByDescending(x => x.Power);
            //    var temp = "";
            //    temp += response.FirstOrDefault().Role + "\n";
            //    foreach (var a in response)
            //    {
            //        temp += a.Power;
            //        temp += " " + a.Time;
            //        temp += "\n";
            //    }
            //    return new ReplyModel()
            //    {
            //        replyToken = token,
            //        messages = new List<ReplyMessage>()
            //    {
            //        new ReplyMessage()
            //        {
            //            type = "text",
            //            text=temp
            //        }
            //    }
            //    };
            //}
            //else
            //{
            //    return new ReplyModel()
            //    {
            //        replyToken = token

            //    };
            //}
        }
Beispiel #29
0
        private static bool ContainsEmptyArguments(TextDocument document, int lineOffset)
        {
            string lineText = CommandHelper.GetWholeCommandLineText(document, lineOffset);

            if (string.IsNullOrEmpty(lineText))
            {
                return(true);
            }

            string[] arguments = LineHelper.EscapeComments(lineText).Split(',');

            foreach (string argument in arguments)
            {
                if (string.IsNullOrWhiteSpace(argument.Replace('>', ' ')))
                {
                    return(true);
                }
            }

            return(false);
        }
        private static MethodDefinition GetOnModelCreatingMethod(EntityFrameworkCoreProject project)
        {
            var lines = new List <ILine>();

            if (project.Settings.UseDataAnnotations)
            {
                var primaryKeys = project.Database.Tables.Where(item => item.PrimaryKey != null).Select(item => item.PrimaryKey?.GetColumns(item).Select(c => c.Name).First()).ToList();

                foreach (var view in project.Database.Views)
                {
                    var result = view.Columns.Where(item => primaryKeys.Contains(item.Name)).ToList();

                    if (result.Count == 0)
                    {
                        lines.Add(LineHelper.Warning(" Add configuration for {0} entity", view.GetSingularName()));
                    }
                    else
                    {
                        lines.Add(new CodeLine(1, "modelBuilder.Entity<{0}>().HasKey(p => new {{ {1} }});", view.GetSingularName(), string.Join(", ", result.Select(item => string.Format("p.{0}", NamingExtensions.namingConvention.GetPropertyName(item.Name))))));
                    }
                }

                lines.Add(new CodeLine());
            }
            else
            {
                lines.Add(new CommentLine(" This code will change for EF Core 2"));
                lines.Add(new CodeLine("EntityMapper.ConfigureEntities(modelBuilder);"));
                lines.Add(new CodeLine());
            }

            lines.Add(new CodeLine(lines.Count == 0 ? 0 : 1, "base.OnModelCreating(modelBuilder);"));

            return(new MethodDefinition(AccessModifier.Protected, "void", "OnModelCreating", new ParameterDefinition("ModelBuilder", "modelBuilder"))
            {
                IsOverride = true,
                Lines = lines
            });
        }
Beispiel #31
0
 private static ErrorLine FindErrorsInLine(TextDocument document, DocumentLine line, string lineText, bool commandSectionCheckRequired)
 {
     if (LineHelper.IsSectionHeaderLine(lineText))
     {
         return(FindErrorsInSectionHeaderLine(line, lineText));
     }
     else
     {
         if (commandSectionCheckRequired && LineHelper.IsLineInStandardStringSection(document, line))
         {
             return(null);
         }
         else if (commandSectionCheckRequired && LineHelper.IsLineInNGStringSection(document, line))
         {
             return(FindErrorsInNGStringLine(line, lineText));
         }
         else
         {
             return(FindErrorsInCommandLine(document, line, lineText, commandSectionCheckRequired));
         }
     }
 }
Beispiel #32
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        private LineHelper[] GetLineHelpers(List<vMeasureSluiceData> list)
        {
            LineHelper beforeLine= new LineHelper("闸前水位", Color.Red ,
                1, SymbolType.Square);

            LineHelper behindLine= new LineHelper("闸后水位", Color.Blue,
                1, SymbolType.Square);
            LineHelper heightLine = new LineHelper("闸高", Color.Green, 1, SymbolType.Square);

            //LineHelper gp2Line = new LineHelper(strings.GP2, ColorHelper.GetLineColor(strings.GP2),
            //    ZedConfigValues.Default.GP2Config.Width, SymbolType.None);
            //LineHelper bp2Line = new LineHelper(strings.BP2, ColorHelper.GetLineColor(strings.BP2),
            //    ZedConfigValues.Default.BP2Config.Width, SymbolType.None);

            LineHelper[] lines = new LineHelper[] {beforeLine ,behindLine ,heightLine };

            //tbl.Compute(
            foreach ( vMeasureSluiceData item in list )
            {
                DateTime dt = (DateTime)item.DT;
                XDate xdt = XDate.DateTimeToXLDate(dt);
                //float beforeWL= (float)Math.Round(item.BeforeWL,2);
                float beforeWL = (float)item.BeforeWL;
                float behindWL= (float)item.BehindWL;
                float height = (float)item.Height;
                //float gp2 = (float)Math.Round(Convert.ToSingle(row["gp2"]), 2);
                //float bp2 = (float)Math.Round(Convert.ToSingle(row["bp2"]), 2);
                //pts.Add(xdt, gt1);

                beforeLine.PointList.Add(xdt, beforeWL);
                behindLine.PointList.Add(xdt, behindWL);
                heightLine.PointList.Add(xdt, height);
                //gp2Line.PointList.Add(xdt, gp2);
                //bp2Line.PointList.Add(xdt, bp2);
            }
            return lines;
        }