示例#1
0
        public FileCabinetFacts() {
            this.config = new TestProviderConfiguration();
            this.mockStorageProvider = new Mock<IStorageProvider<TestProviderConfiguration>>();
            this.mockStorageProvider.SetupGet(p => p.ProviderType).Returns(TestProviderType);

            this.fileCabinet = new FileCabinet<TestProviderConfiguration>(mockStorageProvider.Object, config);
        }
示例#2
0
        public FileCabinetFacts()
        {
            this.config = new TestProviderConfiguration();
            this.mockStorageProvider = new Mock <IStorageProvider <TestProviderConfiguration> >();
            this.mockStorageProvider.SetupGet(p => p.ProviderType).Returns(TestProviderType);

            this.fileCabinet = new FileCabinet <TestProviderConfiguration>(mockStorageProvider.Object, config);
        }
示例#3
0
 /// <param name="documentIds"> Ids of documents to be clipped. </param>
 /// <param name="target"> File cabinet or document tray (basket) documents are stored in. </param>
 /// <returns> Single document after clipping. </returns>
 public Document ClipDocuments(List <int> documentIds, FileCabinet target)
 {
     return(target.PutToContentMergeOperationRelationForDocument
            (
                new ContentMergeOperationInfo()
     {
         Documents = documentIds,
         Operation = ContentMergeOperation.Clip,
         Force = true
     }
            ));
 }
示例#4
0
 public GangInfo(CriminalGang gang)
 {
     InitializeComponent();
     Gang                    = gang;
     FileCabinet             = FileCabinet.GetInstance();
     nameBox.Text            = Gang.Name;
     foundationtimebox.Value = Gang.FoundationDate;
     countryBox.SelectedItem = Gang.Country;
     gangImageBox.Image      = Gang.Image;
     featuresBox.Text        = Gang.Features;
     IdLabelValue.Text       = Gang.Id.ToString();
     leaderlinkedLabel.Text  = Gang.LeaderName == " " ? "None": Gang.LeaderName;
     if (User.Role == UserRole.User)
     {
         foreach (Control c in Controls)
         {
             if (c is TextBox t)
             {
                 t.ReadOnly = true;
             }
             if (c is GroupBox g)
             {
                 foreach (Control gc in g.Controls)
                 {
                     if (gc is RichTextBox rt)
                     {
                         rt.ReadOnly = true;
                     }
                 }
             }
             ComboBox cb = c as ComboBox;
             if (cb != null)
             {
                 cb.Enabled = false;
             }
             DateTimePicker dt = c as DateTimePicker;
             if (dt != null)
             {
                 dt.Enabled = false;
             }
             imageChoseButton.Hide();
             addButton.Hide();
             leaderChoseButton.Hide();
             saveButton.Hide();
             deleteButton.Hide();
         }
     }
 }
示例#5
0
        public void Load()
        {
            using (Stream stream = File.OpenRead(filePath))
            {
                var         serializer = new BinaryFormatter();
                FileCabinet st         = (FileCabinet)serializer.Deserialize(stream);
                Copy(st.Criminals, fileCabinet.Criminals);
                Copy(st.CriminalGangs, fileCabinet.CriminalGangs);
            }

            void Copy <T>(List <T> from, List <T> to)
            {
                to.Clear();
                to.AddRange(from);
            }
        }
示例#6
0
        /// <summary> Changes index values for several documents stored in a file cabinet. </summary>
        /// <remarks>
        /// Runs the query and change index values for each document found.
        ///
        /// The instance of the document that you have used when calling this method doesn't contain valid data anymore.
        /// Use the document that is returned as part of BatchUpdateResultItem in order to get valid data.
        /// Additionally you can check property ErrorMessage of BatchUpdateResultItem in order to make sure that the operation was successful.
        /// This property will contain error message if you try to provided an invalid index value.
        ///
        /// If some of the index values provided could not be set for some reason all documents will remain unchanged.
        /// </remarks>
        /// <param name="fileCabinet"> File cabinet to search documents in. </param>
        /// <param name="query"> Query specifying documents who's index values should be changed. </param>
        /// <param name="indexValues"> Index values to change. </param>
        /// <returns> List of BatchUpdateResultItem each of them containing changed document and an error message if index value(s) could not be changed. </returns>
        public List <BatchUpdateResultItem> ChangeIndexValuesInBatch(FileCabinet fileCabinet, DialogExpression query, List <DocumentIndexField> indexValues)
        {
            var searchDialog = getDefaultSearchDialog(fileCabinet);
            var storeDialog  = getDefaultStoreDialog(fileCabinet);

            var queryResult = runQueryForDocuments(searchDialog, query);

            var batchUpdateData = new BatchUpdateProcessData()
            {
                BreakOnError  = false,
                StoreDialogId = storeDialog.Id,
                Field         = indexValues
            };

            return(queryResult.PostToBatchUpdateRelationForBatchUpdateIndexFieldsResult(batchUpdateData).Item);
        }
示例#7
0
        //Constructor
        public ListMenuPresenter(ListMenu lView)
        {
            listView    = lView;
            fileCabinet = FileCabinet.GetInstance();
            listView.AddCriminalEvent   += ListView_AddCriminalEvent;
            listView.LoadEvent          += ListView_LoadEvent;
            listView.SaveEvent          += ListView_SaveEvent;
            listView.MoveToArchiveEvent += ListView_MoveToArchiveEvent;
            listView.MoveToListevent    += ListView_MoveToListevent;
            listView.AutorizationEvent  += ListView_AutorizationEvent;
            listView.OnUserCahngeEvent  += OnUserChange;
            listView.AddGangEvent       += ListView_AddGangEvent;
            listView.DeleteEvent        += ListView_DeleteEvent;
            listView.ResetEvent         += ListView_ResetEvent;

            listView.SearchCriminalEvent += ListView_SearchCriminalEvent;

            listView.SearchInArchiveEvent += ListView_SearchInArchiveEvent;
        }
        public override void Run(IWwtContext context)
        {
            string path = context.Server.MapPath(@"TourCache");

            try
            {
                if (context.Request.Params["targeturl"] != null && context.Request.Params["filename"] != null)
                {
                    var    url        = context.Request.Params["targeturl"];
                    string targetfile = context.Request.Params["filename"];
                    string filename   = Path.Combine(path, $"{_hasher.HashName(url)}.wtt");

                    if (!File.Exists(filename))
                    {
                        if (url.ToLower().StartsWith("http"))
                        {
                            using (WebClient wc = new WebClient())
                            {
                                byte[] data = wc.DownloadData(url);

                                //context.Response.ContentType = wc.ResponseHeaders["Content-type"].ToString();
                                int length = data.Length;

                                File.WriteAllBytes(filename, data);
                                //context.Response.OutputStream.Write(data, 0, length);
                            }
                        }
                    }


                    FileCabinet.Extract(filename, targetfile, context.Response);
                }
            }
            catch (Exception e)
            {
                context.Response.Write(e.Message);
            }
        }
示例#9
0
 private Dialog getDefaultStoreDialog(FileCabinet fileCabinet)
 {
     return(fileCabinet.GetDialogInfosFromStoresRelation().Dialog.Where(dlg => dlg.IsDefault == !fileCabinet.IsBasket).FirstOrDefault().GetDialogFromSelfRelation());
 }
示例#10
0
        /// <param name="document"> Document to be split. </param>
        /// <param name="pages"> Defines at which page document should be split. This page will belongs to the first part of document. </param>
        /// <param name="documentNames"> Defines the title of the second part of the split document. The first part will keep the title of the original document. </param>
        /// <param name="destination"> File cabinet or document tray (basket) the document is currently stored into. </param>
        /// <remarks>
        /// Platform API is prepared for splitting document in more than two parts at once, that's why you have to proved list of pages and list of names.
        /// Unfortunately it has not been implemented, yet.
        /// So currently, you only can split a document in two parts, means both list must not contain more than one element.
        /// </remarks>
        /// <returns>
        /// DocumentQueryResult that allows you access to document created when splitting.
        /// </returns>
        public DocumentsQueryResult SplitDocument(Document document, List <int> pages, List <string> documentNames, FileCabinet destination)
        {
            if (document.ContentDivideOperationRelationLink == null)
            {
                document = document.GetDocumentFromSelfRelation();
            }

            return(document.PutToContentDivideOperationRelationForDocumentsQueryResult
                   (
                       new ContentDivideOperationInfo()
            {
                Force = true,
                Operation = ContentDivideOperation.Split,
                Pages = pages,
                ResultNames = documentNames
            }
                   ));
        }
        /// <summary> Stores a document into file cabinet using index values provided. </summary>
        /// <remarks>
        /// The instance of the document that you have used when calling this method doesn't contain valid data anymore.
        /// Use the document that is returned as part of DocumentQueryResult in order to get valid data.
        /// </remarks>
        /// <param name="document"> Id of the document to be stored. </param>
        /// <param name="documentTray"> Document tray (basket) document is currently stored in. </param>
        /// <param name="fileCabinet"> File cabinet to store document into. </param>
        /// <param name="indexValues"> Index values to apply to the document when storing. </param>
        /// <param name="keepDocumentInDocumentTray"> Specifies if document should remains in document tray after storing. </param>
        /// <returns>
        /// DocumentQueryResult that allows you access to the document you have just moved.
        /// </returns>
        public DocumentsQueryResult StoreDocumentFromBasketToFileCabinet(Document document, FileCabinet documentTray, FileCabinet fileCabinet, List<DocumentIndexField> indexValues, bool keepDocumentInDocumentTray = false)
        {
            var sourceDocument = new Document
            {
                Id = document.Id,
                Fields = indexValues
            };

            var transferInfo = new DocumentsTransferInfo()
            {
                Documents = new List<Document>() { sourceDocument },
                KeepSource = keepDocumentInDocumentTray,
                SourceFileCabinetId = documentTray.Id
            };

            return fileCabinet.PostToTransferRelationForDocumentsQueryResult(transferInfo);
        }
 /// <param name="documentIds"> Ids of documents to be clipped. </param>
 /// <param name="target"> File cabinet or document tray (basket) documents are stored in. </param>
 /// <returns> Single document after clipping. </returns>
 public Document ClipDocuments(List<int> documentIds, FileCabinet target)
 {
     return target.PutToContentMergeOperationRelationForDocument
             (
                 new ContentMergeOperationInfo()
                 {
                     Documents = documentIds,
                     Operation = ContentMergeOperation.Clip,
                     Force = true
                 }
             );
 }
示例#13
0
 public Dao(FileCabinet store)
 {
     this.fileCabinet = store;
 }
示例#14
0
 private Dialog getDefaultSearchDialog(FileCabinet fileCabinet)
 {
     return(fileCabinet.GetDialogInfosFromSearchesRelation().Dialog.FirstOrDefault(dlg => dlg.IsDefault == !fileCabinet.IsBasket)?.GetDialogFromSelfRelation());
 }
示例#15
0
 //Constructors
 public GangInfo()
 {
     InitializeComponent();
     Gang        = new CriminalGang();
     FileCabinet = FileCabinet.GetInstance();
 }
        /// <remarks>
        /// The instance of the document that you have used when calling this method doesn't contain valid data anymore.
        /// Use the document that is returned as part of DocumentQueryResult in order to get valid data.
        /// </remarks>
        /// <param name="document"> Id of the document to be stored. </param>
        /// <param name="documentTray"> Id of the document tray (basket) document is currently stored in. </param>
        /// <param name="fileCabinet"> File cabinet to store document into. </param>
        /// <returns>
        /// DocumentQueryResult that allows you access to the document you have just moved.
        /// </returns>
        public DocumentsQueryResult StoreDocumentFromBasketToFileCabinetUsingIntellixHints(Document document, FileCabinet documentTray, FileCabinet fileCabinet)
        {
            var transferInfo = new FileCabinetTransferInfo()
            {
                KeepSource = false,
                SourceDocId = new List<int> { document.Id },
                SourceFileCabinetId = documentTray.Id,
                FillIntellix = true
            };

            return fileCabinet.PostToTransferRelationForDocumentsQueryResult(transferInfo);
        }
示例#17
0
        private string createTemplateXML(IExportDocument docRef, IExportTools exportTools, string tempfolder, string tempName)
        {
            string templateFolder = tempfolder;
            string templateName = tempName.ToString() + ".xml";
            string temp = templateFolder + "\\" + templateName;

            NTAccount ntAccount = new NTAccount("Everyone");
            SecurityIdentifier sid = (SecurityIdentifier)ntAccount.Translate(typeof(SecurityIdentifier));
            byte[] sidArray = new byte[sid.BinaryLength];
            sid.GetBinaryForm(sidArray, 0);

            if (!File.Exists(temp))
            {
                fileCabinetForm = new DocuwareFileCabinet(docRef, exportTools, temp);
                fileCabinetForm.ShowDialog();
            }
            if (File.Exists(temp))
            {
                // create the XmlReader object
                XmlReaderSettings settings = new XmlReaderSettings();
                XmlReader reader = XmlReader.Create(temp.ToString(), settings);

                int depth = -1; // tree depth is -1, no indentation

                while (reader.Read()) // display each node's content
                {
                    switch (reader.NodeType)
                    {
                        case XmlNodeType.Element: // XML Element, display its name
                            depth++; // increase tab depth
                            TabOutput(depth); // insert tabs

                            if (reader.Name == "FileCabinetName")
                            {
                                depth++;
                                reader.Read();
                                xmlfilecabinetpath = reader.Value;
                                depth--;
                                reader.Read();
                            }
                            if (reader.Name == "FieldName")
                            {
                                depth++;
                                reader.Read();
                                xmlfieldname = reader.Value;
                                fieldnamelist.Add(reader.Value);
                                getFields(docRef.Children, docRef, xmlfieldname);
                                depth--;
                                reader.Read();
                            }
                            if (reader.Name == "FieldIndex")
                            {
                                depth++;
                                reader.Read();
                                xmlfieldindex = reader.Value;
                                fieldindexlist.Add(Convert.ToUInt32(reader.Value));
                                depth--;
                                reader.Read();
                                openWith.Add(Convert.ToInt32(xmlfieldindex), fieldValue);
                            }

                            // if empty element, decrease depth
                            if (reader.IsEmptyElement)
                                depth--;
                            break;
                        case XmlNodeType.Comment: // XML Comment, display it
                            TabOutput(depth); // insert tabs
                            break;
                        case XmlNodeType.Text: // XML Text, display it
                            TabOutput(depth); // insert tabs
                            break;

                        // XML XMLDeclaration, display it
                        case XmlNodeType.XmlDeclaration:
                            TabOutput(depth); // insert tabs
                            break;
                        case XmlNodeType.EndElement: // XML EndElement, display it
                            TabOutput(depth); // insert tabs
                            depth--; // decrement depth
                            break;
                    } // end switch
                } // end while

                //------------------- DocuWare -------------------
                string fullimportimagepath = exportImages(docRef, exportTools, templateFolder);
                UpdateLogFile("Full path of current working image: "+fullimportimagepath);

                //select filecabinet
                filecabinet = new FileCabinet(session, xmlfilecabinetpath);
                UpdateLogFile(filecabinet.FileCabinetPath);
                filecabinet.Open();
                abasket = new ActiveBasket(session);

                // open basket
                basket = session.GetActiveBasket();
                basket = new Basket(session, abasket.BasketPath);
                UpdateLogFile("Active Basket Path: " + abasket.BasketPath);
                basket = new ActiveBasket(session);
                basket.Open();
                basket.SetAsActive();
                UpdateLogFile("Basket: "+basket.BasketPath);

                //sending bantran.tif to current basket.
                docum = basket.ImportFile(fullimportimagepath);

                UpdateLogFile("FileName: "+docum.FileName);
                if (File.Exists(fullimportimagepath))
                {
                    File.Delete(fullimportimagepath);
                }

                int numberofdocuments = basket.GetNumberOfDocuments();

                docum = new Document(basket, docum.FileName);
                UpdateLogFile("Name: " + docum.Name);
                UpdateLogFile("FileName: " + docum.FileName);

                if (!File.Exists(docum.FileName))
                {
                    UpdateLogFile(docum.FileName + " path does not exist after import into basket.");
                }

                try
                {
                    filecabinet.Store(docum, false, true, openWith);
                }
                catch (Exception e)
                {
                    UpdateLogFile(filecabinet.LastException.Message+ " | " + e.Message);
                }
            }
            return templateName;
        }
 private Dialog getDefaultStoreDialog(FileCabinet fileCabinet)
 {
     return fileCabinet.GetDialogInfosFromStoresRelation().Dialog.Where(dlg => dlg.IsDefault == !fileCabinet.IsBasket).FirstOrDefault().GetDialogFromSelfRelation();
 }
        /// <param name="document"> Document to be split. </param>
        /// <param name="pages"> Defines at which page document should be split. This page will belongs to the first part of document. </param>
        /// <param name="documentNames"> Defines the title of the second part of the split document. The first part will keep the title of the original document. </param>
        /// <param name="destination"> File cabinet or document tray (basket) the document is currently stored into. </param>
        /// <remarks>
        /// Platform API is prepared for splitting document in more than two parts at once, that's why you have to proved list of pages and list of names.
        /// Unfortunately it has not been implemented, yet.
        /// So currently, you only can split a document in two parts, means both list must not contain more than one element.
        /// </remarks>
        /// <returns>
        /// DocumentQueryResult that allows you access to document created when splitting.
        /// </returns>
        public DocumentsQueryResult SplitDocument(Document document, List<int> pages, List<string> documentNames, FileCabinet destination)
        {
            if (document.ContentDivideOperationRelationLink == null)
                document = document.GetDocumentFromSelfRelation();

            return  document.PutToContentDivideOperationRelationForDocumentsQueryResult
                    (
                        new ContentDivideOperationInfo()
                        {
                            Force = true,
                            Operation = ContentDivideOperation.Split,
                            Pages = pages,
                            ResultNames = documentNames
                        }
                    );
        }
        /// <summary> Moves the document from file cabinet to document tray. </summary>
        /// <remarks>
        /// This implementation preserves index values when moving the document.
        /// 
        /// The instance of the document that you have used when calling this method doesn't contain valid data anymore.
        /// Use the document that is returned as part of DocumentQueryResult in order to get valid data.
        /// </remarks>
        /// <param name="document"> Document to be moved. </param>
        /// <param name="fileCabinet"> File cabinet where document is currently located. </param>
        /// <param name="documentTray"> Document tray document has to be moved into. </param>
        /// <returns>
        /// DocumentQueryResult that allows you access to the document you have just moved.
        /// </returns>
        public DocumentsQueryResult MoveDocumentFromFileCabinetToBasket(Document document, FileCabinet fileCabinet, FileCabinet documentTray)
        {
            var transferInfo = new FileCabinetTransferInfo()
            {
                KeepSource = false,   // the document will be moved, NOT copied
                SourceDocId = new List<int> { document.Id},
                SourceFileCabinetId = fileCabinet.Id
            };

            return documentTray.PostToTransferRelationForDocumentsQueryResult(transferInfo);
        }
        /// <summary> Moves the document from file cabinet to document tray. </summary>
        /// <remarks>
        /// This implementation does not preserve index values when moving the document.
        /// 
        /// The instance of the document that you have used when calling this method doesn't contain valid data anymore.
        /// Use the document that is returned as part of DocumentQueryResult in order to get valid data.
        /// </remarks>
        /// <param name="document"> Document to be moved. </param>
        /// <param name="fileCabinet"> File cabinet where document is currently located. </param>
        /// <param name="documentTray"> Document tray document has to be moved into. </param>
        /// <returns>
        /// DocumentQueryResult that allows you access to the document you have just moved.
        /// </returns>
        public DocumentsQueryResult MoveDocumentFromFileCabinetToBasketAndDropIndexValues(Document document, FileCabinet fileCabinet, FileCabinet documentTray)
        {
            var sourceDocument = new Document
            {
                Id = document.Id,
                // Needed in order to preserve document name.
                // (other index values will get lost)
                Fields = new List<DocumentIndexField> { DocumentIndexField.Create("DWWBDOCNAME", document.Title) }
            };

            var transferInfo = new DocumentsTransferInfo()
            {
                Documents = new List<Document>() { sourceDocument },
                KeepSource = false,    // the document will be moved, NOT copied
                SourceFileCabinetId = fileCabinet.Id
            };

            // All index values that were set in file cabinet will get lost here!
            return documentTray.PostToTransferRelationForDocumentsQueryResult(transferInfo);
        }
示例#22
0
文件: Dao.cs 项目: hlv-z/Cursovaya
 //Конструктор, який приймає на вхід екззкмпляр класу FileCabinet
 public Dao(FileCabinet store)
 {
     fileCabinet = store;
 }
示例#23
0
        /// <summary> Stores a document into file cabinet using index values provided. </summary>
        /// <remarks>
        /// The instance of the document that you have used when calling this method doesn't contain valid data anymore.
        /// Use the document that is returned as part of DocumentQueryResult in order to get valid data.
        /// </remarks>
        /// <param name="document"> Id of the document to be stored. </param>
        /// <param name="documentTray"> Document tray (basket) document is currently stored in. </param>
        /// <param name="fileCabinet"> File cabinet to store document into. </param>
        /// <param name="indexValues"> Index values to apply to the document when storing. </param>
        /// <param name="keepDocumentInDocumentTray"> Specifies if document should remains in document tray after storing. </param>
        /// <returns>
        /// DocumentQueryResult that allows you access to the document you have just moved.
        /// </returns>
        public DocumentsQueryResult StoreDocumentFromBasketToFileCabinet(Document document, FileCabinet documentTray, FileCabinet fileCabinet, List <DocumentIndexField> indexValues, bool keepDocumentInDocumentTray = false)
        {
            var sourceDocument = new Document
            {
                Id     = document.Id,
                Fields = indexValues
            };

            var transferInfo = new DocumentsTransferInfo()
            {
                Documents = new List <Document>()
                {
                    sourceDocument
                },
                KeepSource          = keepDocumentInDocumentTray,
                SourceFileCabinetId = documentTray.Id
            };

            return(fileCabinet.PostToTransferRelationForDocumentsQueryResult(transferInfo));
        }
示例#24
0
 public GangList()
 {
     InitializeComponent();
     fileCabinet = FileCabinet.GetInstance();
 }
示例#25
0
        /// <remarks>
        /// The instance of the document that you have used when calling this method doesn't contain valid data anymore.
        /// Use the document that is returned as part of DocumentQueryResult in order to get valid data.
        /// </remarks>
        /// <param name="document"> Id of the document to be stored. </param>
        /// <param name="documentTray"> Id of the document tray (basket) document is currently stored in. </param>
        /// <param name="fileCabinet"> File cabinet to store document into. </param>
        /// <returns>
        /// DocumentQueryResult that allows you access to the document you have just moved.
        /// </returns>
        public DocumentsQueryResult StoreDocumentFromBasketToFileCabinetUsingIntellixHints(Document document, FileCabinet documentTray, FileCabinet fileCabinet)
        {
            var transferInfo = new FileCabinetTransferInfo()
            {
                KeepSource  = false,
                SourceDocId = new List <int> {
                    document.Id
                },
                SourceFileCabinetId = documentTray.Id,
                FillIntellix        = true
            };

            return(fileCabinet.PostToTransferRelationForDocumentsQueryResult(transferInfo));
        }
示例#26
0
        /// <summary> Moves the document from file cabinet to document tray. </summary>
        /// <remarks>
        /// This implementation does not preserve index values when moving the document.
        ///
        /// The instance of the document that you have used when calling this method doesn't contain valid data anymore.
        /// Use the document that is returned as part of DocumentQueryResult in order to get valid data.
        /// </remarks>
        /// <param name="document"> Document to be moved. </param>
        /// <param name="fileCabinet"> File cabinet where document is currently located. </param>
        /// <param name="documentTray"> Document tray document has to be moved into. </param>
        /// <returns>
        /// DocumentQueryResult that allows you access to the document you have just moved.
        /// </returns>
        public DocumentsQueryResult MoveDocumentFromFileCabinetToBasketAndDropIndexValues(Document document, FileCabinet fileCabinet, FileCabinet documentTray)
        {
            var sourceDocument = new Document
            {
                Id = document.Id,
                // Needed in order to preserve document name.
                // (other index values will get lost)
                Fields = new List <DocumentIndexField> {
                    DocumentIndexField.Create("DWWBDOCNAME", document.Title)
                }
            };

            var transferInfo = new DocumentsTransferInfo()
            {
                Documents = new List <Document>()
                {
                    sourceDocument
                },
                KeepSource          = false, // the document will be moved, NOT copied
                SourceFileCabinetId = fileCabinet.Id
            };

            // All index values that were set in file cabinet will get lost here!
            return(documentTray.PostToTransferRelationForDocumentsQueryResult(transferInfo));
        }
        /// <summary> Changes index values for several documents stored in a file cabinet. </summary>
        /// <remarks>
        /// Runs the query and change index values for each document found.
        /// 
        /// The instance of the document that you have used when calling this method doesn't contain valid data anymore.
        /// Use the document that is returned as part of BatchUpdateResultItem in order to get valid data.
        /// Additionally you can check property ErrorMessage of BatchUpdateResultItem in order to make sure that the operation was successful.
        /// This property will contain error message if you try to provided an invalid index value.
        /// 
        /// If some of the index values provided could not be set for some reason all documents will remain unchanged.
        /// </remarks>
        /// <param name="fileCabinet"> File cabinet to search documents in. </param>
        /// <param name="query"> Query specifying documents who's index values should be changed. </param>
        /// <param name="indexValues"> Index values to change. </param>
        /// <returns> List of BatchUpdateResultItem each of them containing changed document and an error message if index value(s) could not be changed. </returns>
        public List<BatchUpdateResultItem> ChangeIndexValuesInBatch(FileCabinet fileCabinet, DialogExpression query, List<DocumentIndexField> indexValues)
        {
            var searchDialog = getDefaultSearchDialog(fileCabinet);
            var storeDialog = getDefaultStoreDialog(fileCabinet);

            var queryResult = runQueryForDocuments(searchDialog, query);

            var batchUpdateData = new BatchUpdateProcessData()
            {
                BreakOnError = false,
                StoreDialogId = storeDialog.Id,
                Field = indexValues
            };

            return queryResult.PostToBatchUpdateRelationForBatchUpdateIndexFieldsResult(batchUpdateData).Item;
        }
示例#28
0
        /// <summary> Moves the document from file cabinet to document tray. </summary>
        /// <remarks>
        /// This implementation preserves index values when moving the document.
        ///
        /// The instance of the document that you have used when calling this method doesn't contain valid data anymore.
        /// Use the document that is returned as part of DocumentQueryResult in order to get valid data.
        /// </remarks>
        /// <param name="document"> Document to be moved. </param>
        /// <param name="fileCabinet"> File cabinet where document is currently located. </param>
        /// <param name="documentTray"> Document tray document has to be moved into. </param>
        /// <returns>
        /// DocumentQueryResult that allows you access to the document you have just moved.
        /// </returns>
        public DocumentsQueryResult MoveDocumentFromFileCabinetToBasket(Document document, FileCabinet fileCabinet, FileCabinet documentTray)
        {
            var transferInfo = new FileCabinetTransferInfo()
            {
                KeepSource  = false,  // the document will be moved, NOT copied
                SourceDocId = new List <int> {
                    document.Id
                },
                SourceFileCabinetId = fileCabinet.Id
            };

            return(documentTray.PostToTransferRelationForDocumentsQueryResult(transferInfo));
        }
示例#29
0
        protected string MakeTourFromXML(IWwtContext context, Stream InputStream, string baseDir)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(InputStream);

            string tourStart = "";

            tourStart += "<?xml version='1.0' encoding='UTF-8'?>";
            tourStart +=
                "<Tour ID=\"{TourGuid}\" Title=\"{Title}\" Descirption=\"{Description}\" RunTime=\"20\" Author=\"{AuthorName}\" AuthorEmail=\"{AuthorEmail}\" OrganizationUrl=\"{OrganizationUrl}\" OrganizationName=\"{OrganizationName}\" Keywords=\"{Keywords}\" UserLevel=\"Beginner\" Classification=\"0\" Taxonomy=\"C.5\">";
            tourStart += "<TourStops>";
            string tourEnd = "";

            tourEnd += "</TourStops>";
            tourEnd += "</Tour>";

            string master = "";

            master +=
                "<TourStop Id=\"{Guid}\" Name=\"\" Description=\"{SlideTitle}\" Thumbnail=\"\" Duration=\"{Duration}\" Master=\"True\" Transition=\"Slew\" HasLocation=\"True\" LocationAltitude=\"100\" LocationLat=\"47.64222\" LocationLng=\"-122.142\" HasTime=\"True\" StartTime=\"7/8/2009 4:09:04 PM\" EndTime=\"7/8/2009 4:08:16 PM\" ActualPlanetScale=\"True\" ShowClouds=\"False\" ShowConstellationBoundries=\"True\" ShowConstellationFigures=\"True\" ShowConstellationSelection=\"True\" ShowEcliptic=\"False\" ShowElevationModel=\"False\" ShowFieldOfView=\"False\" ShowGrid=\"False\" ShowHorizon=\"False\" ShowHorizonPanorama=\"False\" ShowMoonsAsPointSource=\"False\" ShowSolarSystem=\"True\" FovTelescope=\"0\" FovEyepiece=\"0\" FovCamera=\"0\" LocalHorizonMode=\"False\" FadeInOverlays=\"False\" SolarSystemStars=\"True\" SolarSystemMilkyWay=\"True\" SolarSystemCosmos=\"True\" SolarSystemOrbits=\"True\" SolarSystemOverlays=\"True\" SolarSystemLighting=\"True\" SolarSystemScale=\"100\" SolarSystemMultiRes=\"True\">";
            master +=
                "<Place Name=\"Current Screen\" DataSetType=\"Sky\" RA=\"{RA}\" Dec=\"{Dec}\" Constellation=\"CVN\" Classification=\"Unidentified\" Magnitude=\"0\" Distance=\"0\" AngularSize=\"60\" ZoomLevel=\"{ZoomLevel}\" Rotation=\"0.0\" Angle=\"0\" Opacity=\"100\" Target=\"Sun\">";
            master += "<Description><![CDATA[]]></Description>";
            master += "<BackgroundImageSet>";
            master +=
                "<ImageSet Generic=\"False\" DataSetType=\"Sky\" BandPass=\"Visible\" Name=\"SDSS: Sloan Digital Sky Survey (Optical)\" Url=\"http://www.worldwidetelescope.org/wwtweb/sdsstoast.aspx?q={1},{2},{3}\" DemUrl=\"\" BaseTileLevel=\"0\" TileLevels=\"13\" BaseDegreesPerTile=\"180\" FileType=\".png\" BottomsUp=\"False\" Projection=\"Toast\" QuadTreeMap=\"\" CenterX=\"0\" CenterY=\"0\" OffsetX=\"0\" OffsetY=\"0\" Rotation=\"0\" Sparse=\"False\" ElevationModel=\"False\" StockSet=\"False\" WidthFactor=\"1\">";
            master += "<ThumbnailUrl>http://www.worldwidetelescope.org/wwtweb/thumbnail.aspx?name=sloan</ThumbnailUrl>";
            master += "</ImageSet>";
            master += "</BackgroundImageSet>";
            master += "</Place>";
            master += "<Overlays />";
            master += "<MusicTrack>";
            master +=
                "<Overlay Id=\"e3dbf1aa-0e04-4ee8-bd1c-e9d14dd1c780\" Type=\"TerraViewer.AudioOverlay\" Name=\"Music\" X=\"0\" Y=\"0\" Width=\"0\" Height=\"0\" Rotation=\"0\" Color=\"NamedColor:White\" Url=\"\" Animate=\"False\">";
            master += "<Audio Filename=\"music.wma\" Volume=\"100\" Mute=\"False\" TrackType=\"Music\" />";
            master += "</Overlay>";
            master += "</MusicTrack>";
            master += "</TourStop>";


            string titleSlide = "";

            titleSlide +=
                "<TourStop Id=\"9d25fcf1-47a1-4036-84e1-2e4e70647a4b\" Name=\"\" Description=\"Title Slide\" Thumbnail=\"\" Duration=\"00:00:10\" Master=\"False\" Transition=\"Slew\" HasLocation=\"True\" LocationAltitude=\"100\" LocationLat=\"47.64222\" LocationLng=\"-122.142\" HasTime=\"True\" StartTime=\"7/8/2009 4:09:04 PM\" EndTime=\"7/8/2009 4:08:16 PM\" ActualPlanetScale=\"True\" ShowClouds=\"False\" ShowConstellationBoundries=\"True\" ShowConstellationFigures=\"True\" ShowConstellationSelection=\"True\" ShowEcliptic=\"False\" ShowElevationModel=\"False\" ShowFieldOfView=\"False\" ShowGrid=\"False\" ShowHorizon=\"False\" ShowHorizonPanorama=\"False\" ShowMoonsAsPointSource=\"False\" ShowSolarSystem=\"True\" FovTelescope=\"0\" FovEyepiece=\"0\" FovCamera=\"0\" LocalHorizonMode=\"False\" FadeInOverlays=\"False\" SolarSystemStars=\"True\" SolarSystemMilkyWay=\"True\" SolarSystemCosmos=\"True\" SolarSystemOrbits=\"True\" SolarSystemOverlays=\"True\" SolarSystemLighting=\"True\" SolarSystemScale=\"100\" SolarSystemMultiRes=\"True\">";
            titleSlide +=
                "<Place Name=\"Current Screen\" DataSetType=\"Sky\" RA=\"15.2873183407284\" Dec=\"21.5907089633017\" Constellation=\"SER1\" Classification=\"Unidentified\" Magnitude=\"0\" Distance=\"0\" AngularSize=\"60\" ZoomLevel=\"188.893869642374\" Rotation=\"0.0\" Angle=\"0\" Opacity=\"100\" Target=\"Sun\">";
            titleSlide += "<Description><![CDATA[]]></Description>";
            titleSlide += "<BackgroundImageSet>";
            titleSlide +=
                "<ImageSet Generic=\"False\" DataSetType=\"Sky\" BandPass=\"Visible\" Name=\"SDSS: Sloan Digital Sky Survey (Optical)\" Url=\"http://www.worldwidetelescope.org/wwtweb/sdsstoast.aspx?q={1},{2},{3}\" DemUrl=\"\" BaseTileLevel=\"0\" TileLevels=\"13\" BaseDegreesPerTile=\"180\" FileType=\".png\" BottomsUp=\"False\" Projection=\"Toast\" QuadTreeMap=\"\" CenterX=\"0\" CenterY=\"0\" OffsetX=\"0\" OffsetY=\"0\" Rotation=\"0\" Sparse=\"False\" ElevationModel=\"False\" StockSet=\"False\" WidthFactor=\"1\">";
            titleSlide +=
                "<ThumbnailUrl>http://www.worldwidetelescope.org/wwtweb/thumbnail.aspx?name=sloan</ThumbnailUrl>";
            titleSlide += "</ImageSet>";
            titleSlide += "</BackgroundImageSet>";
            titleSlide += "</Place>";
            titleSlide +=
                "<EndTarget Name=\"End Place\" DataSetType=\"Sky\" RA=\"15.2873183407284\" Dec=\"21.5907089633017\" Constellation=\"SER1\" Classification=\"Unidentified\" Magnitude=\"0\" Distance=\"0\" AngularSize=\"60\" ZoomLevel=\"0.367349417666093\" Rotation=\"0\" Angle=\"0\" Opacity=\"0\" Target=\"Custom\">";
            titleSlide += "<Description><![CDATA[]]></Description>";
            titleSlide += "</EndTarget>";
            titleSlide += "<Overlays>";
            titleSlide +=
                "<Overlay Id=\"2e811eba-14cc-4c4b-89d5-47180c36f8f0\" Type=\"TerraViewer.BitmapOverlay\" Name=\"WWT-gz.png\" X=\"956.5342\" Y=\"290.3851\" Width=\"1240\" Height=\"173\" Rotation=\"0\" Color=\"ARGBColor:255:255:255:255\" Url=\"http://www.galaxyzoo.org\" Animate=\"False\">";
            titleSlide += "<Bitmap Filename=\"zoologo.png\" />";
            titleSlide += "</Overlay>";
            titleSlide +=
                "<Overlay Id=\"6c94ab77-95a3-4e46-8cb5-4ba39b2c8937\" Type=\"TerraViewer.TextOverlay\" Name=\"A tour of your favourites\" X=\"901.0809\" Y=\"453.2796\" Width=\"792.3697\" Height=\"42.89062\" Rotation=\"0\" Color=\"ARGBColor:255:255:255:255\" Url=\"\" Animate=\"False\">";
            titleSlide += "<Text>";
            titleSlide +=
                "<TextObject Bold=\"False\" Italic=\"False\" Underline=\"False\" FontSize=\"24\" FontName=\"Verdana\" ForgroundColor=\"NamedColor:White\" BackgroundColor=\"NamedColor:Black\" BorderStyle=\"None\">A Worldwide Telescope Tour of Your Favourites</TextObject>";
            titleSlide += "</Text>";
            titleSlide += "</Overlay>";
            titleSlide += "</Overlays>";
            titleSlide += "</TourStop>";


            string tourstop = "";

            tourstop +=
                "<TourStop Id=\"{Guid}\" Name=\"\" Description=\"{SlideTitle}\" Thumbnail=\"\" Duration=\"00:00:10\" Master=\"False\" Transition=\"Slew\" HasLocation=\"True\" LocationAltitude=\"100\" LocationLat=\"47.64222\" LocationLng=\"-122.142\" HasTime=\"True\" StartTime=\"7/8/2009 4:09:17 PM\" EndTime=\"7/8/2009 4:09:17 PM\" ActualPlanetScale=\"True\" ShowClouds=\"False\" ShowConstellationBoundries=\"True\" ShowConstellationFigures=\"True\" ShowConstellationSelection=\"True\" ShowEcliptic=\"False\" ShowElevationModel=\"False\" ShowFieldOfView=\"False\" ShowGrid=\"False\" ShowHorizon=\"False\" ShowHorizonPanorama=\"False\" ShowMoonsAsPointSource=\"False\" ShowSolarSystem=\"True\" FovTelescope=\"0\" FovEyepiece=\"0\" FovCamera=\"0\" LocalHorizonMode=\"False\" FadeInOverlays=\"False\" SolarSystemStars=\"True\" SolarSystemMilkyWay=\"True\" SolarSystemCosmos=\"True\" SolarSystemOrbits=\"True\" SolarSystemOverlays=\"True\" SolarSystemLighting=\"True\" SolarSystemScale=\"100\" SolarSystemMultiRes=\"True\">";
            tourstop +=
                "<Place Name=\"Current Screen\" DataSetType=\"Sky\" RA=\"{RA}\" Dec=\"{Dec}\" Constellation=\"\" Classification=\"Unidentified\" Magnitude=\"0\" Distance=\"0\" AngularSize=\"60\" ZoomLevel=\"{ZoomLevel}\" Rotation=\"0\" Angle=\"0\" Opacity=\"100\" Target=\"Sun\">";
            tourstop += "<Description><![CDATA[]]></Description>";
            tourstop += "<BackgroundImageSet>";
            tourstop +=
                "<ImageSet Generic=\"False\" DataSetType=\"Sky\" BandPass=\"Visible\" Name=\"SDSS: Sloan Digital Sky Survey (Optical)\" Url=\"http://www.worldwidetelescope.org/wwtweb/sdsstoast.aspx?q={1},{2},{3}\" DemUrl=\"\" BaseTileLevel=\"0\" TileLevels=\"13\" BaseDegreesPerTile=\"180\" FileType=\".png\" BottomsUp=\"False\" Projection=\"Toast\" QuadTreeMap=\"\" CenterX=\"0\" CenterY=\"0\" OffsetX=\"0\" OffsetY=\"0\" Rotation=\"0\" Sparse=\"False\" ElevationModel=\"False\" StockSet=\"False\" WidthFactor=\"1\">";
            tourstop +=
                "<ThumbnailUrl>http://www.worldwidetelescope.org/wwtweb/thumbnail.aspx?name=sloan</ThumbnailUrl>";
            tourstop += "</ImageSet>";
            tourstop += "</BackgroundImageSet>";
            tourstop += "</Place>";
            tourstop += "<Overlays />";
            tourstop += "</TourStop>";


            string        Title       = "";
            string        Description = "";
            string        Author      = "";
            string        AuthorEmail = "";
            string        OrgUrl      = "";
            string        OrgName     = "";
            StringBuilder sb          = new StringBuilder();


            Guid   id       = Guid.NewGuid();
            string tourGuid = id.ToString();
            string dir      = baseDir;

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            string      outputfilename = dir + id.ToString() + ".wtt";
            FileCabinet cab            = new FileCabinet(outputfilename, dir);
            string      page           = context.Request.PhysicalPath.Substring(0, context.Request.PhysicalPath.LastIndexOf('\\'));

            page = page.Substring(0, page.LastIndexOf('\\'));
            List <string> thumbs = new List <string>();

            thumbs.Add(tourGuid + "\\9d25fcf1-47a1-4036-84e1-2e4e70647a4b.thumb.png");

            string musicUrl  = null;
            string musicPath = null;
            string voiceUrl  = null;

            try
            {
                XmlNode Tour = doc["Tour"];

                Title       = Tour["Title"].InnerText;
                Description = Tour["Description"].InnerText;
                Author      = Tour["Author"].InnerText;
                AuthorEmail = Tour["Email"].InnerText;
                OrgUrl      = Tour["OrganizationURL"].InnerText;
                OrgName     = Tour["OrganizationName"].InnerText;
                sb.Append(
                    tourStart.Replace("{TourGuid}", tourGuid)
                    .Replace("{Title}", Title)
                    .Replace("{Description}", Description)
                    .Replace("{AuthorName}", Author)
                    .Replace("{AuthorEmail}", AuthorEmail)
                    .Replace("{OrganizationUrl}", OrgUrl)
                    .Replace("{OrganizationName}", OrgName)
                    .Replace("{Keywords}", ""));

                sb.Append(titleSlide);

                XmlNode Music = Tour["MusicTrack"];
                musicUrl = Music["Filename"].InnerText;
                XmlNode Voice = Tour["VoiceTrack"];
                voiceUrl = Music["Filename"].InnerText;


                string  stopString = master;
                XmlNode TourStops  = Tour["TourStops"];
                foreach (XmlNode child in TourStops.ChildNodes)
                {
                    double RA       = Convert.ToDouble(child["RA"].InnerText);
                    double Dec      = Convert.ToDouble(child["Dec"].InnerText);
                    double Zoom     = Convert.ToDouble(child["ZoomLevel"].InnerText);
                    Guid   stopID   = Guid.NewGuid();
                    string Duration = child["Duration"].InnerText;
                    stopString =
                        stopString.Replace("{Duration}", Duration)
                        .Replace("{Guid}", stopID.ToString())
                        .Replace("{RA}", RA.ToString())
                        .Replace("{Dec}", Dec.ToString())
                        .Replace("{ZoomLevel}", Zoom.ToString());
                    sb.Append(stopString);
                    thumbs.Add(tourGuid + "\\" + stopID.ToString() + ".thumb.png");
                    stopString = tourstop;
                }

                sb.Append(tourEnd);
            }
            catch
            {
            }

            string tourfilename = dir + id.ToString() + ".wttxml";

            File.WriteAllText(tourfilename, sb.ToString(), Encoding.UTF8);

            cab.AddFile(tourfilename, false, "");
            cab.AddFile(page + "\\images\\zoologo.png", true, tourGuid + "\\zoologo.png");

            WebClient client = new WebClient();

            if (!string.IsNullOrEmpty(musicUrl))
            {
                musicPath = $"{dir}{_hasher.HashName(musicUrl)}";

                if (!File.Exists(musicPath))
                {
                    client.DownloadFile(musicUrl, musicPath);
                }
                cab.AddFile(musicPath, true, tourGuid + "\\music.wma");
            }

            foreach (string thumbFile in thumbs)
            {
                cab.AddFile(page + "\\images\\zoo.thumb.png", true, thumbFile);
            }
            cab.Package();
            File.Delete(tourfilename);

            return(outputfilename);
        }