示例#1
0
            internal void Initialize(KeyValues props)
            {
                foreach (var pair in props)
                {
                    if (_properties.ContainsKey(pair.Key))
                    {
                        _properties[pair.Key] = pair.Value;
                    }
                    else
                    {
                        _properties.Add(pair.Key, pair.Value);
                    }
                }

                if (!_sPropertyActions.TryGetValue(GetType(), out var actions))
                {
                    return;
                }

                foreach (var pair in props)
                {
                    if (actions.TryGetValue(pair.Key, out var action))
                    {
                        action(this, pair.Value);
                    }
                }
            }
示例#2
0
        /// <summary>
        /// Asserts the validation.
        /// </summary>
        /// <param name="keys">The keys.</param>
        public void AssertValidation(params string[] keys)
        {
            var sb = new StringBuilder();

            foreach (var item in keys)
            {
                if (!KeyValues.ContainsKey(item))
                {
                    sb.AppendFormat("{0}, ", item);
                }
                else
                {
                    if (string.IsNullOrEmpty(KeyValues[item]))
                    {
                        sb.AppendFormat("No value for '{0}', which is required. ", item);
                    }
                }
                var result = sb.ToString();
                if (result.Length > 0)
                {
                    throw new InvalidDataException("Can't submit to Gateway - missing these input fields: " +
                                                   result.Trim().TrimEnd(','));
                }
            }
        }
示例#3
0
        public static string[] GetSteamLibraryDirectories()
        {
            var dir = GetSteamDirectory();

            if (dir != null)
            {
                var libraryfolders = Path.Combine(dir, "steamapps", "libraryfolders.vdf");
                if (File.Exists(libraryfolders))
                {
                    KeyValues kv = KVFile.ImportKeyValue(File.ReadAllText(libraryfolders), false);

                    int    i = 1;
                    object obj;
                    var    list = new List <string>();

                    list.Add(Path.GetFullPath(Path.Combine(dir, "steamapps")));
                    while ((obj = kv.Root.GetValue(i++.ToString())) != null)
                    {
                        list.Add(Path.GetFullPath(Path.Combine((string)obj, "steamapps")));
                    }

                    if (list.Count > 0)
                    {
                        return(list.ToArray());
                    }
                }
            }
            return(null);
        }
示例#4
0
        public override void Parse()
        {
            base.Parse();

            if (KeyValues.ContainsKey("pid") && KeyValues.ContainsKey("resp"))
            {
                //we parse profileid here
                int profileID;
                if (!int.TryParse(KeyValues["pid"], out profileID))
                {
                    throw new GSException("pid format is incorrect.");
                }
                ProfileId   = profileID;
                RequestType = AuthMethod.ProfileIDAuth;
            }
            else if (KeyValues.ContainsKey("authtoken") && KeyValues.ContainsKey("response"))
            {
                AuthToken   = KeyValues["authtoken"];
                Response    = KeyValues["response"];
                RequestType = AuthMethod.PartnerIDAuth;
            }
            else if (KeyValues.ContainsKey("keyhash") && KeyValues.ContainsKey("nick"))
            {
                RequestType = AuthMethod.CDkeyAuth;
                KeyHash     = KeyValues["keyhash"];
                Nick        = KeyValues["nick"];
            }
            else
            {
                throw new GSException("Unknown authp request method.");
            }
        }
示例#5
0
        /// <summary>
        /// 获取场景进入条件码
        /// </summary>
        /// <param name="scene"></param>
        /// <returns></returns>
        public int GetSceneEntranceCondition(string scene)
        {
            scene = scene.Split('&')[0]; //处理一些特殊格式的

            var gamemap = ConfigTable.Get <GameMap>(scene);

            if (gamemap != null)
            {
                //大地图
                if (gamemap.Tags == "WORLDMAP")
                {
                    return(0);
                }

                //已经有地图打开的纪录
                string key = "SceneEntraceCondition_" + gamemap.Jyx2MapId;
                if (KeyValues.ContainsKey(key))
                {
                    return(int.Parse(GetKeyValues(key)));
                }

                //否则取配置表初始值
                var map = ConfigTable.Get <Jyx2Map>(gamemap.Jyx2MapId);
                if (map != null)
                {
                    return(map.EnterCondition);
                }
            }

            return(-1);
        }
示例#6
0
        private void DemoKeyValueStore()
        {
            var newPerson = new Person(1, "First", "Person");

            "Saving new person: {0} - {1} {2}".ToInfo <RiakService>(newPerson.Id, newPerson.FirstName, newPerson.LastName);
            KeyValues.Persist(newPerson.Id.ToString(), newPerson);

            "Retrieving new person".ToInfo <RiakService>();
            var retrieved = KeyValues.Get <Person>("1");

            "Retrieved: {0} - {1} {2}".ToInfo <RiakService>(retrieved.Id, retrieved.FirstName, retrieved.LastName);

            var additional = new Person(2, "Second", "Person");

            "Adding another person: {0} - {1} {2}".ToInfo <RiakService>(additional.Id, additional.FirstName, additional.LastName);

            "Retrieving all people".ToInfo <RiakService>();
            var people = KeyValues.GetAll <Person>();

            "Retrieved {0} people.".ToInfo <RiakService>(people.Count());

            "Deleting people".ToInfo <RiakService>();
            KeyValues.Delete <Person>("1");
            KeyValues.Delete <Person>("2");
        }
示例#7
0
        public void AddChannel(MergedChannel mergedChannel, bool includeEncrypted)
        {
            foreach (TuningInfo tuningInfo in mergedChannel.TuningInfos)
            {
                // make sure it is DVBS
                if (!(tuningInfo is DvbTuningInfo dvbTuningInfo) || !dvbTuningInfo.TuningSpace.Equals("DVB-S"))
                {
                    continue;
                }
                var locator = dvbTuningInfo.TuneRequest.Locator as DVBSLocator;

                // filter on options
                if ((dvbTuningInfo.IsEncrypted || dvbTuningInfo.IsSuggestedBlocked) && !includeEncrypted)
                {
                    continue;
                }

                // determine satellite, transponder, and service for channel
                var satellite   = GetOrCreateSatellite(locator.OrbitalPosition);
                var transponder = satellite.GetOrCreateTransponder(dvbTuningInfo.Frequency / 1000,
                                                                   (int)locator.SignalPolarisation - 1, locator.SymbolRate / 1000, dvbTuningInfo.Onid,
                                                                   dvbTuningInfo.Tsid);
                var service = transponder.GetOrCreateService(mergedChannel.CallSign, dvbTuningInfo.Sid,
                                                             mergedChannel.Service.ServiceType == 2 ? 1 : mergedChannel.Service.ServiceType == 3 ? 2 : 0,
                                                             dvbTuningInfo.IsEncrypted || dvbTuningInfo.IsSuggestedBlocked);

                // add channel with callsign and channel number
                var keyValues = new KeyValues(WmcStore.WmcObjectStore);
                var region    = GetOrCreateRegion(keyValues.Single(arg => arg.Key == "ClientCountryCode").Value);
                var footprint = region.GetOrCreateFootprint(satellite);
                var headend   = footprint.GetOrCreateHeadend(satellite.PositionEast);
                headend.AddChannel(service, int.Parse(mergedChannel.ChannelNumber.ToString()));
                AddReferenceHeadend(headend);
            }
        }
        public bool Create(KeyValuesViewModel data, out string errMsg)
        {
            KeyValuesDAO keyValuesDAO = new KeyValuesDAO();

            errMsg = "";

            try
            {
                KeyValues modelData = new KeyValues();

                modelData.KeyValueName = data.KeyValueName;
                modelData.Text         = data.Text;
                modelData.Value        = data.Value;
                modelData.Sort         = data.Sort;
                modelData.EnterPriseId = data.EnterPriseId;

                keyValuesDAO.Insert(modelData);
                keyValuesDAO.SaveChange();
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
                return(false);
            }

            return(true);
        }
        /// <summary>
        ///     Generates the commands that correspond to this operation.
        /// </summary>
        /// <returns> The commands that correspond to this operation. </returns>
        public virtual IEnumerable <ModificationCommand> GenerateModificationCommands()
        {
            Debug.Assert(KeyColumns.Length == KeyValues.GetLength(1),
                         $"The number of key values doesn't match the number of keys (${KeyColumns.Length})");
            Debug.Assert(Columns.Length == Values.GetLength(1),
                         $"The number of values doesn't match the number of keys (${Columns.Length})");
            Debug.Assert(KeyValues.GetLength(0) == Values.GetLength(0),
                         $"The number of key values doesn't match the number of values (${KeyValues.GetLength(0)})");

            for (var i = 0; i < KeyValues.GetLength(0); i++)
            {
                var keys = new ColumnModification[KeyColumns.Length];
                for (var j = 0; j < KeyColumns.Length; j++)
                {
                    keys[j] = new ColumnModification(
                        KeyColumns[j], originalValue: null, value: KeyValues[i, j],
                        isRead: false, isWrite: false, isKey: true, isCondition: true);
                }

                var modifications = new ColumnModification[Columns.Length];
                for (var j = 0; j < Columns.Length; j++)
                {
                    modifications[j] = new ColumnModification(
                        Columns[j], originalValue: null, value: Values[i, j],
                        isRead: false, isWrite: true, isKey: true, isCondition: false);
                }

                yield return(new ModificationCommand(Table, Schema, keys.Concat(modifications).ToArray()));
            }
        }
示例#10
0
        /// <summary>
        /// 将为指定的 Key 清除。
        /// </summary>
        /// <param name="key">指定项的 Key。</param>
        protected override async Task RemoveValueCoreAsync(string key)
        {
            await LoadFromFileTask.ConfigureAwait(false);

            CT.Debug($"{key} = null", "Set");
            KeyValues.TryRemove(key, out _);
        }
        async Task LoadOrders(string value)
        {
            LoadingManager.OnLoading();
            Status _statusvalue = (Status)Enum.Parse(typeof(Status), value);

            var orderData = await orderDataStore.GetOrdersOfUserWithSpecificStatus(App.LogUser.UserId, _statusvalue, App.TokenDto.Token);


            KeyValues.Clear();

            KeyValues.Add("orderAdded", orderData);

            UserOrders.Clear();

            foreach (var item in orderData)
            {
                item.StoreOrder = await StoreDataStore.GetItemAsync(item.StoreId.ToString());

                var presenter = new OrderPresenter(item);

                UserOrders.Add(presenter);
            }

            LoadingManager.OffLoading();
        }
        public override void Parse()
        {
            base.Parse();
            if (!KeyValues.ContainsKey("sesskey"))
            {
                throw new GSException("sesskey is missing.");
            }
            int sessKey;

            if (!int.TryParse(KeyValues["sesskey"], out sessKey))
            {
                throw new GSException("sesskey is not a valid int.");
            }
            SessionKey = sessKey;
            if (!KeyValues.ContainsKey("connid"))
            {
                throw new GSException("connid is missing.");
            }
            int connectionID;

            if (!int.TryParse(KeyValues["connid"], out connectionID))
            {
                throw new GSException("connid format is incorrect.");
            }
            ConnectionID = connectionID;

            if (KeyValues.ContainsKey("challenge"))
            {
                IsClientLocalStorageAvailable = true;
                Challenge = KeyValues["challenge"];
            }
        }
示例#13
0
 private void SetPrettyName(KeyValues kv)
 {
     if (kv.Key == "Type")
     {
         kv.Name = "Typ";
     }
     else if (kv.Key == "ProviderName")
     {
         kv.Name = "Leverantörsnamn";
     }
     else if (kv.Key == "pType")
     {
         kv.Name = "P-Typ";
     }
     else if (kv.Key == "DeliveryLibrary")
     {
         kv.Name = "Ägandebibliotek";
     }
     else if (kv.Key == "HomeLibrary")
     {
         kv.Name = "Hembibliotek";
     }
     else if (kv.Key == "CancellationReason")
     {
         kv.Name = "Annulleringsorsak";
     }
     else if (kv.Key == "PurchasedMaterial")
     {
         kv.Name = "Inköpt Material";
     }
     else
     {
         kv.Name = kv.Key;
     }
 }
示例#14
0
        public VMTFile(Stream stream, String FileName = "")
        {
            this.FileName = FileName;
            if (stream == null)
            {
                MakeDefaultMaterial();
                return;
            }

            KeyValues = KeyValues.FromStream(stream);

            if (KeyValues.Keys.Count() > 0 && KeyValues != null)
            {
                ShaderType = KeyValues.Keys.First();

                //If shader is null, return
                if (string.IsNullOrEmpty(ShaderType))
                {
                    throw new FileLoadException(String.Format("Shader type is missing in material, skip parse", FileName));
                }
            }
            else
            {
                throw new FileLoadException(String.Format("is missing any KeyValues data, skip parse", FileName));
            }
        }
        public async Task <bool> CheckUpdate(Server server)
        {
            if (!server.Game.SteamID.HasValue)
            {
                throw new Exception("Server game with SteamCMD Handler has no SteamID assigned!");
            }

            uint appID = server.Game.SteamID.GetValueOrDefault();

            string appManifestFile = Path.Combine(server.Path, "SteamApps", string.Format(CultureInfo.InvariantCulture, "appmanifest_{0}.acf", appID));

            if (File.Exists(appManifestFile))
            {
                KeyValues manifestKv;
                using (Stream s = File.OpenRead(appManifestFile))
                {
                    manifestKv = new KeyValues(s);
                }

                Dictionary <string, object> appState = (Dictionary <string, object>)manifestKv.Items["AppState"];

                var serverData = await _steamAPIService.GetAppInfo(appID);

                if (appState["buildid"] != serverData.KeyValues["depots"]["branches"][server.Branch]["buildid"])
                {
                    return(true);
                }
            }

            return(false);
        }
        public override void Parse()
        {
            base.Parse();
            if (!KeyValues.ContainsKey("gamename"))
            {
                throw new GSException("gamename is missing.");
            }

            if (!KeyValues.ContainsKey("response"))
            {
                throw new GSException("response is missing.");
            }

            if (KeyValues.ContainsKey("port"))
            {
                int port;
                if (!int.TryParse(KeyValues["port"], out port))
                {
                    throw new GSException("port format is incorrect.");
                }
                Port = port;
            }

            GameName = KeyValues["gamename"];
        }
        /// <summary>
        /// Accept message from client.
        /// </summary>
        /// <param name="message">Request message.</param>
        public override void AcceptMessage(StreamMessage message)
        {
            base.AcceptMessage(message);

            if (XmlParseResult != ErrorCodes.ER_00_NO_ERROR)
            {
                return;
            }

            _dataLength = Convert.ToInt32(KeyValues.Item("Length"), 16);

            try
            {
                if (message.CharsLeft < _dataLength)
                {
                    XmlParseResult = ErrorCodes.ER_80_DATA_LENGTH_ERROR;
                }
                else if (message.CharsLeft > _dataLength)
                {
                    XmlParseResult = ErrorCodes.ER_15_INVALID_INPUT_DATA;
                }
                else
                {
                    _data = message.Substring(_dataLength);
                }
            }
            catch (Exception)
            {
                XmlParseResult = ErrorCodes.ER_80_DATA_LENGTH_ERROR;
            }
        }
示例#18
0
        public ActionResult GetAvailableValues(KeyValueRequest req)
        {
            var res = new KeyValueResult();

            res.KeyValues = new List <KeyValues>();

            try
            {
                var searcher       = ExamineManager.Instance.SearchProviderCollection["ChalmersILLOrderItemsSearcher"];
                var searchCriteria = searcher.CreateSearchCriteria(Examine.SearchCriteria.BooleanOperation.Or);
                var allOrders      = searcher.Search(searchCriteria.RawQuery("nodeTypeAlias:ChalmersILLOrderItem"));

                foreach (var k in req.Keys)
                {
                    var keyValues = new KeyValues();
                    keyValues.Key = k;
                    SetPrettyName(keyValues);
                    keyValues.AvailableValues = allOrders.Where(x => x.Fields.ContainsKey(k)).Select(x => x.Fields[k]).Distinct().OrderBy(x => x).ToList();
                    res.KeyValues.Add(keyValues);
                }

                res.Success = true;
                res.Message = "Successfully fetched available values for keys.";
            }
            catch (Exception e)
            {
                res.Success = false;
                res.Message = "Failed to fetch available values for keys: " + e.Message;
            }

            return(Json(res, JsonRequestBehavior.AllowGet));
        }
示例#19
0
        /// <summary>
        ///     Generates the commands that correspond to this operation.
        /// </summary>
        /// <returns> The commands that correspond to this operation. </returns>
        public virtual IEnumerable <ModificationCommand> GenerateModificationCommands([CanBeNull] IModel model)
        {
            Debug.Assert(KeyColumns.Length == KeyValues.GetLength(1),
                         $"The number of key values doesn't match the number of keys (${KeyColumns.Length})");
            Debug.Assert(Columns.Length == Values.GetLength(1),
                         $"The number of values doesn't match the number of keys (${Columns.Length})");
            Debug.Assert(KeyValues.GetLength(0) == Values.GetLength(0),
                         $"The number of key values doesn't match the number of values (${KeyValues.GetLength(0)})");

            var properties = model != null
                ? TableMapping.GetTableMapping(model, Table, Schema)?.GetPropertyMap()
                : null;

            for (var i = 0; i < KeyValues.GetLength(0); i++)
            {
                var keys = new ColumnModification[KeyColumns.Length];
                for (var j = 0; j < KeyColumns.Length; j++)
                {
                    keys[j] = new ColumnModification(
                        KeyColumns[j], originalValue: null, value: KeyValues[i, j], property: properties?.Find(KeyColumns[j]),
                        isRead: false, isWrite: false, isKey: true, isCondition: true);
                }

                var modifications = new ColumnModification[Columns.Length];
                for (var j = 0; j < Columns.Length; j++)
                {
                    modifications[j] = new ColumnModification(
                        Columns[j], originalValue: null, value: Values[i, j], property: properties?.Find(Columns[j]),
                        isRead: false, isWrite: true, isKey: true, isCondition: false);
                }

                yield return(new ModificationCommand(Table, Schema, keys.Concat(modifications).ToArray()));
            }
        }
示例#20
0
        void LoadManifest()
        {
            var configPath =
                InstallBase.GetChildDirectoryWithName("SteamApps").GetChildFileWithName("appmanifest_" + AppId + ".acf");

            AppManifest = new KeyValues(Tools.FileUtil.Ops.ReadTextFileWithRetry(configPath));
        }
示例#21
0
        public JsonNode ToJson()
        {
            var jps    = KeyValues.LookupToJsonValues();
            var jpAccs = Accounts.LookupToJson();

            jps.KeyValues["accounts"] = jpAccs;
            return(jps);
        }
示例#22
0
 public SteamHelper(KeyValues steamConfig, IAbsoluteDirectoryPath steamPath, bool cache = true) {
     _cache = cache;
     _appCache = new Dictionary<int, SteamApp>();
     KeyValues = steamConfig;
     _steamPath = steamPath;
     SteamFound = KeyValues != null || (_steamPath != null && _steamPath.Exists);
     _baseInstallPaths = GetBaseInstallFolderPaths();
 }
示例#23
0
        public TblAudit ToAudit()
        {
            var audit = new TblAudit
            {
                TableName = TableName,
                DateTime  = DateTime.UtcNow,
                Action    = Action,
                UserId    = UserId,
                KeyValues = KeyValues.First().Value.ToString(),
                OldValues = OldValues.Count == 0 ? null : JsonConvert.SerializeObject(OldValues),
                NewValues = NewValues.Count == 0 ? null : JsonConvert.SerializeObject(NewValues),
            };


            List <AuditDelta> DeltaList = new List <AuditDelta>();

            JObject sourceJObject = JsonConvert.DeserializeObject <JObject>(audit.OldValues);

            if (audit.Action == "Modified")
            {
                JObject targetJObject = JsonConvert.DeserializeObject <JObject>(audit.NewValues);

                foreach (KeyValuePair <string, JToken> sourceProperty in sourceJObject)
                {
                    JProperty targetProp = targetJObject.Property(sourceProperty.Key);

                    if (!JToken.DeepEquals(sourceProperty.Value, targetProp.Value))
                    {
                        AuditDelta delta = new AuditDelta
                        {
                            FieldName   = sourceProperty.Key,
                            ValueBefore = Convert.ToString(sourceProperty.Value),
                            ValueAfter  = Convert.ToString(targetProp.Value)
                        };
                        DeltaList.Add(delta);
                    }
                }
            }
            else
            {
                foreach (KeyValuePair <string, JToken> sourceProperty in sourceJObject)
                {
                    AuditDelta delta = new AuditDelta
                    {
                        FieldName   = sourceProperty.Key,
                        ValueBefore = Convert.ToString(sourceProperty.Value),
                        ValueAfter  = string.Empty
                    };
                    DeltaList.Add(delta);
                }
            }



            audit.Changes = JsonConvert.SerializeObject(DeltaList);

            return(audit);
        }
        public override void Parse()
        {
            base.Parse();


            if (KeyValues.ContainsKey("pid"))
            {
                int profileID;
                if (!int.TryParse(KeyValues["pid"], out profileID))
                {
                    throw new GSException("pid format is incorrect.");
                }
                ProfileId = profileID;
            }

            if (KeyValues.ContainsKey("ptype"))
            {
                PersistStorageType storageType;
                if (!Enum.TryParse(KeyValues["ptype"], out storageType))
                {
                    throw new GSException("ptype format is incorrect.");
                }
                StorageType = storageType;
            }


            if (KeyValues.ContainsKey("dindex"))
            {
                int dataIndex;
                if (!int.TryParse(KeyValues["dindex"], out dataIndex))
                {
                    throw new GSException("dindex format is incorrect.");
                }
                DataIndex = dataIndex;
            }

            if (!KeyValues.ContainsKey("keys"))
            {
                throw new GSException("keys is missing.");
            }

            string keys = KeyValues["keys"];

            if (keys == "")
            {
                GetAllDataFlag = true;
            }
            else
            {
                string[] keyArray = keys.Split('\x1');
                foreach (var key in keyArray)
                {
                    Keys.Add(key);
                }
                GetAllDataFlag = false;
            }
        }
        void ReadSteamConfig() {
            var steamPath = GetSteamPath();
            if (steamPath == null || !steamPath.Exists)
                return;

            var steamConfigPath = steamPath.GetChildDirectoryWithName("config").GetChildFileWithName("config.vdf");
            if (steamConfigPath.Exists)
                SteamConfig = new KeyValues(Tools.FileUtil.Ops.ReadTextFileWithRetry(steamConfigPath));
        }
示例#26
0
        public object GetOptional(string name)
        {
            if (!KeyValues.Contains(name))
            {
                return(null);
            }

            return(Get(name));
        }
示例#27
0
        public T GetOptional <T> (string name)
        {
            if (!KeyValues.Contains(name))
            {
                return(default(T));
            }

            return((T)Get(name));
        }
示例#28
0
        /// <summary>
        /// 获取指定 Key 的值,如果不存在,需要返回 null。
        /// </summary>
        /// <param name="key">指定项的 Key。</param>
        /// <returns>
        /// 执行项的 Key,如果不存在,则为 null / Task&lt;string&gt;.FromResult(null)"/>。
        /// </returns>
        protected override async Task <string?> ReadValueCoreAsync(string key)
        {
            await LoadFromFileTask.ConfigureAwait(false);

            var value = KeyValues.TryGetValue(key, out var v) ? v : null;

            CT.Debug($"{key} = {value ?? "null"}", "Get");
            return(value);
        }
示例#29
0
        public void SetValue(string key, string value)
        {
            if (KeyValues == null)
            {
                KeyValues = new KeyValuePair[0];
            }

            KeyValues.Append(new KeyValuePair(key, value));
        }
示例#30
0
 public SteamHelper(KeyValues steamConfig, IAbsoluteDirectoryPath steamPath, bool cache = true)
 {
     _cache            = cache;
     _appCache         = new Dictionary <int, SteamApp>();
     KeyValues         = steamConfig;
     _steamPath        = steamPath;
     SteamFound        = KeyValues != null || (_steamPath != null && _steamPath.Exists);
     _baseInstallPaths = GetBaseInstallFolderPaths();
 }
示例#31
0
        public void MultiRoot2()
        {
            var keyVals = KeyValues.ParseList(Properties.Resources.entities);

            foreach (var keyVal in keyVals)
            {
                Console.WriteLine((string)keyVal["classname"]);
            }
        }
        /// <summary>
        /// Accept message from client.
        /// </summary>
        /// <param name="message">Request message.</param>
        public override void AcceptMessage(StreamMessage message)
        {
            base.AcceptMessage(message);

            if (XmlParseResult == ErrorCodes.ER_00_NO_ERROR)
            {
                _delay = KeyValues.Item("Delay");
            }
        }
示例#33
0
        private static string GetGameName(KeyValues.KeyValues kv)
        {
            while (true)
            {
                var kvp =
                    kv.KeyNameValues.FirstOrDefault(
                        k => k.Key.Equals("name", StringComparison.InvariantCultureIgnoreCase));
                if (kvp != null)
                    return kvp.Value;

                var userConfigKv =
                    kv.KeyChilds.FirstOrDefault(
                        c => c.Name.Equals("UserConfig", StringComparison.InvariantCultureIgnoreCase));
                if (userConfigKv == null) return null;
                kv = userConfigKv;
            }
        }
示例#34
0
 void LoadManifest() {
     var configPath =
         InstallBase.GetChildDirectoryWithName("SteamApps").GetChildFileWithName("appmanifest_" + AppId + ".acf");
     AppManifest = new KeyValues(Tools.FileUtil.Ops.ReadTextFileWithRetry(configPath));
 }
示例#35
0
 public SteamApp(int appId, IAbsoluteDirectoryPath installBase, KeyValues appConfig) {
     AppId = appId;
     InstallBase = installBase;
     AppConfig = appConfig;
     if (installBase != null)
         LoadManifest();
     SetAppPath();
 }
示例#36
0
    /// <summary>
    /// Used to Export language xml files
    /// </summary>
    /// <param name="requestParam">source and target xml files name seperated with delemeter</param>
    /// <returns></returns>
    public string ExportLanguageXML(string requestParam)
    {
        string RetVal = string.Empty;
        string XMLFilesDir = string.Empty;
        string SrcLanguageName = string.Empty;
        string TrgLanguageName = string.Empty;
        string FileName = string.Empty;
        string SrcLngXML = string.Empty;
        string TrgLngXML = string.Empty;
        DataSet dsSrcLng = new DataSet();
        DataSet dsTrgLng = new DataSet();
        DataTable DtSrcLng = new DataTable();
        DataTable DtTrgLng = new DataTable();
        System.IO.FileStream SrcReadXml = null;
        System.IO.FileStream TrgReadXml = null;
        string OutputXmlFilePath = string.Empty;
        List<KeyValues> lstKeyValue = new List<KeyValues>();
        KeyValues KeyVal = null;
        ArrayList ALTargetKeys = new ArrayList();
        DataRow[] drArray;
        string[] Params;

        //Variables for creating XLS Logfile
        string XLSFileMsg = string.Empty;
        try
        {
            // Get Source Path of XML files
            XMLFilesDir = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.MasterKeyVals);
            OutputXmlFilePath = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.LanguageXMLFiles);

            Params = Global.SplitString(requestParam, Constants.Delimiters.ParamDelimiter);
            // Get source and target language xml file names from input param
            SrcLanguageName = Params[0].ToString();
            TrgLanguageName = Params[1].ToString();

            // Get Complete path of source language XML file
            SrcLngXML = XMLFilesDir + SrcLanguageName + ".XML";
            TrgLngXML = XMLFilesDir + TrgLanguageName + ".XML";
            FileName = SrcLanguageName.Split(new string[] { "[" }, StringSplitOptions.None)[0].ToString() + "- " + TrgLanguageName.Split(new string[] { " [" }, StringSplitOptions.None)[0].ToString();

            // Create new FileStream with which to read the schema.
            SrcReadXml = new FileStream(SrcLngXML, FileMode.Open);
            TrgReadXml = new FileStream(TrgLngXML, FileMode.Open);

            // Read language xml files as data set
            dsSrcLng.ReadXml(SrcReadXml);
            dsTrgLng.ReadXml(TrgReadXml);

            // Get data table from dataset
            DtSrcLng = dsSrcLng.Tables[0];
            DtTrgLng = dsTrgLng.Tables[0];
            foreach (DataRow row in DtSrcLng.Rows)
            {
                // List<KeyValues> listTest = new List<KeyValues>();
                drArray = null;
                KeyVal = new KeyValues();
                if (!ALTargetKeys.Contains(row["Key"].ToString().Trim()))
                {
                    ALTargetKeys.Add(row["Key"].ToString().Trim());
                    KeyVal.Key = row["Key"].ToString();
                    KeyVal.ValueSource = row["Value"].ToString();
                    drArray = DtTrgLng.Select("Key = '" + row["Key"].ToString() + "'");
                    if (drArray.Length > 0)
                    {
                        KeyVal.ValueTarget = drArray[0]["Value"].ToString();
                    }
                    lstKeyValue.Add(KeyVal);
                }
            }

            //foreach (DataRow row in DtTrgLng.Rows)
            //{
            //    if (!ALTargetKeys.Contains(row["Key"].ToString().ToUpper().Trim()))
            //    {
            //        KeyVal = new KeyValues();
            //        KeyVal.Key = row["Key"].ToString();
            //        KeyVal.ValueTarget = row["Value"].ToString();
            //        lstKeyValue.Add(KeyVal);
            //    }
            //}

            IWorksheet ExcelSheet = (IWorksheet)Factory.GetWorkbook().Sheets[0];   //(IWorksheet)ExcelWorkbook.Sheets[0];
            int RowIndex = 0;
            //Set the hidden fields for langaugue file names
            ExcelSheet.Cells[RowIndex, 1].Value = SrcLanguageName;
            ExcelSheet.Cells[RowIndex, 2].Value = TrgLanguageName;
            // hide first row as it consist of xml file names
            SpreadsheetGear.IRange Range = ExcelSheet.Range[0, 0, 0, 2];
            Range.RowHeight = 0.0;
            //Create Header row for XLS file
            RowIndex++;
            CreateHeader(ref ExcelSheet, RowIndex, FileName);
            foreach (KeyValues KeyValues in lstKeyValue)
            {
                RowIndex++;
                ExcelSheet.Cells[RowIndex, 0].Value = KeyValues.Key;
                ExcelSheet.Cells[RowIndex, 1].Value = KeyValues.ValueSource;
                ExcelSheet.Cells[RowIndex, 2].Value = KeyValues.ValueTarget;
                ExcelSheet.Cells[RowIndex, 0].Borders.Color = System.Drawing.Color.Black;
                ExcelSheet.Cells[RowIndex, 1].Borders.Color = System.Drawing.Color.Black;
                ExcelSheet.Cells[RowIndex, 2].Borders.Color = System.Drawing.Color.Black;
                if (KeyValues.Key.ToString() == "FILE_VERSION")
                {
                    SpreadsheetGear.IRange RngFileVersion = ExcelSheet.Range[RowIndex, 0, RowIndex + 1, 2];
                    RngFileVersion.NumberFormat = "0.0";
                }
            }

            // hide columns containing keys
            SpreadsheetGear.IRange Rng = ExcelSheet.Range[0, 0, RowIndex - 1, 0];
            Rng.ColumnWidth = 0.0;

            // Increase width of rows containing data values
            SpreadsheetGear.IRange RangeData = ExcelSheet.Range[0, 1, RowIndex - 1, 2];
            RangeData.ColumnWidth = 50.0;

            // hide first four rows
            SpreadsheetGear.IRange Rng1 = ExcelSheet.Range[2, 0, 6, 2];
            Rng1.RowHeight = 0.0;
            ExcelSheet.Name = FileName;
            ExcelSheet.SaveAs(OutputXmlFilePath + FileName + ".xls", SpreadsheetGear.FileFormat.Excel8);
            SrcReadXml.Close();
            TrgReadXml.Close();
            RetVal = "true" + Constants.Delimiters.ParamDelimiter + FileName;

            #region "Call method to write log in XLS file"
            if (RetVal.Contains("true"))
            {
                XLSFileMsg = string.Format(Constants.CSVLogMessage.ExportLanguage, SrcLanguageName, TrgLanguageName);
                WriteLogInXLSFile(Constants.AdminModules.LanguageSettings.ToString(), XLSFileMsg);
            }
            #endregion

        }
        catch (Exception ex)
        {
            RetVal = "false";
            Global.CreateExceptionString(ex, null);
        }
        finally
        {
            SrcReadXml.Dispose();
            TrgReadXml.Dispose();
        }
        return RetVal;
    }