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));
            }
        }
예제 #2
0
        public void ProcessAction(string parameter)
        {
            string[] indices         = parameter.Split(';');
            int      columnIndex     = Int32.Parse(indices[0]);
            int      rowIndex        = Int32.Parse(indices[1]);
            string   columnValueType = indices[2];
            string   rowValueType    = indices[3];

            var editor = (ASPxPivotGridListEditor)View.Editor;

            PivotDrillDownDataSource drillDown = editor.PivotGridControl.CreateDrillDownDataSource(columnIndex, rowIndex);
            ArrayList keysToShow = new ArrayList();

            foreach (PivotDrillDownDataRow row in drillDown)
            {
                object key = row[View.ObjectTypeInfo.KeyMember.Name];
                if (key != null)
                {
                    keysToShow.Add(key);
                }
            }

            // Show list view
            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);
            ListView           listView = Application.CreateListView(viewId, collectionSource, true);
            ShowViewParameters svp      = new ShowViewParameters(listView);

            svp.TargetWindow = TargetWindow.NewModalWindow;

            // Add Default Values controller
            if (TargetDefaultValuesController != null)
            {
                var pivotFieldValuePairs = GetPivotFieldValues(editor.PivotGridControl, columnIndex, rowIndex);
                Dictionary <string, object> dicPivotFieldValues = GetDefaultValues(pivotFieldValuePairs);

                var defaultValuesController = (Xafology.ExpressApp.Controllers.DefaultValuesViewController)Activator.CreateInstance(TargetDefaultValuesController, dicPivotFieldValues);
                svp.Controllers.Add(defaultValuesController);
            }

            Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(Frame, null));
        }
예제 #3
0
        void IXafCallbackHandler.ProcessAction(string parameter)
        {
            string[] indices     = parameter.Split(';');
            int      columnIndex = Int32.Parse(indices[0]);
            int      rowIndex    = Int32.Parse(indices[1]);
            PivotDrillDownDataSource drillDown = ((ASPxPivotGridListEditor)View.Editor).PivotGridControl.CreateDrillDownDataSource(columnIndex, rowIndex);
            string name       = View.ObjectTypeInfo.KeyMember.Name;
            IList  keysToShow = drillDown.Cast <PivotDrillDownDataRow>().Where(row => row[name] != null).Select(row => row[name]).ToList();

            if (keysToShow.Count > 0)
            {
                Type   targetType = View.ObjectTypeInfo.Type;
                string viewId     = Application.GetListViewId(targetType);
                CollectionSourceBase collectionSource = Application.CreateCollectionSource(Application.CreateObjectSpace(targetType), targetType, viewId);
                collectionSource.Criteria["SelectedObjects"] = new InOperator(ObjectSpace.GetKeyPropertyName(targetType), keysToShow);
                ListView listView = Application.CreateListView(viewId, collectionSource, false);
                Application.ShowViewStrategy.ShowViewInPopupWindow(listView);
            }
        }
예제 #4
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)));
        }
예제 #5
0
        public void ProccesExcellRows(IEnumerable records, ObjectSpace objectSpace, DoWorkEventArgs e) {

            var i = 0;

            //for every row in excell sheet
            foreach (Row record in records) {
                ++i;
                if (i == 1) continue;
                if (_BgWorker.CancellationPending) { e.Cancel = true; break; }

                //var os = new ObjectSpace(objectSpace, XafTypesInfo.Instance);
                object newObj = null;

                //chech if row contains Oid

                //get key property name of the object type being imported
                var kp = objectSpace.GetKeyPropertyName(Type);
                //check if it exists in excel and is mapped ?
                var idMapping = ImportMap.Mappings.Where(p => p.MapedTo == kp).FirstOrDefault();
                if (idMapping != null && GetQString(record[idMapping.Column].Value) != string.Empty) {
                    try {
                        //find existing object
                        var val = record[idMapping.Column];
                        var gwid = new Guid(GetQString(val.Value));
                        newObj = objectSpace.FindObject(Type, new BinaryOperator(kp, gwid), true);
                    } catch {

                    }
                }
                if (newObj == null) //create a new instance
                    newObj = objectSpace.CreateObject(Type) as IXPSimpleObject;

                string message;
                if (newObj != null) {
                    var props = ((IXPSimpleObject)newObj).ClassInfo.PersistentProperties
                        .OfType<XPMemberInfo>();


                    foreach (var mapping in ImportMap.Mappings) {
                        if (_BgWorker.CancellationPending) { e.Cancel = true; break; }
                        Application.DoEvents();

                        var mapping1 = mapping;
                        var prop = props.Where(p => p.Name == mapping1.MapedTo).FirstOrDefault();

                        try {
                            var val = record[mapping.Column];
                            // continue;

                            if (val != null) {
                                //if simple property
                                if (prop.ReferenceType == null) {
                                    var isNullable = prop.MemberType.IsGenericType && prop.MemberType.GetGenericTypeDefinition() == typeof(Nullable<>);
                                    object convertedValue = null;

                                    if (prop.MemberType == null) return;

                                    if (isNullable) {
                                        if (prop.StorageType == typeof(int)) {
                                            int number;
                                            var rez = Int32.TryParse(val.Value, out number);
                                            if (rez) convertedValue = number;

                                        } else if (prop.StorageType == typeof(DateTime)) {
                                            if (val.Value != string.Empty) {
                                                //Include validate
                                                var dt = DateTime.FromOADate(Convert.ToDouble(val.Value));
                                                convertedValue = dt;
                                            }
                                        } else if (prop.StorageType == typeof(double)) {
                                            double number;
                                            var rez = Double.TryParse(val.Value, out number);
                                            if (rez) convertedValue = number;
                                        }
                                    } else {

                                        if (prop.MemberType == typeof(char))
                                            convertedValue = Convert.ChangeType(GetQString(val.Value), prop.MemberType);
                                        else if (prop.MemberType == typeof(Guid))
                                            convertedValue = new Guid(GetQString(val.Value));
                                        else if (prop.StorageType == typeof(DateTime)) {
                                            if (val.Value != string.Empty) {
                                                //Include validate
                                                var dt = DateTime.FromOADate(Convert.ToDouble(val.Value));
                                                convertedValue = dt;
                                            }
                                        } else if (prop.MemberType == typeof(double)) {
                                            double number;
                                            //  Application.CurrentCulture.NumberFormat.NumberDecimalSeparator = ".";
                                            var rez = Double.TryParse(val.Value, NumberStyles.Number, new NumberFormatInfo { NumberDecimalSeparator = "." }, out number);
                                            if (rez) convertedValue = number;
                                        } else if (prop.MemberType == typeof(bool)) {
                                            if (val.Value != string.Empty && (val.Value.Length == 1 || val.Value.ToLower() == "true" || val.Value.ToLower() == "false")) {
                                                bool truefalse;
                                                if (val.Value.ToLower() == "true" || val.Value.ToLower() == "false")
                                                    truefalse = Convert.ToBoolean(val.Value);
                                                else
                                                    truefalse = Convert.ToBoolean(Convert.ToInt32(val.Value));
                                                convertedValue = truefalse;
                                            }
                                        } else
                                            convertedValue = Convert.ChangeType(val.Value, prop.MemberType);
                                    }

                                    if (convertedValue != null) {
                                        if (convertedValue.GetType() == typeof(double))
                                            convertedValue = Math.Round((double)convertedValue, 2, MidpointRounding.ToEven);

                                        prop.SetValue(newObj, convertedValue);
                                    }
                                }
                                //if referenced property
                                if (prop.ReferenceType != null) {

                                    //if other referenced type
                                    if (prop.MemberType.IsSubclassOf(typeof(XPBaseObject))) {
                                        var text = val.Value;
                                        var typ = prop.MemberType;
                                        var mval = ImportWizard.Helper.GetXpObjectByKeyValue(objectSpace, text, typ);
                                        prop.SetValue(newObj, objectSpace.GetObject(mval));
                                    }
                                }

                            }

                        } catch (Exception E) {
                            message = string.Format("Error processing record {0}. {1}", i, E);
                            _BgWorker.ReportProgress(0, message);
                        }

                        if (CurrentCollectionSource != null)
                            AddNewObjectToCollectionSource(CurrentCollectionSource, newObj, ObjectSpace);
                        ObjectSpace.Session.Save(newObj);
                    }
                }

                objectSpace.CommitChanges();
                message = string.Format("Importing record {0} succesfull.", i);
                _BgWorker.ReportProgress(1, message);
                Application.DoEvents();
            }
        }