Example #1
0
 /// <summary>
 ///   Initializes a new instance of the Profile class based on another Profile object. </summary>
 /// <param name="profile">
 ///   The Profile object whose properties and events are used to initialize the object being constructed. </param>
 protected Profile(Profile profile)
 {
     m_name = profile.m_name;
     m_readOnly = profile.m_readOnly;
     Changing = profile.Changing;
     Changed = profile.Changed;
 }
 public AuthenticationService()
 {
     var settingsFile = Environment.GetEnvironmentVariable("WINDIR") + @"\PictoOn.ini";;
     _settings = new Ini(settingsFile);
 }
Example #3
0
        private void UpdateCategories(Profile profile, Language language)
        {
            if (language.IsTextless) {
                return;
            }

            var categories = this.categoryRepository.FindAll();
            profile.SetValue("Grupper", "Antal", categories.Count);

            foreach (var category in categories) {
                var translation = this.categoryTranslationService.Translate(category, language);

                // [Grupper]1=People
                safeWriteToProfile(profile, "Grupper", category.Index.ToString(), translation);

                safeWriteToProfile(profile, translation, "Antal", "0");
                safeWriteToProfile(profile, translation, "Kod", category.Code);
            }
        }
Example #4
0
        /// <summary>
        /// Writes a value only if a previous value does not already exist.
        /// </summary>
        private void safeWriteToProfile(Profile profile, string section, string entry, string value)
        {
            if (profile.HasEntry(section, entry)) {
                return;
            }

            profile.SetValue(section, entry, value);
        }
Example #5
0
        public static void Main(string[] args)
        {
            //this method is just for some tests
            //TestConnectionStability();
            //return;

            int cycle_cnt = 0;
            while (true)
            {
                cycle_cnt++;
                //Console.Clear();
                Console.WriteLine("Cycle: " + cycle_cnt);
                Thread.CurrentThread.Name = "Main";

                #region Settings
                string startupPath = Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);
                if (File.Exists(startupPath + "\\settings.ini"))
                    profile = new Ini(startupPath + "\\settings.ini");
                else
                {
                    logger.Trace("Did not find" + startupPath);

                }
                channel = (string)profile.GetValue("Main", "Channel");
                nick = (string)profile.GetValue("Main", "Nick");
                real = (string)profile.GetValue("Main", "Real");
                #endregion

                #region IRC Setup
                irc = new IrcClient();
                irc.SendDelay = 500;
                irc.ActiveChannelSyncing = true;
                irc.OnChannelMessage += new IrcEventHandler(OnChannelMessage);
                irc.OnQueryMessage += new IrcEventHandler(OnQueryMessage);
                irc.OnBan += new BanEventHandler(OnBanMessage);

                irc.OnError += new Meebey.SmartIrc4net.ErrorEventHandler(OnError);
                irc.OnPart += new PartEventHandler(irc_OnPart);
                irc.OnRawMessage += new IrcEventHandler(OnRawMessage);
                if (proactiveMode)
                {
                    timer = new System.Timers.Timer();
                    timer.Elapsed += new System.Timers.ElapsedEventHandler(autoAnswering);
                }
                #endregion

                sl = new SortedList();

                Console.WriteLine("**********************************************************");
                Console.WriteLine("These are my settings: ");
                Console.WriteLine("Trying to connect to " + serverlist[0] + " on port " + port + " - joining channel: " + channel);
                Console.WriteLine("My nickname is: " + nick + " and my real name is: " + real);
                Console.WriteLine("**********************************************************");
                try
                {
                    irc.AutoRetry = true;
                    irc.AutoReconnect = true;
                    irc.Connect(serverlist, port);
                }
                catch (ConnectionException e)
                {
                    logger.Trace("couldn't connect! Reason: " + e.Message);
                }

                try
                {
                    // here we logon and register our nickname and so on
                    irc.OnRawMessage += new IrcEventHandler(irc_OnRawMessage);
                    irc.Login(nick, real);

                    //load all channels
                    irc.RfcList("");

                    Dictionary<string, int> chann = new Dictionary<string, int>();

                    // join the channel
                    irc.RfcJoin(channel);
                    irc.OnChannelAction += new ActionEventHandler(irc_OnChannelAction);

                    #region Prelude Setup
                    //initialize interface
                    logger.Trace("Loading Prelude...");
                    pi = new PreLudeInterface();
                    //define path to mind file
                    pi.loadedMind = "mind.mdu";
                    pi.avoidLearnByRepeating = true;
                    pi.initializedAssociater = Mind.MatchingAlgorithm.Dice;
                    //start your engine ...
                    pi.initializeEngine();
                    logger.Trace("Prelude loaded and initialized...");
                    #endregion

                    // spawn a new thread to read the stdin of the console, this we use
                    // for reading IRC commands from the keyboard while the IRC connection
                    // stays in its own thread
                    new Thread(new ThreadStart(ReadCommands)).Start();
                    irc.Listen();
                    // when Listen() returns our IRC session is over, to be sure we call
                    // disconnect manually
                    irc.Disconnect();
                }
                catch (ConnectionException)
                {
                    logger.Trace("Connection exception");
                    pi.stopPreludeEngine();
                }
                catch (Exception e)
                {
                    logger.Trace("Error occurred! Message: " + e.Message);
                    logger.Trace("Exception: " + e.StackTrace);
                    pi.stopPreludeEngine();

                }

                logger.Trace("Going to sleep");
                System.Threading.Thread.Sleep(5 * 60000);
                logger.Trace("===========================================");
            }
        }
 public PictoOnIni()
 {
     this.settingsFile = new FileInfo(Environment.GetEnvironmentVariable("WINDIR") + @"\PictoOn.ini");
     this.ini = new Ini(settingsFile.FullName);
 }