Esempio n. 1
0
        public ModelPicture(FilePicture file)
        {
            InitializeComponent();

            _file = file;

            BitmapImage src = new BitmapImage();

            src.BeginInit();
            src.UriSource = new Uri(_file.FullName, UriKind.Absolute);
            src.EndInit();
            img.Source = src;
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static FileType NewFileType(FileInfo file)
        {
            FileType newFileType;

            if (file.Extension == extensionBSL)
            {
                var text          = File.ReadAllLines(file.FullName);
                var newFileModule = new FileModule();
                newFileModule.FunctionList = Parser.Parse(text, newFileModule);
                newFileType = newFileModule;
            }
            else if (file.Extension == extensionMDO)
            {
                newFileType = new FileMdo();
            }
            else if (file.Extension == extensionPNG)
            {
                newFileType = new FilePicture();
            }
            else if (file.Extension == extensionMXLX)
            {
                newFileType = new FileMXLX();
            }
            else if (file.Extension == extensionHTML)
            {
                newFileType = new FileHTML();
            }
            else if (file.Extension == extensionZIP)
            {
                newFileType = new FileZIP();
            }
            else if (file.Extension == extensionFORM)
            {
                newFileType = new FileForm();
            }
            else
            {
                newFileType = new FileOther();
            }

            newFileType.Name     = file.Name;
            newFileType.FullName = file.FullName;
            return(newFileType);
        }
Esempio n. 3
0
 /// <summary>
 /// Liefert XElement mit den "allgemeinen" Daten
 /// </summary>
 /// <param name="saveToFile">Pfad in welche Datei gespeichert wird (wichtig für relativen Pfad des FilePictures)</param>
 /// <returns>Erzeugtes XElement</returns>
 protected XElement GetRootPropsElement(L3dFilePath saveToFile)
 {
     return(new XElement(FileDescriptions.FILE_GENERAL_EL_PROPS,
                         new XAttribute(FileDescriptions.FILE_GENERAL_AT_AUTHOR, FileAuthor ?? ""),
                         new XAttribute(FileDescriptions.FILE_GENERAL_AT_INFO, FileInfo ?? ""),
                         new XAttribute(FileDescriptions.FILE_GENERAL_AT_PICTURE, FilePicture.GetPathRelativeToFile(saveToFile)),
                         new XAttribute(FileDescriptions.FILE_GENERAL_AT_DOKU, FileDoku.GetPathRelativeToFile(saveToFile))));
 }
Esempio n. 4
0
        protected void btnApply_Click(object sender, EventArgs e)
        {
            using (SqlConnection Con = new SqlConnection(Helper.GetConnection()))
            {
                Con.Open();

                // Verifies if Email is Existing.
                bool exists = false;
                using (SqlCommand cmd = new SqlCommand("SELECT COUNT(*) FROM applicant_basic_info WHERE a_email = @email", Con))
                {
                    cmd.Parameters.AddWithValue("@email", txtEmail.Text);
                    exists = (int)cmd.ExecuteScalar() > 0;
                }

                // If email already exists
                // Error Code will be shown
                // test
                if (exists)
                {
                    error.Visible = true;
                }

                //Else the registration will continue.
                else
                {
                    string SQL = @"INSERT INTO applicant_basic_info (access_type_id, user_statusid, a_email, a_password, first_name, middle_name, last_name, 
                                                        date_of_birth, gender, applicant_cv, applicant_profile_picture)

                                              VALUES (@access_type_id, @user_statusid, @a_email, @a_password, @first_name, @middle_name, @last_name, 
                                                      @date_of_birth, @gender, @applicant_cv, @applicant_profile_picture)";

                    using (SqlCommand cmd = new SqlCommand(SQL, Con))

                    {
                        cmd.Parameters.AddWithValue("@access_type_id", 1);
                        cmd.Parameters.AddWithValue("@user_statusid", 1);

                        cmd.Parameters.AddWithValue("@a_email", txtEmail.Text);
                        cmd.Parameters.AddWithValue("@a_password", txtPW.Text);


                        cmd.Parameters.AddWithValue("@first_name", txtFN.Text);
                        cmd.Parameters.AddWithValue("@middle_name", txtMN.Text);
                        cmd.Parameters.AddWithValue("@last_name", txtLN.Text);

                        cmd.Parameters.AddWithValue("@date_of_birth", txtBirthDate.Text);
                        cmd.Parameters.AddWithValue("@gender", DropDownList7.SelectedItem.Value);

                        string fileExt = Path.GetExtension(FileContent.FileName);
                        string id      = Guid.NewGuid().ToString();
                        cmd.Parameters.AddWithValue("@applicant_cv", id + fileExt);
                        FileContent.SaveAs(Server.MapPath("~/Files/CV/" + id + fileExt));

                        string fileExt2 = Path.GetExtension(FilePicture.FileName);
                        string id2      = Guid.NewGuid().ToString();
                        cmd.Parameters.AddWithValue("@applicant_profile_picture", id2 + fileExt2);
                        FilePicture.SaveAs(Server.MapPath("~/Files/img/" + id2 + fileExt2));

                        cmd.ExecuteNonQuery();

                        Response.Redirect("~/Default.aspx");
                    }
                }
            }
        }
Esempio n. 5
0
        private void InitCover(Tag tag)
        {
            IPicture pic = null;

            foreach (var p in tag.Pictures)
            {
                if (p.Type == PictureType.FrontCover)
                {
                    pic = p;
                    break;
                }
                switch (p.Type)
                {
                case PictureType.Other:
                case PictureType.OtherFileIcon:
                case PictureType.FileIcon:
                    pic = p;
                    break;

                default:
                    if (pic == null)
                    {
                        pic = p;
                    }
                    break;
                }
            }

            // Check for art in the files folder
            var maybeAlbumFolder = false;

            if (pic == null)
            {
                var fileGuid = string.Empty;
                // We could check all files with the same extension all have the same artist or album
                // For now just check if we have 20 or less files with the same extension
                if (Item.Directory.GetFiles("*" + Item.Extension).Length <= 20)
                {
                    maybeAlbumFolder = true;
                }

                if (tag.TagTypes.HasFlag(TagTypes.Id3v2))
                {
                    File tagv2File = File.Create(Item.FullName);
                    var  tag2      = (TagLib.Id3v2.Tag)tagv2File.GetTag(TagTypes.Id3v2);

                    var pvt = TagLib.Id3v2.PrivateFrame.Get(tag2, "WM/WMCollectionID", false);
                    if (pvt != null)
                    {
                        var albumGuid = new Guid(pvt.PrivateData.Data);
                        fileGuid = albumGuid.ToString();
                    }
                }

                if (maybeAlbumFolder || !string.IsNullOrEmpty(fileGuid))
                {
                    var largeFiles = Directory.GetFiles(Item.Directory.FullName, AlbumArtPrefix + "*" + fileGuid + "*Large.jpg");
                    if (largeFiles.Length > 0)
                    {
                        pic = new FilePicture(new FileInfo(largeFiles[0]));
                    }
                }
            }

            if (pic == null && maybeAlbumFolder)
            {
                var albumFolderImg = System.IO.Path.Combine(Item.Directory.FullName, AlbumFolder);
                if (System.IO.File.Exists(albumFolderImg))
                {
                    pic = new FilePicture(new FileInfo(albumFolderImg));
                }
            }

            if (pic != null)
            {
                try {
                    CachedCover = new Cover(Item, pic.Data.ToStream());
                }
                catch (Exception ex) {
                    Debug("Failed to generate thumb for " + Item.FullName, ex);
                }
            }
        }