/// <summary>
        /// Retrieves list of Company objects from SqlCommand, after database query
        /// number of rows retrieved and returned depends upon the rows field value
        /// </summary>
        /// <param name="cmd">The command object to use for query</param>
        /// <param name="rows">Number of rows to process</param>
        /// <returns>A list of Company objects</returns>
        private CompanyList GetList(SqlCommand cmd, long rows)
        {
            // Select multiple records
            SqlDataReader reader;
            long          result = SelectRecords(cmd, out reader);

            //Company list
            CompanyList list = new CompanyList();

            using ( reader )
            {
                // Read rows until end of result or number of rows specified is reached
                while (reader.Read() && rows-- != 0)
                {
                    Company companyObject = new Company();
                    FillObject(companyObject, reader);

                    list.Add(companyObject);
                }

                // Close the reader in order to receive output parameters
                // Output parameters are not available until reader is closed.
                reader.Close();
            }

            return(list);
        }
Esempio n. 2
0
        public void AddCompany(Company company)
        {
            if (company == null)
            {
                throw new ArgumentNullException(nameof(company));
            }

            CompanyList.Add(company);
        }
Esempio n. 3
0
        public async Task LoadStateAsync()
        {
            ApplicationData applicationData = new ApplicationData();
            var             list            = applicationData.GetAll();

            foreach (var item in list)
            {
                await Task.Run(() => CompanyList.Add(item));
            }
        }
Esempio n. 4
0
        public void LoadState()
        {
            ApplicationData applicationData = new ApplicationData();
            var             list            = applicationData.GetAll();

            foreach (var item in list)
            {
                CompanyList.Add(item);
            }
        }
        public void RefreshCities()
        {
            CityList.Clear();
            RequestService.GetCities().ToList().ForEach(c => CityList.Add(c));
            OnPropertyChanged(nameof(CityList));
            SelectedCity = CityList.FirstOrDefault();

            CompanyList.Clear();
            RequestService.GetServiceCompanies().ToList().ForEach(c => CompanyList.Add(c));
            OnPropertyChanged(nameof(CompanyList));
        }
        public void SearchCompany(string searchString)
        {
            ClearCompanyDataGrid();

            var companies = _companyService.SearchCompanies(searchString);

            foreach (var company in companies)
            {
                var companyViewModel = new CompanyViewModel(company);

                CompanyList.Add(companyViewModel);
            }
        }
Esempio n. 7
0
        async void SaveItem()
        {
            if (Item.ID != 0)
            {
                int p = CompanyList.IndexOf(Item);
                CompanyList.Remove(Item);
                CompanyList.Insert(p, Item);
            }
            else
            {
                CompanyList.Add(Item);
            }
            await App.Database.SaveItemAsync(Item);

            await Nav.PopAsync();
        }
Esempio n. 8
0
        private async void StartAnalyse(object parameter)
        {
            var applicationData = new ApplicationData();
            var company         = new Company();

            for (int i = CompanyList.Count - 1; i >= 0; i--)
            {
                await Task.Run(() => company = Analyse(CompanyList[i]));

                CompanyList.RemoveAt(i);
                CompanyList.Add(company);
            }

            await SaveStateAsync();
            await SaveToFileAsync();

            MessageBox.Show("اطلاعات در فایل و دیتابیس ذخیره شد", "Done", MessageBoxButton.OK, MessageBoxImage.Information);
        }
        public void Add()
        {
            var newEntity = new CompanyEntity()
            {
                CompanyId    = -1,
                CompanyOwner = ApplicationHelper.CurrentUserProfile.CompanyId,
                Deleted      = false,
                IsCustomer   = true,
                IsSupplier   = true,
                TaxCode      = "",
                CompanyCode  = "",
                Address      = "",
                Phone        = "",
                Website      = ""
            };

            SelectedCompany = newEntity;
            CompanyList.Add(newEntity);
            CompanyList = new List <CompanyEntity>(_companyList);
        }
Esempio n. 10
0
        private bool NewCompany(string itemID)
        {
            Company item = new Company();

            //all new records will be give a negative int autoid...
            //when they are updated then sql will generate one for them overiding this set value...
            //it will allow us to give uniqueness to the tempory new records...
            //Before they are updated to the entity and given an autoid...
            //we use a negative number and keep subtracting by 1 for each new item added...
            //This will allow it to alwasy be unique and never interfere with SQL's positive autoid...
            _newCompanyAutoId    = _newCompanyAutoId - 1;
            item.AutoID          = _newCompanyAutoId;
            item.CompanyID       = itemID;
            item.IsValid         = 1;
            item.NotValidMessage = "New Record Key Field/s Are Required.";
            CompanyList.Add(item);
            _serviceAgent.AddToCompanyRepository(item);
            SelectedCompany = CompanyList.LastOrDefault();

            AllowEdit = true;
            Dirty     = false;
            return(true);
        }
        private CompanyList LoadExposureDocument(IResult result) {
            CompanyList companies = new CompanyList();

            if (!Common.IsFileAvailable(ExposureFilePath)) {
                result.Errors.Add(string.Format("File not found: [{0}]", ExposureFilePath));
            }

            XmlDocument exposureXMLDoc = new XmlDocument();
            exposureXMLDoc.Load(ExposureFilePath);

            XmlNodeList companyNodeList = exposureXMLDoc.SelectNodes("/companies/company");

            foreach (XmlNode companyNode in companyNodeList) {
                Company company = new Company();
                company.CompanyId = Convert.ToInt32(companyNode.SelectSingleNode("id").InnerText);

                XmlNodeList regionNodeList = companyNode.SelectNodes("region");
                foreach (XmlNode regionNode in regionNodeList) {
                    company.Regions.Add(Convert.ToInt32(regionNode.InnerText));
                }

                companies.Add(company);
            }

            return companies;
        }
Esempio n. 12
0
        private void CreateFillerData()
        {
            for (int i = 0; i < 3; i++)
            {
                var movie = CreateMovieWithoutRelatedInfo();
                InitialMoviesInDb.Add(movie);

                var similar = new MovieSimilar
                {
                    Movie     = TestMovieSeededWithRelatedInfo,
                    MovieId   = TestMovieSeededWithRelatedInfo.Id,
                    Similar   = movie,
                    SimilarId = movie.Id
                };

                TestMovieSeededWithRelatedInfo.Similars.Add(similar);
            }

            for (int i = 0; i < 3; i++)
            {
                var person = CreatePersonWithoutRelatedInfo();
                PeopleList.Add(person);

                TestMovieSeededWithRelatedInfo.ActorList.Add(new MovieActor
                {
                    Movie    = TestMovieSeededWithRelatedInfo,
                    MovieId  = TestMovieSeededWithRelatedInfo.Id,
                    Person   = person,
                    PersonId = person.Id
                });
            }

            for (int i = 0; i < 3; i++)
            {
                var person = CreatePersonWithoutRelatedInfo();
                PeopleList.Add(person);

                TestMovieSeededWithRelatedInfo.DirectorList.Add(new MovieDirector
                {
                    Movie    = TestMovieSeededWithRelatedInfo,
                    MovieId  = TestMovieSeededWithRelatedInfo.Id,
                    Person   = person,
                    PersonId = person.Id
                });
            }

            for (int i = 0; i < 3; i++)
            {
                var person = CreatePersonWithoutRelatedInfo();
                PeopleList.Add(person);

                TestMovieSeededWithRelatedInfo.WriterList.Add(new MovieWriter
                {
                    Movie    = TestMovieSeededWithRelatedInfo,
                    MovieId  = TestMovieSeededWithRelatedInfo.Id,
                    Person   = person,
                    PersonId = person.Id
                });
            }

            for (int i = 0; i < 3; i++)
            {
                var company = CreateCompanyWithoutRelatedInfo();
                CompanyList.Add(company);

                TestMovieSeededWithRelatedInfo.CompanyList.Add(new MovieCompany
                {
                    Movie     = TestMovieSeededWithRelatedInfo,
                    MovieId   = TestMovieSeededWithRelatedInfo.Id,
                    Company   = company,
                    CompanyId = company.Id
                });
            }

            for (int i = 0; i < 3; i++)
            {
                var rating = fixture.Build <Rating>()
                             .With(x => x.Movie, TestMovieSeededWithRelatedInfo)
                             .With(x => x.MovieId, TestMovieSeededWithRelatedInfo.Id)
                             .Create();

                TestMovieSeededWithRelatedInfo.Ratings.Add(rating);
            }
        }
        public async Task <IActionResult> OnPostFilterAsync()
        {
            try
            {
                CreateLists();

                var resultLog = await apiHttpClient.Get <List <LogItem> >("/api/Log/GetByFilter/" + FilterModel.FromDate.Ticks + "/" + FilterModel.ToDate.Ticks + "/" + FilterModel.Succeeded);

                var resultUser = await apiHttpClient.Get <List <UserItem> >("/api/User/GetAll");

                var resultCompany = await apiHttpClient.Get <List <CompanyItem> >("/api/Company/GetAll");

                if (resultLog.Succeeded && resultUser.Succeeded && resultCompany.Succeeded)
                {
                    LogList     = resultLog.Data;
                    UserList    = resultUser.Data;
                    CompanyList = resultCompany.Data;

                    UserList.Add(new UserItem
                    {
                        Id   = Guid.Empty,
                        Name = localizer["Not logged in"]
                    });

                    CompanyList.Add(new CompanyItem
                    {
                        Id   = Guid.Empty,
                        Name = ""
                    });

                    var unkonwnUser = new UserItem
                    {
                        Id   = Guid.NewGuid(),
                        Name = localizer["Unknown"]
                    };

                    var unkonwnCompany = new CompanyItem()
                    {
                        Id   = Guid.NewGuid(),
                        Name = localizer["Unknown"]
                    };

                    foreach (var logItem in LogList)
                    {
                        var user = UserList.SingleOrDefault(x => x.Id == logItem.UserId);

                        logItem.UserItem = user ?? unkonwnUser;

                        var company = CompanyList.SingleOrDefault(x => x.Id == logItem.CompanyId);

                        logItem.CompanyItem = company ?? unkonwnCompany;
                    }

                    return(Page());
                }

                return(await errorHandler.View(this, null, !resultLog.Succeeded?resultLog.Exception : !resultUser.Succeeded?resultUser.Exception : resultCompany.Exception));
            }
            catch (Exception exception)
            {
                return(await errorHandler.Log(this, null, exception));
            }
        }
Esempio n. 14
0
        //public static void InitHR()
        //{
        //    try
        //    {
        //        IList<CompanyData> listCData = new List<CompanyData>();
        //        IList<DepartmentData> ListDData = new List<DepartmentData>();
        //        IList<PostData> ListPData = new List<PostData>();

        //        List<OrganizationWS.T_HR_COMPANY> comList = (List<OrganizationWS.T_HR_COMPANY>)App.Current.Resources["SYS_CompanyInfo"];
        //        List<OrganizationWS.T_HR_DEPARTMENT> deptList = (List<OrganizationWS.T_HR_DEPARTMENT>)App.Current.Resources["SYS_DepartmentInfo"];
        //        List<OrganizationWS.T_HR_POST> postList = (List<OrganizationWS.T_HR_POST>)App.Current.Resources["SYS_PostInfo"];


        //        comList.ForEach(comHR =>
        //        {
        //            ObservableCollection<VirtualDepartment> listDepartment = new ObservableCollection<VirtualDepartment>();

        //            VirtualCompany vc = new VirtualCompany();
        //            vc.ID = comHR.COMPANYID;
        //            vc.Name = comHR.CNAME;
        //            vc.DepartmentCollection = listDepartment;


        //            CompanyData cData = CreateItem<CompanyData>(vc);
        //            List<DepartmentData> listDepartmentData = new List<DepartmentData>();

        //            List<OrganizationWS.T_HR_DEPARTMENT> deptListPart = deptList.FindAll(item =>
        //            {
        //                if (item.T_HR_COMPANY == null)
        //                {
        //                    return false;
        //                }
        //                return item.T_HR_COMPANY.COMPANYID == comHR.COMPANYID;

        //            });

        //            deptListPart.ForEach(deptHR =>
        //            {
        //                ObservableCollection<VirtualPost> listPost = new ObservableCollection<VirtualPost>();

        //                VirtualDepartment vd = new VirtualDepartment();
        //                vd.ID = deptHR.DEPARTMENTID;
        //                vd.Name = deptHR.T_HR_DEPARTMENTDICTIONARY.DEPARTMENTNAME;
        //                vd.VirtualCompany = vc;
        //                vd.PostCollection = listPost;
        //                listDepartment.Add(vd);


        //                DepartmentData dData = CreateItem<DepartmentData>(vd);
        //                List<PostData> listPostData = new List<PostData>();

        //                List<OrganizationWS.T_HR_POST> postListPart = postList.FindAll(item =>
        //                {
        //                    if (item.T_HR_DEPARTMENT == null)
        //                    {
        //                        return false;
        //                    }
        //                    return item.T_HR_DEPARTMENT.DEPARTMENTID == deptHR.DEPARTMENTID;
        //                });

        //                postListPart.ForEach(postHR =>
        //                {
        //                    VirtualPost vp = new VirtualPost();
        //                    vp.ID = postHR.POSTID;
        //                    vp.Name = postHR.T_HR_POSTDICTIONARY.POSTNAME;
        //                    vp.VirtualCompany = vc;
        //                    vp.VirtualDepartment = vd;
        //                    listPost.Add(vp);


        //                    PostData pData = CreateItem<PostData>(vp);
        //                    pData.Company = cData;
        //                    pData.Department = dData;
        //                    listPostData.Add(pData);
        //                    ListPData.Add(pData);

        //                });

        //                dData.Company = cData;
        //                dData.PostCollection = listPostData;
        //                listDepartmentData.Add(dData);
        //                ListDData.Add(dData);
        //            });

        //            cData.DepartmentCollection = listDepartmentData;
        //            listCData.Add(cData);
        //            CompanyList.Add(vc);
        //        });

        //        ReferencedData<CompanyData>.RefData = listCData;
        //        ReferencedData<DepartmentData>.RefData = ListDData;
        //        ReferencedData<PostData>.RefData = ListPData;
        //    }
        //    catch (Exception ex)
        //    {
        //        System.Diagnostics.Debug.WriteLine(ex);
        //        throw new Exception("调用HR服务异常", ex);
        //    }
        //}

        #endregion

        /// <summary>
        /// 新的,从平台组织架构缓存中加载。
        /// </summary>
        public static void InitHR()
        {
            try
            {
                IList <CompanyData>    listCData = new List <CompanyData>();
                IList <DepartmentData> ListDData = new List <DepartmentData>();
                IList <PostData>       ListPData = new List <PostData>();


                List <OrganizationWS.T_HR_COMPANY> comList
                    = App.Current.Resources["SYS_CompanyInfo"] as List <OrganizationWS.T_HR_COMPANY> ?? new List <OrganizationWS.T_HR_COMPANY>();
                List <OrganizationWS.T_HR_DEPARTMENT> deptList
                    = App.Current.Resources["SYS_DepartmentInfo"] as List <OrganizationWS.T_HR_DEPARTMENT> ?? new List <OrganizationWS.T_HR_DEPARTMENT>();
                List <OrganizationWS.T_HR_POST> postList
                    = App.Current.Resources["SYS_PostInfo"] as List <OrganizationWS.T_HR_POST> ?? new List <OrganizationWS.T_HR_POST>();


                comList.ForEach(comHR =>
                {
                    ObservableCollection <VirtualDepartment> listDepartment = new ObservableCollection <VirtualDepartment>();

                    VirtualCompany vc       = new VirtualCompany();
                    vc.ID                   = comHR.COMPANYID;
                    vc.Name                 = comHR.CNAME;
                    vc.DepartmentCollection = listDepartment;


                    CompanyData cData = CreateItem <CompanyData>(vc);
                    List <DepartmentData> listDepartmentData = new List <DepartmentData>();

                    List <OrganizationWS.T_HR_DEPARTMENT> deptListPart = deptList.FindAll(item =>
                    {
                        if (item.T_HR_COMPANY == null)
                        {
                            return(false);
                        }
                        return(item.T_HR_COMPANY.COMPANYID == comHR.COMPANYID);
                    });

                    deptListPart.ForEach(deptHR =>
                    {
                        ObservableCollection <VirtualPost> listPost = new ObservableCollection <VirtualPost>();

                        VirtualDepartment vd = new VirtualDepartment();
                        vd.ID             = deptHR.DEPARTMENTID;
                        vd.Name           = deptHR.T_HR_DEPARTMENTDICTIONARY.DEPARTMENTNAME;
                        vd.VirtualCompany = vc;
                        vd.PostCollection = listPost;
                        listDepartment.Add(vd);


                        DepartmentData dData         = CreateItem <DepartmentData>(vd);
                        List <PostData> listPostData = new List <PostData>();

                        List <OrganizationWS.T_HR_POST> postListPart = postList.FindAll(item =>
                        {
                            if (item.T_HR_DEPARTMENT == null)
                            {
                                return(false);
                            }
                            return(item.T_HR_DEPARTMENT.DEPARTMENTID == deptHR.DEPARTMENTID);
                        });

                        postListPart.ForEach(postHR =>
                        {
                            VirtualPost vp       = new VirtualPost();
                            vp.ID                = postHR.POSTID;
                            vp.Name              = postHR.T_HR_POSTDICTIONARY.POSTNAME;
                            vp.VirtualCompany    = vc;
                            vp.VirtualDepartment = vd;
                            listPost.Add(vp);


                            PostData pData   = CreateItem <PostData>(vp);
                            pData.Company    = cData;
                            pData.Department = dData;
                            listPostData.Add(pData);
                            ListPData.Add(pData);
                        });

                        dData.Company        = cData;
                        dData.PostCollection = listPostData;
                        listDepartmentData.Add(dData);
                        ListDData.Add(dData);
                    });

                    cData.DepartmentCollection = listDepartmentData;
                    listCData.Add(cData);
                    CompanyList.Add(vc);
                });

                ReferencedData <CompanyData> .RefData    = listCData;
                ReferencedData <DepartmentData> .RefData = ListDData;
                ReferencedData <PostData> .RefData       = ListPData;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
                throw new Exception("调用HR服务异常", ex);
            }
        }