public static NiceSystemInfo GetSystemInfoFromTrayType(this string trayType) { // use null if not there NiceSystemInfo ret = DSSwitch.full().GetSystems(false).FirstOrDefault(_ => _.Name == trayType); return(ret); }
public static NiceSystemInfo GetSystemInfoFromAPIId(this string apiId) { // use Default if not there NiceSystemInfo ret = DSSwitch.full().GetSystems(false).FirstOrDefault(_ => _.APIId == apiId); if (ret == null) { return(NiceSystemInfo.DEFAULT); } return(ret); }
public string Process_Registration_JustVerified(NiceSystemInfo niceSystem, out bool ok, bool sendAdminNotification, bool sendAdminNotificationToWhatsapp, IMyLog log, LogForEmailSend log4Email) { StringBuilder sbInfo = new StringBuilder(); string telToCheck = null; ok = false; string friendlyEmail = null; bool okIntern = false; try { timeNow = DateTime.UtcNow; // 1 extract (check) input data if (string.IsNullOrEmpty(APIId)) { throw new ArgumentException("X-APIId missing"); } // 2 load user file and check guid string email = Data_AppUserFile.API_IdToEmail(APIId); if (email == null) { throw new ArgumentException("X-APIId unknown"); } DSSwitch.appUser().Update_General(email, delegate(Data_AppUserFile user, Object args) { if (user == null) { throw new ArgumentException("X-APIId unknown"); } if (user.ApiGuId != APIId) { throw new ArgumentException("X-APIId unknown"); } if (user.AccountStatus != Data_AppUserFile.eUserStatus.email_sent_for_verification) { throw new ArgumentException("AccountStatus is wrong"); } // 3 action, produce telCheck file and update AccountStatus user.AccountStatus = Data_AppUserFile.eUserStatus.verified_checkingTelNumbers; telToCheck = user.MobileNumbers_AllConfirmed__.getVal + user.MobileNumbers_AllUnConfirmed__.getVal; friendlyEmail = user.Email; okIntern = true; }, null, delegate(Object args) { // post process if (log != null) { log.Info(friendlyEmail + " just verified his email"); } if (sendAdminNotification) { EMail.SendAdminNotification(friendlyEmail + " just verified his email", log4Email); } if (sendAdminNotificationToWhatsapp) { NotificationInfo notificationInfo = DSSwitch.full().GetNotificationInfo(); NiceSystemInfo notifyToUse = DSSwitch.full().GetSystems(false).FirstOrDefault(s => s.Name == notificationInfo.Name); if (notifyToUse != null) { Data_Net__00NormalMessage msg = new Data_Net__00NormalMessage( Data_AppUserFile.API_IdToEmail(notifyToUse.APIId), "zapi_" + notificationInfo.RxTel, DateTime.UtcNow.Ticks, friendlyEmail + " just verified his email", 0, 10, true); DSSwitch.msgFile00().Store(notifyToUse, msg, Data_Net__00NormalMessage.eLocation.Queued, log); } } Data_Net__04CheckTelNumbers _04 = new Data_Net__04CheckTelNumbers(friendlyEmail, timeNow.Ticks, telToCheck, ""); DSSwitch.msgFile04().Store(niceSystem, _04, log); }, log); } catch (ArgumentException ae) { sbInfo.Append(ae.Message); } catch (Exception) { sbInfo.Append("ERROR"); } ok = okIntern; return(sbInfo.ToString()); }