Пример #1
0
        public string axFUpload(int id, string filekind, string filename)
        {
            UpFileInfo r = new UpFileInfo();
            #region
            try
            {
                //banner 圖片
                if (filekind == "Banner")
                    handleImageSave(filename, id, ImageFileUpParm.BannerIndex, filekind, "Banner", "Banner");

                r.result = true;
                r.file_name = filename;
            }
            catch (LogicError ex)
            {
                r.result = false;
                r.message = getRecMessage(ex.Message);
            }
            catch (Exception ex)
            {
                r.result = false;
                r.message = ex.Message;
            }
            #endregion
            return defJSON(r);
        }
        public string aj_FUpload(string id, string filekind, string fileName)
        {
            UpFileInfo r = new UpFileInfo();
            #region
            string tpl_File = string.Empty;
            try
            {
                //banner
                if (filekind == "Banner")
                    handleImageSave(fileName, id, ImageFileUpParm.BannerRotator, filekind, "Active", "AboutUsData");


                r.result = true;
                r.file_name = fileName;
            }
            catch (LogicError ex)
            {
                r.result = false;
                r.message = getRecMessage(ex.Message);
            }
            catch (Exception ex)
            {
                r.result = false;
                r.message = ex.Message;
            }
            #endregion
            return defJSON(r);
        }
Пример #3
0
        /// <summary>
        /// 获取需要更新的文件列件信息
        /// </summary>
        /// <returns></returns>
        public List <UpFileInfo> GetUpFileList()
        {
            List <UpFileInfo> lstUpFile = new List <UpFileInfo>();

            List <UpFileInfo> lstLocalUpFile  = GetLocalUpFileList();
            List <UpFileInfo> lstSourceUpFile = IProxy.GetUpdateFiles();

            foreach (UpFileInfo objSourceUpFile in lstSourceUpFile)
            {
                UpFileInfo objLocalUpFile = lstLocalUpFile.Where(t => t.FileName == objSourceUpFile.FileName).FirstOrDefault();
                if (objLocalUpFile != null)
                {   //若本地有,但版本不同
                    if (objLocalUpFile.Version != objSourceUpFile.Version)
                    {
                        lstUpFile.Add(objSourceUpFile);
                    }
                }
                else //若本地没有
                {
                    lstUpFile.Add(objSourceUpFile);
                }
            }
            //若服务器配置的文件不存在,则报错
            if (lstUpFile.Where(t => t.FileLength < 0).Count() > 0)
            {
                throw new Exception("服务器配置的文件不存在");
            }

            return(lstUpFile);
        }
Пример #4
0
        /// <summary>
        /// 获取本地Xml目录
        /// </summary>
        /// <returns></returns>
        private List <UpFileInfo> GetLocalUpFileList()
        {
            List <UpFileInfo> lstUpFile = new List <UpFileInfo>();

            if (!File.Exists(ConfigSet.Current.XmlFileName))
            {
                return(new List <UpFileInfo>());
            }
            XDocument objDoc = XDocument.Load(ConfigSet.Current.XmlFileName);

            foreach (XElement objElem in objDoc.Document.Element("update").Element("files").Elements("file"))
            {
                UpFileInfo objUpFile = new UpFileInfo();
                objUpFile.FileName = objElem.Attribute("path").Value;
                objUpFile.Version  = objElem.Attribute("ver").Value;
                FileInfo objFile = new FileInfo(objElem.Attribute("path").Value);
                if (objFile.Exists)
                {
                    objUpFile.FileLength = objFile.Length;
                }
                else
                {
                    objUpFile.FileLength = -1;
                }
                lstUpFile.Add(objUpFile);
            }
            return(lstUpFile);
        }
        public string aj_FUpload(string id, string filekind, string fileName)
        {
            UpFileInfo r = new UpFileInfo();
            #region
            string tpl_File = string.Empty;
            try
            {
                //證書
                if (filekind == "Certificate")
                    handleImageSave(fileName, id, ImageFileUpParm.Certificate, filekind, "Active", "ProductCertificate");


                r.result = true;
                r.file_name = fileName;
            }
            catch (LogicError ex)
            {
                r.result = false;
                r.message = getRecMessage(ex.Message);
            }
            catch (Exception ex)
            {
                r.result = false;
                r.message = ex.Message;
            }
            #endregion
            return defJSON(r);
        }
Пример #6
0
        public string axFUpload(string id, string filekind, string filename)
        {
            UpFileInfo r = new UpFileInfo();

            #region
            try
            {
                hdlUpImage(filename, filekind, id, ImageFileUpParm.ProductList);
                //代表 圖片
                //if (filekind == "Photo1")
                //    handleImageSave(filename, id, ImageFileUpParm.ProductList, filekind, "Albums", "Photo");

                r.result    = true;
                r.file_name = filename;
            }
            catch (LogicError ex)
            {
                r.result  = false;
                r.message = getRecMessage(ex.Message);
            }
            catch (Exception ex)
            {
                r.result  = false;
                r.message = ex.Message;
            }
            #endregion
            return(defJSON(r));
        }
        public string aj_FUpload(string id, string filekind, string fileName)
        {
            UpFileInfo r = new UpFileInfo();
            #region
            string tpl_File = string.Empty;
            try
            {
                //代表圖
                if (filekind == "img1")
                    handleImageSave(fileName, id, ImageFileUpParm.Product, filekind, "Active", "ProductData");
                //附件
                if (filekind == "file1")
                    handleFileSave(fileName, id, SysFileUpParm.BaseLimit, filekind, "Active", "ProductData");

                r.result = true;
                r.file_name = fileName;
            }
            catch (LogicError ex)
            {
                r.result = false;
                r.message = getRecMessage(ex.Message);
            }
            catch (Exception ex)
            {
                r.result = false;
                r.message = ex.Message;
            }
            #endregion
            return defJSON(r);
        }
        public string axFUpload(int id, string filekind, string filename)
        {
            UpFileInfo r = new UpFileInfo();
            #region
            try
            {
                if (filekind == "Photo1")
                    handleImageSave(filename, id, ImageFileUpParm.ProductIndex, filekind, "ProductData", "Photo");
                if (filekind == "Photo2")
                    handleImageSave(filename, id, ImageFileUpParm.ProductImgs, filekind, "ProductData", "Photo");

                r.result = true;
                r.file_name = filename;
            }
            catch (LogicError ex)
            {
                r.result = false;
                r.message = getRecMessage(ex.Message);
            }
            catch (Exception ex)
            {
                r.result = false;
                r.message = ex.Message;
            }
            #endregion
            return defJSON(r);
        }
        public string axFUpload(int id, string filekind, string filename)
        {
            UpFileInfo r = new UpFileInfo();
            #region
            try
            {
                //代表 圖片1
                if (filekind == "Photo1")
                    handleImageSave(filename, id, ImageFileUpParm.Photo, filekind, "InfoDetail", "Photo");
                //代表 圖片2
                if (filekind == "Photo2")
                    handleImageSave(filename, id, ImageFileUpParm.Photo_type2, filekind, "InfoDetail", "Photo");

                r.result = true;
                r.file_name = filename;
            }
            catch (LogicError ex)
            {
                r.result = false;
                r.message = getRecMessage(ex.Message);
            }
            catch (Exception ex)
            {
                r.result = false;
                r.message = ex.Message;
            }
            #endregion
            return defJSON(r);
        }
Пример #10
0
        public string axFUpload(string id, string filekind, string filename)
        {
            UpFileInfo r = new UpFileInfo();

            #region
            try
            {
                if (filekind == "BannerImg")
                {
                    hdlUpImage(filename, filekind, id, ImageFileUpParm.BannerRotator);
                }
                if (filekind == "NewsImg")
                {
                    hdlUpImage(filename, filekind, id, ImageFileUpParm.NewsList);
                }

                r.result    = true;
                r.file_name = filename;
            }
            catch (LogicError ex)
            {
                r.result  = false;
                r.message = getRecMessage(ex.Message);
            }
            catch (Exception ex)
            {
                r.result  = false;
                r.message = ex.Message;
            }
            #endregion
            return(defJSON(r));
        }
        public string aj_FUpload(string id, string filekind, string fileName)
        {
            UpFileInfo r = new UpFileInfo();
            #region
            string tpl_File = string.Empty;
            try
            {
                ////代表圖
                //if (filekind == "List")
                //    handleImageSave(fileName, id, ImageFileUpParm.ProductList, filekind, "Active", "ProductAttachment");
                ////輪播圖
                //if (filekind == "Banner")
                //    handleImageSave(fileName, id, ImageFileUpParm.ProductBanner, filekind, "Active", "ProductAttachment");
                //附件
                if (filekind == "file1")
                    handleFileSave(fileName, id, SysFileUpParm.ProductFile, filekind, "Active", "ProductAttachment");

                r.result = true;
                r.file_name = fileName;
            }
            catch (LogicError ex)
            {
                r.result = false;
                r.message = getRecMessage(ex.Message);
            }
            catch (Exception ex)
            {
                r.result = false;
                r.message = ex.Message;
            }
            #endregion
            return defJSON(r);
        }
        public string aj_FUpload(string id, string filekind, string fileName)
        {
            UpFileInfo r = new UpFileInfo();

            #region
            string tpl_File = string.Empty;
            try
            {
                //證書
                if (filekind == "Certificate")
                {
                    handleImageSave(fileName, id, ImageFileUpParm.Certificate, filekind, "Active", "ProductCertificate");
                }


                r.result    = true;
                r.file_name = fileName;
            }
            catch (LogicError ex)
            {
                r.result  = false;
                r.message = getRecMessage(ex.Message);
            }
            catch (Exception ex)
            {
                r.result  = false;
                r.message = ex.Message;
            }
            #endregion
            return(defJSON(r));
        }
Пример #13
0
        public string axFUpload(int id, string filekind, string filename)
        {
            UpFileInfo r = new UpFileInfo();

            #region
            try
            {
                if (filekind == "File1")
                {
                    handleFileSave(filename, id, ImageFileUpParm.NewsBasicSingle, filekind, "News", "News");
                }

                r.result    = true;
                r.file_name = filename;
            }
            catch (LogicError ex)
            {
                r.result  = false;
                r.message = getRecMessage(ex.Message);
            }
            catch (Exception ex)
            {
                r.result  = false;
                r.message = ex.Message;
            }
            #endregion
            return(defJSON(r));
        }
Пример #14
0
        List <UpFileInfo> GetUpdateFiles()
        {
            List <UpFileInfo> lstUpFile = new List <UpFileInfo>();
            string            xmlPath   = Path.Combine(ClientUpFolder + AppUpdaterXMLFileName);

            if (!File.Exists(xmlPath))
            {
                throw new Exception("更新目录Xml文件不存在");
            }
            XDocument objDoc = XDocument.Load(xmlPath);

            foreach (XElement objElem in objDoc.Document.Element("update").Element("files").Elements("file"))
            {
                UpFileInfo objUpFile = new UpFileInfo();
                objUpFile.FileName = objElem.Attribute("path").Value;
                objUpFile.Version  = objElem.Attribute("ver").Value;
                FileInfo objFile = new FileInfo(Path.Combine(ClientUpFolder, objElem.Attribute("path").Value));
                if (objFile.Exists)
                {
                    objUpFile.FileLength = objFile.Length;
                }
                else
                {
                    objUpFile.FileLength = -1;
                }
                lstUpFile.Add(objUpFile);
            }
            return(lstUpFile);
        }
Пример #15
0
        public string aj_FUpload(string id, string filekind, string fileName)
        {
            UpFileInfo r = new UpFileInfo();

            #region
            string tpl_File = string.Empty;
            try
            {
                //代表圖
                if (filekind == "img1")
                {
                    handleImageSave(fileName, id, ImageFileUpParm.Product, filekind, "Active", "ProductData");
                }
                //附件
                if (filekind == "file1")
                {
                    handleFileSave(fileName, id, SysFileUpParm.BaseLimit, filekind, "Active", "ProductData");
                }

                r.result    = true;
                r.file_name = fileName;
            }
            catch (LogicError ex)
            {
                r.result  = false;
                r.message = getRecMessage(ex.Message);
            }
            catch (Exception ex)
            {
                r.result  = false;
                r.message = ex.Message;
            }
            #endregion
            return(defJSON(r));
        }
        public string axFUpload(int id, string filekind, string filename)
        {
            UpFileInfo r = new UpFileInfo();
            #region
            try
            {
                if (filekind == "File1")
                    handleFileSave(filename, id, ImageFileUpParm.NewsBasicSingle, filekind, "News", "News");

                r.result = true;
                r.file_name = filename;
            }
            catch (LogicError ex)
            {
                r.result = false;
                r.message = getRecMessage(ex.Message);
            }
            catch (Exception ex)
            {
                r.result = false;
                r.message = ex.Message;
            }
            #endregion
            return defJSON(r);
        }
        public string aj_FUpload(string id, string filekind, HttpPostedFileBase file)
        {
            UpFileInfo r = new UpFileInfo();

            #region
            string tpl_File = string.Empty;
            try
            {
                //代表圖片
                if (filekind == "List")
                {
                    handleImageSave(file, id, ImageFileUpParm.NewsList, filekind, "Active", "News");
                }


                r.result    = true;
                r.file_name = file.FileName;
            }
            catch (LogicError ex)
            {
                r.result  = false;
                r.message = getRecMessage(ex.Message);
            }
            catch (Exception ex)
            {
                r.result  = false;
                r.message = ex.Message;
            }
            #endregion
            return(defJSON(r));
        }
Пример #18
0
        public string aj_FUpload(string id, string filekind, string fileName)
        {
            UpFileInfo r = new UpFileInfo();
            #region
            string tpl_File = string.Empty;
            try
            {
                //banner
                if (filekind == "NewProduct")
                    handleImageSave(fileName, id, ImageFileUpParm.IndexNewProduct, filekind, "Active", "ParmData");
                if (filekind == "About1")
                    handleImageSave(fileName, id, ImageFileUpParm.IndexInfo, filekind, "Active", "ParmData");
                if (filekind == "About2")
                    handleImageSave(fileName, id, ImageFileUpParm.IndexInfo, filekind, "Active", "ParmData");
                if (filekind == "EXHIBITION")
                    handleImageSave(fileName, id, ImageFileUpParm.IndexInfo, filekind, "Active", "ParmData");
                if (filekind == "SUPPORT")
                    handleImageSave(fileName, id, ImageFileUpParm.IndexInfo, filekind, "Active", "ParmData");

                if (filekind == "NewProduct_jp")
                    handleImageSave(fileName, id, ImageFileUpParm.IndexNewProduct, filekind, "Active", "ParmData");
                if (filekind == "About1_jp")
                    handleImageSave(fileName, id, ImageFileUpParm.IndexInfo, filekind, "Active", "ParmData");
                if (filekind == "About2_jp")
                    handleImageSave(fileName, id, ImageFileUpParm.IndexInfo, filekind, "Active", "ParmData");
                if (filekind == "EXHIBITION_jp")
                    handleImageSave(fileName, id, ImageFileUpParm.IndexInfo, filekind, "Active", "ParmData");
                if (filekind == "SUPPORT_jp")
                    handleImageSave(fileName, id, ImageFileUpParm.IndexInfo, filekind, "Active", "ParmData");


                r.result = true;
                r.file_name = fileName;
            }
            catch (LogicError ex)
            {
                r.result = false;
                r.message = getRecMessage(ex.Message);
            }
            catch (Exception ex)
            {
                r.result = false;
                r.message = ex.Message;
            }
            #endregion
            return defJSON(r);
        }
Пример #19
0
        public string axFUpload(int id, string filekind, string filename, bool check_add, string word)
        {
            UpFileInfo r = new UpFileInfo();
            #region
            try
            {
                //banner 圖片
                if (filekind == "Banner")
                {
                    handleImageSave(filename, id, ImageFileUpParm.BannerIndex, filekind, "Banner", "Banner");

                    if (check_add)
                    {
                        string upload_path_tpl = "~/_Upload/{0}/{1}/{2}/{3}/{4}";
                        string upload_path_tpl_icon = "~/_Upload/{0}/{1}/{2}/{3}/{4}/{5}";
                        string web_path_parm = string.Format(upload_path_tpl, "Banner", "Banner", id, filekind, filename);
                        string web_path_parm_icon = string.Format(upload_path_tpl_icon, "Banner", "Banner", id, filekind, "icon", filename);
                        AddTextToImg(web_path_parm, word);
                        AddTextToImg(web_path_parm_icon, word);
                    }
                }
                //banner 圖片
                if (filekind == "Photo")
                    handleImageSave(filename, id, ImageFileUpParm.BannerClient, filekind, "Banner", "Banner");

                r.result = true;
                r.file_name = filename;
            }
            catch (LogicError ex)
            {
                r.result = false;
                r.message = getRecMessage(ex.Message);
            }
            catch (Exception ex)
            {
                r.result = false;
                r.message = ex.Message;
            }
            #endregion
            return defJSON(r);
        }
Пример #20
0
        public string aj_FUpload(string id, string filekind, HttpPostedFileBase file)
        {
            UpFileInfo r = new UpFileInfo();

            #region
            string tpl_File = string.Empty;
            try
            {
                //banner
                if (filekind == "Banner")
                {
                    handleImageSave(file, id, ImageFileUpParm.BrandRotator, filekind, "Active", "BrandData");
                }
                //album
                if (filekind == "Album")
                {
                    handleImageSave(file, id, ImageFileUpParm.BrandRotator, filekind, "Active", "Album");
                }
                if (filekind == "AlbumList")
                {
                    handleImageSave(file, id, ImageFileUpParm.BrandRotator, filekind, "Active", "AlbumList");
                }


                r.result    = true;
                r.file_name = file.FileName;
            }
            catch (LogicError ex)
            {
                r.result  = false;
                r.message = getRecMessage(ex.Message);
            }
            catch (Exception ex)
            {
                r.result  = false;
                r.message = ex.Message;
            }
            #endregion
            return(defJSON(r));
        }
        public string axFUpload(int id, string filekind, string filename)
        {
            UpFileInfo r = new UpFileInfo();
            #region
            try
            {
                //banner 圖片
                if (filekind == "Banner")
                    handleImageSave(filename, id, ImageFileUpParm.BannerRotator, filekind, "StudyAbroad", "Banner");

                //代表 圖片
                if (filekind == "Photo1")
                    handleImageSave(filename, id, ImageFileUpParm.Photo, filekind, "StudyAbroad", "Photo");

                //照片集錦 圖片
                if (filekind == "Photo2")
                    handleImageSave(filename, id, ImageFileUpParm.PhotoCollection, filekind, "StudyAbroad", "Photo");

                r.result = true;
                r.file_name = filename;
            }
            catch (LogicError ex)
            {
                r.result = false;
                r.message = getRecMessage(ex.Message);
            }
            catch (Exception ex)
            {
                r.result = false;
                r.message = ex.Message;
            }
            #endregion
            return defJSON(r);
        }
Пример #22
0
        /// <summary>
        /// 下载更新文件
        /// </summary>
        /// <param name="objUpFile"></param>
        private void DownloadFile(UpFileInfo objUpFile)
        {
            Stream sourceStream = null;

            try
            {
                sourceStream = ServiceProxy.Current.CreateUpdateFileStream(objUpFile.FileName);
            }
            catch (Exception ex)
            {
                this.Dispatcher.Invoke(new Action(() =>
                {
                    MessageBox.Show("编码:ServiceProxy.CreateUpdateFileStream\r\n描述:" + ex.Message);
                    UpdaterStatus = EFileStatus.Error;
                    this.Close();
                }));
            }

            //创建文件夹
            Directory.CreateDirectory(Path.GetDirectoryName(Path.GetFullPath(ConfigSet.Current.TempFolder + objUpFile.FileName)));
            using (var targetStream = new FileStream(ConfigSet.Current.TempFolder + objUpFile.FileName, FileMode.Create, FileAccess.Write, FileShare.None))
            {
                //定义文件缓冲区
                byte[] buffer = new byte[ConfigSet.Current.BufferSize];
                int    count  = 0;

                long totalDownloadedByte = 0;
                while ((count = sourceStream.Read(buffer, 0, (int)ConfigSet.Current.BufferSize)) > 0)
                {
                    //总下载字节数
                    totalDownloadedByte = count + totalDownloadedByte;
                    targetStream.Write(buffer, 0, count);
                    targetStream.Flush();

                    if (ConfigSet.Current.DelayMillisecond > 0)
                    {
                        Thread.Sleep(ConfigSet.Current.DelayMillisecond);
                    }

                    this.Dispatcher.Invoke(new Action(() =>
                    {
                        long totalDownloadKB = (long)Math.Floor((double)totalDownloadedByte / 1024);
                        //百分比,小于等于最大整数
                        int percent = (int)Math.Floor((double)totalDownloadedByte / (double)objUpFile.FileLength * 100);

                        DataTable dt = gridControl.ItemsSource as DataTable;
                        foreach (DataRow objRow in dt.Rows)
                        {
                            if (objRow[0].ToString() == objUpFile.FileName)
                            {
                                objRow[2] = totalDownloadKB.ToString() + "K";
                                objRow[3] = percent.ToString() + "%";
                                break;
                            }
                        }
                    }));
                }
                targetStream.Close();
                sourceStream.Close();
            }

            //下载完成后,检查并更新
            this.Dispatcher.Invoke(new Action(() =>
            {
                DataTable dt = gridControl.ItemsSource as DataTable;
                foreach (DataRow objRow in dt.Rows)
                {
                    if (objRow[0].ToString() == objUpFile.FileName)
                    {
                        DownloadedFileNum++;    //下载完成数
                        DownloadingThreadNum--; //正在更新的线程数
                        this.Title = String.Format("开始下载...   已完成[{0}/{1}]   活动线程数[{2}]",
                                                   DownloadedFileNum, UpdateUpFileList.Count, DownloadingThreadNum);
                        break;
                    }
                }
            }));
        }
Пример #23
0
        public string aj_FUpload(string id, string filekind, string fileName)
        {
            UpFileInfo r = new UpFileInfo();

            #region
            string tpl_File = string.Empty;
            try
            {
                //banner
                if (filekind == "NewProduct")
                {
                    handleImageSave(fileName, id, ImageFileUpParm.IndexNewProduct, filekind, "Active", "ParmData");
                }
                if (filekind == "About1")
                {
                    handleImageSave(fileName, id, ImageFileUpParm.IndexInfo, filekind, "Active", "ParmData");
                }
                if (filekind == "About2")
                {
                    handleImageSave(fileName, id, ImageFileUpParm.IndexInfo, filekind, "Active", "ParmData");
                }
                if (filekind == "EXHIBITION")
                {
                    handleImageSave(fileName, id, ImageFileUpParm.IndexInfo, filekind, "Active", "ParmData");
                }
                if (filekind == "SUPPORT")
                {
                    handleImageSave(fileName, id, ImageFileUpParm.IndexInfo, filekind, "Active", "ParmData");
                }

                if (filekind == "NewProduct_jp")
                {
                    handleImageSave(fileName, id, ImageFileUpParm.IndexNewProduct, filekind, "Active", "ParmData");
                }
                if (filekind == "About1_jp")
                {
                    handleImageSave(fileName, id, ImageFileUpParm.IndexInfo, filekind, "Active", "ParmData");
                }
                if (filekind == "About2_jp")
                {
                    handleImageSave(fileName, id, ImageFileUpParm.IndexInfo, filekind, "Active", "ParmData");
                }
                if (filekind == "EXHIBITION_jp")
                {
                    handleImageSave(fileName, id, ImageFileUpParm.IndexInfo, filekind, "Active", "ParmData");
                }
                if (filekind == "SUPPORT_jp")
                {
                    handleImageSave(fileName, id, ImageFileUpParm.IndexInfo, filekind, "Active", "ParmData");
                }


                r.result    = true;
                r.file_name = fileName;
            }
            catch (LogicError ex)
            {
                r.result  = false;
                r.message = getRecMessage(ex.Message);
            }
            catch (Exception ex)
            {
                r.result  = false;
                r.message = ex.Message;
            }
            #endregion
            return(defJSON(r));
        }