public ForecastTypeRegistration(ForecastType selectedForecastType, IList <ForecastType> presenceTypes)
        {
            _selectedForecastType = selectedForecastType;
            ForecastTypes         = presenceTypes;

            Initialize();
        }
Esempio n. 2
0
        private UIDataManager()
        {
            //最新在线人数
            this.CurrentOnlineNumber = null;
            //开奖号码
            this.CurrentWinningNumber = null;

            #region 由于所赋的值都能保证其合法性,因此可以直接为字段而不是属性赋值,减少校验代码的性能损耗。
            //定码类型
            this.currentSelectedForecastType = GS.DEFAULT_FORECAST_TYPE;
            //排除最新期数号
            this.currentSelectedNewestPeriod = GS.DEFAULT_NEWEST_PERIOD_COUNT;
            //定码个数
            this.currentSelectedDingMaCount = GS.DEFAULT_DING_MA_COUNT;
            #endregion

            //当前计划状态(“最大连中”、“最大连挂”)
            CalMaxContinueWinAndMaxContinueLose();
            //当前计划状态(“中奖期数”、“没中奖期数”)
            CalTotalWinAndTotalLose();


            #region 创建下一轮要用的 WinLog,并填充当前可以准备的所有预测数据。
            //List<string> planForecastNumberList = CalPlanForecastList(new List<Number>(), this.currentSelectedDingMaCount, this.currentSelectedForecastType);
            //nextNewestLog = new WinLog(planForecastNumberList, 0, this.currentSelectedForecastType);

            List <Number> historyData = mgr.GetTopRangeHistorySourceData(0, this.currentSelectedNewestPeriod, true, false).ExtractWinningNumber();
            nextNewestLog = new WinLog(historyData, this.currentSelectedDingMaCount, this.currentSelectedForecastType);
            //nextNewestLogActuallyHistoryWinningNumberCount = historyData.Count;
            #endregion


            //绑定事件
            mgr.OnNewSourceDataAdded += Mgr_OnNewSourceDataAdded;
        }
Esempio n. 3
0
        private Mock <ForecastOverviewForecast> CreateWorkdayForecastMock(ForecastType forecastType)
        {
            var forecastMock = CreateMock <ForecastOverviewForecast>();

            forecastMock.SetupGet(x => x.IsWorkDay).Returns(true);
            forecastMock.SetupGet(x => x.ForecastType).Returns(forecastType);
            return(forecastMock);
        }
Esempio n. 4
0
        public static void ShouldHaveDescriptionAndType()
        {
            var forecastObjectType = new ForecastType(new MetadataServiceMocked());
            var fields             = forecastObjectType.Fields.ToList();

            fields.Count.ShouldBe(4);
            fields[0].Description.ShouldBe("Metadata for a data source with id MET_API.");
            fields[0].Type.ShouldBe(typeof(StoredMetadataType));
            fields[1].Description.ShouldBe("The Geo-Data used in the query");
            fields[1].Type.ShouldBe(typeof(GeometryType));
        }
        public async Task <RevenueForecasts> CreateForecastAsync(ForecastType forecastType)
        {
            var forecast = new RevenueForecasts
            {
                IsReady      = false,
                ForecastType = forecastType
            };
            await _forecasts.InsertOneAsync(forecast);

            return(forecast);
        }
Esempio n. 6
0
        public void SetupVisualsBySearchOption_OneForecastForEachDisplayHandlerType_AppliesTheExpectedDisplayHandlers()
        {
            // Arrange
            const int projectForecastTypeId = 1;
            var       projectForecastType   = new ForecastType {
                Id = projectForecastTypeId
            };
            var projectSupportingForecastType = new ForecastType {
                Id = 2, SupportsProjectHours = true
            };
            var nonProjectSupportingForecastType = new ForecastType {
                Id = 3, SupportsProjectHours = false
            };


            var forecastMonth = new ForecastOverviewForecastMonth
            {
                Forecasts = new List <ForecastOverviewForecast>()
            };

            // Non workday forecast
            var nonWorkDayForecastMock = CreateMock <ForecastOverviewForecast>();

            nonWorkDayForecastMock.SetupGet(x => x.IsWorkDay).Returns(false);
            forecastMonth.Forecasts.Add(nonWorkDayForecastMock.Object);

            // Project forecast
            var projectForecastMock = CreateWorkdayForecastMock(projectForecastType);

            forecastMonth.Forecasts.Add(projectForecastMock.Object);

            // Projectsupporting forecast
            var projectSupportingForecastMock = CreateWorkdayForecastMock(projectSupportingForecastType);

            forecastMonth.Forecasts.Add(projectSupportingForecastMock.Object);

            // Non projectsupporting forecast
            var nonProjectSupportingForecastMock = CreateWorkdayForecastMock(nonProjectSupportingForecastType);

            forecastMonth.Forecasts.Add(nonProjectSupportingForecastMock.Object);

            var sut = Fixture.Create <ForecastOverviewSearchOptions>();

            sut.SelectedTabIndex = 0; // Indicates that searching by registration

            // Act
            sut.SetupVisualsBySearchOption(forecastMonth, projectForecastTypeId);

            // Assert
            nonWorkDayForecastMock.VerifySet(x => x.DisplayHandler           = It.IsAny <EmptyDisplayHandler>());
            projectForecastMock.VerifySet(x => x.DisplayHandler              = It.IsAny <PureProjectTypeDisplayHandler>());
            projectSupportingForecastMock.VerifySet(x => x.DisplayHandler    = It.IsAny <SupportsProjectsWithFocusDisplayHandler>());
            nonProjectSupportingForecastMock.VerifySet(x => x.DisplayHandler = It.IsAny <NonProjectSupportingDisplayHandler>());
        }
Esempio n. 7
0
        /// <summary>
        ///     Gets the weather forecast for the specified city asynchronously.
        /// </summary>
        /// <param name="cityId">the city id</param>
        /// <param name="forecastType">the forecast type (Hourly, ThreeHour or Daily)</param>
        /// <param name="requestOptions">
        ///     the request options (can change the behavior of requesting and controls caching,
        ///     cancellation, unit and language options of the result)
        /// </param>
        /// <returns>
        ///     a task that represents the asynchronous operation. The task result is the weather
        ///     forecast; or <see langword="null"/> if the city could not be found.
        /// </returns>
        public Task <WeatherForecast?> GetWeatherForecastAsync(int cityId, ForecastType forecastType = ForecastType.ThreeHour, RequestOptions?requestOptions = default)
        {
            requestOptions ??= RequestOptions.Default;
            requestOptions.CancellationToken.ThrowIfCancellationRequested();

            // send request
            var parameters = new NameValueCollection {
                { "id", cityId.ToString() }
            };

            return(RequestAsync <WeatherForecast>(GetEndpoint(forecastType), parameters, requestOptions));
        }
        private ForecastOverviewForecast CreateForecast(ForecastDate date, ForecastType forecastType, int?dedicatedHours = null)
        {
            var forecast = new ForecastOverviewForecast
            {
                Date         = date,
                ForecastType = forecastType,
                DedicatedForecastTypeHours = dedicatedHours
            };

            forecast.DisplayHandler = new SupportsProjectsWithFocusDisplayHandler(forecast, null, null, _project.Id);
            return(forecast);
        }
Esempio n. 9
0
 // public void AddSunlight(int x, int y, int amt) {
 //     if (!ValidCoordinate(x,y)) return;
 // }
 // public void AddWater(int x, int y, int amt) {
 //     if (!ValidCoordinate(x,y)) return;
 // }
 public void AddWeather(int x, int y, ForecastType type, int amt)
 {
     // we aren't using 'ammount' at this time
     if (!ValidCoordinate(x, y))
     {
         return;
     }
     if (tiles[x][y].currentPlant != null)
     {
         tiles[x][y].currentPlant.ReceiveWeather(type);
     }
 }
Esempio n. 10
0
    public void centerAtOrigin(SerializedProperty editorTiles)
    {
        int xMin = 5;
        int yMin = 5;
        int xMax = -1;
        int yMax = -1;
        int xMid = 2;
        int yMid = 2;

        for (int j = 0; j < editorTiles.arraySize; j++)
        {
            Vector2Int   editorOffset = editorTiles.GetArrayElementAtIndex(j).FindPropertyRelative("editorOffset").vector2IntValue;
            ForecastType type         = (ForecastType)(editorTiles.GetArrayElementAtIndex(j).FindPropertyRelative("type").enumValueIndex);
            if (type != 0)   // find the non-null tiles and get the minimum coordinates
            {
                if (editorOffset.x < xMin)
                {
                    xMin = editorOffset.x;
                }
                if (editorOffset.y < yMin)
                {
                    yMin = editorOffset.y;
                }
                if (editorOffset.x > xMax)
                {
                    xMax = editorOffset.x;
                }
                if (editorOffset.y > yMax)
                {
                    yMax = editorOffset.y;
                }
            }
        }
        xMid = (int)(((float)xMax - (float)xMin) / 2f + (float)xMin + .5f);
        yMid = (int)(((float)yMax - (float)yMin) / 2f + (float)yMin + .5f);
        // Debug.Log(xMid + "," + xMin + "," + xMax);
        for (int j = 0; j < editorTiles.arraySize; j++)
        {
            Vector2Int editorOffset = editorTiles.GetArrayElementAtIndex(j).FindPropertyRelative("editorOffset").vector2IntValue;
            Vector2Int offset       = editorTiles.GetArrayElementAtIndex(j).FindPropertyRelative("offset").vector2IntValue;
            offset.x = editorOffset.x - xMid;
            offset.y = editorOffset.y - yMid;
            // Debug.Log(editorOffset + "/" + offset);
            editorTiles.GetArrayElementAtIndex(j).FindPropertyRelative("offset").vector2IntValue = offset;
        }
        editorTiles.serializedObject.ApplyModifiedProperties();
    }
Esempio n. 11
0
    public void BeginNewTurn()
    {
        Debug.Log("start new turn: " + currentlyWanting);
        receivedThisTurn = ForecastType.None;

        if (initialized && !changeNeedEveryTurn && !needMet && !currentlyWanting.Equals(ForecastType.None))
        {
            Debug.Log("cancelling because need wasn't met");
            return;
        }
        // override the randomness if we choose to alternate instead
        if (initialized && alwaysAlternateAfterNeedMet && needMet)
        {
            Debug.Log("Alternating " + currentlyWanting);
            if (currentlyWanting.Equals(ForecastType.Water))
            {
                currentlyWanting = ForecastType.Sun;
            }
            else if (currentlyWanting.Equals(ForecastType.Sun))
            {
                currentlyWanting = ForecastType.Water;
            }
            Debug.Log("Done Alternating " + currentlyWanting);
        }
        else
        {
            Debug.Log("randomizing new want");
            int selection = Random.Range(0, 4);
            // plants don't want lightning
            while (((ForecastType)selection).Equals(ForecastType.Lightning))
            {
                selection = Random.Range(0, 4);
            }
            if (noNoneDays)
            {
                while (((ForecastType)selection).Equals(ForecastType.None) || ((ForecastType)selection).Equals(ForecastType.Lightning))
                {
                    selection = Random.Range(0, 4);
                }
            }
            currentlyWanting = (ForecastType)selection;
            Debug.Log("random new want: " + currentlyWanting);
        }
        // Debug.Log(currentlyWanting);
        initialized = true;
        AnnounceWant();
    }
Esempio n. 12
0
        /// <summary>
        /// Gets forecasts supporting project hours
        /// for the current year
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="queryInternalCustomers"></param>
        /// <param name="dateSpan"></param>
        /// <returns></returns>
        public decimal GetHourSumByCriteria(int userId, bool queryInternalCustomers, DateSpan dateSpan)
        {
            Forecast             forecastAlias     = null;
            ForecastType         forecastTypeAlias = null;
            User                 userAlias         = null;
            ForecastProjectHours regAlias          = null;
            Company              companyAlias      = null;
            Project              projectAlias      = null;
            ForecastMonth        monthAlias        = null;

            var query = Session.QueryOver(() => regAlias)
                        .JoinAlias(() => regAlias.Parent, () => forecastAlias)
                        .JoinAlias(() => forecastAlias.ForecastMonth, () => monthAlias)
                        .JoinAlias(() => monthAlias.User, () => userAlias)
                        .JoinAlias(() => forecastAlias.ForecastType, () => forecastTypeAlias)
                        .JoinAlias(() => regAlias.Project, () => projectAlias)
                        .JoinAlias(() => projectAlias.Company, () => companyAlias)
                        .Where(() => userAlias.UserID == userId)
                        .And(() => forecastAlias.Date >= dateSpan.From)
                        .And(() => forecastAlias.Date <= dateSpan.To)
                        .And(() => forecastTypeAlias.SupportsProjectHours)
                        .And(() => companyAlias.Internal == queryInternalCustomers)
                        .Select(Projections.Sum <ForecastProjectHours>(x => x.Hours));

            var result = query
                         .UnderlyingCriteria
                         .UniqueResult <decimal>();

            // Dedicatedhours are accounted for internally
            if (queryInternalCustomers)
            {
                var typeDedicatedHours = Session.QueryOver(() => forecastAlias)
                                         .JoinAlias(() => forecastAlias.ForecastMonth, () => monthAlias)
                                         .JoinAlias(() => monthAlias.User, () => userAlias)
                                         .JoinAlias(() => forecastAlias.ForecastType, () => forecastTypeAlias)
                                         .Where(() => forecastAlias.Date >= dateSpan.From)
                                         .And(() => forecastAlias.Date <= dateSpan.To)
                                         .And(() => forecastTypeAlias.StatisticsInclusion)
                                         .And(() => userAlias.UserID == userId)
                                         .Select(Projections.Sum <Forecast>(x => x.DedicatedForecastTypeHours))
                                         .UnderlyingCriteria
                                         .UniqueResult <decimal>();
                result = result + typeDedicatedHours;
            }

            return(result);
        }
Esempio n. 13
0
        private string GetEndpoint(ForecastType forecastType)
        {
            switch (forecastType)
            {
            case ForecastType.ThreeHour:
                return("forecast");

            case ForecastType.Hourly:
                return("forecast/hourly");

            case ForecastType.Daily:
                return("forecast/daily");

            default:
                throw new ArgumentException("Unknown forecast type.", nameof(forecastType));
            }
        }
Esempio n. 14
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        var  oldColor = GUI.backgroundColor;
        Rect boxRect  = new Rect(position.x, position.y + 5, 20, 20);
        SerializedProperty editorTiles = property.FindPropertyRelative("editorTiles");

        if (editorTiles.arraySize == 0)
        {
            return;
        }
        for (int x = 0; x < 5; x++)
        {
            for (int y = 0; y < 5; y++)
            {
                SerializedProperty editorTile   = editorTiles.GetArrayElementAtIndex(x * 5 + y);
                Vector2Int         editorOffset = editorTile.FindPropertyRelative("editorOffset").vector2IntValue;
                // for (int i = 0; i < count; i++) {
                ForecastType type = (ForecastType)(editorTile.FindPropertyRelative("type").enumValueIndex);
                if (editorOffset.x == x && editorOffset.y == y)   // get the relevant forecastTie to test its type
                {
                    if (type.Equals(ForecastType.Water))
                    {
                        GUI.backgroundColor = Color.blue;
                    }
                    else if (type.Equals(ForecastType.Sun))
                    {
                        GUI.backgroundColor = Color.yellow;
                    }
                    else
                    {
                        GUI.backgroundColor = oldColor;
                    }
                }
                if (GUI.Button(new Rect(position.x + x * 20, position.y + 100 - (y + 1) * 20 + EditorGUIUtility.singleLineHeight / 2, 20, 20), ""))
                {
                    SerializedProperty editorTileType = editorTile.FindPropertyRelative("type");
                    editorTileType.enumValueIndex = (editorTileType.enumValueIndex + 1) % 3;
                    centerAtOrigin(editorTiles);
                }
            }
        }
        GUI.backgroundColor = oldColor;
        property.serializedObject.ApplyModifiedProperties();
        // Debug.Log(debugString);
    }
Esempio n. 15
0
    // public ForecastQueue forecastQueue;

    public void ApplyCurrentTetramino(ForecastShape _shape)
    {
        // Debug.Log("Applying!!!");
        int          x    = shapePositioning.currentOriginTile.x;
        int          y    = shapePositioning.currentOriginTile.y;
        ForecastType type = WeatherQueue.currentWeather;

        for (int i = 0; i < _shape.tiles.Count; i++)
        {
            Vector2Int offs = ShapePositioning.RotateOffset(_shape.tiles[i].offset, shapePositioning.rotation);
            // note that this is not using the type on the forecastTile (deprecated), but is instead using the current weather in the weatherqueue.
            if (_shape.tiles[i].type != ForecastType.None)
            {
                state.AddWeather(x + offs.x, y + offs.y, type, 1);
            }
            // if(_shape.tiles[i].type == ForecastType.Sun) state.AddSunlight(x+offs.x, y+offs.y, 1);
        }
    }
Esempio n. 16
0
        public static ForecastUtil Get(ForecastType type)
        {
            var text   = File.ReadAllText($@"Forecast\{type}Forecast.txt");
            var lines  = text.Split('\n');
            var result = new ForecastUtil();

            foreach (var item in lines)
            {
                if (string.IsNullOrEmpty(item.Trim()) == false)
                {
                    var values = item.Split(',');
                    result.Periods.Add(new ForecastItem {
                        Year = int.Parse(values[0]), Interest = double.Parse(values[1])
                    });
                }
            }

            return(result);
        }
Esempio n. 17
0
        public void UpdateSelectedState(int newNewestPeriod = GS.DEFAULT_NEWEST_PERIOD_COUNT, int newDingMaCount = GS.DEFAULT_DING_MA_COUNT, ForecastType newForecastType = GS.DEFAULT_FORECAST_TYPE)
        {
            if (this.currentSelectedNewestPeriod == newNewestPeriod && this.currentSelectedDingMaCount == newDingMaCount && this.currentSelectedForecastType == newForecastType)
            {
                return;
            }

            #region 校验 “排除最新期数号” 和 “定码个数” 值的合法性。
            if (newNewestPeriod < GS.MIN_NEWEST_PERIOD_COUNT || newNewestPeriod > GS.MAX_NEWEST_PERIOD_COUNT)
            {
                throw new ApplicationException("“排除最新期数号” 的值超出允许的最大范围(" + GS.MIN_NEWEST_PERIOD_COUNT + "-" + GS.MAX_NEWEST_PERIOD_COUNT + ")");
            }
            if (newDingMaCount < GS.MIN_DING_MA_COUNT || newDingMaCount > GS.MAX_DING_MA_COUNT)
            {
                throw new ApplicationException("“定码个数” 的值超出允许的最大范围(" + GS.MIN_DING_MA_COUNT + "-" + GS.MAX_DING_MA_COUNT + ")");
            }
            if (newNewestPeriod + newDingMaCount > 100)
            {
                throw new ArgumentOutOfRangeException("newDingMaCount", "所设置的 “排除最新期数号” 和 “定码个数” 两个数的和不能大于 100!请重新设置!");
            }



            #endregion

            this.currentSelectedNewestPeriod = newNewestPeriod;
            this.currentSelectedDingMaCount  = newDingMaCount;
            this.currentSelectedForecastType = newForecastType;

            //int actuallyCount;
            lock (syncObj)
            {
                List <SourceData> historySourceDatas = mgr.GetTopRangeHistorySourceData(0, this.currentSelectedNewestPeriod, true, false);
                nextNewestLog.FillForecast(historySourceDatas.ExtractWinningNumber(), this.currentSelectedDingMaCount, this.currentSelectedForecastType);
                //nextNewestLog.FillForecast(CalNextPlanForecastList(out actuallyCount), actuallyCount, this.currentSelectedForecastType);
            }

            UpdateAllWinLogs();
            CalTotalWinAndTotalLose();
            CalMaxContinueWinAndMaxContinueLose();
        }
        public static ForecastType Create()
        {
            var doc = new ForecastType
            {
                UBLVersionID  = "2.1",
                ProfileID     = "bpid:urn:oasis:names:draft:bpss:ubl-2-1-cpfr-forecast-draft",
                ID            = "OF758494",
                CopyIndicator = false,
                UUID          = "349ABBAE-DF9D-40B4-849F-94C5FF9D1AF4",
                IssueDate     = "2010-01-01",
                IssueTime     = "12:00:01.000",
                Note          = new List <TextType>()
                {
                    new TextType
                    {
                        Value = "sample"
                    }
                },
                BasedOnConsensusIndicator = true,
                ForecastPurposeCode       = "ORDER_FORECAST",
                ForecastPeriod            = new PeriodType
                {
                    StartDate = "2010-02-01",
                    EndDate   = "2010-05-26"
                },
                SenderParty = new PartyType
                {
                    PartyIdentification = new List <PartyIdentificationType>()
                    {
                        new PartyIdentificationType
                        {
                            ID = "6903148000007"
                        }
                    },
                    PartyName = new List <PartyNameType>()
                    {
                        new PartyNameType
                        {
                            Name = "Consortial"
                        }
                    },
                    PostalAddress = new AddressType
                    {
                        StreetName       = "Busy Street",
                        BuildingName     = "Thereabouts",
                        BuildingNumber   = "56A",
                        CityName         = "Farthing",
                        PostalZone       = "AA99 1BB",
                        CountrySubentity = "Heremouthshire",
                        AddressLine      = new List <AddressLineType>()
                        {
                            new AddressLineType
                            {
                                Line = "The Roundabout"
                            }
                        },
                        Country = new CountryType
                        {
                            IdentificationCode = "GB"
                        }
                    },
                    PartyTaxScheme = new List <PartyTaxSchemeType>()
                    {
                        new PartyTaxSchemeType
                        {
                            RegistrationName = "Farthing Purchasing Consortium",
                            CompanyID        = "175 269 2355",
                            ExemptionReason  = new List <TextType>()
                            {
                                new TextType
                                {
                                    Value = "N/A"
                                }
                            },
                            TaxScheme = new TaxSchemeType
                            {
                                ID          = "VAT",
                                TaxTypeCode = "VAT"
                            }
                        }
                    },
                    Contact = new ContactType
                    {
                        Name           = "Mrs Bouquet",
                        Telephone      = "0158 1233714",
                        Telefax        = "0158 1233856",
                        ElectronicMail = "*****@*****.**"
                    }
                },
                ReceiverParty = new PartyType
                {
                    PartyIdentification = new List <PartyIdentificationType>()
                    {
                        new PartyIdentificationType
                        {
                            ID = "2203148000007"
                        }
                    },
                    PartyName = new List <PartyNameType>()
                    {
                        new PartyNameType
                        {
                            Name = "IYT Corporation"
                        }
                    },
                    PostalAddress = new AddressType
                    {
                        StreetName       = "Avon Way",
                        BuildingName     = "Thereabouts",
                        BuildingNumber   = "56A",
                        CityName         = "Bridgtow",
                        PostalZone       = "ZZ99 1ZZ",
                        CountrySubentity = "Avon",
                        AddressLine      = new List <AddressLineType>()
                        {
                            new AddressLineType
                            {
                                Line = "3rd Floor, Room 5"
                            }
                        },
                        Country = new CountryType
                        {
                            IdentificationCode = "GB"
                        }
                    },
                    PartyTaxScheme = new List <PartyTaxSchemeType>()
                    {
                        new PartyTaxSchemeType
                        {
                            RegistrationName = "Bridgtow District Council",
                            CompanyID        = "12356478",
                            ExemptionReason  = new List <TextType>()
                            {
                                new TextType
                                {
                                    Value = "Local Authority"
                                }
                            },
                            TaxScheme = new TaxSchemeType
                            {
                                ID          = "UK VAT",
                                TaxTypeCode = "VAT"
                            }
                        }
                    },
                    Contact = new ContactType
                    {
                        Name           = "Mr Fred Churchill",
                        Telephone      = "0127 2653214",
                        Telefax        = "0127 2653215",
                        ElectronicMail = "*****@*****.**"
                    }
                },
                BuyerCustomerParty = new CustomerPartyType
                {
                    Party = new PartyType
                    {
                        PartyIdentification = new List <PartyIdentificationType>()
                        {
                            new PartyIdentificationType
                            {
                                ID = "0012345000359"
                            }
                        },
                    }
                },
                SellerSupplierParty = new SupplierPartyType
                {
                    Party = new PartyType
                    {
                        PartyIdentification = new List <PartyIdentificationType>()
                        {
                            new PartyIdentificationType
                            {
                                ID = "0012345000058"
                            }
                        },
                    }
                },
                ForecastLine = new List <ForecastLineType>()
                {
                    new ForecastLineType
                    {
                        ID = "forecastLineID",
                        ForecastTypeCode = "TOTAL",
                        ForecastPeriod   = new PeriodType
                        {
                            StartDate = "2010-02-01",
                            EndDate   = "2010-05-26"
                        },
                        SalesItem = new SalesItemType
                        {
                            Quantity = new QuantityType
                            {
                                unitCode = "KGM",
                                Value    = 20M
                            },
                            Item = new ItemType
                            {
                                Description = new List <TextType>()
                                {
                                    new TextType
                                    {
                                        Value = "Acme beeswax"
                                    }
                                },
                                Name = "beeswax",
                                BuyersItemIdentification = new ItemIdentificationType
                                {
                                    ID = "6578489"
                                },
                                SellersItemIdentification = new ItemIdentificationType
                                {
                                    ID = "17589683"
                                },
                                StandardItemIdentification = new ItemIdentificationType
                                {
                                    ID = "00123450000584"
                                }
                            }
                        }
                    }
                },
            };

            doc.Xmlns = new System.Xml.Serialization.XmlSerializerNamespaces(new[]
            {
                new XmlQualifiedName("cac", "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"),
                new XmlQualifiedName("cbc", "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"),
            });
            return(doc);
        }
Esempio n. 19
0
 public void ReceiveWeather(ForecastType type)
 {
     receivedThisTurn = type;
     Debug.Log(currentlyWanting + ";" + receivedThisTurn);
 }
Esempio n. 20
0
 /// <summary>
 /// 在开奖结果的信息公布之后,根据指定的 “预测列表”、“定码类型” 和开奖结果的源数据对象 sourceData 来创建一个用来存储开奖记录数据的对象。
 /// 即根据:计划预测 “PlanForecast”、定码类型 “currentForecastType”、计划结果 “isWin” 和 SourceData 对象来创建 WinLog 对象。
 /// </summary>
 /// <param name="planForecastNumberList"></param>
 /// <param name="actuallyHistoryWinningNumberCount"> 实际上能够获取得到用来计算 “计划预测” 列表的 “排除最新期数号” 数量(因为有时候能获取到的 “排除最新期数号” 的数量并不一定能够达到所要求获取的数量)。</param>
 /// <param name="forecastType"></param>
 /// <param name="sourceData"></param>
 public WinLog(List <string> planForecastNumberList, int actuallyHistoryWinningNumberCount, ForecastType forecastType, SourceData sourceData) : this(planForecastNumberList, actuallyHistoryWinningNumberCount, forecastType)
 {
     FillResult(sourceData);
 }
Esempio n. 21
0
 /// <summary>
 /// 在还没有公布开奖结果的信息之前,根据指定的 “历史中奖号码记录列表”、“定码数量” 和 “定码类型” 来创建一个用来存储开奖记录数据的对象。
 /// 即根据:计划预测 “PlanForecast”、定码类型 “currentForecastType”、计划结果 “isWin” 来创建 WinLog 对象。
 /// </summary>
 /// <param name="historyWinningNumber">历史中奖号码记录集合(集合可以没有任何元素,但本身不可以为 null,否则会抛出异常)。</param>
 /// <param name="dingMaCount">设定要保留的定码个数。</param>
 /// <param name="forecastType">设定的定码类型。</param>
 public WinLog(List <Number> historyWinningNumber, int dingMaCount, ForecastType forecastType) : this()
 {
     FillForecast(historyWinningNumber, dingMaCount, forecastType);
 }
Esempio n. 22
0
        /// <summary>
        /// 根据传入的最新历史中奖号码集合(historyWinningNumber)、保留的定码个数(dingMaCount)和定码类型(forecastType)来计算出下一个即将公布的中奖号码的定码 “计划预测” 列表。
        /// 如果 historyWinningNumber 为 null 则抛出异常。
        /// 注意:该方法目的是计算即将公布(但还没公布)的未来一期的 “计划预测” 值;
        /// historyWinningNumber 参数的 Count 属性值其实就是界面上选择的 “排除最新期数号”;
        /// dingMaCount 参数其实就是界面上选择的 “定码个数”;
        /// forecastType 参数就是界面上选择的定码类型 “前二码/后二码”;
        /// </summary>
        /// <param name="historyWinningNumber">最新的某个期数范围的历史中奖号码的集合(集合可以没有任何元素,但本身不可以为 null),期数范围由该 historyWinningNumber 集合的元素个数来确定,集合中的每个中奖号码之间没有顺序关系,中奖号码有可能会出现重复。</param>
        /// <param name="dingMaCount">要经过筛选后最后保留的定码(前二码/后二码)个数。</param>
        /// <param name="forecastType">定码的类型(前二码/后二码)。</param>
        /// <returns>
        /// 返回 “计划预测” 列表。如果 historyWinningNumber 为 null 则抛出异常。
        /// </returns>
        private List <string> CalPlanForecastList(List <Number> historyWinningNumber, int dingMaCount, ForecastType forecastType)
        {
            if (historyWinningNumber == null)
            {
                throw new ArgumentNullException("historyWinningNumber");
            }
            //如果 “排除最新期数” 的数量超出允许的最大范围。
            if (historyWinningNumber.Count < GS.MIN_NEWEST_PERIOD_COUNT || historyWinningNumber.Count > GS.MAX_NEWEST_PERIOD_COUNT)
            {
                throw new ArgumentOutOfRangeException("historyWinningNumber", "“排除最新期数” 的数量超出允许的最大范围(" + GS.MIN_NEWEST_PERIOD_COUNT + "-" + GS.MAX_NEWEST_PERIOD_COUNT + ")!");
            }
            if (dingMaCount < GS.MIN_DING_MA_COUNT || dingMaCount > (100 - historyWinningNumber.Count))
            {
                throw new ArgumentOutOfRangeException("dingMaCount", "所设置的 “排除最新期数号” 和 “定码个数” 两个数的和不能大于 100!请重新设置!");
            }
            //dingMaCount 参数就算满足了上面的限定,也有可能会超过所允许的最大值 MAX_DING_MA_COUNT,所以需要在此继续补充判断。
            if (dingMaCount > GS.MAX_DING_MA_COUNT)
            {
                throw new ArgumentOutOfRangeException("dingMaCount", "要保留的定码个数超出所允许的最大值(" + GS.MAX_DING_MA_COUNT + ")!");
            }
            //如果历史中奖号码列表 historyWinningNumber 中出现格式非法(即号码长度不等于 5)的中奖号码值,则抛出异常。
            if (historyWinningNumber.Exists(n => n.Length != 5))
            {
                throw new ArgumentException("所传入的 “历史中奖号码” 列表中含有格式非法的中奖号码!", "historyWinningNumber");
            }

            bool          isFirstTwo = forecastType == ForecastType.FirstTwo;
            List <string> planForecastListWaitForRemove = (from n in historyWinningNumber
                                                           select isFirstTwo ? n.FirstTwo() : n.LastTwo()).Distinct().ToList();

            ////由于该方法的功能只是负责计算出 “计划预测” 列表,并不需要设置当前对象的相关数据,填充数据的工作交给相关的方法去实现。
            //this.actuallyHistoryWinningNumberCount = historyWinningNumber.Count;

            #region 用后面的几行代码代替第 1 行的 GetRandoms() 方法,降低耦合度。
            //return GetRandoms(planForecastListWaitForRemove, dingMaCount).ToList();

            List <string> fullItems = GetFullForecastNumberList();
            RemoveSpecifiedItems(fullItems, planForecastListWaitForRemove);
            return(RandomSelectSomeItems(fullItems, dingMaCount).ToList());

            #endregion
        }
Esempio n. 23
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="historyWinningNumber">最新的某个范围的历史中奖号码的集合,范围由该 historyWinningNumber 集合的元素个数来确定,集合中的每个中奖号码之间没有顺序关系,中奖号码有可能会出现重复。</param>
        /// <param name="dingMaCount">要经过筛选后最后保留的定码(前二码/后二码)个数。</param>
        /// <param name="forecastType">定码的类型(前二码/后二码)。</param>
        public void FillForecast(List <Number> historyWinningNumber, int dingMaCount, ForecastType forecastType)
        {
            List <string> planForecastList = CalPlanForecastList(historyWinningNumber, dingMaCount, forecastType);

            FillForecast(planForecastList, historyWinningNumber.Count, forecastType);
        }
Esempio n. 24
0
        /// <summary>
        /// 根据指定的 “预测列表” 和 “定码类型” 来填充或更新当前对象的未确定属性(例如:计划预测 “PlanForecast”、计划结果 “isWin”、定码类型 “currentForecastType”、实际的排除最新期数号“actuallyHistoryWinningNumberCount” 等)的值。
        /// </summary>
        /// <param name="planForecastNumberList">在当前中奖纪录开奖前所计算预测出的 “计划预测” 列表,“定码个数” 由该 planForecastNumberList 列表的元素个数来确定。</param>
        /// <param name="actuallyHistoryWinningNumberCount"> 实际上能够获取得到用来计算 “计划预测” 列表的 “排除最新期数号” 数量(因为有时候能获取到的 “排除最新期数号” 的数量并不一定能够达到所要求获取的数量)。</param>
        /// <param name="forecastType">定码的类型(前二码/后二码)。</param>
        public void FillForecast(List <string> planForecastNumberList, int actuallyHistoryWinningNumberCount, ForecastType forecastType)
        {
            if (planForecastNumberList == null)
            {
                throw new ArgumentNullException("planForecastNumberList");
            }

            //如果 “计划预测” 列表 planForecastNumberList 中出现格式非法(即号码长度不等于 2)的预测号码值,则抛出异常。
            if (planForecastNumberList.Exists(n => n.Length != 2))
            {
                throw new ArgumentException("所传入的 “计划预测” 列表中含有格式非法的预测号码!", "planForecastNumberList");
            }


            //填充当前选中的 “定码类型”(前二码/后二码)。
            this.currentForecastType = forecastType;

            this.actuallyHistoryWinningNumberCount = actuallyHistoryWinningNumberCount;

            bool isFirstTwo = this.currentForecastType == ForecastType.FirstTwo;

            #region 旧思路
            ////如果当前的定码类型为 “前二码”。
            //if (isFirstTwo)
            //{
            //    this.firstTwoPlanForecast.Clear();
            //    //填充 “计划预测” 列表。
            //    this.firstTwoPlanForecast.AddRange(planForecastNumberList);
            //    //计算 “计划结果” 值(即 this.isWin 字段值),判断是否中奖。
            //    this.isWin = this.firstTwoPlanForecast.Contains(this.winningNumber.FirstTwo());
            //}
            ////否则,如果当前的定码类型为 “后二码”。
            //else
            //{
            //    this.lastTwoPlanForecast.Clear();
            //    //填充 “计划预测” 列表。
            //    this.lastTwoPlanForecast.AddRange(planForecastNumberList);
            //    //计算 “计划结果” 值(即 this.isWin 字段值),判断是否中奖。
            //    this.isWin = this.lastTwoPlanForecast.Contains(this.winningNumber.LastTwo());
            //}
            #endregion


            #region 新思路

            #region 严重错误!!!下面第一行的把 firstTwoPlanForecast 或 lastTwoPlanForecast(假设为变量 a 或 b,以 a 为例)赋值给变量 currentForecastContainer(假设为 c)的行为本质上是把 a 变量中所存储的对象的引用赋值给变量 c,所以此时 c 中存储的是对 a 中存储的对象的引用。而又因为下面第 2 行是给 c 重新赋值,而不是给 c 所指向的集合对象添加元素,所以执行完之后变量 a 中的集合还是没有任何元素。
            ////先根据当前的定码类型来设定当前用来存储的存储容器字段是 “前二码”(this.firstTwoPlanForecast)还是 “后二码”(this.lastTwoPlanForecast)的。
            //List<string> currentForecastContainer = isFirstTwo ? this.firstTwoPlanForecast : this.lastTwoPlanForecast;

            ////在当前的存储容器字段 currentForecast 中填充 “计划预测” 列表。
            //currentForecastContainer = planForecastNumberList;
            #endregion
            #region 修改之后解决了上面的严重错误,只要把 “直接给变量 currentForecastContainer 重新赋值” 的操作改成 “直接给变量 currentForecastContainer 所引用的集合对象添加元素” 即可。
            //先根据当前的定码类型来设定当前用来存储的存储容器字段是 “前二码”(this.firstTwoPlanForecast)还是 “后二码”(this.lastTwoPlanForecast)的。
            List <string> currentForecastContainer = isFirstTwo ? this.firstTwoPlanForecast : this.lastTwoPlanForecast;

            currentForecastContainer.Clear();
            //在当前的存储容器字段 currentForecast 中填充 “计划预测” 列表。
            currentForecastContainer.AddRange(planForecastNumberList);
            #endregion

            //如果 sourceData 对象已经初始化,则顺带初始化 this.isWin 字段。
            if (this.sourceData != null)
            {
                string dingMa = isFirstTwo ? this.winningNumber.FirstTwo() : this.winningNumber.LastTwo();
                //计算 “计划结果” 值(即 this.isWin 字段值),判断是否中奖。
                this.isWin = currentForecastContainer.Contains(dingMa);
            }
            #endregion
        }
Esempio n. 25
0
 /// <summary>
 /// 在还没有公布开奖结果的信息之前,根据指定的 “预测列表”、实际获取到的 “排除最新期数号” 的数量和 “定码类型” 来创建一个用来存储开奖记录数据的对象。
 /// 即根据:计划预测 “PlanForecast”、定码类型 “currentForecastType”、计划结果 “isWin” 来创建 WinLog 对象。
 /// </summary>
 /// <param name="planForecastNumberList">在当前中奖纪录开奖前所计算预测出的 “计划预测” 列表,“定码个数” 由该 planForecastNumberList 列表的元素个数来确定。</param>
 /// <param name="actuallyHistoryWinningNumberCount"> 实际上能够获取得到用来计算 “计划预测” 列表的 “排除最新期数号” 数量(因为有时候能获取到的 “排除最新期数号” 的数量并不一定能够达到所要求获取的数量)。</param>
 /// <param name="forecastType">定码的类型(前二码/后二码)。</param>
 public WinLog(List <string> planForecastNumberList, int actuallyHistoryWinningNumberCount, ForecastType forecastType) : this()
 {
     FillForecast(planForecastNumberList, actuallyHistoryWinningNumberCount, forecastType);
 }
Esempio n. 26
0
 private string GetEndpoint(ForecastType forecastType) => forecastType switch
 {
Esempio n. 27
0
        /// <summary>
        ///     Gets the weather forecast for the specified city asynchronously.
        /// </summary>
        /// <param name="latitude">the latitude to get the weather forecast for</param>
        /// <param name="longitude">the longitude to get the weather forecast for</param>
        /// <param name="forecastType">the forecast type (Hourly, ThreeHour or Daily)</param>
        /// <param name="requestOptions">
        ///     the request options (can change the behavior of requesting and controls caching,
        ///     cancellation, unit and language options of the result)
        /// </param>
        /// <returns>
        ///     a task that represents the asynchronous operation. The task result is the weather
        ///     forecast; or <see langword="null"/> if the city could not be found.
        /// </returns>
        public Task <WeatherForecast?> GetWeatherForecastAsync(double latitude, double longitude, ForecastType forecastType = ForecastType.ThreeHour, RequestOptions?requestOptions = default)
        {
            requestOptions ??= RequestOptions.Default;
            requestOptions.CancellationToken.ThrowIfCancellationRequested();

            var parameters = new NameValueCollection {
                { "lat", latitude.ToString(CultureInfo.InvariantCulture) },
                { "lon", longitude.ToString(CultureInfo.InvariantCulture) }
            };

            // send request
            return(RequestAsync <WeatherForecast>(GetEndpoint(forecastType), parameters, requestOptions));
        }
Esempio n. 28
0
 private void SetForecastTypeAndDedicatedHours(ForecastTypeRegistration forecastTypeReg, ForecastType forecastType, decimal?dedicatedHours)
 {
     forecastTypeReg.SelectedForecastType = forecastType;
     forecastTypeReg.DedicatedHours       = dedicatedHours;
 }
        private void CreateForecastWithSingleProjectRegistration(ForecastMonth month, DateTime date, ForecastType forecastType, Project project, decimal hours, decimal?dedicatedHours = null)
        {
            var forecast = month.AddForecast(date, forecastType, dedicatedHours);

            if (forecastType.SupportsProjectHours)
            {
                forecast.AddProjectRegistration(project, hours);
            }
        }
Esempio n. 30
0
        /// <summary>
        ///     Gets the weather forecast for the specified city asynchronously.
        /// </summary>
        /// <param name="zipCode">the zip code</param>
        /// <param name="country">the country where the zip code is in (defaults to US)</param>
        /// <param name="forecastType">the forecast type (Hourly, ThreeHour or Daily)</param>
        /// <param name="requestOptions">
        ///     the request options (can change the behavior of requesting and controls caching,
        ///     cancellation, unit and language options of the result)
        /// </param>
        /// <returns>
        ///     a task that represents the asynchronous operation. The task result is the weather
        ///     forecast; or <see langword="null"/> if the city could not be found.
        /// </returns>
        public Task <WeatherForecast?> GetWeatherForecastAsync(int zipCode, string country = "us", ForecastType forecastType = ForecastType.ThreeHour, RequestOptions?requestOptions = default)
        {
            requestOptions ??= RequestOptions.Default;
            requestOptions.CancellationToken.ThrowIfCancellationRequested();

            // send request
            var parameters = new NameValueCollection {
                { "zip", zipCode + "," + country }
            };

            return(RequestAsync <WeatherForecast>(GetEndpoint(forecastType), parameters, requestOptions));
        }