int UnicontaLogin() { int ret = simulatedloginButton(); UCInitializer.SetupCompanies(); var cmbCompanies = UCInitializer.Companies; if (UCInitializer.CurrentSession.User._DefaultCompany != 0) { //var comp = UCInitializer.Companies.Where(c => c.CompanyId == UCInitializer.CurrentSession.User._DefaultCompany).FirstOrDefault(); var comp = UCInitializer.Companies.Where(c => c.CompanyId == 4852).FirstOrDefault(); //Løbeklubben Puls 3060 //var comp = UCInitializer.Companies.Where(c => c.CompanyId == 4850).FirstOrDefault(); //Puls 3060 Ref UCInitializer.SetCompany(comp.CompanyId); UCInitializer.SetCurrentCompanyFinanceYear(); } else if (UCInitializer.Companies.Count() > 0) { var comp = UCInitializer.Companies[0]; UCInitializer.SetCompany(comp.CompanyId); UCInitializer.SetCurrentCompanyFinanceYear(); } //else // MessageBox.Show("You do not have any access to company.", "Information", MessageBoxButton.OK, MessageBoxImage.Asterisk); var CurrentCompany = UCInitializer.CurrentCompany; this.toolStripStatusLabel1.Text += " - " + CurrentCompany.CompanyId + " - " + CurrentCompany.Name; return(0); }
static void Main() { System.Diagnostics.Process[] p = System.Diagnostics.Process.GetProcessesByName("Trans2Summa3060"); if (p.Length > 1) { clsUtil.SetForegroundWindow(p[0].MainWindowHandle); } else { Uniconta.ClientTools.Localization.SetLocalizationStrings(System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName); Uniconta.WindowsAPI.Startup.OnLoad(); UCInitializer.InitUniconta(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new FrmMain()); } }
ErrorCodes SetLogin(string username, string password) { try { var ses = UCInitializer.GetSession(); var task = ses.LoginAsync(username, password, Uniconta.Common.User.LoginType.API, new Guid("73c93c84-af78-41e4-ada1-b8101c95ba89"), Uniconta.ClientTools.Localization.InititalLanguageCode); task.Wait(); var res = task.Result; return(res); } catch { System.Windows.Forms.MessageBox.Show("System Exception. Application Will Close.", "Fatal Error"); this.Close(); return(ErrorCodes.Exception); } }