Example #1
0
        /// <summary>
        /// 打包AB资源
        /// </summary>
        /// <param name="buildTarget">打包的平台</param>
        public static void BuildAssetBundles(BuildTarget buildTarget)
        {
            // Choose the output path according to the build target.
            var outputPath = CreateAssetBundleDirectory(buildTarget);

            const BuildAssetBundleOptions options = BuildAssetBundleOptions.ChunkBasedCompression;
            //获取manifest文件
            var manifest = BuildPipeline.BuildAssetBundles(outputPath, options, buildTarget);

            var versionsPath = outputPath + "/versions.txt";
            var versions     = new Dictionary <string, string>();

            LoadVersions(versionsPath, versions);

            var buildVersions = GetVersions(manifest);

            var updates = new List <string>();

            foreach (var item in buildVersions)
            {
                string hash;
                var    isNew = true;
                if (versions.TryGetValue(item.Key, out hash))
                {
                    if (hash.Equals(item.Value))
                    {
                        isNew = false;
                    }
                }
                if (isNew)
                {
                    updates.Add(item.Key);
                }
            }

            if (updates.Count > 0)
            {
                using (var s = new StreamWriter(File.Open(outputPath + "/updates.txt", FileMode.Append)))
                {
                    s.WriteLine(DateTime.Now.ToFileTime() + ":");
                    foreach (var item in updates)
                    {
                        s.WriteLine(item);
                    }
                    s.Flush();
                    s.Close();
                }

                SaveVersions(versionsPath, buildVersions);
            }
            else
            {
                Debug.Log("不需要打包");
            }

            string[] ignoredFiles = { GetPlatformName(), "versions.txt", "updates.txt", "manifest" };

            var files = Directory.GetFiles(outputPath, "*", SearchOption.AllDirectories);

            var deletes = (from t in files
                           let file = t.Replace('\\', '/').Replace(outputPath.Replace('\\', '/') + '/', "")
                                      where !file.EndsWith(".manifest", StringComparison.Ordinal) && !Array.Exists(ignoredFiles, s => s.Equals(file))
                                      where !buildVersions.ContainsKey(file)
                                      select t).ToList();

            foreach (var delete in deletes)
            {
                if (!File.Exists(delete))
                {
                    continue;
                }
                File.Delete(delete);
                File.Delete(delete + ".manifest");
            }
            Debug.Log("AB打包完成");
            //最终将bytes 文件复制到AB文件夹
            //最终将bytes 文件复制到AB文件夹
            //最终将bytes 文件复制到AB文件夹
            //最终将bytes 文件复制到AB文件夹
            //最终将bytes 文件复制到AB文件夹
            FileTool.CopyFile(Application.streamingAssetsPath + "/Hotfix/" + LWUtility.HotfixFileName, outputPath + "/" + LWUtility.HotfixFileName, true);
            deletes.Clear();
        }
Example #2
0
        public void LoadPage()
        {
            if (!AjaxLoadCheck())
            {
                return;
            }
            //Response.ContentType = "text/plain";
            //Response.Charset = "utf-8";

            System.Drawing.Bitmap   bitmap   = null;                 //按截图区域生成Bitmap
            System.Drawing.Image    thumbImg = null;                 //被截图
            System.Drawing.Graphics gps      = null;                 //存绘图对象
            System.Drawing.Image    finalImg = null;                 //最终图片
            string pointX = RequestTool.RequestSafeString("pointX"); //X坐标
            string pointY = RequestTool.RequestSafeString("pointY"); //Y坐标
            string imgUrl = RequestTool.RequestSafeString("imgUrl"); //被截图图片地址
            string rlSize = "80";                                    // context.Request.Params["maxVal"];        //截图矩形的大小

            int           finalWidth  = 80;
            int           finalHeight = 80;
            BaseConfig    conf        = ShopCache.GetBaseConfig();
            B_WaterConfig bc          = new B_WaterConfig();

            if (!string.IsNullOrEmpty(pointX) && !string.IsNullOrEmpty(pointY) && !string.IsNullOrEmpty(imgUrl))
            {
                string ext = System.IO.Path.GetExtension(imgUrl).ToLower();   //上传文件的后缀(小写)

                bitmap = new System.Drawing.Bitmap(Convert.ToInt32(rlSize), Convert.ToInt32(rlSize));

                thumbImg = System.Drawing.Image.FromFile(HttpContext.Current.Server.MapPath(imgUrl));

                System.Drawing.Rectangle rl = new System.Drawing.Rectangle(Convert.ToInt32(pointX), Convert.ToInt32(pointY), Convert.ToInt32(rlSize), Convert.ToInt32(rlSize)); //得到截图矩形

                gps = System.Drawing.Graphics.FromImage(bitmap);                                                                                                                //读到绘图对象

                gps.DrawImage(thumbImg, 0, 0, rl, System.Drawing.GraphicsUnit.Pixel);
                string savePath = conf.UpLoadPath + "/avatar/admin/";
                finalImg = PubClass.GetThumbNailImage(bitmap, finalWidth, finalHeight);
                if (!File.Exists(savePath))   //如果路径不存在,则创建
                {
                    System.IO.Directory.CreateDirectory(ImageHelper.rootpath(savePath));
                }
                string rndname   = DateTime.Now.ToString("yyMMddssfff");
                string finalPath = savePath + rndname + "_small" + ext;
                finalImg.Save(HttpContext.Current.Server.MapPath(finalPath));
                string formconfig = HttpContext.Current.Server.MapPath(@"~/" + imgUrl);
                string toconfig   = HttpContext.Current.Server.MapPath(@"~" + conf.UpLoadPath + "/avatar/admin/" + rndname + "_original" + ext);
                ImageHelper.DeleteImage(formconfig);
                FileTool.CopyFile(formconfig, toconfig, true);

                bitmap.Dispose();
                thumbImg.Dispose();
                gps.Dispose();
                finalImg.Dispose();
                GC.Collect();
                ////写入数据库
                //Lebi_Image model = new Lebi_Image();
                //model.Image = finalPath;
                //model.Keyid = CurrentUser.id;
                //model.Size = "120$120";
                //model.TableName = "avatar";
                //B_Lebi_Image.Add(model);
                //PubClass.FileDel(HttpContext.Current.Server.MapPath(imgUrl));
                Response.Write(finalPath);
            }
        }
Example #3
0
        /// <summary>
        /// 导出淘宝格式商品数据
        /// </summary>
        public void taobao_product_out()
        {
            if (!Power("supplier_product_datainout", "导入导出"))
            {
                AjaxNoPower();
                return;
            }
            string        lang = RequestTool.RequestString("lang");
            SearchProduct sp   = new SearchProduct(CurrentSupplier, CurrentLanguage.Code);

            string where = "Supplier_id =" + CurrentSupplier.id + " and Product_id=0 " + sp.SQL;
            List <Lebi_Product> ps = B_Lebi_Product.GetList(where, "");


            string titles = "title,cid,seller_cids,stuff_status,location_state,location_city,item_type,price,auction_increment,num,valid_thru,freight_payer,post_fee,ems_fee,express_fee,has_invoice,has_warranty,approve_status,has_showcase,list_time,description,cateProps,postage_id,has_discount,modified,upload_fail_msg,picture_status,auction_point,picture,video,skuProps,inputPids,inputValues,outer_id,propAlias,auto_fill,num_id,local_cid,navigation_type,user_name,syncStatus,is_lighting_consigment,is_xinpin,foodparame,features,buyareatype,global_stock_type,global_stock_country,sub_stock_type,item_size,item_weight,sell_promise,custom_design_flag,wireless_desc,VolumeL,VolumeW,VolumeH,PackageRate";

            string[]  arr = titles.Split(',');
            DataTable dt  = new DataTable();

            foreach (string col in arr)
            {
                dt.Columns.Add(col);
            }
            DataRow r = dt.NewRow();

            dt.Rows.Add(r);

            StringBuilder sb = new StringBuilder();

            sb.Append("version 1.00,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\r\n");
            sb.Append(titles + "\r\n");
            sb.Append("宝贝名称,宝贝类目,店铺类目,新旧程度,省,城市,出售方式,宝贝价格,加价幅度,宝贝数量,有效期,运费承担,平邮,EMS,快递,发票,保修,放入仓库,橱窗推荐,开始时间,宝贝描述,宝贝属性,邮费模版ID,会员打折,修改时间,上传状态,图片状态,返点比例,新图片,视频,销售属性组合,用户输入ID串,用户输入名-值对,商家编码,销售属性别名,代充类型,数字ID,本地ID,宝贝分类,用户名称,宝贝状态,闪电发货,新品,食品专项,尺码库,采购地,库存类型,国家地区,库存计数,物流体积,物流重量,退换货承诺,定制工具,无线详情,包装尺寸L,包装尺寸W,包装尺寸H,包装率\r\n");
            //sb.Append("title,stuff_status,price,num,description,modified,item_weight,picture,wireless_desc \r\n");
            //sb.Append("宝贝名称,新旧程度,宝贝价格,宝贝数量,宝贝描述,修改时间,物流重量,新图片,无线详情  \r\n");
            string domain = "http://" + RequestTool.GetRequestDomainPort();
            string images = "";

            string[] temparr;
            string   temp;
            int      i          = 0;
            string   name       = "";
            string   filename   = System.DateTime.Now.ToString("yyyyMMddhhmmss");
            string   serverpath = HttpContext.Current.Server.MapPath(@"~/" + WebPath);
            string   savepath   = serverpath + "/download/taobaoproduct" + filename + "/taobao";

            if (Directory.Exists(savepath))
            {
                Directory.Delete(savepath);
            }
            Directory.CreateDirectory(savepath);
            foreach (Lebi_Product pro in ps)
            {
                dt.Rows[0]["title"]         = Lang(pro.Name, lang);
                dt.Rows[0]["stuff_status"]  = "1";
                dt.Rows[0]["price"]         = pro.Price;
                dt.Rows[0]["num"]           = pro.Count_Stock;
                dt.Rows[0]["description"]   = taobao_product_out_langtxt(pro.Description, lang);
                dt.Rows[0]["modified"]      = pro.Time_Edit;
                dt.Rows[0]["item_weight"]   = pro.Weight;
                dt.Rows[0]["outer_id"]      = pro.Number;
                dt.Rows[0]["wireless_desc"] = taobao_product_out_langtxt(pro.MobileDescription, lang);
                dt.Rows[0]["VolumeL"]       = pro.VolumeL;
                dt.Rows[0]["VolumeW"]       = pro.VolumeW;
                dt.Rows[0]["VolumeH"]       = pro.VolumeH;
                dt.Rows[0]["PackageRate"]   = pro.PackageRate;
                //处理图片
                images  = pro.ImageOriginal + pro.Images;
                temparr = images.Split('@');
                images  = "";
                i       = 0;
                foreach (string img in temparr)
                {
                    if (img != "")
                    {
                        name = MD5(img);
                        FileTool.CopyFile(serverpath + img, savepath + "/" + name + ".tbi", true);
                        temp = domain + img;
                        //temp = name + ":0:" + i + ":|;";
                        temp    = name + ":1:" + i + ":|" + temp + ";";
                        images += temp;

                        i++;
                    }
                }
                dt.Rows[0]["picture"] = images;
                i = 0;
                foreach (DataColumn col in dt.Columns)
                {
                    if (i == 0)
                    {
                        sb.Append(dt.Rows[0][col.ToString()]);
                    }
                    else
                    {
                        sb.Append("," + dt.Rows[0][col.ToString()]);
                    }
                    i++;
                }
                sb.Append("\r\n");
            }
            HtmlEngine.Instance.WriteFile(serverpath + "/download/taobaoproduct" + filename + "/taobao.csv", sb.ToString());
            //ZipUtil.RAR(serverpath + "/download/taobaoproduct" + filename, serverpath + "/download", "taobaoproduct" + filename + ".rar");
            string err = "";

            ZipUtil.ZipFile(serverpath + "/download/taobaoproduct" + filename + "/taobao", serverpath + "/download/taobaoproduct" + filename + "/taobao.zip", out err);
            ZipUtil.ZipFile(serverpath + "/download/taobaoproduct" + filename, serverpath + "/download/taobaoproduct" + filename + ".zip", out err);
            Response.Write("{\"msg\":\"OK\",\"url\":\"" + WebPath + "/download/taobaoproduct" + filename + ".zip\"}");
        }