Ejemplo n.º 1
0
 public void AddToList(FormControl formControl)
 {
     if (formControl != null && !Exists(formControl))
     {
         dictionaries.AddFormControl(formControl);
     }
 }
Ejemplo n.º 2
0
 public void UpdateInList(FormControl formControl)
 {
     if (formControl != null && Exists(formControl))
     {
         //  FormControls.Find(x => x.Id == formControl.Id).Name = formControl.Name;
         var trash = new FormControl();
         dictionaries.FormControls.TryRemove(formControl.UniqueID(), out trash);
         dictionaries.AddFormControl(formControl);
     }
 }
Ejemplo n.º 3
0
        public FormControl GetFormControl(int id)
        {
            FormControl formControl = null;

            Parallel.ForEach(dictionaries.FormControls, (fc) =>
            {
                if (id == fc.Value.Id)
                {
                    formControl = fc.Value;
                }
            });
            return(formControl);
        }
Ejemplo n.º 4
0
        public void LoadList()
        {
            if (ModuleConfig.StorageType == StorageType.MySql)
            {
                FormControl.CreateMySqlTableIfNotExists();
                var query = @"SELECT * FROM `tmodule_form_controls`";

                Task.Factory.StartNew(() =>
                {
                    return(Query.ExecuteMySql(query).Rows);
                }).ContinueWith((rows) =>
                {
                    Parallel.ForEach(rows.Result.Cast <DataRow>(), (row) =>
                    {
                        dictionaries.AddFormControl(new FormControl
                        {
                            Id           = row["id"].ToString().ToInt32(),
                            ParentFormID = row["parent_form_id"].ToString().ToInt32(),
                            Name         = row["name"].ToString(),
                            Type         = row["type"].ToString(),
                            OriginalText = row["original_text"].ToString()
                        });
                    });
                }).Wait();

                // foreach (DataRow row in Query.ExecuteMySql(query).Rows)
                // {
                //    FormControls.Add(new FormControl
                //    {
                //        Id = Convert.ToInt32(row["id"].ToString()),
                //        ParentFormID = Convert.ToInt32(row["parent_form_id"].ToString()),
                //        Name = row["name"].ToString(),
                //        Type = row["type"].ToString(),
                //        OriginalText = row["original_text"].ToString()
                //    });
                // }
            }

            IsLoaded = true;
        }
Ejemplo n.º 5
0
 public Translation GetTranslation(FormControl formControl, Language language)
 {
     return(dictionaries.GetTranslation(formControl, language));
 }
Ejemplo n.º 6
0
 public bool Exists(FormControl formControl)
 {
     return(dictionaries.FormControls.ContainsKey(formControl.UniqueID()));
 }