Exemple #1
0
        private async void OnMessageReceivedAsync(StreamElement xmlMessage)
        {
            Debug.WriteLine($"SERVER <- {xmlMessage}");

            if (xmlMessage.OpensXmppStream)
            {
                // Stream opened
            }
            else if (xmlMessage.ClosesXmppStream)
            {
                // Stream closed
            }
            else
            {
                var message = XmppSerializer.Deserialize(xmlMessage.Name, xmlMessage.ToString());

                if (message is InfoQuery || message is Message || message is Presence)
                {
                    await this.OnStanzaAsync(message).ConfigureAwait(false);
                }
                else
                {
                    await this.OnStreamFragmentAsync(message).ConfigureAwait(false);
                }
            }
        }
        /// <summary>
        /// Opens the stream for writing.
        /// </summary>
        /// <param name="jobConfig">The current job configuration</param>
        /// <param name="streamConfig">The current stream configuration</param>
        public void Open(JobElement jobConfig, StreamElement streamConfig)
        {
            JobConfig = jobConfig;
            var csvPath = streamConfig.Settings["path"];

            CsvFile = new StreamWriter(new FileStream(csvPath, FileMode.Create, FileAccess.Write));

            // write the header labels row
            var first = true;

            foreach (AttributeElement attrib in jobConfig.Attributes)
            {
                if (!first)
                {
                    CsvFile.Write(",\"{0}\"", attrib.Name);
                }
                else
                {
                    first = false;
                    CsvFile.Write("\"{0}\"", attrib.Name);
                }
            }

            CsvFile.Flush();
        }
        protected async Task <StreamElement> OpenFileStream(StorageFile f)
        {
            StreamElement s = new StreamElement();

            s.File   = f;
            s.Stream = await f.OpenReadAsync();

            return(s);
        }
        public IOutputStream CreateOutputStream(JobElement jobConfig, StreamElement streamConfig)
        {
            var container = ContainerFactory.GetContainer();

            // get a reference to the stream object
            var stream = container.GetInstance <IOutputStream>(streamConfig.Name);

            // open the stream for writting
            stream.Open(jobConfig, streamConfig);

            return(stream);
        }
Exemple #5
0
        /// <summary>
        /// Opens the stream for writing
        /// </summary>
        /// <param name="jobConfig">The current job configuration</param>
        /// <param name="streamConfig">The current stream configuration</param>
        public void Open(JobElement jobConfig, StreamElement streamConfig)
        {
            JobConfig    = jobConfig;
            StreamConfig = streamConfig;

            // build the time name based on
            var safeJobName = GetSafeFileName(JobConfig.Name);

            FileName = $"{Path.GetTempPath()}{safeJobName}";

            // open a temp file to stream the user data
            Logger.Debug("Writting users to file: \"{0}\"", FileName);
            DataStream = new StreamWriter(FileName);
            DataStream.WriteLine("{\n\"users\":[");
        }
Exemple #6
0
        /// <summary>
        /// Opens the stream for writing
        /// </summary>
        /// <param name="jobConfig">The current job configuration.</param>
        /// <param name="streamConfig">The stream configuration.</param>
        public void Open(JobElement jobConfig, StreamElement streamConfig)
        {
            JobConfig    = jobConfig;
            StreamConfig = streamConfig;

            // get the login interval
            int loginIntervalMinutes;

            if (!int.TryParse(streamConfig.Settings["loginIntervalMinutes"], out loginIntervalMinutes))
            {
                loginIntervalMinutes = 20;
            }
            var loginInterval = loginIntervalMinutes * 60 * 1000;

            // authenticate with the c360 api
            var loginSettings = new LoginSettings
            {
                BaseAddress  = StreamConfig.Settings["baseAddress"],
                Organization = StreamConfig.Settings["organization"],
                Username     = StreamConfig.Settings["username"],
                Password     = StreamConfig.Settings["password"]
            };

            Login(loginSettings);

            // setup a task to renew the token on a regular interval
            // authenticate with the c360 api

            _timer = new Timer(Login, loginSettings, loginInterval, loginInterval);

            // load the cache services for cached content
            EmployeeCache        = CacheServiceFactory.CreateCacheService(Logger, "Employee", false);
            JobTitleCache        = CacheServiceFactory.CreateCacheService(Logger, "JobTitle", false);
            DepartmentCache      = CacheServiceFactory.CreateCacheService(Logger, "Department", false);
            WorkflowCache        = CacheServiceFactory.CreateCacheService(Logger, "Workflow", false);
            EmployeeGroupCache   = CacheServiceFactory.CreateCacheService(Logger, "EmployeeGroup", true);
            EmployeeProfileCache = CacheServiceFactory.CreateCacheService(Logger, "EmployeeProfile", false);
            DivisionCache        = CacheServiceFactory.CreateCacheService(Logger, "Division", false);
        }
 /// <summary>
 /// Opens the stream for writing.
 /// </summary>
 /// <param name="jobConfig">The current job configuration</param>
 /// <param name="streamConfig">The current stream configuration</param>
 public void Open(JobElement jobConfig, StreamElement streamConfig)
 {
     JobConfig    = jobConfig;
     StreamConfig = streamConfig;
 }
Exemple #8
0
 protected void PublishMessage(StreamElement message)
 {
     this.messageStream.OnNext(message);
 }