Beispiel #1
0
        public ActionResult Index(string id)
        {
            ViewBag.iboName = "";
            ViewBag.IBONum  = "";
            ViewBag.email   = "";
            ViewBag.phone   = "";
            if (id != null)
            {
                BaseClient client = new BaseClient(baseApiUrl, "IBO", "GetIBO");
                IBO        ibo    = client.Get <IBO>(id);
                if (ibo != null)
                {
                    ViewBag.iboName  = string.Concat(ibo.firstName, " ", ibo.lastName);
                    ViewBag.lastName = ibo.lastName;
                    ViewBag.IBONum   = ibo.IBONum;
                    ViewBag.email    = ibo.email;
                    ViewBag.phone    = ibo.phone;
                }
            }
            Contact contact = new Contact();

            contact.contactLevel  = "0";
            contact.datetime      = DateTime.Now;
            contact.birthday      = DateTime.Now;
            contact.isPublic      = true;
            contact.contactTypeId = 2;
            contact.languageId    = 1;
            ViewBag.contact       = contact;
            return(View());
        }
Beispiel #2
0
        /// <summary>
        /// Generates the vertices, normals and indices and creates them for the OpenGL.
        /// This method has to be called once before drawing.
        /// </summary>
        /// <param name="gl"></param>
        public void GenerateGeometry(OpenGL gl, OGLModelUsage usage)
        {
            GL     = gl;
            _usage = usage;

            // Create the data buffers.
            var buffers = OGLBufferId.CreateBufferIds(gl, 3);

            IndexBuffer  = new IBO(buffers[0]);
            NormalBuffer = new VBO(buffers[1]);
            VertexBuffer = new VBO(buffers[2]);

            if (AutoCalculateNormals)
            {
                CalculateNormals();
            }

            var vertData = Vertices.SelectMany(v => v.to_array()).ToArray();

            VertexBuffer.BindBuffer(gl);                                                         // GL.BindBuffer(OpenGL.GL_ARRAY_BUFFER, VertexBuffer.Buffer.Value);
            VertexBuffer.SetBufferData(gl, OGLBufferDataTarget.ArrayBuffer, vertData, usage, 3); // GL.BufferData(OpenGL.GL_ARRAY_BUFFER, vertData, (uint)usage);

            var normData = Normals.SelectMany(v => v.to_array()).ToArray();

            NormalBuffer.BindBuffer(gl);                                                         //GL.BindBuffer(OpenGL.GL_ARRAY_BUFFER, NormalBuffer.Buffer.Value);
            NormalBuffer.SetBufferData(gl, OGLBufferDataTarget.ArrayBuffer, normData, usage, 3); // GL.BufferData(OpenGL.GL_ARRAY_BUFFER, normData, (uint)usage);

            IndexBuffer.BindBuffer(gl);                                                          // GL.BindBuffer(OpenGL.GL_ARRAY_BUFFER, IndexBuffer.Buffer.Value);
            IndexBuffer.SetBufferData(gl, OGLBufferDataTarget.ArrayBuffer, Indices, usage, 1);   // GL.BufferData(OpenGL.GL_ARRAY_BUFFER, Indices, (uint)usage);

            if (new OGLModelUsage[] { OGLModelUsage.StaticCopy, OGLModelUsage.StaticDraw, OGLModelUsage.StaticRead }.Contains(usage))
            {
                ClearStaticData();
            }
        }
        public ActionResult Update()
        {
            IBO ibo = IBOVirtualAPI.GetIBOByUId(WebSecurity.CurrentUserId.ToString());

            ViewBag.languages = languages;
            return(View(ibo));
        }
        public SalesController(IBO bo, ILog log)
        {
            if (bo == null) throw new ArgumentNullException(nameof(bo));
            if (log == null) throw new ArgumentNullException(nameof(log));

            BO = bo;
            Log = log;
        }
Beispiel #5
0
        public IBO GetIBOByUId(int id)
        {
            IBO ibo = (from u in db.IBOs where u.UserId == id select u).FirstOrDefault();

            if (ibo == null)
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            return(ibo);
        }
Beispiel #6
0
        public IBO GetIBO(string id)
        {
            IBO ibo = db.IBOs.Find(id);

            if (ibo == null)
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            return(ibo);
        }
Beispiel #7
0
        public IBOShort GetIBOShort(string id)
        {
            IBO ibo = db.IBOs.Find(id);

            if (ibo == null)
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            return(new IBOShort {
                IBONum = ibo.IBONum, firstName = ibo.firstName, lastName = ibo.lastName, email = ibo.email, phone = ibo.phone
            });
        }
        public static IBO ParseIBO(IBO model)
        {
            IBO ibo = new IBO();

            ibo.IBONum          = model.IBONum;
            ibo.firstName       = model.firstName;
            ibo.lastName        = model.lastName;
            ibo.languageId      = model.languageId;
            ibo.email           = model.email;
            ibo.phone           = model.phone;
            ibo.newsletteroptin = model.newsletteroptin;
            ibo.birthday        = model.birthday != null ? model.birthday : DateTime.Now;
            ibo.picture         = HttpUtility.HtmlEncode(model.picture != null ? model.picture : "");
            ibo.twitter         = model.twitter != null ? model.twitter : "";
            ibo.UPLine          = model.UPLine != null ? model.UPLine : "";
            return(ibo);
        }
        public ActionResult Update(IBO model)
        {
            IBO iboUpdate = ModelParser.ParseIBO(model);

            iboUpdate.UserId      = WebSecurity.CurrentUserId;
            iboUpdate.datetime    = DateTime.Now;
            iboUpdate.facebookid  = FacebookId != null ? FacebookId : "";
            iboUpdate.accesstoken = AccessToken != null ? AccessToken : "";
            iboUpdate.level       = model.level;
            try
            {
                string result = IBOVirtualAPI.Update <IBO>(model.IBONum, iboUpdate);
                Cookies.Nullify();
            }
            catch { }
            return(RedirectToAction("Index", "Dashboard"));
        }
Beispiel #10
0
 public HttpResponseMessage PostIBO(IBO ibo)
 {
     if (ModelState.IsValid)
     {
         db.IBOs.Add(ibo);
         db.SaveChanges();
         if ((!string.IsNullOrEmpty(ibo.email)) && (ibo.newsletteroptin == true))
         {
             EmailHelper mail = new EmailHelper();
             mail.AddToMailingList(ibo.firstName, ibo.lastName, ibo.email);
         }
         HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, ibo);
         response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = ibo.IBONum }));
         return(response);
     }
     else
     {
         return(Request.CreateResponse(HttpStatusCode.BadRequest));
     }
 }
 public ActionResult Forgot(ForgotModel model)
 {
     if (WebSecurity.GetUserId(model.UserName) > -1 && (WebSecurity.IsConfirmed(model.UserName)))
     {
         string token = WebSecurity.GeneratePasswordResetToken(model.UserName, 1200);
         /* Get IBO Email */
         IBO ibo = IBOVirtualAPI.GetIBOByUId(WebSecurity.GetUserId(model.UserName).ToString());
         /* Set And Send Email Reset Request */
         ResertEmailContact contact = new ResertEmailContact();
         contact.name  = model.UserName;
         contact.email = ibo.email;
         contact.token = token;
         bool result = IBOVirtualAPI.CreateResetEmail(contact);
     }
     else
     {
         ModelState.AddModelError(String.Empty, TextResources.Businesslms.ErrorUserNotFound);
     }
     return(View(model));
 }
Beispiel #12
0
        public HttpResponseMessage PutIBO(string id, IBO ibo)
        {
            if (ModelState.IsValid && id == ibo.IBONum)
            {
                db.Entry(ibo).State = EntityState.Modified;

                try
                {
                    db.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
        public ActionResult AddIBO(IBO model)
        {
            ViewBag.languages = languages;
            IBO ibo = ModelParser.ParseIBO(model);

            ibo.UserId      = WebSecurity.CurrentUserId;
            ibo.datetime    = DateTime.Now;
            ibo.facebookid  = FacebookId != null ? FacebookId : "";
            ibo.accesstoken = AccessToken != null ? AccessToken : "";
            ibo.level       = model.level;
            try
            {
                bool result = IBOVirtualAPI.Create <IBO>(ibo);
                Cookies.iboCookie.Nullify();
                return(RedirectToAction("Index", "Dashboard"));
            }
            catch
            {
                ModelState.AddModelError(null, "The IBO Number is already been used");
                return(View(model));
            }
        }
Beispiel #14
0
        public HttpResponseMessage DeleteIBO(string id)
        {
            IBO ibo = db.IBOs.Find(id);

            if (ibo == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            db.IBOs.Remove(ibo);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, ibo));
        }
Beispiel #15
0
 public void SetIBO(IBO data)
 {
     this.Set <IBO>(data);
 }
Beispiel #16
0
        public static unsafe bool TryGetMesh(Renderable renderable, [MaybeNullWhen(false)] out Mesh mesh)
        {
            ArgumentNullException.ThrowIfNull(renderable);

            if (renderable.TryGetScreen(out var screen) == false)
            {
                goto FAILURE;
            }
            if (Engine.CurrentContext != screen)
            {
                goto FAILURE;
            }
            if (renderable.IsLoaded == false)
            {
                goto FAILURE;
            }

            const uint IndexSize = sizeof(int);

            var vertexType = renderable.VertexType;

            Debug.Assert(vertexType != null);
            if (VertexMarshalHelper.TryGetVertexTypeData(vertexType, out var vertexTypeData) == false)
            {
                goto FAILURE;
            }

            var vertexSize = (ulong)vertexTypeData.VertexSize;

            Debug.Assert(vertexType != null);

            var vbo = renderable.VBO;
            var ibo = renderable.IBO;

            var verticesCount    = vbo.Length;
            var indicesCount     = ibo.Length;
            var verticesByteSize = verticesCount * vertexSize;
            var indicesByteSize  = indicesCount * IndexSize;

            var bufLen = verticesByteSize + indicesByteSize;
            var buf    = UniquePtr.Malloc(checked ((nuint)bufLen));
            var vDest  = (void *)buf.Ptr;
            var iDest  = buf.GetPtr <byte>() + verticesByteSize;

            try {
                try {
                    VBO.Bind(vbo);
                    var vSource = (void *)VBO.MapBufferReadOnly();
                    Buffer.MemoryCopy(vSource, vDest, bufLen, verticesByteSize);
                }
                finally {
                    VBO.UnmapBuffer();
                    VBO.Unbind();
                }
                try {
                    IBO.Bind(ibo);
                    var iSource = (void *)IBO.MapBufferReadOnly();
                    Buffer.MemoryCopy(iSource, iDest, bufLen, indicesByteSize);
                }
                finally {
                    IBO.UnmapBuffer();
                    IBO.Unbind();
                }
                mesh = Mesh.Create(vertexTypeData, IndexSize, vDest, verticesByteSize, iDest, indicesByteSize, ref buf, static buf => buf.Dispose());
                return(true);
            }
            finally {
                buf.Dispose();
            }

FAILURE:
            mesh = null;
            return(false);
        }
Beispiel #17
0
        public static unsafe bool TryGetMeshRaw(
            Renderable renderable,
            void *vertices, ulong verticesByteSize,
            int *indices, ulong indicesByteSize,
            [MaybeNullWhen(false)] out Type vertexType,
            out ulong verticesByteSizeActual,
            out uint indicesByteSizeActual)
        {
            ArgumentNullException.ThrowIfNull(renderable);

            if (renderable.TryGetScreen(out var screen) == false)
            {
                goto FAILURE;
            }
            if (Engine.CurrentContext != screen)
            {
                goto FAILURE;
            }
            if (renderable.IsLoaded == false)
            {
                goto FAILURE;
            }
            vertexType = renderable.VertexType;
            Debug.Assert(vertexType != null);
            if (VertexMarshalHelper.TryGetVertexTypeData(vertexType, out var vertexTypeData) == false)
            {
                goto FAILURE;
            }

            var vertexSize = (ulong)vertexTypeData.VertexSize;

            Debug.Assert(vertexType != null);

            var vbo = renderable.VBO;
            var ibo = renderable.IBO;

            var verticesCount = vbo.Length;
            var indicesCount  = ibo.Length;

            verticesByteSizeActual = verticesCount * vertexSize;
            indicesByteSizeActual  = indicesCount * sizeof(int);

            if (verticesByteSize < verticesByteSizeActual)
            {
                goto FAILURE;
            }
            if (indicesByteSize < indicesByteSizeActual)
            {
                goto FAILURE;
            }

            try {
                VBO.Bind(vbo);
                var vSource = (void *)VBO.MapBufferReadOnly();
                Buffer.MemoryCopy(vSource, vertices, verticesByteSize, verticesByteSizeActual);
            }
            finally {
                VBO.UnmapBuffer();
                VBO.Unbind();
            }
            try {
                IBO.Bind(ibo);
                var iSource = (void *)IBO.MapBufferReadOnly();
                Buffer.MemoryCopy(iSource, indices, indicesByteSize, indicesByteSizeActual);
            }
            finally {
                IBO.UnmapBuffer();
                IBO.Unbind();
            }
            return(true);

FAILURE:
            vertexType             = null;
            verticesByteSizeActual = 0;
            indicesByteSizeActual  = 0;
            return(false);
        }
Beispiel #18
0
 public BOCommandExecuted(IBO bo)
 {
     BO = bo;
     BOType = bo.GetType();
 }