Beispiel #1
0
 public int IlocInsert(Model.Iloc loc)
 {
     StringBuilder sb = new StringBuilder();
     try
     {
         HashEncrypt hashpt=new HashEncrypt();
         sb.AppendFormat(@"insert into iloc(dc_id,whse_id,loc_id,llts_id,bkfill_loc,ldes_id,
         ldim_id,x_coord,y_coord,z_coord,bkfill_x_coord,bkfill_y_coord,
         bkfill_z_coord,lsta_id,sel_stk_pos,sel_seq_loc,sel_pos_hgt,rsv_stk_pos,
         rsv_pos_hgt,stk_lmt,stk_pos_wid,lev,lhnd_id,ldsp_id,
         create_user,create_dtim,comingle_allow,change_user,change_dtim,lcat_id,
         space_remain,max_loc_wgt,loc_status,stk_pos_dep,hash_loc_id
         ) values ('{0}','{1}','{2}','{3}','{4}','{5}',
         '{6}','{7}','{8}','{9}','{10}','{11}',
         '{12}','{13}','{14}','{15}','{16}','{17}',
         '{18}','{19}','{20}','{21}','{22}','{23}',
         '{24}','{25}','{26}','{27}','{28}','{29}',
         '{30}','{31}','{32}','{33}','{34}')",
         loc.dc_id, loc.whse_id, loc.loc_id, loc.llts_id, loc.bkfill_loc, loc.ldes_id,
         loc.ldim_id, loc.x_coord, loc.y_coord, loc.z_coord, loc.bkfill_x_coord, loc.bkfill_y_coord,
         loc.bkfill_z_coord, loc.lsta_id, loc.sel_stk_pos, loc.sel_seq_loc, loc.sel_pos_hgt, loc.rsv_stk_pos,
         loc.rsv_pos_hgt, loc.stk_lmt, loc.stk_pos_wid, loc.lev, loc.lhnd_id, loc.ldsp_id,
         loc.create_user, Common.CommonFunction.DateTimeToString(loc.create_dtim), loc.comingle_allow, loc.change_user, Common.CommonFunction.DateTimeToString(loc.change_dtim), loc.lcat_id,
         loc.space_remain, loc.max_loc_wgt, loc.loc_status, loc.stk_pos_dep, hashpt.Md5Encrypt(loc.loc_id, "16")
         );
         return _access.execCommand(sb.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("IlocDao-->IlocInsert-->" + ex.Message + sb.ToString(), ex);
     }
 }
Beispiel #2
0
        public ActionResult Index()
        {
            HttpCookie cookies = Request.Cookies["vendor"];
            if (cookies != null)
            {
                ViewBag.LoginEmail = cookies["email"];
            }
            else
            {
                ViewBag.LoginEmail = null;
            }

            if (Session["vendor"] != null)
            {
                return RedirectToAction("", "home");
            }
            else
            {
                string vendorid = Request.QueryString["vendor_id"];
                string key = Request.QueryString["key"];
                string keysec = string.Empty;
                if (!string.IsNullOrEmpty(vendorid) && !string.IsNullOrEmpty(key))
                {
                    int vendor_id = Convert.ToInt32(vendorid);
                    _vendorImp = new VendorMgr(connectionString);
                    string str = _vendorImp.GetLoginId(vendor_id);
                    HashEncrypt hmd5 = new HashEncrypt();
                    string mdlogin_id = hmd5.Md5Encrypt(str, "MD5");
                    keysec = hmd5.Md5Encrypt(mdlogin_id + str, "MD5");
                    if (key.ToString().Trim() != keysec.ToString().Trim())
                    {
                        return View();
                    }
                    else
                    {
                        BLL.gigade.Model.Vendor vendor = new BLL.gigade.Model.Vendor();
                        BLL.gigade.Model.Vendor ven = new BLL.gigade.Model.Vendor();
                        vendor.vendor_id = Convert.ToUInt32(vendorid);
                        _vendorImp = new VendorMgr(connectionString);
                        ven = _vendorImp.GetSingle(vendor);
                        ven.vendor_password = "";
                        Session["vendor"] = ven;
                        Session["lgnName"] = ven.vendor_name_simple;
                        return RedirectToAction("", "home");
                    }
                }
                else
                {
                    return View();
                }

            }
        }
Beispiel #3
0
        /// <summary>
        /// 上傳圖片
        /// </summary>
        /// <returns></returns>
        public ActionResult SaveCourseImg()
        {
            string xmlPath = ConfigurationManager.AppSettings["SiteConfig"];
            try
            {
                ViewBag.status = false;
                string path = Server.MapPath(xmlPath); ///<add key="SiteConfig" value="/Config.xml"/>
                ISiteConfigImplMgr siteConfigMgr;
                siteConfigMgr = new SiteConfigMgr(path);
                SiteConfig extention_config = siteConfigMgr.GetConfigByName("PIC_Extention_Format");
                SiteConfig minValue_config = siteConfigMgr.GetConfigByName("PIC_Length_MinValue");
                SiteConfig maxValue_config = siteConfigMgr.GetConfigByName("PIC_640_Length_Max");
                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;
                HttpPostedFileBase file = Request.Files["Filedata"];
                //int courseCheck = file.FileName.LastIndexOf("course_");
                string nameType = "course";
                string imgServerPath = Unitle.GetImgGigade100ComSitePath(Unitle.ImgPathType.server);
                string coursePath = Unitle.GetImgGigade100ComPath(Unitle.ImgGigade100ComType.coursePath);
                string imgLocalPath = Unitle.GetImgGigade100ComSitePath(Unitle.ImgPathType.local);//<add key="imglocalpath" value=" ftp://192.168.18.166:2121/img"/> FTP路徑
                string coursePicturePath = imgLocalPath + coursePath;//課程圖片保存路徑
                string imgLocalServerPath = ConfigurationManager.AppSettings["imgLocalServerPath"];
                string[] Mappath = new string[2];
                FileManagement fileLoad = new FileManagement();
                string fileName = string.Empty;
                string fileExtention = string.Empty;
                ViewBag.moreFileOneTime = true;//圖片狀態判斷
                int courseNameCheck = file.FileName.LastIndexOf("course_");//獲取圖片前綴名稱
                string errorMsg = "ERROR/";
                //if (courseNameCheck==-1)
                //{
                //    errorMsg += "[" + file.FileName + "] ";
                //    errorMsg += Resources.Product.FILE_NAME_ERROR;
                //    ViewBag.fileName = errorMsg;
                //    //return View("~/Views/Product/upLoad.cshtml");
                //    return View("~/Views/Course/upLoad.cshtml");
                //}

                fileName = nameType + fileLoad.NewFileName(file.FileName);
                fileName = fileName.Substring(0, fileName.LastIndexOf("."));
                fileExtention = file.FileName.Substring(file.FileName.LastIndexOf('.'));


                string NewFileName = string.Empty;
                string returnName = imgServerPath;
                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 == "course")
                {
                    Mappath[0] = firstFolder;
                    Mappath[1] = secondFolder;
                    CreateFolder(coursePicturePath, Mappath);
                    coursePicturePath += firstFolder + secondFolder;

                    coursePath += firstFolder + secondFolder;

                    returnName += coursePath + NewFileName + fileExtention;

                    NewFileName = coursePicturePath + NewFileName + fileExtention;
                    ServerPath = Server.MapPath(imgLocalServerPath + coursePath);

                }
                string ErrorMsg = string.Empty;
                Resource.CoreMessage = new CoreResource("Product");

                //上傳圖片
                bool result = false;
                result = fileLoad.UpLoadFile(file, ServerPath, NewFileName, extention, int.Parse(maxValue), int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd);
               
                if (string.IsNullOrEmpty(ErrorMsg))
                {
                    ViewBag.fileName = returnName;
                    ViewBag.Type = nameType;
                    ViewBag.status = true;
                    //獲取文件長度 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
                { 
                    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/Course/upLoad.cshtml");
        }
Beispiel #4
0
        public HttpResponseBase GetUploadArchives()
        {
            string json = string.Empty;

            try
            {
                #region 上傳

                string ErrorMsg = string.Empty;
                string path = Server.MapPath(xmlPath);
                SiteConfigMgr _siteConfigMgr = new SiteConfigMgr(path);
                SiteConfig extention_config = _siteConfigMgr.GetConfigByName("PIC_Extention_Format");
                SiteConfig admin_userName = _siteConfigMgr.GetConfigByName("ADMIN_USERNAME");
                SiteConfig admin_passwd = _siteConfigMgr.GetConfigByName("ADMIN_PASSWD");
                //擴展名、最小值、最大值
                string extention = extention_config.Value == "" ? extention_config.DefaultValue : extention_config.Value;
                string fileName = string.Empty;//當前文件名

                _ITicketDetail = new TicketDetailMgr(mySqlConnectionString);
                FileManagement fileLoad = new FileManagement();
                if (Request.Files.Count > 0)
                {
                    HttpPostedFileBase file = Request.Files[0];

                    string fileExtention = string.Empty;//當前文件的擴展名
                    string oldFileName = file.FileName.Substring(0, file.FileName.LastIndexOf('.'));
                    fileName = fileLoad.NewFileName(file.FileName);

                    if (fileName != "")
                    {
                        string filepathday = fileName.Substring(0, fileName.LastIndexOf("."));//每天建立一個文件夾保存村的文件;

                        fileName = oldFileName + "_" + filepathday;//上傳文檔為以前的名字+年月日時分秒.後綴名
                        filepathday = filepathday.Substring(0, 8);
                        fileExtention = file.FileName.Substring(file.FileName.LastIndexOf('.')).ToLower().ToString();
                        // string NewFileName = string.Empty;

                        BLL.gigade.Common.HashEncrypt hash = new BLL.gigade.Common.HashEncrypt();
                        // NewFileName = hash.Md5Encrypt(fileName, "32");
                        string ServerPath = string.Empty;
                        FTP f_cf = new FTP();
                        archives = archives + filepathday + "/";//創建多層路徑
                        string localPromoPath = imgLocalPath + archives;//圖片存儲地址
                        f_cf.MakeMultiDirectory(localPromoPath.Substring(0, localPromoPath.Length - archives.Length + 1), archives.Substring(1, archives.Length - 2).Split('/'), ftpuser, ftppwd);
                        // fileName = NewFileName + fileExtention;
                        fileName = localPromoPath + fileName + fileExtention;//絕對路徑
                        ServerPath = Server.MapPath(imgLocalServerPath + archives);

                        Resource.CoreMessage = new CoreResource("Product");//尋找product.resx中的資源文件
                        bool result = _ITicketDetail.UpLoadFile(file, ServerPath, fileName, extention, (int.MaxValue / 1024) - 1, 0, ref ErrorMsg, ftpuser, ftppwd);
                        if (result)
                        {
                            json = "{\"success\":\"true\"}";
                        }
                        else
                        {
                            json = "{\"success\":\"false\",\"msg\":\"上傳失败\"}";

                        }

                    }

                }
                #endregion

            }
            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);
                json = "{\"success\":\"false\",\"msg\":\"參數出錯\"}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
        public HttpResponseBase GetOrderDetailList()
        {
            List<OrderDetailQuery> stores = new List<OrderDetailQuery>();
            string json = string.Empty;
            try
            {
                OrderDetailQuery query = new OrderDetailQuery();
                query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量
                query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量
                //付款單號
                query.Order_Id = Convert.ToUInt32(Request.Params["OrderId"].ToString());
                query.isChildItem = 0;
                _orderDetailMgr = new OrderDetailMgr(mySqlConnectionString);
                int totalCount = 0;
                stores = _orderDetailMgr.GetOrderDetailList(query, out totalCount);

                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                //listUser是准备转换的对象
                //獲取供應商後臺登陸的vendorMd5加密
                _vendorImp = new VendorMgr(mySqlConnectionString);
                foreach (OrderDetailQuery item in stores)
                {
                    string str = _vendorImp.GetLoginId(Convert.ToInt32(item.Vendor_Id));
                    if (str != "")
                    {
                        HashEncrypt hmd5 = new HashEncrypt();
                        string mdlogin_id = hmd5.Md5Encrypt(str, "MD5");
                        item.VendorMd5 = hmd5.Md5Encrypt(mdlogin_id + str, "MD5");
                    }                 
                    if (item.item_mode == 2)
                    {
                        item.subtotal = (item.Single_Money * item.parent_num)-uint.Parse(item.Deduct_Happygo_Money.ToString())-item.Deduct_Welfare-item.Deduct_Bonus;
                    }
                    else
                    {
                        item.subtotal = (item.Single_Money * item.Buy_Num) -uint.Parse( item.Deduct_Happygo_Money.ToString()) - item.Deduct_Welfare - item.Deduct_Bonus;
                    }
                }
                json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(stores, Formatting.Indented, timeConverter) + "}";//返回json數據
            }
            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);
                json = "{success:true,totalCount:0,data:[]}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
        public void InsertIntoPromoShareCon(PromoShareCondition query)
        {
            List<PromoShareCondition> list = new List<PromoShareCondition>();
            PshareConMgr = new PromoShareConditionMgr(mySqlConnectionString);
            string json = string.Empty;
             DataTable _dt=new DataTable();
            try
            {
                for (int i = 0; i < condition.Length; i++)
                {
                    if (!string.IsNullOrEmpty(Request.Params[condition[i]]))
                    {
                        query = new PromoShareConditionQuery();
                        query.promo_id = Convert.ToInt32(Request.Params["promo_id"]);
                        query.condition_name = condition[i];
                        query.condition_value = Request.Params[ condition[i]];
                        if (query.condition_name == "picture")
                        {
                            #region 上傳圖片
                            string ErrorMsg = string.Empty;
                            string path = Server.MapPath(xmlPath);
                            SiteConfigMgr _siteConfigMgr = new SiteConfigMgr(path);
                            SiteConfig extention_config = _siteConfigMgr.GetConfigByName("PIC_Extention_Format");
                            SiteConfig minValue_config = _siteConfigMgr.GetConfigByName("PIC_Length_Min_Element");
                            SiteConfig maxValue_config = _siteConfigMgr.GetConfigByName("PIC_Length_MaxValue");
                            SiteConfig admin_userName = _siteConfigMgr.GetConfigByName("ADMIN_USERNAME");
                            SiteConfig admin_passwd = _siteConfigMgr.GetConfigByName("ADMIN_PASSWD");
                            //擴展名、最小值、最大值
                            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;
                            string localPromoPath = imgLocalPath + promoPath;//圖片存儲地址
                            FileManagement fileLoad = new FileManagement();
                            if (Request.Files.Count > 0)
                            {
                                HttpPostedFileBase file = Request.Files[0];
                                string fileName = string.Empty;//當前文件名
                                string fileExtention = string.Empty;//當前文件的擴展名
                                fileName = fileLoad.NewFileName(file.FileName);
                                if (fileName != "")
                                {
                                    fileName = fileName.Substring(0, fileName.LastIndexOf("."));
                                    fileExtention = file.FileName.Substring(file.FileName.LastIndexOf('.')).ToLower().ToString();
                                    string NewFileName = string.Empty;
                                    HashEncrypt hash = new HashEncrypt();
                                    NewFileName = hash.Md5Encrypt(fileName, "32");
                                    string ServerPath = string.Empty;
                                    FTP f_cf = new FTP();
                                    f_cf.MakeMultiDirectory(localPromoPath.Substring(0, localPromoPath.Length - promoPath.Length + 1), promoPath.Substring(1, promoPath.Length - 2).Split('/'), ftpuser, ftppwd);
                                    fileName = NewFileName + fileExtention;
                                    NewFileName = localPromoPath + NewFileName + fileExtention;//絕對路徑
                                    ServerPath = Server.MapPath(imgLocalServerPath + promoPath);

                                    //上傳之前刪除已有的圖片
                                    if (query.promo_id != 0)
                                    {
                                        _dt = PshareConMgr.Get(condition, query);
                                        if (_dt.Rows[0]["picture"].ToString() != "")
                                        {
                                            string oldFileName = _dt.Rows[0]["picture"].ToString();
                                            CommonFunction.DeletePicFile(ServerPath + oldFileName);//刪除本地圖片
                                            FTP ftp = new FTP(localPromoPath, ftpuser, ftppwd);
                                            List<string> tem = ftp.GetFileList();
                                            if (tem.Contains(oldFileName))
                                            {
                                                FTP ftps = new FTP(localPromoPath + oldFileName, ftpuser, ftppwd);
                                                ftps.DeleteFile(localPromoPath + oldFileName);
                                            }
                                        }
                                    }
                                    try
                                    {
                                        Resource.CoreMessage = new CoreResource("Product");
                                        bool result = fileLoad.UpLoadFile(file, ServerPath, NewFileName, extention, int.Parse(maxValue), int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd);
                                        if (result)
                                        {
                                            query.condition_value = fileName;
                                        }

                                    }
                                    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);
                                    }
                                    if (!string.IsNullOrEmpty(ErrorMsg))
                                    {
                                        string jsonStr = string.Empty;
                                        json = "{success:true,msg:\"" + ErrorMsg + "\"}";
                                        this.Response.Clear();
                                        this.Response.Write(json);
                                        this.Response.End();
                                    }

                                }
                            }
                            else
                            {
                                query.condition_value = _dt.Rows[0]["picture"].ToString();
                            }
                            #endregion
                        }
                        list.Add(query);
                    }
                }
             
                PshareConMgr.AddSql(list);
            }
            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);
                json = "{success:false}";
            }
        }
        /// <summary>
        /// 會員活動新增編輯
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase SaveMemberEvent()
        {
            string json = string.Empty;
            try
            {
                MemberEventQuery query = new MemberEventQuery();
                _memberEvent = new MemberEventMgr(mySqlConnectionString);
                if (!string.IsNullOrEmpty(Request.Params["rowID"]))
                {
                    query.rowID = int.Parse(Request.Params["rowID"]);
                }
                query.me_name = Request.Params["me_name"];
                query.me_desc = Request.Params["me_desc"];
                query.event_id = Request.Params["event_id"];

                if (!string.IsNullOrEmpty(Request.Params["me_startdate"]))
                {
                    query.me_startdate = DateTime.Parse(Request.Params["me_startdate"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["me_enddate"]))
                {
                    query.me_enddate = DateTime.Parse(Request.Params["me_enddate"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["me_birthday"]))
                {
                    //query.me_birthday = int.Parse(Request.Params["me_birthday"]);
                    if (Request.Params["me_birthday"] == "1")
                    {
                        query.me_birthday = 1;
                    }
                    else
                    {
                        query.me_birthday = 0;
                    }
                }
                if (!string.IsNullOrEmpty(Request.Params["me_bonus_onetime"]))
                {
                    if (Request.Params["me_bonus_onetime"] == "1")
                    {
                        query.me_bonus_onetime = 1;
                    }
                    else
                    {
                        query.me_bonus_onetime = 0;
                    }
                }
                if (!string.IsNullOrEmpty(Request.Params["me_banner_link"]))
                {
                    query.me_banner_link = Request.Params["me_banner_link"];
                }
                if (!string.IsNullOrEmpty(Request.Params["code"]))
                {
                    query.ml_code = Request.Params["code"].TrimEnd(',');
                }
                else
                {
                    query.ml_code = "0";
                }
                if (!string.IsNullOrEmpty(Request.Params["et_id"]))
                {
                    query.et_id = int.Parse(Request.Params["et_id"]);
                }
                //query.et_name = Request.Params["et_name"];
                switch (Request.Params["et_name"])
                {
                    case "1":
                        query.et_name = "DD";
                        query.et_date_parameter = "";
                        break;
                    case "2":
                        query.et_name = "WW";
                        if (!string.IsNullOrEmpty(Request.Params["week"]))
                        {
                            query.et_date_parameter = Request.Params["week"].TrimEnd(',');
                        }
                        break;
                    case "3":
                        query.et_name = "MM";
                        if (!string.IsNullOrEmpty(Request.Params["month"]))
                        {
                            query.et_date_parameter = Request.Params["month"].TrimEnd(',');
                        }
                        break;
                }

                #region 處理每天的開始結束時間
                query.et_starttime = Request.Params["et_starttime"];
                query.et_endtime = Request.Params["et_endtime"];

                #endregion
                query.k_user = (Session["caller"] as Caller).user_id;
                query.m_user = (Session["caller"] as Caller).user_id;
                query.k_date = DateTime.Now;
                query.m_date = query.k_date;
                string event_json=_memberEvent.IsGetEventID(query.event_id);
                if (event_json.IndexOf("true") > 0)
                {
                    #region 判斷數據不能重複
                    if (_memberEvent.IsRepeat(query))//不重複
                    {

                        #region 上傳圖片


                        string path = Server.MapPath(xmlPath);
                        SiteConfigMgr _siteConfigMgr = new SiteConfigMgr(path);
                        SiteConfig extention_config = _siteConfigMgr.GetConfigByName("PIC_Extention_Format");
                        SiteConfig minValue_config = _siteConfigMgr.GetConfigByName("PIC_Length_Min_Element");
                        SiteConfig maxValue_config = _siteConfigMgr.GetConfigByName("PIC_Length_MaxValue");
                        SiteConfig admin_userName = _siteConfigMgr.GetConfigByName("ADMIN_USERNAME");
                        SiteConfig admin_passwd = _siteConfigMgr.GetConfigByName("ADMIN_PASSWD");
                        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;
                        string localMemberEventPath = imgLocalPath + MemberEventPath;//圖片存儲地址
                        FileManagement fileLoad = new FileManagement();
                        int totalCount = 0;
                        MemberEventQuery oldQuery = _memberEvent.Query(new MemberEventQuery { rowID = query.rowID }, out totalCount).FirstOrDefault();
                        if (Request.Files.Count > 0)
                        {
                            HttpPostedFileBase file = Request.Files[0];
                            string fileName = string.Empty;//當前文件名
                            string fileExtention = string.Empty;//當前文件的擴展名
                            fileName = fileLoad.NewFileName(file.FileName);
                            if (fileName != "")
                            {
                                fileName = fileName.Substring(0, fileName.LastIndexOf("."));
                                fileExtention = file.FileName.Substring(file.FileName.LastIndexOf('.')).ToLower().ToString();
                                string NewFileName = string.Empty;
                                BLL.gigade.Common.HashEncrypt hash = new BLL.gigade.Common.HashEncrypt();
                                NewFileName = hash.Md5Encrypt(fileName, "32");
                                string[] dirPath = new string[2];
                                //dirPath[0] = NewFileName.Substring(0, 2)+"/";
                                //dirPath[1] = NewFileName.Substring(2, 2)+"/";
                                string ServerPath = string.Empty;
                                FTP f_cf = new FTP();
                                CreateFolder(localMemberEventPath, dirPath);
                                fileName = NewFileName + fileExtention;
                                NewFileName = localMemberEventPath + NewFileName + fileExtention;//絕對路徑
                                ServerPath = Server.MapPath(imgLocalServerPath + MemberEventPath);
                                string ErrorMsg = string.Empty;
                                //上傳之前刪除已有的圖片
                                if (query.rowID != 0)
                                {

                                    if (oldQuery.me_big_banner != "")
                                    {
                                        string oldFileName = oldQuery.me_big_banner;
                                        CommonFunction.DeletePicFile(ServerPath + oldFileName);//刪除本地圖片
                                        FTP ftp = new FTP(localMemberEventPath, ftpuser, ftppwd);
                                        List<string> tem = ftp.GetFileList();
                                        if (tem.Contains(oldFileName))
                                        {
                                            FTP ftps = new FTP(localMemberEventPath + oldFileName, ftpuser, ftppwd);
                                            ftps.DeleteFile(localMemberEventPath + oldFileName);
                                        }
                                    }
                                }
                                try
                                {
                                    Resource.CoreMessage = new CoreResource("Product");//尋找product.resx中的資源文件
                                    bool result = fileLoad.UpLoadFile(file, ServerPath, NewFileName, extention, int.Parse(maxValue), int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd);
                                    if (result)
                                    {
                                        query.me_big_banner = fileName;
                                    }
                                }
                                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);
                                }

                                if (!string.IsNullOrEmpty(ErrorMsg))
                                {
                                    string jsonStr = string.Empty;
                                    json = "{success:true,msg:\"" + ErrorMsg + "\"}";
                                    this.Response.Clear();
                                    this.Response.Write(json);
                                    this.Response.End();
                                    return this.Response;
                                }
                            }
                            else
                            {
                                query.me_big_banner = oldQuery.me_big_banner;
                            }
                        }
                        #endregion
                        if (_memberEvent.MemberEventSave(query) > 0)
                        {
                            //json = "{success:true}";
                            if (!string.IsNullOrEmpty(Request.Params["rowID"]))
                            {
                                json = "{success:true,msg:'修改成功!'}";
                            }
                            else
                            {
                                json = "{success:true,msg:'新增成功!'}";
                            }
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(Request.Params["rowID"]))
                            {
                                json = "{success:false,msg:'修改失敗!'}";
                            }
                            else
                            {
                                json = "{success:false,msg:'新增失敗!'}";
                            }
                        }

                    }
                    else
                    {
                        json = "{success:false,msg:'數據重複!'}";
                    }
                    #endregion
                }
                else
                {
                    json = "{success:false,msg:'促銷編號錯誤或促銷活動未啟用'}";
                }
                




            }
            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);
                json = "{success:false,msg:'異常!'}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Beispiel #8
0
        public HttpResponseBase EditPass()
        {
            string jsonStr = "{success:false}";
            try
            {
                _vendorMgr = new VendorMgr(connectionString);
                string newPass = string.Empty;

                string vendorId = string.Empty;
                if (!string.IsNullOrEmpty(Request.Params["vendorId"]))
                {
                    vendorId = Request.Params["vendorId"].ToString();
                }
                if (!string.IsNullOrEmpty(Request.Params["newPass"]))
                {
                    BLL.gigade.Common.HashEncrypt hash = new BLL.gigade.Common.HashEncrypt();
                    newPass = hash.SHA256Encrypt(Request.Params["newPass"].ToString());

                }


                if (_vendorMgr.EditPass(vendorId, newPass) > 0)
                {
                    jsonStr = "{success:true}";
                }
                else
                {
                    jsonStr = "{success:false}";
                }

            }
            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);
                jsonStr = "{success:false}";
            }

            this.Response.Clear();
            this.Response.Write(jsonStr.ToString());
            this.Response.End();
            return this.Response;
        }
        public HttpResponseBase SaveChinatrust()
        {
            string json = string.Empty;
            try
            {
                _eventChinatrust = new EventChinatrustMgr(mySqlConnectionString);
                FileManagement fileLoad = new FileManagement();
                EventChinatrustQuery query = new EventChinatrustQuery();
                EventChinatrustQuery oldModel = new EventChinatrustQuery();
                List<EventChinatrustQuery> store = new List<EventChinatrustQuery>();
                if (!string.IsNullOrEmpty(Request.Params["row_id"]))
                {//如果是編輯獲取該id數據
                    int totalCount = 0;
                    query.IsPage = false;
                    query.event_active = -1;
                    query.row_id = int.Parse(Request.Params["row_id"]);
                    store = _eventChinatrust.GetEventChinatrustList(query, out totalCount);
                }
                #region 需要更改的屬性
                if (!string.IsNullOrEmpty(Request.Params["row_id"]))
                {
                    query.row_id = Convert.ToInt32(Request.Params["row_id"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["event_name"]))
                {
                    query.event_name = Request.Params["event_name"];
                }
                if (!string.IsNullOrEmpty(Request.Params["event_desc"]))
                {
                    query.event_desc = Request.Params["event_desc"];
                }
                if (!string.IsNullOrEmpty(Request.Params["event_start_time"]))
                {
                    query.event_start_time = DateTime.Parse(Request.Params["event_start_time"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["event_end_time"]))
                {
                    query.event_end_time = DateTime.Parse(Request.Params["event_end_time"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["user_register_time"]))
                { 
                    query.user_register_time=DateTime.Parse(Request.Params["user_register_time"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["event_banner"]))
                {
                    query.event_banner = Request.Params["event_banner"];
                }
                #endregion
                query.event_type = "EC";
                #region 上傳圖片
                string path = Server.MapPath(xmlPath);
                SiteConfigMgr _siteConfigMgr = new SiteConfigMgr(path);
                SiteConfig extention_config = _siteConfigMgr.GetConfigByName("PIC_Extention_Format");
                SiteConfig minValue_config = _siteConfigMgr.GetConfigByName("PIC_Length_Min_Element");
                SiteConfig maxValue_config = _siteConfigMgr.GetConfigByName("PIC_Length_MaxValue");
                SiteConfig admin_userName = _siteConfigMgr.GetConfigByName("ADMIN_USERNAME");
                SiteConfig admin_passwd = _siteConfigMgr.GetConfigByName("ADMIN_PASSWD");
                //擴展名、最小值、最大值
                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;
                string localPromoPath = imgLocalPath + PaperPath;//圖片存儲地址

                if (Request.Files.Count > 0)
                {
                    HttpPostedFileBase file = Request.Files[0];
                    string fileName = string.Empty;//當前文件名
                    string fileExtention = string.Empty;//當前文件的擴展名
                    fileName = fileLoad.NewFileName(file.FileName);
                    if (fileName != "")
                    {
                        fileName = fileName.Substring(0, fileName.LastIndexOf("."));
                        fileExtention = file.FileName.Substring(file.FileName.LastIndexOf('.')).ToLower().ToString();
                        string NewFileName = string.Empty;
                        BLL.gigade.Common.HashEncrypt hash = new BLL.gigade.Common.HashEncrypt();
                        NewFileName = hash.Md5Encrypt(fileName, "32");
                        string ServerPath = string.Empty;
                        FTP f_cf = new FTP();
                        f_cf.MakeMultiDirectory(localPromoPath.Substring(0, localPromoPath.Length - PaperPath.Length + 1), PaperPath.Substring(1, PaperPath.Length - 2).Split('/'), ftpuser, ftppwd);
                        fileName = NewFileName + fileExtention;
                        NewFileName = localPromoPath + NewFileName + fileExtention;//絕對路徑
                        ServerPath = Server.MapPath(imgLocalServerPath + PaperPath);
                        string ErrorMsg = string.Empty;
                        //上傳之前刪除已有的圖片
                        if (query.row_id != 0)
                        {
                            oldModel = store.FirstOrDefault();
                            if (oldModel.event_banner != "")
                            {
                                string oldFileName = oldModel.event_banner;
                                CommonFunction.DeletePicFile(ServerPath + oldFileName);//刪除本地圖片
                                FTP ftp = new FTP(localPromoPath, ftpuser, ftppwd);
                                List<string> tem = ftp.GetFileList();
                                if (tem.Contains(oldFileName))
                                {
                                    FTP ftps = new FTP(localPromoPath + oldFileName, ftpuser, ftppwd);
                                    ftps.DeleteFile(localPromoPath + oldFileName);
                                }
                            }
                        }
                        try
                        {
                            Resource.CoreMessage = new CoreResource("Product");//尋找product.resx中的資源文件
                            bool result = fileLoad.UpLoadFile(file, ServerPath, NewFileName, extention, int.Parse(maxValue), int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd);
                            if (result)
                            {
                                query.event_banner = fileName;
                            }
                        }
                        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);
                        }
                        if (!string.IsNullOrEmpty(ErrorMsg))
                        {
                            string jsonStr = string.Empty;
                            json = "{success:true,msg:\"" + ErrorMsg + "\"}";
                            this.Response.Clear();
                            this.Response.Write(json);
                            this.Response.End();
                            return this.Response;
                        }
                    }

                }
                #endregion
                if (query.row_id == 0)
                {
                    query.event_create_time = DateTime.Now;
                    query.event_update_time = query.event_create_time;
                    query.event_create_user = Convert.ToInt32((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id);
                    query.event_update_user = query.event_create_user;
                    if (_eventChinatrust.AddEventChinatrust(query) > 0)
                    {
                        json = "{success:true }";
                    }
                    else
                    {
                        json = "{success:false,msg:'新增失敗!'}";
                    }
                }
                else
                {
                    query.event_update_time = DateTime.Now;
                    query.event_update_user = Convert.ToInt32((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id);
                    if (_eventChinatrust.UpdateEventChinatrust(query) > 0)
                    {
                        json = "{success:true }";
                    }
                    else
                    {
                        json = "{success:false,msg:'修改失敗!'}";
                    }
                }
            }
            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);
                json = "{success:false}";
            }
            this.Response.Clear();
            this.Response.Write(json.ToString());
            this.Response.End();
            return this.Response;
        }
Beispiel #10
0
        public ActionResult Login()
        {
            object notice = new object();
            if (string.IsNullOrEmpty(Request.Params["txtEmail"]))
            {
                notice = "{result:'Notice',msg:'" + Resources.Login.NOTICE_NO_EMAIL + "'}";
                ViewBag.notice = notice;
                return View("Index");
            }

            string IsRemember = Request.Params["chkRememberEmail"] != null ? Request.Params["chkRememberEmail"] : "false";
            string email = Request.Params["txtEmail"].Trim();
            string passwd = Request.Params["hid_password"].Trim();
            string challenge_id = Request.Params["challenge_id"];
            int CookieExpireTime = 10;
            ViewBag.LoginEmail = null;
            ICallerImplMgr callerMgr = new CallerMgr(connectionString);
            Caller caller = null;
            UserLoginAttemptsMgr ulaMgr = new UserLoginAttemptsMgr(connectionString);

            //記錄/清空cookie

            BLL.gigade.Common.CommonFunction.Cookie_Set("UserInfo", "email", email, IsRemember, CookieExpireTime);


            if (!Regex.IsMatch(email, @"^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$"))
            {
                notice = "{result:'Notice',msg:'" + Resources.Login.NOTICE_EMAIL_FORMAT_ERROR + "'}";
                ViewBag.notice = notice;
                if (IsRemember == "true")
                {
                    ViewBag.LoginEmail = email;
                }

                return View("Index");
            }

            if (passwd == "")
            {
                notice = "{result:'Notice',msg:'" + Resources.Login.NOTICE_NO_PASSWD + "'}";
                ViewBag.notice = notice;
                if (IsRemember == "true")
                {
                    ViewBag.LoginEmail = email;
                }
                return View("Index");
            }

            try
            {
                caller = callerMgr.Login(email);
            }
            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);
            }


            if (caller == null)
            {
                notice = "{result:'Error',msg:'" + Resources.Login.ERROR_EMAIL_PASSWD_ERROR + "'}";
                ViewBag.notice = notice;
                if (IsRemember == "true")
                {
                    ViewBag.LoginEmail = email;
                }
                UserLoginAttempts ula = new UserLoginAttempts();
                ula.login_mail = email;
                ula.login_ipfrom = CommonFunction.GetIP4Address(Request.UserHostAddress.ToString());
                ula.login_type = 3;
                ulaMgr.Insert(ula);
                return View("Index");
            }
            else
            {
                if (caller.user_status == 2)
                {
                    notice = "{result:'Error',msg:'" + Resources.Login.NOTICE_EMAIL_STOP + "'}";

                    if (IsRemember == "true")
                    {
                        ViewBag.LoginEmail = email;
                    }
                    UserLoginAttempts ula = new UserLoginAttempts();
                    ula.login_mail = email;
                    ula.login_ipfrom = CommonFunction.GetIP4Address(Request.UserHostAddress.ToString());
                    ula.login_type = 3;
                    ulaMgr.Insert(ula);
                    ViewBag.notice = notice;
                    return View("Index");
                }

                if (caller.user_status == 3)
                {
                    notice = "{result:'Error',msg:'" + Resources.Login.NOTICE_EMAIL_DELETE + "'}";

                    if (IsRemember == "true")
                    {
                        ViewBag.LoginEmail = email;
                    }

                    UserLoginAttempts ula = new UserLoginAttempts();
                    ula.login_mail = caller.user_email;
                    ula.login_ipfrom = CommonFunction.GetIP4Address(Request.UserHostAddress.ToString());
                    ula.login_type = 3;
                    ulaMgr.Insert(ula);
                    ViewBag.notice = notice;
                    return View("Index");
                }

                string challenge_key = "";

                try
                {
                    challenge_key = callerMgr.Get_Challenge_Key(challenge_id);
                    callerMgr.Kill_Challenge_Id(challenge_id);
                }
                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);
                }

                BLL.gigade.Common.HashEncrypt hash = new BLL.gigade.Common.HashEncrypt();
                string newpasswd = hash.SHA256Encrypt(caller.user_password + challenge_key);


                if (passwd != newpasswd)
                {
                    try
                    {
                        callerMgr.Add_Login_Attempts(caller.user_id);

                    }
                    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);
                    }

                    caller.user_login_attempts++;
                    string tempStr = string.Format(Resources.Login.ERROR_PASSWD_ERROR_TIMES, caller.user_login_attempts, 5);//後台登入改為5次 edit by shuangshuang0420j 201504101555 from hill

                    notice = "{result:'Error',msg:'" + tempStr + "'}";
                    ViewBag.notice = notice;

                    ViewBag.challenge_id = callerMgr.Add_Challenge();
                    ViewBag.challenge_key = callerMgr.Get_Challenge_Key(ViewBag.challenge_id);
                    //後台登入改為5次并計入UserLoginAttempts表 edit by shuangshuang0420j 201504101555 from hill
                    UserLoginAttempts ula = new UserLoginAttempts();
                    ula.login_mail = caller.user_email;
                    ula.login_ipfrom = CommonFunction.GetIP4Address(Request.UserHostAddress.ToString());
                    ula.login_type = 3;
                    ulaMgr.Insert(ula);
                    if (caller.user_login_attempts >= 5)//後台登入改為5次 edit by shuangshuang0420j 201504101555 from hill
                    {
                        try
                        {
                            callerMgr.Modify_User_Status(caller.user_id, 2);
                        }
                        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);
                        }

                    }


                    if (IsRemember == "true")
                    {
                        ViewBag.LoginEmail = email;
                    }

                    return View("Index");
                }

                if (caller.user_status == 0)
                {
                    notice = "{result:'Notice',msg:'" + Resources.Login.NOTICE_FIRST_LOGIN + "'}";
                    ViewBag.notice = notice;
                    ViewBag.isFirst = 1;
                    ViewBag.uid = caller.user_id;
                    ViewBag.email = caller.user_email;
                    return View("ChangePasswd");
                }

                try
                {
                    //添加登錄記錄
                    callerMgr.Add_Manage_Login(caller.user_id);

                    //修改登入數據
                    callerMgr.Modify_User_Login_Data(caller.user_id);
                }
                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);
                }

                caller.user_password = "";

                try
                {
                    string xmlPath = ConfigurationManager.AppSettings["SiteConfig"];//XML的設置
                    string path = Server.MapPath(xmlPath);
                    SiteConfigMgr _siteConfigMgr = new SiteConfigMgr(path);
                    string APIServer = _siteConfigMgr.GetConfigByName("APIServer").Value;


                    GigadeApiRequest request = new GigadeApiRequest(APIServer);

                    var result = request.Request<SuppliersLoginViewModel, SuppliersLoginResult>("api/admin/account/login",
                         new SuppliersLoginViewModel() { user_email = email, user_password = newpasswd, user_halfToken = challenge_key, login_ipfrom = CommonFunction.GetIP4Address(Request.UserHostAddress.ToString()) });
                    var back = result.result;
                    Session["AccessToken"] = back.userToken.user_token;
                }
                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);
                }
                

                Session["caller"] = caller;
                return Redirect("../home");

            }

        }
Beispiel #11
0
        public ActionResult Change()
        {
            ICallerImplMgr mgr = null;
            Caller caller = null;
            object notice = new object();
            int nUserId = 0;
            string sPasswd1;
            string sPasswd2 = "";
            string sCode;
            if (!string.IsNullOrEmpty(Request.Params["uid"]) && !string.IsNullOrEmpty(Request.Params["code"]) && Request.Params["hid_isFirst"] != "1")
            {
                nUserId = int.Parse(Request.Params["uid"]);
                sCode = Request.Params["code"];
                sPasswd1 = Request.Params["passwd1"];
                sPasswd2 = Request.Params["passwd2"];
                mgr = new CallerMgr(connectionString);

                try
                {
                    caller = mgr.GetUserById(nUserId);
                }
                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);
                }

                BLL.gigade.Common.HashEncrypt hash = new BLL.gigade.Common.HashEncrypt();

                string sDB_Confirm_Code = caller.user_confirm_code;
                if (sDB_Confirm_Code == "")
                {
                    ViewBag.ConfirmSend = Resources.Login.ERROR_PASSWD_ACTIVATION;
                    return View("NoticeShow");
                }
                else if (sDB_Confirm_Code != hash.SHA256Encrypt(sCode))
                {
                    ViewBag.ConfirmSend = Resources.Login.ERROR_PASSWD_ACTIVATION;
                    return View("NoticeShow");
                }
                else if (sPasswd1 == "" || sPasswd2 == "")
                {
                    notice = "{result:'Notice',msg:'" + Resources.Login.NOTICE_NO_PASSWD + "'}";
                    ViewBag.notice = notice;
                    return View("ChangePasswd");
                }
                else if (sPasswd1 != sPasswd2)
                {
                    notice = "{result:'Notice',msg:'" + Resources.Login.NOTICE_PASSWD_MISMATCH + "'}";
                    ViewBag.notice = notice;
                    return View("ChangePasswd");
                }
            }
            else if (Request.Params["hid_isFirst"] == "1" && !string.IsNullOrEmpty(Request.Params["uid"]))
            {
                nUserId = int.Parse(Request.Params["uid"]);
                sPasswd1 = Request.Params["passwd1"];
                sPasswd2 = Request.Params["passwd2"];
                mgr = new CallerMgr(connectionString);

                if (sPasswd1 == "" || sPasswd2 == "")
                {
                    notice = "{result:'Notice',msg:'" + Resources.Login.NOTICE_NO_PASSWD + "'}";
                    ViewBag.notice = notice;
                    return View("ChangePasswd");
                }
                else if (sPasswd1 != sPasswd2)
                {
                    notice = "{result:'Notice',msg:'" + Resources.Login.NOTICE_PASSWD_MISMATCH + "'}";
                    ViewBag.notice = notice;
                    return View("ChangePasswd");
                }

                //修改用戶狀態
                try
                {
                    mgr.Modify_User_Status(nUserId, 1);
                }
                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);
                }

            }
            else
            {
                ViewBag.ConfirmSend = Resources.Login.ERROR_ACCESS_LIMIT;
                return View("NoticeShow");
            }

            try
            {
                mgr.Modify_User_Password(nUserId, sPasswd2);
            }
            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);
            }

            notice = "{result:'Notice',msg:'" + Resources.Login.NOTICE_PASSWD_CHANGE_OK + "'}";
            ViewBag.notice = notice;
            return View("LoginAgain");
        }
Beispiel #12
0
        public ActionResult ChangePasswd()
        {
            if (!string.IsNullOrEmpty(Request.QueryString["uid"]) && !string.IsNullOrEmpty(Request.QueryString["code"]))
            {
                BLL.gigade.Common.HashEncrypt hash = new BLL.gigade.Common.HashEncrypt();
                int nGet_User_Id = int.Parse(Request.QueryString["uid"].Trim());
                string sGet_Confirm_Code = Request.QueryString["code"];
                ICallerImplMgr callerMgr = new CallerMgr(connectionString);
                Caller caller = null;
                try
                {
                    caller = callerMgr.GetUserById(nGet_User_Id);
                }
                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);
                }

                string sDB_Confrim_Code = caller.user_confirm_code;

                if (sDB_Confrim_Code == "")
                {
                    ViewBag.ConfirmSend = Resources.Login.ERROR_PASSWD_ACTIVATION;
                    return View("NoticeShow");
                }

                if (sDB_Confrim_Code != hash.SHA256Encrypt(sGet_Confirm_Code))
                {
                    ViewBag.ConfirmSend = Resources.Login.ERROR_PASSWD_ACTIVATION;
                    return View("NoticeShow");
                }

                ViewBag.uid = nGet_User_Id;
                ViewBag.code = sGet_Confirm_Code;
                ViewBag.email = caller.user_email;
                return View();
            }
            else
            {
                ViewBag.ConfirmSend = Resources.Login.ERROR_PASSWD_ACTIVATION;
                return View("NoticeShow");
            }

        }
Beispiel #13
0
        public ActionResult DoForget()
        {
            object notice = new object();
            if (!string.IsNullOrEmpty(Request.Params["txtEmail"]))
            {
                string _email = Request.Params["txtEmail"].Trim().ToLower();
                if (!Regex.IsMatch(_email, @"^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$"))
                {
                    notice = "{result:'Notice',msg:'" + Resources.Login.NOTICE_EMAIL_FORMAT_ERROR + "'}";
                    ViewBag.notice = notice;
                    return View("Forget");
                }

                Caller caller = null;
                ICallerImplMgr callerMgr = new CallerMgr(connectionString);
                UserLoginAttemptsMgr ulaMgr = new UserLoginAttemptsMgr(connectionString);
                try
                {
                    caller = callerMgr.Login(_email);
                }
                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);
                }

                if (caller == null)
                {
                    notice = "{result:'Error',msg:'" + Resources.Login.ERROR_EMIAL_NOT_MATCH + "'}";
                    ViewBag.notice = notice;
                    return View("Forget");
                }

                if (caller.user_status >= 2)
                {
                    notice = "{result:'Error',msg:'" + Resources.Login.ERROR_EMAIL_STATUS_INACTIVE + "'}";
                    ViewBag.notice = notice;
                    UserLoginAttempts ula = new UserLoginAttempts();
                    ula.login_mail = caller.user_email;
                    ula.login_ipfrom = CommonFunction.GetIP4Address(Request.UserHostAddress.ToString());
                    ula.login_type = 3;
                    ulaMgr.Insert(ula);
                    return View("Forget");
                }

                string sUser_Confirm_Code = BLL.gigade.Common.CommonFunction.Generate_Rand_String(8);

                BLL.gigade.Common.HashEncrypt hash = new BLL.gigade.Common.HashEncrypt();

                try
                {
                    callerMgr.Modify_User_Confirm_Code(caller.user_id, hash.SHA256Encrypt(sUser_Confirm_Code));
                }
                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 Redirect("/Login/ChangePasswd?uid=" + caller.user_id + "&code=" + sUser_Confirm_Code);

                ViewBag.ConfirmSend = "請檢查您的E-mail信箱,以取得密碼的相關資訊!";
                return View("NoticeShow");

            }
            else
            {
                notice = "{result:'Notice',msg:'登錄信箱不能為空!'}";
                ViewBag.notice = notice;
                return View("Forget");
            }
        }
        public ActionResult UpLoadImg()
        {
            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 = siteConfigMgr.GetConfigByName("PIC_Length_MaxValue");
            SiteConfig admin_userName = siteConfigMgr.GetConfigByName("ADMIN_USERNAME");
            SiteConfig admin_passwd = siteConfigMgr.GetConfigByName("ADMIN_PASSWD");
            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;

            string elementPath = ConfigurationManager.AppSettings["elementPath"];
            FileManagement fileLoad = new FileManagement();
            HttpPostedFileBase file = Request.Files["Filedata"];
            string fileName = string.Empty;
            string fileExtention = string.Empty;
            string[] Mappath = new string[2];
            fileName = fileLoad.NewFileName(file.FileName);
            fileName = fileName.Substring(0, fileName.LastIndexOf("."));
            fileExtention = file.FileName.Substring(file.FileName.LastIndexOf('.')).ToLower();
            string localElePath = imgLocalPath + elementPath;
            string returnName = imgServerPath;////"http://192.168.71.159:8080"
            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;
            Mappath[0] = firstFolder;
            Mappath[1] = secondFolder;
            //CreateFolder(localElePath, Mappath);
            //   localElePath += firstFolder + secondFolder;
            //  elementPath += firstFolder + secondFolder;
            returnName += elementPath + NewFileName + fileExtention;
            NewFileName = localElePath + NewFileName + fileExtention;
            ServerPath = Server.MapPath(imgLocalServerPath + elementPath);
            string ErrorMsg = string.Empty;
            try
            {
                result = fileLoad.UpLoadFile(file, ServerPath, NewFileName, extention, int.Parse(maxValue), int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd);
            }
            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);
            }
            if (string.IsNullOrEmpty(ErrorMsg))
            {
                ViewBag.fileName = returnName;
                ViewBag.Type = "pic";
            }
            else
            {
                ViewBag.fileName = "ERROR/" + ErrorMsg;
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = "ERROR/" + ErrorMsg;
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);

            }
            return View("~/Views/PromotionsAmountTrial/upLoad.cshtml");
        }
Beispiel #15
0
 public int HashAll()
 {
     StringBuilder sql = new StringBuilder();
     StringBuilder str = new StringBuilder();
     try
     {
         HashEncrypt hashpt=new HashEncrypt();
         
         sql.AppendFormat("select row_id,loc_id,hash_loc_id from iloc where hash_loc_id is NULL;");
         DataTable _dt = _access.getDataTable(sql.ToString());
         for (int i = 0; i < _dt.Rows.Count; i++)
         {
             str.AppendFormat("UPDATE iloc SET hash_loc_id='{0}' WHERE row_id ='{1}';",hashpt.Md5Encrypt(_dt.Rows[i]["loc_id"].ToString(),"16"),_dt.Rows[i]["row_id"]);
         }
         if (!string.IsNullOrEmpty(str.ToString()))
         {
             return _access.execCommand(str.ToString());
         }
         else
         {
             return 1;
         }
     }
     catch (Exception ex)
     {
         throw new Exception("IlocDao.HashAll-->" + ex.Message + str.ToString(), ex);
     }
 }
        /// <summary>
        /// 供應商出貨單
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase OrderWaitDeliverList()
        {
            string jsonStr = String.Empty;
            StringBuilder sb = new StringBuilder();
            HashEncrypt hmd5 = new HashEncrypt();
            _IOrderSlaveMgr = new OrderSlaveMgr(mySqlConnectionString);
            _OrderPaymentNcccMgr = new OrderPaymentNcccMgr(mySqlConnectionString);
            _SinopacMgr = new SinopacDetailMgr(mySqlConnectionString);
            _vendorImp = new VendorMgr(mySqlConnectionString);
            try
            {
                #region 前提查詢條件
                if (!string.IsNullOrEmpty(Request.Params["search_type"]))//查詢條件
                {
                    int search_type = int.Parse(Request.Params["search_type"]);
                    string searchcontent = "";
                    if (!string.IsNullOrEmpty(Request.Params["searchcontent"]))
                    {
                        searchcontent = Request.Params["searchcontent"];
                    }
                    switch (search_type)
                    {
                        case 1:
                            sb.AppendFormat(" and om.order_id LIKE '%{0}%' ", searchcontent);
                            break;
                        case 2:
                            sb.AppendFormat(" AND om.order_name LIKE '%{0}%' ", searchcontent);
                            break;
                        case 3:
                            sb.AppendFormat(" AND u.user_email LIKE '%{0}%' ", searchcontent);
                            break;
                        case 4:
                            sb.AppendFormat(" AND om.delivery_name LIKE '%{0}%' ", searchcontent);
                            break;
                        case 5:
                            sb.AppendFormat(" AND om.source_trace LIKE '%{0}%' ", searchcontent);
                            break;
                        default:
                            sb.Append(" ");
                            break;
                    }
                }
                if (!string.IsNullOrEmpty(Request.Params["search_vendor"]))//供應商條件
                {
                    if (int.Parse(Request.Params["search_vendor"]) != 0)
                    {
                        sb.AppendFormat("  AND os.vendor_id = '{0}' ", Request.Params["search_vendor"]);
                    }
                }
                #endregion
                List<OrderSlaveQuery> store = new List<OrderSlaveQuery>();
                OrderSlaveQuery query = new OrderSlaveQuery();
                query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量
                query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量

                int totalCount = 0;
                store = _IOrderSlaveMgr.GetOrderWaitDeliver(query, sb.ToString(), out totalCount);//查询出供應商出貨單

                int vendor_id = 0;
                string loginIdStr = string.Empty;
                string mdlogin_id = string.Empty;

                StringBuilder Order_id_store = new StringBuilder();
                foreach (var item in store)
                {
                    Order_id_store.AppendFormat("{0},", item.order_id);
                }
                string dtSql = "and order_id in(" + Order_id_store.ToString().TrimEnd(',') + ") ";//去查詢DataTable
                DataTable _dtNccc = _OrderPaymentNcccMgr.OrderPaymentNccc(null, dtSql);
                DataTable _dtSino = _SinopacMgr.GetSinopacDetai(null, dtSql);
                // String Sql = "123"; 
                foreach (var item in store)
                {
                    //組裝用於登錄到供應商後臺的金鑰
                    vendor_id = Convert.ToInt32(item.vendor_id);
                    loginIdStr = _vendorImp.GetLoginId(vendor_id);
                    mdlogin_id = hmd5.Md5Encrypt(loginIdStr, "MD5");
                    //http://localhost:32088/?vendor_id=2&key=f32bef1b57de24330d8bf900cee4ba5e
                    item.key = vendorServerPath + "?vendor_id=" + item.vendor_id + "&key=" + hmd5.Md5Encrypt(mdlogin_id + loginIdStr, "MD5");

                    item.status = "待出貨";
                    if (item.order_payment == 1)//付款方式为ATM
                    {
                        DataRow[] rows = _dtSino.Select("order_id='" + item.order_id + "'");
                        if (rows.Count() != 0)
                        {
                            item.pay_time = DateTime.Parse(rows[0]["pay_time"].ToString()).ToString("yyyy/MM/dd HH:mm:ss");
                        }
                        else { item.pay_time = ""; }
                    }
                    else
                    {
                        DataRow[] rows = _dtNccc.Select("order_id='" + item.order_id + "'");
                        if (rows.Count() != 0)
                        {
                            item.pay_time = DateTime.Parse(rows[0]["pay_time"].ToString()).ToString("yyyy/MM/dd HH:mm:ss");
                        }
                        else { item.pay_time = ""; }
                    }
                }
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd";
                jsonStr = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(store, Formatting.Indented, timeConverter) + "}";//返回json數據
            }
            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);
                jsonStr = "{success:false,msg:0}";
            }
            this.Response.Clear();
            this.Response.Write(jsonStr.ToString());
            this.Response.End();
            return this.Response;
        }
Beispiel #17
0
        public HttpResponseBase BannerImageEdit()
        {
            string json = string.Empty;
            BannerContent bc = new BannerContent();
            Serial serial = new Serial();
            _bcMgr = new BannerContentMgr(mySqlConnectionString);
            _ISerImplMgr = new SerialMgr(mySqlConnectionString);
            serial = _ISerImplMgr.GetSerialById(72);
            string path = Server.MapPath(xmlPath);
            SiteConfigMgr _siteConfigMgr = new SiteConfigMgr(path);
            SiteConfig extention_config = _siteConfigMgr.GetConfigByName("PIC_Extention_Format");
            SiteConfig minValue_config = _siteConfigMgr.GetConfigByName("PIC_Length_MinValue");
            SiteConfig maxValue_config = _siteConfigMgr.GetConfigByName("PIC_Length_MaxValue");
            SiteConfig admin_userName = _siteConfigMgr.GetConfigByName("ADMIN_USERNAME");
            SiteConfig admin_passwd = _siteConfigMgr.GetConfigByName("ADMIN_PASSWD");
            //擴展名、最小值、最大值
            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;
            string localPromoPath = imgLocalServerPath + promoPath;//圖片存儲地址 /aimg.gigade100.com/ +/promotion/dev/ 

            string NewName = string.Empty;//當前文件名
            string fileExtention = string.Empty;//當前文件的擴展名
            string NewFileName = string.Empty;
            FileManagement fileLoad = new FileManagement();

            try
            {
                string oldImg = string.Empty;
                serial = _ISerImplMgr.GetSerialById(6);
                List<BannerContent> store = new List<BannerContent>();
                if (!string.IsNullOrEmpty(Request.Params["banner_content_id"]))
                {
                    int totalCount = 0;
                    bc.IsPage = false;
                    bc.banner_content_id = uint.Parse(Request.Params["banner_content_id"]);
                    if (Request.Params["history"] == "1")
                    {
                        bc.banner_status = 3;
                    }
                    store = _bcMgr.GetList(bc, out totalCount);
                    foreach (var item in store)
                    {
                        oldImg = item.banner_image;
                    }
                }
                bc = new BannerContent();
                bc.banner_title = Request.Params["banner_title"];
                bc.banner_link_url = Request.Params["banner_link_url"];
                if (!string.IsNullOrEmpty(Request.Params["banner_site_id"]))
                {
                    bc.banner_site_id = uint.Parse(Request.Params["banner_site_id"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["banner_link_mode"]))
                {
                    bc.banner_link_mode = int.Parse(Request.Params["banner_link_mode"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["banner_sort"]))
                {
                    bc.banner_sort = uint.Parse(Request.Params["banner_sort"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["banner_statuses"]))
                {
                    bc.banner_status = uint.Parse(Request.Params["banner_statuses"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["banner_start"]))
                {
                    bc.banner_start = DateTime.Parse(DateTime.Parse(Request.Params["banner_start"]).ToString("yyyy-MM-dd") + " 00:00:00");
                }
                if (!string.IsNullOrEmpty(Request.Params["banner_end"]))
                {
                    bc.banner_end = DateTime.Parse(DateTime.Parse(Request.Params["banner_end"]).ToString("yyyy-MM-dd") + " 23:59:59");
                }
                bc.banner_ipfrom = CommonFunction.GetClientIPNew();
                if (bc.banner_ipfrom == "::1")
                {
                    bc.banner_ipfrom = System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName())[2].ToString();
                }
                if (!string.IsNullOrEmpty(Request.Params["banner_content_id"]) && Request.Params["banner_image"] == oldImg)
                {
                    bc.banner_image = oldImg;
                }
                if (Request.Files["banner_image"] != null && Request.Files["banner_image"].ContentLength > 0)
                {
                    HttpPostedFileBase file = Request.Files["banner_image"];
                    if (file.ContentLength > int.Parse(minValue) * 1024 && file.ContentLength < int.Parse(maxValue) * 1024)
                    {
                        NewName = Path.GetFileName(file.FileName);
                        bool result = false;
                        string filename = NewName.Substring(0, NewName.LastIndexOf("."));
                        //獲得文件的後綴名
                        fileExtention = NewName.Substring(NewName.LastIndexOf(".")).ToLower();
                        //新的文件名是哈希字符串
                        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) + "/";
                        NewFileName = NewFileName + fileExtention;
                        NewName = NewFileName;
                        string ServerPath = string.Empty;
                        string localPromoDirectory = Server.MapPath(localPromoPath);
                        if (!System.IO.Directory.Exists(localPromoDirectory))
                        {
                            System.IO.Directory.CreateDirectory(localPromoDirectory);
                        }
                        FTP ftp = new FTP();
                        string directorys = promoPath + firstFolder + secondFolder;
                        ftp.MakeMultiDirectory(imgLocalPath+"/", directorys.Substring(1, directorys.Length - 2).Split('/'), ftpuser, ftppwd);
                        //NewFileName = localPromoPath + NewFileName;//絕對路徑
                        ServerPath = Server.MapPath(localPromoPath + firstFolder + secondFolder);
                        string ErrorMsg = string.Empty;
                        //上傳
                        result = fileLoad.UpLoadFile(file, ServerPath, imgLocalPath + directorys + NewFileName, extention, int.Parse(maxValue), int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd);
                        if (!result)
                        {
                            json = "{success:false,msg:'圖片上傳失敗!'}";
                            this.Response.Clear();
                            this.Response.Write(json);
                            this.Response.End();
                            return this.Response;
                        }
                        bc.banner_image = NewName;
                        string oldImgPath = string.Empty;
                        string ftppath = string.Empty;
                        if (oldImg.Length >= 4)
                        {
                            oldImgPath = localPromoPath + oldImg.Substring(0, 2) + "/" + oldImg.Substring(2, 2) + "/" + oldImg;
                        }
                        if (System.IO.File.Exists(Server.MapPath(oldImgPath)))
                        {
                            ftppath=imgLocalPath + promoPath + oldImg.Substring(0, 2) + "/" + oldImg.Substring(2, 2) + "/";
                            System.IO.File.Delete(Server.MapPath(oldImgPath));
                            FTP ftp1 = new FTP(ftppath, ftpuser, ftppwd);
                            List<string> tem = ftp1.GetFileList();
                            if (tem.Contains(oldImg))
                            {
                                FTP ftps = new FTP(ftppath + oldImg, ftpuser, ftppwd);
                                ftps.DeleteFile(ftppath + oldImg);
                            }
                        }
                    }
                    else
                    {
                        json = "{success:false,msg:'上傳圖片不能超過" + maxValue + "K'}";
                        this.Response.Clear();
                        this.Response.Write(json);
                        this.Response.End();
                        return this.Response;
                    }
                }
                
                #region 新增
                if (String.IsNullOrEmpty(Request.Params["banner_content_id"]))
                {
                    bc.banner_content_id = uint.Parse((serial.Serial_Value + 1).ToString());
                    if (_bcMgr.Add(bc) > 0)
                    {
                        serial.Serial_Value = serial.Serial_Value + 1;/*所在操作表的列增加*/
                        _ISerImplMgr.Update(serial);/*修改所在的表的列對應的值*/
                        json = "{success:true,msg:\"" + "新增成功!" + "\"}";
                    }

                }
                #endregion
                #region 編輯
                else
                {
                    bc.banner_content_id = uint.Parse(Request.Params["banner_content_id"]);
                    if (_bcMgr.Update(bc) > 0)
                    {
                        json = "{success:true,msg:\"" + "修改成功!" + "\"}";
                    }

                }
                #endregion
            }
            catch (Exception ex)
            {
                json = "{success:false,msg:\"" + "異常" + "\"}";
                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(json);
            this.Response.End();
            return this.Response;

        }
        public ActionResult upLoadImg()
        {
            BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"];//獲取當前登入的供應商
            int writerID = (int)vendorModel.vendor_id;

            string path = Server.MapPath(xmlPath);
            siteConfigMgr = new SiteConfigMgr(path);
            ViewBag.moreFileOneTime = false;
            SiteConfig extention_config = siteConfigMgr.GetConfigByName("PIC_Extention_Format");
            SiteConfig minValue_config = siteConfigMgr.GetConfigByName("PIC_Length_MinValue");
            SiteConfig maxValue_config = siteConfigMgr.GetConfigByName("PIC_Length_MaxValue");
            SiteConfig admin_userName = siteConfigMgr.GetConfigByName("ADMIN_USERNAME");
            SiteConfig admin_passwd = siteConfigMgr.GetConfigByName("ADMIN_PASSWD");

            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;

            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 localDescPath = imgLocalPath + descPath;
            //string localDesc400Path = imgLocalPath + desc400Path;
            string[] Mappath = new string[2];

            FileManagement fileLoad = new FileManagement();

            HttpPostedFileBase file = Request.Files["Filedata"];
            string nameType = Request.Params["nameType"];
            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_");
                string errorMsg = "ERROR/";
                if (prodCheck == -1 && specCheck == -1 && descCheck == -1)
                {
                    errorMsg += "[" + file.FileName + "] ";
                    errorMsg += Resources.VendorProduct.FILE_NAME_ERROR;

                    ViewBag.fileName = errorMsg;
                    return View("~/Views/VendorProduct/upLoad.cshtml");
                }
                else
                {
                    nameType = file.FileName.Split('_')[0];
                    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);
                    ProductSpecTemp proSpecTemp = new ProductSpecTemp();
                    string spec = file.FileName.Split('_')[1].Split('.')[0];
                    bool checkStatus = true;
                    if (!string.IsNullOrEmpty(Request.Params["product_id"].Split(';')[0].ToString()))
                    {
                        //product_spec
                        proSpecTemp.product_id = Request.Params["product_id"].Split(';')[0].ToString();
                    }
                    //product_spec_temp
                    _specTempMgr = new ProductSpecTempMgr(connectionString);

                    List<ProductSpecTemp> pSpecTempList = _specTempMgr.VendorQuery(new ProductSpecTemp { Writer_Id = writerID, 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.VendorProduct.SPEC_NOT_FIND;
                        ViewBag.fileName = errorMsg;
                        return View("~/Views/VendorProduct/upLoad.cshtml");
                    }
                }
                #endregion
            }

            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")
            {

                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("VendorProduct");
            try
            {
                //上傳圖片

                result = fileLoad.UpLoadFile(file, ServerPath, NewFileName, extention, int.Parse(maxValue), int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd);
                //上傳對應大小圖片
                //压缩图片至其它规格
            }
            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);
            }
            if (string.IsNullOrEmpty(ErrorMsg))
            {
                ViewBag.fileName = returnName;
            }
            else
            {
                ViewBag.fileName = "ERROR/" + ErrorMsg;
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = "ERROR/" + ErrorMsg;
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);

            }
            return View("~/Views/VendorProduct/upLoad.cshtml");
        }
        public HttpResponseBase EventChinaTrustBagSave()
        {
            string json = string.Empty;
            EventChinaTrustBagQuery query = new EventChinaTrustBagQuery();
            EventChinaTrustBagQuery oldModel = new EventChinaTrustBagQuery();
            try
            {
                if (!string.IsNullOrEmpty(Request.Params["event_id"]))
                {
                    query.event_id = Request.Params["event_id"];
                }
                if (!string.IsNullOrEmpty(Request.Params["bag_name"]))
                {
                    query.bag_name = Request.Params["bag_name"];
                }
                if (!string.IsNullOrEmpty(Request.Params["bag_desc"]))
                {
                    query.bag_desc = Request.Params["bag_desc"];
                }
                if (!string.IsNullOrEmpty(Request.Params["bag_banner"]))
                {
                    query.bag_banner = Request.Params["bag_banner"];
                }
                if (!string.IsNullOrEmpty(Request.Params["bag_start_time"]))
                {
                    query.bag_start_time =Convert.ToDateTime( Request.Params["bag_start_time"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["bag_end_time"]))
                {
                    query.bag_end_time = Convert.ToDateTime(Request.Params["bag_end_time"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["bag_show_start_time"]))
                {
                    query.bag_show_start_time =  Convert.ToDateTime(Request.Params["bag_show_start_time"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["bag_show_end_time"]))
                {
                    query.bag_show_end_time =Convert.ToDateTime(Request.Params["bag_show_end_time"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["product_number"]))
                {
                    query.product_number =Convert.ToInt32(Request.Params["product_number"]);
                }
                if (string.IsNullOrEmpty(Request.Params["bag_id"]))//新增
                {
                    query.bag_create_user=(Session["caller"] as Caller).user_id;
                    query.bag_update_user = (Session["caller"] as Caller).user_id;
                    query.bag_create_time = DateTime.Now;
                    query.bag_update_time = query.bag_create_time;
                }
                else//編輯
                {
                    query.bag_id = Convert.ToInt32(Request.Params["bag_id"]);
                    query.bag_update_time = DateTime.Now;
                    query.bag_update_user = (Session["caller"] as Caller).user_id;
                }
                _eventChinaTrustBag = new EventChinaTrustBagMgr(mySqlConnectionString);
                #region  上傳圖片
                string path = Server.MapPath(xmlPath);
                SiteConfigMgr _siteConfigMgr = new SiteConfigMgr(path);
                SiteConfig extention_config = _siteConfigMgr.GetConfigByName("PIC_Extention_Format");
                SiteConfig minValue_config = _siteConfigMgr.GetConfigByName("PIC_Length_Min_Element");
                SiteConfig maxValue_config = _siteConfigMgr.GetConfigByName("PIC_Length_MaxValue");
                SiteConfig admin_userName = _siteConfigMgr.GetConfigByName("ADMIN_USERNAME");
                SiteConfig admin_passwd = _siteConfigMgr.GetConfigByName("ADMIN_PASSWD");
                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;
                string localPromoPath = imgLocalPath + PaperPath;//圖片存儲地址
                if (Request.Files.Count > 0)
                {
                    HttpPostedFileBase file = Request.Files[0];
                    string fileName = string.Empty;//當前文件名
                    string fileExtention = string.Empty;//當前文件的擴展名
                    FileManagement fileLoad = new FileManagement();
                    fileName = fileLoad.NewFileName(file.FileName);
                    if (fileName != "")
                    {
                        fileName = fileName.Substring(0, fileName.LastIndexOf("."));
                        fileExtention = file.FileName.Substring(file.FileName.LastIndexOf('.')).ToLower().ToString();
                        string NewFileName = string.Empty;
                        BLL.gigade.Common.HashEncrypt hash = new BLL.gigade.Common.HashEncrypt();
                        NewFileName = hash.Md5Encrypt(fileName, "32");
                        string ServerPath = string.Empty;
                        FTP f_cf = new FTP();
                        f_cf.MakeMultiDirectory(localPromoPath.Substring(0, localPromoPath.Length - PaperPath.Length + 1), PaperPath.Substring(1, PaperPath.Length - 2).Split('/'), ftpuser, ftppwd);
                        fileName = NewFileName + fileExtention;
                        NewFileName = localPromoPath + NewFileName + fileExtention;//絕對路徑
                        ServerPath = Server.MapPath(imgLocalServerPath + PaperPath);
                        string ErrorMsg = string.Empty;
                        if (query.bag_id != 0)
                        {
                            oldModel = _eventChinaTrustBag.GetSinggleData(query);
                            if (oldModel.bag_banner != "")
                                {
                                    string oldFileName = oldModel.bag_banner;
                                    CommonFunction.DeletePicFile(ServerPath + oldFileName);//刪除
                                    FTP ftp = new FTP(localPromoPath, ftpuser, ftppwd);
                                    List<string> tem = ftp.GetFileList();
                                    if (tem.Contains(oldFileName))
                                    {
                                        FTP ftps = new FTP(localPromoPath + oldFileName, ftpuser, ftppwd);
                                        ftps.DeleteFile(localPromoPath + oldFileName);
                                    }
                                }
                        }

                        try
                        {
                            Resource.CoreMessage = new CoreResource("Product");
                            bool result = fileLoad.UpLoadFile(file, ServerPath, NewFileName, extention, int.Parse(maxValue), int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd);
                            if (result)
                            {
                                query.bag_banner = fileName;
                            }
                        }
                        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);
                        }
                        if (!string.IsNullOrEmpty(ErrorMsg))
                        {
                            string jsonStr = string.Empty;
                            json = "{success:true,msg:\"" + ErrorMsg + "\"}";
                            this.Response.Clear();
                            this.Response.Write(json);
                            this.Response.End();
                        }
                    }
                }
                else
                {
                    query.bag_banner = oldModel.bag_banner;
                }
                #endregion
          
                if (_eventChinaTrustBag.EventChinaTrustBagSave(query) > 0)
                {
                    json = "{success:true}";
                }
                else
                {
                    json = "{success:false}";
                }
            }
            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);
                json = "{success:false}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Beispiel #20
0
        public HttpResponseBase PaperEdit()
        {
            string json = string.Empty;
            Paper p = new Paper();
            _paperMgr = new PaperMgr(mySqlConnectionString);

            string path = Server.MapPath(xmlPath);
            SiteConfigMgr _siteConfigMgr = new SiteConfigMgr(path);
            SiteConfig extention_config = _siteConfigMgr.GetConfigByName("PIC_Extention_Format");
            SiteConfig minValue_config = _siteConfigMgr.GetConfigByName("PIC_Length_Min_Element");
            SiteConfig maxValue_config = _siteConfigMgr.GetConfigByName("PIC_Length_MaxValue");
            SiteConfig admin_userName = _siteConfigMgr.GetConfigByName("ADMIN_USERNAME");
            SiteConfig admin_passwd = _siteConfigMgr.GetConfigByName("ADMIN_PASSWD");
            //擴展名、最小值、最大值
            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;
            string localBannerPath = imgLocalPath + PaperPath;//圖片存儲地址

            FileManagement fileLoad = new FileManagement();

            try
            {
                List<Paper> store = new List<Paper>();
                if (!string.IsNullOrEmpty(Request.Params["paper_id"]))
                {
                    int totalCount = 0;
                    p.IsPage = false;
                    p.paperID = int.Parse(Request.Params["paper_id"]);
                    store = _paperMgr.GetPaperList(p, out totalCount);
                }
                string oldImg = string.Empty;
                foreach (var item in store)
                {
                    oldImg = item.paperBanner;
                }

                p = new Paper();
                p.paperName = Request.Params["paper_name"];
                p.paperMemo = Request.Params["paper_memo"];
                p.bannerUrl = Request.Params["banner_url"];
                if (!string.IsNullOrEmpty(Request.Params["paper_start"]))
                {
                    p.paperStart = DateTime.Parse(DateTime.Parse(Request.Params["paper_start"]).ToString("yyyy-MM-dd HH:mm:ss"));
                }
                if (!string.IsNullOrEmpty(Request.Params["paper_end"]))
                {
                    p.paperEnd = DateTime.Parse(DateTime.Parse(Request.Params["paper_end"]).ToString("yyyy-MM-dd HH:mm:ss"));
                }
                p.event_ID = Request.Params["eventid"];
                if (!string.IsNullOrEmpty(Request.Params["isRepeatGift"]))
                {
                    p.isRepeatGift = int.Parse(Request.Params["isRepeatGift"]);
                }
                //if (!string.IsNullOrEmpty(Request.Params["isPromotion"]))
                //{
                //    p.isPromotion = int.Parse(Request.Params["isPromotion"]);
                //    if (p.isPromotion == 1)
                //    {
                //        p.promotionUrl = Request.Params["promotion_url"];
                //    }
                //}
                //if (!string.IsNullOrEmpty(Request.Params["isPromotion"]))
                //{
                //    p.isPromotion = int.Parse(Request.Params["isPromotion"]);
                //    if (p.isPromotion == 1)
                //    {
                //        p.promotionUrl = Request.Params["promotion_url"];
                //    }
                //}

                //if (!string.IsNullOrEmpty(Request.Params["isGiveBonus"]))
                //{
                //    p.isGiveBonus = int.Parse(Request.Params["isGiveBonus"]);
                //    if (p.isGiveBonus == 1)
                //    {
                //        if (!string.IsNullOrEmpty(Request.Params["bonus_num"]))
                //        {
                //            p.bonusNum = int.Parse(Request.Params["bonus_num"]);
                //        }
                //    }
                //}

                //if (!string.IsNullOrEmpty(Request.Params["isGiveProduct"]))
                //{
                //    p.isGiveProduct = int.Parse(Request.Params["isGiveProduct"]);
                //    if (p.isGiveProduct == 1)
                //    {
                //        if (!string.IsNullOrEmpty(Request.Params["product_id"]))
                //        {
                //            p.productID = int.Parse(Request.Params["product_id"]);
                //        }
                //    }
                //}

                if (!string.IsNullOrEmpty(Request.Params["isRepeatWrite"]))
                {
                    p.isRepeatWrite = int.Parse(Request.Params["isRepeatWrite"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["isNewMember"]))
                {
                    p.isNewMember = int.Parse(Request.Params["isNewMember"]);
                }
                p.creator = int.Parse((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString());
                System.Net.IPAddress[] addlist = System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName()).AddressList;
                if (addlist.Length > 0)
                {
                    p.ipfrom = addlist[0].ToString();
                }
                if (!string.IsNullOrEmpty(Request.Params["paper_id"]) && Request.Params["paper_banner"] == oldImg)
                {
                    p.paperBanner = oldImg;
                }
                else
                {
                    string ServerPath = string.Empty;
                    ServerPath = Server.MapPath(imgLocalServerPath + PaperPath);
                    if (Request.Files.Count > 0)//單個圖片上傳
                    {
                        HttpPostedFileBase file = Request.Files[0];
                        string fileName = string.Empty;//當前文件名

                        string fileExtention = string.Empty;//當前文件的擴展名
                        //獲取圖片名稱
                        fileName = fileLoad.NewFileName(file.FileName);
                        if (fileName != "")
                        {
                            fileName = fileName.Substring(0, fileName.LastIndexOf("."));
                            fileExtention = file.FileName.Substring(file.FileName.LastIndexOf('.')).ToLower().ToString();

                            string NewFileName = string.Empty;

                            BLL.gigade.Common.HashEncrypt hash = new BLL.gigade.Common.HashEncrypt();
                            NewFileName = hash.Md5Encrypt(fileName, "32");
                            //判斷目錄是否存在,不存在則創建
                            FTP f_cf = new FTP();
                            f_cf.MakeMultiDirectory(localBannerPath.Substring(0, localBannerPath.Length - PaperPath.Length + 1), PaperPath.Substring(1, PaperPath.Length - 2).Split('/'), ftpuser, ftppwd);

                            fileName = NewFileName + fileExtention;
                            NewFileName = localBannerPath + NewFileName + fileExtention;//絕對路徑

                            string ErrorMsg = string.Empty;

                            bool result = fileLoad.UpLoadFile(file, ServerPath, NewFileName, extention, int.Parse(maxValue), int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd);
                            if (result)//上傳成功
                            {
                                p.paperBanner = fileName;
                                //上傳新圖片成功后,再刪除舊的圖片
                                CommonFunction.DeletePicFile(ServerPath + oldImg);//刪除本地圖片
                                FTP ftp = new FTP(localBannerPath, ftpuser, ftppwd);
                                List<string> tem = ftp.GetFileList();
                                if (tem.Contains(oldImg))
                                {
                                    FTP ftps = new FTP(localBannerPath + oldImg, ftpuser, ftppwd);
                                    ftps.DeleteFile(localBannerPath + oldImg);//刪除ftp:71.159上的舊圖片
                                }
                            }
                            else
                            {
                                p.paperBanner = oldImg;
                            }
                        }
                        else
                        {
                            //上傳之前刪除已有的圖片
                            CommonFunction.DeletePicFile(ServerPath + oldImg);//刪除本地圖片
                            FTP ftp = new FTP(localBannerPath, ftpuser, ftppwd);
                            List<string> tem = ftp.GetFileList();
                            if (tem.Contains(oldImg))
                            {
                                FTP ftps = new FTP(localBannerPath + oldImg, ftpuser, ftppwd);
                                ftps.DeleteFile(localBannerPath + oldImg);//刪除ftp:71.159上的舊圖片
                            }
                            p.paperBanner = "";
                        }

                    }
                }

                #region 新增
                if (String.IsNullOrEmpty(Request.Params["paper_id"]))
                {
                    if (_paperMgr.Add(p) > 0)
                    {
                        json = "{success:true,msg:\"" + "新增成功!" + "\"}";
                    }

                }
                #endregion
                #region 編輯
                else
                {
                    p.paperID = int.Parse(Request.Params["paper_id"]);
                    p.modifier = int.Parse((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString());
                    if (_paperMgr.Update(p) > 0)
                    {
                        json = "{success:true,msg:\"" + "修改成功!" + "\"}";
                    }

                }
                #endregion
            }
            catch (Exception ex)
            {
                json = "{success:false,msg:\"" + "異常" + "\"}";
                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(json);
            this.Response.End();
            return this.Response;

        }
Beispiel #21
0
        public HttpResponseBase SaveVendor()
        {
            string jsonStr = String.Empty;
            try
            {
                VendorQuery venQuery = new VendorQuery();

                venQuery.user_type = 2;//變更者類型1.供應商2.管理員
                if (Request.Params["vendor_id"].ToString() == "")
                {
                    #region 獲取供應商數據
                    if (!string.IsNullOrEmpty(Request.Params["vendor_status"].ToString()))
                    {
                        venQuery.vendor_status = Convert.ToUInt32(Request.Params["vendor_status"].ToString());
                    }
                    else
                    {
                        venQuery.vendor_status = 1;
                    }

                    _vendorMgr = new VendorMgr(connectionString);
                    if (!string.IsNullOrEmpty(Request.Params["vendor_email"].ToString()))
                    {
                        try
                        {
                            if (_vendorMgr.IsExitEmail(Request.Params["vendor_email"].ToString().ToLower()) != 0)
                            {
                                jsonStr = "{success:true,msg:0}";//返回json數據
                                this.Response.Clear();
                                this.Response.Write(jsonStr);
                                this.Response.End();
                                return this.Response;
                            }
                            else
                            {
                                venQuery.vendor_email = Request.Params["vendor_email"].Trim().ToLower();
                            }
                        }
                        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);
                            jsonStr = "{success:false,msg:1}";
                            this.Response.Clear();
                            this.Response.Write(jsonStr);
                            this.Response.End();
                            return this.Response;
                        }
                    }
                    else
                    {
                        venQuery.vendor_email = "";
                    }

                    BLL.gigade.Common.HashEncrypt hash = new BLL.gigade.Common.HashEncrypt();
                    if (!string.IsNullOrEmpty(Request.Params["vendor_password"].ToString()))
                    {
                        venQuery.vendor_password = hash.SHA256Encrypt(Request.Params["vendor_password"].ToString());
                    }
                    else
                    {
                        //新增供應商時如果未設置密碼則將統一編號進行加密作為密碼進行保存
                        venQuery.vendor_password = hash.SHA256Encrypt(Request.Params["vendor_invoice"]);
                    }

                    if (!string.IsNullOrEmpty(Request.Params["vendor_name_full"].ToString()))
                    {
                        venQuery.vendor_name_full = Request.Params["vendor_name_full"].ToString().Trim();
                    }
                    else
                    {
                        venQuery.vendor_name_full = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["vendor_name_simple"].ToString()))
                    {
                        venQuery.vendor_name_simple = Request.Params["vendor_name_simple"].ToString().Trim();
                    }
                    else
                    {
                        venQuery.vendor_name_simple = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["vendor_invoice"].ToString()))
                    {
                        venQuery.vendor_invoice = Request.Params["vendor_invoice"].ToString();
                    }
                    else
                    {
                        venQuery.vendor_invoice = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["company_phone"].ToString()))
                    {
                        venQuery.company_phone = Request.Params["company_phone"].ToString();
                    }
                    else
                    {
                        venQuery.company_phone = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["company_fax"].ToString()))
                    {
                        venQuery.company_fax = Request.Params["company_fax"].ToString();
                    }
                    else
                    {
                        venQuery.company_fax = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["company_person"].ToString()))
                    {
                        venQuery.company_person = Request.Params["company_person"].ToString();
                    }
                    else
                    {
                        venQuery.company_person = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["company_zip"].ToString()))
                    {
                        venQuery.company_zip = Convert.ToUInt32(Request.Params["company_zip"].ToString());
                    }
                    else
                    {
                        venQuery.company_zip = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["company_address"].ToString()))
                    {
                        venQuery.company_address = Request.Params["company_address"].ToString();
                    }
                    else
                    {
                        venQuery.company_address = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["invoice_zip"].ToString()))
                    {
                        venQuery.invoice_zip = Convert.ToUInt32(Request.Params["invoice_zip"].ToString());
                    }
                    else
                    {
                        venQuery.invoice_zip = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["invoice_address"].ToString()))
                    {
                        venQuery.invoice_address = Request.Params["invoice_address"].ToString();
                    }
                    else
                    {
                        venQuery.invoice_address = "";
                    }

                    if (!string.IsNullOrEmpty(Request.Params["pm"].ToString()))
                    {
                        venQuery.product_manage = Convert.ToUInt32(Request.Params["pm"].ToString());
                    }
                    else
                    {
                        venQuery.product_manage = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["cost_percent"].ToString()))
                    {
                        venQuery.cost_percent = Convert.ToUInt32(Request.Params["cost_percent"].ToString());
                    }
                    else
                    {
                        venQuery.cost_percent = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["creditcard_1_percent"].ToString()))
                    {
                        venQuery.creditcard_1_percent = Convert.ToUInt32(Request.Params["creditcard_1_percent"].ToString());
                    }
                    else
                    {
                        venQuery.creditcard_1_percent = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["creditcard_3_percent"].ToString()))
                    {
                        venQuery.creditcard_3_percent = Request.Params["creditcard_3_percent"].ToString();
                    }
                    else
                    {
                        venQuery.creditcard_3_percent = "0";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["agreement_createdate"].ToString()))
                    {
                        venQuery.agreement_createdate = Convert.ToUInt32(CommonFunction.GetPHPTime(Request.Params["agreement_createdate"].ToString()));

                    }
                    else
                    {
                        venQuery.agreement_createdate = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["agreement_start"].ToString()))
                    {
                        venQuery.agreement_start = Convert.ToUInt32(CommonFunction.GetPHPTime(Request.Params["agreement_start"].ToString()));
                    }
                    else
                    {
                        venQuery.agreement_start = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["agreement_end"].ToString()))
                    {
                        venQuery.agreement_end = Convert.ToUInt32(CommonFunction.GetPHPTime(Request.Params["agreement_end"].ToString()));
                    }
                    else
                    {
                        venQuery.agreement_end = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["checkout_type"].ToString()))
                    {
                        venQuery.checkout_type = Convert.ToUInt32(Request.Params["checkout_type"].ToString());
                    }
                    else
                    {
                        venQuery.checkout_type = 1;
                    }
                    if (venQuery.checkout_type == 3)
                    {
                        if (!string.IsNullOrEmpty(Request.Params["checkout_other"].ToString()))
                        {
                            venQuery.checkout_other = Request.Params["checkout_other"].ToString();
                        }
                        else
                        {
                            venQuery.checkout_other = "";
                        }
                    }
                    if (!string.IsNullOrEmpty(Request.Params["bank_code"].ToString()))
                    {
                        venQuery.bank_code = Request.Params["bank_code"].ToString();
                    }
                    else
                    {
                        venQuery.bank_code = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["bank_name"].ToString()))
                    {
                        venQuery.bank_name = Request.Params["bank_name"].ToString();
                    }
                    else
                    {
                        venQuery.bank_name = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["bank_number"].ToString()))
                    {
                        venQuery.bank_number = Request.Params["bank_number"].ToString();
                    }
                    else
                    {
                        venQuery.bank_number = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["bank_account"].ToString()))
                    {
                        venQuery.bank_account = Request.Params["bank_account"].ToString();
                    }
                    else
                    {
                        venQuery.bank_account = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["bank_number"].ToString()))
                    {
                        venQuery.bank_number = Request.Params["bank_number"].ToString();
                    }
                    else
                    {
                        venQuery.bank_number = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["freight_low_limit"].ToString()))
                    {
                        venQuery.freight_low_limit = Convert.ToUInt32(Request.Params["freight_low_limit"].ToString());
                    }
                    else
                    {
                        venQuery.freight_low_limit = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["freight_low_money"].ToString()))
                    {
                        venQuery.freight_low_money = Convert.ToUInt32(Request.Params["freight_low_money"].ToString());
                    }
                    else
                    {
                        venQuery.freight_low_money = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["freight_return_low_money"].ToString()))
                    {
                        venQuery.freight_return_low_money = Convert.ToUInt32(Request.Params["freight_return_low_money"].ToString());
                    }
                    else
                    {
                        venQuery.freight_return_low_money = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["freight_normal_limit"].ToString()))
                    {
                        venQuery.freight_normal_limit = Convert.ToUInt32(Request.Params["freight_normal_limit"].ToString());
                    }
                    else
                    {
                        venQuery.freight_normal_limit = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["freight_normal_money"].ToString()))
                    {
                        venQuery.freight_normal_money = Convert.ToUInt32(Request.Params["freight_normal_money"].ToString());
                    }
                    else
                    {
                        venQuery.freight_normal_money = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["freight_return_normal_money"].ToString()))
                    {
                        venQuery.freight_return_normal_money = Convert.ToUInt32(Request.Params["freight_return_normal_money"].ToString());
                    }
                    else
                    {
                        venQuery.freight_return_normal_money = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["assist"].ToString()))
                    {
                        venQuery.assist = Convert.ToUInt32(Request.Params["assist"].ToString());
                    }
                    else
                    {
                        venQuery.assist = 0;
                    }
                    //if (!string.IsNullOrEmpty(Request.Params["dispatch"].ToString()))
                    //{
                    //    venQuery.dispatch = Convert.ToUInt32(Request.Params["dispatch"].ToString());
                    //}
                    //else
                    //{
                    //    venQuery.dispatch = 0;
                    //}
                    //if (!string.IsNullOrEmpty(Request.Params["product_mode"].ToString()))
                    //{
                    //    venQuery.product_mode = Convert.ToUInt32(Request.Params["product_mode"].ToString());
                    //}
                    //else
                    //{
                    //    venQuery.product_mode = 1;
                    //}
                    if (!string.IsNullOrEmpty(Request.Params["procurement_days"].ToString()))
                    {
                        venQuery.procurement_days = Convert.ToInt32(Request.Params["procurement_days"].ToString());
                    }
                    else
                    {
                        venQuery.procurement_days = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["self_send_days"].ToString()))
                    {
                        venQuery.self_send_days = Convert.ToInt32(Request.Params["self_send_days"].ToString());
                    }
                    else
                    {
                        venQuery.self_send_days = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["stuff_ware_days"].ToString()))
                    {
                        venQuery.stuff_ware_days = Convert.ToInt32(Request.Params["stuff_ware_days"].ToString());
                    }
                    else
                    {
                        venQuery.stuff_ware_days = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["dispatch_days"].ToString()))
                    {
                        venQuery.dispatch_days = Convert.ToInt32(Request.Params["dispatch_days"].ToString());
                    }
                    else
                    {
                        venQuery.dispatch_days = 0;
                    }

                    if (!string.IsNullOrEmpty(Request.Params["gigade_bunus_percent"].ToString()))
                    {
                        venQuery.gigade_bunus_percent = Convert.ToUInt32(Request.Params["gigade_bunus_percent"].ToString());
                    }
                    else
                    {
                        venQuery.gigade_bunus_percent = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["gigade_bunus_threshold"].ToString()))
                    {
                        venQuery.gigade_bunus_threshold = Convert.ToUInt32(Request.Params["gigade_bunus_threshold"].ToString());
                    }
                    else
                    {
                        venQuery.gigade_bunus_threshold = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["vendor_note"].ToString()))
                    {
                        venQuery.vendor_note = Request.Params["vendor_note"].ToString();
                    }
                    else
                    {
                        venQuery.vendor_note = "";
                    }

                    if (!string.IsNullOrEmpty(Request.Params["prod_cate"].ToString()))
                    {
                        venQuery.prod_cate = Request.Params["prod_cate"].ToString();
                    }
                    else
                    {
                        venQuery.prod_cate = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["buy_cate"].ToString()))
                    {
                        venQuery.buy_cate = Request.Params["buy_cate"].ToString();
                    }
                    else
                    {
                        venQuery.buy_cate = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["tax_type"].ToString()))
                    {
                        venQuery.tax_type = Request.Params["tax_type"].ToString();
                    }
                    else
                    {
                        venQuery.tax_type = "";
                    }
                    #endregion

                    #region   //對聯絡人的 信息處理


                    if (!string.IsNullOrEmpty(Request.Params["conactValues"].ToString()))
                    {
                        string contact = Request.Params["conactValues"].ToString();
                        string[] contactarr = contact.Split('|');
                        string[] contact1;
                        for (int i = 0; i < contactarr.Length - 1; i++)
                        {
                            contact1 = contactarr[i].Split(',');
                            if (i == 0)
                            {
                                venQuery.contact_type_1 = 4;
                                venQuery.contact_name_1 = contact1[1];
                                venQuery.contact_phone_1_1 = contact1[2];
                                venQuery.contact_phone_2_1 = contact1[3];
                                venQuery.contact_mobile_1 = contact1[4];
                                venQuery.contact_email_1 = contact1[5].ToLower();
                            }
                            else if (i == 1)
                            {
                                venQuery.contact_type_2 = Convert.ToUInt32(ContactType(contact1[0].ToString()));
                                venQuery.contact_name_2 = contact1[1];
                                venQuery.contact_phone_1_2 = contact1[2];
                                venQuery.contact_phone_2_2 = contact1[3];
                                venQuery.contact_mobile_2 = contact1[4];
                                venQuery.contact_email_2 = contact1[5].ToLower().ToLower();
                            }
                            else if (i == 2)
                            {
                                venQuery.contact_type_3 = Convert.ToUInt32(ContactType(contact1[0].ToString()));
                                venQuery.contact_name_3 = contact1[1];
                                venQuery.contact_phone_1_3 = contact1[2];
                                venQuery.contact_phone_2_3 = contact1[3];
                                venQuery.contact_mobile_3 = contact1[4];
                                venQuery.contact_email_3 = contact1[5].ToLower();
                            }
                            else if (i == 3)
                            {
                                venQuery.contact_type_4 = Convert.ToUInt32(ContactType(contact1[0].ToString()));
                                venQuery.contact_name_4 = contact1[1];
                                venQuery.contact_phone_1_4 = contact1[2];
                                venQuery.contact_phone_2_4 = contact1[3];
                                venQuery.contact_mobile_4 = contact1[4];
                                venQuery.contact_email_4 = contact1[5].ToLower();
                            }
                            else if (i == 4)
                            {
                                venQuery.contact_type_5 = Convert.ToUInt32(ContactType(contact1[0].ToString()));
                                venQuery.contact_name_5 = contact1[1];
                                venQuery.contact_phone_1_5 = contact1[2];
                                venQuery.contact_phone_2_5 = contact1[3];
                                venQuery.contact_mobile_5 = contact1[4];
                                venQuery.contact_email_5 = contact1[5].ToLower();
                            }

                        }


                    }
                    #endregion
                    venQuery.ip = Request.UserHostAddress;
                    venQuery.file_name = "VendorList.chtml";
                    venQuery.created = DateTime.Now;
                    venQuery.kuser_id = Convert.ToUInt32((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString());
                    venQuery.export_flag = 1;
                    venQuery.kuser = (int)venQuery.kuser_id;
                    venQuery.kdate = venQuery.created;
                    //供應商類型
                    if (!string.IsNullOrEmpty(Request.Params["gigade_vendor_type"]))
                    {
                        venQuery.vendor_type = Request.Params["gigade_vendor_type"].ToString();
                    }
                    mgr = new CallerMgr(connectionString);
                    Caller caller = new Caller();
                    caller = mgr.GetUserById(Convert.ToInt32(venQuery.kuser_id));
                    venQuery.kuser_name = caller.user_username;

                    return VendorAdd(venQuery);
                }
                else
                {
                    venQuery.vendor_id = Convert.ToUInt32(Request.Params["vendor_id"].ToString());
                    venQuery.vendor_code = Request.Params["vendor_code"].ToString();
                    _vendorMgr = new VendorMgr(connectionString);
                    _configMgr = new ConfigMgr(connectionString);
                    Vendor oldven = _vendorMgr.GetSingle(venQuery);
                    StringBuilder update_log = new StringBuilder();
                    List<TableChangeLog> list = new List<TableChangeLog>();

                    #region 獲取供應商數據
                    uint isUint = 0;//判斷字符串是否能夠轉換為uint類型
                    if (uint.TryParse(Request.Params["vendor_status"].ToString(), out isUint))
                    {
                        venQuery.vendor_status = Convert.ToUInt32(Request.Params["vendor_status"].ToString());
                        if (oldven.vendor_status != venQuery.vendor_status)
                        {//1:啟用2:停用3:失格
                            // update_log.AppendFormat("vendor_status:{0}:{1}:供應商狀態#", oldven.vendor_status, venQuery.vendor_status);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "vendor_status";
                            item.old_value = oldven.vendor_status.ToString();
                            item.new_value = venQuery.vendor_status.ToString();
                            item.field_ch_name = "供應商狀態";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.vendor_status = oldven.vendor_status;
                    }
                    //供應商類型
                    if (!string.IsNullOrEmpty(Request.Params["gigade_vendor_type"]))
                    {
                        venQuery.vendor_type = Request.Params["gigade_vendor_type"].ToString();

                    }
                    int tmp = 0;
                    string[] strs = venQuery.vendor_type.Split(',');
                    for (int i = 0; i < strs.Length; i++)
                    {
                        if (!int.TryParse(strs[i], out tmp))
                        {
                            venQuery.vendor_type = oldven.vendor_type;
                            break;
                        }
                    }
                    if (oldven.vendor_type != venQuery.vendor_type)
                    {
                        // update_log.AppendFormat("vendor_type:{0}:{1}:供應商類型#", oldven.vendor_type, venQuery.vendor_type);
                        TableChangeLog item = new TableChangeLog();
                        item.change_field = "vendor_type";
                        item.old_value = oldven.vendor_type;
                        item.new_value = venQuery.vendor_type;
                        item.field_ch_name = "供應商類型";
                        list.Add(item);
                    }
                    if (!string.IsNullOrEmpty(Request.Params["vendor_email"].ToString()))
                    {
                        int total = _vendorMgr.IsExitEmail(Request.Params["vendor_email"].ToString().ToLower());
                        try
                        {
                            if (total > 1)
                            {
                                jsonStr = "{success:true,msg:0}";//返回json數據
                                this.Response.Clear();
                                this.Response.Write(jsonStr);
                                this.Response.End();
                                return this.Response;
                            }
                            else
                            {
                                if (total == 1)
                                {
                                    if (Request.Params["vendor_email"].ToString().ToLower() == oldven.vendor_email.ToLower())
                                    {
                                        venQuery.vendor_email = oldven.vendor_email.ToLower();
                                    }
                                    else
                                    {
                                        jsonStr = "{success:true,msg:0}";//返回json數據rue
                                        this.Response.Clear();
                                        this.Response.Write(jsonStr);
                                        this.Response.End();
                                        return this.Response;
                                    }
                                }
                                else if (total == 0)
                                {
                                    venQuery.vendor_email = Request.Params["vendor_email"].ToString().ToLower();
                                    if (oldven.vendor_email != venQuery.vendor_email)
                                    {
                                        // update_log.AppendFormat("vendor_email:{0}:{1}:公司Email#", oldven.vendor_email, venQuery.vendor_email);
                                        TableChangeLog item = new TableChangeLog();
                                        item.change_field = "vendor_email";
                                        item.old_value = oldven.vendor_email;
                                        item.new_value = venQuery.vendor_email;
                                        item.field_ch_name = "公司Email";
                                        list.Add(item);
                                    }
                                }
                            }
                        }
                        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);
                            jsonStr = "{success:false,msg:1}";
                            this.Response.Clear();
                            this.Response.Write(jsonStr);
                            this.Response.End();
                            return this.Response;
                        }
                    }
                    else
                    {
                        venQuery.vendor_email = oldven.vendor_email;
                    }
                    //if (!string.IsNullOrEmpty(Request.Params["vendor_password"].ToString()))
                    //{
                    //    BLL.gigade.Common.HashEncrypt hash = new BLL.gigade.Common.HashEncrypt();
                    //    venQuery.vendor_password = hash.SHA256Encrypt(Request.Params["vendor_password"].ToString());
                    //}
                    //else
                    //{
                    //    venQuery.vendor_password = oldven.vendor_password;
                    //}
                    if (!string.IsNullOrEmpty(Request.Params["vendor_name_full"].ToString()))
                    {
                        venQuery.vendor_name_full = Request.Params["vendor_name_full"].ToString().Trim();
                    }
                    else
                    {
                        venQuery.vendor_name_full = oldven.vendor_name_full;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["vendor_name_simple"].ToString()))
                    {
                        venQuery.vendor_name_simple = Request.Params["vendor_name_simple"].ToString().Trim();
                    }
                    else
                    {
                        venQuery.vendor_name_simple = oldven.vendor_name_simple;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["vendor_invoice"].ToString()))
                    {
                        venQuery.vendor_invoice = Request.Params["vendor_invoice"].ToString();
                        if (oldven.vendor_invoice != venQuery.vendor_invoice)
                        {
                            // update_log.AppendFormat("vendor_invoice:{0}:{1}:統一編號#", oldven.vendor_invoice, venQuery.vendor_invoice);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "vendor_invoice";
                            item.old_value = oldven.vendor_invoice;
                            item.new_value = venQuery.vendor_invoice;
                            item.field_ch_name = "統一編號";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.vendor_invoice = oldven.vendor_invoice;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["company_phone"].ToString()))
                    {
                        venQuery.company_phone = Request.Params["company_phone"].ToString();
                        if (oldven.company_phone != venQuery.company_phone)
                        {
                            //update_log.AppendFormat("company_phone:{0}:{1}:公司電話#", oldven.company_phone, venQuery.company_phone);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "company_phone";
                            item.old_value = oldven.company_phone;
                            item.new_value = venQuery.company_phone;
                            item.field_ch_name = "公司電話";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.company_phone = oldven.company_phone;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["company_fax"].ToString()))
                    {
                        venQuery.company_fax = Request.Params["company_fax"].ToString();
                        if (oldven.company_fax != venQuery.company_fax)
                        {
                            // update_log.AppendFormat("company_fax:{0}:{1}:公司傳真#", oldven.company_fax, venQuery.company_fax);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "company_fax";
                            item.old_value = oldven.company_fax;
                            item.new_value = venQuery.company_fax;
                            item.field_ch_name = "公司傳真";
                            list.Add(item);
                        }
                    }


                    if (!string.IsNullOrEmpty(Request.Params["company_person"].ToString()))
                    {
                        venQuery.company_person = Request.Params["company_person"].ToString();
                        if (oldven.company_person != venQuery.company_person)
                        {
                            //update_log.AppendFormat("company_person:{0}:{1}:公司負責人#", oldven.company_person, venQuery.company_person);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "company_person";
                            item.old_value = oldven.company_person;
                            item.new_value = venQuery.company_person;
                            item.field_ch_name = "公司負責人";
                            list.Add(item);
                        }
                    }

                    if (!string.IsNullOrEmpty(Request.Params["company_zip"].ToString()))
                    {

                        venQuery.company_zip = Convert.ToUInt32(Request.Params["company_zip"].ToString());

                    }

                    venQuery.company_address = Request.Params["company_address"].ToString();
                    if (oldven.company_zip != venQuery.company_zip || oldven.company_address != venQuery.company_address)
                    {
                        //update_log.AppendFormat("company_address:{0}:{1}:公司地址#", oldven.company_zip + "&" + oldven.company_address, venQuery.company_zip + "&" + venQuery.company_address);
                        TableChangeLog item = new TableChangeLog();
                        item.change_field = "company_address";
                        item.old_value = oldven.company_zip + "&" + oldven.company_address;
                        item.new_value = venQuery.company_zip + "&" + venQuery.company_address;
                        item.field_ch_name = "公司地址";
                        list.Add(item);
                    }
                    if (!string.IsNullOrEmpty(Request.Params["invoice_zip"].ToString()))
                    {
                        venQuery.invoice_zip = Convert.ToUInt32(Request.Params["invoice_zip"].ToString());
                    }

                    venQuery.invoice_address = Request.Params["invoice_address"].ToString();

                    if (oldven.invoice_zip != venQuery.invoice_zip || oldven.invoice_address != venQuery.invoice_address)
                    {
                        //update_log.AppendFormat("invoice_address:{0}:{1}:發票地址#", oldven.invoice_zip + "&" + oldven.invoice_address, venQuery.invoice_zip + "&" + venQuery.invoice_address);
                        TableChangeLog item = new TableChangeLog();
                        item.change_field = "invoice_address";
                        item.old_value = oldven.invoice_zip + "&" + oldven.invoice_address;
                        item.new_value = venQuery.invoice_zip + "&" + venQuery.invoice_address;
                        item.field_ch_name = "發票地址";
                        list.Add(item);
                    }
                    venQuery.erp_id = oldven.erp_id;
                    if (uint.TryParse(Request.Params["cost_percent"].ToString(), out isUint))
                    {
                        venQuery.cost_percent = Convert.ToUInt32(Request.Params["cost_percent"].ToString());
                        if (oldven.cost_percent != venQuery.cost_percent)
                        {
                            //update_log.AppendFormat("cost_percent:{0}:{1}:成本百分比#", oldven.cost_percent, venQuery.cost_percent);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "cost_percent";
                            item.old_value = oldven.cost_percent.ToString();
                            item.new_value = venQuery.cost_percent.ToString();
                            item.field_ch_name = "成本百分比";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.cost_percent = 0;
                    }


                    if (uint.TryParse(Request.Params["creditcard_1_percent"].ToString(), out isUint))
                    {
                        venQuery.creditcard_1_percent = Convert.ToUInt32(Request.Params["creditcard_1_percent"].ToString());
                    }
                    else
                    {
                        venQuery.creditcard_1_percent = 0;
                    }

                    if (!string.IsNullOrEmpty(Request.Params["creditcard_3_percent"].ToString()))
                    {
                        venQuery.creditcard_3_percent = Request.Params["creditcard_3_percent"].ToString();
                    }
                    else
                    {
                        venQuery.creditcard_3_percent = "0";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["agreement_createdate"].ToString()))
                    {
                        venQuery.agreement_createdate = Convert.ToUInt32(CommonFunction.GetPHPTime(Request.Params["agreement_createdate"].ToString()));
                        if (oldven.agreement_createdate != venQuery.agreement_createdate)
                        {

                            //update_log.AppendFormat("agreement_createdate:{0}:{1}:合約簽訂日期#", CommonFunction.GetNetTime(oldven.agreement_createdate).ToShortDateString(), CommonFunction.GetNetTime(venQuery.agreement_createdate).ToShortDateString());
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "agreement_createdate";
                            item.old_value = CommonFunction.GetNetTime(oldven.agreement_createdate).ToShortDateString();
                            item.new_value = CommonFunction.GetNetTime(venQuery.agreement_createdate).ToShortDateString();
                            item.field_ch_name = "合約簽訂日期";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.agreement_createdate = oldven.agreement_createdate;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["agreement_start"].ToString()))
                    {
                        venQuery.agreement_start = Convert.ToUInt32(CommonFunction.GetPHPTime(Request.Params["agreement_start"].ToString()));
                        if (oldven.agreement_start != venQuery.agreement_start)
                        {
                            // update_log.AppendFormat("agreement_start:{0}:{1}:合約開始日#", CommonFunction.GetNetTime(oldven.agreement_start).ToShortDateString(), CommonFunction.GetNetTime(venQuery.agreement_start).ToShortDateString());
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "agreement_start";
                            item.old_value = CommonFunction.GetNetTime(oldven.agreement_start).ToShortDateString();
                            item.new_value = CommonFunction.GetNetTime(venQuery.agreement_start).ToShortDateString();
                            item.field_ch_name = "合約開始日";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.agreement_start = oldven.agreement_start;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["agreement_end"].ToString()))
                    {
                        venQuery.agreement_end = Convert.ToUInt32(CommonFunction.GetPHPTime(Request.Params["agreement_end"].ToString()));
                        if (oldven.agreement_end != venQuery.agreement_end)
                        {
                            // update_log.AppendFormat("agreement_end:{0}:{1}:合約結束日#", CommonFunction.GetNetTime(oldven.agreement_end).ToShortDateString(), CommonFunction.GetNetTime(venQuery.agreement_end).ToShortDateString());
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "agreement_end";
                            item.old_value = CommonFunction.GetNetTime(oldven.agreement_end).ToShortDateString();
                            item.new_value = CommonFunction.GetNetTime(venQuery.agreement_end).ToShortDateString();
                            item.field_ch_name = "合約結束日";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.agreement_end = oldven.agreement_end;
                    }
                    if (uint.TryParse(Request.Params["checkout_type"].ToString(), out isUint))
                    {
                        venQuery.checkout_type = Convert.ToUInt32(Request.Params["checkout_type"].ToString());
                    }
                    else
                    {
                        venQuery.checkout_type = oldven.checkout_type;
                    }
                    if (venQuery.checkout_type == 3)
                    {
                        if (!string.IsNullOrEmpty(Request.Params["checkout_other"].ToString()))
                        {
                            venQuery.checkout_other = Request.Params["checkout_other"].ToString();
                        }
                        else
                        {
                            venQuery.checkout_other = oldven.checkout_other;
                        }
                    }
                    if (!string.IsNullOrEmpty(Request.Params["bank_code"].ToString()))
                    {
                        venQuery.bank_code = Request.Params["bank_code"].ToString();
                        if (oldven.bank_code != venQuery.bank_code)
                        {
                            //update_log.AppendFormat("bank_code:{0}:{1}:銀行代碼#", oldven.bank_code, venQuery.bank_code);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "bank_code";
                            item.old_value = oldven.bank_code;
                            item.new_value = venQuery.bank_code;
                            item.field_ch_name = "銀行代碼";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.bank_code = oldven.bank_code;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["bank_name"].ToString()))
                    {
                        venQuery.bank_name = Request.Params["bank_name"].ToString();
                        if (oldven.bank_name != venQuery.bank_name)
                        {
                            //update_log.AppendFormat("bank_name:{0}:{1}:銀行名稱#", oldven.bank_name, venQuery.bank_name);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "bank_name";
                            item.old_value = oldven.bank_name;
                            item.new_value = venQuery.bank_name;
                            item.field_ch_name = "銀行名稱";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.bank_name = oldven.bank_name;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["bank_number"].ToString()))
                    {
                        venQuery.bank_number = Request.Params["bank_number"].ToString();
                        if (oldven.bank_number != venQuery.bank_number)
                        {
                            // update_log.AppendFormat("bank_number:{0}:{1}:銀行賬號#", oldven.bank_number, venQuery.bank_number);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "bank_number";
                            item.old_value = oldven.bank_number;
                            item.new_value = venQuery.bank_number;
                            item.field_ch_name = "銀行賬號";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.bank_number = oldven.bank_number;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["bank_account"].ToString()))
                    {
                        venQuery.bank_account = Request.Params["bank_account"].ToString();
                        if (oldven.bank_account != venQuery.bank_account)
                        {
                            //update_log.AppendFormat("bank_account:{0}:{1}:銀行戶名#", oldven.bank_account, venQuery.bank_account);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "bank_account";
                            item.old_value = oldven.bank_account;
                            item.new_value = venQuery.bank_account;
                            item.field_ch_name = "銀行戶名";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.bank_account = oldven.bank_account;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["bank_number"].ToString()))
                    {
                        venQuery.bank_number = Request.Params["bank_number"].ToString();
                    }
                    else
                    {
                        venQuery.bank_number = oldven.bank_number;
                    }

                    if (uint.TryParse(Request.Params["freight_low_limit"].ToString(), out isUint))
                    {
                        venQuery.freight_low_limit = Convert.ToUInt32(Request.Params["freight_low_limit"].ToString());
                    }
                    else
                    {
                        venQuery.freight_low_limit = 0;
                    }
                    if (uint.TryParse(Request.Params["freight_low_money"].ToString(), out isUint))
                    {
                        venQuery.freight_low_money = Convert.ToUInt32(Request.Params["freight_low_money"].ToString());
                    }
                    else
                    {
                        venQuery.freight_low_money = 0;
                    }
                    if (uint.TryParse(Request.Params["freight_return_low_money"].ToString(), out isUint))
                    {
                        venQuery.freight_return_low_money = Convert.ToUInt32(Request.Params["freight_return_low_money"].ToString());
                    }
                    else
                    {
                        venQuery.freight_return_low_money = 0;
                    }
                    if (uint.TryParse(Request.Params["freight_normal_limit"].ToString(), out isUint))
                    {
                        venQuery.freight_normal_limit = Convert.ToUInt32(Request.Params["freight_normal_limit"].ToString());
                    }
                    else
                    {
                        venQuery.freight_normal_limit = 0;
                    }
                    if (uint.TryParse(Request.Params["freight_normal_money"].ToString(), out isUint))
                    {
                        venQuery.freight_normal_money = Convert.ToUInt32(Request.Params["freight_normal_money"].ToString());
                    }
                    else
                    {
                        venQuery.freight_normal_money = 0;
                    }
                    if (uint.TryParse(Request.Params["freight_return_normal_money"].ToString(), out isUint))
                    {
                        venQuery.freight_return_normal_money = Convert.ToUInt32(Request.Params["freight_return_normal_money"].ToString());
                    }
                    else
                    {
                        venQuery.freight_return_normal_money = 0;
                    }
                    if (uint.TryParse(Request.Params["assist"].ToString(), out isUint))
                    {
                        venQuery.assist = Convert.ToUInt32(Request.Params["assist"].ToString());
                    }
                    else
                    {
                        venQuery.assist = venQuery.assist;
                    }
                    //if (uint.TryParse(Request.Params["dispatch"].ToString(), out isUint))
                    //{
                    //    venQuery.dispatch = Convert.ToUInt32(Request.Params["dispatch"].ToString());
                    //}
                    //else
                    //{
                    //    venQuery.dispatch = 0;
                    //}
                    //if (uint.TryParse(Request.Params["product_mode"].ToString(), out isUint))
                    //{
                    //    venQuery.product_mode = Convert.ToUInt32(Request.Params["product_mode"].ToString());
                    //}
                    //else
                    //{
                    //    venQuery.product_mode = 0;
                    //}
                    //try
                    //{
                    //    //Regex email = new System.Text.RegularExpressions.Regex("(([a-z0-9]{1})([\\.a-z0-9_-]*)@([a-z0-9]+)(\\.([a-z0-9]+)){1,3})");
                    //    //Regex name = new System.Text.RegularExpressions.Regex("[\u4e00-\u9fa5]");
                    //    //if (email.IsMatch(Request.Params["pm"].ToString()))
                    //    //{
                    //    //    venQuery.product_manage = _configMgr.QueryByEmail(Request.Params["pm"].ToString());
                    //    //}
                    //    //else if (name.IsMatch(Request.Params["pm"].ToString()))
                    //    //{
                    //    //    venQuery.product_manage = _configMgr.QueryByName(Request.Params["pm"].ToString());
                    //    //}
                    //}
                    //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);
                    //    venQuery.product_manage = 0;
                    //}
                    if (!string.IsNullOrEmpty(Request.Params["procurement_days"].ToString()))
                    {
                        venQuery.procurement_days = Convert.ToInt32(Request.Params["procurement_days"].ToString());
                    }
                    else
                    {
                        venQuery.procurement_days = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["self_send_days"].ToString()))
                    {
                        venQuery.self_send_days = Convert.ToInt32(Request.Params["self_send_days"].ToString());
                        if (oldven.self_send_days != venQuery.self_send_days)
                        {
                            //update_log.AppendFormat("self_send_days:{0}:{1}:自出出貨天數#", oldven.self_send_days, venQuery.self_send_days);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "self_send_days";
                            item.old_value = oldven.self_send_days.ToString();
                            item.new_value = venQuery.self_send_days.ToString();
                            item.field_ch_name = "自出出貨天數";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.self_send_days = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["stuff_ware_days"].ToString()))
                    {
                        venQuery.stuff_ware_days = Convert.ToInt32(Request.Params["stuff_ware_days"].ToString());
                        if (oldven.stuff_ware_days != venQuery.stuff_ware_days)
                        {
                            // update_log.AppendFormat("stuff_ware_days:{0}:{1}:寄倉出貨天數#", oldven.stuff_ware_days, venQuery.stuff_ware_days);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "stuff_ware_days";
                            item.old_value = oldven.stuff_ware_days.ToString();
                            item.new_value = venQuery.stuff_ware_days.ToString();
                            item.field_ch_name = "寄倉出貨天數";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.stuff_ware_days = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["dispatch_days"].ToString()))
                    {
                        venQuery.dispatch_days = Convert.ToInt32(Request.Params["dispatch_days"].ToString());
                        if (oldven.dispatch_days != venQuery.dispatch_days)
                        {
                            // update_log.AppendFormat("dispatch_days:{0}:{1}:調度出貨天數#", oldven.dispatch_days, venQuery.dispatch_days);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "dispatch_days";
                            item.old_value = oldven.dispatch_days.ToString();
                            item.new_value = venQuery.dispatch_days.ToString();
                            item.field_ch_name = "調度出貨天數";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.dispatch_days = 0;
                    }
                    if (Request.Params["pm"].ToString() == "")
                    {
                        venQuery.product_manage = 0;
                    }
                    else
                    {
                        if (uint.TryParse(Request.Params["pm"].ToString(), out isUint))
                        {
                            venQuery.product_manage = Convert.ToUInt32(Request.Params["pm"].ToString());
                        }
                        else
                        {
                            venQuery.product_manage = oldven.product_manage;
                        }
                    }
                    if (oldven.product_manage != venQuery.product_manage)
                    {
                        // update_log.AppendFormat("product_manage:{0}:{1}:管理人員#", oldven.product_manage, venQuery.product_manage);
                        TableChangeLog item = new TableChangeLog();
                        item.change_field = "product_manage";
                        item.old_value = oldven.product_manage.ToString();
                        item.new_value = venQuery.product_manage.ToString();
                        item.field_ch_name = "管理人員";
                        list.Add(item);
                    }
                    if (uint.TryParse(Request.Params["gigade_bunus_percent"].ToString(), out isUint))
                    {
                        venQuery.gigade_bunus_percent = Convert.ToUInt32(Request.Params["gigade_bunus_percent"].ToString());
                    }
                    else
                    {
                        venQuery.gigade_bunus_percent = 0;
                    }
                    if (uint.TryParse(Request.Params["gigade_bunus_threshold"].ToString(), out isUint))
                    {
                        venQuery.gigade_bunus_threshold = Convert.ToUInt32(Request.Params["gigade_bunus_threshold"].ToString());
                    }
                    else
                    {
                        venQuery.gigade_bunus_threshold = 0;
                    }
                    venQuery.vendor_note = Request.Params["vendor_note"].ToString();
                    #endregion

                    #region 對聯絡人的 信息處理
                    string delcon = string.Empty;

                    if (!string.IsNullOrEmpty(Request.Params["delconnect"].ToString()))
                    {
                        delcon = Request.Params["delconnect"].ToString().TrimEnd(',');
                        var delArr = delcon.Split(',');
                        int re_1 = 0, re_2 = 0, re_3 = 0;
                        if (delArr.Length == 4)
                        {
                            //update_log.AppendFormat("contact_type_2:{0}:{1}:原第二聯絡人類型#", oldven.contact_type_2, 7);                           
                            //update_log.AppendFormat("contact_name_2:{0}:{1}:原第二聯絡人姓名#", oldven.contact_name_2, "刪除");                          
                            //update_log.AppendFormat("contact_phone_1_2:{0}:{1}:原第二聯絡人電話一#", oldven.contact_phone_1_2, "刪除");
                            //update_log.AppendFormat("contact_phone_2_2:{0}:{1}:原第二聯絡人電話二#", oldven.contact_phone_2_2, "刪除");
                            //update_log.AppendFormat("contact_mobile_2:{0}:{1}:原第二聯絡人手機號碼#", oldven.contact_mobile_2, "刪除");
                            //update_log.AppendFormat("contact_email_2:{0}:{1}:原第二聯絡人郵箱#", oldven.contact_email_2, "刪除");
                            //update_log.AppendFormat("contact_type_3:{0}:{1}:原第三聯絡人類型#", oldven.contact_type_3, 7);
                            //update_log.AppendFormat("contact_name_3:{0}:{1}:原第三聯絡人姓名#", oldven.contact_name_3, "刪除");
                            //update_log.AppendFormat("contact_phone_1_3:{0}:{1}:原第三聯絡人電話一#", oldven.contact_phone_1_3, "刪除");
                            //update_log.AppendFormat("contact_phone_2_3:{0}:{1}:原第三聯絡人電話二#", oldven.contact_phone_2_3, "刪除");
                            //update_log.AppendFormat("contact_mobile_3:{0}:{1}:原第三聯絡人手機號碼#", oldven.contact_mobile_3, "刪除");
                            //update_log.AppendFormat("contact_email_3:{0}:{1}:原第三聯絡人郵箱#", oldven.contact_email_3, "刪除");
                            //update_log.AppendFormat("contact_type_4:{0}:{1}:原第四聯絡人類型#", oldven.contact_type_4, 7);
                            //update_log.AppendFormat("contact_name_4:{0}:{1}:原第四聯絡人姓名#", oldven.contact_name_4, "刪除");
                            //update_log.AppendFormat("contact_phone_1_4:{0}:{1}:原第四聯絡人電話一#", oldven.contact_phone_1_4, "刪除");
                            //update_log.AppendFormat("contact_phone_2_4:{0}:{1}:原第四聯絡人電話二#", oldven.contact_phone_2_4, "刪除");
                            //update_log.AppendFormat("contact_mobile_4:{0}:{1}:原第四聯絡人手機號碼#", oldven.contact_mobile_4, "刪除");
                            //update_log.AppendFormat("contact_email_4:{0}:{1}:原第四聯絡人郵箱#", oldven.contact_email_4, "刪除");
                            //update_log.AppendFormat("contact_type_5:{0}:{1}:第五聯絡人類型#", oldven.contact_type_5, 7);
                            //update_log.AppendFormat("contact_name_5:{0}:{1}:第五聯絡人姓名#", oldven.contact_name_5, "刪除");
                            //update_log.AppendFormat("contact_phone_1_5:{0}:{1}:第五聯絡人電話一#", oldven.contact_phone_1_5, "刪除");
                            //update_log.AppendFormat("contact_phone_2_5:{0}:{1}:第五聯絡人電話二#", oldven.contact_phone_2_5, "刪除");
                            //update_log.AppendFormat("contact_mobile_5:{0}:{1}:第五聯絡人手機號碼#", oldven.contact_mobile_5, "刪除");
                            //update_log.AppendFormat("contact_email_5:{0}:{1}:第五聯絡人郵箱#", oldven.contact_email_5, "刪除");

                            list.Add(new TableChangeLog() { change_field = "contact_type_2", old_value = oldven.contact_type_2.ToString(), new_value = "7", field_ch_name = "原第二聯絡人類型" });
                            list.Add(new TableChangeLog() { change_field = "contact_name_2", old_value = oldven.contact_name_2, new_value = "刪除", field_ch_name = "原第二聯絡人姓名" });
                            list.Add(new TableChangeLog() { change_field = "contact_phone_1_2", old_value = oldven.contact_phone_1_2, new_value = "刪除", field_ch_name = "原第二聯絡人電話一" });
                            list.Add(new TableChangeLog() { change_field = "contact_phone_2_2", old_value = oldven.contact_phone_2_2, new_value = "刪除", field_ch_name = "原第二聯絡人電話二" });
                            list.Add(new TableChangeLog() { change_field = "contact_mobile_2", old_value = oldven.contact_mobile_2, new_value = "刪除", field_ch_name = "原第二聯絡人手機號碼" });
                            list.Add(new TableChangeLog() { change_field = "contact_email_2", old_value = oldven.contact_email_2, new_value = "刪除", field_ch_name = "原第二聯絡人郵箱" });
                            list.Add(new TableChangeLog() { change_field = "contact_type_3", old_value = oldven.contact_type_3.ToString(), new_value = "7", field_ch_name = "原第三聯絡人類型" });
                            list.Add(new TableChangeLog() { change_field = "contact_name_3", old_value = oldven.contact_name_3, new_value = "刪除", field_ch_name = "原第三聯絡人姓名" });
                            list.Add(new TableChangeLog() { change_field = "contact_phone_1_3", old_value = oldven.contact_phone_1_3, new_value = "刪除", field_ch_name = "原第三聯絡人電話一" });
                            list.Add(new TableChangeLog() { change_field = "contact_phone_2_3", old_value = oldven.contact_phone_2_3, new_value = "刪除", field_ch_name = "原第三聯絡人電話二" });
                            list.Add(new TableChangeLog() { change_field = "contact_mobile_3", old_value = oldven.contact_mobile_3, new_value = "刪除", field_ch_name = "原第三聯絡人手機號碼" });
                            list.Add(new TableChangeLog() { change_field = "contact_email_3", old_value = oldven.contact_email_3, new_value = "刪除", field_ch_name = "原第三聯絡人郵箱" });
                            list.Add(new TableChangeLog() { change_field = "contact_type_4", old_value = oldven.contact_type_4.ToString(), new_value = "7", field_ch_name = "原第四聯絡人類型" });
                            list.Add(new TableChangeLog() { change_field = "contact_name_4", old_value = oldven.contact_name_4, new_value = "刪除", field_ch_name = "原第四聯絡人姓名" });
                            list.Add(new TableChangeLog() { change_field = "contact_phone_1_4", old_value = oldven.contact_phone_1_4, new_value = "刪除", field_ch_name = "原第四聯絡人電話一" });
                            list.Add(new TableChangeLog() { change_field = "contact_phone_2_4", old_value = oldven.contact_phone_2_4, new_value = "刪除", field_ch_name = "原第四聯絡人電話二" });
                            list.Add(new TableChangeLog() { change_field = "contact_mobile_4", old_value = oldven.contact_mobile_4, new_value = "刪除", field_ch_name = "原第四聯絡人手機號碼" });
                            list.Add(new TableChangeLog() { change_field = "contact_email_4", old_value = oldven.contact_email_4, new_value = "刪除", field_ch_name = "原第四聯絡人郵箱" });
                            list.Add(new TableChangeLog() { change_field = "contact_type_5", old_value = oldven.contact_type_5.ToString(), new_value = "7", field_ch_name = "第五聯絡人類型" });
                            list.Add(new TableChangeLog() { change_field = "contact_name_5", old_value = oldven.contact_name_5, new_value = "刪除", field_ch_name = "第五聯絡人姓名" });
                            list.Add(new TableChangeLog() { change_field = "contact_phone_1_5", old_value = oldven.contact_phone_1_5, new_value = "刪除", field_ch_name = "第五聯絡人電話一" });
                            list.Add(new TableChangeLog() { change_field = "contact_phone_2_5", old_value = oldven.contact_phone_2_5, new_value = "刪除", field_ch_name = "第五聯絡人電話二" });
                            list.Add(new TableChangeLog() { change_field = "contact_mobile_5", old_value = oldven.contact_mobile_5, new_value = "刪除", field_ch_name = "第五聯絡人手機號碼" });
                            list.Add(new TableChangeLog() { change_field = "contact_email_5", old_value = oldven.contact_email_5, new_value = "刪除", field_ch_name = "第五聯絡人郵箱" });
                        }
                        else
                        {
                            for (int i = 0; i < delArr.Length; i++)
                            {
                                int del = Convert.ToInt32(delArr[i]);

                                if (del == 1 && re_1 == 0 && oldven.contact_type_2 != 0)
                                {
                                    re_1++;
                                    //update_log.AppendFormat("contact_type_2:{0}:{1}:原第二聯絡人類型#", oldven.contact_type_2, 7);
                                    //update_log.AppendFormat("contact_name_2:{0}:{1}:原第二聯絡人姓名#", oldven.contact_name_2, "刪除");
                                    //update_log.AppendFormat("contact_phone_1_2:{0}:{1}:原第二聯絡人電話一#", oldven.contact_phone_1_2, "刪除");
                                    //update_log.AppendFormat("contact_phone_2_2:{0}:{1}:原第二聯絡人電話二#", oldven.contact_phone_2_2, "刪除");
                                    //update_log.AppendFormat("contact_mobile_2:{0}:{1}:原第二聯絡人手機號碼#", oldven.contact_mobile_2, "刪除");
                                    //update_log.AppendFormat("contact_email_2:{0}:{1}:原第二聯絡人郵箱#", oldven.contact_email_2, "刪除");

                                    list.Add(new TableChangeLog() { change_field = "contact_type_2", old_value = oldven.contact_type_2.ToString(), new_value = "7", field_ch_name = "原第二聯絡人類型" });
                                    list.Add(new TableChangeLog() { change_field = "contact_name_2", old_value = oldven.contact_name_2, new_value = "刪除", field_ch_name = "原第二聯絡人姓名" });
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_1_2", old_value = oldven.contact_phone_1_2, new_value = "刪除", field_ch_name = "原第二聯絡人電話一" });
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_2_2", old_value = oldven.contact_phone_2_2, new_value = "刪除", field_ch_name = "原第二聯絡人電話二" });
                                    list.Add(new TableChangeLog() { change_field = "contact_mobile_2", old_value = oldven.contact_mobile_2, new_value = "刪除", field_ch_name = "原第二聯絡人手機號碼" });
                                    list.Add(new TableChangeLog() { change_field = "contact_email_2", old_value = oldven.contact_email_2, new_value = "刪除", field_ch_name = "原第二聯絡人郵箱" });

                                }
                                else if (((del == 2 && re_2 == 0) || re_1 == 1) && oldven.contact_type_3 != 0)
                                {
                                    if (re_1 == 1)
                                    {
                                        re_1++;
                                    }
                                    else
                                    {
                                        re_2++;
                                    }
                                    //update_log.AppendFormat("contact_type_3:{0}:{1}:原第三聯絡人類型#", oldven.contact_type_3, 7);
                                    //update_log.AppendFormat("contact_name_3:{0}:{1}:原第三聯絡人姓名#", oldven.contact_name_3, "刪除");
                                    //update_log.AppendFormat("contact_phone_1_3:{0}:{1}:原第三聯絡人電話一#", oldven.contact_phone_1_3, "刪除");
                                    //update_log.AppendFormat("contact_phone_2_3:{0}:{1}:原第三聯絡人電話二#", oldven.contact_phone_2_3, "刪除");
                                    //update_log.AppendFormat("contact_mobile_3:{0}:{1}:原第三聯絡人手機號碼#", oldven.contact_mobile_3, "刪除");
                                    //update_log.AppendFormat("contact_email_3:{0}:{1}:原第三聯絡人郵箱#", oldven.contact_email_3, "刪除");
                                    list.Add(new TableChangeLog() { change_field = "contact_type_3", old_value = oldven.contact_type_3.ToString(), new_value = "7", field_ch_name = "原第三聯絡人類型" });
                                    list.Add(new TableChangeLog() { change_field = "contact_name_3", old_value = oldven.contact_name_3, new_value = "刪除", field_ch_name = "原第三聯絡人姓名" });
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_1_3", old_value = oldven.contact_phone_1_3, new_value = "刪除", field_ch_name = "原第三聯絡人電話一" });
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_2_3", old_value = oldven.contact_phone_2_3, new_value = "刪除", field_ch_name = "原第三聯絡人電話二" });
                                    list.Add(new TableChangeLog() { change_field = "contact_mobile_3", old_value = oldven.contact_mobile_3, new_value = "刪除", field_ch_name = "原第三聯絡人手機號碼" });
                                    list.Add(new TableChangeLog() { change_field = "contact_email_3", old_value = oldven.contact_email_3, new_value = "刪除", field_ch_name = "原第三聯絡人郵箱" });
                                }
                                else if (((del == 3 && re_3 == 0) || re_1 == 2 || re_2 == 1) && oldven.contact_type_4 != 0)
                                {
                                    if (re_1 == 2)
                                    {
                                        re_1++;
                                    }
                                    else if (re_2 == 1)
                                    {
                                        re_2++;
                                    }
                                    else
                                    {
                                        re_3++;
                                    }
                                    //update_log.AppendFormat("contact_type_4:{0}:{1}:原第四聯絡人類型#", oldven.contact_type_4, 7);
                                    //update_log.AppendFormat("contact_name_4:{0}:{1}:原第四聯絡人姓名#", oldven.contact_name_4, "刪除");
                                    //update_log.AppendFormat("contact_phone_1_4:{0}:{1}:原第四聯絡人電話一#", oldven.contact_phone_1_4, "刪除");
                                    //update_log.AppendFormat("contact_phone_2_4:{0}:{1}:原第四聯絡人電話二#", oldven.contact_phone_2_4, "刪除");
                                    //update_log.AppendFormat("contact_mobile_4:{0}:{1}:原第四聯絡人手機號碼#", oldven.contact_mobile_4, "刪除");
                                    //update_log.AppendFormat("contact_email_4:{0}:{1}:原第四聯絡人郵箱#", oldven.contact_email_4, "刪除");
                                    list.Add(new TableChangeLog() { change_field = "contact_type_4", old_value = oldven.contact_type_4.ToString(), new_value = "7", field_ch_name = "原第四聯絡人類型" });
                                    list.Add(new TableChangeLog() { change_field = "contact_name_4", old_value = oldven.contact_name_4, new_value = "刪除", field_ch_name = "原第四聯絡人姓名" });
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_1_4", old_value = oldven.contact_phone_1_4, new_value = "刪除", field_ch_name = "原第四聯絡人電話一" });
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_2_4", old_value = oldven.contact_phone_2_4, new_value = "刪除", field_ch_name = "原第四聯絡人電話二" });
                                    list.Add(new TableChangeLog() { change_field = "contact_mobile_4", old_value = oldven.contact_mobile_4, new_value = "刪除", field_ch_name = "原第四聯絡人手機號碼" });
                                    list.Add(new TableChangeLog() { change_field = "contact_email_4", old_value = oldven.contact_email_4, new_value = "刪除", field_ch_name = "原第四聯絡人郵箱" });
                                }
                                else if ((del == 4 || re_1 == 3 || re_2 == 2 || re_3 == 1) && oldven.contact_type_5 != 0)
                                {


                                    //update_log.AppendFormat("contact_type_5:{0}:{1}:第五聯絡人類型#", oldven.contact_type_5, 7);
                                    //update_log.AppendFormat("contact_name_5:{0}:{1}:第五聯絡人姓名#", oldven.contact_name_5, "刪除");
                                    //update_log.AppendFormat("contact_phone_1_5:{0}:{1}:第五聯絡人電話一#", oldven.contact_phone_1_5, "刪除");
                                    //update_log.AppendFormat("contact_phone_2_5:{0}:{1}:第五聯絡人電話二#", oldven.contact_phone_2_5, "刪除");
                                    //update_log.AppendFormat("contact_mobile_5:{0}:{1}:第五聯絡人手機號碼#", oldven.contact_mobile_5, "刪除");
                                    //update_log.AppendFormat("contact_email_5:{0}:{1}:第五聯絡人郵箱#", oldven.contact_email_5, "刪除");
                                    list.Add(new TableChangeLog() { change_field = "contact_type_5", old_value = oldven.contact_type_5.ToString(), new_value = "7", field_ch_name = "第五聯絡人類型" });
                                    list.Add(new TableChangeLog() { change_field = "contact_name_5", old_value = oldven.contact_name_5, new_value = "刪除", field_ch_name = "第五聯絡人姓名" });
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_1_5", old_value = oldven.contact_phone_1_5, new_value = "刪除", field_ch_name = "第五聯絡人電話一" });
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_2_5", old_value = oldven.contact_phone_2_5, new_value = "刪除", field_ch_name = "第五聯絡人電話二" });
                                    list.Add(new TableChangeLog() { change_field = "contact_mobile_5", old_value = oldven.contact_mobile_5, new_value = "刪除", field_ch_name = "第五聯絡人手機號碼" });
                                    list.Add(new TableChangeLog() { change_field = "contact_email_5", old_value = oldven.contact_email_5, new_value = "刪除", field_ch_name = "第五聯絡人郵箱" });
                                }
                            }
                        }
                    }


                    string[] contactarr = null;
                    if (!string.IsNullOrEmpty(Request.Params["conactValues"].ToString()))
                    {

                        string contact = Request.Params["conactValues"].ToString();
                        contactarr = contact.Split('|');
                    }
                    for (int i = 0; i < 5; i++)
                    {
                        string[] contact1 = null;
                        if (contactarr != null && contactarr.Length > i + 1)
                        {
                            contact1 = contactarr[i].Split(',');
                        }
                        if (i == 0)
                        {
                            if (contact1 != null)
                            {
                                venQuery.contact_type_1 = 4;
                                venQuery.contact_name_1 = contact1[1];
                                venQuery.contact_phone_1_1 = contact1[2];
                                venQuery.contact_phone_2_1 = contact1[3];
                                venQuery.contact_mobile_1 = contact1[4];
                                venQuery.contact_email_1 = contact1[5].ToLower();

                                if (oldven.contact_type_1 != venQuery.contact_type_1)
                                {
                                    // update_log.AppendFormat("contact_type_1:{0}:{1}:第一聯絡人類型#", oldven.contact_type_1, venQuery.contact_type_1);
                                    list.Add(new TableChangeLog() { change_field = "contact_type_1", old_value = oldven.contact_type_1.ToString(), new_value = venQuery.contact_type_1.ToString(), field_ch_name = "第一聯絡人類型" });
                                }
                                if (oldven.contact_name_1 != venQuery.contact_name_1)
                                {
                                    // update_log.AppendFormat("contact_name_1:{0}:{1}:第一聯絡人姓名#", oldven.contact_name_1, venQuery.contact_name_1);
                                    list.Add(new TableChangeLog() { change_field = "contact_name_1", old_value = oldven.contact_name_1, new_value = venQuery.contact_name_1, field_ch_name = "第一聯絡人姓名" });
                                }
                                if (oldven.contact_phone_1_1 != venQuery.contact_phone_1_1)
                                {
                                    //update_log.AppendFormat("contact_phone_1_1:{0}:{1}:第一聯絡人電話一#", oldven.contact_phone_1_1, venQuery.contact_phone_1_1);
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_1_1", old_value = oldven.contact_phone_1_1, new_value = venQuery.contact_phone_1_1, field_ch_name = "第一聯絡人電話一" });
                                }
                                if (oldven.contact_phone_2_1 != venQuery.contact_phone_2_1)
                                {
                                    // update_log.AppendFormat("contact_phone_2_1:{0}:{1}:第一聯絡人電話二#", oldven.contact_phone_2_1, venQuery.contact_phone_2_1);
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_2_1", old_value = oldven.contact_phone_2_1, new_value = venQuery.contact_phone_2_1, field_ch_name = "第一聯絡人電話二" });
                                }
                                if (oldven.contact_mobile_1 != venQuery.contact_mobile_1)
                                {
                                    // update_log.AppendFormat("contact_mobile_1:{0}:{1}:第一聯絡人手機號碼#", oldven.contact_mobile_1, venQuery.contact_mobile_1);
                                    list.Add(new TableChangeLog() { change_field = "contact_mobile_1", old_value = oldven.contact_mobile_1, new_value = venQuery.contact_mobile_1, field_ch_name = "第一聯絡人手機號碼" });
                                }
                                if (oldven.contact_email_1 != venQuery.contact_email_1)
                                {
                                    //update_log.AppendFormat("contact_email_1:{0}:{1}:第一聯絡人郵箱#", oldven.contact_email_1, venQuery.contact_email_1);
                                    list.Add(new TableChangeLog() { change_field = "contact_email_1", old_value = oldven.contact_email_1, new_value = venQuery.contact_email_1, field_ch_name = "第一聯絡人郵箱" });
                                }

                            }
                        }
                        else if (i == 1)
                        {


                            if (contact1 != null)
                            {
                                venQuery.contact_type_2 = Convert.ToUInt32(ContactType(contact1[0].ToString()));
                                venQuery.contact_name_2 = contact1[1];
                                venQuery.contact_phone_1_2 = contact1[2];
                                venQuery.contact_phone_2_2 = contact1[3];
                                venQuery.contact_mobile_2 = contact1[4];
                                venQuery.contact_email_2 = contact1[5].ToLower().ToLower();

                                if (oldven.contact_type_2 != venQuery.contact_type_2)
                                {
                                    // update_log.AppendFormat("contact_type_2:{0}:{1}:第二聯絡人類型#", oldven.contact_type_2, venQuery.contact_type_2);
                                    list.Add(new TableChangeLog() { change_field = "contact_type_2", old_value = oldven.contact_type_2.ToString(), new_value = venQuery.contact_type_2.ToString(), field_ch_name = "第二聯絡人類型" });
                                }
                                if (oldven.contact_name_2 != venQuery.contact_name_2)
                                {
                                    //update_log.AppendFormat("contact_name_2:{0}:{1}:第二聯絡人姓名#", oldven.contact_name_2, venQuery.contact_name_2);
                                    list.Add(new TableChangeLog() { change_field = "contact_name_2", old_value = oldven.contact_name_2, new_value = venQuery.contact_name_2, field_ch_name = "第二聯絡人姓名" });
                                }
                                if (oldven.contact_phone_1_2 != venQuery.contact_phone_1_2)
                                {
                                    //update_log.AppendFormat("contact_phone_1_2:{0}:{1}:第二聯絡人電話一#", oldven.contact_phone_1_2, venQuery.contact_phone_1_2);
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_1_2", old_value = oldven.contact_phone_1_2, new_value = venQuery.contact_phone_1_2, field_ch_name = "第二聯絡人電話一" });
                                }
                                if (oldven.contact_phone_2_2 != venQuery.contact_phone_2_2)
                                {
                                    //update_log.AppendFormat("contact_phone_2_2:{0}:{1}:第二聯絡人電話二#", oldven.contact_phone_2_2, venQuery.contact_phone_2_2);
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_2_2", old_value = oldven.contact_phone_2_2, new_value = venQuery.contact_phone_2_2, field_ch_name = "第二聯絡人電話二" });
                                }
                                if (oldven.contact_mobile_2 != venQuery.contact_mobile_2)
                                {
                                    // update_log.AppendFormat("contact_mobile_2:{0}:{1}:第二聯絡人手機號碼#", oldven.contact_mobile_2, venQuery.contact_mobile_2);
                                    list.Add(new TableChangeLog() { change_field = "contact_mobile_2", old_value = oldven.contact_mobile_2, new_value = venQuery.contact_mobile_2, field_ch_name = "第二聯絡人手機號碼" });
                                }
                                if (oldven.contact_email_2 != venQuery.contact_email_2)
                                {
                                    // update_log.AppendFormat("contact_email_2:{0}:{1}:第二聯絡人郵箱#", oldven.contact_email_2, venQuery.contact_email_2);
                                    list.Add(new TableChangeLog() { change_field = "contact_email_2", old_value = oldven.contact_email_2, new_value = venQuery.contact_email_2, field_ch_name = "第二聯絡人郵箱" });
                                }
                            }
                        }
                        else if (i == 2)
                        {


                            if (contact1 != null)
                            {
                                venQuery.contact_type_3 = Convert.ToUInt32(ContactType(contact1[0].ToString()));
                                venQuery.contact_name_3 = contact1[1];
                                venQuery.contact_phone_1_3 = contact1[2];
                                venQuery.contact_phone_2_3 = contact1[3];
                                venQuery.contact_mobile_3 = contact1[4];
                                venQuery.contact_email_3 = contact1[5].ToLower();
                                if (oldven.contact_type_3 != venQuery.contact_type_3)
                                {
                                    //update_log.AppendFormat("contact_type_3:{0}:{1}:第三聯絡人類型#", oldven.contact_type_3, venQuery.contact_type_3);
                                    list.Add(new TableChangeLog() { change_field = "contact_type_3", old_value = oldven.contact_type_3.ToString(), new_value = venQuery.contact_type_3.ToString(), field_ch_name = "第三聯絡人類型" });
                                }
                                if (oldven.contact_name_3 != venQuery.contact_name_3)
                                {
                                    //update_log.AppendFormat("contact_name_3:{0}:{1}:第三聯絡人姓名#", oldven.contact_name_3, venQuery.contact_name_3);
                                    list.Add(new TableChangeLog() { change_field = "contact_name_3", old_value = oldven.contact_name_3, new_value = venQuery.contact_name_3, field_ch_name = "第三聯絡人姓名" });
                                }
                                if (oldven.contact_phone_1_3 != venQuery.contact_phone_1_3)
                                {
                                    // update_log.AppendFormat("contact_phone_1_3:{0}:{1}:第三聯絡人電話一#", oldven.contact_phone_1_3, venQuery.contact_phone_1_3);
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_1_3", old_value = oldven.contact_phone_1_3, new_value = venQuery.contact_phone_1_3, field_ch_name = "第三聯絡人電話一" });
                                }
                                if (oldven.contact_phone_2_3 != venQuery.contact_phone_2_3)
                                {
                                    // update_log.AppendFormat("contact_phone_2_3:{0}:{1}:第三聯絡人電話二#", oldven.contact_phone_2_3, venQuery.contact_phone_2_3);
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_2_3", old_value = oldven.contact_phone_2_3, new_value = venQuery.contact_phone_2_3, field_ch_name = "第三聯絡人電話二" });
                                }
                                if (oldven.contact_mobile_3 != venQuery.contact_mobile_3)
                                {
                                    //  update_log.AppendFormat("contact_mobile_3:{0}:{1}:第三聯絡人手機號碼#", oldven.contact_mobile_3, venQuery.contact_mobile_3);
                                    list.Add(new TableChangeLog() { change_field = "contact_mobile_3", old_value = oldven.contact_mobile_3, new_value = venQuery.contact_mobile_3, field_ch_name = "第三聯絡人手機號碼" });
                                }
                                if (oldven.contact_email_3 != venQuery.contact_email_3)
                                {
                                    // update_log.AppendFormat("contact_email_3:{0}:{1}:第三聯絡人郵箱#", oldven.contact_email_3, venQuery.contact_email_3);
                                    list.Add(new TableChangeLog() { change_field = "contact_email_3", old_value = oldven.contact_email_3, new_value = venQuery.contact_email_3, field_ch_name = "第三聯絡人郵箱" });
                                }
                            }
                        }
                        else if (i == 3)
                        {


                            if (contact1 != null)
                            {
                                venQuery.contact_type_4 = Convert.ToUInt32(ContactType(contact1[0].ToString()));
                                venQuery.contact_name_4 = contact1[1];
                                venQuery.contact_phone_1_4 = contact1[2];
                                venQuery.contact_phone_2_4 = contact1[3];
                                venQuery.contact_mobile_4 = contact1[4];
                                venQuery.contact_email_4 = contact1[5].ToLower();
                                if (oldven.contact_type_4 != venQuery.contact_type_4)
                                {
                                    //update_log.AppendFormat("contact_type_4:{0}:{1}:第四聯絡人類型#", oldven.contact_type_4, venQuery.contact_type_4);
                                    list.Add(new TableChangeLog() { change_field = "contact_type_4", old_value = oldven.contact_type_4.ToString(), new_value = venQuery.contact_type_4.ToString(), field_ch_name = "原第四聯絡人類型" });
                                }
                                if (oldven.contact_name_4 != venQuery.contact_name_4)
                                {
                                    // update_log.AppendFormat("contact_name_4:{0}:{1}:第四聯絡人姓名#", oldven.contact_name_4, venQuery.contact_name_4);
                                    list.Add(new TableChangeLog() { change_field = "contact_name_4", old_value = oldven.contact_name_4, new_value = venQuery.contact_name_4, field_ch_name = "第四聯絡人姓名" });
                                }
                                if (oldven.contact_phone_1_4 != venQuery.contact_phone_1_4)
                                {
                                    //update_log.AppendFormat("contact_phone_1_4:{0}:{1}:第四聯絡人電話一#", oldven.contact_phone_1_4, venQuery.contact_phone_1_4);
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_1_4", old_value = oldven.contact_phone_1_4, new_value = venQuery.contact_phone_1_4, field_ch_name = "第四聯絡人電話一" });
                                }
                                if (oldven.contact_phone_2_4 != venQuery.contact_phone_2_4)
                                {
                                    // update_log.AppendFormat("contact_phone_2_4:{0}:{1}:第四聯絡人電話二#", oldven.contact_phone_2_4, venQuery.contact_phone_2_4);
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_2_4", old_value = oldven.contact_phone_2_4, new_value = venQuery.contact_phone_2_4, field_ch_name = "第四聯絡人電話二" });
                                }
                                if (oldven.contact_mobile_4 != venQuery.contact_mobile_4)
                                {
                                    // update_log.AppendFormat("contact_mobile_4:{0}:{1}:第四聯絡人手機號碼#", oldven.contact_mobile_4, venQuery.contact_mobile_4);
                                    list.Add(new TableChangeLog() { change_field = "contact_mobile_4", old_value = oldven.contact_mobile_4, new_value = venQuery.contact_mobile_4, field_ch_name = "第四聯絡人手機號碼" });
                                }
                                if (oldven.contact_email_4 != venQuery.contact_email_4)
                                {
                                    // update_log.AppendFormat("contact_email_4:{0}:{1}:第四聯絡人郵箱#", oldven.contact_email_4, venQuery.contact_email_4);
                                    list.Add(new TableChangeLog() { change_field = "contact_email_4", old_value = oldven.contact_email_4, new_value = venQuery.contact_email_4, field_ch_name = "第四聯絡人郵箱" });
                                }
                            }
                        }
                        else if (i == 4)
                        {


                            if (contact1 != null)
                            {
                                venQuery.contact_type_5 = Convert.ToUInt32(ContactType(contact1[0].ToString()));
                                venQuery.contact_name_5 = contact1[1];
                                venQuery.contact_phone_1_5 = contact1[2];
                                venQuery.contact_phone_2_5 = contact1[3];
                                venQuery.contact_mobile_5 = contact1[4];
                                venQuery.contact_email_5 = contact1[5].ToLower();
                                if (oldven.contact_type_5 != venQuery.contact_type_5)
                                {
                                    //update_log.AppendFormat("contact_type_5:{0}:{1}:第五聯絡人類型#", oldven.contact_type_5, venQuery.contact_type_5);
                                    list.Add(new TableChangeLog() { change_field = "contact_type_5", old_value = oldven.contact_type_5.ToString(), new_value = venQuery.contact_type_5.ToString(), field_ch_name = "第五聯絡人類型" });
                                }
                                if (oldven.contact_name_5 != venQuery.contact_name_5)
                                {
                                    // update_log.AppendFormat("contact_name_5:{0}:{1}:第五聯絡人姓名#", oldven.contact_name_5, venQuery.contact_name_5);
                                    list.Add(new TableChangeLog() { change_field = "contact_name_5", old_value = oldven.contact_name_5, new_value = venQuery.contact_name_5, field_ch_name = "第五聯絡人姓名" });
                                }
                                if (oldven.contact_phone_1_5 != venQuery.contact_phone_1_5)
                                {
                                    // update_log.AppendFormat("contact_phone_1_5:{0}:{1}:第五聯絡人電話一#", oldven.contact_phone_1_5, venQuery.contact_phone_1_5);
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_1_5", old_value = oldven.contact_phone_1_5, new_value = venQuery.contact_phone_1_5, field_ch_name = "第五聯絡人電話一" });
                                }
                                if (oldven.contact_phone_2_5 != venQuery.contact_phone_2_5)
                                {
                                    // update_log.AppendFormat("contact_phone_2_5:{0}:{1}:第五聯絡人電話二#", oldven.contact_phone_2_5, venQuery.contact_phone_2_5);
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_2_5", old_value = oldven.contact_phone_2_5, new_value = venQuery.contact_phone_2_5, field_ch_name = "第五聯絡人電話二" });
                                }
                                if (oldven.contact_mobile_5 != venQuery.contact_mobile_5)
                                {
                                    //update_log.AppendFormat("contact_mobile_5:{0}:{1}:第五聯絡人手機號碼#", oldven.contact_mobile_5, venQuery.contact_mobile_5);
                                    list.Add(new TableChangeLog() { change_field = "contact_mobile_5", old_value = oldven.contact_mobile_5, new_value = venQuery.contact_mobile_5, field_ch_name = "第五聯絡人手機號碼" });
                                }
                                if (oldven.contact_email_5 != venQuery.contact_email_5)
                                {
                                    //update_log.AppendFormat("contact_email_5:{0}:{1}:第五聯絡人郵箱#", oldven.contact_email_5, venQuery.contact_email_5);
                                    list.Add(new TableChangeLog() { change_field = "contact_email_5", old_value = oldven.contact_email_5, new_value = venQuery.contact_email_5, field_ch_name = "第五聯絡人郵箱" });
                                }
                            }
                        }
                    }

                    #endregion


                    venQuery.ip = Request.UserHostAddress;
                    venQuery.file_name = "VendorList.chtml";
                    venQuery.created = DateTime.Now;
                    venQuery.kuser_id = Convert.ToUInt32((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString());
                    venQuery.export_flag = 1;
                    mgr = new CallerMgr(connectionString);
                    Caller caller = new Caller();
                    caller = mgr.GetUserById(Convert.ToInt32(venQuery.kuser_id));
                    venQuery.kuser_name = caller.user_username;
                    return VendorEdit(venQuery, list);
                }
            }
            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);
                jsonStr = "{success:false}";
            }

            this.Response.Clear();
            this.Response.Write(jsonStr.ToString());
            this.Response.End();
            return this.Response;
        }
Beispiel #22
0
        //  [HttpPost]
        public HttpResponseBase SaveVipUserGroup()
        {
            NameValueCollection param = Request.Params;
            VipUserGroup userGroup = new VipUserGroup();
            string json = string.Empty;
            bool size = true;
            Serial serial = new Serial();
            _userGroupMgr = new VipUserGroupMgr(mySqlConnectionString);
            _ISerImplMgr = new SerialMgr(mySqlConnectionString);
            serial = _ISerImplMgr.GetSerialById(72);
            string path = Server.MapPath(xmlPath);
            SiteConfigMgr _siteConfigMgr = new SiteConfigMgr(path);
            SiteConfig extention_config = _siteConfigMgr.GetConfigByName("PIC_Extention_Format");
            SiteConfig minValue_config = _siteConfigMgr.GetConfigByName("PIC_Length_MinValue");
            SiteConfig maxValue_config = _siteConfigMgr.GetConfigByName("PIC_Length_MaxValue");
            SiteConfig admin_userName = _siteConfigMgr.GetConfigByName("ADMIN_USERNAME");
            SiteConfig admin_passwd = _siteConfigMgr.GetConfigByName("ADMIN_PASSWD");
            //擴展名、最小值、最大值
            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;
            string localPromoPath = imgLocalPath + promoPath;//圖片存儲地址
            Random rand = new Random();
            int newRand = rand.Next(1000, 9999);

            string NewName = string.Empty;//當前文件名
            string fileExtention = string.Empty;//當前文件的擴展名
            string NewFileName = string.Empty;
            FileManagement fileLoad = new FileManagement();
            try
            {
                #region 新增
                if (String.IsNullOrEmpty(param["group_id"]))
                {
                    if (!string.IsNullOrEmpty(Request.Form["group_name"]))
                    {
                        userGroup.group_name = Request.Form["group_name"].ToString();
                    }
                    if (!string.IsNullOrEmpty(Request.Form["tax_id"]))
                    {
                        userGroup.tax_id = Request.Form["tax_id"].ToString();
                    }
                    if (!string.IsNullOrEmpty(Request.Form["eng_name"]))
                    {
                        userGroup.eng_name = Request.Form["eng_name"].ToString();
                    }
                    if (!string.IsNullOrEmpty(Request.Form["gift_bonus"]))
                    {
                        userGroup.gift_bonus = Convert.ToUInt32(Request.Form["gift_bonus"]);
                    }
                    if (!string.IsNullOrEmpty(Request.Form["group_category"]))
                    {
                        userGroup.group_category = Convert.ToUInt32(Request.Form["group_category"]);
                    }

                    siteConfigMgr = new SiteConfigMgr(Server.MapPath(xmlPath));
                    try
                    {
                        if (Request.Files["image_name"] != null && Request.Files["image_name"].ContentLength > 0)
                        {
                            HttpPostedFileBase file = Request.Files["image_name"];
                            if (file.ContentLength > int.Parse(minValue) * 1024 && file.ContentLength < int.Parse(maxValue) * 1024)
                            {
                                NewName = Path.GetFileName(file.FileName);
                                bool result = false;
                                //獲得文件的後綴名
                                fileExtention = NewName.Substring(NewName.LastIndexOf(".")).ToLower();
                                //新的文件名是隨機數字
                                BLL.gigade.Common.HashEncrypt hash = new BLL.gigade.Common.HashEncrypt();
                                NewFileName = hash.Md5Encrypt(newRand.ToString(), "32") + fileExtention;
                                NewName = NewFileName;
                                string ServerPath = string.Empty;
                                //判斷目錄是否存在,不存在則創建
                                string[] mapPath = new string[1];
                                mapPath[0] = promoPath.Substring(1, promoPath.Length - 2);
                                string jian = localPromoPath.Substring(0, localPromoPath.Length - promoPath.Length + 1);
                                CreateFolder(localPromoPath.Substring(0, localPromoPath.Length - promoPath.Length + 1), mapPath);
                                NewFileName = localPromoPath + NewFileName;//絕對路徑
                                ServerPath = Server.MapPath(imgLocalServerPath + promoPath);
                                string ErrorMsg = string.Empty;
                                //上傳
                                result = fileLoad.UpLoadFile(file, ServerPath, NewFileName, extention, int.Parse(maxValue), int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd);
                                if (result)
                                {
                                    userGroup.image_name = NewName;
                                }

                            }
                            else
                            {
                                size = false;
                            }
                        }

                    }

                    catch (Exception)
                    {
                        userGroup.image_name = string.Empty;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["check_iden"]))
                    {
                        userGroup.check_iden = int.Parse(Request.Params["check_iden"]);
                    }
                    userGroup.createdate = (uint)CommonFunction.GetPHPTime(DateTime.Now.ToString());
                    userGroup.group_id = uint.Parse((serial.Serial_Value + 1).ToString());
                    if (_userGroupMgr.Insert(userGroup) > 0)
                    {
                        serial.Serial_Value = serial.Serial_Value + 1;/*所在操作表的列增加*/
                        _ISerImplMgr.Update(serial);/*修改所在的表的列對應的值*/
                        if (size)
                        {
                            json = "{success:true,msg:\"" + "" + "\"}";
                        }
                        else
                        {
                            json = "{success:true,msg:\"" + " 文件大小應大於1KB小於100KB!" + "\"}";
                        }
                    }
                    else
                    {
                        json = "{success:false,msg:\"" + "新增失敗!" + "\"}";
                    }

                }
                #endregion
                #region 編輯
                else
                {
                    _userGroupMgr = new VipUserGroupMgr(mySqlConnectionString);
                    userGroup.group_id = Convert.ToUInt32(param["group_id"]);
                    VipUserGroup oldUserGroup = _userGroupMgr.GetModelById(userGroup.group_id);
                    if (!string.IsNullOrEmpty(Request.Form["group_name"]))
                    {
                        userGroup.group_name = Request.Form["group_name"].ToString();
                    }
                    if (!string.IsNullOrEmpty(Request.Form["tax_id"]))
                    {
                        userGroup.tax_id = Request.Form["tax_id"].ToString();
                    }

                    if (!string.IsNullOrEmpty(Request.Form["eng_name"]))
                    {
                        userGroup.eng_name = Request.Form["eng_name"].ToString();
                    }
                    if (!string.IsNullOrEmpty(Request.Form["gift_bonus"]))
                    {
                        userGroup.gift_bonus = Convert.ToUInt32(Request.Form["gift_bonus"]);
                    }
                    if (!string.IsNullOrEmpty(Request.Form["group_category"]))
                    {
                        userGroup.group_category = Convert.ToUInt32(Request.Form["group_category"]);
                    }
                    try
                    {
                        //如果圖片沒有改變
                        if (Request.Form["image_name"] == oldUserGroup.image_name)
                        {
                            userGroup.image_name = Request.Form["image_name"];
                        }
                        else
                        {
                            //圖片改變了
                            if (Request.Files["image_name"] != null && Request.Files["image_name"].ContentLength > 0)
                            {
                                HttpPostedFileBase file = Request.Files["image_name"];
                                if (file.ContentLength > int.Parse(minValue) * 1024 && file.ContentLength < int.Parse(maxValue) * 1024)
                                {
                                    NewName = Path.GetFileName(file.FileName);
                                    bool result = false;

                                    //獲得文件的後綴名
                                    fileExtention = NewName.Substring(NewName.LastIndexOf(".")).ToLower();
                                    //新的文件名是隨機數字
                                    BLL.gigade.Common.HashEncrypt hash = new BLL.gigade.Common.HashEncrypt();
                                    NewFileName = hash.Md5Encrypt(newRand.ToString(), "32") + fileExtention;
                                    NewName = NewFileName;
                                    string ServerPath = string.Empty;
                                    //判斷目錄是否存在,不存在則創建
                                    string[] mapPath = new string[1];
                                    mapPath[0] = promoPath.Substring(1, promoPath.Length - 2);
                                    string jian = localPromoPath.Substring(0, localPromoPath.Length - promoPath.Length + 1);
                                    CreateFolder(localPromoPath.Substring(0, localPromoPath.Length - promoPath.Length + 1), mapPath);
                                    //  returnName += promoPath + NewFileName;
                                    NewFileName = localPromoPath + NewFileName;//絕對路徑
                                    ServerPath = Server.MapPath(imgLocalServerPath + promoPath);
                                    string ErrorMsg = string.Empty;
                                    //上傳之前刪除已有的圖片
                                    string oldFileName = oldUserGroup.image_name;
                                    //FTP ftp = new FTP(localPromoPath, ftpuser, ftppwd);
                                    //List<string> tem = ftp.GetFileList();
                                    //上傳
                                    result = fileLoad.UpLoadFile(file, ServerPath, NewFileName, extention, int.Parse(maxValue), int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd);
                                    if (result)
                                    {
                                        userGroup.image_name = NewName;

                                        if (System.IO.File.Exists(ServerPath + oldFileName))
                                        {
                                            FTP ftps = new FTP(localPromoPath + oldFileName, ftpuser, ftppwd);
                                            if (System.IO.File.Exists(localPromoPath + oldFileName))
                                            {
                                                ftps.DeleteFile(localPromoPath + oldFileName);//刪除ftp:71.159上的舊圖片
                                            }
                                            DeletePicFile(ServerPath + oldFileName);//刪除本地圖片
                                        }
                                    }
                                    else
                                    {
                                        userGroup.image_name = oldUserGroup.image_name;
                                    }
                                }
                                else
                                {
                                    size = false;
                                    userGroup.image_name = oldUserGroup.image_name;
                                }
                            }
                        }
                    }

                    catch (Exception)
                    {
                        userGroup.image_name = oldUserGroup.image_name;
                    }
                    try
                    {
                        userGroup.check_iden = int.Parse(Request.Params["check_iden"]);
                    }
                    catch (Exception)
                    {
                        userGroup.check_iden = 0;
                    }
                    if (_userGroupMgr.Update(userGroup) > 0)
                    {
                        if (size)
                        {
                            json = "{success:true,msg:\"" + "" + "\"}";
                        }
                        else
                        {
                            json = "{success:true,msg:\"" + " 文件大小應大於1KB小於100KB!" + "\"}";
                        }
                    }
                    else
                    {
                        json = "{success:false,msg:\"" + "修改失敗!" + "\"}";
                    }

                }
                #endregion
            }
            catch (Exception ex)
            {
                json = "{success:false,msg:\"" + "異常" + "\"}";
                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(json);
            this.Response.End();
            return this.Response;

        }
 public HttpResponseBase ProductPreview()
 {
     _siteConfigMgr = new SiteConfigMgr(Server.MapPath(xmlPath));
     _pMaster = new PriceMasterMgr(connectionString);
     List<SiteConfig> configList = _siteConfigMgr.Query();
     PriceMaster Pm = new PriceMaster();
     BLL.gigade.Common.HashEncrypt hash = new BLL.gigade.Common.HashEncrypt();
     string DomainName = configList.Where(m => m.Name.Equals("DoMain_Name")).FirstOrDefault().Value;
     string json = string.Empty;
     try
     {
         if (!string.IsNullOrEmpty(Request.Form["Product_Id"]))//商品ID
         {
             string type = Request.Form["Type"];
             string product_id = Request.Form["Product_Id"].ToString();
             string site_id = Request.Form["Site_Id"] == null ? "" : Request.Form["Site_Id"].ToString();
             string user_level = Request.Form["Level"] == null ? "" : Request.Form["Level"].ToString();
             string user_id = Request.Form["Master_User_Id"] == null ? "" : Request.Form["Master_User_Id"].ToString();
             string result = "";
             if (type == "0")
             {
                 result += "http://" + DomainName + "/product.php?pid=" + product_id + "&view=" + DateTime.Now.ToString("yyyyMMdd");//商品預覽
             }
             if (type == "1")
             {
                 //商品預覽+價格頁面
                 result += "http://" + DomainName + "/product.php?pid=" + product_id + "&view=" + DateTime.Now.ToString("yyyyMMdd") + "&sid=" + site_id + "&ulv=" + user_level + "&uid=" + user_id + "&view=" + DateTime.Now.ToString("yyyyMMdd");
                 result += "|";
                 result += "http://" + DomainName + "/product.php?pid=" + product_id + "&sid=" + site_id + "&code=" + hash.Md5Encrypt(product_id + "&sid=" + site_id, "32");//商品隱賣連結: + "&ulv=" + user_level
             }
             json = result.ToString().ToLower();
         }
     }
     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);
         json = "無預覽信息";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }
Beispiel #24
0
        public HttpResponseBase SaveUsersList()
        {
            string json = string.Empty;
            try
            {
                #region 獲取會員基本信息
                //獲取會員基本信息
                UsersListQuery user = new UsersListQuery();
                if (!string.IsNullOrEmpty(Request.Params["user_id"]))
                {
                    user.user_id = Convert.ToUInt32(Request.Params["user_id"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["user_name"]))
                {
                    user.user_name = Request.Params["user_name"].ToString();
                }
                if (!string.IsNullOrEmpty(Request.Params["user_gender"]))
                {
                    user.user_gender = Convert.ToUInt32(Request.Params["user_gender"]);
                }
                //if (!string.IsNullOrEmpty(Request.Params["user_phone"]))
                //{
                //    user.user_phone = Request.Params["user_phone"].ToString();
                //}
                if (!string.IsNullOrEmpty(Request.Params["user_mobile"]))
                {
                     user.user_mobile = Request.Params["user_mobile"].ToString();
                   // user.user_mobile = EncryptComputer.EncryptDecryptTextByApi(Request.Params["user_mobile"].ToString());
                }
                if (!string.IsNullOrEmpty(Request.Params["my_birthday"]))
                {
                    DateTime birth = Convert.ToDateTime(Request.Params["my_birthday"].ToString());
                    user.user_birthday_year = Convert.ToUInt32(birth.Year);
                    user.user_birthday_month = Convert.ToUInt32(birth.Month);
                    user.user_birthday_day = Convert.ToUInt32(birth.Day);
                }
                else
                {
                    user.user_birthday_year = 1970;
                    user.user_birthday_month = 0;
                    user.user_birthday_day = 0;
                }
                if (user.user_id == 0 && !string.IsNullOrEmpty(Request.Params["user_password_add"]))
                {
                    HashEncrypt hmd5 = new HashEncrypt();
                    user.user_password = hmd5.SHA256Encrypt(Request.Params["user_password_add"].Trim());
                }
                else if (!string.IsNullOrEmpty(Request.Params["user_password_edit"]))
                {
                    HashEncrypt hmd5 = new HashEncrypt();
                    user.user_password = hmd5.SHA256Encrypt(Request.Params["user_password_edit"].Trim());
                }
                if (Request.Params["send_sms_ad"].ToString() == "on")
                {
                    user.send_sms_ad = true;
                }
                else
                {
                    user.send_sms_ad = false;
                }
                if (!string.IsNullOrEmpty(Request.Params["admNote"]))
                {
                    user.adm_note = Request.Params["admNote"].ToString();
                }
                user.user_zip = Convert.ToUInt32(Request.Params["user_zip"]);
                user.user_address = Request.Params["user_address"].ToString();
                if (!string.IsNullOrEmpty(Request.Params["paper_invoice"]))
                {
                    if (Request.Params["paper_invoice"].ToString() == "on")
                    {
                        user.paper_invoice = true;
                    }
                    else
                    {
                        user.paper_invoice = false;
                    }
                }
                #endregion
                #region 獲取會員生活屬性
                List<UserLife> userInfoList = new List<UserLife>();
                UserLife uModel = new UserLife();
                uModel.user_id = user.user_id;
                uModel.kdate = (uint)CommonFunction.GetPHPTime();
                uModel.kuser = (Session["caller"] as Caller).user_id;
                user.update_user = uModel.kuser;
                if (Request.Params["user_marriage"] == "1")
                {
                    UserLife model = new UserLife();
                    model.user_id = uModel.user_id;
                    model.kdate = uModel.kdate;
                    model.kuser = uModel.kuser;
                    model.info_type = "user_marriage";
                    model.info_name = "是否結婚";
                    model.info_code = "1";
                    userInfoList.Add(model);

                }
                if (!string.IsNullOrEmpty(Request.Params["child_num"]) && Convert.ToInt32(Request.Params["child_num"]) != 0)
                {
                    UserLife model = new UserLife();
                    model.user_id = uModel.user_id;
                    model.kdate = uModel.kdate;
                    model.kuser = uModel.kuser;
                    model.info_type = "child_num";
                    model.info_name = "孩子個數";
                    model.info_code = Request.Params["child_num"];
                    userInfoList.Add(model);
                }
                if (!string.IsNullOrEmpty(Request.Params["vegetarian_type"]) && Convert.ToInt32(Request.Params["vegetarian_type"]) != 0)
                {
                    UserLife model = new UserLife();
                    model.user_id = uModel.user_id;
                    model.kdate = uModel.kdate;
                    model.kuser = uModel.kuser;
                    model.info_type = "vegetarian_type";
                    model.info_name = "是否吃素";
                    model.info_code = Request.Params["vegetarian_type"];
                    userInfoList.Add(model);
                }
                if (Request.Params["like_fivespice"] == "on")
                {
                    UserLife model = new UserLife();
                    model.user_id = uModel.user_id;
                    model.kdate = uModel.kdate;
                    model.kuser = uModel.kuser;
                    model.info_type = "like_fivespice";
                    model.info_name = "是否吃五辛";
                    model.info_code = "1";
                    userInfoList.Add(model);
                }
                string contact = string.Empty;
                if (Request.Params["contact1"] == "on")
                {
                    contact += "1,";

                }
                if (Request.Params["contact2"] == "on")
                {
                    contact += "2,";

                }
                if (Request.Params["contact3"] == "on")
                {
                    contact += "3,";

                }
                contact = contact.TrimEnd(',');
                if (!string.IsNullOrEmpty(contact))
                {
                    UserLife model = new UserLife();
                    model.user_id = uModel.user_id;
                    model.kdate = uModel.kdate;
                    model.kuser = uModel.kuser;
                    model.info_type = "like_contact";
                    model.info_name = "方便聯繫方式";
                    model.info_code = contact;
                    userInfoList.Add(model);
                }
                if (!string.IsNullOrEmpty(Request.Params["like_time"]) && Convert.ToInt32(Request.Params["like_time"]) != 0)
                {
                    UserLife model = new UserLife();
                    model.user_id = uModel.user_id;
                    model.kdate = uModel.kdate;
                    model.kuser = uModel.kuser;
                    model.info_type = "like_time";
                    model.info_name = "方便聯繫時間";
                    model.info_code = Request.Params["like_time"];
                    userInfoList.Add(model);
                }
                if (!string.IsNullOrEmpty(Request.Params["user_salary"]) && Convert.ToInt32(Request.Params["user_salary"]) != 0)
                {
                    UserLife model = new UserLife();
                    model.user_id = uModel.user_id;
                    model.kdate = uModel.kdate;
                    model.kuser = uModel.kuser;
                    model.info_type = "user_salary";
                    model.info_name = "年薪";
                    model.info_code = Request.Params["user_salary"];
                    userInfoList.Add(model);
                }
                if (!string.IsNullOrEmpty(Request.Params["work_type"]) && Convert.ToInt32(Request.Params["work_type"]) != 0)
                {
                    UserLife model = new UserLife();
                    model.user_id = uModel.user_id;
                    model.kdate = uModel.kdate;
                    model.kuser = uModel.kuser;
                    model.info_type = "work_type";
                    model.info_name = "職業";
                    model.info_code = Request.Params["work_type"];
                    userInfoList.Add(model);
                }
                if (!string.IsNullOrEmpty(Request.Params["user_educated"]) && Convert.ToInt32(Request.Params["user_educated"]) != 0)
                {
                    UserLife model = new UserLife();
                    model.user_id = uModel.user_id;
                    model.kdate = uModel.kdate;
                    model.kuser = uModel.kuser;
                    model.info_type = "user_educated";
                    model.info_name = "教育";
                    model.info_code = Request.Params["user_educated"];
                    userInfoList.Add(model);
                }
                if (!string.IsNullOrEmpty(Request.Params["user_religion"]) && Convert.ToInt32(Request.Params["user_religion"]) != 0)
                {
                    UserLife model = new UserLife();
                    model.user_id = uModel.user_id;
                    model.kdate = uModel.kdate;
                    model.kuser = uModel.kuser;
                    model.info_type = "user_religion";
                    model.info_name = "宗教信仰";
                    model.info_code = Request.Params["user_religion"];
                    userInfoList.Add(model);
                }
                if (!string.IsNullOrEmpty(Request.Params["user_constellation"]) && Convert.ToInt32(Request.Params["user_constellation"]) != 0)
                {
                    UserLife model = new UserLife();
                    model.user_id = uModel.user_id;
                    model.kdate = uModel.kdate;
                    model.kuser = uModel.kuser;
                    model.info_type = "user_constellation";
                    model.info_name = "星座";
                    model.info_code = Request.Params["user_constellation"];
                    userInfoList.Add(model);
                }
                #endregion
                _uslmpgr = new UsersListMgr(mySqlConnectionString);
                if (_uslmpgr.SaveUserList(user, userInfoList))
                {
                    json = "{success:true}";//返回json數據
                }

            }
            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);
                json = "{success:false,error:\"" + BLL.gigade.Common.CommonFunction.MySqlException(ex) + "\"}";

            }
            this.Response.Clear();
            this.Response.Write(json.ToString());
            this.Response.End();
            return this.Response;
        }
Beispiel #25
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");
        }
Beispiel #26
0
        public HttpResponseBase SavePhone()
        {
            string jsonStr = string.Empty;
            UserQuery user = new UserQuery();
            HashEncrypt hmd5 = new HashEncrypt();
            try
            {
                if (!string.IsNullOrEmpty(Request.Params["name"]))
                {
                    user.user_name = Request.Params["name"].ToString();
                }
                else
                {
                    user.user_name = "";
                }
                if (!string.IsNullOrEmpty(Request.Params["tel"]))
                {
                    if (!CommonFunction.isMobile(Request.Params["tel"].ToString()))
                    {
                        jsonStr = "{success:false,msg:0}";
                        this.Response.Clear();
                        this.Response.Write(jsonStr.ToString());
                        this.Response.End();
                        return this.Response;
                    }
                    else
                    {
                        //user.user_mobile = EncryptComputer.EncryptDecryptTextByApi(Request.Params["tel"].ToString());
                        user.user_mobile = Request.Params["tel"].ToString();
                    }
                    //if (user.user_mobile.Length < 10 || user.user_mobile.Substring(0, 2).ToString() != "09")
                    //{
                    //    for (int i = user.user_mobile.Length; i < 10; i++)
                    //    {
                    //        user.user_mobile = "0" + user.user_mobile;
                    //    }
                    //}
                }
                else
                {
                    user.user_mobile = "";
                }

                user.user_email = Request.Params["tel"] + "@user.gigade.com.tw";
                #region 獲取生日的年月日
                try
                {
                    DateTime birth = Convert.ToDateTime(Request.Params["birth"].ToString());
                    user.user_birthday_year = Convert.ToUInt32(birth.Year);
                    user.user_birthday_month = Convert.ToUInt32(birth.Month);
                    user.user_birthday_day = Convert.ToUInt32(birth.Day);
                }
                catch (Exception)
                {
                    user.user_birthday_year = 1970;
                    user.user_birthday_month = 0;
                    user.user_birthday_day = 0;
                }
                #endregion
                #region 密碼
                user.user_password = "******" + user.user_birthday_year;
                if (user.user_birthday_month.ToString().Length == 1)
                {
                    user.user_password += "0" + user.user_birthday_month;
                }
                else
                {
                    user.user_password += user.user_birthday_month;
                }
                if (user.user_birthday_day.ToString().Length == 1)
                {
                    user.user_password += "0" + user.user_birthday_day;
                }
                else
                {
                    user.user_password += user.user_birthday_day;
                }
                user.user_password = hmd5.SHA256Encrypt(user.user_password);
                #endregion
                if (!string.IsNullOrEmpty(Request.Params["zip"]))
                {
                    user.user_zip = Convert.ToUInt32(Request.Params["zip"].ToString());
                }
                else
                {
                    user.user_zip = 0;
                }
                if (!string.IsNullOrEmpty(Request.Params["address"]))
                {
                    user.user_address = Request.Params["address"].ToString();
                }
                else
                {
                    user.user_address = "";
                }
                if (!string.IsNullOrEmpty(Request.Params["IsAcceptAd"]))
                {
                    if (Request.Params["IsAcceptAd"].ToString() == "on")
                    {
                        user.send_sms_ad = true;
                    }
                }
                else
                {
                    user.send_sms_ad = false;
                }
                if (!string.IsNullOrEmpty(Request.Params["Remark"]))
                {
                    user.adm_note = Request.Params["Remark"].ToString();
                }
                else
                {
                    user.adm_note = "";
                }

                user.ip = Request.UserHostAddress;
                user.file_name = "UserPhone.chtml";

                user.created = DateTime.Now;
                user.kuser_id = Convert.ToUInt32((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString());
                mgr = new CallerMgr(mySqlConnectionString);
                Caller caller = new Caller();
                caller = mgr.GetUserById(Convert.ToInt32(user.kuser_id));
                user.kuser_name = caller.user_username;

                user.content = "user_email:" + user.user_email + ",user_mobile:" + user.user_mobile + ",user_birthday_year" + user.user_birthday_year + ",user_birthday_month" + user.user_birthday_month + ",user_birthday_day" + user.user_birthday_day + ",user_zip" + user.user_zip + ",user_address" + user.user_address + ",send_sms_ad" + user.send_sms_ad + ",adm_note" + user.adm_note;

                user.user_status = 1;
                user.user_source = "電話會員";
                user.user_login_attempts = 0;
                user.user_reg_date = Convert.ToUInt32(CommonFunction.GetPHPTime(DateTime.Now.ToString()));
                user.user_updatedate = Convert.ToUInt32(CommonFunction.GetPHPTime(DateTime.Now.ToString()));
                user.user_type = 2;

                _usmpgr = new UsersMgr(mySqlConnectionString);//實現方法
                if (_usmpgr.QueryByUserMobile(user.user_mobile).Rows.Count == 0)
                {
                    _usmpgr = new UsersMgr(mySqlConnectionString);
                    if (_usmpgr.SaveUserPhone(user) > 0)
                    {
                        jsonStr = "{success:true,msg:1}";
                    }
                    else
                    {
                        jsonStr = "{success:false,msg:2 }";
                    }
                }
                else
                {
                    jsonStr = "{success:false,msg:3 }";
                }
            }
            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);
                jsonStr = "{success:false,msg:0}";
            }
            this.Response.Clear();
            this.Response.Write(jsonStr.ToString());
            this.Response.End();
            return this.Response;
        }
        public ActionResult upLoadImg()
        {
            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 (prodCheck == 0 && type == 0)
            {
                type = 3;
            }
            int mobileCheck = file.FileName.LastIndexOf("mobile_");
            if (mobileCheck == 0 && type == 0)
            {
                type = 4;
            }
            string path = Server.MapPath(xmlPath);
            siteConfigMgr = new SiteConfigMgr(path);
            ViewBag.moreFileOneTime = false;
            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;
            }

            SiteConfig admin_userName = siteConfigMgr.GetConfigByName("ADMIN_USERNAME");
            SiteConfig admin_passwd = siteConfigMgr.GetConfigByName("ADMIN_PASSWD");

            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 && 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;
                    }
                    fileName = nameType + fileLoad.NewFileName(file.FileName);
                    fileName = fileName.Substring(0, fileName.LastIndexOf("."));
                    fileExtention = file.FileName.Substring(file.FileName.LastIndexOf('.'));
                }
                #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 == "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);

                localProdPath += firstFolder + secondFolder;

                prodPath += firstFolder + secondFolder;

                returnName += prodPath + NewFileName + fileExtention;
                NewFileName = localProdPath + NewFileName + fileExtention;
                ServerPath = Server.MapPath(imgLocalServerPath + prodPath);
            }
            string ErrorMsg = string.Empty;
            Resource.CoreMessage = new CoreResource("Product");
            try
            {
                //上傳圖片
                result = fileLoad.UpLoadFile(file, ServerPath, NewFileName, extention, int.Parse(maxValue), int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd);
                //上傳對應大小圖片
                //压缩图片至其它规格
            }
            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);
            }
            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);

            }
            return View("~/Views/Product/upLoad.cshtml");
        }
Beispiel #28
0
        public HttpResponseBase SaveElementDetaiil()
        {
            string resultJson = "{success:false}";
            ElementDetail model = new ElementDetail();
            ElementDetail oldModel = new ElementDetail();
            _detailMgr = new ElementDetailMgr(mySqlConnectionString);
            #region 獲取圖片信息
            string path = Server.MapPath(xmlPath);
            SiteConfigMgr _siteConfigMgr = new SiteConfigMgr(path);
            SiteConfig extention_config = _siteConfigMgr.GetConfigByName("PIC_Extention_Format");
            SiteConfig minValue_config = _siteConfigMgr.GetConfigByName("PIC_Length_Min_Element");
            SiteConfig maxValue_config = _siteConfigMgr.GetConfigByName("PIC_Length_MaxValue");
            SiteConfig admin_userName = _siteConfigMgr.GetConfigByName("ADMIN_USERNAME");
            SiteConfig admin_passwd = _siteConfigMgr.GetConfigByName("ADMIN_PASSWD");
            //擴展名、最小值、最大值
            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;
            string localBannerPath = imgLocalPath + ElementPath;//圖片存儲地址

            #endregion
            if (!String.IsNullOrEmpty(Request.Params["element_id"]))//如果不存在該id說明是添加頁面
            {
                model.element_id = Convert.ToInt32(Request.Params["element_id"].ToString());
                oldModel = _detailMgr.GetModel(model);
            }
            #region 獲取數據
            int isTranInt = 0;
            //if (Int32.TryParse(Request.Params["element_area_id"].ToString(), out isTranInt))
            //{
            //    model.element_area_id = Convert.ToInt32(Request.Params["element_area_id"].ToString());
            //}
            //else
            //{
            //    model.element_area_id = oldModel.element_area_id;
            //}
            if (!string.IsNullOrEmpty(Request.Params["element_name"].ToString()))
            {
                model.element_name = Request.Params["element_name"].ToString();
            }
            else
            {
                model.element_name = oldModel.element_name;
            }
            if (!string.IsNullOrEmpty(Request.Params["packet_id"]))
            {
                model.packet_id = Convert.ToInt32(Request.Params["packet_id"]);
            }
            if (Int32.TryParse(Request.Params["element_type"].ToString(), out isTranInt))
            {
                model.element_type = Convert.ToInt32(Request.Params["element_type"]);
            }
            if (model.element_type == 1)
            {
                #region 上傳圖片
                try
                {
                    FileManagement fileLoad = new FileManagement();

                    //if (Request.Files.Count > 0)//單個圖片上傳
                    for (int iFile = 0; iFile < Request.Files.Count; iFile++)//多個上傳圖片
                    {
                        HttpPostedFileBase file = Request.Files[iFile];//單個Request.Files[0]
                        string fileName = string.Empty;//當前文件名
                        string fileExtention = string.Empty;//當前文件的擴展名
                        //獲取圖片名稱
                        fileName = fileLoad.NewFileName(file.FileName);
                        if (iFile == 0 && fileName == oldModel.element_content)
                        {
                            fileName = "";
                        }
                        if(iFile == 1 && string.IsNullOrEmpty(Request.Params["element_img_big"].ToString()) )
                        {
                            fileName = Request.Params["element_img_big"].ToString();
                        }
                        if (!String.IsNullOrEmpty(fileName))
                        {
                            fileName = fileName.Substring(0, fileName.LastIndexOf("."));
                            fileExtention = file.FileName.Substring(file.FileName.LastIndexOf('.')).ToLower().ToString();
                            string NewFileName = string.Empty;
                            BLL.gigade.Common.HashEncrypt hash = new BLL.gigade.Common.HashEncrypt();
                            NewFileName = hash.Md5Encrypt(fileName, "32");
                            string ServerPath = string.Empty;
                            //判斷目錄是否存在,不存在則創建
                            FTP f_cf = new FTP();
                            f_cf.MakeMultiDirectory(localBannerPath.Substring(0, localBannerPath.Length - ElementPath.Length + 1), ElementPath.Substring(1, ElementPath.Length - 2).Split('/'), ftpuser, ftppwd);

                            fileName = NewFileName + fileExtention;
                            NewFileName = localBannerPath + NewFileName + fileExtention;//絕對路徑
                            ServerPath = Server.MapPath(imgLocalServerPath + ElementPath);
                            string ErrorMsg = string.Empty;

                            //上傳之前刪除已有的圖片
                            if (model.element_id != 0)
                            {
                                string oldFileName = oldModel.element_content;
                                if (iFile == 1)
                                {
                                    oldFileName = oldModel.element_img_big;
                                }
                                CommonFunction.DeletePicFile(ServerPath + oldFileName);//刪除本地圖片
                                FTP ftp = new FTP(localBannerPath, ftpuser, ftppwd);
                                List<string> tem = ftp.GetFileList();
                                if (tem.Contains(oldFileName))
                                {
                                    FTP ftps = new FTP(localBannerPath + oldFileName, ftpuser, ftppwd);
                                    ftps.DeleteFile(localBannerPath + oldFileName);//刪除ftp:71.159上的舊圖片
                                }
                            }
                            try
                            {
                                //上傳
                                Resource.CoreMessage = new CoreResource("Product");//尋找product.resx中的資源文件
                                bool result = fileLoad.UpLoadFile(file, ServerPath, NewFileName, extention, int.Parse(maxValue), int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd);
                                if (result)//上傳成功
                                {
                                    if (iFile == 0)
                                    {
                                        model.element_content = fileName;
                                    }
                                    else 
                                    {
                                        model.element_img_big = fileName; 
                                    }
                                }
                            }
                            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);
                                model.element_content = oldModel.element_content;
                            }
                            if (!string.IsNullOrEmpty(ErrorMsg))
                            {
                                if (iFile == 0)
                                {
                                    ErrorMsg = "元素圖 " + ErrorMsg;
                                }
                                else {
                                    ErrorMsg = "元素圖(大) " + ErrorMsg;
                                }
                                string json = string.Empty;
                                json = "{success:true,msg:\""+ ErrorMsg + "\"}";
                                this.Response.Clear();
                                this.Response.Write(json);
                                this.Response.End();
                                return this.Response;
                            }
                        }
                        else
                        {
                            if (iFile == 0)
                            {
                                model.element_content = oldModel.element_content;
                            }
                            else 
                            {
                                if (Request.Params["element_img_big"].ToString() == "")
                                {//編輯時如果傳過來空值則直接刪除
                                    model.element_img_big = "";
                                }
                                else
                                {
                                    model.element_img_big = oldModel.element_img_big;
                                }
                                //model.element_img_big = oldModel.element_img_big;
                            }
                        }
                    }
                }
                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);
                    model.element_content = oldModel.element_content;
                }
                #endregion
            }
            else if (model.element_type == 2)
            {
                if (!string.IsNullOrEmpty(Request.Params["element_content"].ToString()))
                {
                    model.element_content = Request.Params["element_content"].ToString();
                }
                else
                {
                    model.element_content = oldModel.element_content;
                }
            }
            else if (model.element_type == 3)
            {
                if (int.TryParse(Request.Params["element_product_id"].ToString(), out isTranInt))
                {
                    model.element_content = Request.Params["element_product_id"].ToString();
                }
                else
                {
                    model.element_content = oldModel.element_content;
                }
                #region 上傳圖片
                try
                {
                    FileManagement fileLoad = new FileManagement();
                    //if (Request.Files.Count > 0)//單個圖片上傳
                    for (int iFile = 1; iFile < Request.Files.Count; iFile++)//多個上傳圖片
                    {
                        HttpPostedFileBase file = Request.Files[iFile];//單個Request.Files[0]
                        string fileName = string.Empty;//當前文件名
                        string fileExtention = string.Empty;//當前文件的擴展名
                        //獲取圖片名稱
                        fileName = fileLoad.NewFileName(file.FileName);
                        if (!String.IsNullOrEmpty(fileName) && !String.IsNullOrEmpty(Request.Params["element_img_big"].ToString()))
                        {//可獲取文件,名稱不為空則變更圖片
                            fileName = fileName.Substring(0, fileName.LastIndexOf("."));
                            fileExtention = file.FileName.Substring(file.FileName.LastIndexOf('.')).ToLower().ToString();
                            string NewFileName = string.Empty;
                            BLL.gigade.Common.HashEncrypt hash = new BLL.gigade.Common.HashEncrypt();
                            NewFileName = hash.Md5Encrypt(fileName, "32");
                            string ServerPath = string.Empty;
                            //判斷目錄是否存在,不存在則創建
                            FTP f_cf = new FTP();
                            f_cf.MakeMultiDirectory(localBannerPath.Substring(0, localBannerPath.Length - ElementPath.Length + 1), ElementPath.Substring(1, ElementPath.Length - 2).Split('/'), ftpuser, ftppwd);

                            fileName = NewFileName + fileExtention;
                            NewFileName = localBannerPath + NewFileName + fileExtention;//絕對路徑
                            ServerPath = Server.MapPath(imgLocalServerPath + ElementPath);
                            string ErrorMsg = string.Empty;

                            //上傳之前刪除已有的圖片
                            if (model.element_id != 0)
                            {
                                string oldFileName = oldModel.element_img_big;
                                CommonFunction.DeletePicFile(ServerPath + oldFileName);//刪除本地圖片
                                FTP ftp = new FTP(localBannerPath, ftpuser, ftppwd);
                                List<string> tem = ftp.GetFileList();
                                if (tem.Contains(oldFileName))
                                {
                                    FTP ftps = new FTP(localBannerPath + oldFileName, ftpuser, ftppwd);
                                    ftps.DeleteFile(localBannerPath + oldFileName);//刪除ftp:71.159上的舊圖片
                                }
                            }
                            try
                            {
                                //上傳
                                Resource.CoreMessage = new CoreResource("Product");//尋找product.resx中的資源文件
                                bool result = fileLoad.UpLoadFile(file, ServerPath, NewFileName, extention, int.Parse(maxValue), int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd);                                
                                if (result)//上傳成功
                                {
                                    model.element_img_big = fileName;                                    
                                }
                            }
                            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);
                                model.element_img_big = oldModel.element_img_big;
                            }
                            if (!string.IsNullOrEmpty(ErrorMsg))
                            {
                                ErrorMsg = "元素圖(大)" + ErrorMsg;
                                string json = string.Empty;
                                json = "{success:true,msg:\"" + ErrorMsg + "\"}";
                                this.Response.Clear();
                                this.Response.Write(json);
                                this.Response.End();
                                return this.Response;
                            }
                        }
                        else
                        {
                            if (Request.Params["element_img_big"].ToString() == "")
                            {//編輯時如果傳過來空值則直接刪除
                                model.element_img_big = "";
                            }
                            else
                            {
                                model.element_img_big = oldModel.element_img_big;
                            }
                        }
                    }
                }
                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);
                    model.element_img_big = oldModel.element_img_big;
                }
                #endregion
            }
            if (int.TryParse(Request.Params["category_id_s"].ToString(), out isTranInt))
            {
                model.category_id = uint.Parse(Request.Params["category_id_s"].ToString());
            }
            else
            {
                model.category_id = 0;
            }

            model.category_name = Server.HtmlDecode(Request.Params["category_name_s"].ToString());


            if (!string.IsNullOrEmpty(Request.Params["element_link_url"].ToString()))
            {
                model.element_link_url = Request.Params["element_link_url"].ToString();
            }
            //else
            //{
            //    model.element_link_url = oldModel.element_link_url;
            //}
            if (int.TryParse(Request.Params["element_link_mode"].ToString(), out isTranInt))
            {
                model.element_link_mode = Convert.ToInt32(Request.Params["element_link_mode"]);
            }
            else
            {
                model.element_link_mode = oldModel.element_link_mode;
            }
            if (!string.IsNullOrEmpty(Request.Params["element_sort"].ToString()))
            {
                model.element_sort = Convert.ToInt32(Request.Params["element_sort"].ToString());
            }
            //else
            //{
            //    model.element_sort = oldModel.element_sort;
            //}

            if (!string.IsNullOrEmpty(Request.Params["element_start"].ToString()))
            {
                model.element_start = Convert.ToDateTime(Request.Params["element_start"].ToString());
            }
            else
            {
                model.element_start = oldModel.element_start;
            }
            if (!string.IsNullOrEmpty(Request.Params["element_end"].ToString()))
            {
                model.element_end = Convert.ToDateTime(Request.Params["element_end"].ToString());
            }
            else
            {
                model.element_end = oldModel.element_end;
            }

            model.element_remark = (Request.Params["element_remark"].ToString());

            model.element_status = 0;//默認為不啟用
            #endregion

            try
            {
                //判斷是否能夠獲取到rowid
                if (String.IsNullOrEmpty(Request.Params["element_id"]))//如果不存在該id說明是添加頁面
                {
                    model.element_createdate = DateTime.Now;
                    model.element_updatedate = model.element_createdate;
                    model.create_userid = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;
                    model.update_userid = model.create_userid;
                    //這裡加上各種參數

                    if (_detailMgr.Save(model) > 0)
                    {
                        resultJson = "{success:true}";//返回json數據
                    }
                }
                else
                {
                    //model.element_createdate = oldModel.element_createdate;
                    model.element_updatedate = DateTime.Now;
                    model.update_userid = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;
                    //    model.create_userid = oldModel.create_userid;
                    //這裡加上各種參數
                    if (_detailMgr.Update(model) > 0)//如果可以獲取到rowid則進行修改
                    {
                        resultJson = "{success:true}";//返回json數據
                    }
                }
            }
            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);
                resultJson = "{success:false}";
            }
            this.Response.Clear();
            this.Response.Write(resultJson);
            this.Response.End();
            return this.Response;
        }
        public HttpResponseBase InsertNewPromoCarnet()
        {
            NewPromoCarnetQuery query = new NewPromoCarnetQuery();
            NewPromoCarnetQuery oldModel = new NewPromoCarnetQuery();
            _INewPromoCarnetMgr = new NewPromoCarnetMgr(mySqlConnectionString);
            string json = string.Empty;

            try
            {
                if (!string.IsNullOrEmpty(Request.Params["row_id"]))
                {
                    query.row_id = Convert.ToInt32(Request.Params["row_id"].ToString());
                }
                if (!string.IsNullOrEmpty(Request.Params["present_event_id"]))
                {
                    query.present_event_id = Request.Params["present_event_id"].ToString();
                }
                if (!string.IsNullOrEmpty(Request.Params["group_id"]))
                {
                    query.group_id = Convert.ToInt32(Request.Params["group_id"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["new_user"]))
                {
                    query.new_user = Convert.ToInt32(Request.Params["new_user"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["new_user_date"]))
                {
                    query.new_user_date = Convert.ToDateTime(Request.Params["new_user_date"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["count_by"]))
                {
                    query.count_by = Convert.ToInt32(Request.Params["count_by"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["count"]))
                {
                    query.count = Convert.ToInt32(Request.Params["count"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["device"]))
                {
                    query.device = (Request.Params["device"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["message_mode"]))
                {
                    query.message_mode = Convert.ToInt32(Request.Params["message_mode"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["message_content"]))
                {
                    query.message_content = (Request.Params["message_content"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["link_url"]))
                {
                    query.link_url = (Request.Params["link_url"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["promo_image"]))
                {
                    query.promo_image = Request.Params["promo_image"];
                }
                if (!string.IsNullOrEmpty(Request.Params["active_now"]))
                {
                    query.active_now = Convert.ToInt32(Request.Params["active_now"]);
                }

                #region 上傳圖片
                string ErrorMsg = string.Empty;
                string path = Server.MapPath(xmlPath);
                SiteConfigMgr _siteConfigMgr = new SiteConfigMgr(path);
                SiteConfig extention_config = _siteConfigMgr.GetConfigByName("PIC_Extention_Format");
                SiteConfig minValue_config = _siteConfigMgr.GetConfigByName("PIC_Length_Min_Element");
                SiteConfig maxValue_config = _siteConfigMgr.GetConfigByName("PIC_Length_MaxValue");
                SiteConfig admin_userName = _siteConfigMgr.GetConfigByName("ADMIN_USERNAME");
                SiteConfig admin_passwd = _siteConfigMgr.GetConfigByName("ADMIN_PASSWD");
                //擴展名、最小值、最大值
                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;
                string localPromoPath = imgLocalPath + NewPromoPath;//圖片存儲地址
                FileManagement fileLoad = new FileManagement();
                if (Request.Files.Count > 0)
                {
                    HttpPostedFileBase file = Request.Files[0];
                    string fileName = string.Empty;//當前文件名
                    string fileExtention = string.Empty;//當前文件的擴展名
                    fileName = fileLoad.NewFileName(file.FileName);
                    if (fileName != "")
                    {
                        fileName = fileName.Substring(0, fileName.LastIndexOf("."));
                        fileExtention = file.FileName.Substring(file.FileName.LastIndexOf('.')).ToLower().ToString();
                        string NewFileName = string.Empty;
                        BLL.gigade.Common.HashEncrypt hash = new BLL.gigade.Common.HashEncrypt();
                        NewFileName = hash.Md5Encrypt(fileName, "32");
                        string ServerPath = string.Empty;
                        FTP f_cf = new FTP();
                        f_cf.MakeMultiDirectory(localPromoPath.Substring(0, localPromoPath.Length - NewPromoPath.Length + 1), NewPromoPath.Substring(1, NewPromoPath.Length - 2).Split('/'), ftpuser, ftppwd);
                        fileName = NewFileName + fileExtention;
                        NewFileName = localPromoPath + NewFileName + fileExtention;//絕對路徑
                        ServerPath = Server.MapPath(imgLocalServerPath + NewPromoPath);

                        //上傳之前刪除已有的圖片
                        if (query.row_id != 0)
                        {
                            oldModel = _INewPromoCarnetMgr.GetModel(query);
                            if (oldModel.promo_image != "")
                            {
                                string oldFileName = oldModel.promo_image;
                                CommonFunction.DeletePicFile(ServerPath + oldFileName);//刪除本地圖片
                                FTP ftp = new FTP(localPromoPath, ftpuser, ftppwd);
                                List<string> tem = ftp.GetFileList();
                                if (tem.Contains(oldFileName))
                                {
                                    FTP ftps = new FTP(localPromoPath + oldFileName, ftpuser, ftppwd);
                                    ftps.DeleteFile(localPromoPath + oldFileName);
                                }
                            }
                        }
                        try
                        {
                            Resource.CoreMessage = new CoreResource("Product");//尋找product.resx中的資源文件
                            bool result = fileLoad.UpLoadFile(file, ServerPath, NewFileName, extention, int.Parse(maxValue), int.Parse(minValue), ref ErrorMsg, ftpuser, ftppwd);
                            if (result)
                            {
                                query.promo_image = fileName;
                            }
                        }
                        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);
                        }
                        if (!string.IsNullOrEmpty(ErrorMsg))
                        {
                            string jsonStr = string.Empty;
                            json = "{success:true,msg:\"" + ErrorMsg + "\"}";
                            this.Response.Clear();
                            this.Response.Write(json);
                            this.Response.End();
                            return this.Response;
                        }
                    }

                }
                else
                {
                    query.promo_image = oldModel.promo_image;
                }
                #endregion

                if (!string.IsNullOrEmpty(Request.Params["event_name"]))
                {
                    query.event_name = Request.Params["event_name"];
                }
                if (!string.IsNullOrEmpty(Request.Params["event_desc"]))
                {
                    query.event_desc = Request.Params["event_desc"];
                }
                if (!string.IsNullOrEmpty(Request.Params["start"]))
                {
                    query.start = Convert.ToDateTime(Request.Params["start"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["end"]))
                {
                    query.end = Convert.ToDateTime(Request.Params["end"]);
                }

                if (query.row_id == 0)
                {
                    query.kuser = (Session["caller"] as Caller).user_id;
                    query.muser = query.kuser;
                    query.created = DateTime.Now;
                    query.modified = query.created;
                    query.row_id = _INewPromoCarnetMgr.GetNewPromoCarnetMaxId();

                    query.event_id = BLL.gigade.Common.CommonFunction.GetEventId("F2", query.row_id.ToString());
                    if (_INewPromoCarnetMgr.InsertNewPromoCarnet(query) > 0)
                    {
                        json = "{success:true}";
                    }
                    else
                    {
                        json = "{success:false}";
                    }
                }
                else
                {
                    query.muser = (Session["caller"] as Caller).user_id;
                    query.modified = DateTime.Now;
                    if (_INewPromoCarnetMgr.UpdateNewPromoCarnet(query))
                    {
                        json = "{success:true}";
                    }
                    else
                    {
                        json = "{success:false}";
                    }

                }
            }
            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);
                json = "{success:false}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
        public HttpResponseBase IlocUploadExcel()
        {
            string newName = string.Empty;
            string json = string.Empty;
            List<IlocQuery> store = new List<IlocQuery>();
            HashEncrypt hashpt = new HashEncrypt();
            try
            {

                DTIlocExcel.Clear();
                DTIlocExcel.Columns.Clear();
                DTIlocExcel.Columns.Add("料位編號", typeof(String));
                DTIlocExcel.Columns.Add("料位類型", typeof(String));
                DTIlocExcel.Columns.Add("所在層數");
                DTIlocExcel.Columns.Add("不能匯入的原因", typeof(String));
                int result = 0;
                int count = 0;//總匯入數
                int entercount = 0;//插入失敗個數
                int errorcount = 0;//數據異常個數
                int create_user = (Session["caller"] as Caller).user_id;
                if (Request.Files["ImportExcelFile"] != null && Request.Files["ImportExcelFile"].ContentLength > 0)
                {
                    HttpPostedFileBase excelFile = Request.Files["ImportExcelFile"];
                    newName = Server.MapPath(excelPath) + excelFile.FileName;
                    excelFile.SaveAs(newName);
                    DataTable dt = new DataTable();
                    NPOI4ExcelHelper helper = new NPOI4ExcelHelper(newName);
                    dt = helper.SheetData();
                    if (dt.Rows.Count > 0)
                    {
                        _IlocMgr = new IlocMgr(mySqlConnectionString);
                        _IiplasMgr = new IplasMgr(mySqlConnectionString);

                        int i = 0;
                        foreach (DataRow dr in dt.Rows)
                        {
                            StringBuilder strsql = new StringBuilder();
                            Iloc ic = new BLL.gigade.Model.Iloc();
                            i++;
                            try
                            {
                                if (!string.IsNullOrEmpty(dr[0].ToString()) && Regex.IsMatch(dr[0].ToString(), @"^[A-Z]{2}\d{3}[A-Z]\d{2}$") && !string.IsNullOrEmpty(dr[1].ToString()) && (dr[1].ToString() == "S" || dr[1].ToString() == "R"))
                                {
                                    int loc_id_exsit = _IiplasMgr.YesOrNoLocIdExsit(dr[0].ToString());//判斷料位是否存在
                                    ic.loc_id = dr[0].ToString();
                                    ic.lsta_id = "F";
                                    ic.lcat_id = dr[1].ToString();
                                    ic.create_dtim = DateTime.Now;
                                    ic.change_dtim = DateTime.Now;
                                    ic.create_user = create_user;
                                    ic.change_user = create_user;
                                    ic.loc_status = 1;
                                    ic.lev = GetIntByString(dr[2].ToString());
                                    if (loc_id_exsit > 0)
                                    {
                                        DataRow drtwo = DTIlocExcel.NewRow();
                                        drtwo[0] = dr[0].ToString();
                                        drtwo[1] = dr[1].ToString();
                                        drtwo[2] = dr[2].ToString();
                                        drtwo[3] = "該料位已存在";
                                        DTIlocExcel.Rows.Add(drtwo);
                                        errorcount++;
                                        continue;
                                    }
                                    else//料位不存在
                                    {
                                        string has = hashpt.Md5Encrypt(ic.loc_id, "16");

                                        strsql.AppendFormat(@"insert into iloc(dc_id,whse_id,loc_id,llts_id,bkfill_loc,ldes_id,
                                             ldim_id,x_coord,y_coord,z_coord,bkfill_x_coord,bkfill_y_coord,
                                             bkfill_z_coord,lsta_id,sel_stk_pos,sel_seq_loc,sel_pos_hgt,rsv_stk_pos,
                                             rsv_pos_hgt,stk_lmt,stk_pos_wid,lev,lhnd_id,ldsp_id,
                                             create_user,create_dtim,comingle_allow,change_user,change_dtim,lcat_id,
                                             space_remain,max_loc_wgt,loc_status,stk_pos_dep,hash_loc_id
                    ) values ('{0}','{1}','{2}','{3}','{4}','{5}',
                              '{6}','{7}','{8}','{9}','{10}','{11}',
                              '{12}','{13}','{14}','{15}','{16}','{17}',
                              '{18}','{19}','{20}','{21}','{22}','{23}',
                              '{24}','{25}','{26}','{27}','{28}','{29}',
                              '{30}','{31}','{32}','{33}','{34}');",
                             ic.dc_id, ic.whse_id, ic.loc_id, ic.llts_id, ic.bkfill_loc, ic.ldes_id,
                             ic.ldim_id, ic.x_coord, ic.y_coord, ic.z_coord, ic.bkfill_x_coord, ic.bkfill_y_coord,
                             ic.bkfill_z_coord, ic.lsta_id, ic.sel_stk_pos, ic.sel_seq_loc, ic.sel_pos_hgt, ic.rsv_stk_pos,
                             ic.rsv_pos_hgt, ic.stk_lmt, ic.stk_pos_wid, ic.lev, ic.lhnd_id, ic.ldsp_id,
                             ic.create_user, BLL.gigade.Common.CommonFunction.DateTimeToString(ic.create_dtim), ic.comingle_allow, ic.change_user, BLL.gigade.Common.CommonFunction.DateTimeToString(ic.change_dtim), ic.lcat_id,
                             ic.space_remain, ic.max_loc_wgt, ic.loc_status, ic.stk_pos_dep, has
                             );
                                        result = _IlocMgr.SaveBySql(strsql.ToString());
                                        if (result > 0)
                                        {
                                            count++;
                                            continue;
                                        }
                                        else
                                        {
                                            DataRow drtwo = DTIlocExcel.NewRow();
                                            drtwo[0] = dr[0].ToString();
                                            drtwo[1] = dr[1].ToString();
                                            drtwo[2] = dr[2].ToString();
                                            drtwo[3] = "料位插入數據庫時失敗";
                                            DTIlocExcel.Rows.Add(drtwo);
                                            entercount++;
                                            continue;
                                        }
                                    }
                                }
                                else
                                {
                                    DataRow drtwo = DTIlocExcel.NewRow();
                                    drtwo[0] = dr[0].ToString();
                                    drtwo[1] = dr[1].ToString();
                                    drtwo[2] = dr[2].ToString();
                                    drtwo[3] = "料位編號或者料位類型或者所在層數不符合格式";
                                    DTIlocExcel.Rows.Add(drtwo);
                                    errorcount++;
                                    continue;
                                }
                            }
                            catch
                            {
                                DataRow drtwo = DTIlocExcel.NewRow();
                                drtwo[0] = dr[0].ToString();
                                drtwo[1] = dr[1].ToString();
                                drtwo[2] = dr[2].ToString();
                                drtwo[3] = "數據異常";
                                DTIlocExcel.Rows.Add(drtwo);
                                errorcount++;
                                continue;
                            }
                        }
                        if (count > 0)
                        {
                            json = "{success:true,total:" + count + ",error:" + errorcount + ",entercount:" + entercount + "}";
                        }
                        else
                        {
                            json = "{success:true,total:" + 0 + ",error:" + errorcount + ",entercount:" + entercount + "}";
                        }
                    }
                    else
                    {
                        json = "{success:true,total:" + 0 + ",error:" + 0 + ",entercount" + 0 + "}";
                    }
                }
            }
            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);
                json = "{success:false,data:" + "" + "}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }