old mode 100755
new mode 100644
File was renamed from ZigbeeApp/Shared/Phone/TemplateData/TemplateDataFormLogic.cs |
| | |
| | | using Shared.Phone.UserCenter;
|
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.Text;
|
| | |
|
| | | namespace Shared.Phone.TemplateData
|
| | | {
|
| | | /// <summary>
|
| | | /// 模板数据的界面逻辑
|
| | | /// </summary>
|
| | | public class TemplateDataFormLogic
|
| | | {
|
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 模板数据的界面逻辑
|
| | | /// </summary>
|
| | | private static TemplateDataFormLogic m_Current = null;
|
| | | /// <summary>
|
| | | /// 模板数据的界面逻辑
|
| | | /// </summary>
|
| | | public static TemplateDataFormLogic Current
|
| | | {
|
| | | get
|
| | | {
|
| | | if (m_Current == null)
|
| | | {
|
| | | m_Current = new TemplateDataFormLogic();
|
| | | }
|
| | | 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 = TemplateCommonLogic.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(DirNameResourse.AllResidenceTemplateDirectory.Length + 1);
|
| | | // //调用回调函数
|
| | | // HdlThreadLogic.Current.RunMain(() =>
|
| | | // {
|
| | | // finishEvent?.Invoke(listText1[select], fileName);
|
| | | // });
|
| | | // }
|
| | | // });
|
| | | //}
|
| | | //else
|
| | | {
|
| | | //调用回调函数
|
| | | finishEvent?.Invoke(listText1[select], listLocal[select].FileName);
|
| | | }
|
| | | };
|
| | | }
|
| | |
|
| | | #endregion
|
| | | }
|
| | | }
|
| | | 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 |
| | | } |
| | | } |