예제 #1
0
        private string GetRobotJobFileName(Globals.BackgroundAppType type, out string guid)
        {
            Guid id = Guid.NewGuid();

            guid = id.ToString("N");

            return($"{ type.ToString().ToLower() }_{ guid }");
        }
예제 #2
0
        public static void Save(string path, string guid, Globals.BackgroundAppType type, DateTime executionDate, Dictionary <string, object> parameters)
        {
            var job = new Job()
            {
                Id            = guid,
                Type          = type,
                Status        = RobotJobStatus.ACTIVE,
                CreationDate  = DateTime.Now,
                ExecutionDate = executionDate
            };

            job.SetParameters(parameters);

            XmlSerializer SerializerObj = new XmlSerializer(typeof(Job));

            using (TextWriter writer = new StreamWriter(path))
            {
                SerializerObj.Serialize(writer, job);
                writer.Close();
            }
        }
예제 #3
0
        public string Create(Globals.BackgroundAppType type, DateTime dt, Dictionary <string, object> parameters)
        {
            try
            {
                string guid = null;
                string name = GetRobotJobFileName(type, out guid);

                AddSynObject(guid);

                lock (GetSyncObject(guid))
                {
                    string file = Path.Combine(CommonService.JobsDirectory, $"{ name }.xml");

                    RobotJobManager.Save(file, name, type, dt, parameters);
                }

                return(name);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }