Ejemplo n.º 1
0
        public async Task <RO <object> > CustomerEvents([FromBody] CustomerEventsData events)
        {
            // if events.Client.Customerkey = "ALL" - return all clients - all events
            var ro = new RO <object>();

            if (ModelState.IsValid)
            {
                                #if SESAM
                VendorInterface vendor = new VendorInterface();
                ro = await vendor.CustomerEvents(events);
                                #else
                var eventsList = await VendorDL.GetCustomerEvents(events);

                var ro = new RO <CustomerEventList>
                {
                    ReturnCode  = 0,
                    ReturnValue = eventsList
                };
                return(ro);
                                #endif
            }
            else
            {
                var message = string.Join(" | ", ModelState.Values.SelectMany(v => v.Errors).Select(e => e.ErrorMessage));
                ro.ReturnCode = 100;
                ro.Message    = "Bad request - CustomerEvents - Incorrect parameters:" + " - " + events.CustomerKey + "/" + events.FromDate + "/" + events.ToDate;
            }
            return(ro);
        }
Ejemplo n.º 2
0
        public async Task <RO <BossIDWS.Vendor.REST.ReturnObjects.AccessPointList> > CustomerAccessPoints([FromBody] CurrentClientData currentClient)
        {
            var ro = new RO <BossIDWS.Vendor.REST.ReturnObjects.AccessPointList>();

            if (ModelState.IsValid)
            {
                                #if SESAM
                VendorInterface vendor = new VendorInterface();
                ro = await vendor.CustomerAccessPoints(currentClient);
                                #else
                var detailsList = await VendorDL.CustomerAccessPoints(currentClient.CustomerKey);

                var ro = new RO <AccessPointDetailList>
                {
                    ReturnCode  = 0,
                    ReturnValue = detailsList
                };
                                #endif
            }
            else
            {
                var message = string.Join(" | ", ModelState.Values.SelectMany(v => v.Errors).Select(e => e.ErrorMessage));
                ro.ReturnCode = 100;
                ro.Message    = $"Bad request - CustomerAccessPoints - Incorrect parameters: {message}";
            }
            return(ro);
        }
Ejemplo n.º 3
0
        public async Task <RO <string> > CustomerChangePoints([FromBody] ClientChangePointsData clientdata)
        {
            var ro = new RO <string>();

            if (ModelState.IsValid)
            {
                                #if SESAM
                VendorInterface vendor = new VendorInterface();
                ro = await vendor.CustomerChangePoints(clientdata);
                                #else
                var result = await VendorDL.CustomerChangePoints(clientdata);

                if (result != null)
                {
                    ro.ReturnCode  = 0;
                    ro.ReturnValue = result;
                }
                else
                {
                    ro.ReturnCode = 100;
                }
                                #endif
            }
            else
            {
                var message = string.Join(" | ", ModelState.Values.SelectMany(v => v.Errors).Select(e => e.ErrorMessage));
                ro.ReturnCode = 100;
                ro.Message    = $"Bad request - CustomerChangePoints - Incorrect parameters: {message}";
            }
            return(ro);
        }
Ejemplo n.º 4
0
        public async Task <RO <string> > CustomerDelete([FromBody] CurrentClientData currentClient)
        {
            var ro = new RO <string>();

            if (ModelState.IsValid)
            {
                                #if SESAM
                VendorInterface vendor = new VendorInterface();
                ro = await vendor.CustomerDelete(currentClient);
                                #else
                var returnCode = await VendorDL.CustomerStatusChanged(true, true, currentClient.CustomerKey);

                var ro = new RO <string> {
                    ReturnCode = returnCode
                };
                                #endif
            }
            else
            {
                var message = string.Join(" | ", ModelState.Values.SelectMany(v => v.Errors).Select(e => e.ErrorMessage));
                ro.ReturnCode = 100;
                ro.Message    = $"Bad request - CustomerDelete - Incorrect parameters: {message}";
            }
            return(ro);
        }
Ejemplo n.º 5
0
        public async Task <RO <AccessPointDetailList> > AccessPointDetails(AccessPointData accessPoint)
        {
            var ro = new RO <AccessPointDetailList>();

            if (ModelState.IsValid)
            {
                                #if SESAM
                VendorInterface vendor = new VendorInterface();
                ro = await vendor.AccessPointDetails(accessPoint);
                                #else
                var accesspoints = await VendorDL.AccessPointDetails(accessPoint);

                ro.ReturnCode  = 0;
                ro.ReturnValue = accesspoints;
                                #endif
            }
            else
            {
                var message = string.Join(" | ", ModelState.Values.SelectMany(v => v.Errors).Select(e => e.ErrorMessage));

                ro.ReturnCode = 100;
                ro.Message    = $"Bad request - AccessPointDetails - Incorrect parameters: {message}";
            }
            return(ro);
        }
Ejemplo n.º 6
0
        public async Task <RO <Client> > CustomerNewHousehold([FromBody] HouseHoldClientData client)
        {
            var ro = new RO <Client>();

            if (ModelState.IsValid)
            {
                                #if SESAM
                VendorInterface vendor = new VendorInterface();
                ro = await vendor.AddNewClient(client);
                                #else
                var result = await VendorDL.AddNewClient(client);

                if (result != null)
                {
                    ro.ReturnCode  = 0;
                    ro.ReturnValue = result;
                }
                else
                {
                    ro.ReturnCode = -1;
                }
                                #endif
            }
            else
            {
                var message = string.Join(" | ", ModelState.Values.SelectMany(v => v.Errors).Select(e => e.ErrorMessage));
                ro.ReturnCode = -100;
                ro.Message    = $"Bad request - CustomerNewHousehold - Incorrect parameters: {message}";
            }
            return(ro);
        }
Ejemplo n.º 7
0
        public void Actualiza(VendorBE pItem, List <VendorAddressBE> pListaVendorAddress, List <VendorContactBE> pListaVendorContact, List <VendorClassificationBE> pListaVendorClassification)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    VendorDL               Vendor               = new VendorDL();
                    VendorAddressDL        VendorAddress        = new VendorAddressDL();
                    VendorContactDL        VendorContact        = new VendorContactDL();
                    VendorClassificationDL VendorClassification = new VendorClassificationDL();

                    foreach (var item in pListaVendorAddress)
                    {
                        if (item.TipoOper == Convert.ToInt32(Operacion.Nuevo)) //Nuevo
                        {
                            item.IdVendor = pItem.IdVendor;
                            VendorAddress.Inserta(item);
                        }
                        else
                        {
                            VendorAddress.Actualiza(item);
                        }
                    }

                    foreach (var item in pListaVendorContact)
                    {
                        if (item.TipoOper == Convert.ToInt32(Operacion.Nuevo)) //Nuevo
                        {
                            item.IdVendor = pItem.IdVendor;
                            VendorContact.Inserta(item);
                        }
                        else
                        {
                            VendorContact.Actualiza(item);
                        }
                    }

                    foreach (var item in pListaVendorClassification)
                    {
                        if (item.TipoOper == Convert.ToInt32(Operacion.Nuevo)) //Nuevo
                        {
                            item.IdVendor = pItem.IdVendor;
                            VendorClassification.Inserta(item);
                        }
                        else
                        {
                            VendorClassification.Actualiza(item);
                        }
                    }

                    Vendor.Actualiza(pItem);

                    ts.Complete();
                }
            }
            catch (Exception ex)
            { throw ex; }
        }
Ejemplo n.º 8
0
 public List <VendorBE> ListaTodosActivo(int IdCompany)
 {
     try
     {
         VendorDL Vendor = new VendorDL();
         return(Vendor.ListaTodosActivo(IdCompany));
     }
     catch (Exception ex)
     { throw ex; }
 }
Ejemplo n.º 9
0
 public VendorBE Selecciona(int IdVendor)
 {
     try
     {
         VendorDL Vendor = new VendorDL();
         VendorBE objEmp = Vendor.Selecciona(IdVendor);
         return(objEmp);
     }
     catch (Exception ex)
     { throw ex; }
 }
Ejemplo n.º 10
0
        public async Task <RO <Client> > CustomerMove([FromBody] MovedClientData movedClient)
        {
            var ro = new RO <Client>();

            var result = await VendorDL.CustomerMove(movedClient);

            if (result != null)
            {
                ro.ReturnCode  = 0;
                ro.ReturnValue = result;
            }
            else
            {
                ro.ReturnCode = 100;
            }
            return(ro);
        }
Ejemplo n.º 11
0
        public async Task <RO <string> > AccessPointOutOfOrder(AccessPointOutOfOrderData accessPoint)
        {
            var ro = new RO <string>();

            if (ModelState.IsValid)
            {
                ro = await VendorDL.AccessPointOutOfOrder(accessPoint);
            }
            else
            {
                var message = string.Join(" | ", ModelState.Values.SelectMany(v => v.Errors).Select(e => e.ErrorMessage));

                ro.ReturnCode = 60;
                ro.Message    = $"Bad request - AccessPointOutOfOrder - Incorrect parameters: {message}";
            }
            return(ro);
        }
Ejemplo n.º 12
0
        public void Elimina(VendorBE pItem)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    VendorDL               Vendor               = new VendorDL();
                    VendorAddressDL        VendorAddress        = new VendorAddressDL();
                    VendorContactDL        VendorContact        = new VendorContactDL();
                    VendorClassificationDL VendorClassification = new VendorClassificationDL();

                    List <VendorAddressBE> lstVendorAddress = null;
                    lstVendorAddress = new VendorAddressDL().ListaTodosActivo(pItem.IdVendor);

                    foreach (var item in lstVendorAddress)
                    {
                        VendorAddress.Elimina(item);
                    }

                    List <VendorContactBE> lstVendorContact = null;
                    lstVendorContact = new VendorContactDL().ListaTodosActivo(pItem.IdVendor);

                    foreach (var item in lstVendorContact)
                    {
                        VendorContact.Elimina(item);
                    }

                    List <VendorClassificationBE> lstVendorClassification = null;
                    lstVendorClassification = new VendorClassificationDL().ListaTodosActivo(pItem.IdVendor);

                    foreach (var item in lstVendorClassification)
                    {
                        VendorClassification.Elimina(item);
                    }



                    Vendor.Elimina(pItem);

                    ts.Complete();
                }
            }
            catch (Exception ex)
            { throw ex; }
        }
Ejemplo n.º 13
0
        public Int32 Inserta(VendorBE pItem, List <VendorAddressBE> pListaVendorAddress, List <VendorContactBE> pListaVendorContact, List <VendorClassificationBE> pListaVendorClassification)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    VendorDL               Vendor               = new VendorDL();
                    VendorAddressDL        VendorAddress        = new VendorAddressDL();
                    VendorContactDL        VendorContact        = new VendorContactDL();
                    VendorClassificationDL VendorClassification = new VendorClassificationDL();

                    int IdVendor = 0;
                    IdVendor = Vendor.Inserta(pItem);

                    foreach (var item in pListaVendorAddress)
                    {
                        item.IdVendor = IdVendor;
                        VendorAddress.Inserta(item);
                    }

                    foreach (var item in pListaVendorContact)
                    {
                        item.IdVendor = IdVendor;
                        VendorContact.Inserta(item);
                    }

                    foreach (var item in pListaVendorClassification)
                    {
                        item.IdVendor = IdVendor;
                        VendorClassification.Inserta(item);
                    }


                    ts.Complete();

                    return(IdVendor);
                }
            }
            catch (Exception ex)
            { throw ex; }
        }
Ejemplo n.º 14
0
 public static DataTable FillSuppVendorDetList(int argVendorID, string argSuppType)
 {
     return(VendorDL.FillSuppVendorDetList(argVendorID, argSuppType));
 }
Ejemplo n.º 15
0
 public static DataTable PopulateVendorDetList(int argVendorID, string argSuppType, string argListVendorId)
 {
     return(VendorDL.PopulateVendorDetList(argVendorID, argSuppType, argListVendorId));
 }
Ejemplo n.º 16
0
 public static void DeleteVendorDetailsWithoutMaster()
 {
     VendorDL.DeleteVendorDetailsWithoutMaster();
 }
Ejemplo n.º 17
0
 public static void ImportTransaction(string argVName, string argVAddress, string argContact, string argEmail, string argCST, string argTNGST, string argTIN, string argPAN, int argSupply, int argContract, int argService)
 {
     VendorDL.ImportTransaction(argVName, argVAddress, argContact, argEmail, argCST, argTNGST, argTIN, argPAN, argSupply, argContract, argService);
 }
Ejemplo n.º 18
0
 public static string GetCodeCheckVendor()
 {
     return(VendorDL.GetCodeCheckVendor());
 }
Ejemplo n.º 19
0
 public static bool IsChkSupplierValid(int argVendorID, string argType)
 {
     return(VendorDL.IsChkSupplierValid(argVendorID, argType));
 }
Ejemplo n.º 20
0
        private static void InitializeTestData()
        {
            /**************************************************
            *  Testparameters spesific to current test
            **************************************************/

            Type            = TestType.REST;
            _installationID = "123";

            //Add accesspoints - at least 3
            AvailableAccessPoints = new List <AccessPoint>();

            var ap1 = new AccessPoint {
                accesspointid = "1718", tag = "", name = "1"
            };

            AvailableAccessPoints.Add(ap1);

            var ap2 = new AccessPoint {
                accesspointid = "1719", tag = "", name = "2"
            };

            AvailableAccessPoints.Add(ap2);

            var ap3 = new AccessPoint {
                accesspointid = "1720", tag = "", name = "3"
            };

            AvailableAccessPoints.Add(ap3);

            /**************************************************
            *  Generic testparameters - no need to touch.....
            **************************************************/
            _allAccessPoints = new AccessPointData {
                InstallationID = InstallationID, Type = AccessPointData.AccessPointType.ALL
            };
            _accessPointsByID = new AccessPointData {
                InstallationID = InstallationID, Type = AccessPointData.AccessPointType.ID, AccessPoint = ap1.accesspointid
            };
            _accessPointsByName = new AccessPointData {
                InstallationID = InstallationID, Type = AccessPointData.AccessPointType.NAME, AccessPoint = ap2.name
            };
            _accessPointsByTag = new AccessPointData {
                InstallationID = InstallationID, Type = AccessPointData.AccessPointType.TAG, AccessPoint = ap3.tag
            };
            _apOutOfOrder = new AccessPointOutOfOrderData {
                InstallationID = TestSetup.InstallationID, AccessPoint = ap1.name, Message = "Out of Order", Type = AccessPointData.AccessPointType.NAME
            };

            if (Type == TestType.LiteDB)
            {
                AvailableAccessPoints.Add(VendorDL.GetRandomAccessPoint());
                AvailableAccessPoints.Add(VendorDL.GetRandomAccessPoint());
                AvailableAccessPoints.Add(VendorDL.GetRandomAccessPoint());
            }

            _availableCards = new Stack <string>();

            // Generate RFID cards
            for (var i = 0; i < 50; i++)
            {
                _availableCards.Push(Utils.GetRandomHexString());
            }

            HouseHoldClient = new HouseHoldClientData
            {
                Customerguid   = Guid.NewGuid().ToString(),
                Customerid     = Utils.GetRandomNumber(1001, 1000000).ToString(),
                Description    = "sample client description",
                Primary        = AvailableAccessPoints[0].accesspointid,
                Secondary1     = AvailableAccessPoints[1].accesspointid,
                Propertyunit   = "Propertyunitstring",
                Streetaddress  = "Customer address",
                RFID           = _availableCards.Pop() + ";" + _availableCards.Pop(),
                InstallationID = InstallationID
            };

            HouseHoldClient2 = new HouseHoldClientData
            {
                Customerguid   = Guid.NewGuid().ToString(),
                Customerid     = Utils.GetRandomNumber(1001, 1000000).ToString(),
                Description    = "testclient - to be deleted during test",
                Primary        = AvailableAccessPoints[0].accesspointid,
                Secondary1     = AvailableAccessPoints[1].accesspointid,
                Propertyunit   = "Propertyunitstring",
                Streetaddress  = "Customer address",
                RFID           = _availableCards.Pop() + ";" + _availableCards.Pop(),
                InstallationID = InstallationID
            };

            CommercialClient = new CommercialClientData
            {
                Name           = "Commercial name",
                Customerguid   = Guid.NewGuid().ToString(),
                Customerid     = new Random().Next(1001, 1000000).ToString(),
                Description    = "sample client description",
                Primary        = AvailableAccessPoints[0].accesspointid,
                Secondary1     = AvailableAccessPoints[1].accesspointid,
                Propertyunit   = "Propertyunitstring",
                Streetaddress  = "Customer address",
                RFID           = _availableCards.Pop() + ";" + _availableCards.Pop(),
                InstallationID = InstallationID
            };

            RequestAllEvents = new EventsData
            {
                Customerkey    = "ALL",
                FromDate       = DateTime.Now.AddDays(-100),
                ToDate         = DateTime.Now,
                InstallationID = InstallationID
            };

            if (Client1 == null)
            {
                var c1 = JsonConvert.DeserializeObject <Client>(Utils.GetSetting("Client1"));
                if (c1 != null)
                {
                    Client1 = c1;
                }

                var c2 = JsonConvert.DeserializeObject <Client>(Utils.GetSetting("Client2"));
                if (c2 != null)
                {
                    Client2 = c2;
                }
            }
        }
Ejemplo n.º 21
0
 public static void InsertVendorSupplierDet(int argVendorID, string argSuppType, DataTable dtList)
 {
     VendorDL.InsertVendorSupplierDet(argVendorID, argSuppType, dtList);
 }
Ejemplo n.º 22
0
 public static bool DelVendorSupplierDet(int argVendorID, int argSuppVenID, string argSuppType)
 {
     return(VendorDL.DelVendorSupplierDet(argVendorID, argSuppVenID, argSuppType));
 }
Ejemplo n.º 23
0
        public IHttpActionResult InitializeDB()
        {
            var data = new Dbobjects();
            var db   = data.LiteDb;

            var clients    = db.GetCollection <DBClient>("clients");
            var clientList = clients.FindAll();

            //db.DropCollection("clients");
            //db.DropCollection("cards");
            //db.DropCollection("accesspoints");
            //db.DropCollection("accesspointDetails");
            db.DropCollection("customerEvents");

            //var accesspointsList = db.GetCollection<DBAccessPoint>("accesspoints");
            //var accesspointDetailsList = db.GetCollection<DBAccessPointDetail>("accesspointDetails");

            //for (var i = 1; i < 21; i++)
            //{
            //    var accesspoint = new DBAccessPoint()
            //    {
            //        accesspointguid = Guid.NewGuid().ToString(),
            //        installationid = "0",
            //        accesspointid = i.ToString(),
            //        name = $"AccessPoint {i}"
            //    };

            //    accesspointsList.Insert(accesspoint);

            //    var accesspointDetail = new DBAccessPointDetail()
            //    {
            //        accesspointguid = accesspoint.accesspointguid,
            //        installationid = "0",
            //        accesspointid = accesspoint.accesspointid,
            //        serial = Guid.NewGuid().ToString()
            //    };

            //    accesspointDetailsList.Insert(accesspointDetail);
            //}

            //// Get card collection
            //var cards = db.GetCollection<DBCard>("cards");

            //for (int i = 1; i < 201; i++)
            //{
            //    var card = new DBCard()
            //    {
            //        RFID = GetRandomHexNumber(14)
            //    };

            //    cards.Insert(card);
            //}

            //var cards = db.GetCollection<DBCard>("cards");

            //var cardsAvaileable = cards.FindAll().Select(x => x.RFID).ToArray();

            var events = db.GetCollection <DBEvents>("customerEvents");


            for (var i = 1; i < 1001; i++)
            {
                var customerEvent = new DBEvents()
                {
                    installationid = "0",
                    accesspointid  = VendorDL.GetRandomAccessPoint().accesspointid,
                    customerkey    = VendorDL.GetRandomClient(),
                    eventtype      = new Random().Next(0, 4).ToString(),
                    rfid           = VendorDL.GetRandomCard(),
                    EventDate      = VendorDL.GetRandomEventDate(),
                    unit           = "kilo",
                    value          = new Random().Next(1, 100).ToString(),
                    vendorid       = "0",
                    size           = "N",
                    wpn            = "Rest"
                };

                events.Insert(customerEvent);
            }


            return(Ok());
        }
Ejemplo n.º 24
0
 //
 public static DataTable GetVendorCodeRegen()
 {
     return(VendorDL.GetVendorCodeRegen());
 }
Ejemplo n.º 25
0
 public static DataTable PopulateSType()
 {
     return(VendorDL.PopulateSType());
 }
Ejemplo n.º 26
0
 public static void MaxIncVendorMasterUpdate(int argVendorId, string argVendorCode)
 {
     VendorDL.MaxIncVendorMasterUpdate(argVendorId, argVendorCode);
 }
Ejemplo n.º 27
0
 public static bool IsValidName(string argName)
 {
     return(VendorDL.IsValidName(argName));
 }