Example #1
0
        public VPMobileSettings GetConfig(String session, string configName)//, ILog logFile)
        {
            const string LOCAL = _MOD + "AddConfig(string, ILog)";

            VPMobileSettings retVal = null;

            try
            {
                Logging.LogMessage(Logging.LogType.Info,
                                   string.Format("Session: {0} ", session) + string.Format(Constants.FMT_ENTERING, LOCAL) +
                                   string.Format("configName: {0}", configName));

                string path = ReturnPath(_CONFIGS, string.Format(_FMT_CONFIG, configName));

                //retVal = File.Exists(path) ? ConfigHandler.DeserializeConfig( logFile, path) : null;
                retVal = File.Exists(path) ? ConfigHandler.DeserializeConfig(path) : null;

                return(retVal);
            }
            catch (Exception ex)
            {
                Logging.LogMessage(Logging.LogType.Error,
                                   string.Format("Session: {0} ", session) + string.Format(Constants.FMT_ERROR_IN, LOCAL), ex);
                retVal = null;
            }
            return(retVal);
        }
Example #2
0
        public bool AddConfig(String session, VPMobileSettings config)//, ILog logFile)
        {
            const string LOCAL = _MOD + "AddConfig(VPMobileSettings, ILog)";

            bool retVal = false;

            try
            {
                Logging.LogMessage(Logging.LogType.Info,
                                   string.Format("Session: {0} ", session) + string.Format(Constants.FMT_ENTERING, LOCAL) +
                                   string.Format("config.Name: {0}", config.Name));

                string path = ReturnPath(_CONFIGS);

                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                path = Path.Combine(path, config.Name + ".config");
                using (FileStream fs = new FileStream(path, FileMode.CreateNew))
                {
                    XmlSerializer ser = new XmlSerializer(typeof(VPMobileSettings));
                    ser.Serialize(fs, config);
                }
                retVal = true;
            }
            catch (Exception ex)
            {
                Logging.LogMessage(Logging.LogType.Error,
                                   string.Format("Session: {0} ", session) + string.Format(Constants.FMT_ERROR_IN, LOCAL), ex);
                retVal = false;
            }
            return(retVal);
        }
        public EditConfigurationViewModel()
        {
            _mobileService = new VPMobileServiceClient();
            _mobileService.GetAllRoutingFileInfoCompleted += GetAllRoutingFileInfoCompleted;

            PropertyChanged       += OnPropertyChanged;
            _configuration         = new VPMobileSettings();
            _dispatchSettings      = new ObservableCollection <VPMobileDispatchSettings>();
            _visibleDispatchGroups = new ObservableCollection <Pair <bool, VPDispatchIncidentTypeSettings> >();
            _avlSettings           = new ObservableCollection <VPMobileAVLSettings>();
            _visibleAvlGroups      = new ObservableCollection <Pair <bool, VPAVLGroupInfo> >();
            _routingFiles          = new ObservableCollection <RoutingFileInfo>();
            _mobileService.UpdateConfigCompleted += UpdateConfigCompleted;
            _mobileService.AddConfigCompleted    += AddConfigCompleted;
            _vpService = new VPMServiceClient();
            _vpService.GetAvailableAvlSettingsCompleted      += GetAvailableAvlSettingsCompleted;
            _vpService.GetAvailableDispatchSettingsCompleted += GetAvailableDispatchSettingsCompleted;
        }