Пример #1
0
 public HttpResponseBase GetChinatrustList()
 {
     string jsonStr = string.Empty;
    // int tranInt = 0;
     try
     {
         List<EventChinatrustQuery> store = new List<EventChinatrustQuery>();
         EventChinatrustQuery query = new EventChinatrustQuery();
         query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");
         if (!string.IsNullOrEmpty(Request.Params["limit"]))
         {
             query.Limit = Convert.ToInt32(Request.Params["limit"]);
         }
         query.event_active = -1;
         if (int.Parse(Request.Params["event_active"]) != -1)
         {
             query.event_active = int.Parse(Request.Params["event_active"]);
         }
         if (!string.IsNullOrEmpty(Request.Params["event_search"]))
         {
             //if (int.TryParse(Request.Params["event_search"], out tranInt))
             //{
             //    query.event_id = int.Parse(Request.Params["event_search"].ToString());
             //}
             //else
             //{
             query.event_id_name = Request.Params["event_search"];
             //}
         }
         if (!string.IsNullOrEmpty(Request.Params["date"]))
         {
             query.dateCondition = Convert.ToInt32(Request.Params["date"]);
         }
         if (!string.IsNullOrEmpty(Request.Params["TimeStart"]))
         {
             query.event_start_time = DateTime.Parse(Request.Params["TimeStart"]);
         }
         if (!string.IsNullOrEmpty(Request.Params["TimeEnd"]))
         {
             query.event_end_time = DateTime.Parse(Request.Params["TimeEnd"]);
         }
         int totalCount = 0;
         _eventChinatrust = new EventChinatrustMgr(mySqlConnectionString);
         store = _eventChinatrust.GetEventChinatrustList(query, out totalCount);
         for (int i = 0; i < store.Count; i++)
         {
             store[i].event_desc = Server.HtmlDecode(Server.HtmlDecode(store[i].event_desc));
             if (store[i].event_banner != "")
             {
                 store[i].s_event_banner = imgServerPath + PaperPath + store[i].event_banner;//"http://192.168.71.10:8765"+/paper/
             }
             else
             {
                 store[i].s_event_banner = defaultImg;
             }
         }
         IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
         //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
         timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
         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;
 }
Пример #2
0
 public JsonResult UpdateActiveQuestion()
 {
     try
     {
         EventChinatrustQuery query = new EventChinatrustQuery();
         if (!string.IsNullOrEmpty(Request.Params["row_id"].ToString()))
         {
             query.row_id = Convert.ToInt32(Request.Params["row_id"].ToString());
         }
         query.event_active = Convert.ToInt32(Request.Params["event_active"] ?? "0");
         _eventChinatrust = new EventChinatrustMgr(mySqlConnectionString);
         query.event_update_user = (Session["caller"] as Caller).user_id;
         query.event_update_time = DateTime.Now;
         if (_eventChinatrust.UpEventChinatrustStatus(query) > 0)
         {
             return Json(new { success = "true" });
         }
         else
         {
             return Json(new { 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);
         return Json(new { success = "false" });
     }
 }
Пример #3
0
 public HttpResponseBase GetChinaTrustStore()
 {
     string json=string.Empty;
     List<EventChinatrustQuery> store = new List<EventChinatrustQuery>();
     try
     {
         _eventChinatrust=new EventChinatrustMgr (mySqlConnectionString);
         store = _eventChinatrust.GetChinaTrustStore();
         json = "{success:true,data:" + JsonConvert.SerializeObject(store, Formatting.Indented) + "}";
     }
     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;
 }
Пример #4
0
        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;
        }