예제 #1
0
        public List<NewPromoQuestionQuery> GetPromoQuestionList(NewPromoQuestionQuery query)
        {
            StringBuilder sql = new StringBuilder();
            StringBuilder sqlCondi = new StringBuilder();
            try
            {
                sql.Append(@" select  row_id,event_name, present_event_id,event_desc,event_id,group_id,link_url,promo_image,device,count_by,count,active_now,new_user,new_user_date,start,end,active,kuser,muser,created,modified ");

                sqlCondi.Append(" from new_promo_questionnaire  ");
                sqlCondi.Append(" where event_id!='' ");
                if (!string.IsNullOrEmpty(query.event_id))
                {
                    sqlCondi.AppendFormat(" and event_id='{0}'", query.event_id);
                }
                if (!string.IsNullOrEmpty(query.row_id_in))
                {
                    sqlCondi.AppendFormat(" and  row_id in({0}) ", query.row_id_in);
                }
                if (query.row_id != 0)
                {
                    sqlCondi.AppendFormat(" and  row_id ='{0}' ", query.row_id);
                }
                sqlCondi.Append(" order by row_id desc ");


                sql.Append(sqlCondi.ToString());

                return _access.getDataTableForObj<NewPromoQuestionQuery>(sql.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("NewPromoQuestionDao.GetPromoQuestionList-->" + ex.Message + sql.ToString(), ex);
            }

        }
예제 #2
0
        public DataTable GetPromoQuestionList(NewPromoQuestionQuery query, out int totalCount)
        {
            StringBuilder sql = new StringBuilder();
            StringBuilder sqlcount = new StringBuilder();
            StringBuilder sqlCondition = new StringBuilder();
            try
            {
                sql.Append(@" select  row_id,event_name, q.present_event_id,event_desc,q.event_id,q.group_id,link_url,promo_image,
promo_image as s_promo_image,device,count_by,count,active_now, new_user,new_user_date,
start,end,active,kuser,muser,created,modified,vug.group_name as group_name ");

                sqlCondition.Append(" from new_promo_questionnaire q ");
                sqlCondition.Append("LEFT JOIN vip_user_group vug on q.group_id=vug.group_id ");
                sqlCondition.Append(" where q.event_id!='' ");
                sqlcount.Append("select count(row_id) as totalCount ");
                if (query.event_id != "")
                {
                    sqlCondition.AppendFormat(" and q.event_id='{0}' ", query.event_id);
                }
                else
                {
                    if (query.searchtype == 0)//已過期
                    {
                        sqlCondition.AppendFormat(" and end <'{0}' ", query.end.ToString("yyyy-MM-dd HH:mm:ss"));
                    }
                    else
                    {
                        sqlCondition.AppendFormat(" and end >'{0}' ", query.end.ToString("yyyy-MM-dd HH:mm:ss"));
                    }
                }
                
                totalCount = 0;
                if (query.IsPage)
                {
                    sqlcount.Append(sqlCondition.ToString());
                    DataTable _dt = _access.getDataTable(sqlcount.ToString());
                    if (_dt.Rows.Count > 0)
                    {
                        totalCount = int.Parse(_dt.Rows[0]["totalCount"].ToString());
                    }
                    sqlCondition.Append(" order by row_id desc ");
                    sqlCondition.AppendFormat(" limit {0},{1} ", query.Start, query.Limit);
                }

                sql.Append(sqlCondition.ToString());

                return _access.getDataTable(sql.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("NewPromoQuestionDao.GetPromoQuestionList-->" + ex.Message + sql.ToString() + sqlcount.ToString(), ex);
            }

        }
예제 #3
0
 public int UpdateNewPromoQuestion(NewPromoQuestionQuery query)
 {
     try
     {
         return _access.execCommand(_INewsPromoQuestionDao.UpdateNewPromoQuestion(query));
     }
     catch (Exception ex)
     {
         throw new Exception("NewPromoQuestionMgr-->UpdateNewPromoQuestion" + ex.Message, ex);
     }
 }
예제 #4
0
 public List<NewPromoQuestionQuery> GetPromoQuestionList(NewPromoQuestionQuery query)
 {
     try
     {
         return _INewsPromoQuestionDao.GetPromoQuestionList(query);
     }
     catch (Exception ex)
     {
         throw new Exception("NewPromoQuestionMgr-->GetPromoQuestionList" + ex.Message, ex);
     }
 }
예제 #5
0
 public DataTable GetPromoQuestionList(NewPromoQuestionQuery query, out int totalCount)
 {
     try
     {
         return _INewsPromoQuestionDao.GetPromoQuestionList(query, out totalCount);
     }
     catch (Exception ex)
     {
         throw new Exception("NewPromoQuestionMgr-->GetPromoQuestionList" + ex.Message, ex);
     }
 }
예제 #6
0
        public HttpResponseBase PromoQuestionnaireList()
        {
            string jsonStr = string.Empty;

            try
            {
                NewPromoQuestionQuery query = new NewPromoQuestionQuery();
                query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");
                if (!string.IsNullOrEmpty(Request.Params["limit"]))
                {
                    query.Limit = Convert.ToInt32(Request.Params["limit"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["SearchTime"]))
                {
                    query.searchtype = int.Parse(Request.Params["SearchTime"]);
                    query.end = DateTime.Now;
                }
                int totalCount = 0;
                _INewPromoQuestionMgr = new NewPromoQuestionMgr(mySqlConnectionString);

                DataTable _dt = _INewPromoQuestionMgr.GetPromoQuestionList(query, out totalCount);
                for (int i = 0; i < _dt.Rows.Count; i++)
                {
                    if (_dt.Rows[i]["promo_image"].ToString() != "")
                    {
                        _dt.Rows[i]["s_promo_image"] = imgServerPath + NewPromoPath + _dt.Rows[i]["promo_image"];
                    }
                    else
                    {
                        _dt.Rows[i]["s_promo_image"] = defaultImg;
                    }
                }
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                jsonStr = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(_dt, 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;
        }
예제 #7
0
 public int InsertNewPromoQuestion(NewPromoQuestionQuery query)
 {
     try
     {
         int row_id = 0;
         DataTable dt = _access.getDataTable(_INewsPromoQuestionDao.GetMaxRowId());
         if (dt.Rows.Count > 0)
         {
             row_id = Convert.ToInt32(dt.Rows[0]["row_id"].ToString());
         }
         query.row_id = row_id + 1;
         query.event_id = BLL.gigade.Common.CommonFunction.GetEventId("F1", query.row_id.ToString());
         return _access.execCommand(_INewsPromoQuestionDao.InsertNewPromoQuestion(query));
     }
     catch (Exception ex)
     {
         throw new Exception("NewPromoQuestionMgr-->InsertNewPromoQuestion" + ex.Message, ex);
     }
 }
예제 #8
0
        /// <summary>
        /// 更改活動使用狀態
        /// </summary>
        /// <returns>數據庫操作結果</returns>
        public JsonResult UpdateActiveQuestion()
        {
            try
            {
                int row_id = 0;
                if (!string.IsNullOrEmpty(Request.Params["row_id"].ToString()))
                {
                    row_id = Convert.ToInt32(Request.Params["row_id"].ToString());
                }
                int activeValue = Convert.ToInt32(Request.Params["active"] ?? "0");
                _INewPromoQuestionMgr = new NewPromoQuestionMgr(mySqlConnectionString);
                NewPromoQuestionQuery model = new NewPromoQuestionQuery();
                model.row_id = row_id;
                model.active = activeValue;
                model.muser = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;
                model.modified = DateTime.Now;
                if (_INewPromoQuestionMgr.UpdateActive(model) > 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" });
            }

        }
예제 #9
0
        /// <summary>
        /// 刪除問卷送禮
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase DeleteQuestion()
        {
            NewPromoQuestionQuery query = new NewPromoQuestionQuery();
            string json = string.Empty;
            try
            {
                string Row_id = "";
                if (!string.IsNullOrEmpty(Request.Params["rowId"]))
                {
                    Row_id = Request.Params["rowId"];
                    Row_id = Row_id.TrimEnd(',');
                }

                _INewPromoQuestionMgr = new NewPromoQuestionMgr(mySqlConnectionString);

                int result = _INewPromoQuestionMgr.DeleteQuestion(Row_id);
                if (result > 0)
                {

                    json = "{success:true,msg:\"" + result + "\"}";
                }
                else
                {
                    json = "{success:false,msg:\"" + result + "\"}";
                }
            }
            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:'0'}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;

        }
예제 #10
0
        /// <summary>
        /// 分步保存第二步
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase SaveQuestion()
        {
            string json = string.Empty;
            try
            {
                _INewPromoQuestionMgr = new NewPromoQuestionMgr(mySqlConnectionString);
                NewPromoQuestionQuery query = new NewPromoQuestionQuery();
                NewPromoQuestionQuery oldModel = new NewPromoQuestionQuery();
                #region 需要更改的屬性
                if (!string.IsNullOrEmpty(Request.Params["row_id"]))
                {
                    query.row_id = Convert.ToInt32(Request.Params["row_id"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["event_id"]))
                {
                    query.event_id = Request.Params["event_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["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 = DateTime.Parse(Request.Params["start"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["end"]))
                {
                    query.end = DateTime.Parse(Request.Params["end"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["group_id"]))
                {
                    query.group_id = int.Parse(Request.Params["group_id"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["new_user"]))
                {
                    query.new_user = int.Parse(Request.Params["new_user"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["new_user_date"]))
                {
                    query.new_user_date = DateTime.Parse(Request.Params["new_user_date"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["count_by"]))
                {
                    query.count_by = int.Parse(Request.Params["count_by"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["count"]))
                {
                    query.count = int.Parse(Request.Params["count"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["device"]))
                {
                    query.device = Request.Params["device"];
                }
                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 = int.Parse(Request.Params["active_now"]);
                }


                #endregion


                #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 + 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);
                        string ErrorMsg = string.Empty;
                        //上傳之前刪除已有的圖片
                        if (query.row_id != 0)
                        {
                            oldModel = _INewPromoQuestionMgr.GetPromoQuestionList(new NewPromoQuestionQuery { row_id = query.row_id }).FirstOrDefault();
                            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;
                        }
                    }

                }
                #endregion
                if (query.row_id == 0)
                {

                    query.created = DateTime.Now;
                    query.modified = query.created;
                    query.kuser = Convert.ToInt32((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id);
                    query.muser = query.kuser;
                    if (_INewPromoQuestionMgr.InsertNewPromoQuestion(query) > 0)
                    {
                        json = "{success:true }";
                    }
                    else
                    {
                        json = "{success:false }";
                    }
                }
                else
                {
                    query.modified = DateTime.Now;
                    query.muser = Convert.ToInt32((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id);
                    if (_INewPromoQuestionMgr.UpdateNewPromoQuestion(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.ToString());
            this.Response.End();
            return this.Response;

        }
예제 #11
0
 public string UpdateActive(NewPromoQuestionQuery query)
 {
     StringBuilder sql = new StringBuilder();
     try
     {
         sql.AppendFormat("set sql_safe_updates=0;update new_promo_questionnaire set active='{0}' where row_id='{1}';set sql_safe_updates=1;", query.active, query.row_id);
         return sql.ToString();
     }
     catch (Exception ex)
     {
         throw new Exception("NewPromoQuestionDao.UpdateActive-->" + ex.Message + sql.ToString(), ex);
     }
 }
예제 #12
0
 public string UpdateNewPromoQuestion(NewPromoQuestionQuery store)
 {
     StringBuilder sql = new StringBuilder();
     try
     {
         sql.AppendFormat(@" update   new_promo_questionnaire set ");
         //if (store.IsModified != 0)//新增
         //{
             sql.AppendFormat(@"  event_name='{0}',event_desc='{1}',start='{2}',end='{3}',", store.event_name, store.event_desc, Common.CommonFunction.DateTimeToString(store.start), Common.CommonFunction.DateTimeToString(store.end));
         //}
         sql.AppendFormat(@" present_event_id='{0}',group_id='{1}'", store.present_event_id, store.group_id);
         sql.AppendFormat(@",link_url='{0}',promo_image='{1}',device='{2}',count_by='{3}'", store.link_url, store.promo_image, store.device, store.count_by);
         sql.AppendFormat(@",count='{0}',active_now='{1}',new_user='******',new_user_date='{3}'", store.count, store.active_now, store.new_user, Common.CommonFunction.DateTimeToString(store.new_user_date));
         sql.AppendFormat(@",active='{0}'", store.active);
         sql.AppendFormat(@",muser='******',modified='{1}' where row_id='{2}'", store.muser, Common.CommonFunction.DateTimeToString(store.modified), store.row_id);
         return sql.ToString();
     }
     catch (Exception ex)
     {
         throw new Exception("NewPromoQuestionDao.UpdateNewPromoQuestion-->" + ex.Message + sql.ToString(), ex);
     }
 }
예제 #13
0
 public string InsertNewPromoQuestion(NewPromoQuestionQuery store)
 {
     StringBuilder sql = new StringBuilder();
     try
     {
         sql.Append(@"insert into new_promo_questionnaire (row_id,present_event_id, event_name,event_desc,event_id,group_id,link_url,promo_image,device,count_by,count,active_now,new_user,new_user_date,start,end,active,kuser,muser,created,modified )");
         sql.AppendFormat(@" values('{0}','{1}','{2}','{3}','{4}','{5}'", store.row_id, store.present_event_id, store.event_name, store.event_desc, store.event_id, store.group_id);
         sql.AppendFormat(@",'{0}','{1}','{2}','{3}'", store.link_url, store.promo_image, store.device, store.count_by);
         sql.AppendFormat(@",'{0}','{1}','{2}','{3}'", store.count, store.active_now, store.new_user, Common.CommonFunction.DateTimeToString(store.new_user_date));
         sql.AppendFormat(@",'{0}','{1}','{2}','{3}'", Common.CommonFunction.DateTimeToString(store.start), Common.CommonFunction.DateTimeToString(store.end), store.active, store.kuser);
         sql.AppendFormat(@",'{0}','{1}','{2}');", store.muser, Common.CommonFunction.DateTimeToString(store.created), Common.CommonFunction.DateTimeToString(store.modified));
         return sql.ToString();
     }
     catch (Exception ex)
     {
         throw new Exception("NewPromoQuestionDao.InsertNewPromoQuestion-->" + ex.Message + sql.ToString(), ex);
     }
 }