예제 #1
0
        private void ProcessOutbox()
        {
            UpdateStatus("Start processing for outbox...");
            UpdateStatus(statusSeperator);

            mChrome.GoToUrl("https://www.corrlinks.com/NewMessage.aspx");
            Thread.Sleep(1000);

            messageOut = CheckOutbox();
            int k = 0;

            while (messageOut != null)
            {
                k++;
                SendMessage(messageOut);
                messageOut = CheckOutbox();
                //if(k % 7 == 0)
                ValidateSentMessages();
            }
            UpdateStatus("Message checked out " + k.ToString());

            ValidateSentMessages();
            UpdateStatus(statusSeperator);
            UpdateStatus("Finished processing for sending messages...");
        }
예제 #2
0
 /// <summary>
 /// 输出消息
 /// </summary>
 /// <param name="o"></param>
 /// <param name="type"></param>
 /// <param name="message"></param>
 protected void LogOutEvent(Object sender, LogType type, string message)
 {
     if (MessageOut != null)
     {
         MessageOut.BeginInvoke(sender, new LogOutEventArgs(type, message), new AsyncCallback(CallBackEvent), MessageOut);
     }
 }
예제 #3
0
        private void CopyDirectory(DirectoryInfo source, DirectoryInfo target)
        {
            Directory.CreateDirectory(target.FullName);

            foreach (FileInfo fi in source.GetFiles("*.dll"))
            {
                MessageOut?.Invoke($@"Copying {target.FullName}\{fi.Name}");
                fi.CopyTo(Path.Combine(target.FullName, fi.Name), true);
            }

            foreach (DirectoryInfo diSourceSubDir in source.GetDirectories())
            {
                DirectoryInfo nextTargetSubDir = target.CreateSubdirectory(diSourceSubDir.Name);
                if (!_ignoredDirectories.Contains(diSourceSubDir.FullName))
                {
                    CopyDirectory(diSourceSubDir, nextTargetSubDir);
                }
            }
            foreach (FileInfo fi in source.GetFiles("*.cs"))
            {
                MessageOut?.Invoke($@"Copying {target.FullName}\{fi.Name}");
                fi.CopyTo(Path.Combine(target.FullName, fi.Name), true);
            }

            foreach (DirectoryInfo diSourceSubDir in source.GetDirectories())
            {
                DirectoryInfo nextTargetSubDir = target.CreateSubdirectory(diSourceSubDir.Name);
                if (!_ignoredDirectories.Contains(diSourceSubDir.FullName))
                {
                    CopyDirectory(diSourceSubDir, nextTargetSubDir);
                }
            }
        }
예제 #4
0
        public async void Returns_MessageOut_when_MessageSend()
        {
            MessageOut messageOut = new MessageOut
            {
                ID                  = Guid.NewGuid(),
                Content             = "Message's content",
                SendingUserUsername = ADMIN_USERNAME,
            };

            StatusCode <MessageOut> status         = new StatusCode <MessageOut>(StatusCodes.Status200OK, messageOut);
            Mock <IMessageService>  messageService = new Mock <IMessageService>();

            messageService.Setup(_ => _.SendMessage(It.IsAny <MessagePost>(), It.IsAny <string>()))
            .Returns(Task.FromResult(status));

            MessagesController messagesController = new MessagesController(messageService.Object, UserManagerHelper.GetUserManager(ADMIN_USERNAME));

            messagesController.Authenticate(ADMIN_USERNAME);

            MessagePost messagePost = new MessagePost
            {
                ToUserUsername = ADMIN_USERNAME,
                Content        = "Message's content"
            };

            IActionResult result = await messagesController.SendMessage(messagePost);

            Assert.NotNull(result);
            OkObjectResult okObjectResult = result as OkObjectResult;

            Assert.NotNull(okObjectResult);
            Assert.IsType <MessageOut>(okObjectResult.Value);
        }
예제 #5
0
        private static void ThreadLoop()
        {
            try
            {
                while (!logCancelSource.IsCancellationRequested)
                {
                    string str = logQueue.Take(logCancelSource.Token);

                    if (EnableDebugLog)
                    {
                        Debug.Write(str);
                    }

                    if (EnableConsole)
                    {
                        Console.Write(str);
                    }

                    try
                    {
                        File.AppendAllText(logFileName, str);
                    }
                    catch (Exception)
                    {
                    }

                    MessageOut?.Invoke(null, str);
                }
            }
            catch (OperationCanceledException)
            {
            }
        }
예제 #6
0
 /// <summary>
 /// 事件处理完的回调函数
 /// </summary>
 /// <param name="ar"></param>
 private void CallBackEvent(IAsyncResult ar)
 {
     if (ar.AsyncState is EventHandler <LogOutEventArgs> MessageOut)
     {
         MessageOut.EndInvoke(ar);
     }
 }
예제 #7
0
        private MessageOut CheckOutbox()
        {
            MessageOut msg = new MessageOut();

            WebRequest   request   = null;
            WebResponse  response  = null;
            Stream       resStream = null;
            StreamReader resReader = null;

            try
            {
                string uristring = "http://ddtext.com/corrlinks/outbox.php";
                request   = WebRequest.Create(uristring.Trim());
                response  = request.GetResponse();
                resStream = response.GetResponseStream();
                resReader = new StreamReader(resStream);
                string resstring = resReader.ReadToEnd();

                string trimmed      = resstring.Replace("<pre>", "");
                int    lineBreakPos = trimmed.IndexOf("\n");
                String header       = trimmed.Substring(0, lineBreakPos);
                msg.MESSAGE = trimmed.Substring(lineBreakPos + 1);
                String[] split = header.Split('|');

                try
                {
                    msg.INBOX_ID  = Convert.ToInt32(split[0]);
                    msg.INMATE_ID = Convert.ToInt32(split[1]);
                    msg.SUBJECT   = split[2];
                } catch
                {
                    UpdateStatus("No more messages in outbox");
                    return(null);
                }
                if (split[2] == "")
                {
                    UpdateStatus("Message body is empty");
                }
            }
            catch (Exception ex)
            {
                UpdateStatus("Error while checking outbox");
                return(null);
            }
            finally
            {
                if (resReader != null)
                {
                    resReader.Close();
                }
                if (response != null)
                {
                    response.Close();
                }
            }
            return(msg);
        }
예제 #8
0
        public void Callback(MessageOut msgOut)
        {
            var data    = JsonConvert.DeserializeObject <CallbackData>(msgOut.Data);
            var service = ServiceManager.Resolve(data.ServiceName);

            if (service != null)
            {
                Invoke(service, data.MethodName, data.Args);
            }
        }
예제 #9
0
 public void CopyProjectFiles()
 {
     if (Directory.Exists(_scriptDirectory))
     {
         MessageOut?.Invoke("Cleaning Script Directory...");
         Directory.Delete(_scriptDirectory, true);
     }
     MessageOut?.Invoke("Copying Project Files...");
     CopyDirectory(new DirectoryInfo(_projectDirectory), new DirectoryInfo(_scriptDirectory));
 }
예제 #10
0
        private string[] GenerateReferences(string projectRoot)
        {
            MessageOut?.Invoke("Searching References...");

            var referenceList = new List <string>();

            foreach (var requiredReference in _requiredReferences)
            {
                MessageOut?.Invoke($"Added Required Reference: {requiredReference}");
                referenceList.Add(requiredReference);
            }

            foreach (var projectFile in GetProjectFiles(projectRoot, "cs"))
            {
                MessageOut?.Invoke($"Parsing File References: {projectFile}");
                foreach (var reference in ReadFileReferences(projectFile))
                {
                    if (!referenceList.Contains(reference))
                    {
                        MessageOut?.Invoke($"Found New Reference: {reference}");
                        referenceList.Add(reference);
                    }
                }
                referenceList.Sort();
            }

            foreach (var reference in referenceList.ToArray())
            {
                MessageOut?.Invoke($"Verifying Reference: {reference}");
                if (Assembly.LoadWithPartialName($"{reference}") == null)
                {
                    MessageOut?.Invoke($"Ignoring Reference: {reference}");
                    referenceList.Remove(reference);
                }
                else
                {
                    MessageOut?.Invoke($"Added Reference: {reference}");
                }
            }

            var referenceHeaders = new List <string>();

            foreach (var reference in referenceList)
            {
                referenceHeaders.Add($@"//     <reference>{reference.Replace(_projectDirectory, "")}</reference>");
            }

            foreach (var projectFile in GetProjectFiles(projectRoot, "dll"))
            {
                referenceHeaders.Add($@"//     <reference>{projectFile.Replace($"{_projectDirectory}\\", "")}</reference>");
            }

            return(WrapHeaderContents("references", referenceHeaders.ToArray()));
        }
예제 #11
0
        public bool CreateMessageOut(MessageOut sms)
        {
            if (sms != null)
            {
                _context.Add(sms);
                _context.SaveChanges();
                return(true);
            }

            return(false);
        }
예제 #12
0
        private string[] GenerateFiles(string projectRoot)
        {
            var list = new List <string>();

            foreach (var projectFile in GetProjectFiles(projectRoot, "cs"))
            {
                MessageOut?.Invoke($"Added Project File: {projectFile}");
                list.Add($@"//     <file>{projectFile.Replace($"{_projectDirectory}\\", "")}</file>");
            }

            return(WrapHeaderContents("files", list.ToArray()));
        }
예제 #13
0
        public async Task <bool> UpdateMessageOutAsync(MessageOut sms)
        {
            if (sms != null)
            {
                _context.Update(sms);
                await _context.SaveChangesAsync();

                return(true);
            }

            return(false);
        }
        // Generar los mensajes para el servidor.
        public void generarMensaje()
        {
            VentaDTO            miVenta   = new VentaDTO();
            List <DetalleVenta> miDetalle = generarDetalleVenta();

            miVenta.VentaInfo            = generarVenta();
            miVenta.DetalleVentaInfo     = miDetalle;
            miVenta.DatosFacturacionInfo = generarDatosFacturacion();
            miVenta.DatosFacturacionInfo.CantidadDetalle = miDetalle.Count;
            MessageOut myMsg = MessageOut.create();

            myMsg.setMensaje(miVenta);
        }
예제 #15
0
        public SharpScriptGenerator(string projectDirectory)
        {
            MessageOut?.Invoke("Initializing...");
            _projectDirectory = projectDirectory;
            MessageOut?.Invoke($"Project Directory: {projectDirectory}");
            _scriptDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SharpScript");
            MessageOut?.Invoke($"Output Directory: {_scriptDirectory}");
            _projectScriptFile = Path.Combine(_scriptDirectory, "SharpScript.ps1");
            MessageOut?.Invoke($"Script File: {_scriptDirectory}");
            _projectConfigFile = Path.Combine(_scriptDirectory, "SharpScript.config");
            MessageOut?.Invoke($"Configuration File: {_scriptDirectory}");
            if (!Directory.Exists(_scriptDirectory))
            {
                MessageOut?.Invoke("Creating Script Directory...");
                Directory.CreateDirectory(_scriptDirectory);
            }

            _ignoredFiles = new[]
            {
                Path.Combine(_projectDirectory, "Program.cs")
            };
            _ignoredDirectories = new[]
            {
                Path.Combine(_projectDirectory, "obj"),
                Path.Combine(_projectDirectory, "bin"),
                Path.Combine(_projectDirectory, "Properties")
            };
            _requiredReferences = new[]
            {
                "System.Core",
            };

            MessageOut?.Invoke($"Ignored Files: {_scriptDirectory}");
            MessageOut?.Invoke($"Ignored Directories: {_scriptDirectory}");
            MessageOut?.Invoke($"Required References: {_scriptDirectory}");
        }
예제 #16
0
        public async Task ProcessSubscription()
        {
            try
            {
                // get all new onbaording
                var newOnboard = await _context.MessageIns.Where(x => x.IsProcessed == false).ToListAsync();

                for (int i = 0; i < newOnboard.Count(); i++)
                {
                    using (var transaction = await _context.Database.BeginTransactionAsync(System.Data.IsolationLevel.ReadUncommitted))
                    {
                        // get the tax payer to process
                        string retSms   = "";
                        var    taxpayer = await _taxPayerRepository.GetTaxPayerByPhoneNumberAsync(newOnboard[i].PhoneNo);

                        switch (newOnboard[i].msg.ToUpper())
                        {
                        case "DAILY":
                            taxpayer.SubscriptionType = "DAILY";
                            taxpayer.AmountToDeduct   = 6;
                            break;

                        case "WEEKLY":
                            taxpayer.SubscriptionType = "WEEKLY";
                            taxpayer.AmountToDeduct   = 42;
                            break;

                        case "MONTHLY":
                            taxpayer.SubscriptionType = "MONTHLY";
                            taxpayer.AmountToDeduct   = 168;
                            break;

                        case "STOP":
                            taxpayer.IsActive = false;
                            break;

                        case "BALANCE":
                            taxpayer.IsActive = false;
                            break;

                        default:
                            break;
                        }

                        string subType = "";

                        if (newOnboard[i].msg.ToUpper() == "BALANCE")
                        {
                            subType = "CHECK BALANCE";
                            retSms  = "IPT payment history. Sub. Type: " + taxpayer.SubscriptionType +
                                      " Cur. Deduct. AMT: " + taxpayer.AmountToDeduct.ToString() + "NGN" +
                                      " Total AMT Deducted: " + taxpayer.TotalAmmountDeducted.ToString() + "NGN" +
                                      " Payable Balance: " + taxpayer.Balance.ToString() + "NGN" +
                                      " Last Payment Date: " + taxpayer.LastPaymentDate.ToString();
                        }
                        else
                        {
                            subType                  = "SUBSCRIPTION CHANGE";
                            taxpayer.UpdatedBy       = "SMS";
                            taxpayer.LastDateUpdated = DateTime.Now;
                            if (taxpayer.IsActive)
                            {
                                retSms = "Your IPT subscripton has been changed to " + taxpayer.SubscriptionType + " with subsequence deduction of " + taxpayer.AmountToDeduct.ToString() + "NGN.";
                            }
                            else
                            {
                                retSms = "Your IPT subscripton has been DEACTIVATED and all deductions suspended.";
                            }
                        }


                        MessageOut messageOut = new MessageOut
                        {
                            MSGType       = "SMS:TEXT",
                            msg           = retSms,
                            PhoneNo       = taxpayer.PhoneNo,
                            ServiceType   = subType,
                            Sender        = "I PAY TAX",
                            IsProcessed   = true,
                            Status        = "Send",
                            Receiver      = taxpayer.PhoneNo,
                            DateProcessed = DateTime.Now
                        };

                        _context.Add(messageOut);

                        newOnboard.FirstOrDefault().IsProcessed = true;

                        _context.SaveChanges();

                        transaction.Commit();

                        // return;
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public bool Connect()
        {
            Task.Run(new Action(() =>
            {
                // 创建一个实例
                client           = new ConnectClient(this.Config);
                client.Received += (sender, ByteBuf) =>
                {
                    try
                    {
                        MessageOut msgOut = MessageOut.Parse(ByteBuf);
                        if (msgOut != null)
                        {
                            if (msgOut.Mode != MessageMode.Heartbeat)
                            {
                                ServiceManager.Log(msgOut.ToJson());
                            }

                            if (msgOut.Mode == MessageMode.Result)
                            {
                                ServiceManager.Resolve <IMessageService>().Completed(msgOut);
                            }
                            else if (msgOut.Mode == MessageMode.Callback)
                            {
                                ServiceManager.Resolve <ICallbackService>().Callback(msgOut);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ServiceManager.Error(ex);
                    }
                };

                lastHeartbeat = DateTime.Now;

                while (true)
                {
                    if (client != null)
                    {
                        if (!client.IsRunning())
                        {
                            client.Connect();
                            client.Start();
                        }

                        SendHeartbeat();
                    }
                    else
                    {
                        break;
                    }

                    System.Threading.Thread.Sleep(10);
                }
            }));

            DateTime start = DateTime.Now;

            while (client == null || !client.IsRunning())
            {
                if ((DateTime.Now - start).TotalSeconds > 2)
                {
                    this.Disconnect();

                    return(false);
                }

                System.Threading.Thread.Sleep(10);
            }

            return(true);
        }
예제 #18
0
파일: Chat.cs 프로젝트: k-t/SharpHaven
 public void SendMessage(string text)
 {
     MessageOut.Raise(text);
 }
예제 #19
0
 public void UpdateRecords(MessageOut sms, string msgStatus, DateTime sentTime)
 {
     sms.msgstatus = msgStatus;
     sms.senttime  = sentTime;
     _dbContext.SubmitChanges();
 }
예제 #20
0
 public NicoListManager(MessageOut msgout)
 {
     msgout_ = msgout;
 }
예제 #21
0
        public async Task <StatusCode <MessageOut> > SendMessage(MessagePost messagePost, string senderUsername)
        {
            if (!await _databaseContext.Users.AnyAsync(_ => _.UserName == messagePost.ToUserUsername))
            {
                return(new StatusCode <MessageOut>(StatusCodes.Status404NotFound, $"{messagePost.ToUserUsername} user not found"));
            }

            string receiverId = (await _databaseContext.Users
                                 .FirstOrDefaultAsync(_ => _.UserName == messagePost.ToUserUsername))?
                                .Id;

            string senderId = (await _databaseContext.Users
                               .FirstOrDefaultAsync(_ => _.UserName == senderUsername))?
                              .Id;

            MessageThread messageThread = await _databaseContext.MessageThreads
                                          .Include(_ => _.Messages)
                                          .Include(_ => _.MessageThreadParticipants)
                                          .Where(_ => _.MessageThreadParticipants.Any(_ => _.UserID == senderId))
                                          .FirstOrDefaultAsync(_ => _.MessageThreadParticipants.Any(_ => _.UserID == receiverId));

            if (messageThread == null)
            {
                messageThread = new MessageThread
                {
                    MessageThreadParticipants = new List <MessageThreadParticipant>
                    {
                        new MessageThreadParticipant
                        {
                            UserID = senderId
                        },
                        new MessageThreadParticipant
                        {
                            UserID = receiverId
                        }
                    }
                };

                await _databaseContext.MessageThreads
                .AddAsync(messageThread);
            }

            DateTime sentDate = DateTime.Now;
            Message  message  = new Message
            {
                Content       = messagePost.Content,
                SendingUserID = senderId,
                ThreadID      = messageThread.ID,
                SentDate      = sentDate,

                MessageReadStates = new List <MessageReadState>
                {
                    new MessageReadState
                    {
                        ReadDate = sentDate,
                        UserID   = senderId
                    }
                }
            };

            await _databaseContext.Messages.AddAsync(message);

            await _databaseContext.SaveChangesAsync();

            MessageOut result = _mapper.Map <MessageOut>(message);

            return(new StatusCode <MessageOut>(StatusCodes.Status200OK, result));
        }
예제 #22
0
파일: NicoUtil.cs 프로젝트: tdenc/nicorank
 public NicoMylist(NicoNetwork network, MessageOut msgout, CancelObject cancel_object)
 {
     niconico_network_ = network;
     msgout_           = msgout;
     cancel_object_    = cancel_object;
 }
예제 #23
0
        public async Task ProcessDeductions()
        {
            try
            {
                // get all deductions

                var deductions = await _context.TaxPayers.Where(x => x.IsActive == true && x.Balance > 0 && (DateTime.Compare(Convert.ToDateTime(x.NextPaymentDate), DateTime.Today) <= 0))
                                 .ToListAsync();

                //var newOnboard = await _context.MessageIns.Where(x => x.IsProcessed == false && x.msg.ToUpper() == "IPT").ToListAsync();
                for (int i = 0; i < deductions.Count(); i++)
                {
                    using (var transaction = await _context.Database.BeginTransactionAsync(System.Data.IsolationLevel.ReadUncommitted))
                    {
                        PaymentTransaction payment = new PaymentTransaction
                        {
                            PaymentDate            = DateTime.Now,
                            IPTaxId                = deductions[i].IPTaxId,
                            PaymentReferenceNo     = _taxPayerRepository.GenerateTaxpayerIdAsync(10, false),
                            AmountPaid             = deductions[i].AmountToDeduct,
                            PaymentType            = deductions[i].SubscriptionType,
                            PaymentServiceProvider = "SMS",
                            TaxPayer               = deductions[i],
                            TransactionDate        = DateTime.Now,
                            TransactionReferenceNo = _taxPayerRepository.GuidToBigInteger(Guid.NewGuid()).ToString().Substring(0, 12),
                            Status      = "Success",
                            CreatedBy   = "Service",
                            DateCreated = DateTime.Now
                        };

                        DateTime nextpaymentDate = Convert.ToDateTime(deductions[i].NextPaymentDate);

                        switch (deductions[i].SubscriptionType.ToUpper())
                        {
                        case "DAILY":
                            deductions[i].NextPaymentDate      = nextpaymentDate.AddDays(1);
                            deductions[i].TotalAmmountDeducted = deductions[i].TotalAmmountDeducted + 6;
                            break;

                        case "WEEKLY":
                            deductions[i].NextPaymentDate      = nextpaymentDate.AddDays(7);
                            deductions[i].TotalAmmountDeducted = deductions[i].TotalAmmountDeducted + 42;
                            break;

                        case "MONTHLY":
                            deductions[i].NextPaymentDate      = nextpaymentDate.AddMonths(1);
                            deductions[i].TotalAmmountDeducted = deductions[i].TotalAmmountDeducted + 168;
                            break;

                        default:
                            break;
                        }


                        deductions[i].Balance = deductions[i].Balance - deductions[i].AmountToDeduct;



                        var retSms = "Your " + deductions[i].SubscriptionType.ToUpper() +
                                     " IPT payment deductions of " + deductions[i].AmountToDeduct.ToString() +
                                     "NGN was successfull. Total Tax payable balance is " + deductions[i].Balance.ToString() + "NGN";

                        MessageOut messageOut = new MessageOut
                        {
                            MSGType       = "SMS:TEXT",
                            msg           = retSms,
                            PhoneNo       = deductions[i].PhoneNo,
                            ServiceType   = "PAYMENT DEDUCTIONS",
                            Sender        = "I PAY TAX",
                            Status        = "Send",
                            IsProcessed   = true,
                            Receiver      = deductions[i].PhoneNo,
                            DateProcessed = DateTime.Now
                        };

                        deductions[i].LastPaymentDate = DateTime.Now;

                        _context.Add(payment);
                        _context.Update(deductions[i]);
                        _context.Add(messageOut);


                        _context.SaveChanges();

                        transaction.Commit();

                        // return;
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
예제 #24
0
파일: NicoUtil.cs 프로젝트: tdenc/nicorank
        public static Video GetVideo(NicoNetwork network, string video_id, CancelObject cancel_object, MessageOut msgout)
        {
            Video video = null;

            for (int error_times = 0; ; ++error_times)
            {
                try
                {
                    video = new Video(network.GetThumbInfo(video_id));
                }
                catch (Exception)
                {
                    if (error_times >= checking_error_num_ - 1)
                    {
                        return(Video.GetOtherStateVideo());
                    }
                    else
                    {
                        if (msgout != null)
                        {
                            msgout.Write("ニコニコ動画へのアクセスエラーが起きました。3秒後に再試行します。\r\n");
                        }
                        cancel_object.Wait(3000);
                        continue;
                    }
                }
                break;
            }
            return(video);
        }
예제 #25
0
        public async Task ProcessNewOnBaording()
        {
            try
            {
                // get all new onbaording
                var newOnboard = await _context.MessageIns.Where(x => x.IsProcessed == false && x.msg.ToUpper() == "IPT").ToListAsync();

                for (int i = 0; i < newOnboard.Count(); i++)
                {
                    using (var transaction = await _context.Database.BeginTransactionAsync(System.Data.IsolationLevel.ReadUncommitted))
                    {
                        var retSms = "";
                        var iptID  = "";

                        var existingTaxpayer = await _context.TaxPayers.Where(x => x.PhoneNo == newOnboard[i].PhoneNo).ToListAsync();

                        if (existingTaxpayer.Count() == 0)
                        {
                            TaxPayer taxpayer = new TaxPayer
                            {
                                PhoneNo          = newOnboard[i].PhoneNo,
                                IPTaxId          = _taxPayerRepository.GuidToBigInteger(Guid.NewGuid()).ToString().Substring(0, 10),
                                SubscriptionType = "DAILY",
                                AmountToDeduct   = 6,
                                Balance          = 3500,
                                CreatedBy        = "SMS",
                                IsActive         = true,
                                DateCreated      = DateTime.Now,
                                LastPaymentDate  = DateTime.Now,
                                NextPaymentDate  = DateTime.Now
                            };
                            iptID = taxpayer.IPTaxId;


                            retSms = "Thank you for Subcribing to IPT. Your I pay tax Id is " + iptID + " with DAILY deduction of " + taxpayer.AmountToDeduct.ToString() + "NGN.";

                            _context.Add(taxpayer);
                        }
                        else
                        {
                            iptID  = existingTaxpayer.FirstOrDefault().IPTaxId;
                            retSms = "You have already registered for IPT. Your IPT ID is " + iptID;
                        }



                        MessageOut messageOut = new MessageOut {
                            MSGType       = "SMS:TEXT",
                            msg           = retSms,
                            PhoneNo       = newOnboard[i].PhoneNo,
                            ServiceType   = "ON-BOARDING",
                            Sender        = "I PAY TAX",
                            IsProcessed   = true,
                            Status        = "Send",
                            Receiver      = newOnboard[i].PhoneNo,
                            DateProcessed = DateTime.Now
                        };

                        _context.Add(messageOut);

                        newOnboard[i].IsProcessed = true;

                        _context.SaveChanges();

                        transaction.Commit();

                        // return;
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
예제 #26
0
        private bool SendMessage(MessageOut msg)
        {
            mChrome.GoToUrl("https://www.corrlinks.com/NewMessage.aspx");
            Thread.Sleep(1000);

            mChrome.SetTextByID("ctl00_mainContentPlaceHolder_subjectTextBox", msg.SUBJECT);

            UpdateStatus("Fill the message body");

            if (!mChrome.SetTextByID("ctl00_mainContentPlaceHolder_messageTextBox", msg.MESSAGE))
            {
                mChrome.FindById("ctl00_mainContentPlaceHolder_messageTextBox").SendKeys(msg.MESSAGE);
            }
            Thread.Sleep(500);

            mChrome.TryCloseAlert();

            try
            {
                mChrome.FindById("ctl00_mainContentPlaceHolder_addressBox_addressTextBox").Click();
            } catch
            {
                UpdateStatus("Error when clicking addressbox field");
                return(false);
            }


            String addressHtmlBody = mChrome.FindByXPath("//table[@class='AddressBoxDataGrid']/tbody").GetAttribute("innerHTML");
            int    addressCount    = Regex.Matches(addressHtmlBody, "<tr").Count - 1;

            bool addressFound = false;

            for (int j = 0; j < addressCount; j++)
            {
                String tr      = "//table[@class='AddressBoxDataGrid']/tbody/tr[" + (j + 2).ToString() + "]";
                String address = mChrome.FindByXPath(tr + "/th").GetAttribute("innerHTML");

                int inmate_id = MyUtil.GetMateID(address);
                if (inmate_id == msg.INMATE_ID)
                {
                    addressFound = true;
                    mChrome.FindByXPath(tr + "/td[1]//input").Click();
                    mChrome.FindById("ctl00_mainContentPlaceHolder_addressBox_okButton").Click();
                    Thread.Sleep(3000);

                    mChrome.FindById("ctl00_mainContentPlaceHolder_sendMessageButton").Click();
                    Thread.Sleep(3000);
                    UpdateStatus("Sent message to " + msg.INMATE_ID);
                    break;
                }
            }
            if (!addressFound) // Send request if address not found
            {
                UpdateStatus("Address not found" + msg.INMATE_ID.ToString());

                string validationURL = "http://ddtext.com/corrlinks/sentmessage-update.php?";
                validationURL += "msgID[]=" + msg.INBOX_ID + "&" + "addressnotfound=" + msg.INMATE_ID;

                string validationResult = MyUtil.GetRequest(validationURL);
                UpdateStatus(validationResult);
            }
            return(addressFound);
        }
예제 #27
0
 private void MessageIn_Completed(object sender, object e)
 {
     MessageOut.Begin();
 }
예제 #28
0
파일: NicoUtil.cs 프로젝트: tdenc/nicorank
 public NicoCommentManager(NicoNetwork network, MessageOut msgout, CancelObject cancel_object)
 {
     niconico_network_ = network;
     msgout_           = msgout;
     cancel_object_    = cancel_object;
 }