Esempio n. 1
0
        public void SendCode(string phone, string text, SendMethod sendMethod)
        {
            GlobalLogManager.WriteString("Info: WCFPlugin SendCode: phone {0}, text {1}, method {2}",
                                         phone, text, sendMethod);

            if (string.IsNullOrWhiteSpace(phone))
            {
                return;
            }

            switch (sendMethod)
            {
            case SendMethod.SMS:
                CallManagementInterface.SendSMS(phone, text, 0);
                break;

            case SendMethod.Call:
                CallManagementInterface.StartAutoinformator(phone, text, 0);
                break;

            case SendMethod.Both:
                CallManagementInterface.SendSMS(phone, text, 0);
                CallManagementInterface.StartAutoinformator(phone, text, 0);
                break;
            }
        }
Esempio n. 2
0
        private void DoPayments(double amount, IClient client, string logDescription, string messageTemplate)
        {
            CheckAndCreateBilling(client);
            client.Billing.Balance += amount;
            PaymentRoutine.AddBillingLogsInThreadPool(
                amount,
                BillingTypes.Manually,
                client.Billing.ID,
                null /*orderId*/,
                string.Empty,
                logDescription,
                client.Billing.Balance ?? 0,
                BillingLogType.Client,
                null /*orerNumber*/);

            string number  = _clientManager.GetDefaultPhone(client.ID);
            string message = string.Format(messageTemplate, amount);

            if (!string.IsNullOrWhiteSpace(number))
            {
                if (PluginParams.NeedMakeCall)
                {
                    CallManagementInterface.StartAutoinformator(number, message, 0);
                }

                if (PluginParams.NeedSendSms)
                {
                    CallManagementInterface.SendSMS(number, message, 0);
                }
            }
            else
            {
                GlobalLogManager.WriteString("Warning: WCFPlugin. У клиента не указан номер телефона");
            }
        }
Esempio n. 3
0
        private void DoBalanceNotify(IBilling billing)
        {
            if (billing == null)
            {
                return;
            }

            Stopwatch timeWatcher = new Stopwatch();
            var       clients     = ClientManager.ClientManager.GetManager().GetClients();
            IClient   client      = null;

            timeWatcher.Start();
            foreach (var item in clients)
            {
                if (item.IDBilling == billing.ID)
                {
                    client = item;
                    break;
                }
            }
            timeWatcher.Stop();
            if (timeWatcher.ElapsedMilliseconds > 500)
            {
                GlobalLogManager.WriteString("Warning: ClientsBountyManager. Поиск клиента по IDBilling более 500 мс.");
            }

            if (client == null)
            {
                GlobalLogManager.WriteString("Error: ClientsBountyManager. Не найден клиент со счетом ID = {0}, Account = {1}", billing.ID, billing.Account);
                return;
            }

            string number = ClientManager.ClientManager.GetManager().GetDefaultPhone(client.ID);

            if (!string.IsNullOrWhiteSpace(number))
            {
                if (_param.NeedMakeBalanceNotifyCall)
                {
                    CallManagementInterface.StartAutoinformator(number, _param.BalanceNotifyMessage, 0);
                }

                if (_param.NeedSendBalanceNotifySMS)
                {
                    CallManagementInterface.SendSMS(number, _param.BalanceNotifyMessage, 0);
                }
            }
            else
            {
                GlobalLogManager.WriteString("Warning: ClientsBountyManager. У клиента не указан номер телефона");
            }
        }
Esempio n. 4
0
        void _orders_StatePropertyChanged(object sender, CxPropertyChangedEventArgs <IOrder> e)
        {
            PluginParams param;

            lock (_paramLock)
            {
                param = new PluginParams(_param);
            }

            var order = e.Object;

            if (order.State == Enums.OrderStates.Paid &&            //Заказ оплачен
                param.IdsServices.Contains(order.IDService ?? 0) && //с указанной услугой
                order.Cost.HasValue && order.Cost.Value > 0.0 &&    //и не нулевой стоимостью
                order.Client != null)
            {
                var client = order.Client;
                if (client.IDBilling == null) //Если у клиента еще нет счета, то создаем его
                {
                    client.Billing = _billings.AddNew(item =>
                    {
                        item.ID        = DbUtils.GenID();
                        item.Account   = item.ID.ToString();
                        item.Balance   = 0;
                        item.Limit     = 0;
                        item.OwnerType = BillingLogType.Client;
                    });
                }

                var    bountySumm = order.Cost.Value * param.Procent;
                double oldBalance = client.Billing.Balance ?? 0;
                client.Billing.Balance = oldBalance + bountySumm;         //Пополняем счет клиента
                PaymentRoutine.PaymentRoutine.AddBillingLogsInThreadPool( //И записываем в лог
                    bountySumm,
                    BillingTypes.Order,
                    client.Billing.ID,
                    order.ID,
                    string.Empty,
                    param.BountyDescription,
                    client.Billing.Balance ?? 0,
                    BillingLogType.Client,
                    order.Number);

                string number  = ClientManager.ClientManager.GetManager().GetDefaultPhone(client.ID);
                string message = string.Format(param.MessageTemplate, bountySumm);

                if (!string.IsNullOrWhiteSpace(number))
                {
                    if (param.NeedMakeCall)
                    {
                        CallManagementInterface.StartAutoinformator(number, message, order.ID);
                    }

                    if (param.NeedSendSMS)
                    {
                        CallManagementInterface.SendSMS(number, message, order.ID);
                    }
                }
                else
                {
                    GlobalLogManager.WriteString("Warning: ClientsBountyManager. У клиента не указан номер телефона");
                }
            }
        }