コード例 #1
0
ファイル: UploadWS.cs プロジェクト: Appacts/appacts-sdk-wp7
        /// <summary>
        /// Locations the specified device id.
        /// </summary>
        /// <param name="deviceId">The device id.</param>
        /// <param name="applicationId">The application id.</param>
        /// <param name="deviceLocation">The device location.</param>
        /// <returns></returns>
        public WebServiceResponseCodeType Location(Guid deviceId, Guid applicationId, DeviceLocation deviceLocation)
        {
            KeyValuePair<string, string>[] keyValuePairs = new KeyValuePair<string, string>[] {
                new KeyValuePair<string, string>(QueryStringKeyType.LOCATION_LONGITUDE, deviceLocation.Longitude.ToString()),
                new KeyValuePair<string, string>(QueryStringKeyType.LOCATION_LATITUDE, deviceLocation.Latitude.ToString()),
                new KeyValuePair<string, string>(QueryStringKeyType.LOCATION_COUNTRY, deviceLocation.CountryName),
                new KeyValuePair<string, string>(QueryStringKeyType.LOCATION_COUNTRY_CODE, deviceLocation.CountryCode),
                new KeyValuePair<string, string>(QueryStringKeyType.LOCATION_ADMIN, deviceLocation.CountryAdminName),
                new KeyValuePair<string, string>(QueryStringKeyType.LOCATION_ADMIN_CODE, deviceLocation.CountryAdminCode),
                new KeyValuePair<string, string>(QueryStringKeyType.APPLICATION_GUID, applicationId.ToString()),
                new KeyValuePair<string, string>(QueryStringKeyType.DEVICE_GUID, deviceId.ToString())
            };

            return this.webServiceCall(this.baseUrl, WebServiceType.Location, keyValuePairs);
        }
コード例 #2
0
ファイル: StorageSql.cs プロジェクト: Appacts/appacts-sdk-wp7
        /// <summary>
        /// Updates the specified device.
        /// </summary>
        /// <param name="device">The device.</param>
        public void Update(DeviceLocation device)
        {
            try
            {
                threadQueue.WaitOne();

                this.SubmitChanges();
            }
            catch (Exception ex)
            {
                throw new ExceptionDatabaseLayer(ex);
            }
            finally
            {
                threadQueue.Set();
            }
        }
コード例 #3
0
ファイル: Analytics.cs プロジェクト: Appacts/appacts-sdk-wp7
        /// <summary>
        /// Uploads the specified state info.
        /// </summary>
        /// <param name="stateInfo">The state info.</param>
        private void upload(Object stateInfo)
        {
            Guid deviceId = Guid.Empty;
            bool exceptionWasRaised = false;

            if(!this.threadUploadInterrupted) {

                try {
                    AppactsPlugin.Data.Model.DeviceLocation device = this.iStorageDal.GetDeviceLocation();

                    if (device == null)
                    {
                        deviceId = this.iUploadDal.Device
                            (this.applicationId, iDeviceInformation.GetModel(), iPlatform.GetOS(),
                            (int)DeviceType.WindowsPhone, iPlatform.GetCarrier(),
                            this.applicationVersion,
                            (DateTime.Now - DateTime.UtcNow).Hours,
                            this.iDeviceInformation.GetLocale(),
                            this.iDeviceInformation.GetScreenResolution().Width.ToString(),
                            this.iDeviceInformation.GetScreenResolution().Height.ToString(),
                            this.iDeviceInformation.GetManufacturer());

                        if (deviceId == Guid.Empty)
                        {
                            this.authenticationFailure = true;
                            return;
                        }

                        device = new Data.Model.DeviceLocation(deviceId);
                        this.iStorageDal.Save(device);
                    }
                    else
                    {
                        deviceId = device.Id;

                        if (!this.upgradedProcessed)
                        {
                            this.upgradedProcessed = this.uploadUpgraded(deviceId);
                        }
                    }
                } catch(ExceptionDatabaseLayer ex) {
                    #if DEBUG
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                    System.Diagnostics.Debug.WriteLine("Save Device");
                    #endif
                    exceptionWasRaised = true;
                } catch(ExceptionWebServiceLayer ex) {
                    #if DEBUG
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                    System.Diagnostics.Debug.WriteLine("Save Device");
                    #endif
                    exceptionWasRaised = true;
                }
            }

            //remember current count before we start processing items, so later we can
            //find out if we need to call upload thread again
            int numberOfItemsWaitingToBeUploadedBefore = this.numberOfItemsWaitingToBeUploaded;

            if(!this.threadUploadInterrupted && !exceptionWasRaised) {
                try {
                    this.uploadSystemError(deviceId);
                } catch(ExceptionDatabaseLayer ex) {
                    #if DEBUG
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                    System.Diagnostics.Debug.WriteLine("uploadSystemError");
                    #endif
                    exceptionWasRaised = true;
                } catch(ExceptionWebServiceLayer ex) {
                    #if DEBUG
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                     System.Diagnostics.Debug.WriteLine("uploadSystemError");
                    #endif
                    exceptionWasRaised = true;
                }
            }

            if(!this.threadUploadInterrupted && !exceptionWasRaised) {
                try {
                    this.uploadCrash(deviceId);
                } catch(ExceptionDatabaseLayer ex) {
                    #if DEBUG
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                     System.Diagnostics.Debug.WriteLine("uploadSystemError");
                    #endif
                    exceptionWasRaised = true;
                } catch(ExceptionWebServiceLayer ex) {
                    #if DEBUG
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                    System.Diagnostics.Debug.WriteLine("uploadCrash");
                    #endif
                    exceptionWasRaised = true;
                }
            }

            if(!this.threadUploadInterrupted && !exceptionWasRaised && !this.userProcessed) {
                try {
                    this.userProcessed =  this.uploadUser(deviceId);
                } catch(ExceptionDatabaseLayer ex) {
                    #if DEBUG
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                    System.Diagnostics.Debug.WriteLine("uploadUser");
                    #endif
                    exceptionWasRaised = true;
                } catch(ExceptionWebServiceLayer ex) {
                    #if DEBUG
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                    System.Diagnostics.Debug.WriteLine("uploadUser");
                    #endif
                    exceptionWasRaised = true;
                }
            }

            if(!this.threadUploadInterrupted && !exceptionWasRaised) {
                try {
                    this.uploadError(deviceId);
                } catch(ExceptionDatabaseLayer ex) {
                    #if DEBUG
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                    System.Diagnostics.Debug.WriteLine("uploadError");
                    #endif
                    exceptionWasRaised = true;
                } catch(ExceptionWebServiceLayer ex) {
                    #if DEBUG
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                    System.Diagnostics.Debug.WriteLine("uploadError");
                    #endif
                    exceptionWasRaised = true;
                }
            }

            if(!this.threadUploadInterrupted && !exceptionWasRaised) {
                try {
                    this.uploadEvent(deviceId);
                } catch(ExceptionDatabaseLayer ex) {
                    #if DEBUG
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                    System.Diagnostics.Debug.WriteLine("uploadEvent");
                    #endif
                    exceptionWasRaised = true;
                } catch(ExceptionWebServiceLayer ex) {
                    #if DEBUG
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                    System.Diagnostics.Debug.WriteLine("uploadEvent");
                    #endif
                    exceptionWasRaised = true;
                }
            }

            if(!this.threadUploadInterrupted && !exceptionWasRaised) {
                try {
                    this.uploadFeedback(deviceId);
                } catch(ExceptionDatabaseLayer ex) {
                    #if DEBUG
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                    System.Diagnostics.Debug.WriteLine("uploadFeedback");
                    #endif
                    exceptionWasRaised = true;
                } catch(ExceptionWebServiceLayer ex) {
                    #if DEBUG
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                    System.Diagnostics.Debug.WriteLine("uploadFeedback");
                    #endif
                    exceptionWasRaised = true;
                }
            }

            if(!this.threadUploadInterrupted && !exceptionWasRaised && !this.deviceLocationProcessed) {
                try {
                    this.deviceLocationProcessed = this.uploadDeviceLocation(deviceId);
                } catch(ExceptionDatabaseLayer ex) {
                    #if DEBUG
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                    System.Diagnostics.Debug.WriteLine("uploadDeviceLocation");
                    #endif
                    exceptionWasRaised = true;
                } catch(ExceptionWebServiceLayer ex) {
                    #if DEBUG
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                    System.Diagnostics.Debug.WriteLine("uploadDeviceLocation");
                    #endif
                    exceptionWasRaised = true;
                }
            }

            if(!exceptionWasRaised) {
                this.uploadSuccesfullyCompleted(numberOfItemsWaitingToBeUploadedBefore);
            }

            lock(this.threadIsUploadingLock) {
                this.threadIsUploading = false;

                #if DEBUG
                System.Diagnostics.Debug.WriteLine("Ending upload thread");
                #endif

                Monitor.PulseAll(this.threadIsUploadingLock);
            }
        }
コード例 #4
0
ファイル: StorageSql.cs プロジェクト: Appacts/appacts-sdk-wp7
        /// <summary>
        /// Saves the specified device location.
        /// </summary>
        /// <param name="deviceLocation">The device location.</param>
        public void Save(DeviceLocation deviceLocation)
        {
            try
            {
                threadQueue.WaitOne();

                this.DeviceLocation.InsertOnSubmit(deviceLocation);

                this.SubmitChanges();
            }
            catch (Exception ex)
            {
                throw new ExceptionDatabaseLayer(ex);
            }
            finally
            {
                threadQueue.Set();
            }
        }