private void HandlePRLINES(MaximoOperationExecutionContext maximoTemplateData, CrudOperationData crudDataEntity, object sr)
        {
            var prlines = (IEnumerable <CrudOperationData>)crudDataEntity.GetRelationship("prline");

            var recordKey = crudDataEntity.Id;
            var user      = SecurityFacade.CurrentUser();

            w.CloneArray((IEnumerable <CrudOperationData>) crudDataEntity.GetRelationship("prline"), sr, "PRLINE",
                         delegate(object integrationObject, CrudOperationData crudData)
            {
                if (ReflectionUtil.IsNull(integrationObject, "PRLINENUM"))
                {
                    w.SetValue(integrationObject, "PRLINENUM", 1);
                }
                var enterdate = sr;
                w.SetValueIfNull(integrationObject, "ENTERDATE", DateTime.Now.FromServerToRightKind());
                w.SetValueIfNull(integrationObject, "TAX1", 0);
                w.SetValueIfNull(integrationObject, "TAX2", 0);
                w.SetValueIfNull(integrationObject, "TAX3", 0);
                w.SetValueIfNull(integrationObject, "TAX4", 0);
                w.SetValueIfNull(integrationObject, "TAX5", 0);
                w.SetValueIfNull(integrationObject, "ISSUE", false);
                w.SetValueIfNull(integrationObject, "CHARGESTORE", false);
                w.SetValueIfNull(integrationObject, "RECEIPTREQD", false);
                w.SetValueIfNull(integrationObject, "LOADEDCOST", 0);
                w.SetValueIfNull(integrationObject, "PRORATESERVICE", false);
                w.SetValueIfNull(integrationObject, "CONVERTTORFQ", false);
                w.SetValueIfNull(integrationObject, "INSPECTIONREQUIRED", false);
                w.SetValueIfNull(integrationObject, "ISDISTRIBUTED", false);
                w.SetValueIfNull(integrationObject, "LINECOST", 0);
                w.SetValueIfNull(integrationObject, "LINETYPE", "ITEM");
                w.SetValueIfNull(integrationObject, "ENTERBY", user.Login);
                w.SetValueIfNull(integrationObject, "SITEID", user.SiteId);
                w.SetValueIfNull(integrationObject, "ORGID", user.OrgId);
                w.SetValueIfNull(integrationObject, "ENTEREDASTASK", false);
                w.SetValueIfNull(integrationObject, "CONVERTTOCONTRACT", false);
                w.SetValueIfNull(integrationObject, "LANGCODE", "EN");
                w.SetValueIfNull(integrationObject, "CONVERSION", 1);
                w.SetValueIfNull(integrationObject, "HASID", false);
                w.SetValueIfNull(integrationObject, "PRLINENUM", 0);
                w.SetValueIfNull(integrationObject, "MKTPLCITEM", false);
                w.SetValueIfNull(integrationObject, "TAXEXEMPT", false);
                w.SetValueIfNull(integrationObject, "CONSIGNMENT", false);
                w.SetValueIfNull(integrationObject, "ITEMNUM", "test");

                ReflectionUtil.SetProperty(integrationObject, "action", OperationType.Add.ToString());
            });
        }
Exemple #2
0
        public static void HandleAttachmentsForUpdate(CrudOperationData entity, object maximoTicket)
        {
            var maximoAttachments = entity.GetRelationship("attachment_");
            var attachmentList    = new List <Attachment>();
            //on ie9 the screenshot data come on the root entity. Look at ApplicationController#PopulateInputsInJson and screenshotService#handleRichTextBoxSubmit
            var screenshotString = entity.GetAttribute("newscreenshot") as string;
            var screenshotName   = entity.GetAttribute("newscreenshot_path") as string;

            if (screenshotString != null && screenshotName != null)
            {
                Log.DebugFormat("handling screenshot for update");
                HandleScreenshots(screenshotString, screenshotName, attachmentList);
            }
            foreach (var maximoAttachment in (IEnumerable <CrudOperationData>)maximoAttachments)
            {
                var attachmentsAdded = DoHandleAttachment(maximoAttachment, maximoTicket);
                attachmentList.AddRange(attachmentsAdded);
            }

            if (attachmentList.Any() && maximoTicket is ServiceIncident)
            {
                AddWorkLogEnttry(maximoTicket);
            }

            if (maximoTicket is ServiceIncident)
            {
                ((ServiceIncident)maximoTicket).Attachment = attachmentList.ToArray();
            }
            else if (maximoTicket is ChangeRequest)
            {
                ((ChangeRequest)maximoTicket).Attachment = attachmentList.ToArray();
            }
        }
        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());
            });
        }
        protected virtual void HandleAttachments(CrudOperationData entity, object wo, ApplicationMetadata metadata)
        {
            var user = SecurityFacade.CurrentUser();

            var attachmentString = entity.GetUnMappedAttribute("newattachment");
            var attachmentPath   = entity.GetUnMappedAttribute("newattachment_path");

            if (!String.IsNullOrWhiteSpace(attachmentString) && !String.IsNullOrWhiteSpace(attachmentPath))
            {
                _attachmentHandler.HandleAttachments(wo, attachmentString, attachmentPath, metadata);
            }
            var screenshotString = entity.GetUnMappedAttribute("newscreenshot");
            var screenshotName   = "screen" + DateTime.Now.ToUserTimezone(user).ToString("yyyyMMdd") + ".png";

            if (!String.IsNullOrWhiteSpace(screenshotString) && !String.IsNullOrWhiteSpace(screenshotName))
            {
                _attachmentHandler.HandleAttachments(wo, screenshotString, screenshotName, metadata);
            }

            var attachments = entity.GetRelationship("attachment");

            if (attachments != null)
            {
                foreach (var attachment in (IEnumerable <CrudOperationData>)attachments)
                {
                    attachmentString = attachment.GetUnMappedAttribute("newattachment");
                    attachmentPath   = (string)(attachment.GetUnMappedAttribute("newattachment_path") ?? attachment.GetAttribute("document"));
                    if (attachmentString != null && attachmentPath != null)
                    {
                        _attachmentHandler.HandleAttachments(wo, attachmentString, attachmentPath, metadata);
                    }
                }
            }
        }
Exemple #5
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());
            });
        }
Exemple #6
0
        protected virtual void HandleLongDescription(ServiceIncident webServiceObject, CrudOperationData entity, ApplicationMetadata metadata, bool update)
        {
            var problem = webServiceObject.Problem;
            var ld      = (CrudOperationData)entity.GetRelationship("longdescription");

            if (ld != null)
            {
                problem.Description = (string)ld.GetAttribute("ldtext");
            }
        }
 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);
         }
     });
 }
Exemple #8
0
        public static T HandleLongDescription <T>(T integrationObject, CrudOperationData entity, string property = "DESCRIPTION_LONGDESCRIPTION")
        {
            var ld = (CrudOperationData)entity.GetRelationship("longdescription");

            if (ld != null)
            {
                w.SetValue(integrationObject, property, ld.GetAttribute("ldtext"));
            }
            return(integrationObject);
        }
Exemple #9
0
        private void HandleLongDescription(object integrationObject, CrudOperationData entity, ApplicationMetadata metadata)
        {
            var ld          = (CrudOperationData)entity.GetRelationship("longdescription");
            var association = entity.EntityMetadata.Associations.First(a => a.To == "longdescription");

            if (ld != null)
            {
                var originalLd      = (string)ld.GetAttribute("ldtext");
                var longDescription = ParseSchemaBasedLD(originalLd, entity, metadata.Schema.SchemaId);
                w.SetValue(integrationObject, "DESCRIPTION_LONGDESCRIPTION", longDescription);
            }
        }
Exemple #10
0
        private void HandleSolutions(MaximoOperationExecutionContext maximoTemplateData, CrudOperationData crudDataEntity, object sr)
        {
            var solutions = (IEnumerable <CrudOperationData>)crudDataEntity.GetRelationship("solution");
            var recordKey = crudDataEntity.Id;
            var user      = SecurityFacade.CurrentUser();

            w.CloneArray((IEnumerable <CrudOperationData>) crudDataEntity.GetRelationship("solution"), sr, "SOLUTION",
                         delegate(object integrationObject, CrudOperationData crudData)
            {
                if (ReflectionUtil.IsNull(integrationObject, "SOLUTION"))
                {
                    w.SetValue(integrationObject, "SOLUTION", -1);
                }
                var enterdate = sr;

                w.SetValueIfNull(integrationObject, "SOLUTIONID", 0);
                w.SetValueIfNull(integrationObject, "ORGID", user.OrgId);


                ReflectionUtil.SetProperty(integrationObject, "action", OperationType.Add.ToString());
            });
        }
Exemple #11
0
        protected override void HandleLongDescription(ServiceIncident webServiceObject, CrudOperationData entity, ApplicationMetadata metadata, bool update)
        {
            var problem = webServiceObject.Problem;
            var ld      = (CrudOperationData)entity.GetRelationship("longdescription");

            if (ld != null)
            {
                var originalLd = (string)ld.GetAttribute("ldtext");
                if (!update)
                {
                    problem.Description = HapagSRLongDescriptionHandler.ParseSchemaBasedLongDescription(originalLd,
                                                                                                        entity, metadata.Schema.SchemaId);
                }
                else
                {
                    problem.Description = originalLd;
                }
            }
        }
        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);
                }
            });
        }
Exemple #13
0
        protected void HandleWorkLog(CrudOperationData entity, ServiceIncident maximoTicket)
        {
            var maximoWorklogs = entity.GetRelationship("worklog_");
            var worklogList    = new List <Activity>();
            var user           = SecurityFacade.CurrentUser();

            foreach (var jsonWorklog in (IEnumerable <CrudOperationData>)maximoWorklogs)
            {
                var worklogid = jsonWorklog.GetAttribute("worklogid");
                if (worklogid == null)
                {
                    var activity = LongDescriptionHandler.HandleLongDescription(new Activity(), jsonWorklog, "ActionLog");
                    activity.ActionLogSummary = (string)jsonWorklog.GetAttribute("description");
                    activity.type             = "WorkLog";
                    activity.UserID           = ISMConstants.AddEmailIfNeeded(user.MaximoPersonId);
                    //activity.LogDateTimeSpecified = true;
                    //activity.LogDateTime = DateTime.Now;
                    activity.ActivityType = "CLIENTNOTE";
                    worklogList.Add(activity);
                }
            }
            maximoTicket.Activity = ArrayUtil.PushRange(maximoTicket.Activity, worklogList);
        }
Exemple #14
0
        private static Boolean HandleWorkLog(CrudOperationData entity, ChangeRequest maximoTicket)
        {
            var maximoWorklogs = entity.GetRelationship("worklog_");
            var worklogList    = new List <ChangeLog>();
            var user           = SecurityFacade.CurrentUser();

            foreach (var jsonWorklog in (IEnumerable <CrudOperationData>)maximoWorklogs)
            {
                var worklogid = jsonWorklog.GetAttribute("worklogid");
                if (worklogid == null)
                {
                    var changeLog = new ChangeLog {
                        Log                  = (string)jsonWorklog.GetAttribute("description"),
                        ActionID             = "CLIENTNOTE",
                        UserID               = ISMConstants.AddEmailIfNeeded(user.MaximoPersonId),
                        LogDateTimeSpecified = true,
                        LogDateTime          = DateTime.Now
                    };
                    var longDesc = "";
                    var ld       = (CrudOperationData)jsonWorklog.GetRelationship("longdescription");
                    if (ld != null)
                    {
                        longDesc = (string)ld.GetAttribute("ldtext");
                    }
                    changeLog.FlexFields = new[] {
                        new FlexFieldsFlexField {
                            mappedTo = "WLLongDesc", id = "0", Value = longDesc
                        }
                    };

                    worklogList.Add(changeLog);
                }
            }

            maximoTicket.ChangeLog = ArrayUtil.PushRange(maximoTicket.ChangeLog, worklogList);
            return(worklogList.Any());
        }
Exemple #15
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());
            });
        }
Exemple #16
0
        public static void HandleWorkLogs(CrudOperationData entity, object rootObject)
        {
            var user        = SecurityFacade.CurrentUser();
            var worklogs    = (IEnumerable <CrudOperationData>)entity.GetRelationship("worklog");
            var newWorkLogs = worklogs.Where(r => r.GetAttribute("worklogid") == null);
//            var association =entity.EntityMetadata.Associations.First(a => a.To == "worklog");
            var recordKey = entity.Id;

            w.CloneArray(worklogs, rootObject, "WORKLOG", delegate(object integrationObject, CrudOperationData crudData) {
                ReflectionUtil.SetProperty(integrationObject, "action", ProcessingActionType.AddChange.ToString());
                w.SetValueIfNull(integrationObject, "worklogid", -1);
                w.SetValue(integrationObject, "recordkey", recordKey);
                w.SetValueIfNull(integrationObject, "class", entity.TableName);

                w.CopyFromRootEntity(rootObject, integrationObject, "siteid", user.SiteId);
                w.CopyFromRootEntity(rootObject, integrationObject, "orgid", user.OrgId);
                w.CopyFromRootEntity(rootObject, integrationObject, "createby", user.Login, "CHANGEBY");
                w.CopyFromRootEntity(rootObject, integrationObject, "createdate", DateTime.Now.FromServerToRightKind());
                w.CopyFromRootEntity(rootObject, integrationObject, "modifydate", DateTime.Now.FromServerToRightKind());
                w.SetValueIfNull(integrationObject, "logtype", "CLIENTNOTE");

                LongDescriptionHandler.HandleLongDescription(integrationObject, crudData);
            });
        }
        public IEnumerable <Activity> LoadFromServicePlan(string schemaid, CrudOperationData jsonObject)
        {
            if ("installstd".Equals(schemaid))
            {
                return(HandleIbmTechMatrix(jsonObject, "HLAINPCS", "HLAINPCH", "HLAINPCW", "HLAINPCH_HLU", "HLAINPCS_HLU"));
            }
            if ("installlan".Equals(schemaid))
            {
                if ("lan".Equals(jsonObject.GetAttribute("lantype")))
                {
                    return(HandleIbmTechMatrix(jsonObject, "HLAINPRS", "HLAINPRH", "HLAINPRW", "HLAINPRH_HLU", "HLAINPRS_HLU"));
                }
                return(HandleIbmTechMatrix(jsonObject, "HLAINPRSEP", "HLAINPRHHP", "HLAINPRWWP", "HLAINPRHHP_HLU", "HLAINPRSEP_HLU"));
            }

            if ("installother".Equals(schemaid))
            {
                var classification = jsonObject.GetAttribute("classification") ?? "";
                if (!classification.Equals("43290200"))
                {
                    return(DoLoadFromFile("HLAINOTHER"));
                }
                return(HandleIbmTechMatrix(jsonObject, "HLAINVPCS", "HLAINVPCS", "HLAINVPCS", "HLAINVPCS_HLU",
                                           "HLAINVPCS_HLU"));
            }
            var lanType      = jsonObject.GetAttribute("lantype") as string ?? "";
            var isLan        = lanType.Equals("lan", StringComparison.CurrentCultureIgnoreCase);
            var isLanHostPap = lanType.Equals("lan/host/pap", StringComparison.CurrentCultureIgnoreCase);
            var assetRel     = (CrudOperationData)jsonObject.GetRelationship("asset");

            if (assetRel == null)
            {
                throw ExceptionUtil.InvalidOperation("asset should be selected");
            }
            var assetStatus  = assetRel.GetAttribute("status") as string ?? "";
            var isIdleStatus = "150 Idle".Equals(assetStatus, StringComparison.CurrentCultureIgnoreCase);

            if ("move".Equals(schemaid))
            {
                var currentITC     = GetCurrentITC(jsonObject);
                var fromLocation   = jsonObject.GetAttribute("fromlocation");
                var toLocation     = jsonObject.GetAttribute("tolocation");
                var classification = jsonObject.GetUnMappedAttribute("asset_.classstructureid") ?? "";

                var toITC = ISMConstants.AddEmailIfNeeded(jsonObject.GetAttribute("toitc") as string);
                if (toITC != null)
                {
                    toITC = toITC.ToUpper();
                }
                if (fromLocation.Equals(toLocation))
                {
                    if (currentITC.Equals(toITC))
                    {
                        return(HandleIbmTechMatrix(jsonObject, "HLAMVINS", "HLAMVINH", "HLAMVINW", "HLAMVINH_HLU", "HLAMVINS_HLU"));
                    }

                    if (isIdleStatus)
                    {
                        return(HandleIbmTechMatrix(jsonObject, "HLAMVINCOS", "HLAMVINCOH", null, "HLAMVINCOH_HLU", "HLAMVINCOS_HLU"));
                    }



                    if (classification.StartsWith("432121"))
                    {
                        if (isLan)
                        {
                            return(HandleIbmTechMatrix(jsonObject, "HLARMPRSIO", "HLARMPRHIO", "HLARMPRWIO", "HLARMPRHIO_HLU", "HLARMPRSIO_HLU"));
                        }
                        if ("lan/host".Equals(lanType) || isLanHostPap)
                        {
                            return(HandleIbmTechMatrix(jsonObject, "HLARMPPSIO", "HLARMPPHIO", "HLARMPPWIO", "HLARMPPHIO_HLU", "HLARMPPSIO_HLU"));
                        }
                    }
                    return(HandleIbmTechMatrix(jsonObject, "HLARMPCSIO", "HLARMPCHIO", "HLARMPCWIO", "HLARMPCHIO_HLU", "HLARMPCSIO_HLU"));
                }

                if (currentITC.Equals(toITC))
                {
                    if (isIdleStatus)
                    {
                        return(DoLoadFromFile("HLAMVOTS"));
                    }
                    if (classification.StartsWith("432121"))
                    {
                        if (isLan)
                        {
                            return(HandleIbmTechMatrix2Cases(jsonObject, "HLARMPRSOS", "HLARMPRSOS_HLU"));
                        }
                        if (isLanHostPap)
                        {
                            return(HandleIbmTechMatrix2Cases(jsonObject, "HLARMPPSOS", "HLARMPPSOS_HLU"));
                        }
                    }
                    return(HandleIbmTechMatrix2Cases(jsonObject, "HLARMPCSOS", "HLARMPCSOS_HLU"));
                }
                if (classification.StartsWith("432121"))
                {
                    if (isLan)
                    {
                        return(HandleIbmTechMatrix2Cases(jsonObject, "HLARMPRSOO", "HLARMPRSOO_HLU"));
                    }
                    if (isLanHostPap)
                    {
                        return(HandleIbmTechMatrix2Cases(jsonObject, "HLARMPPSOO", "HLARMPPSOO_HLU"));
                    }
                }
                if (!isIdleStatus)
                {
                    return(HandleIbmTechMatrix2Cases(jsonObject, "HLARMPCSOO", "HLARMPCSOO_HLU"));
                }
                return(DoLoadFromFile("HLAMVOTCOS"));
            }

            if ("update".Equals(schemaid))
            {
                return(DoLoadFromFile("HLAUPDASSD"));
            }

            if ("add".Equals(schemaid))
            {
                return(HandleIbmTechMatrix(jsonObject, "HLAADDCOMS", "HLAADDCOMH", "HLAADDCOMW", "HLAADDCOMH_HLU", "HLAADDCOMS"));
            }

            if ("removestd".Equals(schemaid))
            {
                return(HandleIbmTechMatrix(jsonObject, "HLARVPCS", "HLARVPCH", "HLARVPCW", "HLARVPCH_HLU", "HLARVPCS_HLU"));
            }

            if ("removelan".Equals(schemaid))
            {
                if (isLan)
                {
                    return(HandleIbmTechMatrix(jsonObject, "HLARVPRS", "HLARVPRH", "HLARVPRW", "HLARVPRH_HLU", "HLARVPRS_HLU"));
                }
                return(HandleIbmTechMatrix(jsonObject, "HLARVPRSEP", "HLARVPRHHP", "HLARVPRWWP", "HLARVPRHHP_HLU", "HLARVPRSEP_HLU"));
            }

            if ("removeother".Equals(schemaid))
            {
                return(DoLoadFromFile("HLARVOTHER"));
            }

            if ("replacestd".Equals(schemaid))
            {
                return(HandleIbmTechMatrix(jsonObject, "HLARPPCS", "HLARPPCH", "HLARPPCW", "HLARPPCH_HLU", "HLARPPCS_HLU"));
            }

            if ("replacelan".Equals(schemaid))
            {
                if (isLan)
                {
                    return(HandleIbmTechMatrix(jsonObject, "HLARPPRS", "HLARPPRH", "HLARPPRW", "HLARPPRH_HLU", "HLARPPRS_HLU"));
                }
                return(HandleIbmTechMatrix(jsonObject, "HLARPPRSEP", "HLARPPRHHP", "HLARPPRWWP", "HLARPPRHHP_HLU", "HLARPPRSEP_HLU"));
            }

            if ("replaceother".Equals(schemaid))
            {
                return(DoLoadFromFile("HLARPOTHER"));
            }

            if ("decommission".Equals(schemaid))
            {
                return(DoLoadFromFile("HLADECOMM"));
            }

            return(null);
        }