Beispiel #1
0
        protected void FileDocumento_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
        {
            string ruta     = Server.MapPath("~/ASP/Documentos/");
            string savePath = MapPath("~/ASP/Documentos/" + _DataSistema.Cusuario + "_" + CboTipoDocumento.SelectedValue + Path.GetFileName(e.FileName));

            ((AsyncFileUpload)sender).SaveAs(savePath);
        }
    protected void AsyncFileUpload_Donor_Confirmed_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        //System.Threading.Thread.Sleep(5000);

        //if (AsyncFileUpload_Donor_Confirmed.HasFile)
        //{
        //    string[] sa_file = Path.GetFileName(e.FileName).Split('.');
        //    string s_TimeStamp = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();
        //    string m_AppDir = HttpContext.Current.Request.PhysicalApplicationPath.ToString();

        //    if (!Directory.Exists(m_AppDir + "/Uploads/" + s_id + "/"))
        //        Directory.CreateDirectory(m_AppDir + "/Uploads/" + s_id + "/");

        //    string strPath = MapPath("~/Uploads/" + s_id + "/") + sa_file[0] + "_" + s_TimeStamp + "_Donor_Confirmed" + "." + sa_file[sa_file.Length - 1];

        //    AsyncFileUpload_Donor_Confirmed.SaveAs(strPath);
        //}

        var AsyncFileUpload = AsyncFileUpload_Donor_Confirmed;

        if (AsyncFileUpload.HasFile)
        {
            if (Path.GetExtension(AsyncFileUpload.FileName) == ".xlsx")
            {
                var dt = ExcelPackageExtensions.GetDataTable(AsyncFileUpload.FileContent);
            }
        }
    }
 protected void AfuImageUpload_OnUploadedComplete(object sender, AsyncFileUploadEventArgs ea)
 {
     if (ea.State == AsyncFileUploadState.Success)
     {
         string filename = System.IO.Path.GetFileName(afuImageUpload.FileName);
         var path = Server.MapPath("~/UploadedImages/") + filename;
         afuImageUpload.SaveAs(path);
     }
 }
    void AsyncFileUpload1_UploadedComplete(object sender, AsyncFileUploadEventArgs e)
    {
        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "size", "top.$get(\"" + uploadResult.ClientID + "\").innerHTML = 'Uploaded size: " + AsyncFileUpload1.FileBytes.Length.ToString() + "';", true);

        // Uncomment to save to AsyncFileUpload\Uploads folder.
        // ASP.NET must have the necessary permissions to write to the file system.

        // string savePath = MapPath("~/AsyncFileUpload/Uploads/" + Path.GetFileName(e.filename));
        // AsyncFileUpload1.SaveAs(savePath);
    }
Beispiel #5
0
        protected void afuUploader_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
        {
            AsyncFileUpload afuUploader = sender as AsyncFileUpload;
            string          fileName    = afuUploader.FileName;

            if (afuUploader != null)
            {
                string uploadedFilePath = PathHelper.GetFileSystemPath(Constants.Paths.MultimediaStorageRoot, _tmpUploadPath, fileName);
                afuUploader.SaveAs(uploadedFilePath);
            }
        }
        protected void AsyncFileUploadField_OnUploadedComplete(object sender, AsyncFileUploadEventArgs e)
        {
            System.Threading.Thread.Sleep(3000);

            var strPath = MapPath("~/Uploads/") + Path.GetFileName(e.GetHashCode() + "_" + e.FileName);

            if (!Directory.Exists(MapPath("~/Uploads/")))
            {
                Directory.CreateDirectory(MapPath("~/Uploads/"));
            }

            AsyncFileUploadField.SaveAs(strPath);
        }
        protected void AfuImageUpload_OnUploadedComplete(object sender, AsyncFileUploadEventArgs ea)
        {
            if (ea.State == AsyncFileUploadState.Success)
            {
                var filename = System.IO.Path.GetFileName(afuImageUpload.FileName);
                txtImageFileName.Text = filename;

                var mappedPath = Server.MapPath("~/UploadedImages/Teasers/") + filename;
                afuImageUpload.SaveAs(mappedPath);

                RelativeImagePath = MakeRelativeImagePath(filename);
            }
        }
        protected void AfuImageUpload_OnUploadedComplete(object sender, AsyncFileUploadEventArgs ea)
        {
            if (ea.State == AsyncFileUploadState.Success)
            {
                var filename = System.IO.Path.GetFileName(afuImageUpload.FileName);

                // TODO: replace with constant
                var mappedPath = Server.MapPath("~/UploadedImages/Offers/") + filename;
                afuImageUpload.SaveAs(mappedPath);

                RelativeImagePath = ImagePath + filename;
            }
        }
Beispiel #9
0
        protected void FlatFileUpload_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
        {
            //ImageNames.Add(e.FileName);

            //int Count = ImageNames.Count;

            //string NextImage = "FlatFileUpload" + Count;

            //Control c = Page.FindControl(NextImage);
            //AsyncFileUpload up = (AsyncFileUpload)c;

            //if (up.HasFile)
            //    Images.Add(up.PostedFile);
        }
        protected void AsyncFileUpload_UploadedComplete(object sender, AsyncFileUploadEventArgs e)
        {
            var fup = sender as AsyncFileUpload;
            if (fup == null)
                return;

            if (KidsOnlineUser == null || KidsOnlineUser.Kids_UserInfo == null)
                return;
            var user = KidsOnlineUser.Kids_UserInfo;


            var FilePath = FileUploadUtil.SaveUploadeFile((AsyncFileUpload)sender, SystemConfigs.UrlKidsPicFilesPath(KidsOnlineUser.SSOUser.UserID),
                                                                    UploadFileType.Pictures, UploadFileSizeLimitation._500K);

            if (string.IsNullOrWhiteSpace(FilePath))
                return;

            user.MarkAsModified();

            switch (fup.ID)
            {

                case "fupChildPic":
                    user.ChildPic = FilePath;
                    SessionItems.ChildPic = FilePath;
                    ImgChildPic.ImageUrl = "~/JpegImage.aspx?act=30&d=" + DateTime.Now;
                    break;

                case "fupChildIdentityPic":
                    user.ChildIdentityPic = FilePath;
                    SessionItems.ChildIdentityPic = FilePath;
                    ImgChildIdentityPic.ImageUrl = "~/JpegImage.aspx?act=31&d=" + DateTime.Now;
                    break;

                case "fupChildNationalCardFaceUp":
                    user.ChildNationalCardFaceUPPic = FilePath;
                    SessionItems.ChildNationalCardFaceUpPic = FilePath;
                    ImgChildNationalCardFaceUp.ImageUrl = "~/JpegImage.aspx?act=32&d=" + DateTime.Now;
                    break;

                case "fupChildNationalCardFaceDown":
                    user.ChildNationalCardFaceDownPic = FilePath;
                    SessionItems.ChildNationalCardFaceDownPic = FilePath;
                    ImgChildNationalCardFaceDown.ImageUrl = "~/JpegImage.aspx?act=33&d=" + DateTime.Now;
                    break;
            }
            KidsUser_DataProvider.SaveKidsUser(user, this, KidsSecureFormBaseClass.RefreshOnlineKidsUserInfo);
        }
        protected void HouseFileUpload_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
        {
            ImageNames.Add(e.FileName);

            int Count = ImageNames.Count;

            string NextImage = "HouseFileUpload" + Count;

            Control         c  = Page.FindControl(NextImage);
            AsyncFileUpload up = (AsyncFileUpload)c;

            if (up.HasFile)
            {
                Images.Add(up.PostedFile);
            }
        }
Beispiel #12
0
 protected void Archivo_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
 {
     HttpContext.Current.Session["Archivo"] = null;
     if (uploadFile.HasFile)
     {
         try
         {
             byte[] bytes = uploadFile.FileBytes;
             HttpContext.Current.Session["Archivo"] = bytes;
         }
         catch (Exception ex)
         {
             string mns = ex.InnerException.ToString();
             HttpContext.Current.Session["Archivo"] = null;
         }
     }
 }
 protected void AsyncFileUpload1_UploadedComplete(object sender, AsyncFileUploadEventArgs e)
 {
     if (AsyncFileUpload1.HasFile)
     {
         if (!IsValidImage(AsyncFileUpload1.PostedFile.FileName))
         {
             Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "PopupScript", "<script>alert('You have upload an invalid file. Please select another one.');</script>");
         }
         else
         {
             string fileUploadDir = Server.MapPath("~/temp/anonymous/");
             if (!System.IO.Directory.Exists(fileUploadDir))
             {
                 System.IO.Directory.CreateDirectory(fileUploadDir);
             }
             AsyncFileUpload1.SaveAs(fileUploadDir + AsyncFileUpload1.PostedFile.FileName);
         }
     }
 }
Beispiel #14
0
 protected void OnUploadComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
 {
     if (afu.HasFile)
     {
         if (e.FileName.Contains(".exe") || e.FileName.Contains(".bat") || e.FileName.Contains(".dll"))
         {
             Util.PageMessage(this, "This file type cannot be uploaded. Please try again a different file type.");
         }
         else
         {
             String path = MapPath("~\\Dashboard\\Training\\Admin\\Files\\") + Path.GetFileName(e.FileName);
             afu.SaveAs(path);
             Util.WriteLogWithDetails("File \"" + e.FileName + "\" successfully uploaded to Admin page.", "training_log");
             Util.PageMessage(this, "File '" + e.FileName + "' successfully uploaded! Refresh the page using the refresh icon at the top right of the page to update your list of files or continue uploading more files.");
         }
     }
     else
     {
         Util.PageMessage(this, "File upload error.");
     }
 }
Beispiel #15
0
 protected void Archivo_UploadedComplete2(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
 {
     HttpContext.Current.Session["Archivo"]       = null;
     HttpContext.Current.Session["NombreArchivo"] = null;
     if (this.AsyncFileUpload1.HasFile)
     {
         try
         {
             byte[] bytes = AsyncFileUpload1.FileBytes;
             HttpContext.Current.Session["NombreArchivo"] = AsyncFileUpload1.FileName;
             HttpContext.Current.Session["Archivo"]       = bytes;
         }
         catch (Exception ex)
         {
             string mns = ex.InnerException.ToString();
             HttpContext.Current.Session["Archivo"]       = null;
             HttpContext.Current.Session["NombreArchivo"] = null;
             throw (ex);
         }
     }
 }
    protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        string PhotoPath = "";

        if (FileUpload1.HasFile)
        {
            string name = FileUpload1.FileName;
            string ext  = System.IO.Path.GetExtension(name);

            if (ext.Trim() != ".jpg" && ext.Trim() != ".jpeg" && ext.Trim() != ".png" && ext.Trim() != ".gif" && ext.Trim() != ".org")
            {
                divGroupSucces.Style.Add("display", "block");
                lblSuccMess.Text     = "File format not supported.Image should be '.jpg or .jpeg or .png or .gif'";
                lblSuccMess.CssClass = "RedErrormsg";
                return;
            }

            int FileLength = FileUpload1.PostedFile.ContentLength;
            if (FileLength <= 3145728)
            {
                PhotoPath = DateTime.Now.ToString().Replace("/", "").Replace(".", "").Replace(":", "").Replace(" ", "") + System.IO.Path.GetExtension(FileUpload1.FileName).ToString();
                FileUpload1.SaveAs(Server.MapPath("~\\CroppedPhoto\\" + PhotoPath));
                ViewState["ImagePath"] = PhotoPath;
                Session["ImagePath"]   = PhotoPath;
                imgUser.Src            = "~/CroppedPhoto/" + PhotoPath;
                ImgRemovePic.Visible   = true;
            }
            else
            {
                PhotoPath = Convert.ToString(ViewState["ImagePath"]);
            }
        }
        else
        {
            divGroupSucces.Style.Add("display", "block");
            lblSuccMess.Text     = "Please select image to upload.";
            lblSuccMess.CssClass = "RedErrormsg";
            return;
        }
    }
Beispiel #17
0
    protected void ULComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        //System.Diagnostics.Debug.Write("Upload Complete");

        LabelStatus.Text += "UL Completed<br/>";

        AjaxControlToolkit.AsyncFileUpload fileupload = (AjaxControlToolkit.AsyncFileUpload)sender;
        //Upload files
        if (fileupload.HasFile)
        {
            //use newly created id to name file
            string newfilename = Path.GetFileNameWithoutExtension(fileupload.FileName);
            string savepath    = Server.MapPath("~/admin/xml/");
            string extension   = Path.GetExtension(fileupload.FileName);
            string newfile     = shared.SaveFile(fileupload.PostedFile, newfilename, savepath, extension);
            LoadXML(newfile);
        }
        else
        {
            LabelStatus.Text = "No valid file uploaded.";
        }
    }
Beispiel #18
0
    protected void chatRoomImgUpload_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        if (!SAVECLICKED)
        {
            try
            {
                string savePath = Helper.GetUniqueNameUser(e.FileName, MapPath("~/Images/user/"));
                if (savePath != null)
                {
                    //chatRoomImgUpload.SaveAs(savePath);

                    //string newName = "I_" + Path.GetFileName(savePath);
                    //Helper.ResizeImageFile(savePath, 50, Path.Combine(MapPath("~/Images/chatroom/"), newName));
                    /********************************************************/
                    HttpPostedFile        file = chatRoomImgUpload.PostedFile;
                    ImageResizer.ImageJob i    = new ImageResizer.ImageJob(file, savePath, new ImageResizer.ResizeSettings("width=50;height=50;format=jpg;mode=pad"));
                    i.CreateParentDirectory = true; //Auto-create the uploads directory.
                    i.Build();
                    /********************************************************/
                    string virtPath  = "~/Images/user/" + Path.GetFileName(savePath);
                    string finalPath = System.Web.VirtualPathUtility.ToAbsolute(virtPath);
                    Session.Add(USER_SAVE_STRING, virtPath);
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "size" + new Guid(), "top.$get(\"" + imgUser.ClientID + "\").setAttribute(\"src\", \"" + Server.HtmlEncode(finalPath) + "\");", true);
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                //Console.WriteLine(ex.StackTrace);
            }
        }
        else
        {
            SAVECLICKED = false;
        }
    }
 protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
 {
     if (AsyncFileUpload1.HasFile)
     {
         var virtualfilepath = WebConfigurationManager.AppSettings["orderpdf"].ToString() + orderid.ToString() + "/" + AsyncFileUpload1.FileName;
         orderid = Session["OrderID"].ToString();
         var folderpath = Server.MapPath(WebConfigurationManager.AppSettings["orderpdf"].ToString() + orderid.ToString() + "/");
         if (!Directory.Exists(folderpath))
         {
             Directory.CreateDirectory(folderpath);
         }
         Pdf_path = Server.MapPath(virtualfilepath);
         AsyncFileUpload1.SaveAs(Pdf_path);
         //FileUpload1.Attributes.Clear();
         //FileUpload1.Dispose();
         //hlBuyerPODwn.Visible = true;
         btncancel.Visible = true;
         btnFinish.Visible = true;
         //btnDFinish.Visible = false;
         //hlBuyerPODwn.NavigateUrl = Pdf_path;
         lblMsg.Text = string.Empty;
         //btnUpload.Visible = false;
         lblUploadText.Text           = Pdf_path;
         Session["Download_Pdf_path"] = Pdf_path;
         Session["Pdf_path"]          = virtualfilepath;
         //upd1.Update();
     }
     else
     {
         lblMsg.Text = " *Please select a file to upload ";
         //hlBuyerPODwn.Visible = false;
         //btncancel.Visible = false;
         Session["Download_Pdf_path"] = null;
         Session["Pdf_path"]          = null;
     }
 }
        protected void OnAsyncFileUploadComplete(object sender, AsyncFileUploadEventArgs e)
        {
            if (filePromo2Logo.PostedFile != null)
            {
                HttpPostedFile file = filePromo2Logo.PostedFile;

                byte[] data = ReadFile(file);
                Session[STORED_IMAGE] = data;
            }
        }
    protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        // Save file
        string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);

        filename = String.Format("NMT_{0}_FORCAST_{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), filename);
        AsyncFileUpload1.SaveAs(Server.MapPath("~/Files/") + filename);

        // HATC Order
        string CustCode = "40118010";

        filename = Server.MapPath("~/Files/") + filename;
        if (File.Exists(filename))
        {
            string line = string.Empty;
            using (StreamReader sr = new StreamReader(filename))
            {
                int totalLine = 0;
                Dictionary <int, string> DueDate = new Dictionary <int, string>();
                using (SqlProcedure sp = new SqlProcedure("sp_NMT_Forcast_ClearData"))
                {
                    sp.ExecuteNonQuery();
                }
                while ((line = sr.ReadLine()) != null)
                {
                    if (line.Length > 0)
                    {
                        string[] data = line.Split(',');
                        if (data.Length > 0 && totalLine == 0)
                        {
                            #region DeliveryDate

                            for (int i = 11; i < data.Length; i++)
                            {
                                if (data[i].StartsWith("Daily Qty(N+"))
                                {
                                    //Daily Qty(N+1 month 26th)
                                    // get N Month
                                    //string[] montData = data[i].Split('+');
                                    //string DeliveryDate = String.Format("{0}-{1}-", data[236].ToString().Trim() , String.Format("{0:00}"
                                    //    , Convert.ToInt32( data[237].ToString().Trim()) + Convert.ToInt32(data[1].Substring(0,1))));

                                    if (!DueDate.ContainsKey(i))
                                    {
                                        DueDate.Add(i, data[i]);
                                    }
                                }
                            }
                            #endregion
                        }
                        else
                        {
                            // RowData
                            //DeliveryDate + string.Format("{0:00}", montData[1].Substring(7,montData[1].Length-1).Replace("th","").Replace("st","").Replace("nd","").Replace("rd",""))
                            if (!String.IsNullOrEmpty(data[236].Trim()))
                            {
                                foreach (KeyValuePair <int, string> item in DueDate)
                                {
                                    int Qty = 0;
                                    Int32.TryParse(data[item.Key], out Qty);

                                    string[] _dueDate = item.Value.Trim().Split('+');
                                    //Daily Qty(N+2 month 18th)
                                    int _month = Convert.ToInt32(data[237]) + Convert.ToInt32(_dueDate[1].Substring(0, 1));
                                    int _year  = Convert.ToInt32(data[236]);
                                    if (_month > 12)
                                    {
                                        _year += Convert.ToInt32(_month / 12);
                                        _month = _month % 12;
                                    }
                                    //Check Day
                                    int _day           = Convert.ToInt32(_dueDate[1].Substring(8, 4).Trim().Replace("th", "").Replace("st", "").Replace("nd", "").Replace("rd", "").Replace(")", ""));
                                    int lastDayOfMonth = DateTime.DaysInMonth(_year, _month);
                                    if (_day <= lastDayOfMonth)
                                    {
                                        string DeliveryDate = string.Format("{0}-{1}-{2}"
                                                                            , _year
                                                                            , String.Format("{0:00}", _month)
                                                                            , String.Format("{0:00}", _day)
                                                                            );
                                        //DeliveryDate + string.Format("{0:00}", montData[1].Substring(7,montData[1].Length-1).Replace("th","").Replace("st","").Replace("nd","").Replace("rd",""))
                                        MyCompany.Data.Objects.NMTForcastImport Order = new MyCompany.Data.Objects.NMTForcastImport();
                                        Order.OrderBy             = CustCode;
                                        Order.DeliveryDestination = data[10].ToString().Trim();
                                        Order.CustomerMatCode     = data[4].Trim();
                                        Order.PartsDevision       = "1";
                                        Order.CustomerPO          = "";
                                        Order.ReliabilityDevision = "P";
                                        Order.DeliveryDate        = Convert.ToDateTime(DeliveryDate);
                                        Order.Quantity            = Qty.ToString().Trim();
                                        Order.Unit       = "ST";
                                        Order.PlngPeriod = "D";
                                        Order.SAPCode    = "";//SharedBusinessRules.getSAPCode(Order.CustomerMatCode);
                                        Order.Insert();
                                    }
                                }
                            }
                        }
                    }

                    totalLine++;
                }
                sr.Close();
            }
        }
    }
    /// <summary>
    /// Event after file uploaded.
    /// </summary>
    /// <param name="sender">Object ccAsyncFileUpload.</param>
    /// <param name="e">AsyncFileUploadEventArgs e.</param>
    protected void OnAsyncFileUploadedComplete(Object sender, AsyncFileUploadEventArgs e)
    {
        AsyncFileUpload afu = (AsyncFileUpload)sender;
        if (afu.HasFile)
        {
            String fileExtension = Path.GetExtension(afu.PostedFile.FileName).ToLower();

            // Check max uploaded file size.
            if (afu.PostedFile.ContentLength > _defaultUploadLimit)
            {
                // File size limit exceeded (_defaultUploadLimit/1048576 Mb);
            }
            else if (this.allowedFileExtensions.Contains(fileExtension))
            {
                // Make file path string.
                String destDir = Server.MapPath(Constants._defaultPhotoPath);
                String keyName = this._userID.ToString();
                String destPath = Path.Combine(destDir, String.Concat(keyName, fileExtension));

                // Save photo-file on server.
                afu.PostedFile.SaveAs(destPath);

                // Save photo-path in database.
                PersonalInfoRepository.ModifyAvatar(
                    this._userID, String.Concat(keyName, fileExtension));
            }
        }
    }
    protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {

        // Save file
        string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);
        string fn = filename;
        filename = String.Format("IMCT_{0}_ORDER_{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), filename);
        AsyncFileUpload1.SaveAs(Server.MapPath("~/Files/") + filename);

        // HATC Order
        string CustCode = "40111011";
        filename = Server.MapPath("~/Files/") + filename;
        if (File.Exists(filename))
        {
            string line = string.Empty;
            using (StreamReader sr = new StreamReader(filename))
            {
                //using (SqlProcedure sp = new SqlProcedure("sp_IMCT_Order_ClearData"))
                //{
                //    sp.ExecuteNonQuery();
                //}
                int i = 1;
                while ((line = sr.ReadLine()) != null)
                {
                    if (line.Length > 0)
                    {
                        if (!line.Contains("ISUZU"))
                        {
                            MyCompany.Models.IMCTOrderImport Order = new MyCompany.Models.IMCTOrderImport();
                            Order.OrderBy = CustCode;
                            Order.DeliveryDestination = line.Substring(120, 5).Trim();
                            Order.CustomerMatCode = line.Substring(35, 10).Trim();
                            Order.CustomerPO = line.Substring(2, 10).Trim();
                            Order.ReliabilityDevision = "P";
                            Order.DeliveryDate = Convert.ToDateTime(line.Substring(50, 4).Trim() + "-" + line.Substring(54, 2).Trim() + "-" + line.Substring(56, 2).Trim());
                            Order.Quantity = float.Parse(line.Substring(58, 6)).ToString().Trim();
                            Order.Unit = "ST";
                            Order.PlngPeriod = "D";
                            string[] materialTemp = SharedBusinessRules.getMaterial(line.Substring(35, 10).Trim().Replace(" ", ""), CustCode, line.Substring(120, 5).Trim(), "IMCT").Split(':');
                            if (materialTemp.Length > 1)
                            {
                                Order.SAPCode = materialTemp[0];
                                Order.PartsDevision = materialTemp[1];
                                Order.DeliveryDestinationCode = materialTemp[2];
                                Order.Key1 = materialTemp[3];
                                Order.Key2 = materialTemp[4];
                                Order.Key3 = materialTemp[5];
                            }
                            Order.AddCode = i.ToString();
                            Order.PlantCode = "";
                            Order.Arrivaltime = line.Substring(159, 2).Trim() + ":" + line.Substring(161, 2).Trim();
                            Order.FromTo = "RTP:" + line.Substring(120, 5).Trim();
                            Order.Filename = fn;
                            Order.Insert();
                            i++;
                        }
                    }
                }
                
                sr.Close();
            }

        }
    }
    protected void AFU_Final_Donor_Information_BOM_Upload_OnUploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        string region = "", market = "";

        GetRegionMarket(ref region, ref market);
        if (AFU_Final_Donor_Information_BOM_Upload.HasFile)
        {
            MWIntakeUpload(AFU_Final_Donor_Information_BOM_Upload, MWIntakeCommon.FileCategory._bom, region, market);
        }
    }
Beispiel #25
0
    protected void FileUploadComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);

        AsyncFileUpload1.SaveAs(Server.MapPath("Rahul-") + filename);
    }
Beispiel #26
0
        private void uploader_UploadedComplete(object sender, AsyncFileUploadEventArgs e)
        {
            if (isOnInit)
                return;

            string key = "";
            lock (SyncRoot)
            {
                if (this.UseUploadedFileName)
                {
                    this.FileName = Path.GetFileName(e.FileName);
                    key = this.FileName;
                }
                else
                    key = this.FileName + Path.GetExtension(e.FileName);

                if (!string.IsNullOrEmpty(this.FileName) && !string.IsNullOrEmpty(this.StoragePath))
                {
                    string container_path = this.FilePath;
                    if (container_path.StartsWith("/"))
                        container_path = container_path.Remove(0, 1);
                    if (!String.IsNullOrEmpty(container_path))
                        container = new DirectoryContainer(this.StoragePath, container_path);
                    else
                        container = new DirectoryContainer(null, this.StoragePath);

                    try
                    {
                        if (container.Agent.HasKey(key))
                            container.Agent.Erase(key);
                        ((FileAgent)this.container.Agent).Write(key, this.uploader.FileContent);
                    }
                    catch (Exception ex)
                    {
                        this.container.Agent.CloseStream(key);
                        throw ex;
                    }
                }
                this.uploader.ClearFileFromPersistedStore();
            }

            if (null != this.FileUploaded)
                FileUploaded(this, new UploaderEventArgs(key));

            RaiseBubbleEvent(this, new CommandEventArgs("upload complete", key));
        }
Beispiel #27
0
 protected void UploadComplete(object sender, AsyncFileUploadEventArgs e)
 {
 }
 protected virtual void OnUploadedComplete(AsyncFileUploadEventArgs e)
 {
     if (UploadedComplete != null)
     {
         UploadedComplete(this, e);
     }
     //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "OnUploadedComplete", "top.$find(\"" + this.ClientID + "\")._stopLoad('111------www');", true);
 }
        void ReceivedFile(string sendingControlID)
        {
            AsyncFileUploadEventArgs eventArgs = null;
            _lastError = String.Empty;

            if(this.Page.Request.Files.Count > 0) {
                HttpPostedFile file = null;
                if(sendingControlID == null || sendingControlID == String.Empty) {
                    file = this.Page.Request.Files[0];
                } else {
                    foreach(string uploadedFile in this.Page.Request.Files) {
                        var fileToUse = uploadedFile;
                        var straggler = "$ctl02";
                        if(fileToUse.EndsWith(straggler))
                            fileToUse = fileToUse.Remove(fileToUse.Length - straggler.Length);

                        if(fileToUse.Replace("$", "_").EndsWith(sendingControlID)) {
                            file = this.Page.Request.Files[uploadedFile];
                            break;
                        }
                    }
                }
                if(file == null) {
                    _lastError = Constants.Errors.FileNull;
                    eventArgs = new AsyncFileUploadEventArgs(
                        AsyncFileUploadState.Failed,
                        Constants.Errors.FileNull,
                        String.Empty,
                        String.Empty
                    );

                    OnUploadedFileError(eventArgs);
                } else if(file.FileName == String.Empty) {
                    _lastError = Constants.Errors.NoFileName;

                    eventArgs = new AsyncFileUploadEventArgs(
                       AsyncFileUploadState.Unknown,
                       Constants.Errors.NoFileName,
                       file.FileName,
                       file.ContentLength.ToString()
                    );

                    OnUploadedFileError(eventArgs);
                } else if(file.InputStream == null) {
                    _lastError = Constants.Errors.NoFileName;

                    eventArgs = new AsyncFileUploadEventArgs(
                        AsyncFileUploadState.Failed,
                        Constants.Errors.NoFileName,
                        file.FileName,
                        file.ContentLength.ToString()
                    );

                    OnUploadedFileError(eventArgs);
                } else if(file.ContentLength < 1) {
                    _lastError = Constants.Errors.EmptyContentLength;

                    eventArgs = new AsyncFileUploadEventArgs(
                        AsyncFileUploadState.Unknown,
                        Constants.Errors.EmptyContentLength,
                        file.FileName,
                        file.ContentLength.ToString()
                    );

                    OnUploadedFileError(eventArgs);
                } else {
                    eventArgs = new AsyncFileUploadEventArgs(
                        AsyncFileUploadState.Success,
                        String.Empty,
                        file.FileName,
                        file.ContentLength.ToString()
                    );

                    if(_persistFile) {
                        GC.SuppressFinalize(file);
                        PersistentStoreManager.Instance.AddFileToSession(this.ClientID, file.FileName, file);
                    } else {
                        _postedFile = file;
                    }
                    OnUploadedComplete(eventArgs);
                }
            }
        }
 protected virtual void OnUploadedFileError(AsyncFileUploadEventArgs e)
 {
     if(UploadedFileError != null)
         UploadedFileError(this, e);
 }
 protected virtual void OnUploadedComplete(AsyncFileUploadEventArgs e)
 {
     if(UploadedComplete != null)
         UploadedComplete(this, e);
 }
Beispiel #32
0
 /// <summary>
 /// Load photo.
 /// </summary>
 /// <param name="sender">Object sender.</param>
 /// <param name="e">Eventargs e.</param>
 protected void OnfuPhoto_UploadedComplete(Object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
 {
 }
    protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        // Save file
        string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);

        filename = String.Format("AAT_{0}_ORDER_{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), filename);
        AsyncFileUpload1.SaveAs(Server.MapPath("~/Files/") + filename);

        // AAT
        string CustCode = "40116011";

        filename = Server.MapPath("~/Files/") + filename;
        if (File.Exists(filename))
        {
            DataTable dt         = new DataTable();
            var       connString = string.Format(@"Provider=Microsoft.Jet.OleDb.4.0; Data Source={0};Extended Properties=""Text;HDR=YES;FMT=Delimited""", Path.GetDirectoryName(filename));
            using (OleDbConnection con = new OleDbConnection(connString))
            {
                try
                {
                    using (SqlProcedure sp = new SqlProcedure("sp_AAT_Order_ClearData"))
                    {
                        sp.ExecuteNonQuery();
                    }
                    if (con.State != ConnectionState.Open)
                    {
                        con.Open();
                    }
                    var query = "SELECT * FROM [" + Path.GetFileName(filename) + "]";
                    using (var adapter = new OleDbDataAdapter(query, con))
                    {
                        adapter.Fill(dt);
                        if (dt.Columns.Count == 39)
                        {
                            bool boolStatusInsert = false;
                            foreach (DataRow _item in dt.Rows)
                            {
                                if (boolStatusInsert)
                                {
                                    if (_item[38].ToString() == "W")
                                    {
                                        MyCompany.Data.Objects.AATOrderImport Order = new MyCompany.Data.Objects.AATOrderImport();
                                        Order.OrderBy             = CustCode;
                                        Order.DeliveryDestination = _item[8].ToString();
                                        Order.CustomerMatCode     = _item[11].ToString();
                                        string[] scpdTemp = SharedBusinessRules.getMaterial(_item[11].ToString(), CustCode, _item[8].ToString(), "AAT").Split(':');
                                        Order.PartsDevision       = scpdTemp[1];
                                        Order.CustomerPO          = _item[12].ToString();
                                        Order.ReliabilityDevision = "F";
                                        Order.DeliveryDate        = Convert.ToDateTime(_item[35].ToString().Substring(0, 4).Trim() + "-" + _item[35].ToString().Substring(4, 2).Trim() + "-" + _item[35].ToString().Substring(6, 2).Trim());
                                        Order.Quantity            = _item[32].ToString();
                                        Order.Unit       = _item[33].ToString();
                                        Order.PlngPeriod = "D";
                                        Order.SAPCode    = scpdTemp[0];
                                        Order.Insert();
                                    }
                                }
                                else
                                {
                                    boolStatusInsert = true;
                                }
                            }
                        }
                        else if (dt.Columns.Count == 30)
                        {
                            bool boolStatusInsert = false;
                            foreach (DataRow _item in dt.Rows)
                            {
                                if (boolStatusInsert)
                                {
                                    MyCompany.Data.Objects.AATOrderImport Order = new MyCompany.Data.Objects.AATOrderImport();
                                    Order.OrderBy             = CustCode;
                                    Order.DeliveryDestination = _item[8].ToString();
                                    Order.CustomerMatCode     = _item[11].ToString();
                                    string[] scpdTemp = SharedBusinessRules.getMaterial(_item[11].ToString(), CustCode, _item[8].ToString(), "AAT").Split(':');
                                    Order.PartsDevision       = scpdTemp[1];
                                    Order.CustomerPO          = _item[12].ToString();
                                    Order.ReliabilityDevision = "F";
                                    Order.DeliveryDate        = Convert.ToDateTime(_item[28].ToString().Substring(0, 4).Trim() + "-" + _item[28].ToString().Substring(4, 2).Trim() + "-" + _item[28].ToString().Substring(6, 2).Trim());
                                    Order.Quantity            = _item[25].ToString();
                                    Order.Unit       = _item[26].ToString();
                                    Order.PlngPeriod = "D";
                                    Order.SAPCode    = scpdTemp[0];
                                    Order.Insert();
                                }
                                else
                                {
                                    boolStatusInsert = true;
                                }
                            }
                        }
                    }
                    con.Close();
                }
                catch (Exception ex)
                {
                }
            }
        }
    }
    protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        // Save file
        string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);

        filename = String.Format("NPT_{0}_ORDER_{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), filename);
        AsyncFileUpload1.SaveAs(Server.MapPath("~/Files/") + filename);

        // HATC Order
        string CustCode = "40132010";

        filename = Server.MapPath("~/Files/") + filename;
        if (File.Exists(filename))
        {
            string line = string.Empty;
            using (StreamReader sr = new StreamReader(filename))
            {
                int totalLine = 0;
                Dictionary <int, string> DueDate = new Dictionary <int, string>();
                while ((line = sr.ReadLine()) != null)
                {
                    if (line.Length > 0)
                    {
                        string[] data = line.Split(',');
                        if (data.Length > 0 && totalLine == 0)
                        {
                            #region DeliveryDate
                            for (int i = 11; i < data.Length; i++)
                            {
                                string[] orderData = data[i].Split('-');
                                if (orderData.Length > 1)
                                {
                                    int OrderDate = 0;
                                    Int32.TryParse(orderData[0], out OrderDate);
                                    if (OrderDate > 0)
                                    {
                                        // Is Delivery Date

                                        string DeliveryDate = String.Format("{0:00}", OrderDate);
                                        switch (orderData[1].ToLower())
                                        {
                                        case "jan": DeliveryDate = "-01-" + DeliveryDate;
                                            break;

                                        case "feb": DeliveryDate = "-02-" + DeliveryDate;
                                            break;

                                        case "mar": DeliveryDate = "-03-" + DeliveryDate;
                                            break;

                                        case "apl": DeliveryDate = "-04-" + DeliveryDate;
                                            break;

                                        case "may": DeliveryDate = "-05-" + DeliveryDate;
                                            break;

                                        case "jun": DeliveryDate = "-06-" + DeliveryDate;
                                            break;

                                        case "jul": DeliveryDate = "-07-" + DeliveryDate;
                                            break;

                                        case "aug": DeliveryDate = "-08-" + DeliveryDate;
                                            break;

                                        case "sep": DeliveryDate = "-09-" + DeliveryDate;
                                            break;

                                        case "oct": DeliveryDate = "-10-" + DeliveryDate;
                                            break;

                                        case "nov": DeliveryDate = "-11-" + DeliveryDate;
                                            break;

                                        case "dec": DeliveryDate = "-12-" + DeliveryDate;
                                            break;
                                        }
                                        // DataIndexing , Month and date
                                        if (!DueDate.ContainsKey(i))
                                        {
                                            DueDate.Add(i, DeliveryDate);
                                        }
                                    }
                                    else
                                    {
                                        // Forcast
                                    }
                                }
                            }
                            #endregion
                        }
                        else
                        {
                            // RowData
                            if (!String.IsNullOrEmpty(data[236].Trim()))
                            {
                                foreach (KeyValuePair <int, string> item in DueDate)
                                {
                                    int Qty = 0;
                                    Int32.TryParse(data[item.Key], out Qty);

                                    MyCompany.Data.Objects.NPTOrderImport Order = new MyCompany.Data.Objects.NPTOrderImport();
                                    Order.OrderBy             = CustCode;
                                    Order.DeliveryDestination = data[10].ToString().Trim();
                                    Order.CustomerMatCode     = data[4].Trim();
                                    Order.PartsDevision       = "1";
                                    Order.CustomerPO          = "";
                                    Order.ReliabilityDevision = "P";
                                    Order.DeliveryDate        = Convert.ToDateTime(data[236] + item.Value);
                                    Order.Quantity            = Qty.ToString().Trim();
                                    Order.Unit       = "ST";
                                    Order.PlngPeriod = "D";
                                    Order.SAPCode    = "";//SharedBusinessRules.getSAPCode(Order.CustomerMatCode);
                                    Order.Insert();
                                }
                            }
                        }
                    }

                    totalLine++;
                }
                sr.Close();
            }
        }
    }
    protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);

        filename = String.Format("MMTH_{0}_FORVAST_{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), filename);
        AsyncFileUpload1.SaveAs(Server.MapPath("~/Files/") + filename);
        filename = Server.MapPath("~/Files/") + filename;
        if (File.Exists(filename))
        {
            string line = string.Empty;
            using (StreamReader sr = new StreamReader(filename))
            {
                using (SqlProcedure sp = new SqlProcedure("sp_MMTH_Order_ClearData"))
                {
                    sp.ExecuteNonQuery();
                }
                while ((line = sr.ReadLine()) != null)
                {
                    string[] arr = line.Split('|');
                    if (!arr[4].Contains("9999999999999999"))
                    {
                        string plantCode = arr[2];
                        string yyyy      = arr[3].Substring(0, 4);
                        string MM        = arr[3].Substring(4, 2);
                        string partNo    = arr[4];
                        string dayOld    = arr[11];
                        for (int d = 12; d <= arr.Length - 1; d += 2)
                        {
                            if (arr[d - 1] == "00")
                            {
                                break;
                            }
                            if (Convert.ToInt32(dayOld) > Convert.ToInt32(arr[d - 1]))
                            {
                                DateTime dtTemp = Convert.ToDateTime(yyyy + "-" + MM + "-01");
                                dtTemp = dtTemp.AddMonths(1);
                                MM     = dtTemp.Month.ToString();
                                yyyy   = dtTemp.Year.ToString();
                            }
                            MyCompany.Models.MMTHForcastImport forcast = new MyCompany.Models.MMTHForcastImport();
                            forcast.OrderBy             = "40113011";
                            forcast.DeliveryDestination = plantCode;
                            forcast.CustomerMatCode     = partNo.Trim();
                            string[] materialTemp = SharedBusinessRules.getMaterial(forcast.CustomerMatCode, "40113011", plantCode, "MMTh").Split(':');
                            if (materialTemp.Length > 1)
                            {
                                forcast.SAPCode                 = materialTemp[0];
                                forcast.PartsDevision           = materialTemp[1];
                                forcast.DeliveryDestinationCode = materialTemp[2];
                            }
                            forcast.CustomerPO          = "";
                            forcast.ReliabilityDevision = "F";
                            forcast.Unit         = "ST";
                            forcast.PlngPeriod   = "D";
                            forcast.DeliveryDate = Convert.ToDateTime(yyyy + "-" + MM + "-" + arr[d - 1]);
                            forcast.Quantity     = Convert.ToInt32(arr[d]);
                            forcast.Insert();
                            dayOld = arr[d - 1];
                        }
                    }
                }
            }
        }
    }
Beispiel #36
0
        private void AsyncFileUpload1UploadedComplete(object sender, AsyncFileUploadEventArgs e)
        {
            string filename = e.FileName;
            if (filename == null)
                return;
            string contentType = AsyncFileUpload1.PostedFile.ContentType;
            if (!contentType.Contains("image"))
                return;
            var fileName = Path.GetFileName(filename);
            if (fileName.Contains(".pdf"))
            {
                AsyncFileUpload1.FailedValidation = true;
                return;
            }
            if (int.Parse(e.FileSize) > 2000000)
            {
                AsyncFileUpload1.FailedValidation = true;
                return;
            }
            string savePath = Page.MapPath(String.Format("~/Avatars/{0}", Path.GetFileName(filename).Replace(" ", "+")));
            ScriptManager.RegisterClientScriptBlock(this, GetType(), "size", "$(function() {top.$get(\"" + uploadResult.ClientID + "\").innerHTML = 'Uploaded size: " + AsyncFileUpload1.FileBytes.Length.ToString() + "';});", true);

            AsyncFileUpload1.SaveAs(savePath);
            _user.Avatar = Path.GetFileName(filename).Replace(" ", "+");
            Members.SaveMember(_user);
        }
Beispiel #37
0
 protected void chatRoomImgUpload_UploadedFileError(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
 {
     Console.WriteLine("Error.");
 }
        void AsyncFileUpload1_UploadedComplete(object sender, AsyncFileUploadEventArgs e)
        {
            // Uncomment to save to AsyncFileUpload\Uploads folder.
            // ASP.NET must have the necessary permissions to write to the file system.
            Catologie item = new Catologie();
            item.CatologyGuid = new Guid(LiteralCatologyGuid.Text);
            item.UrlHinhanh = AsyncFileUpload1.FileName;
            item.DataImage = AsyncFileUpload1.FileBytes;

            //co the xay ra loi cho nay
            OnSaveFile_Event(item);
        }
    protected void AFU_Final_Donor_Information_PCN_Warning_Document_OnUploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        string region = "", market = "";

        GetRegionMarket(ref region, ref market);
        if (AFU_Final_Donor_Information_PCN_Warning_Document.HasFile)
        {
            MWIntakeUpload(AFU_Final_Donor_Information_PCN_Warning_Document, MWIntakeCommon.FileCategory._pcnwarn, region, market);

            // string[] sa_file = Path.GetFileName(e.FileName).Split('.');

            //// if (sa_file[sa_file.Length - 1].ToUpper().Equals("PDF"))
            //// {
            //     string s_TimeStamp = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();
            //     string m_AppDir = HttpContext.Current.Request.PhysicalApplicationPath.ToString();

            //     if (!Directory.Exists(m_AppDir + "/Uploads/" + s_id + "/"))
            //         Directory.CreateDirectory(m_AppDir + "/Uploads/" + s_id + "/");

            //     string strPath = MapPath("~/Uploads/" + s_id + "/") + sa_file[0] + "_" + s_TimeStamp + "_Warning_Document" + "." + sa_file[sa_file.Length - 1];
            //     //string strPath = MapPath(m_AppDir + "\\Uploads\\\\" + i_ticket + "\\\\") + Path.GetFileName(e.filename);

            //     AsyncFileUpload_Warning_Document.SaveAs(strPath);
            //l_Test.Text = "Finished!";
            //}
            //else
            //{
            //    lbl_Error_1.Text = "You could only upload pdf file!";
            //}
        }
    }
        private void RecievedFile(string sendingControlID)
        {
            AsyncFileUploadEventArgs eventArgs = null;
            lastError = String.Empty;

            if (this.Page.Request.Files.Count > 0)
            {
                HttpPostedFile file = null;
                if (sendingControlID == null || sendingControlID == String.Empty)
                {
                    file = this.Page.Request.Files[0];
                }
                else
                {
                    foreach (string postedFile in this.Page.Request.Files)
                    {
                        if (postedFile.Replace("$","_").StartsWith(sendingControlID))
                        {
                            file = this.Page.Request.Files[postedFile];
                            break;
                        }
                    }
                }
                if (file == null)
                {
                    lastError = Constants.Errors.FileNull;
                    eventArgs = new AsyncFileUploadEventArgs(AsyncFileUploadState.Failed, Constants.Errors.FileNull, String.Empty, String.Empty);
                    OnUploadedFileError(eventArgs);
                }
                else if (file.FileName == String.Empty)
                {
                    lastError = Constants.Errors.NoFileName;
                    eventArgs = new AsyncFileUploadEventArgs(AsyncFileUploadState.Unknown, Constants.Errors.NoFileName, file.FileName, file.ContentLength.ToString());
                    OnUploadedFileError(eventArgs);
                }
                else if (file.InputStream == null)
                {
                    lastError = Constants.Errors.NoFileName;
                    eventArgs = new AsyncFileUploadEventArgs(AsyncFileUploadState.Failed, Constants.Errors.NoFileName, file.FileName, file.ContentLength.ToString());
                    OnUploadedFileError(eventArgs);
                }
                else if (file.ContentLength < 1)
                {
                    lastError = Constants.Errors.EmptyContentLength;
                    eventArgs = new AsyncFileUploadEventArgs(AsyncFileUploadState.Unknown, Constants.Errors.EmptyContentLength, file.FileName, file.ContentLength.ToString());
                    OnUploadedFileError(eventArgs);
                }
                else
                {
                    eventArgs = new AsyncFileUploadEventArgs(AsyncFileUploadState.Success, String.Empty, file.FileName, file.ContentLength.ToString());
                    GC.SuppressFinalize(file);
                    AfuPersistedStoreManager.Instance.AddFileToSession(this.ClientID, file.FileName, file);
                    OnUploadedComplete(eventArgs);
                }
            }
        }
        protected void AsyncFileUpload_UploadedFileError(object sender, AsyncFileUploadEventArgs e)
        {

        }
Beispiel #42
0
    protected void ULComplete_CSV_Exotics(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        LabelStatus.Text += "UL Completed<br/>";

        AjaxControlToolkit.AsyncFileUpload fileupload = (AjaxControlToolkit.AsyncFileUpload)sender;
        //Upload files
        if (fileupload.HasFile)
        {
            //use newly created id to name file
            string newfilename = "exotics";
            string savepath    = Server.MapPath("~/admin/csv/");
            string extension   = Path.GetExtension(fileupload.FileName);
            LabelStatus.Text += "Saving File:<br/>";
            string newfile = shared.SaveFile(fileupload.PostedFile, newfilename, savepath, extension);
            LabelStatus.Text += "Loading Exotics Information:<br/>";
            string csvfile = newfile;

            string path = Server.MapPath("~/admin/csv/" + csvfile);
            string full = Path.GetFullPath(path);
            string file = Path.GetFileName(full);
            string dir  = Path.GetDirectoryName(full);

            //create the "database" connection string
            //Microsoft.ACE.OLEDB.12.0
            string connString = "Provider=Microsoft.Jet.OLEDB.4.0;"
                                + "Data Source=\"" + dir + "\\\";"
                                + "Extended Properties=\"text;HDR=No;FMT=Delimited\"";
            //LabelStatus.Text += "<br/>";
            //LabelStatus.Text+= connString + "<br/>";
            //LabelStatus.Text += "<br/>File Location: " + dir + "\\" + file;
            //LabelStatus.Text += "<br/>Exists: " + System.IO.File.Exists(dir + "\\" + file) + "<br/>" + System.IO.File.ReadAllText(dir + "\\" + file) + "<br/><br/>";
            //create the database query
            string query = "SELECT * FROM " + csvfile;
            //create a DataTable to hold the query results
            DataTable dTable = new DataTable();
            //create an OleDbDataAdapter to execute the query
            OleDbDataAdapter dAdapter = new OleDbDataAdapter(query, connString);
            try
            {
                //fill the DataTable
                dAdapter.Fill(dTable);
            }
            catch (InvalidOperationException /*e*/)
            { }


            dAdapter.Dispose();

            LabelStatus.Text += "Loading Inormation";
            try
            {
                //LoadInfo(dTable);
                ProcessCSV_Exotics(dTable);
            }
            catch (Exception ex) { LabelStatus.Text = "Error Loading csv: " + ex.ToString(); }
        }
        else
        {
            LabelStatus.Text = "No valid file uploaded.";
        }
    }
Beispiel #43
0
    protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        // Save file
        string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);

        filename = String.Format("HATC_{0}_FORCAST_{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), filename);
        AsyncFileUpload1.SaveAs(Server.MapPath("~/Files/") + filename);

        // HATC Order
        //string CustCode = "40108011";
        filename = Server.MapPath("~/Files/") + filename;
        if (File.Exists(filename))
        {
            using (StreamReader sr = new StreamReader(filename))
            {
                List <MyCompany.Data.Objects.HATCForcastMonthImport> HATCList = new List <MyCompany.Data.Objects.HATCForcastMonthImport>();
                string line = string.Empty, CustMatNo = string.Empty, year = string.Empty, PlantCode = string.Empty;
                Dictionary <int, string> dueDate = new Dictionary <int, string>();
                Dictionary <int, double> orderQty = new Dictionary <int, double>();
                using (SqlProcedure sp = new SqlProcedure("sp_HATC_ForcastMonth_ClearData"))
                {
                    sp.ExecuteNonQuery();
                }
                while ((line = sr.ReadLine()) != null)
                {
                    if (line.EndsWith("MONTH") && line.StartsWith(""))
                    {
                        dueDate.Clear();
                        // Correct DueDate
                        string[] _data     = line.Substring(line.IndexOf("PLAN GROUP") + 10, line.IndexOf("MONTH") - line.IndexOf("PLAN GROUP") - 10).Trim().Split(' ');
                        int      dataIndex = 0;
                        for (int i = 0; i < _data.Length; i++)
                        {
                            if (!String.IsNullOrEmpty(_data[i]))
                            {
                                dueDate.Add(dataIndex, _data[i]);
                                dataIndex++;
                            }
                        }
                    }

                    int lineNum = 0;
                    if (Int32.TryParse(line.Substring(0, 6).Trim(), out lineNum))
                    {
                        if (!(line.Trim().EndsWith("ROKI(THAILAND)CO.,LTD.") || line.Trim().StartsWith("TOTAL") || String.IsNullOrEmpty(line.Substring(0, 50).Trim())))
                        {
                            CustMatNo = line.Substring(6, 35).Trim();
                            PlantCode = line.Substring(41, 15).Trim();
                            string[] _qty      = line.Substring(57, line.Length - 57).Trim().Split(' ');
                            int      dataIndex = 0;
                            orderQty.Clear();
                            for (int i = 0; i < _qty.Length; i++)
                            {
                                if (!String.IsNullOrEmpty(_qty[i]))
                                {
                                    orderQty.Add(dataIndex, Convert.ToDouble(_qty[i]));
                                    dataIndex++;
                                }
                            }

                            // Insert Data
                            foreach (KeyValuePair <int, string> item in dueDate)
                            {
                                MyCompany.Data.Objects.HATCForcastMonthImport Order = new MyCompany.Data.Objects.HATCForcastMonthImport();

                                Order.OrderBy             = PlantCode.EndsWith("03") ? "40138011" : "40108011";
                                Order.DeliveryDestination = "";
                                Order.CustomerMatCode     = CustMatNo;
                                Order.PartsDevision       = "1";
                                Order.CustomerPO          = "";
                                Order.ReliabilityDevision = "F";
                                Order.Unit       = "ST";
                                Order.PlngPeriod = "M";
                                Order.SAPCode    = "";//SharedBusinessRules.getSAPCode(Order.CustomerMatCode);
                                string[] _dueDate = item.Value.Split('/');
                                Order.DeliveryDate = Convert.ToDateTime(String.Format("{0}-{1}-{2}", _dueDate[1], string.Format("{0:00}", Convert.ToInt32(_dueDate[0])), "01"));
                                Order.Quantity     = Convert.ToDecimal(orderQty[item.Key]);
                                Order.Insert();
                            }
                        }
                    }
                }
                sr.Close();
            }
        }
    }
Beispiel #44
0
    protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        // Save file
        string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);

        AsyncFileUpload1.SaveAs(Server.MapPath("~/Files/") + filename);

        // HATC Order
        string CustCode = "40138011";

        filename = Server.MapPath("~/Files/") + filename;

        if (File.Exists(filename))
        {
            string           line           = string.Empty;
            string           CustPartNo     = "";
            string           CustDesination = "";
            bool             flagGetPostion = false;
            DateTime         IssueDate;
            List <MQtyOrder> colDate  = new List <MQtyOrder>();
            List <String>    itemHead = new List <string>();
            using (StreamReader sr = new StreamReader(filename))
            {
                using (SqlProcedure sp = new SqlProcedure("sp_TSM_ForcastMonth_ClearData"))
                {
                    sp.ExecuteNonQuery();
                }
                while ((line = sr.ReadLine()) != null)
                {
                    if (line.Trim().Length > 0)
                    {
                        string[] item = ParseCsvRow(line);
                        //Head
                        if (item.Length == 9)
                        {
                            if (IsDateTime(item[8]) == true)
                            {
                                IssueDate = Convert.ToDateTime(item[8].Trim());
                                //MessageBox.Show(item[8]);

                                for (int iMonth = 2; iMonth < item.Length - 1; iMonth++)
                                {
                                    //List<String> itemHead = new List<string>();
                                    int month = DateTime.Parse("1/" + item[iMonth] + "/2008").Month;
                                    if (month < IssueDate.Month)
                                    {
                                        itemHead.Add("01/" + month.ToString("0#") + "/" + (Convert.ToInt32(item[8].Trim().Substring(6)) + 1).ToString().Trim());
                                    }
                                    else
                                    {
                                        itemHead.Add("01/" + month.ToString("0#") + item[8].Substring(6).Trim());
                                    }
                                    //MessageBox.Show(month.ToString());
                                    //itemHead
                                }
                            }
                            //itemHead = item;
                        }
                        //Detail
                        if (item.Length == 8)
                        {
                            for (int iMonth = 0; iMonth < itemHead.Count; iMonth++)
                            {
                                MyCompany.Data.Objects.TSMForcastMonthImport Order = new MyCompany.Data.Objects.TSMForcastMonthImport();
                                Order.OrderBy             = CustCode;
                                Order.DeliveryDestination = "";
                                Order.CustomerMatCode     = item[0];
                                Order.PartsDevision       = "1";
                                Order.CustomerPO          = "";
                                Order.ReliabilityDevision = "P";
                                //Order.DeliveryDate = itemHead[iMonth];
                                string[] spritDate = itemHead[iMonth].Split(Convert.ToChar("/"));
                                if (spritDate.Length == 3)
                                {
                                    Order.DeliveryDate = Convert.ToDateTime(DateTime.Now.Year.ToString().Substring(0, 2) + spritDate[2] + "-" + Convert.ToInt32(spritDate[1]).ToString("0#") + "-" + spritDate[0]);
                                }
                                else
                                {
                                    Order.DeliveryDate = null;
                                }
                                Order.Quantity   = item[iMonth + 2];
                                Order.Unit       = "ST";
                                Order.PlngPeriod = "D";
                                Order.SAPCode    = "";//SharedBusinessRules.getSAPCode(Order.CustomerMatCode);
                                Order.Insert();
                                //MT05 result = new MT05();
                                //result.OrderBy = CustomerCode;
                                //result.DeliveryDesination = CustDesination;
                                //result.CustomerMatCode = item[0];
                                //result.PartsDivision = "1";
                                //result.CustomerPONo = "Not sure";
                                //result.ReliabilityDivision = "P";
                                //result.DeliveryDate = itemHead[iMonth];
                                //result.Quantity = Convert.ToInt32(item[iMonth + 2]);
                                //result.Unit = "ST";
                                //result.PIngPeriod = "D";
                                //Data.Add(result);
                            }
                        }
                    }
                }
            }
        }
    }
Beispiel #45
0
    protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        // Save file
        string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);

        filename = String.Format("KMT_{0}_ORDER_{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), filename);
        AsyncFileUpload1.SaveAs(Server.MapPath("~/Files/") + filename);

        // HATC Order
        string CustCode = "40104010";

        filename = Server.MapPath("~/Files/") + filename;
        if (File.Exists(filename))
        {
            //int i = 0;
            string line;
            // Read the file and display it line by line.
            System.IO.StreamReader file =
                new System.IO.StreamReader(filename);
            //List<MQtyOrder> colDate = new List<MQtyOrder>();
            //List<String> itemHead = new List<string>();
            StringBuilder htmlString = new StringBuilder();
            while ((line = file.ReadLine()) != null)
            {
                htmlString.Append(line);
                htmlString.Append("\r\n");
            }
            DataSet ds = new DataSet();
            ds = ConvertHTMLTablesToDataSet(htmlString.ToString());
            DataTable dt = new DataTable();
            dt = ds.Tables[0];
            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    MyCompany.Data.Objects.KMTOrderImport Order = new MyCompany.Data.Objects.KMTOrderImport();
                    Order.OrderBy             = CustCode;
                    Order.DeliveryDestination = dt.Rows[i][5].ToString().Trim();
                    Order.CustomerMatCode     = dt.Rows[i][1].ToString().Trim().Replace(" ", "");
                    Order.PartsDevision       = "1";
                    Order.CustomerPO          = dt.Rows[i][3].ToString().Trim();
                    Order.ReliabilityDevision = "P";
                    string[] spritDate = dt.Rows[i][4].ToString().Trim().Split(Convert.ToChar("/"));
                    if (spritDate.Length == 3)
                    {
                        Order.DeliveryDate = Convert.ToDateTime(spritDate[2] + "-" + Convert.ToInt32(spritDate[1]).ToString("0#") + "-" + spritDate[0]);
                    }
                    else
                    {
                        Order.DeliveryDate = null;
                    }
                    Order.Quantity   = float.Parse(dt.Rows[i][7].ToString().Trim()).ToString().Trim();
                    Order.Unit       = "ST";
                    Order.PlngPeriod = "D";
                    Order.SAPCode    = "";//SharedBusinessRules.getSAPCode(Order.CustomerMatCode);
                    Order.Insert();
                }
            }



            //try
            //{

            //    System.Data.OleDb.OleDbConnection MyConnection;
            //    System.Data.OleDb.OleDbCommand myCommand = new System.Data.OleDb.OleDbCommand();
            //    string sql = null;
            //    MyConnection = new System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" + filename + ";Extended Properties=Excel 8.0;HDR=YES;IMEX=1;");
            //    MyConnection.Open();
            //    myCommand.Connection = MyConnection;
            //    sql = "select * from [Sheet1$]";
            //    myCommand.CommandText = sql;
            //    OleDbDataReader reader = myCommand.ExecuteReader();

            //    while (reader.Read())
            //    {
            //        var val1 = reader[0].ToString();
            //    }
            //    //myCommand.ExecuteNonQuery();
            //    //System.Data.OleDb.OleDbDataReader dr = new System.Data.OleDb.OleDbDataReader();
            //    System.Data.OleDb.OleDbDataAdapter da = new System.Data.OleDb.OleDbDataAdapter(sql, MyConnection);
            //    //Dim y As New Odbc.OdbcDataAdapter(sql, MyConnection);
            //    //dr = myCommand.ExecuteReader();
            //    DataTable dt = new DataTable();
            //    da.Fill(dt);
            //    MyConnection.Close();
            //    //MessageBox.Show("Success");
            //}
            //catch (Exception ex)
            //{
            //    //MessageBox.Show(ex.ToString());
            //}


            //string line = string.Empty;
            //using (StreamReader sr = new StreamReader(filename))
            //{
            //    while ((line = sr.ReadLine()) != null)
            //    {
            //        if (line.Length > 0)
            //        {
            //            #region Format
            //            string shipto = line.Substring(145, 5) + "-" + line.Substring(22, 6);
            //            if ((line.Substring(140, 5) == "45320" || line.Substring(140, 5) == "05386") && line.Substring(10, 12) != "000000000000")
            //            {
            //                MyCompany.Data.Objects.HATCOrderImport Order = new MyCompany.Data.Objects.HATCOrderImport();

            //                Order.OrderBy = CustCode;
            //                Order.DeliveryDestination = CustCode;
            //                Order.CustomerMatCode = line.Substring(28, 18).Replace(" ", "");
            //                Order.PartsDevision = "1";
            //                Order.CustomerPO = line.Substring(10, 12);
            //                Order.ReliabilityDevision = "P";
            //                Order.DeliveryDate = line.Substring(124, 2) + line.Substring(122, 2) + line.Substring(118, 4);
            //                Order.Quantity = line.Substring(126, 7);
            //                Order.Unit = "ST";
            //                Order.PlngPeriod = "D";
            //                Order.SAPCode = SharedBusinessRules.getSAPCode(Order.CustomerMatCode);
            //                Order.Insert();
            //            }
            //            #endregion
            //        }
            //    }
            //sr.Close();
            //}
        }

        //// Forcast

        //string CustomerCode = "";
        //string Desination = "";
        ////BindDataT05(CustomerCode, "HATC", "ODB");
        //List<MT05> Data = new List<MT05>();
        //if (openFileDialog1.ShowDialog() == DialogResult.OK)
        //{
        //    string path = openFileDialog1.FileName.ToString().Trim();
        //    ////Import File to Datatable
        //    string line;
        //    // Read the file and display it line by line.
        //    System.IO.StreamReader file =
        //           new System.IO.StreamReader(path);
        //    try
        //    {
        //        int rowsCount = 0;
        //        int i = 0;
        //        List<string> str = new List<string>();

        //        string CustPartNo = "";
        //        while ((line = file.ReadLine()) != null)
        //        {
        //            rowsCount++;
        //            MT05 T05 = new MT05();
        //            if (rowsCount % 16 == 0)
        //            {

        //                //Get Customer code
        //                CustomerCode = str[2].Substring(5, 10).Trim();
        //                Desination = str[9].Substring(8, 10).Trim();
        //                //Get Customer Part No && Array Date
        //                //string[] arrStrLine6;
        //                //arrStrLine6 = str[5].Split(Convert.ToChar(" "));
        //                //int getRow5 = 0;
        //                List<MQtyOrder> QtyOfDate = new List<MQtyOrder>();
        //                //CustPartNo = str[5].Split(Convert.ToChar(" "));
        //                CustPartNo = str[5].Substring(0, 31);
        //                #region DateOfOrder
        //                if (str[5].Substring(33, 4) == "DATE")
        //                {
        //                    //MessageBox.Show("Line OK");
        //                    string Month = "";
        //                    int startPostition = 0;
        //                    int endPostition = 0;
        //                    string flagPosition = "End";
        //                    //string flagSavePosition = "No";
        //                    //Merge stirng Date
        //                    for (int iRow5 = 37; iRow5 < str[5].Length; iRow5++)
        //                    {
        //                        if (str[5].Substring(iRow5, 1) != " ")
        //                        {
        //                            if (flagPosition == "End")
        //                            {
        //                                startPostition = iRow5;
        //                                flagPosition = "Start";
        //                            }
        //                            if (str[5].Substring(iRow5, 5) == "TOTAL")
        //                            {
        //                                //MessageBox.Show("End Line !!!");
        //                                //return;
        //                                break;
        //                            }
        //                            else
        //                            {
        //                                Month = Month + str[5].Substring(iRow5, 1);
        //                            }

        //                        }
        //                        else
        //                        {
        //                            if (flagPosition == "Start")
        //                            {
        //                                //flagPosition = "End";
        //                                //}
        //                                flagPosition = "End";
        //                                endPostition = iRow5;
        //                                //flagSavePosition = "NO";
        //                            }
        //                            if (Month != "")
        //                            {
        //                                //Save Date
        //                                MQtyOrder Qty = new MQtyOrder();
        //                                Qty.OrderDate = Month;
        //                                Qty.startPosition = startPostition;
        //                                Qty.endPosition = endPostition;
        //                                QtyOfDate.Add(Qty);
        //                                //MessageBox.Show(Month + " : " + startPostition + "," + endPostition);
        //                                Month = "";
        //                            }
        //                        }
        //                    }
        //                #endregion
        //                    #region QtyOfOrder
        //                    if (str[6].Substring(33, 4) == "QTY.")
        //                    {
        //                        //for (int iRow6 = 37; iRow6 < str[6].Length; iRow6++)
        //                        //{

        //                        //}
        //                        for (int iQty = 0; iQty < QtyOfDate.Count; iQty++)
        //                        {
        //                            //MQtyOrder Qty = new MQtyOrder();
        //                            //Qty = QtyOfDate[iQty];
        //                            //Qty.OrderQty =
        //                            string Qty = str[6].Substring(QtyOfDate[iQty].startPosition, QtyOfDate[iQty].endPosition - QtyOfDate[iQty].startPosition).ToString().Trim();
        //                            if (Qty == "")
        //                            {
        //                                QtyOfDate[iQty].OrderQty = 0;
        //                            }
        //                            else
        //                            {
        //                                QtyOfDate[iQty].OrderQty = Convert.ToInt32(Qty);
        //                            }
        //                            //QtyOfDate[iQty].OrderQty = str[6].Substring(QtyOfDate[iQty].startPosition, QtyOfDate[iQty].endPosition - QtyOfDate[iQty].startPosition);
        //                        }
        //                    }
        //                    #endregion
        //                    #region ShowData
        //                    //List<MT05> Data = new List<MT05>();
        //                    for (int iShow = 0; iShow < QtyOfDate.Count; iShow++)
        //                    {
        //                        MT05 result = new MT05();
        //                        result.OrderBy = CustomerCode;
        //                        result.DeliveryDesination = Desination;
        //                        result.CustomerMatCode = CustPartNo;
        //                        result.PartsDivision = "1";
        //                        result.CustomerPONo = "Not sure";
        //                        result.ReliabilityDivision = "P";
        //                        result.DeliveryDate = QtyOfDate[iShow].OrderDate;
        //                        result.Quantity = QtyOfDate[iShow].OrderQty;
        //                        result.Unit = "ST";
        //                        result.PIngPeriod = "D";
        //                        Data.Add(result);
        //                    }
        //                    #endregion
        //                    str.Clear();
        //                    //rowsCount = 1;
        //                }

        //            }
        //            else
        //            {
        //                str.Add(line);
        //            }
        //        }
        //        dgvData.DataSource = Data;
        //    }
        //    catch (Exception)
        //    {

        //        throw;
        //    }
        //}
    }
 protected void updDistressImage_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
 {
     Session["PhotoChanged"] = true;
 }
 void asyncImageUpload_UploadedComplete(object sender, AsyncFileUploadEventArgs e)
 {
     string fileRelativeLocation = "/AsyncFileUpload/Uploads/" +
                                 Path.GetFileName(e.FileName);
     string LastAsyncFileUploadLocation = MapPath("~" + fileRelativeLocation);
     if (File.Exists(LastAsyncFileUploadLocation))
         File.Delete(LastAsyncFileUploadLocation);
     asyncImageUpload.SaveAs(LastAsyncFileUploadLocation);
     PrimaryPhotoURL = Config.Urls.Home + fileRelativeLocation;
 }
Beispiel #48
0
        protected void AsyncFileUpload_UploadedComplete(object sender, AsyncFileUploadEventArgs e)
        {
            var FilePath = FileUploadUtil.SaveUploadeFile((AsyncFileUpload)sender, SystemConfigs.UrlKidsPicFilesPath(OnlineKidsUser.SSOUser.UserID),
                                                          UploadFileType.Pictures, UploadFileSizeLimitation._500K);


            if (string.IsNullOrWhiteSpace(FilePath))
                return;

            switch ((sender as AsyncFileUpload).ID)
            {

                case "fupChildPic":
                    SessionItems.ChildPic = FilePath;
                    ImgChildPic.ImageUrl = "~/JpegImage.aspx?act=30&d=" + DateTime.Now;
                    break;

                case "fupChildIdentityPic":
                    SessionItems.ChildIdentityPic = FilePath;
                    ImgChildIdentityPic.ImageUrl = "~/JpegImage.aspx?act=31&d=" + DateTime.Now;
                    break;

                case "fupChildNationalCardFaceUp":
                    SessionItems.ChildNationalCardFaceUpPic = FilePath;
                    ImgChildNationalCardFaceUp.ImageUrl = "~/JpegImage.aspx?act=32&d=" + DateTime.Now;
                    break;

                case "fupChildNationalCardFaceDown":
                    SessionItems.ChildNationalCardFaceDownPic = FilePath;
                    ImgChildNationalCardFaceDown.ImageUrl = "~/JpegImage.aspx?act=33&d=" + DateTime.Now;
                    break;
            }

        }
Beispiel #49
0
 private void AsyncFileUpload1UploadedComplete(object sender, AsyncFileUploadEventArgs e)
 {
     ProcessUpload(e);
 }
Beispiel #50
0
        private void ProcessUpload(AsyncFileUploadEventArgs e)
        {
            if (e.FileName == null) return;

            ModConfigBase controller = (ModConfigBase)ConfigHelper.ModClass("UploadConfig");
            string types = "";
            if (AllowAttachments)
                types += controller.ModConfiguration.Settings["AllowedAttachmentTypes"].ToString();
            if (AllowImageUploads)
            {
                if (types != "")
                    types += ",";
                types += controller.ModConfiguration.Settings["AllowedImageTypes"].ToString();
            }
            string[] allowedTypes = types.Split(',');
            int fileSizeLimit = FileSizeLimit * (1024 * 1024);
            string uploadpath = controller.ModConfiguration.Settings["FileUploadLocation"].ToString();
            string filext = Path.GetExtension(AsyncFileUpload1.PostedFile.FileName).Replace(".", "");
            string contentType = AsyncFileUpload1.PostedFile.ContentType;
            bool allowed = false;

            if (contentType.Contains("image") && !AllowImageUploads)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "prohibited",
                    "$(function() {top.$get(\"" + uploadResult.ClientID + "\").innerHTML = 'Image upload prohibited';});", true);
                AsyncFileUpload1.FailedValidation = true;
                return;
            }
            if (!contentType.Contains("image") && !AllowAttachments)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "prohibited",
                    "$(function() {top.$get(\"" + uploadResult.ClientID + "\").innerHTML = 'File attachments prohibited';});", true);
                AsyncFileUpload1.FailedValidation = true;
                return;
            }

            foreach (string allowedType in allowedTypes)
            {
                if (filext == allowedType)
                {
                    allowed = true;
                    break;
                }
            }
            if (!allowed || (int.Parse(e.FileSize) > fileSizeLimit))
            {
                AsyncFileUpload1.FailedValidation = true;
                return;
            }

            var name = Path.GetFileName(e.FileName);
            if (contentType.Contains("image"))
            {
                uploadpath = "/Gallery";
            }
            string savePath =
                Page.MapPath(String.Format("{0}/{1}/{2}", uploadpath, HttpContext.Current.User.Identity.Name,
                    name.Replace(" ", "+")));
            if (File.Exists(savePath))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "exists",
                    "$(function() {top.$get(\"" + uploadResult.ClientID + "\").innerHTML = 'File already exists';});", true);
                AsyncFileUpload1.FailedValidation = true;
                return;
            }

            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "size",
                "$(function() {top.$get(\"" + uploadResult.ClientID + "\").innerHTML = 'Uploaded size: " +
                e.FileSize + "';});", true);

            if (!Directory.Exists(Page.MapPath(String.Format("{0}/{1}", uploadpath, HttpContext.Current.User.Identity.Name))))
            {
                Directory.CreateDirectory(
                    Page.MapPath(String.Format("{0}/{1}", uploadpath, HttpContext.Current.User.Identity.Name)));
            }

            if (contentType.Contains("image"))
            {
                if (e.FileName != null && AllowImageUploads)
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "tag",
                        "$(function() {top.$get(\"" + imageTag.ClientID + "\").innerHTML = '[img]" +
                        String.Format("{0}/{1}/{2}", uploadpath, HttpContext.Current.User.Identity.Name, name.Replace(" ", "+")) +
                        "[/img]';});", true);
                }
            }
            else
            {
                if (e.FileName != null && AllowAttachments)
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "tag",
                        "$(function() {top.$get(\"" + imageTag.ClientID + "\").innerHTML = '[file=" + e.FileName + "]" +
                        String.Format("{0}/{1}/{2}", uploadpath, HttpContext.Current.User.Identity.Name, name.Replace(" ", "+")) +
                        "[/file]';});", true);
                }
            }

            AsyncFileUpload1.SaveAs(savePath);
            if (contentType.Contains("image"))
            {
                string thumbPath =
                    Page.MapPath(String.Format("{0}/{1}/thumbnail/{2}", uploadpath, HttpContext.Current.User.Identity.Name,
                        name.Replace(" ", "+")));
                if (!Directory.Exists(Page.MapPath(String.Format("{0}/{1}/thumbnail", uploadpath, HttpContext.Current.User.Identity.Name))))
                {
                    Directory.CreateDirectory(Page.MapPath(String.Format("{0}/{1}/thumbnail", uploadpath, HttpContext.Current.User.Identity.Name)));
                }
                GalleryFunctions.CreateThumbnail(savePath, thumbPath, 100);
            }
        }
Beispiel #51
0
 private void AsyncFileUpload1UploadedFileError(object sender, AsyncFileUploadEventArgs e)
 {
     ScriptManager.RegisterClientScriptBlock(this, GetType(), "error", "$(function() {top.$get(\"" + uploadResult.ClientID + "\").innerHTML = 'Error: " + e.StatusMessage + "';});", true);
 }
 void AsyncFileUpload1_UploadedFileError(object sender, AsyncFileUploadEventArgs e)
 {
     ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "error", "top.$get(\"" + uploadResult.ClientID + "\").innerHTML = 'Error: " + e.statusMessage + "';", true);
 }
Beispiel #53
0
    protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        // Save file
        string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);
        string fn       = filename;

        filename = String.Format("THM_{0}_ORDER_{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), filename);
        AsyncFileUpload1.SaveAs(Server.MapPath("~/Files/") + filename);

        // HATC Order
        string CustCode = string.Empty; // "40108011";

        filename = Server.MapPath("~/Files/") + filename;
        if (File.Exists(filename))
        {
            string line = string.Empty;
            using (StreamReader sr = new StreamReader(filename))
            {
                int totalLine = 0, totalOrder = 1;

                using (SqlProcedure sp = new SqlProcedure("sp_THM_Order_ClearData"))
                {
                    sp.ExecuteNonQuery();
                }

                while ((line = sr.ReadLine()) != null)
                {
                    totalLine++;
                    if (line.Length > 0)
                    {
                        #region Format
                        // "000000000000" is Supply Part
                        string shipto = line.Substring(145, 5) + "-" + line.Substring(22, 6);
                        if ((line.Substring(140, 5) == "45320" || line.Substring(140, 5) == "05386") && line.Substring(10, 12) != "000000000000")
                        {
                            MyCompany.Models.THMOrderImport Order = new MyCompany.Models.THMOrderImport();
                            Order.DeliveryDestination = line.Substring(145, 5) + "-" + line.Substring(22, 6);
                            Order.OrderBy             = "40101011";
                            Order.CustomerMatCode     = line.Substring(28, 18).Trim().Replace(" ", "");
                            string[] materialTemp = SharedBusinessRules.getMaterial(line.Substring(28, 18).Trim().Replace(" ", ""), Order.OrderBy, line.Substring(22, 6), line.Substring(145, 5)).Split(':');
                            if (materialTemp.Length > 1)
                            {
                                Order.SAPCode                 = materialTemp[0];
                                Order.PartsDevision           = materialTemp[1];
                                Order.DeliveryDestinationCode = materialTemp[2];
                                Order.Key1 = materialTemp[3];
                                Order.Key2 = materialTemp[4];
                                Order.Key3 = materialTemp[5];
                            }
                            Order.CustomerPO          = line.Substring(10, 12).Trim();
                            Order.ReliabilityDevision = "P"; //Realiability = [Forcast=F,Order=P]
                            Order.DeliveryDate        = Convert.ToDateTime(line.Substring(118, 4).Trim() + "-" + line.Substring(122, 2).Trim() + "-" + line.Substring(124, 2).Trim());
                            Order.Quantity            = line.Substring(126, 7).Trim();
                            Order.Unit = "ST";       // SD Fixd Data Unit = ST
                            //SD Fixd Data Unit = ST, Periad = D, Realiability = [Forcast=F,Order=P]
                            Order.PlngPeriod  = "D"; // Periad = D
                            Order.PlantCode   = line.Substring(22, 6) + " Add. " + line.Substring(94, 4).Trim();
                            Order.AddCode     = totalOrder.ToString();
                            Order.Arrivaltime = line.Substring(116, 2) + ":00:00";
                            Order.FromTo      = line.Substring(88, 5).Trim() + ":" + line.Substring(145, 5);
                            Order.Filename    = fn;
                            Order.Insert();
                            totalOrder++;
                        }
                        #endregion
                    }
                }

                sr.Close();
            }
        }
        //// Save file
        //string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);
        //filename = String.Format("THM_{0}_ORDER_{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), filename);
        //AsyncFileUpload1.SaveAs(Server.MapPath("~/Files/") + filename);


        //string CustCode = "40101010";
        //filename = Server.MapPath("~/Files/") + filename;
        //if (File.Exists(filename))
        //{
        //    string line = string.Empty;
        //    using (StreamReader sr = new StreamReader(filename))
        //    {
        //        using (SqlProcedure sp = new SqlProcedure("sp_THM_Order_ClearData"))
        //        {
        //            sp.ExecuteNonQuery();
        //        }
        //        while ((line = sr.ReadLine()) != null)
        //        {
        //            if (line.Length > 0)
        //            {
        //                //string shipto = line.Substring(145, 5) + "-" + line.Substring(22, 6);
        //                if ((line.Substring(140, 5) == "45320" || line.Substring(140, 5) == "05386") && line.Substring(10, 12) != "000000000000")
        //                //if ((line.Substring(140, 5).Trim() == "CRS1" || line.Substring(140, 5) == "45320") && line.Substring(10, 12) != "000000000000")
        //                {
        //                    //string[] item = line.Split(Convert.ToChar("|"));
        //                    MyCompany.Models.THMOrderImport Order = new MyCompany.Models.THMOrderImport();
        //                    Order.OrderBy = CustCode;
        //                    Order.DeliveryDestination = ""; //Not sure
        //                    Order.CustomerMatCode = line.Substring(28, 18).Replace(" ","");
        //                    Order.PartsDevision = "1";
        //                    Order.CustomerPO = line.Substring(10, 12);
        //                    Order.ReliabilityDevision = "P";
        //                    Order.DeliveryDate =Convert.ToDateTime( line.Substring(118, 4) + "-" + line.Substring(122, 2) + "-" + line.Substring(124, 2));
        //                    Order.Quantity = float.Parse(line.Substring(126, 7)).ToString().Trim();
        //                    Order.Unit = "ST";
        //                    Order.PlngPeriod = "D";
        //                    string[] materialTemp = SharedBusinessRules.getMaterial(Order.CustomerMatCode, Order.OrderBy, PlantCode, LocationCode).Split(':');
        //                    if (materialTemp.Length > 1)
        //                    {
        //                        Order.SAPCode = materialTemp[0];
        //                        Order.PartsDevision = materialTemp[1];
        //                        Order.DeliveryDestinationCode = materialTemp[2];
        //                    }
        //                    Order.Insert();

        //                }

        //            }
        //        }
        //        sr.Close();
        //    }

        //}
    }
Beispiel #54
0
 protected void chatRoomImgUpload_UploadedFileError(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
 {
     //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "error", "top.$get(\"" + uploadResult.ClientID + "\").innerHTML = 'Error: " + e.statusMessage + "';", true);
     Console.WriteLine("Error.");
 }
Beispiel #55
0
        void ReceivedFile(string sendingControlID)
        {
            AsyncFileUploadEventArgs eventArgs = null;

            _lastError = String.Empty;

            if (this.Page.Request.Files.Count > 0)
            {
                HttpPostedFile file = null;
                if (sendingControlID == null || sendingControlID == String.Empty)
                {
                    file = this.Page.Request.Files[0];
                }
                else
                {
                    foreach (string uploadedFile in this.Page.Request.Files)
                    {
                        var fileToUse = uploadedFile;
                        var straggler = "$ctl02";
                        if (fileToUse.EndsWith(straggler))
                        {
                            fileToUse = fileToUse.Remove(fileToUse.Length - straggler.Length);
                        }

                        if (fileToUse.Replace("$", "_").EndsWith(sendingControlID))
                        {
                            file = this.Page.Request.Files[uploadedFile];
                            break;
                        }
                    }
                }
                if (file == null)
                {
                    _lastError = Constants.Errors.FileNull;
                    eventArgs  = new AsyncFileUploadEventArgs(
                        AsyncFileUploadState.Failed,
                        Constants.Errors.FileNull,
                        String.Empty,
                        String.Empty
                        );

                    OnUploadedFileError(eventArgs);
                }
                else if (file.FileName == String.Empty)
                {
                    _lastError = Constants.Errors.NoFileName;

                    eventArgs = new AsyncFileUploadEventArgs(
                        AsyncFileUploadState.Unknown,
                        Constants.Errors.NoFileName,
                        file.FileName,
                        file.ContentLength.ToString()
                        );

                    OnUploadedFileError(eventArgs);
                }
                else if (file.InputStream == null)
                {
                    _lastError = Constants.Errors.NoFileName;

                    eventArgs = new AsyncFileUploadEventArgs(
                        AsyncFileUploadState.Failed,
                        Constants.Errors.NoFileName,
                        file.FileName,
                        file.ContentLength.ToString()
                        );

                    OnUploadedFileError(eventArgs);
                }
                else if (file.ContentLength < 1)
                {
                    _lastError = Constants.Errors.EmptyContentLength;

                    eventArgs = new AsyncFileUploadEventArgs(
                        AsyncFileUploadState.Unknown,
                        Constants.Errors.EmptyContentLength,
                        file.FileName,
                        file.ContentLength.ToString()
                        );

                    OnUploadedFileError(eventArgs);
                }
                else
                {
                    eventArgs = new AsyncFileUploadEventArgs(
                        AsyncFileUploadState.Success,
                        String.Empty,
                        file.FileName,
                        file.ContentLength.ToString()
                        );

                    if (_persistFile)
                    {
                        GC.SuppressFinalize(file);
                        PersistentStoreManager.Instance.AddFileToSession(this.ClientID, file.FileName, file);
                    }
                    else
                    {
                        _postedFile = file;
                    }
                    OnUploadedComplete(eventArgs);
                }
            }
        }
Beispiel #56
0
        void asyncImageUpload_UploadedComplete(object sender, AsyncFileUploadEventArgs e)
        {
            Image image;
            try
            {
                string savePath = MapPath("~/AsyncFileUpload/Uploads/" + Path.GetFileName(e.FileName));
                asyncImageUpload.SaveAs(savePath);
                image = Image.FromFile(savePath);
                Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "imgUpdate",
                    String.Format("top.document.getElementById('tempPhoto').src='./AsyncFileUpload/Uploads/{0}';",
                    e.FileName), true);
                //image = Image.FromStream
                  //  (asyncImageUpload.PostedFile.InputStream);
            }
            catch
            {
                lblError.Text = Lang.Trans("Invalid image!");
                return;
            }
            Photo photo;

            if (Session["temp_photo"] == null)
                photo = new Photo();
            else
                photo = (Photo)Session["temp_photo"];

            if (image.Height < Config.Photos.PhotoMinHeight
                || image.Width < Config.Photos.PhotoMinWidth)
            {
                lblError.Text = Lang.Trans("The photo is too small!");
                return;
            }

            photo.Image = image;

            string tempFileName;

            if (!Misc.GetTempFileName(out tempFileName))
                tempFileName = Path.GetTempFileName();

            photo.Image.Save(tempFileName);
            Session["temp_photo_fileName"] = tempFileName;

            if (Config.Photos.AutoApprovePhotos
                || CurrentUserSession.BillingPlanOptions.AutoApprovePhotos.Value
                || CurrentUserSession.Level != null && CurrentUserSession.Level.Restrictions.AutoApprovePhotos)
            {
                photo.Approved = true;
            }
            else
            {
                photo.Approved = false;
            }

            photo.ExplicitPhoto = false;
            chkPrivatePhoto.Enabled = true;

            #region Find faces
            if (Config.Photos.FindFacesForThumbnails)
            {
                FindFaces(photo);
            }

            #endregion

            photo.Image = null;
            Session["temp_photo"] = photo;

            divFileUploadControls.Style.Add("display","none");
            divImageRotateControls.Visible = true;
            
        }