Ejemplo n.º 1
0
        //设置防打扰时间(此脚本中的net代表闹钟,other代表防打扰时间,包括学习时间和睡眠时间)
        public void setOtherClock(string childsn, string silenceDatasString, Action success, Action error)
        {
            GuLog.Debug("<><CupClockManager> setOtherClock-New");

            GuLog.Debug(string.Format("----CupClockManager.setOtherClock-New---->childSN: {0}, originData: {1}", childsn, silenceDatasString));
            AllSilenceTimeSectionFromServer silenceDatas = mJsonUtils.String2Json <AllSilenceTimeSectionFromServer>(silenceDatasString);
            ClocksInfo clocksInfo     = this.SilenceDatas2ClockInfos(childsn, silenceDatas);//将网络下发的防打扰数据的格式转为本地格式
            string     localClockInfo = mJsonUtils.Json2String(clocksInfo);

            mLocalClockInfoAgent.saveOtherClockInfo(childsn, localClockInfo);//将转型后的防打扰数据存入本地
            GuLog.Debug(string.Format("----CupClockManager.setOtherClock-New---->childSN: {0}, formatedData: {1}", childsn, localClockInfo));

            string netClockInfo = mLocalClockInfoAgent.getNetClockInfo(childsn);

            if (string.IsNullOrEmpty(netClockInfo))
            {//如果此时水杯中没有此孩子的闹钟数据,则用转型后的防打扰时间覆盖
                mAlarmManager.replaceAlarmList(localClockInfo, success, error);
            }
            else
            {//如果此时水杯中有此孩子的闹钟数据,则与防打扰数据拼接起来一并推送给底层
                ClocksInfo netinfo = mJsonUtils.String2Json <ClocksInfo>(netClockInfo);
                netinfo.clocks.AddRange(clocksInfo.clocks);
                string allData = mJsonUtils.Json2String(netinfo);
                mAlarmManager.replaceAlarmList(allData, success, error);
                GuLog.Debug(string.Format("----CupClockManager.setOtherClock-New---->childSN: {0}, allData: {1}", childsn, allData));
            }
        }
Ejemplo n.º 2
0
        public void setNetClock(string childsn, string netClockInfo, Action success, Action error)
        {
            GuLog.Debug("<><CupClockManager> setNetClock");

            string otherClockInfo = mLocalClockInfoAgent.getOtherClockInfo(childsn);

            mLocalClockInfoAgent.saveNetClockInfo(childsn, netClockInfo);
            UnityEngine.Debug.LogFormat("----{0}----CupClockManager.setNetClock: {1}, {2}", System.DateTime.Now.ToString("HH:mm:ss:fff"), childsn, netClockInfo);
            if (string.IsNullOrEmpty(otherClockInfo))
            {
                UnityEngine.Debug.LogFormat("----{0}----CupClockManager.replaceAlarmList_1", System.DateTime.Now.ToString("HH:mm:ss:fff"));
                mAlarmManager.replaceAlarmList(netClockInfo, success, error);
            }
            else
            {
                ClocksInfo otherinfo = mJsonUtils.String2Json <ClocksInfo>(otherClockInfo);
                ClocksInfo netinfo   = mJsonUtils.String2Json <ClocksInfo>(netClockInfo);

                netinfo.clocks.AddRange(otherinfo.clocks);
                string allinfoStr = mJsonUtils.Json2String(netinfo);

                mAlarmManager.replaceAlarmList(allinfoStr, success, error);
                UnityEngine.Debug.LogFormat("----{0}----CupClockManager.replaceAlarmList_2: {1}, {2}, {3}", System.DateTime.Now.ToString("HH:mm:ss:fff"), allinfoStr, otherinfo, netinfo);
            }
        }
Ejemplo n.º 3
0
        public void setOtherClock(string childsn, List <ClocksItem> clocks, Action success, Action error)
        {
            GuLog.Debug("<><CupClockManager> setOtherClock");

            string netClockInfo = mLocalClockInfoAgent.getNetClockInfo(childsn);

            ClocksInfo localinfo = new ClocksInfo();

            localinfo.clocks = clocks;
            string localClockInfo = mJsonUtils.Json2String(localinfo);

            mLocalClockInfoAgent.saveOtherClockInfo(childsn, localClockInfo);
            if (string.IsNullOrEmpty(netClockInfo))
            {
                mAlarmManager.replaceAlarmList(localClockInfo, success, error);
            }
            else
            {
                ClocksInfo netinfo = mJsonUtils.String2Json <ClocksInfo>(netClockInfo);
                netinfo.clocks.AddRange(clocks);

                string allinfoStr = mJsonUtils.Json2String(netinfo);

                mAlarmManager.replaceAlarmList(allinfoStr, success, error);
            }
        }
Ejemplo n.º 4
0
        public void replaceAlarmList(string alarmInfo, Action success, Action error)
        {
            if (string.IsNullOrEmpty(alarmInfo))
            {
                GuLog.Error("----AlarmManager.replaceAlarmList----parameter[string: alarmInfo] is null or empty");
                return;
            }

            ClocksInfo clocksInfo = this.JsonUtils.String2Json <ClocksInfo>(alarmInfo);

            if (clocksInfo == null || clocksInfo.clocks == null)
            {
                GuLog.Error("----AlarmManager.replaceAlarmList----parameter[string: alarmInfo] can't convert to the type[ClocksInfo]");
                return;
            }

            List <ClocksItem> deleteItems = new List <ClocksItem>();

            clocksInfo.clocks.ForEach((clocksItem) =>
            {
                if (clocksItem != null && clocksItem.clock_enable == 0)
                {
                    deleteItems.Add(clocksItem);
                }
            });
            if (deleteItems.Count > 0)
            {
                deleteItems.ForEach((clocksItem) => { clocksInfo.clocks.Remove(clocksItem); });
            }

            alarmInfo = this.JsonUtils.Json2String(clocksInfo);
            GuLog.Debug(string.Format("----AlarmManager.replaceAlarmList----formatted alarmInfo: {0}", alarmInfo));

            SetAlarmCallback callback = new SetAlarmCallback();

            callback.setCallback(success, error);
            GuLog.Debug("<><AlarmManager> replaceAlarmList:" + alarmInfo);
            getAlarmManagerWrap().CallStatic("replaceAlarmList", alarmInfo, callback);
        }
Ejemplo n.º 5
0
 //数据转型(将网络下发的防打扰数据的格式转为本地格式)
 private ClocksInfo SilenceDatas2ClockInfos(string childsn, AllSilenceTimeSectionFromServer silenceDatas)
 {
     if (silenceDatas != null && silenceDatas.configs != null && silenceDatas.configs.Count > 0)
     {
         int        id         = 1;
         ClocksInfo clocksInfo = new ClocksInfo();
         foreach (SilenceTimeSectionFromServer silenceData in silenceDatas.configs)
         {
             clocksInfo.clocks.Add(new ClocksItem()
             {//起始时间
                 id             = id++,
                 x_child_sn     = childsn,
                 clock_type     = this.GetClockType(silenceData.type, "_begin"),
                 clock_enable   = silenceData.enable,
                 clock_hour     = silenceData.start_hour,
                 clock_min      = silenceData.start_min,
                 clock_weekdays = silenceData.weekdays
             });
             clocksInfo.clocks.Add(new ClocksItem()
             {//结束时间
                 id             = id++,
                 x_child_sn     = childsn,
                 clock_type     = this.GetClockType(silenceData.type, "_end"),
                 clock_enable   = silenceData.enable,
                 clock_hour     = silenceData.end_hour,
                 clock_min      = silenceData.end_min,
                 clock_weekdays = silenceData.weekdays
             });
         }
         return(clocksInfo);
     }
     else
     {
         GuLog.Error("----CupClockManager.SilenceDatas2ClockInfos---->silenceDatas is null");
         return(null);
     }
 }