예제 #1
0
        public ActionResult History()
        {
            //return View("~/Views/Info/History.cshtml");
            HistoryContext db = new HistoryContext();

            return View(db.Sadrzajs.ToList());
        }
예제 #2
0
        public async Task <IEnumerable <Variant> > GetHistory(string itemDefinitionId, string propertyName, TimeSpan history)
        {
            var dt = DateTime.UtcNow.Subtract(history);

            using (var context = new HistoryContext())
            {
                context.Configuration.AutoDetectChangesEnabled = false;

                var results = await context.Roots
                              .Where(r => r.Name == itemDefinitionId)
                              .SelectMany(t => t.History
                                          .Where(h => h.Name == propertyName && h.TimestampUtc > dt)
                                          .Select(h => new { h.Id, h.TimestampUtc, h.Value }))
                              .OrderByDescending(h => h.TimestampUtc)
                              .ToListAsync();

                return(results.Select(h => new Variant(h.TimestampUtc, Convert.ToDouble(h.Value))));
            }
        }
예제 #3
0
        private void HandleSave(string name)
        {
            try
            {
                using (var db = new HistoryContext())
                {
                    var now = DateTime.Now;
                    // add file to commit!
                    provider.CopyFileToCache(name);
                    // commit to git...
                    var commitId = provider.Commit();

                    var doc = db.Documents.Where(d => d.CurrentFullName == name).SingleOrDefault();
                    if (doc == null)
                    {
                        doc = new Document()
                        {
                            CurrentFullName = name
                        };
                        db.Documents.Add(doc);
                    }

                    var commit = new Commit()
                    {
                        Document     = doc,
                        RepositoryId = commitId,
                        Timestamp    = now,
                    };

                    db.Commits.Add(commit);

                    // Build tokens, code members, and code classes
                    //Parser(name, db, doc, commit); // test

                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
예제 #4
0
        public async Task <SourceResponse <BaseTrack> > GetItemsAsync(int count, string token,
                                                                      CancellationTokenSource cancellationToken = default(CancellationTokenSource))
        {
            using (var db = new HistoryContext())
            {
                if (_firstTime)
                {
                    db.Database.Migrate();
                }

                _firstTime = false;


                // Set the default token to zero
                if (string.IsNullOrEmpty(token))
                {
                    token = "0";
                }

                if (token == "eol")
                {
                    token = "0";
                }

                // Get items in date descending order, skip the token and take the count
                var tracks = await db.Tracks.Include(x => x.User).OrderByDescending(x => x.LastPlaybackDate).Skip(int.Parse(token)).Take(count).ToListAsync();

                // If there are no tracks
                if (!tracks.Any())
                {
                    return(new SourceResponse <BaseTrack>(null, null, false, "No History", "Listen to some songs to get started"));
                }

                // Set the new token;
                if (token != "eol")
                {
                    token = (int.Parse(token) + count).ToString();
                }

                return(new SourceResponse <BaseTrack>(tracks, token));
            }
        }
예제 #5
0
        public override Task <Response> AddHistory(History request, ServerCallContext context)
        {
            Response response = new Response();

            try
            {
                var optionsBuilder = new DbContextOptionsBuilder <HistoryContext>();
                optionsBuilder.UseSqlite("Data sourse = tdb.mdf");
                using var con = new HistoryContext(optionsBuilder.Options);
                con.Histories.Add(request);
                con.SaveChangesAsync();
            }
            catch (Exception e)
            {
                _logger.LogInformation(e.Message);
                response.ModificationResponse = Changes.AddFailed;
                return(Task.FromResult(response));
            }
            response.ModificationResponse = Changes.AddOk;
            return(Task.FromResult(response));
        }
예제 #6
0
        public virtual void Setup()
        {
            this.conf = new JobConf();
            this.conf.Set(CommonConfigurationKeys.HadoopSecurityGroupMapping, typeof(TestHsWebServicesAcls.NullGroupsProvider
                                                                                     ).FullName);
            this.conf.SetBoolean(MRConfig.MrAclsEnabled, true);
            Groups.GetUserToGroupsMappingService(conf);
            this.ctx = BuildHistoryContext(this.conf);
            WebApp webApp = Org.Mockito.Mockito.Mock <HsWebApp>();

            Org.Mockito.Mockito.When(webApp.Name()).ThenReturn("hsmockwebapp");
            this.hsWebServices = new HsWebServices(ctx, conf, webApp);
            this.hsWebServices.SetResponse(Org.Mockito.Mockito.Mock <HttpServletResponse>());
            Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job job = ctx.GetAllJobs().Values.GetEnumerator
                                                                 ().Next();
            this.jobIdStr = job.GetID().ToString();
            Task task = job.GetTasks().Values.GetEnumerator().Next();

            this.taskIdStr        = task.GetID().ToString();
            this.taskAttemptIdStr = task.GetAttempts().Keys.GetEnumerator().Next().ToString();
        }
예제 #7
0
        public void RunRequest(string employeeID, string requestID)
        {
            int waitSec = _random.Next(_beginSpanSec, _endSpanSec);

            Thread.Sleep(waitSec * 1000);

            using (var context = new HistoryContext())
            {
                var changeField = context.Histories.FirstOrDefault(w => w.RequestID == requestID);
                if (changeField != null)
                {
                    changeField.RequestStatus = RequestStatusType.Processed;
                    changeField.OperationTime = waitSec;
                    context.Histories.AddOrUpdate(changeField);
                    context.SaveChangesAsync();
                }
            }

            Employees.Instance.ChangeStatus(employeeID, EmployeeStatusType.Free);
            Requests.Instance.Remove(requestID);
        }
예제 #8
0
        protected HistoryOperation CreateInsertOperation(
            string contextKey, string migrationId, XDocument model, string productVersion = null)
        {
            using (var connection = ProviderFactory.CreateConnection())
            {
                connection.ConnectionString = ConnectionString;

                using (var historyContext = new HistoryContext(connection, "dbo"))
                {
                    historyContext.History.Add(
                        new HistoryRow
                    {
                        MigrationId = migrationId,
                        ContextKey  = contextKey,
                        Model       = CompressModel(model),
                        ProductVersion
                            = productVersion
                              ?? typeof(DbContext).Assembly()
                              .GetCustomAttributes <AssemblyInformationalVersionAttribute>()
                              .Single()
                              .InformationalVersion,
                    });

                    var cancellingLogger = new CommandTreeCancellingLogger(historyContext);
                    DbInterception.Add(cancellingLogger);

                    try
                    {
                        historyContext.SaveChanges();

                        return(new HistoryOperation(
                                   cancellingLogger.Log.OfType <DbModificationCommandTree>().ToList()));
                    }
                    finally
                    {
                        DbInterception.Remove(cancellingLogger);
                    }
                }
            }
        }
예제 #9
0
        private void DoOperationBody(int?maxStoreMin, EmployeeType employeeType)
        {
            var tdRequestModel = Requests.Instance.GetStoredRequestModel(maxStoreMin);

            if (tdRequestModel == null)
            {
                return;
            }
            if (Employees.Instance.CountFreeEmployees <= 0)
            {
                return;
            }

            var employee = Employees.Instance.GetFreeEmployee(employeeType);

            if (employee == null)
            {
                return;
            }

            if (!Employees.Instance.ChangeStatus(employee.ID, EmployeeStatusType.Work))
            {
                return;
            }

            using (var context = new HistoryContext())
            {
                context.SetEmpployee(tdRequestModel.ID, employee.ID);
            }

            if (Requests.Instance.ChangeStatus(tdRequestModel.ID, RequestStatusType.Involved))
            {
                Requests.Instance.RunRequest(employee.ID, tdRequestModel.ID);
            }
            else
            {
                Employees.Instance.ChangeStatus(employee.ID, EmployeeStatusType.Free);
            }
        }
예제 #10
0
        private XDocument GetInitialHistoryModel()
        {
            var initialHistoryModel
                = (from migrationId in _migrationAssembly.MigrationIds
                   let migrationMetadata = (IMigrationMetadata)_migrationAssembly.GetMigration(migrationId)
                                           select new ModelCompressor().Decompress(Convert.FromBase64String(migrationMetadata.Target)))
                  .FirstOrDefault();

            if (initialHistoryModel == null)
            {
                using (var historyContext = new HistoryContext(CreateConnection(), true, null))
                {
                    initialHistoryModel = historyContext.GetModel();

                    initialHistoryModel
                    .Descendants()
                    .Each(a => a.SetAttributeValue(EdmXNames.IsSystemName, true));
                }
            }

            return(initialHistoryModel);
        }
예제 #11
0
            protected override void ConfigureServlets()
            {
                Org.Apache.Hadoop.Mapreduce.V2.HS.Webapp.TestHsWebServices.appContext = new MockHistoryContext
                                                                                            (0, 1, 1, 1);
                JobHistory     jobHistoryService = new JobHistory();
                HistoryContext historyContext    = (HistoryContext)jobHistoryService;

                Org.Apache.Hadoop.Mapreduce.V2.HS.Webapp.TestHsWebServices.webApp = new HsWebApp(
                    historyContext);
                this.Bind <JAXBContextResolver>();
                this.Bind <HsWebServices>();
                this.Bind <GenericExceptionHandler>();
                this.Bind <WebApp>().ToInstance(Org.Apache.Hadoop.Mapreduce.V2.HS.Webapp.TestHsWebServices
                                                .webApp);
                this.Bind <AppContext>().ToInstance(Org.Apache.Hadoop.Mapreduce.V2.HS.Webapp.TestHsWebServices
                                                    .appContext);
                this.Bind <HistoryContext>().ToInstance(Org.Apache.Hadoop.Mapreduce.V2.HS.Webapp.TestHsWebServices
                                                        .appContext);
                this.Bind <Configuration>().ToInstance(Org.Apache.Hadoop.Mapreduce.V2.HS.Webapp.TestHsWebServices
                                                       .conf);
                this.Serve("/*").With(typeof(GuiceContainer));
            }
예제 #12
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        ///


        public App()
        {
            this.InitializeComponent();
            this.Suspending += OnSuspending;

            using (HistoryContext db = new HistoryContext())
            {
                db.Database.Migrate();
            }

            using (ServerIPerfContext db = new ServerIPerfContext())
            {
                db.Database.Migrate();
            }

            // Enable Reveal for App
            this.FocusVisualKind = FocusVisualKind.Reveal;
            //if (AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Xbox")
            //{
            //    this.FocusVisualKind = FocusVisualKind.Reveal;
            //}
        }
예제 #13
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            // need to handle undo here because
            // this is a modal dialog.
            Keys undoKey = Keys.Control | Keys.Z;

            if (keyData == undoKey)
            {
                if (m_numOfOperation > 0)
                {
                    m_numOfOperation--;
                    HistoryContext hc = m_mgr.Cast <HistoryContext>();
                    if (hc.CanUndo)
                    {
                        hc.Undo();
                    }
                }
                UpdateActiveTabPage();
                return(true);
            }
            return(base.ProcessCmdKey(ref msg, keyData));
        }
예제 #14
0
        public void ShouldResolveDifferentContextsForDifferentHistories()
        {
            string historyKey     = Guid.NewGuid().ToString();
            var    createdContext = new HistoryContext(new History(historyKey), _scheduler);

            Locator.CurrentMutable.RegisterConstant(createdContext, historyKey);
            var context = HistoryContext.GetContext(historyKey);

            Assert.Equal(createdContext, context);

            historyKey = Guid.NewGuid().ToString();

            createdContext = new HistoryContext(new History(historyKey), _scheduler);
            Locator.CurrentMutable.RegisterConstant(createdContext, historyKey);
            var nextContext = HistoryContext.GetContext(historyKey);

            Assert.Equal(createdContext, nextContext);

            Assert.NotNull(context);
            Assert.NotNull(nextContext);
            Assert.NotEqual(context, nextContext);
        }
예제 #15
0
        public async void Add_New_Version()
        {
            //arrange
            var record = new PayloadModel
            {
                Key       = "customer.1",
                FirstName = "saif",
                LastName  = "manea",
                Address   = "earth"
            };
            var options = new DbContextOptionsBuilder <HistoryContext>()
                          .UseInMemoryDatabase(databaseName: "MyData1").Options;

            // Act
            using (var context = new HistoryContext(options))
            {
                RegistrationHistoryService historyRepository = new RegistrationHistoryService(context);
                bool result = await historyRepository.Create(record);

                // Assert
                Assert.True(result);
            }
        }
예제 #16
0
        public bool Remove(string requestID)
        {
            if (!_requestDict.ContainsKey(requestID))
            {
                return(true);
            }

            if (!_requestDict.TryGetValue(requestID, out var removeRequestModel))
            {
                return(false);
            }

            if (removeRequestModel.Status != RequestStatusType.Involved)
            {
                return(false);
            }

            if (!_requestDict.TryRemove(requestID, out removeRequestModel))
            {
                return(false);
            }

            Interlocked.Decrement(ref _countRequest);

            using (var context = new HistoryContext())
            {
                var removeField = context.Histories.FirstOrDefault(w => w.RequestID == requestID);
                if (removeField != null)
                {
                    removeField.Deleted = true;
                    context.Histories.AddOrUpdate(removeField);
                    context.SaveChangesAsync();
                }
            }

            return(true);
        }
예제 #17
0
        public ContextHandleTestBase()
        {
            var options = new DbContextOptionsBuilder <HistoryContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var context = new HistoryContext(options);

            context.Database.EnsureCreated();

            context.Histories.AddRange(new[] {
                new History {
                    HistoryId = 5, CalcHistory = "5 + 5 = 10"
                },
                new History {
                    HistoryId = 6, CalcHistory = "10 + 5 = 15"
                },
                new History {
                    HistoryId = 7, CalcHistory = "15 + 5 = 20"
                }
            });
            context.SaveChanges();
            historyContext = context;
        }
예제 #18
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public async void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory,
                                    HistoryContext context, AdministratorSeedData seeder)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            app.UseIdentity();

            // Add external authentication middleware below. To configure them please see https://go.microsoft.com/fwlink/?LinkID=532715

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Landing}/{id?}");
                //template: "{controller=Home}/{action=Index}/{id?}");
            });

            //dcowan: Seed administrator data
            await seeder.EnsureSeedData();

            DbInitializer.Initialize(context);
        }
예제 #19
0
        public void Setup()
        {
            var options = new DbContextOptionsBuilder <StagingContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;
            var optionh = new DbContextOptionsBuilder <HistoryContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;
            var optione = new DbContextOptionsBuilder <ErrorContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;
            var optionl = new DbContextOptionsBuilder <LogContext>().UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;

            _context        = new StagingContext(options);
            _contextHistory = new HistoryContext(optionh);
            _contextError   = new ErrorContext(optione);
            _contextLog     = new LogContext(optionl);
            List <PcpAssignment> pcpas = new List <PcpAssignment>()
            {
                new PcpAssignment()
                {
                    PcpAssignmentId    = 1,
                    PcpHeaderId        = 1,
                    PlanCode           = "305",
                    Cin                = "32001378A",
                    Npi                = "1205940145",
                    TradingPartnerCode = "IEHP"
                },
                new PcpAssignment()
                {
                    PcpAssignmentId    = 2,
                    PcpHeaderId        = 1,
                    PlanCode           = "305",
                    Cin                = "32001379A",
                    Npi                = "1356455299",
                    TradingPartnerCode = "IEHP"
                }
            };

            _context.PcpAssignments.AddRange(pcpas);
            _pcpaController = new PcpaController(_context, _contextHistory, _contextError, _contextLog);
        }
예제 #20
0
 public HistoryRepository(HistoryContext context)
 {
     this.context = context;
 }
        private readonly UserManager <ApplicationUser> _userManager; //dcowan: need Identity users

        public CommentController(HistoryContext context, UserManager <ApplicationUser> userManager)
        {
            _context     = context;
            _userManager = userManager;
        }
예제 #22
0
 public RecordRepository(IOptions <HistorySettings> settings)
 {
     _context = new HistoryContext(settings);
 }
예제 #23
0
 private Commit GetLatestCommit(String name)
 {
     try
     {
         using (var db = new HistoryContext())
         {
             var commit = db.Commits.Where(c => c.Document.CurrentFullName == name).OrderByDescending(c => c.Timestamp)
                  // Funky shaping stuff to get document.
                 .Select(c => new { D = c.Document, RepoId = c.RepositoryId, T = c.Timestamp, ID = c.Id })
                 .ToList()
                 .Select(anon => new Commit() { Document = anon.D, Timestamp = anon.T, RepositoryId = anon.RepoId, Id = anon.ID }).
                 FirstOrDefault();
             return commit;
         }
     }
     catch (Exception ex)
     {
         Trace.WriteLine(ex.Message);
         Trace.WriteLine(ex.StackTrace);
     }
     return null;
 }
예제 #24
0
        private static void Parser(string name, HistoryContext db, Document doc, Commit commit)
        {
            //var parser = new Tokenizing.TokenParser();
            //var tokens = parser.Parse(name);

            //// initial pass on class declarations...
            //var classTokens = tokens.Where(t => t.Kind == "ClassDeclaration");
            //Dictionary<string, CodeClass> classCache = new Dictionary<string, CodeClass>();
            //Dictionary<string, CodeMember> methodCache = new Dictionary<string, CodeMember>();

            //foreach (var cToken in classTokens)
            //{
            //    var klass = db.CodeClass.Where(c => c.Signature == cToken.Value).SingleOrDefault();
            //    if (klass == null)
            //    {
            //        klass = new CodeClass()
            //        {
            //            Document = doc,
            //            Name = cToken.Name,
            //            Signature = cToken.Value,
            //            Namespace =  parser.GetNamespace(cToken.Node),
            //            Parent = null
            //        };
            //        db.CodeClass.Add(klass);
            //    }
            //    classCache.Add(klass.Signature, klass);
            //}

            //// setting parents of class declarations (inner classes)
            //foreach (var cToken in classTokens)
            //{
            //    var klass = classCache[cToken.Value];
            //    if (!string.IsNullOrEmpty(cToken.ParentSignature))
            //    {
            //        klass.Parent = classCache[cToken.ParentSignature];
            //    }
            //}

            //// setting code members
            //var methodTokens = tokens.Where(t => t.Kind == "MethodDeclaration");
            //foreach (var methodToken in methodTokens)
            //{
            //    if( string.IsNullOrEmpty( methodToken.ParentSignature ) )
            //        continue;

            //    var member = db.CodeMember.Where(m => m.Signature == methodToken.Value).SingleOrDefault();
            //    var parent = classCache[methodToken.ParentSignature];
            //    if (member == null)
            //    {
            //        member = new CodeMember() { ShortName = methodToken.Name, Signature = methodToken.Value, Parent = parent };
            //        db.CodeMember.Add(member);
            //    }
            //    if (member.Parent.Signature != member.Parent.Signature)
            //    {
            //        // might happen if class renamed or method moved within same file...
            //        member.Parent = parent;
            //    }

            //    methodCache.Add(methodToken.Value, member);

            //    // build method boundaries
            //    var methodBoundary = new CodeToken()
            //    {
            //        LineStart = methodToken.LineStart,
            //        LineEnd = methodToken.LineEnd,
            //        Commit = commit,
            //        Document = doc,
            //        Parent = member,
            //        Kind = methodToken.Kind,
            //        Value = methodToken.Value,
            //        Name = methodToken.Name,
            //        Path = methodToken.ParentSignature
            //    };
            //    db.CodeTokens.Add(methodBoundary);
            //}

            //var invocations = tokens.Where(t => t.Kind == "Invocation");
            //foreach (var invoke in invocations)
            //{
            //    if (!string.IsNullOrEmpty(invoke.ParentSignature) &&
            //        methodCache.ContainsKey(invoke.ParentSignature))
            //    {
            //        var member = methodCache[invoke.ParentSignature];
            //        var token = new CodeToken()
            //        {
            //            LineStart = invoke.LineStart,
            //            LineEnd = invoke.LineEnd,
            //            Commit = commit,
            //            Document = doc,
            //            Parent = member,
            //            IsSystem = invoke.IsSystem,
            //            Kind = invoke.Kind,
            //            Value = invoke.Value,
            //            Name = invoke.Name,
            //            Path = invoke.ParentSignature
            //        };
            //        db.CodeTokens.Add(token);
            //    }
            //}
        }
 public HistoryDbRepository(HistoryContext context)
 {
     _context = context;
 }
예제 #26
0
 public HsWebApp(HistoryContext history)
 {
     this.history = history;
 }
예제 #27
0
 public AppealsController(HistoryContext context)
 {
     _context = context;
 }
예제 #28
0
 public IndexModel(HistoryContext db)
 {
     _context = db;
 }
예제 #29
0
 public UserInfoHistoryRepository(HistoryContext requestsContext) => _requestsContext = requestsContext;
예제 #30
0
 public COCController(HistoryContext context)
 {
     _context = context;
 }
        public static void Setup(HistoryContext context)
        {
            var events = context.Events.ToList();

            events.ForEach(x => EventsReceived.WithLabels(x.Title).Inc(0));
        }
예제 #32
0
 public HsWebServices(HistoryContext ctx, Configuration conf, WebApp webapp)
 {
     this.ctx    = ctx;
     this.webapp = webapp;
 }
예제 #33
0
        private void SaveLogCursor(IVsTextView pView, int iNewLine, String searchTerm)
        {
            // Get column of cursor position
            int iLine, iCol;
            pView.GetCaretPos(out iLine, out iCol);

            if (searchTerm != "")
            {
                iLine = iNewLine;
            }

            // Usually just stray document open, not worth until actually moving around.
            if (iLine == 0 && iCol == 0)
                return;

            // For now, not handling navigation in dirty files.
            if (IsDirty(pView))
                return;

            // Get latest snapshot and make sure same as current buffer.
            if (!Sync(pView))
                return;

            using (var db = new HistoryContext())
            {
                // Save..
                var click = new CommitAlignedClick()
                {
                    LineNumber = iLine,
                    ColumnNumber = iCol,
                    WordExtent = GetWordExtent(pView, iLine, iCol),
                    Timestamp = DateTime.Now,
                    SearchTerm = searchTerm
                };
                // Need to add to parents?  Otherwise is creating multiple documents!!
                var commit = GetLatestCommit(_fileCommitIdCache[pView]);
                if (commit != null)
                {
                    // This should tell context this belongs to db
                    db.Commits.Attach(commit);
                    // http://stackoverflow.com/questions/7082744/cannot-insert-duplicate-key-in-object-dbo-user-r-nthe-statement-has-been-term
                    click.Commit = commit;
                    commit.Clicks.Add(click);
                    db.Clicks.Add(click);
                    db.SaveChanges();
                }
            }
        }
예제 #34
0
 private void LoadHistory()
 {
     this.m_history = HistoryContext.LoadDefault();
     if (m_history == null) m_history = new HistoryContext();
 }
예제 #35
0
 private Commit GetLatestCommit(long id)
 {
     try
     {
         using (var db = new HistoryContext())
         {
             var commit = db.Commits.Where(c => c.Id == id)
                 // Funky shaping stuff to get document.
                 .Select(c => new { D = c.Document, RepoId = c.RepositoryId, T = c.Timestamp, ID = c.Id, Clicks = c.Clicks })
                 .ToList()
                 .Select(anon => new Commit() { Document = anon.D, Timestamp = anon.T, RepositoryId = anon.RepoId, Id = anon.ID, Clicks = anon.Clicks }).
                 FirstOrDefault();
             return commit;
         }
     }
     catch (Exception ex)
     {
         Trace.WriteLine(ex.Message);
         Trace.WriteLine(ex.StackTrace);
     }
     return null;
 }
예제 #36
0
        public HistoryController(HistoryContext historyContext, IMapper mapper)
        {
            _repository = new DBRepository <CarHistory>(historyContext);

            _mapper = mapper;
        }
예제 #37
0
        private void HandleSave(string name)
        {
            try
            {
                using (var db = new HistoryContext())
                {
                    var now = DateTime.Now;
                    // add file to commit!
                    provider.CopyFileToCache(name);
                    // commit to git...
                    var commitId = provider.Commit();

                    var doc = db.Documents.Where(d => d.CurrentFullName == name).SingleOrDefault();
                    if (doc == null)
                    {
                        doc = new Document() { CurrentFullName = name };
                        db.Documents.Add(doc);
                    }

                    var commit = new Commit()
                    {
                        Document = doc,
                        RepositoryId = commitId,
                        Timestamp = now,
                    };

                    db.Commits.Add(commit);

                    // Build tokens, code members, and code classes
                    //Parser(name, db, doc, commit); // test

                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }