Пример #1
0
        protected void lvProjectImages_ItemDataBound(object sender, ListViewItemEventArgs e)
        {
            string tag = _tag + "[lvProjectImages_ItemDataBound]";

            //---
            if (e.Item.ItemType != ListViewItemType.DataItem)
            {
                return;
            }

            LogHelpers.WriteStatus(tag, "Start...");

            try
            {
                string      imageLink = e.Item.DataItem.ToString();
                HiddenField hfImage   = (HiddenField)e.Item.FindControl("hfImageLink");
                Image       img       = (Image)e.Item.FindControl("itemImage");
                //---
                hfImage.Value = imageLink;
                img.ImageUrl  = "~/" + Path.Combine(Utilities.GetDirectory("ImagesDir"), imageLink);
            }
            catch (Exception ex)
            {
                LogHelpers.WriteException(tag, ex.ToString());
            }
            finally
            {
                LogHelpers.WriteStatus(tag, "End...");
            }
        }
Пример #2
0
        private void StartBindingCategory()
        {
            string tag = _tag + "[StartBindingCategory]";

            LogHelpers.WriteStatus(tag, "Start...");

            try
            {
                var result = MenuDAL.GetAllSubMenuProjects();
                if (result.Code < 0)
                {
                    lbError.InnerText = result.ErrorMessage;
                    lbError.Visible   = true;
                    LogHelpers.WriteError(tag, result.ErrorMessage);

                    return;
                }
            }
            catch (Exception ex)
            {
                LogHelpers.WriteException(tag, ex.ToString());
                //--
                lbError.InnerText = ex.Message;
                lbError.Visible   = true;
            }
            finally
            {
                LogHelpers.WriteStatus(tag, "End.");
            }
        }
Пример #3
0
        private void StartLoadProjectImages(string imageLinks)
        {
            string tag = _tag + "[StartLoadProjectImages]";

            LogHelpers.WriteStatus(tag, "ImageLinks: " + imageLinks, "Start...");
            //---
            if (string.IsNullOrEmpty(imageLinks))
            {
                return;
            }

            try
            {
                hfListImage.Value = imageLinks;
                //---
                string[] images = imageLinks.Split('|');
                if (images != null && images.Length > 0)
                {
                    lvProjectImages.DataSource = images.ToList();
                    lvProjectImages.DataBind();
                }
            }
            catch (Exception ex)
            {
                LogHelpers.WriteException(tag, ex.ToString());
            }
            finally
            {
                LogHelpers.WriteStatus(tag, "ImageLinks: " + imageLinks, "End.");
            }
        }
Пример #4
0
        public static string UploadFileToServer(string address, string dir)
        {
            string tag = "[Utilities][SaveFileToServer]";

            LogHelpers.WriteStatus(tag, string.Format("Address: {0} - Dir: {1}",
                                                      address,
                                                      dir),
                                   "Start...");

            try
            {
                string ext      = Path.GetExtension(address);
                string folder   = DateTime.Now.ToString("MMddyyyy");
                string fileName = DateTime.Now.ToString("HHmmssfff") + ext;
                string result   = Path.Combine(folder, fileName);
                //---

                string dirServer = HttpContext.Current.Server.MapPath(Path.Combine(dir, folder));
                if (!Directory.Exists(dirServer))
                {
                    Directory.CreateDirectory(dirServer);
                }

                string fullPath = Path.Combine(dirServer, fileName);

                WebClient wc = new WebClient();
                wc.DownloadFile(address, fullPath);

                return(result.Replace("\\", "/"));
            }
            catch (Exception ex)
            {
                LogHelpers.WriteError(tag, ex.ToString());
                return(string.Empty);
            }
            finally
            {
                LogHelpers.WriteStatus(tag, string.Format("Address: {0} - Dir: {1}",
                                                          address,
                                                          dir),
                                       "End.");
            }
        }
Пример #5
0
        public static string SaveMutipleFileToServer(string[] images, string dir)
        {
            string tag = "[Utilities][Utilities]";

            LogHelpers.WriteStatus(tag, "Start...");
            //---
            string result = string.Empty;

            try
            {
                foreach (string filePath in images)
                {
                    string uploadFile = UploadFileToServer(filePath, dir);
                    //---
                    if (string.IsNullOrEmpty(result))
                    {
                        result = uploadFile;
                    }
                    else
                    {
                        result += "|" + uploadFile;
                    }
                }

                return(result);
            }
            catch (Exception ex)
            {
                LogHelpers.WriteException(tag, ex.ToString());

                return(result);
            }
            finally
            {
                LogHelpers.WriteStatus(tag, "End.");
            }
        }