Example #1
0
        public ActionResult Teachers_Read([DataSourceRequest] DataSourceRequest request)
        {
            DataSourceResult result = _teacherService.GetAll().ToDataSourceResult(request);

            return(Json(result));
        }
        public DataSourceResult _complianceDepartmentExcel([DataSourceRequest] DataSourceRequest request, Search search)
        {
            DataSourceResult result = new DataSourceResult();

            try
            {
                search.EndDate          = (search.EndDate != null && search.EndDate.ToString() != "") ? search.EndDate.Value.Date.AddHours(23).AddMinutes(29).AddSeconds(59) : search.EndDate;
                search.OrgTypeLevel1IDs = (search.OrgTypeLevel1IDs != null && search.OrgTypeLevel1IDs != "-1") ? search.OrgTypeLevel1IDs : "";
                search.OrgTypeLevel2IDs = (search.OrgTypeLevel2IDs != null && search.OrgTypeLevel2IDs != "-1") ? search.OrgTypeLevel2IDs : "";
                search.OrgTypeLevel3IDs = (search.OrgTypeLevel3IDs != null && search.OrgTypeLevel3IDs != "-1") ? search.OrgTypeLevel3IDs : "";

                List <ComplianceQuestionDetail> ComplianceQuestionDetailList = new List <ComplianceQuestionDetail>();
                DataTable dt = new DataTable();

                dt = ReportComplianceDepartment(search).Tables[0];

                object totalNum        = dt.Compute("Sum(Num)", "");
                object totalDen        = dt.Compute("Sum(Den)", "");
                object totalCompliance = (Convert.ToDecimal(totalNum) / Convert.ToDecimal(totalDen)) * 100;

                dt.Select().ToList <DataRow>().ForEach(r => { r["TotalNumerator"] = Convert.ToDecimal(totalNum); r["TotalDenominator"] = Convert.ToDecimal(totalDen); r["OverallCompliance"] = Convert.ToDecimal(totalCompliance); });

                ComplianceQuestionDetailList = dt.ToList <ComplianceQuestionDetail>();
                if (search.TracerListNames.Split(',').ToArray().Count() == 1)
                {
                    if (search.TracerListNames.Contains("All"))
                    {
                        ComplianceQuestionDetailList = ComplianceQuestionDetailList.OrderBy(i => i.OverallCompliance).ToList();
                    }
                    else
                    {
                        ComplianceQuestionDetailList = ComplianceQuestionDetailList.OrderBy(i => i.QuesNo).ToList();
                    }
                }
                else
                {
                    ComplianceQuestionDetailList = ComplianceQuestionDetailList.OrderBy(i => i.OverallCompliance).ToList();
                }
                result = ComplianceQuestionDetailList.ToDataSourceResult(request, cqc => new ComplianceQuestionDetail
                {
                    QuestionText      = cqc.QuestionText.ReplaceSpecialCharacters(),
                    TotalNumerator    = cqc.TotalNumerator,
                    TotalDenominator  = cqc.TotalDenominator,
                    OverallCompliance = cqc.OverallCompliance,
                    TracerCustomName  = cqc.TracerCustomName,
                    TracerSection     = cqc.TracerSection,
                    QuesNo            = cqc.QuesNo,
                    StandardEPs       = cqc.StandardEPs.ReplaceNewline(),
                    Observation       = cqc.Observation.ReplaceNewline(),
                    Num                  = cqc.Num,
                    Den                  = cqc.Den,
                    Compliance           = cqc.Compliance,
                    OrgName_Rank3        = cqc.OrgName_Rank3,
                    OrgName_Rank2        = cqc.OrgName_Rank2,
                    OrgName_Rank1_Dept   = cqc.OrgName_Rank1_Dept,
                    SurveyTeam           = cqc.SurveyTeam.ReplaceNewline(),
                    MedicalStaffInvolved = cqc.MedicalStaffInvolved.ReplaceNewline(),
                    Location             = cqc.Location.ReplaceNewline(),
                    MedicalRecordNumber  = cqc.MedicalRecordNumber.ReplaceNewline(),
                    EquipmentObserved    = cqc.EquipmentObserved.ReplaceNewline(),
                    ContractedService    = cqc.ContractedService.ReplaceNewline(),
                    StaffInterviewed     = cqc.StaffInterviewed.ReplaceNewline(),
                    TracerNote           = cqc.TracerNote.ReplaceNewline(),
                    UpdatedByName        = cqc.UpdatedByName,
                    ObservationDate      = cqc.ObservationDate,
                    LastUpdated          = cqc.LastUpdated,
                    QuestionNotes        = cqc.QuestionNotes.ReplaceNewline(),
                    QID                  = cqc.QID,
                    LimitDepartment      = cqc.LimitDepartment
                });
            }
            catch (Exception ex)
            {
                if (ex.Message.ToString() == "No Data")
                {
                    result.Errors = WebConstants.NO_DATA_FOUND_EXCEL_VIEW;
                }
                else if (ex.Message.ToString() == "Limit")
                {
                    result.Errors = "Maximum limit of " + ConfigurationManager.AppSettings["ReportOutputLimit"].ToString() + " records reached. Refine your criteria to narrow the result.";
                }

                if (ex.Message.ToString() != "No Data" && ex.Message.ToString() != "Limit")
                {
                    ExceptionLog exceptionLog = new ExceptionLog
                    {
                        ExceptionText = "Reports: " + ex.Message,
                        PageName      = "TracerComplianceDepartment",
                        MethodName    = "_ComplianceQuestionDepartmentExcel",
                        UserID        = Convert.ToInt32(AppSession.UserID),
                        SiteId        = Convert.ToInt32(AppSession.SelectedSiteId),
                        TransSQL      = "",
                        HttpReferrer  = null
                    };
                    _exceptionService.LogException(exceptionLog);
                }
            }


            return(result);
        }
Example #3
0
        public ActionResult Interventions_Read([DataSourceRequest] DataSourceRequest request, string filtreAnnee)
        {
            Nullable <DateTime> dateDebut;
            Nullable <DateTime> dateFin;

            MentoratNetCore.Extensions.CscExtensionsMethodes.AttribuerDateDebutDateFinAnneeFinanciereProjet(filtreAnnee, out dateDebut, out dateFin);

            List <Intervention> interventions;

            var strMessageDatasource = "";

            //on filtre selon l'année financière sélectionner par le combobox...par défaut on affiche tout.
            if (dateDebut == null || dateFin == null)
            {
                interventions        = db.Interventions.ToList();
                strMessageDatasource = "";
            }
            else
            {
                interventions        = db.Interventions.Where(b => b.Date_Intervention >= dateDebut && b.Date_Intervention <= dateFin).ToList();
                strMessageDatasource = "(" + DateTime.Parse(dateDebut.ToString()).ToShortDateString() + " au " + DateTime.Parse(dateFin.ToString()).ToShortDateString() + ")";
            }



            if (request.Groups.Count > 0)
            {
                GroupDescriptor monGroup = request.Groups.Where(g => g.Member == "No_Mentore_Intervention").FirstOrDefault();

                if (monGroup != null)
                {
                    monGroup.Member = "Mentore.NomComplet_Mentore";
                    // monGroup.SortDirection = System.ComponentModel.ListSortDirection.Ascending;
                    monGroup.DisplayContent = "No_Mentore_Intervention";
                }

                monGroup = request.Groups.Where(g => g.Member == "No_Mentor_Intervention").FirstOrDefault();

                if (monGroup != null)
                {
                    monGroup.Member         = "Mentor.NomCompletMentor";
                    monGroup.DisplayContent = "No_Mentor_Intervention";
                    //   monGroup.SortDirection = System.ComponentModel.ListSortDirection.Ascending;
                }
            }

            if (request.Sorts.Count == 0) // par défaut le tri est par la date
            {
                request.Sorts.Add(new SortDescriptor("Date_Intervention", ListSortDirection.Descending));
            }
            else
            {
                SortDescriptor monsort = request.Sorts.Where(w => w.Member == "No_Mentore_Intervention").FirstOrDefault();

                if (monsort != null)
                {//Le tri est la le combobox alors on va trier sur le nom du Mentore
                    var sort1 = new SortDescriptor("Mentore.NomComplet_Mentore", monsort.SortDirection);
                    request.Sorts.Insert(request.Sorts.IndexOf(monsort), sort1);
                }
                monsort = request.Sorts.Where(w => w.Member == "No_Mentor_Intervention").FirstOrDefault();

                if (monsort != null)
                {//Le tri est la le combobox alors on va trier sur le nom du Mentor
                    var sort1 = new SortDescriptor("Mentor.NomCompletMentor", monsort.SortDirection);
                    request.Sorts.Insert(request.Sorts.IndexOf(monsort), sort1);
                }
            }



            DataSourceResult result = interventions.ToDataSourceResult(request, intervention => new Intervention
            {
                No_Intervention        = intervention.No_Intervention,
                Date_Intervention      = intervention.Date_Intervention,
                No_Mentor_Intervention = intervention.No_Mentor_Intervention,
                Mentor = new Mentor
                {
                    NoMentor     = intervention.Mentor.NoMentor,
                    PrenomMentor = intervention.Mentor.PrenomMentor,
                    NomMentor    = intervention.Mentor.NomMentor
                },
                No_Mentore_Intervention = intervention.No_Mentore_Intervention,
                Mentore = new Mentore
                {
                    No_Mentore     = intervention.Mentore.No_Mentore,
                    Nom_Mentore    = intervention.Mentore.Nom_Mentore,
                    Prenom_Mentore = intervention.Mentore.Prenom_Mentore
                },
                Duree_Intervention       = intervention.Duree_Intervention,
                Description_Intervention = intervention.Description_Intervention
            });


            var resultModif = new MentoratNetCore.Extensions.KendoDataSourceResult(result);

            resultModif.MessageDataSource = strMessageDatasource;

            return(Json(resultModif));
        }
Example #4
0
 /// <summary>
 /// 生成反馈
 /// </summary>
 /// <param name="result">数据库查询结果</param>
 /// <returns></returns>
 public static Feedback ToFeedback(this DataSourceResult result)
 {
     return(Feedback.CreateList(result.Data, result.Total));
 }
Example #5
0
        public async Task <IActionResult> SeNames(DataSourceRequest command, UrlEntityListModel model)
        {
            bool?active = null;

            switch (model.SearchActiveId)
            {
            case 1:
                active = true;
                break;

            case 2:
                active = false;
                break;

            default:
                break;
            }
            var entityUrls = await _slugService.GetAllEntityUrl(model.SeName, active, command.Page - 1, command.PageSize);

            var items = new List <UrlEntityModel>();

            foreach (var x in entityUrls)
            {
                //language
                string languageName;
                if (String.IsNullOrEmpty(x.LanguageId))
                {
                    languageName = _translationService.GetResource("admin.configuration.senames.Language.Standard");
                }
                else
                {
                    var language = await _languageService.GetLanguageById(x.LanguageId);

                    languageName = language != null ? language.Name : "Unknown";
                }

                //details URL
                string detailsUrl = "";
                var    entityName = x.EntityName != null?x.EntityName.ToLowerInvariant() : "";

                switch (entityName)
                {
                case "brand":
                    detailsUrl = Url.Action("Edit", "Brand", new { id = x.EntityId, area = Constants.AreaAdmin });
                    break;

                case "blogpost":
                    detailsUrl = Url.Action("Edit", "Blog", new { id = x.EntityId, area = Constants.AreaAdmin });
                    break;

                case "category":
                    detailsUrl = Url.Action("Edit", "Category", new { id = x.EntityId, area = Constants.AreaAdmin });
                    break;

                case "collection":
                    detailsUrl = Url.Action("Edit", "Collection", new { id = x.EntityId, area = Constants.AreaAdmin });
                    break;

                case "product":
                    detailsUrl = Url.Action("Edit", "Product", new { id = x.EntityId, area = Constants.AreaAdmin });
                    break;

                case "newsitem":
                    detailsUrl = Url.Action("Edit", "News", new { id = x.EntityId, area = Constants.AreaAdmin });
                    break;

                case "page":
                    detailsUrl = Url.Action("Edit", "Page", new { id = x.EntityId, area = Constants.AreaAdmin });
                    break;

                case "vendor":
                    detailsUrl = Url.Action("Edit", "Vendor", new { id = x.EntityId, area = Constants.AreaAdmin });
                    break;

                case "course":
                    detailsUrl = Url.Action("Edit", "Course", new { id = x.EntityId, area = Constants.AreaAdmin });
                    break;

                case "knowledgebasecategory":
                    detailsUrl = Url.Action("EditCategory", "Knowledgebase", new { id = x.EntityId, area = Constants.AreaAdmin });
                    break;

                case "knowledgebasearticle":
                    detailsUrl = Url.Action("EditArticle", "Knowledgebase", new { id = x.EntityId, area = Constants.AreaAdmin });
                    break;

                default:
                    break;
                }

                items.Add(new UrlEntityModel {
                    Id         = x.Id,
                    Name       = x.Slug,
                    EntityId   = x.EntityId,
                    EntityName = x.EntityName,
                    IsActive   = x.IsActive,
                    Language   = languageName,
                    DetailsUrl = detailsUrl
                });
            }
            var gridModel = new DataSourceResult {
                Data  = items,
                Total = entityUrls.TotalCount
            };

            return(Json(gridModel));
        }
Example #6
0
        public virtual ActionResult HardwareList(DataSourceRequest command, HardwareListModel model)
        {
            if (string.IsNullOrEmpty(model.CustomerConnector) && model.Hardware_ID == 0 && model.Amount == 0 && string.IsNullOrEmpty(model.RequestDate) && string.IsNullOrEmpty(model.Description) && model.Status == 0 )
            {
                var hardwareItems = _hardwareService.GetAllHardware();
                var gridModel = new DataSourceResult
                {

                    Data = hardwareItems.Select(x => new HardwareModel
                    {
                        Amount = x.Amount,
                        CustomerName = _customerService.GetCustomerById(x.Customer_ID).CustomerName,
                        Hardware = _hardwareService.GetHardwareById(x.Hardware_ID).HardwareName,
                        CustomerConnector = x.CustomerConnector,
                        RequestDate = x.RequestDate,
                        Description = x.Description,
                        HardwareTypeDescription = _hardwareService.GetHardwareTypeById(x.Hardware_ID).Description,
                        DeliveryDate = x.DeliveryDate,
                        DeliveryDescription = x.DeliveryDescription,
                        DeliveryDeviceSerialNumber = x.DeliveryDeviceSerialNumber,
                        Check_Delivery = x.Status == 1 ? true : false,
                        Check_Revocation = x.Status == 2 ? true : false,
                        Customer_ID = x.Customer_ID,
                        Hardware_ID = x.Hardware_ID,
                        Request_ID = x.Request_ID

                    }),
                    Total = hardwareItems.Count()
                };

                return Json(gridModel);
            }
            else
            {
                var hardwareItems = _hardwareService.SearchHardware(model.CustomerConnector,model.Hardware_ID,model.RequestDate,model.Description,model.Status);
                var gridModel = new DataSourceResult
                {

                    Data = hardwareItems.Select(x => new HardwareModel
                    {
                        Amount = x.Amount,
                        CustomerName = _customerService.GetCustomerById(x.Customer_ID).CustomerName,
                        Hardware = _hardwareService.GetHardwareById(x.Hardware_ID).HardwareName,
                        CustomerConnector = x.CustomerConnector,
                        RequestDate = x.RequestDate,
                        Description = x.Description,
                        Customer_ID = x.Customer_ID,
                        Hardware_ID = x.Hardware_ID,
                        Request_ID = x.Request_ID,
                        HardwareTypeDescription = _hardwareService.GetHardwareTypeById(x.Hardware_ID).Description,
                        DeliveryDate = x.DeliveryDate,
                        DeliveryDescription = x.DeliveryDescription,
                        DeliveryDeviceSerialNumber = x.DeliveryDeviceSerialNumber,
                        Check_Delivery = x.Status == 1 ? true : false,
                        Check_Revocation = x.Status == 2 ? true : false,


                    }),
                    Total = hardwareItems.Count()
                };

                return Json(gridModel);
            }
        }
Example #7
0
        public ActionResult SubmitHardware(DataSourceRequest command, HardwareListModel model)
        {
            HttpSessionStateBase session = HttpContext.Session;
            try
            {
                if (false) // field validation
                {

                    var gridModel = new DataSourceResult
                    {
                        ExtraData = new HardwareListModel
                        {
                            Message = Message.InvalidCharacter,
                        },
                        Total = 1
                    };
                    return Json(gridModel);

                }

                Tbl_Hardware tu = new Tbl_Hardware();
                tu.Request_ID = model.Request_ID;
                tu.CustomerConnector = model.CustomerConnector;
                tu.Customer_ID = model.Customer_ID;
                tu.Description = model.Description;
                tu.Hardware_ID = model.Hardware_ID;
                tu.RequestDate = model.RequestDate;
                if (model.Check_Delivery && !model.Check_Revocation)
                    tu.Status = 1;
                else if (!model.Check_Delivery && model.Check_Revocation)
                    tu.Status = 2;
                else
                    tu.Status = 0;
                tu.DeliveryDate = model.DeliveryDate;
                tu.DeliveryDescription = model.DeliveryDescription;
                tu.DeliveryDeviceSerialNumber = model.DeliveryDeviceSerialNumber;
                tu.Amount = model.Amount;
                tu.LastUpdateUser_ID = Convert.ToInt32(session["UserID"]);
                tu.LastUpdateDate = DateTime.Now.ToString("yyyy-MM-dd");
                tu.LastUpdateTime = DateTime.Now.ToString("HH:mm");

                if (_hardwareService.AddNewHardware(tu))
                {
                    var gridModel = new DataSourceResult
                    {
                        ExtraData = new HardwareListModel
                        {
                            Message = Message.OperationSuccessful,
                            MessageColor = "green"
                        },
                        Total = 1
                    };
                    return Json(gridModel);
                }
                else
                {
                    var gridModel = new DataSourceResult
                    {
                        ExtraData = new HardwareListModel
                        {
                            Message = Message.OperationUnsuccessful,
                            MessageColor = "red"
                        },
                        Total = 1
                    };
                    return Json(gridModel);
                }


            }
            catch (Exception ex)
            {
                var gridModel = new DataSourceResult
                {
                    ExtraData = new HardwareListModel
                    {
                        Message = Message.OperationUnsuccessful,
                        MessageColor = "red"
                    },
                    Total = 1
                };
                return Json(gridModel);
            }
            //return "";
        }
Example #8
0
        public ActionResult InsertCustomer(CustomerModel model, string returnurl)
        {
            HttpSessionStateBase session = HttpContext.Session;

            try
            {
                if (model.Customer_ID == 0)
                {
                    // update process
                    Tbl_Customer tg = new Tbl_Customer();
                    tg.Address = model.Address;
                    tg.CompanyRegistrationName = model.CompanyRegistrationName;
                    tg.CustomerConnector       = model.CustomerConnector;
                    tg.CustomerField_ID        = model.CustomerField_ID;
                    tg.CustomerName            = model.CustomerName;
                    tg.EconomicalNumber        = model.EconomicalNumber;
                    tg.Email              = model.Email;
                    tg.FaxNo              = model.FaxNo;
                    tg.MobileNo           = model.MobileNo;
                    tg.NationalID         = model.NationalID;
                    tg.PostalCode         = model.PostalCode;
                    tg.RegistrationNumber = model.RegistrationNumber;
                    tg.SubscriptionCode   = model.SubscriptionCode;
                    tg.TelNo              = model.TelNo;
                    tg.Active             = model.IsActive_ID;
                    tg.LastUpdateUser_ID  = Convert.ToInt32(session["UserID"]);
                    tg.LastUpdateDate     = DateTime.Now.ToString("yyyy-MM-dd");
                    tg.LastUpdateTime     = DateTime.Now.ToString("HH:mm");
                    int res = _customerService.AddNewCustomer(tg, model.Customer_ID, model.IsActive_ID, model.CustomerField_ID);
                    if (res > 0)
                    {
                        var gridModel = new DataSourceResult
                        {
                            ExtraData = new CustomerListModel
                            {
                                Message          = Message.OperationSuccessful,
                                Customer_ID      = res,
                                SubscriptionCode = _customerService.GetCustomerById(res).SubscriptionCode,
                                MessageColor     = "green",
                            },
                            Total = 1
                        };
                        return(Json(gridModel));
                    }
                    else
                    {
                        var gridModel = new DataSourceResult
                        {
                            ExtraData = new CustomerListModel
                            {
                                Message      = Message.OperationUnsuccessful,
                                MessageColor = "red",
                            },
                            Total = 1
                        };
                        return(Json(gridModel));
                    }
                }
                else
                {
                    var gridModel = new DataSourceResult
                    {
                        ExtraData = new CustomerListModel
                        {
                            Message      = Message.OperationUnsuccessful,
                            MessageColor = "red",
                        },
                        Total = 1
                    };
                    return(Json(gridModel));
                }
            }
            catch (Exception ex)
            {
                var gridModel = new DataSourceResult
                {
                    ExtraData = new CustomerListModel
                    {
                        Message      = Message.OperationUnsuccessful,
                        MessageColor = "red",
                    },
                    Total = 1
                };
                return(Json(gridModel));
            }
        }
Example #9
0
        public virtual ActionResult CustomerList(DataSourceRequest command, CustomerListModel model)
        {
            if (string.IsNullOrEmpty(model.Address) && string.IsNullOrEmpty(model.CompanyRegistrationName) && string.IsNullOrEmpty(model.CustomerConnector) && string.IsNullOrEmpty(model.CustomerName) && string.IsNullOrEmpty(model.CompanyRegistrationName) && string.IsNullOrEmpty(model.EconomicalNumber) && string.IsNullOrEmpty(model.Email) && string.IsNullOrEmpty(model.FaxNo) && string.IsNullOrEmpty(model.MobileNo) && string.IsNullOrEmpty(model.NationalID) && string.IsNullOrEmpty(model.PostalCode) && string.IsNullOrEmpty(model.RegistrationNumber) && string.IsNullOrEmpty(model.SubscriptionCode) && string.IsNullOrEmpty(model.TelNo) && model.IsActive_ID == 0 && model.CustomerField_ID == 0)
            {
                var Items     = _customerService.GetAllCustomers();
                var gridModel = new DataSourceResult
                {
                    Data = Items.Select(x => new CustomerModel
                    {
                        TelNo                   = x.TelNo,
                        SubscriptionCode        = x.SubscriptionCode,
                        RegistrationNumber      = x.RegistrationNumber,
                        PostalCode              = x.PostalCode,
                        NationalID              = x.NationalID,
                        MobileNo                = x.MobileNo,
                        Address                 = x.Address,
                        CompanyRegistrationName = x.CompanyRegistrationName,
                        CustomerConnector       = x.CustomerConnector,
                        CustomerField_ID        = x.CustomerField_ID,
                        Field                   = _customerService.GetFieldById(x.CustomerField_ID).CustomerField_Name,
                        CustomerName            = x.CustomerName,
                        Customer_ID             = x.Customer_ID,
                        EconomicalNumber        = x.EconomicalNumber,
                        Email                   = x.Email,
                        FaxNo                   = x.FaxNo,
                        IsActive_ID             = x.Active,
                        IsActive                = _comm.GetLiteralByInt(x.Active),
                    }),
                    Total = Items.Count()
                };

                return(Json(gridModel));
            }
            else
            {
                //var UserItems = _groupService.SearchCustomer(model.GroupName, model.Description);
                var UserItems = _customerService.SearchCustomers(model.Address, model.CompanyRegistrationName, model.CustomerConnector, model.CustomerName, model.EconomicalNumber, model.Email, model.FaxNo, model.MobileNo, model.NationalID, model.PostalCode, model.RegistrationNumber, model.SubscriptionCode, model.TelNo, model.CustomerField_ID, model.IsActive_ID);
                var gridModel = new DataSourceResult
                {
                    Data = UserItems.Select(x => new CustomerModel
                    {
                        TelNo                   = x.TelNo,
                        SubscriptionCode        = x.SubscriptionCode,
                        RegistrationNumber      = x.RegistrationNumber,
                        PostalCode              = x.PostalCode,
                        NationalID              = x.NationalID,
                        MobileNo                = x.MobileNo,
                        Address                 = x.Address,
                        CompanyRegistrationName = x.CompanyRegistrationName,
                        CustomerConnector       = x.CustomerConnector,
                        CustomerField_ID        = x.CustomerField_ID,
                        CustomerName            = x.CustomerName,
                        Customer_ID             = x.Customer_ID,
                        EconomicalNumber        = x.EconomicalNumber,
                        Email                   = x.Email,
                        FaxNo                   = x.FaxNo,
                        IsActive_ID             = x.Active,
                        Field                   = _customerService.GetFieldById(x.CustomerField_ID).CustomerField_Name,
                        IsActive                = _comm.GetLiteralByInt(x.Active)
                    }),
                    Total = UserItems.Count()
                };

                return(Json(gridModel));
            }
        }
Example #10
0
        public async Task <IActionResult> BestsellersReportList(DataSourceRequest command, BestsellersReportModel model)
        {
            //a vendor should have access only to his products
            if (_workContext.CurrentVendor != null && !_workContext.CurrentCustomer.IsStaff())
            {
                model.VendorId = _workContext.CurrentVendor.Id;
            }

            if (_workContext.CurrentCustomer.IsStaff())
            {
                model.StoreId = _workContext.CurrentCustomer.StaffStoreId;
            }

            DateTime?startDateValue = (model.StartDate == null) ? null
                            : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.StartDate.Value, _dateTimeHelper.CurrentTimeZone);

            DateTime?endDateValue = (model.EndDate == null) ? null
                            : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.EndDate.Value, _dateTimeHelper.CurrentTimeZone).AddDays(1);

            OrderStatus?  orderStatus   = model.OrderStatusId > 0 ? (OrderStatus?)(model.OrderStatusId) : null;
            PaymentStatus?paymentStatus = model.PaymentStatusId > 0 ? (PaymentStatus?)(model.PaymentStatusId) : null;

            var items = await _orderReportService.BestSellersReport(
                createdFromUtc : startDateValue,
                createdToUtc : endDateValue,
                os : orderStatus,
                ps : paymentStatus,
                billingCountryId : model.BillingCountryId,
                orderBy : 2,
                vendorId : model.VendorId,
                pageIndex : command.Page - 1,
                pageSize : command.PageSize,
                showHidden : true,
                storeId : model.StoreId);

            var result = new List <BestsellersReportLineModel>();

            foreach (var x in items)
            {
                var m = new BestsellersReportLineModel
                {
                    ProductId     = x.ProductId,
                    TotalAmount   = _priceFormatter.FormatPrice(x.TotalAmount, true, false),
                    TotalQuantity = x.TotalQuantity,
                };
                var product = await _productService.GetProductById(x.ProductId);

                if (product != null)
                {
                    m.ProductName = product.Name;
                }
                if (_workContext.CurrentVendor != null)
                {
                    if (product.VendorId == _workContext.CurrentVendor.Id)
                    {
                        result.Add(m);
                    }
                }
                else
                {
                    result.Add(m);
                }
            }
            var gridModel = new DataSourceResult
            {
                Data  = result,
                Total = items.TotalCount
            };

            return(Json(gridModel));
        }
Example #11
0
        public async Task <IActionResult> OrderIncompleteReportList(DataSourceRequest command)
        {
            if (!await _permissionService.Authorize(StandardPermissionProvider.ManageOrders))
            {
                return(Content(""));
            }

            //a vendor does have access to this report
            if (_workContext.CurrentVendor != null && !_workContext.CurrentCustomer.IsStaff())
            {
                return(Content(""));
            }

            string storeId = "";

            if (_workContext.CurrentCustomer.IsStaff())
            {
                storeId = _workContext.CurrentCustomer.StaffStoreId;
            }


            var model = new List <OrderIncompleteReportLineModel>();
            //not paid
            var psPending = await _orderReportService.GetOrderAverageReportLine(storeId : storeId, ps : PaymentStatus.Pending, ignoreCancelledOrders : true);

            model.Add(new OrderIncompleteReportLineModel
            {
                Item     = _localizationService.GetResource("Admin.Reports.Incomplete.TotalUnpaidOrders"),
                Count    = psPending.CountOrders,
                Total    = _priceFormatter.FormatPrice(psPending.SumOrders, true, false),
                ViewLink = Url.Action("List", "Order", new { paymentStatusId = ((int)PaymentStatus.Pending).ToString() })
            });
            //not shipped
            var ssPending = await _orderReportService.GetOrderAverageReportLine(storeId : storeId, ss : ShippingStatus.NotYetShipped, ignoreCancelledOrders : true);

            model.Add(new OrderIncompleteReportLineModel
            {
                Item     = _localizationService.GetResource("Admin.Reports.Incomplete.TotalNotShippedOrders"),
                Count    = ssPending.CountOrders,
                Total    = _priceFormatter.FormatPrice(ssPending.SumOrders, true, false),
                ViewLink = Url.Action("List", "Order", new { shippingStatusId = ((int)ShippingStatus.NotYetShipped).ToString() })
            });
            //pending
            var osPending = await _orderReportService.GetOrderAverageReportLine(storeId : storeId, os : OrderStatus.Pending, ignoreCancelledOrders : true);

            model.Add(new OrderIncompleteReportLineModel
            {
                Item     = _localizationService.GetResource("Admin.Reports.Incomplete.TotalIncompleteOrders"),
                Count    = osPending.CountOrders,
                Total    = _priceFormatter.FormatPrice(osPending.SumOrders, true, false),
                ViewLink = Url.Action("List", "Order", new { orderStatusId = ((int)OrderStatus.Pending).ToString() })
            });

            var gridModel = new DataSourceResult
            {
                Data  = model,
                Total = model.Count
            };

            return(Json(gridModel));
        }
Example #12
0
        public async Task <IActionResult> RatesList(DataSourceRequest command)
        {
            var records = await _shippingByWeightService.GetAll(command.Page - 1, command.PageSize);

            var sbwModel = new List <ShippingByWeightModel>();

            foreach (var x in records)
            {
                var m = new ShippingByWeightModel
                {
                    Id                       = x.Id,
                    StoreId                  = x.StoreId,
                    WarehouseId              = x.WarehouseId,
                    ShippingMethodId         = x.ShippingMethodId,
                    CountryId                = x.CountryId,
                    From                     = x.From,
                    To                       = x.To,
                    AdditionalFixedCost      = x.AdditionalFixedCost,
                    PercentageRateOfSubtotal = x.PercentageRateOfSubtotal,
                    RatePerWeightUnit        = x.RatePerWeightUnit,
                    LowerWeightLimit         = x.LowerWeightLimit,
                };
                //shipping method
                var shippingMethod = await _shippingMethodService.GetShippingMethodById(x.ShippingMethodId);

                m.ShippingMethodName = (shippingMethod != null) ? shippingMethod.Name : "Unavailable";
                //store
                var store = await _storeService.GetStoreById(x.StoreId);

                m.StoreName = (store != null) ? store.Shortcut : "*";
                //warehouse
                var warehouse = await _warehouseService.GetWarehouseById(x.WarehouseId);

                m.WarehouseName = (warehouse != null) ? warehouse.Name : "*";
                //country
                var c = await _countryService.GetCountryById(x.CountryId);

                m.CountryName = (c != null) ? c.Name : "*";
                //state
                var s = c?.StateProvinces.FirstOrDefault(y => y.Id == x.StateProvinceId);
                m.StateProvinceName = (s != null) ? s.Name : "*";
                //zip
                m.Zip = (!String.IsNullOrEmpty(x.Zip)) ? x.Zip : "*";


                var htmlSb = new StringBuilder("<div>");
                htmlSb.AppendFormat("{0}: {1}", _translationService.GetResource("Plugins.Shipping.ByWeight.Fields.From"), m.From);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _translationService.GetResource("Plugins.Shipping.ByWeight.Fields.To"), m.To);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _translationService.GetResource("Plugins.Shipping.ByWeight.Fields.AdditionalFixedCost"), m.AdditionalFixedCost);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _translationService.GetResource("Plugins.Shipping.ByWeight.Fields.RatePerWeightUnit"), m.RatePerWeightUnit);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _translationService.GetResource("Plugins.Shipping.ByWeight.Fields.LowerWeightLimit"), m.LowerWeightLimit);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _translationService.GetResource("Plugins.Shipping.ByWeight.Fields.PercentageRateOfSubtotal"), m.PercentageRateOfSubtotal);

                htmlSb.Append("</div>");
                m.DataHtml = htmlSb.ToString();

                sbwModel.Add(m);
            }
            var gridModel = new DataSourceResult
            {
                Data  = sbwModel,
                Total = records.TotalCount
            };

            return(Json(gridModel));
        }
        public ActionResult AllOrders_Read([DataSourceRequest] DataSourceRequest request)
        {
            DataSourceResult result = this.orderService.All().To <OrdersViewModel>().ToList().OrderByDescending(x => x.Id).ToDataSourceResult(request);

            return(this.Json(result));
        }
Example #14
0
        public ActionResult PostList(DataSourceRequest command, PostListModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManagePosts))
            {
                return(AccessDeniedView());
            }


            var categoryIds = new List <int> {
                model.SearchCategoryId
            };

            //include subcategories
            if (model.SearchIncludeSubCategories && model.SearchCategoryId > 0)
            {
                categoryIds.AddRange(GetChildCategoryIds(model.SearchCategoryId));
            }

            //0 - all (according to "ShowHidden" parameter)
            //1 - published only
            //2 - unpublished only
            bool?overridePublished = null;

            if (model.SearchPublishedId == 1)
            {
                overridePublished = true;
            }
            else if (model.SearchPublishedId == 2)
            {
                overridePublished = false;
            }

            var posts = _postService.SearchPosts(
                categoryIds: categoryIds,
                keywords: model.SearchPostName,
                pageIndex: command.Page - 1,
                pageSize: command.PageSize,
                showHidden: true,
                overridePublished: overridePublished
                );
            var gridModel = new DataSourceResult();

            gridModel.Data = posts.Select(x =>
            {
                var postModel = x.ToModel();
                var createdBy = _customerService.GetCustomerById(x.CreatedBy);
                if (createdBy != null)
                {
                    postModel.CreatedByName = createdBy.Username;
                }

                var approvedBy = _customerService.GetCustomerById(x.ApprovedBy);
                if (approvedBy != null)
                {
                    postModel.ApprovedByName = approvedBy.Username;
                }

                postModel.CreatedOn = _dateTimeHelper.ConvertToUserTime(x.CreatedOnUtc);
                if (x.ApprovedOnUtc != null)
                {
                    postModel.ApprovedOn = _dateTimeHelper.ConvertToUserTime(x.ApprovedOnUtc.Value);
                }

                //little hack here:
                //ensure that post full descriptions are not returned
                //otherwise, we can get the following error if posts have too long descriptions:
                //"Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property. "
                //also it improves performance
                postModel.FullDescription = "";

                //picture
                var defaultPostPicture        = _pictureService.GetPicturesByPostId(x.Id, 1).FirstOrDefault();
                postModel.PictureThumbnailUrl = _pictureService.GetPictureUrl(defaultPostPicture, 75, true);
                return(postModel);
            });
            gridModel.Total = posts.TotalCount;

            return(Json(gridModel));
        }
        public async Task<IActionResult> SeNames(DataSourceRequest command, UrlRecordListModel model)
        {
            var urlRecords = await _urlRecordService.GetAllUrlRecords(model.SeName, command.Page - 1, command.PageSize);
            var items = new List<UrlRecordModel>();
            foreach (var x in urlRecords)
            {
                //language
                string languageName;
                if (String.IsNullOrEmpty(x.LanguageId))
                {
                    languageName = _localizationService.GetResource("Admin.System.SeNames.Language.Standard");
                }
                else
                {
                    var language = await _languageService.GetLanguageById(x.LanguageId);
                    languageName = language != null ? language.Name : "Unknown";
                }

                //details URL
                string detailsUrl = "";
                var entityName = x.EntityName != null ? x.EntityName.ToLowerInvariant() : "";
                switch (entityName)
                {
                    case "blogpost":
                        detailsUrl = Url.Action("Edit", "Blog", new { id = x.EntityId });
                        break;
                    case "category":
                        detailsUrl = Url.Action("Edit", "Category", new { id = x.EntityId });
                        break;
                    case "manufacturer":
                        detailsUrl = Url.Action("Edit", "Manufacturer", new { id = x.EntityId });
                        break;
                    case "product":
                        detailsUrl = Url.Action("Edit", "Product", new { id = x.EntityId });
                        break;
                    case "newsitem":
                        detailsUrl = Url.Action("Edit", "News", new { id = x.EntityId });
                        break;
                    case "topic":
                        detailsUrl = Url.Action("Edit", "Topic", new { id = x.EntityId });
                        break;
                    case "vendor":
                        detailsUrl = Url.Action("Edit", "Vendor", new { id = x.EntityId });
                        break;
                    case "course":
                        detailsUrl = Url.Action("Edit", "Course", new { id = x.EntityId });
                        break;
                    case "knowledgebasecategory":
                        detailsUrl = Url.Action("EditCategory", "Knowledgebase", new { id = x.EntityId });
                        break;
                    case "knowledgebasearticle":
                        detailsUrl = Url.Action("EditArticle", "Knowledgebase", new { id = x.EntityId });
                        break;
                    default:
                        break;
                }

                items.Add(new UrlRecordModel {
                    Id = x.Id,
                    Name = x.Slug,
                    EntityId = x.EntityId,
                    EntityName = x.EntityName,
                    IsActive = x.IsActive,
                    Language = languageName,
                    DetailsUrl = detailsUrl
                });

            }
            var gridModel = new DataSourceResult {
                Data = items,
                Total = urlRecords.TotalCount
            };
            return Json(gridModel);
        }
Example #16
0
        public DataSourceResult QuestionEPRelationExcel([DataSourceRequest] DataSourceRequest request, Search search)
        {
            DataSourceResult result = new DataSourceResult();

            try
            {
                SearchFormat sf = new SearchFormat();
                sf.CheckInputs(search);

                List <QuestionEpRelation> questionEPExcel = new List <QuestionEpRelation>();
                DataTable dt = new DataTable();

                dt = questionEPData(search).Tables[0];

                //convert datatable to list
                questionEPExcel = dt.ToList <QuestionEpRelation>();


                result = questionEPExcel.ToDataSourceResult(request, tc => new QuestionEpRelation
                {
                    TracerTemplateName      = tc.TracerTemplateName,
                    TemplateStatus          = tc.TemplateStatus,
                    TracerCustomName        = tc.TracerCustomName,
                    TracerStatusName        = tc.TracerStatusName,
                    SortOrder               = tc.SortOrder,
                    QuestionText            = tc.QuestionText,
                    StdEffectiveBeginDate   = tc.StdEffectiveBeginDate,
                    EPChangeStatus          = tc.EPChangeStatus,
                    ImpactOnQuestion        = tc.ImpactOnQuestion,
                    StdEPMappingToQuestion  = tc.StdEPMappingToQuestion,
                    EPTextMappingToQuestion = tc.EPTextMappingToQuestion,
                    ComparedStdEP           = tc.ComparedStdEP,
                    ComparedEPText          = tc.ComparedEPText,
                    EpChangeDescription     = tc.EpChangeDescription
                });
            }
            catch (Exception ex)
            {
                if (ex.Message.ToString() == "No Data")
                {
                    result.Errors = "No Data found matching your criteria.";
                }
                else if (ex.Message.ToString() == "Limit")
                {
                    result.Errors = "Maximum limit of " + ConfigurationManager.AppSettings["ReportOutputLimit"].ToString() + " records reached. Refine your criteria to narrow the result.";
                }


                if (ex.Message.ToString() != "No Data" && ex.Message.ToString() != "Limit")
                {
                    ExceptionLog exceptionLog = new ExceptionLog
                    {
                        ExceptionText = "Reports: " + ex.Message,
                        PageName      = "QuestionEPRelation",
                        MethodName    = "QuestionEPRelationExcel",
                        UserID        = Convert.ToInt32(AppSession.UserID),
                        SiteId        = Convert.ToInt32(AppSession.SelectedSiteId),
                        TransSQL      = "",
                        HttpReferrer  = null
                    };
                    _exceptionService.LogException(exceptionLog);
                }
            }

            return(result);
        }
Example #17
0
 public async Task CreateResultDataSourceAsync(DataSourceResult dataSourceResult)
 {
     _wpbDataContext.DataSourceResults.Add(dataSourceResult);
     await _wpbDataContext.SaveChangesAsync();
 }
Example #18
0
        public JsonResult Read([DataSourceRequest] DataSourceRequest request)
        {
            try
            {
                var empId      = Convert.ToInt64(Session[Constants.SessionEmpID]);
                var roleId     = Convert.ToInt32(Session[Constants.SessionRoleID]);
                var GetDetails = DB.Database.SqlQuery <ProjectMasterList>(
                    @"exec " + Constants.P_GetEmpTimesheet_ProjectMasterEntry + " @empId,@roleId",
                    new object[] {
                    new SqlParameter("@empId", empId),
                    new SqlParameter("@roleId", roleId)
                }).ToList();

                //var NewEnryModel = DB.NewEntry.Join(DB.ProjectMaster,x=>x.ProjectID,y=>y.ProjectID,(x,y)=>new { x.InvolveMonth,x.InvolvePercent}) .OrderBy(x => x.ProjectID).ToList();

                //var GetDetails = new List<ProjectMasterList>();
                //var list = (from x in DB.ProjectMaster
                //            join m in DB.MasterData on x.TypeofResearch equals m.MstID into researches
                //            from m in researches.DefaultIfEmpty()
                //            join re in DB.ResearchMaster on x.ResearchArea equals re.RsID into researchAreas
                //            from re in researchAreas.DefaultIfEmpty()
                //            join md in DB.MasterData on x.ProjectGrant equals md.MstID into projectGrants
                //            from md in projectGrants.DefaultIfEmpty()
                //            join co in DB.MasterData on x.CostCentre equals co.MstCode
                //            where x.IsActive
                //            select new { x.ProjectID, x.ProjectCode, x.ProjectName, x.ProjectDesc, x.InternalOrder, CostCenter = x.CostCentre, ProjectGrant = md.MstName, ResearchArea = re.RsDesc, x.StartDate, x.EndDate, x.IsActive ,  TypeOfResearch = m.MstName }).ToList();

                //if (roleId != 1)
                //{
                //    list = (from x in list
                //            join y in DB.ProjectEmployee on x.ProjectID equals y.ProjectID
                //            where y.CheckRole && y.EmployeeID == empId
                //            select x).ToList();
                //}

                //int i = 1;
                //foreach (var item in list)
                //{
                //    GetDetails.Add(new ProjectMasterList()
                //    {
                //        ProjectID = item.ProjectID,
                //        ProjectCode = item.ProjectCode,
                //        ProjectName = item.ProjectName,
                //        ProjectDesc = item.ProjectDesc,
                //        InternalOrder = item.InternalOrder,
                //        CostCentre = item.CostCenter,
                //        ProjectGrant = item.ProjectGrant,
                //        ResearchArea = item.ResearchArea,
                //        StartDate = item.StartDate.Value.ToString("dd MMM yyyy"),
                //        EndDate = item.EndDate.Value.ToString("dd MMM yyyy"),
                //        ItemNo = i++,
                //        TypeofResearch = item.TypeOfResearch
                //    });
                //}

                DataSourceResult result = GetDetails.ToDataSourceResult(request);
                return(Json(result));
            }
            catch (Exception ex)
            {
                LogHelper.ErrorLog(ex);
                throw ex;
            }
        }
Example #19
0
        public virtual ActionResult DeviceFailureList(DataSourceRequest command, DeviceFailureListModel model)
        {
            if (model.Customer_ID == 0 && string.IsNullOrEmpty(model.CustomerConnector) && string.IsNullOrEmpty(model.RequestDate) && model.ProblemType_ID == 0 && model.TroubleShooting_ID == 0 && string.IsNullOrEmpty(model.Reserve) && string.IsNullOrEmpty(model.Description))
            {
                var hardwareItems = _hardwareService.GetAllDeviceFailure();
                var gridModel = new DataSourceResult
                {

                    Data = hardwareItems.Select(x => new DeviceFailureModel
                    {
                       
                        CustomerName = _customerService.GetCustomerById(x.Customer_ID).CustomerName,
                        ProblemType = _ptypes.GetLiteralByInt(x.ProblemType),
                        CustomerConnector = x.CustomerConnector,
                         TroubleShooting_ID = x.Troubleshooting,
                          DeliveryDeviceSerialNumber = x.DeliveryDeviceSerialNumber,
                          DeliveryDate = x.DeliveryDate,
                          WarrantyPeriod = x.WarrantyPeriod,
                          TroubleShooting = _tsh.GetLiteralByInt(x.Troubleshooting),
                        RequestDate = x.RequestDate,
                        Description = x.Description,
                        Customer_ID = x.Customer_ID,
                        ProblemType_ID = x.ProblemType,
                        Request_ID = x.Request_ID


                    }),
                    Total = hardwareItems.Count()
                };

                return Json(gridModel);
            }
            else
            {
                var hardwareItems = _hardwareService.SearchDeviceFailure(model.CustomerConnector, model.RequestDate, model.ProblemType_ID, model.TroubleShooting_ID, model.Reserve, model.Description);
                var gridModel = new DataSourceResult
                {

                    Data = hardwareItems.Select(x => new DeviceFailureModel
                    {
                        CustomerName = _customerService.GetCustomerById(x.Customer_ID).CustomerName,
                        ProblemType = _ptypes.GetLiteralByInt(x.ProblemType),
                        CustomerConnector = x.CustomerConnector,
                        TroubleShooting_ID = x.Troubleshooting,
                        TroubleShooting = _tsh.GetLiteralByInt(x.Troubleshooting),
                        DeliveryDeviceSerialNumber = x.DeliveryDeviceSerialNumber,
                        DeliveryDate = x.DeliveryDate,
                        WarrantyPeriod = x.WarrantyPeriod,
                        RequestDate = x.RequestDate,
                        Description = x.Description,
                        Customer_ID = x.Customer_ID,
                        ProblemType_ID = x.ProblemType,
                        Request_ID = x.Request_ID


                    }),
                    Total = hardwareItems.Count()
                };

                return Json(gridModel);
            }
        }
Example #20
0
        public virtual ActionResult BrnIssueList(DataSourceRequest command, DqquebrnListModel model, string sort, string sortDir)
        {
            DateTime?startDateValue = (model.CreatedOnFrom == null) ? null
                : (DateTime?)model.CreatedOnFrom.Value;

            DateTime?endDateValue = (model.CreatedOnTo == null) ? null
                            : (DateTime?)model.CreatedOnTo.Value.AddDays(1);
            //startDateValue, endDateValue,

            IssueStatus?issueStatus = model.STATUS_CODE > 0 ? (IssueStatus?)(model.STATUS_CODE) : null;

            var identity = ((CustomPrincipal)User).CustomIdentity;

            int catalogId = model.CATALOG_ID;

            //var routeValues = System.Web.HttpContext.Current.Request.RequestContext.RouteData.Values;
            ////RouteValueDictionary routeValues;

            //int catalogId = 1;

            //if (routeValues.ContainsKey("id"))
            //    catalogId = int.Parse((string)routeValues["id"]);

            //if (Session["CATALOG_ID"] != null)
            //    catalogId = Convert.ToInt32(Session["CATALOG_ID"]);
            //else
            //    catalogId = model.CATALOG_ID;

            int[] corpCatalogs = { 61, 11, 12, 5, 21 };
            if (corpCatalogs.Contains(catalogId))
            {
                var items     = _dqQueService.GetAllCorpQueIssues(model.SearchName, catalogId, model.CUST_ID, model.RULE_ID, model.BRANCH_CODE, issueStatus, model.PRIORITY_CODE, command.Page - 1, command.PageSize, string.Format("{0} {1}", sort, sortDir));
                var gridModel = new DataSourceResult
                {
                    Data = items.Select(x => new DqquebrnListModel
                    {
                        CUST_ID             = x.CUST_ID,
                        RULE_NAME           = x.RULE_NAME,
                        ISSUE_STATUS_DESC   = x.MdmDQQueStatuses.STATUS_DESCRIPTION,
                        ISSUE_PRIORITY_DESC = x.MdmDQPriorities.PRIORITY_DESCRIPTION,
                        RUN_DATE            = x.RUN_DATE,
                        BRANCH_CODE         = x.BRANCH_CODE,
                        BRANCH_NAME         = x.BRANCH_NAME,
                        CREATED_DATE        = x.CREATED_DATE,
                        PRIORITY_CODE       = x.ISSUE_PRIORITY,
                        STATUS_CODE         = x.ISSUE_STATUS,
                        TIER               = x.TIER,
                        REASON             = x.REASON,
                        CATALOG_ID         = x.CATALOG_ID,
                        CATALOG_TABLE_NAME = x.CATALOG_TABLE_NAME,
                        AUTH_REJECT_REASON = x.AUTH_REJECT_REASON
                    }),
                    Total = items.TotalCount
                };
                return(Json(gridModel));
            }
            else
            {
                var items     = _dqQueService.GetAllBrnQueIssues(model.SearchName, catalogId, model.CUST_ID, model.RULE_ID, model.BRANCH_CODE, issueStatus, model.PRIORITY_CODE, model.TIER, command.Page - 1, command.PageSize, string.Format("{0} {1}", sort, sortDir));
                var gridModel = new DataSourceResult
                {
                    Data = items.Select(x => new DqquebrnListModel
                    {
                        CUST_ID             = x.CUST_ID,
                        RULE_NAME           = x.RULE_NAME,
                        ISSUE_STATUS_DESC   = x.MdmDQQueStatuses.STATUS_DESCRIPTION,
                        ISSUE_PRIORITY_DESC = x.MdmDQPriorities.PRIORITY_DESCRIPTION,
                        RUN_DATE            = x.RUN_DATE,
                        BRANCH_CODE         = x.BRANCH_CODE,
                        BRANCH_NAME         = x.BRANCH_NAME,
                        CREATED_DATE        = x.CREATED_DATE,
                        PRIORITY_CODE       = x.ISSUE_PRIORITY,
                        STATUS_CODE         = x.ISSUE_STATUS,
                        TIER               = x.TIER,
                        REASON             = x.REASON,
                        CATALOG_ID         = x.CATALOG_ID,
                        CATALOG_TABLE_NAME = x.CATALOG_TABLE_NAME,
                        AUTH_REJECT_REASON = x.AUTH_REJECT_REASON
                    }),
                    Total = items.TotalCount
                };

                return(Json(gridModel));
            }
        }
Example #21
0
        public ActionResult SubmitReturnRepairedDevice(ReturnRepairedDeviceModel model)
        {
            HttpSessionStateBase session = HttpContext.Session;
            try
            {

                Tbl_ReturnRepairedDevice tu = new Tbl_ReturnRepairedDevice();
                tu.Customer_ID = model.Customer_ID;
                tu.CustomerConnector = model.CustomerConnector;
                tu.DeviceSerialNumber = model.Reserve;
                tu.DeliveryDate = model.DeliveryDate;
                tu.WarrantyPeriod = model.WarrantyPeriod;
                tu.Repairs = model.Repairs;
                tu.ReturnDate = model.ReturnDate;
                tu.Description = model.Description;
                tu.Request_ID = model.Request_ID;
                tu.LastUpdateUser_ID = Convert.ToInt32(session["UserID"]);
                tu.LastUpdateDate = DateTime.Now.ToString("yyyy-MM-dd");
                tu.LastUpdateTime = DateTime.Now.ToString("HH:mm");

                if (_hardwareService.AddNewReturnRepairedDevice(tu))
                {
                    var gridModel = new DataSourceResult
                    {
                        ExtraData = new ReturnRepairedDeviceModel
                        {
                            Message = Message.OperationSuccessful,
                            MessageColor = "green"
                        },
                        Total = 1
                    };
                    return Json(gridModel);
                }
                else
                {
                    var gridModel = new DataSourceResult
                    {
                        ExtraData = new ReturnRepairedDeviceModel
                        {
                            Message = Message.OperationUnsuccessful,
                            MessageColor = "red"
                        },
                        Total = 1
                    };
                    return Json(gridModel);
                }

            }
            catch (Exception ex)
            {
                var gridModel = new DataSourceResult
                {
                    ExtraData = new ReturnRepairedDeviceModel
                    {
                        Message = Message.OperationUnsuccessful,
                        MessageColor = "red"
                    },
                    Total = 1
                };
                return Json(gridModel);
            }
            //return "";
        }
Example #22
0
        public virtual ActionResult AuthList(DataSourceRequest command, DqqueAuthListModel model, string sort, string sortDir)
        {
            DateTime?startDateValue = (model.CreatedOnFrom == null) ? null
                : (DateTime?)model.CreatedOnFrom.Value;

            DateTime?endDateValue = (model.CreatedOnTo == null) ? null
                            : (DateTime?)model.CreatedOnTo.Value.AddDays(1);
            //startDateValue, endDateValue,
            IssueStatus?issueStatus = model.STATUS_CODE > 0 ? (IssueStatus?)(model.STATUS_CODE) : null;

            var identity = ((CustomPrincipal)User).CustomIdentity;

            int catalogId = model.CATALOG_ID;

            int[] corpCatalogs = { 61, 11, 12, 5, 21 };
            if (corpCatalogs.Contains(catalogId))
            {
                var items     = _dqQueService.GetAllCorpUnAuthIssues(model.SearchName, model.CATALOG_ID, model.CUST_ID, model.RULE_ID, model.BRANCH_CODE.ToString(), issueStatus, model.PRIORITY_CODE, command.Page - 1, command.PageSize, string.Format("{0} {1}", sort, sortDir));
                var gridModel = new DataSourceResult
                {
                    Data = items.Select(x => new DqqueAuthListModel
                    {
                        EXCEPTION_ID        = x.EXCEPTION_ID,
                        CUST_ID             = x.CUST_ID,
                        RULE_NAME           = x.RULE_NAME,
                        BRANCH_CODE         = x.BRANCH_CODE,
                        ISSUE_STATUS_DESC   = x.ISSUE_STATUS_DESC,
                        ISSUE_PRIORITY_DESC = x.ISSUE_PRIORITY_DESC,
                        RUN_DATE            = x.RUN_DATE,
                        BRANCH_NAME         = x.BRANCH_NAME,
                        CREATED_DATE        = x.CREATED_DATE,
                        PRIORITY_CODE       = x.ISSUE_PRIORITY,
                        STATUS_CODE         = x.ISSUE_STATUS,
                        REASON             = x.REASON,
                        FIRSTNAME          = x.FIRST_NAME,
                        SURNAME            = x.SURNAME,
                        OTHERNAME          = x.OTHERNAME,
                        CATALOG_ID         = x.CATALOG_ID,
                        CATALOG_TABLE_NAME = x.CATALOG_TABLE_NAME
                    }),
                    Total = items.TotalCount
                };

                return(Json(gridModel));
            }
            else
            {
                var items     = _dqQueService.GetAllBrnUnAuthIssues(model.SearchName, model.CATALOG_ID, model.CUST_ID, model.RULE_ID, model.BRANCH_CODE.ToString(), issueStatus, model.PRIORITY_CODE, model.TIER, command.Page - 1, command.PageSize, string.Format("{0} {1}", sort, sortDir));
                var gridModel = new DataSourceResult
                {
                    Data = items.Select(x => new DqqueAuthListModel
                    {
                        EXCEPTION_ID        = x.EXCEPTION_ID,
                        CUST_ID             = x.CUST_ID,
                        RULE_NAME           = x.RULE_NAME,
                        BRANCH_CODE         = x.BRANCH_CODE,
                        ISSUE_STATUS_DESC   = x.ISSUE_STATUS_DESC,
                        ISSUE_PRIORITY_DESC = x.ISSUE_PRIORITY_DESC,
                        RUN_DATE            = x.RUN_DATE,
                        BRANCH_NAME         = x.BRANCH_NAME,
                        CREATED_DATE        = x.CREATED_DATE,
                        PRIORITY_CODE       = x.ISSUE_PRIORITY,
                        STATUS_CODE         = x.ISSUE_STATUS,
                        REASON             = x.REASON,
                        FIRSTNAME          = x.FIRST_NAME,
                        SURNAME            = x.SURNAME,
                        OTHERNAME          = x.OTHERNAME,
                        CATALOG_ID         = x.CATALOG_ID,
                        CATALOG_TABLE_NAME = x.CATALOG_TABLE_NAME
                    }),
                    Total = items.TotalCount
                };

                return(Json(gridModel));
            }
        }
Example #23
0
        public virtual ActionResult OrderList(DataSourceRequest command, Admin.Models.Orders.OrderListModel model)
        {
            var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext);
            var amazonSettings = _settingService.LoadSetting<OrderAmazonSettings>(storeScope);
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageOrders))
                return AccessDeniedKendoGridJson();

            //a vendor should have access only to his products
            if (_workContext.CurrentVendor != null)
            {
                model.VendorId = _workContext.CurrentVendor.Id;
            }

            DateTime? startDateValue = (model.StartDate == null) ? null
                            : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.StartDate.Value, _dateTimeHelper.CurrentTimeZone);

            DateTime? endDateValue = (model.EndDate == null) ? null
                            : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.EndDate.Value, _dateTimeHelper.CurrentTimeZone).AddDays(1);

            var orderStatusIds = !model.OrderStatusIds.Contains(0) ? model.OrderStatusIds : null;
            var paymentStatusIds = !model.PaymentStatusIds.Contains(0) ? model.PaymentStatusIds : null;
            var shippingStatusIds = !model.ShippingStatusIds.Contains(0) ? model.ShippingStatusIds : null;

            var filterByProductId = 0;
            var product = _productService.GetProductById(model.ProductId);
            if (product != null && HasAccessToProduct(product))
                filterByProductId = model.ProductId;

            //load orders
            var orders = _orderAmazonService.SearchOrders(storeId: model.StoreId,
                vendorId: model.VendorId,
                productId: filterByProductId,
                warehouseId: model.WarehouseId,
                paymentMethodSystemName: model.PaymentMethodSystemName,
                createdFromUtc: startDateValue,
                createdToUtc: endDateValue,
                osIds: orderStatusIds,
                psIds: paymentStatusIds,
                ssIds: shippingStatusIds,
                billingEmail: model.BillingEmail,
                billingLastName: model.BillingLastName,
                billingCountryId: model.BillingCountryId,
                orderNotes: model.OrderNotes,
                pageIndex: command.Page - 1,
                pageSize: command.PageSize);
            var gridModel = new DataSourceResult
            {
                Data = orders.Select(x =>
                {
                    var store = _storeService.GetStoreById(x.StoreId);
                    return new OrderModel
                    {
                        Id = x.Id,
                        StoreName = store != null ? store.Name : "Unknown",
                        OrderTotal = _priceFormatter.FormatPrice(x.OrderTotal, true, false),
                        OrderStatus = x.OrderStatus.GetLocalizedEnum(_localizationService, _workContext),
                        OrderStatusId = x.OrderStatusId,
                        PaymentStatus = x.PaymentStatus.GetLocalizedEnum(_localizationService, _workContext),
                        PaymentStatusId = x.PaymentStatusId,
                        ShippingStatus = x.ShippingStatus.GetLocalizedEnum(_localizationService, _workContext),
                        ShippingStatusId = x.ShippingStatusId,
                        CustomerEmail = x.BillingAddress.Email,
                        CustomerFullName = string.Format("{0} {1}", x.BillingAddress.FirstName, x.BillingAddress.LastName),
                        CreatedOn = _dateTimeHelper.ConvertToUserTime(x.CreatedOnUtc, DateTimeKind.Utc),
                        CustomOrderNumber = x.CustomOrderNumber,

                        OrderAmazon = _orderAmazonService.GetOrderAmazonByOrderId(x.Id)
                    };
                }),
                Total = orders.TotalCount
            };

            //summary report
            //currently we do not support productId and warehouseId parameters for this report
            var reportSummary = _orderReportService.GetOrderAverageReportLine(
                storeId: model.StoreId,
                vendorId: model.VendorId,
                orderId: 0,
                paymentMethodSystemName: model.PaymentMethodSystemName,
                osIds: orderStatusIds,
                psIds: paymentStatusIds,
                ssIds: shippingStatusIds,
                startTimeUtc: startDateValue,
                endTimeUtc: endDateValue,
                billingEmail: model.BillingEmail,
                billingLastName: model.BillingLastName,
                billingCountryId: model.BillingCountryId,
                orderNotes: model.OrderNotes);

            var profit = _orderReportService.ProfitReport(
                storeId: model.StoreId,
                vendorId: model.VendorId,
                paymentMethodSystemName: model.PaymentMethodSystemName,
                osIds: orderStatusIds,
                psIds: paymentStatusIds,
                ssIds: shippingStatusIds,
                startTimeUtc: startDateValue,
                endTimeUtc: endDateValue,
                billingEmail: model.BillingEmail,
                billingLastName: model.BillingLastName,
                billingCountryId: model.BillingCountryId,
                orderNotes: model.OrderNotes);
            var primaryStoreCurrency = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId);
            if (primaryStoreCurrency == null)
                throw new Exception("Cannot load primary store currency");

            gridModel.ExtraData = new Admin.Models.Orders.OrderAggreratorModel
            {
                aggregatorprofit = _priceFormatter.FormatPrice(profit, true, false),
                aggregatorshipping = _priceFormatter.FormatShippingPrice(reportSummary.SumShippingExclTax, true, primaryStoreCurrency, _workContext.WorkingLanguage, false),
                aggregatortax = _priceFormatter.FormatPrice(reportSummary.SumTax, true, false),
                aggregatortotal = _priceFormatter.FormatPrice(reportSummary.SumOrders, true, false)
            };

            return Json(gridModel);
        }
Example #24
0
        public DataSourceResult _taskReportExcel([DataSourceRequest] DataSourceRequest request, SearchTaskReport search)
        {
            DataSourceResult result = new DataSourceResult();

            try
            {
                List <TaskReportExcelView> TaskReportExcelList = new List <TaskReportExcelView>();
                DataTable dt = new DataTable();

                dt = TaskReportData(search).Tables[0];

                TaskReportExcelList = dt.ToList <TaskReportExcelView>();

                result = TaskReportExcelList.ToDataSourceResult(request, cqc => new TaskReportExcelView
                {
                    StatusName         = cqc.StatusName,
                    TaskID             = cqc.TaskID,
                    TaskName           = cqc.TaskName,
                    TaskDescription    = cqc.TaskDescription,
                    AssignedBy         = cqc.AssignedBy,
                    AssignedTo         = cqc.AssignedTo,
                    CcedTo             = cqc.CcedTo,
                    AssignedDate       = cqc.AssignedDate,
                    DueDate            = cqc.DueDate,
                    CompleteDate       = cqc.CompleteDate,
                    TaskResolution     = cqc.TaskResolution,
                    StandardEp         = cqc.StandardEp.ReplaceNewline(),
                    CmsStandard        = cqc.CmsStandard,
                    TracerCustomName   = cqc.TracerCustomName,
                    QuestionText       = cqc.QuestionText.ReplaceNewline(),
                    Observation        = cqc.Observation.ReplaceNewline(),
                    OrgName_Rank3      = cqc.OrgName_Rank3,
                    OrgName_Rank2      = cqc.OrgName_Rank2,
                    OrgName_Rank1_Dept = cqc.OrgName_Rank1_Dept
                });
            }
            catch (Exception ex)
            {
                if (ex.Message.ToString() == "No Data")
                {
                    result.Errors = WebConstants.NO_DATA_FOUND_TASK_REPORT;
                }
                else if (ex.Message.ToString() == "Limit")
                {
                    result.Errors = "Maximum limit of " + ConfigurationManager.AppSettings["ReportOutputLimit"].ToString() + " records reached. Refine your criteria to narrow the result.";
                }

                if (ex.Message.ToString() != "No Data" && ex.Message.ToString() != "Limit")
                {
                    ExceptionLog exceptionLog = new ExceptionLog
                    {
                        ExceptionText = "Reports: " + ex.Message,
                        PageName      = "TracerComplianceQuestion",
                        MethodName    = "_ComplianceQuestionDetailExcel",
                        UserID        = Convert.ToInt32(AppSession.UserID),
                        SiteId        = Convert.ToInt32(AppSession.SelectedSiteId),
                        TransSQL      = "",
                        HttpReferrer  = null
                    };
                    _exceptionService.LogException(exceptionLog);
                }
            }
            return(result);
        }
Example #25
0
        public DataSourceResult _saveandscheduledReportsExcel([DataSourceRequest] DataSourceRequest request, SearchSavedReportsInput search, int EProductID = 1)
        {
            DataSourceResult result = new DataSourceResult();

            try
            {
                //System.Diagnostics.Debug.WriteLine("EProductID:" + EProductID);
                //System.Diagnostics.Debug.WriteLine("AppSession.LinkType:" + AppSession.LinkType);
                //System.Diagnostics.Debug.WriteLine("AppSession.PageID:" + AppSession.PageID);

                List <SaveandScheduledDetails> SaveandScheduledDetailsList = new List <SaveandScheduledDetails>();
                DataTable dt = new DataTable();

                if (EProductID == (int)WebConstants.ProductID.TracerER || AppSession.LinkType == (int)WebConstants.LinkType.AMPCorporateReports || AppSession.LinkType == (int)WebConstants.LinkType.AmpHome)
                {
                    List <int> siteIDList = new List <int>();

                    int eProductId;
                    int ERReportCategoryID;
                    if (AppSession.LinkType == (int)WebConstants.LinkType.AMPCorporateReports || AppSession.LinkType == (int)WebConstants.LinkType.AmpHome)
                    {
                        // Mark Orlando: It appears AMP Reports should go through here.
                        siteIDList         = AppSession.Sites.Select(m => m.SiteID).ToList();
                        eProductId         = (int)WebConstants.ProductID.AMP;
                        ERReportCategoryID = (int)WebConstants.ReportCategoryID.AMP;
                    }
                    else
                    {
                        // M.Orlando 09/27/2017: Updated for TEN
                        siteIDList = AppSession.Sites.Where(m => m.RoleID.In((int)(WebConstants.Role.ProgramAdministrator),
                                                                             (int)(WebConstants.Role.MockSurveyUser),
                                                                             (int)(WebConstants.Role.MockSurveyReviewer))).Select(m => m.SiteID).ToList();
                        eProductId         = (int)WebConstants.ProductID.TracerER;
                        ERReportCategoryID = (int)WebConstants.ReportCategoryID.TracerER;
                    }
                    // Mark Orlando: Requests to get ER Tracer Reports runs here and executes SP ustReport_GetSavedandScheduledERReports.
                    dt = ERSearchSaveandScheduleddataset(string.Join(",", siteIDList.ToArray()), search.SearchSelectedSites == null ? string.Join(",", siteIDList.ToArray()) : search.SearchSelectedSites, eProductId, ERReportCategoryID).Tables[0];
                }
                else
                {
                    // Mark Orlando: Requests to get Tracer Reports runs here and executes SP ustReport_GetSavedandScheduledReports.
                    dt = SaveandScheduleddataset(EProductID).Tables[0];
                }
                SaveandScheduledDetailsList = dt.ToList <SaveandScheduledDetails>();

                // to do filter data
                if (search.MyReportsView)
                {
                    SaveandScheduledDetailsList = SaveandScheduledDetailsList.Where(s => s.UserID == AppSession.UserID).ToList();
                }
                else
                {
                    if (search.ReportUserScheduleID > 0)
                    {
                        SaveandScheduledDetailsList = SaveandScheduledDetailsList.Where(s => s.ERReportUserScheduleID == search.ReportUserScheduleID).ToList();
                    }
                    else if (search.ERMyReportIDs != null && search.ERMyReportIDs != "-1" && search.ERMyReportIDs != "")
                    {
                        SaveandScheduledDetailsList = SaveandScheduledDetailsList.Where(s => GetSearchIds(search.ERMyReportIDs)
                                                                                        .Contains(s.ERReportUserScheduleID.ToString()))
                                                      .ToList();
                    }
                    else
                    {
                        search.CreatedByIDs    = (search.CreatedByIDs != null && search.CreatedByIDs != "-1") ? search.CreatedByIDs : "";
                        search.ERReportIDs     = (search.ERReportIDs != null && search.ERReportIDs != "-1") ? search.ERReportIDs : "";
                        search.ERRecurrenceIDs = (search.ERRecurrenceIDs != null && search.ERRecurrenceIDs != "-1") ? search.ERRecurrenceIDs : "";
                        // filter by user
                        if (!String.IsNullOrEmpty(search.CreatedByIDs))
                        {
                            SaveandScheduledDetailsList = SaveandScheduledDetailsList.Where(s => GetSearchIds(search.CreatedByIDs)
                                                                                            .Contains(s.UserID.ToString()))
                                                          .ToList();
                        }

                        // filter by Report Name
                        if (!String.IsNullOrEmpty(search.ERReportIDs))
                        {
                            SaveandScheduledDetailsList = SaveandScheduledDetailsList.Where(s => GetSearchIds(search.ERReportIDs)
                                                                                            .Contains(s.ERReportID.ToString()))
                                                          .ToList();
                        }

                        // filter by Report Frequency / Schedule Type
                        if (!String.IsNullOrEmpty(search.ERRecurrenceIDs))
                        {
                            SaveandScheduledDetailsList = SaveandScheduledDetailsList.Where(s => GetSearchIds(search.ERRecurrenceIDs)
                                                                                            .Contains(s.ERScheduleTypeID.ToString()))
                                                          .ToList();
                        }

                        // filter by Create Date
                        if (search.CreateDateFrom.HasValue && search.CreateDateFrom.Value > DateTime.MinValue)
                        {
                            DateTime maxDate = DateTime.MaxValue;
                            if (search.CreateDateTo.HasValue)
                            {
                                maxDate = search.CreateDateTo.Value.AddDays(1).Date;
                            }
                            SaveandScheduledDetailsList = SaveandScheduledDetailsList.Where(s =>
                                                                                            s.CreateDate >= search.CreateDateFrom && s.CreateDate < maxDate)
                                                          .ToList();
                        }
                    }
                }

                result = SaveandScheduledDetailsList.ToDataSourceResult(request, cqc => new SaveandScheduledDetails
                {
                    ERReportUserScheduleID = cqc.ERReportUserScheduleID,
                    ERReportID             = cqc.ERReportID,
                    UserID = cqc.UserID,
                    ERReportScheduleStatusID = cqc.ERReportScheduleStatusID,
                    EmailTo            = cqc.EmailTo,
                    LastRundate        = cqc.LastRundate,
                    LastRunStatus      = cqc.LastRunStatus,
                    ReportNameOverride = cqc.ReportNameOverride,
                    ReportDescription  = cqc.ReportDescription,
                    ERScheduleTypeID   = cqc.ERScheduleTypeID,
                    NextRunScheduled   = cqc.NextRunScheduled,
                    CreateDate         = cqc.CreateDate,
                    UpdateDate         = cqc.UpdateDate,
                    ERReportName       = cqc.ERReportName,
                    SiteID             = cqc.SiteID,
                    FirstName          = cqc.FirstName,
                    LastName           = cqc.LastName,
                    CreatedBy          = cqc.FirstName.ToString() + " " + cqc.LastName.ToString(),
                    UpdatedBy          = cqc.UpdateByUserFirstName.ToString() + " " + cqc.UpdateByUserLastName.ToString(),
                    UpdateByUserID     = cqc.UpdateByUserID,
                    //  UpdateByUserFirstName = cqc.UpdateByUserFirstName,
                    // UpdateByUserLastName = cqc.UpdateByUserLastName,
                    CC                                = cqc.CC,
                    BCC                               = cqc.BCC,
                    ReplyTo                           = cqc.ReplyTo,
                    Subject                           = cqc.Subject,
                    RenderFormatTypeID                = cqc.RenderFormatTypeID,
                    Comment                           = cqc.Comment,
                    ERReportScheduleStatusName        = cqc.ERReportScheduleStatusName,
                    ERReportScheduleStatusDescription = cqc.ERReportScheduleStatusDescription == "Complete" ? "None" : cqc.ERReportScheduleStatusDescription,
                    ERScheduleName                    = cqc.ERScheduleName,
                    ERScheduleDescription             = cqc.ERScheduleDescription == "One-time" ? "None" : cqc.ERScheduleDescription,
                    LastRunMessage                    = cqc.LastRunMessage == "" ? "None" : cqc.LastRunMessage,
                    ReportSource                      = cqc.ReportSource,
                });
            }
            catch (Exception ex)
            {
                if (ex.Message.ToString() == "No Data")
                {
                    result.Errors = WebConstants.NO_DATA_FOUND_EXCEL_VIEW;
                }
                else if (ex.Message.ToString() == "Limit")
                {
                    result.Errors = "Maximum limit of " + ConfigurationManager.AppSettings["ReportOutputLimit"].ToString() + " records reached. Refine your criteria to narrow the result.";
                }

                if (ex.Message.ToString() != "No Data" && ex.Message.ToString() != "Limit")
                {
                    ExceptionLog exceptionLog = new ExceptionLog
                    {
                        ExceptionText = "Reports: " + ex.Message,
                        PageName      = "_saveandscheduledReportsExcel",
                        MethodName    = "_saveandscheduledReportsExcel",
                        UserID        = Convert.ToInt32(AppSession.UserID),
                        SiteId        = Convert.ToInt32(AppSession.SelectedSiteId),
                        TransSQL      = "",
                        HttpReferrer  = null
                    };
                    _exceptionService.LogException(exceptionLog);
                }
            }


            return(result);
        }
        public async Task <ApiResult <DataSourceResult> > GetUsers([DataSourceRequest] DataSourceRequest request)
        {
            DataSourceResult dataResult = await _userManager.GetAllUsersWithRoles().ToDataSourceResultAsync(request);

            return(Ok(dataResult));
        }
Example #27
0
        public IActionResult RateByWeightByTotalList(DataSourceRequest command, ConfigurationModel filter)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings))
            {
                return(AccessDeniedKendoGridJson());
            }

            //var records = _shippingByWeightService.GetAll(command.Page - 1, command.PageSize);
            Core.IPagedList <ShippingByWeightByTotalRecord> records = _shippingByWeightService.FindRecords(
                pageIndex: command.Page - 1,
                pageSize: command.PageSize,
                storeId: filter.SearchStoreId,
                warehouseId: filter.SearchWarehouseId,
                countryId: filter.SearchCountryId,
                stateProvinceId: filter.SearchStateProvinceId,
                zip: filter.SearchZip,
                shippingMethodId: filter.SearchShippingMethodId,
                weight: null,
                orderSubtotal: null
                );

            List <ShippingByWeightByTotalModel> sbwModel = records.Select(record => {
                ShippingByWeightByTotalModel model = new ShippingByWeightByTotalModel {
                    Id                       = record.Id,
                    StoreId                  = record.StoreId,
                    StoreName                = _storeService.GetStoreById(record.StoreId)?.Name ?? "*",
                    WarehouseId              = record.WarehouseId,
                    WarehouseName            = _shippingService.GetWarehouseById(record.WarehouseId)?.Name ?? "*",
                    ShippingMethodId         = record.ShippingMethodId,
                    ShippingMethodName       = _shippingService.GetShippingMethodById(record.ShippingMethodId)?.Name ?? "Unavailable",
                    CountryId                = record.CountryId,
                    CountryName              = _countryService.GetCountryById(record.CountryId)?.Name ?? "*",
                    StateProvinceId          = record.StateProvinceId,
                    StateProvinceName        = _stateProvinceService.GetStateProvinceById(record.StateProvinceId)?.Name ?? "*",
                    WeightFrom               = record.WeightFrom,
                    WeightTo                 = record.WeightTo,
                    OrderSubtotalFrom        = record.OrderSubtotalFrom,
                    OrderSubtotalTo          = record.OrderSubtotalTo,
                    AdditionalFixedCost      = record.AdditionalFixedCost,
                    PercentageRateOfSubtotal = record.PercentageRateOfSubtotal,
                    RatePerWeightUnit        = record.RatePerWeightUnit,
                    LowerWeightLimit         = record.LowerWeightLimit,
                    Zip                      = !string.IsNullOrEmpty(record.Zip) ? record.Zip : "*",
                    MontoDolar               = record.MontoDolar
                };

                StringBuilder htmlSb = new StringBuilder("<div>");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.FixedByWeightByTotal.Fields.WeightFrom"), model.WeightFrom);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.FixedByWeightByTotal.Fields.WeightTo"), model.WeightTo);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.FixedByWeightByTotal.Fields.OrderSubtotalFrom"), model.OrderSubtotalFrom);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.FixedByWeightByTotal.Fields.OrderSubtotalTo"), model.OrderSubtotalTo);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.FixedByWeightByTotal.Fields.AdditionalFixedCost"), model.AdditionalFixedCost);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.FixedByWeightByTotal.Fields.RatePerWeightUnit"), model.RatePerWeightUnit);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.FixedByWeightByTotal.Fields.LowerWeightLimit"), model.LowerWeightLimit);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.FixedByWeightByTotal.Fields.PercentageRateOfSubtotal"), model.PercentageRateOfSubtotal);

                htmlSb.Append("</div>");
                model.DataHtml = htmlSb.ToString();

                return(model);
            }).ToList();

            DataSourceResult gridModel = new DataSourceResult {
                Data  = sbwModel,
                Total = records.TotalCount
            };

            return(Json(gridModel));
        }
Example #28
0
        public ActionResult SeNames(DataSourceRequest command, UrlRecordListModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance))
            {
                return(AccessDeniedView());
            }

            var urlRecords = _urlRecordService.GetAllUrlRecords(model.SeName, command.Page - 1, command.PageSize);
            var gridModel  = new DataSourceResult
            {
                Data = urlRecords.Select(x =>
                {
                    //language
                    string languageName;
                    if (x.LanguageId == 0)
                    {
                        languageName = _localizationService.GetResource("Admin.System.SeNames.Language.Standard");
                    }
                    else
                    {
                        var language = _languageService.GetLanguageById(x.LanguageId);
                        languageName = language != null ? language.Name : "Unknown";
                    }

                    //details URL
                    string detailsUrl = "";
                    var entityName    = x.EntityName != null ? x.EntityName.ToLowerInvariant() : "";
                    switch (entityName)
                    {
                    case "blogpost":
                        detailsUrl = Url.Action("Edit", "Blog", new { id = x.EntityId });
                        break;

                    case "category":
                        detailsUrl = Url.Action("Edit", "Category", new { id = x.EntityId });
                        break;

                    case "manufacturer":
                        detailsUrl = Url.Action("Edit", "Manufacturer", new { id = x.EntityId });
                        break;

                    case "product":
                        detailsUrl = Url.Action("Edit", "Product", new { id = x.EntityId });
                        break;

                    case "newsitem":
                        detailsUrl = Url.Action("Edit", "News", new { id = x.EntityId });
                        break;

                    case "topic":
                        detailsUrl = Url.Action("Edit", "Topic", new { id = x.EntityId });
                        break;

                    case "vendor":
                        detailsUrl = Url.Action("Edit", "Vendor", new { id = x.EntityId });
                        break;

                    default:
                        break;
                    }

                    return(new UrlRecordModel
                    {
                        Id = x.Id,
                        Name = x.Slug,
                        EntityId = x.EntityId,
                        EntityName = x.EntityName,
                        IsActive = x.IsActive,
                        Language = languageName,
                        DetailsUrl = detailsUrl
                    });
                }),
                Total = urlRecords.TotalCount
            };

            return(Json(gridModel));
        }
        public ActionResult ShipPlatoonAssignmentsData(DataSourceRequest command, Guid id, Guid?memberId)
        {
            var gridModel = new DataSourceResult();

            TerritoryBattlePhase      tbp       = db.TerritoryBattlePhases.Find(id);
            DataTable                 ds        = new DataTable();
            IEnumerable <PhaseReport> newReport = (IEnumerable <PhaseReport>)HttpContext.Cache.Get("ShipPlatoonAssignments" + id);

            if (newReport == null)
            {
                newReport = db.PhaseReports.Where(x => x.TerritoryBattlePhase_Id == id && x.MemberCharacter_Id == null);
                if (!newReport.Any())
                {
                    using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SwgohDb"].ConnectionString))
                    {
                        SqlCommand sqlComm = new SqlCommand("sp_RequiredPlatoonShips", conn);
                        sqlComm.Parameters.AddWithValue("@phaseGuid", id);

                        sqlComm.CommandType = System.Data.CommandType.StoredProcedure;

                        SqlDataAdapter da = new SqlDataAdapter();
                        da.SelectCommand = sqlComm;

                        da.Fill(ds);

                        Guid?currentShipId            = Guid.Empty;
                        List <MemberShip> memberShips = new List <MemberShip>();
                        int assignedShips             = 0;

                        foreach (DataRow row in ds.Rows)
                        {
                            if (currentShipId != row.Field <Guid>("Ship_Id"))
                            {
                                currentShipId = row.Field <Guid>("Ship_Id");
                                memberShips   = db.MemberShips.Where(x => x.Ship_Id == currentShipId &&
                                                                     x.Member.Guild_Id == tbp.TerritoryBattle.Guild_Id &&
                                                                     x.Stars >= tbp.RequiredStars)
                                                .OrderBy(x => x.ShipPower)
                                                .ThenBy(x => x.Stars)
                                                .ThenBy(x => x.Level).ToList();
                                assignedShips = 0;
                            }

                            try
                            {
                                row[1] = memberShips[assignedShips].Id;
                            }
                            catch
                            {
                                row[1] = DBNull.Value;
                            }
                            assignedShips++;
                        }
                        newReport = ds.AsEnumerable().Select(
                            dataRow => new PhaseReport
                        {
                            Id                      = Guid.NewGuid(),
                            PlatoonShip_Id          = dataRow.Field <Guid?>("PlatoonShip_Id"),
                            PlatoonShip             = db.PlatoonShips.Find(dataRow.Field <Guid?>("PlatoonShip_Id")),
                            TerritoryBattlePhase_Id = dataRow.Field <Guid>("TerritoryBattlePhase_Id"),
                            TerritoryBattlePhase    = db.TerritoryBattlePhases.Find(dataRow.Field <Guid>("TerritoryBattlePhase_Id")),
                            MemberShip_Id           = dataRow.Field <Guid?>("Ship_Id"),
                            MemberShip              = db.MemberShips.Find(dataRow.Field <Guid?>("Ship_Id"))
                        }).ToList();

                        db.BulkInsert(newReport);
                    }
                }
                HttpContext.Cache.Insert("ShipPlatoonAssignments" + id, newReport, null, Cache.NoAbsoluteExpiration, new TimeSpan(24, 0, 0));
            }
            if (memberId.HasValue)
            {
                //gridModel = newReport.Where(x => x.MemberShip.Member_Id == memberId).ToList().ToDataSourceResult(command, Mapper.Map<PhaseReport, PlatoonAssignmentsModel>);
                gridModel = db.PhaseReports.Where(x => x.TerritoryBattlePhase_Id == id && x.MemberCharacter_Id == null & x.MemberShip.Member_Id == memberId)
                            .ToList().ToDataSourceResult(command, Mapper.Map <PhaseReport, PlatoonAssignmentsModel>);
            }
            else
            {
                gridModel = (DataSourceResult)HttpContext.Cache.Get("ShipPlatoonAssignmentsGrid" + id.ToString());
                if (gridModel == null)
                {
                    gridModel = newReport.ToDataSourceResult(command, Mapper.Map <PhaseReport, PlatoonAssignmentsModel>);
                    HttpContext.Cache.Insert("ShipPlatoonAssignmentsGrid" + id, gridModel, null, Cache.NoAbsoluteExpiration, new TimeSpan(24, 0, 0));
                }
            }
            return(Json(gridModel));
        }
        public ActionResult RatesList(DataSourceRequest command)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings))
            {
                return(Content("Access denied"));
            }

            var records  = _shippingByWeightService.GetAll(command.Page - 1, command.PageSize);
            var sbwModel = records.Select(x =>
            {
                var m = new ShippingByWeightModel()
                {
                    Id                       = x.Id,
                    StoreId                  = x.StoreId,
                    ShippingMethodId         = x.ShippingMethodId,
                    CountryId                = x.CountryId,
                    From                     = x.From,
                    To                       = x.To,
                    AdditionalFixedCost      = x.AdditionalFixedCost,
                    PercentageRateOfSubtotal = x.PercentageRateOfSubtotal,
                    RatePerWeightUnit        = x.RatePerWeightUnit,
                    LowerWeightLimit         = x.LowerWeightLimit,
                };
                //shipping method
                var shippingMethod   = _shippingService.GetShippingMethodById(x.ShippingMethodId);
                m.ShippingMethodName = (shippingMethod != null) ? shippingMethod.Name : "Unavailable";
                //store
                var store   = _storeService.GetStoreById(x.StoreId);
                m.StoreName = (store != null) ? store.Name : "*";
                //country
                var c         = _countryService.GetCountryById(x.CountryId);
                m.CountryName = (c != null) ? c.Name : "*";
                //state
                var s = _stateProvinceService.GetStateProvinceById(x.StateProvinceId);
                m.StateProvinceName = (s != null) ? s.Name : "*";
                //zip
                m.Zip = (!String.IsNullOrEmpty(x.Zip)) ? x.Zip : "*";


                var htmlSb = new StringBuilder("<div>");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.ByWeight.Fields.From"), m.From);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.ByWeight.Fields.To"), m.To);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.ByWeight.Fields.AdditionalFixedCost"), m.AdditionalFixedCost);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.ByWeight.Fields.RatePerWeightUnit"), m.RatePerWeightUnit);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.ByWeight.Fields.LowerWeightLimit"), m.LowerWeightLimit);
                htmlSb.Append("<br />");
                htmlSb.AppendFormat("{0}: {1}", _localizationService.GetResource("Plugins.Shipping.ByWeight.Fields.PercentageRateOfSubtotal"), m.PercentageRateOfSubtotal);

                htmlSb.Append("</div>");
                m.DataHtml = htmlSb.ToString();

                return(m);
            })
                           .ToList();
            var gridModel = new DataSourceResult
            {
                Data  = sbwModel,
                Total = records.TotalCount
            };

            return(Json(gridModel));
        }