Esempio n. 1
0
        private void BuildNotify(IOperationData operationData, DynamicObject proxy, InMemoryUser curUser)
        {
            Type          type            = proxy.ProxyType;
            MethodInfo    mi              = type.GetMethod(_MethodName);
            ParameterInfo pi              = mi.GetParameters().First();
            object        notifyInterface = r.InstanceFromType(pi.ParameterType);
            var           header          = r.InstantiateProperty(notifyInterface, "Header");

            r.InstantiateProperty(header, "SenderID", new { Value = SwConstants.ExternalSystemName });
            r.SetProperty(notifyInterface, "Header", header);
            var    rootIntegrationObject = r.InstantiateArrayReturningSingleElement(notifyInterface, "Content");
            object integrationObject     = r.InstantiateProperty(rootIntegrationObject, 0);

            r.SetProperty(integrationObject, "actionSpecified", true);
            r.InstantiateProperty(integrationObject, "CHANGEDATE", new { Value = DateTime.Now.FromServerToRightKind() });
            //TODO: get current user, in the mobile case below code may be wrong
            WsUtil.SetValue(integrationObject, "ORGID", curUser.OrgId);
            WsUtil.SetValue(integrationObject, "SITEID", curUser.SiteId);
            r.InstantiateProperty(integrationObject, "CHANGEBY", new { Value = curUser.Login });
            OperationType  operationType = operationData.OperationType;
            EntityMetadata metadata      = operationData.EntityMetadata;

            r.SetProperty(integrationObject, "action", operationType.ToString());
            Proxy               = proxy;
            IntegrationObject   = integrationObject;
            RootInterfaceObject = notifyInterface;
        }
        protected virtual void HandleMaterials(MaximoOperationExecutionContext maximoTemplateData, CrudOperationData entity, object wo)
        {
            var materials    = (IEnumerable <CrudOperationData>)entity.GetRelationship("matusetrans");
            var newMaterials = materials.Where(r => r.GetAttribute("matusetransid") == null);
            var recordKey    = entity.Id;
            var user         = SecurityFacade.CurrentUser();

            WsUtil.CloneArray(newMaterials, wo, "MATUSETRANS", delegate(object integrationObject, CrudOperationData crudData) {
                var qtyRequested = ReflectionUtil.GetProperty(integrationObject, "QTYREQUESTED");
                if (qtyRequested == null)
                {
                    WsUtil.SetValue(integrationObject, "QTYREQUESTED", 0);
                }
                var realValue = (double)WsUtil.GetRealValue(integrationObject, "QTYREQUESTED");
                WsUtil.SetValue(integrationObject, "QUANTITY", -1 * realValue);
                WsUtil.SetValue(integrationObject, "MATUSETRANSID", -1);
                WsUtil.SetValue(integrationObject, "ENTERBY", user.Login);
                WsUtil.SetValue(integrationObject, "ORGID", user.OrgId);
                WsUtil.SetValue(integrationObject, "SITEID", user.SiteId);
                WsUtil.SetValue(integrationObject, "REFWO", recordKey);
                WsUtil.SetValue(integrationObject, "ACTUALDATE", DateTime.Now.FromServerToRightKind(), true);
                WsUtil.SetValue(integrationObject, "TRANSDATE", DateTime.Now.FromServerToRightKind(), true);

                ReflectionUtil.SetProperty(integrationObject, "action", OperationType.Add.ToString());
            });
        }
Esempio n. 3
0
        //protected override void HandleMaterials(MaximoOperationExecutionContext maximoTemplateData, CrudOperationData entity, object wo) {
        //    var materials = (IEnumerable<CrudOperationData>)entity.GetRelationship("matusetrans");
        //    var newMaterials = materials.Where(r => r.GetAttribute("matusetransid") == null);
        //    var recordKey = entity.Id;
        //    var user = SecurityFacade.CurrentUser();
        //    var crudOperationDatas = newMaterials as CrudOperationData[] ?? newMaterials.ToArray();

        //    WsUtil.CloneArray(crudOperationDatas, wo, "MATUSETRANS", delegate(object integrationObject, CrudOperationData crudData) {
        //        var itemsetid = (string)crudOperationDatas[0].GetAttribute("item_.itemsetid");
        //        var qtyRequested = (double)WsUtil.GetRealValue(integrationObject, "QTYREQUESTED");

        //        WsUtil.SetValue(integrationObject, "MATUSETRANSID", -1);

        //        WsUtil.SetValue(integrationObject, "QUANTITY", -1 * qtyRequested);
        //        WsUtil.SetValue(integrationObject, "CURBAL", 3.00);
        //        WsUtil.SetValue(integrationObject, "PHYSCNT", 15.00);
        //        WsUtil.SetValue(integrationObject, "UNITCOST", 17.36);
        //        WsUtil.SetValue(integrationObject, "ACTUALCOST", 17.36);
        //        WsUtil.SetValue(integrationObject, "CONVERSION", 1.00);
        //        WsUtil.SetValue(integrationObject, "ISSUETYPE", "RETURN");
        //        WsUtil.SetValue(integrationObject, "CURRENCYCODE", "USD");
        //        WsUtil.SetValue(integrationObject, "LINETYPE", "ITEM");
        //        WsUtil.SetValue(integrationObject, "TOSITEID", user.SiteId.ToUpper());
        //        WsUtil.SetValue(integrationObject, "CONSIGNMENT", false);

        //        WsUtil.SetValue(integrationObject, "LINECOST", 0);
        //        WsUtil.SetValue(integrationObject, "OUTSIDE", false);
        //        WsUtil.SetValue(integrationObject, "ROLLUP", false);
        //        WsUtil.SetValue(integrationObject, "ENTEREDASTASK", false);
        //        WsUtil.SetValue(integrationObject, "ITEMSETID", itemsetid);
        //        WsUtil.SetValue(integrationObject, "ENTERBY", user.Login.ToUpper());
        //        WsUtil.SetValue(integrationObject, "ORGID", user.OrgId.ToUpper());
        //        WsUtil.SetValue(integrationObject, "SITEID", user.SiteId.ToUpper());
        //        WsUtil.SetValue(integrationObject, "REFWO", recordKey);
        //        WsUtil.SetValue(integrationObject, "ACTUALDATE", DateTime.Now.FromServerToRightKind(), true);
        //        WsUtil.SetValue(integrationObject, "TRANSDATE", DateTime.Now.FromServerToRightKind(), true);
        //        WsUtil.SetValue(integrationObject, "TRANSDATE", DateTime.Now.FromServerToRightKind(), true);
        //        WsUtil.SetValue(integrationObject, "ENTERDATE", DateTime.Now.FromServerToRightKind(), true);


        //        ReflectionUtil.SetProperty(integrationObject, "action", OperationType.AddChange.ToString());
        //    });
        //}

        protected override void HandleMaterials(MaximoOperationExecutionContext maximoTemplateData, CrudOperationData entity, object wo)
        {
            var materials          = (IEnumerable <CrudOperationData>)entity.GetRelationship("matusetrans");
            var newMaterials       = materials.Where(r => r.GetAttribute("matusetransid") == null);
            var recordKey          = entity.Id;
            var user               = SecurityFacade.CurrentUser();
            var crudOperationDatas = newMaterials as CrudOperationData[] ?? newMaterials.ToArray();

            WsUtil.CloneArray(crudOperationDatas, wo, "MATUSETRANS", delegate(object integrationObject, CrudOperationData crudData) {
                var itemsetid    = (string)crudOperationDatas[0].GetAttribute("item_.itemsetid");
                var qtyRequested = (double)WsUtil.GetRealValue(integrationObject, "QTYREQUESTED");
                WsUtil.SetValue(integrationObject, "MATUSETRANSID", -1);


                WsUtil.SetValue(integrationObject, "ITEMNUM", "PK-NO1-7006");
                WsUtil.SetValue(integrationObject, "STORELOC", "NO1");
                WsUtil.SetValue(integrationObject, "TRANSDATE", DateTime.Now.FromServerToRightKind(), true);
                WsUtil.SetValue(integrationObject, "ACTUALDATE", DateTime.Now.FromServerToRightKind(), true);
                WsUtil.SetValue(integrationObject, "QUANTITY", -1);
                WsUtil.SetValue(integrationObject, "CURBAL", 3);
                WsUtil.SetValue(integrationObject, "PHYSCNT", 7);
                WsUtil.SetValue(integrationObject, "UNITCOST", 17.36);
                WsUtil.SetValue(integrationObject, "ACTUALCOST", 17.36);
                WsUtil.SetValue(integrationObject, "CONVERSION", 1);
                WsUtil.SetValue(integrationObject, "ASSETNUM", "400-153");
                WsUtil.SetValue(integrationObject, "ENTERBY", "JMALONG");
                WsUtil.SetValue(integrationObject, "MEMO", "123");
                WsUtil.SetValue(integrationObject, "OUTSIDE", false);
                WsUtil.SetValue(integrationObject, "ISSUETO", "DHELMS");
                WsUtil.SetValue(integrationObject, "ROLLUP", false);
                WsUtil.SetValue(integrationObject, "BINNUM", "AL001");
                WsUtil.SetValue(integrationObject, "ISSUETYPE", "ISSUE");
                WsUtil.SetValue(integrationObject, "GLDEBITACCT", "5030-100-101");
                WsUtil.SetValue(integrationObject, "LINECOST", 17.36);
                WsUtil.SetValue(integrationObject, "FINANCIALPERIOD", "QTR3_7");
                WsUtil.SetValue(integrationObject, "CURRENCYCODE", "USD");
                WsUtil.SetValue(integrationObject, "CURRENCYUNITCOST", 17.36);
                WsUtil.SetValue(integrationObject, "CURRENCYLINECOST", 17.36);
                WsUtil.SetValue(integrationObject, "LOCATION", "22335");
                WsUtil.SetValue(integrationObject, "DESCRIPTION", "FILTER  FUEL / CAT 1R-0751");
                WsUtil.SetValue(integrationObject, "EXCHANGERATE", 1);
                WsUtil.SetValue(integrationObject, "SPAREPARTADDED", false);
                WsUtil.SetValue(integrationObject, "QTYREQUESTED", 1);
                WsUtil.SetValue(integrationObject, "ORGID", "BSAKSS");
                WsUtil.SetValue(integrationObject, "SITEID", "KOD016");
                WsUtil.SetValue(integrationObject, "REFWO", "41772");
                WsUtil.SetValue(integrationObject, "ENTEREDASTASK", false);
                WsUtil.SetValue(integrationObject, "LINETYPE", "ITEM");
                WsUtil.SetValue(integrationObject, "ITEMSETID", "ITEM2");
                WsUtil.SetValue(integrationObject, "CONDRATE", 100);
                WsUtil.SetValue(integrationObject, "COMMODITYGROUP", "AUTO");
                WsUtil.SetValue(integrationObject, "COMMODITY", "FILTERS");
                WsUtil.SetValue(integrationObject, "TOSITEID", "KOD016");
                WsUtil.SetValue(integrationObject, "CONSIGNMENT", false);

                ReflectionUtil.SetProperty(integrationObject, "action", OperationType.AddChange.ToString());
            });
        }
 protected virtual void HandleLabors(CrudOperationData entity, object maximoWo)
 {
     WsUtil.CloneArray((IEnumerable <CrudOperationData>) entity.GetRelationship("labtrans"), maximoWo, "LABTRANS",
                       delegate(object integrationObject, CrudOperationData crudData) {
         if (ReflectionUtil.IsNull(integrationObject, "LABTRANSID"))
         {
             WsUtil.SetValue(integrationObject, "LABTRANSID", -1);
         }
     });
 }
Esempio n. 5
0
        /// <summary>
        /// On Mea there´s no way to save the attachment directly from a ws. Hence, we need to save it to the filesystem.
        ///
        /// The path used, will then be used on the ws to point to the right location of the file
        ///
        /// </summary>
        /// <param name="attachmentData"></param>
        /// <param name="base64Delegate"></param>
        /// <param name="docLink"></param>
        /// <param name="attachmentPath"></param>
        ///
        //TODO: code to delete wrongly created files, if ws fails
        protected override void HandleAttachmentDataAndPath(string attachmentData,
                                                            object docLink, string attachmentPath)
        {
            var pathVariable = MetadataProvider.GlobalProperty(ApplicationMetadataConstants.MaximoDocLinksPath);
            var pathToSave   = pathVariable + attachmentPath;

            //TODO: Handle exceptions
            File.WriteAllBytes(pathToSave, FileUtils.ToByteArrayFromHtmlString(attachmentData));
            WsUtil.SetValue(docLink, "URLNAME", pathToSave);
            WsUtil.SetValue(docLink, "NEWURLNAME", pathToSave);
        }
 private static void FillLineCostLabor(object integrationObject)
 {
     try {
         var    payRateAux = WsUtil.GetRealValue(integrationObject, "PAYRATE");
         double payRate;
         double.TryParse(payRateAux.ToString(), out payRate);
         var regularHrsAux = WsUtil.GetRealValue(integrationObject, "REGULARHRS");
         int regularHrs;
         int.TryParse(regularHrsAux.ToString(), out regularHrs);
         var lineCost = (payRate * regularHrs);
         WsUtil.SetValue(integrationObject, "LINECOST", lineCost);
     }
     catch {
         WsUtil.SetValue(integrationObject, "LINECOST", null);
     }
 }
Esempio n. 7
0
        public void UpdateStatus(UpdateStatusOperationData opData)
        {
            MaximoOperationExecutionContext maximoExecutionContext = GetContext(opData);
            var    user = SecurityFacade.CurrentUser();
            object wo   = maximoExecutionContext.IntegrationObject;

            //just to validate that the json can be converted to a num
            WsUtil.SetValue(wo, "wonum", opData.wonum);
            var    woStatus    = WsUtil.SetValue(wo, "STATUS", opData.status);
            var    statusDate  = WsUtil.SetValue(wo, "STATUSDATE", opData.statusdate ?? DateTime.Now.FromServerToRightKind());
            object statusIFace = WsUtil.SetValue(wo, "STATUSIFACE", true);
            var    nemo        = ReflectionUtil.InstantiateProperty(wo, "NP_STATUSMEMO", new { Value = WsUtil.GetRealValue(wo, "MEMO") });

            WsUtil.SetChanged(nemo, statusIFace, statusDate, woStatus);
            maximoExecutionContext.InvokeProxy();
        }
        protected override void HandleLabors(CrudOperationData entity, object maximoWo)
        {
            var labors    = (IEnumerable <CrudOperationData>)entity.GetRelationship("labtrans");
            var newLabors = labors.Where(r => r.GetAttribute("labtransid") == null);

            var user = SecurityFacade.CurrentUser();

            WsUtil.CloneArray(newLabors, maximoWo, "LABTRANS",
                              delegate(object integrationObject, CrudOperationData crudData) {
                if (ReflectionUtil.IsNull(integrationObject, "LABTRANSID"))
                {
                    WsUtil.SetValue(integrationObject, "LABTRANSID", -1);
                    WsUtil.SetValue(integrationObject, "ORGID", user.OrgId);
                    WsUtil.SetValue(integrationObject, "SITEID", user.SiteId);
                    WsUtil.SetValue(integrationObject, "TRANSDATE", DateTime.Now.FromServerToRightKind(), true);
                    WsUtil.SetValue(integrationObject, "ENTERDATE", DateTime.Now.FromServerToRightKind(), true);
                    FillLineCostLabor(integrationObject);
                }
            });
        }
Esempio n. 9
0
        private static void HandleTools(MaximoOperationExecutionContext maximoTemplateData, CrudOperationData entity, object wo)
        {
            var tooltrans          = (IEnumerable <CrudOperationData>)entity.GetRelationship("tooltrans");
            var newTools           = tooltrans.Where(r => r.GetAttribute("tooltransid") == null);
            var recordKey          = entity.Id;
            var user               = SecurityFacade.CurrentUser();
            var crudOperationDatas = newTools as CrudOperationData[] ?? newTools.ToArray();

            WsUtil.CloneArray(crudOperationDatas, wo, "TOOLTRANS", delegate(object integrationObject, CrudOperationData crudData) {
                var itemsetid    = (string)crudOperationDatas[0].GetAttribute("toolitem_.itemsetid");
                var qtyRequested = (Int64)WsUtil.GetRealValue(integrationObject, "TOOLQTY");
                var hrsRequested = (double)WsUtil.GetRealValue(integrationObject, "TOOLHRS");
                var rate         = qtyRequested / hrsRequested;

                WsUtil.SetValue(integrationObject, "TOOLTRANSID", -1);

                WsUtil.SetValue(integrationObject, "TOOLQTY", qtyRequested);
                WsUtil.SetValue(integrationObject, "TOOLHRS", hrsRequested);
                WsUtil.SetValue(integrationObject, "TOOLRATE", rate);
                WsUtil.SetValue(integrationObject, "LINECOST", 0);
                WsUtil.SetValue(integrationObject, "OUTSIDE", false);
                WsUtil.SetValue(integrationObject, "ROLLUP", false);
                WsUtil.SetValue(integrationObject, "ENTEREDASTASK", false);
                WsUtil.SetValue(integrationObject, "ITEMSETID", itemsetid);
                WsUtil.SetValue(integrationObject, "ENTERBY", user.Login.ToUpper());
                WsUtil.SetValue(integrationObject, "ORGID", user.OrgId.ToUpper());
                WsUtil.SetValue(integrationObject, "SITEID", user.SiteId.ToUpper());
                WsUtil.SetValue(integrationObject, "REFWO", recordKey);
                WsUtil.SetValue(integrationObject, "ACTUALDATE", DateTime.Now.FromServerToRightKind(), true);
                WsUtil.SetValue(integrationObject, "TRANSDATE", DateTime.Now.FromServerToRightKind(), true);
                WsUtil.SetValue(integrationObject, "TRANSDATE", DateTime.Now.FromServerToRightKind(), true);
                WsUtil.SetValue(integrationObject, "ENTERDATE", DateTime.Now.FromServerToRightKind(), true);


                ReflectionUtil.SetProperty(integrationObject, "action", OperationType.Change.ToString());
            });
        }