Esempio n. 1
0
        public MasterPointModel UpdateMasterPoint(MasterPointModel model)
        {
            MasterPointModel updatedModel = new MasterPointModel();

            updatedModel               = new MasterPointModel();
            updatedModel.ID            = model.ID;
            updatedModel.AreaName      = model.AreaName;
            updatedModel.LocationName  = model.LocationName;
            updatedModel.InDeviceList  = model.InDeviceList;
            updatedModel.OutDeviceList = model.OutDeviceList;

            MasterPointModel mdl = GetInformation(model);

            updatedModel.InsideCount         = mdl.PeopleList.Count();
            updatedModel.GroupModelListByDiv = mdl.GroupModelListByDiv;
            updatedModel.GroupModelListByJab = mdl.GroupModelListByJab;
            updatedModel.PeopleList          = mdl.PeopleList;
            updatedModel.LastIn  = mdl.LastIn;
            updatedModel.LastOut = mdl.LastOut;

            updatedModel.Effect       = model.Effect;
            updatedModel.GroupBy      = model.GroupBy;
            updatedModel.CurrentGroup = model.CurrentGroup;

            return(updatedModel);
        }
Esempio n. 2
0
        public List <MasterPointModel> GetListMasterPoint()
        {
            string path = HostingEnvironment.MapPath(@"~/SQL/config.xml");

            List <MasterPointModel> listMasterPoint = new List <MasterPointModel>();

            XElement xelement = XElement.Load(path);
            IEnumerable <XElement> MasterPointModels = xelement.Elements();

            foreach (var item in MasterPointModels)
            {
                MasterPointModel model = new MasterPointModel();
                model.ID            = item.Element("ID").Value;
                model.AreaName      = item.Element("AreaName").Value;
                model.LocationName  = item.Element("LocationName").Value;
                model.InDeviceList  = item.Element("InDeviceList").Value;
                model.OutDeviceList = item.Element("OutDeviceList").Value;
                MasterPointModel mdl = GetInformation(model);
                model.InsideCount         = mdl.PeopleList.Count();
                model.GroupModelListByDiv = mdl.GroupModelListByDiv;
                model.GroupModelListByJab = mdl.GroupModelListByJab;
                model.PeopleList          = mdl.PeopleList;
                model.LastIn  = mdl.LastIn;
                model.LastOut = mdl.LastOut;

                model.Effect = item.Element("Effect").Value;
                listMasterPoint.Add(model);
            }

            return(listMasterPoint);
        }
Esempio n. 3
0
        public MasterPointModel UpdateMasterPointAssembly(MasterPointModel model)
        {
            MasterPointModel updatedModel = new MasterPointModel();

            updatedModel                = new MasterPointModel();
            updatedModel.ID             = model.ID;
            updatedModel.AreaName       = model.AreaName;
            updatedModel.LocationName   = model.LocationName;
            updatedModel.InDeviceList   = model.InDeviceList;
            updatedModel.OutDeviceList  = model.OutDeviceList;
            updatedModel.AssemblyDevice = model.AssemblyDevice;

            MasterPointModel mdl = GetAssemblyInformation(model);

            updatedModel.InsideCount = mdl.PeopleList.Count();
            updatedModel.PeopleList  = mdl.PeopleList;

            return(updatedModel);
        }
Esempio n. 4
0
        public MasterPointModel GetInformation(MasterPointModel model)
        {
            //new for last in last out
            IEnumerable <LastInLastOut> LastInLastOut = Connection.Instance.Fetch <LastInLastOut>("GetLastInLastOut", new { InDevice = model.InDeviceList, OutDevice = model.OutDeviceList });

            //List<TransactionModel> listTransactionModel = new List<TransactionModel>();
            IEnumerable <TransactionModel> TransactionData = Connection.Instance.Fetch <TransactionModel>("GetTransactionData", new { InDevice = model.InDeviceList, OutDevice = model.OutDeviceList });

            String        LastTransactionData = "";
            List <string> listInside          = new List <string>();
            bool          alreadyOut          = false;

            foreach (TransactionModel item in TransactionData)
            {
                if (!item.TrData.Equals(LastTransactionData))
                {
                    alreadyOut          = true;
                    LastTransactionData = item.TrData;
                    if (item.TrCode.Equals("0"))
                    {
                        listInside.Add(item.TrData);
                        alreadyOut = false;
                    }
                }
                else
                {
                    if (item.TrCode.Equals("9"))
                    {
                        listInside.Remove(item.TrData);
                        alreadyOut = true;
                    }
                    else if (alreadyOut)
                    {
                        listInside.Add(item.TrData);
                        alreadyOut = false;
                    }
                }
            }

            List <PeopleModel> listPeople = new List <PeopleModel>();

            foreach (var item in TransactionData.OrderBy(y => y.TrData).ThenByDescending(m => m.TrDate).ThenByDescending(k => k.TrTime))
            {
                if (listInside.Contains(item.TrData))
                {
                    PeopleModel people = new PeopleModel();
                    people.Seq     = item.SeqNo;
                    people.TrData  = item.TrData;
                    people.Name    = item.Name;
                    people.Divisi  = item.Divisi.Trim();
                    people.Jabatan = item.Jabatan.Trim();
                    people.TimeIn  = item.TrTime;
                    if (!listPeople.Any(p => p.TrData == item.TrData))
                    {
                        listPeople.Add(people);
                    }
                }
            }
            ;

            var groupedPeopleByDivisi =
                from b in listPeople.AsEnumerable()
                group b by b.Divisi into g
                select new
            {
                Group      = g.Key,
                GroupCount = g.Count()
            };

            List <GroupModel> groupByDiv = new List <GroupModel>();

            foreach (var item in groupedPeopleByDivisi)
            {
                GroupModel grpMdl = new GroupModel();
                grpMdl.Group      = item.Group;
                grpMdl.GroupCount = item.GroupCount;
                groupByDiv.Add(grpMdl);
            }

            var groupedPeopleByJabatan =
                from b in listPeople.AsEnumerable()
                group b by b.Jabatan into g
                select new
            {
                Group      = g.Key,
                GroupCount = g.Count()
            };

            List <GroupModel> groupByJab = new List <GroupModel>();

            foreach (var item in groupedPeopleByJabatan)
            {
                GroupModel grpMdl = new GroupModel();
                grpMdl.Group      = item.Group;
                grpMdl.GroupCount = item.GroupCount;
                groupByJab.Add(grpMdl);
            }

            MasterPointModel ret = new MasterPointModel();

            ret.GroupModelListByDiv = groupByDiv;
            ret.GroupModelListByJab = groupByJab;
            ret.PeopleList          = listPeople.OrderByDescending(a => a.Seq).ToList();

            if (LastInLastOut != null && LastInLastOut.Count() > 0)
            {
                LastInLastOut lilo = LastInLastOut.FirstOrDefault();
                ret.LastIn  = lilo.LastIn;
                ret.LastOut = lilo.LastOut;
            }

            return(ret);
        }
Esempio n. 5
0
        /////// people history
        public IEnumerable <PeopleHistory> GetPeopleHistory(MasterPointModel model)
        {
            /////get people inside
            IEnumerable <TransactionModel> TransactionData = Connection.Instance.Fetch <TransactionModel>("GetTransactionData", new { InDevice = model.InDeviceList, OutDevice = model.OutDeviceList });

            String        LastTransactionData = "";
            List <string> listInside          = new List <string>();
            bool          alreadyOut          = false;

            foreach (TransactionModel item in TransactionData)
            {
                if (!item.TrData.Equals(LastTransactionData))
                {
                    alreadyOut          = true;
                    LastTransactionData = item.TrData;
                    if (item.TrCode.Equals("0"))
                    {
                        listInside.Add(item.TrData);
                        alreadyOut = false;
                    }
                }
                else
                {
                    if (item.TrCode.Equals("9"))
                    {
                        listInside.Remove(item.TrData);
                        alreadyOut = true;
                    }
                    else if (alreadyOut)
                    {
                        listInside.Add(item.TrData);
                        alreadyOut = false;
                    }
                }
            }

            List <PeopleModel> listPeople = new List <PeopleModel>();

            foreach (var item in TransactionData.OrderBy(y => y.TrData).ThenByDescending(m => m.TrDate).ThenByDescending(k => k.TrTime))
            {
                if (listInside.Contains(item.TrData))
                {
                    PeopleModel people = new PeopleModel();
                    people.Seq     = item.SeqNo;
                    people.TrData  = item.TrData;
                    people.Name    = item.Name;
                    people.Divisi  = item.Divisi.Trim();
                    people.Jabatan = item.Jabatan.Trim();
                    people.TimeIn  = item.TrTime;
                    if (!listPeople.Any(p => p.TrData == item.TrData))
                    {
                        listPeople.Add(people);
                    }
                }
            }
            ;

            List <PeopleHistory> peopleInside = new List <PeopleHistory>();

            foreach (var item in listPeople)
            {
                PeopleHistory people = new PeopleHistory();
                people.TrData  = item.TrData;
                people.Divisi  = item.Divisi;
                people.Name    = item.Name;
                people.TimeIn  = item.TimeIn;
                people.TimeOut = item.TimeOut;
                peopleInside.Add(people);
            }

            IEnumerable <PeopleHistory> PeopleHistory = Connection.Instance.Fetch <PeopleHistory>("GetPeopleHistory", new { InDevice = model.InDeviceList, OutDevice = model.OutDeviceList });

            PeopleHistory = PeopleHistory.Except(peopleInside, new PersonComparer());

            IEnumerable <PeopleHistory> totalPeople = peopleInside.OrderByDescending(m => m.TimeIn).Union(PeopleHistory, new PersonComparer());

            //List<PeopleHistory> totalPeople = (List<PeopleHistory>)PeopleHistory.Union(peopleInside, new PersonComparer());

            return(totalPeople);
        }
Esempio n. 6
0
        /// <summary>
        /// Used for assembly point
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public MasterPointModel GetAssemblyInformation(MasterPointModel model)
        {
            IEnumerable <TransactionModel> TransactionData = Connection.Instance.Fetch <TransactionModel>("GetAssemblyPointData", new { InDevice = model.InDeviceList, OutDevice = model.OutDeviceList, AssemblyDevice = model.AssemblyDevice });

            String        LastTransactionData = "";
            List <string> listInside          = new List <string>();
            bool          alreadyOut          = false;

            foreach (TransactionModel item in TransactionData)
            {
                if (!item.TrData.Equals(LastTransactionData))
                {
                    alreadyOut          = true;
                    LastTransactionData = item.TrData;
                    if (item.TrCode.Equals("0"))
                    {
                        listInside.Add(item.TrData);
                        alreadyOut = false;
                    }
                }
                else
                {
                    if (item.TrCode.Equals("9"))
                    {
                        listInside.Remove(item.TrData);
                        alreadyOut = true;
                    }
                    else if (alreadyOut)
                    {
                        listInside.Add(item.TrData);
                        alreadyOut = false;
                    }
                }
            }

            List <PeopleModel> listPeople = new List <PeopleModel>();

            foreach (var item in TransactionData.OrderBy(y => y.TrData).ThenByDescending(m => m.TrDate).ThenByDescending(k => k.TrTime))
            {
                if (listInside.Contains(item.TrData))
                {
                    PeopleModel people = new PeopleModel();
                    people.Seq               = item.SeqNo;
                    people.TrData            = item.TrData;
                    people.Name              = item.Name;
                    people.Divisi            = item.Divisi.Trim();
                    people.Jabatan           = item.Jabatan.Trim();
                    people.isAtAssemblyPoint = !string.IsNullOrEmpty(item.DataAssembly);

                    if (!listPeople.Any(p => p.TrData == item.TrData))
                    {
                        listPeople.Add(people);
                    }
                }
            }
            ;


            MasterPointModel ret = new MasterPointModel();

            ret.PeopleList            = listPeople.OrderByDescending(a => a.Seq).ToList();
            ret.PeopleInAssemblyPoint = listPeople.Where(a => a.isAtAssemblyPoint == true).Count();
            ret.PeopleStillInside     = ret.PeopleList.Where(a => a.isAtAssemblyPoint == false).Count();

            return(ret);
        }