Пример #1
0
        internal static int Prepare
            (SPWeb site, DocumentContent document, string fileName, CompensatiionGood compensatiionGood)
        {
            string _stt = "AddDocument2Collection";

            try
            {
                SPFile _docFile = document.AddDocument2Collection(site, fileName, CommonDefinitions.IPRSADConsignmentLibraryTitle, compensatiionGood);
                return(_docFile.Item.ID);
            }
            catch (Exception ex)
            {
                throw new ApplicationError("Dokument.PrepareConsignment", _stt, String.Format("Cannot finish the operation because of error {0}", ex.Message), ex);
            }
        }
        private GenericStateMachineEngine.ActionResult ClearThroughCustom()
        {
            try
            {
                Entities _edc = m_DataContextManagement.DataContext;
                string   _masterDocumentName             = CurrentClearance.FinishedGoodsExportFormFileName(_edc);
                int      _sadConsignmentIdentifier       = default(int);
                Func <IEnumerable <Disposal> > _dspslLst = () => CurrentClearance.Disposal(_edc);
                switch (ToSelectedGroup(CurrentClearance.ProcedureCode))
                {
                case Group.Tobacco:
                case Group.TobaccoNotAllocated:
                    DocumentContent _newTobaccoDoc =
                        DisposalsFormFactory.GetTobaccoFreeCirculationFormContent(_dspslLst(), CurrentClearance.ClearenceProcedure.Value, _masterDocumentName);
                    _sadConsignmentIdentifier = SPDocumentFactory.Prepare(SPContext.Current.Web, _newTobaccoDoc, _masterDocumentName, CompensatiionGood.Tobacco);
                    break;

                case Group.Waste:
                case Group.Dust:
                    DocumentContent   _newDustWasteDoc   = DisposalsFormFactory.GetDustWasteFormContent(_dspslLst(), CurrentClearance.ClearenceProcedure.Value, _masterDocumentName);
                    CompensatiionGood _compensatiionGood = SelectedGroup == Group.Waste ? CompensatiionGood.Waste : CompensatiionGood.Dust;
                    _sadConsignmentIdentifier = SPDocumentFactory.Prepare(SPContext.Current.Web, _newDustWasteDoc, _masterDocumentName, _compensatiionGood);
                    break;

                case Group.Cartons:
                    DocumentContent _newBoxFormContent = DisposalsFormFactory.GetBoxFormContent(_dspslLst(), CurrentClearance.ClearenceProcedure.Value, _masterDocumentName);
                    _sadConsignmentIdentifier = SPDocumentFactory.Prepare(SPContext.Current.Web, _newBoxFormContent, _masterDocumentName, CompensatiionGood.Cartons);
                    break;
                }
                SADConsignment _sadConsignment = Element.GetAtIndex <SADConsignment>(_edc.SADConsignment, _sadConsignmentIdentifier);
                CurrentClearance.ClearThroughCustom(_edc, _sadConsignment, (x, y, z) => { }); //TODO implement tracing
                _edc.SubmitChanges();
                Response.Redirect(Request.RawUrl);
                return(GenericStateMachineEngine.ActionResult.Success);
            }
            catch (GenericStateMachineEngine.ActionResult _ar)
            {
                return(_ar);
            }
            catch (Exception ex)
            {
                return(GenericStateMachineEngine.ActionResult.Exception(ex, "ClearThroughCustom"));
            }
        }
        /// <summary>
        /// Adds the document to collection <see cref="SPFileCollection" />.
        /// </summary>
        /// <param name="destinationCollection">The destination collection.</param>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="compensatiionGood">The compensatiion good.</param>
        /// <returns>
        /// An object of <see cref="SPFile" /> containing the serialized <paramref name="destinationCollection" />
        /// </returns>
        public SPFile AddDocument2Collection(SPWeb site, string fileName, string listName, CompensatiionGood compensatiionGood)
        {
            string stylesheetName = String.Empty;

            switch (compensatiionGood)
            {
            case CompensatiionGood.Dust:
                stylesheetName = DocumentNames.DustFormStylesheetName;
                break;

            case CompensatiionGood.Waste:
                stylesheetName = DocumentNames.WasteFormStylesheetName;
                break;

            case CompensatiionGood.Cartons:
                stylesheetName = DocumentNames.CartonsFormStylesheetName;
                break;

            case CompensatiionGood.Tobacco:
                stylesheetName = DocumentNames.TobaccoFormStylesheetName;
                break;
            }
            return(File.CreateXmlFile <DocumentContent>(site, this, fileName, listName, stylesheetName));
        }