MagnusTheRed90 30 Newbie Poster

I need an end user license agreement for code shared amongst my home projects with other developers. The EULA needs to include a "pay to the order of x" clause, and also needs to include the ability for me to utilze the code at multiple companies that I could participate in. I suspect the EULA may need to be fairly complete, and preclude explicitly illicit usage. If we could have a discussion that would be cool. I was learning about EULA's in college but haven't made one for real life yet.

MagnusTheRed90 30 Newbie Poster

The following is not exactly what I wanted, it uses looping instead of queries. I do not know a query technique that gets me around the problem with the where statement growing for every login expressed. I also noticed that some of the variables at the top of the program were not what they should have been, it was the date times of the first or second grouping of code.

List<Post> posts = new List<Post>();

            User user = new User("Joe Schmoe");

            DateTime dateOccurred = DateTime.Now - TimeSpan.FromDays(-4);
            user.AddLoginEvent("192.168.1.1", dateOccurred);
            Post post = new Post(user, "Something Good... ", dateOccurred.AddMinutes(15));
            posts.Add(post);

            dateOccurred = DateTime.Now - TimeSpan.FromDays(-3);
            user.AddLoginEvent("192.168.1.2", dateOccurred);
            post = new Post(user, "Something Bad... ", dateOccurred.AddMinutes(15));
            posts.Add(post);

            dateOccurred = DateTime.Now - TimeSpan.FromDays(-2);
            user.AddLoginEvent("192.168.1.1", dateOccurred);
            post = new Post(user, "Something Good... ", dateOccurred.AddMinutes(15));
            posts.Add(post);

            dateOccurred = DateTime.Now - TimeSpan.FromDays(-1);
            user.AddLoginEvent("192.168.1.2", dateOccurred);
            post = new Post(user, "Something Bad... ", dateOccurred.AddMinutes(15));
            posts.Add(post);

            posts = posts.OrderByDescending(p => p.DateOccurred).ToList();

            //var query = user.LoginEvents.Join(posts, x => x.User, y => y.User, (x, y) => new { Login = x, Post = y })
            //    .Where(obj => obj.Login.DateOccurred < obj.Post.DateOccurred)
            //    .Join(user.LoginEvents, x => x.Login.User, y => y.User, (x, y) => new { Post = x.Post, Login = x.Login, LoginY = y })
            //    .Where(obj => obj.LoginY.DateOccurred < obj.Post.DateOccurred);
            ////.Select(obj => new { IpAddress = obj.Login.IpAddress, Content = obj.Post.Content, DateOccurred = obj.Post.DateOccurred });
            ////.Select(obj => new { IpAddress = obj.Login.IpAddress, Content = obj.Post.Content, DateOccurred = obj.Post.DateOccurred, NextLogin = obj.LoginY });

            //var query = from pst in posts
            //            from …
rproffitt commented: Working code wins over "this would be better if it worked" code. +15
MagnusTheRed90 30 Newbie Poster

I believe that I have the answer to my own question. Looks like not many of you do angular js. The most profound thing I learned from this is that we are using multiple views in all the online examples, with one view, "the home view" being the initial drop page. This was really really important to figuring anything out. I am not completely done with my application, but I think this is an appropriate response, and my code compiles. I am also doing a uib modal, so ignore anything that is ui bootstrap.

angular.module('UnitModule', [
    'UnitModule.UnitsController',
    'UnitModule.AddWeaponController',
])
.config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {
    $routeProvider.when('/', {
        templateUrl: '/Units',
        controller: 'Units',
    });
    $routeProvider.when('/AddWeapon/:unitId', {
        templateUrl: '/Home/AddWeapon',
        controller: 'AddWeapon',
    });
    $routeProvider.otherwise({
        redirectTo: '/'
    });
}]);

//Units controller
angular.module('UnitModule.UnitsController', ['ngRoute', 'ui.bootstrap'])
    .controller('Units', function ($scope, $http, $routeParams, $q, $rootScope, $route, $uibModal) {

});

angular.module('UnitModule.AddWeaponController', ['ngRoute'])
    .controller('AddWeapon', function ($scope, $http, $routeParams) {
        $scope.unitId = $routeParams.unitId;

}//end class

//additionally you need an AddWeapon() method that returns a partial view
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using TroopTransportGeneticAlgorithim.Repositories;
using TroopTransportGeneticAlgorithim.Models;

namespace TroopTransportOptimizer.Controllers {
    public class UnitsController : Controller {
        // GET: Units
        public ActionResult Index() {

            return View();
        }//end method

        public ActionResult AddWeapon() {
            return PartialView();
        }

    }//end class

}//end namespace

//additionally you need at least two files/views under the Units folder
    -index.cshtml
    -AddWeapon.cshtml
MagnusTheRed90 30 Newbie Poster

The following code fixes the problem.

    /// <summary>
    /// Copies file to archival directory. 
    /// </summary>
    /// <param name="fileName"></param>
    public void CopyFile(String fileName) {
        var stream = SrcRepo.GetById(fileName);

        //plus 1 for preceding slash character in the path
        String pathInsideArchive = fileName.Substring(FileSystemPath.Length + 1, fileName.Length - FileSystemPath.Length - 1);

        DestRepo.Insert(pathInsideArchive, stream);
    }//end method

    /// <summary>
    /// Insert file into existing archive file. 
    /// </summary>
    /// <param name="fullPath"></param>
    /// <param name="stream"></param>
    public void InsertIntoFile(String fullPath, Stream stream) {
        using (var fs = new FileStream(FullArchivalPath, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)) {
            using (var zipFile = new ZipFile(fs)) {
                zipFile.BeginUpdate();

                var dataSource = new CustomDataSource();
                dataSource.SetStream(stream);

                zipFile.Add(dataSource, fullPath);

                zipFile.CommitUpdate();
                zipFile.Close();

            }
        }
    }//end method

    /// <summary>
    /// A do nothing class necessary for some functionality in the prior code. 
    /// </summary>
    public class CustomDataSource : IStaticDataSource {
        private Stream stream;

        public CustomDataSource() { }

        public CustomDataSource(Stream stream) {
            SetStream(stream);
        }

        public Stream GetSource() {
            return stream;
        }

        public void SetStream(Stream stream) {
            this.stream = stream;
            this.stream.Position = 0;
        }
    }//end class
MagnusTheRed90 30 Newbie Poster

If you answer, great, but I'm dropping oracle support. Will be going mssql.

rproffitt commented: For many reasons I keep on keeping on with MySQL. +15