예제 #1
0
        private void ComprobanteExportReportAction_Execute(object sender, SingleChoiceActionExecuteEventArgs e)
        {
            if (e.SelectedObjects.Count == 0)
            {
                return;
            }

            var rutaBase = RutaExpComprobantes;

            if (string.IsNullOrEmpty(rutaBase))
            {
                throw new UserFriendlyException("No está definida la ruta para exportación de comprobantes");
            }

            foreach (ComprobanteBase obj in e.SelectedObjects)
            {
                var criteria =
                    (CriteriaOperator)
                    new BinaryOperator(View.ObjectTypeInfo.KeyMember.Name, ObjectSpace.GetKeyValue(obj));

                var reportData = ObjectSpace.GetObject((IReportData)e.SelectedChoiceActionItem.Data);
                var rep        = (XafReport)reportData.LoadReport(ObjectSpace);
                rep.SetFilteringObject(new LocalizedCriteriaWrapper(View.ObjectTypeInfo.Type, criteria));

                var ruta       = ExpandFilename(obj, rutaBase);
                var directorio = Path.GetDirectoryName(ruta) ?? "";
                if (!Directory.Exists(directorio))
                {
                    Directory.CreateDirectory(directorio);
                }
                rep.ExportToPdf(ruta, new PdfExportOptions());
            }
        }
        public void ProcessAction(DevExpress.XtraPivotGrid.PivotCellEventArgs e)
        {
            PivotGridListEditor listEditor = ((DevExpress.ExpressApp.ListView)View).Editor as PivotGridListEditor;

            int columnIndex = e.ColumnIndex;
            int rowIndex    = e.RowIndex;
            PivotDrillDownDataSource drillDown  = listEditor.PivotGridControl.CreateDrillDownDataSource(columnIndex, rowIndex);
            List <object>            keysToShow = new List <object>();

            for (int i = 0; i < drillDown.RowCount; i++)
            {
                object obj = drillDown[i][0];
                if (obj != null)
                {
                    keysToShow.Add(ObjectSpace.GetKeyValue(obj));
                }
            }

            if (keysToShow.Count > 0)
            {
                string viewId = Application.GetListViewId(View.ObjectTypeInfo.Type);
                CollectionSourceBase collectionSource = Application.CreateCollectionSource(Application.CreateObjectSpace(), View.ObjectTypeInfo.Type, viewId);
                collectionSource.Criteria["SelectedObjects"] = new InOperator(ObjectSpace.GetKeyPropertyName(View.ObjectTypeInfo.Type), keysToShow);
                DevExpress.ExpressApp.ListView listView = Application.CreateListView(viewId, collectionSource, true);
                ShowViewParameters             svp      = new ShowViewParameters(listView);
                svp.TargetWindow = TargetWindow.NewModalWindow;
                //svp.Context = TemplateContext.View;
                Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(Frame, null));
            }
        }
예제 #3
0
        protected override void ExecuteResetPassword(object targetUserObject, ResetPasswordParameters resetPasswordParameters)
        {
            Guard.ArgumentNotNull(targetUserObject, "targetUserObject");
            Guard.ArgumentNotNull(resetPasswordParameters, "resetPasswordParameters");

            CustomResetPasswordEventArgs customResetPasswordEventArgs = new CustomResetPasswordEventArgs(targetUserObject, resetPasswordParameters);

            try
            {
                CustomResetPassword?.Invoke(this, customResetPasswordEventArgs);

                if (!customResetPasswordEventArgs.Handled)
                {
                    this.TargetEmployee = (Employee)targetUserObject;

                    KeyValuePair <HttpStatusCode, string> result = MultiTenantHelper.SetPassword(this.AuthenticatingEmployee, this.TargetEmployee, resetPasswordParameters.Password);

                    if (result.Key == HttpStatusCode.OK)
                    {
                        this.TargetEmployee.SetPassword(resetPasswordParameters.Password);
                        this.TargetEmployee.ChangePasswordOnFirstLogon = false;
                        this.ObjectSpace.CommitChanges();
                    }

                    if (SecuritySystem.CurrentUserId.Equals(ObjectSpace.GetKeyValue(targetUserObject)))
                    {
                        SecurityModule.TryUpdateLogonParameters(resetPasswordParameters.Password);
                    }
                }
            }
            catch (Exception ex)
            {
                ToastMessageHelper.ShowErrorMessage(this.Application, ex, InformationPosition.Bottom);
            }
        }
        protected override void ReplaceLayer(ModelApplicationBase model, ModelApplicationBase layer, bool isCurrentUserModel, ShowViewParameters showViewParameters)
        {
            var showViewStrategyBase = (WinShowViewStrategyBase)Application.ShowViewStrategy;
            var modelApplicationBase = ((ModelApplicationBase)Application.Model);
            var lastLayer            = modelApplicationBase.LastLayer;

            modelApplicationBase.RemoveLayer(lastLayer.Id);

            var dummyLayer = modelApplicationBase.CreatorInstance.CreateModelApplication();

            dummyLayer.Id = lastLayer.Id;
            ModelApplicationHelper.AddLayer(modelApplicationBase, dummyLayer);
            var keyValue        = ObjectSpace.GetKeyValue(View.CurrentObject);
            var objectType      = View.ObjectTypeInfo.Type;
            var modelDetailView = View.Model;

            showViewStrategyBase.CloseAllWindows();

            base.ReplaceLayer(model, layer, isCurrentUserModel, showViewParameters);
            showViewStrategyBase.ShowStartupWindow();

            var xafApplication = ApplicationHelper.Instance.Application;
            var objectSpace    = xafApplication.CreateObjectSpace(modelDetailView.ModelClass.TypeInfo.Type);
            var objectByKey    = objectSpace.GetObjectByKey(objectType, keyValue);

            showViewStrategyBase = (WinShowViewStrategyBase)xafApplication.ShowViewStrategy;

            showViewParameters.CreatedView = xafApplication.CreateDetailView(objectSpace, modelDetailView, true, objectByKey);
            showViewStrategyBase.ShowView(showViewParameters, new ShowViewSource(null, null));
        }
예제 #5
0
        protected virtual CriteriaOperator GetCriteriaOperator(IModelEmailReceipient modelEmailReceipient, object o)
        {
            var keyValue = ObjectSpace.GetKeyValue(o);

            modelEmailReceipient.Criteria = modelEmailReceipient.Criteria.Replace(RuleObjectKeyValue, keyValue + "");
            var criteriaOperator = CriteriaOperator.Parse(modelEmailReceipient.Criteria);

            return(criteriaOperator);
        }
예제 #6
0
        CriteriaOperator GetCriteria(IMemberInfo memberInfo)
        {
            IMemberInfo collectionMemberInfo = GetCollectionMemberInfo(memberInfo);

            return(collectionMemberInfo != null && collectionMemberInfo.AssociatedMemberInfo != null
                       ? CriteriaOperator.Parse(string.Format("{0}.{1}=?", memberInfo.Owner.Name,
                                                              collectionMemberInfo.ListElementTypeInfo.KeyMember.Name),
                                                (Guid)ObjectSpace.GetKeyValue(View.CurrentObject))
                       : null);
        }
예제 #7
0
        CriteriaOperator GetCriteria(IMemberInfo memberInfo)
        {
            IMemberInfo collectionMemberInfo = GetCollectionMemberInfo(memberInfo);

            return(collectionMemberInfo?.AssociatedMemberInfo != null
                       ? CriteriaOperator.Parse(
                       $"{memberInfo.Owner.Name}.{collectionMemberInfo.ListElementTypeInfo.KeyMember.Name}=?",
                       (Guid)ObjectSpace.GetKeyValue(View.CurrentObject))
                       : null);
        }
예제 #8
0
        private void UpdateDataExtractAction_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            var scheduler = Frame.GetController <DataExtractJobSchedulerController>().JobScheduler;

            if (scheduler != null)
            {
                scheduler.StartDataExtractUpdate(ViewCurrentObject);
            }
            else
            {
                var dm = new DataExtractDataManager(Application);
                dm.UpdateDataExtractByKey(ObjectSpace.GetKeyValue(ViewCurrentObject));
                ObjectSpace.Refresh();
            }
        }
        private void UpdateDataExtractAction_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            var scheduler = Application.GetJobScheduler();

            if (scheduler != null && UpdateBySchedulerEnabled)
            {
                scheduler.StartDataExtractUpdate(ViewCurrentObject);
            }
            else
            {
                var dm = new DataExtractDataManager(Application);
                dm.UpdateDataExtractByKey(ObjectSpace.GetKeyValue(ViewCurrentObject));
                ObjectSpace.Refresh();
            }
        }
예제 #10
0
        private void NewObjectViewController_ObjectCreated(object sender, ObjectCreatedEventArgs e)
        {
            var nuevaNota = (Nota)e.CreatedObject;
            var orig      = (BasicObject)((PropertyCollectionSource)((ListView)View).CollectionSource).MasterObject;

            if (orig == null)
            {
                nuevaNota.OriginanteType = null;
                nuevaNota.OriginanteKey  = null;
            }
            else if (ObjectSpace.IsNewObject(nuevaNota))
            {
                throw new ArgumentException("No puede vincular con un objeto sin guardar.");
            }
            else
            {
                nuevaNota.OriginanteType = ((XPObjectSpace)ObjectSpace).Session.GetObjectType(orig);
                nuevaNota.OriginanteKey  = (int)ObjectSpace.GetKeyValue(orig);
            }
        }
예제 #11
0
        protected void ShowInAnalysis(SingleChoiceActionExecuteEventArgs e)
        {
            var os = Application.CreateObjectSpace();
            var typeInfoContainer = (ITypeInfoContainer)Application.Modules.Where(@base => typeof(ITypeInfoContainer).IsAssignableFrom(@base.GetType())).Single();
            var report            =
                os.GetObjectByKey(typeInfoContainer.TypesInfo.AnalysisType, e.SelectedChoiceActionItem.Data) as IAnalysisInfo;

            e.ShowViewParameters.CreatedView          = Application.CreateDetailView(os, report);
            e.ShowViewParameters.TargetWindow         = TargetWindow.Default;
            e.ShowViewParameters.Context              = TemplateContext.View;
            e.ShowViewParameters.CreateAllControllers = true;

            var keys = new ArrayList();

            foreach (object selectedObject in View.SelectedObjects)
            {
                keys.Add(ObjectSpace.GetKeyValue(selectedObject));
            }
            e.ShowViewParameters.Controllers.Add(
                new AssignCustomAnalysisDataSourceDetailViewController(
                    new InOperator(ObjectSpace.GetKeyPropertyName(View.ObjectTypeInfo.Type), keys)));
        }
예제 #12
0
        private void ShowNotesAction_CustomizePopupWindowParams(object sender, CustomizePopupWindowParamsEventArgs args)
        {
            ListView      lv       = Application.CreateListView(Application.CreateObjectSpace(typeof(AuditDataItemPersistent)), typeof(AuditDataItemPersistent), true);
            GroupOperator criteria = new GroupOperator(GroupOperatorType.And);

            criteria.Operands.Add(new BinaryOperator("AuditedObject.TargetType", ((XPObjectSpace)ObjectSpace).Session.GetObjectType(View.CurrentObject)));
            criteria.Operands.Add(new BinaryOperator("AuditedObject.TargetKey", XPWeakReference.KeyToString(ObjectSpace.GetKeyValue(View.CurrentObject))));
            lv.CollectionSource.Criteria["ByTargetObject"] = criteria;
            args.View = lv;
        }
        private void OnCustomProcessSelectedItem(object sender, CustomProcessListViewSelectedItemEventArgs e)
        {
            e.Handled = true;
            var    shortcut       = new ViewShortcut(GetViewId(e.InnerArgs.CurrentObject), ObjectSpace.GetKeyValueAsString(e.InnerArgs.CurrentObject));
            var    requestManager = ((WebApplication)Application).RequestManager;
            string hashUrl        = requestManager.GetQueryString(shortcut);
            var    script         = $"window.open('{HttpContext.Current.Request.Url}#{hashUrl}','_blank');";

            WebWindow.CurrentRequestWindow.RegisterStartupScript($"WindowOpen{View.ObjectTypeInfo.FullName}-{ObjectSpace.GetKeyValue(e.InnerArgs.CurrentObject)}", script, true);
        }
        private void ComprobanteExportAndMailReportAction_Execute(object sender, SingleChoiceActionExecuteEventArgs e)
        {
            if (e.SelectedObjects.Count == 0)
            {
                return;
            }

            var rutaBase = RutaExpComprobantes;

            if (string.IsNullOrEmpty(rutaBase))
            {
                throw new UserFriendlyException("No está definida la ruta para exportación de comprobantes");
            }

            var cuentaEmail = Identificadores.GetInstance(ObjectSpace).CuentaEmailFacturacion;

            if (cuentaEmail == null)
            {
                throw new UserFriendlyException("No está definida la cuenta de mail para el envío de comprobantes");
            }

            var plantillaMensaje   = Identificadores.GetInstance(ObjectSpace).PlantillaMensajeFacturacion;
            var plantillaContenido = plantillaMensaje != null ? plantillaMensaje.Contenido : "";

            foreach (Comprobante obj in e.SelectedObjects)
            {
                var criteria = (CriteriaOperator) new BinaryOperator(View.ObjectTypeInfo.KeyMember.Name, ObjectSpace.GetKeyValue(obj));

                var reportData = ObjectSpace.GetObject(( IReportData )e.SelectedChoiceActionItem.Data);
                var rep        = ( XafReport )reportData.LoadReport(ObjectSpace);
                rep.SetFilteringObject(new LocalizedCriteriaWrapper(View.ObjectTypeInfo.Type, criteria));

                var ruta     = expandFilename(obj, rutaBase);
                var fileName = Path.GetFileName(ruta);
                var ms       = new MemoryStream( );
                rep.ExportToPdf(ms);

                var mail = new MailMessage( );
                mail.Attachments.Add(new Attachment(ms, fileName, "application/pdf"));

                var cliente = ObjectSpace.FindObject <Cliente>(new BinaryOperator("Persona.Oid", obj.Destinatario.Oid));
                if (cliente == null)
                {
                    return;
                }

                var destinatario = cliente.EmailEnvioFacturacion;
                if (destinatario == null)
                {
                    continue;
                }

                mail.From = new MailAddress(cuentaEmail.DireccionEmail, cuentaEmail.NombreMostrar);
                mail.To.Add(new MailAddress(destinatario.Valor, cliente.Persona.Nombre));
                mail.CC.Add(new MailAddress("*****@*****.**", "Info (Facturacion)"));
                mail.Subject    = fileName;
                mail.Body       = plantillaContenido;
                mail.IsBodyHtml = true;

                cuentaEmail.SendMail(mail);
            }
        }
예제 #15
0
 public IEnumerable Getkeys(ListView listView)
 {
     return(listView.SelectedObjects.OfType <object>().Select(o => ObjectSpace.GetKeyValue(o)));
 }
예제 #16
0
 private void SimpleActionOnExecute(object sender, SimpleActionExecuteEventArgs simpleActionExecuteEventArgs)
 {
     using (var objectSpace = Application.CreateObjectSpace()){
         var objectByKey = objectSpace.GetObjectByKey(View.ObjectTypeInfo.Type, ObjectSpace.GetKeyValue(View.CurrentObject));
         View.ObjectTypeInfo.FindMember("Name2").SetValue(objectByKey, "modify");
         objectSpace.CommitChanges();
     }
 }
예제 #17
0
        WebDataSource WebDataSource(Type resourceType, ListView filterView)
        {
            var criteria = new InOperator(filterView.ObjectTypeInfo.KeyMember.Name,
                                          filterView.SelectedObjects.Cast <object>().Select(o => ObjectSpace.GetKeyValue(o)));

            return(new WebDataSource(ObjectSpace, Application.TypesInfo.FindTypeInfo(resourceType), ObjectSpace.CreateCollection(resourceType, criteria)));
        }