コード例 #1
0
        public async Task <ActionResult> LoadPopup(int?id = 0)
        {
            PrintTemplateViewModel model = new PrintTemplateViewModel();

            try
            {
                if (id > 0)
                {
                    HttpResponseMessage response = await Get("PrintTemplate/GetById/" + id);

                    if (response.IsSuccessStatusCode && response.StatusCode == System.Net.HttpStatusCode.OK)
                    {
                        var responseContent = await response.Content.ReadAsAsync <SPPrintTemplateDto>();

                        model = this.templateMapper.ToObject(responseContent);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
            }

            return(PartialView("~/Views/PrintTemplate/_Add.cshtml", model));
        }
コード例 #2
0
        /// <summary>
        /// Action that deletes the print template
        /// </summary>
        /// <param name="printTemplatePostData">template id</param>
        /// <returns>status response and data for reloading grid</returns>
        public async Task <ActionResult> DeleteTemplate(PrintTemplateViewModel printTemplatePostData)
        {
            bool   status  = false;
            string message = string.Empty;
            HttpResponseMessage response = null;

            try
            {
                response = await Delete("PrintTemplate/Delete/" + printTemplatePostData.Id);

                if (response.IsSuccessStatusCode && response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    status = true;
                }

                message = response.ReasonPhrase;
            }
            catch (Exception ex)
            {
                message = response.ReasonPhrase;
                logger.Error(ex.Message);
            }

            return(Json(new { Status = status, Msg = message, Data = RenderRazorViewToString("_Grid", await GetData()) }));
        }
コード例 #3
0
        /// <summary>
        /// 下发播放列表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnRelease_Click(object sender, RoutedEventArgs e)
        {
            PrintTemplateViewModel Releasetemplate = TemplateGrid.Items[TemplateGrid.SelectedIndex] as PrintTemplateViewModel;
            IssueCommand           ic = new IssueCommand();

            ic.Command   = AdvertManage.Model.Enum.CommandType.PrintTemplate;
            ic.CommandId = Releasetemplate.Id;
            ic.ShowDialog();
        }
コード例 #4
0
        private void btnDownload_Click(object sender, RoutedEventArgs e)
        {
            PrintTemplateViewModel Releasetemplate = TemplateGrid.Items[TemplateGrid.SelectedIndex] as PrintTemplateViewModel;

            System.Windows.Forms.FolderBrowserDialog foldBrowerDialog = new System.Windows.Forms.FolderBrowserDialog();
            foldBrowerDialog.ShowDialog();
            if (!string.IsNullOrEmpty(foldBrowerDialog.SelectedPath))
            {
                if (Releasetemplate.DownLoad(foldBrowerDialog.SelectedPath))
                {
                    MessageBox.Show("发布离线版本成功!");
                }
                else
                {
                    MessageBox.Show("发布离线版本失败!");
                }
            }
        }
コード例 #5
0
        public async Task <ActionResult> Add(PrintTemplateViewModel model)
        {
            bool   status  = false;
            string message = string.Empty;
            HttpResponseMessage response = null;
            int id = 0;

            try
            {
                if (model.Id > 0)
                {
                    id       = model.Id;
                    response = await Put("PrintTemplate/Update", this.templateMapper.ToEntity(model));

                    message = response.ReasonPhrase;
                    if (response.IsSuccessStatusCode && response.StatusCode == System.Net.HttpStatusCode.OK)
                    {
                        status = true;
                    }
                }
                else
                {
                    response = await Post("PrintTemplate/Create", this.templateMapper.ToEntity(model));

                    message = response.ReasonPhrase;
                    if (response.IsSuccessStatusCode && response.StatusCode == System.Net.HttpStatusCode.Created)
                    {
                        status = true;
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
            }

            return(Json(new { status = status, msg = message, id = id }, JsonRequestBehavior.AllowGet));
        }
コード例 #6
0
        /// <summary>
        /// Action that performs activate or deactivate operation
        /// </summary>
        /// <param name="printTemplatePostData">template id and status to be changed</param>
        /// <returns>status response and data for reloading grid</returns>
        public async Task <ActionResult> ActiveDeactivateTemplate(PrintTemplateViewModel printTemplatePostData)
        {
            string message = string.Empty;
            bool   status  = false;

            try
            {
                printTemplatePostData.IsActive = printTemplatePostData.Activate == 1 ? true : false;
                HttpResponseMessage response = await Put("PrintTemplate/Update", printTemplatePostData);

                if (response.IsSuccessStatusCode && response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    status = true;
                }

                message = response.ReasonPhrase;
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
            }

            return(Json(new { Status = status, Msg = message, Data = RenderRazorViewToString("_Grid", await GetData()) }));
        }