public FillParameterBuilder(DateTime targetReportDate, string key)
 {
     reportDate = targetReportDate;
     dateType = DateType.Fixed;
     ParamList = XmlHelper.GetFillParams("RequestReport", key);
     SheetDataAdapter.BuildFillParameterFromConfig(fillParameter, ParamList);
 }
Пример #2
0
        public DateRange(DateTime date, Interval interval, DateType type)
        {
            switch (interval)
            {
                case Interval.None:
                    _from = date;
                    _to = date;
                    break;

                case Interval.Day:
                    _from = date;
                    _to = date;
                    break;

                case Interval.Week:
                    _from = DateTime.Now.Subtract(TimeSpan.FromDays((int)date.DayOfWeek));
                    _to = _from.Value.AddDays(6);
                    break;

                case Interval.Month:
                    _from = new DateTime(date.Year, date.Month, 1);
                    _to = new DateTime(date.Year, date.Month, DateTime.DaysInMonth(date.Year, date.Month));
                    break;

                case Interval.Quarter:
                    if ((date.Month >= 1) && (date.Month <= 3))
                    {
                        _from = new DateTime(date.Year, 1, 1);
                        _to = new DateTime(date.Year, 3, DateTime.DaysInMonth(date.Year, 3));
                    }
                    else if ((date.Month >= 4) && (date.Month <= 6))
                    {
                        _from = new DateTime(date.Year, 4, 1);
                        _to = new DateTime(date.Year, 6, DateTime.DaysInMonth(date.Year, 3));
                    }
                    else if ((date.Month >= 7) && (date.Month <= 9))
                    {
                        _from = new DateTime(date.Year, 7, 1);
                        _to = new DateTime(date.Year, 9, DateTime.DaysInMonth(date.Year, 3));
                    }
                    else
                    {
                        _from = new DateTime(date.Year, 10, 1);
                        _to = new DateTime(date.Year, 12, DateTime.DaysInMonth(date.Year, 12));
                    }
                    break;

                case Interval.Year:
                    _from = new DateTime(date.Year, 1, 1);
                    _to = new DateTime(date.Year, 12, DateTime.DaysInMonth(date.Year, 12));
                    break;

                default:
                    _from = DateTime.MinValue;
                    _to = DateTime.MaxValue;
                    break;
            }

            _type = type;
        }
Пример #3
0
 public RequestReport(DateTime startDate, DateTime endDate)
     : base("RequestReport", startDate, ReportType.Weekly)
 {
     StartDate = startDate;
     EndDate = endDate;
     dateType = DateType.Custom;
 }
Пример #4
0
        private static string DateTypeAndDateToString(DateType dateType, DateTime? date)
        {
            string date_string = "";

            if (date != null )
            {

                date_string = date.Value.ToShortDateString ();

                if (dateType != null)
                {

                    if (dateType.Id == 3)
                    {
                        // YearMonth
                        date_string = String.Format("{0:y}", date);
                    }
                    else if (dateType.Id == 4)
                    {
                        date_string = date.Value.Year.ToString ();
                    }
                }
            }

            return date_string;
        }
Пример #5
0
 public DateOptions()
 {
   eX4XcIhHpDXt70u2x3N.k8isAcYzkUOGF();
   // ISSUE: explicit constructor call
   base.\u002Ector();
   this.AoQY1dhn6w = DateType.Column;
   this.x7jYd3p5R9 = DateTime.Today;
 }
 public FillParameterBuilder(DateTime startDate, DateTime endDate, string key)
 {
     this.startDate = startDate;
     this.endDate = endDate;
     dateType = DateType.Custom;
     ParamList = XmlHelper.GetFillParams("RequestReport", key);
     SheetDataAdapter.BuildFillParameterFromConfig(fillParameter, ParamList);
 }
Пример #7
0
        public DateRange(DateTime from, DateTime to, DateType type)
        {
            if (from > to)
                throw new ArgumentException("Start date must be before end date");

            _from = from;
            _to = to;
            _type = type;
        }
Пример #8
0
 public static string encodeDate(DateTime date, string inputfield, DateType dateType)
 {
     if (inputfield.Length == 64)
     {
         int    index          = (int)dateType;
         string data           = date.ToString("yyyyMMdd");
         var    aStringBuilder = new StringBuilder(inputfield);
         aStringBuilder.Remove(index, data.Length);
         aStringBuilder.Insert(index, data);
         return(aStringBuilder.ToString());
     }
     return(inputfield);
 }
Пример #9
0
        public static DateTime decodeDate(string inputfield, DateType dateType)
        {
            DateTime outDate = DateTime.Now;

            if (inputfield.Length == 64)
            {
                int    index = (int)dateType;
                string data  = inputfield.Substring(index, 8);
                DateTime.TryParseExact(data, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out outDate);
                return(outDate);
            }
            return(outDate);
        }
Пример #10
0
        private static DateTime AddDatetime(DateTime source, string value, DateType dtype)
        {
            value = value.ToUpper();
            char     key      = value.Last();
            int      dayvalue = Convert.ToInt32(value.Remove(value.Length - 1));
            DateTime result   = source;

            if (dtype == DateType.day)
            {
                switch (key)
                {
                case 'Y':
                    result = source.AddYears(dayvalue);
                    break;

                case 'M':
                    result = source.AddMonths(dayvalue);
                    break;

                case 'W':
                    result = source.AddDays(dayvalue * 7);
                    break;

                case 'D':
                    result = source.AddDays(dayvalue);
                    break;

                default: break;
                }
            }
            else
            {
                switch (key)
                {
                case 'H':
                    result = source.AddHours(dayvalue);
                    break;

                case 'M':
                    result = source.AddMinutes(dayvalue);
                    break;

                case 'S':
                    result = source.AddSeconds(dayvalue);
                    break;

                default: break;
                }
            }
            return(result);
        }
Пример #11
0
        public Enrollment EnrollStudent(EnrollStudentRequest request)
        {
            using (var db = new s18838Context()) {
                if (request.Studies == null ||
                    request.BirthDate == null ||
                    request.FirstName == null ||
                    request.IndexNumber == null ||
                    request.LastName == null)
                {
                    throw new Exception();
                }
                using (var transaction = db.Database.BeginTransaction())
                {
                    var study = GetStudies(request.Studies);
                    if (study == null)
                    {
                        transaction.Rollback();
                        throw new Exception();
                    }
                    Enrollment enrollment = GetLastEnrollmentForStudy(study.IdStudy);
                    if (enrollment == null)
                    {
                        enrollment = new Enrollment()
                        {
                            Semester  = 1,
                            IdStudy   = study.IdStudy,
                            StartDate = DateType.FromString(DateTime.Now.ToString("MM.dd.yyyy"))
                        };

                        SaveEnrollment(db, enrollment);
                    }
                    if (CheckIfStudentExists(request.IndexNumber))
                    {
                        transaction.Rollback();
                        throw new Exception();
                    }
                    var student = new Student()
                    {
                        IndexNumber  = request.IndexNumber,
                        FirstName    = request.FirstName,
                        LastName     = request.LastName,
                        BirthDate    = DateType.FromString(request.BirthDate),
                        IdEnrollment = IntegerType.FromObject(enrollment.IdEnrollment)
                    };
                    SaveStudent(db, student);
                    transaction.Commit();
                    return(enrollment);
                }
            }
        }
Пример #12
0
 public frmRepRegPedExp1()
 {
     base.Closed += new EventHandler(this.frmRepRegPedExp1_Closed);
     base.Load   += new EventHandler(this.frmRepRegPedExp1_Load);
     base.Click  += new EventHandler(this.frmRepRegPedExp1_Click);
     this.Informe = new ReportDocument();
     this.DS      = new DataSet();
     this.InitializeComponent();
     try
     {
         SqlConnection connection = new SqlConnection("data source=" + Variables.gServer + ";user id=teleprinter;password=tele;initial catalog=Colector;persist security info=False;packet size=4096");
         connection.Open();
         SqlCommand command = new SqlCommand("SELECT * from " + Variables.gTermi + "TmpRegPedExp as PC1TmpRegPedExp", connection);
         command.CommandTimeout      = 500;
         this.AdapOR01               = new SqlDataAdapter();
         this.AdapOR01.SelectCommand = command;
         this.DS.Clear();
         this.AdapOR01.Fill(this.DS, "PC1TmpRegPedExp");
         this.Informe.Load(Application.StartupPath + @"\repregpedexp.rpt");
         this.Informe.SetDataSource(this.DS);
         connection.Close();
         FormulaFieldDefinitions definitions = this.Informe.get_DataDefinition().get_FormulaFields();
         FormulaFieldDefinition  definition  = definitions.get_Item("desdefechaent");
         if (StringType.StrCmp(Variables.gDesdeFechaEnt, Strings.Space(0), false) != 0)
         {
             definition.set_Text("'" + Strings.Format(DateType.FromString(Variables.gDesdeFechaEnt), "dd/MM/yyyy") + "'");
         }
         else
         {
             definition.set_Text("''");
         }
         FormulaFieldDefinition definition2 = definitions.get_Item("hastafechaent");
         if (StringType.StrCmp(Variables.gHastaFechaEnt, Strings.Space(0), false) != 0)
         {
             definition2.set_Text("'" + Strings.Format(DateType.FromString(Variables.gHastaFechaEnt), "dd/MM/yyyy") + "'");
         }
         else
         {
             definition2.set_Text("''");
         }
         this.CrystalReportViewer1.set_ReportSource(this.Informe);
     }
     catch (Exception exception1)
     {
         ProjectData.SetProjectError(exception1);
         Exception exception = exception1;
         Interaction.MsgBox("Se ha producido el siguiente error:" + exception.Message, 0, null);
         ProjectData.ClearProjectError();
     }
 }
Пример #13
0
        public virtual bool BulkDeleteValue(CacheExpire cacheExpire, DateType dateType, DateTime startDate, DateTime endDate)
        {
            bool flag = true;
            List <CacheKeyMapDescriptor> lstMapList = CacheKeyMapManger.Instance.GetCacheKeyMapList(cacheExpire, dateType, startDate, endDate);

            lstMapList.ForEach(x =>
            {
                if (!DeleteValue(x.CacheKey, true))
                {
                    flag = false;
                }
            });
            return(flag);
        }
Пример #14
0
        public override List <string> GetAllKeys(CacheExpire cacheExpire, DateType dateType, DateTime startDate, DateTime endDate)
        {
            List <string> lstKeys = new List <string>();

            foreach (var item in ChangeServerList())
            {
                MongoCollection <MongoDBCacheEntity> collection = GetMongoDBCollection(item.ConnStr);
                List <MongoDBCacheEntity>            lstEntity  = collection.FindAll().ToList();
                if (dateType == DateType.CreateTime)
                {
                    switch (cacheExpire)
                    {
                    case CacheExpire.Expired:     //已过期 包括过期和无效
                        lstEntity = lstEntity.Where(x => x.CacheSta == CacheStatus.Invalid && x.ExpireDate < DateTime.Now && x.Created >= startDate && x.Created < endDate).ToList();
                        break;

                    case CacheExpire.NoExpired:     //未过期
                        lstEntity = lstEntity.Where(x => x.CacheSta == CacheStatus.Effective && x.ExpireDate >= DateTime.Now && x.Created >= startDate && x.Created < endDate).ToList();
                        break;

                    default:
                        lstEntity = lstEntity.Where(x => x.CacheSta == CacheStatus.Effective && x.Created >= startDate && x.Created < endDate).ToList();
                        break;
                    }
                }
                else if (dateType == DateType.ExpireTime)
                {
                    switch (cacheExpire)
                    {
                    case CacheExpire.Expired:     //已过期 包括过期和无效
                        lstEntity = lstEntity.Where(x => x.CacheSta == CacheStatus.Invalid && x.ExpireDate < DateTime.Now && x.ExpireDate >= startDate && x.ExpireDate < endDate).ToList();
                        break;

                    case CacheExpire.NoExpired:     //未过期
                        lstEntity = lstEntity.Where(x => x.CacheSta == CacheStatus.Effective && x.ExpireDate >= DateTime.Now && x.ExpireDate >= startDate && x.ExpireDate < endDate).ToList();
                        break;

                    default:
                        lstEntity = lstEntity.Where(x => x.CacheSta == CacheStatus.Effective && x.ExpireDate >= startDate && x.ExpireDate < endDate).ToList();
                        break;
                    }
                }
                lstEntity.ForEach(x =>
                {
                    lstKeys.Add(x.CacheKey);
                });
            }
            return(lstKeys);
        }
Пример #15
0
        public DataTable StatisticsSaleTotal(OrderSearchInfo orderSearch, DateType dateType)
        {
            string condition = PrepareCondition(orderSearch).ToString();

            SqlParameter[] parameters =
            {
                new SqlParameter("@type",      SqlDbType.VarChar),
                new SqlParameter("@condition", SqlDbType.NVarChar),
                new SqlParameter("@dateType",  SqlDbType.Int)
            };
            parameters[0].Value = "StatisticsSaleTotal";
            parameters[1].Value = condition;
            parameters[2].Value = (int)dateType;
            return(ShopMssqlHelper.ExecuteDataTable("usp_Order", parameters));
        }
Пример #16
0
        private void writeDateToINI(INIFile i, string sectionName, DateType relPlay, string dateString)
        {
            string keyName;

            if (relPlay == DateType.Release)
            {
                keyName = nKeys.ReleaseDateInt;
            }
            else //DateType.LastPlayed
            {
                keyName = nKeys.LastPlayedInt;
            }

            i.IniWriteValue(sectionName, keyName, dateString);
        }
Пример #17
0
        /// <summary>
        /// Remove appearances and points from the global and season athlete data sets.
        /// </summary>
        /// <param name="currentDate"></param>
        private void RemoveAthletePoints(DateType currentDate)
        {
            // Remove from the global athletes data set.
            foreach (AthleteDetails athlete in this.Model.Athletes.AthleteDetails)
            {
                athlete.RemoveAppearances(currentDate);
            }

            // Remove from the season athletes data set.
            foreach (AthleteSeasonDetails athlete in this.Model.CurrentSeason.Athletes)
            {
                athlete.RemoveAppearances(currentDate);
                athlete.RemovePoints(currentDate);
            }
        }
Пример #18
0
 public LineItem(double Amount, DateTime Date, LineItemType liType)
 {
     if (Amount < 0)
     {
         throw new ApplicationException("New Line Item must have an Amount >= 0");
     }
     if (liType == LineItemType.Disbursement)
     {
         Amount = Amount * -1;
     }
     m_Amount   = Amount;
     m_Date     = Date;
     m_DateType = DateType.Date;
     m_Type     = liType;
 }
Пример #19
0
        private string FindDate(string title)
        {
            FindDate findDate = _printTitleManager.FindDateManager.Find(title, _expectedDate);

            if (findDate.Found)
            {
                _date      = findDate.Date;
                _dateType  = findDate.DateType;
                _dateMatch = findDate.matchValues;
                title      = findDate.matchValues.Replace(" $$date$$ ");
                _foundDate = true;
            }
            //_dateOtherMatchList = findDate.matchValuesList;
            return(title);
        }
Пример #20
0
 /// <summary>
 /// Loop through all clubs and set the points in the mode.
 /// </summary>
 /// <param name="mobTrophyPoints">points for all clubs</param>
 /// <param name="currentDate">current date</param>
 private void SaveMobTrophyPointsToModel(
     List <MobTrophyPoints> mobTrophyPoints,
     DateType currentDate)
 {
     foreach (MobTrophyPoints club in mobTrophyPoints)
     {
         this.Model.CurrentSeason.AddNewMobTrophyPoints(
             club.ClubName,
             new CommonPoints(
                 club.FinishingPoints,
                 club.PositionPoints,
                 club.BestPoints,
                 currentDate));
     }
 }
Пример #21
0
        public void SetUp()
        {
            datatype = new DateType();

            datedata[0] = 0;
            datedata[1] = 0;
            datedata[2] = 0;
            datedata[3] = 191;
            datedata[4] = 169;
            datedata[5] = 97;
            datedata[6] = 245;
            datedata[7] = 248;

            // All date values are represented in UTC
            cal = new DateTime(1996, 2, 1, 13, 15, 23, 0, DateTimeKind.Utc);
        }
 protected void SetDateField(DateType type)
 {
    if (type != null)
    {
         if (type.Name == "Fecha exacta" || type.Name == "Fecha aproximada")
         {
             datefield.Full ();
         } else if (type.Name == "Se desconoce el día")
         {
             datefield.WithoutDay ();
         } else if (type.Name == "Se desconoce el día y el mes")
         {
             datefield.YearOnly ();
         }
    }
 }
Пример #23
0
 public LineItem(double Amount, int Periods, int OddDays, LineItemType liType)
 {
     if (Amount < 0)
     {
         throw new ApplicationException("New Line Item must have an Amount >= 0");
     }
     if (liType == LineItemType.Disbursement)
     {
         Amount = Amount * -1;
     }
     m_Amount            = Amount;
     this.m_Span.Periods = Periods;
     this.m_Span.OddDays = OddDays;
     m_DateType          = DateType.Periods;
     m_Type = liType;
 }
Пример #24
0
        public static DateTime TimeToDateTime(object time)
        {
            DateTime dt;// = new DateTime();

            if (time is TimeSpan)
            {
                TimeSpan ts = (TimeSpan)time;
                //dt = new DateTime();
                dt = TimeToDateTime(ts);//dt.Add(ts);
            }
            else
            {
                dt = DateType.FromObject(time);
            }
            return(dt);
        }
Пример #25
0
        private void ShowDate(DateType dateType, bool shown)
        {
            var label = dateType == DateType.From ? NoMinLabel : NoMaxLabel;
            var dtp   = dateType == DateType.From ? FromDateTimePicker : ToDateTimePicker;

            if (shown)
            {
                label.Hide();
                dtp.Show();
            }
            else
            {
                label.Show();
                dtp.Hide();
            }
        }
Пример #26
0
        private void Populate()
        {
            IntegerType c1 = new IntegerType("id", "id");
            Border      b1 = c1.Border;

            stackPanel.Children.Add(b1);

            StringType c2 = new StringType("First Name", "First Name");
            Border     b2 = c2.Border;

            stackPanel.Children.Add(b2);

            StringType c3 = new StringType("Last Name", "Last Name");
            Border     b3 = c3.Border;

            stackPanel.Children.Add(b3);

            RadioType c4 = new RadioType("Gender", "Male", "Female");
            Border    b4 = c4.Border;

            stackPanel.Children.Add(b4);

            LongType c5 = new LongType("Phone No.", "Phone No");
            Border   b5 = c5.Border;

            stackPanel.Children.Add(b5);

            DateType c9 = new DateType("Date", System.DateTime.Now);
            Border   b9 = c9.Border;

            stackPanel.Children.Add(b9);

            FloatType c6 = new FloatType("Salary", "Salary");
            Border    b6 = c6.Border;

            stackPanel.Children.Add(b6);

            IntegerType c7 = new IntegerType("Roll no", "Roll No");
            Border      b7 = c7.Border;

            stackPanel.Children.Add(b7);

            StringType c8 = new StringType("Address", "Address");
            Border     b8 = c8.Border;

            stackPanel.Children.Add(b8);
        }
Пример #27
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DateObjectModel"/> class.
        /// </summary>
        /// <param name="aDateType">
        /// Type of Date
        /// </param>
        /// <param name="aCFormat">
        /// a c format.
        /// </param>
        /// <param name="aDualDated">
        /// if set to <c>true</c> [a dual dated].
        /// </param>
        /// <param name="aNewYear">
        /// a new year.
        /// </param>
        /// <param name="aQuality">
        /// a quality.
        /// </param>
        /// <param name="aStart">
        /// a start.
        /// </param>
        /// <param name="aStop">
        /// a stop.
        /// </param>
        /// <param name="aVal">
        /// a value.
        /// </param>
        /// <param name="aValType">
        /// Type of Val date.
        /// </param>
        public DateObjectModel(DateType aDateType, string aCFormat, bool aDualDated, string aNewYear, string aQuality, string aStart, string aStop, string aVal, string aValType)
        {
            // Setup defaults
            GCformat   = aCFormat;
            GDualdated = aDualDated;
            GNewYear   = aNewYear;
            GQuality   = aQuality;
            GStart     = aStart;
            GStop      = aStop;
            GVal       = aVal;
            GType      = aDateType;
            GValType   = aValType;

            // Setup specifics
            switch (aDateType)
            {
            case DateType.Range:
            {
                DateObjectModelRange(aCFormat, aDualDated, aNewYear, aQuality, aStart, aStop, aVal);
                break;
            }

            case DateType.Span:
            {
                DateObjectModelSpan(aCFormat, aDualDated, aNewYear, aQuality, aStart, aStop, aVal);
                break;
            }

            case DateType.Str:
            {
                DateObjectModelStr(aVal);
                break;
            }

            case DateType.Val:
            {
                DateObjectModelVal(aValType);
                break;
            }

            default:
            {
                DataStore.CN.NotifyError("Bad DateEnum: " + aDateType.ToString());
                break;
            }
            }
        }
Пример #28
0
        private void AddChildItem(DateTime dt, IFileX file, DateType dtype)
        {
            switch (this.Type)
            {
            case EnumDateTime.Year:
                var mitme = this.AddChildItem(dt.Year * 100 + dt.Month, EnumDateTime.Month);
                mitme.Text = dt.Month + mitme.Type.GetDescription();
                mitme.Add(file, dtype);
                break;

            case EnumDateTime.Month:
                var ditme = this.AddChildItem(dt.Year * 10000 + dt.Month * 100 + dt.Day, EnumDateTime.Day);
                ditme.Text = dt.Day.ToString();
                ditme.Add(file, dtype);
                break;
            }
        }
Пример #29
0
        public async Task <IEXResponse <IEnumerable <HolidaysAndTradingDatesUSResponse> > > HolidaysAndTradingDatesUSAsync(
            DateType type, DirectionType direction = DirectionType.Next, int last = 1, DateTime?startDate = null)
        {
            const string urlPattern = "ref-data/us/dates/[type]/[direction]/[last]/[startDate]";

            var qsb = new QueryStringBuilder();

            var pathNvc = new NameValueCollection
            {
                { "type", type.GetDescriptionFromEnum() },
                { "direction", direction.GetDescriptionFromEnum() },
                { "last", last.ToString() },
                { "startDate", startDate == null?DateTime.Now.ToString("yyyyMMdd") : ((DateTime)startDate).ToString("yyyyMMdd") }
            };

            return(await executor.ExecuteAsync <IEnumerable <HolidaysAndTradingDatesUSResponse> >(urlPattern, pathNvc, qsb));
        }
Пример #30
0
 private void AddPositionPoints(
     EventResults resultsTable,
     DateType currentDate)
 {
     if (this.resultsConfiguration.ResultsConfigurationDetails.ScoresAreDescending)
     {
         this.AddPositionPointsDescending(
             resultsTable,
             currentDate);
     }
     else
     {
         this.AddPositionPointsAscending(
             resultsTable,
             currentDate);
     }
 }
        private static void addDateType(ApplicationDbContext context)
        {
            var rnd       = new Random();
            var isEven    = rnd.Next(1, 100000) % 2 == 0;
            var dateType1 = new DateType
            {
                AddDate                 = isEven ? (DateTime?)null : DateTime.UtcNow,
                UpdateDate              = DateTime.UtcNow,
                AddDateValue            = isEven ? (DateTimeOffset?)null : DateTimeOffset.UtcNow,
                UpdateDateValue         = DateTimeOffset.UtcNow,
                RelativeAddTimeValue    = isEven ? (TimeSpan?)null : TimeSpan.FromMinutes(6),
                RelativeUpdateTimeValue = TimeSpan.FromMinutes(6)
            };

            context.DateTypes.Add(dateType1);
            context.SaveChanges();
        }
Пример #32
0
        /// <summary>
        /// Create a new event.
        /// </summary>
        /// <param name="eventName">Event name</param>
        /// <param name="date">date of the event</param>
        /// <returns>success flag</returns>
        public bool CreateNewEvent(string eventName, DateType date)
        {
            bool success =
                this.eventIo.CreateNewEvent(
                    this.model.CurrentSeason.Name,
                    eventName);

            if (success)
            {
                this.model.UpdateEvents();


                success =
                    this.eventData.SaveEventData(
                        this.model.CurrentSeason.Name,
                        eventName,
                        new EventMiscData()
                {
                    EventDate = date
                });

                if (success)
                {
                    success =
                        this.summaryData.SaveSummaryData(
                            this.model.CurrentSeason.Name,
                            eventName,
                            new Summary());
                }
            }

            if (success)
            {
                this.logger.WriteLog(string.Format("Finishing creating new event {0}", eventName));
            }
            else
            {
                this.logger.WriteLog("Failed to Create New Event");
                Messenger.Default.Send(
                    new HandicapErrorMessage(
                        "Event creation failed"));
            }

            return(success);
        }
Пример #33
0
        public static int GetDateTypeOrderNumber(DateType dateType)
        {
            switch (dateType)
            {
            case DateType.Day:
                return(1);

            case DateType.Month:
                return(2);

            case DateType.Year:
                return(3);

            case DateType.Unknow:
                return(4);
            }
            throw new PBException("unknow DateType {0}", dateType);
        }
Пример #34
0
        /// <summary>
        ///     获取时间
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public DateTime GetDate(DateType type)
        {
            string json = GetHtml(UrlType.GetDate);

            try
            {
                var result = JsonHelper.JsonToModel <JsonResult <string> >(json);
                if (result.err_code == 0)
                {
                    return(Convert.ToDateTime(result.data));
                }
            }
            catch
            {
            }

            return(DateTime.Now);
        }
Пример #35
0
 public Models_Zadanie10.Enrollment EnrollStudent(EnrollStudentReq req)
 {
     using (var db = new s18734Context())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             var study = DoStudiesExist(req.Studies);
             if (study == null)
             {
                 transaction.Rollback();
                 throw new Exception("Studia nie istnieja");
             }
             Models_Zadanie10.Enrollment enrollment = GetEnrollment(study.IdStudy);
             if (enrollment == null)
             {
                 enrollment = new Models_Zadanie10.Enrollment()
                 {
                     Semester  = 1,
                     IdStudy   = study.IdStudy,
                     StartDate = DateType.FromString(DateTime.Now.ToString("MM.dd.yyyy"))
                 };
                 db.Enrollment.Add(enrollment);
                 db.SaveChanges();
             }
             if (checkIfStudentExist(req.IndexNumber))
             {
                 transaction.Rollback();
                 throw new Exception();
             }
             var stud = new Models_Zadanie10.Student
             {
                 IndexNumber  = req.IndexNumber,
                 FirstName    = req.FirstName,
                 LastName     = req.LastName,
                 BirthDate    = DateType.FromString(req.BirthDate),
                 IdEnrollment = IntegerType.FromObject(enrollment.IdEnrollment)
             };
             db.Student.Add(stud);
             db.SaveChanges();
             transaction.Commit();
             return(enrollment);
         }
     }
 }
Пример #36
0
        private string GetDateValue(object value, DateType type)
        {
            var pars = new MethodCallExpressionModel()
            {
                Args = new List <MethodCallExpressionArgs>()
                {
                    new MethodCallExpressionArgs()
                    {
                        IsMember = true, MemberName = value, MemberValue = value
                    },
                    new MethodCallExpressionArgs()
                    {
                        MemberName = type, MemberValue = type
                    }
                }
            };

            return(this.Context.DbMehtods.DateValue(pars));
        }
Пример #37
0
        public static WebConfigData FindActiveEntry(DateType createDate, BooleanType active)
        {
            OrderByClause sort   = new OrderByClause("CreateDate, Active");
            WhereClause   filter = new WhereClause();

            filter.And("CreateDate", createDate.DBValue);
            filter.And("Active", !active.IsValid ? active.DBValue : active.DBValue.Equals("Y") ? 1 : 0);
            SqlDataReader dataReader = GetListReader(DatabaseEnum.INTERNET, TABLE, filter, sort, true);

            if (!dataReader.Read())
            {
                dataReader.Close();
                throw new FinderException("WebConfigData.FindActiveEntry found no rows.");
            }
            WebConfigData data = GetDataObjectFromReader(dataReader);

            dataReader.Close();
            return(data);
        }
Пример #38
0
        /// <summary>
        /// 获取用户单位时间内的发帖数
        /// </summary>
        /// <param name="topNumber">Top条数</param>
        /// <param name="dateType">时间类型</param>
        /// <param name="dateNum">时间数</param>
        /// <param name="postTableName">当前帖子分表名</param>
        /// <returns></returns>
        public static List <UserPostCountInfo> GetUserPostCountList(int topNumber, DateType dateType, int dateNum, string postTableName)
        {
            List <UserPostCountInfo> userPostCountInfoList = new List <UserPostCountInfo>();

            IDataReader iDataReader = DatabaseProvider.GetInstance().GetUserPostCountList(topNumber, dateType, dateNum, postTableName);

            while (iDataReader.Read())
            {
                UserPostCountInfo userPostCountInfo = new UserPostCountInfo();
                userPostCountInfo.Uid       = TypeConverter.ObjectToInt(iDataReader["uid"]);
                userPostCountInfo.Username  = iDataReader["username"].ToString();
                userPostCountInfo.PostCount = TypeConverter.ObjectToInt(iDataReader["postcount"]);

                userPostCountInfoList.Add(userPostCountInfo);
            }
            iDataReader.Close();

            return(userPostCountInfoList);
        }
Пример #39
0
        private static IDayWeather DataSet(dynamic json, DateType dt)
        {
            IDayWeather w = new ADayWeather();

            dynamic aDay = json.forecasts[dt];
            w.DateLabel = aDay.dateLabel;
            w.Date = aDay.date;
            w.Telop = aDay.telop;

            dynamic todayTemperatureMax = aDay.temperature.max;
            if (todayTemperatureMax != null)
            {
                w.TemperatureMax = todayTemperatureMax.celsius + "℃";
            }
            else
            {
                w.TemperatureMax = "---";
            }

            dynamic todayTemperatureMin = aDay.temperature.min;
            if (todayTemperatureMin != null)
            {
                w.TemperatureMin = todayTemperatureMin.celsius + "℃";
            }
            else
            {
                w.TemperatureMin = "---";
            }

            dynamic todayImage = aDay.image;
            if (todayImage != null)
            {
                var image = new Image();
                image.Url = todayImage.url;
                image.Width = todayImage.width;
                image.Height = todayImage.height;
                w.Image = image;
            }

            return w;
        }
Пример #40
0
        public ResponseResult<OrderModel> Get(int page, int page_size, DateTime start_date, DateTime end_date, OrderState order_state, string optional_fields = "", SortType sortType = SortType.Ase, DateType dateType = DateType.Modify_Time)
        {
            IJdClient client = new DefaultJdClient("","","");
            //http://jos.jd.com/api/detail.htm?id=691 接口地址
            var response = client.Execute(new UnionOrderServiceQueryOrdersRequest());
            //判断 是否接受错误  可忽略
            if (response.IsError)
            {

            }
            //对结果进行解析 理论上是响应的结果
            var t = response.queryordersResult;
            //是一窜json格式  OrderModel需要 对响应结果解析并且转换
            var parse=JsonConvert.DeserializeObject<OrderModel>(t);

            return new ResponseResult<OrderModel> {
                Code = int.Parse(response.ErrCode),
                Result = parse
            };
            //throw new NotImplementedException();
        }
Пример #41
0
    public Json.IJsonWriter Value(object obj, DateType type)
    {
      if (obj is DateTime)
      {
        if (_needsComma) _writer.Write(",");
        _needsComma = true;
        DateTime dt = (DateTime)obj;
        switch (type)
        {
          case DateType.Date:
            if (_useUTCDateTime) dt = TimeZoneInfo.ConvertTimeToUtc(dt);
            _writer.Write("new Date(");
            _writer.Write(dt.Year.ToString("0000", NumberFormatInfo.InvariantInfo));
            _writer.Write(", ");
            _writer.Write((dt.Month - 1).ToString(NumberFormatInfo.InvariantInfo));
            _writer.Write(", ");
            _writer.Write(dt.Day.ToString(NumberFormatInfo.InvariantInfo));
            _writer.Write(")");
            break;
          case DateType.TimeOfDay:
            if (_useUTCDateTime) dt = TimeZoneInfo.ConvertTimeToUtc(dt);
            Array();
            base.Value(dt.Hour);
            base.Value(dt.Minute);
            base.Value(dt.Second);
            base.Value(dt.Millisecond);
            ArrayEnd();
            break;
          default:
            WriteDateTime(dt);
            break;
        }

        return this;
      }
      else
      {
        return base.Value(obj);
      }
    }
        public void setDate (DateTime? date, DateType dateType) {
            datefield.CurrentDate = date;
            if (date.HasValue)
            {

                string date_string = date.Value.ToShortDateString ();

                if (dateType != null) {
                    setDateType(dateType);
                    if (dateType.Id == 3)
                    {
                        date_string = String.Format("{0:y}", date);
                    }
                    else if (dateType.Id == 4)
                    {
                        date_string = date.Value.Year.ToString ();
                    }
                }

                label2.Text = date_string;
            } else {
                label2.Text = "";
            }
        }
Пример #43
0
 public static int GetDateTypeOrderNumber(DateType dateType)
 {
     switch (dateType)
     {
         case DateType.Day:
             return 1;
         case DateType.Month:
             return 2;
         case DateType.Year:
             return 3;
         case DateType.Unknow:
             return 4;
     }
     throw new PBException("unknow DateType {0}", dateType);
 }
Пример #44
0
        //public static bool TryCreateDateFromYearMonthDay(NamedValues<ZValue> values, out Date date, out DateType dateType, NamedValues<ZValue> param = null)
        public static bool TryCreateDateFromYearMonthDay(DateValues dateValues, out Date date, out DateType dateType)
        {
            date = Date.MinValue;
            dateType = DateType.Unknow;
            int year;
            int month = 1;
            int day = 1;

            bool foundYear = false;
            bool foundMonth = false;
            bool foundDay = false;

            //ZValue v;
            //if (values.ContainsKey("year"))
            //{
            //    foundYear = true;
            //    v = values["year"];
            //    if (v is ZString)
            //    {
            //        if (!int.TryParse((string)v, out year))
            //        {
            //            values.SetError("error creating Date year is'nt a number : \"{0}\"", v);
            //            return false;
            //        }
            //    }
            //    else if (v is ZInt)
            //        year = (int)v;
            //    else
            //    {
            //        values.SetError("error creating Date year should be a string number or an int : {0}", v);
            //        return false;
            //    }
            //}
            //else
            //    year = Date.Today.Year;

            if (dateValues.year != null)
            {
                foundYear = true;
                year = (int)dateValues.year;
            }
            else
                year = Date.Today.Year;


            //v = null;
            //if (values.ContainsKey("month1"))
            //{
            //    v = values["month1"];
            //    if (v is ZString && string.IsNullOrEmpty((string)v))
            //        v = null;
            //}
            //if (v == null && values.ContainsKey("month2"))
            //{
            //    v = values["month2"];
            //    if (v is ZString && string.IsNullOrEmpty((string)v))
            //        v = null;
            //}
            //if (v == null && values.ContainsKey("month"))
            //{
            //    v = values["month"];
            //    if (v is ZString && string.IsNullOrEmpty((string)v))
            //        v = null;
            //}
            //if (v != null)
            //{
            //    foundMonth = true;
            //    if (v is ZString)
            //    {
            //        if (!int.TryParse((string)v, out month))
            //        {
            //            month = GetMonthNumber((string)v);
            //            if (month == 0)
            //            {
            //                values.SetError("error creating Date invalid month : \"{0}\"", v);
            //                return false;
            //            }
            //        }
            //    }
            //    else if (v is ZInt)
            //        month = (int)v;
            //    else
            //    {
            //        values.SetError("error creating Date month should be a string number or an int : {0}", v);
            //        return false;
            //    }
            //}

            if (dateValues.month != null)
            {
                foundMonth = true;
                month = (int)dateValues.month;
                if (month < 1 || month > 12)
                    return false;
            }


            //if (values.ContainsKey("day"))
            //{
            //    foundDay = true;
            //    v = values["day"];
            //    if (v is ZString)
            //    {
            //        if (!int.TryParse((string)v, out day))
            //        {
            //            values.SetError("error creating Date day is'nt a number : \"{0}\"", v);
            //            return false;
            //        }
            //    }
            //    else if (v is ZInt)
            //    {
            //        day = (int)v;
            //    }
            //    else
            //    {
            //        values.SetError("error creating Date day should be a string number or an int : {0}", v);
            //        return false;
            //    }
            //}

            if (dateValues.day != null)
            {
                foundDay = true;
                day = (int)dateValues.day;
            }



            if (year < 100)
                year = zdate.ToFourDigitYear(year);

            if (day < 1 || day > DateTime.DaysInMonth(year, month))
                return false;

            Date date3 = new Date(year, month, day);
            if (!foundYear)
            {
                if (date3 > Date.Today && month > Date.Today.Month + 2)
                {
                    if (day > DateTime.DaysInMonth(year - 1, month))
                        return false;

                    date3 = new Date(year - 1, month, day);
                }
            }
            date = date3;

            if (foundDay)
                dateType = DateType.Day;
            else if (foundMonth)
                dateType = DateType.Month;
            else
                dateType = DateType.Year;

            return true;
        }
Пример #45
0
 /// <summary>
 /// Creates a vague date string from a vague date instance containing a date type start and end dates 
 /// expressed as days elapsed since 30/12/1899.
 /// </summary>
 /// <param name="vd">a VagueDateInstance with the date to be converted.</param>
 /// <param name="outputFormat">A vague date string in the format specified in the dateType parameter.</param>
 /// <returns></returns>
 public static string FromVagueDateInstance(VagueDateInstance vd, DateType outputFormat)
 {
     return FromTimeSpanDays(vd.StartDate, vd.EndDate, vd.DateType, outputFormat);
 }
Пример #46
0
        /// <summary>
        /// 获取用户单位时间内的发帖数
        /// </summary>
        /// <param name="topNumber">Top条数</param>
        /// <param name="dateType">时间类型</param>
        /// <param name="dateNum">时间数</param>
        /// <param name="postTableName">当前帖子分表名</param>
        /// <returns></returns>
        public IDataReader GetUserPostCountList(int topNumber, DateType dateType, int dateNum, string postTableName)
        {
            string dateTypeStr = "day";
            switch (dateType)
            {
                case DateType.Minute: dateTypeStr = "minute"; break;
                case DateType.Hour: dateTypeStr = "hour"; break;
                case DateType.Day: dateTypeStr = "day"; break;
                case DateType.Week: dateTypeStr = "week"; break;
                case DateType.Month: dateTypeStr = "month"; break;
                case DateType.Year: dateTypeStr = "year"; break;
            }

            string commandText = string.Format("SELECT TOP {0} [posterid] As [uid], [poster] As [username], COUNT(pid) AS [postcount] FROM  [{1}] WHERE [posterid] > 0 AND [invisible] <=0 AND DATEDIFF({2}, [postdatetime], GETDATE()) <= {3} GROUP BY [posterid], [poster] ORDER BY [postcount] DESC",
                                        topNumber,
                                        postTableName,
                                        dateTypeStr,
                                        dateNum);

            return DbHelper.ExecuteReader(CommandType.Text, commandText);
        }
Пример #47
0
 /// <summary>
 /// 获取用户单位时间内的发帖数
 /// </summary>
 /// <param name="topNumber">Top条数</param>
 /// <param name="dateType">时间类型</param>
 /// <param name="dateNum">时间数</param>
 /// <returns></returns>
 public static List<UserPostCountInfo> GetUserPostCountList(int topNumber, DateType dateType, int dateNum)
 {
     return Discuz.Data.Posts.GetUserPostCountList(topNumber, dateType, dateNum, PostTables.GetPostTableName());
 }
Пример #48
0
 /// <summary>
 /// Creates a vague date string of a specified format from a date string.
 /// </summary>
 /// <param name="dateString">Date string.</param>
 /// <param name="dateType">Two-letter date format code as generated by the GetFormat method.</param>
 /// <param name="outputFormat">One of the output formats in the HLU.Date.DateType enumeration.</param>
 /// <returns>A vague date string in the format specified in the dateType parameter.</returns>
 public static string FromDateString(string dateString, string dateType, DateType outputFormat)
 {
     string startDateString;
     string endDateString;
     SplitDateString(dateString, out startDateString, out endDateString);
     return FromDateString(startDateString, endDateString, dateType, outputFormat);
 }
Пример #49
0
        /// <summary>
        /// Creates a vague date string of a specified format from start and end date strings.
        /// </summary>
        /// <param name="startDateString"></param>
        /// <param name="endDateString"></param>
        /// <param name="dateType">Two-letter date format code as generated by the GetFormat method.</param>
        /// <param name="outputFormat">One of the output formats in the HLU.Date.DateType enumeration.</param>
        /// <returns>A vague date string in the format specified in the dateType parameter.</returns>
        public static string FromDateString(string startDateString, string endDateString,
            string dateType, DateType outputFormat)
        {
            try
            {
                DateTimeFormatInfo dtFormatInfo = CultureInfo.CurrentCulture.DateTimeFormat;

                DateTime startDate = DateTime.MinValue;
                DateTime endDate = DateTime.MinValue;

                if ((String.IsNullOrEmpty(startDateString) || !DateTime.TryParse(startDateString, dtFormatInfo,
                    DateTimeStyles.AllowWhiteSpaces | DateTimeStyles.AssumeLocal |
                    DateTimeStyles.NoCurrentDateDefault, out startDate)) && ((outputFormat == DateType.Start) ||
                    (outputFormat == DateType.Vague))) return VagueDateTypes.Unknown.ToString();

                if ((String.IsNullOrEmpty(endDateString) || !DateTime.TryParse(endDateString, dtFormatInfo,
                    DateTimeStyles.AllowWhiteSpaces | DateTimeStyles.AssumeLocal |
                    DateTimeStyles.NoCurrentDateDefault, out endDate)) && ((outputFormat == DateType.End) ||
                    (outputFormat == DateType.Vague))) return VagueDateTypes.Unknown.ToString();

                return FromDate(startDate, endDate, dateType, outputFormat);
            }
            catch { return FromDateString(String.Empty, String.Empty, dateType, outputFormat); }
        }
Пример #50
0
 /// <summary>
 /// Creates a vague date string of a specified format from start and end dates 
 /// expressed as days elapsed since 30/12/1899.
 /// </summary>
 /// <param name="startDateDays">Start date in days since 30/12/1899.</param>
 /// <param name="endDateDays">End date in days since 30/12/1899.</param>
 /// <param name="dateType">Two-letter date format code as generated by the GetFormat method.</param>
 /// <param name="outputFormat">One of the output formats in the HLU.Date.DateType enumeration.</param>
 /// <returns>A vague date string in the format specified in the dateType parameter.</returns>
 public static string FromTimeSpanDays(int startDateDays, int endDateDays,
     string dateType, DateType outputFormat)
 {
     try
     {
         bool useString = false;
         string startDateString = null;
         string endDateString = null;
         if (startDateDays == Int32.MinValue)
         {
             startDateString = String.Empty;
             endDateString = BaseDate.AddDays(endDateDays).ToShortDateString();
             useString = true;
         }
         if (endDateDays == Int32.MinValue)
         {
             startDateString = BaseDate.AddDays(startDateDays).ToShortDateString();
             endDateString = String.Empty;
             useString = true;
         }
         if (!useString)
             return FromDate(BaseDate.AddDays(startDateDays),
                 BaseDate.AddDays(endDateDays), dateType, outputFormat);
         else
             return FromDateString(startDateString, endDateString, dateType, outputFormat);
     }
     catch { return FromDateString(String.Empty, String.Empty, dateType, outputFormat); }
 }
Пример #51
0
        /// <summary>
        /// Converts a vague date composed of separate start and end date strings into a timespan in days since 30/12/1899.
        /// </summary>
        /// <param name="startDateString">Start date string.</param>
        /// <param name="endDateString">End date string.</param>
        /// <param name="dateType">Two-letter date format code as generated by the GetFormat method.</param>
        /// <param name="outputFormat">One of the output formats in the HLU.Date.DateType enumeration.</param>
        /// <returns></returns>
        public static int ToTimeSpanDays(string startDateString, string endDateString,
            string dateType, DateType outputFormat)
        {
            if (String.IsNullOrEmpty(dateType) || (dateType == VagueDate.ToCode(VagueDateTypes.Unknown)))
                return DateUnknown;

            try
            {
                DateTimeFormatInfo dtFormatInfo = CultureInfo.CurrentCulture.DateTimeFormat;

                DateTime startDate;
                bool startDateOk = DateTime.TryParse(startDateString, dtFormatInfo,
                    DateTimeStyles.AllowWhiteSpaces | DateTimeStyles.AssumeLocal |
                    DateTimeStyles.NoCurrentDateDefault, out startDate);

                DateTime endDate;
                bool endDateOk = DateTime.TryParse(endDateString, dtFormatInfo,
                    DateTimeStyles.AllowWhiteSpaces | DateTimeStyles.AssumeLocal |
                    DateTimeStyles.NoCurrentDateDefault, out endDate);

                int year;

                string formatString = String.Empty;
                switch (outputFormat)
                {
                    case DateType.Start:
                        if (dateType.Length > 0)
                            formatString = dateType.Substring(0, 1);
                        switch (VagueDate.FromCode(formatString))
                        {
                            case VagueDateTypes.StartDate: // "D"
                                if (startDateOk) return startDate.Subtract(BaseDate).Days;
                                break;
                            case VagueDateTypes.StartMonthAndYear: // "O"
                                if (startDateOk) return startDate.Subtract(BaseDate).Days;
                                break;
                            case VagueDateTypes.Year: // "Y"
                                if (startDateOk)
                                    return new DateTime(startDate.Year, 1, 1).Subtract(BaseDate).Days;
                                else if (Int32.TryParse(startDateString, out year))
                                    return new DateTime(year, 1, 1).Subtract(BaseDate).Days;
                                break;
                            case VagueDateTypes.Season: // "P"
                                if (!String.IsNullOrEmpty(startDateString))
                                {
                                    string[] splitArray = Regex.Split(startDateString, @"\s+");
                                    if ((splitArray.Length != 2) || !Int32.TryParse(splitArray[1], out year))
                                        return DateUnknown; // 9999;
                                    var q = SeasonNames.Where(s => s.ToLower() == splitArray[0].ToLower());
                                    if (q.Count() > 0)
                                    {
                                        string season = q.ElementAt(0);
                                        int seasonIx = System.Array.IndexOf(SeasonNames, season);
                                        if (seasonIx != -1)
                                            return SeasonStart(splitArray[0], year).Subtract(BaseDate).Days;
                                    }
                                }
                                break;
                            case VagueDateTypes.Unknown: // "U"
                            default:
                                return DateUnknown;
                        }
                        break;
                    case DateType.End:
                        if (dateType.Length > 1)
                            formatString = dateType.Substring(dateType.Length - 1, 1);
                        switch (VagueDate.FromCode(formatString))
                        {
                            case VagueDateTypes.StartDate: // "D"
                                if (endDateOk) return endDate.Subtract(BaseDate).Days;
                                break;
                            case VagueDateTypes.StartMonthAndYear: // "O"
                                if (endDateOk) return endDate.Subtract(BaseDate).Days;
                                break;
                            case VagueDateTypes.Year: // "Y"
                                if (endDateOk)
                                    return new DateTime(endDate.Year, 1, 1).Subtract(BaseDate).Days;
                                else if (Int32.TryParse(endDateString, out year))
                                    return new DateTime(year, 1, 1).Subtract(BaseDate).Days;
                                break;
                            case VagueDateTypes.Season: // "P"
                                if (!String.IsNullOrEmpty(endDateString))
                                {
                                    string[] splitArray = Regex.Split(endDateString, @"\s+");
                                    if ((splitArray.Length != 2) || !Int32.TryParse(splitArray[1], out year))
                                        return DateUnknown; // 9999;
                                    var q = SeasonNames.Where(s => s.ToLower() == splitArray[0].ToLower());
                                    if (q.Count() > 0)
                                    {
                                        string season = q.ElementAt(0);
                                        int seasonIx = System.Array.IndexOf(SeasonNames, season);
                                        return SeasonEnd(season, year).Subtract(BaseDate).Days;
                                    }
                                }
                                break;
                            case VagueDateTypes.Unknown: // "U"
                            default:
                                return DateUnknown;
                        }
                        break;
                }
            }
            catch { }

            return DateUnknown; // 9999
        }
Пример #52
0
 /// <summary>
 /// Converts a vague date string into a timespan in days since 30/12/1899.
 /// </summary>
 /// <param name="dateString">Vague date string.</param>
 /// <param name="dateType">Two-letter date format code as generated by the GetFormat method.</param>
 /// <param name="outputFormat">One of the output formats in the HLU.Date.DateType enumeration.</param>
 /// <returns></returns>
 public static int ToTimeSpanDays(string dateString, string dateType, DateType outputFormat)
 {
     string startDateString;
     string endDateString;
     SplitDateString(dateString, out startDateString, out endDateString);
     return ToTimeSpanDays(startDateString, endDateString, dateType, outputFormat);
 }
Пример #53
0
 public ResponseResult<SerachModel> Search(int page, int page_size, DateTime start_date, DateTime end_date, OrderState order_state, string optional_fields = "", SortType sortType = SortType.Ase, DateType dateType = DateType.Modify_Time)
 {
     throw new NotImplementedException();
 }
Пример #54
0
 protected static string DateString(string date, DateType type)
 {
     var str = date;
     var parseDate = DateTime.MinValue;
     var currentCulture = System.Threading.Thread.CurrentThread.CurrentCulture;
     try {
         System.Threading.Thread.CurrentThread.CurrentCulture =
             System.Globalization.CultureInfo.CreateSpecificCulture("ja-JP");
         if (DateTime.TryParse(date, out parseDate))
             switch (type) {
                 case DateType.TimeSpan:
                     str = (parseDate - DateTime.Parse("1970/1/1")).TotalMilliseconds.ToString();
                     break;
                 case DateType.Date:
                     str = parseDate.ToShortDateString();
                     break;
                 case DateType.Time:
                     str = parseDate.ToShortTimeString();
                     break;
                 case DateType.DateTime:
                     str = parseDate.ToString();
                     break;
             }
     }
     finally {
         System.Threading.Thread.CurrentThread.CurrentCulture = currentCulture;
     }
     return str;
 }
Пример #55
0
        /// <summary>
        /// 获取用户单位时间内的发帖数
        /// </summary>
        /// <param name="topNumber">Top条数</param>
        /// <param name="dateType">时间类型</param>
        /// <param name="dateNum">时间数</param>
        /// <returns></returns>
        public List<UserPostCountInfo> GetUserPostCountList(int topNumber, DateType dateType, int dateNum)
        {
            Discuz.Cache.DNTCache cache = Discuz.Cache.DNTCache.GetCacheService();

            List<UserPostCountInfo> userPostCountInfoList = cache.RetrieveObject("/Aggregation/UserPostCountList") as List<UserPostCountInfo>;
            if (userPostCountInfoList == null)
            {
                userPostCountInfoList = Posts.GetUserPostCountList(topNumber, dateType, (dateNum > 1 ? dateNum : 1));

                //声明新的缓存策略接口
                //Discuz.Cache.ICacheStrategy ics = new AggregationCacheStrategy();
                //ics.TimeOut = 120;
                //cache.LoadCacheStrategy(ics);
                cache.AddObject("/UserPostCountList", userPostCountInfoList, 120);
                //cache.LoadDefaultCacheStrategy();
            }
            return userPostCountInfoList;
        }
Пример #56
0
        /// <summary>
        /// 获取用户单位时间内的发帖数
        /// </summary>
        /// <param name="topNumber">Top条数</param>
        /// <param name="dateType">时间类型</param>
        /// <param name="dateNum">时间数</param>
        /// <param name="postTableName">当前帖子分表名</param>
        /// <returns></returns>
        public static List<UserPostCountInfo> GetUserPostCountList(int topNumber, DateType dateType, int dateNum, string postTableName)
        {
            List<UserPostCountInfo> userPostCountInfoList = new List<UserPostCountInfo>();

            IDataReader iDataReader = DatabaseProvider.GetInstance().GetUserPostCountList(topNumber, dateType, dateNum, postTableName);
            while (iDataReader.Read())
            {
                UserPostCountInfo userPostCountInfo = new UserPostCountInfo();
                userPostCountInfo.Uid = TypeConverter.ObjectToInt(iDataReader["uid"]);
                userPostCountInfo.Username = iDataReader["username"].ToString();
                userPostCountInfo.PostCount = TypeConverter.ObjectToInt(iDataReader["postcount"]);

                userPostCountInfoList.Add(userPostCountInfo);
            }
            iDataReader.Close();   

            return userPostCountInfoList;
        }
 private Brush BrushFromType(DateType type)
 {
     switch (type)
     {
         case DateType.holiday:
             return Brushes.Red;
         case DateType.normal:
             return Brushes.Black;
         case DateType.payment:
             return Brushes.Black;
         default:
             return Brushes.Black;
     }
 }
Пример #58
0
        //public static bool TryCreateDate(NamedValues<ZValue> values, out Date date, out DateType dateType, NamedValues<ZValue> param = null)
        public static bool TryCreateDate(NamedValues<ZValue> values, out Date date, out DateType dateType)
        {
            date = Date.MinValue;
            dateType = DateType.Unknow;
            DateValues dateValues = DateValues.GetDateValues(values);
            //if (!values.ContainsKey("day_near_current_date") && !values.ContainsKey("month") && !values.ContainsKey("month1") && !values.ContainsKey("month2") && !values.ContainsKey("year"))
            if (dateValues.dayNearCurrentDate == null && dateValues.month == null && dateValues.year == null)
            {
                //values.SetError("error creating Date unknow day_near_current_date and month (month1 or month2)");
                //Trace.WriteLine("error creating Date unknow day_near_current_date unknow month (month1 and month2) and unknow year (year1 and year2)");
                return false;
            }

            //if (values.ContainsKey("day_near_current_date"))
            if (dateValues.dayNearCurrentDate != null)
            {
                //return TryCreateDateFromDay(values, out date, out dateType, param);
                return TryCreateDateFromDay(dateValues, out date, out dateType);
            }
            else
            {
                //return TryCreateDateFromYearMonthDay(values, out date, out dateType, param);
                return TryCreateDateFromYearMonthDay(dateValues, out date, out dateType);
            }
        }
Пример #59
0
        //public static bool TryCreateDateFromDay(NamedValues<ZValue> values, out Date date, out DateType dateType, NamedValues<ZValue> param = null)
        public static bool TryCreateDateFromDay(DateValues dateValues, out Date date, out DateType dateType, NamedValues<ZValue> param = null)
        {
            date = Date.MinValue;
            dateType = DateType.Unknow;
            //int day;
            //ZValue v = values["day_near_current_date"];
            //if (v is ZString)
            //{
            //    string s = (string)v;
            //    s = s.Replace('o', '0');
            //    s = s.Replace('O', '0');
            //    if (!int.TryParse(s, out day))
            //    {
            //        //throw new PBException("error creating Date day_near_current_date is'nt a number : \"{0}\"", o);
            //        values.SetError("error creating Date day_near_current_date is'nt a number : \"{0}\"", v);
            //        return false;
            //    }
            //}
            //else if (v is ZInt)
            //    day = (int)v;
            //else
            //{
            //    //throw new PBException("error creating Date day_near_current_date should be a string number or an int : {0}", o);
            //    values.SetError("error creating Date day_near_current_date should be a string number or an int : {0}", v);
            //    return false;
            //}

            //if (!TryGetDateFromDay(day, out date))
            if (!TryGetDateFromDay((int)dateValues.dayNearCurrentDate, out date))
            {
                //throw new PBException("error creating Date bad day_near_current_date : {0}", day);
                //values.SetError("error creating Date bad day_near_current_date : {0}", day);
                Trace.WriteLine("error creating Date bad day_near_current_date : {0}", dateValues.dayNearCurrentDate);
                return false;
            }
            dateType = DateType.Day;
            return true;
        }
Пример #60
0
 /// <summary>
 /// Creates a vague date string of a specified format from start and end dates in ticks.
 /// </summary>
 /// <param name="startDateTicks">Start date in ticks.</param>
 /// <param name="endDateTicks">End date in ticks.</param>
 /// <param name="dateType">Two-letter date format code as generated by the GetFormat method.</param>
 /// <param name="outputFormat">One of the output formats in the HLU.Date.DateType enumeration.</param>
 /// <returns>A vague date string in the format specified in the dateType parameter.</returns>
 public static string FromTimeSpanTicks(long startDateTicks, long endDateTicks,
     string dateType, DateType outputFormat)
 {
     try
     {
         DateTime startDate = new DateTime(startDateTicks);
         DateTime endDate = new DateTime(endDateTicks);
         return FromDate(startDate, endDate, dateType, outputFormat);
     }
     catch { return FromDateString(String.Empty, String.Empty, dateType, outputFormat); }
 }