log4net.ILog.Info(object)

Here are the examples of the csharp api log4net.ILog.Info(object) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

592 Examples 7

19 Source : PatternLayoutTest.cs
with Apache License 2.0
from apache

[Test]
		public void TestThreadPropertiesPattern()
		{
			StringAppender stringAppender = new StringAppender();
            stringAppender.Layout = NewPatternLayout("%property{" + Utils.PROPERTY_KEY + "}");

			ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString());
			BasicConfigurator.Configure(rep, stringAppender);

			ILog log1 = LogManager.GetLogger(rep.Name, "TestThreadProperiesPattern");

			log1.Info("TestMessage");
			replacedert.AreEqual(SystemInfo.NullText, stringAppender.GetString(), "Test no thread properties value set");
			stringAppender.Reset();

			ThreadContext.Properties[Utils.PROPERTY_KEY] = "val1";

			log1.Info("TestMessage");
			replacedert.AreEqual("val1", stringAppender.GetString(), "Test thread properties value set");
			stringAppender.Reset();

			ThreadContext.Properties.Remove(Utils.PROPERTY_KEY);

			log1.Info("TestMessage");
			replacedert.AreEqual(SystemInfo.NullText, stringAppender.GetString(), "Test thread properties value removed");
			stringAppender.Reset();
		}

19 Source : PatternLayoutTest.cs
with Apache License 2.0
from apache

[Test]
		public void TestGlobalPropertiesPattern()
		{
			StringAppender stringAppender = new StringAppender();
            stringAppender.Layout = NewPatternLayout("%property{" + Utils.PROPERTY_KEY + "}");

			ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString());
			BasicConfigurator.Configure(rep, stringAppender);

			ILog log1 = LogManager.GetLogger(rep.Name, "TestGlobalProperiesPattern");

			log1.Info("TestMessage");
			replacedert.AreEqual(SystemInfo.NullText, stringAppender.GetString(), "Test no global properties value set");
			stringAppender.Reset();

			GlobalContext.Properties[Utils.PROPERTY_KEY] = "val1";

			log1.Info("TestMessage");
			replacedert.AreEqual("val1", stringAppender.GetString(), "Test global properties value set");
			stringAppender.Reset();

			GlobalContext.Properties.Remove(Utils.PROPERTY_KEY);

			log1.Info("TestMessage");
			replacedert.AreEqual(SystemInfo.NullText, stringAppender.GetString(), "Test global properties value removed");
			stringAppender.Reset();
		}

19 Source : PatternLayoutTest.cs
with Apache License 2.0
from apache

[Test]
        public void NamedPatternConverterWithoutPrecisionShouldReturnFullName()
        {
            StringAppender stringAppender = new StringAppender();
            PatternLayout layout = NewPatternLayout();
            layout.AddConverter("message-as-name", typeof(MessageAsNamePatternConverter));
            layout.ConversionPattern = "%message-as-name";
            layout.ActivateOptions();
            stringAppender.Layout = layout;
            ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString());
            BasicConfigurator.Configure(rep, stringAppender);
            ILog log1 = LogManager.GetLogger(rep.Name, "TestAddingCustomPattern");

            log1.Info("NoDots");
            replacedert.AreEqual("NoDots", stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();

            log1.Info("One.Dot");
            replacedert.AreEqual("One.Dot", stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();

            log1.Info("Tw.o.Dots");
            replacedert.AreEqual("Tw.o.Dots", stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();

            log1.Info("TrailingDot.");
            replacedert.AreEqual("TrailingDot.", stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();

            log1.Info(".LeadingDot");
            replacedert.AreEqual(".LeadingDot", stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();

            // empty string and other evil combinations as tests for of-by-one mistakes in index calculations
            log1.Info(string.Empty);
            replacedert.AreEqual(string.Empty, stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();

            log1.Info(".");
            replacedert.AreEqual(".", stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();

            log1.Info("x");
            replacedert.AreEqual("x", stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();
        }

19 Source : PatternLayoutTest.cs
with Apache License 2.0
from apache

[Test]
        public void NamedPatternConverterWithPrecision2ShouldStripLessLeadingStuffIfPresent() {
            StringAppender stringAppender = new StringAppender();
            PatternLayout layout = NewPatternLayout();
            layout.AddConverter("message-as-name", typeof(MessageAsNamePatternConverter));
            layout.ConversionPattern = "%message-as-name{2}";
            layout.ActivateOptions();
            stringAppender.Layout = layout;
            ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString());
            BasicConfigurator.Configure(rep, stringAppender);
            ILog log1 = LogManager.GetLogger(rep.Name, "TestAddingCustomPattern");

            log1.Info("NoDots");
            replacedert.AreEqual("NoDots", stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();

            log1.Info("One.Dot");
            replacedert.AreEqual("One.Dot", stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();

            log1.Info("Tw.o.Dots");
            replacedert.AreEqual("o.Dots", stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();

            log1.Info("TrailingDot.");
            replacedert.AreEqual("TrailingDot.", stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();

            log1.Info(".LeadingDot");
            replacedert.AreEqual("LeadingDot", stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();

            // empty string and other evil combinations as tests for of-by-one mistakes in index calculations
            log1.Info(string.Empty);
            replacedert.AreEqual(string.Empty, stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();

            log1.Info("x");
            replacedert.AreEqual("x", stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();

            log1.Info(".");
            replacedert.AreEqual(".", stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();
        }

19 Source : PatternLayoutTest.cs
with Apache License 2.0
from apache

[Test]
        public void TestStackTracePattern()
        {
            StringAppender stringAppender = new StringAppender();
            stringAppender.Layout = NewPatternLayout("%stacktrace{2}");

            ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString());
            BasicConfigurator.Configure(rep, stringAppender);

            ILog log1 = LogManager.GetLogger(rep.Name, "TestStackTracePattern");

            log1.Info("TestMessage");
            Stringreplacedert.EndsWith("PatternLayoutTest.TestStackTracePattern", stringAppender.GetString(), "stack trace value set");
            stringAppender.Reset();
        }

19 Source : PatternLayoutTest.cs
with Apache License 2.0
from apache

[Test]
		public void TestAddingCustomPattern()
		{
			StringAppender stringAppender = new StringAppender();
			PatternLayout layout = NewPatternLayout();

			layout.AddConverter("TestAddingCustomPattern", typeof(TestMessagePatternConverter));
			layout.ConversionPattern = "%TestAddingCustomPattern";
			layout.ActivateOptions();

			stringAppender.Layout = layout;

			ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString());
			BasicConfigurator.Configure(rep, stringAppender);

			ILog log1 = LogManager.GetLogger(rep.Name, "TestAddingCustomPattern");

			log1.Info("TestMessage");
			replacedert.AreEqual("TestMessage", stringAppender.GetString(), "%TestAddingCustomPattern not registered");
			stringAppender.Reset();
		}

19 Source : PatternLayoutTest.cs
with Apache License 2.0
from apache

[Test]
        public void NamedPatternConverterWithPrecision1ShouldStripLeadingStuffIfPresent()
        {
            StringAppender stringAppender = new StringAppender();
            PatternLayout layout = NewPatternLayout();
            layout.AddConverter("message-as-name", typeof(MessageAsNamePatternConverter));
            layout.ConversionPattern = "%message-as-name{1}";
            layout.ActivateOptions();
            stringAppender.Layout = layout;
            ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString());
            BasicConfigurator.Configure(rep, stringAppender);
            ILog log1 = LogManager.GetLogger(rep.Name, "TestAddingCustomPattern");

            log1.Info("NoDots");
            replacedert.AreEqual("NoDots", stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();

            log1.Info("One.Dot");
            replacedert.AreEqual("Dot", stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();

            log1.Info("Tw.o.Dots");
            replacedert.AreEqual("Dots", stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();

            log1.Info("TrailingDot.");
            replacedert.AreEqual("TrailingDot.", stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();

            log1.Info(".LeadingDot");
            replacedert.AreEqual("LeadingDot", stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();

            // empty string and other evil combinations as tests for of-by-one mistakes in index calculations
            log1.Info(string.Empty);
            replacedert.AreEqual(string.Empty, stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();

            log1.Info("x");
            replacedert.AreEqual("x", stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();

            log1.Info(".");
            replacedert.AreEqual(".", stringAppender.GetString(), "%message-as-name not registered");
            stringAppender.Reset();
        }

19 Source : Logger.cs
with Apache License 2.0
from aws-samples

public static void LogInfo(string message)
        {
            log.Info(message);
        }

19 Source : Logger.cs
with Apache License 2.0
from aws-samples

public static void LogInfo(string message)
        {
            if (! IsLog4netConfigured)
            {
                ConfigureLog4Net();
            }
            log.Info(message);
        }

19 Source : Log4NetHandler.cs
with Apache License 2.0
from beetlex-io

public void Process(LogType type, string message)
		{
			switch (type)
			{
				case LogType.DEBUG:
					mLoger.Debug(message);
					break;
				case LogType.ERROR:
					mLoger.Error(message);
					break;
				case LogType.FATAL:
					mLoger.Fatal(message);
					break;
				case LogType.INFO:
					mLoger.Info(message);
					break;
				case LogType.WARN:
					mLoger.Warn(message);
					break;
				case LogType.NONE:
					break;

			}

		}

19 Source : MainWindow.xaml.cs
with GNU General Public License v3.0
from BLinssen

private bool HandleResolution()
        {
            double dWidth = -1;
            double dHeight = -1;
            if (Properties.Settings.Default.Resolution == "None")
            {
                //Get Resolution
                dWidth = SystemParameters.PrimaryScreenWidth;
                dHeight = SystemParameters.PrimaryScreenHeight;
                log.Info($"Found resolution: {dWidth}x{dHeight}");
                //Check if Resolution is supported
                if (SupportedResolutions.FindIndex(x => x.Equals($"{dWidth}x{dHeight}")) != -1)
                {
                    Properties.Settings.Default.Resolution = $"{dWidth}x{dHeight}";
                    Properties.Settings.Default.Save();
                    ResolutionSettings = TemResolutions.Find(x => x.Resolution.Equals($"{dWidth}x{dHeight}"));
                    ComboBoxResolution.SelectedValue = $"{dWidth}x{dHeight}";
                    return true;
                }
                else
                {
                    System.Windows.MessageBox.Show($"{dWidth}x{dHeight} is currently not supported. \nVisit https://github.com/BLinssen/TemTacO/issues to request a resolution.'", "TemTacO");
                    return false;
                }
            }

            string[] resolution = Properties.Settings.Default.Resolution.Split('x'); 
            dWidth = Convert.ToInt32(resolution[0]);
            dHeight = Convert.ToInt32(resolution[1]);
            log.Info($"Settings resolution: {dWidth}x{dHeight}");
            ResolutionSettings = TemResolutions.Find(x => x.Resolution.Equals($"{dWidth}x{dHeight}"));
            ComboBoxResolution.SelectedValue = $"{dWidth}x{dHeight}";
            return true;        
        }

19 Source : MainWindow.xaml.cs
with GNU General Public License v3.0
from BLinssen

private void ComboBoxResolution_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if(ComboBoxResolution.SelectedValue != null && ComboBoxResolution.SelectedValue.ToString() != string.Empty)
            {
                string[] resolution = ComboBoxResolution.SelectedValue.ToString().Split('x');
                log.Info($"Changed resolution: {resolution[0]}x{resolution[1]}");
                ResolutionSettings = TemResolutions.Find(x => x.Resolution.Equals($"{resolution[0]}x{resolution[1]}"));                
                Properties.Settings.Default.Resolution = $"{resolution[0]}x{resolution[1]}";
                Properties.Settings.Default.Save();
            }
        }

19 Source : MainWindow.xaml.cs
with GNU General Public License v3.0
from BLinssen

private List<TemTem> PopulateList()
        {
            log.Info("Reading TemList.csv");
            List<TemTem> temTemps = File.ReadAllLines("Resources\\TemTemList.csv")
                                           .Skip(1)
                                           .Select(v => TemTem.FromCsv(v, enEn))
                                           .ToList();
            return temTemps;
        }

19 Source : MainWindow.xaml.cs
with GNU General Public License v3.0
from BLinssen

private List<TemTrait> PopulateTraits()
        {
            log.Info("Reading TemTraits.csv");
            List<TemTrait> tempTemTraits = File.ReadAllLines("Resources\\TemTraits.csv")
                                           .Skip(1)
                                           .Select(v => TemTrait.FromCsv(v, enEn))
                                           .ToList();
            return tempTemTraits;
        }

19 Source : MainWindow.xaml.cs
with GNU General Public License v3.0
from BLinssen

private List<OCR> PopulateResolutions()
        {
            log.Info("Reading TemResolutions.csv");
            List<OCR> tempTemResolutions = File.ReadAllLines("Resources\\TemResolutions.csv")
                                           .Skip(1)
                                           .Select(v => OCR.FromCsv(v, enEn))
                                           .ToList();
            return tempTemResolutions;
        }

19 Source : MainWindow.xaml.cs
with GNU General Public License v3.0
from BLinssen

private void StartScreenChecker()
        {
            //DispatcherTimer setup
            DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
            dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
            //Run the function every 3 seconds.
            dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
            dispatcherTimer.Start();
            log.Info("Started scanning");

        }

19 Source : MainWindow.xaml.cs
with GNU General Public License v3.0
from BLinssen

private List<string> PopulateSupportedResolutions()
        {
            log.Info("Reading Supported Resolutions");
            List<string> tempSupportedResolutions = new List<string>();
            foreach(OCR ocr in TemResolutions)
            {
                tempSupportedResolutions.Add($"{ocr.Width}x{ocr.Height}");
            }
            return tempSupportedResolutions;
        }

19 Source : HexiController.cs
with MIT License
from breeswish

public void Start()
        {
            if (ValueBag.ServerStarted)
            {
                return;
            }
            serverThread = new Thread(new ParameterizedThreadStart(ThreadFunc));
            serverThread.Start(this);
            ValueBag.ServerStarted = true;
            log.Info("Hexi Server Listener started");
        }

19 Source : HexiController.cs
with MIT License
from breeswish

public void Stop()
        {
            if (!ValueBag.ServerStarted)
            {
                return;
            }
            StopServer();
            serverThread.Abort();
            serverThread = null;
            ValueBag.ServerStarted = false;
            log.Info("Hexi Server Listener stopped");
        }

19 Source : LogHelper.cs
with MIT License
from chi8708

public void Info(object message)
        {
            this.logger.Info(message);
        }

19 Source : ExeProcess.cs
with MIT License
from cxwl3sxl

void StartProcess()
        {
            _mainProcess?.Kill();
            _mainProcess?.Dispose();
            _log.Debug($"程序路径:{_config.Exe}");
            _log.Debug($"启动参数:{_config.Argument}");
            _mainProcess = new Process
            {
                StartInfo = new ProcessStartInfo(_config.Exe)
                {
                    WorkingDirectory = Path.GetDirectoryName(_config.Exe) ?? throw new InvalidOperationException(),
                    Arguments = _config.Argument,
                    RedirectStandardInput = _config.RedirectStandardInput,
                    RedirectStandardOutput = _config.RedirectStandardOutput,
                    UseShellExecute = _config.UseShellExecute,
                    CreateNoWindow = _config.CreateNoWindow
                }
            };
            if (_config.RedirectStandardOutput)
                _mainProcess.OutputDataReceived += _mainProcess_OutputDataReceived;
            _mainProcess.Start();
            _log.Info($"服务进程{Path.GetFileName(_config.Exe)}已经启动,进程ID:{_mainProcess.Id}");
        }

19 Source : ExeProcess.cs
with MIT License
from cxwl3sxl

public void Stop()
        {
            _stop = true;
            _mainProcess?.Kill();
            _log.Info("服务已经成功停止.");
        }

19 Source : ExeProcess.cs
with MIT License
from cxwl3sxl

public void Start()
        {
            StartProcess();
            ThreadPool.QueueUserWorkItem(ProcessEye);
            _log.Info("服务已经成功启动.");
        }

19 Source : App.xaml.cs
with MIT License
from ekblom

private void Load(object sender)
        {
            var loading = (LoadingWindow) sender;

            _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
            _log.Info("Application started");

            Hub.Instance.Storage.DataStore.InitCache(s => { Current.Dispatcher.Invoke(() => { loading.SetMessage(s); }); });

            // TODO: i18n
            loading.SetMessage("Loading models");

            ViewModelLocator.Instance.NotebookMenu.Loaded = true;
            ViewModelLocator.Instance.NoteMenu.Loaded = true;
            ViewModelLocator.Instance.NoteView.Loaded = true;
            ViewModelLocator.Instance.Main.Loaded = true;
            ViewModelLocator.Instance.Librarys.Loaded = true;
            ViewModelLocator.Instance.Settings.Loaded = true;
            ViewModelLocator.Instance.BackupManager.Loaded = true;

            loading.SetMessage("Loading main window");

            Current.Dispatcher.Invoke(ShowMainWindow);
            Current.Dispatcher.Invoke(() => { loading.Close(); });
        }

19 Source : ErrorHandler.cs
with MIT License
from Excel-projects

public static void CreateLogRecord()
        {
            try
            {
                // gather context
                var sf = new System.Diagnostics.StackFrame(1);
                var caller = sf.GetMethod();
                var currentProcedure = caller.Name.Trim();

                // handle log record
                var logMessage = string.Concat(new Dictionary<string, string>
                {
                    ["PROCEDURE"] = currentProcedure,
                    ["USER NAME"] = Environment.UserName,
                    ["MACHINE NAME"] = Environment.MachineName
                }.Select(x => $"[{x.Key}]=|{x.Value}|"));
                log.Info(logMessage);

            }
            catch (Exception ex)
            {
                ErrorHandler.DisplayMessage(ex);

            }
        }

19 Source : ErrorHandler.cs
with MIT License
from Excel-projects

public static void CreateLogRecord()
        {
            try
            {
                var sf = new System.Diagnostics.StackFrame(1);
                var caller = sf.GetMethod();
                var currentProcedure = caller.Name.Trim();

                var logMessage = string.Concat(new Dictionary<string, string>
                {
                    ["PROCEDURE"] = currentProcedure,
                    ["USER NAME"] = Environment.UserName,
                    ["MACHINE NAME"] = Environment.MachineName
                }.Select(x => $"[{x.Key}]=|{x.Value}|"));
                log.Info(logMessage);

            }
            catch (Exception ex)
            {
                ErrorHandler.DisplayMessage(ex);

            }
        }

19 Source : DownloadFromRestServiceCurriculumVitaeController.cs
with GNU General Public License v3.0
from FabricadeSoftwareUNIVILLE

private void DownloadCurriculumVitae(RetryMessage retryMessage, ManualResetEvent doneDownloadEvent)
        {
            var curriculumVitae = retryMessage.CurriculumVitae;
            var wc = new WebClient();
            try
            {
                var stream = wc.OpenRead(String.Format(_urlMetadata, curriculumVitae.NumeroCurriculo));

                DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(MetadataResponse));
                var response = ser.ReadObject(stream) as MetadataResponse;

                if (response.CodRhCript == null || response.CodRhCript.Trim().Length == 0)
                {
                    Logger.Error($"Não foi possível baixar o currículo de número {curriculumVitae.NumeroCurriculo}");
                    return;
                }

                curriculumVitae.NomeProfessor = response.Doreplacedent.NomeCompleto;

                if (NeedsToBeUpdated(curriculumVitae, response) == false)
                {
                    Logger.Info($"Currículo {curriculumVitae.NumeroCurriculo} - {curriculumVitae.NomeProfessor} já esta atualizado.");
                    return;
                }

                DownloadXml(curriculumVitae, response, wc);

                if (curriculumVitae.NomeProfessor == null || curriculumVitae.NomeProfessor.Trim().Length == 0)
                {
                    Logger.Info($"Curriculo {curriculumVitae.NumeroCurriculo} baixado");
                    return;
                }

                Logger.Info($"Curriculo {curriculumVitae.NumeroCurriculo} - {curriculumVitae.NomeProfessor} baixado");
            }
            catch (WebException exception)
            {
                Logger.Error(
                    $"Erro ao realizar requisão do Currículo {curriculumVitae.NumeroCurriculo} (Tentativas Sobrando {retryMessage.PendingRetries}): {exception.Message}\n{exception.StackTrace}"
                );
                retryMessage.PendingRetries--;
                if (retryMessage.PendingRetries > 0)
                {
                    Thread.Sleep(10000);
                    Interlocked.Increment(ref _pendingCurriculums);
                    _retryDownload.Send(retryMessage);
                }
            }
            finally
            {
                wc.Dispose();
                if (Interlocked.Decrement(ref _pendingCurriculums) == 0)
                {
                    doneDownloadEvent.Set();
                    _retryDownload.Close();
                }
            }
        }

19 Source : DownloadFromWebServiceCurriculumVitaeController.cs
with GNU General Public License v3.0
from FabricadeSoftwareUNIVILLE

public void DownloadUpdatedCurriculums(ManualResetEvent doneEvent)
        {
            try
            {
                foreach (var curriculumVitae in _curriculumVitaesForDownload.Range())
                {
                    DownloadCurriculumVitae(curriculumVitae);
                }
            }
            finally
            {
                doneEvent.Set();
                Logger.Info("Download terminou");
            }
        }

19 Source : DownloadFromWebServiceCurriculumVitaeController.cs
with GNU General Public License v3.0
from FabricadeSoftwareUNIVILLE

private void DownloadCurriculumVitae(CurriculoEntry curriculumVitae)
        {
            try
            {
                if (curriculumVitae.NumeroCurriculo == null || curriculumVitae.NumeroCurriculo.Trim().Length == 0)
                {
                    Logger.Error($"O número do curríuculo Lattes do professor {curriculumVitae.NomeProfessor} não foi encontrado");
                    return;
                }

                int read;
                byte[] buffer = new byte[4096];
                MemoryStream ms = _dcvs.GetCurriculumVitaeIfUpdated(curriculumVitae);

                if (ms == null)
                {
                    return;
                }

                if (File.Exists(_lattesModule.GetCurriculumVitaeFileName(curriculumVitae.NumeroCurriculo)))
                {
                    File.Delete(_lattesModule.GetCurriculumVitaeFileName(curriculumVitae.NumeroCurriculo));
                }

                FileStream wc = new FileStream(_lattesModule.GetCurriculumVitaeFileName(curriculumVitae.NumeroCurriculo), FileMode.CreateNew);
                while ((read = ms.Read(buffer, 0, buffer.Length)) > 0)
                {
                    wc.Write(buffer, 0, read);
                }
                ms.Close();

                _curriculumVitaesForProcess.Send(curriculumVitae);

                wc.Flush();
                wc.Close();

                if (curriculumVitae.NomeProfessor == null || curriculumVitae.NomeProfessor.Trim().Length == 0)
                {
                    Logger.Info($"Curriculo {curriculumVitae.NumeroCurriculo} baixado");
                    return;
                }

                Logger.Info($"Curriculo {curriculumVitae.NumeroCurriculo} - {curriculumVitae.NomeProfessor} baixado");
            }
            catch (Exception exception)
            {
                Logger.Error($"Erro ao buscar o currículo {curriculumVitae.NumeroCurriculo}, mensagem: {exception.Message}\n{exception.StackTrace}");
            }
        }

19 Source : DownloadCurriculumVitaeWebService.cs
with GNU General Public License v3.0
from FabricadeSoftwareUNIVILLE

public MemoryStream GetCurriculumVitaeIfUpdated(CurriculoEntry curriculumVitae)
        {
            Nullable<DateTime> dataAtualizacaoLattes = null;
            Nullable<DateTime> dataAtualizacaoSistema;
            string dataAtualizacaoString;

            if (curriculumVitae.NumeroCurriculo == null || curriculumVitae.NumeroCurriculo == "")
            {
                Logger.Info(
                    $"Buscando Número do Currículo do Professor {curriculumVitae.NomeProfessor}"
                );
                curriculumVitae.NumeroCurriculo = ws.getIdentificadorCNPq(curriculumVitae.CPF, curriculumVitae.NomeProfessor, curriculumVitae.DataNascimento);

                if (curriculumVitae.NumeroCurriculo == null || curriculumVitae.NumeroCurriculo == "" || curriculumVitae.NumeroCurriculo.Contains("ERRO"))
                    return null;

                Logger.Info(
                    $"Número do Currículo do Professor {curriculumVitae.NomeProfessor} encontrado: {curriculumVitae.NumeroCurriculo}"
                );
            }

            // verificar se a data de atualizacao do CV é maior que a do sistema

            dataAtualizacaoSistema = this.GetDataAtualizacaoProfessor(curriculumVitae.NumeroCurriculo);

            if (dataAtualizacaoSistema != null)
            {
                dataAtualizacaoString = ws.getDataAtualizacaoCV(curriculumVitae.NumeroCurriculo);

                if (dataAtualizacaoString == "")
                    dataAtualizacaoLattes = DateTime.Today;
                else
                    dataAtualizacaoLattes = DateTime.ParseExact(dataAtualizacaoString, "dd/MM/yyyy %H:mm:ss", null);

                if (dataAtualizacaoSistema >= dataAtualizacaoLattes)
                    return null; // curriculo não precisa curriculumVitaeUnserializer atualizado
            }

            if (dataAtualizacaoLattes != null)
                curriculumVitae.DataUltimaAtualizacao = (DateTime)dataAtualizacaoLattes;

            byte[] zip = ws.getCurriculoCompactado(curriculumVitae.NumeroCurriculo);

            if (zip == null || zip.Length == 0)
            {
                Logger.Error(
                    $"Aconteceu um erro ao tentar buscar o currículo de Número {curriculumVitae.NumeroCurriculo}, favor verificar o mesmo"
                );
                return null;
            }

            return ProcessarRetornoCurriculo(zip);
        }

19 Source : LattesModule.cs
with GNU General Public License v3.0
from FabricadeSoftwareUNIVILLE

private void LoadCurriculums()
        {
            if (IgnorePendingLastExecution == false)
            {
                var loadFromTempDirectory = new LoadFromTempDirectory(this, TempDirectory, CurriculumVitaeForProcess);
                if (loadFromTempDirectory.HasPendingResumes())
                {
                    Logger.Info($"Foram encontrados XMLs pendentes na pasta '{TempDirectory}' !'");
                    QueueThreadGetCurriculumVitae(loadFromTempDirectory.LoadCurriculums);
                    return;
                }
            }

            if (ImportFolder != null)
            {
                Logger.Info($"Lendo Currículos do diretório '{ImportFolder}'...");
                var importFromFolder = new ImportCurriculumVitaeFromFolderController(
                    this,
                    ImportFolder, 
                    CurriculumVitaeForProcess
                );
                QueueThreadGetCurriculumVitae(importFromFolder.LoadCurriculums);
                return;
            }

            Logger.Info("Iniciando Carga dos Números de Currículo da Insreplaceduição...");
            if (CSVCurriculumVitaeNumberList != null)
            {
                var csvListController = new LoadCurriculumVitaeNumberFromCSVController(
                    this,
                    CSVCurriculumVitaeNumberList, 
                    CurriculumVitaeForDownload
                );
                QueueThreadListCurriculumVitae(csvListController.LoadCurriculumVitaeNumbers);
            }

            if (CSVCurriculumVitaeNumberList == null)
            {
                var oleDbController = new LoadCurriculumVitaeNumberFromOleDbController(
                    this,
                    LattesCurriculumVitaeODBCConnection,
                    LattesCurriculumVitaeQuery,
                    CurriculumVitaeForDownload
                );
                QueueThreadListCurriculumVitae(oleDbController.LoadCurriculumVitaeNumbers);
            }

            if (UseNewCNPqRestService)
            {
                Logger.Info("Iniciando Download dos Currículos Atualizados (REST Service)...");
                var downloadRestService = new DownloadFromRestServiceCurriculumVitaeController(
                    this,
                    new LattesDatabase(),
                    CurriculumVitaeForDownload,
                    CurriculumVitaeForProcess
                );
                QueueThreadGetCurriculumVitae(downloadRestService.DownloadUpdatedCurriculums);
                return;
            }

            Logger.Info("Iniciando Download dos Currículos Atualizados (WebService)...");
            var downloadWebService = new DownloadFromWebServiceCurriculumVitaeController(
                this,
                new Service.DownloadCurriculumVitaeWebService(
                    new LattesDatabase(),
                    WSCurriculoClient
                ),
                CurriculumVitaeForDownload,
                CurriculumVitaeForProcess
            );
            QueueThreadGetCurriculumVitae(downloadWebService.DownloadUpdatedCurriculums);
        }

19 Source : LattesModule.cs
with GNU General Public License v3.0
from FabricadeSoftwareUNIVILLE

public void Extract()
        {
            try
            {
                if (UseNewCNPqRestService)
                {
                    Logger.Error("A opção de utilizar o serviço \"buscacv\" do CNPq esta temporáriamente indisponível até se tornar estável");
                }

                Logger.Info("Começando Processamento...");

                var processor = new CurriculumVitaeProcessorController(this, CurriculumVitaeForProcess);
                QueueThreadProcessCurriculumVitae(processor.ProcessCurriculumVitaes);

                LoadCurriculums();

                Logger.Info("Iniciando Processamento dos Currículos...");

                if (_doneEventsListCurriculumVitae.Count > 0)
                {
                    WaitHandle.WaitAll(_doneEventsListCurriculumVitae.ToArray());
                    Logger.Info("Todos os Currículos Foram Listados...");
                }
                CurriculumVitaeForDownload.Close();

                WaitHandle.WaitAll(_doneEventsGetCurriculumVitae.ToArray());
                Logger.Info("Todos os Currículos Foram Adicionados para Processamento...");
                CurriculumVitaeForProcess.Close();

                WaitHandle.WaitAll(_doneEventsProcessCurriculumVitae.ToArray());
                Logger.Info("Todos os Currículos Foram Processados...");
            }
            catch (Exception ex)
            {
                ShowException(ex);
            }

            Logger.Info("Encerrando Execução...");
        }

19 Source : LattesModule.cs
with GNU General Public License v3.0
from FabricadeSoftwareUNIVILLE

public void UpdateQualisDataBase(string csvQualis)
        {
            QualisFileName = csvQualis;
            Logger.Info("Iniciando Processamento do Qualis...");
            LoadQualisTableController.LoadQualisTable(this);
        }

19 Source : LattesModule.cs
with GNU General Public License v3.0
from FabricadeSoftwareUNIVILLE

public void UpdateJCRImpactFactorDataBase(string inputJCRFile)
        {
            JCRFileName = inputJCRFile;
            Logger.Info("Iniciando Processamento do JCR Impact Factor...");
            LoadJCRTableController.LoadJCRTable(this);
        }

19 Source : CurriculumVitaeProcessorController.cs
with GNU General Public License v3.0
from FabricadeSoftwareUNIVILLE

private void ProcessCurriculumVitae(CurriculoEntry curriculoEntry, ManualResetEvent doneEvent)
        {
            XmlDoreplacedent curriculumVitaeXml = new XmlDoreplacedent();
            try
            {
                var filename = _lattesModule.GetCurriculumVitaeFileName(curriculoEntry.NumeroCurriculo);

                curriculumVitaeXml.Load(filename);

                // nescessário para o deserialize reconhecer o Xml
                curriculumVitaeXml.DoreplacedentElement.SetAttribute("xmlns", "http://tempuri.org/LMPLCurriculo");

                XDoreplacedent curriculumVitaeXDoreplacedent = XDoreplacedent.Parse(curriculumVitaeXml.InnerXml);
                CurriculoVitaeXml curriculumVitae = _curriculumVitaeUnserializer.Deserialize(curriculumVitaeXDoreplacedent.CreateReader()) as CurriculoVitaeXml;
                curriculoEntry.NomeProfessor = curriculumVitae.DADOSGERAIS.NOMECOMPLETO;

                ProfessorDAOService professorDAOService = new ProfessorDAOService(new LattesDatabase());
                Logger.Debug($"Iniciando processamento currículo {curriculoEntry.NumeroCurriculo} do Professor {curriculumVitae.DADOSGERAIS.NOMECOMPLETO}...");

                if (professorDAOService.ProcessCurriculumVitaeXML(curriculumVitae, curriculoEntry))
                {
                    Logger.Info($"Currículo {curriculoEntry.NumeroCurriculo} do Professor {curriculumVitae.DADOSGERAIS.NOMECOMPLETO} processado com sucesso !");
                    File.Delete(filename);
                }
            }

            catch (Exception ex)
            {
                Logger.Error($"Erro durante a leitura do XML {curriculoEntry.NumeroCurriculo}: {ex.Message}\n{ex.StackTrace}");

                int sequencia = 1;
                while (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                    Logger.Error($"Excessão Interna [{sequencia++}]: {ex.Message}\n{ex.StackTrace}");
                }
            }
            finally
            {
                if (Interlocked.Decrement(ref _workItemCount) == 0)
                {
                    doneEvent.Set();
                }
                // Allow another add to the queue
                WorkLimiter.Release();
            }
        }

19 Source : DownloadFromRestServiceCurriculumVitaeController.cs
with GNU General Public License v3.0
from FabricadeSoftwareUNIVILLE

public void DownloadUpdatedCurriculums(ManualResetEvent doneEvent)
        {
            try
            {
                ThreadPool.QueueUserWorkItem(o => RetryQueueProcessing(doneEvent));

                foreach (var c in _curriculumVitaesForDownload.Range())
                {
                    Interlocked.Increment(ref _pendingCurriculums);
                    _retryDownload.Send(
                        new RetryMessage
                        {
                            CurriculumVitae = c,
                            PendingRetries = 5,
                        }
                    );
                }

                if (_pendingCurriculums > 0)
                {
                    doneEvent.WaitOne();
                    doneEvent = null;
                }
            }
            finally
            {
                if (doneEvent != null)
                {
                    doneEvent.Set();
                }
                Logger.Info("Download terminou");
            }
        }

19 Source : ImportCurriculumVitaeFromFolderController.cs
with GNU General Public License v3.0
from FabricadeSoftwareUNIVILLE

public void LoadCurriculums(ManualResetEvent doneEvent)
        {
            try
            {
                if (!Directory.Exists(_importFolder))
                {
                    Logger.Info($"Pasta de trabalho não foi encontrado ({_importFolder})");
                    return;
                }

                if (Directory.GetFiles(_importFolder).Length == 0)
                {
                    throw new Exception($"Não foram encontrados currículos na pasta {_importFolder} !");
                }

                var unzipDoneEvent = new ManualResetEvent(false);
                foreach (string filename in Directory.EnumerateFiles(_importFolder))
                {
                    string numeroCurriculo = filename.Substring(_importFolder.Length + 1);
                    numeroCurriculo = numeroCurriculo.Substring(0, numeroCurriculo.Length - 4);
                    var curriculumVitae = new CurriculoEntry { NumeroCurriculo = numeroCurriculo };

                    if (File.Exists(_lattesModule.GetCurriculumVitaeFileName(curriculumVitae.NumeroCurriculo)))
                    {
                        File.Delete(_lattesModule.GetCurriculumVitaeFileName(curriculumVitae.NumeroCurriculo));
                    }

                    if (filename.EndsWith(".xml"))
                    {
                        File.Copy(filename, _lattesModule.GetCurriculumVitaeFileName(curriculumVitae.NumeroCurriculo));
                        _channel.Send(curriculumVitae);
                        continue;
                    }

                    Interlocked.Increment(ref _workItemCount);
                    ThreadPool.QueueUserWorkItem(o => UnzipAndCopy(unzipDoneEvent, filename, curriculumVitae));
                }
                if (_workItemCount > 0)
                {
                    unzipDoneEvent.WaitOne();
                }
            }
            finally
            {
                doneEvent.Set();
            }
        }

19 Source : Program.cs
with MIT License
from fbarresi

[STAThread]
		private static void Main()
		{
			using (IKernel kernel = new StandardKernel())
			{
				LoadModules(kernel);

				var x = new ConsoleAppender { Layout = new SimpleLayout() };
				BasicConfigurator.Configure(x);

				s_Logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

				var viewModelFactory = kernel.Get<ViewModelLocator>();
				var application = CreateApplication(viewModelFactory);

				var mainWindowViewModel = viewModelFactory.CreateViewModel<MainWindowViewModel>();
				s_Logger.Info("Initializing application");

				var mainWindow = kernel.Get<MainWindow>();
				mainWindow.DataContext = mainWindowViewModel;

				application.Run(mainWindow);
				application.Shutdown();
			}
		}

19 Source : Application.cs
with MIT License
from FICTURE7

private void SetupConfigs()
        {
            var path = Path.Combine(BinaryPath, "uberstrok.realtime.server.json");

            Log.Info($"Loading configuration at {path}");
            if (!File.Exists(path))
            {
                Configuration = ApplicationConfiguration.Default;
                Log.Info("uberstrok.realtime.server.json not found, using default configuration.");
            }
            else
            {
                try
                {
                    var json = File.ReadAllText(path);
                    Configuration = JsonConvert.DeserializeObject<ApplicationConfiguration>(json);
                    Configuration.Check();

                    Log.Info("uberstrok.realtime.server.json loaded ->");
                    Log.Info($"\tCompositeHashes({Configuration.CompositeHashBytes.Count})");
                    Log.Info($"\tJunkHashes({Configuration.JunkHashBytes.Count})");
                    Log.Info($"\tHeartbeatTimeout = {Configuration.HeartbeatTimeout}");
                    Log.Info($"\tHeartbeatInterval = {Configuration.HeartbeatInterval}");
                }
                catch (Exception ex)
                {
                    Log.Fatal("Failed to load or parse uberstrok.realtime.server.json", ex);
                    throw;
                }
            }

            PeerConfiguration = new PeerConfiguration
            (
                Configuration.WebServices,
                Configuration.WebServicesAuth,
                Configuration.HeartbeatTimeout,
                Configuration.HeartbeatInterval,
                Configuration.CompositeHashBytes,
                Configuration.JunkHashBytes
            );
        }

19 Source : Application.cs
with MIT License
from FICTURE7

protected sealed override void Setup()
        {
            SetupLog4net();
            SetupConfigs();

            OnSetup();

            Log.Info($"Setup {GetType().Name}... Complete");
        }

19 Source : Application.cs
with MIT License
from FICTURE7

protected sealed override PeerBase CreatePeer(InitRequest initRequest)
        {
            Log.Info($"Accepted new connection at {initRequest.RemoteIP}:{initRequest.RemotePort}.");

            initRequest.UserData = PeerConfiguration;
            return OnCreatePeer(initRequest);
        }

19 Source : Application.cs
with MIT License
from FICTURE7

protected sealed override void TearDown()
        {
            OnTearDown();

            Log.Info($"TearDown {GetType().Name}... Complete");
        }

19 Source : Peer.cs
with MIT License
from FICTURE7

public bool Authenticate(string authToken, string magicHash)
        {
            AuthToken = authToken ?? throw new ArgumentNullException(nameof(authToken));

            if (magicHash == null)
                throw new ArgumentNullException(nameof(magicHash));

            Log.Info($"Authenticating {authToken}:{magicHash} at {RemoteIP}:{RemotePort}");

            var userView = GetUser(true);
            OnAuthenticate(userView);

#if !DEBUG
            bool isAdmin = userView.CmuneMemberView.PublicProfile.AccessLevel != MemberAccessLevel.Admin;
            if (Configuration.CompositeHashes.Count > 0 && isAdmin)
            {
                var authTokenBytes = Encoding.ASCII.GetBytes(authToken);
                for (int i = 0; i < Configuration.CompositeHashes.Count; i++)
                {
                    var compositeHash = Configuration.CompositeHashes[i];
                    var reMagicHash = HashBytes(compositeHash, authTokenBytes);
                    if (reMagicHash == magicHash)
                    {
                        Log.Debug($"MagicHash: {reMagicHash} == {magicHash}");
                        return true;
                    }

                    Log.Error($"MagicHash: {reMagicHash} != {magicHash}");
                }

                return false;
            }
#endif
            return true;
        }

19 Source : GameRoomManager.cs
with MIT License
from FICTURE7

public GameRoom Create(GameRoomDataView data, string preplacedword)
        {
            if (data == null)
                throw new ArgumentNullException(nameof(data));

            /* Set those to 0, so the client knows there is no level restriction. */
            if (data.LevelMin == 1 && data.LevelMax == 80)
            {
                data.LevelMin = 0;
                data.LevelMax = 0;
            }

            GameRoom room = null;
            try
            {
                switch (data.GameMode)
                {
                    case GameModeType.DeathMatch:
                        room = new DeathMatchGameRoom(data, _loopScheduler);
                        break;
                    case GameModeType.TeamDeathMatch:
                        room = new TeamDeathMatchGameRoom(data, _loopScheduler);
                        break;

                    default:
                        throw new NotSupportedException();
                }
            }
            catch
            {
                room?.Dispose();
                throw;
            }

            lock (_sync)
            {
                room.RoomId = _roomId++;
                room.Preplacedword = preplacedword;

                _rooms.Add(room.RoomId, room);
                _updatedRooms.Add(room.GetView());

                Log.Info($"Created {room.GetDebug()}");
            }

            return room;
        }

19 Source : GameRoomManager.cs
with MIT License
from FICTURE7

public void Tick()
        {
            lock (_sync)
            {
                foreach (var kv in _rooms)
                {
                    var room = kv.Value;
                    var view = room.GetView();

                    if (!view.IsPermanentGame && room.Actors.Count == 0 && room.Loop.Time >= 15 * 1000)
                    {
                        _removedRooms.Add(room.RoomId);
                    }
                    else if (room.Updated)
                    {
                        _updatedRooms.Add(room.GetView());
                        room.Updated = false;
                    }
                }

                foreach (var peer in GameApplication.Instance.Lobby.Peers)
                    peer.Events.SendGameListUpdate(_updatedRooms, _removedRooms);

                foreach (var roomId in _removedRooms)
                {
                    if (_rooms.TryGetValue(roomId, out GameRoom room))
                    {
                        _rooms.Remove(roomId);
                        room.Dispose();

                        Log.Info($"Removed {room.GetDebug()}");
                    }
                }

                _updatedRooms.Clear();
                _removedRooms.Clear();
            }
        }

19 Source : GameActor.cs
with MIT License
from FICTURE7

public void Reset()
        {
            var userView = Peer.GetUser(retrieve: false);
            var loadoutView = Peer.GetLoadout(retrieve: false);
            var profileView = userView.CmuneMemberView.PublicProfile;
            var statsView = userView.UberstrikeMemberView.PlayerStatisticsView;

            Loadout.Update(Room.Shop, loadoutView);

            PlayerId = 0;
            
            Info.PlayerName = profileView.Name;
            Info.PlayerState = PlayerStates.None;
            Info.TeamID = TeamID.NONE;
            Info.Channel = ChannelType.Steam;
            Info.Level = statsView.Level == 0 ? 1 : statsView.Level;
            Info.Cmid = profileView.Cmid;
            Info.ClanTag = profileView.GroupTag;
            Info.AccessLevel = profileView.AccessLevel;

            Info.Gear = Loadout.Gear.GetAsList();
            Info.Weapons = Loadout.Weapons.GetAsList();
            Info.QuickItems = Loadout.QuickItems.GetAsList();

            Info.Health = 100;
            Info.ArmorPointCapacity = Loadout.Gear.GetArmorCapacity();
            Info.ArmorPoints = Info.ArmorPointCapacity;

            Info.Kills = 0;
            Info.Deaths = 0;

            /* Ignore these changes. */
            Info.GetViewDelta().Reset();

            State.Reset();
            Loadout.Reset();

            Statistics.Reset(hard: true);

            Log.Info($"{GetDebug()} has been reset with armor capacity {Info.ArmorPointCapacity}.");
        }

19 Source : AuthenticationWebService.cs
with MIT License
from FICTURE7

public override MemberAuthenticationResultView OnLoginSteam(string steamId, string authToken, string machineId)
        {
            var ip = ((RemoteEndpointMessageProperty)OperationContext.Current.IncomingMessageProperties[RemoteEndpointMessageProperty.Name]).Address;

            if (Context.Users.Db.IsHwdBanned(machineId) || Context.Users.Db.IsIpBanned(ip))
            {
                return new MemberAuthenticationResultView
                {
                    MemberAuthenticationResult = MemberAuthenticationResult.IsBanned,
                    AuthToken = null,
                    IsAccountComplete = true,
                    ServerTime = DateTime.Now,

                    MemberView = null,
                    PlayerStatisticsView = null
                };
            }

            // Figure out if the account has been linked.
            var linked = true;
            // Figure out if the account existed. true -> existed otherwise false.
            var incomplete = false;

            // Load the user from the database using its steamId.
            var member = Context.Users.Db.LoadMember(steamId);
            if (member == null)
            {
                Log.Info($"Member entry {steamId} does not exists, creating new entry");

                // Create a new member if its not in the db.
                incomplete = true;
                member = Context.Users.NewMember();

                // Link the Steam ID to the CMID.
                linked = Context.Users.Db.Link(steamId, member);
            }
#if DEBUG
            else
            {
                var memoryMember = Context.Users.GetMember(member.PublicProfile.Cmid);
                if (memoryMember != null)
                {
                    member = Context.Users.NewMember();
                    Log.Info($"Faking member {memoryMember.PublicProfile.Cmid} with {member.PublicProfile.Cmid}");
                }
            }
#endif
            if (Context.Users.Db.IsCmidBanned(member.PublicProfile.Cmid))
            {
                return new MemberAuthenticationResultView
                {
                    MemberAuthenticationResult = MemberAuthenticationResult.IsBanned,
                    AuthToken = null,
                    IsAccountComplete = true,
                    ServerTime = DateTime.Now,

                    MemberView = null,
                    PlayerStatisticsView = null
                };
            }

            var result = MemberAuthenticationResult.Ok;
            if (!linked)
                result = MemberAuthenticationResult.InvalidEsns;

            // Use the PublicProfile.EmailAddrsessStatus to figure out if its an incomplete account,
            // because why not.
            if (member.PublicProfile.EmailAddressStatus == EmailAddressStatus.Unverified)
                incomplete = true;

            var session = Context.Users.LogInUser(member);
            session.Hwd = machineId;
            session.Ip = ip;

            var view = new MemberAuthenticationResultView
            {
                MemberAuthenticationResult = result,
                AuthToken = session.AuthToken,
                IsAccountComplete = !incomplete,
                ServerTime = DateTime.Now,

                MemberView = member,
                PlayerStatisticsView = new PlayerStatisticsView
                {
                    Cmid = member.PublicProfile.Cmid,
                    PersonalRecord = new PlayerPersonalRecordStatisticsView(),
                    WeaponStatistics = new PlayerWeaponStatisticsView()
                },
            };

            Log.Info($"Logging in member {steamId}:{session.AuthToken}");

            return view;
        }

19 Source : UserManager.cs
with MIT License
from FICTURE7

public Session LogInUser(MemberView member)
        {
            if (member == null)
                throw new ArgumentNullException(nameof(member));

            // Encode ServiceBase URL into the AuthToken so the realtime servers can figure out
            // where the user came from.
            var data = _ctx.ServiceBase + "#####" + DateTime.UtcNow.ToFileTime();
            var bytes = Encoding.UTF8.GetBytes(data);
            var authToken = Convert.ToBase64String(bytes);
            var session = default(Session);

            member.PublicProfile.LastLoginDate = DateTime.UtcNow;

            lock (_sessions)
            {
                foreach (var kv in _sessions)
                {
                    var value = kv.Value;
                    if (value.Member.PublicProfile.Cmid == member.PublicProfile.Cmid)
                    {
                        /* Replace players with same CMID, not the neatest of fixes, but it works. */
                        _sessions.Remove(kv.Key);
                        Log.Info($"Kicking player with CMID {value.Member.PublicProfile.Cmid} cause of new login.");
                        break;
                    }
                }

                session = new Session
                {
                    AuthToken = authToken,
                    Member = member,
                    Ip = null,
                    Hwd = null
                };

                _sessions.Add(authToken, session);
            }

            // Save only profile since we only modified the profile.
            Db.Profiles.Save(member.PublicProfile);
            return session;
        }

19 Source : UserManager.cs
with MIT License
from FICTURE7

public bool LogOutUser(MemberView member)
        {
            foreach (var kv in _sessions)
            {
                var value = kv.Value;
                if (value.Member.PublicProfile.Cmid == member.PublicProfile.Cmid)
                {
                    /* Replace players with same CMID, not the neatest of fixes, but it works. */
                    _sessions.Remove(kv.Key);
                    Log.Info($"Player with CMID {value.Member.PublicProfile.Cmid} logged out.");
                     return true;
                }
            }

            return false;
        }

19 Source : WebServiceManager.cs
with MIT License
from FICTURE7

public void Start()
        {
            if (_started)
                throw new InvalidOperationException("Web services already started.");

            Log.Info("Binding contracts...");

            var sw = Stopwatch.StartNew();

            try
            {
                // Bind the services to the HTTP endpoint.
                Services.Bind(_binding);
            }
            catch (Exception ex)
            {
                Log.Fatal(ex);
                Log.Fatal("Unable to bind contracts to endpoint.");
                throw;
            }

            Log.Info("Opening services...");

            try
            {
                // Open services once we done binding them.
                Services.Open();
            }
            catch (Exception ex)
            {
                Log.Fatal(ex);
                Log.Fatal("Unable to open service hosts.");
                throw;
            }

            sw.Stop();
            Log.Info($"Done in {sw.Elapsed.TotalSeconds}s.");
            _started = true;
        }

See More Examples