Example #1
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            AppointmentId = TranslateUtils.ToInt(Request["appointmentID"]);

            if (!string.IsNullOrEmpty(Request.QueryString["Delete"]))
            {
                var list = TranslateUtils.StringCollectionToIntList(Request.QueryString["IDCollection"]);
                if (list.Count > 0)
                {
                    try
                    {
                        DataProviderWx.AppointmentContentDao.Delete(PublishmentSystemId, list);
                        SuccessMessage("预约删除成功!");
                    }
                    catch (Exception ex)
                    {
                        FailMessage(ex, "预约删除失败!");
                    }
                }
            }

            SpContents.ControlToPaginate = RptContents;
            SpContents.ItemsPerPage      = 30;
            SpContents.SelectCommand     = DataProviderWx.AppointmentContentDao.GetSelectString(PublishmentSystemId, AppointmentId);
            SpContents.SortField         = AppointmentContentAttribute.Id;
            SpContents.SortMode          = SortMode.DESC;
            RptContents.ItemDataBound   += rptContents_ItemDataBound;

            if (!IsPostBack)
            {
                BreadCrumb(AppManager.WeiXin.LeftMenu.IdFunction, AppManager.WeiXin.LeftMenu.Function.IdAppointment, "查看预约", AppManager.WeiXin.Permission.WebSite.Appointment);
                SpContents.DataBind();

                BtnHandle.Attributes.Add("onclick", ModalAppointmentHandle.GetOpenWindowStringToMultiple(PublishmentSystemId));

                var urlDelete = PageUtils.AddQueryString(GetRedirectUrl(PublishmentSystemId, AppointmentId), "Delete", "True");
                BtnDelete.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValueAndAlert(urlDelete, "IDCollection", "IDCollection", "请选择需要删除的微预约", "此操作将删除所选微预约,确认吗?"));

                BtnExport.Attributes.Add("onclick", ModalExportAppointmentContent.GetOpenWindowStringByAppointmentContent(PublishmentSystemId, AppointmentId, AppointmentTitle));

                var returnUrl = PageAppointment.GetRedirectUrl(PublishmentSystemId);
                BtnReturn.Attributes.Add("onclick", $"location.href='{returnUrl}';return false");
            }
        }
Example #2
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("PublishmentSystemId");
            _appointmentId     = Body.GetQueryInt("appointmentID");
            _appointmentItemId = Body.GetQueryInt("appointmentItemID");

            SpContents.ControlToPaginate = RptContents;
            SpContents.ItemsPerPage      = 30;
            SpContents.SelectCommand     = DataProviderWx.AppointmentItemDao.GetSelectString(PublishmentSystemId, _appointmentId);
            SpContents.SortField         = AlbumAttribute.Id;
            SpContents.SortMode          = SortMode.ASC;
            RptContents.ItemDataBound   += rptContents_ItemDataBound;

            if (!IsPostBack)
            {
                var pageTitle = _appointmentId > 0 ? "编辑微预约" : "添加微预约";
                BreadCrumb(AppManager.WeiXin.LeftMenu.IdFunction, AppManager.WeiXin.LeftMenu.Function.IdAppointment, pageTitle, AppManager.WeiXin.Permission.WebSite.Appointment);

                LtlPageTitle.Text = pageTitle;

                LtlImageUrl.Text =
                    $@"<img id=""preview_imageUrl"" src=""{AppointmentManager.GetImageUrl(PublishmentSystemInfo,
                        string.Empty)}"" width=""370"" align=""middle"" />";
                LtlContentImageUrl.Text =
                    $@"<img id=""preview_contentImageUrl"" src=""{AppointmentManager.GetContentImageUrl(
                        PublishmentSystemInfo, string.Empty)}"" width=""370"" align=""middle"" />";
                LtlContentResultTopImageUrl.Text =
                    $@"<img id=""preview_contentResultTopImageUrl"" src=""{AppointmentManager.GetContentResultTopImageUrl(
                        PublishmentSystemInfo, string.Empty)}"" width=""370"" align=""middle"" />";
                LtlEndImageUrl.Text =
                    $@"<img id=""preview_endImageUrl"" src=""{AppointmentManager.GetEndImageUrl(PublishmentSystemInfo,
                        string.Empty)}"" width=""370"" align=""middle"" />";

                SpContents.DataBind();

                BtnAdd.Attributes.Add("onclick", ModalAppointmentItemAdd.GetOpenWindowStringToAdd(PublishmentSystemId, _appointmentId, 0));

                //string urlDelete = PageUtils.AddQueryString(BackgroundAppointmentMultipleAdd.GetRedirectUrl(base.PublishmentSystemId, this.appointmentID,this.tbTitle.Text), "Delete", "True");
                //this.btnDelete.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValueAndAlert(urlDelete, "IDCollection", "IDCollection", "请选择需要删除的微预约项目", "此操作将删除所选微预约项目,确认吗?"));

                if (_appointmentId == 0)
                {
                    DtbEndDate.DateTime = DateTime.Now.AddMonths(1);
                }
                else
                {
                    var appointmentInfo = DataProviderWx.AppointmentDao.GetAppointmentInfo(_appointmentId);

                    if (appointmentInfo != null)
                    {
                        TbKeywords.Text       = DataProviderWx.KeywordDao.GetKeywords(appointmentInfo.KeywordId);
                        CbIsEnabled.Checked   = !appointmentInfo.IsDisabled;
                        DtbStartDate.DateTime = appointmentInfo.StartDate;
                        DtbEndDate.DateTime   = appointmentInfo.EndDate;
                        TbTitle.Text          = appointmentInfo.Title;
                        if (!string.IsNullOrEmpty(appointmentInfo.ImageUrl))
                        {
                            LtlImageUrl.Text =
                                $@"<img id=""preview_imageUrl"" src=""{PageUtility.ParseNavigationUrl(
                                    PublishmentSystemInfo, appointmentInfo.ImageUrl)}"" width=""370"" align=""middle"" />";
                        }
                        TbSummary.Text = appointmentInfo.Summary;
                        if (!string.IsNullOrEmpty(appointmentInfo.ContentImageUrl))
                        {
                            LtlContentImageUrl.Text =
                                $@"<img id=""preview_contentImageUrl"" src=""{PageUtility.ParseNavigationUrl(
                                    PublishmentSystemInfo, appointmentInfo.ContentImageUrl)}"" width=""370"" align=""middle"" />";
                        }
                        if (!string.IsNullOrEmpty(appointmentInfo.ContentResultTopImageUrl))
                        {
                            LtlContentResultTopImageUrl.Text =
                                $@"<img id=""preview_contentResultTopImageUrl"" src=""{PageUtility.ParseNavigationUrl(
                                    PublishmentSystemInfo, appointmentInfo.ContentResultTopImageUrl)}"" width=""370"" align=""middle"" />";
                        }

                        TbContentDescription.Text = appointmentInfo.ContentDescription;

                        TbEndTitle.Text   = appointmentInfo.EndTitle;
                        TbEndSummary.Text = appointmentInfo.EndSummary;
                        if (!string.IsNullOrEmpty(appointmentInfo.EndImageUrl))
                        {
                            LtlEndImageUrl.Text =
                                $@"<img id=""preview_endImageUrl"" src=""{PageUtility.ParseNavigationUrl(
                                    PublishmentSystemInfo, appointmentInfo.EndImageUrl)}"" width=""370"" align=""middle"" />";
                        }

                        ImageUrl.Value                 = appointmentInfo.ImageUrl;
                        ContentImageUrl.Value          = appointmentInfo.ContentImageUrl;
                        ContentResultTopImageUrl.Value = appointmentInfo.ContentResultTopImageUrl;
                        EndImageUrl.Value              = appointmentInfo.EndImageUrl;
                        #region 拓展属性
                        #region 姓名
                        if (appointmentInfo.IsFormRealName == "True")
                        {
                            CbIsFormRealName.Checked = true;
                            TbFormRealNameTitle.Text = appointmentInfo.FormRealNameTitle;
                        }
                        else if (string.IsNullOrEmpty(appointmentInfo.IsFormRealName))
                        {
                            CbIsFormRealName.Checked = true;
                            TbFormRealNameTitle.Text = "姓名";
                        }
                        else
                        {
                            CbIsFormRealName.Checked = false;
                            TbFormRealNameTitle.Text = appointmentInfo.FormRealNameTitle;
                        }
                        #endregion
                        #region 电话
                        if (appointmentInfo.IsFormMobile == "True")
                        {
                            CbIsFormMobile.Checked = true;
                            TbFormMobileTitle.Text = appointmentInfo.FormMobileTitle;
                        }
                        else if (string.IsNullOrEmpty(appointmentInfo.IsFormMobile))
                        {
                            CbIsFormMobile.Checked = true;
                            TbFormMobileTitle.Text = "电话";
                        }
                        else
                        {
                            CbIsFormMobile.Checked = false;
                            TbFormMobileTitle.Text = appointmentInfo.FormMobileTitle;
                        }
                        #endregion
                        #region 邮箱
                        if (appointmentInfo.IsFormEmail == "True")
                        {
                            CbIsFormEmail.Checked = true;
                            TbFormEmailTitle.Text = appointmentInfo.FormEmailTitle;
                        }
                        else if (string.IsNullOrEmpty(appointmentInfo.IsFormEmail))
                        {
                            CbIsFormEmail.Checked = true;
                            TbFormEmailTitle.Text = "邮箱";
                        }
                        else
                        {
                            CbIsFormEmail.Checked = false;
                            TbFormEmailTitle.Text = appointmentInfo.FormEmailTitle;
                        }
                        #endregion

                        _appointmentItemId = DataProviderWx.AppointmentItemDao.GetItemId(PublishmentSystemId, _appointmentId);

                        var configExtendInfoList = DataProviderWx.ConfigExtendDao.GetConfigExtendInfoList(PublishmentSystemId, appointmentInfo.Id, EKeywordTypeUtils.GetValue(EKeywordType.Appointment));
                        var itemBuilder          = new StringBuilder();
                        foreach (var configExtendInfo in configExtendInfoList)
                        {
                            if (string.IsNullOrEmpty(configExtendInfo.IsVisible))
                            {
                                configExtendInfo.IsVisible = "checked=checked";
                            }
                            else if (configExtendInfo.IsVisible == "True")
                            {
                                configExtendInfo.IsVisible = "checked=checked";
                            }
                            else
                            {
                                configExtendInfo.IsVisible = "";
                            }
                            itemBuilder.AppendFormat(@"{{id: '{0}', attributeName: '{1}',isVisible:'{2}'}},", configExtendInfo.Id, configExtendInfo.AttributeName, configExtendInfo.IsVisible);
                        }
                        if (itemBuilder.Length > 0)
                        {
                            itemBuilder.Length--;
                        }
                        LtlAwardItems.Text =
                            $@"itemController.itemCount = {configExtendInfoList.Count};itemController.items = [{itemBuilder}];";
                        #endregion
                    }
                }

                BtnReturn.Attributes.Add("onclick",
                                         $@"location.href=""{PageAppointment.GetRedirectUrl(PublishmentSystemId)}"";return false");
            }
        }
Example #3
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (Page.IsPostBack && Page.IsValid)
            {
                var selectedStep = 0;
                if (PhStep1.Visible)
                {
                    selectedStep = 1;
                }
                else if (PhStep2.Visible)
                {
                    selectedStep = 2;
                }
                else if (PhStep3.Visible)
                {
                    selectedStep = 3;
                }
                else if (PhStep4.Visible)
                {
                    selectedStep = 4;
                }
                else if (PhStep5.Visible)
                {
                    selectedStep = 5;
                }

                PhStep1.Visible = false;
                PhStep2.Visible = false;
                PhStep3.Visible = false;
                PhStep4.Visible = false;
                PhStep5.Visible = false;

                if (selectedStep == 1)
                {
                    var isConflict       = false;
                    var conflictKeywords = string.Empty;
                    if (!string.IsNullOrEmpty(TbKeywords.Text))
                    {
                        if (_appointmentId > 0)
                        {
                            var appointmentInfo = DataProviderWx.AppointmentDao.GetAppointmentInfo(_appointmentId);
                            isConflict = KeywordManager.IsKeywordUpdateConflict(PublishmentSystemId, appointmentInfo.KeywordId, TbKeywords.Text, out conflictKeywords);
                        }
                        else
                        {
                            isConflict = KeywordManager.IsKeywordInsertConflict(PublishmentSystemId, TbKeywords.Text, out conflictKeywords);
                        }
                    }

                    if (isConflict)
                    {
                        FailMessage($"触发关键词“{conflictKeywords}”已存在,请设置其他关键词");
                        PhStep1.Visible = true;
                    }
                    else
                    {
                        PhStep2.Visible = true;
                    }
                }
                else if (selectedStep == 2)
                {
                    PhStep3.Visible = true;
                }
                else if (selectedStep == 3)
                {
                    PhStep4.Visible = true;
                }
                else if (selectedStep == 4)
                {
                    var isItemReady = true;
                    var itemCount   = TranslateUtils.ToInt(Request.Form["itemCount"]);

                    var itemIdList        = TranslateUtils.StringCollectionToIntList(Request.Form["itemID"]);
                    var attributeNameList = TranslateUtils.StringCollectionToStringList(Request.Form["itemAttributeName"]);

                    var itemIsVisible = "off";
                    if (!string.IsNullOrEmpty(Request.Form["itemIsVisible"]))
                    {
                        itemIsVisible = Request.Form["itemIsVisible"];
                    }

                    var isVisibleList = TranslateUtils.StringCollectionToStringList(itemIsVisible);

                    if (isVisibleList.Count < itemIdList.Count)
                    {
                        for (var i = isVisibleList.Count; i < itemIdList.Count; i++)
                        {
                            isVisibleList.Add("off");
                        }
                    }

                    var configExtendInfoList = new List <ConfigExtendInfo>();
                    for (var i = 0; i < itemCount; i++)
                    {
                        var configExtendInfo = new ConfigExtendInfo {
                            Id = itemIdList[i], PublishmentSystemId = PublishmentSystemId, KeywordType = EKeywordTypeUtils.GetValue(EKeywordType.Appointment), FunctionId = _appointmentId, AttributeName = attributeNameList[i], IsVisible = isVisibleList[i]
                        };

                        if (string.IsNullOrEmpty(configExtendInfo.AttributeName))
                        {
                            FailMessage("保存失败,属性名称为必填项");
                            isItemReady = false;
                        }
                        if (string.IsNullOrEmpty(configExtendInfo.IsVisible))
                        {
                            FailMessage("保存失败,是否必填为显示项");
                            isItemReady = false;
                        }

                        if (configExtendInfo.IsVisible == "on")
                        {
                            configExtendInfo.IsVisible = "True";
                        }
                        else
                        {
                            configExtendInfo.IsVisible = "False";
                        }

                        configExtendInfoList.Add(configExtendInfo);
                    }

                    if (isItemReady)
                    {
                        DataProviderWx.ConfigExtendDao.DeleteAllNotInIdList(PublishmentSystemId, _appointmentId, itemIdList);

                        foreach (var configExtendInfo in configExtendInfoList)
                        {
                            if (configExtendInfo.Id > 0)
                            {
                                DataProviderWx.ConfigExtendDao.Update(configExtendInfo);
                            }
                            else
                            {
                                DataProviderWx.ConfigExtendDao.Insert(configExtendInfo);
                            }
                        }
                    }

                    if (isItemReady)
                    {
                        PhStep5.Visible = true;
                        BtnSubmit.Text  = "确 认";
                    }
                    else
                    {
                        PhStep4.Visible = true;
                    }
                }
                else if (selectedStep == 5)
                {
                    var appointmentInfo = new AppointmentInfo();
                    appointmentInfo.PublishmentSystemId = PublishmentSystemId;

                    if (_appointmentId > 0)
                    {
                        appointmentInfo = DataProviderWx.AppointmentDao.GetAppointmentInfo(_appointmentId);
                        DataProviderWx.KeywordDao.Update(PublishmentSystemId, appointmentInfo.KeywordId,
                                                         EKeywordType.Appointment, EMatchType.Exact, TbKeywords.Text, !CbIsEnabled.Checked);
                    }
                    else
                    {
                        var keywordInfo = new KeywordInfo();

                        keywordInfo.KeywordId           = 0;
                        keywordInfo.PublishmentSystemId = PublishmentSystemId;
                        keywordInfo.Keywords            = TbKeywords.Text;
                        keywordInfo.IsDisabled          = !CbIsEnabled.Checked;
                        keywordInfo.KeywordType         = EKeywordType.Appointment;
                        keywordInfo.MatchType           = EMatchType.Exact;
                        keywordInfo.Reply   = string.Empty;
                        keywordInfo.AddDate = DateTime.Now;
                        keywordInfo.Taxis   = 0;

                        appointmentInfo.KeywordId = DataProviderWx.KeywordDao.Insert(keywordInfo);
                    }

                    appointmentInfo.StartDate = DtbStartDate.DateTime;
                    appointmentInfo.EndDate   = DtbEndDate.DateTime;
                    appointmentInfo.Title     = TbTitle.Text;
                    appointmentInfo.ImageUrl  = ImageUrl.Value;
                    ;
                    appointmentInfo.Summary = TbSummary.Text;

                    appointmentInfo.ContentImageUrl          = ContentImageUrl.Value;
                    appointmentInfo.ContentDescription       = TbContentDescription.Text;
                    appointmentInfo.ContentResultTopImageUrl = ContentResultTopImageUrl.Value;
                    appointmentInfo.ContentIsSingle          = false;

                    appointmentInfo.EndTitle    = TbEndTitle.Text;
                    appointmentInfo.EndImageUrl = EndImageUrl.Value;
                    appointmentInfo.EndSummary  = TbEndSummary.Text;

                    appointmentInfo.IsFormRealName    = CbIsFormRealName.Checked ? "True" : "False";
                    appointmentInfo.FormRealNameTitle = TbFormRealNameTitle.Text;
                    appointmentInfo.IsFormMobile      = CbIsFormMobile.Checked ? "True" : "False";
                    appointmentInfo.FormMobileTitle   = TbFormMobileTitle.Text;
                    appointmentInfo.IsFormEmail       = CbIsFormEmail.Checked ? "True" : "False";
                    appointmentInfo.FormEmailTitle    = TbFormEmailTitle.Text;

                    try
                    {
                        if (_appointmentId > 0)
                        {
                            DataProviderWx.AppointmentDao.Update(appointmentInfo);

                            Body.AddSiteLog(PublishmentSystemId, "修改微预约", $"微预约:{TbTitle.Text}");
                            SuccessMessage("修改微预约成功!");
                        }
                        else
                        {
                            _appointmentId = DataProviderWx.AppointmentDao.Insert(appointmentInfo);

                            DataProviderWx.AppointmentItemDao.UpdateAppointmentId(PublishmentSystemId,
                                                                                  _appointmentId);

                            Body.AddSiteLog(PublishmentSystemId, "添加微预约", $"微预约:{TbTitle.Text}");
                            SuccessMessage("添加微预约成功!");
                        }

                        AddWaitAndRedirectScript(PageAppointment.GetRedirectUrl(PublishmentSystemId));
                    }
                    catch (Exception ex)
                    {
                        FailMessage(ex, "微预约设置失败!");
                    }

                    BtnSubmit.Visible = false;
                    BtnReturn.Visible = false;
                }
            }
        }
Example #4
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("PublishmentSystemId");
            _appointmentId     = Body.GetQueryInt("appointmentID");
            _appointmentItemId = Body.GetQueryInt("appointmentItemID");

            var selectImageClick  = ModalSelectImage.GetOpenWindowString(PublishmentSystemInfo, TbContentImageUrl.ClientID);
            var uploadImageClick  = ModalUploadImageSingle.GetOpenWindowStringToTextBox(PublishmentSystemId, TbContentImageUrl.ClientID);
            var cuttingImageClick = ModalCuttingImage.GetOpenWindowStringWithTextBox(PublishmentSystemId, TbContentImageUrl.ClientID);
            var previewImageClick = ModalMessage.GetOpenWindowStringToPreviewImage(PublishmentSystemId, TbContentImageUrl.ClientID);

            LtlContentImageUrl.Text = $@"
                      <a class=""btn"" href=""javascript:;"" onclick=""{selectImageClick};return false;"" title=""选择""><i class=""icon-th""></i></a>
                      <a class=""btn"" href=""javascript:;"" onclick=""{uploadImageClick};return false;"" title=""上传""><i class=""icon-arrow-up""></i></a>
                      <a class=""btn"" href=""javascript:;"" onclick=""{cuttingImageClick};return false;"" title=""裁切""><i class=""icon-crop""></i></a>
                      <a class=""btn"" href=""javascript:;"" onclick=""{previewImageClick};return false;"" title=""预览""><i class=""icon-eye-open""></i></a>";

            var selectVideoClick  = ModalSelectVideo.GetOpenWindowString(PublishmentSystemInfo, TbContentVideoUrl.ClientID);
            var uploadVideoClick  = ModalUploadVideo.GetOpenWindowStringToTextBox(PublishmentSystemId, TbContentVideoUrl.ClientID);
            var previewVideoClick = ModalMessage.GetOpenWindowStringToPreviewVideoByUrl(PublishmentSystemId, TbContentVideoUrl.ClientID);

            LtlContentVideoUrl.Text = $@"
                      <a class=""btn"" href=""javascript:;"" onclick=""{selectVideoClick};return false;"" title=""选择""><i class=""icon-th""></i></a>
                      <a class=""btn"" href=""javascript:;"" onclick=""{uploadVideoClick};return false;"" title=""上传""><i class=""icon-arrow-up""></i></a>
                      <a class=""btn"" href=""javascript:;"" onclick=""{previewVideoClick};return false;"" title=""预览""><i class=""icon-eye-open""></i></a>";

            if (!IsPostBack)
            {
                var pageTitle = _appointmentId > 0 ? "编辑微预约" : "添加微预约";
                BreadCrumb(AppManager.WeiXin.LeftMenu.IdFunction, AppManager.WeiXin.LeftMenu.Function.IdAppointment, pageTitle, AppManager.WeiXin.Permission.WebSite.Appointment);
                LtlPageTitle.Text = pageTitle;

                LtlImageUrl.Text =
                    $@"<img id=""preview_imageUrl"" src=""{AppointmentManager.GetImageUrl(PublishmentSystemInfo,
                        string.Empty)}"" width=""370"" align=""middle"" />";
                LtlTopImageUrl.Text =
                    $@"<img id=""preview_topImageUrl"" src=""{AppointmentManager.GetItemTopImageUrl(
                        PublishmentSystemInfo, string.Empty)}"" width=""370"" align=""middle"" />";
                LtlResultTopImageUrl.Text =
                    $@"<img id=""preview_resultTopImageUrl"" src=""{AppointmentManager.GetContentResultTopImageUrl(
                        PublishmentSystemInfo, string.Empty)}"" width=""370"" align=""middle"" />";
                LtlContentImageUrl.Text =
                    $@"<img id=""preview_contentImageUrl"" src=""{AppointmentManager.GetContentImageUrl(
                        PublishmentSystemInfo, string.Empty)}"" width=""370"" align=""middle"" />";

                LtlEndImageUrl.Text =
                    $@"<img id=""preview_endImageUrl"" src=""{AppointmentManager.GetEndImageUrl(PublishmentSystemInfo,
                        string.Empty)}"" width=""370"" align=""middle"" />";

                if (_appointmentId == 0)
                {
                    DtbEndDate.DateTime = DateTime.Now.AddMonths(1);
                }
                else
                {
                    var appointmentInfo = DataProviderWx.AppointmentDao.GetAppointmentInfo(_appointmentId);

                    if (appointmentInfo != null)
                    {
                        TbKeywords.Text       = DataProviderWx.KeywordDao.GetKeywords(appointmentInfo.KeywordId);
                        CbIsEnabled.Checked   = !appointmentInfo.IsDisabled;
                        DtbStartDate.DateTime = appointmentInfo.StartDate;
                        DtbEndDate.DateTime   = appointmentInfo.EndDate;
                        TbTitle.Text          = appointmentInfo.Title;
                        if (!string.IsNullOrEmpty(appointmentInfo.ImageUrl))
                        {
                            LtlImageUrl.Text =
                                $@"<img id=""preview_imageUrl"" src=""{PageUtility.ParseNavigationUrl(
                                    PublishmentSystemInfo, appointmentInfo.ImageUrl)}"" width=""370"" align=""middle"" />";
                        }
                        if (!string.IsNullOrEmpty(appointmentInfo.ContentResultTopImageUrl))
                        {
                            LtlResultTopImageUrl.Text =
                                $@"<img id=""preview_resultTopImageUrl"" src=""{PageUtility.ParseNavigationUrl(
                                    PublishmentSystemInfo, appointmentInfo.ContentResultTopImageUrl)}"" width=""370"" align=""middle"" />";
                        }

                        TbSummary.Text = appointmentInfo.Summary;

                        TbEndTitle.Text   = appointmentInfo.EndTitle;
                        TbEndSummary.Text = appointmentInfo.EndSummary;
                        if (!string.IsNullOrEmpty(appointmentInfo.EndImageUrl))
                        {
                            LtlEndImageUrl.Text =
                                $@"<img id=""preview_endImageUrl"" src=""{PageUtility.ParseNavigationUrl(
                                    PublishmentSystemInfo, appointmentInfo.EndImageUrl)}"" width=""370"" align=""middle"" />";
                        }

                        ImageUrl.Value          = appointmentInfo.ImageUrl;
                        ContentImageUrl.Value   = appointmentInfo.ContentImageUrl;
                        ResultTopImageUrl.Value = appointmentInfo.ContentResultTopImageUrl;
                        EndImageUrl.Value       = appointmentInfo.EndImageUrl;
                        #region 拓展属性
                        #region 姓名
                        if (appointmentInfo.IsFormRealName == "True")
                        {
                            CbIsFormRealName.Checked = true;
                            TbFormRealNameTitle.Text = appointmentInfo.FormRealNameTitle;
                        }
                        else if (string.IsNullOrEmpty(appointmentInfo.IsFormRealName))
                        {
                            CbIsFormRealName.Checked = true;
                            TbFormRealNameTitle.Text = "姓名";
                        }
                        else
                        {
                            CbIsFormRealName.Checked = false;
                            TbFormRealNameTitle.Text = appointmentInfo.FormRealNameTitle;
                        }
                        #endregion
                        #region 电话
                        if (appointmentInfo.IsFormMobile == "True")
                        {
                            CbIsFormMobile.Checked = true;
                            TbFormMobileTitle.Text = appointmentInfo.FormMobileTitle;
                        }
                        else if (string.IsNullOrEmpty(appointmentInfo.IsFormMobile))
                        {
                            CbIsFormMobile.Checked = true;
                            TbFormMobileTitle.Text = "电话";
                        }
                        else
                        {
                            CbIsFormMobile.Checked = false;
                            TbFormMobileTitle.Text = appointmentInfo.FormMobileTitle;
                        }
                        #endregion
                        #region 邮箱
                        if (appointmentInfo.IsFormEmail == "True")
                        {
                            CbIsFormEmail.Checked = true;
                            TbFormEmailTitle.Text = appointmentInfo.FormEmailTitle;
                        }
                        else if (string.IsNullOrEmpty(appointmentInfo.IsFormEmail))
                        {
                            CbIsFormEmail.Checked = true;
                            TbFormEmailTitle.Text = "电话";
                        }
                        else
                        {
                            CbIsFormEmail.Checked = false;
                            TbFormEmailTitle.Text = appointmentInfo.FormEmailTitle;
                        }
                        #endregion

                        _appointmentItemId = DataProviderWx.AppointmentItemDao.GetItemId(PublishmentSystemId, _appointmentId);

                        var configExtendInfoList = DataProviderWx.ConfigExtendDao.GetConfigExtendInfoList(PublishmentSystemId, appointmentInfo.Id, EKeywordTypeUtils.GetValue(EKeywordType.Appointment));
                        var itemBuilder          = new StringBuilder();
                        foreach (var configExtendInfo in configExtendInfoList)
                        {
                            if (string.IsNullOrEmpty(configExtendInfo.IsVisible))
                            {
                                configExtendInfo.IsVisible = "checked=checked";
                            }
                            else if (configExtendInfo.IsVisible == "True")
                            {
                                configExtendInfo.IsVisible = "checked=checked";
                            }
                            else
                            {
                                configExtendInfo.IsVisible = "";
                            }
                            itemBuilder.AppendFormat(@"{{id: '{0}', attributeName: '{1}',isVisible:'{2}'}},", configExtendInfo.Id, configExtendInfo.AttributeName, configExtendInfo.IsVisible);
                        }
                        if (itemBuilder.Length > 0)
                        {
                            itemBuilder.Length--;
                        }
                        LtlAwardItems.Text =
                            $@"itemController.itemCount = {configExtendInfoList.Count};itemController.items = [{itemBuilder}];";
                        #endregion
                    }
                }

                if (_appointmentItemId > 0)
                {
                    var appointmentItemInfo = DataProviderWx.AppointmentItemDao.GetItemInfo(_appointmentItemId);
                    if (appointmentItemInfo != null)
                    {
                        TbItemTitle.Text               = appointmentItemInfo.Title;
                        TopImageUrl.Value              = appointmentItemInfo.TopImageUrl;
                        CbIsDescription.Checked        = appointmentItemInfo.IsDescription;
                        TbDescriptionTitle.Text        = appointmentItemInfo.DescriptionTitle;
                        TbDescription.Text             = appointmentItemInfo.Description;
                        CbIsImageUrl.Checked           = appointmentItemInfo.IsImageUrl;
                        TbImageUrlTitle.Text           = appointmentItemInfo.ImageUrlTitle;
                        TbContentImageUrl.Text         = appointmentItemInfo.ImageUrl;
                        CbIsVideoUrl.Checked           = appointmentItemInfo.IsVideoUrl;
                        TbVideoUrlTitle.Text           = appointmentItemInfo.VideoUrlTitle;
                        TbContentVideoUrl.Text         = appointmentItemInfo.VideoUrl;
                        CbIsImageUrlCollection.Checked = appointmentItemInfo.IsImageUrlCollection;
                        TbImageUrlCollectionTitle.Text = appointmentItemInfo.ImageUrlCollectionTitle;
                        ImageUrlCollection.Value       = appointmentItemInfo.ImageUrlCollection;
                        LargeImageUrlCollection.Value  = appointmentItemInfo.LargeImageUrlCollection;
                        CbIsMap.Checked   = appointmentItemInfo.IsMap;
                        TbMapTitle.Text   = appointmentItemInfo.MapTitle;
                        TbMapAddress.Text = appointmentItemInfo.MapAddress;
                        CbIsTel.Checked   = appointmentItemInfo.IsTel;
                        TbTelTitle.Text   = appointmentItemInfo.TelTitle;
                        TbTel.Text        = appointmentItemInfo.Tel;


                        if (!string.IsNullOrEmpty(appointmentItemInfo.TopImageUrl))
                        {
                            LtlTopImageUrl.Text =
                                $@"<img id=""preview_imageUrl"" src=""{PageUtility.ParseNavigationUrl(
                                    PublishmentSystemInfo, appointmentItemInfo.TopImageUrl)}"" width=""370"" align=""middle"" />";
                        }
                        if (!string.IsNullOrEmpty(appointmentItemInfo.MapAddress))
                        {
                            LtlMap.Text =
                                $@"<iframe style=""width:100%;height:100%;background-color:#ffffff;margin-bottom:15px;"" scrolling=""auto"" frameborder=""0"" width=""100%"" height=""100%"" src=""{MapManager.GetMapUrl(PublishmentSystemInfo, TbMapAddress.Text)}""></iframe>";
                        }
                        if (!string.IsNullOrEmpty(appointmentItemInfo.ImageUrlCollection))
                        {
                            var scriptBuilder = new StringBuilder();
                            scriptBuilder.AppendFormat(@"
addImage('{0}','{1}');
", appointmentItemInfo.ImageUrlCollection, appointmentItemInfo.LargeImageUrlCollection);

                            LtlScript.Text = $@"
$(document).ready(function(){{
	{scriptBuilder}
}});
";
                        }
                    }
                }

                BtnReturn.Attributes.Add("onclick",
                                         $@"location.href=""{PageAppointment.GetRedirectUrl(PublishmentSystemId)}"";return false");
            }
        }
Example #5
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (Page.IsPostBack && Page.IsValid)
            {
                var selectedStep = 0;
                if (phStep1.Visible)
                {
                    selectedStep = 1;
                }
                else if (phStep2.Visible)
                {
                    selectedStep = 2;
                }
                else if (phStep3.Visible)
                {
                    selectedStep = 3;
                }
                else if (phStep4.Visible)
                {
                    selectedStep = 4;
                }

                phStep1.Visible = phStep2.Visible = phStep3.Visible = false;

                if (selectedStep == 1)
                {
                    var isConflict       = false;
                    var conflictKeywords = string.Empty;
                    if (!string.IsNullOrEmpty(tbKeywords.Text))
                    {
                        if (appointmentID > 0)
                        {
                            var appointmentInfo = DataProviderWX.AppointmentDAO.GetAppointmentInfo(appointmentID);
                            isConflict = KeywordManager.IsKeywordUpdateConflict(PublishmentSystemId, appointmentInfo.KeywordID, PageUtils.FilterXss(tbKeywords.Text), out conflictKeywords);
                        }
                        else
                        {
                            isConflict = KeywordManager.IsKeywordInsertConflict(PublishmentSystemId, PageUtils.FilterXss(tbKeywords.Text), out conflictKeywords);
                        }
                    }

                    if (isConflict)
                    {
                        FailMessage($"触发关键词“{conflictKeywords}”已存在,请设置其他关键词");
                    }
                    else
                    {
                        phStep2.Visible = true;
                    }
                }
                else if (selectedStep == 2)
                {
                    var isItemReady         = true;
                    var appointmentItemInfo = new AppointmentItemInfo();
                    appointmentItemInfo.PublishmentSystemID = PublishmentSystemId;
                    if (appointmentItemID > 0)
                    {
                        appointmentItemInfo = DataProviderWX.AppointmentItemDAO.GetItemInfo(appointmentItemID);
                    }

                    appointmentItemInfo.AppointmentID           = appointmentID;
                    appointmentItemInfo.Title                   = PageUtils.FilterXss(tbItemTitle.Text);
                    appointmentItemInfo.TopImageUrl             = topImageUrl.Value;
                    appointmentItemInfo.IsDescription           = cbIsDescription.Checked;
                    appointmentItemInfo.DescriptionTitle        = tbDescriptionTitle.Text;
                    appointmentItemInfo.Description             = tbDescription.Text;
                    appointmentItemInfo.IsImageUrl              = cbIsImageUrl.Checked;
                    appointmentItemInfo.ImageUrlTitle           = tbImageUrlTitle.Text;
                    appointmentItemInfo.ImageUrl                = tbContentImageUrl.Text;
                    appointmentItemInfo.IsVideoUrl              = cbIsVideoUrl.Checked;
                    appointmentItemInfo.VideoUrlTitle           = tbVideoUrlTitle.Text;
                    appointmentItemInfo.VideoUrl                = tbContentVideoUrl.Text;
                    appointmentItemInfo.IsImageUrlCollection    = cbIsImageUrlCollection.Checked;
                    appointmentItemInfo.ImageUrlCollectionTitle = tbImageUrlCollectionTitle.Text;
                    appointmentItemInfo.ImageUrlCollection      = imageUrlCollection.Value;
                    appointmentItemInfo.LargeImageUrlCollection = largeImageUrlCollection.Value;
                    appointmentItemInfo.IsMap                   = cbIsMap.Checked;
                    appointmentItemInfo.MapTitle                = tbMapTitle.Text;
                    appointmentItemInfo.MapAddress              = tbMapAddress.Text;
                    appointmentItemInfo.IsTel                   = cbIsTel.Checked;
                    appointmentItemInfo.TelTitle                = tbTelTitle.Text;
                    appointmentItemInfo.Tel = tbTel.Text;

                    try
                    {
                        if (appointmentItemID > 0)
                        {
                            DataProviderWX.AppointmentItemDAO.Update(appointmentItemInfo);
                            Body.AddLog(PublishmentSystemId, "修改预约项目", $"预约项目:{tbTitle.Text}");
                        }
                        else
                        {
                            appointmentItemID = DataProviderWX.AppointmentItemDAO.Insert(appointmentItemInfo);

                            Body.AddLog(PublishmentSystemId, "新增预约项目", $"预约项目:{tbTitle.Text}");
                        }
                    }
                    catch (Exception ex)
                    {
                        isItemReady = false;
                        FailMessage(ex, "微预约项目设置失败!");
                    }

                    if (isItemReady)
                    {
                        phStep3.Visible = true;
                    }
                    else
                    {
                        phStep2.Visible = true;
                    }
                }
                else if (selectedStep == 3)
                {
                    var isItemReady = true;
                    var itemCount   = TranslateUtils.ToInt(Request.Form["itemCount"]);

                    var itemIDList        = TranslateUtils.StringCollectionToIntList(Request.Form["itemID"]);
                    var attributeNameList = TranslateUtils.StringCollectionToStringList(Request.Form["itemAttributeName"]);

                    var itemIsVisible = "off";
                    if (!string.IsNullOrEmpty(Request.Form["itemIsVisible"]))
                    {
                        itemIsVisible = Request.Form["itemIsVisible"];
                    }

                    var isVisibleList = TranslateUtils.StringCollectionToStringList(itemIsVisible);

                    if (isVisibleList.Count < itemIDList.Count)
                    {
                        for (var i = isVisibleList.Count; i < itemIDList.Count; i++)
                        {
                            isVisibleList.Add("off");
                        }
                    }

                    var configExtendInfoList = new List <ConfigExtendInfo>();
                    for (var i = 0; i < itemCount; i++)
                    {
                        var configExtendInfo = new ConfigExtendInfo {
                            ID = itemIDList[i], PublishmentSystemID = PublishmentSystemId, KeywordType = EKeywordTypeUtils.GetValue(EKeywordType.Appointment), FunctionID = appointmentID, AttributeName = attributeNameList[i], IsVisible = isVisibleList[i]
                        };

                        if (string.IsNullOrEmpty(configExtendInfo.AttributeName))
                        {
                            FailMessage("保存失败,属性名称为必填项");
                            isItemReady = false;
                        }
                        if (string.IsNullOrEmpty(configExtendInfo.IsVisible))
                        {
                            FailMessage("保存失败,是否必填为显示项");
                            isItemReady = false;
                        }

                        if (configExtendInfo.IsVisible == "on")
                        {
                            configExtendInfo.IsVisible = "True";
                        }
                        else
                        {
                            configExtendInfo.IsVisible = "False";
                        }

                        configExtendInfoList.Add(configExtendInfo);
                    }

                    if (isItemReady)
                    {
                        DataProviderWX.ConfigExtendDAO.DeleteAllNotInIDList(PublishmentSystemId, appointmentID, itemIDList);

                        foreach (var configExtendInfo in configExtendInfoList)
                        {
                            if (configExtendInfo.ID > 0)
                            {
                                DataProviderWX.ConfigExtendDAO.Update(configExtendInfo);
                            }
                            else
                            {
                                DataProviderWX.ConfigExtendDAO.Insert(configExtendInfo);
                            }
                        }
                    }

                    if (isItemReady)
                    {
                        phStep4.Visible = true;
                        btnSubmit.Text  = "确 认";
                    }
                    else
                    {
                        phStep3.Visible = true;
                    }
                }
                else if (selectedStep == 4)
                {
                    var appointmentInfo = new AppointmentInfo();
                    appointmentInfo.PublishmentSystemID = PublishmentSystemId;

                    if (appointmentID > 0)
                    {
                        appointmentInfo = DataProviderWX.AppointmentDAO.GetAppointmentInfo(appointmentID);
                        DataProviderWX.KeywordDAO.Update(PublishmentSystemId, appointmentInfo.KeywordID, EKeywordType.Appointment, EMatchType.Exact, tbKeywords.Text, !cbIsEnabled.Checked);
                    }
                    else
                    {
                        var keywordInfo = new KeywordInfo();

                        keywordInfo.KeywordID           = 0;
                        keywordInfo.PublishmentSystemID = PublishmentSystemId;
                        keywordInfo.Keywords            = tbKeywords.Text;
                        keywordInfo.IsDisabled          = !cbIsEnabled.Checked;
                        keywordInfo.KeywordType         = EKeywordType.Appointment;
                        keywordInfo.MatchType           = EMatchType.Exact;
                        keywordInfo.Reply   = string.Empty;
                        keywordInfo.AddDate = DateTime.Now;
                        keywordInfo.Taxis   = 0;

                        appointmentInfo.KeywordID = DataProviderWX.KeywordDAO.Insert(keywordInfo);
                    }

                    appointmentInfo.StartDate = dtbStartDate.DateTime;
                    appointmentInfo.EndDate   = dtbEndDate.DateTime;
                    appointmentInfo.Title     = tbTitle.Text;
                    appointmentInfo.ImageUrl  = imageUrl.Value;
                    appointmentInfo.ContentResultTopImageUrl = resultTopImageUrl.Value;
                    appointmentInfo.Summary         = tbSummary.Text;
                    appointmentInfo.ContentIsSingle = true;
                    appointmentInfo.EndTitle        = tbEndTitle.Text;
                    appointmentInfo.EndImageUrl     = endImageUrl.Value;
                    appointmentInfo.EndSummary      = tbEndSummary.Text;

                    appointmentInfo.IsFormRealName    = cbIsFormRealName.Checked ? "True" : "False";
                    appointmentInfo.FormRealNameTitle = tbFormRealNameTitle.Text;
                    appointmentInfo.IsFormMobile      = cbIsFormMobile.Checked ? "True" : "False";
                    appointmentInfo.FormMobileTitle   = tbFormMobileTitle.Text;
                    appointmentInfo.IsFormEmail       = cbIsFormEmail.Checked ? "True" : "False";
                    appointmentInfo.FormEmailTitle    = tbFormEmailTitle.Text;

                    try
                    {
                        if (appointmentID > 0)
                        {
                            DataProviderWX.AppointmentDAO.Update(appointmentInfo);

                            Body.AddLog(PublishmentSystemId, "修改微预约", $"微预约:{tbTitle.Text}");
                            SuccessMessage("修改微预约成功!");
                        }
                        else
                        {
                            appointmentID = DataProviderWX.AppointmentDAO.Insert(appointmentInfo);
                            DataProviderWX.AppointmentItemDAO.UpdateAppointmentID(PublishmentSystemId, appointmentID);
                            DataProviderWX.ConfigExtendDAO.UpdateFuctionID(PublishmentSystemId, appointmentID);
                            Body.AddLog(PublishmentSystemId, "添加微预约", $"微预约:{tbTitle.Text}");
                            SuccessMessage("添加微预约成功!");
                        }

                        AddWaitAndRedirectScript(PageAppointment.GetRedirectUrl(PublishmentSystemId));
                    }
                    catch (Exception ex)
                    {
                        FailMessage(ex, "微预约设置失败!");
                    }

                    btnSubmit.Visible = false;
                    btnReturn.Visible = false;
                }
            }
        }