示例#1
0
        public static bool AddGroupOfSymbols(GroupModel group)
        {
            string startDateStr = Convert.ToDateTime(group.Start).ToString("yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture);
            string endDateStr = Convert.ToDateTime(group.End).ToString("yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture);

            String query = "INSERT IGNORE INTO " + TblSymbolsGroups;
            query += " (GroupName, TimeFrame, Start, End, CntType) VALUES";
            query += "('" + group.GroupName + "',";
            query += " '" + group.TimeFrame + "',";
            query += " '" + startDateStr + "',";
            query += " '" + endDateStr + "',";
            query += " '" + group.CntType + "');COMMIT;";
            return DoSql(query);
        }
示例#2
0
        private static void AddGroup(GroupModel group)
        {
            var groupValues = new ArrayList
                        {
                            _groupIndexer,
                            _userIndexer,
                            group.GroupName,
                            group.TimeFrame,
                            group.CntType,
                            group.AppType.ToString(),
                            group.Privilege
                        };

            var groupRow = _userDetails.tableGroups.NewRow();

            groupRow.ItemArray = groupValues.ToArray();
            _userDetails.tableGroups.Rows.Add(groupRow);
            _userDetails.AcceptChanges();
        }
示例#3
0
        public static bool AddGroupForUser(int userId, GroupModel group)
        {
            string startDateStr = Convert.ToDateTime(group.Start).ToString("yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture);
            string endDateStr = Convert.ToDateTime(group.End).ToString("yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture);

            var sql = "INSERT IGNORE INTO " + TblGroupsForUsers
                      + " (`UserID`, `GroupID`, `GroupName`, `TimeFrame`, `Start`, `End`, `CntType`, `Privilege`, `AppType`)"
                      + "VALUES('" + userId + "',"
                      + " '" + group.GroupId + "',"
                      + " '" + group.GroupName + "',"
                      + " '" + group.TimeFrame + "',"
                      + " '" + startDateStr + "',"
                      + " '" + endDateStr + "',"
                      + " '" + group.CntType + "',"
                      + " '" + group.Privilege.ToString() + "',"
                      + " '" + group.AppType.ToString() + "');COMMIT;";

            return DoSql(sql);
        }
示例#4
0
        private static void AddGroupSymbols(GroupModel group)
        {
            var symbolList = DataManager.GetSymbolsInGroup(group.GroupId);

            foreach (var symbol in symbolList)
            {
                var symbolValues = new ArrayList
                    {
                        null,
                        _groupIndexer,
                        symbol.SymbolName
                    };

                var symbolRow = _userDetails.tableSymbols.NewRow();

                symbolRow.ItemArray = symbolValues.ToArray();
                _userDetails.tableSymbols.Rows.Add(symbolRow);
                _userDetails.AcceptChanges();
            }
        }
示例#5
0
        private void EditListControl_SaveClick(object sender, EventArgs e)
        {
            var group = new GroupModel
            {
                GroupName = _editListControl.textBoxXListName.Text,
                TimeFrame = _editListControl.cmbHistoricalPeriod.SelectedItem.ToString(),
                Start = new DateTime(),
                End = new DateTime(),
                CntType = _editListControl.cmbContinuationType.SelectedItem.ToString()
            };

            var oldGroupName = _editListControl.OldGroupName;
            if (group.GroupName == "")
            {
                ToastNotification.Show(_editListControl, @"Please enter name of the list", eToastPosition.TopCenter);
            }
            else if ((!_groups.Exists(a => a.GroupName == group.GroupName) && _groups.Exists(a => a.GroupName == oldGroupName)) || (group.GroupName == oldGroupName && _groups.Exists(a => a.GroupName == oldGroupName)))
            {
                var groupId = _groups.Find(a => a.GroupName == oldGroupName).GroupId;
                DataManager.EditGroupOfSymbols(groupId, group);
                var symbolsInGroup = DataManager.GetSymbolsInGroup(groupId);
                foreach (var item in _editListControl.lbSelList.Items)
                {
                    if (!symbolsInGroup.Exists(a => a.SymbolName == item.ToString()) && _symbols.Exists(a => a.SymbolName == item.ToString()))
                    {
                        var symbol = _symbols.Find(a => a.SymbolName == item.ToString());
                        DataManager.AddSymbolIntoGroup(groupId, symbol);

                    }
                }

                symbolsInGroup = DataManager.GetSymbolsInGroup(groupId);
                foreach (var symbol in symbolsInGroup)
                {
                    var exist = false;
                    foreach (var item in _editListControl.lbSelList.Items)
                    {
                        if (symbol.SymbolName == item.ToString()) exist = true;
                    }
                    if (!exist) DataManager.DeleteSymbolFromGroup(groupId, symbol.SymbolId);
                }

                UpdateGroupsTable();

                _adminService.GroupChanged();
                UpdateLogComponents();

                for (var index = 0; index < ui_groups_dataGridViewX_groupsList.Rows.Count; index++)
                {
                    var item = ui_groups_dataGridViewX_groupsList.Rows[index];
                    ui_groups_dataGridViewX_groupsList.Rows[index].Selected = item.Cells[0].Value.ToString() == @group.GroupName;
                }

                CloseEditListControl();
            }
            else
            {
                ToastNotification.Show(_editListControl, @"List with this name is already exists!", eToastPosition.TopCenter);
            }
        }
示例#6
0
        private void AddListControl_SaveClick(object sender, EventArgs e)
        {
            var group = new GroupModel
            {
                GroupName = _addListControl.textBoxXListName.Text,
                TimeFrame = _addListControl.cmbHistoricalPeriod.SelectedItem.ToString(),
                Start = new DateTime(),
                End = new DateTime(),
                CntType = _addListControl.cmbContinuationType.SelectedItem.ToString()
            };

            if (group.GroupName == "")
            {
                ToastNotification.Show(_addListControl, @"Please enter name of the list", eToastPosition.TopCenter);
            }
            else if (!_groups.Exists(a => a.GroupName == group.GroupName))
            {
                if (DataManager.AddGroupOfSymbols(group))
                {
                    UpdateGroupsTable();

                    var groupId = _groups.Find(a => a.GroupName == group.GroupName).GroupId;
                    foreach (var item in _addListControl.lbSelList.Items)
                    {
                        if (_symbols.Exists(a => a.SymbolName == item.ToString()))
                        {
                            var symbol = _symbols.Find(a => a.SymbolName == item.ToString());
                            DataManager.AddSymbolIntoGroup(groupId, symbol);
                        }
                    }
                    _adminService.GroupChanged();
                    for (var index = 0; index < ui_groups_dataGridViewX_groupsList.Rows.Count; index++)
                    {
                        var item = ui_groups_dataGridViewX_groupsList.Rows[index];
                        ui_groups_dataGridViewX_groupsList.Rows[index].Selected = item.Cells[0].Value.ToString() == @group.GroupName;
                    }

                    CloseAddListControl();
                }
            }
            else
            {
                ToastNotification.Show(_addListControl, @"List with this name is already exists!", eToastPosition.TopCenter);
            }
        }
示例#7
0
        public static List<GroupModel> GetGroupsForUser(int userId)
        {
            var groupList = new List<GroupModel>();

            var sql = "SELECT * FROM " + TblGroupsForUsers + " WHERE UserID = '" + userId + "' ; ";
            lock (LockReader)
            {
                var reader = GetReader(sql);
                if (reader != null)
                {
                    while (reader.Read())
                    {
                        var symbol = new GroupModel
                        {
                            GroupId = reader.GetInt32(2),
                            GroupName = reader.GetString(3),
                            TimeFrame = reader.GetString(4),
                            Start = reader.GetDateTime(5),
                            End = reader.GetDateTime(6),
                            CntType = reader.GetString(7)
                        };

                        GroupPrivilege privilege;
                        ApplicationType appType;
                        Enum.TryParse(reader.GetString(8), out privilege);
                        Enum.TryParse(reader.GetString(9), out appType);

                        symbol.Privilege = privilege;
                        symbol.AppType = appType;

                        groupList.Add(symbol);
                    }
                    reader.Close();
                }
            }
            return groupList;
        }
示例#8
0
        public static List<GroupModel> GetGroups()
        {
            var groupList = new List<GroupModel>();

            const string sql = "SELECT * FROM " + TblSymbolsGroups;
            lock (LockReader)
            {
                var reader = GetReader(sql);
                if (reader != null)
                {
                    while (reader.Read())
                    {
                        var group = new GroupModel
                        {
                            GroupId = reader.GetInt32(0),
                            GroupName = reader.GetString(1),
                            TimeFrame = reader.GetString(2),
                            Start = reader.GetDateTime(3),
                            End = reader.GetDateTime(4),
                            CntType = reader.GetString(5)
                        };

                        groupList.Add(group);
                    }

                    reader.Close();
                }
            }
            return groupList;
        }
示例#9
0
        public static bool EditGroupOfSymbols(int groupId, GroupModel group)
        {
            string startDateStr = Convert.ToDateTime(group.Start).ToString("yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture);
            string endDateStr = Convert.ToDateTime(group.End).ToString("yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture);

            String query = "UPDATE " + TblSymbolsGroups
                        + " SET GroupName = '" + group.GroupName
                        + "', TimeFrame = '" + group.TimeFrame
                        + "', Start = '" + startDateStr
                        + "', End = '" + endDateStr
                        + "', CntType = '" + group.CntType
                        + "' WHERE ID = '" + groupId + "' ; COMMIT;";

            if (DoSql(query))
            {
                query = "UPDATE " + TblGroupsForUsers
                    + " SET GroupName = '" + group.GroupName
                    + "', TimeFrame = '" + group.TimeFrame
                    + "', Start = '" + startDateStr
                    + "', End = '" + endDateStr
                    + "', CntType = '" + group.CntType
                    + "' WHERE GroupID = '" + groupId + "' ; COMMIT;";

                return DoSql(query);
            }

            return false;
        }