// GET: /Create public ActionResult Create(int id) { ClientDetail clientDetail = new ClientDetail(); clientDetail = clientDetailRepository.GetGroup(id); //Check Exists if (clientDetail == null) { ViewData["ActionMethod"] = "CreateGet"; return(View("RecordDoesNotExistError")); } ClientDetailClientAccount clientDetailClientAccount = new ClientDetailClientAccount(); clientDetailClientAccount = clientDetailClientAccountRepository.GetClientDetailClientAccount(id); //Check Exists if (clientDetailClientAccount == null) { ViewData["ActionMethod"] = "CreateGet"; return(View("RecordDoesNotExistError")); } string can = clientDetailClientAccount.ClientAccountNumber; string ssc = clientDetailClientAccount.SourceSystemCode; ClientAccount clientAccount = new ClientAccount(); clientAccount = clientAccountRepository.GetClientAccount(can, ssc); //Access Rights ViewData["Access"] = ""; RolesRepository rolesRepository = new RolesRepository(); if (rolesRepository.HasWriteAccessToClientAccount(can, ssc)) { ViewData["Access"] = "WriteAccess"; } ClientAccountSupplierProductVM clientAccountSupplierProductVM = new ClientAccountSupplierProductVM(); clientAccountSupplierProductVM.ClientAccount = clientAccount; clientAccountSupplierProductVM.ClientDetail = clientDetail; ProductRepository productRepository = new ProductRepository(); clientAccountSupplierProductVM.Products = new SelectList(productRepository.GetAllProducts().ToList(), "ProductId", "ProductName"); return(View(clientAccountSupplierProductVM)); }
// GET: /List public ActionResult List(int id, int?page) { ClientDetail clientDetail = new ClientDetail(); clientDetail = clientDetailRepository.GetGroup(id); //Check Exists if (clientDetail == null) { ViewData["ActionMethod"] = "List"; return(View("RecordDoesNotExistError")); } ClientDetailClientAccount clientDetailClientAccount = new ClientDetailClientAccount(); clientDetailClientAccount = clientDetailClientAccountRepository.GetClientDetailClientAccount(id); //Check Exists if (clientDetailClientAccount == null) { ViewData["ActionMethod"] = "List"; return(View("RecordDoesNotExistError")); } string can = clientDetailClientAccount.ClientAccountNumber; string ssc = clientDetailClientAccount.SourceSystemCode; ClientAccount clientAccount = new ClientAccount(); clientAccount = clientAccountRepository.GetClientAccount(can, ssc); //Access Rights ViewData["Access"] = ""; RolesRepository rolesRepository = new RolesRepository(); if (rolesRepository.HasWriteAccessToClientAccount(can, ssc)) { ViewData["Access"] = "WriteAccess"; } //Populate View Model ClientAccountSupplierProductsVM clientAccountSupplierProductsVM = new ClientAccountSupplierProductsVM(); clientAccountSupplierProductsVM.SupplierProducts = clientDetailRepository.ListClientDetailSupplierProducts(id, page ?? 1); clientAccountSupplierProductsVM.ClientAccount = clientAccount; clientAccountSupplierProductsVM.ClientDetail = clientDetail; //Return Form return(View(clientAccountSupplierProductsVM)); }
public ClientSetup() { ClientServerConnection.LogHandlers.Add(new ClientServerConnection.LoggingHandlerDelegate(logToConsole)); // set up the defaults account = new ClientAccount(); account.ServerName = "localhost"; account.ServerPort = Common.DefaultCommunicationPort; account.User = "******"; account.Password = "******"; configDir = ClientServerConnection.DefaultConfigDir; Console.WriteLine("Welcome to the Mybox client setup wizard"); gatherInput(); account.Directory = Common.EndDirWithSlash(account.Directory); configDir = Common.EndDirWithSlash(configDir); // attach the account to the server to get the user ClientServerConnection client = new ClientServerConnection(); Console.WriteLine("client initialized. trying coonection..."); client.StartGetAccountMode(account); // data directory if (!Common.CreateLocalDirectory(account.Directory)) { Console.WriteLine("Data directory could not be created: " + account.Directory); Common.ExitError(); } // config directory if (!Common.CreateLocalDirectory(configDir)) { Console.WriteLine("Config directory could not be created: " + configDir); Common.ExitError(); } try { ClientServerConnection.SetConfigDir(configDir); } catch (Exception) { // toss config file not found exception since it is expected for a new setup } if (!saveConfig()) Console.WriteLine("Unable to save config file"); else Console.WriteLine("Setup finished successfully"); }
// GET: /View public ActionResult View(int id) { ClientDetailAddress clientDetailAddress = new ClientDetailAddress(); clientDetailAddress = clientDetailAddressRepository.GetAddressClientDetail(id); //Check Exists if (clientDetailAddress == null) { ViewData["ActionMethod"] = "ViewGet"; return(View("RecordDoesNotExistError")); } int clientDetailId = clientDetailAddress.ClientDetailId; ClientDetailClientAccount clientDetailClientAccount = new ClientDetailClientAccount(); clientDetailClientAccount = clientDetailClientAccountRepository.GetClientDetailClientAccount(clientDetailId); //Check Exists if (clientDetailClientAccount == null) { ViewData["ActionMethod"] = "ViewGet"; return(View("RecordDoesNotExistError")); } string can = clientDetailClientAccount.ClientAccountNumber; string ssc = clientDetailClientAccount.SourceSystemCode; ClientAccount clientAccount = new ClientAccount(); clientAccount = clientAccountRepository.GetClientAccount(can, ssc); ClientAccountAddressVM clientAccountAddressVM = new ClientAccountAddressVM(); clientAccountAddressVM.ClientAccount = clientAccount; ClientDetail clientDetail = new ClientDetail(); clientDetail = clientDetailRepository.GetGroup(clientDetailId); clientAccountAddressVM.ClientDetail = clientDetail; Address address = new Address(); address = addressRepository.GetAddress(clientDetailAddress.AddressId); addressRepository.EditForDisplay(address); clientAccountAddressVM.Address = address; return(View(clientAccountAddressVM)); }
private void ButtonSearch_Click(object sender, EventArgs e) { try { String TRN = TextBoxTRNSearch.Text.ToString(); ClientAccount[] clientArray = new ClientAccount[1]; Array.Copy (ClientAccount.getClient(TRN), clientArray, 1); } catch (TypeInitializationException ex) { Exception x = ex.InnerException; while (x is TypeInitializationException) { x = x.InnerException; } MessageBox.Show(x.StackTrace + x.Message); } }
private void ButtonShowAllClients_Click(object sender, EventArgs e) { try { ClientAccount[] clientArray = new ClientAccount[ClientAccount.getAllClients().Length]; Array.Copy (ClientAccount.getAllClients(), clientArray, 1); } catch (TypeInitializationException ex) { Exception x = ex.InnerException; while (x is TypeInitializationException) { x = x.InnerException; } MessageBox.Show(x.StackTrace + x.Message); } }
public ClientController() { service = new ClientAccount(); serviceClientAccount = new ClientAccount(); }
public void SaveAccount(ClientAccount Acct) { LDocumentHeader head = Acct.AccountHeader; Acct.AccountHeader = null; //we don't want this extra data saved here LDocumentPart part = new LDocumentPart(); part.SequenceNumber = 0; part.DocType = DocumentType.CLIENTACCOUNT; part._id = Acct._id; part.DocumentID = Acct._id; List<LDocumentPart> parts = new List<LDocumentPart>(); part.Data = DocManager.SerializeToJSONByteArray<ClientAccount>(Acct); parts.Add(part); DocManager.SaveDocument(new LRI(head.DocumentLRI), head, parts); //reattach head Acct.AccountHeader = head; }
public ServiceResponse<ServiceCredentials> RegisterNewAccount(string ServiceLRI, string DomainLRI, string Username, string passwordHash) { //get LRI from domain / username / hash LRI UserLRI = IDMgr.GetUserLRI(new LRI(ServiceLRI), DomainLRI, Username, passwordHash); if (UserLRI == null) { return new ServiceResponse<ServiceCredentials>(true); } else { if (ClientAccountLookup.ContainsKey(UserLRI)) { ServiceResponse<ServiceCredentials> Resp = new ServiceResponse<ServiceCredentials>(); Resp.Error = true; Resp.ErrorCode = 2; Resp.Message = "A user with that LRI is already registered with this system."; Resp.ResponseObject = null; return Resp; } else { //we need this info UserInfo info = new UserInfo();//UserManager.Identities[UserLRI.LRIString]; info.passwordHash = passwordHash; info.Identity = IDMgr.GetUserLIdentity(new LRI(ServiceLRI), DomainLRI, Username, passwordHash); //create new account and add this LRI info ClientAccount Acct = new ClientAccount(); Acct._id = LDocumentManager.RequestGUID(); Acct.AccountLRI = new LRI(LCHARMSConfig.GetSection().LRI + "/" + Acct._id); ClientAccountLookupByAcctID[Acct._id] = Acct; AddIdentityToAccount(Acct._id, info, UserLRI); //ServiceCredentials sc = new ServiceCredentials(); //Acct.ServiceCredentialsByLRI[userlri] = //create a header for the account string ID = LDocumentManager.RequestGUID(); LDocumentHeader NewFileHeader = new LDocumentHeader(); LRI hlri = new LRI(LCHARMSConfig.GetSection().LRI + "/" + ID); NewFileHeader.DocType = DocumentType.DOC_HEADER; NewFileHeader.DocumentID = ID; NewFileHeader.FQDT = "lcharms.client.account"; NewFileHeader.FileName = Username.ToLower() + ".client.account"; NewFileHeader.DocumentLRI = hlri.ToString(); NewFileHeader.IsCopy = false; NewFileHeader.LastAccessDate = DateTime.Now; NewFileHeader.DataLength = 0; //create an ACL for this new file // assign it to the creation user DocManager.AuthManager.CreateACE(ID, info.Identity, LDocACLPermission.GRANT | LDocACLPermission.WRITE | LDocACLPermission.READ | LDocACLPermission.ACCESS_NEXT_VERSION | LDocACLPermission.ACCESS_PREV_VERSION); DocManager.AuthManager.CreateACE(ID, DocManager.AuthManager.PublicIdentity, LDocACLPermission.DENY); Acct.AccountHeader = NewFileHeader; SaveAccount(Acct); return LoginID(UserLRI, passwordHash,false); } } }