Exemple #1
0
        public StiReport GetReport(decimal reportFileId, PersonAdvanceSearchProxy proxy, IList <ReportUIParameter> parmeters)
        {
            try
            {
                if (parmeters.Where(x => Utility.IsEmpty(x.ActionId)).Count() > 0)
                {
                    exception.Add(new ValidationException(ExceptionResourceKeys.ReportParameterActionIdIsEmpty, "شناسه عملیات مشخص نشده است", ExceptionSrc));
                    throw exception;
                }
                ISearchPerson   searchTool = new BPerson();
                IList <decimal> personIdList;
                IList <Person>  persons;
                if (Utility.IsEmpty(parmeters))
                {
                    //مثلا برای گزارش شیفتها چه نیازی به لیست پرسنل است
                    persons = new List <Person>();// searchTool.QuickSearch("", PersonCategory.Public);
                }
                else
                {
                    if (proxy.PersonIdList == null || proxy.PersonIdList.Count == 0)
                    {
                        persons = searchTool.GetPersonInAdvanceSearch(proxy);
                    }
                    else
                    {
                        persons = searchTool.GetPersonByPersonIdList(proxy.PersonIdList);
                    }
                }
                //کلیه پرسنل مدیر , جانشین و اپراتور
                if (persons.Count == 0 && !Utility.IsEmpty(parmeters))
                {
                    persons = searchTool.QuickSearchByPage(0, 1000, "");
                }

                if (persons.Count == 0 && !Utility.IsEmpty(parmeters))
                {
                    exception.Add(new ValidationException(ExceptionResourceKeys.ReportParameterPersonIsEmpty, "مجموعه انتخابی شامل هیچ پرسنلی نمیباشد", ExceptionSrc));
                    throw exception;
                }
                var ids = from o in persons
                          select o.ID;
                personIdList = ids.ToList <decimal>();

                IDictionary <string, object> ParamValues = new Dictionary <string, object>();
                foreach (ReportUIParameter param in parmeters)
                {
                    if (Utility.IsEmpty(param.Value))
                    {
                        exception.Add(new ValidationException(ExceptionResourceKeys.ReportParametersIsEmpty, "مقدار پارامترها مشخص نشده است", ExceptionSrc));
                        throw exception;
                    }

                    string value = param.Value;
                    IDictionary <string, object> result;
                    if (BusinessFactory.Exists(param.ActionId))
                    {
                        result = BusinessFactory.GetBusiness <IBControlParameter>(param.ActionId).ParsParameter(value, param.ActionId);
                    }
                    else
                    {
                        result = BaseControlParameter.ParsParameter(value);
                    }
                    if (result != null)
                    {
                        foreach (var item in result)
                        {
                            ParamValues.Add(item);
                        }
                    }
                }

                ReportFile   file         = this.GetReportFile(reportFileId);
                ReportHelper reportHelper = ReportHelper.Instance("شرکت طرح و پردازش غدیر", BUser.CurrentUser.ID, BUser.CurrentUser.Person.Name, personIdList);
                StiReport    report       = reportHelper.GetReport(@file.File);
                reportHelper.InitAssemblyReport(report);
                reportHelper.InitReportParameter(report, ParamValues);
                reportHelper.InitReportConnection(report, ReportParamRep.GetConnectionString());


                return(report);
            }
            catch (Exception ex)
            {
                BaseBusiness <Report> .LogException(ex, "BReportParameter", "GetReport");

                throw ex;
            }
        }