예제 #1
0
        private void RemoveItem(TreeNode item)
        {
            if (item.Tag is Folder)
            {
            }
            else if (item.Tag is DocumentItem)
            {
                DocumentItem docItem = (DocumentItem)item.Tag;

                if (docItem.ProjectDocument.ReadOnly && !docItem.ProjectDocument.Checkout())
                {
                    return;
                }

                m_manager.Project.RemoveDocument(docItem);
            }
        }
        public async void TestAdd()
        {
            await SetUp();

            var item = new DocumentItem(null);

            item.Name = "default.my";
            _feature.InsertItem(_feature.Items.FindIndex(i => i.Flag == "Local"), item);
            Assert.NotNull(_feature.SelectedItem);
            Assert.Equal("default.my", _feature.SelectedItem.Name);

            const string Original     = @"original.config";
            const string OriginalMono = @"original.mono.config";

            XmlAssert.Equal(Helper.IsRunningOnMono() ? OriginalMono : Original, Current);
            XmlAssert.Equal(Path.Combine("DefaultDocument", "expected_add.site.config"), Path.Combine("Website1", "web.config"));
        }
예제 #3
0
        private void LoadTemplate()
        {
            templateWasLoaded = false;
            model.SetImageRunSource(runIconsList["stop"]);
            RunMenuItem.IsEnabled           = false;
            textBoxListViewLable.Text       = "Loading pattern...";
            textBoxListViewLable.Visibility = Visibility.Visible;

            documentManager.ReadDataFromTemplateAsync((task) =>
            {
                var attributes = documentManager.DocumentsStorage.GetUsedDocumentAttributes();
                InitColumnToListView(attributes);

                var documentItems = new ConcurrentDictionary <string, DocumentItem>();
                foreach (var document in documentManager.DocumentsStorage.GetDocuments())
                {
                    var newDocumentItem = new DocumentItem(document, attributes);
                    int validateStatus  = documentManager.ValidateDocument(document);
                    if (0 != (validateStatus & (int)DocumentManager.ValidateStatus.Warning))
                    {
                        newDocumentItem.Status = DocumentItem.DocumentStatus.WarningOccured;
                    }

                    if (0 != (validateStatus & (int)DocumentManager.ValidateStatus.Error))
                    {
                        newDocumentItem.Status = DocumentItem.DocumentStatus.ErrorOccured;
                    }

                    newDocumentItem.State = DocumentItem.DocumentState.Loaded;
                    documentItems.AddOrUpdate(document.Identifier,
                                              (id) => newDocumentItem,
                                              ((s, item) => newDocumentItem));
                }

                gridView.Dispatcher?.BeginInvoke(new NoArgDelegate(() =>
                {
                    textBoxListViewLable.Visibility = Visibility.Hidden;
                    model.SetDocuments(documentItems);
                    model.SetImageRunSource(runIconsList["start"]);
                    RunMenuItem.IsEnabled = true;
                    var view = (CollectionView)CollectionViewSource.GetDefaultView(listView.ItemsSource);
                    view.SortDescriptions.Add(new SortDescription("Identifier", ListSortDirection.Ascending));
                }), DispatcherPriority.Input);
                templateWasLoaded = true;
            });
        }
예제 #4
0
        public void RemoveDocument(DocumentItem doc)
        {
            ProjectDocument projDoc = doc.ProjectDocument;

            if (projDoc.ReadOnly)
            {
                throw new ReadOnlyDocumentException(projDoc);
            }

            // Remove from the tree
            doc.Parent.Items.Remove(doc);

            // Remove from project file
            projDoc.RemoveDocument(doc);

            projDoc.Modified = true;
        }
예제 #5
0
        private async Task CreateModel(List <ItemDto> items, ItemDto parentId, DocumentItem parent, DocumentItem paragraph, DocumentLoader loader)
        {
            var query = items.Where(f => f.ParentId == parentId);

            foreach (var item in query)
            {
                var documentItem = new DocumentItem();
                documentItem.DocumentLoader = loader;
                documentItem.Number         = item.Number;
                documentItem.IsRootItem     = item.IsRoot;
                documentItem.TextContent    = item.TextContent;
                documentItem.Parent         = parent;
                documentItem.Paragraph      = paragraph;
                await _wordDbContext.AddAsync(documentItem);
                await CreateModel(items, item, documentItem, paragraph, loader);
            }
        }
예제 #6
0
        public async Task <IActionResult> OnPostAsync(Guid?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            DocumentItem = await _context.Documents.FindAsync(id);

            if (DocumentItem != null)
            {
                _context.Documents.Remove(DocumentItem);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
예제 #7
0
        public ActionResult SubmitRequisition()
        {
            var unitofwork = new UnitOfWork();
            List <RequisitionItemVM> vmList = (List <RequisitionItemVM>)Session["RequestList"];

            //RequisitionItemVM rcvm = new RequisitionItemVM;
            Debug.WriteLine(vmList.Count);
            foreach (RequisitionItemVM vm in vmList)
            {
                Debug.WriteLine(vm.Quantity);
            }

            List <DocumentItem> doitems = new List <DocumentItem>();

            if (ModelState.IsValid)
            {
                foreach (RequisitionItemVM rcvm in vmList)
                {
                    if (rcvm.Quantity != 0)
                    {
                        Item         item   = unitofwork.ItemRepository.GetItembyDescrption(rcvm.SelectedDescription);
                        DocumentItem doitem = unitofwork.DocumentItemRepository.InsertDocumentItembyItemandQty(item, rcvm.Quantity);

                        doitems.Add(doitem);
                        unitofwork.Save();
                    }
                }

                Staff            staff = loginService.StaffFromSession;
                RequisitionOrder rq    = new RequisitionOrder(unitofwork.StaffRepository.GetByID(staff.ID));

                rq.DocumentItems = doitems;

                unitofwork.RequisitionOrderRepository.Insert(rq);

                unitofwork.Save();
                Debug.WriteLine("rq.ID:" + rq.ID);

                Session["RequestList"] = null;

                return(RedirectToAction("Index"));
            }

            return(View());
        }
        public void TestAdd()
        {
            SetUp();
            const string Expected     = @"expected_add.config";
            const string ExpectedMono = @"expected_add.mono.config";

            var item = new DocumentItem(null);

            item.Name = "default.my";
            _feature.InsertItem(_feature.Items.FindIndex(i => i.Flag == "Local"), item);
            Assert.NotNull(_feature.SelectedItem);
            Assert.Equal("default.my", _feature.SelectedItem.Name);
            XmlAssert.Equal(
                Helper.IsRunningOnMono()
                    ? Path.Combine("DefaultDocument", ExpectedMono)
                    : Path.Combine("DefaultDocument", Expected),
                Current);
        }
        public Form_Dialog_Edit(DocumentItem ii)
        {
            InitializeComponent();
            if (ii.GetType() == typeof(DocumentData))
            {
            }
            DocumentData d = (DocumentData)ii;

            dat  = (DocumentData)d.Clone();
            bkp  = (DocumentData)d.Clone();
            Text = TB.L.Phrase["Form_Dialog_Edit.Editing"] + " '" + dat.Name + "'";
            dat.BaseData.Save("Temp\\backup" + cc.ToString() + ".pcv");
            d.BaseData.RawData = d.BaseData.RawData.ToList().OrderByDescending(p => p.Length).ToArray();
            RefillTree();
            gr2 = dat.BaseData.GrPath;
            label_ndresol.Text = TB.L.Phrase["Form_Dialog_Edit.Resolution"] + ": " + dat.BaseData.Resolution;
            label_2ndname.Text = TB.L.Phrase["Form_Dialog_Edit.NameCurrent"] + ": " + new FileInfo(dat.BaseData.Filename).Directory.Name + "\\" + new FileInfo(dat.BaseData.Filename).Name;
        }
예제 #10
0
        private void LstDD_ItemTapped(object sender, ItemTappedEventArgs e)
        {
            DocumentItem di = new DocumentItem();

            di = (DocumentItem)e.Item;

            string docName    = di.DocumentItemTitle;
            bool   isFavorite = di.IsFavorite;

            di = null;

            ViewDocument dd       = new ViewDocument(docName, isFavorite);
            Label        lblTitle = dd.FindByName <Label>("lblVDTitle");

            lblTitle.Text = "Policies And Procedures";

            Navigation.PushAsync(dd);
            dd = null;
        }
예제 #11
0
        public void TestAdd()
        {
            SetUp();
            const string Expected = @"expected_add.config";
            var          document = XDocument.Load(Current);
            var          node     = document.Root.XPathSelectElement("/configuration/system.webServer/defaultDocument/files");
            var          add      = new XElement("add",
                                                 new XAttribute("value", "default.my"));

            node?.AddFirst(add);
            document.Save(Expected);

            var item = new DocumentItem(null);

            item.Name = "default.my";
            _feature.InsertItem(_feature.Items.FindIndex(i => i.Flag == "Local"), item);
            Assert.NotNull(_feature.SelectedItem);
            Assert.Equal("default.my", _feature.SelectedItem.Name);
            XmlAssert.Equal(Expected, Current);
        }
예제 #12
0
        public void Execute_InsertImageInvoked()
        {
            // Arrange
            var imageDocumentItem = new DocumentItem(new ImageClass("", "", 1, 1));

            bool isInsertImageInvoked = false;

            _documentMock
            .Setup(d => d.InsertImage(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>()))
            .Callback(() => isInsertImageInvoked = true);

            _documentMock.Setup(d => d.GetItem(It.IsAny <int>())).Returns(imageDocumentItem);
            ICommand command = new InsertImageCommand("", 1, 1, _documentMock.Object, 1);

            // Act
            command.Execute();

            // Assert
            Assert.True(isInsertImageInvoked);
        }
예제 #13
0
 private void LoadFilesFromVCProj(XmlElement rootNode, ProjectItem rootItem)
 {
     foreach (XmlElement element in rootNode.SelectNodes("Filter|File"))
     {
         if (element.Name == "Filter")
         {
             Folder folder = new Folder(element.GetAttribute("Name"));
             folder.ProjectTag = element;
             rootItem.Items.Add(folder);
             LoadFilesFromVCProj(element, folder);
         }
         else if (element.Name == "File")
         {
             string       fileName = element.GetAttribute("RelativePath");
             DocumentItem doc      = new DocumentItem(PathUtils.NormaliseFileName(fileName, BaseDirectory), Manager.FindFileDocumentType(fileName));
             doc.ProjectTag = element;
             rootItem.Items.Add(doc);
         }
     }
 }
예제 #14
0
        public void Execute_InsertParagraphInvoked()
        {
            // Arrange
            var paragrpahDocumentItem = new DocumentItem(new Paragraph.Paragraph(""));

            bool isInsertParagraphInvoked = false;

            _documentMock
            .Setup(d => d.InsertParagraph(It.IsAny <string>(), It.IsAny <int>()))
            .Callback(() => isInsertParagraphInvoked = true);

            _documentMock.Setup(d => d.GetItem(It.IsAny <int>())).Returns(paragrpahDocumentItem);
            ICommand command = new InsertParagraphCommand("", _documentMock.Object, 1);

            // Act
            command.Execute();

            // Assert
            Assert.True(isInsertParagraphInvoked);
        }
예제 #15
0
        public async Task Record(string client, string documentId, IEnumerable <string> keywords)
        {
            if (string.IsNullOrWhiteSpace(client) || string.IsNullOrWhiteSpace(documentId) || keywords == null)
            {
                _logger.LogWarning($"Invalid input, keywords not persisted for client {client}, documentId {documentId}");
                return;
            }

            var documentItem = new DocumentItem
            {
                Client     = client,
                DocumentId = documentId,
                Keywords   = string.Join(',', keywords)
            };

            await _context.DocumentItems.AddAsync(documentItem);

            await _context.SaveChangesAsync();

            _logger.LogInformation($"Successfully persisted result for client: {client}, document: {documentId}");
        }
예제 #16
0
        public ServiceResponse AddDocumentExcludingDb(DocumentItem model)
        {
            DateTime startTime      = DateTime.Now;
            var      documentFacade = this.Container.GetInstance <DocumentFacade>();

            try
            {
                documentFacade.AddToLibrary(model.AppUniqueId, model.OrganizationName, model.Name, model.OriginalName, model.StaffOnly, base.Email, model.RequestValues, false);

                base.LogMessage("Add", DateTime.Now - startTime);

                return(new ServiceResponse());
            }
            catch (Exception ex)
            {
                return(new ServiceResponse
                {
                    HasError = true,
                    Message = ex.Message
                });
            }
        }
예제 #17
0
        public ActionResult delete(int id, int DID, int menuid)
        {
            //int Empid = Convert.ToInt32(Url.RequestContext.RouteData.Values["id"].ToString());
            DocumentService objService = new DocumentService();
            List <EMSDomain.ViewModel.DocumentItem> lstDoc = new List <EMSDomain.ViewModel.DocumentItem>();
            DocumentItem objDoc = new DocumentItem();

            objDoc = objService.GetById(DID);
            string path     = objDoc.FileUrl;
            var    fullPath = Server.MapPath(path);

            db.EmployeeDocuments.Remove(db.EmployeeDocuments.Find(DID));
            db.SaveChanges();
            if (System.IO.File.Exists(fullPath))
            {
                System.IO.File.Delete(fullPath);
            }
            //ViewBag.Empid = Empid;
            ViewBag.Menuid = Request.QueryString["menuId"];

            return(RedirectToAction("Index", new { @id = id, @menuId = Request.QueryString["menuId"] }));
        }
예제 #18
0
        public ActionResult Edit([Bind(Include = "SelectedCategory,SelectedDescription,Quantity,ROID")] RequisitionItemVM rcvm)
        {
            var unitofwork = new UnitOfWork();

            Debug.WriteLine(rcvm.SelectedCategory + "\n" + rcvm.SelectedDescription + " x " + rcvm.Quantity.ToString());

            Debug.WriteLine(rcvm.ROID);
            // Debug.WriteLine(rcvm.RequisitionOrderID);
            if (ModelState.IsValid)
            {
                //get item by itemID
                Item item = unitofwork.ItemRepository.GetItembyDescrption(rcvm.SelectedDescription);
                Debug.WriteLine(item.ID);

                //save this item into the doucumentitem(item, qty)
                DocumentItem doitem = unitofwork.DocumentItemRepository.InsertDocumentItembyItemandQty(item, rcvm.Quantity);

                //doitem.Document.ID = rcvm.ROID;
                unitofwork.Save();
                Debug.WriteLine(doitem.ID);

                RequisitionOrder rq = new RequisitionOrder(unitofwork.StaffRepository.GetByID(10006));
                rq.DocumentItems.Add(unitofwork.DocumentItemRepository.GetByID(doitem.ID));
                rq.ID = rcvm.ROID;
                Debug.WriteLine(rq.ID);


                unitofwork.RequisitionOrderRepository.Insert(rq);
                Debug.WriteLine(rq.ID);

                unitofwork.Save();
                Debug.WriteLine(rq.ID);

                return(RedirectToAction("Index"));
            }

            return(View(rcvm));
        }
예제 #19
0
        public void AddDocument(ProjectItem folder, DocumentItem fileItem)
        {
            ProjectDocument projDoc = folder.ProjectDocument;

            if (projDoc.ReadOnly)
            {
                throw new ReadOnlyDocumentException(projDoc);
            }

            // Insert it into the tree
            folder.Items.InsertSorted(fileItem,
                                      delegate(ProjectItem lhs, ProjectItem rhs)
            {
                string lhsName = lhs is DocumentItem ? (lhs as DocumentItem).RelativeFileName : lhs.Label;
                string rhsName = rhs is DocumentItem ? (rhs as DocumentItem).RelativeFileName : rhs.Label;
                return(String.Compare(lhsName, rhsName, true));
            });

            // Add to project file
            projDoc.AddDocument(folder, fileItem);

            projDoc.Modified = true;
        }
예제 #20
0
        private void LstDDT_ItemTapped(object sender, ItemTappedEventArgs e)
        {
            try
            {
                DocumentItem di = new DocumentItem();
                di = (DocumentItem)e.Item;

                string docName = di.DocumentItemTitle;
                isFavorite = di.IsFavorite;
                di         = null;

                ViewDocument dd       = new ViewDocument(docName, isFavorite);
                Label        lblTitle = dd.FindByName <Label>("lblVDTitle");
                lblTitle.Text = "Policies And Procedures";

                Navigation.PushAsync(dd);
                dd = null;
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
            }
        }
예제 #21
0
        private void addExistingItemToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (projectView.SelectedNode == null)
            {
                return;
            }

            Folder folder = FindFolder(projectView.SelectedNode);

            if (folder == null)
            {
                return;
            }

            if (folder.ProjectDocument.ReadOnly && !folder.ProjectDocument.Checkout())
            {
                return;
            }

            DialogResult result = openExistingFileDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                foreach (string fileName in openExistingFileDialog.FileNames)
                {
                    string ext     = Path.GetExtension(fileName);
                    Type   docType = m_manager.FindFileDocumentType(ext);
                    if (docType == null)
                    {
                        MessageBox.Show(m_mainWindow, "Unknown file type for '" + fileName + "'");
                        continue;
                    }
                    DocumentItem docItem = m_manager.Project.AddDocument(folder, fileName, docType);
                    m_manager.ShowDocument(docItem);
                }
            }
        }
예제 #22
0
        private void buttonUpdateDocument_Click(object sender, EventArgs e)
        {
            if (dataGridViewAllLists.SelectedRows.Count < 1)
            {
                MessageBox.Show("Select one document");
                return;
            }

            _docId = Convert.ToInt32(dataGridViewAllLists.SelectedRows[0].Cells[0].Value);

            _formEditDocument = new FormEditDocument(_docId, DependencyInjector.Retrieve <IWebApiClientManager>());
            DialogResult dialogresult = _formEditDocument.ShowDialog(this);

            if (dialogresult == DialogResult.Cancel)
            {
                _formEditDocument.Close();
            }
            else if (dialogresult == DialogResult.OK)
            {
                try
                {
                    var titleDocument = _formEditDocument.TitleDocument;
                    var createdate    = DateTime.Now;
                    var clientNumber  = _formEditDocument.ClientNumber;
                    _documentItem = new DocumentItem {
                        Id = _docId, Title = titleDocument, Date = createdate, ClientNumber = clientNumber
                    };
                    _webApiClient.UpdateDocument(_documentItem);
                    GetAllDocuments();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(" " + ex);
                    _log.Error(ex);
                }
            }
        }
예제 #23
0
        public InfoDocument CreateInfoDocument(DocumentItem rootDocItem)
        {
            InfoDocument infoDocument = new InfoDocument();

            infoDocument.Title = rootDocItem.TextContent;


            InfoCategoty infoCategoty1 = CreateCategory(rootDocItem, "Категория", "1");
            InfoCategoty infoCategoty2 = CreateCategory(rootDocItem, "Образование и стаж", "2");
            InfoCategoty infoCategoty3 = CreateCategory(rootDocItem, "Назначение на должность", "3");
            InfoCategoty infoCategoty4 = CreateCategory(rootDocItem, "Требования к знаниям", "4");
            InfoCategoty infoCategoty5 = CreateCategory(rootDocItem, "Подчинение", "5");
            InfoCategoty infoCategoty6 = CreateCategory(rootDocItem, "Правила замещения", "6");

            infoDocument.Items = new List <InfoCategoty>();
            infoDocument.Items.Add(infoCategoty1);
            infoDocument.Items.Add(infoCategoty2);
            infoDocument.Items.Add(infoCategoty3);
            infoDocument.Items.Add(infoCategoty4);
            infoDocument.Items.Add(infoCategoty5);
            infoDocument.Items.Add(infoCategoty6);

            return(infoDocument);
        }
예제 #24
0
        public Result DeleteDocumentItem(string docItemObjectId)
        {
            Result output = new Result();

            output.Status = ResultStatus.BadRequest;

            try
            {
                using (var ctx = new EWUSDbContext())
                {
                    DocumentItem documentItem = ctx.DocumentItems.Where(x => x.ObjectId == docItemObjectId).FirstOrDefault();
                    ctx.DocumentItems.Remove(documentItem);

                    ctx.SaveChanges();
                }
                output.Status = ResultStatus.OK;
            }
            catch
            {
                output.Status = ResultStatus.InternalServerError;
            }

            return(output);
        }
예제 #25
0
        public ActionResult Edit([Bind(Include = "ID, CreatedByStaffID, RepliedByStaffID, Comments, Supplier, CreatedDate, ResponseDate, Status, PurchaseOrderID, TransactionItems")] DeliveryOrderVM deliveryOrderVM, int?id)
        {
            //if (ModelState.IsValid)
            //{

            List <DocumentItem>    deliveredItems = new List <DocumentItem>();
            List <TransactionItem> items          = deliveryOrderVM.TransactionItems;

            //Check if Delivery Incomplete
            bool incomplete = false;

            foreach (TransactionItem ti in items)
            {
                if (ti.TakeOverQty < ti.HandOverQty)
                {
                    incomplete = true;
                }
                DocumentItem di = new DocumentItem(ti, uow);
                if (di.Qty != 0)
                {
                    deliveredItems.Add(di);
                }
            }

            //Update PurchaseOrder Status
            PurchaseOrder PO = uow.PurchaseOrderRepository.GetByPurchaseOrderID(id);

            if (incomplete)
            {
                Debug.WriteLine("Incomplete True");
                PO.InProgress();
                uow.PurchaseOrderRepository.Update(PO);
                uow.Save();
            }
            else
            {
                Debug.WriteLine("Complete True");
                PO.Completed();
                uow.PurchaseOrderRepository.Update(PO);
                uow.Save();
            }

            Staff currentUser = loginService.StaffFromSession;

            //Create DeliveryOrder

            DeliveryOrder deliveryOrder = new DeliveryOrder(currentUser, PO.Supplier, PO);

            deliveryOrder.DocumentItems = deliveredItems;
            bool result = uow.StockCardEntryRepository.ProcessDeliveryOrderAcceptance(deliveryOrder);
            //update inventory
            InventoryService inventoryService = new InventoryService();

            foreach (DocumentItem di in deliveredItems)
            {
                inventoryService.UpdateInStoreQty(di.Item.ID);
            }

            if (result)
            {
                uow.DeliveryOrderRepository.Insert(deliveryOrder);
                uow.Save();
                return(RedirectToAction("Index"));
            }
            else
            {
                ViewBag.CreatedByStaffID = new SelectList(db.Staffs, "ID", "UserAccountID", deliveryOrderVM.CreatedByStaffID);
                ViewBag.RepliedByStaffID = new SelectList(db.Staffs, "ID", "UserAccountID", deliveryOrderVM.RepliedByStaffID);
                return(View(deliveryOrderVM));
            }
            //}
            //ViewBag.CreatedByStaffID = new SelectList(db.Staffs, "ID", "UserAccountID", deliveryOrderVM.CreatedByStaffID);
            //ViewBag.RepliedByStaffID = new SelectList(db.Staffs, "ID", "UserAccountID", deliveryOrderVM.RepliedByStaffID);
            //return View(deliveryOrderVM);
        }
        public void TryTransactionScope()
        {
            int count;

            TryDeleteAllTestData();

            var countryItems = GetCountryItems();

            var documentItems = new List <DocumentItem>
            {
                GetDocumentItem(ContactTestFixtureData.Keys.Document[1]),
                GetDocumentItem(ContactTestFixtureData.Keys.Document[2]),
                GetDocumentItem(ContactTestFixtureData.Keys.Document[3])
            };

            var addressItems = new List <AddressItem>
            {
                GetAddressItem(ContactTestFixtureData.Keys.Address[1]),
                GetAddressItem(ContactTestFixtureData.Keys.Address[2]),
                new AddressItem()
            };

            try
            {
                var countryItemsSaved = new List <CountryItem>(countryItems.Count);

                count = countryItems.Count;
                for (var i = 0; i < count; i++)
                {
                    CountryItem countryItemSaved = ContactAgentFactory
                                                   .CreateCountryAgent()
                                                   .SaveCountryItem(countryItems[i]);
                    Debug.WriteLineIf(countryItemSaved.HasErrors, "Error saving countryitem " + (i + 1) + " / " + count + "\n\t" + countryItemSaved.Errors);
                    countryItemsSaved.Add(countryItemSaved);
                }

                using (var scope = new TransactionScope())
                {
                    var addressItemsSaved  = new List <AddressItem>(addressItems.Count);
                    var documentItemsSaved = new List <DocumentItem>(documentItems.Count);

                    count = documentItems.Count;
                    for (var i = 0; i < count; i++)
                    {
                        DocumentItem documentItemSaved = ContactAgentFactory
                                                         .CreateDocumentAgent()
                                                         .SaveDocumentItem(documentItems[i]);
                        documentItemsSaved.Add(documentItemSaved);
                    }

                    count = addressItems.Count;
                    for (var i = 0; i < count; i++)
                    {
                        AddressItem addressItemSaved = ContactAgentFactory
                                                       .CreateAddressAgent()
                                                       .SaveAddressItem(addressItems[i]);
                        Debug.WriteLineIf(addressItemSaved.HasErrors, "Error saving AddressItem " + (i + 1) + " / " + count + "\n\tError = " + GetErrorString(addressItemSaved.Errors));
                        addressItemsSaved.Add(addressItemSaved);
                    }

                    bool succes = !(from i in documentItemsSaved where i.HasErrors select i).Any() & !(from i in addressItemsSaved where i.HasErrors select i).Any();

                    if (succes)
                    {
                        scope.Complete();
                        Debug.WriteLine("OK");
                    }
                    else
                    {
                        throw new ApplicationException(GetErrorString(addressItemsSaved.ToArray()) + GetErrorString(documentItemsSaved.ToArray()));
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error(s) occured.\n" + ex.Message);
            }
        }
        public void TryGetRelationAddresses()
        {
            IContactAgent agent = ContactAgentFactory.CreateContactAgent();

            List <DocumentItem>         documentItemsSaved;
            List <AddressItem>          addressItemsSaved;
            RelationItem                relationItemSaved;
            List <RelationAddressItem>  relationAddressItemsSaved;
            List <RelationDocumentItem> relationDocumentItemsSaved;
            List <CountryItem>          countryItemsSaved;

            AddressItem[] addressItems;
            int           count = 0;

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    Debug.WriteLine("Creating all objects on " + DateTime.Now);
                    List <AddressItem>          addressItemsNew          = GetAddressItems(2);
                    List <CountryItem>          countryItemsNew          = GetCountryItems(2);
                    List <DocumentItem>         documentItemsNew         = GetDocumentItems(2);
                    RelationItem                relationItemNew          = GetRelationItem();
                    List <RelationAddressItem>  relationAddressItemsNew  = GetRelationAddressItems(2);
                    List <RelationDocumentItem> relationDocumentItemsNew = GetRelationDocumentItems(2);

                    Debug.WriteLine("All objects in memory on {0}", DateTime.Now);

                    Debug.WriteLine("Saving all objects");

                    count             = countryItemsNew.Count;
                    countryItemsSaved = new List <CountryItem>(count);
                    Debug.WriteLine("Saving countries objects");
                    for (int i = 0; i < count; i++)
                    {
                        CountryItem countryItemSaved = agent.SaveCountryItem(countryItemsNew[i]);
                        Debug.WriteLine("CountryItem {0} / {1} saved {2}on {3}", (i + 1), count, (countryItemSaved.HasErrors ? "with errors " : ""), DateTime.Now);
                        countryItemsSaved.Add(countryItemSaved);
                    }

                    count = documentItemsNew.Count;
                    documentItemsSaved = new List <DocumentItem>(count);
                    Debug.WriteLine("Saving documents objects");
                    for (int i = 0; i < count; i++)
                    {
                        DocumentItem documentItemSaved = agent.SaveDocumentItem(documentItemsNew[i]);
                        Debug.WriteLine("DocumentItem {0} / {1} saved {2}on {3}", (i + 1), count, (documentItemSaved.HasErrors ? "with errors " : ""), DateTime.Now);
                        documentItemsSaved.Add(documentItemSaved);
                    }

                    relationItemSaved = agent.SaveRelationItem(relationItemNew);
                    Debug.WriteLine("AddressItem saved {0}on {1}", (relationItemSaved.HasErrors ? "with errors " : ""), DateTime.Now);

                    count             = addressItemsNew.Count;
                    addressItemsSaved = new List <AddressItem>(count);
                    Debug.WriteLine("Saving addresses objects");
                    for (int i = 0; i < count; i++)
                    {
                        AddressItem addressItemSaved = agent.SaveAddressItem(addressItemsNew[i]);
                        Debug.WriteLine("CountryItem {0} / {1} saved {2}on {3}", (i + 1), count, (addressItemSaved.HasErrors ? "with errors " : ""), DateTime.Now);
                        addressItemsSaved.Add(addressItemSaved);
                    }

                    count = relationAddressItemsNew.Count;
                    relationAddressItemsSaved = new List <RelationAddressItem>(count);
                    Debug.WriteLine("Saving RelationAddress objects");
                    for (int i = 0; i < count; i++)
                    {
                        RelationAddressItem relationAddressItemSaved = agent.SaveRelationAddressItem(relationAddressItemsNew[i]);
                        Debug.WriteLine("RelationAddressItem {0} / {1} saved {2}on {3}", (i + 1), count, (relationAddressItemSaved.HasErrors ? "with errors " : ""), DateTime.Now);
                        relationAddressItemsSaved.Add(relationAddressItemSaved);
                    }

                    count = relationDocumentItemsNew.Count;
                    relationDocumentItemsSaved = new List <RelationDocumentItem>(count);
                    Debug.WriteLine("Saving RelationDocument objects");
                    for (int i = 0; i < count; i++)
                    {
                        RelationDocumentItem relationDocumentItemSaved = agent.SaveRelationDocumentItem(relationDocumentItemsNew[i]);
                        Debug.WriteLine("RelationDocumentItem {0} / {1} saved {2}on {3}", (i + 1), count, (relationDocumentItemSaved.HasErrors ? "with errors " : ""), DateTime.Now);
                        relationDocumentItemsSaved.Add(relationDocumentItemSaved);
                    }

                    Debug.WriteLine("All objects saved");

                    Debug.WriteLine("Before commiting transaction");
                    scope.Complete();
                    Debug.WriteLine("Commit transaction completed");
                }
                addressItems = agent.GetAddressItemsForRelation(ContactTestFixtureData.Keys.Relation[1]);
            }
            catch (Exception e)
            {
                Debug.WriteLine("Error(s) occured\n" + e.Message);
            }
        }
예제 #28
0
 public void Execute()
 {
     _documentItem = _documentItems [_index];
     _documentItems.RemoveAt(_index);
 }
예제 #29
0
        private async Task UpdateParagraph(List <DocumentItem> items, DocumentItem parent, DocumentItem paragraph)
        {
            var query = items.Where(f => f.ParentId == parent.Id);

            foreach (var item in query)
            {
                using (var connection = new MySqlConnection(_dataBaseMain.ConntectionString))
                {
                    await connection.ExecuteAsync(
                        $"Update documentItem set paragraphId = {paragraph.Id} where Id = {item.Id}");
                }
                await UpdateParagraph(items, item, paragraph);
            }
        }
예제 #30
0
        private void GetOnlineDocuments()
        {
            WebMethods webapi = new WebMethods();

            if (DataItems != null)
            {
                SetDocumentDetails();
            }
            else
            {
                webapi.GetPolicies();
            }

            webapi.policysEvent += ((WebMethods webAPISender, EventArgs e2) =>
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    PolicyModel.DocType[] PolicyDocTypes = SimpleJson.DeserializeObject <PolicyModel.DocType[]>(webAPISender.Polocysresponse);

                    List <Policies> OfflineList = new List <Policies>();

                    foreach (PolicyModel.DocType dst in PolicyDocTypes)
                    {
                        DataItems = new ObservableCollection <DocumentItem>();

                        int i = 0;
                        PolicySubTypes = new string[5];
                        foreach (PolicyModel.DocSubType pd in dst.DocSubTypes)
                        {
                            PolicySubTypes[i] = pd.Name.ToString();
                            DocumentType dt3 = new DocumentType {
                                DocumentTypeId = i, DocumentTypeTitle = pd.Name.ToString()
                            };
                            int j = 0;
                            foreach (PolicyModel.Document orgDoc in pd.Documents)
                            {
                                //await App.PersonRepo.AddNewPersonAsync(orgDoc.DocumentName);
                                DocumentItem pdi = new DocumentItem();
                                pdi.DocumentItemId = j;
                                pdi.DocumentItemTitle = orgDoc.DocumentName;
                                pdi.DocumentType = dt3;

                                DataItems.Add(pdi);

                                //from here
                                Policies OfflineSingleP = new Policies();
                                OfflineSingleP.DocName = orgDoc.DocumentName;
                                OfflineList.Add(OfflineSingleP);
                                OfflineSingleP = null;

                                //till here

                                j = j + 1;
                            }
                            i = i + 1;
                        }
                        //DocumentTypes = new ObservableCollection<Grouping<SelectDocumentTypeViewModel, DocumentItem>>();

                        if (DataItems != null)
                        {
                            SetDocumentDetails();
                        }
                    }
                });
            });
        }
 protected DocumentItem(DocumentItem parent)
 {
     ParentItemObject = parent;
 }
예제 #32
0
파일: MainWindow.cs 프로젝트: GNOME/nemo
    protected void on_search_text_results(List<Tuple<string[], File>> search_results, string search_text)
    {
        if (!search_result_valid)
            return;

        System.Console.WriteLine("got search text results {0}", search_results.Count);

        List<Nemo.Item> items = new List<Nemo.Item>();

        //		int height_left = calendar_event_box.Allocation.Height;

        foreach (Tuple<string[], File> result in search_results)
        {
            Nemo.Item item;

            System.Console.WriteLine("type {0}", result.first[0]);

            if (DocumentItem.is_document(result.first[0]))
                item = new DocumentItem(result.second, result.first, search_input.Text);
            else if (PictureItem.is_image(result.first[0]))
                item = new PictureItem(result.second, result.first);
            else
            {
                item = new Nemo.Item(result.second);
                item.mime_type = result.first[0];
            }

            item.search_func = do_search;

            items.Add(item);
        }

        //		System.Console.WriteLine("{0} - {1} - {2} - {3}", root_x, root_y, search_input.Allocation.Width, search_input.Allocation.Height);

        SearchPopup popup = new SearchPopup(calendar_driver.update_view_set_next);
        popup.get_size = delegate { return calendar_event_box.Allocation.Height; };
        popup.calculate_start_position = delegate {
            int root_x = 0, root_y = 0;
            calendar_event_box.GdkWindow.GetOrigin(out root_x, out root_y);

            int tmp = 0; // throw away
            search_input.GdkWindow.GetOrigin(out root_x, out tmp);

            return new Nemo.Tuple<int, int>(root_x + search_input.Allocation.Width, root_y + calendar_event_box.Allocation.Height);
        };

        popup.set_files_and_show(items, search_text);

        Singleton<OverlayTracker>.Instance.add_overlay_and_show(popup);
    }