public ActionResult View(long id)
        {
            try
            {
                using (var repository = new OrderRepository())
                {
                    var model = repository.Db.OrderToStore.Where(e => e.OrderToStoreId == id)
                                .Select(e => new ViewInfoOrderModel
                    {
                        OrderToStoreId     = e.OrderToStoreId,
                        FranchiseName      = e.Franchise.Name,
                        FranchiseStoreName = e.FranchiseStore.Name,
                        StartDatetime      = e.StartDatetime,
                        LastStatus         = e.LastStatus,
                        Phone    = e.ClientPhone.Phone,
                        FullName = e.Client.FirstName + " " + e.Client.LastName,
                        Address  =
                            e.Address.RegionNameA + " " + e.Address.RegionNameB + " " + e.Address.RegionNameC + " " +
                            e.Address.MainAddress
                            + " " + e.Address.ExtIntNumber,
                        Reference   = e.Address.Reference,
                        IsMap       = e.Address.IsMap,
                        PlaceId     = e.Address.PlaceId,
                        Lat         = e.Address.Lat,
                        Lng         = e.Address.Lng,
                        Total       = e.PosOrder.Total,
                        UserNameIns = e.AspNetUsers.UserName,
                        Notes       = e.ExtraNotes,
                        LstItems    = e.PosOrder.PosOrderItem.Select(i => new InfoItemModel
                        {
                            PosOrderItemId = i.PosOrderItemId,
                            LevelItem      = i.LevelItem,
                            Name           = i.Name,
                            ParentId       = i.ParentId ?? -1,
                            Price          = i.Price
                        }).OrderBy(i => i.PosOrderItemId).ToList()
                    }).FirstOrDefault();

                    ViewBag.Model = JsonConvert.SerializeObject(model);
                }
            }
            catch (Exception ex)
            {
                SharedLogger.LogError(ex, id);
            }

            return(View());
        }
 public ResponseMessageData <ListItemModel> SearchClientsByClientName(String clientName)
 {
     try
     {
         return(new ResponseMessageData <ListItemModel>
         {
             IsSuccess = true,
             LstData = AppInit.Container.Resolve <IClientService>().SearchClientsByClientName(clientName)
         });
     }
     catch (Exception ex)
     {
         SharedLogger.LogError(ex);
         return(ResponseMessageData <ListItemModel> .CreateCriticalMessage("No fue posible listar los clientes por su nombre"));
     }
 }
 public ResponseMessageData <ClientInfoModel> SearchClientsByPhone(String phone)
 {
     try
     {
         return(new ResponseMessageData <ClientInfoModel>
         {
             IsSuccess = true,
             LstData = AppInit.Container.Resolve <IClientService>().SearchClientsByPhone(phone)
         });
     }
     catch (Exception ex)
     {
         SharedLogger.LogError(ex);
         return(ResponseMessageData <ClientInfoModel> .CreateCriticalMessage("No fue posible listar los clientes por el teléfono"));
     }
 }
 public ResponseMessageData <ListItemModel> SearchByCompany(String company)
 {
     try
     {
         return(new ResponseMessageData <ListItemModel>
         {
             IsSuccess = true,
             LstData = AppInit.Container.Resolve <IClientService>().SearchByCompany(company)
         });
     }
     catch (Exception ex)
     {
         SharedLogger.LogError(ex);
         return(ResponseMessageData <ListItemModel> .CreateCriticalMessage("No fue posible buscar por compañía"));
     }
 }
        public ActionResult ChangePass(string id)
        {
            UserChangePassword model = null;

            try
            {
                model = new UserChangePassword {
                    Id = id
                };
            }
            catch (Exception ex)
            {
                SharedLogger.LogError(ex, id);
            }
            return(View(model));
        }
Ejemplo n.º 6
0
 public ResponseMessageData <TrackOrderDto> ShowDetailByOrderId(long orderId)
 {
     try
     {
         return(new ResponseMessageData <TrackOrderDto>
         {
             IsSuccess = true,
             Data = AppInit.Container.Resolve <ITrackService>().ShowDetailByOrderId(orderId)
         });
     }
     catch (Exception ex)
     {
         SharedLogger.LogError(ex);
         return(ResponseMessageData <TrackOrderDto> .CreateCriticalMessage("No fue posible rastrear el detalle de la orden"));
     }
 }
Ejemplo n.º 7
0
        private void getNewPort(IPAddress managerAddress, int registrationPort)
        {
            TCPClient registrationConnection = new TCPClient(managerAddress, registrationPort);

            SharedLogger.Debug(workerName, "Registration Service", $"Registration sent to {managerAddress}:{registrationPort}.");
            registrationConnection.SendObject <string>("REGISTER");
            //while (!registrationConnection.MessageIsAvailable())
            //{
            //    Thread.Sleep(500);
            //}
            string[] registrationInfo = registrationConnection.ReceiveObject <string>().Split('|');
            workerName = registrationInfo[1];
            managerMessageProcessor.UpdateRunnerName(workerName);
            SharedLogger.Msg(workerName, "Registration Service", $"Registered to manager server at {managerAddress.ToString()} with port assignment {registrationInfo[0]}.");
            assignedPort = Convert.ToInt32(registrationInfo[0]);
        }
Ejemplo n.º 8
0
 public ResponseMessageData <AddressInfoModel> SearchAddressByPhone(String phone)
 {
     try
     {
         return(new ResponseMessageData <AddressInfoModel>
         {
             IsSuccess = true,
             LstData = AppInit.Container.Resolve <IAddressService>().SearchAddressByPhone(phone)
         });
     }
     catch (Exception ex)
     {
         SharedLogger.LogError(ex);
         return(ResponseMessageData <AddressInfoModel> .CreateCriticalMessage("No fue posible buscar una dirección por el teléfono"));
     }
 }
Ejemplo n.º 9
0
 public ResponseMessageData <ListItemModel> SearchByZipCode(String zipCode)
 {
     try
     {
         return(new ResponseMessageData <ListItemModel>
         {
             IsSuccess = true,
             LstData = AppInit.Container.Resolve <IAddressService>().SearchByZipCode(zipCode)
         });
     }
     catch (Exception ex)
     {
         SharedLogger.LogError(ex);
         return(ResponseMessageData <ListItemModel> .CreateCriticalMessage("No fue posible determinar la dirección con el código postal"));
     }
 }
 public ResponseMessageData <SyncFranchiseModel> GetListSyncFiles()
 {
     try
     {
         return(new ResponseMessageData <SyncFranchiseModel>
         {
             IsSuccess = true,
             LstData = AppInit.Container.Resolve <IFranchiseService>().GetListSyncFiles(Context.Headers[SharedConstants.Server.USERNAME_HEADER])
         });
     }
     catch (Exception ex)
     {
         SharedLogger.LogError(ex);
         return(ResponseMessageData <SyncFranchiseModel> .CreateCriticalMessage("No fue posible obtener los archivos a sincronizar"));
     }
 }
Ejemplo n.º 11
0
 public ResponseMessageData <ResponseMessage> CancelOrder(long orderToStoreId)
 {
     try
     {
         return(new ResponseMessageData <ResponseMessage>
         {
             IsSuccess = true,
             Data = AppInit.Container.Resolve <IStoreService>().CancelOrder(orderToStoreId),
         });
     }
     catch (Exception ex)
     {
         SharedLogger.LogError(ex);
         return(ResponseMessageData <ResponseMessage> .CreateCriticalMessage("No fue posible cancelar la orden"));
     }
 }
 public ResponseMessageData <ButtonItemModel> GetMenuByUser(String username)
 {
     try
     {
         return(new ResponseMessageData <ButtonItemModel>
         {
             IsSuccess = true,
             LstData = AppInit.Container.Resolve <IAccountService>().GetMenuByUser(username)
         });
     }
     catch (Exception ex)
     {
         SharedLogger.LogError(ex);
         return(ResponseMessageData <ButtonItemModel> .CreateCriticalMessage("No hay menú disponible"));
     }
 }
        private static ResponseRd SendOrderToStore(OrderModelDto model, IHubCallerConnectionContext <dynamic> clients, CustomerOrder.Order order)
        {
            using (var client = new CustomerOrderClient(new BasicHttpBinding(), new EndpointAddress(model.Store.WsAddress + SettingsData.Constants.StoreOrder.WsCustomerOrder)))
            {
                var iTries = 0;
                while (iTries < 3)
                {
                    try
                    {
                        var result = client.AddOrder(order);
                        if (result.IsSuccess && result.Order.orderIdField.IsValidId())
                        {
                            clients.Caller.OnSendToStoreEventChange(new ResponseMessage
                            {
                                Code      = SettingsData.Constants.StoreConst.STORE_RESPONSE_CALL_WS_SUCCESS,
                                IsSuccess = true,
                                Message   = String.Format("Pedido (ATO ID {0}) enviado de forma exitosa", result.Order.orderIdField)
                            });
                            client.Close();
                            return(result);
                        }

                        var resultOrderId = result.IsSuccess ? result.Order.orderIdField : "ND";

                        SharedLogger.LogError(new Exception(
                                                  String.Format("SendOrderToStore: {0} | {1} | {2} | {3} | {4}", result.IsSuccess, result.ErrMsg, result.ResultCode, result.ResultData))
                                              , model.PosOrder, model.Store, model.Phone, model.OrderDetails, model.OrderToStoreId, resultOrderId);
                    }
                    catch (Exception ex)
                    {
                        SharedLogger.LogError(ex);
                        clients.Caller.OnSendToStoreEventChange(new ResponseMessage
                        {
                            Code      = SettingsData.Constants.StoreConst.STORE_RESPONSE_CALL_WS_ERROR,
                            IsSuccess = false,
                            Message   = String.Format("Intento {0} fallido. Error: {1}", (iTries + 1), ex.Message)
                        });
                    }
                    Thread.Sleep(1000);
                    iTries++;
                }

                client.Close();
            }

            return(null);
        }
Ejemplo n.º 14
0
 public ResponseMessageData <StoreNotificationCategoryModel> GetNotificationsByStore(int storeId)
 {
     try
     {
         var response = new ResponseMessageData <StoreNotificationCategoryModel>
         {
             IsSuccess = true,
             LstData   = AppInit.Container.Resolve <IStoreService>().GetNotificationsByStore(storeId)
         };
         return(response);
     }
     catch (Exception ex)
     {
         SharedLogger.LogError(ex);
         return(ResponseMessageData <StoreNotificationCategoryModel> .CreateCriticalMessage("No fue posible obtener las notificaciones para la sucursal seleccionada"));
     }
 }
Ejemplo n.º 15
0
 public ResponseMessageData <TrackOrderDto> SearchByDailyInfo(PagerDto <DailySearchModel> model)
 {
     try
     {
         return(new ResponseMessageData <TrackOrderDto>
         {
             IsSuccess = true,
             LstData = AppInit.Container.Resolve <ITrackService>().SearchByDailyInfo(model),
             Pager = model.Pager
         });
     }
     catch (Exception ex)
     {
         SharedLogger.LogError(ex);
         return(ResponseMessageData <TrackOrderDto> .CreateCriticalMessage("No fue posible obtener los pedidos con esos parámetros"));
     }
 }
Ejemplo n.º 16
0
 public ResponseMessageData <TrackOrderDto> SearchByClientName(PagerDto <long> client)
 {
     try
     {
         return(new ResponseMessageData <TrackOrderDto>
         {
             IsSuccess = true,
             LstData = AppInit.Container.Resolve <ITrackService>().SearchByClient(client),
             Pager = client.Pager
         });
     }
     catch (Exception ex)
     {
         SharedLogger.LogError(ex);
         return(ResponseMessageData <TrackOrderDto> .CreateCriticalMessage("No fue posible rastrear por nombre del cliente"));
     }
 }
Ejemplo n.º 17
0
 public override bool Initialize(bool bForceToInit = false, string parameters = null)
 {
     if (!string.IsNullOrWhiteSpace(parameters))
     {
         try
         {
             dynamic parms = JObject.Parse(parameters);
             Title      = parms.Title;
             UrlBrowser = parms.Url;
         }
         catch (Exception ex)
         {
             SharedLogger.LogError(ex);
         }
     }
     return(base.Initialize(true));
 }
        public ResponseMessageData <bool> SendOrder(PosCheck posCheck)
        {
            try
            {
                MessageBus.Current.SendMessage(posCheck, SharedMessageConstants.ORDER_SEND_POSORDER);

                return(new ResponseMessageData <bool>
                {
                    IsSuccess = true
                });
            }
            catch (Exception ex)
            {
                SharedLogger.LogError(ex);
                return(ResponseMessageData <bool> .CreateCriticalMessage("No fue posible enviar la orden al POS"));
            }
        }
        public ActionResult DoUpsert(FranchiseUpModel model)
        {
            try
            {
                if (ModelState.IsValid == false)
                {
                    return(Json(new ResponseMessageModel
                    {
                        HasError = true,
                        Title = ResShared.TITLE_REGISTER_FAILED,
                        Message = ResShared.ERROR_INVALID_MODEL
                    }));
                }

                using (var service = new FranchiseSettingService())
                {
                    var response = service.ValidateModel(model);

                    if (response.HasError)
                    {
                        response.Title = ResShared.TITLE_REGISTER_FAILED;
                        return(Json(response));
                    }

                    model.UserInsUpId = User.Identity.GetUserId();
                    response          = service.Save(model);

                    if (response.HasError)
                    {
                        response.Title = ResShared.TITLE_REGISTER_FAILED;
                    }

                    return(Json(response));
                }
            }
            catch (Exception ex)
            {
                SharedLogger.LogError(ex);
                return(Json(new ResponseMessageModel
                {
                    HasError = true,
                    Title = ResShared.TITLE_REGISTER_FAILED,
                    Message = ResShared.ERROR_UNKOWN
                }));
            }
        }
 public ResponseMessageData <string> GetAccountInfo()
 {
     try
     {
         return(new ResponseMessageData <string>
         {
             IsSuccess = true,
             Data = AppInit.Container.Resolve <IAccountService>()
                    .GetAccountInfo(Context.Headers[SharedConstants.Server.USERNAME_HEADER], Context.Headers[SharedConstants.Server.CONNECTION_ID_HEADER])
         });
     }
     catch (Exception ex)
     {
         SharedLogger.LogError(ex);
         return(ResponseMessageData <string> .CreateCriticalMessage("No hay información disponible del usuario"));
     }
 }
Ejemplo n.º 21
0
        private void SendEmails(List <EmailOrderToStore> lstEmailsToSend, EmailSettings emailSettings)
        {
            using (var repository = new StoreRepository())
            {
                using (var client = new SmtpClient(emailSettings.Host, emailSettings.Port))
                {
                    //client.DeliveryFormat = SmtpDeliveryFormat.International;
                    client.EnableSsl   = emailSettings.EnableSsl;
                    client.Credentials = new NetworkCredential(emailSettings.Username, emailSettings.Password);
                    //client.UseDefaultCredentials = false;

                    foreach (var emailOrder in lstEmailsToSend)
                    {
                        try
                        {
                            emailOrder.TriesToSend++;
                            using (var mail = new MailMessage())
                            {
                                var body = emailOrder.BuildBody(emailSettings.Template);

                                foreach (var destination in emailOrder.DestinationEmails.Split(';'))
                                {
                                    mail.To.Add(new MailAddress(destination));
                                }

                                mail.From       = new MailAddress(emailSettings.Sender);
                                mail.Sender     = mail.From;
                                mail.Subject    = string.Format(emailSettings.Title, emailOrder.AtoOrderId);
                                mail.Body       = body;
                                mail.IsBodyHtml = true;
                                client.Send(mail);
                            }

                            repository.UpdateOrderToSendByEmail(emailOrder.OrderToStoreEmailId, emailOrder.TriesToSend, true);
                        }
                        catch (Exception ex)
                        {
                            _eventLog.WriteEntry(ex.Message + " -ST- " + ex.StackTrace, EventLogEntryType.Error);
                            SharedLogger.LogError(ex);
                            repository.UpdateOrderToSendByEmail(emailOrder.OrderToStoreEmailId, emailOrder.TriesToSend, false);
                        }
                    }
                }
            }
        }
        public ActionResult SearchMonthlyByYear(int year)
        {
            var response = new ResponseMessageModel {
                HasError = false
            };

            try
            {
                IReportService reportService = new ReportService();
                response.Data = reportService.GetSalesMonthlyByYear(year);
            }
            catch (Exception ex)
            {
                SharedLogger.LogError(ex);
                response.HasError = true;
            }
            return(Json(response));
        }
Ejemplo n.º 23
0
        public ResponseMessageData <ButtonItemModel> GetFranchiseButtons()
        {
            try
            {
                var lstData = AppInit.Container.Resolve <IFranchiseService>().GetFranchiseButtons();

                return(new ResponseMessageData <ButtonItemModel>
                {
                    IsSuccess = true,
                    LstData = lstData
                });
            }
            catch (Exception ex)
            {
                SharedLogger.LogError(ex);
                return(ResponseMessageData <ButtonItemModel> .CreateCriticalMessage("No fue posible obtener las franquicias a emplear"));
            }
        }
Ejemplo n.º 24
0
 public ResponseMessageData <TrackOrderDto> SearchByPhone(PagerDto <String> phone)
 {
     try
     {
         var lstData = AppInit.Container.Resolve <ITrackService>().SearchByPhone(phone);
         return(new ResponseMessageData <TrackOrderDto>
         {
             IsSuccess = true,
             LstData = lstData,
             Pager = phone.Pager
         });
     }
     catch (Exception ex)
     {
         SharedLogger.LogError(ex);
         return(ResponseMessageData <TrackOrderDto> .CreateCriticalMessage("No fue posible rastrear por número telefónico"));
     }
 }
        public ActionResult SearchMonthSalesByDays(ReportRequestMonthModel reportRequest)
        {
            var response = new ResponseMessageModel {
                HasError = false
            };

            try
            {
                IReportService reportService = new ReportService();
                response.Data = reportService.GetMonthSalesByDays(reportRequest.Year, reportRequest.Month);
            }
            catch (Exception ex)
            {
                SharedLogger.LogError(ex);
                response.HasError = true;
            }
            return(Json(response));
        }
        public ActionResult SearchDaysByRange(ReportRequestModel reportRequest)
        {
            var response = new ResponseMessageModel {
                HasError = false
            };

            try
            {
                IReportService reportService = new ReportService();
                response.Data = reportService.GetDailySaleInfo(reportRequest.StartCalculatedDate, reportRequest.EndCalculatedDate);
            }
            catch (Exception ex)
            {
                SharedLogger.LogError(ex);
                response.HasError = true;
            }
            return(Json(response));
        }
        public ActionResult SearchByFranchiseAndDate(ReportRequestModel reportRequest)
        {
            var response = new ResponseMessageModel {
                HasError = false
            };

            try
            {
                IReportService reportService = new ReportService();
                response.Data = reportService.GetClientOrderInfoByFranchiseAndDate(reportRequest);
            }
            catch (Exception ex)
            {
                SharedLogger.LogError(ex);
                response.HasError = true;
            }
            return(Json(response));
        }
        private ResponseMessage DoCancelOrder(long atoOrderId, FranchiseStoreWsInfo fsInfo)
        {
            using (var client = new QueryFunctionClient(new BasicHttpBinding(), new EndpointAddress(fsInfo.WsAddress + SettingsData.Constants.StoreOrder.WsQueryFunction)))
            {
                var iTries = 0;
                while (iTries < 3)
                {
                    try
                    {
                        var result = client.CancelOrder(atoOrderId, false);
                        if (result.IsSuccess)
                        {
                            return(new ResponseMessage
                            {
                                IsSuccess = true,
                                Message = "Orden cancelada de forma exitosa"
                            });
                        }

                        client.Close();
                        return(new ResponseMessage
                        {
                            IsSuccess = false,
                            Message = "No es posible cancelar la orden debido a: " + result.ResultData
                        });
                    }
                    catch (Exception ex)
                    {
                        SharedLogger.LogError(ex);
                    }
                    Thread.Sleep(new Random().Next(200, 800));
                    iTries++;
                }

                client.Close();

                return(new ResponseMessage
                {
                    IsSuccess = false,
                    Message = "No fue posible comunicarse a la sucursal para realizar la cancelación. " +
                              "Por favor reporte a soporte técnico para revisar la conexión con la sucursal " + fsInfo.Name
                });
            }
        }
Ejemplo n.º 29
0
        private static bool IsUpdatedUpToDay(string dataFolder)
        {
            try
            {
                var alohaIniFile = Path.Combine(dataFolder, SettingsData.Constants.SystemConst.ALOHA_INI);

                if (File.Exists(alohaIniFile) == false)
                {
                    return(false);
                }

                var today    = DateTime.Today;
                var fileInfo = new FileInfo(alohaIniFile);

                if (fileInfo.LastWriteTime < today)
                {
                    return(false);
                }


                var dob = FileHelperExt.ReadFirstValue(alohaIniFile, "DOB=");

                if (dob == null)
                {
                    return(false);
                }

                var splitDob = dob.Split(' ');

                if (splitDob.Length != 3)
                {
                    return(false);
                }

                var alohaDate = new DateTime(int.Parse(splitDob[2]), int.Parse(splitDob[0]), int.Parse(splitDob[1]));

                return(alohaDate >= today);
            }
            catch (Exception ex)
            {
                SharedLogger.LogError(ex);
                return(false);
            }
        }
Ejemplo n.º 30
0
        public async Task <ResponseMessageModel> AskForLicense()
        {
            using (_repository)
            {
                var deviceConn = new DeviceConnModel
                {
                    LstClients     = _repository.GetLstClientsCodes(),
                    LstServers     = _repository.GetLstServersCodes(),
                    ActivationCode = _repository.GetActivationCode()
                };

                if (deviceConn.LstClients.Count == 0 || deviceConn.LstServers.Count == 0)
                {
                    return(new ResponseMessageModel
                    {
                        HasError = true,
                        Title = "Error licencia",
                        Message = "Al menos debes tener una terminal y un servidor para activar la licencia"
                    });
                }

                var    deviceConnTx = deviceConn.SerializeAndEncrypt();
                string responseConn;

                using (var proxy = new LicProxySvcClient())
                {
                    responseConn = await proxy.RequestActivationAsync(deviceConnTx);
                }

                try
                {
                    return(ProcessActivationResponse(responseConn));
                }
                catch (Exception ex)
                {
                    SharedLogger.LogError(ex, responseConn);
                    return(new ResponseMessageModel
                    {
                        HasError = true,
                        Message = "Respuesta no válida"
                    });
                }
            }
        }