Exemple #1
0
 public UserSession(int id, Guid guid, UserSessionType userSessionType, Service service, Domain domain, User user, Country country, Language language, MobileOperator mobileOperator, int?trackingID, string iPAddress, string userAgent, string entranceUrl, string refferer, bool hasVerifiedAge, DateTime validUntil, DateTime updated, DateTime created) : base(id, updated, created, false)
 {
     this._guid            = guid;
     this._userSessionType = userSessionType;
     this._service         = service;
     this._domain          = domain;
     this._user            = user;
     this._country         = country;
     this._language        = language;
     this._mobileOperator  = mobileOperator;
     this._trackingID      = trackingID;
     this._iPAddress       = iPAddress;
     this._userAgent       = userAgent;
     this._entranceUrl     = entranceUrl;
     this._refferer        = refferer;
     this._hasVerifiedAge  = hasVerifiedAge;
     this._validUntil      = validUntil;
 }
Exemple #2
0
        public ServiceConfigurationEntry GetConfiguration(Data.Country country, Data.MobileOperator mobileOperator)
        {
            ServiceConfigurationEntry sce = null;

            if (mobileOperator == null)
            {
                if (this._countryConfigurationEntryMap.ContainsKey(country.ID))
                {
                    return(this._countryConfigurationEntryMap[country.ID]);
                }

                sce = ServiceConfigurationEntry.CreateManager().Load(this._serviceData, country);
                if (sce != null)
                {
                    this._countryConfigurationEntryMap.Add(country.ID, sce);
                }

                return(sce);
            }
            else
            {
                return(ServiceConfigurationEntry.CreateManager().Load(this._serviceData, country, mobileOperator));
            }
        }
        // SUMMARY: Here we are receiving message that customer sent to us

        /*
         *  - Check if we can parse shortcode
         *  - Check if we can find ServiceConfigurationEntry
         *  - Check if we have Customer, if not, create one
         *  - We create ShorMessage
         *    -ShortMessage.Guid '{0}' proccessed!
         */

        protected override void ProcessReceiveShortMessageNotification(ReceiveShortMessageNotification notification)
        {
            base.ProcessReceiveShortMessageNotification(notification);

            try
            {
                ActionContext actionContext = null;
                MobiChat.Data.MobileOperator mobileOperator = null;
                MobiChat.Data.Service        service        = null;
                MobiChat.Data.Customer       customer       = null;
                Country country = null;

                Log.Info(string.Format("ShortMessage.ExternalGuid '{0}' arrived!", notification.ShortMessage.ShortMessageID.Value));

                if (notification.ShortMessage.Operator.HasValue)
                {
                    mobileOperator = MobiChat.Data.MobileOperator.CreateManager().Load(notification.ShortMessage.Operator.Value, IDType.External);
                }
                country = mobileOperator != null ? mobileOperator.Country : null;

                int shortcode = -1;
                if (!Int32.TryParse(notification.ShortMessage.Shortcode, out shortcode))
                {
                    Log.Error(string.Format("Shortcode could not be parsed (Shortcode={0})", notification.ShortMessage.Shortcode));
                    return;
                }

                ServiceConfigurationEntry sce = ServiceConfigurationEntry.CreateManager().Load(notification.ShortMessage.Keyword, shortcode, country);
                if (sce == null)
                {
                    Log.Error(string.Format("ServiceConfigurationEntry could not be loaded. ( keyword={0}, shortcode={1}, country={2} )",
                                            notification.ShortMessage.Keyword,
                                            shortcode,
                                            country != null ? country.TwoLetterIsoCode : "NULL"));

                    return;
                }

                service = MobiChat.Data.Service.CreateManager().Load(sce.ServiceConfiguration);
                if (service == null)
                {
                    Log.Error(string.Format("Service could not be loaded by ServiceConfiguration={0}", sce.ServiceConfiguration.ID));
                    return;
                }

                Guid   externalCustomerGuid     = Guid.Empty;
                string notificationCustomerGuid = (from ms in notification.Arguments where ms.Key.Equals("customer") select ms.Value).FirstOrDefault().ToString();
                if (!Guid.TryParse(notificationCustomerGuid, out externalCustomerGuid))
                {
                    Log.Error(string.Format("ExternalCustomerGuid could not be parsed. ExternalCustomerGuid={0}",
                                            (from ms in notification.Arguments where ms.Key.Equals("customer") select ms.Key).ToString()));
                    return;
                }

                country  = service.FallbackCountry;
                customer = this.GetCustomer(externalCustomerGuid, service, country, mobileOperator, notification.ShortMessage.Msisdn);

                if (!notification.ShortMessage.ShortMessageID.HasValue)
                {
                    Log.Error(string.Format("Notification does not contain ShortMessageID"));
                    return;
                }

                MobiChat.Data.ShortMessage shortMessage = MobiChat.Data.ShortMessage.CreateManager().Load(notification.ShortMessage.ShortMessageID.Value);
                if (shortMessage != null)
                {
                    Log.Error(string.Format("ShortMessage with guid:'{0}' allready exists", notification.ShortMessage.ShortMessageID.Value));
                    return;
                }

                shortMessage = new MobiChat.Data.ShortMessage(-1,
                                                              notification.ShortMessage.ShortMessageID.Value,
                                                              actionContext,
                                                              service,
                                                              mobileOperator,
                                                              customer,
                                                              ShortMessageDirection.Incoming,
                                                              ShortMessageStatus.Received,
                                                              notification.ShortMessage.Text,
                                                              shortcode,
                                                              notification.ShortMessage.Keyword,
                                                              DateTime.Now, DateTime.Now);
                shortMessage.Insert();

                Log.Info(string.Format("ShortMessage.Guid '{0}' proccessed!", shortMessage.Guid));

                List <CallbackReport> reports = CallbackReport.CreateManager().Load(CallbackNotificationType.ReceiveShortMessageNotification);
                foreach (CallbackReport report in reports)
                {
                    Code.Report.Call(report.Url.Replace("{data}", shortMessage.Guid.ToString()));
                }
                Code.Report.Call(string.Format("http://{0}/notification/received/{1}", service.Name, shortMessage.Guid.ToString()));
            }
            catch (Exception e)
            {
                Log.Fatal(string.Format("ProcessReceiveShortMessageNotification FATAL!"), e);
            }
        }
        private MobiChat.Data.Customer GetCustomer(Guid externalCustomerGuid, MobiChat.Data.Service service, Country country, MobiChat.Data.MobileOperator mobileOperator, string msisdn)
        {
            MobiChat.Data.Customer customer = MobiChat.Data.Customer.CreateManager().Load(externalCustomerGuid);
            if (customer == null)
            {
                User user = new User(-1,
                                     Guid.NewGuid(),
                                     UserType.CreateManager().Load(1),
                                     UserStatus.Active,
                                     string.Empty,
                                     new byte[] { 0 },
                                     DateTime.Now, DateTime.Now);
                user.Insert();

                customer = new MobiChat.Data.Customer(-1,
                                                      externalCustomerGuid,
                                                      user,
                                                      service,
                                                      country,
                                                      country.Language,
                                                      mobileOperator,
                                                      msisdn,
                                                      string.Empty,
                                                      DateTime.Now, DateTime.Now);
                customer.Insert();
            }

            return(customer);
        }
Exemple #5
0
 public Customer(int id, Guid guid, User user, Service service, Country country, Language language, MobileOperator mobileOperator, string msisdn, string encryptedMsisdn, DateTime updated, DateTime created) : base(id, updated, created, false)
 {
     this._guid            = guid;
     this._user            = user;
     this._service         = service;
     this._country         = country;
     this._language        = language;
     this._mobileOperator  = mobileOperator;
     this._msisdn          = msisdn;
     this._encryptedMsisdn = encryptedMsisdn;
 }
Exemple #6
0
 public ShortMessage(int id, Guid guid, ActionContext actionContext, Service service, MobileOperator mobileOperator, Customer customer, ShortMessageDirection shortMessageDirection, ShortMessageStatus shortMessageStatus, string text, int shortcode, string keyword, DateTime updated, DateTime created) : base(id, updated, created, false)
 {
     this._guid                  = guid;
     this._actionContext         = actionContext;
     this._service               = service;
     this._mobileOperator        = mobileOperator;
     this._customer              = customer;
     this._shortMessageDirection = shortMessageDirection;
     this._shortMessageStatus    = shortMessageStatus;
     this._text                  = text;
     this._shortcode             = shortcode;
     this._keyword               = keyword;
 }