Ejemplo n.º 1
0
 private static CompetitionItemRoiRow[] BuildResult(DbStoredProc proc, SportType sportType, int[] competitionUniqueIDs, BrokerType[] brokerTypes)
 {
     if (brokerTypes != null) {
         proc = proc.WithParam("argbrokerids", brokerTypes.Select(b => (short)b), DbType.Int16);
     }
     if (competitionUniqueIDs != null) {
         proc = proc.WithParam("argcompetitionuniqueids", competitionUniqueIDs, DbType.Int32);
     }
     if (sportType != SportType.Unknown) {
         proc = proc.WithParam("argsporttype", (short) sportType);
     }
     var data = proc.MultiRowExec(DatabaseActions.GetAdapter(TargetDB.MASTER), "fn_getbetroi").Data;
     var result = new CompetitionItemRoiRow[data.Count];
     for (var i = 0; i < result.Length; i++) {
         var row = data[i];
         var betData = (int[])row[1];
         var betIDs = new Dictionary<BetOddType, int>();
         for (var j = 0; j < betData.Length; j+=2) {
             betIDs[(BetOddType) (short) betData[j]] = betData[j + 1];
         }
         result[i] = new CompetitionItemRoiRow {
             ID = (int)row[0],
             BetIDs = betIDs,
             Roi = (float) row[2],
             RoiType = (RoiType) (short) row[3]
         };
     }
     return result;
 }
Ejemplo n.º 2
0
 public static CompetitionItemRoiRow[] GetDataForCompetitionItem(int competitionItemID, BrokerType[] brokerTypes = null, int limitRows = 1)
 {
     var proc = new DbStoredProc()
         .NotRepeatable()
         .WithParam("argcompetitionitemid", competitionItemID)
         .WithParam("arglimittocompetition", limitRows);
     return BuildResult(proc, SportType.Unknown, null, brokerTypes);
 }
Ejemplo n.º 3
0
 public static CompetitionItemRoiRow[] GetDataForDate(DateTime fromDate, DateTime toDate, SportType sportType = SportType.Unknown, int[] competitionUniqueIDs = null, BrokerType[] brokerTypes = null)
 {
     var proc = new DbStoredProc()
         .NotRepeatable()
         .WithParam("argcompetitionmindate", fromDate)
         .WithParam("argcompetitionmaxdate", toDate);
     return BuildResult(proc, sportType, competitionUniqueIDs, brokerTypes);
 }
Ejemplo n.º 4
0
 public static CompetitionItemRoiRow[] GetDataForNow(float minRoi = float.MinValue, SportType sportType = SportType.Unknown, int[] competitionUniqueIDs = null, BrokerType[] brokerTypes = null)
 {
     var proc = new DbStoredProc()
         .NotRepeatable();
     if (minRoi != float.MinValue) {
         proc = proc
             .WithParam("argroimin", minRoi);
     }
     return BuildResult(proc, sportType, competitionUniqueIDs, brokerTypes);
 }
        private DbSchemaObject ParseSchemaObject(FileInfo file)
        {
            DbSchemaObject schemaObject = null;
            var            name         = System.IO.Path.GetFileNameWithoutExtension(file.FullName);
            var            nameparts    = name.Split('_');

            var objectType = (ESchemaObjectType)Enum.Parse(typeof(ESchemaObjectType), nameparts[0]);

            switch (objectType)
            {
            case ESchemaObjectType.Table:
                schemaObject = new DbTable();
                break;

            case ESchemaObjectType.View:
                schemaObject = new DbView();
                break;

            case ESchemaObjectType.StoredProcedure:
                schemaObject = new DbStoredProc();
                break;

            case ESchemaObjectType.ScalarFunction:
                schemaObject = new DbScalarFunction();
                break;

            case ESchemaObjectType.TableFunction:
                schemaObject = new DbTableFunction();
                break;

            case ESchemaObjectType.Trigger:
                schemaObject = new DbTrigger();
                break;

            case ESchemaObjectType.PrimaryKey:
                schemaObject = new DbPrimaryKey();
                break;

            case ESchemaObjectType.ForeignKey:
                schemaObject = new DbForeignKey();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (schemaObject == null)
            {
                throw new Exception("Unable to identify object");
            }

            var objectParts = nameparts[1].Split('.');

            if (objectParts.Length != 2)
            {
                throw new Exception($"Problem with name {nameparts[1]}");
            }

            schemaObject.SchemaName = objectParts[0];
            schemaObject.Name       = objectParts[1];
            schemaObject.Definition = file.ReadAllText();

            return(schemaObject);
        }