Example #1
0
 private void SortPositions()
 {
     AllPositions.AddRange(HorizontalWords.Keys);
     AllPositions.AddRange(VerticalWords.Keys);
     AllPositions = AllPositions.Select(z => z).Distinct().ToList();
     AllPositions = AllPositions.OrderBy(z => z.Item2).ThenBy(z => z.Item1).ToList();
 }
Example #2
0
        /// <summary>
        /// Метод удаления работника
        /// </summary>
        void DelWorker()
        {
            // Удаление выбранного работника из общей коллекции
            AllPositions.Remove(SelectedWorker);

            // Удаление выбранного работника из коллекции вывода отдела
            DivCol.Remove(SelectedWorker);
        }
Example #3
0
        public void AllPositionsNotNull()
        {
            var positions1 = new AllPositions(new DeskSize(7, 8));
            var positions2 = new AllPositions(new DeskSize(7, 0));

            CollectionAssert.AllItemsAreInstancesOfType(positions1.ToList(), typeof(ChessBoxPosition), "Some null position test");
            CollectionAssert.AllItemsAreInstancesOfType(positions2.ToList(), typeof(ChessBoxPosition), "Some null position test2");
            CollectionAssert.AllItemsAreInstancesOfType(positions1.Positions, typeof(ChessBoxPosition), "Some null position test3");
            CollectionAssert.AllItemsAreInstancesOfType(positions2.Positions, typeof(ChessBoxPosition), "Some null position test4");
        }
Example #4
0
        public int?GetWordPos(int x, int y)
        {
            int?pos = new int?();
            var zzz = AllPositions.FindIndex(z => z.Item1 == x && z.Item2 == y);

            if (zzz >= 0)
            {
                pos = zzz + 1;
            }
            return(pos);
        }
Example #5
0
        /// <summary>
        /// Метод вывода добавленных работников в таблицу
        /// </summary>
        public void ShowWorkers()
        {
            // Извлечение департамента соответственно выбору cmbDepShow
            depCol = AllPositions.Where(x => x.Dep == DepShow).ToList();

            // // Извлечение отделов соответственно выбору cmbDepShow (Цикл нужен, чтобы тип данных DivCol оставался ObservationCollection)
            foreach (var t in depCol)
            {
                if (t.Division == DivisionShow)
                {
                    divCol.Add(t);
                }
            }

            // Извлечение директора соответственно выбору cmbDepShow
            dirCol = AllPositions.Where(x => x.Position == "директор").ToList();

            try
            {
                // Источник вывода работников в таблицу DataGrid allDepWorkers
                DivCol = divCol;

                //Источник вывода директора
                TxtDirector = dirCol.Where(x => x.Dep == DepShow.ToString()).First().Position +
                              " " + DepShow;

                Director director = new Director();

                // Источник вывода зарплаты директора
                TxtDirectorSalary = director.SalaryCalculation(0).ToString() + "$";

                // Вывод имени директора департамента
                TxtDirectorName = dirCol.First().Name;
            }
            catch
            {
                TxtDirector = "Директор не назначен";

                TxtDirectorSalary = null;

                TxtDirectorName = null;
            }
        }
    public void Start()
    {
        Rows [0] = Row1;
        Rows [1] = Row2;
        Rows [2] = Row3;
        Rows [3] = Row4;

        Columns [0] = Column1;
        Columns [1] = Column2;
        Columns [2] = Column3;
        Columns [3] = Column4;

        StartCoroutine(ApplyPositions());

        for (int i = 0; i < 4; i++)
        {
            for (int j = 0; j < 4; j++)
            {
                switch (i)
                {
                case 0:
                    AllPositions.Add(Row1 [j]);
                    break;

                case 1:
                    AllPositions.Add(Row2 [j]);
                    break;

                case 2:
                    AllPositions.Add(Row3 [j]);
                    break;

                case 3:
                    AllPositions.Add(Row4 [j]);
                    break;
                }
            }
        }
    }
Example #7
0
        /// <summary>
        /// Метод добавления сотрудника
        /// </summary>
        /// <returns></returns>
        public ObservableCollection <Worker> AddWorker()
        {
            // Условие добавления директора
            if (Position.Contains("директор"))
            {
                try
                {
                    // Заполнение конструктора добавления директора
                    Director addDirector = new Director(Name, Dep, Position);

                    // Извлечение департамента соответственно выбору cmbDep для проверки наличия директора
                    depCol = AllPositions.Where(x => x.Dep == Dep).ToList();

                    // Условие проверки наличия директора в департаменте
                    if (depCol.Where(x => x.Position.Contains("директор")).Count() == 0)
                    {
                        // Добавление в коллекцию нового директора
                        allPositions.Add(addDirector);
                    }
                    else
                    {
                        MessageBox.Show("Директор уже назначен");
                    }
                }
                catch
                {
                    MessageBox.Show("Проверьте корректность заполнения необходимых полей");
                }

                return(allPositions);
            }
            // Условие добавления стажера
            else if (Position.Contains("стажер") || Position.Contains("интерн"))
            {
                try
                {
                    // Заполнение конструктора добавления интерна\стажера
                    Intern intern = new Intern(Name, Dep, Division, Position, 0, 0);

                    // Добавление в коллекцию нового сотрудника
                    allPositions.Add(intern);
                }
                catch
                {
                    MessageBox.Show("Проверьте корректность заполнения необходимых полей");
                }

                return(AllPositions);
            }
            // Условие добавления сотрудника
            else
            {
                try
                {
                    // Заполнение конструктора добавления сотрудника
                    Employee addEmploee = new Employee(Name, Dep, Division, Position, WorkHour, WorkDays);

                    // Добавление в коллекцию нового сотрудника
                    allPositions.Add(addEmploee);
                }
                catch
                {
                    MessageBox.Show("Проверьте корректность заполнения необходимых полей");
                }

                return(allPositions);
            }
        }
Example #8
0
        ///// <summary>
        ///// 添加轨迹
        ///// </summary>
        ///// <param name="ps"></param>
        //public void AddTracks(Track track)
        //{
        //    Vector d = track.FirstPosition.Position.Point2D - track.EndPosition.Position.Point2D;
        //    if (user.Derection*d.Y>0)
        //    {
        //        Alltracks.Add(track);
        //    }
        //}

        /// <summary>
        /// 清空人的轨迹坐标和球的轨迹数据
        /// </summary>
        public void Clear()
        {
            AllPositions.Clear();
            //Alltracks.Clear();
        }
        static void Main(string[] args)
        {
            // ===============================================
            // Parse Json string from file to object
            // {"name":"FxstarJson","email":["*****@*****.**","*****@*****.**"],"websites":{"home page":"http:\/\/fxstar.eu","blog":"http:\/\/blog.fxstar.eu"}}
            // ===============================================
            using (StreamReader sr = new StreamReader("../../json.txt"))
            {
                String json = sr.ReadToEnd();
                // Parse to Jobject
                JObject o = JObject.Parse(json);

                // Write to console
                Console.WriteLine(json);
                Console.WriteLine("Name: " + o["name"]);
                Console.WriteLine("First email address: " + o["email"][0]);
                Console.WriteLine("Website [blog]: " + o["websites"]["blog"]);
            }
            // wait for key
            Console.ReadKey();

            // ===============================================
            // Get json from web page txt file or php file to object
            // {"name":"FxstarJson","email":["*****@*****.**","*****@*****.**"],"websites":{"home page":"http:\/\/fxstar.eu","blog":"http:\/\/blog.fxstar.eu"}}
            // ===============================================
            WebClient c        = new WebClient();
            var       jsondata = c.DownloadString("https://fxstar.eu/json.php");

            // Parse to Jobject
            JObject jo = JObject.Parse(jsondata);

            // Write to console
            Console.WriteLine(jsondata);
            Console.WriteLine("Name: " + jo["name"]);
            Console.WriteLine("First email address: " + jo["email"][0]);
            Console.WriteLine("Website [blog]: " + jo["websites"]["blog"]);
            // wait for key
            Console.ReadKey();


            // ===============================================
            // Deserialize Json String
            // ===============================================
            string jdata = @"{'data':[{'positionId':7980418,'entryTimestamp':1487151223210,'utcLastUpdateTimestamp':1487151223210,'symbolName':'GBPUSD','tradeSide':'BUY','entryPrice':1.2428,'volume':100000,'stopLoss':null,'takeProfit':null,'profit':-338,'profitInPips':-35.7,'commission':-3,'marginRate':1.17765,'swap':0,'currentPrice':1.23923,'comment':null,'channel':'cAlgo','label':null},{'positionId':123456,'entryTimestamp':1487151223210,'utcLastUpdateTimestamp':1487151223210,'symbolName':'GBPUSD','tradeSide':'BUY','entryPrice':1.2428,'volume':100000,'stopLoss':null,'takeProfit':null,'profit':-338,'profitInPips':-35.7,'commission':-3,'marginRate':1.17765,'swap':0,'currentPrice':1.23923,'comment':null,'channel':'cAlgo','label':null}], 'id': 123, 'name': 'Henio'}";

            // Deserializestring to dynamic object class
            dynamic obj = JsonConvert.DeserializeObject <dynamic>(jdata);

            // Write to console
            Console.WriteLine(obj.data[0].positionId);
            Console.WriteLine(obj.data[1].positionId);
            Console.WriteLine(obj.id);
            Console.WriteLine(obj.name);
            // wait for key
            Console.ReadKey();

            // ===============================================
            // Serialize Json String from class with
            // List with positions
            // ===============================================
            try
            {
                // Create first position
                Position pos1 = new Position();
                pos1.positionId     = "123";
                pos1.symbolName     = "GBPJPY";
                pos1.entryTimestamp = "1499900011";

                // Create second position
                Position pos2 = new Position();
                pos2.positionId     = "456";
                pos2.symbolName     = "PLNJPY";
                pos2.entryTimestamp = "1499955611";

                // Create list with 2 positions
                List <Position> List = new List <Position>();
                List.Add(pos1);
                List.Add(pos2);

                // Create AllPositions object and add text and List with positions
                AllPositions positions = new AllPositions();
                positions.name = "Fxstar";
                positions.id   = 123456;
                positions.data = List;

                // Serialize class
                string outJson = JsonConvert.SerializeObject(positions, Formatting.None);

                // Write to console
                Console.WriteLine("\r\n Serialize Class to Json: " + outJson);
                // wait for key
                Console.ReadKey();
            }catch (Exception e) {
                // Write to console
                Console.WriteLine(e.ToString());
                // wait for key
                Console.ReadKey();
            }
        }
Example #10
0
 public RulesManager(DeskManager desk, AllPositions allPositions, DeskHistoryManager historyManager)
 {
     this.desk           = desk;
     this.allPositions   = allPositions;
     this.historyManager = historyManager;
 }
Example #11
0
 public void Dispose()
 {
     desk           = null;
     allPositions   = null;
     historyManager = null;
 }