Beispiel #1
0
 private void LoadParams()
 {
     try
     {
         string fileName = GlobalUtils.AppDirectory + "\\ClientsBountyParams.xml";
         GlobalLogManager.WriteString("Info: Загрузка параметров плагина ClientsBountyManager. fileName = {0}", fileName);
         using (Stream stream = new FileStream(fileName, FileMode.Open))
         {
             XmlSerializer serializer = new XmlSerializer(typeof(PluginParams));
             var           temp       = (PluginParams)serializer.Deserialize(stream);
             lock (_paramLock)
             {
                 _param = new PluginParams(temp);
             }
         }
     }
     catch (Exception e)
     {
         GlobalLogManager.WriteString("Warning: Не удалось загрузить параметры плагина ClientsBountyManager. {0}", e);
         lock (_paramLock)
         {
             _param = new PluginParams();
         }
     }
 }
Beispiel #2
0
 public static void CreateFile(string path)
 {
     using (Stream writer = new FileStream(path + "\\" + "ClientsBountyParams.xml", FileMode.Create))
     {
         var           param      = new PluginParams();
         XmlSerializer serializer = new XmlSerializer(typeof(PluginParams));
         serializer.Serialize(writer, param);
     }
 }
Beispiel #3
0
 public PluginParams(PluginParams other)
 {
     IdsServices               = other.IdsServices;
     Procent                   = other.Procent;
     BountyDescription         = other.BountyDescription;
     MessageTemplate           = other.MessageTemplate;
     NeedMakeCall              = other.NeedMakeCall;
     NeedSendSMS               = other.NeedSendSMS;
     BalanceNotifySumm         = other.BalanceNotifySumm;
     NeedMakeBalanceNotifyCall = other.NeedMakeBalanceNotifyCall;
     NeedSendBalanceNotifySMS  = other.NeedSendBalanceNotifySMS;
     BalanceNotifyMessage      = other.BalanceNotifyMessage;
 }
Beispiel #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. У клиента не указан номер телефона");
                }
            }
        }