コード例 #1
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="AttachedContext" />
 ///     class.
 /// </summary>
 /// <param name="contextStack">The context stack.</param>
 /// <param name="context">The context.</param>
 /// <exception cref="System.ArgumentNullException">contextStack</exception>
 /// <autogeneratedoc />
 /// TODO Edit XML Comment Template for #ctor
 public AttachedContext(ContextStack <InfoContext> contextStack, InfoContext context)
 {
     _contextStack =
         contextStack ?? throw new ArgumentNullException(nameof(contextStack));
     _infoContext = context;
     contextStack.Push(_infoContext);
 }
コード例 #2
0
ファイル: FaceForm.cs プロジェクト: regata-jinr/Extensions
        public FaceForm()
        {
            InitializeComponent();

            _cts = new CancellationTokenSource();

            _currentSpectra    = new List <string>();
            _nonExistedSpectra = new List <string>();
            chosenSpectra      = new Dictionary <string, string>();

            ImageList il = new ImageList();

            il.Images.Add(Properties.Resources.untick);
            il.Images.Add(Properties.Resources.tick);
            il.ImageSize = new Size(50, 50);

            listView1.View           = View.LargeIcon;
            listView1.LargeImageList = il;

            try
            {
                _fillSpectra = Task.Run(() =>
                {
                    using (var ic = new InfoContext())
                    {
                        _currentSpectra = ic.SharedSpectra.Select(s => s.fileS).ToList();
                    }
                });
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка при загрузке спектров", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
コード例 #3
0
        public InfoContext GetInfoContext(DbContext context)
        {
            var infoContext = new InfoContext(context.Database.Connection, contextOwnsConnection: false);

            infoContext.Database.Initialize(force: false);
            return(infoContext);
        }
コード例 #4
0
ファイル: WrenchProject.cs プロジェクト: retahc/old-code
            // TODO: Use varying persistence storages; right now
            // we only ever use FileStateTable.

            public ProviderInfo(short id, WrenchProject proj)
            {
                this.id = id;

                pp = FileStateTable.Load(GetStatePath(proj), proj.Log);

                context = new InfoContext(proj.Graph.GetProviderDeclarationLoc(id), proj);
            }
コード例 #5
0
        public ActionResult FillCity(int state)
        {
            InfoContext db = new InfoContext();

            var cities = db.CityList.Where(c => c.StateId == state);

            return(Json(cities, JsonRequestBehavior.AllowGet));
        }
コード例 #6
0
 public ActionResult GetData()
 {
     using (InfoContext db = new InfoContext())
     {
         var EmoloyeeData = db.InfoList.OrderBy(a => a.Name).ToList();
         return(Json(new { data = EmoloyeeData }, JsonRequestBehavior.AllowGet));
     }
 }
コード例 #7
0
        public ActionResult Add()
        {
            InfoContext db = new InfoContext();

            ViewBag.StateList = db.StateList;
            var model = new Information();

            return(View(model));
        }
コード例 #8
0
        public ReweightsInfoForm(int loadNumber) : base(typeof(ReweightsInfoForm).Name)
        {
            InitializeComponent();
            ChangeLanguageOfControlsTexts(Controls);

            using (var ic = new InfoContext(Settings.ConnectionString))
            {
                DataGridView.DataSource = ic.Reweights.Where(r => r.loadNumber == loadNumber).ToList();
            }
        }
コード例 #9
0
        public void EnumeratorTest( )
        {
            const string name          = "test";
            const string objectContext = "hello";
            var          x             = new InfoContext(name, objectContext);
            var          objects       = x.ToList( );

            Assert.Equal(2, objects.Count);
            Assert.Equal(name, objects[0]);
            Assert.Equal(objectContext, objects[1]);
        }
コード例 #10
0
        public ActionResult Edit(Information model)
        {
            var q = new InfoContext();


            if (ModelState.IsValid)
            {
                q.Entry(model).State = EntityState.Modified;
                q.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View());
        }
コード例 #11
0
        public ActionResult Add(Information model)
        {
            InfoContext db = new InfoContext();

            if (ModelState.IsValid)
            {
                db.InfoList.Add(model);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.StateList = db.StateList;
            return(View(model));
        }
コード例 #12
0
        private void buttonExportToSC_Click(object sender, EventArgs e)
        {
            try
            {
                var cnt = 0;
                foreach (var dlb in DetectorsListBoxes)
                {
                    cnt += dlb.CheckedItems.Count;
                }

                if (cnt == 0)
                {
                    MessageBox.Show("Вы не распределили контейнеры по детекторам", "Ошибка при распределении контейнеров", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }


                using (var ic = new InfoContext(ConString))
                {
                    var recs = ic.Records.FromSqlInterpolated($"exec ContainersToDetector {_loadNumber}").ToList();
                    if (recs.Where(r => r.Container_Number == null).Any())
                    {
                        MessageBox.Show("В журнале не должно быть образцов, не принадлижащих ни одному из контейнеров!", "Ошибка при распределении контейнеров", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    var res = folderBrowserDialog1.ShowDialog();
                    if (res == DialogResult.Cancel)
                    {
                        return;
                    }

                    foreach (var dlb in DetectorsListBoxes)
                    {
                        if (dlb.CheckedItems.Count == 0)
                        {
                            continue;
                        }

                        SaveRecordsToCSV(recs.Where(r => dlb.CheckedItems.Contains(r.Container_Number.ToString()) && !r.SampleSet.StartsWith("m-m")).ToList(), dlb.Name.Substring(dlb.Name.Length - 2));
                    }
                }
                //buttonExportToExcel.Enabled = true;
                MessageBox.Show("Распределение прошло успешно", "Распределение контейнеров по детекторам", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"При распределении контейнеров произошла ошибка{Environment.NewLine}{ex.Message}", "Ошибка при распределении контейнеров", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #13
0
        public async Task <ActionResult> About(string name, string location, string dateIn, string dateOut, string currentUser)
        {
            // upload to firebase <----this works
            var currentTestData = new InfoContext()
            {
                Name        = name,
                Location    = location,
                DateIn      = dateIn,
                DateOut     = dateOut,
                CurrentUser = currentUser
            };
            var client = new Firebase.Database.FirebaseClient("https://clddb-a63b0-default-rtdb.firebaseio.com/");
            await client
            .Child("Garden")
            .Child(currentUser)
            .PostAsync(currentTestData);

            return(View());
        }
コード例 #14
0
        public ActionResult Edit(int?id)
        {
            var q = new InfoContext();

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Information stu = q.InfoList.Find(id);

            if (id == null)
            {
                return(HttpNotFound());
            }
            ;


            return(View(stu));
        }
コード例 #15
0
        public ShowSetContentForm(string setKey) : base(typeof(ShowSetContentForm).Name)
        {
            SetKey = setKey;
            _ic    = new InfoContext(Settings.ConnectionString);
            InitializeComponent();

            var sk  = setKey.Split('-');
            var lst = _ic.Samples.Where(s => s.F_Country_Code == sk[0] && s.F_Client_Id == sk[1] && s.F_Year == sk[2] && s.F_Sample_Set_Id == sk[3] && s.F_Sample_Set_Index == sk[4]).ToList();

            DataGridView.RowsAdded += DataGridView_RowsAdded;
            DataGridView.ColumnHeaderMouseDoubleClick += DataGridView_ColumnHeaderMouseDoubleClick;
            Load += ShowSetContentForm_Load;
            Settings.LanguageChanged += Settings_LanguageChanged;
            //DataGridView.CellValidating += DataGridView_CellValidating;
            DataGridView.CellValueChanged += DataGridView_CellValueChanged;

            foreach (var l in lst)
            {
                Data.Add(l);
            }

            ButtonSaveToDB.Enabled = false;
            HideColumnsWithIndexes(0, 1, 2, 3, 4);
        }
コード例 #16
0
ファイル: ContactController.cs プロジェクト: bzeller7/SCM
 public ContactController(InfoContext dbContext)
 {
     context = dbContext;
 }
コード例 #17
0
ファイル: WrenchProject.cs プロジェクト: emtees/old-code
	    // TODO: Use varying persistence storages; right now
	    // we only ever use FileStateTable.

	    public ProviderInfo (short id, WrenchProject proj) 
	    {
		this.id = id;

		pp = FileStateTable.Load (GetStatePath (proj), proj.Log);

		context = new InfoContext (proj.Graph.GetProviderDeclarationLoc (id), proj);
	    }
コード例 #18
0
 /// <summary>
 ///     Initializes a new instance of the
 ///     <see cref="PushContextAttribute" /> class.
 /// </summary>
 /// <param name="v1">The v1.</param>
 /// <param name="v2">The v2.</param>
 /// <autogeneratedoc />
 /// TODO Edit XML Comment Template for #ctor
 public PushContextAttribute(string v1, string v2)
 {
     Context = new InfoContext(v1, v2);
 }
コード例 #19
0
        public void Before(MethodInfo methodUnderTest)
        {
            var instances =
                Instances.Where(o => o.Key.GetType( ) == methodUnderTest.DeclaringType);

            var instance = instances.Last( ).Key;

            var factoryProps =
                from prop in instance.GetType( ).GetProperties( )
                let atts = GetCustomAttributes(prop, typeof(InfoContextFactoryAttribute))
                           from InfoContextFactoryAttribute att in atts
                           select new { Prop = prop, Att = att };

            var fProps = factoryProps.ToList( );

            if (!fProps.Any( ))
            {
                throw new AttributeNotFoundException(nameof(InfoContextFactoryAttribute));
            }

            var value1 = fProps.First( ).Prop.GetValue(instance);

            if (value1 == null)
            {
            }
            else
            {
                if (!(value1 is InfoContext.Factory entryFactory))
                {
                    throw new ArgumentNullException(nameof(entryFactory));
                }

                Logger.Debug("instance is {instance}");

                var qq =
                    from prop in instance.GetType( ).GetProperties( )
                    let atts =
                        GetCustomAttributes(prop, typeof(ContextStackInstanceAttribute))
                        from ContextStackInstanceAttribute att in atts
                        select new { Prop = prop, Att = att };
                // Assert.NotEmpty(qq);
                foreach (var q in qq)
                {
                    Logger.Debug($"{q.Prop} {q.Att}");
                    var value = q.Prop.GetValue(instance);
                    if (value is ContextStack <InfoContext> stack)
                    {
                        // thread safe?
                        _context = entryFactory("test1", Context);
                        _stack   = stack;
                        _stack.Push(_context);
                    }
                }
            }

            //Assert.NotNull( _stack );

            //var contextAtt = Attribute.GetCustomAttributes(instance.GetType(),)
            // TODO what next??
            var customAttributes = GetCustomAttributes(methodUnderTest, GetType( ));

            // todo IMPLEMENT
            // ReSharper disable once UnusedVariable
            foreach (var q in customAttributes)
            {
            }
        }