示例#1
0
        /// <summary>
        /// 点击文件的界面的时候关闭测试界面,也就是下一次重新加载测试界面
        /// </summary>
        private void CloseDockItem(params string[] strs)
        {
            DocumentGroup dgp = null;

            foreach (DevExpress.Xpf.Docking.BaseLayoutItem bli in dockManager.LayoutRoot.Items)
            {
                if (bli.GetType() == typeof(DevExpress.Xpf.Docking.DocumentGroup))
                {
                    dgp = (DevExpress.Xpf.Docking.DocumentGroup)bli;
                    for (int i = 0; i < dgp.Items.Count; i++)
                    {
                        if (dgp.Items[i] as DevExpress.Xpf.Docking.DocumentPanel != null)
                        {
                            DevExpress.Xpf.Docking.DocumentPanel tempdp = dgp.Items[i] as DevExpress.Xpf.Docking.DocumentPanel;
                            for (int j = 0; j < strs.Length; j++)
                            {
                                if (tempdp.ActualCaption != null && tempdp.ActualCaption.ToString() == strs[j])
                                {
                                    dgp.Items.Remove(tempdp);
                                    i--;
                                }
                            }
                        }
                    }
                }
            }
        }
        protected void Test_CreateGAFRecordsForDocumentGroup_TaxTran_Amounts_Sign_For_Adjustments_And_Memos(Func <TInvoiveAggregate> getInvoiceAggregate,
                                                                                                            decimal expectedSign)
        {
            //Arrange
            var taxAgencyID = VendorDataContext.TaxAgency.BAccountID;
            var taxPeriodID = TaxPeriodDataContext.TaxPeriod.TaxPeriodID;

            var adjAggr = getInvoiceAggregate();

            var adjAggregs = adjAggr.SingleToArray();

            SetupRepositoryMethods(adjAggregs, adjAggr.Document.OrigModule, adjAggr.Document.DocType, taxAgencyID, taxPeriodID);

            var documentGroup = new DocumentGroup <TInvoice>()
            {
                Module            = adjAggr.Document.OrigModule,
                DocumentType      = adjAggr.Document.DocType,
                DocumentsByRefNbr = adjAggregs.ToDictionary(aggr => aggr.Document.RefNbr, aggr => aggr.Document)
            };

            //Action
            var gafRecords = InvoiceGafRecordsCreator.CreateGAFRecordsForDocumentGroup(documentGroup,
                                                                                       taxAgencyID, taxPeriodID)
                             .Single();

            //Assert
            Assert.Equal(expectedSign * InvoiceTranDataContext.TranAmt, gafRecords.Amount);
            Assert.Equal(expectedSign * InvoiceTranDataContext.VatTaxTaxAmt, gafRecords.GSTAmount);
            Assert.Equal(expectedSign * InvoiceTranDataContext.CuryTranAmt, gafRecords.ForeignCurrencyAmount);
            Assert.Equal(expectedSign * InvoiceTranDataContext.VatTaxCuryTaxAmt, gafRecords.ForeignCurrencyAmountGST);
        }
示例#3
0
        private void bbiOptions_ItemClick(object sender, ItemClickEventArgs e)
        {
            DocumentGroup optionsGroup = null;

            if (ParentView == null)
            {
                return;
            }

            if (ParentView.DocumentGroups.Count == 1)
            {
                ParentView.Orientation = Orientation.Vertical;
                optionsGroup           = new DocumentGroup();
                ParentView.DocumentGroups.Add(optionsGroup);
            }
            else
            {
                optionsGroup = ParentView.DocumentGroups[1];
            }

            if (optionsControl == null)
            {
                optionsControl      = new OptionUserControl();
                optionsControl.Text = "Options";
                var document = (Document)ParentView.AddDocument(optionsControl);
                ParentView.Controller.Dock(document, optionsGroup);
                document.Disposed += OptioDocument_Disposed;
            }

            ShowOptions(selectedOptions);
        }
示例#4
0
        public static void ShowPage(ResultPage newpage)
        {
            View view = CreateView(newpage);

            if (ViewManager.Instance.ActiveView == null)
            {
                DocumentGroup mainsite = ViewManager.Instance.WindowProfile.Find <DocumentGroup>();
                mainsite.Parent.Dock(view, DockDirection.Fill);
            }
            else
            {
                DocumentGroup activeView = ViewManager.Instance.ActiveView.FindAncestorOrSelf <DocumentGroup>();

                if (activeView != null)
                {
                    activeView.Dock(view, DockDirection.Fill);
                }
                else
                {
                    view.SnapToBookmark(ViewBookmarkType.DocumentWell);
                }
            }
            ViewCount++;
            view.ShowInFront();
            view.IsActive = true;
        }
示例#5
0
        public static bool EditDocumentGroup(int id, string name, string pageslug)
        {
            using (MainContext db = new MainContext())
            {
                try
                {
                    DocumentGroup record = db.DocumentGroup.Where(d => d.DocumentGroupId == id && d.Deleted == false).SingleOrDefault();
                    if (record != null)
                    {
                        record.GroupName   = name;
                        record.PageSlug    = pageslug;
                        record.TimeUpdated = DateTime.Now;
                        db.SaveChanges();

                        LogtrackManager logkeeper = new LogtrackManager();
                        logkeeper.LogDate    = DateTime.Now;
                        logkeeper.LogProcess = EnumLogType.DokumanGrup.ToString();
                        logkeeper.Message    = LogMessages.DocumentGroupEdited;
                        logkeeper.User       = HttpContext.Current.User.Identity.Name;
                        logkeeper.Data       = record.GroupName;
                        logkeeper.AddInfoLog(logger);

                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    return(false);
                }
            }
        }
示例#6
0
        public static bool AddDocumentGroup(DocumentGroup record)
        {
            using (MainContext db = new MainContext())
            {
                try
                {
                    record.TimeCreated = DateTime.Now;
                    record.Deleted     = false;
                    record.Online      = true;
                    record.SortNumber  = 9999;
                    db.DocumentGroup.Add(record);
                    db.SaveChanges();

                    LogtrackManager logkeeper = new LogtrackManager();
                    logkeeper.LogDate    = DateTime.Now;
                    logkeeper.LogProcess = EnumLogType.DokumanGrup.ToString();
                    logkeeper.Message    = LogMessages.DocumentGroupAdded;
                    logkeeper.User       = HttpContext.Current.User.Identity.Name;
                    logkeeper.Data       = record.GroupName;
                    logkeeper.AddInfoLog(logger);


                    return(true);
                }
                catch (Exception ex)
                {
                    return(false);
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DocumentsOther documentsOtherBo = new DocumentsOther(web);
                DocumentGroup  documentGroupBo  = new DocumentGroup(web);

                var catId = Request.QueryString["catId"];
                int cat   = 0;
                if (!int.TryParse(catId, out cat))
                {
                    catId = "0";
                }

                rpOtherDocument.DataSource = documentGroupBo.get_DocumentType(web, Constants.DocumentGroup.TypeValue.valueStringCollection[2], catId);
                rpOtherDocument.DataBind();

                var items = documentsOtherBo.get_DocumentsLegalInfoItemsByDocumentType(web, Convert.ToString(catId));
                rpDocumentsItem.DataSource = items;
                rpDocumentsItem.DataBind();

                if (items.Count > 0)
                {
                    ltDocumentGroup.Text     = items[0].DocumentType;
                    ltDocumentGroupName.Text = items[0].DocumentType;

                    SetPageTitles(items[0].DocumentType);
                }

                //var pageTitle = HttpContext.GetGlobalResourceObject("napas.resource", "LegalDocuments").ToString();
            }
        }
        void buttonTools_BtnClose(object sender, RoutedEventArgs e)
        {
            DocumentPanel dp = (DocumentPanel)(((Setting)((Grid)((ContentControl)this.Parent).Parent).Parent).Parent);
            DocumentGroup dg = (DocumentGroup)dp.Parent;

            dg.Remove(dp);
        }
        public void Test_CreateGAFRecordsForDocumentGroup_That_Country_Field_Is_Null_When_Sale_Country_Is_Malaysia(string module, Action additionalSetup = null)
        {
            //Arrange
            var taxAgencyID = VendorDataContext.TaxAgency.BAccountID;
            var taxPeriodID = TaxPeriodDataContext.TaxPeriod.TaxPeriodID;

            var invoiceAggr = ArInvoiceAggregateBuilderFactory.CreateInvoiceAggregateBuilder(ARDocType.Invoice, withTax: true, module: module)
                              .Build();

            var invoiceAggregs = invoiceAggr.SingleToArray();

            SetupRepositoryMethods(invoiceAggregs, invoiceAggr.Document.OrigModule, invoiceAggr.Document.DocType, taxAgencyID, taxPeriodID);

            if (additionalSetup != null)
            {
                additionalSetup();
            }

            var documentGroup = new DocumentGroup <AR.ARInvoice>()
            {
                Module            = invoiceAggr.Document.OrigModule,
                DocumentType      = invoiceAggr.Document.DocType,
                DocumentsByRefNbr = invoiceAggregs.ToDictionary(aggr => aggr.Document.RefNbr, aggr => aggr.Document)
            };

            //Action
            var supplyRecord = InvoiceGafRecordsCreator.CreateGAFRecordsForDocumentGroup(documentGroup, taxAgencyID, taxPeriodID)
                               .Single();

            //Assert
            Assert.Null(supplyRecord.Country);
        }
示例#10
0
        private void CreateGafRecordsByCADocuments(DocumentIDGroup documentIDGroup,
                                                   GAFPeriod gafPeriod,
                                                   out IList <PurchaseRecord> purchaseRecords,
                                                   out IList <SupplyRecord> supplyRecords)
        {
            purchaseRecords = new List <PurchaseRecord>();
            supplyRecords   = new List <SupplyRecord>();

            var caAdjs = _gafRepository.GetCAAdjsByIDs(documentIDGroup.DocumentType, documentIDGroup.RefNbrs.ToArray());

            var caAdjGroupsByDrCr = caAdjs.GroupBy(caAdj => caAdj.DrCr);

            foreach (var caAdjGroupByDrCr in caAdjGroupsByDrCr)
            {
                var documentGroup = new DocumentGroup <CAAdj>()
                {
                    Module            = documentIDGroup.Module,
                    DocumentType      = documentIDGroup.DocumentType,
                    DocumentsByRefNbr = caAdjGroupByDrCr.ToDictionary(caAdj => caAdj.AdjRefNbr, caAdj => caAdj)
                };

                if (caAdjGroupByDrCr.Key == CADrCr.CACredit)
                {
                    purchaseRecords = _caDocumentPurchaseGAFRecordsCreator.CreateGAFRecordsForDocumentGroup(documentGroup,
                                                                                                            gafPeriod.TaxAgencyID, gafPeriod.TaxPeriodID);
                }
                else
                {
                    supplyRecords = _caDocumentSupplyGAFRecordsCreator.CreateGAFRecordsForDocumentGroup(documentGroup,
                                                                                                        gafPeriod.TaxAgencyID, gafPeriod.TaxPeriodID);
                }
            }
        }
示例#11
0
        private IList <PurchaseRecord> CreatePurchaseRecordsByAPInvoices(DocumentIDGroup documentIDGroup, GAFPeriod gafPeriod)
        {
            var resultRecords = new List <PurchaseRecord>();

            var apInvoices = _gafRepository.GetAPInvoicesByIDs(documentIDGroup.DocumentType, documentIDGroup.RefNbrs.ToArray());

            //module of taxTran is not honest, it alwayes equals to AP for all Account Payable documents
            var documentGroupsByModule = apInvoices.GroupBy(apReg => apReg.OrigModule);

            foreach (var documentGroupByModule in documentGroupsByModule)
            {
                var documentGroup = new DocumentGroup <APInvoice>()
                {
                    Module            = documentGroupByModule.Key,
                    DocumentType      = documentIDGroup.DocumentType,
                    DocumentsByRefNbr = documentGroupByModule.ToDictionary(invoice => invoice.RefNbr, invoice => invoice)
                };

                var records = _apInvoiceGAFRecordsCreator.CreateGAFRecordsForDocumentGroup(documentGroup,
                                                                                           gafPeriod.TaxAgencyID,
                                                                                           gafPeriod.TaxPeriodID);

                resultRecords.AddRange(records);
            }

            return(resultRecords);
        }
示例#12
0
        protected override void LoadData(DocumentGroup <ARInvoice> documentGroup, int?taxAgencyID, string taxPeriodID)
        {
            base.LoadData(documentGroup, taxAgencyID, taxPeriodID);

            SOInvoices = GafRepository.GetSOInvoices(documentGroup.DocumentType, documentGroup.DocumentsByRefNbr.Keys.ToArray())
                         .ToDictionary(soInvoice => soInvoice.RefNbr, soInvoice => soInvoice);
        }
        private void bbiOptions_ItemClick(object sender, ItemClickEventArgs e)
        {
            DocumentGroup optionsGroup = null;

            if (ParentView == null)
            {
                return;
            }


            if (ParentView.DocumentGroups.Count == 1)
            {
                ParentView.Orientation = Orientation.Vertical;
                optionsGroup           = new DocumentGroup();
                ParentView.DocumentGroups.Add(optionsGroup);
            }
            else
            {
                optionsGroup = ParentView.DocumentGroups[1];
            }

            var instrumentForm = new Controls.OptionUserControl();

            instrumentForm.Text = "Options";
            var document = (Document)ParentView.AddDocument(instrumentForm);

            ParentView.Controller.Dock(document, optionsGroup);
        }
 public NavigationWithPanal(NavBarItem navItem, string viewName, DockLayoutManager dockManager, DocumentGroup documentContainer)
 {
     NavItem           = navItem;
     navItem.Click    += navItem_Click;
     ViewName          = viewName;
     DockManager       = dockManager;
     DocumentContainer = documentContainer;
 }
        protected override void LoadData(DocumentGroup <APInvoice> documentGroup, int?taxAgencyID, string taxPeriodID)
        {
            base.LoadData(documentGroup, taxAgencyID, taxPeriodID);

            Vendors = GetContragentsForDocuments(DocumentsByRefNbr.Values);

            LoadValuableTaxApRegistersForDocuments(documentGroup, taxAgencyID);
        }
示例#16
0
 public DocumentGroup Post(DocumentGroup documentGroup)
 {
     if (documentGroup == null || !ModelState.IsValid)
     {
         throw new HttpException((int)HttpStatusCode.BadRequest, "Invalid Request");
     }
     return(documentGroupService.SaveDocumentGroup(documentGroup.CreateFrom()).CreateFrom());
 }
 /// <summary>
 ///  Create web model from entity [dropdown]
 /// </summary>
 public static Models.DocumentGroupDropDown CreateFromm(this DocumentGroup source)
 {
     return(new Models.DocumentGroupDropDown
     {
         DocumentGroupId = source.DocumentGroupId,
         DocumentGroupCodeName = source.DocumentGroupCode + " - " + source.DocumentGroupName
     });
 }
示例#18
0
 public Boolean Delete(DocumentGroup documentGroup)
 {
     if (documentGroup == null || !ModelState.IsValid)
     {
         throw new HttpException((int)HttpStatusCode.BadRequest, "Invalid Request");
     }
     documentGroupService.DeleteDocumentGroup(documentGroup.DocumentGroupId);
     return(true);
 }
示例#19
0
        public void Test_CreateGAFRecordsForDocumentGroup_When_Document_Is_In_Base_Cury_And_TaxTrans_By_Tax_Document()
        {
            //Arrange
            var taxDataItem = TaxDataBuilder.CreateTaxDataItems(new[]
            {
                TaxDataContext.VatDirect.TaxID,
            })
                              .Single();

            var taxAgencyID = VendorDataContext.TaxAgency.BAccountID;
            var taxPeriodID = TaxPeriodDataContext.TaxPeriod.TaxPeriodID;

            const decimal taxableAmt = 10;
            const decimal taxAmt     = 1m;

            var billAggr1 = new APInvoiceAggregateBuilder()
                            .CreateDocument(APDocType.Invoice,
                                            refNbr: DocumentDataContext.RefNbr,
                                            docDate: DocumentDataContext.DocDate,
                                            curyID: CompanyDataContext.Company.BaseCuryID)
                            .DocumentWith(vendorID: VendorDataContext.Vendor.BAccountID,
                                          vendorLocationID: LocationDataContext.VendorLocation.LocationID)
                            .AddTaxTran(taxDataItem.TaxID, taxDataItem.TranTaxType, taxableAmt, taxAmt, 20, 2)
                            .Build();

            var taxBill1 = new APInvoiceAggregateBuilder()
                           .CreateDocument(APDocType.Invoice)
                           .AddTaxTran(new TaxTran()
            {
                TaxID = taxDataItem.TaxID, OrigRefNbr = DocumentDataContext.RefNbr
            })
                           .Build();

            var billAggregs    = new[] { billAggr1 };
            var taxBillAggregs = new[] { taxBill1 };

            SetupRepositoryMethodsForDocumentsWithTaxDocumentTrans(billAggregs, billAggr1.Document.OrigModule, billAggr1.Document.DocType, taxAgencyID,
                                                                   taxPeriodID, taxBillAggregs);

            var documentGroup = new DocumentGroup <AP.APInvoice>()
            {
                Module            = billAggr1.Document.OrigModule,
                DocumentType      = billAggr1.Document.DocType,
                DocumentsByRefNbr = billAggregs.ToDictionary(aggr => aggr.Document.RefNbr, aggr => aggr.Document)
            };

            //Action
            var purchaseRecord = InvoiceGafRecordsCreator.CreateGAFRecordsForDocumentGroup(documentGroup, taxAgencyID, taxPeriodID)
                                 .Single();

            //Assert
            Assert.Equal(taxableAmt, purchaseRecord.Amount);
            Assert.Equal(taxAmt, purchaseRecord.GSTAmount);
            Assert.Equal(ForeignCurrencyCodeForDocumentInBaseCury, purchaseRecord.ForeignCurrencyCode);
            Assert.Equal(0, purchaseRecord.ForeignCurrencyAmount);
            Assert.Equal(0, purchaseRecord.ForeignCurrencyAmountGST);
        }
        public void Test_CreateGAFRecordsForDocumentGroup_That_Discrepancy_Is_Compensated(Func <TInvoiveAggregate> getInvoiceAggregate, decimal discrepancySign)
        {
            //Arrange
            var taxAgencyID = VendorDataContext.TaxAgency.BAccountID;
            var taxPeriodID = TaxPeriodDataContext.TaxPeriod.TaxPeriodID;

            var billAggr = getInvoiceAggregate();

            var taxIDForDiscrepancy = TaxDataContext.VatTax.TaxID;

            var taxTran = billAggr.TaxTransByTax[taxIDForDiscrepancy].Single();

            taxTran.TaxableAmt     += discrepancySign * 1;
            taxTran.TaxAmt         += discrepancySign * 2;
            taxTran.CuryTaxableAmt += discrepancySign * 3;
            taxTran.CuryTaxAmt     += discrepancySign * 4;

            var taxableAmtWithDiscrepancy     = taxTran.TaxableAmt;
            var taxAmtWithDiscerpancy         = taxTran.TaxAmt;
            var curyTaxableAmtWithDiscerpancy = taxTran.CuryTaxableAmt;
            var curyTaxAmtWithDiscerpancy     = taxTran.CuryTaxAmt;

            var billAggregs = new[] { billAggr };

            SetupRepositoryMethods(billAggregs, billAggr.Document.OrigModule, billAggr.Document.DocType, taxAgencyID, taxPeriodID);

            var documentGroup = new DocumentGroup <TInvoice>()
            {
                Module            = billAggr.Document.OrigModule,
                DocumentType      = billAggr.Document.DocType,
                DocumentsByRefNbr = billAggregs.ToDictionary(aggr => aggr.Document.RefNbr, aggr => aggr.Document)
            };

            //Action
            var gafRecords = InvoiceGafRecordsCreator.CreateGAFRecordsForDocumentGroup(documentGroup, taxAgencyID, taxPeriodID);

            //Assert
            var recordWithCompensatedDiscrepancy = gafRecords.Single(record => record.TaxCode == taxIDForDiscrepancy && record.LineNumber == 2);

            Assert.Equal(taxableAmtWithDiscrepancy - InvoiceTranDataContext.TranAmt, recordWithCompensatedDiscrepancy.Amount);
            Assert.Equal(taxAmtWithDiscerpancy - InvoiceTranDataContext.VatTaxTaxAmt, recordWithCompensatedDiscrepancy.GSTAmount);
            Assert.Equal(curyTaxableAmtWithDiscerpancy - InvoiceTranDataContext.CuryTranAmt, recordWithCompensatedDiscrepancy.ForeignCurrencyAmount);
            Assert.Equal(curyTaxAmtWithDiscerpancy - InvoiceTranDataContext.VatTaxCuryTaxAmt, recordWithCompensatedDiscrepancy.ForeignCurrencyAmountGST);


            var recordsWithoutCompensatedDiscrepancy = gafRecords.Except(recordWithCompensatedDiscrepancy.SingleToArray());

            foreach (var record in recordsWithoutCompensatedDiscrepancy)
            {
                var tranTax = billAggr.TranTaxesByLineNbrAndTax[record.LineNumber][record.TaxCode];

                Assert.Equal(tranTax.TaxableAmt, record.Amount);
                Assert.Equal(tranTax.TaxAmt, record.GSTAmount);
                Assert.Equal(tranTax.CuryTaxableAmt, record.ForeignCurrencyAmount);
                Assert.Equal(tranTax.CuryTaxAmt, record.ForeignCurrencyAmountGST);
            }
        }
示例#21
0
 /// <summary>
 /// Set newly created Document Group object Properties in case of adding
 /// </summary>
 private void SetDocumentGroupProperties(DocumentGroup documentGroup, DocumentGroup dbVersion)
 {
     dbVersion.RecLastUpdatedBy         = dbVersion.RecCreatedBy = documentGroupRepository.LoggedInUserIdentity;
     dbVersion.RecLastUpdatedDt         = dbVersion.RecCreatedDt = DateTime.Now;
     dbVersion.DocumentGroupCode        = documentGroup.DocumentGroupCode;
     dbVersion.DocumentGroupName        = documentGroup.DocumentGroupName;
     dbVersion.DocumentGroupDescription = documentGroup.DocumentGroupDescription;
     dbVersion.UserDomainKey            = documentGroupRepository.UserDomainKey;
 }
        public ApplicationService(PageLocator pageLocator, DocumentGroup documentGroup, EventBus eventBus, IMessenger messenger)
        {
            _documentGroup = documentGroup;
            _pageLocator   = pageLocator ?? throw new ArgumentNullException(nameof(pageLocator));

            _ioc.Register <IApplicationService>(this);
            _ioc.Register(messenger);
            _ioc.Register(eventBus);
        }
示例#23
0
 /// <summary>
 /// update Document Group object Properties in case of updation
 /// </summary>
 protected void UpdateDocumentGroupPropertie(DocumentGroup documentGroup, DocumentGroup dbVersion)
 {
     dbVersion.RecLastUpdatedBy         = documentGroupRepository.LoggedInUserIdentity;
     dbVersion.RecLastUpdatedDt         = DateTime.Now;
     dbVersion.RowVersion               = dbVersion.RowVersion + 1;
     dbVersion.DocumentGroupCode        = documentGroup.DocumentGroupCode;
     dbVersion.DocumentGroupName        = documentGroup.DocumentGroupName;
     dbVersion.DocumentGroupDescription = documentGroup.DocumentGroupDescription;
 }
示例#24
0
        public ChildViewBase()
        {
            SetValue(DocumentsPropertyKey, new FreezableCollection<BaseLayoutItem>());

              // Если понадобится зависимый Ribbon для DocumentPanel, то он будет объединяться.
              MDIMergeStyle = MDIMergeStyle.Always;

              LayoutGroup layoutGroup = new LayoutGroup();
              layoutGroup.Orientation = Orientation.Horizontal;
              LayoutRoot = layoutGroup;

              documentGroup = DockController.AddDocumentGroup(DockType.None);
              DockController.Dock(documentGroup, layoutGroup, DockType.Fill);
              documentGroup.ItemWidth = new GridLength(70, GridUnitType.Star);
              // При изменении активного элемента, изменим зависимое свойство.
              documentGroup.SelectedItemChanged += (s, e) =>
              {
            SelectedDocumentIndex = documentGroup.Items.IndexOf(documentGroup.SelectedItem);
              };

              propLayoutPanel = DockController.AddPanel(DockType.None);
              DockController.Dock(propLayoutPanel, layoutGroup, DockType.Right);
              propLayoutPanel.Caption = "Свойства";
              propLayoutPanel.AllowDrag = false;
              propLayoutPanel.AllowClose = false;
              propLayoutPanel.ItemWidth = new GridLength(30, GridUnitType.Star);

              AutoHideGroup autoHideGroup = new AutoHideGroup();
              autoHideGroup.DockType = Dock.Bottom;
              AutoHideGroups.Add(autoHideGroup);

              LayoutPanel outLayoutPanel = new LayoutPanel();
              outLayoutPanel.Caption = "Вывод";
              outLayoutPanel.AllowDrag = false;
              outLayoutPanel.AllowClose = false;
              autoHideGroup.Add(outLayoutPanel);

              // Элемент для вывода информации о построении.
              txtMessages = new RichTextBox();
              txtMessages.IsReadOnly = true;
              txtMessages.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;
              // Уберем отступы между параграфами.
              Style noSpaceStyle = new Style(typeof(Paragraph));
              noSpaceStyle.Setters.Add(new Setter(Paragraph.MarginProperty, new Thickness(0)));
              txtMessages.Resources.Add(typeof(Paragraph), noSpaceStyle);
              // При изменении содержимого активируем панель и будем прокручивать текст вниз.
              txtMessages.TextChanged += (s, e) =>
              {
            Activate(outLayoutPanel);
            (s as RichTextBox).ScrollToEnd();
              };
              outLayoutPanel.Content = txtMessages;

              synchronizationContext = SynchronizationContext.Current;
              managedThreadId = Thread.CurrentThread.ManagedThreadId;
        }
        public ActionResult ActiveNOnActiveConfirmRelate(int id)
        {
            ViewBag.Current = "Document";

            string        ActiveMode       = string.Empty;
            List <string> UsersId          = new List <string>();
            string        NotificationTime = string.Empty;
            string        UserId           = User.Identity.GetUserId();
            Document      doc = db.DocumentGroups.Include(a => a.document).SingleOrDefault(a => a.Id == id).document;

            DocumentGroup documentGroup = db.DocumentGroups.Find(id);

            if (documentGroup.EnableRelate == true)
            {
                documentGroup.EnableRelate = false;
                ActiveMode = "الغاء  إمكانية الربط";
            }
            else
            {
                documentGroup.EnableRelate = true;
                ActiveMode = "تفعيل إمكانية الربط";
            }
            documentGroup.UpdatedAt       = DateTime.Now.ToString("dd/MM/yyyy-HH:mm:ss");
            db.Entry(documentGroup).State = EntityState.Modified;


            db.SaveChanges();
            int Form_id = documentGroup.DocumentId;

            UsersId = db.UsersGroups.Where(a => a.GroupId == documentGroup.GroupId).Select(a => a.UserId).ToList();
            string       GroupName    = db.Groups.Find(documentGroup.GroupId).Name;
            Notification notification = null;

            NotificationTime = DateTime.Now.ToString("dd/MM/yyyy-HH:mm:ss");

            List <ApplicationUser> Users = db.Users.Where(a => UsersId.Contains(a.Id)).ToList();

            foreach (ApplicationUser user in Users)
            {
                notification = new Notification()
                {
                    CreatedAt = NotificationTime,
                    Active    = false,
                    UserId    = user.Id,
                    Message   = "تمت عملية  " + ActiveMode + " في المجموعة " + GroupName + " رقم الوثيقة :" + doc.DocumentNumber + " موضوع الوثيقة :" + doc.Subject
                                + " ،عنوان الوثيقة :" + doc.Address + "،وصف الوثيقة :" + doc.Description
                    ,
                    NotificationOwnerId = UserId
                };
                db.Notifications.Add(notification);
            }
            db.SaveChanges();


            return(RedirectToAction("Index", new { @id = Form_id, @msg = "EditSuccess" }));
        }
示例#26
0
        public void Test_CreateGAFRecordsForDocumentGroup_When_Tax_Calced_On_Document_Amount()
        {
            //Arrange
            var taxAgencyID  = VendorDataContext.TaxAgency.BAccountID;
            var taxPeriodID  = TaxPeriodDataContext.TaxPeriod.TaxPeriodID;
            var taxDataItems = TaxDataBuilder.CreateTaxDataItems(new[]
            {
                TaxDataContext.VatTax.TaxID,
            });
            var taxDataItemOfTaxCalcedOnDocAmt = TaxDataBuilder.CreateTaxDataItems(new[]
            {
                TaxDataContext.VatTaxCalcedOnDocAmtAmt.TaxID
            })
                                                 .Single();

            const decimal taxableAmt     = 50;
            const decimal taxAmt         = 3.5m;
            const decimal curyTaxableAmt = 101;
            const decimal curyTaxAmt     = 7.1m;

            var documentAggr = _apInvoiceAggregateBuilderFactory.CreateInvoiceAggregateBuilder(APDocType.Invoice, lineCount: 1, taxDataItems: taxDataItems)
                               .AddTaxTran(taxDataItemOfTaxCalcedOnDocAmt.TaxID,
                                           taxDataItemOfTaxCalcedOnDocAmt.TranTaxType,
                                           taxableAmt, taxAmt, curyTaxableAmt, curyTaxAmt)
                               .Build();

            var documentAggregs = documentAggr.SingleToArray();

            SetupRepositoryMethods(documentAggregs, documentAggr.Document.OrigModule, documentAggr.Document.DocType, taxAgencyID, taxPeriodID);

            var documentGroup = new DocumentGroup <AP.APInvoice>()
            {
                Module            = documentAggr.Document.OrigModule,
                DocumentType      = documentAggr.Document.DocType,
                DocumentsByRefNbr = documentAggregs.ToDictionary(aggr => aggr.Document.RefNbr, aggr => aggr.Document)
            };

            //Action
            var gafRecords = InvoiceGafRecordsCreator.CreateGAFRecordsForDocumentGroup(documentGroup,
                                                                                       taxAgencyID, taxPeriodID)
                             .Last();

            //Assert
            Assert.Equal(taxDataItemOfTaxCalcedOnDocAmt.TaxID, gafRecords.TaxCode);
            Assert.Equal(DocumentDataContext.DocDesc, gafRecords.ProductDescription);
            Assert.Equal(DocumentDataContext.RefNbr, gafRecords.InvoiceNumber);
            Assert.Equal(DocumentDataContext.CuryIDEUR, gafRecords.ForeignCurrencyCode);
            Assert.Equal(ContactDataContext.VendorLocationContact.FullName, gafRecords.SupplierName);
            Assert.Equal(VendorDataContext.Vendor.AcctReferenceNbr, gafRecords.SupplierBRN);
            Assert.Equal(null, gafRecords.ImportDeclarationNumber);
            Assert.Equal(2, gafRecords.LineNumber);
            Assert.Equal(taxableAmt, gafRecords.Amount);
            Assert.Equal(taxAmt, gafRecords.GSTAmount);
            Assert.Equal(curyTaxableAmt, gafRecords.ForeignCurrencyAmount);
            Assert.Equal(curyTaxAmt, gafRecords.ForeignCurrencyAmountGST);
        }
示例#27
0
        public void Test_CreateGAFRecordsForDocumentGroup_That_IDN_Has_Been_Taked_From_Determined_Document_When_Exist_Many_Tax_Documents_For_Same_Document_And_Tax(
            TaxDocumentDataItem[] taxDocumentDataItems,
            string expectedDocDesc)
        {
            //Arrange
            var taxDataItems = TaxDataBuilder.CreateTaxDataItems(new[]
            {
                TaxDataContext.VatDirect.TaxID,
                TaxDataContext.VatDirect2.TaxID,
            });

            var taxAgencyID = VendorDataContext.TaxAgency.BAccountID;
            var taxPeriodID = TaxPeriodDataContext.TaxPeriod.TaxPeriodID;

            var billAggr1 = _apInvoiceAggregateBuilderFactory.CreateInvoiceAggregateBuilder(APDocType.Invoice)
                            .AddTaxTran(taxDataItems[0].TaxID, taxDataItems[0].TranTaxType)
                            .AddTaxTran(taxDataItems[1].TaxID, taxDataItems[1].TranTaxType)
                            .Build();


            var docBuilder = new APInvoiceAggregateBuilder();

            var billAggregs    = new[] { billAggr1 };
            var taxBillAggregs = taxDocumentDataItems.Select(taxDocData =>
                                                             docBuilder.CreateDocument(taxDocData.DocType,
                                                                                       refNbr: taxDocData.RefNbr,
                                                                                       docDesc: taxDocData.DocDesc)
                                                             .AddTaxTran(new TaxTran()
            {
                TaxID = taxDataItems[0].TaxID, OrigRefNbr = DocumentDataContext.RefNbr
            })
                                                             .AddTaxTran(new TaxTran()
            {
                TaxID = taxDataItems[1].TaxID, OrigRefNbr = DocumentDataContext.RefNbr
            })
                                                             .Build())
                                 .ToArray();

            SetupRepositoryMethodsForDocumentsWithTaxDocumentTrans(billAggregs, billAggr1.Document.OrigModule,
                                                                   billAggr1.Document.DocType, taxAgencyID, taxPeriodID, taxBillAggregs);

            var documentGroup = new DocumentGroup <AP.APInvoice>()
            {
                Module            = billAggr1.Document.OrigModule,
                DocumentType      = billAggr1.Document.DocType,
                DocumentsByRefNbr = billAggregs.ToDictionary(aggr => aggr.Document.RefNbr, aggr => aggr.Document)
            };

            //Action
            var purchaseRecords =
                InvoiceGafRecordsCreator.CreateGAFRecordsForDocumentGroup(documentGroup, taxAgencyID, taxPeriodID).ToArray();

            //Assert
            Assert.Equal(expectedDocDesc, purchaseRecords[0].ImportDeclarationNumber);
            Assert.Equal(expectedDocDesc, purchaseRecords[1].ImportDeclarationNumber);
        }
示例#28
0
        public void Test_CreateGAFRecordsForDocumentGroup_When_Document_Is_In_Base_Cury()
        {
            //Arrange
            var taxAgencyID = _vendorDataContext.TaxAgency.BAccountID;
            var taxPeriodID = _taxPeriodDataContext.TaxPeriod.TaxPeriodID;

            const decimal taxableAmt = 100;
            const decimal taxAmt     = 15;

            var paymentAggr = new APRegisterAggregateBuilder()
                              .CreateDocument(APDocType.Check,
                                              DocumentDataContext.RefNbr,
                                              DocumentDataContext.DocDate,
                                              CompanyDataContext.Company.BaseCuryID)
                              .DocumentWith(vendorID: _vendorDataContext.Vendor.BAccountID,
                                            vendorLocationID: _locationDataContext.VendorLocation.LocationID)
                              .AddTaxTran(new TaxTran()
            {
                TaxID          = TaxDataContext.WithholdingTax.TaxID,
                TaxableAmt     = taxableAmt,
                TaxAmt         = taxAmt,
                CuryTaxableAmt = 200,
                CuryTaxAmt     = 30,
                AdjdDocType    = APDocType.Invoice,
                AdjdRefNbr     = DocumentDataContext.RefNbr2
            })
                              .Build();

            var paymentAggregs = paymentAggr.SingleToArray();

            var adjdRegister = new APRegister
            {
                DocType = APDocType.Invoice,
                RefNbr  = DocumentDataContext.RefNbr2
            };

            SetupRepositoryMethods(paymentAggregs, adjdRegister.SingleToArray(), paymentAggr.Document.OrigModule, paymentAggr.Document.DocType, taxAgencyID, taxPeriodID);

            var documentGroup = new DocumentGroup <AP.APRegister>()
            {
                Module            = paymentAggr.Document.OrigModule,
                DocumentType      = paymentAggr.Document.DocType,
                DocumentsByRefNbr = paymentAggregs.ToDictionary(aggr => aggr.Document.RefNbr, aggr => aggr.Document)
            };

            //Action
            var purchaseRecord = ApPaymentGAFRecordsCreator.CreateGAFRecordsForDocumentGroup(documentGroup, taxAgencyID, taxPeriodID)
                                 .Single();

            //Assert
            Assert.Equal(taxableAmt, purchaseRecord.Amount);
            Assert.Equal(taxAmt, purchaseRecord.GSTAmount);
            Assert.Equal(ForeignCurrencyCodeForDocumentInBaseCury, purchaseRecord.ForeignCurrencyCode);
            Assert.Equal(0, purchaseRecord.ForeignCurrencyAmount);
            Assert.Equal(0, purchaseRecord.ForeignCurrencyAmountGST);
        }
 /// <summary>
 ///  Create web model from entity
 /// </summary>
 public static Models.DocumentGroup CreateFrom(this DocumentGroup source)
 {
     return(new Models.DocumentGroup
     {
         DocumentGroupId = source.DocumentGroupId,
         DocumentGroupCode = source.DocumentGroupCode,
         DocumentGroupName = source.DocumentGroupName,
         DocumentGroupDescription = source.DocumentGroupDescription
     });
 }
示例#30
0
        private void CreateDefaultLayout()
        {
            DocumentGroup tempGroup = new DocumentGroup();

            tabbedView.DocumentGroups.Add(tempGroup);
            foreach (Document doc in tabbedView.Documents)
            {
                tabbedView.Controller.Dock(doc, tempGroup);
            }
        }
示例#31
0
        public void Test_CreateGAFRecordsForDocumentGroup_For_Documents_With_Two_Taxes_And_Custom_LineNumbers(string module)
        {
            //Arrange
            var taxDataItems = TaxDataBuilder.CreateTaxDataItems(new[]
            {
                TaxDataContext.VatTax.TaxID,
                TaxDataContext.VatTax2.TaxID
            });

            var taxAgencyID = VendorDataContext.TaxAgency.BAccountID;
            var taxPeriodID = TaxPeriodDataContext.TaxPeriod.TaxPeriodID;

            var billAggr1 = new APInvoiceAggregateBuilder()
                            .CreateDocument(
                APDocType.Invoice,
                refNbr: "DOC001",
                docDate: new DateTime(2015, 3, 1),
                curyID: "EUR",
                module: module)
                            .DocumentWith(vendorID: VendorDataContext.Vendor.BAccountID,
                                          vendorLocationID: LocationDataContext.VendorLocation.LocationID)
                            .AddTran(100, 200, "tyre purchase 1", lineNbr: 3, taxDataItems: taxDataItems)
                            .AddTran(300, 600, "oil purchase 1", lineNbr: 7, taxDataItems: taxDataItems)
                            .Build();

            var billAggr2 = new APInvoiceAggregateBuilder()
                            .CreateDocument(APDocType.Invoice,
                                            refNbr: "DOC002",
                                            docDate: new DateTime(2015, 3, 5),
                                            curyID: "GBP",
                                            module: module)
                            .DocumentWith(vendorID: VendorDataContext.Vendor2.BAccountID,
                                          vendorLocationID: LocationDataContext.Vendor2Location.LocationID)
                            .AddTran(200, 400, "tyre purchase 2", lineNbr: 4, taxDataItems: taxDataItems)
                            .AddTran(500, 700, "oil purchase 2", lineNbr: 9, taxDataItems: taxDataItems)
                            .Build();

            var billAggregs = new[] { billAggr1, billAggr2 };

            SetupRepositoryMethods(billAggregs, billAggr1.Document.OrigModule, billAggr1.Document.DocType, taxAgencyID, taxPeriodID);

            var documentGroup = new DocumentGroup <AP.APInvoice>()
            {
                Module            = billAggr1.Document.OrigModule,
                DocumentType      = billAggr1.Document.DocType,
                DocumentsByRefNbr = billAggregs.ToDictionary(aggr => aggr.Document.RefNbr, aggr => aggr.Document)
            };

            //Action
            var purchaseRecords = InvoiceGafRecordsCreator.CreateGAFRecordsForDocumentGroup(documentGroup, taxAgencyID,
                                                                                            taxPeriodID);

            //Assert
            Approvals.VerifyAll(purchaseRecords, "purchaseRecords", record => record.Dump());
        }
        public DocumentViewTabItemModel(View view, DocumentGroup parent)
        {
            if (view == null)
                throw new ArgumentNullException("view", "view is null.");
            if (parent == null)
                throw new ArgumentNullException("parent", "parent is null.");
            if (view.ParentContent != parent)
                throw new ArgumentNullException("parent", "view in not child of parent.");

            View = view;
            DocumentGroup = parent;
        }
        public void NormalGroupUpdateTest()
        {
            XmlDocumentGroup xmlDocumentGroup = XmlHelper.GetXmlDocumentGroup(@".\DataContent\NormalContent\cc54a49bf188f994899cb1c954bb795f.xml");
            xmlDocumentGroup.Operation = Operation.Upd;
            UploadDocumentGroup uploadDocumentGroup = XmlHelper.GetUploadDocumentGroup(xmlDocumentGroup, @".\DataContent\NormalContent\cc54a49bf188f994899cb1c954bb795f.zip");

            using (ShimsContext.Create())
            {
                ShimDateTime.NowGet = () => new DateTime(2000, 1, 1);

                string ident = string.Empty;
                CrawlerLog log = new CrawlerLog();
                DocumentGroup documentGroup = new DocumentGroup();
                IRepository fakeRepository = new StubIRepository
                {
                    GetIdentifierString = (identifier) => { return xmlDocumentGroup.Identifier; },
                    GetOrCreateCrawlerIdString = (crawlerName) => { return 1; },
                    AddDocumentGroupDocumentGroup = (newDocumentGroup) => { documentGroup = newDocumentGroup; },
                    DeleteDocumentGroupString = (identifier) => { ident = identifier; return 1; },
                    AddNewLogCrawlerLog = (crawlerLog) => { log = crawlerLog; }
                };

                WcfHost eu = new WcfHost(fakeRepository);
                var msgActual = eu.UploadFile(uploadDocumentGroup);

                // ReturnMessage
                Assert.AreEqual("Ok", msgActual, "Service return message.");

                // DeleteDocumentGroup
                Assert.AreEqual(xmlDocumentGroup.Identifier, ident, "Identifier");

                // AddDocumentGroup
                Assert.AreEqual(xmlDocumentGroup.Identifier, documentGroup.Identifier, "Identifier");
                Assert.AreEqual(1, documentGroup.CrawlerId, "CrawlerId");
                Assert.AreEqual(1, documentGroup.Operation, "Operation");
                Assert.AreEqual(xmlDocumentGroup.Document.Count, documentGroup.Documents.Count, "DocumentsCount");

                // LogAsserts
                Assert.AreEqual(xmlDocumentGroup.Identifier, log.Identifier, "IdentifierLog");
                Assert.AreEqual(true, log.IsSuccess, "IsSuccess");
                Assert.AreEqual(new DateTime(2000, 1, 1), log.LogDate, "LogDate");
                Assert.AreEqual(xmlDocumentGroup.Crawler, log.CrawlerName, "CrawlerNameLog");
                Assert.AreEqual(1, log.Operation, "OperationLog");
            }
        }
示例#34
0
        public static DocumentPanel SelectPanel(DockLayoutManager manager, DocumentGroup baseGroup, Type controlType, bool autoActivate = false)
        {
            DocumentPanel panel = null;
            if (controlType.GetInterfaces().Contains(typeof (IDocumentPanelManager)))
            {
                // Тип реализует интерфейс
                string controlId = controlType.FullName;
                foreach (
                    DocumentPanel localpanel in
                        baseGroup.Items.Where(
                            x => x is DocumentPanel && (x as DocumentPanel).Control is IDocumentPanelManager))
                {
                    var panelControlId = localpanel.Control.GetType().ToString();
                    if (panelControlId == controlId)
                    {
                        panel = localpanel;
                        break;
                    }
                }

                if (panel == null)
                {
                    // Не найден - создать
                    panel = manager.DockController.AddDocumentPanel(baseGroup);
                    panel.Content = Activator.CreateInstance(controlType);
                    panel.Caption = (panel.Control as IDocumentPanelManager).PanelTitle;
                }
                if (autoActivate)
                    manager.Activate(panel);
            }
            else
            {
                // Тип не реализует интерфейс
                panel = manager.DockController.AddDocumentPanel(baseGroup);
                panel.Content = Activator.CreateInstance(controlType);
                if (autoActivate)
                    manager.Activate(panel);
            }
            return
                panel;
        }
        public void IdentifierGroupDeleteTestNull()
        {
            XmlDocumentGroup xmlDocumentGroup = XmlHelper.GetXmlDocumentGroup(@".\DataContent\NormalContent\cc54a49bf188f994899cb1c954bb795f.xml");
            xmlDocumentGroup.Operation = Operation.Del;
            UploadDocumentGroup uploadDocumentGroup = XmlHelper.GetUploadDocumentGroup(xmlDocumentGroup, @".\DataContent\NormalContent\cc54a49bf188f994899cb1c954bb795f.zip");
            uploadDocumentGroup.Data = null;

            using (ShimsContext.Create())
            {
                ShimDateTime.NowGet = () => new DateTime(2000, 1, 1);

                string ident = string.Empty;
                CrawlerLog log = new CrawlerLog();
                DocumentGroup documentGroup = new DocumentGroup();
                IRepository fakeRepository = new StubIRepository
                {
                    GetIdentifierString = (identifier) => { return string.Empty; },
                    GetOrCreateCrawlerIdString = (crawlerName) => { return 1; },
                    AddDocumentGroupDocumentGroup = (newDocumentGroup) => { documentGroup = newDocumentGroup; },
                    DeleteDocumentGroupString = (identifier) => { ident = identifier; return 1; },
                    AddNewLogCrawlerLog = (crawlerLog) => { log = crawlerLog; }
                };

                WcfHost eu = new WcfHost(fakeRepository);
                var msgActual = eu.UploadFile(uploadDocumentGroup);
                string msgExpected = "Error: Validation Exception - No document idenfier: " + xmlDocumentGroup.Identifier + " .You can't use Operation: Del";

                // ReturnMessage
                Assert.AreEqual(msgExpected, msgActual, "Service return message.");

                // LogAsserts
                Assert.AreEqual(xmlDocumentGroup.Identifier, log.Identifier, "IdentifierLog");
                Assert.AreEqual(false, log.IsSuccess, "IsSuccess");
                Assert.AreEqual(new DateTime(2000, 1, 1), log.LogDate, "LogDate");
                Assert.AreEqual(xmlDocumentGroup.Crawler, log.CrawlerName, "CrawlerNameLog");
                Assert.AreEqual(2, log.Operation, "OperationLog");
            }
        }
        private void AddNewDocumentGroup(
            XmlDocumentGroup xmlDocumentGroup,
            UploadDocumentGroup uploadDocumentGroup,
            Dictionary<string, MemoryStream> documentsData)
        {
            DocumentGroup newDocumentGroup = new DocumentGroup();
            newDocumentGroup.CrawlerId = this.db.GetOrCreateCrawlerId(xmlDocumentGroup.Crawler);
            newDocumentGroup.Identifier = xmlDocumentGroup.Identifier;
            newDocumentGroup.DocumentGroupName = xmlDocumentGroup.FileName;
            newDocumentGroup.DocumentGroupFormat = xmlDocumentGroup.Format;
            newDocumentGroup.Lang = xmlDocumentGroup.Lang;
            newDocumentGroup.Operation = (int)xmlDocumentGroup.Operation;
            newDocumentGroup.DocumentGroupDate = xmlDocumentGroup.Date;

            // Byte Array Data
            newDocumentGroup.DataContent = uploadDocumentGroup.Data;

            List<Document> documents = this.AddDocuments(xmlDocumentGroup.Document, documentsData);
            foreach (Document document in documents)
            {
                newDocumentGroup.Documents.Add(document);
            }

            this.db.AddDocumentGroup(newDocumentGroup);
        }
示例#37
0
        private void TrySetSlot(DocumentGroup group, int? slot)
        {
            if (!slot.HasValue || !(slot <= SlotMax) || group.Slot == slot)
            {
                return;
            }

            // Find out if there is an existing item in the desired slot
            var resident = Groups.FindBySlot((int)slot);
            if (resident != null)
            {
                resident.Slot = null;
            }

            group.Slot = slot;
        }
示例#38
0
        public void SaveGroup(string name, int? slot = null)
        {
            if (DocumentWindowMgr == null)
            {
                Debug.Assert(false, "IVsUIShellDocumentWindowMgr", String.Empty, 0);
                return;
            }

            if (!Package.Environment.GetDocumentWindows().Any())
            {
                return;
            }

            var isBuiltIn = IsBuiltInGroup(name);
            if (isBuiltIn)
            {
                slot = null;
            }

            var group = Groups.FindByName(name);

            var files = new DocumentFilesHashSet(Package.Environment.GetDocumentFiles().OrderBy(Path.GetFileName));
            //var bps = Package.Environment.GetMatchingBreakpoints(files, StringComparer.OrdinalIgnoreCase));

            using (var stream = new VsOleStream())
            {
                var hr = DocumentWindowMgr.SaveDocumentWindowPositions(0, stream);
                if (hr != VSConstants.S_OK)
                {
                    Debug.Assert(false, "SaveDocumentWindowPositions", String.Empty, hr);

                    if (group != null)
                    {
                        Groups.Remove(group);
                    }
                    return;
                }
                stream.Seek(0, SeekOrigin.Begin);

                var documents = String.Join(", ", files.Select(Path.GetFileName));

                if (group == null)
                {
                    group = new DocumentGroup
                    {
                        Name = name,
                        Description = documents,
                        Files = files,
                        Positions = stream.ToArray()
                    };

                    TrySetSlot(group, slot);
                    if (isBuiltIn)
                    {
                        Groups.Insert(0, group);
                    }
                    else
                    {
                        Groups.Add(group);
                    }
                }
                else
                {
                    SaveUndoGroup(group);

                    group.Description = documents;
                    group.Files = files;
                    group.Positions = stream.ToArray();

                    TrySetSlot(group, slot);
                }
            }
        }
示例#39
0
        public void MoveGroup(DocumentGroup group, int delta)
        {
            if (group == null || group.IsBuiltIn)
            {
                return;
            }

            var index = Groups.IndexOf(group);
            var newIndex = index + delta;
            if (newIndex < 0 || newIndex >= Groups.Count)
            {
                return;
            }

            var resident = Groups[newIndex];
            if (resident?.IsBuiltIn == true)
            {
                return;
            }

            Groups.Move(index, newIndex);
        }
示例#40
0
        public void RemoveGroup(DocumentGroup group, bool confirm = true)
        {
            if (group == null)
            {
                return;
            }

            if (confirm)
            {
                var window = new ConfirmDeleteTabsWindow(group.Name);
                if (window.ShowDialog() == false)
                {
                    return;
                }
            }

            SaveUndoGroup(group);
            Groups.Remove(group);
        }
		/// <summary>
		/// check is no more space for next row with height
		/// true, no more spare
		/// false, still got space
		/// 
		/// 20130606 :: mellorasinxelas to abs footer
		/// </summary>
		/// <param name="height"></param>
		/// <param name="group"></param>
		/// <returns></returns>
		public bool isNoMoreY(float height, DocumentGroup group)
		{
			
			switch(group){
				case DocumentGroup.Body:
				case DocumentGroup.Header:
				case DocumentGroup.Loop:
				case DocumentGroup.Table:
					return (Current_y - height <= (Margin_bottom + AbsoluteFooterHeight) );//control with footer
				case DocumentGroup.Footer:
					return (Current_y - height <= Margin_bottom );//without footer h.
					default: return false;
			}
			
			
		}
示例#42
0
        /// <summary>
        /// Draw rowGroup to the Pdf, when goto nextPage, repeat the header!
        /// 201306060 :: mellorasinxelas to write absolute groups
        /// </summary>
        /// <param name="rowGroup"></param>
        /// <param name="data"></param>
        /// <param name="dGroup"></param>
        public void DrawRowGroup(RowGroup rowGroup, System.Collections.IDictionary data, DocumentGroup dGroup)
        {
            bool absolute = false;
            if (rowGroup is Moon.PDFTemplate.FooterGroup)
            {
                absolute = ((Moon.PDFTemplate.FooterGroup)rowGroup).Absolute;
            }

            float oldY = -1;
            bool ignoreAddRow = false;
            if (absolute)
            {
                oldY = PdfDrawer.CurrentY();
                PdfDrawer.SetY(PageDefinition.Margin_bottom + ((rowGroup.Y != -1.0F) ? rowGroup.Y : rowGroup.Height));//20130610 :: Use sY if is stored, otherwise uses Height.
                ignoreAddRow = true; //position has been stored.
            }

            foreach (Row row in rowGroup.Rows)
            {
                if (!absolute)
                {
                    if (PdfDrawer.isNoMoreY(row.Height, dGroup))
                    {
                        NextPage();
                        DrawHeader();
                    }
                }

                if (ignoreAddRow)
                {
                    ignoreAddRow = false;
                }
                else
                {
                    PdfDrawer.NextRow(row.Height, dGroup);
                }

                DrawRow(row.DrawElements, data);
            }

            //returns to old Y value.
            if (absolute)
            {
                PdfDrawer.SetY(oldY);
            }
        }
		/// <summary>
		/// check is no more space for next row with default font height
		/// </summary>
		/// <returns></returns>
		public bool isNoMoreY( DocumentGroup group)
		{
			return isNoMoreY(font.Size, group);
		}
		/// <summary>
		/// move y to next row with height
		/// 20130606 :: Modified to absolute footer.
		/// </summary>
		/// <param name="height"></param>
		/// <param name="group"></param>
		public void NextRow(float height, DocumentGroup group)
		{
			Current_y -= height + 1;
			Current_x = Margin_left;
			
			if(group != DocumentGroup.Footer){
				if(Current_y < Margin_bottom)
				{
					NextPage();
				}
			}
			#if DEBUG
			//Console.WriteLine("NextRow() Current_y: " + Current_y);
			#endif
		}
		/// <summary>
		/// move y to next row with default font height
		/// </summary>
		public void NextRow(DocumentGroup group)
		{
			NextRow(font.Size + 1, group);
		}
示例#46
0
        public void OpenGroup(DocumentGroup group)
        {
            if (group == null)
            {
                return;
            }

            using (var stream = new VsOleStream())
            {
                stream.Write(group.Positions, 0, group.Positions.Length);
                stream.Seek(0, SeekOrigin.Begin);

                var hr = DocumentWindowMgr.ReopenDocumentWindows(stream);
                if (hr != VSConstants.S_OK)
                {
                    Debug.Assert(false, "ReopenDocumentWindows", String.Empty, hr);
                }
            }
        }
示例#47
0
        public void CloseGroup(DocumentGroup group)
        {
            if (group?.Files == null)
            {
                return;
            }

            var documents = from d in Package.Environment.GetDocuments()
                            where @group.Files.Contains(d.FullName)
                            select d;
            documents.CloseAll();
        }
		/// <summary>
		/// is the Current_x already reach to the right side
		/// </summary>
		/// <returns></returns>
		public bool isNoMoreX( DocumentGroup group)
		{
			bool r = false;
			if (Current_x >= pageSize.Width - Margin_right)
			{
				r = true;
			}
			return r;
		}
示例#49
0
        public void SetGroupSlot(DocumentGroup group, int slot)
        {
            if (group == null || group.Slot == slot)
            {
                return;
            }

            var resident = Groups.FindBySlot(slot);

            group.Slot = slot;

            if (resident != null)
            {
                resident.Slot = null;
            }
        }
		/// <summary>
		/// from the current_x, can it fit a width?
		/// </summary>
		/// <param name="width"></param>
		/// <param name="group"></param>
		/// <returns></returns>
		public bool canFitWidth(float width, DocumentGroup group)
		{
			bool r = true;
			if (Current_x + width > pageSize.Width - Margin_right)
			{
				r = false;
			}
			return r;
		}
示例#51
0
        public void RestoreGroup(DocumentGroup group)
        {
            if (group == null)
            {
                return;
            }

            var windows = Package.Environment.GetDocumentWindows();
            if (!IsUndoGroup(group.Name) && windows.Any())
            {
                SaveUndoGroup();
            }

            Package.Environment.Documents.CloseAll();

            OpenGroup(group);
        }
        private static void StartEditing(ListView list, ListViewItem item, DocumentGroup group, Action<TextBox, bool> endEditingFn)
        {
            var edit = item.FindDescendant<TextBox>();

            var visibility = Observable.FromEventPattern<DependencyPropertyChangedEventArgs>(edit, "IsVisibleChanged");

            var disposables = new CompositeDisposable();

            visibility.Where(re => re.EventArgs.NewValue as bool? == false)
                      .Take(1)
                      .Subscribe(re => disposables.Dispose());

            visibility.Where(ivc => ivc.EventArgs.NewValue as bool? == true)
                      .Take(1)
                      .Subscribe(re =>
                                 {
                                     edit.SelectionStart = 0;
                                     edit.SelectionLength = edit.Text.Length;
                                     edit.Focus();
                                 });

            disposables.Add(Observable.FromEventPattern<RoutedEventArgs>(edit, "LostFocus")
                                      .Take(1)
                                      .Subscribe(re => endEditingFn(edit, false)));

            disposables.Add(Observable.FromEventPattern<KeyEventArgs>(edit, "PreviewKeyUp")
                                      .Where(re => re.EventArgs.Key == Key.Escape || re.EventArgs.Key == Key.Enter)
                                      .Take(1)
                                      .Subscribe(re =>
                                                 {
                                                     re.EventArgs.Handled = true;
                                                     endEditingFn(edit, re.EventArgs.Key == Key.Escape);
                                                 }));

            disposables.Add(Observable.FromEventPattern<MouseEventArgs>(list, "MouseLeftButtonDown")
                                      .Take(1)
                                      .Subscribe(re => endEditingFn(edit, false)));

            group.StartEditing();
        }
示例#53
0
        private void SaveUndoGroup(DocumentGroup group)
        {
            var undo = Groups.FindByName(UndoGroupName);

            if (undo == null)
            {
                undo = new DocumentGroup
                {
                    Name = UndoGroupName,
                    Description = group.Description,
                    Files = group.Files,
                    Positions = group.Positions
                };

                Groups.Insert(0, undo);
            }
            else
            {
                undo.Description = group.Description;
                undo.Files = group.Files;
                undo.Positions = group.Positions;
            }
        }