Пример #1
0
        /// <summary>
        /// Parse through and get the data we need for all the fixes.
        /// </summary>
        private void ParseFixData(string effectiveDate)
        {
            // Variable for all the 'bad' characters. We will remove all these characters from the data.
            char[] removeChars = { ' ', '.' };

            // Read ALL the lines in FAA Fix data text file.
            foreach (string line in File.ReadAllLines($"{GlobalConfig.tempPath}\\{effectiveDate}_FIX\\FIX.txt"))
            {
                // Check to see if the begining of the line starts with "FIX1"
                if (line.Substring(0, 4) == "FIX1")
                {
                    // Create the FixModel. This is needed to store the data so we can later write the SCT file.
                    FixModel individualFixData = new FixModel
                    {
                        Id       = line.Substring(4, 5).Trim(removeChars),
                        Lat      = GlobalConfig.CorrectLatLon(line.Substring(66, 14).Trim(removeChars), true, GlobalConfig.Convert),
                        Lon      = GlobalConfig.CorrectLatLon(line.Substring(80, 14).Trim(removeChars), false, GlobalConfig.Convert),
                        Catagory = line.Substring(94, 3).Trim(removeChars),
                        Use      = line.Substring(213, 15).Trim(removeChars),
                        HiArtcc  = line.Substring(233, 4).Trim(removeChars),
                        LoArtcc  = line.Substring(237, 4).Trim(removeChars),
                    };

                    // Set the Decimal Format for the Lat and Lon
                    individualFixData.Lat_Dec = GlobalConfig.CreateDecFormat(individualFixData.Lat, true);
                    individualFixData.Lon_Dec = GlobalConfig.CreateDecFormat(individualFixData.Lon, true);

                    // Add this FIX MODEL to the list of all Fixes.
                    allFixesInData.Add(individualFixData);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Returns a value indicating whether a <see cref="FixModel"/> object describes a fix that
        /// can be applied to a single specified file.
        /// </summary>
        /// <remarks>
        /// For a fix to be applied to a single specified file, every change in the fix must apply
        /// to that same file. For a fix to be applied at all, it's necessary to know the offset
        /// and length of every region to be replaced.
        /// </remarks>
        /// <param name="fixModel">
        /// Represents the fix to be applied.
        /// </param>
        /// <param name="path">
        /// The path to the file to which the fix should be applied.
        /// </param>
        /// <returns>
        /// true if the fix can be applied to the file specified by <paramref name="path"/>,
        /// otherwise false.
        /// </returns>
        public static bool CanBeAppliedToFile(this FixModel fixModel, string path)
        {
            ObservableCollection <ArtifactChangeModel> changes = fixModel.ArtifactChanges;

            return
                (changes.All(ac => ac.FilePath.Equals(path, StringComparison.OrdinalIgnoreCase)) &&
                 changes.SelectMany(ac => ac.Replacements).All(HasOffsetAndLength));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="FixSuggestedAction"/> class.
        /// </summary>
        /// <param name="fix">
        /// The SARIF <see cref="Fix"/> object that describes the action.
        /// </param>
        /// <param name="textBuffer">
        /// The text buffer to which the fix will be applied.
        /// </param>
        /// <param name="previewProvider">
        /// Creates the XAML UIControl that displays the preview.
        /// </param>
        public FixSuggestedAction(
            FixModel fix,
            ITextBuffer textBuffer,
            IPreviewProvider previewProvider)
        {
            this.fix             = fix;
            this.textBuffer      = textBuffer;
            this.previewProvider = previewProvider;
            this.DisplayText     = fix.Description;

            this.edits = this.GetEditsFromFix(fix).AsReadOnly();
        }
Пример #4
0
        public int InsertFix(FixModel fix)
        {
            SqlParameter[] param = { new SqlParameter("@FixID",       SqlDbType.VarChar,                          18), new SqlParameter("@Name", SqlDbType.VarChar, 20),
                                     new SqlParameter("@Amount",      SqlDbType.Int),     new SqlParameter("@Factory", SqlDbType.VarChar,                      20),
                                     new SqlParameter("@FactoryDate", SqlDbType.DateTime, 10) };
            param[0].Value = fix.FixID;
            param[1].Value = fix.Name;
            param[2].Value = fix.Amount;
            param[3].Value = fix.Factory;
            param[4].Value = fix.FactoryDate;
            int result = SqlHelp.ExecuteNonQuery("prc_InsertFix", CommandType.StoredProcedure, param);

            return(result);
        }
Пример #5
0
        public static FixModel ToFixModel(this Fix fix, IDictionary <string, ArtifactLocation> originalUriBaseIds, FileRegionsCache fileRegionsCache)
        {
            fix = fix ?? throw new ArgumentNullException(nameof(fix));

            var model = new FixModel(fix.Description?.Text);

            if (fix.ArtifactChanges != null)
            {
                foreach (ArtifactChange change in fix.ArtifactChanges)
                {
                    model.ArtifactChanges.Add(change.ToArtifactChangeModel(originalUriBaseIds, fileRegionsCache));
                }
            }

            return(model);
        }
Пример #6
0
        public List <FixModel> GetAllFix()
        {
            SqlDataReader   dr   = SqlHelp.ExecuteReader("prc_GetAllFix", CommandType.StoredProcedure);
            List <FixModel> list = new List <FixModel>();

            while (dr.Read())
            {
                FixModel fix = new FixModel();
                fix.FixID       = dr[0].ToString();
                fix.Name        = dr[1].ToString();
                fix.Amount      = Convert.ToInt32(dr[2]);
                fix.Factory     = dr[3].ToString();
                fix.FactoryDate = Convert.ToDateTime(dr[4]);
                list.Add(fix);
            }
            dr.Close();
            return(list);
        }
Пример #7
0
        public static FixModel ToFixModel(this Fix fix)
        {
            if (fix == null)
            {
                return(null);
            }

            FixModel model = new FixModel(fix.Description, new FileSystem());

            if (fix.FileChanges != null)
            {
                foreach (FileChange fileChange in fix.FileChanges)
                {
                    model.FileChanges.Add(fileChange.ToFileChangeModel());
                }
            }

            return(model);
        }
Пример #8
0
        public static FixModel ToFixModel(this Fix fix)
        {
            if (fix == null)
            {
                return(null);
            }

            FixModel model = new FixModel(fix.Description?.Text, new FileSystem());

            if (fix.ArtifactChanges != null)
            {
                foreach (ArtifactChange change in fix.ArtifactChanges)
                {
                    model.ArtifactChanges.Add(change.ToArtifactChangeModel());
                }
            }

            return(model);
        }
Пример #9
0
        protected void Edit_Click(object sender, EventArgs e)
        {
            FixModel fix = new FixModel();

            fix.FixID       = lbID.Text;
            fix.Name        = txtFixName.Text.Trim();
            fix.Amount      = Convert.ToInt32(txtFixAmount.Text.Trim());
            fix.Factory     = txtFixFactory.Text.Trim();
            fix.FactoryDate = Convert.ToDateTime(txtFixFactoryDate.Value);
            bool flag = bll.UpdateFix(fix);

            if (flag)
            {
                Page.ClientScript.RegisterStartupScript(GetType(), "OnSubmit", "<script>alert('修改成功');location.href='FixInfo.aspx';</script>");
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(GetType(), "OnSubmit", "<script>alert('修改失败');</script>");
            }
        }
Пример #10
0
        public List <FixModel> GetFixByCondition(string condition)
        {
            SqlParameter param = new SqlParameter("@Condition", SqlDbType.VarChar, 255);

            param.Value = condition;
            SqlDataReader   dr   = SqlHelp.ExecuteReader("prc_GetFixByCondition", CommandType.StoredProcedure, param);
            List <FixModel> list = new List <FixModel>();

            while (dr.Read())
            {
                FixModel fix = new FixModel();
                fix.FixID       = dr[0].ToString();
                fix.Name        = dr[1].ToString();
                fix.Amount      = Convert.ToInt32(dr[2]);
                fix.Factory     = dr[3].ToString();
                fix.FactoryDate = Convert.ToDateTime(dr[4]);
                list.Add(fix);
            }
            dr.Close();
            return(list);
        }
Пример #11
0
 protected void Page_Load(object sender, EventArgs e)
 {
     user = (UserModel)Session["User"];
     if (Session["User"] == null || Session["User"].ToString() == "" || user.UserType != 1)
     {
         Response.Redirect("../Login.aspx");
     }
     else
     {
         if (!IsPostBack)
         {
             string   fixID = Request.QueryString["ID"].ToString();
             FixModel fix   = bll.GetFixByID(fixID);
             lbID.Text               = fix.FixID;
             txtFixName.Text         = fix.Name;
             txtFixAmount.Text       = fix.Amount.ToString();
             txtFixFactory.Text      = fix.Factory;
             txtFixFactoryDate.Value = fix.FactoryDate.ToString("yyyy-MM-dd");
         }
     }
 }
Пример #12
0
        public FixModel GetFixByID(string fixID)
        {
            SqlParameter param = new SqlParameter("@FixID", SqlDbType.VarChar, 18);

            param.Value = fixID;
            SqlDataReader   dr   = SqlHelp.ExecuteReader("prc_GetFixByID", CommandType.StoredProcedure, param);
            List <FixModel> list = new List <FixModel>();

            dr.Read();
            FixModel fix = new FixModel();

            if (dr.HasRows)
            {
                fix.FixID       = dr[0].ToString();
                fix.Name        = dr[1].ToString();
                fix.Amount      = Convert.ToInt32(dr[2]);
                fix.Factory     = dr[3].ToString();
                fix.FactoryDate = Convert.ToDateTime(dr[4]);
            }
            dr.Close();
            return(fix);
        }
Пример #13
0
        private static SarifErrorListItem GetDesignTimeViewModel1()
        {
            SarifErrorListItem viewModel = new SarifErrorListItem();

            viewModel.Message = "Potential mismatch between sizeof and countof quantities. Use sizeof() to scale byte sizes.";

            viewModel.Tool = new ToolModel()
            {
                Name    = "FxCop",
                Version = "1.0.0.0",
            };

            viewModel.Rule = new RuleModel()
            {
                Id           = "CA1823",
                Name         = "Avoid unused private fields",
                HelpUri      = "http://aka.ms/analysis/ca1823",
                DefaultLevel = "Unknown"
            };

            viewModel.Invocation = new InvocationModel()
            {
                CommandLine = @"""C:\Temp\Foo.exe"" target.file /o out.sarif",
                FileName    = @"C:\Temp\Foo.exe",
            };

            viewModel.Locations.Add(new Models.AnnotatedCodeLocationModel()
            {
                FilePath = @"D:\GitHub\NuGet.Services.Metadata\src\Ng\Catalog2Dnx.cs",
                Region   = new CodeAnalysis.Sarif.Region(11, 1, 11, 2, 0, 0),
            });

            viewModel.Locations.Add(new Models.AnnotatedCodeLocationModel()
            {
                FilePath = @"D:\GitHub\NuGet.Services.Metadata\src\Ng\Catalog2Dnx.cs",
                Region   = new CodeAnalysis.Sarif.Region(12, 1, 12, 2, 0, 0),
            });

            viewModel.RelatedLocations.Add(new Models.AnnotatedCodeLocationModel()
            {
                FilePath = @"D:\GitHub\NuGet.Services.Metadata\src\Ng\Catalog2Dnx.cs",
                Region   = new CodeAnalysis.Sarif.Region(21, 1, 21, 2, 0, 0),
            });

            viewModel.RelatedLocations.Add(new Models.AnnotatedCodeLocationModel()
            {
                FilePath = @"D:\GitHub\NuGet.Services.Metadata\src\Ng\Catalog2Dnx.cs",
                Region   = new CodeAnalysis.Sarif.Region(22, 1, 22, 2, 0, 0),
            });

            viewModel.RelatedLocations.Add(new Models.AnnotatedCodeLocationModel()
            {
                FilePath = @"D:\GitHub\NuGet.Services.Metadata\src\Ng\Catalog2Dnx.cs",
                Region   = new CodeAnalysis.Sarif.Region(23, 1, 23, 2, 0, 0),
            });

            viewModel.CallTrees.Add(new CallTree(
                                        new List <CallTreeNode>
            {
                new CallTreeNode
                {
                    Location = new AnnotatedCodeLocation
                    {
                        Kind = AnnotatedCodeLocationKind.Assignment
                    }
                },

                new CallTreeNode
                {
                    Location = new AnnotatedCodeLocation
                    {
                        Kind   = AnnotatedCodeLocationKind.Call,
                        Target = "my_func"
                    },
                    Children = new List <CallTreeNode>
                    {
                        new CallTreeNode
                        {
                            Location = new AnnotatedCodeLocation
                            {
                                Kind = AnnotatedCodeLocationKind.CallReturn
                            }
                        }
                    }
                }
            }, SarifViewerPackage.SarifToolWindow));

            StackCollection stack1 = new StackCollection("Stack A1");

            stack1.Add(new StackFrameModel()
            {
                Message  = "Message A1.1",
                FilePath = @"D:\GitHub\NuGet.Services.Metadata\src\Ng\Catalog2Dnx.cs",
                Line     = 11,
                Column   = 1,
                FullyQualifiedLogicalName = "My.Assembly.Main(string[] args)",
                Module = "My.Module.dll",
            });
            stack1.Add(new StackFrameModel()
            {
                Message  = "Message A1.2",
                FilePath = @"D:\GitHub\NuGet.Services.Metadata\src\Ng\Catalog2Dnx.cs",
                Line     = 12,
                Column   = 1,
                FullyQualifiedLogicalName = "Our.Shared.Library.Method(int param)",
                Module = "My.Module.dll",
            });
            stack1.Add(new StackFrameModel()
            {
                Message  = "Message A1.3",
                FilePath = @"D:\GitHub\NuGet.Services.Metadata\src\Ng\Catalog2Dnx.cs",
                Line     = 1,
                Column   = 1,
                FullyQualifiedLogicalName = "Your.PIA.External()",
            });
            viewModel.Stacks.Add(stack1);

            FixModel        fix1         = new FixModel("Replace *.Close() with *.Dispose().");
            FileChangeModel fileChange11 = new FileChangeModel();

            fileChange11.FilePath = @"D:\GitHub\NuGet.Services.Metadata\src\Ng\Catalog2Dnx.cs";
            fileChange11.Replacements.Add(new ReplacementModel()
            {
                Offset         = 1234,
                DeletedLength  = ".Close()".Length,
                InsertedString = ".Dispose()",
            });
            fix1.FileChanges.Add(fileChange11);
            viewModel.Fixes.Add(fix1);

            return(viewModel);
        }
Пример #14
0
        public bool InsertFix(FixModel fix)
        {
            int result = dal.InsertFix(fix);

            return(result == 0 ? false : true);
        }
Пример #15
0
        public bool UpdateFix(FixModel fix)
        {
            int result = dal.UpdateFix(fix);

            return(result == 0 ? false : true);
        }
 private List <ReplacementEdit> GetEditsFromFix(FixModel fix) =>
 fix.ArtifactChanges.SelectMany(ac => ac.Replacements).Select(this.ToEdit).ToList();