Example #1
0
        private List <ClientSimple> ConvertToClientSimpleList(List <Client> clients)
        {
            var          list         = new List <ClientSimple>();
            ClientSimple clientSimple = null;

            foreach (var item in clients)
            {
                clientSimple = new ClientSimple
                {
                    Id            = item.Id,
                    Email         = item.Email,
                    AccountNumber = item.AccountNumber
                                    //Rebate = item.Rebate
                };

                if (item.IsOrganization)
                {
                    clientSimple.ClientName = item.OrganizationName;
                }
                else
                {
                    clientSimple.ClientName = item.LastName + ", " + item.FirstName;
                }
                list.Add(clientSimple);
            }

            return(list.OrderBy(c => c.ClientName).ToList());
        }
Example #2
0
    void LoadAndSendChunk(int x, int y, int z)
    {
        ClientSimple c   = server.clients[clientId];
        int          pos = MapUtilCi.Index2d(x, y, server.MapSizeX / ServerSimple.ChunkSize);

        if (c.chunksseen[pos] == null)
        {
            c.chunksseen[pos] = new bool[server.MapSizeZ / ServerSimple.ChunkSize];
        }
        c.chunksseen[pos][z] = true;

        int[] chunk = new int[32 * 32 * 32];

        for (int i = 0; i < server.modsCount; i++)
        {
            server.mods[i].GenerateChunk(x, y, z, chunk);
        }

        byte[] chunkBytes       = MiscCi.UshortArrayToByteArray(chunk, 32 * 32 * 32);
        IntRef compressedLength = new IntRef();

        byte[] chunkCompressed = server.platform.GzipCompress(chunkBytes, 32 * 32 * 32 * 2, compressedLength);

        server.QueueMainThreadAction(SendPacketAction.Create(server, clientId, ServerPackets.ChunkPart(chunkCompressed)));
        server.QueueMainThreadAction(SendPacketAction.Create(server, clientId, ServerPackets.Chunk_(x * ServerSimple.ChunkSize, y * ServerSimple.ChunkSize, z * ServerSimple.ChunkSize, ServerSimple.ChunkSize)));
    }
Example #3
0
    void ProcessPackets()
    {
        for (; ;)
        {
            NetIncomingMessage msg = server.ReadMessage();
            if (msg == null)
            {
                return;
            }
            switch (msg.Type)
            {
            case NetworkMessageType.Connect:
                ClientSimple c = new ClientSimple();
                c.MainSocket = server;
                c.Connection = msg.SenderConnection;
                c.chunksseen = new bool[(MapSizeX / ChunkSize) * (MapSizeY / ChunkSize)][];
                clients[0]   = c;
                clientsCount = 1;
                break;

            case NetworkMessageType.Data:
                byte[]        data   = msg.message;
                Packet_Client packet = new Packet_Client();
                Packet_ClientSerializer.DeserializeBuffer(data, msg.messageLength, packet);
                ProcessPacket(0, packet);
                break;

            case NetworkMessageType.Disconnect:
                break;
            }
        }
    }
Example #4
0
        // GET: Policy/Create
        public ActionResult Create(int?ClientId, string returnUrl)
        {
            if (ClientId.HasValue == false)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            PolicyDetailModel vm = new PolicyDetailModel()
            {
                Companies     = ListProviderSvc.GetInsuranceProviders(),
                PolicyTypes   = ListProviderSvc.GetPolicyTypes(),
                Statuses      = ListProviderSvc.GetPolicyStatuses(),
                Agents        = ListProviderSvc.GetAgents(),
                InceptionDate = DateTime.Now,
                DateIssued    = DateTime.Now,
                ExpiryDate    = DateTime.Now,
                StatusName    = "New",
                ReturnUrl     = returnUrl,
                ClientId      = (int)ClientId
            };

            List <ClientSimple> clients = null;

            if (ClientId == 0)
            {
                clients = ListProviderSvc.GetClientSimpleList();
            }
            else
            {
                clients = new List <ClientSimple>();
                var clientEntity = Uow.Clients.GetById((int)ClientId);
                if (clientEntity == null)
                {
                    return(HttpNotFound());
                }
                ClientSimple client = new ClientSimple
                {
                    Id = clientEntity.Id,
                };
                if (clientEntity.IsOrganization)
                {
                    client.ClientName = clientEntity.OrganizationName;
                }
                else
                {
                    client.ClientName = clientEntity.LastName + ", " + clientEntity.FirstName;
                }

                clients.Add(client);
            }
            vm.Clients = clients;

            List <DefaultRebate> defaultRebates = null;

            defaultRebates    = ListProviderSvc.GetDefaultRebates();
            vm.DefaultRebates = defaultRebates;

            return(View(vm));
        }
Example #5
0
    public override void Run()
    {
        int[]        nearest = new int[3];
        ClientSimple client  = server.clients[clientId];
        int          x       = server.platform.FloatToInt(client.glX);
        int          y       = server.platform.FloatToInt(client.glZ);
        int          z       = server.platform.FloatToInt(client.glY);

        NearestDirty(clientId, x, y, z, nearest);

        if (nearest[0] != -1)
        {
            LoadAndSendChunk(nearest[0], nearest[1], nearest[2]);
        }

        server.clients[clientId].notifyMapAction = null;
    }
Example #6
0
    public ServerSimple()
    {
        one             = 1;
        clients         = new ClientSimple[256];
        clientsCount    = 0;
        blockTypes      = new Packet_BlockType[GlobalVar.MAX_BLOCKTYPES];
        blockTypesCount = 0;
        mods            = new ModSimple[128];

        ModManagerSimple1 m = new ModManagerSimple1();

        m.Start(this);

        mods[modsCount++] = new ModSimpleDefault();
        mods[modsCount++] = new ModSimpleWorldGenerator();
        for (int i = 0; i < modsCount; i++)
        {
            mods[i].Start(m);
        }

        MapSizeX          = 8192;
        MapSizeY          = 8192;
        MapSizeZ          = 128;
        chunks            = new ChunkSimple[(MapSizeX / ChunkSize) * (MapSizeY / ChunkSize)][];
        chunkdrawdistance = 4;
        actions           = new QueueAction();
        mainThreadActions = new QueueAction();

        spawnGlX = MapSizeX / 2;
        spawnGlY = MapSizeZ;
        for (int i = 0; i < modsCount; i++)
        {
            int spawnHeight = mods[i].GetHeight();
            if (spawnHeight != -1)
            {
                spawnGlY = spawnHeight;
            }
        }
        spawnGlZ = MapSizeY / 2;
    }
    public ServerSimple()
    {
        one = 1;
        clients = new ClientSimple[256];
        clientsCount = 0;
        blockTypes = new Packet_BlockType[GlobalVar.MAX_BLOCKTYPES];
        blockTypesCount = 0;
        mods = new ModSimple[128];

        ModManagerSimple1 m = new ModManagerSimple1();
        m.Start(this);

        mods[modsCount++] = new ModSimpleDefault();
        mods[modsCount++] = new ModSimpleWorldGenerator();
        for (int i = 0; i < modsCount; i++)
        {
            mods[i].Start(m);
        }

        MapSizeX = 8192;
        MapSizeY = 8192;
        MapSizeZ = 128;
        chunks = new ChunkSimple[(MapSizeX / ChunkSize) * (MapSizeY / ChunkSize)][];
        chunkdrawdistance = 4;
        actions = new QueueAction();
        mainThreadActions = new QueueAction();

        spawnGlX = MapSizeX / 2;
        spawnGlY = MapSizeZ;
        for (int i = 0; i < modsCount; i++)
        {
            int spawnHeight = mods[i].GetHeight();
            if (spawnHeight != -1)
            {
                spawnGlY = spawnHeight;
            }
        }
        spawnGlZ = MapSizeY / 2;
    }
Example #8
0
    void NearestDirty(int clientid, int playerx, int playery, int playerz, int[] retNearest)
    {
        int nearestdist = intMaxValue;

        retNearest[0] = -1;
        retNearest[1] = -1;
        retNearest[2] = -1;
        int px = (playerx) / ServerSimple.ChunkSize;
        int py = (playery) / ServerSimple.ChunkSize;
        int pz = (playerz) / ServerSimple.ChunkSize;

        int chunksxy = this.mapAreaSize() / ServerSimple.ChunkSize / 2;
        int chunksz  = this.mapAreaSizeZ() / ServerSimple.ChunkSize / 2;

        int startx = px - chunksxy;
        int endx   = px + chunksxy;
        int starty = py - chunksxy;
        int endy   = py + chunksxy;
        int startz = pz - chunksz;
        int endz   = pz + chunksz;

        if (startx < 0)
        {
            startx = 0;
        }
        if (starty < 0)
        {
            starty = 0;
        }
        if (startz < 0)
        {
            startz = 0;
        }
        if (endx >= mapsizexchunks())
        {
            endx = mapsizexchunks() - 1;
        }
        if (endy >= mapsizeychunks())
        {
            endy = mapsizeychunks() - 1;
        }
        if (endz >= mapsizezchunks())
        {
            endz = mapsizezchunks() - 1;
        }

        ClientSimple client = server.clients[clientid];

        for (int x = startx; x <= endx; x++)
        {
            for (int y = starty; y <= endy; y++)
            {
                int pos = MapUtilCi.Index2d(x, y, server.MapSizeX / ServerSimple.ChunkSize);
                if (client.chunksseen[pos] == null)
                {
                    client.chunksseen[pos] = new bool[server.MapSizeZ / ServerSimple.ChunkSize];
                }
                for (int z = startz; z <= endz; z++)
                {
                    bool[] column = client.chunksseen[pos];
                    if (column[z])
                    {
                        continue;
                    }
                    {
                        int dx   = px - x;
                        int dy   = py - y;
                        int dz   = pz - z;
                        int dist = dx * dx + dy * dy + dz * dz;
                        if (dist < nearestdist)
                        {
                            nearestdist   = dist;
                            retNearest[0] = x;
                            retNearest[1] = y;
                            retNearest[2] = z;
                        }
                    }
                }
            }
        }
    }
Example #9
0
        public ActionResult CreateEdit(int?id, int?policyId, string returnUrl)
        {
            InvoiceItemViewModel vm;

            if (id != null) //Edit
            {
                vm = Uow.Invoices.GetAll()
                     .Where(i => i.Id == (int)id)
                     .Include(i => i.Particulars)
                     .ProjectTo <InvoiceItemViewModel>()
                     .FirstOrDefault();

                if (vm.DueDate.Year < 1980)
                {
                    vm.DueDate = DateTime.Now;
                }

                if (!(vm.StatusName.ToLower() == "pending" || vm.StatusName.ToLower() == "rejected"))
                {
                    //Invoice has been approved. Premium and Endorsement Number are fixed at this point.
                    var premiumFromParticular = vm.Particulars.Where(p => p.ParticularTypeName.ToLower() == "premium")
                                                .FirstOrDefault();
                    if (premiumFromParticular != null)
                    {
                        vm.Premium = premiumFromParticular.ParticularAmount;
                    }

                    //For Particular Readonly Values
                    vm.IsReadOnlyState = true;
                }
                else
                {
                    //Invoice not yet approved. Endorsement Number can still be modified.
                    var policy = Uow.Policies.GetAll()
                                 .Where(p => p.Id == vm.PolicyId)
                                 .Include(p => p.Endorsements)
                                 .FirstOrDefault();
                    if (policy != null && policy.Endorsements != null && policy.Endorsements.Count > 0)
                    {
                        var latestEndorsementNumber = policy.Endorsements
                                                      .OrderByDescending(e => e.EffectiveDate)
                                                      .FirstOrDefault()
                                                      .EndorsementNumber;
                        vm.EndorsementNumber = latestEndorsementNumber;
                    }

                    //For Particular Readonly Values
                    vm.IsReadOnlyState = false;
                }

                if (vm.StatusName.ToLower() == "unpaid")
                {
                    vm.PaidDate = DateTime.Now;
                }

                var policies = Uow.Policies.GetAll()
                               .Where(p => p.ClientId == vm.ClientId)
                               .ProjectTo <ClientPoliciesListModel>()
                               .ToList();

                vm.Policies = policies;

                vm.Clients      = ListProviderSvc.GetClientsWithPoliciesSimpleList();
                vm.IsFromPolicy = false;
            }
            else //Create
            {
                vm = new InvoiceItemViewModel
                {
                    StatusName   = "New",
                    IssueDate    = DateTime.Now,
                    DueDate      = DateTime.Now.AddMonths(1),
                    IsFromPolicy = false
                };

                if (policyId != null)
                {
                    vm.IsFromPolicy = true;
                    vm.Policies     = Uow.Policies.GetAll()
                                      .Where(p => p.Id == policyId)
                                      .ProjectTo <ClientPoliciesListModel>()
                                      .ToList();

                    vm.PolicyId          = vm.Policies[0].Id;
                    vm.CompanyName       = vm.Policies[0].CompanyName;
                    vm.EndorsementNumber = vm.Policies[0].LatestEndorsementNumber;
                    vm.Premium           = vm.Policies[0].Premium;
                    vm.Rebate            = vm.Policies[0].Rebate;

                    var item = Uow.Policies.GetAll()
                               .Where(p => p.Id == policyId)
                               .Select(p => p.Client)
                               .FirstOrDefault();

                    var client = new ClientSimple
                    {
                        Id            = item.Id,
                        Email         = item.Email,
                        AccountNumber = item.AccountNumber
                    };

                    if (item.IsOrganization)
                    {
                        client.ClientName = item.OrganizationName;
                    }
                    else
                    {
                        client.ClientName = item.LastName + ", " + item.FirstName;
                    }

                    vm.Clients = new List <ClientSimple>();
                    vm.Clients.Add(client);
                    vm.ClientId      = client.Id;
                    vm.ClientName    = client.ClientName;
                    vm.AccountNumber = client.AccountNumber;
                }
                else
                {
                    vm.Clients = ListProviderSvc.GetClientsWithPoliciesSimpleList();
                }
            }

            vm.ReturnUrl           = returnUrl;
            vm.ParticularTypesList = ListProviderSvc.GetParticularTypes();

            return(View(vm));
        }
 void ProcessPackets()
 {
     for (; ; )
     {
         NetIncomingMessage msg = server.ReadMessage();
         if (msg == null)
         {
             return;
         }
         switch (msg.Type)
         {
             case NetworkMessageType.Connect:
                 ClientSimple c = new ClientSimple();
                 c.MainSocket = server;
                 c.Connection = msg.SenderConnection;
                 c.chunksseen = new bool[(MapSizeX / ChunkSize) * (MapSizeY / ChunkSize)][];
                 clients[0] = c;
                 clientsCount = 1;
                 break;
             case NetworkMessageType.Data:
                 byte[] data = msg.message;
                 Packet_Client packet = new Packet_Client();
                 Packet_ClientSerializer.DeserializeBuffer(data, msg.messageLength, packet);
                 ProcessPacket(0, packet);
                 break;
             case NetworkMessageType.Disconnect:
                 break;
         }
     }
 }