예제 #1
0
        public Formatter()
        {
            Binder            = null;
            Context           = new StreamingContext();
            SurrogateSelector = null;

            Readers.Add("json", DeserializeJson);
            Readers.Add("png", DeserializeImage);
            Readers.Add("tif", DeserializeImage);
            Readers.Add("jpg", DeserializeImage);
            Readers.Add("gif", DeserializeImage);
            Readers.Add("bmp", DeserializeImage);
            SignatureReaders.Add("42 4D", "bmp");                       // .bmp
            SignatureReaders.Add("47 49 46 38 37 61", "gif");           // .gif
            SignatureReaders.Add("47 49 46 38 39 61", "gif");           // .gif
            SignatureReaders.Add("FF D8 FF E0", "jpg");                 // .jpg
            SignatureReaders.Add("FF D8 FF E1", "jpg");                 // .jpg
            SignatureReaders.Add("49 49 2A 00", "tif");                 // .tif
            SignatureReaders.Add("4D 4D 00 2A", "tif");                 // .tif
            SignatureReaders.Add("89 50 4E 47 0D 0A 1A 0A", "png");     // .png
            SignatureReaders.Add("{", "json");
            SignatureReaders.Add("[", "json");
        }
예제 #2
0
        public Image GetImage(String filename)
        {
            var extension = Path.GetExtension(filename).ToLower();

            if (extension == "")
            {
                return(null);
            }
            extension = extension.Substring(1);
            if (Readers.ContainsKey(extension))
            {
                try
                {
                    return(new Image(Readers[extension].ReadImage(filename)));
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    return(null);
                }
            }
            throw new Exception("Image type not supported.");
        }
예제 #3
0
        private IEnumerable <EntityItem <object> > GetChildren(Expression <object> expression, EntityItem <object> parent)
        {
            var entityParent = parent?.Entity;

            if (entityParent == null)
            {
                yield break;
            }

            // Find the reader, the last "reader" is the most important
            var instanceReader =
                Readers
                .Where(f => f.CanRead(this, entityParent))
                .LastOrDefault();

            if (instanceReader != null)
            {
                foreach (var item in instanceReader.GetChildren(this, expression, entityParent))
                {
                    yield return(item);
                }
            }
        }
예제 #4
0
        public static IEnumerable <object[]> GetCerts()
        {
            List <object[]> certs;

            using (var readers = new Readers(ReaderScope.User))
                using (var store = new X509Store(StoreName.My, StoreLocation.CurrentUser))
                {
                    store.Open(OpenFlags.ReadOnly);
                    certs = readers.ListCards()
                            .OfType <EidCard>()
                            .Select(c =>
                    {
                        c.Open();
                        String thumbprint = c.AuthCert.Thumbprint;
                        c.Close();
                        return(store.Certificates.Find(X509FindType.FindByThumbprint, thumbprint, false)[0]);
                    })
                            .Select(c => new object[] { new MyX509Certificate2(c) })
                            .ToList();
                }
            certs.Add(new object[] { new MyX509Certificate2("files/eccert.p12", "Test_001") });
            return(certs);
        }
예제 #5
0
        public async Task RediscoveryAsync()
        {
            var provider = new SingleConnectionBasedConnectionProvider(_conn);
            var session  = new Session(provider, _logger);

            try
            {
                var result = await session.RunAsync(DiscoveryProcedure).ConfigureAwait(false);

                var record = await result.SingleAsync().ConfigureAwait(false);

                ParseDiscoveryResult(record);
            }
            catch (Exception e)
            {
                HandleDiscoveryException(e);
            }
            finally
            {
                try
                {
                    await session.CloseAsync().ConfigureAwait(false);
                }
                catch (Exception)
                {
                    // ignore any exception
                }
                await provider.CloseAsync().ConfigureAwait(false);
            }

            if (!Readers.Any() || !Routers.Any())
            {
                throw new ProtocolException(
                          $"Invalid discovery result: discovered {Routers.Count()} routers, " +
                          $"{Writers.Count()} writers and {Readers.Count()} readers.");
            }
        }
예제 #6
0
        static bool LoadDeclaredReaders(AssemblyDefinition currentAssembly, TypeDefinition klass)
        {
            // register all the reader in this class.  Skip the ones with wrong signature
            bool modified = false;

            foreach (MethodDefinition method in klass.Methods)
            {
                if (method.Parameters.Count != 1)
                {
                    continue;
                }

                if (!method.Parameters[0].ParameterType.Is <NetworkReader>())
                {
                    continue;
                }

                if (method.ReturnType.Is(typeof(void)))
                {
                    continue;
                }

                if (!method.HasCustomAttribute <System.Runtime.CompilerServices.ExtensionAttribute>())
                {
                    continue;
                }

                if (method.HasGenericParameters)
                {
                    continue;
                }

                Readers.Register(method.ReturnType, currentAssembly.MainModule.ImportReference(method));
                modified = true;
            }
            return(modified);
        }
        public void PC_Info(User user, Readers ler)
        {
            ler.Int();
            string WindowsVersion = ler.UString();
            string PlacaDeRede    = ler.UString();
            int    unk            = ler.Int();

            int[] unk2 = { 0 };
            for (int i = 0; i < unk; i++)
            {
                Array.Resize(ref unk2, unk);
                unk2[i] = ler.Int();
            }
            string PlacaDeVideo = ler.UString();

            ler.Int();
            ler.Byte();
            string DirectxVersion = ler.UString();

            PacketManager Write = new PacketManager();

            Write.OP(226);
            Write.Int(0);
            Write.UStr(WindowsVersion);
            Write.UStr(PlacaDeRede);
            Write.Int(unk);
            for (int y = 0; y < unk; y++)
            {
                Write.Int(unk2[y]);
            }
            Write.UStr(PlacaDeVideo);
            Write.Int(0);
            Write.Byte(0);
            Write.UStr(DirectxVersion);
            Write.Hex("00 00 00");
            user.Send(Write.ack);
        }
예제 #8
0
        private async Task <bool> CheckLoaded()
        {
            if (_assetBundle)
            {
                return(true);
            }
            var data = await Readers.ReadResourceAsync(BUNDLE_PATH);

            if (data == null)
            {
                _logger.Error($"Resource at {BUNDLE_PATH} doesn't exist");
                return(false);
            }

            _assetBundle = await Readers.LoadAssetBundleAsync(data);

            if (_assetBundle == null)
            {
                _logger.Error("Couldn't load embedded AssetBundle");
                return(false);
            }

            return(true);
        }
        public void Nick(User user,Readers ler,int userid)
        {
            string nickname = ler.UString();
            
            db.DBConnect data = new db.DBConnect();
            DataSet Banco = new DataSet();
            DataSet Banco1 = new DataSet();

            Console.WriteLine("NICK: "+nickname);
            PacketManager Write = new PacketManager();
            Write.OP(135);
            data.Exec(Banco, "SELECT   `userid`  FROM `nicknames` WHERE `nickname` = '" + nickname+ "'");
            if (Banco.Tables[0].Rows.Count > 0)
            {
                Write.Int(1);
            }
            else
            {
                Write.Int(0);
                data.Exec(Banco, "UPDATE   `nicknames` SET  `nickname` = 'nickname' WHERE `userid` = '"+userid+"'");
            }            
            Write.UStr(nickname);
            user.Send(Write.ack);
        }
예제 #10
0
        public void chat(User user, Readers Ler)
        {
            Ler.Byte();
            Ler.Int();
            string ServerName = Ler.UString();

            Ler.Int();
            Ler.Int();
            Ler.Int();
            string texto = Ler.UString();

            if (user.Status == "LOBBY")
            {
                EnviarLobby(user, texto);
            }
            if (user.Status == "SALA")
            {
                EnviarSala(user, texto);
            }
            if (user.Status == "JOGANDO")
            {
                EnviarSala(user, texto);
            }
        }
예제 #11
0
        private async void RestartReaders()
        {
            try
            {
                IsBusy = true;

                await Task.WhenAll(Readers.Select( x => x.Stop()).ToArray()).ConfigureAwait(false);

                Data.RecordSettingChange("Reader Restart", 1, 0);

                await Task.WhenAll(Readers.Select( x => x.Start()).ToArray()).ConfigureAwait(false);

                Data.RecordSettingChange("Reader Restart", 0, 1);
            }
            catch (Exception e)
            {
                Data.Error("MainWindow", "Failed to restart readers.", e);
            }
            finally
            {
                IsBusy = false;
                _rebuildPartitionOwners = true;
            }
        }
예제 #12
0
        /// <remarks>Throws <see cref="ProtocolException"/> if the discovery result is invalid.</remarks>
        /// <remarks>Throws <see cref="ServiceUnavailableException"/> if the no discovery procedure could be found in the server.</remarks>
        public void Rediscovery()
        {
            try
            {
                using (var provider = new SingleConnectionBasedConnectionProvider(_conn))
                    using (var session = new Session(provider, _logger))
                    {
                        var result = session.Run(DiscoveryProcedure);
                        var record = result.Single();
                        ParseDiscoveryResult(record);
                    }
            }
            catch (Exception e)
            {
                HandleDiscoveryException(e);
            }

            if (!Readers.Any() || !Routers.Any())
            {
                throw new ProtocolException(
                          $"Invalid discovery result: discovered {Routers.Count()} routers, " +
                          $"{Writers.Count()} writers and {Readers.Count()} readers.");
            }
        }
예제 #13
0
        internal static List <Tuple <string, string> > GetForLangFromSection(Section section)
        {
            List <Tuple <string, string> > forLangs = new List <Tuple <string, string> >();
            int type = section.Tables.Count;

            switch (type)
            {
            case 8: {
                List <string> arraySkills = Readers.GetTextFromTable(section.Tables[6]);
                for (int i = 1; i < arraySkills.Count; i += 2)
                {
                    arraySkills[i] = Regex.Replace(arraySkills[i], ",(?=[^()]*\\))", "|");
                    string[] buff = Regex.Split(arraySkills[i], ", ");
                    foreach (string s in buff)
                    {
                        forLangs.Add(new Tuple <string, string>(s, arraySkills[i + 1]));
                    }
                }
            } break;

            case 2: {
                List <string> arraySkills = Readers.GetTextFromTable(section.Tables[0]);
                for (int i = 1; i < arraySkills.Count; i++)
                {
                    if (arraySkills[i - 1].Contains("Fore"))
                    {
                        for (int j = i; j < arraySkills.Count; j += 2)
                        {
                            forLangs.Add(new Tuple <string, string>(arraySkills[j], arraySkills[j + 1]));
                        }
                    }
                }
            } break;
            }
            return(forLangs);
        }
예제 #14
0
        private void addbuton_Click(object sender, RoutedEventArgs e)
        {
            Readers     addReaders     = new Readers();
            Books       addBooks       = new Books();
            InfoReader  addInfoReader  = new InfoReader();
            Return      addReturn      = new Return();
            Extradition addExtradition = new Extradition();

            addReaders.Name    = tbName.Text;
            addReaders.Surname = tbSurname.Text;

            addReturn.ReturnDate = tbReturnDate.SelectedDate;

            addExtradition.DateOfIssue = tbDateOfIssue.SelectedDate;

            addBooks.Title  = tbTitle.Text;
            addBooks.Author = tbAuthor.Text;

            addInfoReader.HomeAddress = tbHomeAddress.Text;
            addInfoReader.Telephone   = tbTelephone.Text;

            addReaders.ID = addBooks.ID;
            addReaders.ID = addInfoReader.ID;
            addReaders.ID = addReturn.ID;
            addReaders.ID = addExtradition.ID;

            dbcontext.db.Readers.Add(addReaders);
            dbcontext.db.Books.Add(addBooks);
            dbcontext.db.InfoReader.Add(addInfoReader);
            dbcontext.db.Return.Add(addReturn);
            dbcontext.db.Extradition.Add(addExtradition);

            dbcontext.db.SaveChanges();

            MessageBox.Show("Вы добавили данные", "Уведомление", MessageBoxButton.OK, MessageBoxImage.Information);
        }
예제 #15
0
        IDictionary <string, object> IJsonConvertible.ToJSON()
        {
            Dictionary <string, object> result = new Dictionary <string, object> {
            };

            foreach (string user in Readers.Union(Writers))
            {
                Dictionary <string, object> userPermissions = new Dictionary <string, object> {
                };

                if (Readers.Contains(user))
                {
                    userPermissions["read"] = true;
                }
                if (Writers.Contains(user))
                {
                    userPermissions["write"] = true;
                }

                result[user] = userPermissions;
            }

            return(result);
        }
    protected void Search(object sender, EventArgs e)
    {
        string search;

        search = TextSearch.Text;

        //链接数据库
        string          OLMSDBConnectionString = ConfigurationManager.ConnectionStrings["OLMSDB"].ConnectionString;
        MySqlConnection OLMSDBConnection       = new MySqlConnection(OLMSDBConnectionString);

        System.Diagnostics.Debug.WriteLine("database is ok");
        String readersql = "";

        if (DropDownList1.SelectedValue == "0")
        {
            readersql = "select * from Readers where Phone like " + "\"%" + search + "%\""
                        + " or " + "Name like " + "\"%" + search + "%\"";
        }
        if (DropDownList1.SelectedValue == "1")
        {
            readersql = "select * from Readers where Phone like " + "\"%" + search + "%\"";
        }
        if (DropDownList1.SelectedValue == "2")
        {
            readersql = "select * from Readers where Name like " + "\"%" + search + "%\"";
        }


        try
        {
            OLMSDBConnection.Open();

            MySqlCommand    cmd1         = new MySqlCommand(readersql, OLMSDBConnection);
            ArrayList       readers_list = new ArrayList();
            MySqlDataReader sqlreader    = cmd1.ExecuteReader();
            while (sqlreader.Read())
            {
                if (sqlreader.HasRows)
                {
                    Readers reader = new Readers();
                    reader.ReaderId = sqlreader["ReaderId"].ToString();
                    reader.Name     = (string)sqlreader["Name"];
                    reader.Phone    = (string)sqlreader["Phone"];
                    if (sqlreader["Email"] == null)
                    {
                        reader.Email = "";
                    }
                    else
                    {
                        reader.Email = sqlreader["Email"].ToString();
                    }
                    readers_list.Add(reader);
                    reader.href = "/Pages/LibrarianPages/ShowReaderInfoByLib.aspx?ReaderId=" + sqlreader["ReaderId"].ToString();
                }
            }
            GridView1.DataSource = readers_list;
            GridView1.DataBind();
            sqlreader.Close();
        }
        catch (MySqlException ex)
        {
            Console.WriteLine(ex.Message);
        }
        finally
        {
            OLMSDBConnection.Close();
        }
    }
예제 #17
0
 private void OnError(Exception exception)
 {
     Debug.Print(exception.Message);
     Readers.Clear();
     EventHistory.Clear();
 }
예제 #18
0
        private object LoadAssetWithDynamicContentReader <T>(string assetName, Stream stream, object options)
        {
            object result;
            var    type = typeof(T);

            var parameters = new ContentReaderParameters
            {
                AssetName = assetName,
                AssetType = type,
                Stream    = stream,
                Options   = options
            };

            try
            {
                IContentReader contentReader;
                lock (registeredContentReaders)
                {
                    if (!registeredContentReaders.TryGetValue(type, out contentReader))
                    {
                        // Use registered factories to handle a type
                        lock (registeredContentReaderFactories)
                        {
                            foreach (var factory in registeredContentReaderFactories)
                            {
                                contentReader = factory.TryCreate(type);
                                if (contentReader != null)
                                {
                                    registeredContentReaders.Add(type, contentReader);
                                    break;
                                }
                            }
                        }

                        // Else tries to get a ContentReaderAttribute to resolve the type
                        if (contentReader == null)
                        {
#if WIN8METRO
                            var contentReaderAttribute = Utilities.GetCustomAttribute <ContentReaderAttribute>(type.GetTypeInfo(), true);
#else
                            var contentReaderAttribute = Utilities.GetCustomAttribute <ContentReaderAttribute>(type, true);
#endif

                            if (contentReaderAttribute != null)
                            {
                                contentReader = Activator.CreateInstance(contentReaderAttribute.ContentReaderType) as IContentReader;
                                if (contentReader != null)
                                {
                                    Readers.Add(typeof(T), contentReader);
                                }
                            }
                        }
                    }
                }

                if (contentReader == null)
                {
                    throw new NotSupportedException(string.Format("Type [{0}] doesn't provide a ContentReaderAttribute, and there is no registered content reader/factory for it.", type.FullName));
                }

                result = contentReader.ReadContent(this, ref parameters);

                if (result == null)
                {
                    throw new NotSupportedException(string.Format("Registered ContentReader of type [{0}] fails to load content of type [{1}] from file [{2}].", contentReader.GetType(), type.FullName, assetName));
                }
            }
            finally
            {
                // If we don't need to keep the stream open, then we can close it
                // and make sure that we will close the stream even if there is an exception.
                if (!parameters.KeepStreamOpen)
                {
                    stream.Dispose();
                }
            }

            return(result);
        }
예제 #19
0
 /// <summary>
 /// 会员办证(添加读者信息)
 /// </summary>
 /// <param name="reader"></param>
 /// <returns></returns>
 public int AddReader(Readers reader)
 {
     return(readerDao.AddReader(reader));
 }
예제 #20
0
 public void RemovingUser(Readers reader, Users user)
 {
     libraryDBEntities.Readers.Remove(reader);
     libraryDBEntities.Users.Remove(user);
     libraryDBEntities.SaveChanges();
 }
예제 #21
0
 private ReaderModel()
 {
     Readers.Attach(this);
     Setup();
 }
예제 #22
0
        public void CriarSala(User user, PlayerInfo pInfo, Readers ler, CharsInfo charsInfo)
        {
            short  blank         = ler.Short();
            string Nome          = ler.UString();
            int    id            = ler.Byte();
            byte   Guild         = ler.Byte();
            string senha         = ler.UString();
            short  playersemSala = ler.Short();
            short  MaxPlayers    = ler.Short();
            byte   jogando       = ler.Byte();
            byte   unk2          = ler.Byte();
            byte   matchmode     = ler.Byte();
            int    gamemode      = ler.Int();
            int    readMatch     = ler.Int();
            int    RandomMap     = ler.Byte();
            int    Map           = ler.Int();

            ler.Int();
            ler.Bytes(97);
            string iLogin         = ler.String();
            int    iUserid        = ler.Int();
            string iNick          = ler.String();
            int    indexcharacter = ler.Int();
            byte   iPersonagemID  = ler.Byte();
            Sala   sala           = new Sala();

            sala.SalaID    = (short)id;
            sala.ITMode    = 2;
            sala.SalaNome  = Nome;
            sala.SalaSenha = senha;
            sala.MatchMode = (int)matchmode;
            sala.GameMode  = (int)gamemode;
            sala.RndMap    = false;
            sala.Map       = (int)Map;
            sala.expulsar  = 3;
            sala.jogando   = false;

            user.PersonagemAtual = iPersonagemID;

            for (int m = 0; m < MaxPlayers; m++)
            {
                if (m == 0)
                {
                    sala.slotslen[0].ativo  = true;
                    sala.slotslen[0].user   = user;
                    sala.slotslen[0].Lider  = true;
                    sala.slotslen[0].aberto = false;
                }
                else
                {
                    sala.slotslen[m].ativo  = false;
                    sala.slotslen[m].aberto = true;
                    sala.slotslen[m].user   = null;
                    sala.slotslen[m].Status = 0;
                    sala.slotslen[m].AFK    = false;
                    sala.slotslen[m].Lider  = false;
                }
            }
            user.AtualSala = sala;

            PacketManager Write = new PacketManager();

            Write.OP(25);
            Write.Int(0);
            Write.UStr(user.pInfo.usuario);
            Write.Int(user.pInfo.userid);
            Write.UStr(user.pInfo.nickname);
            Write.Int(indexcharacter);
            Write.Byte((byte)iPersonagemID);
            Write.Hex("00 FF 00 FF 00 FF 00 00 00 00 00 01 00 00 00 64 00 00");
            Write.Int(user.pInfo.gamePoint);
            Write.Byte(0);
            Write.Byte(0);
            Write.Hex("00 00 00 4E 00 00 00 07 00 00 00 01 01 01 00 00 00 00 00 00 00 00 00 08 00 00 00 01 01 01 00 00 00 00 00 00 00 00 00 09 00 00 00 01 01 01 00 00 00 00 00 00 00 00 00 0A 00 00 00 01 01 01 00 00 00 00 00 00 00 00 00 0B 00 00 00 01 01 01 00 00 00 00 00 00 00 00 00 0C 00 00 00 01 01 01 00 00 00 00 00 00 00 00 00 0D 00 00 00 01 01 01 00 00 00 00 00 00 00 00 00 0E 00 00 00 01 01 01 00 00 00 00 00 00 00 00 00 0F 00 00 00 01 01 01 00 00 00 00 00 00 00 00 00 10 00 00 00 01 01 01 00 00 00 00 00 00 00 00 00 11 00 00 00 01 01 01 00 00 00 00 00 00 00 00 00 12 00 00 00 01 01 01 00 00 00 00 00 00 00 00 00 13 00 00 00 00 00 00 00 00 00 00 00 00 00 00 14 00 00 00 00 00 00 00 00 00 00 00 00 00 00 15 00 00 00 00 00 00 00 00 00 00 00 00 00 00 16 00 00 00 00 00 00 00 00 00 00 00 00 00 00 17 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18 00 00 00 00 00 00 00 00 00 00 00 00 00 00 19 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 00 00 00 00 00 00 00 00 00 00 00 27 00 00 00 01 01 00 00 00 00 00 00 00 00 00 00 28 00 00 00 01 01 00 00 00 00 00 00 00 00 00 00 29 00 00 00 01 01 00 00 00 00 00 00 00 00 00 00 2A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 33 00 00 00 00 00 00 00 00 00 00 00 00 00 00 34 00 00 00 00 00 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 00 00 00 00 00 00 00 00 00 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 38 00 00 00 00 00 00 00 00 00 00 00 00 00 00 39 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 43 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 45 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 47 00 00 00 00 00 00 00 00 00 00 00 00 00 00 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 49 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 51 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 00 00 00 00 00 00 00 00 00 00 00 00 00 00 53 00 00 00 00 00 00 00 00 00 00 00 00 00 00 54 00 00 00 01 01 00 00 00 00 00 00 00 00 00 00 55 00 00 00 00 00 00 00 00 00 00 00 00 00 00 56 00 00 00 00 00 00 00 00 00 00 00 00 00 00 57 00 00 00 00 00 00 00 00 00 00 00 00 00 00 58 00 00 00 00 00 00 00 00 00 00 00 00 00 00 59 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5A 00 00 00 01 01 00 00 00 00 00 00 00 00 00 00 5B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5F 00 00 00 00 00 00 00 00 00 00 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00");
            charsInfo.GetCharactersFromDB(pInfo.userid);;
            Write.Int(charsInfo.getLength());
            for (int countchar = 0; countchar < charsInfo.getLength(); countchar++)
            {
                Write.Byte((byte)charsInfo.personagems[countchar].personagemid);
                Write.Int(0);
                Write.Byte((byte)charsInfo.personagems[countchar].classe);
                Write.Int(0);
                Write.Byte(0);
                Write.Int(charsInfo.personagems[countchar].experiencia);
                Write.Int(charsInfo.personagems[countchar].nivel);
                Write.Int(charsInfo.personagems[countchar].vitoria);
                Write.Int(charsInfo.personagems[countchar].derrota);

                Write.Int(charsInfo.personagems[countchar].equipamentos.Length);
                for (int equipscount = 0; equipscount < charsInfo.personagems[countchar].equipamentos.Length; equipscount++)
                {
                    Write.Int(charsInfo.personagems[countchar].equipamentos[equipscount].itemid);
                    Write.Int(1);
                    Write.Int(charsInfo.personagems[countchar].equipamentos[equipscount].itemuid);
                    Write.Int(0);
                    Write.Int(0);
                    Write.Int(0);
                    Write.Int(0);
                    Write.UShort(0);
                }
                Write.Hex("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF 00 00 00 01 00");
                Write.Int(0);
                Write.Int(255);
                Write.Int(160);
                Write.Hex("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 00 FF 00 00 00 00 00 00");
                Write.Int(0);
                Write.Hex("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 2C 00 00 01 2C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 07");
            }
            Write.Hex("00 00 00 03 01 58 A8 C0 01 8E A8 C0 01 00 00 7F 00 00 00 01 7E FE 00 00 00 00 00 00 00 00 00 00 00 02 00 00 00 00 00 00 E5 6A 00 00 00 01 31 7F 24 36 00 00 00 00 01 00 00 E5 88 00 00 00 01 31 7F 24 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 01 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00");
            Write.Int(user.AtualSala.SalaID);
            Write.UStr(user.AtualSala.SalaNome);
            Write.Hex("01 00");
            Write.UStr(user.AtualSala.SalaSenha);
            Write.Short((short)sala.PlayersEmSala());
            Write.Short((short)(sala.PlayersEmSala() + sala.slotsAbertos()));
            Write.Short(6);
            Write.Byte((byte)sala.MatchMode);
            Write.Int(sala.GameMode);
            Write.Int(sala.ITMode);
            Write.Boolean(sala.RndMap);
            Write.Int(sala.Map);
            Write.Int(12);
            Write.Hex("00 01 01 01 00 00 FF FF FF FF 00 00 00 00 00 00 00 00 01 AA DC 63 C0 25 80 AA DC 63 C0 25 E4 01 00 01 00 00 01 2C 00 00 00 14 00 00 1A 4A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 01 00 00 00 01");

            user.Send(Write.ack);
        }
예제 #23
0
        public ReadersViewModel()
        {
            MOYABAZAEntities model = App.MOYABAZA;

            model.Читатели.Load();
            Readers = CollectionViewSource.GetDefaultView(model.Читатели.Local);

            AddCommand = new RelayCommand(
                (param) =>
            {
                Читатели reader       = new Читатели();
                ReadersReg readersReg = new ReadersReg(model, reader);
                readersReg.ShowDialog();
                if (readersReg.DialogResult == true)
                {
                    model.Читатели.Local.Add(reader);
                    try
                    {
                        model.SaveChanges();
                    }
                    catch (DbUpdateException e)
                    {
                        model.Читатели.Local.Remove(reader);
                        MessageBox.Show($"Такой reader уже существует! \n {e.Message}");
                    }
                    Readers.Refresh();
                }
            },
                (param) => App.ActiveUser.Пользователи_Объекты.Count(uo => uo.Объекты.SName == Constants.ReadersName && uo.W == 1) != 0);

            ChangeCommand = new RelayCommand(
                (param) =>
            {
                ReadersReg readersReg = new ReadersReg(model, _selectedReader);
                readersReg.ShowDialog();
                if (readersReg.DialogResult == true)
                {
                    try
                    {
                        model.SaveChanges();
                    }
                    catch (DbUpdateException e)
                    {
                        model.Entry(_selectedReader).State = EntityState.Unchanged;
                        MessageBox.Show($"Такой reader уже существует! \n {e.Message}");
                    }
                    Readers.Refresh();
                }
                else
                {
                    model.Entry(_selectedReader).State = EntityState.Unchanged;
                }
            },
                (param) => App.ActiveUser.Пользователи_Объекты.Count(uo => uo.Объекты.SName == Constants.ReadersName && uo.E == 1) != 0 && param != null);

            DeleteCommand = new RelayCommand(
                (param) =>
            {
                if (MessageBox.Show("Уверен?", "Назад дороги не будет", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes)
                {
                    try
                    {
                        if (_selectedReader.Выданные_книги.Count != 0)
                        {
                            throw new DbUpdateException("У читателя есть выданные книги!!!!");
                        }
                        model.Читатели.Remove(_selectedReader);
                        model.SaveChanges();
                    }
                    catch (DbUpdateException ex)
                    {
                        MessageBox.Show($"Произошла ошибка при удалении данных: {Environment.CommandLine}{ex.Message}", "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            },
                (param) => App.ActiveUser.Пользователи_Объекты.Count(uo => uo.Объекты.SName == Constants.ReadersName && uo.D == 1) != 0 && param != null);

            ReturnBookCommand = new RelayCommand(
                (param) =>
            {
                IssuingBooksFormMVVM issuingBooksForm = new IssuingBooksFormMVVM(SelectedReader);
                issuingBooksForm.ShowDialog();
            },
                (param) => App.ActiveUser.Пользователи_Объекты.Count(uo => uo.Объекты.SName == Constants.ReadersName && uo.E == 1) != 0 && param != null); // Возможно нужно добавить ещё уровень доступа

            IssueBookCommand = new RelayCommand(
                (param) =>
            {
                IssuingBooksReader issuingBooksReader = new IssuingBooksReader(SelectedReader);
                issuingBooksReader.ShowDialog();
            },
                (param) => App.ActiveUser.Пользователи_Объекты.Count(uo => uo.Объекты.SName == Constants.ReadersName && uo.E == 1) != 0 && param != null); // Возможно нужно добавить ещё уровень доступа

            Readers.Filter = FilterFunction;
        }
예제 #24
0
 /// <summary>
 /// 修改读者信息
 /// </summary>
 /// <param name="reader"></param>
 /// <returns></returns>
 public int EditReader(Readers reader)
 {
     return(readerDao.EditReader(reader));
 }
예제 #25
0
        internal override IEnumerable<Token> Tokenize(Readers.CharReader reader)
        {
            IEnumerable<Token> tokens = base.Tokenize(reader);

            if (IncludeWhitespace && IncludeControlChars)
                return tokens;

            if (!IncludeWhitespace)
                return tokens.Where(t => !(t is WhitespaceToken));
            if (!IncludeControlChars)
                return tokens.Where(t => !(t is ControlCharsToken) && !(t is ByteOrderMarkToken));

            return tokens;
        }
예제 #26
0
 public MainWindow()
 {
     InitializeComponent();
     readers = new Readers(ReaderScope.User);
 }
예제 #27
0
 public IApplicationReader GetReader(string login)
 {
     return(Readers.Find(u => u.Login == login));
 }
예제 #28
0
        public int Undone(int current, DateTime time)
        {
            {
                int step = current;

                try
                {
                    List <ReadersHistory> history;

                    using (LibContext context = new LibContext())
                    {
                        history = context.ReadersHistory.Where(c => c.OperationDate <= time).ToList();
                        history.Reverse();
                        GenericRepository <Readers> generic = new GenericRepository <Readers>(context);

                        if (step < history.Count && step >= 0)
                        {
                            ReadersHistory pacient   = history[step];
                            string         operation = pacient.Operation;

                            context.Database.ExecuteSqlCommand("DISABLE TRIGGER ReadersHistory ON Readers");
                            context.Database.ExecuteSqlCommand("DISABLE TRIGGER ReadersInsert ON Readers");

                            if (operation == "inserted")
                            {
                                Readers entity = generic.Get(c => c.Id == pacient.Id).FirstOrDefault();
                                if (entity != null)
                                {
                                    generic.Remove(entity);
                                }
                            }
                            else if (operation == "updated")
                            {
                                Readers entity = generic.Get(c => c.Id == pacient.Id).FirstOrDefault();
                                if (entity != null)
                                {
                                    entity.Surname    = pacient.HistorySurname;
                                    entity.Name       = pacient.HistoryName;
                                    entity.Patronymic = pacient.HistoryPatronymic;
                                    entity.BirthDate  = pacient.HistoryBirthDate;
                                    entity.PassSeria  = pacient.HistoryPassSeria;
                                    entity.PassNumber = pacient.HistoryPassNumber;
                                    entity.Phone      = pacient.HistoryPhone;
                                    entity.Address    = pacient.HistoryAddress;
                                    entity.UserId     = pacient.HistoryUserId;

                                    generic.Update(entity);
                                }
                            }
                            else if (operation == "deleted")
                            {
                                Readers entity = new Readers
                                {
                                    Id         = pacient.Id,
                                    Surname    = pacient.HistorySurname,
                                    Name       = pacient.HistoryName,
                                    Patronymic = pacient.HistoryPatronymic,
                                    BirthDate  = pacient.HistoryBirthDate,
                                    PassSeria  = pacient.HistoryPassSeria,
                                    PassNumber = pacient.HistoryPassNumber,
                                    Phone      = pacient.HistoryPhone,
                                    Address    = pacient.HistoryAddress,
                                    UserId     = pacient.HistoryUserId
                                };

                                using (var scope = context.Database.BeginTransaction())
                                {
                                    context.Readers.Add(entity);
                                    context.SaveChanges();
                                    scope.Commit();
                                }
                            }

                            context.Database.ExecuteSqlCommand("ENABLE TRIGGER ReadersHistory ON Readers");
                            context.Database.ExecuteSqlCommand("ENABLE TRIGGER ReadersInsert ON Readers");
                        }
                    }
                    step++;
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
                return(step);
            }
        }
        /// <summary>
        /// finds usages of the generic read/write methods and generates read/write functions for them.
        /// <para/>
        /// traverses from non generic classes up thru base types
        /// in order to replace generic parameters with their corresponding generic arguments.
        /// </summary>
        public static void Process(ModuleDefinition module, Writers writers, Readers readers, ref bool weavingFailed)
        {
            var sw = Stopwatch.StartNew();

            var NetworkWriter_Write = typeof(NetworkWriter).GetMethod(nameof(NetworkWriter.Write));
            var NetworkReader_Read  = typeof(NetworkReader).GetMethod(nameof(NetworkReader.Read));

            var count = 0;

            foreach (var type in module.GetTypes())
            {
                if (type.HasGenericParameters)
                {
                    continue;
                }

                TypeReference currentType = type;
                while (currentType != null)
                {
                    var currentTypeDef = currentType.Resolve();
                    foreach (var method in currentTypeDef.Methods)
                    {
                        if (!method.HasBody)
                        {
                            continue;
                        }
                        foreach (var instruction in method.Body.Instructions)
                        {
                            if (instruction.Operand is not GenericInstanceMethod calledMethod)
                            {
                                continue;
                            }

                            if (calledMethod.DeclaringType.FullName == NetworkWriter_Write.DeclaringType.FullName &&
                                calledMethod.Name == NetworkWriter_Write.Name)
                            {
                                var argType = calledMethod.GenericArguments[0];

                                if (argType is GenericParameter genericParameter && genericParameter.Owner == currentTypeDef)
                                {
                                    argType = ((GenericInstanceType)currentType).GenericArguments[genericParameter.Position];
                                }

                                writers.GetWriteFunc(argType, ref weavingFailed);
                                count++;
                            }
                            else if (calledMethod.DeclaringType.FullName == NetworkReader_Read.DeclaringType.FullName &&
                                     calledMethod.Name == NetworkReader_Read.Name)
                            {
                                var argType = calledMethod.GenericArguments[0];

                                if (argType is GenericParameter genericParameter && genericParameter.Owner == currentTypeDef)
                                {
                                    argType = ((GenericInstanceType)currentType).GenericArguments[genericParameter.Position];
                                }

                                readers.GetReadFunc(argType, ref weavingFailed);
                                count++;
                            }
                        }
                    }

                    currentType = currentTypeDef.BaseType;
                }
            }

            Console.WriteLine($"got/generated {count} read/write funcs in {sw.ElapsedMilliseconds} ms");
        }
예제 #30
0
        }   // private int FixThisItem


        /// <summary>
        /// This private static method encapsulates the work of loading an
        /// embedded text file resource that consists of tab delimited strings,
        /// and parsing them into pairs of strrings.
        /// </summary>
        /// <param name="pstrEmbeddedResourceName">
        /// This string is expected to contain the unqualified name of the
        /// embedded text file resource, which is easy to grab from the Solution
        /// Explorer. This routine appends the extension, which must be .txt.
        /// </param>
        /// <returns>
        /// The return value is an array of StringFixups.StringFixup objects,
        /// each consisting of a pair of strings, one being a string for which
        /// to search, while its companion is the replacement string.
        /// </returns>
        private static StringFixups.StringFixup [ ] LoadStringFixups ( string pstrEmbeddedResourceName )
        {
            const string LABEL_ROW = @"JSON	VS";
            const string TSV_EXTENSION = @".txt";

            const int STRING_PER_RESPONSE = ArrayInfo.ARRAY_FIRST_ELEMENT;
            const int STRING_FOR_JSONCONVERTER = STRING_PER_RESPONSE + ArrayInfo.NEXT_INDEX;
            const int EXPECTED_FIELD_COUNT = STRING_FOR_JSONCONVERTER + ArrayInfo.NEXT_INDEX;

            string strEmbeddResourceFileName = string.Concat (
                pstrEmbeddedResourceName ,
                TSV_EXTENSION );
            string [ ] astrAllMapItems = Readers.LoadTextFileFromEntryAssembly ( strEmbeddResourceFileName );
            Parser parser = new Parser (
                CSVParseEngine.DelimiterChar.Tab ,
                CSVParseEngine.GuardChar.DoubleQuote ,
                CSVParseEngine.GuardDisposition.Strip );
            StringFixups.StringFixup [ ] rFunctionMaps = new StringFixups.StringFixup [ ArrayInfo.IndexFromOrdinal ( astrAllMapItems.Length ) ];

            for ( int intI = ArrayInfo.ARRAY_FIRST_ELEMENT ;
                      intI < astrAllMapItems.Length ;
                      intI++ )
            {
                if ( intI == ArrayInfo.ARRAY_FIRST_ELEMENT )
                {
                    if ( astrAllMapItems [ intI ] != LABEL_ROW )
                    {
                        throw new Exception (
                            string.Format (
                                Properties.Resources.ERRMSG_CORRUPTED_EMBBEDDED_RESOURCE_LABEL ,
                                new string [ ]
                                {
                                    strEmbeddResourceFileName ,                 // Format Item 0: internal resource {0}
                                    LABEL_ROW ,                                 // Format Item 1: Expected value = {1}
                                    astrAllMapItems [ intI ] ,                  // Format Item 2: Actual value   = {2}
                                    Environment.NewLine                         // Format Item 3: Platform-specific newline
                                } ) );
                    }   // if ( astrAllMapItems[intI] != LABEL_ROW )
                }   // TRUE (label row sanity check 1 of 2) block, if ( intI == ArrayInfo.ARRAY_FIRST_ELEMENT )
                else
                {
                    string [ ] astrFields = parser.Parse ( astrAllMapItems [ intI ] );

                    if ( astrFields.Length == EXPECTED_FIELD_COUNT )
                    {
                        rFunctionMaps [ ArrayInfo.IndexFromOrdinal ( intI ) ] = new StringFixups.StringFixup (
                            astrFields [ STRING_PER_RESPONSE ] ,
                            astrFields [ STRING_FOR_JSONCONVERTER ] );
                    }   // TRUE (anticipated outcome) block, if ( astrFields.Length == EXPECTED_FIELD_COUNT )
                    else
                    {
                        throw new Exception (
                            string.Format (
                                Properties.Resources.ERRMSG_CORRUPTED_EMBEDDED_RESOURCE_DETAIL ,
                                new object [ ]
                                {
                                    intI ,                                      // Format Item 0: Detail record {0}
                                    strEmbeddResourceFileName ,                 // Format Item 1: internal resource {1}
                                    EXPECTED_FIELD_COUNT ,                      // Format Item 2: Expected field count = {2}
                                    astrFields.Length ,                         // Format Item 3: Actual field count   = {3}
                                    astrAllMapItems [ intI ] ,                  // Format Item 4: Actual record        = {4}
                                    Environment.NewLine                         // Format Item 5: Platform-specific newline
                                } ) );
                    }   // FALSE (unanticipated outcome) block, if ( astrFields.Length == EXPECTED_FIELD_COUNT )
                }   // FALSE (detail row) block, if ( intI == ArrayInfo.ARRAY_FIRST_ELEMENT )
            }   // for ( int intI = ArrayInfo.ARRAY_FIRST_ELEMENT ; intI < astrAllMapItems.Length ; intI++ )

            return rFunctionMaps;
        }   // private static StringFixups.StringFixup [ ] GetSStringFixups
예제 #31
0
        internal ServiceConfig()
        {
            for (int i = 8; i < 13; i++)
            {
                var reader = new Reader
                {
                    Comment    = $"\n        Readers should be of format[Reader #] and TAG should be [Readers.Read_Tag_#]\n        i.e.Reader {i} \u21d4 Readers.Read_Tag_{i}\n      ",
                    Address    = IPAddress.Loopback.ToString(),
                    PortNum    = 6000,
                    ReaderName = $"Reader {i}",
                    Tags       = new Reader.ReaderTags()
                    {
                        ReaderTag = new Reader.ReaderTags.ReadTags()
                        {
                            ReadTag = $":RFID Readers.Readers.ReadTags.Read_Tag_{i}",
                            Note    = "Required, Type BOOLEAN"
                        },

                        WriterTag = new Reader.ReaderTags.WriteTags()
                        {
                            Note     = "Optional, Type BOOLEAN",
                            WriteTag = $"2:RFID Readers.Readers.WriteTags.Write_Tag_{i}"
                        },

                        UuidTag = new Reader.ReaderTags.UidTags()
                        {
                            Note    = "Required, Type STRING, Tag of unique ID of RFID Tag",
                            UuidTag = $"2:RFID Readers.Readers.UuidTags.Uuid_Tag_{i}"
                        },
                        ErrorTag = new Reader.ReaderTags.ErrorTags()
                        {
                            Note        = "Required, Used for Alarms and Events. Type BOOLEAN,STRING",
                            ErrorBool   = $"2:RFID Readers.Readers.AE.Error_B_Station_{i}",
                            ErrorString = $"2:RFID Readers.Readers.AE.Error_S_Station_{i}"
                        }
                    },
                    TimeOut = 10,
                    Uuid    = new Reader.Uid()
                    {
                        UidGuid = Guid.NewGuid(),
                        UidNote = "LEAVE THIS BLANK"
                    },
                    Active = false
                };
                Readers.Add(reader);
            }

            var opc = new OPC()
            {
                ServerAddress = IPAddress.Loopback.ToString(),
                ServerPort    = 49320,
                Auth          = new OPC.LogonAuth()
                {
                    Username       = "******",
                    Password       = "******",
                    AnonymousLogin = false,
                    Note           = "Provide either Username and Password OR AnonymousLogin as true"
                }
            };

            Server.Add(opc);
        }