Exemple #1
0
        public CriterialConstraintForm(
            Dictionary <TId, Criterion> criteria,
            TId mainCriterionId,
            CriterialConstraint constraint)
        {
            InitializeComponent();
            this._constraint      = constraint;
            this._criteria        = criteria;
            this._mainCriterionId = mainCriterionId;
            this.Text             = "Редактировать критериальное ограничение";
            this.FillCriteriaList();
            this.FillSignsList();
            this.nudConstraintValue.DecimalPlaces = Program.ApplicationSettings.ValuesDecimalPlaces;

            this.SelectProperCriterion();
            this.cmbConstraintSign.SelectedItem = RelationManager.GetRelationName(this._constraint.Relation);
            try
            {
                this.nudConstraintValue.Value = Convert.ToDecimal(this._constraint.Value);
            }
            catch (ArgumentOutOfRangeException ex)
            {
                MessageBoxHelper.ShowError("'Value' of 'Constraint' class object is out of range\nOriginal message: " + ex.Message);
                this.DialogResult = DialogResult.Cancel;
                this.Close();
            }
        }
        public EditConstraintForm(
            Constraint constraint)
        {
            InitializeComponent();
            this.FillSignsList();
            this.nudConstraintValue.DecimalPlaces = SettingsManager.Instance.ValuesDecimalPlaces;

            if (constraint != null)
            {
                this.Text                   = "Редактировать функциональное ограничение";
                this.constraint             = constraint;
                this.txtConstraintName.Text = constraint.Name;
                this.txtConstraintVariableIdentifier.Text = constraint.VariableIdentifier;
                this.cmbConstraintSign.SelectedItem       = RelationManager.GetRelationName(constraint.ConstraintRelation);
                try
                {
                    this.nudConstraintValue.Value = Convert.ToDecimal(constraint.Value);
                }
                catch (ArgumentOutOfRangeException ex)
                {
                    MessageBoxHelper.ShowError("'Value' of 'Constraint' class object is out of range\nOriginal message: " + ex.Message);
                    this.DialogResult = DialogResult.Cancel;
                    this.Close();
                }
            }
            else
            {
                this.Text = "Новое функциональное ограничение";
            }
        }
        private static void WriteProducts()
        {
            //ExecuteQuery("INSERT INTO products VALUES (1, 1994, \"Intel\")");
            //ExecuteQuery("INSERT INTO products VALUES (2, 2010, \"AMD\")");
            //ExecuteQuery("INSERT INTO products VALUES (4, 2020, \"AMD\")");
            //ExecuteQuery("INSERT INTO products VALUES (3, 2015, \"Intel\")");

            Table table = RelationManager.GetTable("products");

            //table.Insert(new CustomTuple(table.TableDefinition).AddValueFor<int>("Id", 1).AddValueFor("BuildYear", 1994).AddValueFor("Producer", "Intel"));
            //table.Insert(new CustomTuple(table.TableDefinition).AddValueFor<int>("Id", 2).AddValueFor("BuildYear", 2010).AddValueFor("Producer", "AMD"));
            //table.Insert(new CustomTuple(table.TableDefinition).AddValueFor<int>("Id", 3).AddValueFor("BuildYear", 2020).AddValueFor("Producer", "AMD"));
            //table.Insert(new CustomTuple(table.TableDefinition).AddValueFor<int>("Id", 4).AddValueFor("BuildYear", 2015).AddValueFor("Producer", "Intel"));

            table.StartBulkMode();
            for (int i = 0; i < 10; i++)
            {
                table.Insert(new CustomTuple(table.TableDefinition).AddValueFor <int>("Id", i).AddValueFor("BuildYear", 1900 + i / 5).AddValueFor("Producer", i % 2 == 0 ? "Intel" : "AMD"));
            }
            table.EndBulkMode();

            //RelationManager.GetTable("products").StartBulkMode();
            //for(int i = 0; i < 1000; i++)
            //{
            //    ExecuteQuery("INSERT INTO products VALUES (" + i + ", " + i + ", \"Intel\")");
            //}
            //RelationManager.GetTable("products").EndBulkMode();
        }
        private static void CreateProductsTableIfNotExists(RelationManager relationManager)
        {
            if (!relationManager.TableExists("Products"))
            {
                TableDefinition table = new TableDefinition()
                {
                    Name = "Products",
                    Id   = 1
                };

                table.Add(new AttributeDefinition()
                {
                    Name = "Id", Type = ValueType.Integer
                });
                table.Add(new AttributeDefinition()
                {
                    Name = "BuildYear", Type = ValueType.Integer
                });
                table.Add(new AttributeDefinition()
                {
                    Name = "Producer", Type = ValueType.String
                });
                table.AddIndex(new Index {
                    IsClustered = true, Column = "Id"
                });
                table.AddIndex(new Index {
                    IsClustered = false, Column = "Producer"
                });

                relationManager.CreateTable(table);
                WriteProducts();
            }
        }
Exemple #5
0
        /// <summary>
        /// Метод для заполнения таблицы данными об ограничениях
        /// </summary>
        private void UpdateConstraintsDataGrid()
        {
            this.dgvConstraints.SuspendLayout();

            this.dgvConstraints.Rows.Clear();
            foreach (KeyValuePair <TId, Constraint> constraint in this._model.FunctionalConstraints)
            {
                int ind = this.dgvConstraints.Rows.Add();
                this.dgvConstraints[0, ind].Value    = constraint.Value.Id;
                this.dgvConstraints[0, ind].ReadOnly = true;

                this.dgvConstraints[1, ind].Value           = constraint.Value.Name;
                this.dgvConstraints[1, ind].ReadOnly        = true;
                this.dgvConstraints[1, ind].Style.BackColor = Color.LightGray;

                this.dgvConstraints[2, ind].Value           = constraint.Value.VariableIdentifier;
                this.dgvConstraints[2, ind].ReadOnly        = true;
                this.dgvConstraints[2, ind].Style.BackColor = Color.LightGray;

                this.dgvConstraints[3, ind].Value = RelationManager.GetRelationName(constraint.Value.ConstraintRelation);

                this.dgvConstraints[4, ind].Value = constraint.Value.Value.ToString(SettingsManager.Instance.DoubleStringFormat);

#if !DUMMY
                // Связываемся с колонкой "Выражение" только в том случае, если
                // это режим не для дурачков
                this.dgvConstraints[5, ind].Value           = constraint.Value.Expression;
                this.dgvConstraints[5, ind].ReadOnly        = true;
                this.dgvConstraints[5, ind].Style.BackColor = Color.LightGray;
#endif
            }

            this.dgvConstraints.ResumeLayout();
        }
Exemple #6
0
        public ConstraintForm(
            Model model,
            TId constraintId)
        {
            InitializeComponent();
            this._model        = model;
            this._constraintId = constraintId;
            this.Text          = "Редактировать функциональное ограничение";
            this.FillSignsList();
            this.nudConstraintValue.DecimalPlaces = Program.ApplicationSettings.ValuesDecimalPlaces;
#if DUMMY
            this.DummyMode();
#endif

            // Заполним поля данными
            Constraint constraint = this._model.FunctionalConstraints[this._constraintId];
            this.txtConstraintName.Text = constraint.Name;
            this.txtConstraintVariableIdentifier.Text = constraint.VariableIdentifier;
            this.cmbConstraintSign.SelectedItem       = RelationManager.GetRelationName(constraint.ConstraintRelation);
            try
            {
                this.nudConstraintValue.Value = Convert.ToDecimal(constraint.Value);
            }
            catch (ArgumentOutOfRangeException ex)
            {
                MessageBoxHelper.ShowError("'Value' of 'Constraint' class object is out of range\nOriginal message: " + ex.Message);
                this.DialogResult = DialogResult.Cancel;
                this.Close();
            }
            this.txtConstraintExpression.Text = constraint.Expression;
        }
Exemple #7
0
        private void FillSignsCombo()
        {
            DataGridViewComboBoxCell combo =
                (DataGridViewComboBoxCell)this.dgvConstraints.Columns[3].CellTemplate;

            combo.Items.AddRange(RelationManager.GetRelationNames().ToArray());
        }
Exemple #8
0
        protected virtual bool FindEnemies()
        {
            if (Location == null)
            {
                hountingPath = null;
                return(false);
            }

            ILiveEntity enemy       = null;
            ITile       matchedTile = null;

            globalSearcher.StartSearch(Location.Tile, Location.Tile, Math.Max(DetectRange, SightRange), (tile, layer, bundle) =>
            {
                enemy = tile.LayoutManager.Entities.FirstOrDefault(e => RelationManager.IsEnemy(e.RelationManager.RelationToken));
                if (enemy != null)
                {
                    globalSearcher.StopSearch();
                    matchedTile = tile;
                }
            });
            if (enemy != null)
            {
                hountingPath = globalSearcher.GetShortestRoute(matchedTile);
                //$"{this} found enemies at {hountingPath.Last().GridPosition}".Dump();
                return(true);
            }
            else
            {
                hountingPath = null;
                return(false);
            }
        }
Exemple #9
0
        /// <summary>Draws the text and image content.</summary>
        /// <param name="graphics">The graphics to draw on.</param>
        /// <param name="rectangle">The coordinates of the rectangle to draw.</param>
        /// <param name="text">The string to draw.</param>
        /// <param name="font">The font to use in the string.</param>
        /// <param name="foreColor">The color of the string.</param>
        /// <param name="image">The image to draw.</param>
        /// <param name="imageSize">The image Size.</param>
        /// <param name="textImageRelation">The text image relation.</param>
        public static void DrawContent(Graphics graphics, Rectangle rectangle, string text, Font font, Color foreColor, Image image, Size imageSize, TextImageRelation textImageRelation)
        {
            Rectangle _imageRectangle = new Rectangle(new Point(), imageSize);
            Point     _imagePoint     = RelationManager.GetTextImageRelationLocation(graphics, textImageRelation, _imageRectangle, text, font, rectangle, true);
            Point     _textPoint      = RelationManager.GetTextImageRelationLocation(graphics, textImageRelation, _imageRectangle, text, font, rectangle, false);

            graphics.DrawImage(image, new Rectangle(_imagePoint, imageSize));
            graphics.DrawString(text, font, new SolidBrush(foreColor), _textPoint);
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            //get values
            string   constrName = this.txtConstraintName.Text.Trim();
            string   constrVariableIdentifier = this.txtConstraintVariableIdentifier.Text.Trim();
            Relation constrSign  = RelationManager.ParseName(this.cmbConstraintSign.Text);
            double   constrValue = Convert.ToDouble(this.nudConstraintValue.Value);

            //validation
            if (string.IsNullOrEmpty(constrName))
            {
                MessageBoxHelper.ShowExclamation("Введите имя Функционального ограничения");
                return;
            }

            if (!string.IsNullOrEmpty(constrVariableIdentifier))
            {
                if (!VariableIdentifierChecker.RegExCheck(constrVariableIdentifier))
                {
                    MessageBoxHelper.ShowExclamation("Идентификатор переменной должен наинаться только с заглавной или строчной буквы \nлатинского алфавита и содержать заглавные и строчные буквы латинского алфавита,\n цифры и символ подчеркивания");
                    return;
                }

                if (constraint == null || constraint.VariableIdentifier != constrVariableIdentifier)
                {
                    if (model.CheckConstraintVariableIdentifier(constrVariableIdentifier))
                    {
                        MessageBoxHelper.ShowExclamation("Параметр с таким идентификатором переменной уже существует в модели");
                        return;
                    }
                }
            }

            //init
            if (constraint == null)
            {
                TId constrId = model.FunctionalConstraints.GetFreeConsequentId();
                constraint = new Constraint(
                    constrId,
                    constrName,
                    constrVariableIdentifier,
                    constrSign,
                    constrValue,
                    "");
                model.FunctionalConstraints.Add(constraint);
            }
            else
            {
                constraint.Name = constrName;
                constraint.VariableIdentifier = constrVariableIdentifier;
                constraint.ConstraintRelation = constrSign;
                constraint.Value = constrValue;
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Exemple #11
0
        public StandardResult GetFriends(string account)
        {
            if (string.IsNullOrEmpty(account))
            {
                return(Result(iTripExceptionCode.Error_Wrong_Account));
            }
            IRelationManager manager = new RelationManager();

            return(Result(manager.GetMyFriends(account)));
        }
        private static void WriteProducers()
        {
            //ExecuteQuery("INSERT INTO producers VALUES (1, \"Intel\")");
            //ExecuteQuery("INSERT INTO producers VALUES (2, \"AMD\")");

            Table table = RelationManager.GetTable("producers");

            table.Insert(new CustomTuple(table.TableDefinition).AddValueFor <int>("Id", 1).AddValueFor("Name", "Intel"));
            table.Insert(new CustomTuple(table.TableDefinition).AddValueFor <int>("Id", 2).AddValueFor("Name", "AMD"));
        }
Exemple #13
0
    public bool IsMyFrientd(IEntity target)
    {
        RelationManager relaManager = DataManager.Manager <RelationManager>();

        if (relaManager != null)
        {
            return(relaManager.IsMyFriend(target.GetID()));
        }
        return(false);
    }
Exemple #14
0
        public StandardResult AcceptApplication(string accepter, string applicationId)
        {
            if (string.IsNullOrEmpty(accepter) || string.IsNullOrEmpty(applicationId))
            {
                return(Result(iTripExceptionCode.Error_Null_Reference));
            }

            IRelationManager manager = new RelationManager();

            return(Result(manager.AcceptApplication(accepter, applicationId)));
        }
        unsafe static void Main(string[] args)
        {
            File.Delete(StorageFilePath);
            StorageFile storageFile = new StorageFile(StorageFilePath);

            MemoryManager = new MemoryManager(storageFile);

            RelationManager   = new RelationManager(MemoryManager);
            StatisticsManager = new StatisticsManager(RelationManager);

            RelationManager.Initialize();
            CreateProductsTableIfNotExists(RelationManager);
            CreateProducersTableIfNotExists(RelationManager);

            StatisticsManager.CalculateStatistics();
            StatisticsManager.PrintStatistics();

            //string query = "SELECT products.BuildYear, * FROM products JOIN producers on products.producer = producers.name WHERE producers.Name = \"AMD\" ";
            //string query = "SELECT TOP 1000 * FROM products WHERE products.Producer IN (SELECT Name FROM producers WHERE Id = 2)";
            //string query = "SELECT * FROM products JOIN producers on products.producer = producers.name WHERE (producers.name = \"AMD\" && products.BuildYear = 2010)";
            UserQuery = "SELECT * FROM products WHERE Id = 1";
            //string query = "SELECT products.BuildYear, * FROM products JOIN producers on products.producer = producers.name WHERE producers.Name = \"AMD\"";
            while (!string.IsNullOrEmpty(UserQuery))
            {
                Console.WriteLine("Executing query...");

                List <CustomTuple> result = ExecuteQuery(UserQuery, true);

                if (result.Count > 0)
                {
                    List <string> columnNames = new List <string>();
                    foreach (CustomObject entry in result[0].Entries)
                    {
                        columnNames.Add(entry.AttributeDefinition.Relation.Name + "." + entry.AttributeDefinition.Name.ToString());
                    }
                    Console.WriteLine("[" + string.Join("|", columnNames) + "]");
                }

                foreach (CustomTuple tuple in result)
                {
                    List <string> s = new List <string>();

                    foreach (CustomObject entry in tuple.Entries)
                    {
                        s.Add(entry.Value.ToString());
                    }

                    Console.WriteLine(string.Join("|", s));
                }

                Console.WriteLine("Enter new query:");
                UserQuery = Console.ReadLine();
            }
        }
Exemple #16
0
        /// <summary>
        /// Writes model information (parameters, criteria, functional constraints)
        /// </summary>
        /// <param name="model"><see cref="Model"/> instance to be exported</param>
        /// <param name="outputFileWriter"><see cref="StreamWriter"/> to be used for the output</param>
        private void WriteModelDetails(Model model, StreamWriter outputFileWriter)
        {
            outputFileWriter.WriteLine(NamesAndFormats.Parameters);
            foreach (Parameter parameter in model.Parameters.Values)
            {
                string variableIdentifier = string.IsNullOrEmpty(parameter.VariableIdentifier)
                    ? string.Empty
                    : string.Format(NamesAndFormats.VariableIdentifierFormat, parameter.VariableIdentifier);
                outputFileWriter.WriteLine(string.Format(
                                               NamesAndFormats.ParameterFormat,
                                               parameter.Name,
                                               variableIdentifier,
                                               parameter.MinValue.ToStringInvariant(SettingsManager.Instance.DoubleStringFormat),
                                               parameter.MaxValue.ToStringInvariant(SettingsManager.Instance.DoubleStringFormat)));
            }

            outputFileWriter.WriteLine();
            outputFileWriter.WriteLine();
            outputFileWriter.WriteLine(NamesAndFormats.Criteria);
            foreach (Criterion criterion in model.Criteria.Values)
            {
                string variableIdentifier = string.IsNullOrEmpty(criterion.VariableIdentifier)
                    ? string.Empty
                    : string.Format(NamesAndFormats.VariableIdentifierFormat, criterion.VariableIdentifier);
                outputFileWriter.WriteLine(string.Format(
                                               NamesAndFormats.CriterionFormat,
                                               criterion.Name,
                                               variableIdentifier,
                                               CriterionTypeManager.GetCriterionTypeName(criterion.Type)));
            }

            outputFileWriter.WriteLine();
            outputFileWriter.WriteLine();
            outputFileWriter.WriteLine(NamesAndFormats.Constraints);
            foreach (Constraint constraint in model.FunctionalConstraints.Values)
            {
                string variableIdentifier = string.IsNullOrEmpty(constraint.VariableIdentifier)
                    ? string.Empty
                    : string.Format(NamesAndFormats.VariableIdentifierFormat, constraint.VariableIdentifier);
                outputFileWriter.WriteLine(string.Format(
                                               NamesAndFormats.ConstraintFormat,
                                               constraint.Name,
                                               variableIdentifier,
                                               RelationManager.GetRelationName(constraint.ConstraintRelation),
                                               constraint.Value.ToStringInvariant(SettingsManager.Instance.DoubleStringFormat)));
            }
        }
Exemple #17
0
 public void OnRoleResetOtherInfo()//在玩家进行刷新 或者是 断线重新连接后 进行的处理
 {
     //客户端重新设置下全部的外围数据
     AchievementManager.ResetInfo();
     ActionManager.ResetInfo();
     //CheckManager.ResetInfo();
     EntityManager.ResetInfo();
     RoleGameData.ResetInfo();
     ItemManager.ResetInfo();
     MailManager.ResetInfo();
     RankManager.ResetInfo();
     RelationManager.ResetInfo();
     TaskManager.ResetInfo();
     RoleAnnouncement.ResetInfo();
     MonthManager.ResetInfo();
     RoleChar.ResetInfo();
 }
Exemple #18
0
        private void FillConstraintsDataGrid()
        {
            this.dgvData.SuspendLayout();

            this.dgvData.Rows.Clear();
            foreach (CriterialConstraint constraint in this._criterialConstraints)
            {
                int ind = this.dgvData.Rows.Add();
                this.dgvData[0, ind].Value = constraint.Id;
                this.dgvData[1, ind].Value = this._model.Criteria[constraint.CriterionId].Name;
                this.dgvData[2, ind].Value =
                    this._model.Criteria[constraint.CriterionId].VariableIdentifier;
                this.dgvData[3, ind].Value = RelationManager.GetRelationName(constraint.Relation);
                this.dgvData[4, ind].Value = constraint.Value.ToString(SettingsManager.Instance.DoubleStringFormat);
            }

            this.dgvData.ResumeLayout();
        }
        protected override void UpdateParametersDataGrid <T>(NamedModelEntityCollection <T> entities)
        {
            base.UpdateParametersDataGrid <T>(entities);

            this.dgvModelEntities.SuspendLayout();
            int ind = 0;

            foreach (KeyValuePair <TId, opt.DataModel.Constraint> constraint in
                     ModelStorage.Instance.Model.FunctionalConstraints)
            {
                this.dgvModelEntities[3, ind].Value = RelationManager.
                                                      GetRelationName(constraint.Value.ConstraintRelation);
                this.dgvModelEntities[4, ind].Value = constraint.Value.Value;
                ind++;
            }

            this.dgvModelEntities.ResumeLayout();
        }
Exemple #20
0
        public Table(RelationManager relationManager, MemoryManager memoryManager, TableDefinition tableDefinition, Pointer rootBlock)
        {
            MemoryManager    = memoryManager;
            TableDefinition  = tableDefinition;
            _relationManager = relationManager;

            RootBlock = memoryManager.Read(tableDefinition, rootBlock);

            if (tableDefinition.HasClusteredIndex())
            {
                Index index = tableDefinition.GetClusteredIndex();
                _indexesWithTrees.Add(index, GetBTreeForIndex(rootBlock, index));
            }

            foreach (Index index in TableDefinition.NonClusteredIndexes())
            {
                _indexesWithTrees.Add(index, GetBTreeForIndex(index.RootPointer, index));
            }
        }
Exemple #21
0
        public StandardResult ApplyFriend(string applicant, string friend, string memo)
        {
            if (string.IsNullOrEmpty(applicant) || string.IsNullOrEmpty(friend))
            {
                return(Result(iTripExceptionCode.Error_Null_Reference));
            }

            var wcf_auth = GetService <IServiceAuthenticationReception>();
            var names    = wcf_auth.GetTripperNames(new string[] { applicant });

            if (names == null || names.Length != 1)
            {
                return(Result(iTripExceptionCode.Error_Wrong_Account));
            }

            IRelationManager manager = new RelationManager();

            return(manager.ApplyFriend(applicant, names[0], friend, memo));
        }
Exemple #22
0
    protected override void OnLoading()
    {
        base.OnLoading();
        MailEventRegister(true);
        m_relationMgr      = DataManager.Manager <RelationManager>();
        privateChatManager = DataManager.Manager <ChatDataManager>().PrivateChatManager;
        //聊天相关
        m_chatPanel      = m_trans_chatroot.parent.GetComponent <UIPanel>();
        m_chatScrollView = m_chatPanel.GetComponent <UIScrollView>();
        //load prefab
        m_chatItemPrefab = m_trans_UIChatItemGrid.gameObject;
        m_trans_timeTips.gameObject.SetActive(false);
        m_sprite_bg_searchresults.gameObject.SetActive(false);
        InitFriendSecondTabs();
        InitLeftGrid();

        AddCreator(m_trans_mail_text_scroll.transform);

        privateChatOpenLv = GameTableManager.Instance.GetGlobalConfig <uint>("PrivateChatOpenLevel");
    }
Exemple #23
0
        /// <summary>
        /// Метод для заполнения таблицы данными об ограничениях
        /// </summary>
        private void UpdateConstraintsDataGrid()
        {
            this.dgvConstraints.SuspendLayout();

            this.dgvConstraints.Rows.Clear();
            foreach (KeyValuePair <TId, Constraint> constraint in this._model.FunctionalConstraints)
            {
                int ind = this.dgvConstraints.Rows.Add();
                this.dgvConstraints[0, ind].Value = constraint.Value.Id;
                this.dgvConstraints[1, ind].Value = constraint.Value.Name;
                this.dgvConstraints[2, ind].Value = constraint.Value.VariableIdentifier;
                this.dgvConstraints[3, ind].Value = RelationManager.GetRelationName(constraint.Value.ConstraintRelation);
                this.dgvConstraints[4, ind].Value = constraint.Value.Value.ToString(SettingsManager.Instance.DoubleStringFormat);
#if !DUMMY
                // НЕ РАБОТАЕТ В РЕЖИМЕ ДЛЯ ДУРАЧКОВ
                this.dgvConstraints[5, ind].Value = constraint.Value.Expression;
#endif
            }

            this.dgvConstraints.ResumeLayout();
        }
Exemple #24
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            bool updateOk = true;

            // По очереди считаем все ячейки, которые доступны для редактирования
            foreach (DataGridViewRow row in this.dgvConstraints.Rows)
            {
                TId      constrId    = (TId)row.Cells[0].Value;
                Relation constrSign  = RelationManager.ParseName((string)row.Cells[3].Value);
                double   constrValue = double.NaN;
                try
                {
                    constrValue = Convert.ToDouble(row.Cells[4].Value);
                }
                catch (Exception ex)
                {
                    string message = "Невозможно преобразовать введенное для ограничения '" +
                                     this._model.FunctionalConstraints[constrId].Name +
                                     "' значение в число\nОригинальное сообщение: " + ex.Message;
                    MessageBoxHelper.ShowExclamation(message);
                    updateOk = false;
                    return;
                }

                // Все данные в порядке, можно обновить
                this._model.FunctionalConstraints[constrId].ConstraintRelation = constrSign;
                this._model.FunctionalConstraints[constrId].Value = constrValue;
            }

            if (updateOk)
            {
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                this.UpdateConstraintsDataGrid();
            }
        }
Exemple #25
0
        protected virtual async Task <bool> MoveToSpace(ISpaceRouteElement destination)
        {
            //something stole control to creature, i.e. falling to pit
            if (animator.IsAnimating)
            {
                //wait until finish move
                await animator.AnimatingTask;
                //reset movement
                return(false);
            }

            bool EnemyAtTile = destination.Tile.LayoutManager.Entities.Any(x => RelationManager.IsEnemy(x.RelationManager.RelationToken));

            if (Activated && destination.Tile.IsAccessible && !EnemyAtTile)
            {
                return(await MoveToAsync(destination));
            }
            else
            {
                return(false);
            }
        }
        private static void CreateProducersTableIfNotExists(RelationManager relationManager)
        {
            if (!relationManager.TableExists("Producers"))
            {
                TableDefinition table = new TableDefinition()
                {
                    Name = "Producers",
                    Id   = 2
                };

                table.Add(new AttributeDefinition()
                {
                    Name = "Id", Type = ValueType.Integer
                });
                table.Add(new AttributeDefinition()
                {
                    Name = "Name", Type = ValueType.String
                });

                relationManager.CreateTable(table);
                WriteProducers();
            }
        }
Exemple #27
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            TId      criterionId = ((CriterionComboBoxItem)this.cmbCriterion.SelectedItem).criterionId;
            Relation constrSign  = RelationManager.ParseName(this.cmbConstraintSign.Text);
            double   constrValue = Convert.ToDouble(this.nudConstraintValue.Value);

            if (this._constraint == null)
            {
                this._constraint = new CriterialConstraint(
                    criterionId,
                    constrSign,
                    constrValue);
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                this._constraint.CriterionId = criterionId;
                this._constraint.Relation    = constrSign;
                this._constraint.Value       = constrValue;
                this.DialogResult            = DialogResult.OK;
                this.Close();
            }
        }
Exemple #28
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            try
            {
                Graphics graphics = e.Graphics;
                graphics.SmoothingMode      = SmoothingMode.HighQuality;
                graphics.CompositingQuality = CompositingQuality.GammaCorrected;

                Size      textArea = StringUtil.MeasureText(Text, Font, graphics);
                Rectangle group    = ConfigureStyleBox(textArea);
                Rectangle title    = ConfigureStyleTitleBox(textArea);

                _titleBoxRectangle = new Rectangle(title.X, title.Y, title.Width - 1, title.Height);

                Rectangle _clientRectangle = new Rectangle(group.X, group.Y, group.Width, group.Height);
                ControlGraphicsPath = VisualBorderRenderer.CreateBorderTypePath(_clientRectangle, _border);
                graphics.FillRectangle(new SolidBrush(BackColor), _clientRectangle);

                Color _backColor = Enabled ? BackColorState.Enabled : BackColorState.Disabled;
                VisualBackgroundRenderer.DrawBackground(e.Graphics, _backColor, BackgroundImage, MouseState, group, Border);

                if (_borderEdge.Visible)
                {
                    _borderEdge.Location = new Point(_titleBoxRectangle.X + _border.Thickness, _titleBoxRectangle.Bottom);
                    _borderEdge.Size     = new Size(Width - _border.Thickness - 1, 1);
                }

                VisualBorderRenderer.DrawBorderStyle(e.Graphics, _border, ControlGraphicsPath, MouseState);

                if (_boxStyle == GroupBoxStyle.Classic)
                {
                    Size _newSize;
                    if (_image != null)
                    {
                        _newSize = _image.Size;
                    }
                    else
                    {
                        _newSize = new Size(0, 0);
                    }

                    _titleBoxRectangle = new Rectangle(5, 0, title.Width - 1, title.Height);
                    Point _titleBoxBackground = RelationManager.GetTextImageRelationLocation(graphics, _textImageRelation, new Rectangle(new Point(0, 0), _newSize), Text, Font, _titleBoxRectangle, Relation.Text);
                    graphics.FillRectangle(new SolidBrush(BackColorState.Enabled), new Rectangle(new Point(_titleBoxBackground.X, _titleBoxBackground.Y), new Size(_titleBoxRectangle.Width, _titleBoxRectangle.Height)));
                }

                if (_image != null)
                {
                    VisualControlRenderer.DrawContent(e.Graphics, _titleBoxRectangle, Text, Font, ForeColor, _image, _image.Size, _textImageRelation);
                }
                else
                {
                    StringFormat _stringFormat = new StringFormat {
                        Alignment = _textAlignment, LineAlignment = _textLineAlignment
                    };

                    VisualTextRenderer.RenderText(e.Graphics, _titleBoxRectangle, Text, Font, ForeColor, _stringFormat);
                }
            }
            catch (Exception exception)
            {
                Logger.WriteDebug(exception);
            }
        }
Exemple #29
0
        /// <summary>
        /// 校验数据通过后才能进行入库操作,True:通过,False不通过
        /// </summary>
        /// <returns></returns>
        private bool CheckData()
        {
            bool Rtn = true;

            ResultTable = DataExcel.Clone();//复制当前表的结构,同时记录对象类型ID和对象ID,用于写数据库。数据库中存储关系都是以ID来表示的,名称不符合要求
            RelTypeManager  RelManage     = new RelTypeManager();
            RelationManager RelBOManage   = new RelationManager();
            List <string>   BOTIDList     = new List <string>();
            List <string>   BOTUseGeoList = new List <string>();
            List <string>   BOIDList      = new List <string>();

            foreach (DataRow dr in DataExcel.Rows)
            {
                BOTIDList = new List <string>();
                BOIDList  = new List <string>();
                //校验Excle表格中的对象类型和对象实例是否存在
                if (dr.ItemArray[0].ToString() != "" && dr.ItemArray[1].ToString() != "" && dr.ItemArray[2].ToString() != "" && dr.ItemArray[3].ToString() != "")//校验对象类型
                {
                    BOTIDList = RelManage.GetBOTbyName(dr.ItemArray[2].ToString(), dr.ItemArray[3].ToString());
                    if (BOTIDList[0] == "0" || BOTIDList[1] == "0")
                    {
                        if (BOTIDList[0] == "0")
                        {
                            CheckBOTError = CheckBOTError + "对象类型为:" + dr.ItemArray[2].ToString() + " 有误,基础库中没有此对象类型\r\n";
                        }
                        if (BOTIDList[1] == "0")
                        {
                            CheckBOTError = CheckBOTError + "对象类型为:" + dr.ItemArray[3].ToString() + " 有误,基础库中没有此对象类型\r\n";
                        }

                        Rtn = false;
                        break;
                    }
                    else
                    {
                        BOTUseGeoList = RelManage.GetBOTRelByName(dr.ItemArray[2].ToString(), dr.ItemArray[3].ToString());
                        if (BOTUseGeoList[0] == "1" && BOTUseGeoList[1] == "1")
                        {
                            CheckBOTError = CheckBOTError + "具有空间坐标的对象类型:【" + dr.ItemArray[2].ToString() + "】和【" + dr.ItemArray[3].ToString() + "】,无法创建上下级关系\r\n";
                            //空间关系校验,有空间坐标不允许建立上下级关系
                            Rtn = false;
                            break;
                        }
                        else
                        {
                            DataRow drchk = ResultTable.NewRow();
                            drchk[0] = dr.ItemArray[0].ToString();
                            drchk[1] = dr.ItemArray[1].ToString();
                            drchk[2] = BOTIDList[0]; //返回的对象类型ID1
                            drchk[3] = BOTIDList[1]; //返回的对象类型ID2
                            ResultTable.Rows.Add(drchk);
                        }
                    }
                }
                else//校验对象实例
                {
                    if (dr.ItemArray[2].ToString() != "" && dr.ItemArray[3].ToString() != "")//校验对象
                    {
                        BOIDList = RelBOManage.GetBObyName(dr.ItemArray[2].ToString(), dr.ItemArray[3].ToString());
                        if (BOIDList[0] == "0" || BOIDList[1] == "0")
                        {
                            if (BOIDList[0] == "0")
                            {
                                CheckBOError = CheckBOError + "对象名称为:" + dr.ItemArray[2].ToString() + " 有误,基础库中没有此对象\r\n";
                            }
                            if (BOIDList[1] == "0")
                            {
                                CheckBOError = CheckBOError + "对象名称为:" + dr.ItemArray[3].ToString() + " 有误,基础库中没有此对象\r\n";
                            }
                            Rtn = false;
                        }
                        else
                        {
                            DataRow drchk = ResultTable.NewRow();
                            drchk[0] = "";
                            drchk[1] = "";
                            drchk[2] = BOIDList[0]; //返回的对象ID1
                            drchk[3] = BOIDList[1]; //返回的对象ID2
                            ResultTable.Rows.Add(drchk);
                        }
                    }
                }
            }
            return(Rtn);
        }
Exemple #30
0
        /// <summary>
        /// 提交Excel模板数据到数据库中
        /// </summary>
        /// <returns></returns>
        public string SaveData()
        {
            string result = "保存成功!";
            string TITLE  = "";
            string BOTID1 = "";
            string BOTID2 = "";
            string RTID   = "";
            string RT     = "";
            List <RelTypeModel>  Rlist    = new List <RelTypeModel>();
            List <RelationModel> BOlist   = new List <RelationModel>();
            RelTypeModel         RelModel = new RelTypeModel();

            //调用已经在写好的方法来遍历,具体的在DLL中
            if (DataExcel != null)
            {
                if (CheckData())
                {
                    try
                    {
                        foreach (DataRow dr in ResultTable.Rows)
                        {
                            if (dr.ItemArray[0].ToString() != "" && dr.ItemArray[1].ToString() != "" && dr.ItemArray[2].ToString() != "" && dr.ItemArray[3].ToString() != "")//取对象类型的关系
                            {
                                RelTypeManager manager = new RelTypeManager();
                                RelModel = new RelTypeModel();
                                BOlist   = new List <RelationModel>();
                                TITLE    = dr.ItemArray[0].ToString();
                                RT       = dr.ItemArray[1].ToString();
                                BOTID1   = dr.ItemArray[2].ToString();
                                BOTID2   = dr.ItemArray[3].ToString();
                                if (!manager.Exist(new RelTypeModel()
                                {
                                    Title = TITLE, Botid1 = BOTID1, Botid2 = BOTID2
                                }, ref RTID))                                                                                        //不存在添加对象类型之间的关系,存在则忽略此关系,只添加对象实例关系
                                {
                                    RelModel.Rtid   = RTID;
                                    RelModel.RT     = RT;
                                    RelModel.Title  = TITLE;
                                    RelModel.Botid1 = BOTID1;
                                    RelModel.Botid2 = BOTID2;
                                    Rlist.Add(RelModel);
                                    manager.AddRelationModel(Rlist);
                                }
                            }
                            else//对象实例的关系
                            {
                                RelationManager Rmanage = new RelationManager();
                                RelationModel   tmpbo   = new RelationModel();
                                tmpbo.RelationID = System.Guid.NewGuid().ToString();
                                tmpbo.RTID       = RTID;
                                tmpbo.BOId1      = dr.ItemArray[2].ToString();
                                tmpbo.BOId2      = dr.ItemArray[3].ToString();
                                Rmanage.Add(tmpbo);
                            }
                        }
                    }
                    catch
                    {
                        result = "保存失败!";
                    }
                    finally
                    {
                        DataExcel = null;
                    }
                }
                else
                {
                    result = CheckBOTError + "\r\n" + CheckBOError;
                }
            }
            else
            {
                result = "保存失败!";
            }
            return(result);
        }