예제 #1
0
 /// <summary>
 /// 获取指定农历时间对应的公历时间
 /// </summary>
 /// <param name="CnTime"></param>
 /// <returns></returns>
 public static DateTime ToDateTime(ChinaDateTime CnTime)
 {
     return(CnTime.ToDateTime());
 }
예제 #2
0
        /// <summary>
        /// 转换为UserProfile用于数据库存储
        /// </summary>
        public UserProfile AsUserProfile(long userId)
        {
            UserProfile userProfile;

            if (UserId > 0)
            {
                UserProfileService userProfileService = new UserProfileService();
                userProfile = userProfileService.Get(UserId);
                userProfile.BirthdayType = this.BirthdayType;

                if (this.Gender == GenderType.FeMale)
                {
                    userProfile.Gender = GenderType.FeMale;
                }
                else if (this.Gender == GenderType.Male)
                {
                    userProfile.Gender = GenderType.Male;
                }

                else
                {
                    userProfile.Gender = 0;
                }

                if (this.BirthdayType == BirthdayType.LunarBirthday)
                {
                    ChinaDateTime cdt = new ChinaDateTime(LunarYear, LunarMonth, LunarDay);
                    userProfile.LunarBirthday = new DateTime(LunarYear, LunarMonth, LunarDay);
                    userProfile.Birthday      = cdt.ToDateTime();
                }
                else
                {
                    if (Birthday != null)
                    {
                        ChinaDateTime cdt = new ChinaDateTime(Birthday.Value);
                        userProfile.Birthday      = Birthday.Value;
                        userProfile.LunarBirthday = new DateTime(cdt.Year, cdt.Month, cdt.DayOfMonth);
                    }
                }

                if (!string.IsNullOrEmpty(Introduction))
                {
                    userProfile.Introduction = this.Introduction;
                }
                else
                {
                    userProfile.Introduction = "";
                }

                if (!string.IsNullOrEmpty(Email))
                {
                    userProfile.Email = this.Email;
                }
                else
                {
                    userProfile.Email = "";
                }

                if (!string.IsNullOrEmpty(Mobile))
                {
                    userProfile.Mobile = this.Mobile;
                }
                else
                {
                    userProfile.Mobile = "";
                }

                if (!string.IsNullOrEmpty(Msn))
                {
                    userProfile.Msn = this.Msn;
                }
                else
                {
                    userProfile.Msn = "";
                }

                if (!string.IsNullOrEmpty(NowAreaCode))
                {
                    userProfile.NowAreaCode = this.NowAreaCode;
                }
                else
                {
                    userProfile.NowAreaCode = "";
                }

                if (!string.IsNullOrEmpty(HomeAreaCode))
                {
                    userProfile.HomeAreaCode = this.HomeAreaCode;
                }
                else
                {
                    userProfile.HomeAreaCode = "";
                }

                if (!string.IsNullOrEmpty(QQ))
                {
                    userProfile.QQ = this.QQ;
                }
                else
                {
                    userProfile.QQ = "";
                }
            }
            else
            {
                userProfile = UserProfile.New();

                userProfile.BirthdayType = this.BirthdayType;

                if (this.Gender == GenderType.FeMale)
                {
                    userProfile.Gender = GenderType.FeMale;
                }
                else if (this.Gender == GenderType.Male)
                {
                    userProfile.Gender = GenderType.FeMale;
                }
                else
                {
                    userProfile.Gender = 0;
                }

                if (!string.IsNullOrEmpty(HomeAreaCode))
                {
                    userProfile.HomeAreaCode = this.HomeAreaCode;
                }
                else
                {
                    userProfile.HomeAreaCode = "";
                }

                if (!string.IsNullOrEmpty(NowAreaCode))
                {
                    userProfile.NowAreaCode = this.NowAreaCode;
                }
                else
                {
                    userProfile.NowAreaCode = "";
                }

                if (!string.IsNullOrEmpty(Email))
                {
                    userProfile.Email = this.Email;
                }
                else
                {
                    userProfile.Email = "";
                }

                if (!string.IsNullOrEmpty(Introduction))
                {
                    userProfile.Introduction = this.Introduction;
                }
                else
                {
                    userProfile.Introduction = "";
                }

                if (!string.IsNullOrEmpty(Mobile))
                {
                    userProfile.Mobile = this.Mobile;
                }
                else
                {
                    userProfile.Mobile = "";
                }

                if (!string.IsNullOrEmpty(Msn))
                {
                    userProfile.Msn = this.Msn;
                }
                else
                {
                    userProfile.Msn = "";
                }

                if (!string.IsNullOrEmpty(QQ))
                {
                    userProfile.QQ = this.QQ;
                }
                else
                {
                    userProfile.QQ = "";
                }

                if (Birthday != null)
                {
                    if (this.BirthdayType == BirthdayType.LunarBirthday)
                    {
                        ChinaDateTime cdt = new ChinaDateTime(LunarYear, LunarMonth, LunarDay);
                        userProfile.LunarBirthday = new DateTime(LunarYear, LunarMonth, LunarDay);
                        userProfile.Birthday      = cdt.ToDateTime();
                    }
                    else
                    {
                        ChinaDateTime cdt = new ChinaDateTime(Birthday.Value);
                        userProfile.Birthday      = Birthday.Value;
                        userProfile.LunarBirthday = new DateTime(cdt.Year, cdt.Month, cdt.DayOfMonth);
                    }
                }
                else
                {
                    ChinaDateTime cdt = new ChinaDateTime(DateTime.UtcNow);
                    userProfile.Birthday      = DateTime.UtcNow;
                    userProfile.LunarBirthday = new DateTime(cdt.Year, cdt.Month, cdt.DayOfMonth);
                }

                userProfile.UserId = userId;
            }
            return(userProfile);
        }
예제 #3
0
        /// <summary>
        /// 转换为UserProfile用于数据库存储
        /// </summary>
        public UserProfile AsUserProfile(long userId)
        {
            UserProfile userProfile;
            if (UserId > 0)
            {
                UserProfileService userProfileService = new UserProfileService();
                userProfile = userProfileService.Get(UserId);
                userProfile.BirthdayType = this.BirthdayType;

                if (this.Gender == GenderType.FeMale)
                    userProfile.Gender = GenderType.FeMale;
                else if (this.Gender == GenderType.Male)
                    userProfile.Gender = GenderType.Male;

                else
                    userProfile.Gender = 0;

                if (this.BirthdayType == BirthdayType.LunarBirthday)
                {
                    ChinaDateTime cdt = new ChinaDateTime(LunarYear, LunarMonth, LunarDay);
                    userProfile.LunarBirthday = new DateTime(LunarYear, LunarMonth, LunarDay);
                    userProfile.Birthday = cdt.ToDateTime();

                }
                else
                {
                    if (Birthday != null)
                    {
                        ChinaDateTime cdt = new ChinaDateTime(Birthday.Value);
                        userProfile.Birthday = Birthday.Value;
                        userProfile.LunarBirthday = new DateTime(cdt.Year, cdt.Month, cdt.DayOfMonth);
                    }
                }

                if (!string.IsNullOrEmpty(Introduction))
                    userProfile.Introduction = this.Introduction;
                else
                    userProfile.Introduction = "";

                if (!string.IsNullOrEmpty(Email))
                    userProfile.Email = this.Email;
                else
                    userProfile.Email = "";

                if (!string.IsNullOrEmpty(Mobile))
                    userProfile.Mobile = this.Mobile;
                else
                    userProfile.Mobile = "";

                if (!string.IsNullOrEmpty(Msn))
                    userProfile.Msn = this.Msn;
                else
                    userProfile.Msn = "";

                if (!string.IsNullOrEmpty(NowAreaCode))
                    userProfile.NowAreaCode = this.NowAreaCode;
                else
                    userProfile.NowAreaCode = "";

                if (!string.IsNullOrEmpty(HomeAreaCode))
                    userProfile.HomeAreaCode = this.HomeAreaCode;
                else
                    userProfile.HomeAreaCode = "";

                if (!string.IsNullOrEmpty(QQ))
                    userProfile.QQ = this.QQ;
                else
                    userProfile.QQ = "";
            }
            else
            {
                userProfile = UserProfile.New();

                userProfile.BirthdayType = this.BirthdayType;

                if (this.Gender == GenderType.FeMale)
                    userProfile.Gender = GenderType.FeMale;
                else if (this.Gender == GenderType.Male)
                    userProfile.Gender = GenderType.FeMale;
                else
                    userProfile.Gender = 0;

                if (!string.IsNullOrEmpty(HomeAreaCode))
                    userProfile.HomeAreaCode = this.HomeAreaCode;
                else
                    userProfile.HomeAreaCode = "";

                if (!string.IsNullOrEmpty(NowAreaCode))
                    userProfile.NowAreaCode = this.NowAreaCode;
                else
                    userProfile.NowAreaCode = "";

                if (!string.IsNullOrEmpty(Email))
                    userProfile.Email = this.Email;
                else
                    userProfile.Email = "";

                if (!string.IsNullOrEmpty(Introduction))
                    userProfile.Introduction = this.Introduction;
                else
                    userProfile.Introduction = "";

                if (!string.IsNullOrEmpty(Mobile))
                    userProfile.Mobile = this.Mobile;
                else
                    userProfile.Mobile = "";

                if (!string.IsNullOrEmpty(Msn))
                    userProfile.Msn = this.Msn;
                else
                    userProfile.Msn = "";

                if (!string.IsNullOrEmpty(QQ))
                    userProfile.QQ = this.QQ;
                else
                    userProfile.QQ = "";

                if (Birthday != null)
                {
                    if (this.BirthdayType == BirthdayType.LunarBirthday)
                    {
                        ChinaDateTime cdt = new ChinaDateTime(LunarYear, LunarMonth, LunarDay);
                        userProfile.LunarBirthday = new DateTime(LunarYear, LunarMonth, LunarDay);
                        userProfile.Birthday = cdt.ToDateTime();

                    }
                    else
                    {
                        ChinaDateTime cdt = new ChinaDateTime(Birthday.Value);
                        userProfile.Birthday = Birthday.Value;
                        userProfile.LunarBirthday = new DateTime(cdt.Year, cdt.Month, cdt.DayOfMonth);
                    }
                }
                else
                {
                    ChinaDateTime cdt = new ChinaDateTime(DateTime.UtcNow);
                    userProfile.Birthday = DateTime.UtcNow;
                    userProfile.LunarBirthday = new DateTime(cdt.Year, cdt.Month, cdt.DayOfMonth);
                }

                userProfile.UserId = userId;

            }
            return userProfile;
        }
예제 #4
0
 /// <summary>
 /// 获取指定农历时间对应的公历时间
 /// </summary>
 /// <param name="CnTime"></param>
 /// <returns></returns>
 public static DateTime ToDateTime(ChinaDateTime CnTime)
 {
     return CnTime.ToDateTime();
 }