public void SetUserInfo(UserInfo userInfo)
        {
            if (userInfo == null)
                this.userInfo = new UserInfo();
            else
                this.userInfo = userInfo;

            try
            {
                if (userInfo == null)
                {
                    if(File.Exists(configFilePath))
                        File.Delete(configFilePath);
                    return;
                }

                if (!Directory.Exists(configDirPath))
                    Directory.CreateDirectory(configDirPath);

                using (var fs = File.Create(configFilePath))
                {
                    xmlSerializer.Serialize(fs, userInfo);
                }
            }
            catch (Exception ex)
            {

            }
        }
        public ConfigWindow()
        {
            InitializeComponent();
            settingsRepository = SimpleIoc.Default.GetInstance<ISettingsRepository>();

            userInfo = settingsRepository.GetUserInfo();
            ServerUrl.Text = userInfo.ServerURL;
        }
Beispiel #3
0
 public void Login(UserInfo user)
 {
     ops_client = new OpsClient();
     ops_client.ErrorOccurred += OPSClientOnErrorOccurred;
     ops_client.PhoneBookItemsChanged += OnPhoneBookChanged;
     User = user;
     ops_client.LoginAsync(user.ServerAddress, user.Username, user.Password, OnLoginCompleted);
 }
        public SettingsRepository()
        {
            xmlSerializer = new XmlSerializer(typeof(UserInfo));
            var appPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

            configDirPath = Path.Combine(appPath, "Ozeki", "Call Assistant");
            configFilePath = Path.Combine(configDirPath, "settings.xml");

            LoadSettings();

            if (userInfo == null)
                userInfo = new UserInfo();
        }
        void LoadSettings()
        {
            try
            {
                if(!Directory.Exists(configDirPath))
                    return;

                if(!File.Exists(configFilePath))
                    return;

                using (var fs = File.OpenRead(configFilePath))
                {
                    userInfo = (UserInfo)xmlSerializer.Deserialize(fs);
                }
            }
            catch (Exception ex)
            {
                //TODO log4net log

            }
        }
Beispiel #6
0
        void OnLoginCompleted(bool success)
        {
            IsLoggedIn = success;

            if (success)
            {
                ops_client.SessionCreated += OPSClientOnSessionCreated;
                ops_client.SessionCompleted += OPSClientOnSessionCompleted;
            }
            else
            {
                User = null;
            }

            var handler = LoginCompleted;
            if (handler != null) handler(this, IsLoggedIn ? new VoIPEventArgs<LoginResult>(LoginResult.Success) : new VoIPEventArgs<LoginResult>(LoginResult.UsernameOrPassword));
        }