public bool CancelSchedules(SchedulePO schedule) { var result = true; return(result); }
public SchedulePO CreateSchedules(SchedulePO schedule) { var request = ProxyRequest("CreateEvent"); request.Data = schedule.ObjToJson(); return(ReadFromProxy(request).JsonToObj <SchedulePO>()); }
public bool CancelSchedules(SchedulePO schedule) { var request = ProxyRequest("CancelEvent"); request.Data = schedule.ObjToJson(); return(ReadFromProxy(request).JsonToObj <bool>()); }
private string GetTitle(SchedulePO schedule) { var note = Notes.FindLast(o => o.ScheduleId == schedule.Id); return(note != null ? note.Notes :string.IsNullOrEmpty(schedule.ScheduleTitle)?Utility.DataCache.Project.GetProjectName(schedule.ProjectId):schedule.ScheduleTitle); }
private string GetClass(SchedulePO schedule) { var css = ""; var project = Projects.FindLast(o => o.Id == schedule.ProjectId); if (project != null) { var style = Styles.FindLast(o => o.Id == project.DataStyleId); if (style != null) { css = "klds_" + style.Id; } } return(css); }
public SchedulePO UpdateSchedules(SchedulePO schedule) { return(schedule); }
public SchedulePO CreateSchedules(SchedulePO schedule) { return(schedule); }
public static AccountPO SaveAccount( ChannelPO channel, AccountPO account, AccountAvatarsPO avatar, List <AccountContactsPO> contacts, List <AccountMessagesPO> messages, List <SchedulePO> schedules ) { var now = DateTime.Now; var trans = new Transaction(); try { trans.Begin(); #region DBOP var bllAccount = new DB.Agent.MssqlHelper <AccountPO>(); var bllAccountAvatars = new DB.Agent.MssqlHelper <AccountAvatarsPO>(); var bllAccountContacts = new DB.Agent.MssqlHelper <AccountContactsPO>(); var bllAccountMessages = new DB.Agent.MssqlHelper <AccountMessagesPO>(); var bllProject = new DB.Agent.MssqlHelper <ProjectPO>(); var bllSchedule = new DB.Agent.MssqlHelper <SchedulePO>(); #region avatar and account var condition = account == null ? string.Format("ChannelId={0} AND ChannelIdentity='{1}'", avatar.ChannelId, avatar.ChannelIdentity) : string.Format("ChannelId={0} AND ChannelIdentity='{1}' AND AccountId={2}", avatar.ChannelId, avatar.ChannelIdentity, account.Id); var avatarExists = bllAccountAvatars.FindSingle(condition, trans.DbConnection, trans.DbTrans); if (avatarExists == null) { if (account == null) { account = new DB.Entity.Base.AccountPO { NickName = avatar.DisplayName, Valid = true, UpdateTime = now, CreateTime = now, LastSignin = now, MobileVerifyTime = now, EmailVerifyTime = now }; Logger.Debug(account.SerializeXml()); account = bllAccount.Insert(account, trans.DbConnection, trans.DbTrans); } avatarExists = new AccountAvatarsPO { ChannelId = avatar.ChannelId, ChannelIdentity = avatar.ChannelIdentity, DisplayName = avatar.DisplayName, Code = avatar.Code, Token = avatar.Token, TokenGenerated = avatar.TokenGenerated, TokenExpires = avatar.TokenExpires, UpdateTime = avatar.UpdateTime, RefreshToken = avatar.RefreshToken, AccountId = account.Id, Valid = true, CreateTime = now, SynchroTime = now, SynchroDuration = 600 }; avatarExists.UpdateTime = now; Logger.Debug(avatarExists.SerializeXml()); avatar = bllAccountAvatars.Insert(avatarExists, trans.DbConnection, trans.DbTrans); } else { avatar.Id = avatarExists.Id; avatar.AccountId = avatarExists.AccountId; avatar.Valid = avatarExists.Valid; avatar.CreateTime = avatarExists.CreateTime; avatar.UpdateTime = now; avatar.SynchroTime = now; if (avatar.SynchroDuration == 0) { avatar.SynchroDuration = 600; } Logger.Info(avatar.SerializeXml()); bllAccountAvatars.Update(avatarExists, avatar, trans.DbConnection, trans.DbTrans); account = bllAccount.FindById(avatar.AccountId, trans.DbConnection, trans.DbTrans); } Utility.DataCache.AccountAvatars.InitCache(account.Id); #endregion Logger.Debug("REFRESH ACCOUNT CACHE"); var all = Refresh(account); #region contacts if (contacts != null && contacts.Any()) { Logger.Debug("SAVE CONTACTS"); foreach (var a in contacts) { var a0 = all.Contacts.FindLast( o => o.ChannelId == a.ChannelId && o.ChannelIdentity == a.ChannelIdentity && o.AccountId == account.Id); if (a0 == null) { a0 = new AccountContactsPO { AccountId = account.Id, ChannelId = a.ChannelId, ChannelIdentity = a.ChannelIdentity, DisplayName = a.DisplayName, Detail = a.Detail, CreateTime = now, Valid = true, UpdateTime = now }; a0 = bllAccountContacts.Insert(a0, trans.DbConnection, trans.DbTrans); } else { a0.DisplayName = a.DisplayName; a0.Detail = a.Detail; a0.UpdateTime = now; bllAccountContacts.Update(a, a0, trans.DbConnection, trans.DbTrans); } } Utility.DataCache.AccountContacts.InitCache(account.Id); } #endregion #region messages if (messages != null && messages.Any()) { Logger.Debug("SAVE MESSAGES"); foreach (var b in messages) { var b0 = all.Messages.FindLast( o => o.ChannelId == b.ChannelId && o.ChannelIdentity == b.ChannelIdentity && o.ToAccountId == account.Id); if (b0 == null) { b0 = new AccountMessagesPO { ToAccountId = account.Id, ChannelId = b.ChannelId, ChannelIdentity = b.ChannelIdentity, MessageType = b.MessageType, MessageSubject = b.MessageSubject, MessageContent = b.MessageContent, CreateTime = b.CreateTime, Valid = true, Weblink = b.Weblink, UpdateTime = now }; b0 = bllAccountMessages.Insert(b0, trans.DbConnection, trans.DbTrans); } else { b0.MessageType = b.MessageType; b0.MessageSubject = b.MessageSubject; b0.MessageContent = b.MessageContent; b0.Weblink = b.Weblink; b0.UpdateTime = now; b0.CreateTime = b.CreateTime; bllAccountMessages.Update(b, b0, trans.DbConnection, trans.DbTrans); } } Utility.DataCache.AccountMessages.InitCache(account.Id); } #endregion #region p&s if (schedules != null && schedules.Any()) { Logger.Debug("SAVE SCHEDULES"); var projectCode = avatar.Code + "." + account.Id + "." + channel.Id; var projectExists = Utility.DataCache.Project.CacheList().FindLast(o => o.ChannelId == channel.Id && o.CreatorAccountId == account.Id && o.ProjectCode == projectCode); var projectSchedules = new List <SchedulePO>(); if (projectExists == null) { projectExists = new ProjectPO { ProjectCode = projectCode, Valid = true, CreateTime = now, UpdateTime = now, ProjectName = avatar.DisplayName + "@" + channel.ChannelName, ChannelId = channel.Id, CreatorAccountId = account.Id, EnterDeadline = now }; Logger.Debug(projectExists.SerializeXml()); projectExists = bllProject.Insert(projectExists, trans.DbConnection, trans.DbTrans); } else { projectSchedules = Utility.DataCache.Schedule.CacheList(projectExists.Id); } Utility.DataCache.Project.InitCache(); foreach (var c in schedules) { var c0 = projectSchedules.FindLast( o => o.ProjectId == projectExists.Id && o.ScheduleIdentity == c.ScheduleIdentity); if (c0 == null) { c0 = new SchedulePO { ProjectId = projectExists.Id, ScheduleIdentity = c.ScheduleIdentity, Cycle = c.Cycle, ScheduleTitle = c.ScheduleTitle, ScheduleLead = c.ScheduleLead, BeginDate = c.BeginDate, BeginTime = c.BeginTime, EndDate = c.EndDate, EndTime = c.EndTime, Weblink = c.Weblink, CreateTime = now, Valid = true, UpdateTime = now }; c0 = bllSchedule.Insert(c0, trans.DbConnection, trans.DbTrans); } else { c0.Cycle = c.Cycle; c0.ScheduleTitle = c.ScheduleTitle; c0.ScheduleLead = c.ScheduleLead; c0.BeginDate = c.BeginDate; c0.BeginTime = c.BeginTime; c0.EndDate = c.EndDate; c0.EndTime = c.EndTime; c0.Weblink = c.Weblink; c0.UpdateTime = now; bllSchedule.Update(c, c0, trans.DbConnection, trans.DbTrans); } } Utility.DataCache.Schedule.InitCache(projectExists.Id); } #endregion #endregion trans.Commit(); Logger.Info("处理完结"); } catch (Exception ex) { trans.RollBack(); Logger.Error(ex); } finally { trans.Dispose(); } return(account); }
private List <TimeDuration> GetDurations(SchedulePO schedule) { var subscribe = Subscribes.FindLast(o => o.ProjectId == schedule.ProjectId); var planStart = subscribe == null ? DateTime.Now : subscribe.CreateTime; var planEnd = planStart.AddYears(1); var data = new List <TimeDuration>(); switch (schedule.Cycle) { case 0: //一次 data.Add(new TimeDuration { Begin = new DateTime( schedule.BeginDate.Year, schedule.BeginDate.Month, schedule.BeginDate.Day, schedule.BeginTime.Hour, schedule.BeginTime.Minute, schedule.BeginTime.Second ), End = new DateTime( schedule.EndDate.Year, schedule.EndDate.Month, schedule.EndDate.Day, schedule.EndTime.Hour, schedule.EndTime.Minute, schedule.EndTime.Second ) }); break; case 1: //每天 var currentDay1 = planStart; while (currentDay1 <= planEnd) { data.Add(new TimeDuration { Begin = new DateTime( currentDay1.Year, currentDay1.Month, currentDay1.Day, schedule.BeginTime.Hour, schedule.BeginTime.Minute, schedule.BeginTime.Second ), End = new DateTime( currentDay1.Year, currentDay1.Month, currentDay1.Day, schedule.EndTime.Hour, schedule.EndTime.Minute, schedule.EndTime.Second ) }); currentDay1 = currentDay1.AddDays(1); } break; case 2: var currentDay2 = planStart; while (currentDay2 <= planEnd) { var appendDay2 = false; var d2 = new TimeDuration(); if ((int)currentDay2.DayOfWeek == schedule.BeginDay) { d2.Begin = new DateTime( currentDay2.Year, currentDay2.Month, currentDay2.Day, schedule.BeginTime.Hour, schedule.BeginTime.Minute, schedule.BeginTime.Second ); } if ((int)currentDay2.DayOfWeek == schedule.EndDay) { appendDay2 = true; d2.End = new DateTime( currentDay2.Year, currentDay2.Month, currentDay2.Day, schedule.EndTime.Hour, schedule.EndTime.Minute, schedule.EndTime.Second ); } currentDay2 = currentDay2.AddDays(1); if (appendDay2) { data.Add(d2); } } break; case 3: var currentDay3 = planStart; while (currentDay3 <= planEnd) { var appendDay3 = false; var d3 = new TimeDuration(); if (currentDay3.Day % 10 == schedule.BeginDay) { d3.Begin = new DateTime( currentDay3.Year, currentDay3.Month, currentDay3.Day, schedule.BeginTime.Hour, schedule.BeginTime.Minute, schedule.BeginTime.Second ); } if (currentDay3.Day % 10 == schedule.EndDay) { appendDay3 = true; d3.End = new DateTime( currentDay3.Year, currentDay3.Month, currentDay3.Day, schedule.EndTime.Hour, schedule.EndTime.Minute, schedule.EndTime.Second ); } currentDay3 = currentDay3.AddDays(1); if (appendDay3) { data.Add(d3); } } break; case 4: var currentDay4 = planStart; while (currentDay4 <= planEnd) { var appendDay4 = false; var d4 = new TimeDuration(); if (currentDay4.Day % 15 == schedule.BeginDay) { d4.Begin = new DateTime( currentDay4.Year, currentDay4.Month, currentDay4.Day, schedule.BeginTime.Hour, schedule.BeginTime.Minute, schedule.BeginTime.Second ); } if (currentDay4.Day % 15 == schedule.EndDay) { appendDay4 = true; d4.End = new DateTime( currentDay4.Year, currentDay4.Month, currentDay4.Day, schedule.EndTime.Hour, schedule.EndTime.Minute, schedule.EndTime.Second ); } currentDay4 = currentDay4.AddDays(1); if (appendDay4) { data.Add(d4); } } break; case 5: var currentDay5 = planStart; while (currentDay5 <= planEnd) { var appendDay5 = false; var d5 = new TimeDuration(); if (currentDay5.Day == schedule.BeginDay) { d5.Begin = new DateTime( currentDay5.Year, currentDay5.Month, currentDay5.Day, schedule.BeginTime.Hour, schedule.BeginTime.Minute, schedule.BeginTime.Second ); } if (currentDay5.Day == schedule.EndDay) { appendDay5 = true; d5.End = new DateTime( currentDay5.Year, currentDay5.Month, currentDay5.Day, schedule.EndTime.Hour, schedule.EndTime.Minute, schedule.EndTime.Second ); } currentDay5 = currentDay5.AddDays(1); if (appendDay5) { data.Add(d5); } } break; case 6: var currentDay6 = planStart; while (currentDay6 <= planEnd) { var appendDay6 = false; var d6 = new TimeDuration(); if (currentDay6.DayOfYear == schedule.BeginDay) { d6.Begin = new DateTime( currentDay6.Year, currentDay6.Month, currentDay6.Day, schedule.BeginTime.Hour, schedule.BeginTime.Minute, schedule.BeginTime.Second ); } if (currentDay6.DayOfYear == schedule.EndDay) { appendDay6 = true; d6.End = new DateTime( currentDay6.Year, currentDay6.Month, currentDay6.Day, schedule.EndTime.Hour, schedule.EndTime.Minute, schedule.EndTime.Second ); } currentDay6 = currentDay6.AddDays(1); if (appendDay6) { data.Add(d6); } } break; } return(data); }