Example #1
0
        public ActionResult OnFormat(string data)
        {
            ReturnResult result = new ReturnResult();

            try
            {
                result.data = JsonHelper.ConvertJsonString(data);
            }
            catch (Exception ex)
            {
                result.code = -1;
                result.msg  = ex.Message;
            }
            return(Json(result));
        }
Example #2
0
        private void SaveUpdatedFiles(List<JsonFileItem> selected)
        {
            var jo = new JsonOperator();
            foreach (JsonFileItem item in selected)
            {
                //jo.SetAsModel(model.JsonItems, item.JsonItems);
                jo.JsonItemList = item.JsonItems;
                var newJson = jo.SetToJson();

                var x = JsonHelper.ConvertJsonString(newJson);

                var fileName = PathHelper.GetWholeFileName(item.Path);
                var path = $"{SavedFolder}\\{fileName}";
                FileHelper.SaveFile(path, x);
            }
        }
Example #3
0
        public static bool WriteOnvifMonitors()
        {
            try
            {
                DirectoryInfo dir = new DirectoryInfo(WorkPath);
                if (OnvifManagers != null && OnvifManagers.Count > 0)
                {
                    List <OnvifMonitorStruct> onvifList = OnvifMonitorApis.GetOnvifMonitorList(out ResponseStruct rs);
                    if (onvifList != null && onvifList.Count > 0)
                    {
                        string configStr = JsonHelper.ToJson(onvifList);
                        configStr = JsonHelper.ConvertJsonString(configStr);

                        if (string.IsNullOrEmpty(configStr))
                        {
                            LogWriter.WriteLog("Onvif配置文件写入失败,配置内容为空...", WorkPath + "system.oconf",
                                               ConsoleColor.Yellow);
                            return(false);
                        }
                        else
                        {
                            File.WriteAllText(WorkPath + "system.oconf", configStr);
                            LogWriter.WriteLog("Onvif配置文件写入完成...", WorkPath + "system.oconf");
                            return(true);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                LogWriter.WriteLog("Onvif配置文件写入失败...", ex.Message + "\r\n" + ex.StackTrace, ConsoleColor.Yellow);
                return(false);
            }
        }
Example #4
0
        private void SaveFilesDele(object obj)
        {
            var selected = (List<JsonFileItem>)obj;        

            var jo = new JsonOperator();

            foreach (JsonFileItem item in selected)
            {
                //jo.SetAsModel(model.JsonItems, item.JsonItems);
                jo.JsonItemList = item.JsonItems;
                var newJson = jo.SetToJson();

                var x = JsonHelper.ConvertJsonString(newJson);

                var fileName = PathHelper.GetWholeFileName(item.Path);
                var path = $"{SavedFolder}\\{fileName}";
                FileHelper.SaveFile(path, x);
            }

            this.BeginInvoke(new DeleParaNone(CopyFromModelAction));

            base.EndExecute(null);
        }