Ejemplo n.º 1
0
        /// <summary>
        /// Upload Escalation Matrix Details
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public CommonResponse UploadEscalationMatrixDetails(List <EscalationMatrixDetails> data)
        {
            CommonResponse obj            = new CommonResponse();
            CommonFunction commonFunction = new CommonFunction();

            try
            {
                var dbCheck = db.UnitworkccsTblescalationmatrix.Where(m => m.IsDeleted == 0).ToList();
                db.RemoveRange(dbCheck);
                db.SaveChanges();

                foreach (var item in data)
                {
                    var check = db.UnitworkccsTblescalationmatrix.Where(m => m.OpNo == item.employeeId).FirstOrDefault();

                    if (check == null)
                    {
                        UnitworkccsTblescalationmatrix tblEscalationMatrix = new UnitworkccsTblescalationmatrix();
                        tblEscalationMatrix.Category = item.category;


                        string idsss = "";
                        if (string.IsNullOrEmpty(item.category))
                        {
                            tblEscalationMatrix.CategoryId = idsss;
                        }

                        else
                        {
                            string[]      catSlipt = item.category.Split(',');
                            List <string> catlist  = catSlipt.ToList();

                            foreach (var val in catlist)
                            {
                                var    catid = db.UnitworkccsTblcategorymaster.Where(m => m.CategoryName == val).Select(m => m.CategoryId).FirstOrDefault();
                                string ids   = catid + ",";
                                idsss = idsss + ids;
                            }
                            idsss = idsss.TrimStart(',');
                            idsss = idsss.TrimEnd(',');
                            tblEscalationMatrix.CategoryId = idsss;
                        }

                        tblEscalationMatrix.Cell = item.cell;
                        string cellids = "";
                        if (string.IsNullOrEmpty(item.cell))
                        {
                            tblEscalationMatrix.CellId = cellids;
                        }

                        else
                        {
                            string[]      cellSplit = item.cell.Split(',');
                            List <string> cell      = cellSplit.ToList();

                            foreach (var val in cell)
                            {
                                var    celid = db.UnitworkccsTblshop.Where(m => m.ShopName == val).Select(m => m.ShopId).FirstOrDefault();
                                string ids   = celid + ",";
                                cellids = cellids + ids;
                            }
                            cellids = cellids.TrimStart(',');
                            cellids = cellids.TrimEnd(',');
                            tblEscalationMatrix.CellId = cellids;
                        }
                        //    tblEscalationMatrix.ContactNo = item.contactNo;
                        tblEscalationMatrix.EmployeeId   = db.UnitworkccsTbloperatordetails.Where(m => m.OperatorName == item.employeeName).Select(m => m.OpId).FirstOrDefault();
                        tblEscalationMatrix.EmployeeName = item.employeeName;
                        //   tblEscalationMatrix.MachineId = db.Tblmachinedetails.Where(m => m.MachineName == item.machineName).Select(m => m.MachineId).FirstOrDefault();
                        //  tblEscalationMatrix.MachineName = item.machineName;
                        tblEscalationMatrix.OpNo = item.employeeId;
                        //   tblEscalationMatrix.Role = item.role;
                        //  tblEscalationMatrix.RoleId = db.Tblroles.Where(m => m.RoleName == item.role).Select(m => m.RoleId).FirstOrDefault();
                        tblEscalationMatrix.Shift = item.shift;
                        // tblEscalationMatrix.ShiftId = db.TblshiftMstr.Where(m => m.ShiftName == item.shift).Select(m => m.ShiftId).FirstOrDefault();
                        tblEscalationMatrix.SmsPriority = item.smsPriority;
                        tblEscalationMatrix.SubCell     = item.subCell;
                        string subcellids = "";

                        if (string.IsNullOrEmpty(item.subCell))
                        {
                            tblEscalationMatrix.SubCellId = subcellids;
                        }
                        else
                        {
                            string[]      subcellSplit = item.subCell.Split(',');
                            List <string> subcell      = subcellSplit.ToList();

                            foreach (var val in subcell)
                            {
                                var    subcelid = db.UnitworkccsTblcell.Where(m => m.CellName == val).Select(m => m.CellId).FirstOrDefault();
                                string ids      = subcelid + ",";
                                subcellids = subcellids + ids;
                            }
                            subcellids = subcellids.TrimStart(',');
                            subcellids = subcellids.TrimEnd(',');

                            tblEscalationMatrix.SubCellId = subcellids;
                        }


                        //  tblEscalationMatrix.TimeToBeTriggered = timeToBeTriggered;
                        tblEscalationMatrix.IsDeleted = 0;
                        tblEscalationMatrix.CreatedOn = DateTime.Now;
                        db.UnitworkccsTblescalationmatrix.Add(tblEscalationMatrix);
                        db.SaveChanges();
                        obj.isStatus = true;
                        obj.response = ResourceResponse.AddedSuccessMessage;
                        // }
                    }

                    else

                    {
                        check.Category = item.category;

                        string idsss = "";
                        if (string.IsNullOrEmpty(item.category))
                        {
                            check.CategoryId = idsss;
                        }


                        else
                        {
                            string[]      catSlipt = item.category.Split(',');
                            List <string> catlist  = catSlipt.ToList();

                            foreach (var val in catlist)
                            {
                                var    catid = db.UnitworkccsTblcategorymaster.Where(m => m.CategoryName == val).Select(m => m.CategoryId).FirstOrDefault();
                                string ids   = catid + ",";
                                idsss = idsss + ids;
                            }
                            idsss            = idsss.TrimStart(',');
                            idsss            = idsss.TrimEnd(',');
                            check.CategoryId = idsss;
                        }

                        //  check.PlantId = data.plantId;
                        //  check.PlantCode = db.Tblplant.Where(m => m.PlantId == data.plantId).Select(m => m.PlantCode).FirstOrDefault();
                        check.Cell = item.cell;
                        string cellids = "";
                        if (string.IsNullOrEmpty(item.cell))
                        {
                            check.CellId = cellids;
                        }

                        else
                        {
                            string[]      cellSplit = item.cell.Split(',');
                            List <string> cell      = cellSplit.ToList();

                            foreach (var val in cell)
                            {
                                var    celid = db.UnitworkccsTblshop.Where(m => m.ShopName == val).Select(m => m.ShopId).FirstOrDefault();
                                string ids   = celid + ",";
                                cellids = cellids + ids;
                            }
                            cellids = cellids.TrimStart(',');
                            cellids = cellids.TrimEnd(',');

                            check.CellId = cellids;
                        }

                        //    check.ContactNo = data.contactNo;
                        check.EmployeeId   = db.UnitworkccsTbloperatordetails.Where(m => m.OperatorName == item.employeeName).Select(m => m.OpId).FirstOrDefault();
                        check.EmployeeName = item.employeeName;
                        check.OpNo         = item.employeeId;

                        check.Shift = item.shift;
                        //check.ShiftId = db.TblshiftMstr.Where(m => m.ShiftName == item.shift).Select(m => m.ShiftId).FirstOrDefault();
                        check.SmsPriority = item.smsPriority;

                        check.SubCell = item.subCell;
                        string subcellids = "";
                        if (string.IsNullOrEmpty(item.cell))
                        {
                            check.SubCellId = subcellids;
                        }
                        else
                        {
                            string[]      subcellSplit = item.subCell.Split(',');
                            List <string> subcell      = subcellSplit.ToList();

                            foreach (var val in subcell)
                            {
                                var    subcelid = db.UnitworkccsTblcell.Where(m => m.CellName == val).Select(m => m.CellId).FirstOrDefault();
                                string ids      = subcelid + ",";
                                subcellids = subcellids + ids;
                            }


                            subcellids      = subcellids.TrimStart(',');
                            subcellids      = subcellids.TrimEnd(',');
                            check.SubCellId = subcellids;
                        }
                        //    check.TimeToBeTriggered = timeToBeTriggered;
                        check.IsDeleted  = 0;
                        check.ModifiedOn = DateTime.Now;
                        db.SaveChanges();
                        obj.isStatus = true;
                        obj.response = ResourceResponse.UpdatedSuccessMessage;
                        //}
                    }
                }
            }
            catch (Exception e)
            {
                log.Error(e); if (e.InnerException != null)
                {
                    log.Error(e.InnerException.ToString());
                }
                obj.isStatus = false;
                obj.response = ResourceResponse.FailureMessage;
            }
            return(obj);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Add And Edit Escalation Matrix
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public CommonResponse AddAndEditEscalationMatrix(EscalationMatrixCustom data)
        {
            CommonResponse obj            = new CommonResponse();
            CommonFunction commonFunction = new CommonFunction();

            try
            {
                var check = db.UnitworkccsTblescalationmatrix.Where(m => m.OpNo == data.employeeId && m.EscalationId == data.escalationId && m.IsDeleted == 0).FirstOrDefault();
                if (check == null)
                {
                    UnitworkccsTblescalationmatrix tblEscalationMatrix = new UnitworkccsTblescalationmatrix();
                    // tblEscalationMatrix.Category = db.TblCategoryMaster.Where(m => m.CategoryId == data.categoryId).Select(m => m.CategoryName).FirstOrDefault();
                    tblEscalationMatrix.CategoryId = data.categoryId;
                    //  tblEscalationMatrix.PlantId = data.plantId;
                    // tblEscalationMatrix.PlantCode = db.Tblplant.Where(m => m.PlantId == data.plantId).Select(m => m.PlantCode).FirstOrDefault();
                    //  tblEscalationMatrix.Cell = db.Tblshop.Where(m => m.ShopId == data.cellId).Select(m => m.ShopName).FirstOrDefault();
                    tblEscalationMatrix.CellId = data.cellId;
                    // tblEscalationMatrix.ContactNo = data.contactNo;
                    tblEscalationMatrix.EmployeeId   = db.UnitworkccsTbloperatordetails.Where(m => m.OperatorName == data.emaployeeName).Select(m => m.OpId).FirstOrDefault();
                    tblEscalationMatrix.EmployeeName = data.emaployeeName;
                    //  tblEscalationMatrix.MachineId = data.machineId;
                    //  tblEscalationMatrix.MachineName = db.Tblmachinedetails.Where(m => m.MachineId == data.machineId).Select(m => m.MachineName).FirstOrDefault();
                    tblEscalationMatrix.OpNo = data.employeeId;
                    //  tblEscalationMatrix.Role = db.Tblroles.Where(m => m.RoleId == data.roleId).Select(m => m.RoleName).FirstOrDefault();
                    //  tblEscalationMatrix.RoleId = data.roleId;
                    tblEscalationMatrix.Shift = data.shift;
                    // tblEscalationMatrix.ShiftId = db.TblshiftMstr.Where(m => m.ShiftName == shift).Select(m => m.ShiftId).FirstOrDefault();
                    tblEscalationMatrix.SmsPriority = data.smsPriority;
                    //  tblEscalationMatrix.SubCell = db.Tblcell.Where(m => m.CellId == data.subCellId).Select(m => m.CellName).FirstOrDefault();
                    tblEscalationMatrix.SubCellId = data.subCellId;
                    //  tblEscalationMatrix.TimeToBeTriggered = timeToBeTriggered;
                    tblEscalationMatrix.IsDeleted = 0;
                    tblEscalationMatrix.CreatedOn = DateTime.Now;
                    db.UnitworkccsTblescalationmatrix.Add(tblEscalationMatrix);
                    db.SaveChanges();
                    obj.isStatus = true;
                    obj.response = ResourceResponse.AddedSuccessMessage;
                }
                else
                {
                    //  check.Category = db.TblCategoryMaster.Where(m => m.CategoryId == data.categoryId).Select(m => m.CategoryName).FirstOrDefault();
                    check.CategoryId = data.categoryId;



                    //  check.PlantId = data.plantId;
                    //  check.PlantCode = db.Tblplant.Where(m => m.PlantId == data.plantId).Select(m => m.PlantCode).FirstOrDefault();
                    // check.Cell = db.Tblshop.Where(m => m.ShopId == data.cellId).Select(m => m.ShopName).FirstOrDefault();
                    check.CellId = data.cellId;
                    //    check.ContactNo = data.contactNo;
                    check.EmployeeId   = db.UnitworkccsTbloperatordetails.Where(m => m.OperatorName == data.emaployeeName).Select(m => m.OpId).FirstOrDefault();
                    check.EmployeeName = data.emaployeeName;
                    //  check.MachineId = data.machineId;
                    //  check.MachineName = db.Tblmachinedetails.Where(m => m.MachineId == data.machineId).Select(m => m.MachineName).FirstOrDefault();
                    //  check.Role = db.Tblroles.Where(m => m.RoleId == data.roleId).Select(m => m.RoleName).FirstOrDefault();
                    //  check.RoleId = data.roleId;
                    check.Shift = data.shift;
                    // check.ShiftId = db.TblshiftMstr.Where(m => m.ShiftName == data.shift).Select(m => m.ShiftId).FirstOrDefault();
                    check.SmsPriority = data.smsPriority;
                    //  check.SubCell = db.Tblcell.Where(m => m.CellId == data.subCellId).Select(m => m.CellName).FirstOrDefault();
                    check.SubCellId = data.subCellId;
                    //    check.TimeToBeTriggered = timeToBeTriggered;
                    check.IsDeleted  = 0;
                    check.ModifiedOn = DateTime.Now;
                    db.SaveChanges();
                    obj.isStatus = true;
                    obj.response = ResourceResponse.UpdatedSuccessMessage;
                    //}
                }
            }
            catch (Exception e)
            {
                log.Error(e); if (e.InnerException != null)
                {
                    log.Error(e.InnerException.ToString());
                }
                obj.isStatus = false;
                obj.response = ResourceResponse.FailureMessage;
            }
            return(obj);
        }