示例#1
0
        public void TestCreateAdvise()
        {
            PMDataContext dc = new PMDataContext(null);

            Entity.PM.Advice a = new Entity.PM.Advice
            {
                Priority        = "2",
                TechnicalObject = new Entity.PM.TechnicalObject
                {
                    ExternalIdentifier = "000000000010013816",
                    TechnicalLocation  = new Entity.PM.TechnicalObject
                    {
                        ExternalIdentifier = "?0100000000000005587",
                        TOType             = Entity.PM.TechnicalObjectTypes.TechnicalObjectTypeTechnicalLocation
                    },
                    TOType = Entity.PM.TechnicalObjectTypes.TechnicalObjectTypeEquipment
                },
                Comments            = "Test",
                Type                = "",
                ExecutionStartAt    = DateTime.Now.AddHours(-3),
                ExecutionFinishedAt = DateTime.Now.AddHours(-2),
            };

            var s = dc.CreateAdvice(a);
        }
示例#2
0
        public void InsertSapAdvice()
        {
            SCMS.Entity.PM.Advice returnList = new SCMS.Entity.PM.Advice();
            var sapUser = "******";

            SOFTTEK.SCMS.Entity.PM.Advice         modelInsert         = new Entity.PM.Advice();
            List <SCMS.Entity.PM.TechnicalObject> sapTechnicalObjects = new List <SCMS.Entity.PM.TechnicalObject>();

            SOFTTEK.SAP.Integration.SAPConnection sapConnector = new SAP.Integration.SAPConnection();

            var connectDestination    = sapConnector.LoadDestination();
            var destinationRepository = connectDestination.Repository;

            var initializerRFC = destinationRepository.CreateFunction(new System.Configuration.AppSettingsReader().GetValue("SAP_RFC_CREATE_ADVICE", typeof(string)).ToString());
            var rfcMetadata    = initializerRFC.Metadata;

            bool stateConnection = Ping(connectDestination);

            Dictionary <string, object> input       = new Dictionary <string, object>();
            Dictionary <string, object> output      = new Dictionary <string, object>();
            Dictionary <object, object> tables      = new Dictionary <object, object>();
            Dictionary <object, object> estructuras = new Dictionary <object, object>();

            //if(stateConnection)
            //initializerRFC.Invoke(connectDestination);

            //if (initializerRFC.GetString("EV_INDICADOR") == "0")
            //{
            for (int i = 0; i < rfcMetadata.ParameterCount; i++)
            {
                if (rfcMetadata[i].Direction.Equals(global::SAP.Middleware.Connector.RfcDirection.IMPORT))
                {
                    Type inputType = SAP.Integration.SAPData.GetDataType(rfcMetadata[i].DataType);
                    input[rfcMetadata[i].Name] = initializerRFC.GetValue(rfcMetadata[i].Name);//inputType.IsValueType ? Activator.CreateInstance(inputType) : null;
                }
                else if (rfcMetadata[i].Direction.Equals(global::SAP.Middleware.Connector.RfcDirection.EXPORT))
                {
                    Type outputType = SAP.Integration.SAPData.GetDataType(rfcMetadata[i].DataType);
                    output[rfcMetadata[i].Name] = initializerRFC.GetValue(rfcMetadata[i].Name); //outputType.IsValueType ? Activator.CreateInstance(outputType) : null;
                }
                else if (rfcMetadata[i].Direction.Equals(global::SAP.Middleware.Connector.RfcDirection.TABLES))
                {
                    Type tablesType = SAP.Integration.SAPData.GetDataType(rfcMetadata[i].DataType);
                    tables[rfcMetadata[i].Name] = initializerRFC.GetValue(rfcMetadata[i].Name); //outputType.IsValueType ? Activator.CreateInstance(outputType) : null;
                }
                else if (rfcMetadata[i].Direction.Equals(global::SAP.Middleware.Connector.RfcDataType.STRUCTURE))
                {
                    Type estructurasType = SAP.Integration.SAPData.GetDataType(rfcMetadata[i].DataType);
                    estructuras[rfcMetadata[i].Name] = initializerRFC.GetValue(rfcMetadata[i].Name);
                }
            }
            //}
            //else
            //{
            //    throw new Exception(String.Format("No ha sido posible cosultar las ordenes de trabajo. Causa: {0}", initializerRFC.GetString("EV_TEXT")));
            //}

            TimeSpan ts   = new TimeSpan(DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
            TIME     time = new TIME(Convert.ToUInt32(DateTime.Now.Hour), Convert.ToUInt32(DateTime.Now.Minute), Convert.ToUInt32(DateTime.Now.Second));

            Dictionary <string, object> dic = new Dictionary <string, object>();

            dic.Add("EQUIPMENT", "");
            dic.Add("FUNCT_LOC", "");
            dic.Add("PRIORITY", "Alta");
            dic.Add("NOTIF_DATE", DateTime.Now);
            dic.Add("SHORT_TEXT", "");
            dic.Add("BREAKDOWN", "");
            dic.Add("STRMLFNDATE", DateTime.Now);
            dic.Add("STRMLFNTIME", time.ToString());
            dic.Add("ENDMLFNDATE", DateTime.Now);
            dic.Add("ENDMLFNTIME", time.ToString());
            IRfcStructure dictonaryMetadataTable;

            try
            {
                dictonaryMetadataTable = SOFTTEK.SAP.Integration.SAPData.CreateRFCStructure(dic, connectDestination, "ZPMS_AVISOS_MANTENIMIENTO");
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("Ha ocurrido un error, causa : {0}", ex));
            }
        }