Esempio n. 1
0
 public void RequestGraph(string uid, string parent)
 {
     if (isLocal)
     {
         var path = Path.Combine(rootPath, "graph/graph_" + uid + ".json");
         if (!File.Exists(path))
         {
             ZLog.Warning("the file not exist that path = " + path);
             DFNotifyManager.SendNotify(DFNotifyType.OnGraphDataUpdate, null);
             return;
         }
         var txt   = File.ReadAllText(path);
         var graph = ParseUtil.ParseGraphJson(txt, rootPath);
         if (graph == null)
         {
             ZLog.Warning("the graph data is null");
             DFNotifyManager.SendNotify(DFNotifyType.OnGraphDataUpdate, null);
             return;
         }
         graph.Parent = parent;
         DFNotifyManager.SendNotify(DFNotifyType.OnGraphDataUpdate, graph);
     }
     else
     {
         string address = GetAddress(HttpAPIType.Graph);
         var    json    = new LitJson.JsonData
         {
             ["uid"]    = uid,
             ["parent"] = parent,
             ["code"]   = codes
         };
         ZHttpController.Post(URL_Graph, address, json.ToString(), HttpCompleteHandler, true);
     }
 }
Esempio n. 2
0
        private void HttpCompleteHandler(ZHttpController.Response info)
        {
            if (info.state != ZHttpController.Status.Normal)
            {
                reqNum += 1;
                if (reqNum > maxReconnected)
                {
                    MessageManager.HttpConnected = false;
                    ZHttpController.Clear();
                }
                ZLog.Warning("Http Response Exception...." + info.data);
                DFNotifyManager.SendNotify(DFNotifyType.OnResponseError, ServerErrorStaus.Success);
                return;
            }
            MessageManager.HttpConnected = true;

            int    status = 0;
            string result = DealResponse(info.data, out status);

            ZLog.Log("HttpCompleteHandler....uid = " + info.uid + " ;result = " + result);
            if (status != 0)
            {
                return;
            }
            if (info.uid == URL_Graph)
            {
                Model.GraphModel graph = ParseUtil.ParseGraphJson(result, rootPath);
                DFNotifyManager.SendNotify(DFNotifyType.OnGraphDataUpdate, graph);
            }
            else if (info.uid == URL_Entity)
            {
                Model.EntityInfo tmp = ParseUtil.ParseEntityJson(result, "");
                DFNotifyManager.SendNotify(DFNotifyType.OnEntityDataUpdate, tmp);
            }
            else if (info.uid == URL_Themes)
            {
                // DFNotifyManager.SendNotify(DFNotifyType.OnThemesUpdate, list);
            }
        }