Пример #1
0
        public static void InsertUser(string username)
        {
            GPSTrackerDataContext db = DataContextFactory.GetGPSTrackerDataContext();
            Usermap um = new Usermap();

            um.Name = username;
            db.Usermaps.InsertOnSubmit(um);
            db.SubmitChanges();
        }
        private void loadUserMapping()
        {
            var ofd = new OpenFileDialog();

            ofd.Filter = "*.json|*.json";

            if (ofd.ShowDialog() ?? false)
            {
                Usermap.ReadFromDisk(ofd.FileName);
            }
        }
        private void saveUserMapping()
        {
            var sfd = new SaveFileDialog();

            sfd.Filter = "*.json|*.json";

            if (sfd.ShowDialog() ?? false)
            {
                Usermap.SaveToDisk(sfd.FileName);
            }
        }
Пример #4
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Path != null)
         {
             hashCode = hashCode * 59 + Path.GetHashCode();
         }
         if (ServiceRanking != null)
         {
             hashCode = hashCode * 59 + ServiceRanking.GetHashCode();
         }
         if (JaasControlFlag != null)
         {
             hashCode = hashCode * 59 + JaasControlFlag.GetHashCode();
         }
         if (JaasRealmName != null)
         {
             hashCode = hashCode * 59 + JaasRealmName.GetHashCode();
         }
         if (JaasRanking != null)
         {
             hashCode = hashCode * 59 + JaasRanking.GetHashCode();
         }
         if (Headers != null)
         {
             hashCode = hashCode * 59 + Headers.GetHashCode();
         }
         if (Cookies != null)
         {
             hashCode = hashCode * 59 + Cookies.GetHashCode();
         }
         if (Parameters != null)
         {
             hashCode = hashCode * 59 + Parameters.GetHashCode();
         }
         if (Usermap != null)
         {
             hashCode = hashCode * 59 + Usermap.GetHashCode();
         }
         if (Format != null)
         {
             hashCode = hashCode * 59 + Format.GetHashCode();
         }
         if (TrustedCredentialsAttribute != null)
         {
             hashCode = hashCode * 59 + TrustedCredentialsAttribute.GetHashCode();
         }
         return(hashCode);
     }
 }
Пример #5
0
        private void AddFilesToQueue(string[] files)
        {
            var queue = new List <MapItem>();

            foreach (var file in files)
            {
                if (File.GetAttributes(file).HasFlag(FileAttributes.Directory))
                {
                    AddFilesToQueue(Directory.GetFileSystemEntries(file));
                }
                else
                {
                    using (var stream = new EndianStream(File.OpenRead(file), EndianStream.EndianType.LittleEndian))
                    {
                        try
                        {
                            var contentHeader = Usermap.DeserializeContentHeader(stream);

                            if (!File.Exists(UsermapConversion.GetCanvasFileName(contentHeader.MapId)))
                            {
                                continue;
                            }

                            queue.Add(new MapItem()
                            {
                                VariantName        = contentHeader.Name,
                                VariantAuthor      = contentHeader.Author,
                                VariantDescription = TruncateAtWord(contentHeader.Description, 80),
                                MapId    = contentHeader.MapId,
                                FileName = file
                            });
                        }
                        catch (InvalidDataException ex)
                        {
                            Trace.TraceError(ex.ToString());
                        }
                    }
                }
            }

            Dispatcher.Invoke(() =>
            {
                foreach (var item in queue)
                {
                    FileQueue.Add(item);
                }
            });
        }
Пример #6
0
        /// <summary>
        /// Determine whether a user is a member of a specific role
        /// </summary>
        /// <param name="UserID">The numeric id of the user</param>
        /// <param name="RoleID">The numeric id of the role</param>
        /// <returns>A Boolean indicating whether the user is a member of the role</returns>
        public static bool UserIsInRole(int UserID, UserRoles RoleID)
        {
            bool result = false;

            try
            {
                Usermap u = GPSUser.Get(UserID);

                result = System.Web.Security.Roles.IsUserInRole(u.Name, GetRoleName(RoleID));
            }
            catch
            {
                result = false;
            }

            return(result);
        }
Пример #7
0
        public static void CreateMapVariant(Stream output, MapVariant mapVariant)
        {
            Contract.Requires <ArgumentNullException>(output != null && mapVariant != null);
            Contract.Requires(output.CanWrite);

            mapVariant.Metadata.ContentType = ContentType.MapVariant;
            mapVariant.Metadata.FileLength  = 0x7329;

            var contentHeader = new ContentHeader(mapVariant.Metadata);
            var usermap       = new Usermap(mapVariant);

            var chdr = new Chunk("chdr", version: 10, flags: ChunkFlags.IsHeader, payload: contentHeader);
            var mvar = new Chunk("mvar", version: 50, flags: ChunkFlags.IsInitialized, payload: usermap);

            var blob = new Blob(chdr, mvar);

            using (var s = new BinaryStream(output, StreamState.Write, ByteOrder.BigEndian, false))
                s.Serialize(blob);
        }
Пример #8
0
        /// <summary>
        /// Returns true if ComAdobeGraniteAuthSsoImplSsoAuthenticationHandlerProperties instances are equal
        /// </summary>
        /// <param name="other">Instance of ComAdobeGraniteAuthSsoImplSsoAuthenticationHandlerProperties to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(ComAdobeGraniteAuthSsoImplSsoAuthenticationHandlerProperties other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Path == other.Path ||
                     Path != null &&
                     Path.Equals(other.Path)
                     ) &&
                 (
                     ServiceRanking == other.ServiceRanking ||
                     ServiceRanking != null &&
                     ServiceRanking.Equals(other.ServiceRanking)
                 ) &&
                 (
                     JaasControlFlag == other.JaasControlFlag ||
                     JaasControlFlag != null &&
                     JaasControlFlag.Equals(other.JaasControlFlag)
                 ) &&
                 (
                     JaasRealmName == other.JaasRealmName ||
                     JaasRealmName != null &&
                     JaasRealmName.Equals(other.JaasRealmName)
                 ) &&
                 (
                     JaasRanking == other.JaasRanking ||
                     JaasRanking != null &&
                     JaasRanking.Equals(other.JaasRanking)
                 ) &&
                 (
                     Headers == other.Headers ||
                     Headers != null &&
                     Headers.Equals(other.Headers)
                 ) &&
                 (
                     Cookies == other.Cookies ||
                     Cookies != null &&
                     Cookies.Equals(other.Cookies)
                 ) &&
                 (
                     Parameters == other.Parameters ||
                     Parameters != null &&
                     Parameters.Equals(other.Parameters)
                 ) &&
                 (
                     Usermap == other.Usermap ||
                     Usermap != null &&
                     Usermap.Equals(other.Usermap)
                 ) &&
                 (
                     Format == other.Format ||
                     Format != null &&
                     Format.Equals(other.Format)
                 ) &&
                 (
                     TrustedCredentialsAttribute == other.TrustedCredentialsAttribute ||
                     TrustedCredentialsAttribute != null &&
                     TrustedCredentialsAttribute.Equals(other.TrustedCredentialsAttribute)
                 ));
        }