Пример #1
0
        static void Main(string[] args)
        {
            var model        = new FirstModel();
            var orchestrator = new Orchestrator(8, 40);

            orchestrator.Run();
        }
Пример #2
0
    public void set_firstModel(FirstModel firstModel)
    {
//        /**
//			 * ipad
//				width 图片宽度  3264
//				hight 图片高度  2448
//				x 点横坐标  起始点为图片左上角
//				y 点纵坐标  起始点为图片左上角
//				pic_x = (x - (width/2.f))/2.25
//				pic_y = (higth/2 - y)/2.25
//		*/
//        float width = 3264;
//        float hight = 2448;
//        float pic_x = (firstModel.x - (width / 2f)) / 2.238f;
//        float pic_y = (hight / 2f - firstModel.y) / 2.238f;
//        GetComponent<RectTransform>().anchoredPosition3D = new Vector3(pic_x, pic_y, 0);
//        EventTriggerListener.Get(gameObject).onDown = set_isOpen;
//
//        for (int j = 0; j < firstModel.point_info.Count; j++)
//        {
//            var btn_2 = transform.Find("sbtn_0_" + j);
//            pointSp psp = (pointSp)btn_2.GetComponent(typeof(pointSp));
//            SecondModel secondModel = firstModel.point_info[j];
//            psp.set_secondModel(secondModel, j);
//            EventTriggerListener.Get(btn_2.gameObject).onDown = ButtonOnClick;
//        }
    }
Пример #3
0
    public ActionResult Index()
    {
        var first  = new FirstModel();
        var second = new SecondModel();

        return(View(Tuple.Create(first, second)));
    }
Пример #4
0
    //point_type 气泡  1 警告、2 提示、3 数据(折线图)、4 文件、5 打开
    public void updataPointsData(FirstModel firstModel)
    {
        var firstDisplayImageName = "";

        if (firstModel.point_type == 1)
        {
            firstDisplayImageName = "firstbtns/1";
        }
        else if (firstModel.point_type == 2)
        {
            firstDisplayImageName = "firstbtns/2";
        }
        else if (firstModel.point_type == 3)
        {
            firstDisplayImageName = "firstbtns/3";
        }
        else if (firstModel.point_type == 4)
        {
            firstDisplayImageName = "firstbtns/4";
        }
        else if (firstModel.point_type == 5)
        {
            firstDisplayImageName = "firstbtns/5";
        }
        GetComponent <Image>().sprite = Resources.Load <Sprite>(firstDisplayImageName);
        for (int j = 0; j < firstModel.point_info.Count; j++)
        {
            var btn_2 = transform.Find("sbtn_0_" + j);
//            pointSp psp = (pointSp)btn_2.GetComponent(typeof(pointSp));
            SecondModel secondModel = firstModel.point_info[j];
//            psp.set_secondModel(secondModel, j);
        }
    }
Пример #5
0
 public Forager(CancellationToken cancellationToken,
                Func <Neighbourhood> neighbourhoodFunc,
                FirstModel model)
 {
     _cancellationToken = cancellationToken;
     _neighbourhoodFunc = neighbourhoodFunc;
     _model             = model;
 }
Пример #6
0
        public ActionResult Index()
        {
            home_img   home_img  = new home_img();
            home_text  home_text = new home_text();
            FirstModel model     = new FirstModel();

            model.home_img  = db.home_img.ToList();
            model.home_text = db2.home_text.ToList();
            return(View("Index", model));
        }
Пример #7
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (db != null)
         {
             db.Dispose();
             db = null;
         }
     }
 }
public class ActionResult Save(MyViewModel vmData)
{
    FirstModel  firstModel  = new FirstModel();
    SecondModel secondModel = new SecondModel();

    firstModel.MyDetails   = vmData.MyDetails;
    secondModel.MyDetails  = vmData.MyDetails2;
    secondModel.FirstModel = firstModel;
    db.SecondModel.Add(secondModel);
    db.SaveChanges();
}
Пример #9
0
        public Scout(FirstModel model, int id,
                     Action <double, Idea, int> dance,
                     Action <Idea, double> report,
                     CancellationToken cancellationToken)
        {
            _model             = model;
            _id                = id;
            _dance             = dance;
            _report            = report;
            _cancellationToken = cancellationToken;
            var newIdea = Idea.NewIdea();

            _currentNeighbourhood = new Neighbourhood(newIdea, _model.Fitness(newIdea));
        }
Пример #10
0
        public void Post([FromBody] FirstModel item)
        {
            conn.ConnectionString = @"server=localhost;port=3306;uid=root;pwd=root;database=haberler;";
            try
            {
                conn = new MySql.Data.MySqlClient.MySqlConnection(conn.ConnectionString);
                conn.Open();
                Debug.WriteLine("Bağlandı");
            }
            catch (MySql.Data.MySqlClient.MySqlException ex)
            {
                Debug.WriteLine("HATA");
            }
            string       sqlText = "Insert into dbhaber (Id,tur,HaberHeader,HaberContent,LikeNum,UnlikeNum,ViewNum) values(@Id,@tur,@HaberHeader,@HaberContent,@LikeNum,@UnlikeNum,@ViewNum)";
            MySqlCommand sqlCmd  = new MySqlCommand(sqlText, conn);
            string       NextId  = "Select MAX(Id) from dbhaber";
            MySqlCommand getId   = new MySqlCommand(NextId, conn);
            int          NextIdValue;

            if (Convert.IsDBNull(getId.ExecuteScalar()))
            {
                NextIdValue = 0;
            }
            else
            {
                NextIdValue = Convert.ToInt32(getId.ExecuteScalar()) + 1;
            }
            sqlCmd.Parameters.AddWithValue("@Id", NextIdValue);
            sqlCmd.Parameters.AddWithValue("@tur", item.tur);
            sqlCmd.Parameters.AddWithValue("@HaberHeader", item.HaberHeader);
            sqlCmd.Parameters.AddWithValue("@HaberContent", item.HaberContent);
            sqlCmd.Parameters.AddWithValue("@LikeNum", 0);
            sqlCmd.Parameters.AddWithValue("@UnlikeNum", 0);
            sqlCmd.Parameters.AddWithValue("@ViewNum", 0);
            int i = sqlCmd.ExecuteNonQuery();

            conn.Close();
            done = true;
            if (i >= 1)
            {
                Debug.WriteLine("Haber Eklendi");
            }
        }
Пример #11
0
        public static async Task Main(string[] args)
        {
            IHost host = CreateHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;

                try
                {
                    var myDbContext = services.GetService <MyDbContext>();
                    await myDbContext.Database.MigrateAsync();

                    if (!await myDbContext.MyCoolModels.AnyAsync())
                    {
                        var first  = new FirstModel();
                        var second = new SecondModel();
                        myDbContext.Firsts.Add(first);
                        myDbContext.Seconds.Add(second);
                        await myDbContext.SaveChangesAsync();

                        myDbContext.MyCoolModels.Add(new MyCoolModel()
                        {
                            SomeText = "Hello World",
                            First    = first,
                            Second   = second
                        });
                        await myDbContext.SaveChangesAsync();
                    }
                }
                catch (Exception ex)
                {
                    var logger = services.GetRequiredService <ILogger <Program> >();
                    logger.LogError(ex, "An error occurred migrating the DB.");
                }
            }

            await host.RunAsync();
        }
Пример #12
0
 public GenericRepository()
 {
     this.db = new FirstModel();
 }
Пример #13
0
 public FirstViewModel(Storage storage)
 {
     FModel = new FirstModel(storage);
     _date  = DateTime.Today.Date;
 }
Пример #14
0
        public Orchestrator(int scouts, int localSearchers)
        {
            _syncs = new ManualResetEvent[scouts];

            void DanceFunc(double fitness, Idea idea, int scoutId)
            {
                var neighbourhood = new Neighbourhood(idea, fitness);

                lock (Synlock)
                {
                    _danceFloor.Add(neighbourhood);
                    _syncs[scoutId].Set();
                }

                Thread.Sleep((int)fitness);
                lock (Synlock)
                {
                    _danceFloor.Remove(neighbourhood);
                    _syncs[scoutId].Reset();
                }
            }

            void ReportFunc(Idea idea, double fitness)
            {
                Console.WriteLine($"Reporting {idea} {fitness}");
                lock (Synlock)
                {
                    if (Ideas.ContainsKey(idea))
                    {
                        return;
                    }

                    Ideas.Add(idea, fitness);
                    if (!Fitnesses.ContainsKey(fitness))
                    {
                        Fitnesses.Add(fitness, new List <Idea>());
                    }

                    Fitnesses[fitness].Add(idea);
                }
            }

            Neighbourhood ForagerFunc()
            {
                WaitHandle.WaitAny(_syncs);
                lock (Synlock)
                {
                    if (!_danceFloor.Any())
                    {
                        return(null);
                    }

                    var dancer = _danceFloor[Random.Next(0, _danceFloor.Count - 1)];
                    return(dancer);
                }
            }

            var model = new FirstModel();

            _scouts = new Scout[scouts];
            for (int i = 0; i < scouts; i++)
            {
                _syncs[i]  = new ManualResetEvent(false);
                _scouts[i] = new Scout(model,
                                       i,
                                       DanceFunc,
                                       ReportFunc,
                                       _cancellationTokenSource.Token);

                _scouts[i].Search();
            }

            _foragers = new Forager[localSearchers];
            for (int i = 0; i < localSearchers; i++)
            {
                _foragers[i] = new Forager(_cancellationTokenSource.Token, ForagerFunc, model);
                _foragers[i].Search();
            }
        }
Пример #15
0
 void Awake()
 {
     Instance = this;
 }
Пример #16
0
 public string PostDdata(FirstModel model)
 {
     return(model.Name);
 }