Example #1
0
 /// <summary>
 /// Method used for saving the states to Binary.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnSaveToBinStateClick(object sender, RoutedEventArgs e)
 {
     //Save to Binary State
     if (BinFormatterRadio.IsChecked == true)
     {
         Binload.IsEnabled = true;
         BinaryFormatter formatter1 = new BinaryFormatter();
         DocContainer.SaveDockState(formatter1, StorageFormat.Binary,
                                    AppDomain.CurrentDomain.BaseDirectory.ToString() + "\\docum_bin.bin");
     }
     else
     {
         Binload.IsEnabled = true;
         SoapFormatter formatter1 = new SoapFormatter();
         DocContainer.SaveDockState(formatter1, StorageFormat.Binary,
                                    AppDomain.CurrentDomain.BaseDirectory.ToString() + "\\docum_bin.bin");
     }
 }
Example #2
0
        /// <summary>
        /// Method used for Load the states from Registry.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void OnLoadFromRegStateClick(object sender, RoutedEventArgs e)
        {
            //Load State
            BinaryFormatter formatter1 = new BinaryFormatter();

            try
            {
                DocContainer.LoadDockState(formatter1);
            }
            catch (SerializationException ex)
            {
                MessageBox.Show(ex.Message, AttentionHeader, MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            catch (FormatException ex)
            {
                MessageBox.Show(ex.Message, AttentionHeader, MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Example #3
0
        /// <summary>
        /// Method used for Load the states from XML.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnLoadFromXMLStateClick(object sender, RoutedEventArgs e)
        {
            //Load from XML State
            if (BinFormatterRadio.IsChecked == true)
            {
                BinaryFormatter formatter1 = new BinaryFormatter();
                try
                {
                    DocContainer.LoadDockState(formatter1, StorageFormat.Xml,
                                               AppDomain.CurrentDomain.BaseDirectory.ToString() + "\\docum_xml.xml");
                }
                catch (XmlException ex)
                {
                    MessageBox.Show(ex.Message, AttentionHeader, MessageBoxButton.OK,
                                    MessageBoxImage.Warning);
                }
                catch (InvalidOperationException ex)
                {
                    MessageBox.Show(ex.Message, AttentionHeader, MessageBoxButton.OK,
                                    MessageBoxImage.Warning);
                }
            }
#if !NETCORE
            else
            {
                SoapFormatter formatter1 = new SoapFormatter();
                try
                {
                    DocContainer.LoadDockState(formatter1, StorageFormat.Xml,
                                               AppDomain.CurrentDomain.BaseDirectory.ToString() + "\\docum_xml.xml");
                }
                catch (XmlException ex)
                {
                    MessageBox.Show(ex.Message, AttentionHeader, MessageBoxButton.OK,
                                    MessageBoxImage.Warning);
                }
                catch (InvalidOperationException ex)
                {
                    MessageBox.Show(ex.Message, AttentionHeader, MessageBoxButton.OK,
                                    MessageBoxImage.Warning);
                }
            }
#endif
        }
Example #4
0
        public async Task <ActionResult> Create([Bind(Include = "DocumentDescription,File")] DocContainer document)
        {
            try
            {
                // TODO: Add insert logic here
                // Create Container for chosen Request. Change path to "Request" and use requestID.
                DocContainer con = new DocContainer();
                con.DocumentDescription = document.DocumentDescription;
                //To Get File Extension
                string FileExtension = Path.GetExtension(document.File.FileName);
                con.Address     = $"file://conquest_documents/Request/{requestID}/StoreDocument{FileExtension}";
                con.ContentType = document.File.ContentType;

                con.ObjectKey = new ObjectKey()
                {
                    ObjectType = "ObjectType_Request", Int32Value = int.Parse(requestID)
                };
                HttpResponseMessage createFileResponse = await client.PostAsJsonAsync(API_ADD_DOCUMENT, con);

                // Check response
                if (!createFileResponse.IsSuccessStatusCode)
                {
                    throw new System.ArgumentException(createFileResponse.StatusCode.ToString(), "original");
                }

                // Upload document content to Container for chosen Request.
                string              result                 = new StreamReader(document.File.InputStream).ReadToEnd();
                DocDataObject       docDataObject          = JsonConvert.DeserializeObject <DocDataObject>(createFileResponse.Content.ReadAsStringAsync().Result);
                HttpResponseMessage uploadDocumentResponse = await client.PutAsJsonAsync(docDataObject.UploadUri, result);

                //Check response
                if (!uploadDocumentResponse.IsSuccessStatusCode)
                {
                    throw new System.ArgumentException(uploadDocumentResponse.StatusCode.ToString(), "Cannot upload text");
                }
                return(RedirectToAction("Index", "Home"));
            }
            catch
            {
                return(View());
            }
        }
Example #5
0
        /// <summary>
        /// Method used for saving the states to XML.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnSaveToXMLStateClick(object sender, RoutedEventArgs e)
        {
            //Save to XML sate
            if (BinFormatterRadio.IsChecked == true)
            {
                xmlload.IsEnabled = true;
                BinaryFormatter formatter1 = new BinaryFormatter();
                DocContainer.SaveDockState(formatter1, StorageFormat.Xml,
                                           AppDomain.CurrentDomain.BaseDirectory.ToString() + "\\docum_xml.xml");
            }
#if !NETCORE
            else
            {
                xmlload.IsEnabled = true;
                SoapFormatter formatter1 = new SoapFormatter();
                DocContainer.SaveDockState(formatter1, StorageFormat.Xml,
                                           AppDomain.CurrentDomain.BaseDirectory.ToString() + "\\docum_xml.xml");
            }
#endif
        }
Example #6
0
        /// <summary>
        /// Method used for changing the Layout for the MDI elements.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Layout_Click(object sender, RoutedEventArgs e)
        {
            //Changing Document Containter Layout
            MenuItem c = (MenuItem)sender;
            string   g = c.Header.ToString();

            switch (c.Name)
            {
            case "Cascade":
                DocContainer.SetLayout(MDILayout.Cascade);
                break;

            case "THorizontal":
                DocContainer.SetLayout(MDILayout.Horizontal);
                break;

            case "TVertical":
                DocContainer.SetLayout(MDILayout.Vertical);
                break;
            }
        }
Example #7
0
        private void PutDocInContainer(Document doc)
        {
            var          containerId       = doc.Id.ToDocContainerId();
            var          containerFileName = Path.Combine(_directory, containerId + ".dc");
            DocContainer container;

            if (File.Exists(containerFileName))
            {
                if (!_docContainers.TryGetValue(containerId, out container))
                {
                    container = new DocContainer(_directory, containerId);
                }
                Document existing;
                if (container.TryGet(doc.Id, out existing))
                {
                    foreach (var field in doc.Fields)
                    {
                        existing.Fields[field.Key] = field.Value;
                    }
                    container.Remove(doc.Id);
                    container.Put(existing, _directory);
                }
                else
                {
                    container.Put(doc, _directory);
                }
            }
            else
            {
                if (!_docContainers.TryGetValue(containerId, out container))
                {
                    container = new DocContainer(_directory, containerId);
                    _docContainers[container.Id] = container;
                }
                container.Put(doc, _directory);
            }
            _docContainers[container.Id] = container;
        }
Example #8
0
 /// <summary>
 /// Method used for Load the states from Binary.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnLoadFromBinStateClick(object sender, RoutedEventArgs e)
 {
     //Load from Binary State
     if (BinFormatterRadio.IsChecked == true)
     {
         BinaryFormatter formatter1 = new BinaryFormatter();
         try
         {
             DocContainer.LoadDockState(formatter1, StorageFormat.Binary,
                                        AppDomain.CurrentDomain.BaseDirectory.ToString() + "\\docum_bin.bin");
         }
         catch (SerializationException ex)
         {
             MessageBox.Show(ex.Message, AttentionHeader, MessageBoxButton.OK,
                             MessageBoxImage.Warning);
         }
         catch (XmlException ex)
         {
             MessageBox.Show(ex.Message, AttentionHeader, MessageBoxButton.OK,
                             MessageBoxImage.Warning);
         }
     }
 }
Example #9
0
 /// <summary>
 /// Method used for Reset the States.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnResetStateClick(object sender, RoutedEventArgs e)
 {
     //Reset State
     DocContainer.ResetState();
 }
Example #10
0
 /// <summary>
 /// Method used for reset the states from IS.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnResetStateInIsoStorageClick(object sender, RoutedEventArgs e)
 {
     //Delete Internal Isolated Storage
     DocContainer.DeleteInternalIsolatedStorage();
 }
Example #11
0
 /// <summary>
 /// Method used for Load the states from IS.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnLoadStateFromIsoStorageClick(object sender, RoutedEventArgs e)
 {
     //Load State from Isolated Storage
     DocContainer.LoadDockState();
 }
Example #12
0
 /// <summary>
 /// Method used for saving the states to IS.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnSaveStateToIsoStorageClick(object sender, RoutedEventArgs e)
 {
     Isload.IsEnabled = true;
     //Save State to Isolated Storage
     DocContainer.SaveDockState();
 }
Example #13
0
        public static IDocumentParser ParserFor(this DocContainer doc, BusinessPartner partner)
        {
            var parsers = ServiceLocator.Current.GetAllInstances(typeof(IDocumentParser)).Select(p => (IDocumentParser)p);

            return(parsers.Find(p => p.CanProcess(partner, doc.DocType)));
        }
Example #14
0
 /// <summary>
 /// Method used for saving the states to IS.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnSaveStateToIsoStorageClick(object sender, RoutedEventArgs e)
 {
     //Save State to Isolated Storage
     DocContainer.SaveDockState();
 }
Example #15
0
 private static bool IsInputValid(DocContainer splitWords)
 {
     return(!string.IsNullOrWhiteSpace(splitWords.NoSignWords));
 }