Example #1
0
        public void Excute(LoadDocParametersFactory loadDoc)
        {
            if (loadDoc == null)
                return;
            var doc = loadDoc.GetParameters();
            BuilderFetch buildXML = new BuilderFetch();
            var fetchxml = buildXML.AddConditionLoad(doc)
                            .AddConditionDelivery(doc)
                                    .AddConditionTradeIn(doc)
                                            .AddConditionTestDrive(doc)
                                                                .Builder(doc);

            EntityCollection result = _service.RetrieveMultiple(new FetchExpression(fetchxml));
            foreach (var doctype in result.Entities)
            {
                Entity task = new Entity("task");
                bool? isRequried = doctype.GetAttributeValue<bool?>("new_required");
                bool setReq = false;
                if (isRequried.HasValue && isRequried.Value == true)
                    setReq = true;
                task.Attributes.Add("subject", doc.Subject);
                task.Attributes.Add("new_is_required", setReq);
                task.Attributes.Add("new_task_type", new OptionSetValue(20));//scan(10=regular)

                task.Attributes.Add("ownerid", doc.OwnerId);
                task.Attributes.Add("regardingobjectid", doc.RegardingId);

                _service.Create(task);
            }
        }
Example #2
0
        public void Excute(LoadDocParametersFactory loadDoc)
        {
            if (loadDoc == null)
            {
                return;
            }
            var          doc      = loadDoc.GetParameters();
            BuilderFetch buildXML = new BuilderFetch();
            var          fetchxml = buildXML.AddConditionLoad(doc)
                                    .AddConditionDelivery(doc)
                                    .AddConditionTradeIn(doc)
                                    .AddConditionTestDrive(doc)
                                    .Builder(doc);

            EntityCollection result = _service.RetrieveMultiple(new FetchExpression(fetchxml));

            foreach (var doctype in result.Entities)
            {
                Entity task       = new Entity("task");
                bool?  isRequried = doctype.GetAttributeValue <bool?>("new_required");
                bool   setReq     = false;
                if (isRequried.HasValue && isRequried.Value == true)
                {
                    setReq = true;
                }
                task.Attributes.Add("subject", doc.Subject);
                task.Attributes.Add("new_is_required", setReq);
                task.Attributes.Add("new_task_type", new OptionSetValue(20));//scan(10=regular)

                task.Attributes.Add("ownerid", doc.OwnerId);
                task.Attributes.Add("regardingobjectid", doc.RegardingId);

                _service.Create(task);
            }
        }