Пример #1
0
        protected void btnSaveContinue_Click(object sender, EventArgs e)
        {
            foreach (DataListItem item in dlImagesLocationDescription.Items)
            {
                int        leadImageID = (int)dlImagesLocationDescription.DataKeys[item.ItemIndex];
                LeadsImage leadImage   = null;

                TextBox txtLocation = item.FindControl("txtLocation") as TextBox;

                TextBox txtDescription = item.FindControl("txtDescription") as TextBox;

                if (!string.IsNullOrEmpty(txtLocation.Text) && !string.IsNullOrEmpty(txtDescription.Text))
                {
                    leadImage = LeadsUploadManager.GetLeadsImageById(leadImageID);
                    if (leadImage != null)
                    {
                        leadImage.Location = txtLocation.Text;

                        leadImage.Description = txtDescription.Text;

                        LeadsUploadManager.SaveImage(leadImage);
                    }
                }
            }

            // send user back to list of images
            Response.Redirect("~/Protected/Admin/LeadsImagesUpload.aspx");
        }
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            //string filepath = myimage.ImageUrl;
            //using (WebClient client = new WebClient())
            //{
            //    client.DownloadFile(filepath, Server.MapPath("~/Image/apple.jpg"));
            //}


            var list = LeadsUploadManager.GetLeadsImageById(Convert.ToInt32(hfLeadImageId.Value));

            list.Location    = txtLocation.Text.Trim();
            list.Description = txtDescription.Text.Trim();
            LeadsUploadManager.SaveImage(list);



            //const string javaScript = "<script language=javascript>window.top.close(); window.opener.location.reload(true);</script>";
            const string javaScript = "<script language=javascript>window.top.close(); window.opener.RebindImages();</script>";

            if (!ClientScript.IsStartupScriptRegistered("CloseMyWindow"))
            {
                ClientScript.RegisterStartupScript(GetType(), "CloseMyWindow", javaScript);
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            string LeadId       = "";
            int    policyTypeID = 0;

            if (context.Session["LeadIds"] != null)
            {
                LeadId = Convert.ToString(context.Session["LeadIds"]);
            }
            HttpPostedFile fileToUpload = context.Request.Files["Filedata"];


            string ext                = System.IO.Path.GetExtension(fileToUpload.FileName);
            string ActualFileName     = fileToUpload.FileName.Substring(fileToUpload.FileName.LastIndexOf(@"\") + 1);
            string FileNameWithoutExt = ActualFileName.Replace(ext, "");

            if (ext != ".doc" && ext != ".exl" && ext != ".pdf")
            {
                LeadsImage objLeadImage = new LeadsImage();
                objLeadImage.LeadId    = Convert.ToInt32(LeadId);
                objLeadImage.ImageName = ActualFileName;
                objLeadImage.Status    = 1;

                if (context.Session["policyTypeID"] != null)
                {
                    policyTypeID = (int)context.Session["policyTypeID"];
                }

                objLeadImage.policyTypeID = policyTypeID;

                // 2013-09-24 tortega
                objLeadImage.isPrint = true;

                objLeadImage = LeadsUploadManager.SaveImage(objLeadImage);

                if (Convert.ToInt32(LeadId) > 0)
                {
                    if (!Directory.Exists(HttpContext.Current.Server.MapPath("~/LeadsImage/" + Convert.ToInt32(LeadId) + "/" + objLeadImage.LeadImageId)))
                    {
                        Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~/LeadsImage/" + Convert.ToInt32(LeadId) + "/" + objLeadImage.LeadImageId));
                    }

                    fileToUpload.SaveAs(HttpContext.Current.Server.MapPath("~/LeadsImage/" + Convert.ToInt32(LeadId) + "/" + objLeadImage.LeadImageId + "/" + ActualFileName));
                }
            }

            //string pathToSave = HttpContext.Current.Server.MapPath("~/TempLeadsImage/") + LeadId + "/" +fileToUpload.FileName;


            //if (!Directory.Exists(HttpContext.Current.Server.MapPath("~\\TempLeadsImage\\" + LeadId)))
            //    Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~\\TempLeadsImage\\" + LeadId));

            //fileToUpload.SaveAs(pathToSave);
        }
Пример #4
0
        public static void togglePrintFlag(bool isPrint, int leadImageID)
        {
            LeadsImage leadImage = LeadsUploadManager.GetLeadsImageById(leadImageID);

            if (leadImage != null)
            {
                leadImage.isPrint = isPrint;

                try {
                    LeadsUploadManager.SaveImage(leadImage);
                }
                catch (Exception ex) {
                    Core.EmailHelper.emailError(ex);
                }
            }
        }
Пример #5
0
        public static void saveLeadPhotoDescription(int leadImageID, string photoLocation, string photoDescription)
        {
            LeadsImage leadImage = LeadsUploadManager.GetLeadsImageById(leadImageID);

            if (leadImage != null)
            {
                leadImage.Location    = photoLocation.Trim();
                leadImage.Description = photoDescription.Trim();

                try {
                    LeadsUploadManager.SaveImage(leadImage);
                }
                catch (Exception ex) {
                    Core.EmailHelper.emailError(ex);
                }
            }
        }
Пример #6
0
        protected void dtlist_ItemCommand(object sender, DataListCommandEventArgs e)
        {
            if (e.CommandName.Equals("DoDelete"))
            {
                int LeadImageId = Convert.ToInt32(e.CommandArgument);
                try {
                    var list = LeadsUploadManager.GetLeadsImageById(LeadImageId);
                    list.Status = 0;
                    LeadsUploadManager.SaveImage(list);


                    lblSave.Text    = "Image deleted Successfully.";
                    lblSave.Visible = true;
                    FillImage(this.leadID);
                }
                catch (Exception ex) {
                    lblError.Text    = "Image not deleted.";
                    lblError.Visible = true;
                }
            }
            if (e.CommandName.Equals("DoRotate"))
            {
                try {
                    System.Web.UI.WebControls.Image img = (System.Web.UI.WebControls.Image)e.Item.FindControl("Image1");
                    // get the full path of image url
                    string path = Server.MapPath(img.ImageUrl);

                    // creating image from the image url
                    System.Drawing.Image i = System.Drawing.Image.FromFile(path);

                    // rotate Image 90' Degree
                    i.RotateFlip(RotateFlipType.Rotate90FlipXY);

                    // save it to its actual path
                    i.Save(path);
                    // release Image File
                    i.Dispose();

                    img.Attributes.Add("ImageUrl", path);
                }
                catch (Exception ex) {
                }
            }
        }
Пример #7
0
        protected void uploadFile(FileUpload fileupload, int leadID, string fileDescription)
        {
            string appPath  = ConfigurationManager.AppSettings["appPath"].ToString();
            string filePath = null;

            if (fileupload.HasFile)
            {
                LeadsImage objLeadImage = new LeadsImage();
                objLeadImage.LeadId    = leadID;
                objLeadImage.ImageName = fileupload.FileName;
                objLeadImage.Status    = 1;
                objLeadImage.InsertBy  = userID;
                objLeadImage.isPrint   = true;

                if (!string.IsNullOrEmpty(fileDescription))
                {
                    objLeadImage.Description = fileDescription;
                }

                objLeadImage.policyTypeID = Convert.ToInt32(ucPolicyType1.SelectedValue);
                objLeadImage = LeadsUploadManager.SaveImage(objLeadImage);

                if (fileupload.PostedFile.ContentType == "application/msword")
                {
                }
                else
                {
                    // images
                    string filename = Path.GetFileName(fileupload.FileName);
                    filePath = string.Format("{0}\\LeadsImage\\{1}\\{2}", appPath, leadID, objLeadImage.LeadImageId);

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

                    fileupload.SaveAs(filePath + "\\" + filename);
                }
            }
        }