public FileContentResult GetWxCode(string scene, string page = "pages/logs/main") { ActivityInfoService activityInfoService = new ActivityInfoService(); byte[] resq = null; try { resq = activityInfoService.GetWxCode(scene, page); } catch (Exception ex) { return(new FileContentResult(new byte[0], "image/jpeg")); } //dynamic type = (new Program()).GetType(); //string baseurl = System.IO.Path.GetDirectoryName(type.Assembly.Location); //var addrUrl = baseurl + "/qrcode.jpg"; //System.IO.FileStream fs = new System.IO.FileStream(addrUrl, System.IO.FileMode.Open); if (resq != null && resq.Length > 0) { return(new FileContentResult(resq, "image/jpeg")); } else { return(new FileContentResult(new byte[0], "image/jpeg")); } }
public ResultBase GetH5Signature(string code = "", string url = "https://activity.topcn.xin/index.html") { ActivityInfoService activityInfoService = new ActivityInfoService(); H5Sign resq = new H5Sign(); try { if (!_memoryCache.TryGetValue("Cache_H5Ticket", out string ticket)) { ticket = activityInfoService.GetH5Ticket(code); _memoryCache.Set("Cache_H5Ticket", ticket, DateTimeOffset.Now.AddHours(1.5)); } if (Request.Headers.TryGetValue("Referer", out StringValues value) && value.Count > 0) { resq.url = value[0]; } else { resq.url = url; } Console.WriteLine("SignRequestUrl:" + resq.url); resq.AppId = "wx3283d85d64449029"; resq.Signature = activityInfoService.Sign(ticket, resq); } catch (Exception ex) { return(new ResultBase { IsSuccess = false, Code = CodeConstant.ServerError, Message = ex.Message + ex.StackTrace }); } if (resq != null && !string.IsNullOrEmpty(resq.Signature)) { return(new ResultBase { IsSuccess = true, Code = CodeConstant.Success, Data = resq }); } else { return(new ResultBase { IsSuccess = false, Code = CodeConstant.DataNull }); } }
//Alle Informationen zu einem Termin /// <summary> /// Abfrage aller Informationen eines Termins /// </summary> /// <param name="DateId">Id des Termins</param> /// <returns>Informationen zu einem bestimmten Termin</returns> public DateInfoResponse GetDateById(string DateId) { var activityService = new ActivityInfoService(); var activity = activityService.GetDateInfo(DateId); var response = new DateInfoResponse { DateInfo = activity, }; return(response); }
private void DatabaseForm_Load(object sender, EventArgs e) { LoginForm loginForm = new LoginForm(); loginForm.ShowDialog(this); if (loginForm.Service == null) { return; } this.service = loginForm.Service; this.localDb = new LocalDb(service); }
//Alle eigenen Termine in Zeitraum /// <summary> /// Abfrage aller eigenen Termine im gewünschten Zeitraum /// </summary> /// <param name="UserId">Die UserId des Accounts in der Datenbank</param> /// <param name="From">Anfangsdatum des Zeitraums im Format dd.MM.yyyy</param> /// <param name="Until">Enddatum des Zeitraums im Format dd.MM.yyyy</param> /// <returns>Persönlichen Termine für jeden Tag im gewählten Zeitraum</returns> public PersonalPlanResponse GetPersonalDatesSpan(string UserId, string From, string Until) { var From2 = DateTime.ParseExact(From, "MM-dd-yyyy", null); var Until2 = DateTime.ParseExact(Until, "MM-dd-yyyy", null); var activityService = new ActivityInfoService(); var activityList = activityService.GetPersonalDates(UserId, From2, Until2); var response = new PersonalPlanResponse { Courses = activityList, }; return(response); }
public LocalDb(ActivityInfoService service) { this.service = service; var builder = new SQLiteConnectionStringBuilder(); builder.DataSource = Application.UserAppDataPath + "\\ActivityInfo.db"; connection = new SQLiteConnection(builder.ToString()); connection.Open(); executeSQL("create table if not exists sync_regions (id TEXT, localVersion INTEGER)"); executeSQL("create table if not exists sync_history (lastUpdate INTEGER)"); regionEnum = service.GetSyncRegions().List.GetEnumerator(); }
public ResultBase GetLottery([FromBody] GetLotteryInfoReq req) { if (string.IsNullOrEmpty(req.Uid)) { return(new ResultBase { IsSuccess = false, Code = CodeConstant.ClientError_NotFound_Para, }); } ActivityInfoService activityInfoService = new ActivityInfoService(); Tuple <int[], GetLotteryInfoResq> resq = null; try { resq = activityInfoService.GetLottery(req); } catch (Exception ex) { return(new ResultBase { IsSuccess = false, Code = CodeConstant.ServerError, Message = ex.Message + ex.StackTrace }); } if (resq != null && resq.Item1.Count() > 0) { resq.Item2.lotteryIndex = resq.Item1; return(new ResultBase { IsSuccess = true, Code = CodeConstant.Success, Data = resq.Item2 }); } else { return(new ResultBase { IsSuccess = false, Code = CodeConstant.ClientError_TodayCountIsOver }); } }
public ResultBase HelpGetLottery([FromBody] GetLotteryInfoReq req) { if (string.IsNullOrWhiteSpace(req.Uid) || string.IsNullOrWhiteSpace(req.HelperUid)) { return(new ResultBase { IsSuccess = false, Code = CodeConstant.ClientError_NotFound_Para }); } ActivityInfoService activityInfoService = new ActivityInfoService(); Tuple <bool, int[], GetLotteryInfoResq> resq = new Tuple <bool, int[], GetLotteryInfoResq>(false, new int[] { -1 }, null); try { resq = activityInfoService.HelpGetLottery(req); } catch (Exception ex) { return(new ResultBase { IsSuccess = false, Code = CodeConstant.ServerError, Message = ex.Message + ex.StackTrace }); } if (resq.Item1) { resq.Item3.lotteryIndex = resq.Item2; return(new ResultBase { IsSuccess = true, Code = CodeConstant.Success, Data = resq.Item3 }); } else { return(new ResultBase { IsSuccess = false, Code = CodeConstant.ClientError_TodayCountIsOver }); } }
public ResultBase GetLotteryInfo([FromBody] GetLotteryInfoReq req) { if (string.IsNullOrEmpty(req.Uid)) { return(new ResultBase { IsSuccess = false, Code = CodeConstant.ClientError_NotFound_Para, }); } ActivityInfoService activityInfoService = new ActivityInfoService(); GetLotteryInfoResq resq = new GetLotteryInfoResq(); try { resq = activityInfoService.GetLotteryInfo(req); } catch (Exception ex) { return(new ResultBase { IsSuccess = false, Code = CodeConstant.ServerError, Message = ex.Message + ex.StackTrace }); } if (resq != null) { return(new ResultBase { IsSuccess = true, Code = CodeConstant.Success, Data = resq }); } else { return(new ResultBase { IsSuccess = false, Code = CodeConstant.DataNull }); } }
public ResultBase OpenBox([FromBody] GetLotteryInfoReq req) { if (string.IsNullOrWhiteSpace(req.Uid)) { return(new ResultBase { IsSuccess = false, Code = CodeConstant.ClientError_NotFound_Para }); } ActivityInfoService activityInfoService = new ActivityInfoService(); bool resq = false; try { resq = activityInfoService.GetBox(req); } catch (Exception ex) { return(new ResultBase { IsSuccess = false, Code = CodeConstant.ServerError, Message = ex.Message + ex.StackTrace }); } if (resq) { return(new ResultBase { IsSuccess = true, Code = CodeConstant.Success, }); } else { return(new ResultBase { IsSuccess = false, Code = CodeConstant.ClientError_CountIsNotEnough }); } }
private void okButton_Click(object sender, EventArgs e) { try { String serverUrl = serverCombo.Text; if (!serverUrl.EndsWith("/")) { serverUrl += "/"; } service = new ActivityInfoService(serverUrl, emailTextBox.Text, passwordTextBox.Text); Application.UserAppDataRegistry.SetValue("Server", serverUrl); Application.UserAppDataRegistry.SetValue("Email", emailTextBox.Text); Application.UserAppDataRegistry.SetValue("Password", passwordTextBox.Text); this.Hide(); } catch (AuthenticationException) { MessageBox.Show(this, "Invalid Login"); } }
public ResultBase GetH5UserInfo(string code) { ActivityInfoService activityInfoService = new ActivityInfoService(); H5UserInfo resq = null; try { resq = activityInfoService.GetH5UserInfo(code); } catch (Exception ex) { return(new ResultBase { IsSuccess = false, Code = CodeConstant.ServerError, Message = ex.Message + ex.StackTrace }); } if (resq != null && !string.IsNullOrEmpty(resq.openid)) { return(new ResultBase { IsSuccess = true, Code = CodeConstant.Success, Data = resq }); } else { return(new ResultBase { IsSuccess = false, Code = CodeConstant.DataNull }); } }
//VorlesungsAPI /// <summary> /// Abfrage des persönlichen Stundenplans für eine Woche /// </summary> /// <param name="UserId">Die UserId des Accounts in der Datenbank</param> /// <returns>Liste nach Wochentagen mit den persönlichen/gebuchten Kursterminen</returns> public PersonalPlanResponse GetPersonalDates(string UserId) { //Da hier Abfrage der persönlichen Termine nur für kommende Woche, Festlegung der Variablen des Zeitraums //Alle eigenen Termine von jetzt bis zur nächsten Woche var from = DateTime.Now; var until = from.AddDays(7); var userService = new UserInfoService(); var user = userService.GetUser(UserId); if (user != null && user.UserName.Equals("*****@*****.**")) { // Demodaten var dateList = new List <OwnDatesContract>(); var courseList = new List <DateContract>(); var roomList = new List <DateRoomContract>(); var lecturerList = new List <DateLecturerContract>(); var demoRoom = new DateRoomContract { RoomId = Guid.NewGuid().ToString(), RoomNumber = "R 1.083" }; roomList.Add(demoRoom); var demoLecturer = new DateLecturerContract { LecturerId = Guid.NewGuid().ToString(), LecturerName = "Demo Dozent" }; lecturerList.Add(demoLecturer); var demoCourse = new DateContract { StartTime = "10:00", EndTime = "11:30", IsCanceled = false, Titel = "Demovorlesung", Rooms = roomList, Lecturers = lecturerList }; courseList.Add(demoCourse); var today = DateTime.Today; var demoDate = new OwnDatesContract { StatedDate = today.ToString("dd.MM.yyyy"), InfoString = null, Dates = courseList }; dateList.Add(demoDate); var date = today; var endOfWeek = today.AddDays(7); while (date <= endOfWeek) { demoDate = new OwnDatesContract { StatedDate = date.ToString("dd.MM.yyyy"), InfoString = null, Dates = new List <DateContract>() }; dateList.Add(demoDate); date = date.AddDays(1); } var demoResponse = new PersonalPlanResponse { Courses = dateList, }; //Rückgabe der Response return(demoResponse); } //Initialisierung des ActivityInfoService var activityService = new ActivityInfoService(); //Abfrage der persönlichen Termine mit Hilfe des ActivityInfoService und den Parametern var activityList = activityService.GetPersonalDates(UserId, from, until); //Erstellen des Response mit Hilfe der activityList var response = new PersonalPlanResponse { Courses = activityList, }; //Rückgabe der Response return(response); }
private void cancelButton_Click(object sender, EventArgs e) { service = null; this.Hide(); }