internal static DateTime CaliculatePeriod(DateTime date, PeriodType periodUnit, int amountOfTime)
        {
            try
            {
                switch (periodUnit)
                {
                    case PeriodType.Minutes:
                        return date.AddMinutes((double)amountOfTime);

                    case PeriodType.Hours:
                        return date.AddHours((double)amountOfTime);

                    case PeriodType.Days:
                        return date.AddDays((double)amountOfTime);

                    case PeriodType.Weeks:
                        return date.AddDays((double)(amountOfTime * 7));

                    case PeriodType.Months:
                        return date.AddMonths(amountOfTime);

                    case PeriodType.Years:
                        return date.AddYears(amountOfTime);
                }
            }
            catch { }
            return DateTime.MaxValue;
        }
Exemple #2
0
        /// <summary>
        /// Updates a layer of the state.
        /// </summary>
        /// <param name="layer">The layer.</param>
        /// <param name="upcomingDay">The upcoming day.</param>
        /// <param name="Indicators">The indicators.</param>
        private void UpdateLayer(PeriodType type, CircularQueue <Period> layer, Period upcomingDay, IEnumerable <ITechnicalIndicator> indicators)
        {
            Period currentPeriod = null;
            bool   needNewPeriod = type == PeriodType.Week ? upcomingDay.Date.IsStartOfWeek() : upcomingDay.Date.IsStartOfMonth();

            if (layer.IsEmpty || needNewPeriod)
            {
                currentPeriod            = upcomingDay.Clone();
                currentPeriod.PeriodType = type;
                layer.Enqueue(currentPeriod);
            }
            else
            {
                currentPeriod = layer.Peek();
                currentPeriod.Merge(upcomingDay);
            }

            foreach (var indicator in indicators)
            {
                var newValues       = indicator.Update(currentPeriod);
                var periodIndicator = currentPeriod.Indicators.SingleOrDefault(i => i.Name == indicator.Name);
                if (periodIndicator != null)
                {
                    periodIndicator.Values = newValues;
                }
                else
                {
                    currentPeriod.AddIndicator(new IndicatorValue(indicator.Name, newValues));
                }
            }
        }
        /// <summary>
        /// Returns the usage of the resources for the specified time range.
        /// </summary>
        /// <param name="server_id">Server's ID</param>
        /// <param name="period">required (one of LAST_HOUR,LAST_24H,LAST_7D,LAST_30D,LAST_365D,CUSTOM ),Time range whose logs will be shown.</param>
        /// <param name="start_date">(date) The first date in a custom range. Required only if selected period is "CUSTOM".</param>
        /// <param name="end_date">(date) The second date in a custom range. Required only if selected period is "CUSTOM".</param>
        public ServerMonitoringCenterResponse Show(string server_id, PeriodType period, DateTime?start_date = null, DateTime?end_date = null)
        {
            try
            {
                string requestUrl = "/monitoring_center/{server_id}?";
                requestUrl += string.Format("&period={0}", period);
                if (period == PeriodType.CUSTOM)
                {
                    requestUrl += string.Format("&start_date={0}", start_date.Value.ToString("s") + "Z");
                    requestUrl += string.Format("&end_date={0}", end_date.Value.ToString("s") + "Z");
                }

                var request = new RestRequest(requestUrl, Method.GET);
                request.AddUrlSegment("server_id", server_id);

                var result = restclient.Execute <ServerMonitoringCenterResponse>(request);
                if (result.StatusCode != HttpStatusCode.OK)
                {
                    throw new Exception(result.Content);
                }
                return(result.Data);
            }
            catch
            {
                throw;
            }
        }
		public async Task<List<Ticket>> GetPrice(
			string token, 
			string origin, 
			string destination, 
			DateTime departDate, 
            DateTime returnDate,
			PeriodType period = PeriodType.Year, 
			bool isOneWay = false, 
			int page = 1, 
			int limit = 30,
			bool isShowToAffiliates = true,
			SortingMode sorting = SortingMode.Price,
			TripClassMode tripClass = TripClassMode.Econom)
		{
			var settings = new QuerySettings(origin, destination)
			{
                BeginningOfPeriod = departDate,
				Period = period,
				IsOneWay = isOneWay,
				Page = page,
				Limit = limit,
				IsShowToAffiliates = isShowToAffiliates,
				Sorting = sorting,
				TripClass = tripClass,
			};

            var interval = returnDate - departDate;
            
            settings.TripDuration = period == PeriodType.Day ? interval.Days : interval.Days / 7;

			return await GetPrice(token, settings);
		}
Exemple #5
0
        public DateTime Base(DateTime timestamp)
        {
            switch (PeriodType)
            {
            case PeriodType.Millisecond:
            case PeriodType.Second:
            case PeriodType.Minute:
            case PeriodType.Hour:
            case PeriodType.Day:
            case PeriodType.Week:
            {
                return(new DateTime(timestamp.Ticks - timestamp.Ticks % periodInTicks));
            }

            case PeriodType.Month:
            {
                int months = 12 * (timestamp.Year - 1) + timestamp.Month - 1;
                months = months - months % Duration;
                int year  = 1 + months / 12;
                int month = 1 + months % 12;

                return(new DateTime(year, month, 1));
            }

            case PeriodType.Year:
            {
                int year = timestamp.Year;

                return(new DateTime(year - year % Duration, 1, 1));
            }

            default:
                throw new NotSupportedException(PeriodType.ToString());
            }
        }
Exemple #6
0
        public BaseTime(PeriodType periodType, int duration)
        {
            if (duration <= 0)
            {
                throw new ArgumentException("periodValue");
            }

            PeriodType = periodType;
            Duration   = duration;

            switch (periodType)
            {
            case PeriodType.Millisecond: periodInTicks = duration * TICKS_PER_MILLISECOND; break;

            case PeriodType.Second: periodInTicks = duration * TICKS_PER_SECOND; break;

            case PeriodType.Minute: periodInTicks = duration * TICKS_PER_MINUTE; break;

            case PeriodType.Hour: periodInTicks = duration * TICKS_PER_HOUR; break;

            case PeriodType.Day: periodInTicks = duration * TICKS_PER_DAY; break;

            case PeriodType.Week: periodInTicks = duration * 7 * TICKS_PER_DAY; break;
            }
        }
        /// <summary>
        /// Returns the usage of the resources for the specified time range.
        /// </summary>
        /// <param name="server_id">Server's ID</param>
        /// <param name="period">required (one of LAST_HOUR,LAST_24H,LAST_7D,LAST_30D,LAST_365D,CUSTOM ),Time range whose logs will be shown.</param>
        /// <param name="start_date">(date) The first date in a custom range. Required only if selected period is "CUSTOM".</param>
        /// <param name="end_date">(date) The second date in a custom range. Required only if selected period is "CUSTOM".</param>
        public ServerMonitoringCenterResponse Show(string server_id, PeriodType period, DateTime? start_date = null, DateTime? end_date = null)
        {
            try
            {
                string requestUrl = "/monitoring_center/{server_id}?";
                requestUrl += string.Format("&period={0}", period);
                if (period ==PeriodType.CUSTOM)
                {
                    requestUrl += string.Format("&start_date={0}", start_date.Value.ToString("s") + "Z");
                    requestUrl += string.Format("&end_date={0}", end_date.Value.ToString("s") + "Z");
                }

                var request = new RestRequest(requestUrl, Method.GET);
                request.AddUrlSegment("server_id", server_id);

                var result = restclient.Execute<ServerMonitoringCenterResponse>(request);
                if (result.StatusCode != HttpStatusCode.OK)
                {
                    throw new Exception(result.Content);
                }
                return result.Data;
            }
            catch
            {
                throw;
            }
        }
        private void _timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            if (ActualTime.TotalSeconds > 0)
            {
                ActualTime = ActualTime.Subtract(TimeSpan.FromSeconds(1));
            }
            else
            {
                _timer.Stop();

                PlaySound();

                if (_periodType == PeriodType.Work)
                {
                    _periodType = PeriodType.Break;
                    ActualTime  = _breakDuration;

                    _timer.Start();
                }
                else
                {
                    _periodType = PeriodType.Work;
                    ActualTime  = _workDuration;
                }
            }
        }
Exemple #9
0
        public async Task UpdateProjectInvestmentAsync(PeriodType periodType)
        {
            var para = new ProxyProjectInvestment.Parameter()
            {
                PeriodType = periodType
            };
            var proxy = new ProxyProjectInvestment();
            var user  = BusinessCache.UserTzbProxies.GetRandomProxy(1);

            if (user != null)
            {
                if (user.HasValue)
                {
                    var ret = await proxy.SearchAsync(user.TokenOffical, para);

                    switch (periodType)
                    {
                    case PeriodType.Day:
                        BusinessCache.MonitorInfo.ProjectInvestmentDay = ret;
                        break;

                    case PeriodType.Month:
                        BusinessCache.MonitorInfo.ProjectInvestmentMonth = ret;
                        break;
                    }
                }
            }
        }
Exemple #10
0
        private PeriodDates CalculateDates(DateTime date, PeriodType periodType)
        {
            switch (periodType)
            {
            case PeriodType.Day:
                return(new PeriodDates
                {
                    DateFrom = date.Date,
                    DateTo = date.Date
                });

            case PeriodType.WorkingWeek:
                var dayOfWeek    = date.DayOfWeek == 0 ? 7 : (int)date.DayOfWeek;
                var daysToMonday = (int)DayOfWeek.Monday - dayOfWeek;
                var daysToFriday = (int)DayOfWeek.Friday - dayOfWeek;
                return(new PeriodDates
                {
                    DateFrom = date.AddDays(daysToMonday).Date,
                    DateTo = date.AddDays(daysToFriday).Date
                });

            case PeriodType.Month:
                return(new PeriodDates
                {
                    DateFrom = new DateTime(date.Year, date.Month, 1).Date,
                    DateTo = new DateTime(date.Year, date.Month, DateTime.DaysInMonth(date.Year, date.Month)).Date
                });

            default:
                throw new ArgumentOutOfRangeException(nameof(periodType), periodType, null);
            }
        }
Exemple #11
0
        internal static DateTime CaliculatePeriod(DateTime date, PeriodType periodUnit, int amountOfTime)
        {
            try
            {
                switch (periodUnit)
                {
                case PeriodType.Minutes:
                    return(date.AddMinutes((double)amountOfTime));

                case PeriodType.Hours:
                    return(date.AddHours((double)amountOfTime));

                case PeriodType.Days:
                    return(date.AddDays((double)amountOfTime));

                case PeriodType.Weeks:
                    return(date.AddDays((double)(amountOfTime * 7)));

                case PeriodType.Months:
                    return(date.AddMonths(amountOfTime));

                case PeriodType.Years:
                    return(date.AddYears(amountOfTime));
                }
            }
            catch { }
            return(DateTime.MaxValue);
        }
 public TenderType()
 {
     this.tenderedProjectField         = new ObservableCollection <TenderedProjectType>();
     this.originatorCustomerPartyField = new CustomerPartyType();
     this.contractingPartyField        = new ContractingPartyType();
     this.subcontractorPartyField      = new ObservableCollection <PartyType>();
     this.tendererQualificationDocumentReferenceField = new DocumentReferenceType();
     this.tendererPartyField     = new PartyType();
     this.signatureField         = new ObservableCollection <SignatureType>();
     this.documentReferenceField = new ObservableCollection <DocumentReferenceType>();
     this.validityPeriodField    = new PeriodType();
     this.noteField             = new ObservableCollection <NoteType>();
     this.contractNameField     = new ObservableCollection <ContractNameType>();
     this.issueTimeField        = new IssueTimeType();
     this.issueDateField        = new IssueDateType();
     this.contractFolderIDField = new ContractFolderIDType();
     this.tenderTypeCodeField   = new TenderTypeCodeType();
     this.uUIDField             = new UUIDType();
     this.copyIndicatorField    = new CopyIndicatorType();
     this.idField = new IDType();
     this.profileExecutionIDField = new ProfileExecutionIDType();
     this.profileIDField          = new ProfileIDType();
     this.customizationIDField    = new CustomizationIDType();
     this.uBLVersionIDField       = new UBLVersionIDType();
     this.uBLExtensionsField      = new ObservableCollection <UBLExtensionType>();
 }
 public ForecastType()
 {
     this.forecastLineField                = new ObservableCollection <ForecastLineType>();
     this.sellerSupplierPartyField         = new SupplierPartyType();
     this.buyerCustomerPartyField          = new CustomerPartyType();
     this.receiverPartyField               = new PartyType();
     this.senderPartyField                 = new PartyType();
     this.signatureField                   = new ObservableCollection <SignatureType>();
     this.additionalDocumentReferenceField = new ObservableCollection <DocumentReferenceType>();
     this.forecastPeriodField              = new PeriodType();
     this.forecastPurposeCodeField         = new ForecastPurposeCodeType();
     this.basedOnConsensusIndicatorField   = new BasedOnConsensusIndicatorType();
     this.versionIDField                   = new VersionIDType();
     this.noteField               = new ObservableCollection <NoteType>();
     this.issueTimeField          = new IssueTimeType();
     this.issueDateField          = new IssueDateType();
     this.uUIDField               = new UUIDType();
     this.copyIndicatorField      = new CopyIndicatorType();
     this.idField                 = new IDType();
     this.profileExecutionIDField = new ProfileExecutionIDType();
     this.profileIDField          = new ProfileIDType();
     this.customizationIDField    = new CustomizationIDType();
     this.uBLVersionIDField       = new UBLVersionIDType();
     this.uBLExtensionsField      = new ObservableCollection <UBLExtensionType>();
 }
 public StatementType()
 {
     this.statementLineField               = new ObservableCollection <StatementLineType>();
     this.taxTotalField                    = new ObservableCollection <TaxTotalType>();
     this.allowanceChargeField             = new ObservableCollection <AllowanceChargeType>();
     this.paymentTermsField                = new ObservableCollection <PaymentTermsType>();
     this.paymentMeansField                = new ObservableCollection <PaymentMeansType>();
     this.payeePartyField                  = new PartyType();
     this.originatorCustomerPartyField     = new CustomerPartyType();
     this.sellerSupplierPartyField         = new SupplierPartyType();
     this.buyerCustomerPartyField          = new CustomerPartyType();
     this.accountingCustomerPartyField     = new CustomerPartyType();
     this.accountingSupplierPartyField     = new SupplierPartyType();
     this.signatureField                   = new ObservableCollection <SignatureType>();
     this.additionalDocumentReferenceField = new ObservableCollection <DocumentReferenceType>();
     this.statementPeriodField             = new PeriodType();
     this.statementTypeCodeField           = new StatementTypeCodeType();
     this.lineCountNumericField            = new LineCountNumericType();
     this.totalBalanceAmountField          = new TotalBalanceAmountType();
     this.totalCreditAmountField           = new TotalCreditAmountType();
     this.totalDebitAmountField            = new TotalDebitAmountType();
     this.documentCurrencyCodeField        = new DocumentCurrencyCodeType();
     this.noteField               = new ObservableCollection <NoteType>();
     this.issueTimeField          = new IssueTimeType();
     this.issueDateField          = new IssueDateType();
     this.uUIDField               = new UUIDType();
     this.copyIndicatorField      = new CopyIndicatorType();
     this.idField                 = new IDType();
     this.profileExecutionIDField = new ProfileExecutionIDType();
     this.profileIDField          = new ProfileIDType();
     this.customizationIDField    = new CustomizationIDType();
     this.uBLVersionIDField       = new UBLVersionIDType();
     this.uBLExtensionsField      = new ObservableCollection <UBLExtensionType>();
 }
 public ContractNoticeType()
 {
     this.procurementProjectLotField   = new ObservableCollection <ProcurementProjectLotType>();
     this.procurementProjectField      = new ProcurementProjectType();
     this.tenderingProcessField        = new TenderingProcessType();
     this.tenderingTermsField          = new TenderingTermsType();
     this.receiverPartyField           = new PartyType();
     this.originatorCustomerPartyField = new ObservableCollection <CustomerPartyType>();
     this.contractingPartyField        = new ContractingPartyType();
     this.signatureField                = new ObservableCollection <SignatureType>();
     this.frequencyPeriodField          = new PeriodType();
     this.regulatoryDomainField         = new ObservableCollection <RegulatoryDomainType>();
     this.requestedPublicationDateField = new RequestedPublicationDateType();
     this.noteField             = new ObservableCollection <NoteType>();
     this.issueTimeField        = new IssueTimeType();
     this.issueDateField        = new IssueDateType();
     this.contractFolderIDField = new ContractFolderIDType();
     this.uUIDField             = new UUIDType();
     this.copyIndicatorField    = new CopyIndicatorType();
     this.idField = new IDType();
     this.profileExecutionIDField = new ProfileExecutionIDType();
     this.profileIDField          = new ProfileIDType();
     this.customizationIDField    = new CustomizationIDType();
     this.uBLVersionIDField       = new UBLVersionIDType();
     this.uBLExtensionsField      = new ObservableCollection <UBLExtensionType>();
 }
Exemple #16
0
            public ThisReportParams(ReportParams ps)
            {
                PeriodType = (PeriodType)((int)ps["PeriodType"]);
                if (!ps.GetParam("IntervalBegin").IsNull)
                {
                    IntervalBegin = (DateTime)ps["IntervalBegin"];
                }
                if (!ps.GetParam("IntervalEnd").IsNull)
                {
                    IntervalEnd = (DateTime)ps["IntervalEnd"];
                }
                if (!ps.GetParam("Quarter").IsNull)
                {
                    Quarter = (Quarter)((int)ps["Quarter"]);
                }
                Folder           = (Guid)ps["Folder"];
                ShowDetalization = (bool)((int)ps["ShowDetalization"] != 0);
                TimeMeasureUnits = (TimeMeasureUnits)((int)ps["TimeMeasureUnits"]);
                SortBy           = (ReportDepartmentCostSort)((int)ps["SortBy"]);
                ShowRestrictions = (bool)((int)ps["ShowRestrictions"] != 0);

                //if (PeriodType != PeriodType.DateInterval && (IntervalBegin.HasValue || IntervalEnd.HasValue))
                //	throw new ApplicationException("Заданы даты интервала при типе периода отличном от Интервал дат");

                //if (PeriodType != PeriodType.SelectedQuarter && Quarter.HasValue)
                //	throw new ApplicationException("Задан квартал при типе периода отличном от Квартал");
            }
Exemple #17
0
        } //End getAll()

        /**
         * Method to get a period type by user id
         */
        public PeriodType getPeriod(Int32 pCode)
        {
            String sql = "SP_GETPERIODTYPE";

            try
            {
                SqlCommand oCommand = new SqlCommand(sql);
                oCommand.CommandType = System.Data.CommandType.StoredProcedure;
                oCommand.Parameters.AddWithValue("@CODE", pCode);
                oCommand.Parameters[0].Direction = ParameterDirection.Input;
                DataTable  oDataTable  = DAO.getInstance().executeQuery(oCommand);
                PeriodType oPeriodType = new PeriodType();
                foreach (DataRow oDataRow in oDataTable.Rows)
                {
                    oPeriodType.code        = Convert.ToInt32(oDataRow[0].ToString());
                    oPeriodType.description = oDataRow[1].ToString();
                    oPeriodType.state       = Convert.ToInt16(oDataRow[2].ToString());
                }
                return(oPeriodType);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally { }
        } //End getPeriod()
Exemple #18
0
        } //End getAll()

        public List <PeriodType> getAllActived()
        {
            String sql = "SP_GETALLACTIVEPERIODTYPE";

            try
            {
                SqlCommand oCommand = new SqlCommand(sql);
                oCommand.CommandType = System.Data.CommandType.StoredProcedure;
                DataTable         oDataTable     = DAO.getInstance().executeQuery(oCommand);
                List <PeriodType> listPeriodType = new List <PeriodType>();
                foreach (DataRow oDataRow in oDataTable.Rows)
                {
                    PeriodType oPeriodType = new PeriodType();
                    oPeriodType.code        = Convert.ToInt32(oDataRow[0].ToString());
                    oPeriodType.description = oDataRow[1].ToString();
                    oPeriodType.state       = Convert.ToInt16(oDataRow[2].ToString());
                    listPeriodType.Add(oPeriodType);
                }
                return(listPeriodType);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally { }
        } //End getAll()
Exemple #19
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hash = 23;
         hash = hash * 37 + (Home != null ? Home.GetHashCode() : 0);
         hash = hash * 37 + (Away != null ? Away.GetHashCode() : 0);
         hash = hash * 37 + (ShortHome != null ? ShortHome.GetHashCode() : 0);
         hash = hash * 37 + (ShortAway != null ? ShortAway.GetHashCode() : 0);
         hash = hash * 37 + HomeScore.GetHashCode();
         hash = hash * 37 + AwayScore.GetHashCode();
         hash = hash * 37 + HomeFouls.GetHashCode();
         hash = hash * 37 + AwayFouls.GetHashCode();
         hash = hash * 37 + Period.GetHashCode();
         hash = hash * 37 + PeriodType.GetHashCode();
         hash = hash * 37 + IsTeamEdit.GetHashCode();
         hash = hash * 37 + IsEndGame.GetHashCode();
         hash = hash * 37 + HomeColor.GetHashCode();
         hash = hash * 37 + AwayColor.GetHashCode();
         hash = hash * 37 + (HomeLogo != null ? HomeLogo.GetHashCode() : 0);
         hash = hash * 37 + (AwayLogo != null ? AwayLogo.GetHashCode() : 0);
         hash = hash * 37 + (Configuration != null ? Configuration.GetHashCode() : 0);
         return(hash);
     }
 }
Exemple #20
0
        public Bars GetBars(string symbol, PeriodType period, Client client)
        {
            if (bars != null && bars.Symbol == symbol && bars.Period == period && bars.Count >= MaxBarsCount(period))
            {
                return(bars);
            }

            if (bars == null || bars.Symbol != symbol || bars.Period != period)
            {
                bars = new Bars(symbol, period);
            }

            while (bars.Count < MaxBarsCount(period))
            {
                int  count   = MaxBarsCount(period);
                Bars mt4bars = client.GetBars(symbol, period, ref count, bars.Count);
                if (mt4bars == null)
                {
                    return(bars.Count > 0 ? bars : null);
                }

                bars.Merge(mt4bars);
                if (bars.Count >= count)
                {
                    break;
                }
            }

            bars.SetLenght(MaxBarsCount(period));

            return(bars);
        }
Exemple #21
0
        private void cboPeriodType_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cboPeriodType.SelectedItem != null)
            {
                PeriodType periodType = cboPeriodType.SelectedItem as PeriodType;
                if (periodType.PeriodTypeCode.ToLower() == "any")
                {
                    edtBeginDT.Enabled = true;
                    edtEndDT.Enabled   = true;

                    btnPrevPeriod.Visible = false;
                    btnNextPeriod.Visible = false;
                }
                else
                {
                    edtBeginDT.Enabled = false;
                    edtEndDT.Enabled   = false;

                    btnPrevPeriod.Visible = true;
                    btnNextPeriod.Visible = true;

                    GetPeriod((cboPeriodType.SelectedItem as PeriodType), DateTime.Now, 0);
                }
            }
        }
        private void DrawPeriodEditor()
        {
            var pulse = (Pulse)target;

            _periodType = (PeriodType)EditorGUILayout.EnumPopup(_periodType);

            switch (_periodType)
            {
                case PeriodType.Seconds:
                    pulse.Period = EditorGUILayout.DoubleField(PeriodLabel, pulse.Period);
                    break;
                case PeriodType.Bpm:
                    var bpm = 60.0 / (pulse.Period * pulse.PulsesPerBeat);

                    EditorGUI.BeginChangeCheck();

                    bpm = EditorGUILayout.DoubleField(BpmLabel, bpm);

                    var pulsesPerBeat = (uint)EditorGUILayout.IntSlider(PpbLabel, (int)pulse.PulsesPerBeat, 1, 16);

                    if (EditorGUI.EndChangeCheck())
                    {
                        pulse.SetBpm(bpm, pulsesPerBeat);
                    }

                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }
        }
 public GuaranteeCertificateType()
 {
     this.beneficiaryPartyField           = new PartyType();
     this.interestedPartyField            = new PartyType();
     this.guarantorPartyField             = new PartyType();
     this.signatureField                  = new ObservableCollection <SignatureType>();
     this.immobilizedSecurityField        = new ObservableCollection <ImmobilizedSecurityType>();
     this.guaranteeDocumentReferenceField = new ObservableCollection <DocumentReferenceType>();
     this.applicableRegulationField       = new ObservableCollection <RegulationType>();
     this.applicablePeriodField           = new PeriodType();
     this.noteField              = new ObservableCollection <NoteType>();
     this.constitutionCodeField  = new ConstitutionCodeType();
     this.liabilityAmountField   = new LiabilityAmountType();
     this.purposeField           = new ObservableCollection <PurposeType>();
     this.guaranteeTypeCodeField = new GuaranteeTypeCodeType();
     this.issueTimeField         = new IssueTimeType();
     this.issueDateField         = new IssueDateType();
     this.contractFolderIDField  = new ContractFolderIDType();
     this.uUIDField              = new UUIDType();
     this.copyIndicatorField     = new CopyIndicatorType();
     this.idField = new IDType();
     this.profileExecutionIDField = new ProfileExecutionIDType();
     this.profileIDField          = new ProfileIDType();
     this.customizationIDField    = new CustomizationIDType();
     this.uBLVersionIDField       = new UBLVersionIDType();
     this.uBLExtensionsField      = new ObservableCollection <UBLExtensionType>();
 }
Exemple #24
0
        private void DrawPeriodEditor()
        {
            var pulse = (Pulse)target;

            _periodType = (PeriodType)EditorGUILayout.EnumPopup(_periodType);

            switch (_periodType)
            {
            case PeriodType.Seconds:
                pulse.Period = EditorGUILayout.DoubleField(PeriodLabel, pulse.Period);
                break;

            case PeriodType.Bpm:
                var bpm = 60.0 / (pulse.Period * pulse.PulsesPerBeat);

                EditorGUI.BeginChangeCheck();

                bpm = EditorGUILayout.DoubleField(BpmLabel, bpm);

                var pulsesPerBeat = (uint)EditorGUILayout.IntSlider(PpbLabel, (int)pulse.PulsesPerBeat, 1, 16);

                if (EditorGUI.EndChangeCheck())
                {
                    pulse.SetBpm(bpm, pulsesPerBeat);
                }

                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemple #25
0
    private void RefreshGrid()
    {
        PeriodType period = ReportFilterUtilities.ConvertToPeriodType(uxPeriodGraphicDrop.SelectedValue);

        ReportFilterUtilities.GetOrderDateRange(period, out _startOrderDate, out _endOrderDate);

        decimal           revenue       = 0;
        int               sumQuantity   = 0;
        decimal           sumTax        = 0;
        decimal           sumShipping   = 0;
        SaleReportBuilder reportBuilder = new SaleReportBuilder();
        DataTable         table         = reportBuilder.GetReportData(
            period,
            _startOrderDate,
            _endOrderDate,
            StoreID
            );

        foreach (DataRow row in table.Rows)
        {
            revenue     += Convert.ToDecimal(row["Total"]);
            sumQuantity += Convert.ToInt32(row["Quantity"]);
            sumTax      += Convert.ToDecimal(row["TotalTax"]);
            sumShipping += Convert.ToDecimal(row["TotalShippingCost"]);
        }

        uxRevenueValueLabel.Text  = revenue.ToString("F", CultureInfo.InvariantCulture);
        uxQuantityValueLabel.Text = sumQuantity.ToString("F", CultureInfo.InvariantCulture);
        uxTaxValueLabel.Text      = sumTax.ToString("F", CultureInfo.InvariantCulture);
        uxShippingValueLabel.Text = sumShipping.ToString("F", CultureInfo.InvariantCulture);
    }
Exemple #26
0
 public PingInfo(string symbol, PeriodType period, DateTime bartime, DateTime time, double bid, double ask, int spread, double tickvalue,
                 double accountBalance, double accountEquity, double accountProfit, double accountFreeMargin,
                 int positionTicket, int positionType, double positionLots, double positionOpenPrice, DateTime positionOpenTime,
                 double positionStopLoss, double positionTakeProfit, double positionProfit, string positionComment)
 {
     this.symbol             = symbol;
     this.period             = period;
     this.bartime            = bartime;
     this.time               = time;
     this.bid                = bid;
     this.ask                = ask;
     this.spread             = spread;
     this.tickValue          = tickvalue;
     this.accountBalance     = accountBalance;
     this.accountEquity      = accountEquity;
     this.accountProfit      = accountProfit;
     this.accountFreeMargin  = accountFreeMargin;
     this.positionTicket     = positionTicket;
     this.positionType       = positionType;
     this.positionLots       = positionLots;
     this.positionOpenPrice  = positionOpenPrice;
     this.positionOpenTime   = positionOpenTime;
     this.positionStopLoss   = positionStopLoss;
     this.positionTakeProfit = positionTakeProfit;
     this.positionProfit     = positionProfit;
     this.positionComment    = positionComment;
 }
 public RequestForQuotationType()
 {
     this.requestForQuotationLineField = new ObservableCollection <RequestForQuotationLineType>();
     this.contractField                    = new ObservableCollection <ContractType>();
     this.destinationCountryField          = new CountryType();
     this.deliveryTermsField               = new ObservableCollection <DeliveryTermsType>();
     this.deliveryField                    = new ObservableCollection <DeliveryType>();
     this.buyerCustomerPartyField          = new CustomerPartyType();
     this.sellerSupplierPartyField         = new SupplierPartyType();
     this.originatorCustomerPartyField     = new CustomerPartyType();
     this.signatureField                   = new ObservableCollection <SignatureType>();
     this.additionalDocumentReferenceField = new ObservableCollection <DocumentReferenceType>();
     this.catalogueDocumentReferenceField  = new DocumentReferenceType();
     this.requestedValidityPeriodField     = new PeriodType();
     this.lineCountNumericField            = new LineCountNumericType();
     this.pricingCurrencyCodeField         = new PricingCurrencyCodeType();
     this.noteField = new ObservableCollection <NoteType>();
     this.submissionDueDateField = new SubmissionDueDateType();
     this.issueTimeField         = new IssueTimeType();
     this.issueDateField         = new IssueDateType();
     this.uUIDField               = new UUIDType();
     this.copyIndicatorField      = new CopyIndicatorType();
     this.idField                 = new IDType();
     this.profileExecutionIDField = new ProfileExecutionIDType();
     this.profileIDField          = new ProfileIDType();
     this.customizationIDField    = new CustomizationIDType();
     this.uBLVersionIDField       = new UBLVersionIDType();
     this.uBLExtensionsField      = new ObservableCollection <UBLExtensionType>();
 }
 public RetailEventType()
 {
     this.miscellaneousEventField        = new MiscellaneousEventType();
     this.promotionalEventField          = new PromotionalEventType();
     this.eventCommentField              = new ObservableCollection <EventCommentType>();
     this.sellerSupplierPartyField       = new SupplierPartyType();
     this.buyerCustomerPartyField        = new CustomerPartyType();
     this.receiverPartyField             = new PartyType();
     this.senderPartyField               = new PartyType();
     this.signatureField                 = new ObservableCollection <SignatureType>();
     this.originalDocumentReferenceField = new ObservableCollection <DocumentReferenceType>();
     this.periodField                = new PeriodType();
     this.descriptionField           = new ObservableCollection <DescriptionType>();
     this.buyerEventIDField          = new BuyerEventIDType();
     this.sellerEventIDField         = new SellerEventIDType();
     this.retailEventStatusCodeField = new RetailEventStatusCodeType();
     this.retailEventNameField       = new RetailEventNameType();
     this.noteField               = new ObservableCollection <NoteType>();
     this.issueTimeField          = new IssueTimeType();
     this.issueDateField          = new IssueDateType();
     this.uUIDField               = new UUIDType();
     this.copyIndicatorField      = new CopyIndicatorType();
     this.idField                 = new IDType();
     this.profileExecutionIDField = new ProfileExecutionIDType();
     this.profileIDField          = new ProfileIDType();
     this.customizationIDField    = new CustomizationIDType();
     this.uBLVersionIDField       = new UBLVersionIDType();
     this.uBLExtensionsField      = new ObservableCollection <UBLExtensionType>();
 }
Exemple #29
0
        public List <Agregation> GetAgregations(PeriodType periodType, DateTime from, AgregationBy agregationBy)
        {
            var data = _db.SimpleGet("Agregations", _reflectionHelper.GetPropNames(typeof(Agregation)), new Dictionary <string, object>
            {
                { nameof(Agregation.PeriodType), periodType },
                { nameof(Agregation.AgregationBy), agregationBy },
                { nameof(Agregation.PeriodStart), from }
            }, new Filter {
                Comparison = Comparison.Equal, Name = nameof(Agregation.PeriodType)
            },
                                     new Filter {
                Comparison = Comparison.Equal, Name = nameof(Agregation.AgregationBy)
            },
                                     new Filter {
                Comparison = Comparison.GreaterThan, Name = nameof(Agregation.PeriodStart)
            });

            var agregations = new List <Agregation>();

            foreach (var item in data.Rows.OfType <DataRow>())
            {
                var agrr = this.getFromDbRow(item);

                agrr.PeriodStart  = item.Field <DateTime>("PeriodStart");
                agrr.PeriodType   = item.Field <PeriodType>("PeriodType");
                agrr.Tag          = item.Field <string>("Tag");
                agrr.AgregationBy = item.Field <AgregationBy>("AgregationBy");
                agrr.Id           = item.Field <int>("Id");

                agregations.Add(agrr);
            }

            return(agregations);
        }
Exemple #30
0
        public List <DailyFXEvent> Process(DateTime dateTimeFirstDay, PeriodType periodType)
        {
            var dateTimeLastDay = dateTimeFirstDay.AddXDays(periodType);

            if (Locale == Locale.EnUS)
            {
                var list        = new List <DailyFXEvent>();
                var dateTimeTmp = DateTime.Parse(dateTimeFirstDay.ToString());

                while (dateTimeTmp.CompareTo(dateTimeLastDay) < 0)
                {
                    var dateTimeMonday = dateTimeTmp.StartOfWeek(DayOfWeek.Sunday);
                    var url            = string.Format(_APIUrlFTLocaleMap[Locale],
                                                       dateTimeMonday.Year,
                                                       dateTimeMonday.Month.PaddingZero(),
                                                       dateTimeMonday.Day.PaddingZero());

                    list.AddRange(ProcessFromEnUS(url));
                    dateTimeTmp = dateTimeTmp.AddXDays(PeriodType.Week);
                }

                return(list.Where(x => DateTime.Parse(x.Date.ToString("yyyy-MM-dd")).CompareTo(dateTimeFirstDay) >= 0 && DateTime.Parse(x.Date.ToString("yyyy-MM-dd")).CompareTo(dateTimeLastDay) < 0).ToList());
            }
            else
            {
                var url = string.Format(_APIUrlFTLocaleMap[Locale],
                                        dateTimeFirstDay.Year,
                                        dateTimeFirstDay.Month.PaddingZero(),
                                        dateTimeFirstDay.Day.PaddingZero(),
                                        dateTimeLastDay.Year,
                                        dateTimeLastDay.Month.PaddingZero(),
                                        dateTimeLastDay.Day.PaddingZero());
                return(ProcessInZhCNnZhTW(url));
            }
        }
Exemple #31
0
        public void AgregateCustomers(PeriodType periodType, DateTime from)
        {
            using var tx = _db.CreateTransaction();

            string query = this.createCustomerAgregationQuery(periodType, from);

            var data = _db.Query(query, tx, new Dictionary <string, object> {
                { "from", from }
            });

            foreach (var item in data.Rows.OfType <DataRow>())
            {
                var aggrr = this.getFromDbRow(item);

                int customerId = item.Field <int>(AgregationConstants.CustomerId);

                aggrr.PeriodStart  = _timeManager.FromUnixTime(item.Field <int>("periodtsart"));
                aggrr.PeriodStart  = _timeManager.FromUnixTime(item.Field <int>("periodtsart"));
                aggrr.AgregationBy = AgregationBy.Customer;
                aggrr.Tag          = _tagManager.Tag(new Dictionary <string, string> {
                    { AgregationConstants.CustomerId, customerId.ToString() }
                });
                aggrr.Name       = $"Aggr_{_customerManager.Get(customerId).IdentityTag}_{periodType}";
                aggrr.PeriodType = periodType;

                this.insertAggr(aggrr, tx);
            }

            tx.Commit();
        }
        public List <Jin10Event> Process(DateTime dateTime, PeriodType periodType)
        {
            var dateTimesInRange = new List <DateTime>();

            switch (periodType)
            {
            case PeriodType.Week:
                var dateTimeStartOfWeek = dateTime.StartOfWeek(DayOfWeek.Monday);
                Enumerable.Range(0, 7).ToList().ForEach(index =>
                {
                    dateTimesInRange.Add(dateTimeStartOfWeek.AddDays(index));
                });
                break;

            case PeriodType.Month:
                var daysInMonth          = DateTime.DaysInMonth(dateTime.Year, dateTime.Month);
                var dateTimeStartOfMonth = new DateTime(dateTime.Year, dateTime.Month, 1);
                Enumerable.Range(0, daysInMonth).ToList().ForEach(index =>
                {
                    dateTimesInRange.Add(dateTimeStartOfMonth.AddDays(index));
                });
                break;

            default:
                break;
            }
            return(Process(dateTimesInRange).Select(re => new Jin10Event(re)).ToList());
        }
 public ForecastRevisionType()
 {
     this.forecastRevisionLineField      = new ObservableCollection <ForecastRevisionLineType>();
     this.sellerSupplierPartyField       = new SupplierPartyType();
     this.buyerCustomerPartyField        = new CustomerPartyType();
     this.receiverPartyField             = new PartyType();
     this.senderPartyField               = new PartyType();
     this.signatureField                 = new ObservableCollection <SignatureType>();
     this.originalDocumentReferenceField = new ObservableCollection <DocumentReferenceType>();
     this.forecastPeriodField            = new PeriodType();
     this.purposeCodeField               = new PurposeCodeType();
     this.revisionStatusCodeField        = new RevisionStatusCodeType();
     this.sequenceNumberIDField          = new SequenceNumberIDType();
     this.noteField               = new ObservableCollection <NoteType>();
     this.issueTimeField          = new IssueTimeType();
     this.issueDateField          = new IssueDateType();
     this.uUIDField               = new UUIDType();
     this.copyIndicatorField      = new CopyIndicatorType();
     this.idField                 = new IDType();
     this.profileExecutionIDField = new ProfileExecutionIDType();
     this.profileIDField          = new ProfileIDType();
     this.customizationIDField    = new CustomizationIDType();
     this.uBLVersionIDField       = new UBLVersionIDType();
     this.uBLExtensionsField      = new ObservableCollection <UBLExtensionType>();
 }
Exemple #34
0
        private void btnEmbedPersistedObject_Click(object sender, EventArgs e)
        {
            PeriodType      type     = PeriodType.DAYS;
            CWSteganography cwStegan = new CWSteganography();


            switch (cbPeriodType.SelectedItem.ToString())
            {
            case "HOURS":
                type = PeriodType.HOURS;
                break;

            case "DAYS":
                type = PeriodType.DAYS;
                break;

            case "MONTHS":
                type = PeriodType.MONTHS;
                break;

            case "ACTIVATIONS":
                type = PeriodType.ACTIVATIONS;
                break;

            default:
                type = PeriodType.DAYS;
                break;
            }
            //Initilize The Object With Basic Information.
            CWProductProtection.Initilize(@".\Temp.po", 0, txtPackageName.Text, DateTime.Now, Convert.ToInt32(txtTrialPeriod.Text), type);
            cwStegan.AppendBinaryFileToBinaryFile(@".\Temp.po", findLogoFileDialog.FileName);
            File.Delete(@".\Temp.po");
        }
 public ConsolidationDevice(DeviceControl.DeviceManagerBase deviceManager, DeviceManagerDeviceSettings settings, PeriodType periodType = PeriodType.Day)
     : base(deviceManager, settings)
 {
     Manufacturer = settings.Manufacturer;
     Model = settings.Model;
     //DeviceIdentifier = settings.SerialNo;
     SourceDevices = new List<DeviceLink>();
     PeriodType = periodType;
 }
        public Bars GetBars(string symbol, PeriodType period, ref int count, int offset)
        {
            string rc = Command(string.Format("BR {0} {1} {2} {3}", symbol, (int) period, offset, count));
            if (!ResponseOK(rc) || rc.Length < 3)
                return null;

            string[] reply = rc.Substring(3).Split(new[] {' '});
            if (reply.Length < 5 || reply[0] != symbol)
                return null;

            int rperiod, rbars, roffset, rcount;
            try
            {
                rperiod = int.Parse(reply[1]);
                rbars = int.Parse(reply[2]);
                roffset = int.Parse(reply[3]);
                rcount = int.Parse(reply[4]);
            }
            catch (FormatException)
            {
                return null;
            }
            if (rperiod != (int) period || roffset != offset || rcount*6 != reply.Length - 5)
                return null;

            count = rbars;
            var bars = new Bars(symbol, period);
            for (int i = 5; i < reply.Length; i += 6)
            {
                try
                {
                    DateTime time = FromTimestamp(int.Parse(reply[i]));
                    double open = StringToDouble(reply[i + 1]);
                    double high = StringToDouble(reply[i + 2]);
                    double low = StringToDouble(reply[i + 3]);
                    double close = StringToDouble(reply[i + 4]);
                    int volume = int.Parse(reply[i + 5]);

                    bars.Insert(time, open, high, low, close, volume);
                }
                catch (FormatException)
                {
                    return null;
                }
            }
            return bars;
        }
        /// <summary>
        /// Returns a list of your usages.
        /// </summary>
        /// <param name="page">Allows to use pagination. Sets the number of servers that will be shown in each page.</param>
        /// <param name="perPage">Current page to show.</param>
        /// <param name="sort">Allows to sort the result by priority:sort=name retrieves a list of elements ordered by their names.sort=-creation_date retrieves a list of elements ordered according to their creation date in descending order of priority.</param>
        /// <param name="query">Allows to search one string in the response and return the elements that contain it. In order to specify the string use parameter q:    q=My server</param>
        /// <param name="fields">Returns only the parameters requested: fields=id,name,description,hardware.ram</param>
        /// <param name="period">required (one of LAST_HOUR,LAST_24H,LAST_7D,LAST_30D,LAST_365D,CUSTOM ),Time range whose logs will be shown.</param>
        /// <param name="start_date">(date) The first date in a custom range. Required only if selected period is "CUSTOM".</param>
        /// <param name="end_date">(date) The second date in a custom range. Required only if selected period is "CUSTOM".</param>
        public UsageResponse Get(PeriodType period, int? page = null, int? perPage = null, string sort = null, string query = null, string fields = null, DateTime? start_date = null, DateTime? end_date = null)
        {
            try
            {
                string requestUrl = "/usages?";
                if (page != null)
                {
                    requestUrl += string.Format("&page={0}", page);
                }
                if (perPage != null)
                {
                    requestUrl += string.Format("&per_page={0}", perPage);
                }
                if (!string.IsNullOrEmpty(sort))
                {
                    requestUrl += string.Format("&sort={0}", sort);
                }
                if (!string.IsNullOrEmpty(query))
                {
                    requestUrl += string.Format("&q={0}", query);
                }
                if (!string.IsNullOrEmpty(fields))
                {
                    requestUrl += string.Format("&fields={0}", fields);
                }
                requestUrl += string.Format("&period={0}", period);
                if (period == PeriodType.CUSTOM)
                {
                    requestUrl += string.Format("&start_date={0}", start_date.Value.ToString("s") + "Z");
                    requestUrl += string.Format("&end_date={0}", end_date.Value.ToString("s") + "Z");
                }
                var request = new RestRequest(requestUrl, Method.GET);

                var result = restclient.Execute(request);

                if (result.StatusCode != HttpStatusCode.OK)
                {
                    throw new Exception(result.Content);
                }
                return JsonConvert.DeserializeObject<UsageResponse>(result.Content);
            }
            catch
            {
                throw;
            }
        }
Exemple #38
0
        internal BudgetManager(PeriodType periodType)
        {
            if (periodType == PeriodType.Custom)
                throw new ArgumentException("Cannot initialize with period types custom");

            switch (periodType)
            {
                case PeriodType.Weekly:
                    getPeriod = DateFunctions.GetWeek;
                    break;
                case PeriodType.Monthly:
                    getPeriod = DateFunctions.GetMonth;
                    break;
                case PeriodType.Quarterly:
                    getPeriod = DateFunctions.GetQuarter;
                    break;
                case PeriodType.Yearly:
                    getPeriod = DateFunctions.GetYear;
                    break;
            }
            this.periodType = periodType;
            budgets = new List<Budget>();
        }
Exemple #39
0
 private PeriodDates CalculateDates(DateTime date, PeriodType periodType)
 {
     switch (periodType)
     {
         case PeriodType.Day:
             return new PeriodDates
             {
                 DateFrom = date.Date,
                 DateTo = date.Date
             };
         case PeriodType.WorkingWeek:
             var dayOfWeek = date.DayOfWeek == 0 ? 7 : (int)date.DayOfWeek;
             var daysToMonday = (int)DayOfWeek.Monday - dayOfWeek;
             var daysToFriday = (int)DayOfWeek.Friday - dayOfWeek;
             return new PeriodDates
             {
                 DateFrom = date.AddDays(daysToMonday).Date,
                 DateTo = date.AddDays(daysToFriday).Date
             };
         case PeriodType.Month:
             return new PeriodDates
             {
                 DateFrom = new DateTime(date.Year, date.Month, 1).Date,
                 DateTo = new DateTime(date.Year, date.Month, DateTime.DaysInMonth(date.Year, date.Month)).Date
             };
         default:
             throw new ArgumentOutOfRangeException(nameof(periodType), periodType, null);
     }
 }
 public TwitchList<Video> GetTopVideos(string game = null, PeriodType period = PeriodType.week, PagingInfo pagingInfo = null)
 {
     var request = GetRequest("videos/top", Method.GET);
     request.AddSafeParameter("game", game);
     request.AddParameter("period", period);
     TwitchHelper.AddPaging(request, pagingInfo);
     var response = restClient.Execute<TwitchList<Video>>(request);
     return response.Data;
 }
Exemple #41
0
 public IEnumerable<Event> Get(DateTime date, PeriodType periodType)
 {
     throw new NotImplementedException();
 }
 private void ResetTimer()
 {
     _timer.Stop();
     ActualTime = _workDuration;
     _periodType = PeriodType.Work;
 }
        private void _timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            if (ActualTime.TotalSeconds > 0)
            {
                ActualTime = ActualTime.Subtract(TimeSpan.FromSeconds(1));
            }
            else
            {
                _timer.Stop();

                PlaySound();

                if (_periodType == PeriodType.Work)
                {
                    _periodType = PeriodType.Break;
                    ActualTime = _breakDuration;

                    _timer.Start();
                }
                else
                {
                    _periodType = PeriodType.Work;
                    ActualTime = _workDuration;
                }
            }
        }
 /// <summary>
 /// Creates a new time period with the given duration.
 /// </summary>
 /// <param name="type">Period type.</param>
 /// <param name="duration">Period duration.</param>
 public TimePeriod(PeriodType type, TimeSpan duration)
     : this(type)
 {
     _duration = duration;
 }
 public void AddToPeriodTypes(PeriodType periodType)
 {
     base.AddObject("PeriodTypes", periodType);
 }
        public EnergyConsolidationDevice(DeviceControl.DeviceManagerBase deviceManager, DeviceManagerDeviceSettings settings, PeriodType periodType = PeriodType.Day)
            : base(deviceManager, settings, periodType)
        {
            int interval;
            if (settings.ConsolidationType == ConsolidationType.PVOutput)
            {
                PvOutputSiteSettings pvo = GlobalSettings.ApplicationSettings.FindPVOutputBySystemId(settings.PVOutputSystem);
                if (pvo == null)
                    throw new Exception("EnergyConsolidationDevice - Cannot find PVOutput system - " + settings.PVOutputSystem);
                interval = pvo.DataIntervalSeconds;
            }
            else
                interval = settings.DBIntervalInt;

            DeviceParams = new EnergyConsolidationParams(interval);
        }
 public TickEventArgs(string symbol, PeriodType period, DateTime bartime, DateTime time, double bid, double ask, int spread, double tickvalue,
             double accountBalance, double accountEquity, double accountProfit, double accountFreeMargin,
             int positionTicket, int positionType, double positionLots, double positionOpenPrice, DateTime positionOpenTime,
             double positionStopLoss, double positionTakeProfit, double positionProfit, string positionComment)
 {
     this.symbol             = symbol;
     this.period             = period;
     this.bartime            = bartime;
     this.time               = time;
     this.bid                = bid;
     this.ask                = ask;
     this.spread             = spread;
     this.tickValue          = tickvalue;
     this.accountBalance     = accountBalance;
     this.accountEquity      = accountEquity;
     this.accountProfit      = accountProfit;
     this.accountFreeMargin  = accountFreeMargin;
     this.positionTicket     = positionTicket;
     this.positionType       = positionType;
     this.positionLots       = positionLots;
     this.positionOpenPrice  = positionOpenPrice;
     this.positionOpenTime   = positionOpenTime;
     this.positionStopLoss   = positionStopLoss;
     this.positionTakeProfit = positionTakeProfit;
     this.positionProfit     = positionProfit;
     this.positionComment    = positionComment;
 }
 string GetKeyFromSTKHISDATA(string market, string altSymbol, PeriodType pt)
 {
     return string.Format("{0}:{1}:{2}", market, altSymbol, (int)pt);
 }
 public TwitchList<Video> GetTopVideos(string game = null, PagingInfo pagingInfo = null, PeriodType periodType = PeriodType.week)
 {
     return _client.GetTopVideos<TwitchList<Video>>(game, pagingInfo, periodType);
 }
        /// <summary>
        /// Copies data to Data and calculates.
        /// </summary>
        private void SetDataAndCalculate(string symbol, PeriodType period, DateTime time, bool isPriceChange, bool isUpdateData)
        {
            lock (_lockerDataFeed)
            {
                bool isUpdateChart = isUpdateData;

                Bars bars = _bridge.GetBars(symbol, period);

                if (bars == null && JournalShowSystemMessages)
                {
                    _isSetRootDataError = true;
                    Data.SoundError.Play();
                    var jmsgsys = new JournalMessage(JournalIcons.Error, DateTime.Now,
                                                  symbol + " " + period + " " +
                                                  Language.T("Cannot receive bars!"));
                    AppendJournalMessage(jmsgsys);
                    Log(jmsgsys.Message);
                    return;
                }
                if (bars != null && (bars.Count < MaxBarsCount((int) period) && JournalShowSystemMessages))
                {
                    _isSetRootDataError = true;
                    Data.SoundError.Play();
                    var jmsgsys = new JournalMessage(JournalIcons.Error, DateTime.Now,
                                                  symbol + " " + period + " " +
                                                  Language.T("Cannot receive enough bars!"));
                    AppendJournalMessage(jmsgsys);
                    Log(jmsgsys.Message);
                    return;
                }
                if (_isSetRootDataError && JournalShowSystemMessages)
                {
                    _isSetRootDataError = false;
                    var jmsgsys = new JournalMessage(JournalIcons.Information, DateTime.Now,
                                                  symbol + " " + period + " " +
                                                  Language.T("Enough bars received!"));
                    AppendJournalMessage(jmsgsys);
                    Log(jmsgsys.Message);
                }

                if (bars != null)
                {
                    int countBars = bars.Count;

                    if (countBars < 400)
                        return;

                    if (Data.Bars != countBars ||
                        Data.Time[countBars - 1] != bars.Time[countBars - 1] ||
                        Data.Volume[countBars - 1] != bars.Volume[countBars - 1] ||
                        Math.Abs(Data.Close[countBars - 1] - bars.Close[countBars - 1]) > Data.InstrProperties.Point/2d)
                    {
                        if (Data.Bars == countBars && Data.Time[countBars - 1] == bars.Time[countBars - 1] &&
                            Data.Time[countBars - 10] == bars.Time[countBars - 10])
                        {
                            // Update the last bar only.
                            Data.Open[countBars - 1] = bars.Open[countBars - 1];
                            Data.High[countBars - 1] = bars.High[countBars - 1];
                            Data.Low[countBars - 1] = bars.Low[countBars - 1];
                            Data.Close[countBars - 1] = bars.Close[countBars - 1];
                            Data.Volume[countBars - 1] = bars.Volume[countBars - 1];
                        }
                        else
                        {
                            // Update all the bars.
                            Data.Bars = countBars;
                            Data.Time = new DateTime[countBars];
                            Data.Open = new double[countBars];
                            Data.High = new double[countBars];
                            Data.Low = new double[countBars];
                            Data.Close = new double[countBars];
                            Data.Volume = new int[countBars];
                            bars.Time.CopyTo(Data.Time, 0);
                            bars.Open.CopyTo(Data.Open, 0);
                            bars.High.CopyTo(Data.High, 0);
                            bars.Low.CopyTo(Data.Low, 0);
                            bars.Close.CopyTo(Data.Close, 0);
                            bars.Volume.CopyTo(Data.Volume, 0);
                        }

                        Data.LastClose = Data.Close[countBars - 1];
                        CalculateStrategy(true);
                        isUpdateChart = true;
                    }
                }

                bool isBarChanged = IsBarChanged(Data.Time[Data.Bars - 1]);

                if (_isTrading)
                {
                    TickType tickType = GetTickType((DataPeriods) (int) period, Data.Time[Data.Bars - 1], time,
                                                    Data.Volume[Data.Bars - 1]);

                    if (tickType == TickType.Close || isPriceChange || isBarChanged)
                    {
                        if (JournalShowSystemMessages && tickType != TickType.Regular)
                        {
                            JournalIcons icon = JournalIcons.Warning;
                            string text = string.Empty;
                            if (tickType == TickType.Open)
                            {
                                icon = JournalIcons.BarOpen;
                                text = Language.T("A Bar Open event!");
                            }
                            else if (tickType == TickType.Close)
                            {
                                icon = JournalIcons.BarClose;
                                text = Language.T("A Bar Close event!");
                            }
                            else if (tickType == TickType.AfterClose)
                            {
                                icon = JournalIcons.Warning;
                                text = Language.T("A new tick arrived after a Bar Close event!");
                            }
                            var jmsgsys = new JournalMessage(icon, DateTime.Now,
                                                          symbol + " " + Data.PeriodMTStr + " " +
                                                          time.ToString("HH:mm:ss") + " " + text);
                            AppendJournalMessage(jmsgsys);
                            Log(jmsgsys.Message);
                        }

                        if (isBarChanged && tickType == TickType.Regular)
                        {
                            if (JournalShowSystemMessages)
                            {
                                var jmsgsys = new JournalMessage(JournalIcons.Warning, DateTime.Now,
                                    symbol + " " + Data.PeriodMTStr + " " + time.ToString("HH:mm:ss") + " A Bar Changed event!");
                                AppendJournalMessage(jmsgsys);
                                Log(jmsgsys.Message);
                            }

                            tickType = TickType.Open;
                        }

                        if (tickType == TickType.Open && _barOpenTimeForLastCloseEvent == Data.Time[Data.Bars - 3])
                        {
                            if (JournalShowSystemMessages)
                            {
                                var jmsgsys = new JournalMessage(JournalIcons.Warning, DateTime.Now,
                                    symbol + " " + Data.PeriodMTStr + " " + time.ToString("HH:mm:ss") + " A secondary Bar Close event!");
                                AppendJournalMessage(jmsgsys);
                                Log(jmsgsys.Message);
                            }
                            tickType = TickType.OpenClose;
                        }

                        CalculateTrade(tickType);
                        isUpdateChart = true;

                        if (tickType == TickType.Close || tickType == TickType.OpenClose)
                            _barOpenTimeForLastCloseEvent = Data.Time[Data.Bars - 1];
                    }
                }

                if (isUpdateChart)
                    UpdateChart();
            }
        }
Exemple #51
0
 public static extern int QT_RequestHistory(IntPtr pQuotApi, string market, string stk, PeriodType period);
 /// <summary>
 /// Creates a new time period with no duration.
 /// </summary>
 public TimePeriod(PeriodType type)
 {
     _type = type;
 }
Exemple #53
0
        public IEnumerable<Event> Get(DateTime date, PeriodType periodType)
        {
            var periodDates = CalculateDates(date, periodType);

            using (var connection = new SqlConnection(connectionString))
            {
                return connection.Query(selectByDatesStatement, new {periodDates.DateFrom, periodDates.DateTo})
                    .Select(ResultToEvent);
            }
        }
 public static PeriodType CreatePeriodType(int periodTypeID)
 {
     PeriodType periodType = new PeriodType();
     periodType.PeriodTypeID = periodTypeID;
     return periodType;
 }
Exemple #55
0
 public Interval(PeriodType periodType, int periods)
 {
     _periodType = periodType;
     _periods = periods;
 }
        public Task<List<Ticket>> GetPrice(string token, string origin, string destination, DateTime departDate, DateTime returnDate, PeriodType period = PeriodType.Year, bool isOneWay = false, int page = 1, int limit = 30, bool isShowToAffiliates = true, SortingMode sorting = SortingMode.Price, TripClassMode tripClass = TripClassMode.Econom)
        {
            Contract.Requires<ArgumentNullException>(!String.IsNullOrEmpty(token), "Token can not be null or empty.");

            return Task.FromResult(default(List<Ticket>));
        }
Exemple #57
0
 public SpecialEvent(PeriodType period, ReadOnlyArray<TimeValue> listOfTimeValues, uint eventPriority)
 {
     this.Period = period;
     this.ListOfTimeValues = listOfTimeValues;
     this.EventPriority = eventPriority;
 }
Exemple #58
0
 public static void Save(IValueSink sink, PeriodType value)
 {
     sink.EnterChoice((byte)value.Tag);
     switch(value.Tag)
     {
         case Tags.CalendarEntry:
             Value<CalendarEntryWrapper>.Save(sink, (CalendarEntryWrapper)value);
             break;
         case Tags.CalendarReference:
             Value<CalendarReferenceWrapper>.Save(sink, (CalendarReferenceWrapper)value);
             break;
         default:
             throw new Exception();
     }
     sink.LeaveChoice();
 }
 public Bars GetBars(string symbol, PeriodType period, ref int count)
 {
     return GetBars(symbol, period, ref count, 0);
 }
Exemple #60
0
        public Task<GetStatsForCharacter> GetStatsForCharacter(MembershipType membershipType, long membershipId, long characterId, PeriodType? periodType = null, IEnumerable<ActivityMode> modes = null, IEnumerable<StatsGroup> groups = null, DateTime? monthStart = null, DateTime? monthEnd = null, DateTime? dayStart = null, DateTime? dayEnd = null)
        {
            var model = new
            {
                membershipType,
                membershipId,
                characterId,
                periodType,
                modes,
                groups,
                monthStart = monthStart.HasValue ? String.Format("{0:yyyy-MM}", monthStart) : null,
                monthEnd = monthEnd.HasValue ? String.Format("{0:yyyy-MM}", monthEnd) : null,
                dayStart = dayStart.HasValue ? String.Format("{0:yyyy-MM-dd}", dayStart) : null,
                dayEnd = dayEnd.HasValue ? String.Format("{0:yyyy-MM-dd}", dayEnd) : null
            };

            return Request<GetStatsForCharacter>(model);
        }