public VisaAndMeasure(StateEnvironment stateEnvironment) : base(stateEnvironment) { // S.VAM.CounterSign.SecondLevelEnd }
public MainControlPointPlan(StateEnvironment stateEnvironment) : base(stateEnvironment) { // }
public UndoCommand(StateEnvironment stateEnvironment) : base(stateEnvironment) { }
public QualityAdjustmentNotice(StateEnvironment stateEnvironment) : base(stateEnvironment) { // }
private void LinkSAPDocument(StateEnvironment env) { SAPDataSource source = new SAPDataSource(); // Only documents are interesting if (env.ObjVer.Type != ( int )MFBuiltInObjectType.MFBuiltInObjectTypeDocument) { return; } // Only SAP Document classes are interesting string objectAliases = env.Vault.ClassOperations.GetObjectClassAdmin(env.ObjVerEx.Class).SemanticAliases.Value; if (!objectAliases.Contains("SAPALINK::Document")) { SysUtils.ReportToEventLog("Missing alias: SAPALINK::Document\n", System.Diagnostics.EventLogEntryType.Information); return; } // Map class to SAP document type. If not found, no link. Regex documentTypeRegex = new Regex($"{DocumentTypeProperty.Alias}=(?<documentType>[^;]+)"); Match documentTypeMatch = documentTypeRegex.Match(objectAliases); string documentType = null; if (documentTypeMatch.Success) { documentType = documentTypeMatch.Groups["documentType"].Value; } else if (env.ObjVerEx.Properties.GetProperty(DocumentTypeProperty) != null) { documentType = env.ObjVerEx.Properties.GetProperty(DocumentTypeProperty).GetValueAsUnlocalizedText(); } if (documentType == "" || documentType == null) { throw new Exception("No SAP Document type property nor SAPDocumentType alias found."); } // SAP BusinessobjectType Regex objectTypeRegex = new Regex($"{SAPBusinessObjectIDProperty.Alias}=(?<objectType>[^;]+)"); Match objectTypeMatch = objectTypeRegex.Match(objectAliases); string SAPObjectType = null; if (objectTypeMatch.Success) { SAPObjectType = objectTypeMatch.Groups["objectType"].Value; } else if (env.ObjVerEx.Properties.GetProperty(SAPBusinessObjectIDProperty) != null) { SAPObjectType = env.ObjVerEx.Properties.GetProperty(SAPBusinessObjectIDProperty).GetValueAsUnlocalizedText(); } if (SAPObjectType == "" || SAPObjectType == null) { throw new Exception("No SAP Business object type property nor SAPBusinessObjectType alias found."); } // Open SAP connection NamedValues values = env.Vault.NamedValueStorageOperations.GetNamedValues(MFNamedValueType.MFAdminConfiguration, "SAPDocumentConnector"); if (!values.Contains("Password")) { throw new Exception("The encrypted password could not be found in the NamedValuestorage."); } source.OpenConnection(config.ConnectionString + "password="******"Password"].ToString()), Guid.Empty); // Get previous version's employee IDs. //PropertyValue previousSAPObjectLink = ( env.ObjVerEx.PreviousVersion != null ) ? // env.ObjVerEx.PreviousVersion.Properties.GetProperty( SAPObjectLinkProperty ) : null; //IEnumerable<string> previousSAPObjects = ( previousSAPObjectLink != null ) ? // getSAPObjectIDs( env, previousSAPObjectLink ) : new List<string>(); // Get current version's employee IDs. PropertyValue currentSAPObjectLink = env.ObjVerEx.Properties.GetProperty(SAPObjectLinkProperty); if (currentSAPObjectLink == null) { throw new Exception("No SAP SAPObject property defined."); } IEnumerable <string> currentSAPObjects = getSAPObjectIDs(env, currentSAPObjectLink); //// Get deleted employee IDs. //IEnumerable<string> deletedIDs = previousSAPObjects.Except( currentSAPObjects ); //// Get new employee IDs. //IEnumerable<string> newIDs = currentSAPObjects.Except( previousSAPObjects ); // Remove old links //removeLinks( env, deletedIDs ); // TODO Doesn't work yet. // Create new links createLinks(env, documentType, SAPObjectType, currentSAPObjects, source); // Close connection try { source.CloseConnection(); } catch (Exception ex) { SysUtils.ReportToEventLog("Closing connection to SAP failed.\n" + ex.Message, System.Diagnostics.EventLogEntryType.Warning); } }
public ProjectCompletionConfirm(StateEnvironment stateEnvironment) : base(stateEnvironment) { }
public ConstructionPeriodDelayAnalysis(StateEnvironment stateEnvironment) : base(stateEnvironment) { // }
/// <summary> /// Creates links between document and employees in SAP. /// </summary> /// <param name="env"></param> /// <param name="documentType"></param> /// <param name="newSAPObjects"></param> private void createLinks(StateEnvironment env, string documentType, string SAPObjectType, IEnumerable <string> newSAPObjects, SAPDataSource source) { foreach (string employeeID in newSAPObjects) { // Generate and set SAP properties string documentID = GUIDToDocumentID(env); env.ObjVerEx.Properties.SetProperty(DocumentIDProperty, MFDataType.MFDatatypeText, documentID); // Set properties required by SAP env.ObjVerEx.Properties.SetProperty(ComponentPropertiesProperty, MFDataType.MFDatatypeMultiLineText, "ComponentID=data|ContentType=application/pdf|FileID=" + GetFileID(env) + "|Filename=data.pdf|ADate=" + GetSAPDateFromTS(env.ObjVerEx.GetProperty(20).Value.GetValueAsTimestamp().UtcToLocalTime()) + "|ATime=" + GetSAPTimeFromTS(env.ObjVerEx.GetProperty(20).Value.GetValueAsTimestamp().UtcToLocalTime()) + "|MDate=" + GetSAPDateFromTS(env.ObjVerEx.GetProperty(21).Value.GetValueAsTimestamp().UtcToLocalTime()) + "|MTime=" + GetSAPTimeFromTS(env.ObjVerEx.GetProperty(21).Value.GetValueAsTimestamp().UtcToLocalTime()) + "|AppVer=|Charset="); env.ObjVerEx.SetProperty(DocumentProtectionProperty, MFDataType.MFDatatypeText, "rud"); env.ObjVerEx.SetProperty(ArchiveLinkVersionProperty, MFDataType.MFDatatypeText, "0046"); // Save properties env.ObjVerEx.SaveProperties(); // Get SAP repository if (env.ObjVerEx.Properties.GetProperty(ContentRepositoryProperty) == null) { throw new Exception("No SAP repository defined."); } string repository = env.ObjVerEx.Properties.GetProperty(ContentRepositoryProperty).GetValueAsUnlocalizedText(); // Get filename string fileName = env.ObjVerEx.Title; // Get description string description = ""; PropertyValue descProp; if (env.ObjVerEx.Properties.TryGetProperty(DocumentDescriptionProperty, out descProp)) { description = descProp.GetValueAsLocalizedText(); } // Do the link with RFC function IRfcFunction rfcFunction = SAPHelper.CreateFunction("ARCHIV_CONNECTION_INSERT", source.getDestination()); rfcFunction.SetValue("ARCHIV_ID", repository); rfcFunction.SetValue("AR_OBJECT", documentType); rfcFunction.SetValue("SAP_OBJECT", SAPObjectType); rfcFunction.SetValue("ARC_DOC_ID", documentID); rfcFunction.SetValue("OBJECT_ID", employeeID); // Is the file info in use if (config.UseFileInfo == "true") { rfcFunction.SetValue("FILENAME", fileName); rfcFunction.SetValue("DESCR", description); rfcFunction.SetValue("CREATOR", employeeID); } // try { string result = SAPHelper.InvokeRFC(rfcFunction, source.getDestination()); string message = "Linked document: " + documentID + ", type: " + documentType + "\n" + "with SAP object: " + employeeID + ", type: " + SAPObjectType + "\n" + "Filename: " + fileName + ", Description: " + description + "\n" + result; SysUtils.ReportInfoToEventLog(message); } catch (Exception ex) { // Show failed FRC call in Event viewer. StringBuilder message = new StringBuilder() .AppendLine("ARCHIV_CONNECTION_INSERT") .AppendFormat(" - ARCHIV_ID: '{0}'", repository).AppendLine() .AppendFormat(" - AR_OBJECT: '{0}'", documentType).AppendLine() .AppendFormat(" - SAP_OBJECT: '{0}'", SAPObjectType).AppendLine() .AppendFormat(" - ARC_DOC_ID: '{0}'", documentID).AppendLine() .AppendFormat(" - OBJECT_ID: '{0}'", employeeID).AppendLine(); if (config.UseFileInfo == "true") { message .AppendFormat(" - FILENAME: '{0}'", fileName).AppendLine() .AppendFormat(" - DESCR: '{0}'", description).AppendLine() .AppendFormat(" - CREATOR: '{0}'", employeeID).AppendLine(); } message.AppendLine().AppendLine(ex.Message); SysUtils.ReportErrorToEventLog("SAPDocumentConnector", message.ToString(), ex); throw new RfcInvalidParameterException(ex.Message); } } }
private bool MCPPUpdatePlanDirectlyControl(StateEnvironment env, out string message) { return(CheckToWhereFrom(env, out message)); }
private bool SupervisionMeetingMinutesReviewUpdate(StateEnvironment env, out string message) { return(CheckToWhereFrom(env, out message)); }
private bool DelayAnalysisNormalUpdate(StateEnvironment env, out string message) { return(CheckToWhereFrom(env, out message)); }
private bool VisaAndMeasureUpdate(StateEnvironment env, out string message) { return(CheckToWhereFrom(env, out message)); }
public void CreateChequeTest(StateEnvironment env) { var Vault = env.ObjVerEx.Vault; var oCurrObjVals = Vault.ObjectPropertyOperations.GetProperties(env.ObjVerEx.ObjVer); var VendorID = SearchPropertyValue(oCurrObjVals, Vendor_PD); List <InvoiceValue> InvoiceValues = new List <InvoiceValue>(); InvoiceValues.Add(new InvoiceValue() { PropertyID = Date_PD, TypedValue = SearchPropertyValue(oCurrObjVals, InvoiceDate_PD) }); InvoiceValues.Add(new InvoiceValue() { PropertyID = InvoiceNumber_PD, TypedValue = SearchPropertyValue(oCurrObjVals, InvoiceNumber_PD) }); InvoiceValues.Add(new InvoiceValue() { PropertyID = Vendor_PD, TypedValue = VendorID }); List <ObjVerEx> InvoiceObjVers = SearchForObjects(env, Invoice_CD, InvoiceValues); if (InvoiceObjVers != null) { InvoiceValues = new List <InvoiceValue>(); InvoiceValues.Add(new InvoiceValue() { PropertyID = Vendor_PD, TypedValue = VendorID }); InvoiceValues.Add(new InvoiceValue() { PropertyID = Date_PD, TypedValue = SearchPropertyValue(oCurrObjVals, ChequeDate_PD) }); InvoiceValues.Add(new InvoiceValue() { PropertyID = ChequeNumber_PD, TypedValue = SearchPropertyValue(oCurrObjVals, ChequeNumber_PD) }); InvoiceValues.Add(new InvoiceValue() { PropertyID = Amount_PD, TypedValue = SearchPropertyValue(oCurrObjVals, ChequeAmount_PD) }); List <ObjVerEx> ChequeObjVers = SearchForObjects(env, Cheque_CD, InvoiceValues); ObjVer oCheque; var propertyValues = new PropertyValues(); if (ChequeObjVers != null) { oCheque = Vault.ObjectOperations.CheckOut(ChequeObjVers[0].ObjID).ObjVer; } else { var classPropertyValue = new PropertyValue() { PropertyDef = (int)MFBuiltInPropertyDef.MFBuiltInPropertyDefClass }; classPropertyValue.Value.SetValue(MFDataType.MFDatatypeLookup, Vault.ClassOperations.GetObjectClass(Cheque_CD).ID); propertyValues.Add(-1, classPropertyValue); propertyValues.Add(-1, GetPropertyValue(oCurrObjVals, ChequeNumber_PD)); propertyValues.Add(-1, GetPropertyValue(oCurrObjVals, Date_PD, ChequeDate_PD)); propertyValues.Add(-1, GetPropertyValue(oCurrObjVals, Amount_PD, ChequeAmount_PD)); propertyValues.Add(-1, GetPropertyValue(oCurrObjVals, Vendor_PD)); ObjectVersionAndProperties ppts = Vault.ObjectOperations.CreateNewObject(Cheque_OT, propertyValues); oCheque = ppts.ObjVer; } var ChequeProps = Vault.ObjectPropertyOperations.GetProperties(oCheque); var PaidInvoices = ChequeProps.SearchForProperty(PaidInvoices_PD).TypedValue.GetValueAsLookups(); object[,] PaidInvoicesItems = (object[, ])ChequeProps.SearchForProperty(PaidInvoices_PD).TypedValue.Value; bool FoundInvoice = false; foreach (object PaidInvoicesItem in PaidInvoicesItems) { if (PaidInvoicesItem.ToString() == InvoiceObjVers[0].ObjVer.ID.ToString()) { FoundInvoice = true; break; } } if (!FoundInvoice) { var NewInvoice = new Lookup(); NewInvoice.ObjectType = InvoiceObjVers[0].ObjVer.Type; NewInvoice.Item = InvoiceObjVers[0].ObjVer.ID; NewInvoice.DisplayValue = InvoiceObjVers[0].Title; PaidInvoices.Add(-1, NewInvoice); var PaidIvc = new PropertyValue() { PropertyDef = PaidInvoices_PD //oCurrObjVals.SearchForProperty(PaidInvoices_PD).PropertyDef }; PaidIvc.Value.SetValueToMultiSelectLookup(PaidInvoices); Vault.ObjectPropertyOperations.SetProperty(oCheque, PaidIvc); } env.ObjVerEx.Vault.ObjectOperations.CheckIn(oCheque); } }