Ejemplo n.º 1
0
        public T Show(JGridRequest packet)
        {
            var pk     = GetPrimaryKeyInfo <T>();
            var pkType = pk.PropertyType;

            return(unitOfWork.GenericRepositories <T>().GetById(Convert.ChangeType(packet.RecordId, pkType)));
        }
Ejemplo n.º 2
0
        public string getSelector(JGridRequest packet)
        {
            FilterData filter = new FilterData();

            filter = JsonConvert.DeserializeObject <FilterData>(packet.Data.ToString());

            packet.ModelName = GetSwitch(packet.ModelName);
            sql = string.Format(@"SELECT * FROM {0}", filter.ModelName);
            switch (packet.ModelName)
            {
            case "DistributionPlanView":
                sql = string.Format($@"EXEC Report_DistributionPlan '{filter.CampId}','','{filter.FromDate}','999999','1'");
                break;

            case "UserWiseServiceCountReportView":
                sql = $@"EXEC UserWiseServiceCount '{filter.Users}','{filter.FromDate}','{filter.ToDate}','{filter.BlockId}','{filter.DistrictCode}','{filter.UpazilaCode}','{filter.UnionCode}','{filter.VillageCode}','1','999999'";
                break;

            case "DailyProgressReportView":
                sql = $@"EXEC Report_IndicatorInfo '{filter.Program}','{filter.FromDate}','{filter.ToDate}','{filter.BlockId}','{filter.DistrictCode}','{filter.UpazilaCode}','{filter.UnionCode}','{filter.VillageCode}'";
                break;

            case "MemberInfo":
                sql = $@"EXEC ExportMemberInfo '{filter.FromDate}','{filter.ToDate}','{filter.BenId}','{filter.Users}','{filter.BlockId}','{filter.DistrictCode}','{filter.UpazilaCode}','{filter.UnionCode}','{filter.VillageCode}'";
                break;
            }
            return(sql);
        }
Ejemplo n.º 3
0
        public T GetVerifyInfo(JGridRequest packet, string pkName)
        {
            var sql = string.Format(@"SELECT ISNULL(ud.FullName, '') as UserName,
                                        d.EntryDate as DataCollectionDate
                                        ,ISNULL(d.IsVerified,0) as IsVerified
                                        ,ISNULL(u.FullName,'') as VerifierName
                                        ,d.VerificationDate as VerificationDate
                                        ,ISNULL(d.VerificationNote,'') as VerificationNote
                                        FROM {0} d
                                        LEFT JOIN AspNetUsers u on u.UserId = d.VerifiedBy
                                        LEFT JOIN AspNetUsers ud on ud.UserId = d.UserId
                                        WHERE d.{1} = '{2}'", packet.ModelName, pkName, packet.RecordId);

            return(unitOfWork.GenericRepositories <T>().GetRecordSet(sql).FirstOrDefault());
        }
Ejemplo n.º 4
0
        public string getSelector(JGridRequest packet)
        {
            FilterData filter = new FilterData();

            if (packet.Data != null && packet.RequestType != "Update")
            {
                filter = JsonConvert.DeserializeObject <FilterData>(packet.Data.ToString());
            }
            switch (packet.ModelName)
            {
            case "GmpTrandView":
                sql = string.Format(@"EXEC GetGmpTrand '{0}'", packet.RecordId);
                break;
            }
            return(sql);
        }
Ejemplo n.º 5
0
        public object Insert(JGridRequest packet, Assembly[] asm, Type item)
        {
            string tableName = typeof(T).Name;
            var    pk        = GetPrimaryKeyInfo <T>();
            var    pkType    = pk.PropertyType;

            var requestSourceDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(packet.Data.ToString());
            var obj = Activator.CreateInstance(item);

            foreach (var items in requestSourceDictionary)
            {
                var  destinationType  = obj.GetType();
                var  destinationField = destinationType.GetProperty(items.Key);
                Type fieldType        = Nullable.GetUnderlyingType(destinationField.PropertyType) ?? destinationField.PropertyType;
                var  fieldValue       = (items.Value == null || items.Value == "") ? null : Convert.ChangeType(items.Value, fieldType);
                destinationField.SetValue(obj, fieldValue, null);
            }
            unitOfWork.GenericRepositories <T>().Insert((T)obj);
            unitOfWork.SaveChange();
            return("Operation Succeeded.");
        }
Ejemplo n.º 6
0
        public object EditDelete(int operationType, JGridRequest packet, Assembly[] asm, int?SessionUserId)
        {
            string tableName = typeof(T).Name;
            var    pk        = GetPrimaryKeyInfo <T>();
            var    pkType    = pk.PropertyType;

            if (operationType == 1)
            {
                var      requestSourceDictionary = JsonConvert.DeserializeObject <Dictionary <string, string> >(packet.Data.ToString());
                var      ids  = packet.RecordId.Split(',');
                List <T> list = new List <T>();
                foreach (var recordId in ids)
                {
                    var exist = unitOfWork.GenericRepositories <T>().GetById(Convert.ChangeType(recordId, pkType));
                    foreach (var item in requestSourceDictionary)
                    {
                        var destinationType  = exist.GetType();
                        var destinationField = destinationType.GetProperty(item.Key);
                        if (destinationField != null)
                        {
                            Type fieldType  = Nullable.GetUnderlyingType(destinationField.PropertyType) ?? destinationField.PropertyType;
                            var  fieldValue = (item.Value == null || item.Value == "") ? null : Convert.ChangeType(item.Value, fieldType);
                            destinationField.SetValue(exist, fieldValue, null);
                        }
                    }


                    list.Add(exist);
                    //// For log
                    //InsertVerificationLog(packet.ModelName, 1, pk.Name, Convert.ToInt64(recordId), Convert.ToString(exist.GetPropertyValue("UUID") ?? ""), Convert.ToInt32(exist.GetPropertyValue("UserId") ?? 0), SessionUserId ?? 0, packet.RecordType, "");
                    ////End
                }
                unitOfWork.GenericRepositories <T>().UpdateAll(list);
            }
            else if (operationType == 2)
            {
                var ChildTables = "";
                if (packet.RecordType == "Master")
                {
                    var childList = GetChildTableList <T>();
                    var query     = unitOfWork.GenericRepositories <T>().GetAll().Where($"{pk.Name} = {packet.RecordId}");
                    //Child Include Start
                    foreach (var childitem in childList.ToList())
                    {
                        query = query.Include(childitem);
                    }
                    //Child Include End
                    var existingMasterWithChild = query.FirstOrDefault();

                    Type item = null;
                    foreach (var childListItem in childList)
                    {
                        if (ChildTables == "")
                        {
                            ChildTables += childListItem;
                        }
                        else
                        {
                            ChildTables += "," + childListItem;
                        }

                        for (int i = 0; i < asm.Length; i++)
                        {
                            item = asm[i].GetTypes().Where(x => x.Name == childListItem).FirstOrDefault();
                            if (item != null)
                            {
                                var jgridType   = typeof(Repository <>);
                                var jgridObject = jgridType.MakeGenericType(item);
                                var obj         = Activator.CreateInstance(jgridObject, unitOfWork.context);
                                var childs      = (IEnumerable <object>)existingMasterWithChild.GetPropertyValue(childListItem);

                                ////For log
                                //foreach (var childItem in childs)
                                //{
                                //    //var primaryKey = _utilityHelper.GetPrimaryKeyInfo(childItem.GetType()).Name.ToString();
                                //    ////InsertVerificationLog(childItem.GetType().Name, primaryKey, Convert.ToInt64(childItem.GetPropertyValue(primaryKey) ?? 0), Convert.ToInt32(childItem.GetPropertyValue("UserId") ?? 0), Convert.ToInt32(childItem.GetPropertyValue("ModifiedBy") ?? 0), packet.RecordType);
                                //    //InsertVerificationLog(childItem.GetType().Name, 2, primaryKey, Convert.ToInt64(childItem.GetPropertyValue(primaryKey) ?? 0), Convert.ToString(exist.GetPropertyValue("UUID") ?? ""), Convert.ToInt32(exist.GetPropertyValue("UserId") ?? 0), Convert.ToInt32(CurrentUser ?? "0"), packet.RecordType);
                                //}
                                //// End

                                MethodInvoker("DeleteAll", obj, new object[] { childs });


                                break;
                            }
                        }
                    }

                    //Master Table Data Delete
                    unitOfWork.GenericRepositories <T>().Delete(existingMasterWithChild);

                    // For log
                    var PK = _utilityHelper.GetPrimaryKeyInfo(existingMasterWithChild.GetType()).Name.ToString();
                    // InsertVerificationLog(existingMasterWithChild.GetType().Name, 2, PK, Convert.ToInt64(existingMasterWithChild.GetPropertyValue(PK) ?? 0), Convert.ToString(existingMasterWithChild.GetPropertyValue("UUID") ?? ""), Convert.ToInt32(existingMasterWithChild.GetPropertyValue("UserId") ?? 0), SessionUserId ?? 0, packet.RecordType, ChildTables);
                    //// End
                }
                else
                {
                    var exist = unitOfWork.GenericRepositories <T>().GetById(Convert.ChangeType(packet.RecordId, pkType));
                    unitOfWork.GenericRepositories <T>().Delete(exist);

                    //// For log
                    //InsertVerificationLog(packet.ModelName, 2, pk.Name, Convert.ToInt64(packet.RecordId), Convert.ToString(exist.GetPropertyValue("UUID") ?? ""), Convert.ToInt32(exist.GetPropertyValue("UserId") ?? 0), SessionUserId ?? 0, packet.RecordType,ChildTables);
                    //// End
                }
            }

            unitOfWork.SaveChangeJGrid();
            return("Operation Succeeded.");
        }
Ejemplo n.º 7
0
        public string getSelector(JGridRequest packet)
        {
            FilterData filter = new FilterData();

            if (packet.Data != null && packet.RequestType != "Update")
            {
                filter = JsonConvert.DeserializeObject <FilterData>(packet.Data.ToString());
            }

            switch (packet.ModelName)
            {
            case "MemberInfoView":
                sql = string.Format(@"EXEC SearchMemberInfoData '{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}'",
                                    filter.FromDate, filter.ToDate, filter.BenId, filter.BenName, filter.BenType,
                                    filter.BenUsers, filter.DistrictCode, filter.UpazilaCode, filter.UnionCode, filter.VillageCode,
                                    filter.CenterId, filter.CampId, filter.BlockId, packet.PageSize, packet.PageNo);
                break;

            case "MemberDetailView":
                sql = string.Format(@"exec SearchMemberInfoDetailData '{0}'", packet.RecordId);
                break;

            case "SessionInfoView":
                sql = string.Format(@"EXEC SearchSessionInfoMasterData '{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}'",
                                    filter.FromDate, filter.ToDate, filter.CategoryId, filter.GroupId, filter.SessionAttendance,
                                    filter.IndividualAttendance, filter.CenterId, filter.Users, filter.BenId,
                                    filter.DistrictCode, filter.UpazilaCode, filter.UnionCode, filter.VillageCode, packet.PageSize, packet.PageNo, filter.BlockId);
                break;

            case "SessionMemberInfoView":
                sql = string.Format(@"EXEC SessionInfoDetails '{0}'", packet.RecordId);
                break;

            case "SessionInfoSummaryView":
                sql = string.Format(@"EXEC SessionInfoSummaryDetails '{0}'", packet.RecordId);
                break;

            case "SessionInfoTopicView":
                sql = string.Format(@"EXEC SearchSessionInfoTopicData '{0}'", packet.RecordId);
                break;

            case "SessionMemberGuardiansView":
                sql = string.Format(@"EXEC SearchSessionMemberGuardiansData '{0}'", packet.RecordId);
                break;

            case "GmpView":
                sql = $@"EXEC SearchGmpMaster '{filter.FromDate}','{filter.ToDate}','{filter.Users}','{filter.BenId}','{filter.BenName}','{filter.BenType}','{filter.BenStatus}','{filter.InCare}','{filter.DistrictCode}','{filter.UpazilaCode}','{filter.UnionCode}','{filter.VillageCode}','{filter.CenterId}','{packet.PageSize}','{packet.PageNo}'";
                break;

            case "GmpDetailsView":
                sql = $@"EXEC GmpDetailsByRecordId '{packet.RecordId}'";
                break;

            case "AdmissionView":
                ////sql = $@"EXEC SearchAdmission '{filter.FromDate}','{filter.ToDate}','{filter.Block}','{filter.ServicePointId}','{filter.Users}','{filter.BenId}','{filter.BenName}','{filter.DistrictCode}','{filter.UpazilaCode}','{filter.UnionCode}','{filter.VillageCode}','{packet.PageSize}','{packet.PageNo}'";
                sql = $@"EXEC SearchAdmissionMaster '{filter.FromDate}','{filter.ToDate}','{filter.CenterId}','{filter.Users}','{filter.BenId}','{filter.BenName}','{filter.DistrictCode}','{filter.UpazilaCode}','{filter.UnionCode}','{filter.VillageCode}','{packet.PageSize}','{packet.PageNo}','{filter.BlockId}','{filter.AdmissionType}','{filter.DischargeType}'";
                break;

            case "AdmissionDetailsView":
                sql = $@"EXEC SearchAdmissionDetailsByRecordId '{packet.RecordId}'";
                break;

            case "DischargeView":
                sql = $@"EXEC SearchDischargeByRecordId '{packet.RecordId}'";
                break;

            case "DistributionView":
                sql = $@"EXEC SearchDistribution '{filter.FromDate}','{filter.ToDate}','{filter.Users}','{filter.BenId}','{filter.BenName}','{filter.BenType}','{filter.BenStatus}','{filter.InCare}','{filter.DistrictCode}','{filter.UpazilaCode}','{filter.UnionCode}','{filter.VillageCode}','{filter.CenterId}','{packet.PageSize}','{packet.PageNo}'";
                break;

            case "DistributionDetailsView":
                sql = $@"EXEC SearchDistributionByBenId '{packet.RecordId}'";
                break;

            case "DailyProgressReportView":
                sql = $@"EXEC Report_IndicatorInfo '{filter.Program}','{filter.FromDate}','{filter.ToDate}','{filter.BlockId}','{filter.DistrictCode}','{filter.UpazilaCode}','{filter.UnionCode}','{filter.VillageCode}'";
                break;

            case "UserWiseServiceCountReportView":
                sql = $@"EXEC UserWiseServiceCount '{filter.Users}','{filter.FromDate}','{filter.ToDate}','{filter.BlockId}','{filter.DistrictCode}','{filter.UpazilaCode}','{filter.UnionCode}','{filter.VillageCode}','{packet.PageNo}','{packet.PageSize}'";
                break;

            case "DistributionPlanView":
                sql = $@"EXEC Report_DistributionPlan '{filter.CampId}','{filter.StatusType}','{filter.FromDate}','{packet.PageSize}','{packet.PageNo}'";
                break;
            }
            return(sql);
        }