Example #1
0
        public void AssignSPAToRow(int rowIndex, SPA <T> spa)
        {
            if (spa.Length != N)
            {
                throw new Exception("Incorrect SPA langth; impossible to assign to a matrix row");
            }

            int prevLength = IA[rowIndex + 1] - IA[rowIndex];

            if (IA[rowIndex] < AN.Count)
            {
                AN.RemoveRange(IA[rowIndex], prevLength);
                JA.RemoveRange(IA[rowIndex], prevLength);
            }

            AN.InsertRange(IA[rowIndex], spa.Data);
            JA.InsertRange(IA[rowIndex], spa.Indices);

            int diff = prevLength - spa.RealLength;

            if (diff != 0)
            {
                for (int i = rowIndex + 1; i < IA.Length; i++)
                {
                    IA[i] -= diff;
                }
            }
        }
Example #2
0
 //function for coordinating junction
 public void CoordinateJunctions(int ToD, int[] PreviousStage, Returner ReturnerVariables)
 {
     foreach (JunctionAgent JA in Junctions)
     {
         JA.MediateAuction(ToD, PreviousStage, ReturnerVariables);
     }
     Strat.ProcessZone(this, ToD, PreviousStage, ReturnerVariables);
     //WriteBidsDataBase(ToD);
     //WriteSITDataBase(ToD);
 }
Example #3
0
File: Form1.cs Project: IchPOch/PPO
 private void sbros_Click(object sender, EventArgs e)
 {
     button_off();
     foreach (DataGridViewRow row in Table.SelectedRows)
     {
         row.Selected = false;
     }
     NM.Clear(); PAG.Clear(); BO.Clear(); OPI.Clear();
     JA.Clear(); CO.Clear();
 }
Example #4
0
        private string BuildLifetimeCondition(string ToD)
        {
            string Condition = "AtTime = '" + ToD + "' AND (";

            foreach (JunctionAgent JA in MainZone.Junctions)
            {
                Condition += JA.BuildLifeTimeString();
            }
            Condition  = Condition.Remove((Condition.Length - 3));
            Condition += ")";
            return(Condition);
        }
Example #5
0
        public void SetElem(long lineNumber, int colNumber, int index, T elem)
        {
            if (index < 0)
            {
                throw new System.IndexOutOfRangeException(
                          (lineNumber.ToString() + ", " + colNumber.ToString() + " OutOfRange exception: illegal index"));
            }
            if (index >= N)
            {
                throw new System.IndexOutOfRangeException(
                          (lineNumber.ToString() + ", " + colNumber.ToString() + " OutOfRange exception: illegal index"));
            }

            int i = JA.IndexOf(index);

            if (i != -1)
            {
                if (!isZero(elem))
                {
                    AN[i] = elem;
                }
                else
                {
                    for (int j = i; j < curCountOfElems - 1; j++)
                    {
                        AN[j] = AN[j + 1];
                        JA[j] = JA[j + 1];
                    }
                    JA[--curCountOfElems] = -1;
                }
            }
            else
            {
                if (!isZero(elem))
                {
                    if (curCountOfElems == AN.Count)
                    {
                        AN.Add(elem);
                        JA.Add(-1);
                    }

                    AN[curCountOfElems] = elem;
                    JA[curCountOfElems] = index;
                    curCountOfElems++;
                }
            }
        }
Example #6
0
        public T GetElem(long lineNumber, int colNumber, int index)
        {
            if (index < 0)
            {
                throw new System.IndexOutOfRangeException(
                          (lineNumber.ToString() + ", " + colNumber.ToString() + " OutOfRange exception: illegal index"));
            }
            if (index >= N)
            {
                throw new System.IndexOutOfRangeException(
                          (lineNumber.ToString() + ", " + colNumber.ToString() + " OutOfRange exception: illegal index"));
            }

            int i = JA.IndexOf(index);

            if (i != -1)
            {
                return(AN[i]);
            }
            return(Zero);
        }
Example #7
0
        public void SetElem(long lineNumber, int colNumber, int index1, int index2, T elem)
        {
            if ((index1 < 0) || (index2 < 0))
            {
                throw new System.IndexOutOfRangeException(
                          (lineNumber.ToString() + ", " + colNumber.ToString() + " OutOfRange exception: illegal index"));
            }
            if ((index1 >= M) || (index2 >= N))
            {
                throw new System.IndexOutOfRangeException(
                          (lineNumber.ToString() + ", " + colNumber.ToString() + " OutOfRange exception: illegal index"));
            }

            int j;

            for (j = IA[index1]; j < IA[index1 + 1]; j++)
            {
                if (JA[j] == index2)
                {
                    break;
                }
            }
            if (j < IA[index1 + 1])
            {
                if (!isZero(elem))
                {
                    AN[j] = elem;
                }
                else
                {
                    for (int k = j; k < curCountOfElems - 1; k++)
                    {
                        AN[k] = AN[k + 1];
                        JA[k] = JA[k + 1];
                    }
                    JA[--curCountOfElems] = -1;
                    for (int k = index1; k < IA.Length; k++)
                    {
                        IA[k] -= 1;
                    }
                    IA[0] = 0;
                }
            }
            else
            {
                if (!isZero(elem))
                {
                    if (curCountOfElems == AN.Count)
                    {
                        AN.Add(elem);
                        JA.Add(-1);
                    }

                    for (int k = index1 + 1; k < IA.Length; k++)
                    {
                        IA[k] += 1;
                    }
                    for (int k = curCountOfElems - 1; k >= IA[index1 + 1] - 1; k--)
                    {
                        AN[k + 1] = AN[k];
                        JA[k + 1] = JA[k];
                    }
                    AN[IA[index1 + 1] - 1] = elem;
                    JA[IA[index1 + 1] - 1] = index2;
                    curCountOfElems++;
                }
            }
        }
Example #8
0
File: Form1.cs Project: IchPOch/PPO
 private void AddBut_Click(object sender, EventArgs e)
 {
     if (NM.Text != "" && BO.Text != "" && OPI.Text != "" && JA.Text != "" && PAG.Text != "")
     {
         DialogResult dr = MessageBox.Show("Добавить запись?",
                                           "Добавление",
                                           MessageBoxButtons.OKCancel,
                                           MessageBoxIcon.Question,
                                           MessageBoxDefaultButton.Button2);
         if (dr == DialogResult.OK)
         {
             bool flag = false;
             for (int i = 0; i < Objects.Count; i++)
             {
                 if (NM.Text == Objects[i].Name &&
                     BO.Text == Objects[i].bookname &&
                     JA.Text == Objects[i].Janr &&
                     OPI.Text == Objects[i].opis ||
                     CO.Text == Objects[i].index.ToString())
                 {
                     flag = true;
                 }
             }
             if (!flag)
             {
                 this.Validate();
                 this.biblBindingSource.EndEdit();
                 DataRow nRow = kursDataSet.Tables[0].NewRow();
                 nRow["Код"]      = CO.Text.ToString();
                 nRow["Имя"]      = NM.Text.ToString();
                 nRow["Книга"]    = BO.Text.ToString();
                 nRow["Жанр"]     = JA.Text.ToString();
                 nRow["Страницы"] = PAG.Text.ToString();
                 nRow["Описание"] = OPI.Text.ToString();
                 kursDataSet.Tables[0].Rows.Add(nRow);
                 biblTableAdapter2.Update(kursDataSet.Bibl);
                 kursDataSet.Tables[0].AcceptChanges();
                 Table.Refresh();
                 Bibl.data_update(this.Table, this.Objects);
                 NM.Clear();
                 BO.Clear();
                 JA.Clear();
                 PAG.Clear();
                 OPI.Clear();
                 CO.Clear();
             }
             if (flag)
             {
                 DialogResult er = MessageBox.Show("Такая запись уже существует!",
                                                   "Добавление",
                                                   MessageBoxButtons.OK,
                                                   MessageBoxIcon.Warning,
                                                   MessageBoxDefaultButton.Button1);
             }
         }
     }
     else
     {
         DialogResult dr = MessageBox.Show("Некорректный ввод! Поля пусты.",
                                           "Добавление",
                                           MessageBoxButtons.OK,
                                           MessageBoxIcon.Information,
                                           MessageBoxDefaultButton.Button1);
     }
 }
        public IHttpActionResult Get()
        {
            var    re      = Request;
            var    headers = re.Headers;
            string token   = "";

            if (headers.Contains("APIKey"))
            {
                token = headers.GetValues("APIKey").First();
            }
            Validation validation = new Validation();
            bool       valid      = validation.CheckApiKey(token);

            if (valid) // APIKey is valid
            {
                using (incposdbEntities entity = new incposdbEntities())
                {
                    var medalsList = (from MA in entity.medalAgent
                                      join M in entity.medals on MA.medalId equals M.medalId into JM
                                      join A in entity.agents on MA.agentId equals A.agentId into JA


                                      join U in entity.users on MA.createUserId equals U.userId into JU
                                      from JMM in JM.DefaultIfEmpty()
                                      from JAA in JA.DefaultIfEmpty()


                                      from JUU in JU.DefaultIfEmpty()

                                      select new MedalAgentModel()
                    {
                        id = MA.id,
                        medalId = MA.medalId,
                        agentId = MA.agentId,

                        notes = MA.notes,
                        isActive = MA.isActive,
                        createDate = MA.createDate,
                        updateDate = MA.updateDate,
                        createUserId = MA.createUserId,
                        updateUserId = MA.updateUserId,
                        agentName = JAA.name,
                        medalName = JMM.name,

                        createUserName = JUU.username,
                    }



                                      ).Select(c => new MedalAgentModel()
                    {
                    })
                                     .ToList();

                    /*
                     *
                     * id
                     * medalId
                     * agentId
                     * offerId
                     * couponId
                     * notes
                     * isActive
                     * createDate
                     * updateDate
                     * createUserId
                     * updateUserId
                     * */
                    // can delet or not


                    if (medalsList == null)
                    {
                        return(NotFound());
                    }
                    else
                    {
                        return(Ok(medalsList));
                    }
                }
            }
            //else
            return(NotFound());
        }