Beispiel #1
0
        public string GetAccountInfo(string sMaInfo, string sConnInfo)
        {
            var eInfo     = Cypher.Encrypt(sMaInfo);
            var mConnInfo = Cypher.Decrypt(sConnInfo);

            using (_repository)
            {
                var computerInfo = _repository.GetComputerInfo(eInfo);

                if (computerInfo == null)
                {
                    return(CreateComputerInfo(eInfo, sConnInfo));
                }

                GetDevice decCompInfo;
                if (IsUpdatedComputerInfo(mConnInfo, computerInfo, out decCompInfo) == false)
                {
                    var response = UpdateComputerInfo(eInfo, mConnInfo, decCompInfo);
                    if (string.IsNullOrWhiteSpace(response) == false)
                    {
                        return(response);
                    }
                }

                return(IsValidDeviceInfo(decCompInfo));
            }
        }
Beispiel #2
0
        public GetDevice ValidateMainAccount()
        {
            var eInfo     = Cypher.Encrypt(Environment.MachineName);
            var mConnInfo = ManagementExt.GetKey();

            using (_repository)
            {
                var infoServer = _repository.GetInfoServer(Cypher.Encrypt(eInfo));

                if (infoServer == null)
                {
                    CreateInfoServer(eInfo, mConnInfo);
                    return(null);
                }

                GetDevice decServInfo;
                if (IsUpdatedInfoServer(mConnInfo, infoServer, out decServInfo) == false)
                {
                    UpdateInfoServer(mConnInfo, decServInfo, infoServer);
                    return(null);
                }

                return(decServInfo);
            }
        }
 public void SetFranchiseVersionTerminalOk(int franchiseId, string sVersion, string sMaInfo)
 {
     using (var repository = new FranchiseRepository())
     {
         repository.SetFranchiseVersionTerminalOk(franchiseId, sVersion, Cypher.Encrypt(sMaInfo));
     }
 }
Beispiel #4
0
        public void Create(UsuarioAdministracaoAgenda info)
        {
            DataBase dataBase = new DataBase();

            StringBuilder sql = new StringBuilder();

            sql.Append("insert into [dbo].[UsuarioAdministracaoAgenda]");
            sql.Append(" (");
            sql.Append("[Login]");
            sql.Append(", Senha");
            sql.Append(", Nome");
            sql.Append(")");
            sql.Append(" values ");
            sql.Append("(");
            sql.Append(String.Format("'{0}'", info.Login));
            sql.Append(String.Format(", '{0}'", Cypher.Encrypt(info.Senha)));
            sql.Append(String.Format(", '{0}'", info.Nome));
            sql.Append(")");

            using (SqlConnection connection = dataBase.RetornaConexaoRastreabilidade())
            {
                using (SqlCommand command = new SqlCommand(sql.ToString(), connection))
                {
                    connection.Open();
                    command.ExecuteScalar();
                }
            }
        }
Beispiel #5
0
        private void FazerLogin()
        {
            try
            {
                if (String.IsNullOrEmpty(this.txtLogin.Text) || String.IsNullOrEmpty(this.txtSenha.Text))
                {
                    this.msgDialog.Show("Atenção", "Informe o login e senha.", UserControl.Message.Type.Warning);
                    return;
                }

                UsuarioAdministracaoAgenda usuario = new UsuarioAdministracaoAgenda();
                usuario.Login = this.txtLogin.Text;
                usuario.Senha = Cypher.Encrypt(this.txtSenha.Text);
                usuario       = new UsuarioAdministracaoAgendaRepository().Authenticate(usuario);

                if (usuario != null && usuario.Ativo.Value)
                {
                    UsuarioLogado = usuario;
                    this.Page.Response.Redirect("Home.aspx", false);
                }
                else
                {
                    this.msgDialog.Show("Atenção", "Login inválido.", UserControl.Message.Type.Warning);
                }
            }
            catch (Exception e)
            {
                Log.Create(e);
                Email.Send("Agendamento de congelação - falha na aplicação", e);
                this.msgDialog.Show("Erro", "Falha ao tentar fazer o login.", UserControl.Message.Type.Error);
            }
        }
Beispiel #6
0
        public Model.USUARIO GetUserByEmail(string email)
        {
            email = Cypher.Encrypt(email);
            var aux = Cypher.DecryptObject(_mandiolaDbContext.USUARIOs.FirstOrDefault(x => x.CORREO == email)) as USUARIO;

            return(_mapper.Map <Model.USUARIO>(aux));
        }
Beispiel #7
0
 private static string BuildResponse(int wnd, string msg)
 {
     return(Cypher.Encrypt(new JavaScriptSerializer().Serialize(new ConnectionInfoResponse
     {
         NxWn = wnd,
         Msg = msg
     })));
 }
Beispiel #8
0
        private void UpdateInfoServer(string mConnInfo, GetDevice decServInfo, InfoServer infoServer)
        {
            decServInfo.Hk  = mConnInfo;
            infoServer.Code = Cypher.Encrypt(new JavaScriptSerializer().Serialize(decServInfo));
            _repository.SaveChanges();

            //if (infoServer.InfoCallCenterId.HasValue == false)
            //    return;
        }
Beispiel #9
0
        private async void Start()
        {
            try
            {
                var splashVm = new SplashVm(MILI_SECONDS_TO_INIT);
                var splash   = new SplashWnd {
                    DataContext = splashVm
                };
                splash.Show();

                splashVm.ShowProgress.Execute(null);
                await Task.Delay(TimeSpan.FromMilliseconds(MILI_SECONDS_TO_INIT));

                FixBrowserVersion();

                var bootstrapper = new Bootstrapper();
                var container    = bootstrapper.Build();
                Log.Info("Iniciando Delivery Reactive System...");
                await CatalogsClientConfigure.Initialize();

                var reactiveDeliveryClient = container.Resolve <IReactiveDeliveryClient>();
                var lstHubProxies          = new List <string> {
                    SharedConstants.Server.ACCOUNT_HUB,
                    SharedConstants.Server.CLIENT_HUB,
                    SharedConstants.Server.FRANCHISE_HUB,
                    SharedConstants.Server.ORDER_HUB,
                    SharedConstants.Server.ADDRESS_HUB,
                    SharedConstants.Server.STORE_HUB,
                    SharedConstants.Server.TRACK_HUB
                };

                reactiveDeliveryClient.Initialize(Cypher.Encrypt(Environment.MachineName), container.Resolve <IConfigurationProvider>().Servers, lstHubProxies, container.Resolve <ILoggerFactory>());
                SettingsData.Client.Container = container;
                await SettingConfigureWs.Initialize(reactiveDeliveryClient);

                var mainWindow = container.Resolve <MainWindow>();
                var vm         = container.Resolve <IShellContainerVm>();
                vm.BootStrapper = bootstrapper;

                InitializeSignalRPosConnection();

                vm.Initialize();
                mainWindow.DataContext = vm;

                ShowNextWindow(reactiveDeliveryClient, () =>
                {
                    splash.Close();
                    mainWindow.Show();
                }, vm);
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format("No fue posible iniciar la aplicación. Revise si hay conexión al servidor. {0} Error: {1} - {2}",
                                              Environment.NewLine, ex.Message, ex.InnerException == null ? String.Empty : ex.InnerException.Message), "Error al iniciar");
                Shutdown();
            }
        }
        public IEnumerable <SyncFranchiseModel> GetListSyncFiles(string sHost)
        {
            var eInfo = Cypher.Encrypt(sHost);

            using (_repository)
            {
                var lstFranchiseFiles = _repository.GetListSyncFiles(eInfo);
                return(lstFranchiseFiles);
            }
        }
Beispiel #11
0
        private void CreateInfoServer(string eInfo, string mConnInfo)
        {
            var model = new GetDevice
            {
                Hk   = mConnInfo,             //HostId
                Hn   = Cypher.Decrypt(eInfo), //HostName
                St   = DateTime.MinValue,
                Et   = DateTime.MinValue,
                Iv   = false,                    //Is valid license
                Code = AccountConstants.CODE_NEW
            };

            _repository.AddInfoServer(Cypher.Encrypt(eInfo), Cypher.Encrypt(new JavaScriptSerializer().Serialize(model)));
        }
Beispiel #12
0
        private string CreateComputerInfo(string eInfo, string sConnInfo)
        {
            var model = new GetDevice
            {
                Hk   = Cypher.Decrypt(sConnInfo),             //HostId
                Hn   = Cypher.Decrypt(Cypher.Decrypt(eInfo)), //HostName
                St   = DateTime.MinValue,
                Et   = DateTime.MinValue,
                Iv   = false,                    //Is valid license
                Code = AccountConstants.CODE_NEW
            };

            _repository.AddComputerInfo(eInfo, Cypher.Encrypt(new JavaScriptSerializer().Serialize(model)));
            return(BuildResponse(SharedConstants.Client.STATUS_SCREEN_MESSAGE, AccountConstants.LstCodes[model.Code]));
        }
Beispiel #13
0
        public static string Encrypt(this string identifier, Algorithm algorithm, string key, EncodingType encType)
        {
            Cypher cypher = new Cypher();

            cypher.EncryptionAlgorithm = algorithm;

            if (key != null)
            {
                cypher.Key = key;
            }


            cypher.Encoding = encType;

            return(cypher.Encrypt(identifier));
        }
Beispiel #14
0
        public bool IsUsernameAvailable(string username)
        {
            string usernameE = Cypher.Encrypt(username);

            var pUserName = new SqlParameter
            {
                ParameterName = "@Username",
                Value         = usernameE
            };

            string available = _mandiolaDbContext.Database.SqlQuery <string>("exec UsernameAvailable @Username", pUserName).FirstOrDefault();

            System.Diagnostics.Debug.WriteLine("AVailable SR Result: " + available);

            return(available.Equals("true"));
        }
Beispiel #15
0
        public async Task <User> SignUp(User user)
        {
            IMongoCollection <User> usersCollection = context.Database.GetCollection <User>("Users");
            IAsyncCursor <User>     foundUsers      = await usersCollection.FindAsync(x => x.Username == user.Username || x.Email == user.Email);

            IEnumerable <User> users = await foundUsers.ToListAsync();

            if (users.Any())
            {
                throw new Exception("Username ou e-mail já cadastrados.");
            }

            user.Password = Cypher.Encrypt(user.Password);
            await usersCollection.InsertOneAsync(user);

            return(user);
        }
Beispiel #16
0
        private void UpdateClientDevice(string device)
        {
            try
            {
                var connInfo    = device.DeserializeAndDecrypt <GetDevice>();
                var deviceModel = _repository.GetClientTerminalByHost(Cypher.Encrypt(Cypher.Encrypt(connInfo.Hn)));

                if (deviceModel == null)
                {
                    return;
                }

                deviceModel.Code = device;
                _repository.SaveChanges();
            }
            catch (Exception ex)
            {
                SharedLogger.LogError(ex, device);
            }
        }
        public void OnPostAsync()
        {
            Output = string.Empty;

            if (InputFile != null)
            {
                var isParsed = FileService.ParseFile(InputFile, WebHostEnvironment.WebRootPath, out string parsingResult);
                if (!isParsed)
                {
                    ErrorMessage = Constants.Errors.ParsingError;
                    return;
                }

                Input = parsingResult;
            }

            if (string.IsNullOrEmpty(Input) || string.IsNullOrEmpty(Key))
            {
                return;
            }

            try
            {
                Output = EncryptMode
                    ? Cypher.Encrypt(Input, Key)
                    : Cypher.Decrypt(Input, Key);
            }
            catch (Exception ex)
            {
                ErrorMessage = Constants.Errors.ProcessingError;
                Logger.LogError(ex.Message);
            }

            var isCreated = FileService.CreateFiles(Output, WebHostEnvironment.WebRootPath);

            if (!isCreated)
            {
                ErrorMessage = Constants.Errors.FilesCreationError;
                return;
            }
        }
        public Connection(string address, string username, ILoggerFactory loggerFactory, IEnumerable <string> lstHubProxy)
        {
            _log           = loggerFactory.Create(typeof(Connection));
            _statusStream  = new BehaviorSubject <ConnectionInfo>(new ConnectionInfo(ConnectionStatus.Uninitialized, address));
            Address        = address;
            _hubConnection = new HubConnection(address);
            _hubConnection.Headers.Add(SharedConstants.Server.USERNAME_HEADER, username);
            _hubConnection.Headers.Add(SharedConstants.Server.CONNECTION_ID_HEADER, Cypher.Encrypt(ManagementExt.GetKey()));

            CreateStatus().Subscribe(
                s => _statusStream.OnNext(new ConnectionInfo(s, address)),
                _statusStream.OnError,
                _statusStream.OnCompleted);
            _hubConnection.Error += exception => _log.Error("Hubo un error de conexión a la dirección " + address, exception);

            DicHubProxy = new Dictionary <string, IHubProxy>();

            foreach (var hubName in lstHubProxy)
            {
                DicHubProxy.Add(hubName, _hubConnection.CreateHubProxy(hubName));
            }
        }
Beispiel #19
0
        public ActionResult LogIn([Bind(Include = "PASSWORD,USER_NAME")] USUARIO uSUARIO)
        {
            System.Diagnostics.Debug.WriteLine("User: "******"Pass: "******"Result: " + result);
            USUARIO User = db.USUARIOs.Find(result);

            if (User != null)
            {
                Session["Usuario"] = User;
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                Session["Usuario"] = null;
                ModelState.AddModelError("PASSWORD", "Usuario o contraseña incorrectos");
                return(View());
            }
        }
Beispiel #20
0
        public void Update(UsuarioAdministracaoAgenda info)
        {
            DataBase dataBase = new DataBase();

            StringBuilder sql = new StringBuilder();

            sql.Append("update [dbo].[UsuarioAdministracaoAgenda]");
            sql.Append(" set");
            sql.Append(String.Format(" [Login] = '{0}'", info.Login));
            sql.Append(String.Format(", Senha = '{0}'", Cypher.Encrypt(info.Senha)));
            sql.Append(String.Format(", Nome = '{0}'", info.Nome));
            sql.Append(" where");
            sql.Append(String.Format(" UsuarioAdministracaoAgendaID = {0}", info.UsuarioAdministracaoAgendaID));

            using (SqlConnection connection = dataBase.RetornaConexaoRastreabilidade())
            {
                using (SqlCommand command = new SqlCommand(sql.ToString(), connection))
                {
                    connection.Open();
                    command.ExecuteScalar();
                }
            }
        }
 public static string SerializeAndEncrypt <T>(this T obj)
 {
     return(Cypher.Encrypt(new JavaScriptSerializer().Serialize(obj)));
 }
Beispiel #22
0
        public static ResponseMessage StartSyncFiles(IList <SyncFranchiseModel> lstFranchiseSyncFiles)
        {
            var res = new ResponseMessage();

            if (lstFranchiseSyncFiles.Any() == false)
            {
                res.IsSuccess = true;
                return(res);
            }

            using (var client = new SyncServerSvcClient())
            {
                WcfExt.SetMtomEncodingAndSize(client.Endpoint);
                foreach (var syncFranchiseModel in lstFranchiseSyncFiles)
                {
                    var clientIn = client;
                    var tasks    = new List <Task>();
                    var syncFranchiseModelCopy = syncFranchiseModel;
                    var subscribe = syncFranchiseModel.LstFiles.ToObservable().Subscribe(syncFile =>
                    {
                        switch (syncFile.FileType)
                        {
                        case SettingsData.Constants.FranchiseConst.SYNC_FILE_TYPE_DATA:
                            {
                                tasks.Add(CheckFilesAndSync(syncFile, syncFranchiseModelCopy.Code, clientIn,
                                                            syncFranchiseModelCopy.FranchiseDataVersionUid));
                                break;
                            }

                        case SettingsData.Constants.FranchiseConst.SYNC_FILE_TYPE_LOGO:
                        case SettingsData.Constants.FranchiseConst.SYNC_FILE_TYPE_IMAGE_NOTIFICATION:
                            {
                                var uriPath = syncFile.FileType == SettingsData.Constants.FranchiseConst.SYNC_FILE_TYPE_LOGO ?
                                              SharedConstants.Client.URI_LOGO :
                                              SharedConstants.Client.URI_IMAGE_NOTIFICATION;

                                tasks.Add(CheckResourceAndSync(syncFile, uriPath, syncFile.FileType, clientIn));
                                break;
                            }

                        default:
                            syncFile.HasError = false;
                            break;
                        }
                    });

                    Task.WaitAll(tasks.ToArray());
                    subscribe.Dispose();
                }

                var sb = new StringBuilder();
                res.IsSuccess = true;
                foreach (var syncFranchiseModel in lstFranchiseSyncFiles.Where(e => e.FranchiseId != SharedConstants.ALL_FRANCHISES))
                {
                    try
                    {
                        var franchiseSuccess = true;
                        foreach (var syncFile in syncFranchiseModel.LstFiles.Where(syncFile => syncFile.HasError))
                        {
                            sb.AppendLine(syncFile.Message);
                            res.IsSuccess    = false;
                            franchiseSuccess = false;
                        }

                        if (franchiseSuccess)
                        {
                            client.SetFranchiseVersionTerminalOk(syncFranchiseModel.FranchiseId, syncFranchiseModel.Version,
                                                                 Cypher.Encrypt(Environment.MachineName));
                        }
                    }
                    catch (Exception ex)
                    {
                        res.IsSuccess = false;
                        sb.AppendLine(ex.Message + " -ST- " + ex.StackTrace);
                    }
                }

                if (res.IsSuccess == false)
                {
                    res.Message = sb.ToString();
                }
            }

            return(res);
        }
Beispiel #23
0
        private void InitializeCommands()
        {
            var canSignIn = this.WhenAny(vm => vm.UserName, s => !String.IsNullOrWhiteSpace(s.Value));

            canSignIn.Subscribe(x => IsSignInVisible = x ? Visibility.Visible : Visibility.Hidden);

            SignInCommand = ReactiveCommand.CreateAsyncTask(canSignIn, async x =>
            {
                IsOnSignIn  = Visibility.Collapsed;
                IsOnWaiting = Visibility.Visible;
                var pass    = (PasswordBox)x;
                using (var loginSvc = new LoginSvcClient())
                {
                    try
                    {
                        var response =
                            await
                            loginSvc.LoginAsync(new LoginModel
                        {
                            Password = Cypher.Encrypt(pass.Password),
                            Username = Cypher.Encrypt(UserName)
                        });
                        return(response);
                    }
                    catch (Exception ex)
                    {
                        return(new ResponseMessage {
                            IsSuccess = false, Message = ResNetwork.ERROR_NETWORK_DOWN + ex.Message
                        });
                    }
                    finally
                    {
                        pass.Password = String.Empty;
                        IsOnSignIn    = Visibility.Visible;
                        IsOnWaiting   = Visibility.Collapsed;
                        MessageBus.Current.SendMessage(String.Empty, SharedMessageConstants.LOGIN_FOCUS_USERNAME);
                    }
                }
            });


            SignInCommand.Subscribe(x =>
            {
                if (x.IsSuccess)
                {
                    var bForceToInit = CurrentUserSettings.UserInfo.Username == null ||
                                       CurrentUserSettings.UserInfo.Username != UserName;

                    CurrentUserSettings.UserInfo.Username = x.UserDetail.UserName;
                    CurrentUserSettings.UserInfo.FullName = x.UserDetail.FullName;
                    CurrentUserSettings.UserInfo.Role     = x.UserDetail.Role;
                    ShellContainerVm.ChangeCurrentView(StatusScreen.ShMenu, true, bForceToInit);  //Only when comes from login, it should be reinit
                    OnUserChanged(CurrentUserSettings.UserInfo);
                }
                else
                {
                    MessageBus.Current.SendMessage(new MessageBoxSettings
                    {
                        Message = x.Message,
                        Title   = "Error al ingresar",
                    }, SharedMessageConstants.MSG_SHOW_ERRQST);
                    //Message = x.Message;
                }
            });
        }
        public HttpResponseMessage Token(AuthModel model)
        {
            var usuario = usuarioRepository.FindByUsernameAndPassword(model.Username, Cypher.Encrypt(model.Password));
            var token   = jwtService.CreateToken(usuario.USUARIO_ID, usuario.DS_USERNAME, usuario.TB_USER_ROLES.Select(x => x.ROLE_ID));

            return(Request.CreateResponse(HttpStatusCode.OK, new { Token = token }));
        }