
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Com.FirmLib.Bll;
using FirmHttpDao;
using FWindSoft.DataFramework;
using FWindSoft.Wpf;
using Microsoft.Win32;

namespace Com.FirmLib.UI.Insuer.Model
{
    /// <summary>
    /// 保险上方法
    /// </summary>
    public class InsuerUtils
    {
        public static void LoadPolicyFile(string fileKey)
        {
            try
            {
                if (string.IsNullOrEmpty(fileKey))
                {
                    MessageTip.Show("没有关联保单文件");
                    return;
                }
                SaveFileDialog sflg = new SaveFileDialog();
                sflg.Title = "下载保单";
                //解析名字
                  string name = BllFactory<FileBll>.Instance.GetSuffix(fileKey);
                if (string.IsNullOrEmpty(name))
                {
                    name = fileKey;
                }
                sflg.FileName = name;
                if (sflg.ShowDialog() != true) return;
                string url =
                    BllFactory<FileBll>.Instance.CreateFileUrl(BllHttpSetting.Instance.Default, fileKey);
                var flag = BllFactory<FileBll>.Instance.DownLoadFile(url, sflg.FileName);

                if (flag)
                {
                    MessageTip.Show("下载保单成功");
                }
                else
                {
                    MessageTip.Show("下载保单失败");
                }

            }
            catch (Exception ex)
            {

                MessageTipEx.Show(ex);
            }

        }
    }

}
