コード例 #1
0
 void Upload_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e)
 {
     //Bitmap bitmapImage = ResizeImage(RadAsyncUpload1.UploadedFiles[0].InputStream);
     //System.IO.MemoryStream stream = new System.IO.MemoryStream();
     //bitmapImage.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp);
     //RadBinaryImage1.DataValue = stream.ToArray();
 }
コード例 #2
0
        protected void rauFiles_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e)
        {
            //string str = "123|123|123";
            //string[] strs = Regex.Split(str, "|", RegexOptions.IgnoreCase);

            string filepath = "";

            if (ImgList.Count >= 5)
            {
                RadAjaxManager1.Alert("最多上传5张图!");
                return;
            }
            if (rauFiles.UploadedFiles.Count > 0)
            {
                foreach (UploadedFile file in rauFiles.UploadedFiles)
                {
                    string uploadPath = "/UpLoad/" + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + "/";
                    if (!Directory.Exists(uploadPath))
                    {
                        Directory.CreateDirectory(Server.MapPath(uploadPath));
                    }
                    string name = DateTime.Now.ToString("yyyyMMddHHmmssff") + ".png";
                    filepath = Server.MapPath(uploadPath) + name;
                    file.SaveAs(filepath);
                    ImgModel img = new ImgModel();
                    img.ID     = ImgList.Count + 1;
                    img.imgUrl = uploadPath + name;
                    ImgList.Add(img);
                    RadListView1.Rebind();
                }
                //imgPic.ImageUrl = uploadPath + name;
            }
        }
コード例 #3
0
        protected void rauImagen_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e)
        {
            if (Session["Usuario"] == null)
            {
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "mykey", "CancelEdit();", true);
            }

            try
            {
                String path = Server.MapPath("~/Images/Personal");
                if (e.IsValid)
                {
                    ViewState["fileName"] = (string)ViewState["nroDocumento"] + e.File.GetExtension();
                    string imgPath = Path.Combine(path, (string)ViewState["fileName"]);
                    e.File.InputStream.Dispose();
                    e.File.InputStream.Close();
                    e.File.SaveAs(imgPath, true);
                }
            }
            catch (Exception ex)
            {
                lblMensaje.Text     = ex.Message;
                lblMensaje.CssClass = "mensajeError";
            }
        }
コード例 #4
0
        protected void rauLogoOrganizacion_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e)
        {
            System.Drawing.Image bitmapImage = UtilImage.ResizeImage(System.Drawing.Image.FromStream(rauLogoOrganizacion.UploadedFiles[0].InputStream), 200, 200);
            MemoryStream         stream      = new MemoryStream();

            bitmapImage.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
            vFiLogotipo = Convert.ToBase64String(stream.ToArray());
            vNbLogotipo = rauLogoOrganizacion.UploadedFiles[0].GetName();
            rbiLogoOrganizacion.DataValue = stream.ToArray();
        }
コード例 #5
0
        protected void RadAsyncUpload1_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e)
        {
            //check file size
            //if (e.File.ContentLength < 5000)
            //{
            //}
            string filename = DateTime.Now.ToString("yyyyMMdd") + "_" + Guid.NewGuid().ToString() + e.File.GetExtension();

            var physicalSavePath = MapPath(Config.UploadRewardVirtualPath) + filename;

            //Save physical file on disk
            e.File.SaveAs(physicalSavePath, true);

            //Add filename to session
            Session.Add("Rewardfilename", filename);
        }
コード例 #6
0
        protected void rauFiles_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e)
        {
            string filepath = "";

            if (rauFiles.UploadedFiles.Count > 0)
            {
                UploadedFile file       = rauFiles.UploadedFiles[0];
                string       uploadPath = "/Upload/" + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + "/";
                if (!Directory.Exists(uploadPath))
                {
                    Directory.CreateDirectory(Server.MapPath(uploadPath));
                }
                string name = DateTime.Now.ToString("yyyyMMddHHmmssff") + ".png";
                filepath = Server.MapPath(uploadPath) + name;
                file.SaveAs(filepath);
                imgPic.ImageUrl = uploadPath + name;
            }
        }
コード例 #7
0
        //上传图片
        protected void rauFiles_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e)
        {
            string filepath = "";

            if (rauFiles.UploadedFiles.Count > 0)//判断是否有图片
            {
                UploadedFile file       = rauFiles.UploadedFiles[0];
                string       uploadPath = "../UpLoad/" + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + "/"; //上传路径
                if (!Directory.Exists(uploadPath))                                                                        //判断该路径是否存在
                {
                    Directory.CreateDirectory(Server.MapPath(uploadPath));                                                //在指定路径中创建所有目录
                }
                string name = DateTime.Now.ToString("yyyyMMddHHmmssff") + ".png";                                         //图片命名
                filepath = Server.MapPath(uploadPath) + name;
                file.SaveAs(filepath);                                                                                    //保存图片
                imgPic.ImageUrl = uploadPath + name;
            }
        }
コード例 #8
0
    protected void rau_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e)
    {
        try
        {
            using (Stream docxStream = e.File.InputStream)
                re_converter.LoadDocxContent(docxStream);

            if (re_converter.Content.Trim() != String.Empty)
            {
                String[] pn = new String[] { "@UserID", "@FileName", "@Body", "@IsSignature" };
                Object[] pv = new Object[] { Util.GetUserId(), e.File.FileName.Replace(".docx", String.Empty), re_converter.Content.Trim(), dd_upload_type.SelectedItem.Value };

                // don't allow file over-writes, can mess up follow-up mails relying on old templates
                String qry = "SELECT * FROM dbl_email_template WHERE FileName=@FileName AND UserID=@UserID AND Deleted=0";
                if (SQL.SelectDataTable(qry, pn, pv).Rows.Count > 0)
                {
                    Util.PageMessageAlertify(this, "A template file with that name already exists!\\n\\nPlease upload this file with a different name.");
                }
                else
                {
                    String iqry = "INSERT IGNORE INTO dbl_email_template (UserID,FileName,Body,IsSignature) VALUES(@UserID,@FileName,@Body,@IsSignature)";
                    long   id   = SQL.Insert(iqry, pn, pv);
                    if (id == 0)
                    {
                        String uqry = "UPDATE dbl_email_template SET Body=@Body, IsSignature=@IsSignature, Deleted=0, LastUpdated=CURRENT_TIMESTAMP WHERE UserID=@UserID AND FileName=@FileName";
                        SQL.Update(uqry, pn, pv);
                    }
                    rts.SelectedIndex = rmp.SelectedIndex = 0;
                    Util.ResizeRadWindow(this);
                }
            }
            else
            {
                Util.PageMessageAlertify(this, "The file you have uploaded is empty!");
            }
        }
        catch (Exception r)
        {
            Util.PageMessageAlertify(this, "There was an error converting your Word doc to a Leads Template.<br/><br/>" +
                                     "Please try saving your Word document as a .doc file (Word 97-2003 Document (*.doc)), then re-save that new file back to a .docx file (Word Document (*.docx)) and try uploading again.<br/><br/>" +
                                     "If this does not help then please e-mail an administrator with the Word document as an attachment to resolve the problem.", "Oops");
            Util.Debug("Error uploading Word document as a Leads Mailing Template: (" + User.Identity.Name + ")" + Environment.NewLine + r.Message + " " + r.StackTrace);
        }
    }
コード例 #9
0
 protected void RadFileUp_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e)
 {
     try
     {
         Stream       st     = e.File.InputStream;
         BinaryReader reader = new BinaryReader(e.File.InputStream);
         Byte[]       data   = reader.ReadBytes((int)e.File.InputStream.Length);
         preview.DataValue = data;
         string folderPath = Server.MapPath("~/Users/");
         string filename   = e.File.FileName;
         var    fileStream = new FileStream(folderPath + filename, FileMode.Create, FileAccess.Write);
         st.CopyTo(fileStream);
         fileStream.Dispose();
         PerfilResponse response = new PerfilResponse();
         PerfilRequest  request  = new PerfilRequest();
         request.mdlPerfil.intUsuarioID = Usuario.intUsuarioID;
         request.mdlPerfil.vchRutaIcono = filename;
         request.intVariableID          = 2; //Solo icono
         request.mdlUser = Usuario;
         response        = RisService.setPerfil(request);
         if (response != null)
         {
             if (response.success)
             {
                 Usuario.vchRutaIcono   = request.mdlPerfil.vchRutaIcono;
                 Session["UserRISAxon"] = Usuario;
                 ShowMessage("Se actualizó correctamente la imagen de usuario.", MessageType.Correcto, "alert_container");
             }
             else
             {
                 ShowMessage("Existe un error al cambiar la imagen: " + response.mensaje, MessageType.Error, "alert_container");
             }
         }
         else
         {
             ShowMessage("Existe un error al cambiar la imagen.", MessageType.Error, "alert_container");
         }
     }
     catch (Exception eFU)
     {
         ShowMessage("Existe un error: " + eFU.Message, MessageType.Error, "alert_container");
         Log.EscribeLog("Existe un error en RadFileUp_FileUploaded: " + eFU.Message, 3, Usuario.vchUsuario);
     }
 }
コード例 #10
0
    //protected void CustomValidator2_ServerValidate(object source, ServerValidateEventArgs args)
    //{
    //    try
    //    {
    //        if (FileUpload1.HasFile)
    //        {
    //            int fileSize = FileUpload1.PostedFile.ContentLength;
    //            if (fileSize > 5242880)
    //            {
    //                args.IsValid = false;
    //            }
    //            else
    //            {
    //                args.IsValid = true;
    //            }
    //        }
    //    }
    //    catch
    //    {
    //        args.IsValid = true;
    //    }
    //}
    //protected void RadAsyncUpload1_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e)
    //{
    //    try
    //    {
    //        string imgPath = "";
    //        string ext;

    //        int filesizeInBytes = e.File.ContentLength;
    //        Session["FileSize"] = filesizeInBytes;

    //        imgPath = e.File.FileName;
    //        imgPath = imgPath.Substring(imgPath.LastIndexOf("\\") + 1);
    //        string imageTime = System.DateTime.Now.ToString();
    //        imageTime = imageTime.Replace("/", "");
    //        imageTime = imageTime.Replace(":", "");
    //        imageTime = imageTime.Replace(" ", "");
    //        ext = imgPath.Substring(imgPath.LastIndexOf("."));
    //        imgPath = imgPath.Substring(0, imgPath.LastIndexOf("."));
    //        imgPath = imgPath + "_" + imageTime + ext;

    //        Session["FileName"] = imgPath;
    //    }
    //    catch
    //    {
    //    }
    //}

    protected void RadAsyncUpload1_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e)
    {
        try
        {
            string strPath = "";
            string fileName, strFileName = "";
            string ext = "";


            fileName = e.File.FileName;
            // fileName = txtTitle.Text.Trim().Replace(" ", "").ToString() + "_" + txtEventName.Text.Trim().Replace(" ", "").ToString();
            fileName = fileName.Replace(" ", "").ToString();
            fileName = fileName.Replace("_", "").ToString();
            fileName = fileName.Replace("-", "").ToString();

            fileName = fileName.Substring(fileName.LastIndexOf("\\") + 1);
            string strDate = System.DateTime.Now.ToString();
            strDate  = strDate.Replace("/", "");
            strDate  = strDate.Replace("-", "");
            strDate  = strDate.Replace(":", "");
            strDate  = strDate.Replace(" ", "");
            ext      = fileName.Substring(fileName.LastIndexOf("."));
            fileName = fileName.Substring(0, fileName.LastIndexOf("."));
            fileName = fileName + "_" + strDate + ext;

            if (ext == ".ppt" || ext == ".pptx" || ext == ".pps" || ext == ".ppsx")
            {
                strPath = "Downloads/Ppts";
            }
            else
            {
                strPath = "Downloads/Documents";
            }
            string path = Server.MapPath("~/" + strPath + "/" + fileName);
            Session["DownloadedFile"] = fileName;
            e.File.SaveAs(path);
        }
        catch
        {
        }
    }
コード例 #11
0
ファイル: Photo.ascx.cs プロジェクト: vaibhavgeek/friendyoke
 protected void justadd_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e)
 {
 }
コード例 #12
0
        protected void RadAsyncUpload1_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e)
        {
            string SavedDoc = string.Empty;
            string fileName = string.Empty;

            // try
            {
                int i = RadAsyncUpload1.InitialFileInputsCount;
                try
                {
                    using (Stream str = e.File.InputStream);
                }
                catch
                {
                    string strError = "<Script>FileTimedOut()</script>";
                    this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "strError", strError);
                    return;
                }
                using (Stream str = e.File.InputStream)
                {
                    byte[] content = new byte[str.Length];
                    content = ReadFully(str);
                    uploadedFiles.Add(content);

                    fileName = e.File.FileName.Replace("'", "");
                    Oracle.DataAccess.Client.OracleConnection conn = SQLStatic.SQL.OracleConnection();

                    try
                    {
                        SQLStatic.Sessions.SetSessionValue(session_id, "UPLOAD_MESSAGE", txtmsgUpload.Text);
                        Data.SavePDF(session_id, fileName, content);
                        hidUpload.Value = "1";
                    }
                    catch
                    {
                    }
                    str.Read(content, 0, content.Length);
                    ViewState["Docs"] = ViewState["Docs"].ToString() + "<li>" + fileName + "</li>";
                }
            }
            //catch
            //{
            //    ViewState["Error"] = "T";
            //}
            if (hidcount.Value.Length > 0)
            {
                hidcount.Value = hidcount.Value.Remove(0, 1);
            }

            if (hidcount.Value.Length == 0)
            {
                if (!string.IsNullOrEmpty(ViewState["Docs"].ToString()))
                {
                    SavedDoc = "<br/><u><b>Documents Uploaded Successfully</b></u><ul>" + ViewState["Docs"].ToString() + "</ul>";
                }
                if (ViewState["Error"].ToString().Equals("F"))
                {
                    ConfromSave(SavedDoc);
                }
                else
                {
                    if (string.IsNullOrEmpty(ViewState["Docs"].ToString()))
                    {
                        SavedDoc = "<br/><br/><u><b>Documents Uploaded Successfully</b></u><ul> None</ul>";
                    }
                    else
                    {
                        SavedDoc = "<br/><br/><u><b>Documents Uploaded Successfully</b></u><ul>" + ViewState["Docs"].ToString() + "</ul>";
                    }
                    RadWindowManager1.RadAlert("Upload Failed. Please Try Again." + SavedDoc, 300, 200, "Upload Failed", null);
                }
                ViewState["Docs"] = string.Empty;
                //btnSubmit.Enabled = false;
            }
            txtmsgUpload.Text = string.Empty;
            rgDoc.Rebind();
            string strLE_EE_ID = SQLStatic.Sessions.GetSessionValue(session_id, "LE_EE_ID");
            string strGp       = "<Script>Go('" + strLE_EE_ID + "')</script>";

            this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "strGp", strGp);
        }
コード例 #13
0
ファイル: Default.aspx.cs プロジェクト: gm72/aspnet-sdk
 protected void RadAsyncUpload1_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e)
 {
     InitPackage();
     Push(e.File);
 }
コード例 #14
0
    /// <summary>
    /// Upload Excel file
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void aUploadFile_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e)
    {
        try
        {
            int counter        = 0;
            int counterSuccess = 0;
            int counterRepeat  = 0;

            if (aUploadFile.UploadedFiles.Count > 0)
            {
                string FileName      = Path.GetFileName(aUploadFile.UploadedFiles[0].FileName);
                string extensionName = Path.GetExtension(aUploadFile.UploadedFiles[0].FileName);
                FileName = Guid.NewGuid().ToString();
                aUploadFile.UploadedFiles[0].SaveAs(
                    Server.MapPath(PortalSettings.HomeDirectory + "tmpfiles/" + FileName + extensionName));


                string connString  = "";
                string strFileType = extensionName.ToLower();
                string path        = Server.MapPath(PortalSettings.HomeDirectory + "tmpfiles/" + FileName + extensionName);
                //Connection String to Excel Workbook
                if (strFileType.Trim() == ".xls")
                {
                    connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path +
                                 ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=2\"";
                }
                else if (strFileType.Trim() == ".xlsx")
                {
                    connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path +
                                 ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\"";
                }
                string          query = "SELECT *  FROM [Sheet1$]";
                OleDbConnection conn  = new OleDbConnection(connString);
                if (conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }
                OleDbCommand     cmd = new OleDbCommand(query, conn);
                OleDbDataAdapter da  = new OleDbDataAdapter(cmd);


                DataSet ds = new DataSet();


                da.Fill(ds);

                // List<PotentialUser> potentialUsers=new List<PotentialUser>();
                PotentialUserComponent tmpPotentialUser;
                long batch = DateTime.Now.Ticks;
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    counter++;
                    if (ds.Tables[0].Columns.Contains("Email"))
                    {
                        if (!string.IsNullOrEmpty(dr["Email"].ToString().Replace(" ", "")))
                        {
                            tmpPotentialUser = new PotentialUserComponent(dr["Email"].ToString().Replace(" ", ""));
                            if (tmpPotentialUser.PotentialUser.PotentialUserId == Guid.Empty)
                            {
                                tmpPotentialUser.PotentialUser.Created = DateTime.Now;
                                tmpPotentialUser.PotentialUser.Updated = tmpPotentialUser.PotentialUser.Created;
                                tmpPotentialUser.PotentialUser.Deleted = false;
                            }
                            tmpPotentialUser.PotentialUser.Updated = DateTime.Now;
                            tmpPotentialUser.PotentialUser.Batch   = batch.ToString();

                            if (ds.Tables[0].Columns.Contains("FirstName"))
                            {
                                tmpPotentialUser.PotentialUser.FirstName = dr["FirstName"].ToString();
                            }
                            if (ds.Tables[0].Columns.Contains("LastName"))
                            {
                                tmpPotentialUser.PotentialUser.LastName = dr["LastName"].ToString();
                            }
                            if (ds.Tables[0].Columns.Contains("MiddleName"))
                            {
                                tmpPotentialUser.PotentialUser.MiddleName = dr["MiddleName"].ToString();
                            }
                            if (ds.Tables[0].Columns.Contains("Phone"))
                            {
                                tmpPotentialUser.PotentialUser.Phone = dr["Phone"].ToString();
                            }
                            if (ds.Tables[0].Columns.Contains("Address"))
                            {
                                tmpPotentialUser.PotentialUser.Address = dr["Address"].ToString();
                            }
                            if (ds.Tables[0].Columns.Contains("Country"))
                            {
                                tmpPotentialUser.PotentialUser.Country = dr["Country"].ToString();
                            }
                            if (ds.Tables[0].Columns.Contains("Region"))
                            {
                                tmpPotentialUser.PotentialUser.Region = dr["Region"].ToString();
                            }
                            if (ds.Tables[0].Columns.Contains("City"))
                            {
                                tmpPotentialUser.PotentialUser.City = dr["City"].ToString();
                            }
                            if (ds.Tables[0].Columns.Contains("Language"))
                            {
                                tmpPotentialUser.PotentialUser.Language = dr["Language"].ToString();
                            }
                            if (ds.Tables[0].Columns.Contains("OrganizationName"))
                            {
                                tmpPotentialUser.PotentialUser.OrganizationName = dr["OrganizationName"].ToString();
                            }
                            if (ds.Tables[0].Columns.Contains("OrganizationType"))
                            {
                                tmpPotentialUser.PotentialUser.OrganizationType = dr["OrganizationType"].ToString();
                            }
                            if (ds.Tables[0].Columns.Contains("Qualification"))
                            {
                                tmpPotentialUser.PotentialUser.Qualification = dr["Qualification"].ToString();
                            }
                            if (ds.Tables[0].Columns.Contains("Source"))
                            {
                                tmpPotentialUser.PotentialUser.Source = dr["Source"].ToString();
                            }
                            if (ds.Tables[0].Columns.Contains("Source"))
                            {
                                tmpPotentialUser.PotentialUser.Source = dr["Source"].ToString();
                            }
                            try
                            {
                                if (ds.Tables[0].Columns.Contains("Latitude"))
                                {
                                    tmpPotentialUser.PotentialUser.Latitude = Convert.ToDecimal(dr["Latitude"]);
                                }
                                if (ds.Tables[0].Columns.Contains("Longitude"))
                                {
                                    tmpPotentialUser.PotentialUser.Longitude = Convert.ToDecimal(dr["Longitude"]);
                                }
                            }

                            catch (Exception)
                            {
                            }
                            if (ds.Tables[0].Columns.Contains("CustomField1"))
                            {
                                tmpPotentialUser.PotentialUser.CustomField1 = dr["CustomField1"].ToString();
                            }
                            if (ds.Tables[0].Columns.Contains("CustomField2"))
                            {
                                tmpPotentialUser.PotentialUser.CustomField2 = dr["CustomField2"].ToString();
                            }
                            if (ds.Tables[0].Columns.Contains("Title"))
                            {
                                tmpPotentialUser.PotentialUser.Title = dr["Title"].ToString();
                            }
                            if (ds.Tables[0].Columns.Contains("ZipCode"))
                            {
                                tmpPotentialUser.PotentialUser.ZipCode = dr["ZipCode"].ToString();
                            }
                            if (ds.Tables[0].Columns.Contains("WebSite"))
                            {
                                tmpPotentialUser.PotentialUser.WebSite = dr["WebSite"].ToString();
                            }
                            if (ds.Tables[0].Columns.Contains("LinkedIn"))
                            {
                                tmpPotentialUser.PotentialUser.LinkedIn = dr["LinkedIn"].ToString();
                            }
                            if (ds.Tables[0].Columns.Contains("GooglePlus"))
                            {
                                tmpPotentialUser.PotentialUser.GooglePlus = dr["GooglePlus"].ToString();
                            }
                            if (ds.Tables[0].Columns.Contains("Twitter"))
                            {
                                tmpPotentialUser.PotentialUser.Twitter = dr["Twitter"].ToString();
                            }
                            if (ds.Tables[0].Columns.Contains("Facebook"))
                            {
                                tmpPotentialUser.PotentialUser.Facebook = dr["Facebook"].ToString();
                            }
                            if (ds.Tables[0].Columns.Contains("Skype"))
                            {
                                tmpPotentialUser.PotentialUser.Skype = dr["Skype"].ToString();
                            }
                            if (ds.Tables[0].Columns.Contains("Sector"))
                            {
                                tmpPotentialUser.PotentialUser.Sector = dr["Sector"].ToString();
                            }
                            if (tmpPotentialUser.PotentialUser.PotentialUserId != Guid.Empty)
                            {
                                counterRepeat++;
                                if (chkUpdate.Checked)
                                {
                                    counterSuccess += tmpPotentialUser.Save();
                                }
                            }
                            else
                            {
                                counterSuccess += tmpPotentialUser.Save();
                            }
                        }
                    }
                }

                MIFNEXSOEntities nx = new MIFNEXSOEntities();
                grdPreUsers.DataSource = nx.PotentialUsers;
                grdPreUsers.DataBind();
                da.Dispose();
                conn.Close();
                conn.Dispose();
            }
            lblResult.Text = String.Format("Uploading contact done Succesfutl ({0}), Repeats ({1}) Errors ({2})", counterSuccess, counterRepeat,
                                           counter);
        }
        catch (Exception ee)
        {
            lblResult.Text = "Exception: " + ee.ToString();
        }
    }
コード例 #15
0
        protected void AsyncUpload1_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e)
        {
            try
            {
                int r = AsyncUpload1.UploadedFiles.Count;
                if (r == 0)
                {
                    Toast.Error("Error al terminar proyecto: Seleccione un archivo.", this);
                }
                else
                {
                    DirectoryInfo dirInfo    = new DirectoryInfo(Server.MapPath("~/"));//path localDateTime localDate = DateTime.Now;
                    string        path_local = "files/documents/proyectos/";
                    DateTime      localDate  = DateTime.Now;
                    string        date       = localDate.ToString();
                    date = date.Replace("/", "_");
                    date = date.Replace(":", "_");
                    date = date.Replace(" ", "");
                    string name = path_local + Path.GetFileNameWithoutExtension(e.File.FileName) + "_" + date + Path.GetExtension(e.File.FileName);
                    //funciones.UploadFile(fuparchivo, dirInfo.ToString() + name.Trim(), this.Page);
                    e.File.SaveAs(dirInfo.ToString() + name.Trim());
                    int        id_proyecto = Convert.ToInt32(hdfid_proyecto.Value);
                    documentos documento   = new documentos();
                    documento.id_proyecto       = id_proyecto;
                    documento.path              = funciones.deTextoa64(name);
                    documento.nombre            = Path.GetFileName(funciones.de64aTexto(funciones.deTextoa64(name)));
                    documento.tamaño            = e.File.ContentLength.ToString();
                    documento.publico           = true;
                    documento.extension         = Path.GetExtension(funciones.de64aTexto(funciones.deTextoa64(name)));
                    documento.contentType       = funciones.ContentType(documento.extension);
                    documento.fecha             = DateTime.Now;
                    documento.usuario           = Session["usuario"] as string;
                    documento.id_documento_tipo = 2;
                    documento.comentarios       = txtcomentarioscierre.Text;
                    ProyectosCOM proyectos = new ProyectosCOM();
                    string       vmensaje  = proyectos.Cerrar(id_proyecto, Session["usuario"] as string, documento);
                    if (vmensaje == "")
                    {
                        proyectos proyecto = proyectos.proyecto(id_proyecto);

                        //string usuario_resp = proyecto.usuario_resp;
                        //EmpleadosCOM usuarios = new EmpleadosCOM();
                        //DataTable dt_usuario = usuarios.GetUsers();
                        //DataView dv = dt_usuario.DefaultView;
                        //dv.RowFilter = "usuario_red = '" + usuario_resp.Trim().ToUpper() + "'";
                        //DataTable dt_result = dv.ToTable();
                        ProyectosEmpleadosCOM empleados = new ProyectosEmpleadosCOM();
                        DataTable             users     = empleados.empleados_proyecto(id_proyecto);

                        if (users.Rows.Count > 0)
                        {
                            foreach (DataRow row in users.Rows)
                            {
                                string  saludo  = DateTime.Now.Hour > 13 ? "Buenas tardes" : "Buenos dias";
                                DataRow usuario = row;
                                string  mail_to = usuario["correo"].ToString() == "" ? "" : (usuario["correo"].ToString() + ";");
                                string  subject = "Módulo de proyectos - Proyecto cerrado";
                                string  mail    = "<div>" + saludo + " <strong>" +
                                                  System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(usuario["nombre"].ToString().ToLower())
                                                  + "</strong> <div>" +
                                                  "<br>" +
                                                  "<p>Se le comunica que el proyecto <strong>" + proyecto.proyecto + "</strong>, fue cerrado el dia <strong>"
                                                  + DateTime.Now.ToString("dddd dd MMMM, yyyy hh:mm:ss tt", CultureInfo.CreateSpecificCulture("es-MX")) + "</strong>" +
                                                  "</p>" +
                                                  "<p><strong>Documento de cierre</strong><br>" +
                                                  (txtcomentarioscierre.Text == "" ? "" : txtcomentarioscierre.Text) +
                                                  "<br><a href='https://apps.migesa.com.mx/portal_connext/" + name +
                                                  "' download>Descargar documento</a></p>" +
                                                  "<br><p>Este movimiento fue realizado por <strong>" + System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(Session["nombre"].ToString().ToLower()) + "</strong>" +
                                                  " el dia <strong> " +
                                                  DateTime.Now.ToString("dddd dd MMMM, yyyy hh:mm:ss tt", System.Globalization.CultureInfo.CreateSpecificCulture("es-MX")) + "</strong>" +
                                                  "</p>";
                                CorreosCOM correos = new CorreosCOM();
                                bool       correct = correos.SendMail(mail, subject, mail_to);
                            }
                        }
                        System.Web.UI.ScriptManager.RegisterStartupScript(this, GetType(), Guid.NewGuid().ToString(),
                                                                          "AlertGO('Proyecto terminado correctamente.','mis_proyectos.aspx');", true);
                    }
                    else
                    {
                        Toast.Error("Error al terminar proyecto: " + vmensaje, this);
                    }
                }
            }
            catch (Exception ex)
            {
                Toast.Error("Error al terminar proyecto: " + ex.Message, this);
            }
        }