public DisplayLabel(ServerDbs dbSource, BaseDb db) : this() { _dbSource = dbSource; _db = db; _toString = dbSource.Filename; Content = dbSource.DisplayName; if (_db != null) { _db.Attached.CollectionChanged += delegate(object sender, NotifyCollectionChangedEventArgs e) { if (e.NewItems != null && e.NewItems.Count > 0 && e.Action == NotifyCollectionChangedAction.Replace || e.Action == NotifyCollectionChangedAction.Add) { if (e.NewItems[0] is KeyValuePair<string, object>) { var newItem = (KeyValuePair<string, object>) e.NewItems[0]; if (newItem.Key == "IsEnabled") { if (_db.Attached["IsEnabled"] == null || (bool) _db.Attached["IsEnabled"]) { _stateBrush = Brushes.Black; _stateInactiveBrush = new SolidColorBrush(Color.FromArgb(255, 98, 98, 98)); } else { _stateBrush = Brushes.Red; _stateInactiveBrush = Brushes.Red; } Grid presenter = WpfUtilities.FindParentControl<Grid>(this); TextBox box = (TextBox)presenter.Children[2]; if (box.Text == "Visible") { Foreground = _stateBrush; } else { Foreground = _stateInactiveBrush; } } } } }; } }
public GTabSettings(BaseDb db) : this(db.DbSource, db) { }
public GDbTab GenerateTab(SdeDatabase database, TabControl control, BaseDb baseDb) { return(GDbTabMaker(database, control, baseDb)); }
public void InitAttributes(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, GTabSettings <TKey, ReadableTuple <TKey> > settings, BaseDb gdb) { settings.AttributeList = gdb.AttributeList; settings.AttId = gdb.AttributeList.PrimaryAttribute; settings.AttDisplay = gdb.AttributeList.Attributes.FirstOrDefault(p => p.IsDisplayAttribute) ?? gdb.AttributeList.Attributes[1]; if (typeof(TKey) == typeof(string)) { settings.AttIdWidth = 120; } }
public static void CopyTuplesDefault(TabGenerator <TKey> tabGenerator, List <ReadableTuple <TKey> > items, BaseDb gdb) { int max = tabGenerator.MaxElementsToCopyInCustomMethods < 0 ? gdb.AttributeList.Attributes.Count - tabGenerator.StartIndexInCustomMethods : tabGenerator.MaxElementsToCopyInCustomMethods; StringBuilder builder = new StringBuilder(); List <int> toRemove = (from attribute in gdb.AttributeList.Attributes.OrderByDescending(p => p.Index) where attribute.IsSkippable && !_isAttributeEnabled(attribute, gdb) select attribute.Index).ToList(); for (int i = 0; i < items.Count; i++) { ReadableTuple <TKey> item = items[i]; List <string> objs = item.GetRawElements().Skip(tabGenerator.StartIndexInCustomMethods).Take(max).Select(p => (p ?? "").ToString()).ToList(); foreach (var index in toRemove) { if (index < objs.Count) { objs.RemoveAt(index); } } builder.AppendLine(string.Join(",", objs.ToArray())); } Clipboard.SetDataObject(builder.ToString()); }
private void _onPreviewTabInitialize(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, GTabSettings <TKey, ReadableTuple <TKey> > settings, BaseDb gdb) { }
private static bool _isAttributeEnabled(DbAttribute attribute, BaseDb gdb) { var attached = gdb.Attached[attribute.DisplayName]; return(attached == null || (bool)gdb.Attached[attribute.DisplayName]); }
public GDbTab GetTab(BaseDb db, TabControl control) { return db.IsGenerateTab ? db.GenerateTab(Database, control, db) : null; }
private void Page_Load(object sender, EventArgs e) { if (BaseDb.IsAnonymous(Page.User)) { throw new NeJudgeSecurityException("User, Administrator, Judge"); } if (!IsPostBack) { Page.Response.AddHeader("Refresh", "90"); ArrayList sids = new ArrayList(); int page = 0; #region параметры _rp = new RequirementsProcessor(this.GetType(), Context); _rp.ProcessRequirements(); if (Page.Request.QueryString["sname"] != null) { problem = Page.Request.QueryString["sname"]; } if (Page.Request.QueryString["result"] != null) { result = Page.Request.QueryString["result"]; } try { page = int.Parse(Page.Request.QueryString["page"]); } catch { page = 0; } using (BaseDb db = DbFactory.ConstructDatabase()) { if (_rp.UidDefined) { if (BaseDb.IsJudge(Page.User)) { filter.UserID = _rp.UserID; } else { throw new NeJudgeSecurityException("Judge"); } } if (_rp.TidDefined) { //filter.ContestID = _rp.ContestID; if (db.GetContest(_rp.ContestID).Future) { Hide("Невозможно просмотреть submissions будущего соревнования"); } else { int pid = -1; if (problem != "") { pid = db.GetPidByShortName(_rp.ContestID, problem); if (pid == -1) { throw new NeJudgeInvalidParametersException("sname"); } else { if (!Page.IsPostBack) { filter.ProblemID = problem[0]; } } } if (result != "") { try { Result r = (Result)Enum.Parse (typeof(Result), result); if (!Page.IsPostBack) { filter.Result = r; } } catch (ArgumentException) { throw new NeJudgeInvalidParametersException("result"); } } #endregion foreach (Submission s in db.GetSubmissions(_rp.ContestID, _rp.UidDefined ? _rp.UserID : 0, (problem == "") ? 0 : pid, result)) { sids.Add(s.SID); } if (sids.Count == 0) { //Hide("В этом соревновании нет ни одного submission"); } sids.Reverse(); statusGrid.VirtualItemCount = sids.Count; if (sids.Count - page * statusGrid.PageSize < 0) { page = sids.Count / statusGrid.PageSize; } statusGrid.CurrentPageIndex = page; ArrayList arr = new ArrayList(); int l; if (sids.Count - page * statusGrid.PageSize < statusGrid.PageSize) { l = sids.Count; } else { l = page * statusGrid.PageSize + statusGrid.PageSize; } for (int i = page * statusGrid.PageSize; i < l; i++) { arr.Add(sids[i]); } Bind(arr); HtmlFunctions.BeautifyDataGrid(statusGrid); } } else { Hide(null); } } } }
public VkDbService() { _dbContext = new BaseDb(); }
public bool Init(DbHolder holder) { try { if (!File.Exists(_file)) return false; string dbRawName = Path.GetFileNameWithoutExtension(_file); string dbName = _toDbName(dbRawName.Replace("_db", "")); string[] lines = File.ReadAllLines(_file); string[] itemsRaw = null; bool waitOne = false; foreach (string line in lines) { string t = line; string[] raw = t.Replace("[,", ",[").Replace("{,", ",{").Split(','); if (waitOne && raw.Length <= 1) break; if (waitOne) { raw[0] = raw[0].TrimStart('/', ' ', '\t'); itemsRaw = itemsRaw.Concat(raw).ToArray(); } else { itemsRaw = raw; } if (itemsRaw.Length > 1) { int end = itemsRaw.Length - 1; itemsRaw[end] = itemsRaw[end].Contains("//") ? itemsRaw[end].Substring(0, itemsRaw[end].IndexOf("//", StringComparison.Ordinal)) : itemsRaw[end]; waitOne = true; } } if (itemsRaw == null || itemsRaw.Length <= 1) return false; Dictionary<int, string> comments = new Dictionary<int, string>(); foreach (string line in lines) { if (!line.StartsWith("//")) break; string bufLine = line.Trim('/', ' '); if (bufLine.Length > 2 && bufLine[2] == '.') { int ival; if (Int32.TryParse(bufLine.Substring(0, 2), out ival)) { string t = bufLine.Substring(3).Trim(' ', '\t'); int index = t.LastIndexOf(" ", StringComparison.Ordinal); if (index > -1) { t = t.Substring(index); } else { index = t.LastIndexOf("\t\t", StringComparison.Ordinal); if (index > -1) { t = t.Substring(index); } } comments[ival] = t.Trim(' ', '\t'); } } } List<string> items = itemsRaw.ToList(); items[0] = items[0].TrimStart('/', ' '); items = items.ToList().Select(p => p.Trim(' ')).ToList(); HashSet<int> variable = new HashSet<int>(); if (items.Any(p => p == "...")) { // Find the longest line if (_hasLogic(items, variable)) { } else { int itemIndex = items.IndexOf("..."); List<int> count = lines.Select(line => line.Split(',').Length).ToList(); int missingArguments = count.Max(p => p) - items.Count; if (missingArguments == 0) { items[itemIndex] = "Unknown"; } else if (missingArguments < 0) { items.RemoveAt(itemIndex); } else { items.RemoveAt(itemIndex); for (int i = 0; i < missingArguments; i++) { items.Insert(itemIndex, "Variable"); variable.Add(itemIndex + i); } } } } if (items.Any(p => p.Contains('[')) || items.Any(p => p.Contains('{'))) { bool begin = false; for (int i = 0; i < items.Count; i++) { if (items[i].StartsWith("[") || items[i].StartsWith("{")) { if (items[i] != "{}") begin = true; } if (begin) { variable.Add(i); } if (items[i].EndsWith("]") || items[i].EndsWith("}")) { begin = false; } } } items = items.Select(p => p.Trim('[', ']', '{', '}')).ToList(); AttributeList list = new AttributeList(); IntLineStream reader = new IntLineStream(_file); Type dbType = typeof (int); bool? duplicates = reader.HasDuplicateIds(); if (duplicates == null || duplicates == true) { dbType = typeof (string); } bool first = true; DbAttribute bindingAttribute = null; for (int i = 0; i < items.Count; i++) { string value = items[i]; string desc = null; string toDisplay = _toDisplay(value); DbAttribute att; if (comments.ContainsKey(i + 1)) desc = comments[i + 1]; if (i == 0 && first) { if (duplicates == null) { att = new PrimaryAttribute(value, dbType, 0, toDisplay); } else if (duplicates == true) { att = new PrimaryAttribute("RealId", dbType, ""); first = false; i--; } else { att = new PrimaryAttribute(value, dbType, 0, toDisplay); } } else { string toLower = value.ToLower(); CustomAttribute custom = new CustomAttribute(value, typeof(string), "", toDisplay, desc); att = custom; if (toLower.Contains("skillid")) { att.AttachedObject = ServerDbs.Skills; custom.SetDataType(dbType == typeof(int) ? typeof(SelectTupleProperty<int>) : typeof(SelectTupleProperty<string>)); if (i == 1) bindingAttribute = new DbAttribute("Elements", typeof(SkillBinding), duplicates == true ? 2 : 1) { IsDisplayAttribute = true, Visibility = VisibleState.Hidden }; } if (toLower.Contains("mobid")) { att.AttachedObject = ServerDbs.Mobs; custom.SetDataType(dbType == typeof(int) ? typeof(SelectTupleProperty<int>) : typeof(SelectTupleProperty<string>)); if (i == 1) bindingAttribute = new DbAttribute("Elements", typeof(MobBinding), duplicates == true ? 2 : 1) { IsDisplayAttribute = true, Visibility = VisibleState.Hidden }; } if (toLower.Contains("itemid")) { att.AttachedObject = ServerDbs.Items; custom.SetDataType(dbType == typeof(int) ? typeof(SelectTupleProperty<int>) : typeof(SelectTupleProperty<string>)); if (i == 1) bindingAttribute = new DbAttribute("Elements", typeof(ItemBinding), duplicates == true ? 2 : 1) { IsDisplayAttribute = true, Visibility = VisibleState.Hidden }; } if (variable.Contains(i)) att.IsSkippable = true; } list.Add(att); } if (bindingAttribute != null) list.Add(bindingAttribute); else { string toLower = items[0].ToLower(); if (toLower.Contains("skillid")) { bindingAttribute = new DbAttribute("Elements", typeof(SkillBinding), duplicates == true ? 2 : 1) { IsDisplayAttribute = true, Visibility = VisibleState.Hidden }; } if (toLower.Contains("mobid")) { bindingAttribute = new DbAttribute("Elements", typeof(MobBinding), duplicates == true ? 2 : 1) { IsDisplayAttribute = true, Visibility = VisibleState.Hidden }; } if (toLower.Contains("itemid")) { bindingAttribute = new DbAttribute("Elements", typeof(ItemBinding), duplicates == true ? 2 : 1) { IsDisplayAttribute = true, Visibility = VisibleState.Hidden }; } if (bindingAttribute != null) list.Add(bindingAttribute); } if (dbType == typeof(int)) { _adb = new DummyDb<int>(); _adb.To<int>().TabGenerator.OnSetCustomCommands += GTabsMaker.SelectFromMobDb; _adb.To<int>().TabGenerator.OnSetCustomCommands += GTabsMaker.SelectFromItemDb; _adb.To<int>().TabGenerator.OnSetCustomCommands += GTabsMaker.SelectFromSkillDb; } else { _adb = new DummyDb<string>(); var db = _adb.To<string>(); if (duplicates == true) { db.LayoutIndexes = new int[] { 1, list.Attributes.Count }; db.DbLoader = DbLoaderMethods.DbUniqueLoader; db.DbWriter = DbWriterMethods.DbUniqueWriter; db.TabGenerator.OnInitSettings += delegate(GDbTabWrapper<string, ReadableTuple<string>> tab, GTabSettings<string, ReadableTuple<string>> settings, BaseDb gdb) { settings.CanChangeId = false; settings.CustomAddItemMethod = delegate { try { string id = Methods.RandomString(32); ReadableTuple<string> item = new ReadableTuple<string>(id, settings.AttributeList); item.Added = true; db.Table.Commands.StoreAndExecute(new AddTuple<string, ReadableTuple<string>>(id, item)); tab._listView.ScrollToCenterOfView(item); } catch (KeyInvalidException) { } catch (Exception err) { ErrorHandler.HandleException(err); } }; }; db.TabGenerator.StartIndexInCustomMethods = 1; db.TabGenerator.OnInitSettings += delegate(GDbTabWrapper<string, ReadableTuple<string>> tab, GTabSettings<string, ReadableTuple<string>> settings, BaseDb gdb) { settings.AttributeList = gdb.AttributeList; settings.AttId = gdb.AttributeList.Attributes[1]; settings.AttDisplay = gdb.AttributeList.Attributes.FirstOrDefault(p => p.IsDisplayAttribute) ?? gdb.AttributeList.Attributes[2]; settings.AttIdWidth = 60; }; db.TabGenerator.OnSetCustomCommands += GTabsMaker.SelectFromMobDbString; db.TabGenerator.OnSetCustomCommands += GTabsMaker.SelectFromSkillDbString; } else if (duplicates == null) { db.UnsafeContext = true; db.DbWriter = DbWriterMethods.DbStringCommaWriter; } } ServerDbs sdb = ServerDbs.Instantiate(dbRawName, dbName, FileType.Txt); if (bindingAttribute != null) bindingAttribute.AttachedObject = _adb; _adb.IsCustom = true; _adb.DbSource = sdb; _adb.AttributeList = list; return true; } catch { } return false; }
private void Button1_Click(object sender, EventArgs e) { int pid = selprob.PID; using (BaseDb db = DbFactory.ConstructDatabase()) { int tid = db.GetTid(pid); if (db.GetContest(tid).Now) { if (Page.IsValid) { string extension = ""; switch (languageDropDownList.SelectedValue) { case "Pascal": extension = "pas"; break; case "C++": extension = "cpp"; break; case "C": extension = "c"; break; default: extension = "cpp"; break; } string temp = Path.GetTempFileName(); if (sourceTextBox.Text.Trim() != "") { StreamWriter sw = null; try { sw = new StreamWriter(temp); sw.WriteLine(sourceTextBox.Text.Trim()); } finally { if (sw != null) { sw.Close(); } } } else { if (fileBrowser.PostedFile != null) { fileBrowser.PostedFile.SaveAs(temp); } } int uid = db.GetUid(Page.User.Identity.Name); //TODO Language l = (Language)Enum.Parse(typeof(Language), extension, true); Submission s = new Submission(pid, uid, tid, DateTime.Now, l); int sid = db.AddSubmission(s); if (Directory.Exists(Path.Combine(Config.SubmissionsDirectory, sid.ToString()))) { Directory.Delete(Path.Combine(Config.SubmissionsDirectory, sid.ToString())); } Directory.CreateDirectory(Path.Combine(Config.SubmissionsDirectory, sid.ToString())); File.Move(temp, Path.Combine(Path.Combine( Config.SubmissionsDirectory, sid.ToString()), "sln." + extension)); //TODO:переделать DfTest dt = new DfTest(pid.ToString(), sid.ToString(), l.ToString()); Thread t = new Thread(new ThreadStart(dt.CheckSolution)); Response.Redirect("~/status.aspx?tid=" + tid, false); t.Start(); } } else { throw new NeJudgeInvalidParametersException("pid"); //"Соревнование либо закончилась, либо ещё не начиналось."; } } }
public static string ToHerculesEntry(BaseDb db, int itemId) { var dbItems = db.GetMeta<int>(ServerDbs.Items); StringBuilder builder = new StringBuilder(); var tuple = dbItems.TryGetTuple(itemId); if (tuple != null) { builder.AppendLineUnix("{"); builder.AppendLineUnix("\tId: " + tuple.GetKey<int>().ToString(CultureInfo.InvariantCulture)); builder.AppendLineUnix("\tAegisName: \"" + tuple.GetValue<string>(ServerItemAttributes.AegisName) + "\""); builder.AppendLineUnix("\tName: \"" + tuple.GetValue<string>(ServerItemAttributes.Name) + "\""); builder.AppendLineUnix("\tType: " + tuple.GetValue<string>(ServerItemAttributes.Type)); _trySet(tuple, builder, ServerItemAttributes.Buy); _trySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.Sell, (tuple.GetValue<int>(ServerItemAttributes.Buy) / 2).ToString(CultureInfo.InvariantCulture)); _trySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.Weight, "0"); _trySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.Attack, "0"); _trySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.Matk, "0"); _trySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.Defense, "0"); _trySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.Range, "0"); _trySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.NumberOfSlots, "0"); _trySetIfDefaultEmptyAddHex(tuple, builder, ServerItemAttributes.ApplicableJob, ""); _trySetIfDefaultEmptyUpper(tuple, builder, ServerItemAttributes.Upper); _trySetGender(tuple, builder, ServerItemAttributes.Gender, "2"); _trySetIfDefaultLocation(tuple, builder, ServerItemAttributes.Location); _trySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.WeaponLevel, "0"); _trySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.EquipLevel, "0"); _trySetIfRefineable(tuple, builder, ServerItemAttributes.Refineable, true); _trySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.ClassNumber, "0"); _trySetIfDefaultBoolean(tuple, builder, ServerItemAttributes.BindOnEquip, false); _trySetIfDefaultBoolean(tuple, builder, ServerItemAttributes.BuyingStore, false); _trySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.Delay, "0"); var trade = tuple.GetRawValue(ServerItemAttributes.Trade.Index) as Trade; if (trade != null && trade.NeedPrinting()) builder.AppendLineUnix(trade.ToWriteString()); var nouse = tuple.GetRawValue(ServerItemAttributes.NoUse.Index) as NoUse; if (nouse != null && nouse.NeedPrinting()) builder.AppendLineUnix(nouse.ToWriteString()); _trySetIfDefaultEmptyBracket(tuple, builder, ServerItemAttributes.Stack, ""); _trySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.Sprite, "0"); _trySetIfDefaultEmptyScript(tuple, builder, ServerItemAttributes.Script, ""); _trySetIfDefaultEmptyScript(tuple, builder, ServerItemAttributes.OnEquipScript, ""); _trySetIfDefaultEmptyScript(tuple, builder, ServerItemAttributes.OnUnequipScript, ""); builder.Append("},"); } return builder.ToString(); }
public void RemoveTable(BaseDb db) { Database.AllTables.Remove(db.DbSource); _dbs.Remove(db); }
public bool Repair(BaseDb db) { return(true); }
private static void _guessAttributes(ICollection <string> elements, ICollection <DbAttribute> attributes, int numberOfAttributes, BaseDb db) { if (db.Attached["Scanned"] == null || (db.Attached["FromUserRawInput"] != null && (bool)db.Attached["FromUserRawInput"])) { if (attributes.Any(p => p.IsSkippable)) { attributes.Where(p => p.IsSkippable).ToList().ForEach(p => db.Attached[p.ToString()] = true); if (numberOfAttributes < 0) { // We have to detect how many attributes there are if (db.Attached["NumberOfAttributesToGuess"] != null) { numberOfAttributes = (int)db.Attached["NumberOfAttributesToGuess"]; } else { numberOfAttributes = attributes.Count(p => p.Visibility == VisibleState.Visible); } } while (elements.Count < numberOfAttributes && attributes.Any(p => p.IsSkippable)) { var attribute = attributes.First(p => p.IsSkippable); attributes.Remove(attribute); if (db.Attached["FromUserRawInput"] == null || !((bool)db.Attached["FromUserRawInput"])) { db.Attached[attribute.DisplayName] = false; } } } db.Attached["Scanned"] = true; db.Attached["FromUserRawInput"] = false; } }
public SalesAnalysisController(VkService vkService) { _dbContext = new BaseDb(); _vkService = vkService; }
public CohortAnalysisController() { _dbContext = new BaseDb(); _vkService = new VkService(); }
public static void TgOnTabVisualUpdate(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, GTabSettings <TKey, ReadableTuple <TKey> > settings, BaseDb gdb) { Exception exception = null; bool success = tab.Dispatch(delegate { try { UIElement content = (UIElement)tab.Content; // (UIElement)(tab.Content ?? ((Window)tab.AttachedProperty["AttachedWindow"]).Content); if (gdb.To <TKey>().TabGenerator == null || gdb.To <TKey>().TabGenerator.IsTabEnabledMethod == null) { content.IsEnabled = IsTabEnabled(settings, gdb); } else { content.IsEnabled = gdb.To <TKey>().TabGenerator.IsTabEnabledMethod(settings, gdb); } return(true); } catch (Exception err) { exception = err; return(false); } }); if (!success) { throw exception; } List <DbAttribute> attributes = settings.AttributeList.Attributes; if (gdb.LayoutIndexes != null) { foreach (var attribute in attributes) { if (attribute.IsSkippable) { bool isSet = _isAttributeEnabled(attribute, gdb); tab.Dispatch(delegate { var elements = DisplayablePropertyHelper.GetAll(tab.PropertiesGrid, attribute.DisplayName); foreach (var element in elements) { element.Visibility = isSet ? Visibility.Visible : Visibility.Collapsed; element.IsEnabled = isSet; } }); } } } }
public static void Writer2 <TKey>(ReadableTuple <TKey> item, ServerType destServer, StringBuilder builder, BaseDb db, List <string> aegisNames, List <string> names) { var itemCopy = new ReadableTuple <TKey>(item.GetKey <TKey>(), item.Attributes); itemCopy.Copy(item); item = itemCopy; int key = item.GetKey <int>(); if (destServer == ServerType.RAthena) { var itemDb = db.GetMeta <int>(ServerDbs.Items); ServerType source = DbPathLocator.GetServerType(); if (source == ServerType.Hercules) { List <string> constantsList = Constants.Keys.ToList(); Table <int, ReadableTuple <int> > table = db.GetMeta <int>(ServerDbs.Items); var tuple = item; var res2 = table.TryGetTuple(key); if (res2 != null) { string name = res2.GetValue(ServerItemAttributes.AegisName).ToString(); int low = Int32.MaxValue; int index = -1; for (int j = 0; j < Constants.Count; j++) { int dist = Methods.LevenshteinDistance(name, constantsList[j]); if (dist < low) { low = dist; index = j; } } string closestString = constantsList[index]; int groupId = Constants[closestString]; tuple.SetRawValue(0, groupId); } } Dictionary <int, ReadableTuple <int> > dico = (Dictionary <int, ReadableTuple <int> >)item.GetRawValue(1); key = item.GetKey <int>(); foreach (var pair in dico.OrderBy(p => p.Key)) { var dbTuple = itemDb.TryGetTuple(pair.Key); List <string> items = ServerItemGroupSubAttributes.AttributeList.Attributes.Select(p => pair.Value.GetValue <string>(p)).ToList(); RemoveDefaultValues(items); builder.AppendLine(key + "," + string.Join(",", items.ToArray()) + (dbTuple == null ? "" : "\t// " + dbTuple.GetValue(ServerItemAttributes.Name))); } builder.AppendLine(); } else if (destServer == ServerType.Hercules) { builder.AppendLine(ItemGroupParser.ToHerculesDbEntry(db, item.GetKey <int>(), aegisNames, names)); builder.AppendLine(); } }
private GDbTab _gDbTabMaker(SdeDatabase database, TabControl control, BaseDb gdb) { GTabSettings <TKey, ReadableTuple <TKey> > settings = new GTabSettings <TKey, ReadableTuple <TKey> >(gdb); GDbTabWrapper <TKey, ReadableTuple <TKey> > tab = new GDbTabWrapper <TKey, ReadableTuple <TKey> >(); Table <TKey, ReadableTuple <TKey> > table = gdb.To <TKey>().Table; settings.Table = table; settings.Control = control; Settings.Control = control; Settings.Gdb = gdb; Settings.Tab = tab; Settings.Table = table; Settings.Database = database; InitStyle(tab, settings, gdb); InitAttributes(tab, settings, gdb); if (OnInitSettings != null) { OnInitSettings(tab, settings, gdb); } DisplayableProperty <TKey, ReadableTuple <TKey> > generalProperties = new DisplayableProperty <TKey, ReadableTuple <TKey> >(); generalProperties.Spacing = DefaultSpacing; Settings.GeneralProperties = generalProperties; SdeEditor.Instance.SelectionChanged += new SdeEditor.SdeSelectionChangedEventHandler((sender, oldTab, newTab) => { try { TabItem item = newTab; if (gdb.DbSource.AlternativeName != null) { if (WpfUtilities.IsTab(item, gdb.DbSource.Filename) || WpfUtilities.IsTab(item, gdb.DbSource.AlternativeName)) { if (generalProperties.OnTabVisible != null) { generalProperties.OnTabVisible(this); } if (OnPreviewTabVisualUpdate != null) { OnPreviewTabVisualUpdate(tab, settings, gdb); } if (OnTabVisualUpdate != null) { OnTabVisualUpdate(tab, settings, gdb); } if (OnTabRefreshed != null) { OnTabRefreshed(Settings); } } } else { if (WpfUtilities.IsTab(item, gdb.DbSource)) { if (generalProperties.OnTabVisible != null) { generalProperties.OnTabVisible(this); } if (OnPreviewTabVisualUpdate != null) { OnPreviewTabVisualUpdate(tab, settings, gdb); } if (OnTabVisualUpdate != null) { OnTabVisualUpdate(tab, settings, gdb); } if (OnTabRefreshed != null) { OnTabRefreshed(Settings); } } } } catch (Exception err) { ErrorHandler.HandleException(err); } }); database.PreviewReloaded += delegate { if (OnPreviewDatabaseReloaded != null) { OnPreviewDatabaseReloaded(tab, settings, gdb); } }; database.Reloaded += delegate { //if (OnPreviewTabVisualUpdate != null) OnPreviewTabVisualUpdate(tab, settings, gdb); //if (OnTabVisualUpdate != null) OnTabVisualUpdate(tab, settings, gdb); DisplayablePropertyHelper.CheckAttributeRestrictions(tab, settings, gdb); if (OnDatabaseReloaded != null) { OnDatabaseReloaded(tab, settings, gdb); } if (OnTabRefreshed != null) { OnTabRefreshed(Settings); } }; int line = 0; if (OnPreviewGenerateGrid != null) { OnPreviewGenerateGrid(ref line, Settings); } if (GenerateGrid != null) { GenerateGrid(ref line, Settings); } if (OnGenerateGrid != null) { OnGenerateGrid(ref line, Settings); } settings.DisplayablePropertyMaker = generalProperties; settings.ClientDatabase = database; if (SetSettings != null) { SetSettings(tab, settings, gdb); } if (OnSetCustomCommands != null) { OnSetCustomCommands(tab, settings, gdb); } if (OnPreviewTabInitialize != null) { OnPreviewTabInitialize(tab, settings, gdb); } tab.Initialize(settings); if (OnAfterTabInitialize != null) { OnAfterTabInitialize(tab, settings, gdb); } return(tab); }
private void Page_Load(object sender, EventArgs e) { BaseDb db = DbFactory.ConstructDatabase(); if (db.CheckPid(pid)) { Problem p = db.GetProblem(pid); if (db.GetContest(p.TID).Future) { Hide("Соревнование, задачу с которого вы хотите просмотреть, ещё не началось. Попробуйте позже."); } else { nameLiteral.Text = "<h1> Задача " + p.ShortName + " ( #"+ pid + " ). "+ p.Name + "</h1>"; Limits l = DfTest.GetLimits(pid.ToString()); tlLiteral.Text += l.Time + " секунды"; mlLiteral.Text += l.Memory + " КБ"; olLiteral.Text += l.Output + " байт"; if (p.Text == "") { textLiteral.Visible = false; } else { textLiteral.Text += p.Text; } if (p.InputFormat == "") { infoLiteral.Visible = false; } else { infoLiteral.Text += p.InputFormat; } if (p.OutputFormat == "") { outfoLiteral.Visible = false; } else { outfoLiteral.Text += p.OutputFormat; } string str = ""; if (p.InputSample == "") { inexLiteral.Visible = false; } else { StringReader str_rdr = new StringReader(p.InputSample); while ((str = str_rdr.ReadLine()) != null) { inexLiteral.Text += str + "<br>"; } inexLiteral.Text += "</code>"; } if (p.OutputSample == "") { outexLiteral.Visible = false; } else { StringReader str_rdr2 = new StringReader(p.OutputSample); while ((str = str_rdr2.ReadLine()) != null) { outexLiteral.Text += str + "<br>"; } outexLiteral.Text += "</code>"; } if (p.Author == "") { authorLiteral.Visible = false; } else { authorLiteral.Text += p.Author; authorLiteral.Text += "<hr>"; } } } else { throw new NeJudgeInvalidParametersException("pid"); } db.Close(); }
private void _onSetCustomCommands(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, GTabSettings <TKey, ReadableTuple <TKey> > settings, BaseDb gdb) { int max = MaxElementsToCopyInCustomMethods < 0 ? settings.AttributeList.Attributes.Count - StartIndexInCustomMethods : MaxElementsToCopyInCustomMethods; settings.AddedCommands.Add(new GItemCommand <TKey, ReadableTuple <TKey> > { AllowMultipleSelection = true, DisplayName = "Copy entries to clipboard", ImagePath = "export.png", InsertIndex = 3, AddToCommandsStack = false, Shortcut = ApplicationShortcut.Copy, GenericCommand = delegate(List <ReadableTuple <TKey> > items) { StringBuilder builder = new StringBuilder(); List <int> toRemove = (from attribute in gdb.AttributeList.Attributes.OrderByDescending(p => p.Index) where attribute.IsSkippable && !_isAttributeEnabled(attribute, gdb) select attribute.Index).ToList(); for (int i = 0; i < items.Count; i++) { ReadableTuple <TKey> item = items[i]; List <string> objs = item.GetRawElements().Skip(StartIndexInCustomMethods).Take(max).Select(p => (p ?? "").ToString()).ToList(); foreach (var index in toRemove) { objs.RemoveAt(index); } builder.AppendLine(string.Join(",", objs.ToArray())); } Clipboard.SetDataObject(builder.ToString()); } }); }
public override IDataProvider GetData(string Code, int Count) { try { CommonDataProvider cdp = new CommonDataProvider(this); DbParam[] dps = new DbParam[] { new DbParam("@Symbol", DbType.String, Code), new DbParam("@Q1", DbType.DateTime, StartTime), new DbParam("@Q2", DbType.DateTime, EndTime), }; BaseDb bd = DB.Open(false); try { DataTable dt = bd.GetDataTable("select Price,Volume,QuoteTime from Intraday where Symbol=? and QuoteTime>=? and QuoteTime<=? order by QuoteTime", dps); double LastV = -1; foreach (DataRow dr in dt.Rows) { double NowV = (double)dr["Volume"]; if (LastV >= 0) { if (NowV > LastV) { dr["Volume"] = NowV - LastV; } else { dr["Volume"] = (double)0; } } LastV = NowV; } dps[2].Value = ((DateTime)dps[1].Value).AddSeconds(-1); dps[1].Value = ((DateTime)dps[1].Value).AddDays(-30); DataRow drr = bd.GetFirstRow("select Price from Intraday where Symbol=? and QuoteTime>=? and QuoteTime<=? order by QuoteTime desc", dps); if (dt.Rows.Count > 0) { cdp.SetStringData("LastTradeTime", ((DateTime)dt.Rows[dt.Rows.Count - 1]["QuoteTime"]).ToString()); } if (drr != null) { cdp.SetStringData("LastPrice", drr[0].ToString()); } SetStrings(cdp, Code); if (dt.Rows.Count == 0) { dt.Rows.Add(new object[] { double.NaN, 0, StartTime }); } double[] CLOSE = new double[dt.Rows.Count]; double[] VOLUME = new double[dt.Rows.Count]; double[] DATE = new double[dt.Rows.Count]; for (int i = 0; i < dt.Rows.Count; i++) { CLOSE[i] = ToDouble(dt.Rows[i]["Price"]); VOLUME[i] = ToDouble(dt.Rows[i]["Volume"]); DATE[i] = ((DateTime)dt.Rows[i]["QuoteTime"]).ToOADate(); } cdp.LoadBinary("CLOSE", CLOSE); cdp.LoadBinary("DATE", DATE); cdp.LoadBinary("VOLUME", VOLUME); } finally { bd.Close(); } return(cdp); } catch { } return(base.GetData(Code, Count)); }
private void _setSettings(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, GTabSettings <TKey, ReadableTuple <TKey> > settings, BaseDb gdb) { List <DbAttribute> attributes; if (gdb.LayoutSearch != null) { attributes = gdb.LayoutSearch.ToList(); } else { attributes = new DbAttribute[] { settings.AttId, settings.AttDisplay }.Concat(gdb.AttributeList.Attributes.Skip(1).Where(p => p.IsSearchable != null && p != settings.AttId && p != settings.AttDisplay)).ToList(); } if (attributes.Count % 2 != 0) { attributes.Add(null); } settings.SearchEngine.SetAttributes(attributes); settings.SearchEngine.SetSettings(settings.AttId, true); settings.SearchEngine.SetSettings(settings.AttDisplay, true); foreach (DbAttribute attribute in attributes) { if (attribute != null && attribute.IsSearchable == true) { settings.SearchEngine.SetSettings(attribute, true); } } }
public static void CheckAttributeRestrictions <TKey>(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, GTabSettings <TKey, ReadableTuple <TKey> > settings, BaseDb gdb) { foreach (var attributeS in settings.AttributeList.Attributes) { DbAttribute attribute = attributeS; if (attribute.Requirements.Renewal == RenewalType.Both && attribute.Requirements.Server == ServerType.Both) { continue; } tab.PropertiesGrid.Dispatch(delegate { var gridAttributes = GetAll(tab.PropertiesGrid, attribute); RenewalType rType = DbPathLocator.GetIsRenewal() ? RenewalType.Renewal : RenewalType.PreRenewal; ServerType sType = DbPathLocator.GetServerType(); gridAttributes.ForEach(p => p.IsEnabled = false); if ((attribute.Requirements.Renewal & rType) == rType && (attribute.Requirements.Server & sType) == sType) { gridAttributes.ForEach(p => p.IsEnabled = true); } else { gridAttributes.ForEach(p => p.IsEnabled = false); } }); } }
public void InitStyle(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, GTabSettings <TKey, ReadableTuple <TKey> > settings, BaseDb gdb) { GTabsMaker.SInit(tab, settings, gdb); }
public MemologyController(BaseDb baseDb, VkService vkService) { _dbContext = baseDb; _vkService = vkService; }
static public void PreScan(object Sender) { Tools.Log("Prescan starting"); if (StartTime > DateTime.MinValue) { return; } StartTime = DateTime.Now; try { string[] PreExchange = Config.PreScanExchange.Split(';'); for (int i = 0; i < PreExchange.Length; i++) { PreExchange[i] = Utils.GetPart1(PreExchange[i]); } string[] PreScan = Config.PreScan.Split(';'); Hashtable htConditionIdMap = new Hashtable(); DbParam[] dpPreScan = new DbParam[] { new DbParam("@Condition", DbType.String, ""), new DbParam("@Exchange", DbType.String, ""), new DbParam("@StartTime", DbType.DateTime, DateTime.Now), new DbParam("@ScanType", DbType.Int32, 1), }; // Insert pre-defined scan to condition // Get condition id . BaseDb bd = DB.Open(false); try { string s = bd.GetCommaValues("select ConditionId from Condition " + GetWhere("EndTime"), ""); if (s != "") { bd.DoCommand("delete from ScanedQuote where ConditionId in (" + s + ")"); bd.DoCommand("delete from Condition " + GetWhere("EndTime")); } Tools.Log("PreScan=" + PreScan.Length + ";PreExchange=" + PreExchange.Length); for (int i = 0; i < PreScan.Length; i++) { for (int j = 0; j < PreExchange.Length; j++) { dpPreScan[0].Value = Utils.GetName(PreScan[i]); dpPreScan[1].Value = PreExchange[j]; dpPreScan[3].Value = Utils.GetParam(PreScan[i], "1"); bd.DoCommand("insert into Condition (Condition,Exchange,StartTime,Scaned,ScanType) values (?,?,?,0,?)", dpPreScan); } } DataTable dtPreScan = bd.GetDataTable("select ConditionId,Condition,Exchange from Condition " + GetWhere("StartTime"), null, PreScan.Length * PreExchange.Length); foreach (DataRow dr in dtPreScan.Rows) { htConditionIdMap[dr["Condition"].ToString().Trim() + dr["Exchange"].ToString().Trim()] = dr["ConditionId"].ToString(); } } finally { bd.Close(); } Tools.Log("Get scan formulas"); // Get scan formulas FormulaBase[] fbs = new FormulaBase[PreScan.Length]; int[] Ns = new int[PreScan.Length]; int N = 0; for (int i = 0; i < fbs.Length; i++) { fbs[i] = FormulaBase.GetFormulaByName("Scan." + Utils.GetValue(PreScan[i])); Tools.Log(fbs[i].FullName); if (fbs[i] != null) { Ns[i] = fbs[i].DataCountAtLeast(); N = Math.Max(N, Ns[i]); } } if (Config.PrescanLoadToMemory) { N = Config.MaxDataForPull; } Tools.Log("Pre-Scan- N = " + N); DataManagerBase dmb = Utils.GetDataManager(Config.DefaultDataManager); DataTable dt = dmb.GetStockList(); if (dt == null) { return; } Tools.Log(dt.Rows.Count.ToString()); // Scan int Progress = 0; Hashtable htTotal = new Hashtable(); Hashtable htResultCount = new Hashtable(); ArrayList al = new ArrayList(); try { foreach (DataRow dr in dt.Rows) { try { string Symbol = dr[0].ToString(); IDataProvider idp = GetDataProvider(dmb, Symbol, N); if (!Utils.VerifyVolumeAndDate(idp)) { continue; } string NowExchange = dr["Exchange"].ToString(); foreach (string s in PreExchange) { if (s.Length <= NowExchange.Length) { if (string.Compare(s, NowExchange.Substring(0, s.Length), true) == 0) { NowExchange = s; break; } } } for (int j = 0; j < fbs.Length; j++) { try { if (fbs[j] != null) { idp.MaxCount = Ns[j]; FormulaPackage fp = fbs[j].Run(idp); string ConditionId = (string)htConditionIdMap[Utils.GetName(PreScan[j]) + NowExchange]; if (ConditionId != null) { FormulaData fd = fp[fp.Count - 1]; if (fd.Length > 0) { if (fd.LASTDATA > 0) { al.Add(ConditionId + "," + Symbol); htResultCount[ConditionId] = Utils.ObjPlusDef(htResultCount[ConditionId], 1); } } htTotal[ConditionId] = Utils.ObjPlusDef(htTotal[ConditionId], 1); } Progress++; if ((Progress % 10) == 0) { HttpRuntime.Cache["PreScan"] = Progress; } } } catch (Exception e) { Tools.Log(Symbol + "/" + fbs[j] + "/" + e); } } Thread.Sleep(1); } catch (Exception e) { Tools.Log("Pre-scan symbol loop:" + e.Message); } } } finally { Utils.BulkInsert(al); } // Update pre-scan conditions dpPreScan = new DbParam[] { new DbParam("@Scaned", DbType.Int32, 0), new DbParam("@Total", DbType.Int32, 0), new DbParam("@ResultCount", DbType.Int32, 0), new DbParam("@EndTime", DbType.DateTime, DateTime.Now), }; bd = DB.Open(false); try { for (int i = 0; i < PreScan.Length; i++) { for (int j = 0; j < PreExchange.Length; j++) { string ConditionId = (string)htConditionIdMap[Utils.GetName(PreScan[i]) + PreExchange[j]]; dpPreScan[0].Value = Utils.ObjDef(htTotal[ConditionId], 0); dpPreScan[1].Value = Utils.ObjDef(htTotal[ConditionId], 0); dpPreScan[2].Value = Utils.ObjDef(htResultCount[ConditionId], 0); bd.DoCommand("update Condition set Scaned=?,Total=?,ResultCount=?,EndTime=? where ConditionId=" + ConditionId, dpPreScan); } } } finally { bd.Close(); } } catch (Exception e) { Tools.Log("Update pre-scan service:" + e.Message); } finally { StartTime = DateTime.MinValue; } }
internal QuerySql(BaseDb db, DbSqlCommand customSqlCommand) { this.customSqlCommand = customSqlCommand; Db = db; }
public bool Show(BaseDb db) { return(true); }
internal QuerySql(BaseDb Db, string sql, IReadOnlyList <object> parameters) { sqlString = sql.Trim('\n', '\r', ' ', '\t'); this.Db = Db; this.parameters = parameters; }
/// <summary> /// Converts a group from an ItemGroup to a Hercules entry /// </summary> /// <param name="gdb">The base db.</param> /// <param name="groupId">The group id.</param> /// <param name="aegisNames">The aegis names.</param> /// <param name="names">The names.</param> /// <returns>A string for an ItemGroup entry converted to Hercules's format</returns> public static string ToHerculesDbEntry(BaseDb gdb, int groupId, List <string> aegisNames, List <string> names) { StringBuilder builder = new StringBuilder(); var dbItems = gdb.GetMeta <int>(ServerDbs.Items); var dbGroups = gdb.Get <int>(ServerDbs.ItemGroups); if (groupId < 500) { var dbConstants = gdb.Get <string>(ServerDbs.Constants); string sId = groupId.ToString(CultureInfo.InvariantCulture); // The current db is from rAthena var tuple = dbConstants.FastItems.FirstOrDefault(p => p.GetValue <string>(1) == sId && p.GetKey <string>().StartsWith("IG_")); string constant = null; if (tuple != null) { constant = tuple.GetKey <string>().Substring(3); } else { var res = DbIOItemGroups.Constants.Where(p => p.Value == groupId).ToList(); if (res.Count > 0) { constant = res[0].Key; } } if (constant != null) { string originalConstantValue = constant; ReadableTuple <int> tupleItem; // Attempts to retrieve the item based on the script tupleItem = dbItems.FastItems.FirstOrDefault(p => p.GetValue <string>(ServerItemAttributes.Script).IndexOf("getrandgroupitem(IG_" + originalConstantValue + ")", StringComparison.OrdinalIgnoreCase) > -1); if (tupleItem == null) { // Attempts to retrieve the item based on a formatted constant name (with underscore) StringBuilder temp = new StringBuilder(); temp.Append(constant[0]); for (int i = 1; i < constant.Length; i++) { if (constant[i] == '_') { i++; if (i < constant.Length) { temp.Append(constant[i]); } } else if (char.IsUpper(constant[i])) { temp.Append('_'); temp.Append(constant[i]); } else { temp.Append(constant[i]); } } constant = temp.ToString(); // Attempts to retrieve the item with the Old prefix string oldConstant = "Old_" + constant; // Attempts to retrieve the item without the Old prefix tupleItem = dbItems.FastItems.FirstOrDefault(p => p.GetStringValue(ServerItemAttributes.AegisName.Index) == oldConstant); if (tupleItem == null) { tupleItem = dbItems.FastItems.FirstOrDefault(p => p.GetStringValue(ServerItemAttributes.AegisName.Index) == constant); } } // Retrieve the closest item based on the names in the ItemDb. // It uses the Levenshtein distance algorithm to find the clostest match. // This method 'always' returns a value, but a warning is prompted to the user in the error console. if (tupleItem == null) { List <string> values1 = aegisNames; List <string> values2 = names; string closestMatch1 = Methods.ClosestString(originalConstantValue, values1); string closestMatch2 = Methods.ClosestString(originalConstantValue, values2); int lev1 = Methods.LevenshteinDistance(originalConstantValue, closestMatch1); int lev2 = Methods.LevenshteinDistance(originalConstantValue, closestMatch2); tupleItem = dbItems.FastItems[lev1 < lev2 ? values1.IndexOf(closestMatch1) : values2.IndexOf(closestMatch2)]; string closestMatch = tupleItem.GetValue <string>(ServerItemAttributes.AegisName); if (Math.Min(lev1, lev2) != 0 && closestMatch.Replace("_", "") != constant) { DbIOErrorHandler.Handle(StackTraceException.GetStrackTraceException(), "A suspicious conversion occurred for the item [" + originalConstantValue + "]. The group item name is [" + tupleItem.GetValue <string>(ServerItemAttributes.AegisName) + "]."); } } builder.AppendLine(tupleItem.GetValue <string>(ServerItemAttributes.AegisName) + ": ("); Dictionary <int, ReadableTuple <int> > table = (Dictionary <int, ReadableTuple <int> >)dbGroups.GetTuple(groupId).GetRawValue(ServerItemGroupAttributes.Table.Index); foreach (var pair in table) { tupleItem = dbItems.TryGetTuple(pair.Key); string name = tupleItem == null ? "ID" + pair.Key : tupleItem.GetValue <string>(ServerItemAttributes.AegisName); if (pair.Value.GetValue <string>(ServerItemGroupSubAttributes.Rate) == "1") { builder.Append("\t\""); builder.Append(name); builder.AppendLine("\","); } else { builder.Append("\t(\""); builder.Append(name); builder.Append("\","); builder.Append(pair.Value.GetValue <string>(ServerItemGroupSubAttributes.Rate)); builder.AppendLine("),"); } } builder.Append(")"); } else { DbIOErrorHandler.Handle(StackTraceException.GetStrackTraceException(), "Failed to find the constant name with the id [" + sId + "]."); } } else { // The current db is from Hercules var tuple = dbItems.TryGetTuple(groupId); if (tuple != null) { // Check if the item is a package or a group! Dictionary <int, ReadableTuple <int> > table = (Dictionary <int, ReadableTuple <int> >)dbGroups.GetTuple(groupId).GetRawValue(ServerItemGroupAttributes.Table.Index); if (table.Values.Any(p => p.GetRawElements().Skip(3).Take(6).Count(q => (q ?? "").ToString() == "") > 0)) { // This is a package } else { // This is an item_group builder.AppendLine(tuple.GetValue <string>(ServerItemAttributes.AegisName) + ": ("); foreach (var pair in table) { tuple = dbItems.TryGetTuple(pair.Key); string name = tuple == null ? "ID" + pair.Key : tuple.GetValue <string>(ServerItemAttributes.AegisName); if (pair.Value.GetValue <string>(ServerItemGroupSubAttributes.Rate) == "1") { builder.Append("\t\""); builder.Append(name); builder.AppendLine("\","); } else { builder.Append("\t(\""); builder.Append(name); builder.Append("\","); builder.Append(pair.Value.GetValue <string>(ServerItemGroupSubAttributes.Rate)); builder.AppendLine("),"); } } builder.Append(")"); } } else { DbIOErrorHandler.Handle(StackTraceException.GetStrackTraceException(), "Failed to retrieve the item ID associated with the group ID.", groupId.ToString(CultureInfo.InvariantCulture), ErrorLevel.Critical); } } return(builder.ToString()); }
public static bool IsTabEnabled(GTabSettings <TKey, ReadableTuple <TKey> > settings, BaseDb gdb) { if (DbPathLocator.DetectPath(settings.DbData) == null) { return(false); } if (!gdb.IsEnabled) { return(false); } if (!Boolean.Parse(ProjectConfiguration.ConfigAsker["[Server database editor - Enabled state - " + settings.DbData.DisplayName + "]", true.ToString()])) { return(false); } return(true); }
private void btnScan_Click(object sender, System.EventArgs e) { CurrentFullName = ddlFormula.SelectedItem.Value; Exchange = ddlExchange.SelectedItem.Value; string Param = ""; foreach (string s in Request.Form) { if (s.StartsWith("__Param")) { if (Param != "") { Param += ","; } Param += double.Parse(Request.Form[s]); } } Condition = CurrentFullName; if (Param != "") { Condition = CurrentFullName + "(" + Param + ")"; } DbParam[] dps = new DbParam[] { new DbParam("@Condition", DbType.String, Condition), new DbParam("@Exchange", DbType.String, Exchange), new DbParam("@StartTime", DbType.DateTime, DateTime.Now.AddHours(- Tools.ToIntDef(ConfigurationManager.AppSettings["ScanCacheTime"], 0))) }; bool b = true; BaseDb bd = DB.Open(true); try { DataRow dr = bd.GetFirstRow("select * from condition where Condition=? and Exchange=? and StartTime>?", dps); if (dr != null && !Config.KeepLatestScanResultOnly) { ConditionId = dr["ConditionId"].ToString(); b = false; } else { dps[2] = null; if (Config.KeepLatestScanResultOnly) { DataTable dt = bd.GetDataTable("select ConditionId from condition where Condition=? and Exchange=?", dps); foreach (DataRow drDel in dt.Rows) { bd.DoCommand("delete from ScanedQuote where ConditionId = " + drDel["ConditionId"]); } bd.DoCommand("delete from condition where Condition=? and Exchange=?", dps); } bd.DoCommand("insert into condition (Condition,Exchange,Scaned) values (?,?,0)", dps); ConditionId = bd.GetFirstRow("select max(ConditionId) from condition")[0].ToString(); } } finally { bd.Close(); } if (b) { ThreadPool.QueueUserWorkItem(new WaitCallback(Scanning), new ScanId(ConditionId, Condition, Exchange)); Response.Redirect("Progress.aspx?ConditionId=" + ConditionId); } else { Response.Redirect("StockList.aspx?ConditionId=" + ConditionId); } }
public void AddTable(BaseDb db) { _dbs.Add(db); db.Holder = this; db.Init(Database); }