Exemple #1
0
        public ServiceResults DoService(string[] inputData)
        {
            var output = new ServiceResults();

            output.Result.Add("MESSAGE", string.Empty);

            if (inputData.Length == 3)
            {
                try
                {
                    Account registeredAccount = dbAccessor.AddAccount(inputData[0], inputData[1], inputData[2]);
                    Random  rnd    = new Random();
                    string  authNo = rnd.Next(10000).ToString("D4");
                    string  msg    = "\n認証番号:" + authNo;

                    bool MessageWasSent = lineMessenger.SendMessage(registeredAccount.access_token, msg);

                    if (MessageWasSent)
                    {
                        logger.Log("認証番号送信成功", inputData[0]);
                        output.Result["MESSAGE"] = Messages.PM03;
                        output.Result.Add("AUTHNO", authNo);
                        output.IsSuccessed = true;
                        return(output);
                    }
                    else
                    {
                        logger.Log("認証番号送信失敗", inputData[0]);
                        dbAccessor.DeleteAccount(inputData[0]);
                        output.Result["MESSAGE"] = Messages.EM04;
                        return(output);
                    }
                }
                catch (Exception e)
                {
                    if (!string.IsNullOrEmpty(e.InnerException.ToString()))
                    {
                        List <string> innerException = e.InnerException.ToString().Split("\'").ToList();
                        //IDが重複している場合
                        if (innerException.Any(x => x == @"PRIMARY"))
                        {
                            output.Result["MESSAGE"] = Messages.EM03a;
                            return(output);
                        }
                        //アクセストークンが重複している場合
                        if (innerException.Any(x => x == @"access_token"))
                        {
                            output.Result["MESSAGE"] = Messages.EM03b;
                            return(output);
                        }
                    }
                    logger.Log("データベース未接続", inputData[0]);
                    output.Result["MESSAGE"] = Messages.EM01;
                    return(output);
                }
            }
            logger.Log("登録サービスへの入力データが不正", inputData[0]);
            output.Result["MESSAGE"] = Messages.EM10;
            return(output);
        }
Exemple #2
0
        public ServiceResults DoService(string[] inputData)
        {
            var output = new ServiceResults();

            output.Result.Add("MESSAGE", string.Empty);

            if (inputData.Length == 2)
            {
                try
                {
                    if (dbAccessor.IsVerified(inputData[0], inputData[1]))
                    {
                        logger.Log("パスワード照合成功", inputData[0]);
                        dbAccessor.DeleteAccount(inputData[0]);
                        logger.Log("通知先登録解除完了", inputData[0]);
                        output.Result["MESSAGE"] = Messages.PM02;
                        output.IsSuccessed       = true;
                    }
                    else
                    {
                        logger.Log("パスワード照合失敗", inputData[0]);
                        output.Result["MESSAGE"] = Messages.EM06;
                    }
                    return(output);
                }
                catch
                {
                    logger.Log("データベース未接続", inputData[0]);
                    output.Result["MESSAGE"] = Messages.EM01;
                    return(output);
                }
            }
            logger.Log("登録解除サービスへの入力データが不正", inputData[0]);
            output.Result["MESSAGE"] = Messages.EM10;
            return(output);
        }