public async Task DownloadAllFiles(string startFile = null) { TwilioService twilioService = new TwilioService(); bool isStarted = false; string lastFile = ""; using (var context = new CovidContext()) { List<DataCollectionStatistic> startFileStat = await context.DataCollectionStatistics.ToListAsync(); lastFile = startFileStat?.Last()?.FileName; } if (string.IsNullOrWhiteSpace(startFile) && string.IsNullOrWhiteSpace(lastFile)) { isStarted = true; } List<DataFile> files = new List<DataFile>(); files = await GetListOfFiles("CSSEGISandData", "COVID-19", "csse_covid_19_data/csse_covid_19_daily_reports"); foreach (DataFile file in files) { if (file.FileName == startFile) { isStarted = true; } if (isStarted == true) { DateTime startTime = DateTime.Now; await ParseAndDeleteFile(file); await SaveEntriesToDataModel(file.FileName); DateTime fileComplete = DateTime.Now; var elapsed = fileComplete - startTime; twilioService.SendSMS($"COVIDAP -> File {file.FileName}. Records:{Entries.Count} Completed in {elapsed.Minutes}:{elapsed.Seconds}"); Entries.Clear(); } if (file.FileName == lastFile) { isStarted = true; } } twilioService.SendSMS("COVIDAP -> SUCCESS - UP TO DATE"); }
public EntityResponse <UserDto> AsAGift(int userId, List <UserDto> model) { UserDto me = null; foreach (var item in model) { if (!this.IsPremiumUser(item.PhoneNumber)) { me = this.GetUser(userId); if (me.GiftCount > me.GiftPendingCount) { var prms = new Dictionary <string, SqlParam>(); prms.Add("@UserId", new SqlParam() { Direction = System.Data.ParameterDirection.Input, SqlType = System.Data.SqlDbType.Int, Value = userId }); prms.Add("@PhoneNumber", new SqlParam() { Direction = System.Data.ParameterDirection.Input, SqlType = System.Data.SqlDbType.NVarChar, Value = item.PhoneNumber }); var result = _baseService.ExecuteNonQuery("sp_AsAGift", prms); if (result != 0) { TwilioService.SendSMS(new TwilioDto { Content = me.FirstName + " " + me.LastName + " adlı arkadaşınız size 7TP Deprem Erken Uyarı Sistemini hediye etti. Uygulamayı indirmek için http://7tpbilisim.com/store/ adresine gidebilirsiniz.", PhoneNumber = "+9" + item.PhoneNumber }); } } } } return(new EntityResponse <UserDto>() { ResponseCode = ResponseCodes.Successful, EntityData = me }); }
public PrimitiveResponse SendSms(List <TwilioDto> model) { PrimitiveResponse primitiveResult = null; try { foreach (var item in model) { item.PhoneNumber = "+9" + item.PhoneNumber; TwilioService.SendSMS(item); } primitiveResult = new PrimitiveResponse() { ResponseCode = ResponseCodes.Successful, ResponseMessage = "Send Sms Success." }; } catch (Exception ex) { primitiveResult = new PrimitiveResponse() { ResponseCode = ResponseCodes.ServiceError, ResponseMessage = ex.Message }; } return(primitiveResult); }
public PrimitiveResponse AddFriendsToGroup(int groupId, List <UserDto> model) { UserDto me = this.GetUser(groupId); PrimitiveResponse primitiveResult = null; int groupCount = this.GetGroupCount(groupId); if (groupCount == 0) { primitiveResult = new PrimitiveResponse() { ResponseCode = ResponseCodes.InsertNotCompleted, ResponseMessage = groupId + " Id'li bir grup yok!" }; } else if (model.Where(x => x.PhoneNumber == me.PhoneNumber).ToList().Count != 0) { primitiveResult = new PrimitiveResponse() { ResponseCode = ResponseCodes.InsertNotCompleted, ResponseMessage = "Kişi kendini gruplara ekleyemez!" }; } else { foreach (var item in model) { var prms = new Dictionary <string, SqlParam>(); prms.Add("@GroupId", new SqlParam() { Direction = System.Data.ParameterDirection.Input, SqlType = System.Data.SqlDbType.Int, Value = groupId }); prms.Add("@PhoneNumber", new SqlParam() { Direction = System.Data.ParameterDirection.Input, SqlType = System.Data.SqlDbType.NVarChar, Value = item.PhoneNumber }); var result = _baseService.ExecuteNonQuery("sp_AddFriendsToGroup", prms); TwilioService.SendSMS(new TwilioDto { Content = me.FirstName + " " + me.LastName + " adlı arkadaşınız sizi 7TP Deprem Erken Uyarı Sistemine davet ediyor. Uygulamayı indirmek için http://7tpbilisim.com/store/ adresine gidebilirsiniz.", PhoneNumber = "+9" + item.PhoneNumber }); } primitiveResult = new PrimitiveResponse() { ResponseCode = ResponseCodes.Successful, ResponseMessage = "Insert successfully." }; } return(primitiveResult); }