Beispiel #1
0
        public Setup()
        {
            LoadPlugins();
            AllTitlesProcessed = false;
            CurrentTitle = null;
            CurrentTitleIndex = 0;
            current = this;
            //_titleCollection.loadTitleCollection();
            _ImporterSelection = new Choice();
            List<string> _Importers = new List<string>();
            foreach (OMLPlugin _plugin in availablePlugins) {
                OMLApplication.DebugLine("[Setup] Adding " + _plugin.Name + " to the list of Importers");
                _Importers.Add(_plugin.Description);
            }

            _ImporterSelection.Options = _Importers;
            _ImporterSelection.ChosenChanged += delegate(object sender, EventArgs e)
            {
                OMLApplication.ExecuteSafe(delegate
                {
                    Choice c = (Choice)sender;
                    ImporterDescription = @"Notice: " + GetPlugin().SetupDescription();
                    OMLApplication.DebugLine("Item Chosed: " + c.Options[c.ChosenIndex]);
                });
            };
        }
Beispiel #2
0
        public static List<Copy> GetAll()
        {
            List<Copy> allcopies = new List<Copy>{};

              SqlConnection conn = DB.Connection();
              conn.Open();

              SqlCommand cmd = new SqlCommand("SELECT * FROM copies;", conn);
              SqlDataReader rdr = cmd.ExecuteReader();

              while (rdr.Read())
              {
            int copyId = rdr.GetInt32(0);
            int copyBookId = rdr.GetInt32(1);

            Copy newCopy = new Copy(copyBookId, copyId);
            allcopies.Add(newCopy);
              }
              if (rdr != null)
              {
            rdr.Close();
              }
              if (conn != null)
              {
            conn.Close();
              }
              return allcopies;
        }
Beispiel #3
0
 public static void AddBytes(List<byte> list, byte[] array)
 {
     foreach (byte b in array)
     {
         list.Add(b);
     }
 }
Beispiel #4
0
        public static List<Patron> GetAll()
        {
            List<Patron> allPatrons = new List<Patron> {};
              SqlConnection conn = DB.Connection();
              conn.Open();
              SqlDataReader rdr = null;

              SqlCommand cmd = new SqlCommand ("SELECT * FROM patrons;", conn);

              rdr = cmd.ExecuteReader();

              while (rdr.Read())
              {
            int patronId = rdr.GetInt32(0);
            string patronFirstName = rdr.GetString(1);
            string patronLastName = rdr.GetString(2);
            string phoneNumber = rdr.GetString(3);
            Patron newPatron = new Patron (patronFirstName, patronLastName, phoneNumber, patronId);

            allPatrons.Add(newPatron);
              }
              if (rdr != null)
              {
            rdr.Close();
              }
              if (conn != null)
              {
            conn.Close();
              }
              return allPatrons;
        }
Beispiel #5
0
        public static List<Book> GetBooks(bool useDB)
        {
            try
            {
                DataTable table;
                List<Book> books = new List<Book>();
                if (useDB)
                {
                    table = DBLibrary.GetBooks(cs);
                }
                else
                {
                    table = DBLibrary.GetTestData();
                }
                Book book;
                foreach (DataRow row in table.Rows)
                {
                    book = new Book((int)row[0]);
                    book.Name = row["name"].ToString();
                    book.Author = row["author"].ToString();
                    book.Country = row["country"].ToString();
                    book.Year = (int)row["year"];
                    books.Add(book);
                }
                return books;
            }
            catch (Exception)
            {

                throw;
            }
        }
Beispiel #6
0
        public static List<Copy> GetAll()
        {
            List<Copy> allCopies = new List<Copy> {};
              SqlConnection conn = DB.Connection();
              conn.Open();
              SqlDataReader rdr = null;

              SqlCommand cmd = new SqlCommand ("SELECT * FROM copies;", conn);

              rdr = cmd.ExecuteReader();

              while (rdr.Read())
              {
            int copyId = rdr.GetInt32(0);
            DateTime copyCheckoutDate = rdr.GetDateTime(1);
            string copyCondition = rdr.GetString(2);
            int bookId = rdr.GetInt32(3);
            DateTime copyDueDate = rdr.GetDateTime(4);
            Copy newCopy = new Copy (copyCondition, bookId, copyCheckoutDate, copyDueDate, copyId);

            allCopies.Add(newCopy);
              }
              if (rdr != null)
              {
            rdr.Close();
              }
              if (conn != null)
              {
            conn.Close();
              }
              return allCopies;
        }
Beispiel #7
0
        public static List<byte> ConvertBoolsToBytes(bool[] data)
        {
            List<byte> result = new List<byte>();
            //wrap into 8 bit bunches of a byte

            byte eightBits = 0;
            int counter = 0;
            foreach (bool b in data)
            {
                //write to next location on eightBits

                if (b)
                {
                    eightBits |= Writer.Masks[counter];
                }

                counter++;

                if (counter > 7)
                {
                    counter = 0;
                    result.Add(eightBits);
                    eightBits = 0;
                }
            }

            if (counter > 0)
            {
                //pad out the eightBits with zeros then add
                result.Add(eightBits);
            }

            return result;
        }
Beispiel #8
0
        public void DownloadAllVideos(PDownload pDownload)
        {
            Broadcasts broadcasts = GetBroadcasts(pDownload.User);
            broadcasts.broadcasts = broadcasts.broadcasts.Where(b => b.available_for_replay || b.state == "RUNNING").ToList();
            if (pDownload.IsReverseOrder) broadcasts.broadcasts.Reverse();

            #region Selected Videos
            List<int> selectedVideos = pDownload.SelectedVideos;
            if (selectedVideos.Any())
            {
                List<Broadcast> selectedBroadcasts = new List<Broadcast>();
                selectedBroadcasts.AddRange(selectedVideos.Select(selectedVideo => broadcasts.broadcasts[selectedVideo]));
                broadcasts.broadcasts = selectedBroadcasts.ToList();
            }
            #endregion

            #region Selected Broadcasts
            List<string> selectedBroadcastsText = pDownload.SelectedBroadcasts;
            if (selectedBroadcastsText.Any())
            {
                broadcasts.broadcasts =
                    selectedBroadcastsText.Select(
                        selectedBroadcast => broadcasts.broadcasts.First(b => b.id == selectedBroadcast)).ToList();
            }
            #endregion

            Console.WriteLine(broadcasts.broadcasts.Count + " broadcasts found.");
            foreach (var broadcast in broadcasts.broadcasts)
            {
                DownloadVideos(broadcast, pDownload.DownloadLiveStream);
            }
        }
Beispiel #9
0
        private void LoadData(DTO.HoaDon data)
        {
            listHoaDonDetail = HoaDonDetailBus.GetListByIdHoaDon(data.Id);
            dataUser = data.User;

            lbMaHD.Text = data.MaHoaDon;
            lbNguoiNhap.Text = dataUser == null ? string.Empty : dataUser.UserName;
            lbNgayGio.Text = data.CreateDate.ToString(Constant.DEFAULT_DATE_TIME_FORMAT);
            lbGhiChu.Text = data.GhiChu;

            foreach (DTO.HoaDonDetail detail in listHoaDonDetail)
            {
                ListViewItem lvi = new ListViewItem();

                lvi.SubItems.Add(detail.SanPham.Id.ToString());
                lvi.SubItems.Add((lvThongTin.Items.Count + 1).ToString());
                lvi.SubItems.Add(detail.SanPham.MaSanPham + Constant.SYMBOL_LINK_STRING + detail.SanPham.Ten);
                lvi.SubItems.Add(detail.SoLuong.ToString());
                lvi.SubItems.Add(detail.SanPham.DonViTinh);
                lvi.SubItems.Add(detail.SanPham.GiaMua.ToString(Constant.DEFAULT_FORMAT_MONEY));
                lvi.SubItems.Add(detail.SanPham.GiaBan.ToString(Constant.DEFAULT_FORMAT_MONEY));
                lvi.SubItems.Add(detail.ThanhTien.ToString(Constant.DEFAULT_FORMAT_MONEY));

                lvThongTin.Items.Add(lvi);
            }

            lbTongHD.Text = data.ThanhTien.ToString(Constant.DEFAULT_FORMAT_MONEY);
        }
 private void btnBrowse_Click(object sender, EventArgs e)
 {
     if (openFileDialog1.ShowDialog() == DialogResult.OK)
     {
         btnUpload.Enabled = true;
         lblError.Text = "";
         #region dataGridView stuff
         List<String> files = openFileDialog1.SafeFileNames.ToList();
         List<Library.File> myFiles = new List<Library.File>();
         foreach (string f in files)
         {
             Library.File file = new Library.File(f, "", Project);
             myFiles.Add(file);
         }
         dataGridView1.DataSource = myFiles;
         dataGridView1.Columns.Remove("id");
         dataGridView1.Columns.Remove("VersionNr");
         dataGridView1.Columns.Remove("FileLock");
         dataGridView1.Columns.Remove("FileLockTime");
         dataGridView1.Columns.Remove("Project");
         dataGridView1.AutoResizeColumns();
         #endregion
         foreach (string filepath in openFileDialog1.FileNames)
         {
             fullFilePathList.Add(filepath);
             fileToUploadList.Add(Path.GetFileName(filepath));
         }
     }
 }
Beispiel #11
0
        private void buttonReserve_Click(object sender, EventArgs e)
        {
            LibraryReader.LibraryEntities context = new LibraryReader.LibraryEntities();

            List<int> books = new List<int>();

            foreach (DataGridViewRow row in dataGridViewBooks.SelectedRows)
            {
                if (row.Cells[0].Value != null)
                {
                    books.Add(Convert.ToInt32(row.Cells[0].Value));
                }
            }

            if (books.Count > 0)
            {

                var client = (from c in context.Clients
                              where c.ClientID == id
                              select c).SingleOrDefault();

                foreach (LibraryReader.ClientsBook cBook in client.ClientsBooks)
                {
                    if (books.Contains(cBook.BookID))
                    {
                        cBook.Reservation = true;
                        MessageBox.Show("Резервирането е успешно!");
                    }
                }

                context.SaveChanges();
            }
        }
 public BackEnd(string data)
 {
     words = new List<string>(data.Split(' ', '\r'));
     content = new List<string>(data.Split(' ', '\r', '\n'));
     frequency = BuildOccu(content);
     length = BuildLeng(content);
 }
        public override string ReadLine()
        {
            if (stream.Position == stream.Length)
            {
                return null;
            }

            var byteList = new List<int>();
            while (stream.Position != stream.Length)
            {
                int b = stream.ReadByte();
                if (b == (int)'\n')
                {
                    break;
                }
                else
                {
                    byteList.Add(b);
                }
            }
            while (byteList[byteList.Count - 1] == (int)'\r')
            {
                byteList.RemoveAt(byteList.Count - 1);
            }
            return Encoding.UTF8.GetString(byteList.Select(value => (byte)value).ToArray());
        }
Beispiel #14
0
        public override void Install(IDictionary stateSaver)
        {
            base.Install(stateSaver);

            var installdir = GetParameter("targetdir");

            string msg = "";
            foreach (var k in Context.Parameters.Keys)
                msg += (k + "\n");
            msg += "VALUES:\n";
            foreach (var v in Context.Parameters.Values)
                msg += (v + "\n");
            //MessageBox.Show(msg);

            List<string> writeableDirs = new List<string>();

            string configDir = Path.Combine(Path.Combine(installdir, "Myro"), "config");
            string storeDir = Path.Combine(Path.Combine(installdir, "Myro"), "store");

            writeableDirs.Add(configDir);
            writeableDirs.Add(storeDir);
            writeableDirs.AddRange(Directory.GetDirectories(configDir, "*", SearchOption.AllDirectories));
            writeableDirs.AddRange(Directory.GetDirectories(storeDir, "*", SearchOption.AllDirectories));

            string dirs = "";
            foreach (var d in writeableDirs)
            {
                dirs += (d + "\n");
                if (GrantModifyAccessToFolder("Everyone", d) != true)
                    throw new Exception("Couldn't make " + d + " writeable");
            }

            //MessageBox.Show("Made writeable:\n" + dirs);
        }
        public List<PortInfo> GetPortInfo()
        {
            List<PortInfo> portInfo = new List<PortInfo>();

            string ip = Convert.ToString(Net.GetExternalIpAddress(30000));
            foreach (INetFwOpenPort port in GetAuthOpenPortsList())
            {
                portInfo.Add(new PortInfo()
                {
                    IP = ip,
                    Port = port.Port,
                    Name = port.Name
                });
                //sb.AppendLine(ip + ":" + port.Port + " - " + port.Name + " - " + port.Enabled + " - " + port.IpVersion);
                Console.WriteLine(port.Port + ", " + port.Name);
            }
            /*StringBuilder sb = new StringBuilder();
            foreach (INetFwOpenPort port in GetAuthOpenPortsList())
            {
                
                sb.AppendLine(ip + ":" + port.Port + " - " + port.Name + " - " + port.Enabled + " - " + port.IpVersion);
                Console.WriteLine(port.Port + ", " + port.Name);
            }
            System.Windows.Forms.MessageBox.Show(sb.ToString());*/
            return portInfo;
        }
Beispiel #16
0
        public Server()
        {
            path = Directory.GetCurrentDirectory();
            configFile = Path.Combine(path, "patients.json");
            try
            {
                Console.WriteLine("loading session");
                patients = JsonCommunication.loadPatientsJson(configFile);
            }
            catch (Exception)
            {
                Console.WriteLine("no sessions to load");
                patients = new List<Patient>(); // to be replaced with list loaded from patient document
            }

            serverListener = new TcpListener(IPAddress.Any, Port);
            serverListener.Start();
            Console.WriteLine("Server gestart, wachten op verbindingen...\r\n");
            while (true)
            {
                Console.WriteLine("Wachten op verbindingen...\r\n");
                TcpClient tcp = serverListener.AcceptTcpClient();
                new Thread(Handler).Start(tcp);
                Console.WriteLine("Nieuwe verbinding geaccepteerd.\r\n");
            }
        }
Beispiel #17
0
        public static List<Author> GetAll()
        {
            List<Author> allAuthors = new List<Author> {};
              SqlConnection conn = DB.Connection();
              conn.Open();
              SqlDataReader rdr = null;

              SqlCommand cmd = new SqlCommand ("SELECT * FROM authors;", conn);

              rdr = cmd.ExecuteReader();

              while (rdr.Read())
              {
            int authorId = rdr.GetInt32(0);
            string authorName = rdr.GetString(1);
            Author newAuthor = new Author (authorName, authorId);
            allAuthors.Add(newAuthor);
              }
              if (rdr != null)
              {
            rdr.Close();
              }
              if (conn != null)
              {
            conn.Close();
              }
              return allAuthors;
        }
        public DataBaseSingleton()
        {
            Console.WriteLine("Создание объекта класса DataBaseSingleton");

            _employeesList = new List<Employee>();
            CreateTestRecords();
        }
Beispiel #19
0
        public static string GetString(Container container)
        {
            StringBuilder result = new StringBuilder();
            List<byte> bytes = new List<byte>();
            byte[] containerBytes = container.GetData().ToArray();
            for (int i = 0; i < 3; i++)
            {
                PrintLine(result, containerBytes[i]);
            }

            foreach (Frame frame in container.Frames)
            {
                result.AppendLine(string.Empty);
                result.Append(GetString(frame));

                foreach (Chunk chunk in frame.Chunks)
                {
                    result.AppendLine(string.Empty);
                    byte[] output = chunk.GetData().ToArray();
                    foreach (byte b in output)
                    {
                        PrintLine(result, b);
                    }
                }
            }

            return result.ToString();
        }
Beispiel #20
0
        public static List<Book> GetAll()
        {
            List<Book> allBooks = new List<Book>();

              SqlConnection connection = DB.Connection();
              connection.Open();

              SqlCommand command = new SqlCommand("SELECT * FROM books;", connection);
              SqlDataReader reader = command.ExecuteReader();

              while (reader.Read())
              {
            int id = reader.GetInt32(0);
            string title = reader.GetString(1);
            Book book = new Book(title, id);
            allBooks.Add(book);
              }

              if (reader != null)
              {
            reader.Close();
              }
              if (connection != null)
              {
            connection.Close();
              }
              return allBooks;
        }
        public MovieGallery(List<TitleFilter> filters)
        {
            this.filters = filters;

            if (filters != null && filters.Count != 0)
            {
                // create the title given the list of filters
                StringBuilder sb = new StringBuilder(filters.Count * 10);
                sb.Append(Filter.Home);

                foreach (TitleFilter filter in filters)
                {
                    sb.Append(" > ");
                    if (!string.IsNullOrEmpty(filter.FilterText))
                        sb.Append(filter.FilterText);
                    else
                        sb.Append(filter.FilterType.ToString());
                }

                _title = sb.ToString();
            }
            else
            {
                _title = Filter.Home;
            }

            Initialize(TitleCollectionManager.GetFilteredTitles(this.filters));
        }
Beispiel #22
0
 public static List<Book> GetTestBooks()
 {
     List<Book> temp = new List<Book>();
     temp.Add(new Book(1, "Sota ja rauha", "Leo Tolstoi", "Venäjä", 1867));
     temp.Add(new Book(2, "Anna Karenina", "Leo Tolstoi", "Venäjä", 1877));
     return temp;
 }
Beispiel #23
0
        private void buttonReLoan_Click(object sender, EventArgs e)
        {
            LibraryReader.LibraryEntities context = new LibraryReader.LibraryEntities();

            List<int> books = new List<int>();

            foreach (DataGridViewRow row in dataGridViewLoaned.SelectedRows)
            {
                if (row.Cells[0].Value != null)
                {
                    books.Add(Convert.ToInt32(row.Cells[0].Value));
                }
            }

            if (books.Count > 0)
            {

                var client = (from c in context.Clients
                              where c.ClientID == id
                              select c).SingleOrDefault();

                foreach (LibraryReader.ClientsBook cBook in client.ClientsBooks)
                {
                    if (books.Contains(cBook.BookID))
                    {
                        cBook.DateLoaned = DateTime.Now;
                        cBook.DateReturned = DateTime.Now.AddMonths(1);
                        MessageBox.Show("Презаписването е успешно!");
                    }
                }

                context.SaveChanges();
            }
        }
Beispiel #24
0
        public Filter(MovieGallery gallery, TitleFilterType filterType, List<TitleFilter> existingFilters)
        {
            this.filterType = filterType;
            this.existingFilters = existingFilters;

            _gallery = gallery;
        }
Beispiel #25
0
        public static void AddBytes(List<byte> list, int value)
        {
            byte b0 = (byte)value;
            byte b1 = (byte)(value >> 8);

            list.Add(b0);
            list.Add(b1);
        }
Beispiel #26
0
 /// <summary>
 /// Taken from png Sub filter, not sure if this is useful with existing ordering
 /// </summary>
 /// <param name="values"></param>
 public static void Filter(List<byte> values)
 {
     List<byte> raw = new List<byte>(values);
     for (int i = 1; i < values.Count; i++)
     {
         values[i] = (byte)((raw[i] - raw[i - 1]) & 0xff);
     }
 }
Beispiel #27
0
 public static bool WriteFile(List<string> lines, string fileName)
 {
     var theFile = string.Format("{0}\\{1}", GetPath(), fileName);
     if (File.Exists(theFile))
         File.Delete(theFile);
     File.WriteAllLines(theFile, lines);
     return true;
 }
 public Wave(string enemy_type ,int total_number, float spawn_rate, Queue<Vector2> waypoints, float grow_rate)
 {
     this.spawn_rate = spawn_rate;
     this.grow_rate = grow_rate;
     this.enemy_type = enemy_type;
     this.total_number = total_number;
     this.waypoints = waypoints;
     this.active_enemies = new List<Enemy>();
 }
Beispiel #29
0
        public static void AddBytes32(List<byte> list, int value)
        {
            byte[] byteArray = BitConverter.GetBytes(value);

            list.Add(byteArray[0]);
            list.Add(byteArray[1]);
            list.Add(byteArray[2]);
            list.Add(byteArray[3]);
        }
        public VirtualDirectory(string[] paths)
        {
            childDirectories = new List<VirtualDirectory>();

            foreach (string path in paths)
            {
                this.AddChildDirectory(path);
            }
        }