Exemple #1
0
        private void loadUserFileAndCheckGUID(Action action, IMyLog log)
        {
            string email = Data_AppUserFile.API_IdToEmail(m_RequId);

            if (email == null)
            {
                throw new ArgumentException("X-APIId unknown");
            }
            DSSwitch.appUser().Update_General(email, delegate(Data_AppUserFile user, Object args)
            {
                m_User = user;
                if (m_User == null)
                {
                    throw new ArgumentException("X-APIId unknown");
                }
                if (!m_User.IsAccountActive(m_Message))
                {
                    throw new ArgumentException("Account not active (1). " + m_User.AccountStatusExplained());
                }
                if (m_User.ApiGuId != m_RequId)
                {
                    throw new ArgumentException("X-APIId unknown");
                }
                action();
            }, null, null, log);
        }
Exemple #2
0
        public static void EmailFromAPpiKey(IMyLog log, QuestionOption it)
        {
            var    key   = Question.Ask("Enter API Key");
            string email = Data_AppUserFile.API_IdToEmail(key);

            email = Data_AppUserFile.EmailToRealEmail(email);
            Console.WriteLine(key);
            Console.WriteLine(email);
            Console.WriteLine("");
        }
Exemple #3
0
 private void Init(string data, bool dataIsEmail)
 {
     if (dataIsEmail)
     {
         this.Email = data;
         this.APIId = null;
     }
     else
     {
         this.Email = Data_AppUserFile.API_IdToEmail(data);
         this.APIId = data;
     }
 }
Exemple #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // This comes from the AdminTool

        try
        {
            Response.ContentType = "text/plain";
            string XAPIId = Request.Headers["X-APIId"];
            string email_ = Data_AppUserFile.API_IdToEmail(XAPIId);
            string email  = Data_AppUserFile.EmailToRealEmail(email_);

            Data_AppUserFile user = DSSwitch.appUser().RetrieveOne(email, MyLog.GetLogger("APICredit"));

            switch (user.AccountStatus)
            {
            case Data_AppUserFile.eUserStatus.commercial_monthly:
                Response.Write(user.MonthlyAccount.monthly_CurrentCredit.ToString());
                break;

            case Data_AppUserFile.eUserStatus.commercial_payassent:
                Response.Write(user.PayAsSentAccount.payAsSent_CurrentCredit.ToString());
                break;

            case Data_AppUserFile.eUserStatus.commercial_monthlyDifPrice:
                Response.Write(user.MonthlyDifPriceAccount.monthlyDifPrice_CurrentCredit.ToString());
                break;

            case Data_AppUserFile.eUserStatus.commercial_systemDuplication:
                Response.Write(user.SystemDuplicationAccount.systemDuplication_PaidUntil.ToUkTime(false));
                break;

            default:
                Response.Write(Data_AppUserFile.GetNiceStatusText(user.AccountStatus));
                break;
            }
        }
        catch (Exception)
        {
            Response.ContentType = "text/plain";
            Response.Write("Fehler");
        }
    }
Exemple #5
0
        public string SendWhatsApp(NiceSystemInfo niceSystem, string XAPIMobile, string Message, bool isWelcomeMessage, IMyLog log, out string fileName)
        {
            fileName = "";
            string[] requTelList    = null;
            string   cleanMessage   = null;
            bool     sendFooter     = true;
            bool     deleteOnFailed = false;

            try
            {
                timeNow = DateTime.UtcNow;
                // 1 extract (check) input data
                #region 1 extract (check) input data
                if (string.IsNullOrEmpty(APIId))
                {
                    throw new ArgumentException("X-APIId missing");
                }

                if (string.IsNullOrEmpty(XAPIMobile))
                {
                    throw new ArgumentException("X-APIMobile missing");
                }

                requTelList = XAPIMobile.Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < requTelList.Length; i++)
                {
                    requTelList[i] = "+" + requTelList[i];
                }

                cleanMessage = Message.Replace(":SE", ":  SE").Replace(": SE", ":  SE");
                if (string.IsNullOrEmpty(cleanMessage))
                {
                    throw new ArgumentException("No POST data");
                }
                #endregion

                // 2 load user file and check guid
                #region 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.IsAccountActive(cleanMessage))
                    {
                        throw new ArgumentException("Account not active (7). " + user.AccountStatusExplained());
                    }
                    if (user.ApiGuId != APIId)
                    {
                        throw new ArgumentException("X-APIId unknown");
                    }
                    #endregion

                    // 3 action
                    user.CommitOrThrow_Send(requTelList, isWelcomeMessage, cleanMessage.Length, ref user.AccountStatus, out sendFooter);
                    deleteOnFailed = user.DeleteOnFailed;
                }, null, null, log);

                // 5) createMessageFile
                bool noCounterUpdate = false;
                if (Message.StartsWith("__NoSend"))
                {
                    noCounterUpdate = true;
                }
                else if (Message == "Welcome\r\n")
                {
                    noCounterUpdate = true;
                }
                else if (Message == "Welcome to NiceApi.net\r\n")
                {
                    noCounterUpdate = true;
                }

                int telNoId = 0;
                foreach (string tel1 in requTelList)
                {
                    fileName +=
                        createMessageFile(
                            niceSystem,
                            telNoId,
                            requTelList[telNoId],
                            cleanMessage,
                            email,
                            timeNow,
                            log,
                            noCounterUpdate,
                            sendFooter,
                            deleteOnFailed ?
                            1 : -1) + ", ";
                    // move on
                    telNoId++;
                }

                if (telNoId == 1)
                {
                    return("queued");
                }
                else
                {
                    return("queued x" + telNoId.ToString());
                }
            }
            catch (ArgumentException ae)
            {
                return(ae.Message);
            }
        }
Exemple #6
0
        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());
        }