public string QuerySpecPic()
        {
            _specTempMgr = new ProductSpecTempMgr(connectionString);
            _specMgr = new ProductSpecMgr(connectionString);

            string json = string.Empty;
            if (string.IsNullOrEmpty(Request.Params["product_id"]))
            {
                //查找臨時表記錄
                ProductSpecTemp psTemp = new ProductSpecTemp();
                psTemp.Writer_Id = (Session["caller"] as Caller).user_id;
                psTemp.spec_type = 1;
                //string str = "{success:true,items:"+JsonConvert.+"}";
                List<ProductSpecTemp> results = _specTempMgr.Query(psTemp); //JsonConvert.SerializeObject();
                foreach (var item in results)
                {
                    if (item.spec_image != "")
                    {
                        item.spec_image = imgServerPath + specPath + GetDetailFolder(item.spec_image) + item.spec_image;
                    }

                }
                json = "{success:true,items:" + JsonConvert.SerializeObject(results) + "}";
                json = json.Replace("spec_image", "img");
            }
            else
            {
                //查找正式表
                ProductSpec pSpec = new ProductSpec();
                pSpec.product_id = uint.Parse(Request.Params["product_id"]);
                pSpec.spec_type = 1;
                List<ProductSpec> spList = _specMgr.Query(pSpec);
                foreach (var item in spList)
                {
                    if (item.spec_image != "")
                    {
                        item.spec_image = imgServerPath + specPath + GetDetailFolder(item.spec_image) + item.spec_image;
                    }

                }
                json = "{success:true,items:" + JsonConvert.SerializeObject(spList) + "}";
                json = json.Replace("spec_image", "img");

            }
            return json;
        }
        public void DeletePicOnServer(bool prod, bool spec, bool desc, string product_id, int type = 1)
        {
            int writerId = (Session["caller"] as Caller).user_id;
            _productTempMgr = new ProductTempMgr(connectionString);
            _specTempMgr = new ProductSpecTempMgr(connectionString);
            _pPicTempMgr = new ProductPictureTempImplMgr(connectionString);
            ArrayList ImgList = new ArrayList();
            ProductSpecTemp pSpec = new ProductSpecTemp();
            pSpec.Writer_Id = writerId;
            pSpec.spec_type = 1;
            //刪除對應的圖片
            //商品圖
            if (prod)
            {
                ProductTemp query = new ProductTemp { Writer_Id = writerId, Combo_Type = COMBO_TYPE, Product_Id = product_id.ToString() };
                string fileName = _productTempMgr.GetProTemp(query).Product_Image;
                if (!string.IsNullOrEmpty(fileName))
                {
                    ImgList.Add(imgLocalPath + prodPath + GetDetailFolder(fileName) + fileName);
                    ImgList.Add(imgLocalPath + prod50Path + GetDetailFolder(fileName) + fileName);
                    ImgList.Add(imgLocalPath + prod150Path + GetDetailFolder(fileName) + fileName);
                    ImgList.Add(imgLocalPath + prod280Path + GetDetailFolder(fileName) + fileName);
                }

            }
            //規格圖
            if (spec)
            {
                List<ProductSpecTemp> pSList = _specTempMgr.Query(pSpec);
                foreach (var item in pSList)
                {
                    if (item.spec_image != "")
                    {
                        ImgList.Add(imgLocalPath + specPath + GetDetailFolder(item.spec_image) + item.spec_image);
                        ImgList.Add(imgLocalPath + spec100Path + GetDetailFolder(item.spec_image) + item.spec_image);
                        ImgList.Add(imgLocalPath + spec280Path + GetDetailFolder(item.spec_image) + item.spec_image);
                    }
                }
            }
            //商品說明圖
            if (desc)
            {
                ProductPictureTemp query = new ProductPictureTemp { writer_Id = writerId, combo_type = COMBO_TYPE, product_id = product_id };
                List<ProductPictureTemp> pPList = _pPicTempMgr.Query(query);
                SetPath(type);
                foreach (var item in pPList)
                {
                    ImgList.Add(imgLocalPath + descPath + GetDetailFolder(item.image_filename) + item.image_filename);
                    ImgList.Add(imgLocalPath + desc400Path + GetDetailFolder(item.image_filename) + item.image_filename);
                }
            }

            foreach (string item in ImgList)
            {
                //刪除服務器上對應的圖片
                if (System.IO.File.Exists(item))
                {
                    System.IO.File.Delete(item);
                }
            }
        }
Esempio n. 3
0
        public HttpResponseBase spec2TempQuery()
        {
            string resultStr = "{success:false}";
            Caller _caller = (Session["caller"] as Caller);
            try
            {
                if (!string.IsNullOrEmpty(Request.Params["ProductId"]))
                {
                    //product_spec
                    uint pid = uint.Parse(Request.Form["ProductId"]);
                    _specMgr = new ProductSpecMgr(connectionString);
                    resultStr = "{success:true,data:" + JsonConvert.SerializeObject(_specMgr.Query(new ProductSpec { product_id = pid, spec_type = 2 })) + "}";

                }
                else
                {
                    //product_spec_temp
                    _specTempMgr = new ProductSpecTempMgr(connectionString);
                    ProductSpecTemp query = new ProductSpecTemp { Writer_Id = _caller.user_id, spec_type = 2 };
                    if (!string.IsNullOrEmpty(Request.Form["OldProductId"]))
                    {
                        query.product_id = Request.Form["OldProductId"];
                    }
                    resultStr = "{success:true,data:" + JsonConvert.SerializeObject(_specTempMgr.Query(query)) + "}";

                }

            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
            }

            this.Response.Clear();
            this.Response.Write(resultStr);
            this.Response.End();
            return this.Response;
        }
Esempio n. 4
0
        public HttpResponseBase specTempSave()
        {
            string resultStr = "{success:true}";
            bool result = true;
            try
            {

                Caller _caller = (Session["caller"] as Caller);
                string specType = Request.Params["specType"];
                string spec1Name = Request.Params["spec1Name"];
                string spec1Result = Request.Params["spec1Result"];
                string spec2Name = "";
                string spec2Result;

                _specMgr = new ProductSpecMgr(connectionString);
                _specTempMgr = new ProductSpecTempMgr(connectionString);
                _productTempMgr = new ProductTempMgr(connectionString);
                _productItemMgr = new ProductItemMgr(connectionString);
                _productItemTempMgr = new ProductItemTempMgr(connectionString);
                _serialMgr = new SerialMgr(connectionString);

                if (!string.IsNullOrEmpty(Request.Params["ProductId"]))
                {
                    uint proId = uint.Parse(Request.Params["ProductId"]);

                    _functionMgr = new FunctionMgr(connectionString);
                    string function = Request.Params["function"] ?? "";
                    Function fun = _functionMgr.QueryFunction(function, "/Product/ProductSave");
                    int functionid = fun == null ? 0 : fun.RowId;
                    HistoryBatch batch = new HistoryBatch { functionid = functionid };
                    batch.batchno = Request.Params["batch"] ?? "";
                    batch.kuser = (Session["caller"] as Caller).user_email;

                    #region 正式表修改
                    List<ProductSpec> spec1List = null;
                    List<ProductSpec> spec2List = null;
                    List<ProductSpec> specUpdateList = new List<ProductSpec>();
                    List<ProductSpec> specAddList = new List<ProductSpec>();
                    JavaScriptSerializer jss = new JavaScriptSerializer();
                    spec1List = jss.Deserialize<List<ProductSpec>>(spec1Result);
                    if (spec1List != null)
                    {
                        //規格一處理
                        spec1List.ForEach(m =>
                        {
                            m.product_id = proId;
                            m.spec_type = 1;
                            if (m.spec_id != 0)
                            {
                                specUpdateList.Add(m);
                            }
                            else
                            {
                                specAddList.Add(m);
                            }
                        });
                    }

                    //規格二處理
                    if (specType.Equals("2"))
                    {
                        spec2Name = Request.Params["spec2Name"];
                        spec2Result = Request.Params["spec2Result"];
                        spec2List = jss.Deserialize<List<ProductSpec>>(spec2Result);

                        spec2List.ForEach(m =>
                        {
                            m.product_id = proId;
                            m.spec_type = 2;
                            if (m.spec_id != 0)
                            {
                                specUpdateList.Add(m);
                            }
                            else
                            {
                                specAddList.Add(m);
                            }
                        });
                    }

                    Product proModel = new Product();
                    _productMgr = new ProductMgr(connectionString);
                    _tableHistoryMgr = new TableHistoryMgr(connectionString);
                    proModel = _productMgr.Query(new Product { Product_Id = proId }).FirstOrDefault();
                    proModel.Spec_Title_1 = spec1Name;
                    proModel.Spec_Title_2 = spec2Name;

                    if (specUpdateList.Count() > 0)
                    {
                        for (int i = 0, j = specUpdateList.Count(); i < j; i++)
                        {
                            ArrayList sqls = new ArrayList();
                            sqls.Add(_specMgr.Update(specUpdateList[i]));
                            if (i == 0)
                            {
                                sqls.Add(_productMgr.Update(proModel));
                            }
                            if (!_tableHistoryMgr.SaveHistory<ProductSpec>(specUpdateList[i], batch, sqls))
                            {
                                result = false;
                            }
                        }
                    }

                    if (specAddList.Count() > 0)
                    {

                        List<ProductItem> saveItemList = new List<ProductItem>();
                        List<ProductSpec> spec1ExistList = spec1List.Where(m => m.spec_id != 0).ToList();     //規格一中原本就存在的規格
                        specAddList.ForEach(p => p.spec_id = uint.Parse(_serialMgr.NextSerial(18).ToString()));
                        ProductItem saveTemp;
                        List<PriceMaster> list_price = new List<PriceMaster>();
                        PriceMasterMgr pm = new PriceMasterMgr(connectionString);
                        list_price = pm.GetPriceMasterInfoByID2(proId.ToString());//獲取同一個ID下其他產品的價格信息
                        PriceMaster _p = list_price.FirstOrDefault();//add by wangwei0216w 2014/9/19 獲取同一個ID下其他產品的信息
                        //List<ProductItem> pro_list = new List<ProductItem>();
                        //ProductItemMgr pig = new ProductItemMgr(connectionString);
                        //pro_list = pig.GetProductItemByID(Convert.ToInt32(proId));
                        //ProductItem _product = pro_list.FirstOrDefault();//獲取同一個ID下其他產品的信息
                        foreach (var m in specAddList)
                        {
                            if (specType.Equals("1"))
                            {
                                if (m.spec_type == 1)
                                {
                                    saveTemp = new ProductItem();
                                    if (_p.same_price == 1)             //add by wangwei 0216w 2014/9/19 如果同價 就將價格賦予新增規格
                                    {
                                        //saveTemp.Item_Cost = Convert.ToUInt32(_p.cost);
                                        //saveTemp.Item_Money = Convert.ToUInt32(_p.price);
                                    }
                                    else
                                    {
                                        resultStr = "{success:true,Msg:true}";
                                    }
                                    saveTemp.Spec_Id_1 = m.spec_id;
                                    saveTemp.Product_Id = proId;
                                    // saveTemp.Item_Stock = 10;
                                    saveTemp.Item_Alarm = 1;
                                    saveItemList.Add(saveTemp);
                                }
                                else
                                {
                                    saveTemp = new ProductItem();
                                    if (_p.same_price == 1)             //add by wangwei 0216w 2014/9/19 如果同價 就將價格賦予新增規格
                                    {
                                        //saveTemp.Item_Cost = Convert.ToUInt32(_p.cost);
                                        //saveTemp.Item_Money = Convert.ToUInt32(_p.price);
                                    }
                                    else
                                    {
                                        resultStr = "{success:true,Msg:true}";
                                    }
                                    saveTemp.Spec_Id_2 = m.spec_id;
                                    saveTemp.Product_Id = proId;
                                    //saveTemp.Item_Stock = 10;
                                    saveTemp.Item_Alarm = 1;
                                    saveItemList.Add(saveTemp);
                                }
                            }
                            else
                            {
                                if (m.spec_type == 1)
                                {
                                    foreach (ProductSpec item in spec2List)
                                    {
                                        saveTemp = new ProductItem();
                                        if (_p.same_price == 1)             //add by wangwei 0216w 2014/9/19 如果同價 就將價格賦予新增規格
                                        {
                                            //saveTemp.Item_Cost = Convert.ToUInt32(_p.cost);
                                            //saveTemp.Item_Money = Convert.ToUInt32(_p.price);
                                        }
                                        else
                                        {
                                            resultStr = "{success:true,Msg:true}";
                                        }
                                        saveTemp.Spec_Id_1 = m.spec_id;
                                        saveTemp.Spec_Id_2 = item.spec_id;
                                        //saveTemp.Item_Stock = 10;
                                        saveTemp.Item_Alarm = 1;
                                        saveTemp.Product_Id = proId;
                                        saveItemList.Add(saveTemp);
                                    }
                                }
                                else
                                {
                                    foreach (ProductSpec item2 in spec1ExistList)
                                    {
                                        saveTemp = new ProductItem();
                                        if (_p.same_price == 1)             //add by wangwei 0216w 2014/9/19 如果同價 就將價格賦予新增規格
                                        {
                                            //saveTemp.Item_Cost = Convert.ToUInt32(_p.cost);
                                            //saveTemp.Item_Money = Convert.ToUInt32(_p.price);
                                        }
                                        else
                                        {
                                            resultStr = "{success:true,Msg:true}";
                                        }
                                        saveTemp.Spec_Id_1 = item2.spec_id;
                                        saveTemp.Spec_Id_2 = m.spec_id;
                                        //saveTemp.Item_Stock = 10;
                                        saveTemp.Item_Alarm = 1;
                                        saveTemp.Product_Id = proId;
                                        saveItemList.Add(saveTemp);
                                    }

                                }
                            }
                        }

                        _specMgr.Save(specAddList);
                        _productItemMgr.Save(saveItemList);
                        ProductItem pro;
                        if (proModel.Product_Status != 0) //add by wangwei0216w 2014/9/18 作用:將Export_flag的值設置為1
                        {
                            pro = new ProductItem() { Product_Id = proModel.Product_Id, Export_flag = 1 };
                            _productItemMgr.UpdateExportFlag(pro);
                        }
                        if (result) //如果之前保存規格,插入臨時表登操作有誤,則不執行插入itemprice的操作
                        {
                            List<ProductItem> item_list = _productItemMgr.GetProductNewItem_ID(Convert.ToInt32(proModel.Product_Id));   //得到product_item的新增ID
                            ItemPrice i = new ItemPrice();
                            ItemPriceMgr ipm = new ItemPriceMgr(connectionString);
                            ArrayList liststr = new ArrayList();
                            foreach (PriceMaster p in list_price)
                            {
                                foreach (ProductItem pi in item_list)
                                {
                                    if (p.same_price == 1)
                                    {
                                        i.price_master_id = p.price_master_id;
                                        i.item_id = pi.Item_Id;
                                        i.item_money = Convert.ToUInt32(p.price);
                                        i.item_cost = Convert.ToUInt32(p.cost);
                                        i.event_cost = Convert.ToUInt32(p.event_cost);
                                        i.event_money = Convert.ToUInt32(p.event_price);
                                    }
                                    else
                                    {
                                        i.price_master_id = p.price_master_id;
                                        i.item_id = pi.Item_Id;
                                        i.item_money = 0;
                                        i.item_cost = 0;
                                        i.event_money = 0;
                                        i.event_cost = 0;
                                        resultStr = "{success:true,Msg:true}";
                                    }
                                    liststr.Add(ipm.Save(i));
                                }
                            }
                            ipm.AddItemPricBySpec(liststr, connectionString);
                        }
                    }
                    //若為單一商品,則把product_item.export_flag改為2 edit by xiangwang0413w 2014/06/30
                    //if (proModel.Combination == 1)
                    //{
                    //    _productItemMgr = new ProductItemMgr(connectionString);
                    //    ProductItem pro_Item = new ProductItem() { Product_Id = proModel.Product_Id, Export_flag = 2 };
                    //    _productItemMgr.UpdateExportFlag(pro_Item);
                    //}

                    #endregion
                }
                else
                {
                    #region 臨時表修改
                    _productTempMgr = new ProductTempMgr(connectionString); //add by xiangwang 2014.09.26 可修改庫存預設值為99

                    string product_id = "0";
                    if (!string.IsNullOrEmpty(Request.Form["OldProductId"]))
                    {
                        product_id = Request.Form["OldProductId"];
                    }

                    //add by xiangwang 2014.09.26 可修改庫存預設值為99
                    ProductTemp query = _productTempMgr.GetProTemp(new ProductTemp { Writer_Id = _caller.user_id, Combo_Type = COMBO_TYPE, Product_Id = product_id });


                    if (!specType.Equals("0") && !string.IsNullOrEmpty(specType))
                    {
                        #region 有規格
                        List<ProductSpecTemp> spec1List;
                        List<ProductSpecTemp> spec2List;
                        List<ProductSpecTemp> specAllList = new List<ProductSpecTemp>();

                        JavaScriptSerializer jss = new JavaScriptSerializer();
                        spec1List = jss.Deserialize<List<ProductSpecTemp>>(spec1Result);

                        foreach (ProductSpecTemp item in spec1List)
                        {
                            //   specid = _serialMgr.NextSerial(18);
                            //item.spec_id = uint.Parse(specid.ToString());
                            item.Writer_Id = _caller.user_id;
                            item.product_id = product_id;
                            item.spec_type = 1;
                            item.spec_image = "";
                            specAllList.Add(item);
                        }

                        if (specType.Equals("2"))
                        {
                            spec2Name = Request.Params["spec2Name"];
                            spec2Result = Request.Params["spec2Result"];
                            spec2List = jss.Deserialize<List<ProductSpecTemp>>(spec2Result);

                            foreach (ProductSpecTemp item in spec2List)
                            {
                                // specid = _serialMgr.NextSerial(18);
                                //item.spec_id = uint.Parse(specid.ToString());
                                item.Writer_Id = _caller.user_id;
                                item.product_id = product_id;
                                item.spec_type = 2;
                                item.spec_image = "";
                                specAllList.Add(item);
                            }
                        }

                        List<ProductSpecTemp> tempList = _specTempMgr.Query(new ProductSpecTemp { Writer_Id = _caller.user_id, product_id = product_id });
                        if (tempList == null || tempList.Count() <= 0)
                        {
                            #region 保存

                            specAllList.ForEach(p => p.spec_id = uint.Parse(_serialMgr.NextSerial(18).ToString()));

                            bool saveSpecResult = _specTempMgr.Save(specAllList);

                            if (saveSpecResult)
                            {
                                _productItemTempMgr.Delete(new ProductItemTemp { Writer_Id = _caller.user_id, Product_Id = product_id });
                                #region 保存ProductItemTemp

                                List<ProductSpecTemp> specAllResultList = _specTempMgr.Query(new ProductSpecTemp { Writer_Id = _caller.user_id, product_id = product_id });
                                List<ProductSpecTemp> spec1ResultList = specAllResultList.Where(m => m.spec_type == 1).ToList();
                                List<ProductSpecTemp> spec2ResultList = specAllResultList.Where(m => m.spec_type == 2).ToList();

                                List<ProductItemTemp> saveItemList = new List<ProductItemTemp>();

                                if (specType.Equals("1"))
                                {
                                    foreach (ProductSpecTemp specTemp1 in spec1ResultList)
                                    {
                                        ProductItemTemp itemTemp = new ProductItemTemp();
                                        itemTemp.Writer_Id = _caller.user_id;
                                        itemTemp.Product_Id = product_id;
                                        itemTemp.Spec_Id_1 = specTemp1.spec_id;
                                        //itemTemp.Item_Stock = 10;
                                        itemTemp.Item_Alarm = 1;
                                        saveItemList.Add(itemTemp);

                                    }
                                }
                                else if (specType.Equals("2"))
                                {
                                    foreach (ProductSpecTemp specTemp1 in spec1ResultList)
                                    {
                                        foreach (ProductSpecTemp specTemp2 in spec2ResultList)
                                        {
                                            ProductItemTemp itemTemp = new ProductItemTemp();
                                            itemTemp.Writer_Id = _caller.user_id;
                                            itemTemp.Product_Id = product_id;
                                            itemTemp.Spec_Id_1 = specTemp1.spec_id;
                                            itemTemp.Spec_Id_2 = specTemp2.spec_id;
                                            //itemTemp.Item_Stock = 10;
                                            itemTemp.Item_Alarm = 1;
                                            itemTemp.Item_Code = "";
                                            itemTemp.Barcode = "";
                                            saveItemList.Add(itemTemp);
                                        }
                                    }
                                }

                                //add by xiangwang 2014.09.26 可修改庫存預設值為99
                                //saveItemList.ForEach(m => m.SetDefaultItemStock(query));

                                bool saveItemResult = _productItemTempMgr.Save(saveItemList);

                                if (!saveItemResult)
                                {
                                    result = false;
                                }

                                #endregion

                            }
                            else
                            {
                                result = false;
                            }
                            #endregion
                        }
                        else
                        {
                            #region 更新
                            string strSpecInit = Request.Params["specInit"];
                            string[] specs = strSpecInit.Split(',');

                            List<ProductSpecTemp> addList = specAllList.Where(p => p.spec_id == 0).ToList();
                            if (addList.Count() > 0)
                            {
                                addList.ForEach(p => p.spec_id = uint.Parse(_serialMgr.NextSerial(18).ToString()));

                                List<ProductSpecTemp> specAllResultList = _specTempMgr.Query(new ProductSpecTemp { Writer_Id = _caller.user_id, product_id = product_id });
                                List<ProductSpecTemp> spec1ResultList = specAllResultList.Where(m => m.spec_type == 1).ToList();
                                List<ProductSpecTemp> spec2ResultList = specAllResultList.Where(m => m.spec_type == 2).ToList();
                                List<ProductItemTemp> saveItemList = new List<ProductItemTemp>();
                                foreach (ProductSpecTemp item in addList)
                                {
                                    if (specType.Equals("1"))
                                    {
                                        if (item.spec_type == 1)
                                        {
                                            ProductItemTemp saveTemp = new ProductItemTemp();
                                            saveTemp.Writer_Id = _caller.user_id;
                                            saveTemp.Spec_Id_1 = item.spec_id;
                                            saveTemp.Product_Id = product_id;
                                            //saveTemp.Item_Stock = 10;
                                            saveTemp.Item_Alarm = 1;
                                            saveItemList.Add(saveTemp);
                                        }
                                        else
                                        {
                                            ProductItemTemp saveTemp = new ProductItemTemp();
                                            saveTemp.Writer_Id = _caller.user_id;
                                            saveTemp.Spec_Id_2 = item.spec_id;
                                            saveTemp.Product_Id = product_id;
                                            // saveTemp.Item_Stock = 10;
                                            saveTemp.Item_Alarm = 1;
                                            saveItemList.Add(saveTemp);
                                        }
                                    }
                                    else
                                    {
                                        if (item.spec_type == 1)
                                        {
                                            foreach (ProductSpecTemp item1 in spec2ResultList)
                                            {
                                                ProductItemTemp saveTemp = new ProductItemTemp();
                                                saveTemp.Writer_Id = _caller.user_id;
                                                saveTemp.Spec_Id_1 = item.spec_id;
                                                saveTemp.Spec_Id_2 = item1.spec_id;
                                                //saveTemp.Item_Stock = 10;
                                                saveTemp.Item_Alarm = 1;
                                                saveTemp.Product_Id = product_id;
                                                saveItemList.Add(saveTemp);
                                            }

                                            foreach (ProductSpecTemp item1 in addList.Where(p => p.spec_type == 2).ToList())
                                            {
                                                ProductItemTemp saveTemp = new ProductItemTemp();
                                                saveTemp.Writer_Id = _caller.user_id;
                                                saveTemp.Spec_Id_1 = item.spec_id;
                                                saveTemp.Spec_Id_2 = item1.spec_id;
                                                //saveTemp.Item_Stock = 10;
                                                saveTemp.Item_Alarm = 1;
                                                saveTemp.Product_Id = product_id;
                                                saveItemList.Add(saveTemp);
                                            }
                                        }
                                        else
                                        {
                                            foreach (ProductSpecTemp item2 in spec1ResultList)
                                            {
                                                ProductItemTemp saveTemp = new ProductItemTemp();
                                                saveTemp.Writer_Id = _caller.user_id;
                                                saveTemp.Spec_Id_1 = item2.spec_id;
                                                saveTemp.Spec_Id_2 = item.spec_id;
                                                saveTemp.Product_Id = product_id;
                                                // saveTemp.Item_Stock = 10;
                                                saveTemp.Item_Alarm = 1;
                                                saveItemList.Add(saveTemp);
                                            }

                                        }
                                    }
                                }
                                _specTempMgr.Save(addList);

                                //add by xiangwang 2014.09.26 可修改庫存預設值為99
                                //saveItemList.ForEach(m => m.SetDefaultItemStock(query));

                                _productItemTempMgr.Save(saveItemList);

                            }

                            if (specs.Length > 0)
                            {
                                List<ProductSpecTemp> updateList = new List<ProductSpecTemp>();
                                foreach (string initSpecId in specs)
                                {
                                    ProductSpecTemp nowItem = specAllList.Where(p => p.spec_id == uint.Parse(initSpecId)).FirstOrDefault();
                                    if (nowItem != null)
                                    {
                                        updateList.Add(nowItem);
                                    }
                                    else
                                    {

                                        ProductItemTemp delTemp = new ProductItemTemp { Writer_Id = _caller.user_id, Product_Id = product_id };
                                        uint spectype = _specTempMgr.Query(new ProductSpecTemp { spec_id = uint.Parse(initSpecId), product_id = product_id })[0].spec_type;
                                        if (spectype == 1)
                                        {
                                            delTemp.Spec_Id_1 = uint.Parse(initSpecId);
                                        }
                                        else if (spectype == 2)
                                        {
                                            delTemp.Spec_Id_2 = uint.Parse(initSpecId);
                                        }
                                        if (!_productItemTempMgr.Delete(delTemp))
                                        {
                                            result = false;
                                        }
                                        if (!_specTempMgr.Delete(new ProductSpecTemp { spec_id = uint.Parse(initSpecId), Writer_Id = _caller.user_id, product_id = product_id }))
                                        {
                                            result = false;
                                        }
                                        DeletePicOnServer(false, true, false, uint.Parse(initSpecId), product_id);
                                    }

                                }
                                if (!_specTempMgr.Update(updateList, "spec"))
                                {
                                    result = false;
                                }
                            }

                            #endregion
                        }

                        #region 更新Product

                        ProductTemp proTemp = new ProductTemp();
                        proTemp.Writer_Id = _caller.user_id;
                        proTemp.Product_Spec = uint.Parse(specType);
                        proTemp.Spec_Title_1 = spec1Name;
                        proTemp.Spec_Title_2 = spec2Name;
                        proTemp.Combo_Type = COMBO_TYPE;
                        proTemp.Product_Id = product_id;
                        bool saveProductResult = _productTempMgr.SpecInfoSave(proTemp);
                        if (!saveProductResult)
                        {
                            result = false;
                        }
                        #endregion

                        #endregion
                    }
                    else
                    {
                        #region 無規格
                        List<ProductItemTemp> saveList = new List<ProductItemTemp>();
                        //如果原數據有規格
                        if (query.Product_Spec != 0)
                        {
                            //刪除服務器上對應的圖片
                            DeletePicOnServer(false, true, false, 0, product_id);

                            _productItemTempMgr.Delete(new ProductItemTemp { Writer_Id = _caller.user_id, Product_Id = product_id });

                            _specTempMgr.Delete(new ProductSpecTemp { Writer_Id = _caller.user_id, product_id = product_id });

                            _productTempMgr.SpecInfoSave(new ProductTemp { Product_Spec = 0, Spec_Title_1 = "", Spec_Title_2 = "", Writer_Id = _caller.user_id, Combo_Type = COMBO_TYPE, Product_Id = product_id });

                            saveList = new List<ProductItemTemp>();
                            saveList.Add(new ProductItemTemp { Writer_Id = _caller.user_id, Product_Id = product_id/*, Item_Stock = 10*/, Item_Alarm = 1 });
                        }
                        else
                        {
                            List<ProductItemTemp> itemQuery = _productItemTempMgr.Query(new ProductItemTemp { Writer_Id = _caller.user_id, Product_Id = product_id });
                            if (itemQuery.Count() <= 0)
                            {
                                saveList = new List<ProductItemTemp>();
                                saveList.Add(new ProductItemTemp { Writer_Id = _caller.user_id, Product_Id = product_id, /*Item_Stock = 10,*/ Item_Alarm = 1 });
                                // _productItemTempMgr.Save(saveList);
                            }
                        }

                        //add by xiangwang 2014.09.26 可修改庫存預設值為99
                        //saveList.ForEach(m => m.SetDefaultItemStock(query));
                        _productItemTempMgr.Save(saveList);

                        #endregion
                    }
                    #endregion

                    #region 調度或自出商品,商品庫存預設為99
                    var proditemTemp = new ProductItemTemp { Product_Id = product_id, Writer_Id = _caller.user_id };
                    proditemTemp.SetDefaultItemStock(query);
                    _productItemTempMgr.UpdateItemStock(proditemTemp);
                    #endregion
                }
            }
            catch (Exception ex)
            {
                result = false;
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
            }

            if (!result)
            {
                resultStr = "{success:false,Msg:false}";
            }

            this.Response.Clear();
            this.Response.Write(resultStr);
            this.Response.End();
            return this.Response;
        }
Esempio n. 5
0
        public ActionResult upLoadImg()
        {
            try
            {
                HttpPostedFileBase file = Request.Files["Filedata"];
                int type = Request["appOrexplain"] == null ? 0 : Convert.ToInt32(Request["appOrexplain"]);
                string nameType = Request.Params["nameType"];  // 將 nametype 提前 使其判斷傳入的圖片是否為商品主圖 edit by zhuoqin0830w 2015/01/29
                int prodCheck = file.FileName.LastIndexOf("prod_");  // 將 proCheck 提前 使其判斷批量上傳的圖片中是否存在商品主圖   edit by zhuoqin0830w 2015/01/30
                if (nameType == "spec")
                {
                    type = 5;
                }
                if (prodCheck == 0 && type == 0) //批量上傳時type才會 ==0,其他單獨上傳時是不需要根據prod處理圖片的
                {
                    type = 3;
                }
                int mobileCheck = file.FileName.LastIndexOf("mobile_");//批量上傳時type才會 ==0,其他單獨上傳時是不需要根據prod處理圖片的
                if (mobileCheck == 0 && type == 0)
                {
                    type = 4;
                }
                string path = Server.MapPath(xmlPath);
                siteConfigMgr = new SiteConfigMgr(path);
                SiteConfig extention_config = siteConfigMgr.GetConfigByName("PIC_Extention_Format");
                SiteConfig minValue_config = siteConfigMgr.GetConfigByName("PIC_Length_MinValue");
                SiteConfig maxValue_config = null;

                //判斷 批量上傳 或 單個上傳 的圖片是否為 商品主圖 或 手機商品圖  edit by zhuoqin0830w 2015/03/24
                switch (nameType)
                {
                    //如果  nameType == prod  則表示 是 單個上傳 商品主圖
                    case "prod":
                        maxValue_config = siteConfigMgr.GetConfigByName("PIC_280_Length_Max");
                        break;
                    //如果  nameType == mobile  則表示 是 單個上傳 手機商品圖 
                    case "mobile":
                        maxValue_config = siteConfigMgr.GetConfigByName("PIC_640_Length_Max");
                        break;
                    //如果  nameType == null  則表示 是 批量上傳
                    case null:
                        //如果  prodCheck == 0  則表示 是 批量上傳 中包含 商品主圖 
                        if (prodCheck == 0)
                        {
                            maxValue_config = siteConfigMgr.GetConfigByName("PIC_280_Length_Max");
                        }
                        //如果  mobileCheck == 0  則表示 是 批量上傳 中包含 手機商品圖 
                        else if (mobileCheck == 0)
                        {
                            maxValue_config = siteConfigMgr.GetConfigByName("PIC_640_Length_Max");
                        }
                        else
                        {
                            maxValue_config = siteConfigMgr.GetConfigByName("PIC_Length_MaxValue");
                        }
                        break;
                    default:
                        maxValue_config = siteConfigMgr.GetConfigByName("PIC_Length_MaxValue");
                        break;
                }

                string extention = extention_config.Value == "" ? extention_config.DefaultValue : extention_config.Value;
                string minValue = minValue_config.Value == "" ? minValue_config.DefaultValue : minValue_config.Value;
                string maxValue = maxValue_config.Value == "" ? maxValue_config.DefaultValue : maxValue_config.Value;


                if ((nameType == "mobile" && type == 4) || (mobileCheck == 0 && type == 4)) //add by wwei0216w 2015/4/1 添加原因:手機圖片要放在640*640路徑下
                {
                    prodPath = prodMobile640;
                }
                string localProdPath = imgLocalPath + prodPath;

                //string localProd50Path = imgLocalPath + prod50Path;
                //string localProd150Path = imgLocalPath + prod150Path;
                //string localProd280Path = imgLocalPath + prod280Path;

                string localSpecPath = imgLocalPath + specPath;
                //string localSpec100Path = imgLocalPath + spec100Path;
                //string localSpec280Path = imgLocalPath + spec280Path;

                string[] Mappath = new string[2];

                FileManagement fileLoad = new FileManagement();

                string fileName = string.Empty;
                string fileExtention = string.Empty;
                ViewBag.spec_id = -1;
                if (nameType != null)
                {
                    fileName = nameType + fileLoad.NewFileName(file.FileName);
                    fileName = fileName.Substring(0, fileName.LastIndexOf("."));
                    fileExtention = file.FileName.Substring(file.FileName.LastIndexOf('.')).ToLower();

                }
                else
                {
                    #region 批次上傳圖片操作
                    //此處由批次上傳進入.
                    //判斷文件名格式是否正確
                    ViewBag.moreFileOneTime = true;
                    //int prodCheck = file.FileName.LastIndexOf("prod_");
                    int specCheck = file.FileName.LastIndexOf("spec_");
                    int descCheck = file.FileName.LastIndexOf("desc_");
                    int appCheck = file.FileName.LastIndexOf("app_");
                    string errorMsg = "ERROR/";
                    if (prodCheck == -1 && specCheck == -1 && descCheck == -1 && appCheck == -1 && mobileCheck == -1)
                    {
                        errorMsg += "[" + file.FileName + "] ";
                        errorMsg += Resources.Product.FILE_NAME_ERROR;
                        ViewBag.fileName = errorMsg;
                        return View("~/Views/Product/upLoad.cshtml");
                    }
                    else
                    {
                        nameType = file.FileName.Split('_')[0];
                        if (nameType == "app")
                        {
                            type = 2;
                        }
                        else if (nameType == "desc")
                        {
                            type = 1;
                        }
                        else if (nameType == "spec")
                        {
                            type = 5;
                        }
                        fileName = nameType + fileLoad.NewFileName(file.FileName);
                        fileName = fileName.Substring(0, fileName.LastIndexOf("."));
                        fileExtention = file.FileName.Substring(file.FileName.LastIndexOf('.'));
                    }
                    if (specCheck == 0)
                    {
                        Caller _caller = (Session["caller"] as Caller);
                        string spec = file.FileName.Split('_')[1].Split('.')[0];
                        bool checkStatus = true;
                        if (!string.IsNullOrEmpty(Request.Params["product_id"].Split(';')[0].ToString()))
                        {
                            //product_spec
                            uint pid = uint.Parse(Request.Params["product_id"].Split(';')[0].ToString());

                            _specMgr = new ProductSpecMgr(connectionString);
                            List<ProductSpec> pSpecList = _specMgr.Query(new ProductSpec { product_id = pid, spec_type = 1 });
                            foreach (var item in pSpecList)
                            {
                                if (item.spec_name == spec)
                                {
                                    checkStatus = false;
                                    ViewBag.spec_id = item.spec_id;
                                }
                            }
                        }
                        else
                        {
                            //product_spec_temp
                            _specTempMgr = new ProductSpecTempMgr(connectionString);
                            List<ProductSpecTemp> pSpecTempList = _specTempMgr.Query(new ProductSpecTemp { Writer_Id = _caller.user_id, spec_type = 1 });
                            foreach (var item in pSpecTempList)
                            {
                                if (item.spec_name == spec)
                                {
                                    checkStatus = false;
                                    ViewBag.spec_id = item.spec_id;
                                }
                            }
                        }
                        if (checkStatus)//表示沒有要上傳圖片規格相同的規格一
                        {
                            errorMsg += "[" + file.FileName + "] " + Resources.Product.SPEC_NOT_FIND;
                            ViewBag.fileName = errorMsg;
                            return View("~/Views/Product/upLoad.cshtml");
                        }
                    }
                    #endregion
                }
                SetPath(type);//設定圖片路徑
                string localDescPath = imgLocalPath + descPath;
                //string localDesc400Path = imgLocalPath + desc400Path;
                string returnName = imgServerPath;

                bool result = false;
                string NewFileName = string.Empty;


                BLL.gigade.Common.HashEncrypt hash = new BLL.gigade.Common.HashEncrypt();
                NewFileName = hash.Md5Encrypt(fileName, "32");

                string firstFolder = NewFileName.Substring(0, 2) + "/";
                string secondFolder = NewFileName.Substring(2, 2) + "/";
                string ServerPath = string.Empty;

                if (nameType == "spec")
                {
                    Mappath[0] = firstFolder;
                    Mappath[1] = secondFolder;

                    CreateFolder(localSpecPath, Mappath);
                    //CreateFolder(localSpec100Path, Mappath);
                    //CreateFolder(localSpec280Path, Mappath);

                    localSpecPath += firstFolder + secondFolder;
                    //localSpec100Path += firstFolder + secondFolder;
                    //localSpec280Path += firstFolder + secondFolder;
                    specPath += firstFolder + secondFolder;

                    returnName += specPath + NewFileName + fileExtention;
                    //localSpec100Path += NewFileName + fileExtention;
                    //localSpec280Path += NewFileName + fileExtention;
                    NewFileName = localSpecPath + NewFileName + fileExtention;
                    ServerPath = Server.MapPath(imgLocalServerPath + specPath);

                }
                else if (nameType == "desc" || nameType == "app")
                {

                    Mappath[0] = firstFolder;
                    Mappath[1] = secondFolder;

                    CreateFolder(localDescPath, Mappath);
                    //CreateFolder(localDesc400Path, Mappath);

                    localDescPath += firstFolder + secondFolder;

                    //localDesc400Path += firstFolder + secondFolder;
                    descPath += firstFolder + secondFolder;

                    //localDesc400Path += NewFileName + fileExtention;
                    returnName += descPath + NewFileName + fileExtention;


                    NewFileName = localDescPath + NewFileName + fileExtention;

                    ServerPath = Server.MapPath(imgLocalServerPath + descPath);
                }
                else
                {
                    Mappath[0] = firstFolder;
                    Mappath[1] = secondFolder;
                    //Data:2014/06/26
                    //author:Castle
                    //在前台如果各种尺寸的图档没有的时候,前台会自动产生!!!
                    CreateFolder(localProdPath, Mappath);
                    //CreateFolder(localProd50Path, Mappath);
                    //CreateFolder(localProd150Path, Mappath);
                    //CreateFolder(localProd280Path, Mappath);

                    localProdPath += firstFolder + secondFolder;
                    //localProd50Path += firstFolder + secondFolder;
                    //localProd150Path += firstFolder + secondFolder;
                    //localProd280Path += firstFolder + secondFolder;
                    prodPath += firstFolder + secondFolder;

                    //localProd50Path += NewFileName + fileExtention;
                    //localProd150Path += NewFileName + fileExtention;
                    //localProd280Path += NewFileName + fileExtention;
                    returnName += prodPath + NewFileName + fileExtention;
                    NewFileName = localProdPath + NewFileName + fileExtention;
                    ServerPath = Server.MapPath(imgLocalServerPath + prodPath);
                }
                string ErrorMsg = string.Empty;
                Resource.CoreMessage = new CoreResource("Product");

                //上傳圖片

                result = fileLoad.UpLoadFile(file, ServerPath, NewFileName, extention, int.Parse(maxValue), int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd);
                #region //
                //上傳對應大小圖片
                //压缩图片至其它规格

                //Data:2014/06/26
                //author:Castle
                //在前台如果各种尺寸的图档没有的时候,前台会自动产生!!!
                //if (result)
                //{
                //    FTP ftp = null;
                //    string newFileName = NewFileName.Substring(NewFileName.LastIndexOf("/"));

                //    GigadeService.TransImageClient transImg = new GigadeService.TransImageClient();
                //    if (nameType == "spec")
                //    {
                //        string sourceImgPath = Server.MapPath(imgLocalServerPath + specPath + NewFileName.Substring(NewFileName.LastIndexOf("/")));
                //        ErrorMsg = transImg.Trans(sourceImgPath, Server.MapPath(imgLocalServerPath + spec100Path + firstFolder + secondFolder), newFileName, 100, 100, admin_userName.Value, admin_passwd.Value);
                //        if (string.IsNullOrWhiteSpace(ErrorMsg))
                //        {
                //            file.SaveAs(Server.MapPath(imgLocalServerPath + spec100Path + firstFolder + secondFolder + newFileName));
                //            ftp = new FTP(localSpec100Path, ftpuser, ftppwd);
                //            ftp.UploadFile(Server.MapPath(imgLocalServerPath + spec100Path + firstFolder + secondFolder + newFileName));
                //        }

                //        if (!Directory.Exists(Server.MapPath(imgLocalServerPath + spec280Path + firstFolder + secondFolder)))
                //            Directory.CreateDirectory(Server.MapPath(imgLocalServerPath + spec280Path + firstFolder + secondFolder));
                //        ErrorMsg = transImg.Trans(sourceImgPath, Server.MapPath(imgLocalServerPath + spec280Path + firstFolder + secondFolder), newFileName, 280, 280, admin_userName.Value, admin_passwd.Value);
                //        if (string.IsNullOrWhiteSpace(ErrorMsg))
                //        {
                //            file.SaveAs(Server.MapPath(imgLocalServerPath + spec280Path + firstFolder + secondFolder + newFileName));
                //            ftp = new FTP(localSpec100Path, ftpuser, ftppwd);
                //            ftp.UploadFile(Server.MapPath(imgLocalServerPath + spec280Path + firstFolder + secondFolder + newFileName));
                //        }
                //    }
                //    else if (nameType == "desc")
                //    {
                //        string sourceImgPath = Server.MapPath(imgLocalServerPath + descPath + NewFileName.Substring(NewFileName.LastIndexOf("/")));
                //        ErrorMsg = transImg.Trans(sourceImgPath, Server.MapPath(imgLocalServerPath + desc400Path + firstFolder + secondFolder), newFileName, 400, 400, admin_userName.Value, admin_passwd.Value);
                //        if (string.IsNullOrWhiteSpace(ErrorMsg))
                //        {
                //            file.SaveAs(Server.MapPath(imgLocalServerPath + desc400Path + firstFolder + secondFolder + newFileName));
                //            ftp = new FTP(localSpec100Path, ftpuser, ftppwd);
                //            ftp.UploadFile(Server.MapPath(imgLocalServerPath + desc400Path + firstFolder + secondFolder + newFileName));
                //        }
                //    }
                //    else
                //    {
                //        //string sourceImgPath = Server.MapPath(imgLocalServerPath + prodPath + NewFileName.Substring(NewFileName.LastIndexOf("/")));
                //        //ErrorMsg = transImg.Trans(sourceImgPath, Server.MapPath(imgLocalServerPath + prod50Path + firstFolder + secondFolder), newFileName, 50, 50, admin_userName.Value, admin_passwd.Value);
                //        //if (string.IsNullOrWhiteSpace(ErrorMsg))
                //        //{
                //        //    file.SaveAs(Server.MapPath(imgLocalServerPath + prod50Path + firstFolder + secondFolder + newFileName));
                //        //    ftp = new FTP(localProd50Path, ftpuser, ftppwd);
                //        //    ftp.UploadFile(Server.MapPath(imgLocalServerPath + prod50Path + firstFolder + secondFolder + newFileName));
                //        //}

                //        //ErrorMsg = transImg.Trans(sourceImgPath, Server.MapPath(imgLocalServerPath + prod150Path + firstFolder + secondFolder), newFileName, 150, 150, admin_userName.Value, admin_passwd.Value);
                //        //if (string.IsNullOrWhiteSpace(ErrorMsg))
                //        //{
                //        //    file.SaveAs(Server.MapPath(imgLocalServerPath + prod150Path + firstFolder + secondFolder + newFileName));
                //        //    ftp = new FTP(localProd150Path, ftpuser, ftppwd);
                //        //    ftp.UploadFile(Server.MapPath(imgLocalServerPath + prod150Path + firstFolder + secondFolder + newFileName));
                //        //}

                //        ////if (!Directory.Exists(Server.MapPath(imgLocalServerPath + prod280Path + firstFolder + secondFolder)))
                //        ////    Directory.CreateDirectory(Server.MapPath(imgLocalServerPath + prod280Path + firstFolder + secondFolder));
                //        ////ImageClass iC280 = new ImageClass(sourceImgPath);
                //        //////iC280.ImageMagick(sourceImgPath, Server.MapPath(imgLocalServerPath + prod280Path + firstFolder + secondFolder + NewFileName.Substring(NewFileName.LastIndexOf("/"))), 280, 280, ref error);
                //        ////iC150.MakeThumbnail(Server.MapPath(imgLocalServerPath + prod280Path + firstFolder + secondFolder + NewFileName.Substring(NewFileName.LastIndexOf("/"))), 280, 280, ref error);
                //        //ErrorMsg = transImg.Trans(sourceImgPath, Server.MapPath(imgLocalServerPath + prod280Path + firstFolder + secondFolder), newFileName, 280, 280, admin_userName.Value, admin_passwd.Value);
                //        //if (string.IsNullOrWhiteSpace(ErrorMsg))
                //        //{
                //        //    file.SaveAs(Server.MapPath(imgLocalServerPath + prod280Path + firstFolder + secondFolder + newFileName));
                //        //    ftp = new FTP(localProd280Path, ftpuser, ftppwd);
                //        //    ftp.UploadFile(Server.MapPath(imgLocalServerPath + prod280Path + firstFolder + secondFolder + newFileName));
                //        //}
                //    }
                //}
                #endregion
                if (string.IsNullOrEmpty(ErrorMsg))
                {
                    ViewBag.fileName = returnName;
                    ViewBag.Type = type;

                    //獲取文件長度 add by zhuoqin0830w 2015/01/29
                    string[] strFile = file.FileName.Split('_');
                    //判斷文件名的長度是否大於 1 如果大於 1 則再次進行判斷是否為數字 如果不是則進行強制轉換  
                    int image_sort = 0;
                    int.TryParse(strFile.Length > 1 ? strFile[1] : "0", out image_sort);
                    ViewBag.image_sort = image_sort;
                }
                else
                {
                    // 判斷 批量上傳中 是否存在 商品圖 或 手機商品圖  edit by zhuoqin0830w 2015/03/24
                    if (prodCheck == 0 || mobileCheck == 0)
                    { ViewBag.fileName = "ERROR/" + "[" + file.FileName + "] " + ErrorMsg; }
                    else { ViewBag.fileName = "ERROR/" + "[" + file.FileName + "] " + ErrorMsg; }

                    Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                    logMessage.Content = "ERROR/" + ErrorMsg;
                    logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                    log.Error(logMessage);
                }
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
            }

            return View("~/Views/Product/upLoad.cshtml");
        }
        /// <summary>
        /// 從product_temp product_spec_temp 和product_picture中獲取圖片路徑 刪除服務器上面的圖片
        /// </summary>
        /// <param name="prod">是否獲取product_temp圖片路徑數據</param>
        /// <param name="spec">是否獲取product_spec_temp圖片路徑數據</param>
        /// <param name="desc">是否獲取product_picture_temp圖片路徑數據</param>
        /// <param name="product_id">商品id</param>
        public void DeletePicOnServer(bool prod, bool spec, bool desc, string product_id)
        {
            BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"];
            int write_Id = Convert.ToInt32(vendorModel.vendor_id);

            _productTempMgr = new ProductTempMgr(connectionString);
            _specTempMgr = new ProductSpecTempMgr(connectionString);
            _pPicTempMgr = new ProductPictureTempImplMgr(connectionString);
            ArrayList ImgList = new ArrayList();

            ProductSpecTemp pSpec = new ProductSpecTemp();
            pSpec.Writer_Id = write_Id;
            pSpec.product_id = product_id;
            pSpec.spec_type = 1;

            //刪除對應的圖片
            //商品圖
            if (prod)
            {
                ProductTemp query = new ProductTemp { Writer_Id = write_Id, Combo_Type = COMBO_TYPE, Product_Id = product_id, Create_Channel = 2 };
                string fileName = _productTempMgr.GetProTempByVendor(query).FirstOrDefault().Product_Image;
                if (!string.IsNullOrEmpty(fileName))
                {
                    ImgList.Add(imgLocalPath + prodPath + GetDetailFolder(fileName) + fileName);
                    ImgList.Add(imgLocalPath + prod50Path + GetDetailFolder(fileName) + fileName);
                    ImgList.Add(imgLocalPath + prod150Path + GetDetailFolder(fileName) + fileName);
                    ImgList.Add(imgLocalPath + prod280Path + GetDetailFolder(fileName) + fileName);
                }

            }
            //規格圖
            if (spec)
            {
                List<ProductSpecTemp> pSList = _specTempMgr.Query(pSpec);
                foreach (var item in pSList)
                {
                    if (item.spec_image != "")
                    {
                        ImgList.Add(imgLocalPath + specPath + GetDetailFolder(item.spec_image) + item.spec_image);
                        ImgList.Add(imgLocalPath + spec100Path + GetDetailFolder(item.spec_image) + item.spec_image);
                        ImgList.Add(imgLocalPath + spec280Path + GetDetailFolder(item.spec_image) + item.spec_image);
                    }
                }
            }
            //商品說明圖
            if (desc)
            {
                ProductPictureTemp query = new ProductPictureTemp { writer_Id = write_Id, combo_type = COMBO_TYPE, product_id = product_id };
                List<ProductPictureTemp> pPList = _pPicTempMgr.Query(query);
                foreach (var item in pPList)
                {
                    ImgList.Add(imgLocalPath + descPath + GetDetailFolder(item.image_filename) + item.image_filename);
                    ImgList.Add(imgLocalPath + desc400Path + GetDetailFolder(item.image_filename) + item.image_filename);
                }
            }

            foreach (string item in ImgList)
            {
                //刪除服務器上對應的圖片
                if (System.IO.File.Exists(item))
                {
                    System.IO.File.Delete(item);
                }
            }
        }
        public string QuerySpecPic()
        {
            _specTempMgr = new ProductSpecTempMgr(connectionString);
            _specMgr = new ProductSpecMgr(connectionString);

            string json = string.Empty;

            BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"];


            //查找臨時表記錄
            ProductSpecTemp psTemp = new ProductSpecTemp();
            psTemp.Writer_Id = Convert.ToInt32(vendorModel.vendor_id);
            psTemp.spec_type = 1;
            //string str = "{success:true,items:"+JsonConvert.+"}";
            List<ProductSpecTemp> results = _specTempMgr.Query(psTemp); //JsonConvert.SerializeObject();
            foreach (var item in results)
            {
                if (item.spec_image != "")
                {
                    item.spec_image = imgServerPath + specPath + GetDetailFolder(item.spec_image) + item.spec_image;
                }

            }
            json = "{success:true,items:" + JsonConvert.SerializeObject(results) + "}";
            json = json.Replace("spec_image", "img");
            return json;
        }