Example #1
0
 public void resetSimulation()
 {
     SaveLoad.Save(new State(), "training.data");
     maxTime = 0;
     agent   = new agent(this, cart, pole, weight, negativeReward, true);
     SceneManager.LoadScene(0);
 }
Example #2
0
        public IQueryable Get()
        {
            agent = db.agents.FirstOrDefault(s => s.name == db.MobileUsers.FirstOrDefault(a => a.AgentMobileId == User.Identity.Name).AgentName);
            var model = db.balDocs.Where(s => s.agent == agent.id);

            return(model);
        }
Example #3
0
        public bool trade(int i, int j)
        {
            agent ai   = seating[i];
            agent aj   = seating[j];
            int   posi = ai.Position;
            int   posj = aj.Position;

            if (ai.getUtility(posi, store) > ai.getUtility(posj, store) ||
                aj.getUtility(posj, store) > aj.getUtility(posi, store))
            {
                return(false);
            }
            else if (ai.getUtility(posi, store) == ai.getUtility(posj, store) &&
                     aj.getUtility(posj, store) == aj.getUtility(posi, store))
            {
                return(false);
            }
            else
            {
                aj.Position = posi;
                ai.Position = posj;
                ai.Traded   = true;
                aj.Traded   = true;
                store[i]    = aj;
                store[j]    = ai;
                return(true);
            }
        }
Example #4
0
        public IQueryable Get()
        {
            agent = db.agents.FirstOrDefault(s => s.name == db.MobileUsers.FirstOrDefault(a => a.AgentMobileId == User.Identity.Name).AgentName);
            var model = db.paymentsHistory.Where(s => s.agent == agent.id).ToList();

            return(model.AsQueryable());
        }
        public async Task <IHttpActionResult> RegisterAgent(agent cust)
        {
            var    email         = cust.Email;
            string code          = string.Empty;
            var    UserManager   = HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>();
            var    SignInManager = HttpContext.Current.GetOwinContext().Get <ApplicationSignInManager>();

            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = email, Email = email
                };
                var result = await UserManager.CreateAsync(user, string.Concat(email, "#3Rp"));

                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);

                    //  var callbackUrl = Request.GetUrlHelper().Link  Request..Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + "\">here</a>");

                    await UserManager.AddToRoleAsync(user.Id, "Agent");

                    return(Ok(code));
                }
            }
            return(Content(HttpStatusCode.NotAcceptable, code));
            // If we got this far, something failed, redisplay form
        }
        // GET: agents/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            agent agent = db.agents.Find(id);

            if (agent == null)
            {
                return(HttpNotFound());
            }
            double?payment   = db.agent_payment.Where(a => a.id_agent == id).AsEnumerable().Sum(x => x.amount);
            double?totalBill = db.bill_out.Where(a => a.id_agent == id).AsEnumerable().Sum(b => b.total);
            double?owe       = totalBill - payment;

            if (owe == null)
            {
                owe = 0;
            }
            if (payment == null)
            {
                payment = 0;
            }
            ViewBag.owe  = owe;
            ViewBag.paid = payment;
            ViewBag.aid  = agent.id;
            return(View(agent));
        }
Example #7
0
 public AgentesRobots(int width, int height, int countChildren, int countBlocking, int countDirt)
 {
     report       = "";
     calification = false;
     t            = 0;
     T            = 0;
     rand         = new Random();
     things       = new agent[width, height];
     for (int i = 0; i < width; i++)
     {
         for (int j = 0; j < height; j++)
         {
             things[i, j] = agent.empty;
         }
     }
     this.countChildren = countChildren;
     this.countBlocking = countBlocking;
     this.countDirt     = countDirt;
     childrenLess       = countChildren;
     dirtLess           = countDirt;
     CorralGenerator();
     BoardGenerator(countBlocking, agent.blocking);
     BoardGenerator(countDirt, agent.dirt);
     BoardGenerator(countChildren, agent.children);
     BoardGenerator(1, agent.robot);
 }
Example #8
0
 // PUT: api/Agents/5
 public bool Put(int id, agent value)
 {
     using (var db = new OcphDbContext())
     {
         return(db.Agents.Update(O => new { O.Address, O.CityID, O.ContactName, O.Email, O.Handphone, O.Name, O.NPWP, O.Phone },
                                 value, O => O.Id == value.Id));
     }
 }
        public ActionResult DeleteConfirmed(int id)
        {
            agent agent = db.agents.Find(id);

            db.agents.Remove(agent);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        private void DumyRobot()
        {
            int   x     = 0;
            int   y     = 0;
            agent temp1 = agent.empty;

            for (int i = 0; i < board.things.GetLength(0); i++)
            {
                for (int j = 0; j < board.things.GetLength(1); j++)
                {
                    if (board.things[i, j] == agent.robot || board.things[i, j] == agent.corralRobot || board.things[i, j] == agent.robotChildren ||
                        board.things[i, j] == agent.corralRobotChildren || board.things[i, j] == agent.dirtRobot || board.things[i, j] == agent.dirtRobotChildren)
                    {
                        x     = i;
                        y     = j;
                        temp1 = board.things[i, j];
                    }
                }
            }
            int r = 0;

            if (temp1 == agent.robot || temp1 == agent.robotChildren || temp1 == agent.dirtRobotChildren || temp1 == agent.corralRobot)
            {
                while (true)
                {
                    r = board.rand.Next(0, 4);
                    if (0 <= x + board.moveX[r] && x + board.moveX[r] < board.things.GetLength(0) && 0 <= y + board.moveY[r] && y + board.moveY[r] < board.things.GetLength(1) &&
                        board.things[x + board.moveX[r], y + board.moveY[r]] != agent.blocking && board.things[x + board.moveX[r], y + board.moveY[r]] != agent.corralFull &&
                        ((temp1 != agent.dirtRobotChildren && temp1 != agent.robotChildren) || board.things[x + board.moveX[r], y + board.moveY[r]] != agent.children))
                    {
                        board.Combine(x + board.moveX[r], y + board.moveY[r], temp1);
                        board.Split(x, y);
                        break;
                    }
                }
            }
            if (temp1 == agent.corralRobotChildren)
            {
                while (true)
                {
                    r = board.rand.Next(0, 4);
                    if (0 <= x + board.moveX[r] && x + board.moveX[r] < board.things.GetLength(0) && 0 <= y + board.moveY[r] && y + board.moveY[r] < board.things.GetLength(1) &&
                        board.things[x + board.moveX[r], y + board.moveY[r]] != agent.blocking && board.things[x + board.moveX[r], y + board.moveY[r]] != agent.corralFull)
                    {
                        board.Combine(x + board.moveX[r], y + board.moveY[r], temp1);
                        board.Split(x, y);
                        board.childrenLess--;
                        break;
                    }
                }
                board.Combine(x, y, agent.children);
            }
            if (temp1 == agent.dirtRobot)
            {
                board.things[x, y] = agent.robot;
                board.dirtLess--;
            }
        }
Example #11
0
        public string SaveFromFile(string file)
        {
            agent = db.agents.FirstOrDefault(s => s.name == db.MobileUsers.FirstOrDefault(a => a.AgentMobileId == User.Identity.Name).AgentName);
            string model;

            using (System.IO.StreamReader fileStr =
                       new System.IO.StreamReader(@"D:\order\logPayment\" + file + ".txt"))
            {
                model = fileStr.ReadToEnd();
            }
            try
            {
                using (System.IO.StreamWriter fileLog =
                           new System.IO.StreamWriter(@"D:\order\logPayment\" + agent.name + ".txt"))
                {
                    fileLog.WriteLine("{0}", model);
                }
                try
                {
                    var log = new logsString {
                        id = 0, agent = agent.name, content = model, date = DateTime.Now
                    };
                    db.Entry(log).State = EntityState.Added;
                    db.SaveChanges();
                    var logs = JsonConvert.DeserializeObject <logsPayment[]>(model);
                    foreach (var item in logs.ToList())
                    {
                        item.timeStampServer = DateTime.Now;
                        db.Entry(item).State = EntityState.Added;
                        db.SaveChanges();
                    }
                    var pays = JsonConvert.DeserializeObject <Payment[]>(model);
                    foreach (var a in pays.ToList())
                    {
                        foreach (var c in db.Payments.Where(o => o.agent == a.agent && o.customer == a.customer).ToList())
                        {
                            db.Entry(c).State = EntityState.Deleted;
                            db.SaveChanges();
                        }
                    }
                    foreach (var item in pays)
                    {
                        db.Entry(item).State = EntityState.Added;
                        db.SaveChanges();
                    }
                    return("Записано");
                }
                catch (Exception ex)
                {
                    return(ex.Message);
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Example #12
0
        private void AgentToolStripButton_main_Click(object sender, EventArgs e)    //Открытие формы агентов
        {
            agent form = new agent(sqliteConnection);

            this.Hide();
            form.ShowDialog();
            this.Show();
            loadChart();
        }
        public void showMain(System.Windows.Forms.TreeNode currentNode)
        {
            clearCellValueChangedEvent();
            clearCellClickEvent();
            if (currentNode.Name == "ctiDrive")
            {
                ConfigLeaf.ctiDrive cti = new ConfigLeaf.ctiDrive();
                cti.showDataGridView(dataGridView1);
                MainConfigAreaTitle.Text = "CTI数据库配置";
            }
            else if (currentNode.Name == "drivesConfig")
            {
                drivesConfig drivesConfig = new drivesConfig();
                drivesConfig.showDataGridView(dataGridView1);
                MainConfigAreaTitle.Text = "分机,坐席设备";
            }
            else if (currentNode.Name == "URLConfig")
            {
                URLConfig URLConfig = new URLConfig();
                URLConfig.showDataGridView(dataGridView1);
                MainConfigAreaTitle.Text = "URL跳转配置";
            }
            else if (currentNode.Name == "agent" || currentNode.Name == "agentConfig")
            {
                agent agent = new agent();
                agent.showDataGridView(dataGridView1);
                MainConfigAreaTitle.Text = "坐席配置";
            }
            else if (currentNode.Name == "agentGroup")
            {
                showSonNode(currentNode);
                agentGroup ag = new agentGroup();
                ag.esunnetConfig = this;
                ag.showDataGridView(dataGridView1);
                MainConfigAreaTitle.Text = "坐席组配置";
            }
            else if (currentNode.Name == "agentStatus")
            {
                agentStatus ageSta = new agentStatus();

                ageSta.showDataGridView(dataGridView1);
                MainConfigAreaTitle.Text = "坐席忙碌原因";
            }
            else if (currentNode.Parent != null)
            {
                if (currentNode.Parent.Name == "agentGroup")
                {
                    string[]       fullName = currentNode.Name.Split('<');
                    agentGroupLeaf aGL      = new agentGroupLeaf();
                    aGL.groupId = fullName[1];
                    aGL.showDataGridView(dataGridView1);
                    MainConfigAreaTitle.Text = "坐席组" + fullName[1];
                }
                ;
            }
            ;
        }
Example #14
0
 public void resetSimulation(string logFileName)
 {
     SaveLoad.Save(new State(), "trainingX.data");
     SaveLoad.Save(new State(), "trainingZ.data");
     maxTime = 0;
     agentX  = new agent(this, cart, pole, weight, negativeReward, true);
     agentZ  = new agent(this, cart, pole, weight, negativeReward, false);
     File.CreateText(Application.persistentDataPath + "/" + logFileName);
     SceneManager.LoadScene(0);
 }
Example #15
0
        public IQueryable Get()
        {
            agent = db.agents.FirstOrDefault(s => s.name == db.MobileUsers.FirstOrDefault(a => a.AgentMobileId == User.Identity.Name).AgentName);
            var dep    = db.agents.Where(s => s.id == agent.id).FirstOrDefault().dep;
            var groups = db.GoodsAgents.Where(s => s.dep == dep);
            var list   = db.Groups.Where(s => groups.Any(g => s.tree.Contains(g.code)) || groups.Any(t => s.GroupId == t.code));
            var root   = db.Groups.Where(s => (list.Any(g => g.tree.Contains(s.GroupId)) || list.Any(g => g.GroupId == s.GroupId)));

            return(db.Items.Where(s => root.Any(r => s.tree.Contains(r.GroupId))));
        }
 public ActionResult Edit([Bind(Include = "id,name,addr,phone")] agent agent)
 {
     if (ModelState.IsValid)
     {
         db.Entry(agent).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(agent));
 }
Example #17
0
 /// <summary>
 /// add a new mutex
 /// </summary>
 public void AddMutex(agent a1, agent a2)
 {
     int index = MutexExists(a1, a2);
     if (index == -1)
     {
         agent[] mutex = new agent[2];
         mutex[0] = a1;
         mutex[1] = a2;
         mutexes.Add(mutex);
     }
 }
Example #18
0
    void Start()
    {
        startUp = GameObject.Find("Main Camera").GetComponent("OnStartUp") as OnStartUp;

        inputPath = startUp.inputPath;

        ReadFile rf = new ReadFile();

        rf.read(inputPath);

        maxAgents = rf.maxAgents;

        agentFrames = rf.agentFrames;
        agentCoords = rf.agentCoords;
        deltas      = rf.deltas;
        distances   = rf.distances;

        agentNum = 0;

        /* Create all of the agents from the specified file. */
        for (int count = 0; count < agentFrames.Count; count += 2)
        {
            a = ScriptableObject.CreateInstance <agent>();

            a.setStart(agentFrames[count]);
            a.setDur(agentFrames[count + 1]);
            a.setCoords(agentCoords);
            a.setDeltas(deltas);
            a.setDistance(distances);
            a.id = agentNum;

            agentList.Add(a);

            int range = agentFrames[count + 1] + 1;
            if (range < agentCoords.Count)
            {
                agentCoords.RemoveRange(0, range);
                deltas.RemoveRange(0, range);
                distances.RemoveRange(0, range);
            }
            agentNum++;
        }

        //agentNum = 0;
        //while (agentNum < maxAgents)
        //{

        //    if (0 == agentList[agentNum].getStart())
        //    {
        //        agentList[agentNum].create();
        //    }
        //    agentNum++;
        //}
    }
Example #19
0
 public IHttpActionResult Put(int id, [FromBody] agent value)
 {
     try
     {
         return(Ok(context.Put(id, value)));
     }
     catch (Exception ex)
     {
         return(Content(HttpStatusCode.NotFound, ex.Message));
     }
 }
        public ActionResult Create([Bind(Include = "id,name,addr,phone")] agent agent)
        {
            if (ModelState.IsValid)
            {
                db.agents.Add(agent);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(agent));
        }
Example #21
0
 public IQueryable Get()
 {
     agent = db.agents.FirstOrDefault(s => s.name == db.MobileUsers.FirstOrDefault(a => a.AgentMobileId == User.Identity.Name).AgentName);
     try
     {
         return(db.Plans.Where(s => s.agent == agent.id));
     }
     catch (Exception ex)
     {
         return(new List <Plan>().AsQueryable());
     }
 }
Example #22
0
 public IActionResult Get()
 {
     try
     {
         agent = db.agents.FirstOrDefault(s => s.name == db.MobileUsers.FirstOrDefault(a => a.AgentMobileId == User.Identity.Name).AgentName);
         var model = db.Customers.Where(m => m.idAgent.Trim() == agent.id).OrderBy(s => s.Kontr);
         return(Ok(model));
     }
     catch (Exception ex)
     {
         return(Ok(ex.Message));
     }
 }
Example #23
0
        public IQueryable Get()
        {
            agent = db.agents.FirstOrDefault(s => s.name == db.MobileUsers.FirstOrDefault(a => a.AgentMobileId == User.Identity.Name).AgentName);
            var dep       = db.agents.Where(s => s.id == agent.id).FirstOrDefault().dep;
            var groups    = db.GoodsAgents.Where(s => s.dep == dep);
            var list      = db.Groups.Where(s => groups.Any(g => s.tree.Contains(g.code)) || groups.Any(t => s.GroupId == t.code));
            var root      = db.Groups.Where(s => list.Any(g => g.tree.Contains(s.GroupId)) || list.Any(g => g.GroupId == s.GroupId));
            var items     = db.Items.Where(s => root.Any(r => s.tree.Contains(r.GroupId)));
            var customers = db.Customers.Where(m => m.idAgent.Trim() == agent.id);
            var model     = db.Prices.Where(s => (items.Any(i => i.ItemId == s.TovId) || root.Any(i => i.GroupId == s.TovId)) && customers.Any(c => c.idKontr == s.KnId)).Select(s => new { KnId = s.KnId, TovId = s.TovId, Price = s.Price1, Discount = s.Discount });

            return(model);
        }
Example #24
0
 public AgentEditVM(agent item)
 {
     this.CitySourceView = Common.ResourcesBase.GetMainWindowViewModel().CityCollection.SourceView;
     this.Address        = item.Address;
     this.ContactName    = item.ContactName;
     this.Email          = item.Email;
     this.Handphone      = item.Handphone;
     this.Id             = item.Id;
     this.Name           = item.Name;
     this.Phone          = item.Phone;
     this.CityID         = item.CityID;
     this.NPWP           = item.NPWP;
 }
Example #25
0
 public agent GetAgentById(int id)
 {
     try
     {
         gestion_agentEntities1 context = new gestion_agentEntities1();
         agent t = context.agent.Where(e => e.id == id).FirstOrDefault <agent>();
         return(t);
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #26
0
 /// <summary>
 /// Get unit of product by name
 /// </summary>
 /// <param name="name">unit name</param>
 /// <returns></returns>
 public agent GetAgentBLByName(string name)
 {
     try
     {
         gestion_agentEntities1 context = new gestion_agentEntities1();
         agent t = context.agent.Where(e => e.Nom == name).FirstOrDefault <agent>();
         return(t);
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #27
0
 public IHttpActionResult Post(agent value)
 {
     try
     {
         var    result   = context.Post(value);
         string username = User.Identity.Name;
         context.BroadcastData(result);
         return(Ok(result));
     }
     catch (Exception ex)
     {
         return(Content(HttpStatusCode.NotFound, ex.Message));
     }
 }
Example #28
0
        internal async Task <bool> Update(int id, agent newitem)
        {
            SourceView.Refresh();
            var res = await client.PutAsync <agent>("Put", newitem.Id, newitem);

            if (res != default(agent))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #29
0
 public bool canMoveGap(agent.Action where)
 {
     bool retVal = true;
     int absPos = getPositionOf(0);
     if (where.Equals(LEFT))
     retVal = (getYCoord(absPos) != 0);
     else if (where.Equals(RIGHT))
     retVal = (getYCoord(absPos) != 2);
     else if (where.Equals(UP))
     retVal = (getXCoord(absPos) != 0);
     else if (where.Equals(DOWN))
     retVal = (getXCoord(absPos) != 2);
     return retVal;
 }
        // GET: agents/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            agent agent = db.agents.Find(id);

            if (agent == null)
            {
                return(HttpNotFound());
            }
            return(View(agent));
        }
Example #31
0
        /// <summary>
        /// the given agent makes a request to run
        /// </summary>
        public bool RequestPermission(agent a)
        {
            bool has_permission = true;

            int i = 0;
            while ((i < mutexes.Count) && (has_permission))
            {
                agent[] mutex = (agent[])mutexes[i];
                if ((mutex[0] == a) && (mutex[1].running)) has_permission = false;
                if ((mutex[0].running) && (mutex[1] == a)) has_permission = false;
                i++;
            }

            return(has_permission);
        }
Example #32
0
        public async Task <bool> Add(agent item)
        {
            var res = await client.PostAsync <agent>("Post", item);

            if (res != null)
            {
                Source.Add(res);
                SourceView.Refresh();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #33
0
 // PUT: api/Agent/5
 public IHttpActionResult Put(int id, [FromBody] agent value)
 {
     try
     {
         if (value == null || !IsValid(value))
         {
             throw new SystemException("Periksa Kembali Data Anda");
         }
         return(Ok(agentContext.Update(value)));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Example #34
0
 /// <summary>
 /// is the given mutex exists return its index
 /// </summary>
 private int MutexExists(agent a1, agent a2)
 {
     int index = -1;
     int i = 0;
     while ((i < mutexes.Count) && (index == -1))
     {
         agent[] mutex = (agent[])mutexes[i];
         if (((mutex[0] == a1) && (mutex[1] == a2)) ||
             ((mutex[0] == a2) && (mutex[1] == a1)))
             index = i;
         i++;
     }
     return(index);
 }
Example #35
0
 /// <summary>
 /// remove a mutex
 /// </summary>
 public void RemoveMutex(agent a1, agent a2)
 {
     int index = MutexExists(a1, a2);
     if (index > -1) mutexes.RemoveAt(index);
 }