Beispiel #1
0
        /// <summary>
        /// 操作商品細項
        /// </summary>
        /// <param name="pe">需要操作的商品條件</param>
        /// <returns>操作是否成功</returns>
        public bool UpdateProductExt(List<ProductExtCustom> lists , Caller _caller,string controlId)
        {
            bool flag = true;
            IFunctionImplMgr _functionMgr = new FunctionMgr(conStr); //用於找到控件的function信息
            ITableHistoryImplMgr _tableHistoryMgr; //用於歷史記錄保存的類
            IProductExtImplMgr _productExtMgr = new ProductExtMgr(conStr);
            try
            {
                Function fun = _functionMgr.QueryFunction(controlId, "/ProductParticulars/Index");
                ArrayList aList = new ArrayList();
                _tableHistoryMgr = new TableHistoryMgr(conStr);//實例化歷史記錄的類
                HistoryBatch batch = new HistoryBatch { functionid = fun.RowId };
                Int64 n_Time = CommonFunction.GetPHPTime();
                batch.kuser = _caller.user_email;
                foreach (ProductExtCustom item in lists)
                {
                    aList.Add(pei.UpdateProductExt(item));
                    batch.batchno = n_Time + "_" + "2" + "_" + item.Product_id;//add by wwei0216w 2015/7/6 註:將item_id改為product_id 統一使用product_id查詢
                    flag = _tableHistoryMgr.SaveHistory<ProductExtCustom>(item, batch, aList);
                    if(flag == false)
                    {
                        throw new Exception("ProductExtMgr-->UpdateProductExt Exception!" );
                    }
                }

                return flag;
            }
            catch (Exception ex)
            {
                throw new Exception("ProductExtMgr-->UpdateProductExt-->" + ex.Message, ex);
            }
        }
 /// <summary>
 /// 匯出功能
 /// </summary>
 public ActionResult OutToExcel(int rowId = 0, string functionName = "")
 {
     try
     {
         IFunctionImplMgr _funMgr = new FunctionMgr(connectionString);
         Function fun = new Function { RowId = rowId };
         MemoryStream ms = _funMgr.ExcelOut(fun, functionName);
         if (ms == null)
         {
             return new EmptyResult();
         }
         return File(ms.ToArray(), "application/-excel", "權限人員名單_" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".xls");
     }
     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 Json(new { success = false });
     }
 }