Inheritance: System.EventArgs
コード例 #1
0
    protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {
        if (e == null)
        {
            throw new ArgumentNullException(nameof(e));
        }

        if (e.State != AjaxControlToolkit.AjaxFileUploadState.Success)
        {
            return;
        }

        using (FlightData fd = new FlightData())
        {
            if (fd.ParseFlightData(System.Text.Encoding.UTF8.GetString(e.GetContents())))
            {
                if (fd.HasLatLongInfo)
                {
                    Coordinates.AddRange(fd.GetTrajectory());
                    HasTime  = HasTime && fd.HasDateTime;
                    HasAlt   = HasAlt && fd.HasAltitude;
                    HasSpeed = HasSpeed && fd.HasSpeed;
                }
            }
            else
            {
                lblErr.Text = fd.ErrorString;
            }
        }

        e.DeleteTemporaryData();
    }
コード例 #2
0
    protected void AjaxFileUpload1_OnUploadComplete(object sender, AjaxFileUploadEventArgs file)
    {
        // User can save file to File System, database or in session state
        if(file.ContentType.Contains("jpg") || file.ContentType.Contains("gif")
            || file.ContentType.Contains("png") || file.ContentType.Contains("jpeg")) {

            // Limit preview file for file equal or under 4MB only, otherwise when GetContents invoked
            // System.OutOfMemoryException will thrown if file is too big to be read.
            if(file.FileSize <= 1024 * 1024 * 4) {
                Session["fileContentType_" + file.FileId] = file.ContentType;
                Session["fileContents_" + file.FileId] = file.GetContents();

                // Set PostedUrl to preview the uploaded file.
                file.PostedUrl = string.Format("?preview=1&fileId={0}", file.FileId);
            } else {
                file.PostedUrl = "fileTooBig.gif";
            }

            // Since we never call the SaveAs method(), we need to delete the temporary fileß
            file.DeleteTemporaryData();
        }

        // In a real app, you would call SaveAs() to save the uploaded file somewhere
        // AjaxFileUpload1.SaveAs(MapPath("~/App_Data/" + file.FileName), true);
    }
コード例 #3
0
    protected void afuUpload_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {
        if (e == null)
        {
            throw new ArgumentNullException(nameof(e));
        }
        if (e.State != AjaxControlToolkit.AjaxFileUploadState.Success)
        {
            return;
        }

        PendingFlight pf = new PendingFlight()
        {
            User = Page.User.Identity.Name
        };
        string szOriginal = pf.FlightData = System.Text.Encoding.UTF8.GetString(e.GetContents());

        using (FlightData fd = new FlightData())
        {
            fd.AutoFill(pf, (AutoFillOptions)Session[SessionKeyOpt]);

            pf.FlightData = string.Empty;
            LogbookEntry leEmpty = new PendingFlight()
            {
                User = Page.User.Identity.Name, FlightData = string.Empty
            };
            if (!pf.IsEqualTo(leEmpty))
            {
                pf.TailNumDisplay = fd.TailNumber ?? string.Empty;
                pf.FlightData     = szOriginal;
                pf.Commit();
            }
        }
    }
コード例 #4
0
    protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {
        byte[] image = e.GetContents();

        MembershipUser currentUser = Membership.GetUser();

        if (currentUser != null)
        {
            currentUserId = (Guid)currentUser.ProviderUserKey;


            string connectionString =
                ConfigurationManager.ConnectionStrings["SecurityConnectionString"].ConnectionString;
            string updateSql = "UPDATE UserProfiles SET BackgroundPicture = @BackgroundPicture WHERE UserId = @UserId";
            try
            {
                using (SqlConnection myConnection = new SqlConnection(connectionString))
                {
                    myConnection.Open();
                    SqlCommand myCommand = new SqlCommand(updateSql, myConnection);
                    myCommand.Parameters.AddWithValue("@UserId", currentUserId);
                    myCommand.Parameters.AddWithValue("@BackgroundPicture", image);
                    myCommand.ExecuteNonQuery();
                    myConnection.Close();
                }
            }
            catch { }
        }
        this.DataBind();
        e.DeleteTemporaryData();
    }
コード例 #5
0
        void XhrDone(string fileId)
        {
            AjaxFileUploadEventArgs args;

            var tempFolder = BuildTempFolder(fileId);

            if (!Directory.Exists(tempFolder))
            {
                return;
            }

            var files = Directory.GetFiles(tempFolder);

            if (files.Length == 0)
            {
                return;
            }

            var fileInfo = new FileInfo(files[0]);

            _uploadedFilePath = fileInfo.FullName;

            args = new AjaxFileUploadEventArgs(
                fileId, AjaxFileUploadState.Success, "Success", fileInfo.Name, (int)fileInfo.Length,
                fileInfo.Extension);

            if (UploadComplete != null)
            {
                UploadComplete(this, args);
            }

            Page.Response.Write(new JavaScriptSerializer().Serialize(args));
        }
コード例 #6
0
    public void AjaxFileUploadKelengkapan_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {
        if (Session["userid"] is object)
        {
            userid = Session["userid"].ToString();
        }

        //string user = "";
        string wilayah = "";

        LANDCOMP.generateNUm gn = new LANDCOMP.generateNUm();
        gn.Datas();

        string _stNomor;

        string _stDates = DateTime.Today.ToString("yyyyMMdd");

        string uploadFolder = Request.PhysicalApplicationPath + "uploadDocument\\";

        LANDCOMP.paramz ext = new LANDCOMP.paramz();

        ext.setExtension(Path.GetExtension(e.FileName));

        if (ext.getExtsion() != ".exe")
        {
            _stFAsli = System.IO.Path.GetFileName(e.FileName);


            _stNomor = gn.GenerateNumber("", 101, 3, _stDates, userid);

            AjaxFileUploadKelengkapan.SaveAs(uploadFolder + _stNomor + ext.getExtsion());
            e.PostedUrl = string.Format(e.FileName + "|" + _stNomor + "|" + userid + "|" + wilayah);
        }
    }
コード例 #7
0
    protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {
        string filename = Path.GetFileName(e.FileName);
        string ruta     = Server.MapPath("~/TMP");

        // Si el directorio no existe, crearlo
        if (!Directory.Exists(ruta))
        {
            Directory.CreateDirectory(ruta);
        }

        string archivo = String.Format("{0}\\{1}", ruta, filename);

        // Verificar que el archivo no exista
        if (File.Exists(archivo))
        {
            lblError.Text = (String.Format("Ya existe Documento con nombre\"{0}\".", filename));
        }
        else
        {
            AjaxFileUpload1.SaveAs(ruta + "\\" + filename);
        }
        Session["archivo"] = ruta + "\\" + filename;
        Session["carga"]   = filename;
        e.DeleteTemporaryData();
    }
コード例 #8
0
    protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {
        if (e == null)
        {
            throw new ArgumentNullException("e");
        }
        if (e.State != AjaxControlToolkit.AjaxFileUploadState.Success)
        {
            return;
        }

        string szKey = FileObjectSessionKey(e.FileId);

        PendingIDs.Add(szKey);
        Session[szKey] = new MFBPendingImage(new MFBPostedFile(e.FileName, e.ContentType, e.FileSize, e.GetContents(), e.FileId), szKey);
        e.DeleteTemporaryData();

        RefreshPreviewList();

        if (Mode == UploadMode.Legacy)
        {
            Mode = UploadMode.Ajax;
        }

        if (UploadComplete != null)
        {
            UploadComplete(this, e);
        }
    }
コード例 #9
0
    protected void AjaxFileUploadMultiple_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {
        string filename = System.IO.Path.GetFileName(e.FileName);
        //string strUploadPath = "~/K_Log/" + Request.UrlReferrer.Query.Split(new char[]{'='})[1].ToString() + "/";
        string strUploadPath = "~/K_Log/" + Session["Folder_Name2"].ToString() + "/";

        AjaxFileUploadMultiple.SaveAs(Server.MapPath(strUploadPath) + filename);
    }
コード例 #10
0
    protected void afuUploadImage_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {
        string nomeArquivo = e.FileName;

        afuUploadImage.SaveAs(Server.MapPath("~/Upload/" + nomeArquivo));

        arquivosEnviados.Add(Server.MapPath("~/Upload/" + nomeArquivo));
    }
コード例 #11
0
 protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
 {
     //myl.Text = "started Imported Data!";
     string fileNametoupload = Server.MapPath("~/files/") + e.FileName.ToString();
     //       AjaxFileUpload afu=(AjaxFileUpload)(importDataForm.FindControl("AjaxFileUpload1"));
     //afu.SaveAs(fileNametoupload);
     //  getExcelFile(fileNametoupload, foruseremail.Value, forusertime.Value);
 }
コード例 #12
0
ファイル: Default.aspx.cs プロジェクト: blockspacer/turtle
    protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {
        TESTCASE_CHECKSUM tbl      = new TESTCASE_CHECKSUM();
        string            filePath = "C:/Users/chritan/Documents/turtle/output/" + e.FileName;

        AjaxFileUpload1.SaveAs(filePath);

        tbl.read_checksums(filePath);
    }
コード例 #13
0
ファイル: Upload.aspx.cs プロジェクト: VikySihabudin/Landai
    public void AjaxFileUploadMRS_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {
        string user    = Request.Params["user"].ToString();
        string wilayah = Request.Params["wilay"].ToString();

        LANDCOMP.generateNUm gn = new LANDCOMP.generateNUm();
        gn.Datas();

        string _stNomor;

        string _stDates = DateTime.Today.ToString("yyyyMMdd");

        string uploadFolder = Request.PhysicalApplicationPath + "uploadDocument\\";

        LANDCOMP.paramz ext = new LANDCOMP.paramz();

        ext.setExtension(Path.GetExtension(e.FileName));

        if (ext.getExtsion() != ".exe")
        {
            _stFAsli = System.IO.Path.GetFileName(e.FileName);

            string wilay  = user;
            string owner1 = "";
            switch (wilayah)
            {
            case "1":
                owner1 = "SBU1";
                break;

            case "2":
                owner1 = "SBU2";
                break;

            case "3":
                owner1 = "SBU3";
                break;

            case "4":
                owner1 = "TSJ1";
                break;

            case "5":
                owner1 = "LANDCOMP1";
                break;

            default:
                break;
            }

            _stNomor = gn.GenerateNumber(owner1, 100, 51, _stDates, user);

            AjaxFileUploadMRS.SaveAs(uploadFolder + _stNomor + ext.getExtsion());
            e.PostedUrl = string.Format(e.FileName + "|" + _stNomor + "|" + user + "|" + wilayah);
        }
    }
コード例 #14
0
    protected void AjaxFileUpload_ImagePrograma_OnUploadComplete(object sender, AjaxFileUploadEventArgs e)
    {
        string filePath = "~/imagenes/programasGenerales/" + e.FileName;

        var ajaxFileUpload = (AjaxFileUpload)sender;
        ajaxFileUpload.SaveAs(MapPath(filePath));

        e.PostedUrl = Page.ResolveUrl(filePath);
        Image_Programa.ImageUrl = Page.ResolveUrl(filePath);
    }
コード例 #15
0
    protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {
        //// Generate file path
        //string filePath = "Images1/" + e.FileName;

        //// Save upload file to the file system
        //AjaxFileUpload1.SaveAs(MapPath(filePath));


        //Response.Write(MapPath(filePath));
    }
コード例 #16
0
    protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {
        //count = count + 1;



        string fileNameWithPath = Server.MapPath("~/test/") + e.FileName.ToString();



        AjaxFileUpload1.SaveAs(fileNameWithPath);
    }
コード例 #17
0
    protected void ajaxFileUpload_OnUploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {
        if (e.ContentType.Contains("jpg") || e.ContentType.Contains("gif") ||
            e.ContentType.Contains("png") || e.ContentType.Contains("jpeg"))
        {
            Session["fileContentType_" + e.FileId] = e.ContentType;
            Session["fileContents_" + e.FileId]    = e.GetContents();
        }

        // Set PostedUrl to preview the uploaded file.
        e.PostedUrl = string.Format("?preview=1&fileId={0}", e.FileId);
    }
    protected void AjaxFileUpload1_OnUploadComplete(object sender, AjaxFileUploadEventArgs file)
    {
        // User can save file to File System, database or in session state
        if (file.ContentType.Contains("jpg") || file.ContentType.Contains("gif")
            || file.ContentType.Contains("png") || file.ContentType.Contains("jpeg"))
        {
            Session["fileContentType_" + file.FileId] = file.ContentType;
            Session["fileContents_" + file.FileId] = file.GetContents();
        }

        // Set PostedUrl to preview the uploaded file.
        file.PostedUrl = string.Format("?preview=1&fileId={0}", file.FileId);
    }
コード例 #19
0
 protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
 {
     if (this.contentTypes.Contains(e.ContentType))
     {
         if (e.FileSize <= 1024 * 1024 * 4)
         {
             string filePath = string.Concat("~/上傳的檔案/", ("P" + MasterPage.Global.會員編號 + e.ContentType));
             this.AjaxFileUpload1.SaveAs(MapPath(filePath));
             MasterPage.Global.頭貼路徑 = "~/上傳的檔案/" + ("P" + MasterPage.Global.會員編號 + e.ContentType);
             存圖片路徑();
         }
         else
         {
             e.PostedUrl = "Images/fileTooBig.gif";
         }
     }
 }
コード例 #20
0
        protected void upload_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
        {
            string fileName = Path.GetFileName(e.FileName);

            byte[] Image     = null;
            string extension = string.Empty;

            extension = Path.GetExtension(fileName).ToLower();// Get selected image extension

            fileName = string.Format("{0}{1}.{2}", WebUtils.GetFileName(fileName.Split('.')[0]), DateTime.Now.ToString("ddMMyyyyhhmmss"), WebUtils.GetFileExtension(fileName));

            if (fileName != null)
            {
                fileNameUpload = fileName;
                //fileNameUpload = string.Format("{0}{1}{2}", fileName.Split('.')[0], DateTime.Now.ToString("ddMMyyyyhhmmss"), extension);

                string path = Path.Combine(Server.MapPath(ImagePath), fileNameUpload);
                if (extension == ".jpg" || extension == ".jpeg" || extension == ".png" || extension == ".gif" || extension == ".bmp" ||
                    extension == ".pdf" || extension == ".xlsx" || extension == ".xls")
                {
                    path = Path.Combine(Server.MapPath(ImagePath), fileNameUpload);
                    upLoad.SaveAs(path);
                }
                if (extension == ".mp3")
                {
                    string fileNameUploadMp3 = fileNameUpload;
                    string fileNameUploadOgg = fileNameUpload.Replace("mp3", "ogg").Replace("MP3", "ogg");

                    path = Path.Combine(Server.MapPath(ImagePath), fileNameUploadMp3);
                    upLoad.SaveAs(path);
                }

                else
                {
                    lbMsg.Text = "fdsaf";
                }
            }
            else
            {
                fileNameUpload   = txtIdVideo.Value.Trim();
                txtIdVideo.Value = null;
            }

            productId = SaveNewsCategory();
            btnUploadImage_Click(null, null);
        }
コード例 #21
0
 protected void AjaxFileUpload1_UploadComplete1(object sender, AjaxFileUploadEventArgs e)
 {
     string TenAnh = e.FileName;
     String[] tmp = TenAnh.Split('.');
     TenAnh = tmp[0];
     string strDestPath = Server.MapPath("~/admin/images/");
     String TenImage = macay.ToString() + "_" + DateTime.Now.ToFileTimeUtc().ToString();
     String url = "images/"+TenImage+"."+tmp[1];
     if (dao.anh_caythuoc.insert_anh(macay, TenAnh, url))
     {
         AjaxFileUpload1.SaveAs(@strDestPath + TenImage + "." + tmp[1]);
     }
     else
     {
         lbDisplay.Text = "Looix";
     }
     
 }
コード例 #22
0
    protected void AjaxFileUploadFoto_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {
        string Folder = Server.MapPath("~/images/Produk/");

        if (!Directory.Exists(Folder))
        {
            Directory.CreateDirectory(Folder);
        }

        if (Session["IDProduk"] != null)
        {
            FotoProduk_Class ClassFotoProduk = new FotoProduk_Class();

            var FotoProduk = ClassFotoProduk.Tambah(Session["IDProduk"].ToInt(), Path.GetExtension(e.FileName));

            AjaxFileUploadFoto.SaveAs(Folder + FotoProduk.IDFotoProduk + FotoProduk.ExtensiFoto);
        }
    }
コード例 #23
0
        protected void AjaxFileUpload1_OnUploadComplete(object sender, AjaxFileUploadEventArgs file)
        {
            LectureNote lNote = new LectureNote();
            lNote.LectureId = -1;
            lNote.CourseId = Session["courseID"].ToString();
            //Check whether or not the title is specified.
            if (txtboxLectureTitle.Text == String.Empty)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "errorTitle",
                                                   "alert('Please provide title of the lecture note!!!');", true);
            }
            else
            {
                lNote.LTitle = txtboxLectureTitle.Text;
                //Check whether or not there is valid file to upload.
                if (file.ContentType.Contains("pdf") || file.ContentType.Contains("doc")
                    || file.ContentType.Contains("rtf") || file.ContentType.Contains("docx"))
                {
                    //Append date and time in the filename to make it unique.
                    string filename = Path.GetFileNameWithoutExtension(fileuploadLectureNote.FileName) +
                                      DateTime.Now.ToString("_yyyy_mm_dd_HH_mm_ss");
                    string extension = Path.GetExtension(fileuploadLectureNote.FileName);
                    string directory = Server.MapPath("~/CourseMaterials/" + Session["courseID"] + "/LectureNote");
                    //Create directory if no folder toa save the lecture note
                    if (!Directory.Exists(directory))
                    {
                        Directory.CreateDirectory(directory);
                    }
                    lNote.LFileLocation = directory + "/" + filename + extension;
                    fileuploadLectureNote.SaveAs(lNote.LFileLocation);
                    ClientScript.RegisterStartupScript(this.GetType(), "successUpload",
                                                       "alert('Uploaded successfully!!!');", true);
                    LectureNoteController.Save(lNote);
                    Response.Redirect("~/InstructorSite/formManageLectureNote.aspx");
                }
                else //If the file format is invalid.
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "fileFormatError",
                                                       "alert('File format error: Only pdf or ppt files are allowed!!!');",
                                                       true);
                }

            }
        }
コード例 #24
0
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {
        string filePath        = MapPath("~/App_Data/" + e.FileName);
        string fileContentType = e.ContentType;
        int    fileSize        = e.FileSize;
        string fileName        = e.FileName;
        string path            = MapPath("~/App_Data/" + e.FileName);

        AjaxFileUpload1.SaveAs(path);
        //e.PostedUrl = string.Format("?preview=1&fileId={0}", e.FileId);

        FileInfo fileInfo = new FileInfo(filePath);
        string   ID       = Path.GetFileNameWithoutExtension(path);

        // The byte[] to save the data in
        byte[] data = new byte[fileInfo.Length];

        // Load a filestream and put its content into the byte[]
        using (FileStream fs = fileInfo.OpenRead())
        {
            fs.Read(data, 0, data.Length);
        }

        byte[] EncryptData     = CryptoImage.EncryptBytes(data);
        int    EncryptfileSize = EncryptData.Length;

        System.Data.SqlClient.SqlConnection sqlConnection = new System.Data.SqlClient.SqlConnection();

        sqlConnection.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["constring"].ConnectionString;
        String SqlCmdText1 = "UPDATE VisitorsCard SET VisImage =@VisImage,VisImageContentType=@VisImageContentType,VisImageLength=@VisImageLength WHERE VisIdentityNo = @VisIdentityNo";

        System.Data.SqlClient.SqlCommand sqlCmdObj1 = new System.Data.SqlClient.SqlCommand(SqlCmdText1, sqlConnection);

        sqlCmdObj1.Parameters.Add("@VisIdentityNo", System.Data.SqlDbType.VarChar, 100).Value       = ID;
        sqlCmdObj1.Parameters.Add("@VisImage", System.Data.SqlDbType.Binary, EncryptfileSize).Value = EncryptData;
        sqlCmdObj1.Parameters.Add("@VisImageContentType", System.Data.SqlDbType.VarChar, 255).Value = fileContentType;
        sqlCmdObj1.Parameters.Add("@VisImageLength", System.Data.SqlDbType.Int).Value = EncryptfileSize;

        sqlConnection.Open();
        sqlCmdObj1.ExecuteNonQuery();
        sqlConnection.Close();
    }
コード例 #25
0
    protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {
        if (e == null)
        {
            throw new ArgumentNullException("e");
        }
        if (e.State != AjaxControlToolkit.AjaxFileUploadState.Success)
        {
            return;
        }

        TimeZoneInfo tz = (TimeZoneInfo)Session[SessionKeyTZ];

        TelemetryMatchResult tmr = new TelemetryMatchResult()
        {
            TelemetryFileName = e.FileName
        };

        if (tz != null)
        {
            tmr.TimeZoneOffset = tz.BaseUtcOffset.TotalHours;
        }


        DateTime?       dtFallback = null;
        Regex           rDate      = new Regex("^(?:19|20)\\d{2}[. _-]?[01]?\\d[. _-]?[012]?\\d", RegexOptions.Compiled);
        MatchCollection mc         = rDate.Matches(e.FileName);

        if (mc != null && mc.Count > 0 && mc[0].Groups.Count > 0)
        {
            DateTime dt;
            if (DateTime.TryParse(mc[0].Groups[0].Value, out dt))
            {
                dtFallback         = dt;
                tmr.TimeZoneOffset = 0; // do it all in local time.
            }
        }
        tmr.MatchToFlight(System.Text.Encoding.UTF8.GetString(e.GetContents()), Page.User.Identity.Name, dtFallback);
        Results.Add(tmr);

        e.DeleteTemporaryData();
    }
コード例 #26
0
ファイル: Import.aspx.cs プロジェクト: xmas25/MyFlightbookWeb
    protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {
        if (e == null)
        {
            throw new ArgumentNullException(nameof(e));
        }

        if (e.State != AjaxControlToolkit.AjaxFileUploadState.Success)
        {
            lblFileRequired.Text = Resources.LogbookEntry.errImportInvalidCSVFile;
            SetWizardStep(wsUpload);
            return;
        }

        Session[szSessFile] = e.GetContents();

        e.DeleteTemporaryData();

        // Now we wait for the force refresh
    }
コード例 #27
0
    protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {
        bool   ret      = false;
        string filePath = Config.GetTempPath + e.FileName;

        try
        {
            TESTCASE_CHECKSUMS_VIEW tbl = new TESTCASE_CHECKSUMS_VIEW();
            AjaxFileUpload1.SaveAs(filePath);

            ret = tbl.update_checksums(Master.CurrentUserName, filePath);
        }
        catch (Exception ex)
        {
            using (StreamWriter writer = new StreamWriter(filePath, true))
            {
                writer.WriteLine("Message :" + ex.Message + Environment.NewLine + "StackTrace :" + ex.StackTrace +
                                 "" + Environment.NewLine + "Date :" + DateTime.Now.ToString());
                writer.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine);
            }
        }
    }
コード例 #28
0
            void XhrDone(string fileId)
            {
                AjaxFileUploadEventArgs args;

                var tempFolder = GetTempFolder(fileId);

                if (!Directory.Exists(tempFolder))
                {
                    return;
                }

                var files = Directory.GetFiles(tempFolder);

                if (files.Length == 0)
                {
                    return;
                }

                var fileInfo = new FileInfo(files[0]);

                CheckTempFilePath(fileInfo.FullName);
                SetUploadedFilePath(fileInfo.FullName);
                var originalFilename = StripTempFileExtension(fileInfo.Name);

                args = new AjaxFileUploadEventArgs(
                    fileId, AjaxFileUploadState.Success, "Success", originalFilename, (int)fileInfo.Length,
                    Path.GetExtension(originalFilename));

                if (UploadComplete != null)
                {
                    UploadComplete(Control, args);
                }

                args.DeleteTemporaryData();

                Response.Write(new JavaScriptSerializer().Serialize(args));
            }
コード例 #29
0
        protected void HtmlEditorExtenderContent_ImageUploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
        {
            string fileName = DateTime.Now.ToString("MMM-ddd-d-HH-mm-ss-yyyy") + "_" + e.FileName;

            string subpath = Server.MapPath("~/StoryImages/") + subcategory.Trim();

            //if not the create user directory
            if (!System.IO.Directory.Exists(subpath))
            {
                System.IO.Directory.CreateDirectory(subpath);

                // Create the path and file name to check for duplicates.
                string filepath = subpath + "\\" + fileName;

                HtmlEditorExtenderContent.AjaxFileUpload.SaveAs(filepath);

                e.PostedUrl = Page.ResolveUrl(subpath + "\\" + fileName);
            }
            else
            {
                // Create the path and file name to check for duplicates.
                string filepath = subpath + "\\" + fileName;

                HtmlEditorExtenderContent.AjaxFileUpload.SaveAs(filepath);

                e.PostedUrl = Page.ResolveUrl(subpath + "\\" + fileName);
            }

            //// Generate file path
            //string filePath = CreateaUserDirectory(e.FileName);

            //// Save uploaded file to the file system
            //var ajaxFileUpload = (AjaxFileUpload)sender;
            //ajaxFileUpload.SaveAs(MapPath(filePath));

            // Update client with saved image path
        }
コード例 #30
0
    protected void buzon_HtmlEditorExtender_ImageUploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {
        MemoryStream datosImagen = new MemoryStream(e.GetContents());

        System.Drawing.Image imagen = System.Drawing.Image.FromStream(datosImagen);

        if (imagen.Width > imagen.Height)
        {
            if (imagen.Width > 250)
            {
                int alturaImagen = 250 * imagen.Height / imagen.Width;

                imagen = new Bitmap(imagen, 250, alturaImagen);
            }
        }
        else
        {
            if (imagen.Height > 250)
            {
                int anchuraImagen = 250 * imagen.Width / imagen.Height;

                imagen = new Bitmap(imagen, anchuraImagen, 250);
            }
        }
        ImageConverter conversor = new ImageConverter();

        byte[] datosImagenRedimensionada = (byte[])conversor.ConvertTo(imagen, typeof(byte[]));

        if (e.ContentType.Contains("jpg") || e.ContentType.Contains("gif") ||
            e.ContentType.Contains("png") || e.ContentType.Contains("jpeg"))
        {
            Session["fileContentType_" + e.FileId] = e.ContentType;
            Session["fileContents_" + e.FileId]    = datosImagenRedimensionada;
        }

        e.PostedUrl = string.Format("?preview=1&fileId={0}", e.FileId);
    }
コード例 #31
0
            void XhrDone(string fileId)
            {
                AjaxFileUploadEventArgs args;

                var tempFolder = BuildTempFolder(fileId);
                if(!Directory.Exists(tempFolder))
                    return;

                var files = Directory.GetFiles(tempFolder);
                if(files.Length == 0)
                    return;

                var fileInfo = new FileInfo(files[0]);
                SetUploadedFilePath(fileInfo.FullName);

                args = new AjaxFileUploadEventArgs(
                    fileId, AjaxFileUploadState.Success, "Success", fileInfo.Name, (int)fileInfo.Length,
                    fileInfo.Extension);

                if(UploadComplete != null)
                    UploadComplete(this, args);

                Response.Write(new JavaScriptSerializer().Serialize(args));
            }
コード例 #32
0
        protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
        {
            string fileNametoupload = Server.MapPath("~/AjaxUpload/") + e.FileName.ToString();

            AjaxFileUpload1.SaveAs(fileNametoupload);
        }
コード例 #33
0
        protected void ajaxUpload1_OnUploadComplete(object sender, AjaxFileUploadEventArgs e)
        {
            if (e.ContentType.Contains("jpg") || e.ContentType.Contains("gif")
            || e.ContentType.Contains("png") || e.ContentType.Contains("jpeg"))
            {
                Session["fileContentType_" + e.FileId] = e.ContentType;
                Session["fileContents_" + e.FileId] = e.GetContents();
            }

            // Set PostedUrl to preview the uploaded file.         
            e.PostedUrl = string.Format("?preview=1&fileId={0}", e.FileId);
            
            // Generate file path
            string filePath = "~/Images/" + e.FileName;
            var ajaxFileUpload = htmlEditorExtender2.AjaxFileUpload;
            //ajaxFileUpload.AllowedFileTypes = "jpg,jpeg,gif,png";
            // Save upload file to the file system
            ajaxFileUpload.SaveAs(MapPath(filePath));
            // Update client with saved image path
            e.PostedUrl = Page.ResolveUrl(filePath);
        }
コード例 #34
0
 protected void ajaxUpload1_OnUploadComplete(object sender, AjaxFileUploadEventArgs e)
 { }
コード例 #35
0
 protected void AjaxFileUpload1_UploadComplete1(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
 {
 }
コード例 #36
0
 protected void fuProfilePhoto_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
 {
     imgProfilePhoto.ImageUrl = "data:" + e.ContentType + ";base64," + Convert.ToBase64String(e.GetContents());
 }
コード例 #37
0
 protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
 {
     byte[] image = e.GetContents();
 }
コード例 #38
0
ファイル: Default.aspx.cs プロジェクト: VikySihabudin/Landai
    protected void AjaxFileUpload3_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {
        string filePath = Request.PhysicalApplicationPath + @"uploads\" + e.FileName;

        AjaxFileUpload3.SaveAs(filePath);
    }