コード例 #1
0
        /// <summary>
        /// The operation to calculate metrics for saved and presented shapes.
        /// </summary>
        /// <param name="options">The options object which contains extra information
        /// which helps during the exeuction of this modus.</param>
        public static void Start(MeasureOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            Logger.Log(I_StartProc_Measure);
            // Load in new shapes to measure.
            if (options.HasDirectories)
            {
                foreach (string dir in options.ShapeDirectories)
                {
                    Settings.FileManager.AddDirectoryDirect(dir);
                }
            }
            // Perform metric calculations.
            IRecordHolder <MeshEntry> recordHolder = MetricCalculator;

            recordHolder.TakeSnapShot(Settings.MeshLibrary);
            // Save results to external file.
            SaveMetrics(recordHolder);
            // Notify the user of the refined shapes.
            Logger.Log(I_ShapeCount, Settings.MeshLibrary.Count);
            Logger.Log(I_EndProc_Measure);
        }
コード例 #2
0
        public static Dictionary <string, Measure> GetMeasures(Account account, Channel channel, SqlConnection connection, MeasureOptions options, MeasureOptionsOperator @operator = MeasureOptionsOperator.And)
        {
            SqlCommand cmd = DataManager.CreateCommand(AppSettings.Get(typeof(Measure), "GetMeasures.SP"),
                                                       System.Data.CommandType.StoredProcedure);

            cmd.Connection = connection;

            cmd.Parameters["@accountID"].Value = account == null ? DBNull.Value : (object)account.ID;
            cmd.Parameters["@channelID"].Value = channel == null ? DBNull.Value : (object)channel.ID;
            cmd.Parameters["@flags"].Value     = options;
            cmd.Parameters["@operator"].Value  = @operator;

            List <Measure> measures = new List <Measure>();

            using (SqlDataReader reader = cmd.ExecuteReader())
            {
                while (reader.Read())
                {
                    Measure m = new Measure()
                    {
                        ID          = (int)reader["MeasureID"],
                        Account     = account,
                        Name        = (string)reader["Name"],
                        DisplayName = (string)reader["DisplayName"],
                        OltpName    = (string)reader["FieldName"],
                        Options     = (MeasureOptions)reader["Flags"]
                    };

                    measures.Add(m);
                }
            }

            return(measures.ToDictionary(m => m.Name));
        }