Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ApplicationMeta"/> class.
 /// </summary>
 /// <param name="applicationId">The application id.</param>
 /// <param name="applicationStateType">Type of the application state.</param>
 /// <param name="dateCreated">The date created.</param>
 /// <param name="optStatusType">Type of the opt status.</param>
 public ApplicationMeta(Guid applicationId, ApplicationStateType applicationStateType, 
     DateTime dateCreated, OptStatusType optStatusType)
 {
     this.Id = applicationId;
     this.State = applicationStateType;
     this.DateCreated = dateCreated;
     this.OptStatus = optStatusType;
 }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ApplicationMeta"/> class.
 /// </summary>
 /// <param name="applicationId">The application id.</param>
 /// <param name="applicationStateType">Type of the application state.</param>
 /// <param name="dateCreated">The date created.</param>
 public ApplicationMeta(Guid applicationId, ApplicationStateType applicationStateType, DateTime dateCreated, 
     Guid sessionId, String version, bool upgraded, OptStatusType optStatus)
 {
     this.Id = applicationId;
     this.State = applicationStateType;
     this.DateCreated = dateCreated;
     this.OptStatus = optStatus;
     this.Version = version;
     this.Upgraded = upgraded;
     this.SessionId = sessionId;
 }
Пример #3
0
 /// <summary>
 /// Sets the opt status.
 /// </summary>
 /// <param name="optStatusType">Type of the opt status.</param>
 public void SetOptStatus(Data.Model.Enum.OptStatusType optStatusType)
 {
     try
     {
         this.optStatusType = optStatusType;
         if (this.started && this.databaseExists)
         {
             AppactsPlugin.Data.Model.ApplicationMeta application = this.iStorageDal.GetApplication(this.applicationId);
             application.OptStatus = optStatusType;
             this.iStorageDal.Update(application);
         }
     }
     catch (ExceptionDatabaseLayer ex)
     {
         this.logSystemError(ex);
     }
 }
Пример #4
0
        /// <summary>
        /// Inits this instance.
        /// </summary>
        private void init(Guid applicationId, UploadType uploadType, string applicationVersion)
        {
            this.applicationId = applicationId;
            this.applicationVersion = applicationVersion;
            this.sessionId = Guid.NewGuid();

            this.iStorageDal = new StorageSql(connectonString);
            this.iUploadDal = new UploadWS(baseUrl);

            this.iDeviceInformation = new DeviceInformation();
            this.iDeviceDynamicInformation = new DeviceDynamicInformation();
            this.iPlatform = new Platform();

            try
            {
                this.initDatabase();

                this.databaseExists = true;
            }
            catch (ExceptionDatabaseLayer) { }

            if (this.databaseExists)
            {
                AppactsPlugin.Data.Model.ApplicationMeta applicationMeta = null;
                bool applicationInitialSetup = false;

                try
                {
                    applicationMeta = this.iStorageDal.GetApplication(this.applicationId);

                    if (applicationMeta == null)
                    {
                        applicationMeta = new ApplicationMeta(this.applicationId, ApplicationStateType.Close, DateTime.Now, OptStatusType.OptIn);

                        this.iStorageDal.Save(applicationMeta);
                        applicationInitialSetup = true;
                    }
                }
                catch (ExceptionDatabaseLayer ex)
                {
                    this.logSystemError(ex);
                }

                try
                {
                    this.optStatusType = applicationMeta.OptStatus;

                    if (applicationMeta.State == ApplicationStateType.Open)
                    {
                        this.iStorageDal.Save(new Crash(this.applicationId, applicationMeta.SessionId, this.applicationVersion));
                    }

                    this.iStorageDal.Save(new EventItem(this.applicationId, null, null,
                        EventType.ApplicationOpen, 0, this.sessionId, this.applicationVersion));

                    applicationMeta.SessionId = this.sessionId;
                    applicationMeta.State = ApplicationStateType.Open;

                    if (applicationMeta.Version == null || applicationMeta.Version != this.applicationVersion)
                    {
                        applicationMeta.Version = this.applicationVersion;
                        applicationMeta.Upgraded = !applicationInitialSetup;
                    }

                    this.iStorageDal.Update(applicationMeta);

                    //#if DEBUG
                   // throw new ExceptionDatabaseLayer(new Exception("Random test"));
                    //#endif
                }
                catch (ExceptionDatabaseLayer exceptionDatabaseLayer)
                {
                    this.logSystemError(exceptionDatabaseLayer);
                }
            }

            this.session = new Session();
        }
Пример #5
0
 /// <summary>
 /// Gets the opt status.
 /// </summary>
 /// <returns></returns>
 public OptStatusType GetOptStatus()
 {
     OptStatusType optStatusType = OptStatusType.None;
     try
     {
         if (this.started && this.databaseExists)
         {
             AppactsPlugin.Data.Model.ApplicationMeta application = this.iStorageDal.GetApplication(this.applicationId);
             optStatusType = application.OptStatus;
         }
     }
     catch (ExceptionDatabaseLayer ex)
     {
         this.logSystemError(ex);
     }
     return optStatusType;
 }