Ejemplo n.º 1
0
        public ActionResult CreateChannel()
        {
            SWfsChannelService service     = new SWfsChannelService();
            string             channelName = Request.Params["ChannelName"];
            SWfsChannel        channel     = service.GetChannelByName(channelName);

            if (channel != null)
            {
                return(Json(new { result = "0", message = "频道名称已存在!" }));
            }
            CommonService cs        = new CommonService();
            string        channelNo = DateTime.Now.ToString("yyyyMMdd");
            string        channelId = cs.GetNextCounterId("ChannelNo").ToString("000");

            channelNo += channelId.Substring(channelId.Length - 3, 3);
            string sordNos = Request.Params["SordNo"];
            short  status  = Convert.ToInt16(Request.Params["Status"]);

            if (!string.IsNullOrEmpty(sordNos))
            {
                SWfsChannelSordRef sordRef    = new SWfsChannelSordRef();
                string[]           sordNoList = sordNos.Split(',');
                foreach (string sordNo in sordNoList)
                {
                    sordRef.SordNo    = sordNo;
                    sordRef.ChannelNo = channelNo;
                    try
                    {
                        service.InsertChannelSordRef(sordRef);
                    }
                    catch (Exception ex)
                    {
                        return(Json(new { result = "0", message = ex.Message }));
                    }
                }
            }
            channel               = new SWfsChannel();
            channel.ChannelNo     = channelNo;
            channel.ChannelName   = channelName;
            channel.Status        = status;
            channel.SiteNo        = 2;
            channel.CreateUserId  = PresentationHelper.GetPassport().UserName;
            channel.DateCreate    = DateTime.Now;
            channel.SortNo        = 0;
            channel.DeleteFlag    = 0;
            channel.Description   = "";
            channel.HtmlContent   = "";
            channel.BackgroundPic = "";
            channel.HolidayMode   = 0;//是否开启假日模式(0:未开启,1:开启)
            try
            {
                service.InsertChannel(channel);
                return(Json(new { result = "1", message = "添加成功!" }, "text/plain", Encoding.UTF8));
            }
            catch (Exception ex)
            {
                return(Json(new { result = "0", message = ex.Message }, "text/plain", Encoding.UTF8));
            }
        }
Ejemplo n.º 2
0
        public ActionResult EditChannel()
        {
            SWfsChannelService service     = new SWfsChannelService();
            CommonService      cs          = new CommonService();
            SWfsChannel        channel     = new SWfsChannel();
            string             channelName = Request.Params["ChannelName"];
            string             channelNo   = Request.Params["ChannelNo"];

            channel = service.GetChannelInfo(channelNo);
            if (service.GetChannelByName(channelName) != null && channelName != channel.ChannelName)
            {
                return(Json(new { result = "0", message = "频道名称已存在!" }));
            }
            string sordNos = Request.Params["SordNo"];
            short  status  = Convert.ToInt16(Request.Params["Status"]);

            if (!string.IsNullOrEmpty(sordNos))
            {
                int isDelete = service.DeleteChannelSordRef(channelNo);
                if (isDelete >= 0)
                {
                    SWfsChannelSordRef sordRef    = new SWfsChannelSordRef();
                    string[]           sordNoList = sordNos.Split(',');
                    foreach (string sordNo in sordNoList)
                    {
                        sordRef.SordNo    = sordNo;
                        sordRef.ChannelNo = channelNo;
                        try
                        {
                            service.InsertChannelSordRef(sordRef);
                        }
                        catch (Exception ex)
                        {
                            return(Json(new { result = "0", message = ex.Message }));
                        }
                    }
                }
            }
            channel.ChannelNo   = channelNo;
            channel.ChannelName = channelName;
            channel.Status      = status;
            try
            {
                bool flag = service.UpdateChannel(channel);
                if (flag)
                {
                    return(Json(new { result = "1", message = "修改成功!" }, "text/plain", Encoding.UTF8));
                }
                else
                {
                    return(Json(new { result = "0", message = "修改失败!" }, "text/plain", Encoding.UTF8));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { result = "0", message = ex.Message }, "text/plain", Encoding.UTF8));
            }
        }
Ejemplo n.º 3
0
        public int InsertChannelSordRef(SWfsChannelSordRef sordref)
        {
            int i = DapperUtil.Insert <SWfsChannelSordRef>(sordref, false);

            return(i);
        }