public async Task SetValue(string id, Package <TValue>?value) { Dictionary <string, FileItemValue>?list = await ListLoader.GetData().ConfigureAwait(false); if (list == null) { return; } if (list.TryGetValue(id, out FileItemValue? item)) { await Set(item, value).ConfigureAwait(false); if (value == null) { _ = list.Remove(id); await ListLoader.Save(list).ConfigureAwait(false); } } else if (value != null) { FileItemValue nitem = new FileItemValue { FileName = id }; await Set(nitem, value).ConfigureAwait(false); list.Add(id, nitem); await ListLoader.Save(list).ConfigureAwait(false); } }
protected void LoadAllLists(ZipFile arc, Manifest manifest) { foreach (ZipEntry entry in arc) { if (entry.Name.StartsWith("abdata/list/characustom", StringComparison.OrdinalIgnoreCase) && entry.Name.EndsWith(".csv", StringComparison.OrdinalIgnoreCase)) { var stream = arc.GetInputStream(entry); var chaListData = ListLoader.LoadCSV(stream); SetPossessNew(chaListData); UniversalAutoResolver.GenerateResolutionInfo(manifest, chaListData); IndexList(manifest, chaListData); ListLoader.ExternalDataList.Add(chaListData); if (LoadedData.TryGetValue(manifest, out lists)) { lists.Add(chaListData); } else { LoadedData[manifest] = new List <ChaListData> { chaListData }; } } } }
protected void LoadAllLists(ZipFile arc, Manifest manifest) { List <ZipEntry> BoneList = new List <ZipEntry>(); foreach (ZipEntry entry in arc) { if (entry.Name.StartsWith("abdata/list/characustom", StringComparison.OrdinalIgnoreCase) && entry.Name.EndsWith(".csv", StringComparison.OrdinalIgnoreCase)) { try { var stream = arc.GetInputStream(entry); var chaListData = ListLoader.LoadCSV(stream); SetPossessNew(chaListData); UniversalAutoResolver.UniversalAutoResolver.GenerateResolutionInfo(manifest, chaListData, _gatheredResolutionInfos); ListLoader.ExternalDataList.Add(chaListData); } catch (Exception ex) { Logger.Log(LogLevel.Error, $"Failed to load list file \"{entry.Name}\" from archive \"{arc.Name}\" with error: {ex.Message}"); Logger.Log(LogLevel.Error, $"Error details: {ex}"); } } } }
private readonly bool _sortBySortOrder; // default by Title, set to true to use SortORder public LocalList(string listTitle, Func <ISharePointListItem, bool> predicate, bool sortBySortOrder = false) { _logger.Log("Initialise local list: " + listTitle, Type.Information); _predicate = predicate; _sortBySortOrder = sortBySortOrder; Title = listTitle; var listLoader = new ListLoader(); var listItems = new ListItems(); _spListItems = new List <ISharePointListItem>(); try { listItems = listLoader.GetItems(listTitle); _logger.Log($"Loaded {listItems.Count} list items for list {listTitle}", Type.Information); _spListItems = listItems .Select(x => new LocalListItem(x)) .Cast <ISharePointListItem>().ToList(); } catch (Exception ex) { _logger.Log(string.Format("List not loaded {0}, does the list exists and has items? Message: {1}", listTitle, ex.Message), Type.Warning); } }
protected void LoadAllLists(ZipFile arc) { foreach (ZipEntry entry in arc) { if (entry.Name.StartsWith("list/characustom") && entry.Name.EndsWith(".csv")) { var stream = arc.GetInputStream(entry); ListLoader.LoadCSV(stream); } } }
public async IAsyncEnumerable <Package <TValue>?> GetValues() { Dictionary <string, FileItemValue>?list = await ListLoader.GetData().ConfigureAwait(false); if (list != null) { foreach (FileItemValue v in list.Values) { yield return(await Load(v).ConfigureAwait(false)); } } }
public async IAsyncEnumerable <string> GetKeys() { Dictionary <string, FileItemValue>?list = await ListLoader.GetData().ConfigureAwait(false); if (list != null) { foreach (string v in list.Keys) { yield return(v); } } }
public void Deserialize(Dictionary <string, object> values) { Type type = GetType(); foreach (KeyValuePair <string, object> item in values) { PropertyInfo p = type.GetProperty(item.Key); if (p == null) { continue; } if (item.Value == null) { continue; } Type pt = p.PropertyType; if (pt.IsGenericType && pt.GetGenericTypeDefinition() == typeof(List <>)) { dynamic list = p.GetValue(this); if (list == null) { continue; } Type listItemType = pt.GetGenericArguments()[0]; foreach (object value in (System.Collections.IEnumerable)item.Value) { ListLoader listItem = Activator.CreateInstance(listItemType) as ListLoader; if (listItem == null) { continue; } list.Add((dynamic)listItem); listItem.Deserialize((Dictionary <string, object>)value); } } else { object value = item.Value; if (pt != value.GetType()) { value = Convert.ChangeType(value, pt); } p.SetValue(this, value); } } }
protected void LoadAllLists(ZipFile arc, Manifest manifest) { foreach (ZipEntry entry in arc) { if (entry.Name.StartsWith("abdata/list/characustom", StringComparison.OrdinalIgnoreCase) && entry.Name.EndsWith(".csv", StringComparison.OrdinalIgnoreCase)) { try { var stream = arc.GetInputStream(entry); var chaListData = ListLoader.LoadCSV(stream); SetPossessNew(chaListData); UniversalAutoResolver.GenerateResolutionInfo(manifest, chaListData); IndexList(manifest, chaListData); ListLoader.ExternalDataList.Add(chaListData); if (LoadedData.TryGetValue(manifest, out lists)) { lists.Add(chaListData); } else { LoadedData[manifest] = new List <ChaListData> { chaListData }; } } catch (SystemException ex) { Logger.Log(LogLevel.Error, $"[SIDELOADER] Failed to load list file \"{entry.Name}\" from archive \"{arc.Name}\" with error: {ex.Message}"); Logger.Log(LogLevel.Debug, $"[SIDELOADER] Error details: {ex}"); } } } }
protected void LoadAllLists(ZipFile arc, Manifest manifest) { List <ZipEntry> BoneList = new List <ZipEntry>(); foreach (ZipEntry entry in arc) { if (entry.Name.StartsWith("abdata/list/characustom", StringComparison.OrdinalIgnoreCase) && entry.Name.EndsWith(".csv", StringComparison.OrdinalIgnoreCase)) { try { var stream = arc.GetInputStream(entry); var chaListData = ListLoader.LoadCSV(stream); SetPossessNew(chaListData); UniversalAutoResolver.GenerateResolutionInfo(manifest, chaListData); ListLoader.ExternalDataList.Add(chaListData); } catch (Exception ex) { Logger.Log(LogLevel.Error, $"[SIDELOADER] Failed to load list file \"{entry.Name}\" from archive \"{arc.Name}\" with error: {ex.Message}"); Logger.Log(LogLevel.Error, $"[SIDELOADER] Error details: {ex}"); } } if (entry.Name.StartsWith("abdata/studio/info", StringComparison.OrdinalIgnoreCase) && entry.Name.EndsWith(".csv", StringComparison.OrdinalIgnoreCase)) { if (Path.GetFileNameWithoutExtension(entry.Name).ToLower().StartsWith("itembonelist_")) { BoneList.Add(entry); } else { try { var stream = arc.GetInputStream(entry); var studioListData = ListLoader.LoadStudioCSV(stream, entry.Name); UniversalAutoResolver.GenerateStudioResolutionInfo(manifest, studioListData); ListLoader.ExternalStudioDataList.Add(studioListData); } catch (Exception ex) { Logger.Log(LogLevel.Error, $"[SIDELOADER] Failed to load list file \"{entry.Name}\" from archive \"{arc.Name}\" with error: {ex.Message}"); Logger.Log(LogLevel.Error, $"[SIDELOADER] Error details: {ex}"); } } } } //ItemBoneList data must be resolved after the corresponding item so they can be resolved to the same ID foreach (ZipEntry entry in BoneList) { try { var stream = arc.GetInputStream(entry); var studioListData = ListLoader.LoadStudioCSV(stream, entry.Name); UniversalAutoResolver.GenerateStudioResolutionInfo(manifest, studioListData); ListLoader.ExternalStudioDataList.Add(studioListData); } catch (Exception ex) { Logger.Log(LogLevel.Error, $"[SIDELOADER] Failed to load list file \"{entry.Name}\" from archive \"{arc.Name}\" with error: {ex.Message}"); Logger.Log(LogLevel.Error, $"[SIDELOADER] Error details: {ex}"); } } }
protected void PopulaAbertura(Int32 Nro_Oportunidade) { #region "Definição de título" //**************** //* Define título //**************** if (Nro_Oportunidade == 0) { this.lblTitulo.Text = "CRIAÇÃO DE OPORTUNIDADE"; } else { this.lblTitulo.Text = "ALTERANDO DADOS DA OPORTUNIDADE Nº " + Nro_Oportunidade; } #endregion #region "Situação da oportunidade" //******************************************************** //* ABERTURA - Localiza combo da situação da oportunidade //******************************************************** ASPxFormLayout oFormLayoutComando = nvbEtapas.Groups[0].FindControl("layComando") as ASPxFormLayout; if (oFormLayoutComando != null) { //***************************** //* Localiza combo da situação //***************************** ASPxComboBox oComboSituacao = oFormLayoutComando.FindControl("cboSituacao") as ASPxComboBox; if (oComboSituacao != null) { //*************** //* Popula combo //*************** ListLoader.Popula_CBO_OrcamentoSituacao(oComboSituacao); } } #endregion #region "Etapa 1 (Abertura)" //***************************** //* ABERTURA - Localiza layout //***************************** ASPxFormLayout oFormLayoutAbertura = nvbEtapas.Groups[1].FindControl("layAbertura") as ASPxFormLayout; if (oFormLayoutAbertura != null) { //************************************* //* Localiza combo do canal de entrada //************************************* ASPxComboBox oComboCanalEntrada = oFormLayoutAbertura.FindControl("cboCanalEntrada") as ASPxComboBox; if (oComboCanalEntrada != null) { //*************** //* Popula combo //*************** ListLoader.Popula_CBO_CanalEntrada(oComboCanalEntrada); } //******************************* //* Localiza combo de atendentes //******************************* ASPxComboBox oComboAtendente = oFormLayoutAbertura.FindControl("cboAtendente") as ASPxComboBox; if (oComboAtendente != null) { //*************** //* Popula combo //*************** ListLoader.Popula_CBO_Atendentes(oComboAtendente, Session["Decision_LoginInfo"]); } } #endregion #region "Etapa 2 (Orçamento) //**************************************** //* ORÇAMENTO - Localiza layout de campos //**************************************** ASPxFormLayout oFormLayoutOrcamento0 = nvbEtapas.Groups[2].FindControl("layOrcamento0") as ASPxFormLayout; if (oFormLayoutOrcamento0 != null) { //***************************************** //* Localiza combo de estágio de orçamento //***************************************** ASPxComboBox oComboEstagioOrcamento = oFormLayoutOrcamento0.FindControl("cboEstagioOrcamento") as ASPxComboBox; if (oComboEstagioOrcamento != null) { //*************** //* Popula combo //*************** ListLoader.Popula_CBO_EstagioOrcamento(oComboEstagioOrcamento); } } #endregion }
public async Task <bool> HasKey(string id) { Dictionary <string, FileItemValue>?list = await ListLoader.GetData().ConfigureAwait(false); return(list == null ? false : list.ContainsKey(id)); }
public async Task <Package <TValue>?> GetValue(string id) { Dictionary <string, FileItemValue>?list = await ListLoader.GetData().ConfigureAwait(false); return(list == null ? null : (list.TryGetValue(id, out FileItemValue? item) ? await Load(item).ConfigureAwait(false) : null)); }
public override async Task Initialize() { await base.Initialize().ConfigureAwait(false); await ListLoader.Save(new Dictionary <string, FileItemValue>()).ConfigureAwait(false); }