Beispiel #1
0
        /// <summary>
        /// Конструктор по умолчанию
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();
            Loaded += (s, e) => {
                HttpClient httpClient = new HttpClient();
                string     url        = host + $@"getCompanyList";
                DataContractJsonSerializer jsonCompanyFormatter = new DataContractJsonSerializer(typeof(CompanyTable[]));
                CompanyTable[]             ct = (CompanyTable[])jsonCompanyFormatter.ReadObject(new MemoryStream(Encoding.UTF8.GetBytes(httpClient.GetStringAsync(url).Result)));
                CompanyTable first            = ct.First();
                TextBoxCompany.Text = first.Name;
                string urlDep = host + $@"getDepartmentsListForCompany/{first.ID}";
                DataContractJsonSerializer jsonDepartmentFormatter = new DataContractJsonSerializer(typeof(DepartmentTable[]));
                DepartmentTable[]          dt = (DepartmentTable[])jsonDepartmentFormatter.ReadObject(new MemoryStream(Encoding.UTF8.GetBytes(httpClient.GetStringAsync(urlDep).Result)));
                DeportmentDataGrid.ItemsSource = dt;
            };
            Closing += (s, e) => {
            };

            btnShowDepartment.Click += (s, e) => {
                if (DeportmentDataGrid.SelectedItem != null)
                {
                    EditDeportmant editWindow = new EditDeportmant(((DepartmentTable)DeportmentDataGrid.SelectedItem).ID);
                    editWindow.Show();
                }
            };
        }
Beispiel #2
0
 public DBHelper(string connectionString, LogFunc log = null) : base(connectionString, log)
 {
     _AppLogTable   = new AppLogTable(connectionString, log);
     _CompanyTable  = new CompanyTable(connectionString, log);
     _MaterialTable = new MaterialTable(connectionString, log);
     _ReceiptTable  = new ReceiptTable(connectionString, log);
     _RecordTable   = new RecordTable(connectionString, log);
 }
Beispiel #3
0
        static void Main(string[] args)
        {
            Database db = new Database();

            db.Connect();

            Vehicle u = new Vehicle();

            u.Id = 14;
            // u.Manufacturer = "Stadler";
            //u.Model = "Tango NF2 kopie";


            Console.WriteLine("Seznam vsech statu ve DB");
            foreach (Country c in CountryTable.Select())
            {
                Console.WriteLine(c.Id + " " + c.Name + " " + c.Continent);
            }
            Console.WriteLine("----");

            Console.WriteLine("Seznam vsech mest ve DB");
            foreach (City c in CityTable.Select())
            {
                Console.WriteLine(c.Id + " " + c.Name + " " + c.Region + " STAT: " + c.Country.Name);
            }
            Console.WriteLine("----");


            Console.WriteLine("Seznam vsech vozidel ve DB");
            foreach (Vehicle v in VehicleTable.Select())
            {
                Console.WriteLine(v.Id + "  Znacka:" + v.vehicleModel.Manufacturer + " Model:" + v.vehicleModel.Model + " Podtyp:" + v.Podtyp + " City:" + v.city.Name + " Depo:" + v.depot.Name);
            }

            Console.WriteLine("Seznam vsech company ve DB");
            foreach (Company c in CompanyTable.Select())
            {
                Console.WriteLine(c.Id + " Nazev:" + c.Name);
            }


            //VehicleTable.Insert(u, db);

            /*
             * int count1 = VehicleTable.Select(db).Count;
             * int dltCount = VehicleTable.Delete(7, db);
             * int count2 = VehicleTable.Select(db).Count;
             *
             * Console.WriteLine("#C: " + count1);
             * Console.WriteLine("#D: " + dltCount);
             * Console.WriteLine("#C: " + count2);
             */
            db.Close();
            Console.ReadKey();
        }
Beispiel #4
0
        public HttpResponseMessage Get()
        {
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, "value");

            ICompanyService _Companyservice = DependencyResolver.Current.GetService <ICompanyService>();
            CompanyTable    company         = _Companyservice.FirstOrDefault(x => x.AliasCompanyName == "ATK");

            BuildTreeLDAP(company, company.DomainTable.LDAPBaseDN, "");
            BuildTreeLDAP(company, company.DomainTable.LDAPBaseDN, "", true);
            return(response);
        }
Beispiel #5
0
        private void POST_CheckCompany()
        {
            if (ConfirmType == CONFIRMTYPE_DECLINE_COMPANY)
            {
                var companyAccount = AccountTable.RetrieveAccountByCompanyID(CompanyID);

                AccountTable.DeleteAccount(companyAccount.Id);
                CompanyTable.DeleteCompany(CompanyID);
            }
            else if (ConfirmType == CONFIRMTYPE_CONFIRM_COMPANY)
            {
                CompanyTable.UpdateCompanyConfirm(CompanyID, true);
            }
        }
Beispiel #6
0
        public void OnPost()
        {
            ValidateEquality(ConfirmEmail, Email, nameof(ConfirmEmail), "The email addresses do not match!");
            ValidateEquality(ConfirmPassword, Password, nameof(ConfirmPassword), "The passwords do not match!");

            if (ModelState.IsValid)
            {
                var company = CompanyTable.CreateCompany(CompanyType, CompanyName, CompanyDescription, Latitude, Longitude);

                var accountType = (CompanyType == CompanyType.RESTAURANT) ? AccountType.RESTAURANT : AccountType.TAXI;
                UserAgent.Register(accountType, Email, Password, new ContactDetails {
                    FirstName = FirstName, LastName = LastName
                }, company.Id);
            }
        }
Beispiel #7
0
 public void Save(CompanyView viewTable)
 {
     if (viewTable.Id == null)
     {
         var domainTable = new CompanyTable();
         Mapper.Map(viewTable, domainTable);
         SaveDomain(domainTable);
     }
     else
     {
         var domainTable = Find(viewTable.Id);
         Mapper.Map(viewTable, domainTable);
         SaveDomain(domainTable);
     }
 }
Beispiel #8
0
        public void SaveDomain(CompanyTable domainTable, string currentUserName = "")
        {
            string          localUserName = getCurrentUserName(currentUserName);
            ApplicationUser user          = _AccountService.FirstOrDefault(x => x.UserName == localUserName);

            if (domainTable.Id == Guid.Empty)
            {
                domainTable.Id                        = Guid.NewGuid();
                domainTable.CreatedDate               = DateTime.UtcNow;
                domainTable.ModifiedDate              = domainTable.CreatedDate;
                domainTable.ApplicationUserCreatedId  = user.Id;
                domainTable.ApplicationUserModifiedId = user.Id;
                repo.Add(domainTable);
            }
            else
            {
                domainTable.ModifiedDate = DateTime.UtcNow;
                domainTable.ApplicationUserModifiedId = user.Id;
                repo.Update(domainTable);
            }
            _uow.Save();
        }
Beispiel #9
0
        private void BuildTreeLDAP(CompanyTable _item, string _LDAPpath, string _parentDepartmentName = "", bool afterUpdate = false)
        {
            DirectoryEntry    entry = new DirectoryEntry("LDAP://" + _item.DomainTable.LDAPServer + ":" + Convert.ToString(_item.DomainTable.LDAPPort) + "/" + _LDAPpath, _item.DomainTable.LDAPLogin, _item.DomainTable.LDAPPassword, AuthenticationTypes.None);
            DirectorySearcher ds    = new DirectorySearcher(entry);

            ds.SearchScope = SearchScope.OneLevel;
            ds.Filter      = "(&(objectCategory=organizationalUnit)(!(name=Computers))(!(name=Disable))(!(name=Improvers))(!(name=Service&App))(!(name=Labs))(!(name=Servers))(!(name=Users))(!(name=Groups))(!(name=Disabled)))";
            ds.PropertiesToLoad.Add("distinguishedname");
            ds.PropertiesToLoad.Add("name");

            foreach (SearchResult result in ds.FindAll())
            {
                if (result.Properties.Contains("distinguishedname") && result.Properties.Contains("name"))
                {
                    Guid depId = Guid.Empty;
                    if (afterUpdate == false)
                    {
                        depId = DepartmentIntegration(result.Properties["name"][0].ToString(), _parentDepartmentName, _item.Id);
                    }
                    getUsersDepartment(_item, result.Properties["distinguishedname"][0].ToString(), depId, afterUpdate);
                    BuildTreeLDAP(_item, result.Properties["distinguishedname"][0].ToString(), result.Properties["name"][0].ToString(), afterUpdate);
                }
            }
        }
Beispiel #10
0
        private void getUsersDepartment(CompanyTable _item, string _LDAPpath, Guid _department, bool afterUpdate)
        {
            DirectoryEntry entry = new DirectoryEntry("LDAP://" + _item.DomainTable.LDAPServer + ":"
                                                      + Convert.ToString(_item.DomainTable.LDAPPort) + "/"
                                                      + _LDAPpath, _item.DomainTable.LDAPLogin, _item.DomainTable.LDAPPassword, AuthenticationTypes.None);
            DirectorySearcher ds = new DirectorySearcher(entry);
            string            ldapData;
            Guid titleId = Guid.Empty;

            ds.SearchScope = SearchScope.OneLevel;
            ds.Filter      = "(&(objectCategory=user)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))";
            ds.PropertiesToLoad.Add("title");
            ds.PropertiesToLoad.Add("mail");
            ds.PropertiesToLoad.Add("telephonenumber");
            ds.PropertiesToLoad.Add("mobile");
            ds.PropertiesToLoad.Add("description");
            ds.PropertiesToLoad.Add("cn");
            ds.PropertiesToLoad.Add("sn");
            ds.PropertiesToLoad.Add("manager");
            ds.PropertiesToLoad.Add("sAMAccountName");

            foreach (SearchResult result in ds.FindAll())
            {
                if (result.Properties.Contains("title") && afterUpdate == false)
                {
                    ldapData = result.Properties["title"][0].ToString();
                    titleId  = TitleIntegration(ldapData);
                }

                if (result.Properties.Contains("description") && result.Properties.Contains("mail"))
                {
                    string   telephone = string.Empty;
                    string   mobile    = string.Empty;
                    string   mail      = string.Empty;
                    string   userid    = string.Empty;
                    string   userName  = string.Empty;
                    string   manager   = string.Empty;
                    string[] emplName  = new string[3];

                    ldapData = result.Properties["description"][0].ToString();
                    //mail = result.Properties["mail"][0].ToString();
                    mail = "*****@*****.**";

                    emplName = DecodeLDAPNameUsers(ldapData, 0);

                    if (result.Properties.Contains("telephonenumber"))
                    {
                        telephone = result.Properties["telephonenumber"][0].ToString();
                    }
                    if (result.Properties.Contains("mobile"))
                    {
                        mobile = result.Properties["mobile"][0].ToString();
                    }
                    if (result.Properties.Contains("cn"))
                    {
                        userName = result.Properties["cn"][0].ToString();
                    }
                    if (result.Properties.Contains("sAMAccountName"))
                    {
                        userid = result.Properties["sAMAccountName"][0].ToString();
                    }
                    if (result.Properties.Contains("manager"))
                    {
                        manager = result.Properties["manager"][0].ToString();
                    }

                    if (emplName[0] != null && emplName[1] != null)
                    {
                        if (afterUpdate == true)
                        {
                            try
                            {
                                DirectoryEntry entryManager = new DirectoryEntry("LDAP://" + _item.DomainTable.LDAPServer + ":"
                                                                                 + Convert.ToString(_item.DomainTable.LDAPPort) + "/"
                                                                                 + manager, _item.DomainTable.LDAPLogin, _item.DomainTable.LDAPPassword, AuthenticationTypes.None);

                                if (entryManager.Properties.Contains("sAMAccountName"))
                                {
                                    string ManagerUserId = entryManager.Properties["sAMAccountName"].Value.ToString();

                                    ApplicationDbContext context = new ApplicationDbContext();
                                    var um        = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context));
                                    var userTable = um.FindByName(ManagerUserId);
                                    manager = userTable != null ? userTable.Id : String.Empty;

                                    EmplUpdateIntegration(emplName[1], emplName[0], emplName[2], _item.Id, manager);
                                }
                            }
                            catch
                            {
                                return;
                            }
                        }
                        else
                        {
                            PrincipalContext ctx       = new PrincipalContext(ContextType.Domain);
                            UserPrincipal    user      = UserPrincipal.FindByIdentity(ctx, userid);
                            string           domainSID = user.Sid.ToString();

                            String ApplicationUserId = UserIntegration(userid, mail, domainSID, _item.Id);
                            EmplIntegration(emplName[1], emplName[0], emplName[2], telephone, mobile, ApplicationUserId, _department, titleId, _item.Id, manager);
                        }
                    }
                }
            }
        }