Example #1
0
        private static String contextToString(IPluginExecutionContext context)
        {
            StringBuilder s = new StringBuilder();

            s.AppendFormat(" Depth              : {0}", RRUtils.stringVal(context.Depth)); s.AppendLine();
            s.AppendFormat(" CorrelationId      : {0}", RRUtils.stringVal(context.CorrelationId)); s.AppendLine();
            s.AppendFormat(" InitiatingUserId   : {0}", RRUtils.stringVal(context.InitiatingUserId)); s.AppendLine();
            s.AppendFormat(" IsExecutingOffline : {0}", RRUtils.stringVal(context.IsExecutingOffline)); s.AppendLine();
            s.AppendFormat(" IsInTransaction    : {0}", RRUtils.stringVal(context.IsInTransaction)); s.AppendLine();
            s.AppendFormat(" IsOfflinePlayback  : {0}", RRUtils.stringVal(context.IsOfflinePlayback)); s.AppendLine();
            s.AppendFormat(" IsolationMode      : {0}", RRUtils.stringVal(context.IsolationMode)); s.AppendLine();
            s.AppendFormat(" MessageName        : {0}", RRUtils.stringVal(context.MessageName)); s.AppendLine();
            s.AppendFormat(" Mode               : {0}", RRUtils.stringVal(context.Mode)); s.AppendLine();
            s.AppendFormat(" OperationCreatedOn : {0}", RRUtils.stringVal(context.OperationCreatedOn)); s.AppendLine();
            s.AppendFormat(" OperationId        : {0}", RRUtils.stringVal(context.OperationId)); s.AppendLine();
            s.AppendFormat(" OrganizationId     : {0}", RRUtils.stringVal(context.OrganizationId)); s.AppendLine();
            s.AppendFormat(" OrganizationName   : {0}", RRUtils.stringVal(context.OrganizationName)); s.AppendLine();
            s.AppendFormat(" OwningExtension    : {0}", RRUtils.stringVal(context.OwningExtension)); s.AppendLine();
            s.AppendFormat(" ParentContext      : {0}", RRUtils.stringVal(context.ParentContext)); s.AppendLine();
            s.AppendFormat(" PrimaryEntityId    : {0}", RRUtils.stringVal(context.PrimaryEntityId)); s.AppendLine();
            s.AppendFormat(" PrimaryEntityName  : {0}", RRUtils.stringVal(context.PrimaryEntityName)); s.AppendLine();
            s.AppendFormat(" RequestId          : {0}", RRUtils.stringVal(context.RequestId)); s.AppendLine();
            s.AppendFormat(" SecondaryEntityName: {0}", RRUtils.stringVal(context.SecondaryEntityName)); s.AppendLine();
            s.AppendFormat(" Stage              : {0}", RRUtils.stringVal(context.Stage)); s.AppendLine();
            s.AppendFormat(" UserId             : {0}", RRUtils.stringVal(context.UserId)); s.AppendLine();
            s.AppendFormat(" BusinessUnitId     : {0}", RRUtils.stringVal(context.BusinessUnitId)); s.AppendLine();
            s.AppendFormat(" Type               : {0}", context.GetType().ToString()); s.AppendLine();

            s.AppendLine("");
            s.AppendLine("Input Parameters");
            foreach (KeyValuePair <String, Object> pair in context.InputParameters)
            {
                s.AppendFormat("{0} : {1}", RRUtils.stringVal(pair.Key), RRUtils.stringVal(pair.Value));
                s.AppendLine();
            }
            s.AppendLine("");
            s.AppendLine("Output Parameters");
            foreach (KeyValuePair <String, Object> pair in context.OutputParameters)
            {
                s.AppendFormat("{0} : {1}", RRUtils.stringVal(pair.Key), RRUtils.stringVal(pair.Value));
                s.AppendLine();
            }

            s.AppendLine("");
            s.AppendLine("Shared Variables");
            foreach (KeyValuePair <String, Object> pair in context.SharedVariables)
            {
                s.AppendFormat("{0} : {1}", RRUtils.stringVal(pair.Key), RRUtils.stringVal(pair.Value));
                s.AppendLine();
            }

            return(s.ToString());
        }
Example #2
0
        public static EntityReference getRateTable(EntityReference resRef, ContextWrapper contextWrapper)
        {
            EntityReference rateTableRef = null;
            ColumnSet       userCols     = new ColumnSet("fsip_ratetable");
            Entity          res          = contextWrapper.service.Retrieve(resRef.LogicalName, resRef.Id, userCols);

            if (res != null)
            {
                rateTableRef = RRUtils.getEntityReference(res, "fsip_ratetable");
            }
            return(rateTableRef);
        }
Example #3
0
        public static String getFormattedValue(Entity entity, String attribute)
        {
            String ret = null;

            if (entity.FormattedValues != null &&
                entity.FormattedValues.Contains(attribute) &&
                entity.FormattedValues[attribute] != null)
            {
                ret = RRUtils.stringVal(entity.FormattedValues[attribute]);
            }
            return(ret);
        }
Example #4
0
        public static EntityCollection cloneEntityCollection(EntityCollection source)
        {
            EntityCollection ret = new EntityCollection();

            foreach (Entity sourceEntity in source.Entities)
            {
                EntityReference sourceParty = RRUtils.getEntityReference(sourceEntity, "partyid");
                Entity          newParty    = new Entity("activityparty");
                newParty["partyid"] = new EntityReference(sourceParty.LogicalName, sourceParty.Id);
                ret.Entities.Add(newParty);
            }

            return(ret);
        }
Example #5
0
        public Config(ContextWrapper contextWrapper)
        {
            string fetchXml = @"
            <fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false' no-lock='true'>
              <entity name='new_mapconfiguration'>
                <attribute name='fsip_approvesawhentimecardsapproved' />
                <attribute name='fsip_autogeneratebuildingid' />
                <attribute name='fsip_createprojectnumbers' />
                <attribute name='fsip_createtimecardswhensaismarkeddone' />
                <attribute name='fsip_defaultpaymentterm' />
                <attribute name='fsip_defaulttaxscheduleforaccounts' />
                <attribute name='fsip_defaulttaxscheduleforfreight' />
                <attribute name='fsip_enableinvoicetax' />
                <attribute name='fsip_enablequotetax' />
                <attribute name='fsip_enableworkordertax' />
                <attribute name='fsip_erpintegration' />
                <attribute name='fsip_externalbuildinglink' />
                <attribute name='fsip_mapsaactualtimestoscheduled' />
                <attribute name='fsip_overheadpercent' />
                <attribute name='fsip_retainageproduct' />
                <attribute name='fsip_syncsascheduledtimestoactual' />
                <attribute name='fsip_useoverridecostsinwototals' />
                <attribute name='new_googlekey' />
              </entity>
            </fetch>";

            EntityCollection collection = contextWrapper.service.RetrieveMultiple(new FetchExpression(fetchXml));

            // there must be one and only one config record
            switch (collection.Entities.Count)
            {
            case 0:
                throw new InvalidPluginExecutionException("There is no configuration record. Please set one up in the 'Settings' area.");

            case 1:
                Entity config = collection.Entities[0];

                _approvesawhentimecardsapproved    = RRUtils.getBoolValue(config, "fsip_approvesawhentimecardsapproved");
                _autogeneratebuildingid            = RRUtils.getBoolValue(config, "fsip_autogeneratebuildingid");
                _createProjectNumbers              = RRUtils.getBoolValue(config, "fsip_createprojectnumbers");
                _createtimecardswhensaismarkeddone = RRUtils.getBoolValue(config, "fsip_createtimecardswhensaismarkeddone");
                _defaultPaymentTerm            = RRUtils.getEntityReference(config, "fsip_defaultpaymentterm");
                _defaulttaxscheduleforaccounts = RRUtils.getEntityReference(config, "fsip_defaulttaxscheduleforaccounts");
                _defaulttaxscheduleforfreight  = RRUtils.getEntityReference(config, "fsip_defaulttaxscheduleforfreight");
                _enableinvoicetax            = RRUtils.getBoolValue(config, "fsip_enableinvoicetax");
                _enablequotetax              = RRUtils.getBoolValue(config, "fsip_enablequotetax");
                _enableworkordertax          = RRUtils.getBoolValue(config, "fsip_enableworkordertax");
                _erpIntegration              = RRUtils.getIntValue(config, "fsip_erpintegration");
                _externalBuildingLink        = RRUtils.getIntValue(config, "fsip_externalbuildinglink");
                _googleApiKey                = RRUtils.getStringValue(config, "new_googlekey");
                _mapsaactualtimestoscheduled = RRUtils.getBoolValue(config, "fsip_mapsaactualtimestoscheduled");
                _overheadPct                  = RRUtils.getDecimalValue(config, "fsip_overheadpercent");
                _retainageProduct             = RRUtils.getEntityReference(config, "fsip_retainageproduct");
                _syncsascheduledtimestoactual = RRUtils.getBoolValue(config, "fsip_syncsascheduledtimestoactual");
                _useoverridecostsinwototals   = RRUtils.getBoolValue(config, "fsip_useoverridecostsinwototals");;

                break;

            default:
                throw new InvalidPluginExecutionException("More than one configuration record found. Please ensure only one Config record exisits.");
            }
        }