黄学彪
2020-12-17 9f326f4000847e6167d8166fa2f6a66f53cb3734
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
using Shared.Phone.UserCenter;
using System;
using System.Collections.Generic;
using System.Text;
 
namespace Shared.Phone
{
    /// <summary>
    /// 模板数据的界面逻辑
    /// </summary>
    public class HdlTemplateDataFormLogic
    {
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// 模板数据的界面逻辑
        /// </summary>
        private static HdlTemplateDataFormLogic m_Current = null;
        /// <summary>
        /// 模板数据的界面逻辑
        /// </summary>
        public static HdlTemplateDataFormLogic Current
        {
            get
            {
                if (m_Current == null)
                {
                    m_Current = new HdlTemplateDataFormLogic();
                }
                return m_Current;
            }
        }
 
        #endregion
 
        #region ■ 显示模板选择菜单___________________
 
        /// <summary>
        /// 显示底部模板选择菜单
        /// </summary>
        /// <param name="nowSelectFile">当前选择的模板的文件名字</param>
        /// <param name="finishEvent">结束选择的事件,第一个参数是选择的模板的名字,第二个参数是选择的模板的文件名字</param>
        public void ShowBottomSelectTemplateForm(string nowSelectFile, Action<string, string> finishEvent)
        {
            //2020.09.15 不再获取云端模板
 
            //获取本地的模板
            var listLocal = HdlTemplateCommonLogic.Current.GetLocalAllModelList();
            //获取云端的模板
            //var listClound = TemplateCommonLogic.Current.GetCloundAllModelList();
            //if (listLocal.Count == 0 && listClound.Count == 0)
            if (listLocal.Count == 0)
            {
                //检测不到可供选择的模板数据
                HdlMessageLogic.Current.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.NotHadTemplateDataToSelect));
                return;
            }
            var listEsixtName = new HashSet<string>();
 
            var listText1 = new List<string>();
            var listText2 = new List<string>();
            int defultIndex = -1;
            for (int i = 0; i < listLocal.Count; i++)
            {
                //ModelData_Local_yyyyMMdd_HHmmss.bin
                string[] strArry = listLocal[i].FileName.Split(new string[] { "_" }, StringSplitOptions.RemoveEmptyEntries);
                if (strArry.Length != 4) { continue; }
 
                listText1.Add(listLocal[i].ModelName);
 
                string strTime = strArry[2].Substring(0, 4) + ".";
                strTime += strArry[2].Substring(4, 2) + ".";
                strTime += strArry[2].Substring(6, 2) + " ";
                strTime += strArry[3].Substring(0, 2) + ":";
                strTime += strArry[3].Substring(2, 2);
 
                listText2.Add(strTime);
                if (nowSelectFile == listLocal[i].FileName)
                {
                    defultIndex = i;
                }
                //已经存在了的模板名字
                listEsixtName.Add(listLocal[i].ModelName);
            }
            //for (int i = 0; i < listClound.Count; i++)
            //{
            //    //如果本地已经存在了这个模板,则已本地的为准
            //    if (listEsixtName.Contains(listClound[i].TemplateName) == true)
            //    {
            //        continue;
            //    }
            //    listText1.Add(listClound[i].TemplateName);
            //    listText2.Add(listClound[i].CreatedOnUtc);
            //}
 
            var selectForm = new BottomItemSelectForm();
            selectForm.SelectRowCanCancel = false;
            selectForm.AddForm(Language.StringByID(R.MyInternationalizationString.SelectTemplate), listText1, listText2, defultIndex);
            selectForm.FinishSelectEvent += (select) =>
            {
                //已选模版:南沙金茂府_户型A
                //if (select >= listLocal.Count)
                //{
                //    //如果选择的是云端模板的话
                //    int index = select - listLocal.Count;
                //    //需要去下载这个模板
                //    TemplateCommonLogic.Current.DownLoadTemplate(listClound[index].Id, (fullName) =>
                //    {
                //        if (fullName != null)
                //        {
                //            string fileName = fullName.Substring(HdlFileNameResourse.AllResidenceTemplateDirectory.Length + 1);
                //            //调用回调函数
                //            HdlThreadLogic.Current.RunMain(() =>
                //            {
                //                finishEvent?.Invoke(listText1[select], fileName);
                //            });
                //        }
                //    });
                //}
                //else
                {
                    //调用回调函数
                    finishEvent?.Invoke(listText1[select], listLocal[select].FileName);
                }
            };
        }
 
        #endregion
    }
}