Example #1
0
        public static TaskManage SaveTasks(string ip, int port, IEnumerable <TaskItem> tasks, out string msg)
        {
            string strTask = Common.XmlSerializeToStr(tasks);

            string str = SendToServer(ip, port, OperationType.SaveTasks, strTask);

            if (str.StartsWith("err", StringComparison.OrdinalIgnoreCase))
            {
                msg = str.Substring(3);
                return(null);
            }
            var ret = new TaskManage();
            // 分拆出时间数据
            int lastRunSplit = str.IndexOf('|');

            if (lastRunSplit > 0 && lastRunSplit < 40)
            {
                string[] tmp = str.Substring(0, lastRunSplit).Split(',');
                ret.serverTime  = tmp[0];
                ret.lastRunTime = tmp.Length > 1 ? tmp[1] : string.Empty;
                str             = str.Substring(lastRunSplit + 1);
            }

            ret.tasks = Common.XmlDeserializeFromStr <List <TaskItem> >(str);
            ret.ip    = ip;

            msg = null;
            return(ret);
        }
Example #2
0
        /// <summary>
        /// 获取所有任务
        /// </summary>
        /// <param name="ip"></param>
        /// <param name="port"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static TaskManage GetAllTask(string ip, int port, out string msg)
        {
            // 连接网络数据库,返回全部任务
            string str = SendToServer(ip, port, OperationType.GetAllTasks, null);

            if (string.IsNullOrEmpty(str))
            {
                msg = ("数据为空");
                return(null);
            }
            string isDebug = ConfigurationManager.AppSettings["PlanDebug"];

            if (!string.IsNullOrEmpty(isDebug) && isDebug == "1")
            {
                HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=tmp");
                HttpContext.Current.Response.ContentType = "application/unknown";
                HttpContext.Current.Response.Write(str);
                HttpContext.Current.Response.End();
                msg = null;
                return(null);
            }

            if (str.StartsWith("err", StringComparison.OrdinalIgnoreCase))
            {
                msg = (str.Substring(3));
                return(null);
            }

            var ret = new TaskManage();

            // 分拆出时间数据
            int lastRunSplit = str.IndexOf('|');

            if (lastRunSplit > 0 && lastRunSplit < 40)
            {
                string[] tmp = str.Substring(0, lastRunSplit).Split(',');
                ret.serverTime  = tmp[0];
                ret.lastRunTime = tmp.Length > 1 ? tmp[1] : string.Empty;
                str             = str.Substring(lastRunSplit + 1);
            }
            ret.tasks = Common.XmlDeserializeFromStr <List <TaskItem> >(str);
            ret.ip    = ip;

            msg = null;
            return(ret);
        }