old mode 100755
new mode 100644
File was renamed from ZigbeeApp/Shared/Phone/TemplateData/TemplateCommonLogic.cs |
| | |
| | | using System.Text;
|
| | | using ZigBee.Device;
|
| | |
|
| | | namespace Shared.Phone.TemplateData
|
| | | namespace Shared.Phone |
| | | {
|
| | | /// <summary>
|
| | | /// 模板的共通逻辑类
|
| | | /// </summary>
|
| | | public class TemplateCommonLogic
|
| | | public class HdlTemplateCommonLogic |
| | | {
|
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 模板的共通逻辑类
|
| | | /// </summary>
|
| | | private static TemplateCommonLogic m_Current = null;
|
| | | private static HdlTemplateCommonLogic m_Current = null; |
| | | /// <summary>
|
| | | /// 模板的共通逻辑类
|
| | | /// </summary>
|
| | | public static TemplateCommonLogic Current
|
| | | public static HdlTemplateCommonLogic Current |
| | | {
|
| | | get
|
| | | {
|
| | | if (m_Current == null)
|
| | | {
|
| | | m_Current = new TemplateCommonLogic();
|
| | | m_Current = new HdlTemplateCommonLogic(); |
| | | }
|
| | | return m_Current;
|
| | | }
|
| | |
| | | {
|
| | | this.modelData = new TemplateMemoryData();
|
| | | //保存的路径
|
| | | string saveFile = DirNameResourse.LocalTemplateDirectory;
|
| | | string saveFile = HdlFileNameResourse.LocalTemplateDirectory; |
| | |
|
| | | //如果当前住宅拥有选择的模板
|
| | | if (Common.Config.Instance.Home.SelectTemplate != string.Empty)
|
| | |
| | | //反序列化设备的保存文件内容
|
| | | var tempData = this.DeserializeDeviceDataByDiv(saveDiv, deviceData);
|
| | | //将设备模板数据添加入缓存
|
| | | string mainKey = Common.LocalDevice.Current.GetDeviceMainKeys(tempData.DeviceMac, tempData.DeviceEpoint);
|
| | | string mainKey = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(tempData.DeviceMac, tempData.DeviceEpoint); |
| | | this.SetTemplateDeviceDataToMemmory(tempData, deviceData, mainKey, true);
|
| | | }
|
| | | //清空
|
| | |
| | | //反序列化设备的保存文件内容
|
| | | var tempData = this.DeserializeDeviceDataByDiv(saveDiv, deviceData);
|
| | | //将设备模板数据添加入缓存
|
| | | string mainKey = Common.LocalDevice.Current.GetDeviceMainKeys(tempData.DeviceMac, tempData.DeviceEpoint);
|
| | | string mainKey = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(tempData.DeviceMac, tempData.DeviceEpoint); |
| | | this.SetTemplateDeviceDataToMemmory(tempData, deviceData, mainKey, true);
|
| | | }
|
| | | }
|
| | |
| | | this.modelData.dicDeviceTemplateSelect = new Dictionary<string, string>();
|
| | | this.modelData.dicGatewayTemplateSelect = new Dictionary<string, string>();
|
| | |
|
| | | string fileData2 = HdlFileLogic.Current.ReadFileTextContent(DirNameResourse.DeviceTemplateSelectFile);
|
| | | string fileData2 = HdlFileLogic.Current.ReadFileTextContent(HdlFileNameResourse.DeviceTemplateSelectFile); |
| | | if (fileData2 != null)
|
| | | {
|
| | | //设备选择的模板对象(keys:本地设备的Mac value:模板中的Mac)
|
| | | this.modelData.dicDeviceTemplateSelect = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(fileData2);
|
| | | }
|
| | | fileData2 = HdlFileLogic.Current.ReadFileTextContent(DirNameResourse.GatewayTemplateSelectFile);
|
| | | fileData2 = HdlFileLogic.Current.ReadFileTextContent(HdlFileNameResourse.GatewayTemplateSelectFile); |
| | | if (fileData2 != null)
|
| | | {
|
| | | //网关对象选择的模板对象(keys:本地网关ID, value:模板中的网关ID)
|
| | |
| | | foreach (var deviceKey in room.ListDevice)
|
| | | {
|
| | | this.modelData.dicDeviceTemplateRoom[deviceKey] = room.Id;
|
| | | } |
| | | foreach (var strMac in room.ListDeviceMac) |
| | | { |
| | | //物理设备所在的区域,在这个函数外面已经初始化了这个变量 |
| | | this.modelData.dicDeviceTemplateRealRoom[strMac] = room.Id; |
| | | }
|
| | | if (hadRoom == false)
|
| | | {
|
| | |
| | | this.strTempContentData = string.Empty;
|
| | |
|
| | | //删掉这两个保存选择模板的文件(这两个东西可能还存在)
|
| | | HdlFileLogic.Current.DeleteFile(DirNameResourse.DeviceTemplateSelectFile);
|
| | | HdlFileLogic.Current.DeleteFile(DirNameResourse.GatewayTemplateSelectFile);
|
| | | HdlFileLogic.Current.DeleteFile(HdlFileNameResourse.DeviceTemplateSelectFile); |
| | | HdlFileLogic.Current.DeleteFile(HdlFileNameResourse.GatewayTemplateSelectFile); |
| | |
|
| | | //再次初始化房间
|
| | | HdlRoomLogic.Current.InitAllRoom();
|
| | |
| | | if (Common.Config.Instance.Home.TemplateMode != 2)
|
| | | {
|
| | | //存放的路径
|
| | | string fullFile = System.IO.Path.Combine(DirNameResourse.LocalTemplateDirectory, TemplateFileName);
|
| | | string fullFile = System.IO.Path.Combine(HdlFileNameResourse.LocalTemplateDirectory, TemplateFileName); |
| | | HdlFileLogic.Current.DeleteFile(fullFile);
|
| | | }
|
| | | //覆盖物理设备所在的房间数据
|
| | | HdlFileLogic.Current.SaveFileContent(DirNameResourse.DeviceRoomIdFile, this.modelData.dicDeviceTemplateRealRoom);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | foreach (var deviceKey in room.ListDevice)
|
| | | {
|
| | | this.modelData.dicDeviceTemplateRoom[deviceKey] = room.Id;
|
| | | } |
| | | foreach (var strMac in room.ListDeviceMac) |
| | | { |
| | | //物理设备所在的区域,在这个函数外面已经初始化了这个变量 |
| | | this.modelData.dicDeviceTemplateRealRoom[strMac] = room.Id; |
| | | }
|
| | | this.strTempContentData = string.Empty;
|
| | | return true;
|
| | |
| | | //反序列化设备的保存文件内容
|
| | | var tempData = this.DeserializeDeviceDataByDiv(saveDiv, this.strTempContentData);
|
| | | //将设备模板数据添加入缓存(此处特殊,不需要加入设备模板缓存中)
|
| | | string mainKey = Common.LocalDevice.Current.GetDeviceMainKeys(tempData.DeviceMac, tempData.DeviceEpoint);
|
| | | string mainKey = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(tempData.DeviceMac, tempData.DeviceEpoint); |
| | | this.SetTemplateDeviceDataToMemmory(tempData, this.strTempContentData, mainKey, addToTemplate);
|
| | | this.strTempContentData = string.Empty;
|
| | | return;
|
| | |
| | | this.strTempContentData = string.Empty;
|
| | | return;
|
| | | }
|
| | | //物理设备的房间
|
| | | else if (strData == "#DeviceTemplateRealRoom END#")
|
| | | {
|
| | | this.modelData.dicDeviceTemplateRealRoom = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(this.strTempContentData);
|
| | | this.strTempContentData = string.Empty;
|
| | | return;
|
| | | }
|
| | | //模板住宅的信息(目前在这里基本没用)
|
| | | else if (strData == "#TemplateHomeInfo END#")
|
| | | {
|
| | |
| | | private void ReadTemplateFileMethord(Action<string, ModelDeviceSaveEnum, string> AdjustAction)
|
| | | {
|
| | | //保存的路径
|
| | | string saveFile = DirNameResourse.LocalTemplateDirectory;
|
| | | string saveFile = HdlFileNameResourse.LocalTemplateDirectory; |
| | | saveFile = System.IO.Path.Combine(saveFile, TemplateFileName);
|
| | |
|
| | | string fileData = HdlFileLogic.Current.ReadFileTextContent(saveFile);
|
| | |
| | | /// 保存模板数据到本地
|
| | | /// </summary>
|
| | | /// <param name="backupName">备份名称</param>
|
| | | public void SaveTemplateDataToLocation(string backupName)
|
| | | /// <param name="saveFirmware">是否下载固件</param> |
| | | public void SaveTemplateDataToLocation(string backupName, bool downloadFirmware = true) |
| | | {
|
| | | //获取本地全部的模板列表的基本信息
|
| | | var localModel = this.GetLocalAllModelList();
|
| | |
| | | this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.BackUpDataIsEsixtAndPickUp), () =>
|
| | | {
|
| | | //将模板数据保存到到指定的文件夹中
|
| | | this.SaveTemplateDataToLocation2(fileName, backupName);
|
| | | this.SaveTemplateDataToLocation2(fileName, backupName, downloadFirmware); |
| | | });
|
| | | return;
|
| | | }
|
| | | }
|
| | | //将模板数据保存到到指定的文件夹中
|
| | | this.SaveTemplateDataToLocation2(fileName, backupName);
|
| | | this.SaveTemplateDataToLocation2(fileName, backupName, downloadFirmware); |
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// </summary>
|
| | | /// <param name="fileName">保存文件的名字</param>
|
| | | /// <param name="backName">模板备份的名字</param>
|
| | | private void SaveTemplateDataToLocation2(string fileName, string backupName)
|
| | | /// <param name="saveFirmware">是否下载固件</param> |
| | | private void SaveTemplateDataToLocation2(string fileName, string backupName, bool downloadFirmware = true) |
| | | {
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | |
| | |
|
| | | //将模板数据保存到到指定的文件夹中
|
| | | var fileFullName = this.SaveTemplateDataToFile(fileName, backupName);
|
| | | if (downloadFirmware == false) |
| | | { |
| | | //本地备份保存成功 |
| | | this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.SaveLocalBackDataSuccess)); |
| | | ProgressFormBar.Current.Close(); |
| | | return; |
| | | } |
| | | //获取升级固件文件
|
| | | var result = HdlFirmwareUpdateLogic.DownLoadTemplateDeviceFirmware(fileFullName, "正在保存升级固件数据");
|
| | | var result = HdlFirmwareUpdateLogic.Current.DownLoadTemplateDeviceFirmware(fileFullName, "正在保存升级固件数据"); |
| | | if (result == -1)
|
| | | {
|
| | | this.ShowMassage(ShowMsgType.Tip, "保存升级固件数据失败");
|
| | | //删掉这个模板 |
| | | HdlFileLogic.Current.DeleteFile(fileFullName); |
| | | }
|
| | | else
|
| | | {
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | var listDevice = Common.LocalDevice.Current.listAllDevice;
|
| | | var listDevice = HdlDeviceCommonLogic.Current.listAllDevice; |
| | | foreach (var device in listDevice)
|
| | | {
|
| | | if (listMac.Contains(device.DeviceAddr) == false)
|
| | | {
|
| | | listMac.Add(device.DeviceAddr);
|
| | | //重新添加Mac名字缓存
|
| | | TemplateDeviceDataLogic.Current.ReDeviceMacName(device, Common.LocalDevice.Current.GetDeviceMacName(device));
|
| | | HdlTemplateDeviceDataLogic.Current.ReDeviceMacName(device, HdlDeviceCommonLogic.Current.GetDeviceMacName(device)); |
| | | }
|
| | | //重新添加端点名字缓存
|
| | | TemplateDeviceDataLogic.Current.ReDeviceEpointName(device, Common.LocalDevice.Current.GetDeviceEpointName(device));
|
| | | HdlTemplateDeviceDataLogic.Current.ReDeviceEpointName(device, HdlDeviceCommonLogic.Current.GetDeviceEpointName(device)); |
| | | }
|
| | | }
|
| | | #endregion
|
| | |
| | | var dicData = new Dictionary<string, List<LocalModelBaseInfo>>();
|
| | | var listTime = new List<string>();
|
| | |
|
| | | var strPath = DirNameResourse.AllResidenceTemplateDirectory;
|
| | | var strPath = HdlFileNameResourse.AllResidenceTemplateDirectory; |
| | | //获取全部文件
|
| | | var arryFile = System.IO.Directory.GetFiles(strPath, "ModelData_*");
|
| | | foreach (string modelFile in arryFile)
|
| | |
| | | /// <summary>
|
| | | /// 获取云端全部的模板列表的基本信息
|
| | | /// </summary>
|
| | | /// <param name="mode">失败时是否显示tip消息</param> |
| | | /// <returns></returns>
|
| | | public List<CloundModelBaseInfo> GetCloundAllModelList()
|
| | | public List<CloundModelBaseInfo> GetCloundAllModelList(ShowNetCodeMode mode= ShowNetCodeMode.YES) |
| | | {
|
| | | var pra = new
|
| | | var result = HdlHttpLogic.Current.RequestResponseFromZigbeeHttps("home-wisdom/template/metaInfo/findAll", RestSharp.Method.POST, null); |
| | | //检测状态码 |
| | | if (HdlCheckLogic.Current.CheckNetCode(result, mode) == false) |
| | | {
|
| | | RequestVersion = Common.CommonPage.RequestVersion,
|
| | | RequestSource = 5,
|
| | | LoginAccessToken = Common.Config.Instance.Token
|
| | | };
|
| | | var result = UserCenterLogic.GetResponseDataByRequestHttps("ProjectTemplate/GetProTemplateList", false, pra);
|
| | | if (result == null) { return new List<CloundModelBaseInfo>(); }
|
| | | return new List<CloundModelBaseInfo>(); |
| | | } |
| | |
|
| | | var dicData = new Dictionary<string, List<CloundModelBaseInfo>>();
|
| | | var listTime = new List<string>();
|
| | |
|
| | | var listCloundData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<CloundModelBaseInfo>>(result);
|
| | | var listCloundData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<CloundModelBaseInfo>>(result.Data.ToString()); |
| | | foreach (var data in listCloundData)
|
| | | {
|
| | | //变更时间格式
|
| | | data.CreatedOnUtc = UserCenterLogic.ConvertUtcTimeToLocalTime(data.CreatedOnUtc).ToString("yyyy.MM.dd HH:mm");
|
| | | if (dicData.ContainsKey(data.CreatedOnUtc) == false)
|
| | | data.CreateTime = HdlCommonLogic.Current.ConvertUtcTimeToLocalTime2(data.CreateTime).ToString("yyyy.MM.dd HH:mm"); |
| | | if (dicData.ContainsKey(data.CreateTime) == false) |
| | | {
|
| | | dicData[data.CreatedOnUtc] = new List<CloundModelBaseInfo>();
|
| | | listTime.Add(data.CreatedOnUtc);
|
| | | dicData[data.CreateTime] = new List<CloundModelBaseInfo>(); |
| | | listTime.Add(data.CreateTime); |
| | | }
|
| | | dicData[data.CreatedOnUtc].Add(data);
|
| | | dicData[data.CreateTime].Add(data); |
| | | }
|
| | |
|
| | | //按时间排序
|
| | |
| | | /// </summary>
|
| | | /// <param name="i_localTemplate">本地模板信息</param>
|
| | | /// <param name="i_saveName">备份名字</param>
|
| | | public void UpLoadTemplateData(LocalModelBaseInfo i_localTemplate, string i_saveName)
|
| | | /// <param name="mode">失败时是否显示tip消息</param> |
| | | public void UpLoadTemplateData(LocalModelBaseInfo i_localTemplate, string i_saveName, ShowNetCodeMode mode = ShowNetCodeMode.YES) |
| | | {
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | |
| | | return;
|
| | | }
|
| | | }
|
| | | //创建新的模板备份 |
| | | var templateId = this.CreatNewTemplateNameToDB(i_saveName, mode); |
| | | if (templateId == null) |
| | | { |
| | | ProgressBar.Close(); |
| | | return; |
| | | } |
| | | |
| | | //这里修改掉模板文件里面记载的模板名称
|
| | | string templateFile = System.IO.Path.Combine(DirNameResourse.AllResidenceTemplateDirectory, i_localTemplate.FileName);
|
| | | string templateFile = System.IO.Path.Combine(HdlFileNameResourse.AllResidenceTemplateDirectory, i_localTemplate.FileName); |
| | | string binFileData = HdlFileLogic.Current.ReadFileTextContent(templateFile);
|
| | | var arryBinFile = binFileData.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
|
| | | //替换目标 这里是模板基本信息的json数据
|
| | |
| | | string replaceDta = Newtonsoft.Json.JsonConvert.SerializeObject(templateBaseInfo);
|
| | | binFileData = binFileData.Replace(strFileData, replaceDta);
|
| | |
|
| | | var pra = new
|
| | | {
|
| | | RequestVersion = Common.CommonPage.RequestVersion,
|
| | | RequestSource = 5,
|
| | | LoginAccessToken = Common.Config.Instance.Token,
|
| | | ProTemplateName = i_saveName,
|
| | | ProTemplateDetails = new List<TemplateDetailsInfo>()
|
| | | };
|
| | | var detailsInfo = new TemplateDetailsInfo();
|
| | | detailsInfo.DetailName = "ModelData_Cloud_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".bin";
|
| | | detailsInfo.DetailContent = Encoding.UTF8.GetBytes(binFileData);
|
| | | pra.ProTemplateDetails.Add(detailsInfo);
|
| | |
|
| | | //清掉这个字符串缓存
|
| | | binFileData = null;
|
| | |
|
| | | var result = UserCenterLogic.GetResultStatuByRequestHttps("ProjectTemplate/AddProTemplate", false, pra);
|
| | | if (result == true)
|
| | | var dicQuery = new Dictionary<string, object>(); |
| | | dicQuery["fileName"] = "ModelData_Cloud_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".bin"; |
| | | dicQuery["templateId"] = templateId; |
| | | var result = HdlHttpLogic.Current.RequestResponseFromZigbeeHttps("home-wisdom/template/file/add", RestSharp.Method.POST, Encoding.UTF8.GetBytes(binFileData), dicQuery, null, CheckMode.A不检测, true, 10); |
| | | //检测状态码 |
| | | if (HdlCheckLogic.Current.CheckNetCode(result, mode) == true) |
| | | {
|
| | | //上传模板成功
|
| | | this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.UploadTemplateSuccess));
|
| | |
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 上传模板文件的信息
|
| | | /// 在云端创建新的模板名称 |
| | | /// </summary>
|
| | | private class TemplateDetailsInfo
|
| | | /// <param name="i_saveName">新名字</param> |
| | | /// <param name="mode">失败时是否显示tip消息</param> |
| | | /// <returns></returns> |
| | | private string CreatNewTemplateNameToDB(string i_saveName, ShowNetCodeMode mode = ShowNetCodeMode.YES) |
| | | {
|
| | | /// <summary>
|
| | | /// 文件名字
|
| | | /// </summary>
|
| | | public string DetailName = string.Empty;
|
| | | /// <summary>
|
| | | /// 模板内容
|
| | | /// </summary>
|
| | | public byte[] DetailContent = null;
|
| | | var pra = new { templateName = i_saveName }; |
| | | |
| | | var result = HdlHttpLogic.Current.RequestResponseFromZigbeeHttps("home-wisdom/template/metaInfo/add", RestSharp.Method.POST, pra); |
| | | //检测状态码 |
| | | if (HdlCheckLogic.Current.CheckNetCode(result, mode) == false) |
| | | { |
| | | return null; |
| | | } |
| | | var idData = Newtonsoft.Json.JsonConvert.DeserializeObject<IdInfoClass>(result.Data.ToString()); |
| | | return idData.Id; |
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | /// </summary>
|
| | | /// <param name="i_templateId">数据库主键</param>
|
| | | /// <param name="i_SuccessAction">下载完全成功之后的回调事件,参数为保存模板的全路径(参数null代表失败)</param>
|
| | | public void DownLoadTemplate(string i_templateId, Action<string> i_SuccessAction = null)
|
| | | /// <param name="mode">失败时是否显示tip消息</param> |
| | | public void DownLoadTemplate(string i_templateId, Action<string> i_SuccessAction = null,ShowNetCodeMode mode= ShowNetCodeMode.YES) |
| | | {
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | |
| | | ProgressFormBar.Current.SetMsg("正在下载模板数据");
|
| | | System.Threading.Thread.Sleep(1500);
|
| | |
|
| | | var pra = new
|
| | | {
|
| | | RequestVersion = Common.CommonPage.RequestVersion,
|
| | | RequestSource = 5,
|
| | | LoginAccessToken = Common.Config.Instance.Token,
|
| | | ProTemplateId = i_templateId
|
| | | };
|
| | | var result = UserCenterLogic.GetResponseDataByRequestHttps("ProjectTemplate/GetProTemplateDetailList", false, pra);
|
| | | if (result == null)
|
| | | var pra = new { templateId = i_templateId }; |
| | | |
| | | //获取指定模板的列表文件 |
| | | var result = HdlHttpLogic.Current.RequestResponseFromZigbeeHttps("home-wisdom/template/file/findAll", RestSharp.Method.POST, pra); |
| | | //检测状态码 |
| | | if (HdlCheckLogic.Current.CheckNetCode(result, mode) == false) |
| | | {
|
| | | //下载模板失败
|
| | | this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.DownloadTemplateFail));
|
| | |
| | | i_SuccessAction?.Invoke(null);
|
| | | return;
|
| | | }
|
| | | var fileListData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<DownloadTemplateData>>(result);
|
| | | if (fileListData.Count == 0)
|
| | | var listFileData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<DownloadTemplateData>>(result.Data.ToString()); |
| | | if (listFileData.Count == 0) |
| | | {
|
| | | //下载模板失败
|
| | | this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.DownloadTemplateFail));
|
| | |
| | | i_SuccessAction?.Invoke(null);
|
| | | return;
|
| | | }
|
| | | |
| | | //下载模板的内容 |
| | | var pra2 = new { templateFileId = listFileData[0].Id, templateMetaInfoId = i_templateId }; |
| | | var byteContent = HdlHttpLogic.Current.RequestByteFromZigbeeHttps("home-wisdom/template/file/downOne", RestSharp.Method.POST, pra2, null, null, CheckMode.A不检测, true, 10); |
| | | if (byteContent == null || byteContent.Length == 0) |
| | | { |
| | | //下载模板失败 |
| | | this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.DownloadTemplateFail)); |
| | | ProgressFormBar.Current.Close(); |
| | | i_SuccessAction?.Invoke(null); |
| | | return; |
| | | } |
| | | |
| | | //解析这个模板的名字
|
| | | var strFileData = this.GetDataFromFileContent(Encoding.UTF8.GetString(fileListData[0].DetailContent), "#START#", "#TemplateData END#");
|
| | | var strFileData = this.GetDataFromFileContent(Encoding.UTF8.GetString(byteContent), "#START#", "#TemplateData END#"); |
| | | var templateBaseInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<LocalModelBaseInfo>(strFileData);
|
| | |
|
| | | //检测本地的模板是否有同名的
|
| | | var listLocal = this.GetLocalAllModelList();
|
| | | string fileName = fileListData[0].DetailName;
|
| | | string fileName = listFileData[0].FileName; |
| | | foreach (var localData in listLocal)
|
| | | {
|
| | | if (localData.ModelName == templateBaseInfo.ModelName)
|
| | |
| | | }
|
| | |
|
| | | //存成文件
|
| | | string fileFullName = System.IO.Path.Combine(DirNameResourse.AllResidenceTemplateDirectory, fileName);
|
| | | HdlFileLogic.Current.SaveByteToFile(fileFullName, fileListData[0].DetailContent);
|
| | | string fileFullName = System.IO.Path.Combine(HdlFileNameResourse.AllResidenceTemplateDirectory, fileName); |
| | | HdlFileLogic.Current.SaveByteToFile(fileFullName, byteContent); |
| | | byteContent = null; |
| | |
|
| | | //获取升级固件文件
|
| | | var result2 = HdlFirmwareUpdateLogic.DownLoadTemplateDeviceFirmware(fileFullName, "正在获取升级固件数据");
|
| | | var result2 = HdlFirmwareUpdateLogic.Current.DownLoadTemplateDeviceFirmware(fileFullName, "正在获取升级固件数据"); |
| | | if (result2 == -1)
|
| | | {
|
| | | this.ShowMassage(ShowMsgType.Tip, "获取升级固件数据失败");
|
| | |
| | | /// <summary>
|
| | | /// 模板文件名字
|
| | | /// </summary>
|
| | | public string DetailName = string.Empty;
|
| | | public string FileName = string.Empty; |
| | | /// <summary>
|
| | | /// 模板数据
|
| | | /// 主键 |
| | | /// </summary>
|
| | | public byte[] DetailContent = null;
|
| | | public string Id = string.Empty; |
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | /// 删除云端模板备份
|
| | | /// </summary>
|
| | | /// <param name="i_templateId">模板主键</param>
|
| | | /// <param name="mode">失败时是否显示tip消息</param> |
| | | /// <returns></returns>
|
| | | public bool DeleteTemplateFromDb(string i_templateId)
|
| | | public bool DeleteTemplateFromDb(string i_templateId, ShowNetCodeMode mode = ShowNetCodeMode.YES) |
| | | {
|
| | | var pra = new
|
| | | var pra = new { templateId = i_templateId }; |
| | | |
| | | var result = HdlHttpLogic.Current.RequestResponseFromZigbeeHttps("home-wisdom/template/metaInfo/delete", RestSharp.Method.POST, pra); |
| | | if (result != null && result.Code == HttpMessageEnum.A10605) |
| | | {
|
| | | RequestVersion = Common.CommonPage.RequestVersion,
|
| | | RequestSource = 5,
|
| | | LoginAccessToken = Common.Config.Instance.Token,
|
| | | ProTemplateId = i_templateId
|
| | | };
|
| | | var result = UserCenterLogic.GetResultStatuByRequestHttps("ProjectTemplate/DeleteProTemplate", false, pra);
|
| | | return result;
|
| | | //模板对象不存在,当做成功 |
| | | return true; |
| | | } |
| | | //检测状态码 |
| | | if (HdlCheckLogic.Current.CheckNetCode(result, mode) == false) |
| | | { |
| | | return false; |
| | | } |
| | | return true; |
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// <returns></returns>
|
| | | public void DeleteLocalTemplate(LocalModelBaseInfo i_baseInfo)
|
| | | {
|
| | | var fullFile = System.IO.Path.Combine(DirNameResourse.AllResidenceTemplateDirectory, i_baseInfo.FileName);
|
| | | var fullFile = System.IO.Path.Combine(HdlFileNameResourse.AllResidenceTemplateDirectory, i_baseInfo.FileName); |
| | | HdlFileLogic.Current.DeleteFile(fullFile);
|
| | | }
|
| | |
|
| | |
| | | this.CrearWriteDeviceSelectTemplateData(ref writeText);
|
| | |
|
| | | //写入内容
|
| | | string saveFile = DirNameResourse.AllResidenceTemplateDirectory;
|
| | | string saveFile = HdlFileNameResourse.AllResidenceTemplateDirectory; |
| | | saveFile = System.IO.Path.Combine(saveFile, fileName);
|
| | |
|
| | | HdlFileLogic.Current.SaveTextToFile(saveFile, writeText);
|
| | |
| | | /// 生成写入文件的【模板基本数据】
|
| | | /// </summary>
|
| | | /// <param name="writeText"></param>
|
| | | private void CreatWriteTemplateBaseData(ref string writeText, string backUpName)
|
| | | public void CreatWriteTemplateBaseData(ref string writeText, string backUpName) |
| | | {
|
| | | var modelData = new LocalModelBaseInfo();
|
| | | modelData.EditorTime = DateTime.Now.ToString("yyyy.MM.dd HH:mm");
|
| | |
| | | {
|
| | | if (listData.Count > 0)
|
| | | {
|
| | | var listDevice = Common.LocalDevice.Current.GetDevicesByMac(listData[0].DeviceMac, false);
|
| | | var listDevice = HdlDeviceCommonLogic.Current.GetDevicesByMac(listData[0].DeviceMac, false); |
| | | funcCount += listDevice.Count;
|
| | | }
|
| | | }
|
| | |
| | | /// 生成写入文件的【模板住宅信息数据】
|
| | | /// </summary>
|
| | | /// <param name="writeText"></param>
|
| | | private void CreatWriteTemplateHomeData(ref string writeText)
|
| | | public void CreatWriteTemplateHomeData(ref string writeText) |
| | | {
|
| | | var homeData = new TemplateHomeInfo();
|
| | | homeData.ResidenceAddressName = Common.Config.Instance.Home.ResidenceAddressName;
|
| | |
| | | /// 生成写入文件的【设备模板数据】
|
| | | /// </summary>
|
| | | /// <param name="writeText"></param>
|
| | | private void CreatWriteDeviceTemplateData(ref string writeText)
|
| | | public void CreatWriteDeviceTemplateData(ref string writeText) |
| | | {
|
| | | foreach (var list in this.modelData.dicDeviceTemplateData.Values)
|
| | | {
|
| | |
| | | /// 生成写入文件的【设备对象数据】
|
| | | /// </summary>
|
| | | /// <param name="writeText"></param>
|
| | | private void CreatWriteCommonDeviceData(ref string writeText)
|
| | | public void CreatWriteCommonDeviceData(ref string writeText) |
| | | {
|
| | | var listDevice = Common.LocalDevice.Current.listAllDevice;
|
| | | var listDevice = HdlDeviceCommonLogic.Current.listAllDevice; |
| | | var listCheck = new HashSet<string>();
|
| | | foreach (var device in listDevice)
|
| | | {
|
| | |
| | | if (listCheck.Contains(device.DeviceAddr) == false)
|
| | | {
|
| | | listCheck.Add(device.DeviceAddr);
|
| | | var otaDevice = Common.LocalDevice.Current.GetOTADevice(device.DeviceAddr);
|
| | | var otaDevice = HdlDeviceCommonLogic.Current.GetOTADevice(device.DeviceAddr); |
| | | if (otaDevice != null)
|
| | | {
|
| | | writeText += "#DeviceInfo START#" + (int)otaDevice.Type + "\r\n";
|
| | |
| | | /// 生成写入文件的【网关对象数据】
|
| | | /// </summary>
|
| | | /// <param name="writeText"></param>
|
| | | private void CreatWriteGatewayData(ref string writeText)
|
| | | public void CreatWriteGatewayData(ref string writeText) |
| | | {
|
| | | var listGateway = HdlGatewayLogic.Current.GetAllLocalGateway();
|
| | | foreach (var gateway in listGateway)
|
| | |
| | | /// 生成写入文件的【场景数据】
|
| | | /// </summary>
|
| | | /// <param name="writeText"></param>
|
| | | private void CreatWriteSceneData(ref string writeText)
|
| | | public void CreatWriteSceneData(ref string writeText) |
| | | {
|
| | | //全部的场景
|
| | | var listScene = HdlSceneLogic.Current.GetAllLocalScene();
|
| | |
| | | /// 生成写入文件的【房间模板数据】
|
| | | /// </summary>
|
| | | /// <param name="writeText"></param>
|
| | | private void CrearWriteRoomTemplateData(ref string writeText)
|
| | | public void CrearWriteRoomTemplateData(ref string writeText) |
| | | {
|
| | | //楼层数据
|
| | | writeText += "#START#\r\n";
|
| | |
| | | writeText += dataInfo2 + "\r\n";
|
| | | writeText += "#RoomInfo END#\r\n\r\n";
|
| | | }
|
| | | //物理网关所在的房间
|
| | | var dicRealRoom = new Dictionary<string, string>();
|
| | | var listGateway = HdlGatewayLogic.Current.GetAllLocalGateway();
|
| | | foreach (var gateway in listGateway)
|
| | | {
|
| | | dicRealRoom[gateway.GwId] = gateway.RoomId;
|
| | | }
|
| | | //获取全部物理设备所属房间的记录
|
| | | var dicDeviceRoom = HdlRoomLogic.Current.GetAllRealDeviceRoomData();
|
| | | foreach (var strMac in dicDeviceRoom.Keys)
|
| | | {
|
| | | dicRealRoom[strMac] = dicDeviceRoom[strMac];
|
| | | }
|
| | |
|
| | | writeText += "#START#\r\n";
|
| | | string dataInfo = Newtonsoft.Json.JsonConvert.SerializeObject(dicRealRoom);
|
| | | writeText += dataInfo + "\r\n";
|
| | | writeText += "#DeviceTemplateRealRoom END#\r\n\r\n";
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 生成写入文件的【设备和网关选择的模板的数据】
|
| | | /// </summary>
|
| | | /// <param name="writeText"></param>
|
| | | private void CrearWriteDeviceSelectTemplateData(ref string writeText)
|
| | | public void CrearWriteDeviceSelectTemplateData(ref string writeText) |
| | | {
|
| | | //设备选择模板的数据
|
| | | writeText += "#START#\r\n";
|
| | |
| | | public void AddDeviceTemplateSelect(string sourceMac, string targetMac)
|
| | | {
|
| | | //获取本地指定的Mac的全部设备
|
| | | var listDevice = Common.LocalDevice.Current.GetDevicesByMac(sourceMac, false);
|
| | | var otaDevice = Common.LocalDevice.Current.GetOTADevice(sourceMac);
|
| | | var listDevice = HdlDeviceCommonLogic.Current.GetDevicesByMac(sourceMac, false); |
| | | var otaDevice = HdlDeviceCommonLogic.Current.GetOTADevice(sourceMac); |
| | | if (otaDevice != null)
|
| | | {
|
| | | //这里ota设备也要加进去,重中之重
|
| | |
| | | foreach (var device in listDevice)
|
| | | {
|
| | | //模板选择的时候,他们的端点是一致的
|
| | | string localDeviceKey = Common.LocalDevice.Current.GetDeviceMainKeys(device);
|
| | | string templateDeviceKey = Common.LocalDevice.Current.GetDeviceMainKeys(targetMac, device.DeviceEpoint);
|
| | | string localDeviceKey = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device); |
| | | string templateDeviceKey = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(targetMac, device.DeviceEpoint); |
| | |
|
| | | if (this.modelData.dicDeviceTemplateRoom.ContainsKey(templateDeviceKey) == true
|
| | | && (device is OTADevice) == false)
|
| | |
| | | if (this.modelData.dicDeviceTemplateData.ContainsKey(localDeviceKey) == true)
|
| | | {
|
| | | //删除这个设备的模板保存文件
|
| | | HdlFileLogic.Current.DeleteFile(System.IO.Path.Combine(DirNameResourse.LocalTemplateDirectory, device.FilePath));
|
| | | HdlFileLogic.Current.DeleteFile(System.IO.Path.Combine(HdlFileNameResourse.LocalTemplateDirectory, device.FilePath)); |
| | | //移除当前端点保存的模板数据
|
| | | this.modelData.dicDeviceTemplateData.Remove(localDeviceKey);
|
| | | }
|
| | |
| | | //修改端点缓存名字
|
| | | if (tempData.DataSaveDiv == ModelDeviceSaveEnum.A端点名称)
|
| | | {
|
| | | Common.LocalDevice.Current.SetEpointName(device, ((ModelDeviceEpointNameInfo)tempData).deviceEpointName);
|
| | | HdlDeviceCommonLogic.Current.SetEpointName(device, ((ModelDeviceEpointNameInfo)tempData).deviceEpointName); |
| | | }
|
| | | else if (tempData.DataSaveDiv == ModelDeviceSaveEnum.A设备名称)
|
| | | {
|
| | | Common.LocalDevice.Current.SetMacName(device, ((ModelDeviceMacNameInfo)tempData).deviceMacName);
|
| | | HdlDeviceCommonLogic.Current.SetMacName(device, ((ModelDeviceMacNameInfo)tempData).deviceMacName); |
| | | }
|
| | | }
|
| | | }
|
| | |
| | | this.modelData.dicDeviceTemplateSelect[sourceMac] = targetMac;
|
| | | //保存的路径
|
| | | string fileData = Newtonsoft.Json.JsonConvert.SerializeObject(this.modelData.dicDeviceTemplateSelect);
|
| | | HdlFileLogic.Current.SaveTextToFile(DirNameResourse.DeviceTemplateSelectFile, fileData);
|
| | | HdlFileLogic.Current.SaveTextToFile(HdlFileNameResourse.DeviceTemplateSelectFile, fileData); |
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | public void RemoveDeviceTemplateSelect(string sourceMac)
|
| | | {
|
| | | ////获取本地指定的Mac的全部设备
|
| | | //var listDevice = Common.LocalDevice.Current.GetDevicesByMac(sourceMac, false);
|
| | | //var listDevice = HdlDeviceCommonLogic.Current.GetDevicesByMac(sourceMac, false); |
| | | //foreach (var device in listDevice)
|
| | | //{
|
| | | // //还原场景的执行目标
|
| | |
| | | this.modelData.dicDeviceTemplateSelect.Remove(sourceMac);
|
| | | //保存的路径
|
| | | string fileData = Newtonsoft.Json.JsonConvert.SerializeObject(this.modelData.dicDeviceTemplateSelect);
|
| | | HdlFileLogic.Current.SaveTextToFile(DirNameResourse.DeviceTemplateSelectFile, fileData);
|
| | | HdlFileLogic.Current.SaveTextToFile(HdlFileNameResourse.DeviceTemplateSelectFile, fileData); |
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | this.modelData.dicGatewayTemplateSelect[sourceGwid] = targetGwid;
|
| | | //保存的路径
|
| | | string fileData = Newtonsoft.Json.JsonConvert.SerializeObject(this.modelData.dicGatewayTemplateSelect);
|
| | | HdlFileLogic.Current.SaveTextToFile(DirNameResourse.GatewayTemplateSelectFile, fileData);
|
| | | HdlFileLogic.Current.SaveTextToFile(HdlFileNameResourse.GatewayTemplateSelectFile, fileData); |
| | |
|
| | | //变更网关房间
|
| | | if (this.modelData.dicDeviceTemplateRealRoom.ContainsKey(targetGwid) == true)
|
| | |
| | | this.modelData.dicGatewayTemplateSelect.Remove(sourceGwid);
|
| | | //保存的路径
|
| | | string fileData = Newtonsoft.Json.JsonConvert.SerializeObject(this.modelData.dicGatewayTemplateSelect);
|
| | | HdlFileLogic.Current.SaveTextToFile(DirNameResourse.GatewayTemplateSelectFile, fileData);
|
| | | HdlFileLogic.Current.SaveTextToFile(HdlFileNameResourse.GatewayTemplateSelectFile, fileData); |
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | this.modelData.dicDeviceTemplateSelect = new Dictionary<string, string>();
|
| | | this.modelData.dicGatewayTemplateSelect = new Dictionary<string, string>();
|
| | | //删掉这两个保存选择模板的文件
|
| | | HdlFileLogic.Current.DeleteFile(DirNameResourse.DeviceTemplateSelectFile);
|
| | | HdlFileLogic.Current.DeleteFile(DirNameResourse.GatewayTemplateSelectFile);
|
| | | HdlFileLogic.Current.DeleteFile(HdlFileNameResourse.DeviceTemplateSelectFile); |
| | | HdlFileLogic.Current.DeleteFile(HdlFileNameResourse.GatewayTemplateSelectFile); |
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | string modelId = this.GetDeviceModelId(localDevice.DeviceAddr);
|
| | | //模板中的网关ID
|
| | | string gatewayTemplateId = this.modelData.dicGatewayTemplateSelect[localDevice.CurrentGateWayId];
|
| | | foreach (var listData in this.modelData.dicDeviceFileContent.Values)
|
| | | foreach (var mainKey in this.modelData.dicDeviceFileContent.Keys) |
| | | {
|
| | | var listData = this.modelData.dicDeviceFileContent[mainKey]; |
| | | foreach (var data in listData)
|
| | | {
|
| | | if (data.saveDiv != ModelDeviceSaveEnum.A设备名称)
|
| | |
| | | {
|
| | | //该模板不是这个网关的,或者模块ID不一样的
|
| | | break;
|
| | | } |
| | | if (localDevice.DriveCode != 0) |
| | | { |
| | | //如果是虚拟设备,则如果不是同一个端点,则不能作为模板对象 |
| | | string checkKey = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(data.DeviceMac, localDevice.DeviceEpoint); |
| | | if (checkKey != mainKey) |
| | | { |
| | | break; |
| | | } |
| | | }
|
| | | listCheck.Add(data.DeviceMac);
|
| | |
|
| | |
| | | public void DeleteDevice(CommonDevice device)
|
| | | {
|
| | | //删除保存文件
|
| | | string saveFile = DirNameResourse.LocalTemplateDirectory;
|
| | | string saveFile = HdlFileNameResourse.LocalTemplateDirectory; |
| | | saveFile = System.IO.Path.Combine(saveFile, device.FilePath);
|
| | | HdlFileLogic.Current.DeleteFile(saveFile);
|
| | |
|
| | | //移除模板缓存
|
| | | this.modelData.dicDeviceTemplateData.Remove(Common.LocalDevice.Current.GetDeviceMainKeys(device));
|
| | | this.modelData.dicDeviceTemplateData.Remove(HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device)); |
| | | //移除设备选择缓存
|
| | | if (this.modelData.dicDeviceTemplateSelect.ContainsKey(device.DeviceAddr) == true)
|
| | | {
|
| | | this.modelData.dicDeviceTemplateSelect.Remove(device.DeviceAddr);
|
| | | HdlFileLogic.Current.SaveFileContent(DirNameResourse.DeviceTemplateSelectFile, this.modelData.dicDeviceTemplateSelect);
|
| | | HdlFileLogic.Current.SaveFileContent(HdlFileNameResourse.DeviceTemplateSelectFile, this.modelData.dicDeviceTemplateSelect); |
| | | }
|
| | | }
|
| | |
|
| | |
| | | /// <param name="deviceEpoint">设备Epoint</param>
|
| | | public void SaveDeviceMemmoryData(string deviceMac, int deviceEpoint)
|
| | | {
|
| | | string mainkey = Common.LocalDevice.Current.GetDeviceMainKeys(deviceMac, deviceEpoint);
|
| | | string mainkey = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(deviceMac, deviceEpoint); |
| | | if (this.modelData.dicDeviceTemplateData.ContainsKey(mainkey) == false)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | //保存路径
|
| | | string saveFile = DirNameResourse.LocalTemplateDirectory;
|
| | | string saveFile = HdlFileNameResourse.LocalTemplateDirectory; |
| | | saveFile = System.IO.Path.Combine(saveFile, "Device_" + mainkey);
|
| | |
|
| | | var listData = this.modelData.dicDeviceTemplateData[mainkey];
|
| | |
| | | continue;
|
| | | }
|
| | | //取本地Ota设备对象
|
| | | var localOta = Common.LocalDevice.Current.GetOTADevice(localMac);
|
| | | var localOta = HdlDeviceCommonLogic.Current.GetOTADevice(localMac); |
| | | if (localOta == null)
|
| | | {
|
| | | //应该不会进来,即使进来,我也不知道为什么
|
| | |
| | | {
|
| | | //只要两者的固件版本不一样,并且本地有这个升级固件,则都需要升级
|
| | | if (localOta.ImgVersion != tempDevice.ImgVersion
|
| | | && HdlFirmwareUpdateLogic.IsEsixtDeviceFirmwareFile((OTADevice)tempDevice) == true)
|
| | | && HdlFirmwareUpdateLogic.Current.IsEsixtDeviceFirmwareFile((OTADevice)tempDevice) == true) |
| | | {
|
| | | //按网关分组
|
| | | if (dicGatewayDevice.ContainsKey(localOta.CurrentGateWayId) == false)
|
| | |
| | | dicGatewayDevice[localOta.CurrentGateWayId] = new Dictionary<string, string>();
|
| | | }
|
| | | var dicDevice = dicGatewayDevice[localOta.CurrentGateWayId];
|
| | | dicDevice[localMac] = HdlFirmwareUpdateLogic.GetDeviceFirmwareFile((OTADevice)tempDevice);
|
| | | dicDevice[localMac] = HdlFirmwareUpdateLogic.Current.GetDeviceFirmwareFile((OTADevice)tempDevice); |
| | | }
|
| | | break;
|
| | | }
|
| | |
| | | if (tempGateway.LinuxFirmwareVersion != localGateway.LinuxFirmwareVersion)
|
| | | {
|
| | | //Linux升级固件文件全路径
|
| | | string updateFile = HdlFirmwareUpdateLogic.GetGatewayLinuxFirmwareFile(tempGateway);
|
| | | string updateFile = HdlFirmwareUpdateLogic.Current.GetGatewayLinuxFirmwareFile(tempGateway); |
| | | if (System.IO.File.Exists(updateFile) == true)
|
| | | {
|
| | | //如果存在的话
|
| | |
| | | if (tempGateway.CoordinatorFirmwareVersion != localGateway.CoordinatorFirmwareVersion)
|
| | | {
|
| | | //协调器升级固件文件全路径
|
| | | string updateFile = HdlFirmwareUpdateLogic.GetGatewayCoordinatorFirmwareFile(tempGateway);
|
| | | string updateFile = HdlFirmwareUpdateLogic.Current.GetGatewayCoordinatorFirmwareFile(tempGateway); |
| | | if (System.IO.File.Exists(updateFile) == true)
|
| | | {
|
| | | //如果存在的话
|
| | |
| | | if (localCode.DriveCode == tempCode.DriveCode && localCode.DriveFwVersion != tempCode.DriveFwVersion)
|
| | | {
|
| | | //虚拟驱动升级固件文件全路径
|
| | | string updateFile = HdlFirmwareUpdateLogic.GetGatewayDriveCodeFirmwareFile(tempCode);
|
| | | string updateFile = HdlFirmwareUpdateLogic.Current.GetGatewayDriveCodeFirmwareFile(tempCode); |
| | | if (System.IO.File.Exists(updateFile) == true)
|
| | | {
|
| | | //如果存在的话
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | } |
| | | if (listUpdateInfo.Count == 2) |
| | | { |
| | | listUpdateInfo.Add(null); |
| | | }
|
| | | //添加目标缓存
|
| | | if (needUpdate == true)
|
| | |
| | | /// <param name="templateFileName">模板文件的名字(全住宅存放的模板)</param>
|
| | | public void CopyTemplateFileToLocalDirectory(string templateFileName)
|
| | | {
|
| | | string sourceFile = System.IO.Path.Combine(DirNameResourse.AllResidenceTemplateDirectory, templateFileName);
|
| | | string sourceFile = System.IO.Path.Combine(HdlFileNameResourse.AllResidenceTemplateDirectory, templateFileName); |
| | |
|
| | | this.CopyTemplateFileToLocalDirectory2(sourceFile);
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | //保存的路径
|
| | | string targetFile = DirNameResourse.LocalTemplateDirectory;
|
| | | string targetFile = HdlFileNameResourse.LocalTemplateDirectory; |
| | | targetFile = System.IO.Path.Combine(targetFile, TemplateFileName);
|
| | |
|
| | | try { System.IO.File.Copy(fullTemplateName, targetFile, true); }
|
| | |
| | | public void DeleteAllLocalFile()
|
| | | {
|
| | | //获取这个路径下面全部的文件
|
| | | var listFile = HdlFileLogic.Current.GetFileFromDirectory(DirNameResourse.LocalTemplateDirectory, false); ;
|
| | | var listFile = HdlFileLogic.Current.GetFileFromDirectory(HdlFileNameResourse.LocalTemplateDirectory, false); ; |
| | | foreach (var file in listFile)
|
| | | {
|
| | | HdlFileLogic.Current.DeleteFile(file);
|
| | |
| | | /// <returns></returns>
|
| | | private string GetDeviceModelId(string deviceMac)
|
| | | {
|
| | | var listDevice = Common.LocalDevice.Current.GetDevicesByMac(deviceMac);
|
| | | var listDevice = HdlDeviceCommonLogic.Current.GetDevicesByMac(deviceMac); |
| | | foreach (var device in listDevice)
|
| | | {
|
| | | if (device.ModelIdentifier != string.Empty)
|
| | |
| | | /// <returns></returns>
|
| | | public TemplateDeviceDataCommon GetDeviceModelDataClass(string deviceMac, int deviceEpoint, ModelDeviceSaveEnum saveEnum, TemplateDeviceDataCommon newClass)
|
| | | {
|
| | | string mainkey = Common.LocalDevice.Current.GetDeviceMainKeys(deviceMac, deviceEpoint);
|
| | | string mainkey = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(deviceMac, deviceEpoint); |
| | |
|
| | | //创建存储空间
|
| | | if (this.modelData.dicDeviceTemplateData.ContainsKey(mainkey) == false)
|