示例#1
0
        private static void СозданиеЗадач() //  < ----- )))))))))))))))))))))))))
        {
            var service      = new OrganizationService(connection);
            var dataFromXmlx = new Program().ExcelOpenSpreadsheets(@"C:\Users\savchinvv\Desktop\Задачи.xlsx");

            for (int i = 2; i < dataFromXmlx.Tables[0].Rows.Count; i++)
            {
                var newTask = new SoftLine.Models.Task()
                {
                    Subject               = dataFromXmlx.Tables[0].Rows[i][0].ToString(),
                    RegardingObjectId     = ToSpravaEntity(dataFromXmlx.Tables[0].Rows[i][1].ToString()),
                    PriorityCode          = ToOptionSetValue(dataFromXmlx.Tables[0].Rows[i][2].ToString()),
                    ScheduledEnd          = FindDate(dataFromXmlx.Tables[0].Rows[i][3].ToString()),
                    ScheduledStart        = FindDate(dataFromXmlx.Tables[0].Rows[i][4].ToString()),
                    ActualDurationMinutes = ToInt32(dataFromXmlx.Tables[0].Rows[i][5].ToString()),
                    Description           = dataFromXmlx.Tables[0].Rows[i][6].ToString(),
                    PercentComplete       = ToInt32(dataFromXmlx.Tables[0].Rows[i][7].ToString()),
                    ActualStart           = FindDate(dataFromXmlx.Tables[0].Rows[i][9].ToString()),
                    ActualEnd             = FindDate(dataFromXmlx.Tables[0].Rows[i][10].ToString())
                };
                var id = service.Create(newTask);
                Console.WriteLine("{0} - созданая Задача", dataFromXmlx.Tables[0].Rows[i][0].ToString());
                bool?status = false;
                if (dataFromXmlx.Tables[0].Rows[i][8].ToString() == "Завершено")
                {
                    status = ChangeStateCode(id);
                }
                Console.WriteLine("Задача = StatusChange->{0}", status ?? null);
            }
        }
示例#2
0
        private static bool?ChangeStateCode(Guid id)
        {
            var             service = new OrganizationService(connection);
            SetStateRequest state   = new SetStateRequest();

            state.State  = new OptionSetValue((int)TaskState.Completed);
            state.Status =
                new OptionSetValue(5);
            state.EntityMoniker = new EntityReference()
            {
                Id          = id,
                LogicalName = SoftLine.Models.Task.EntityLogicalName
            };
            SetStateResponse stateSet = (SetStateResponse)service.Execute(state);

            SoftLine.Models.Task task =
                service.Retrieve(SoftLine.Models.Task.EntityLogicalName, id, new ColumnSet("statecode")).ToEntity <SoftLine.Models.Task>();
            if (task.StateCode == TaskState.Completed)
            {
                return(true);
            }
            return(null);
        }
示例#3
0
        //  < ----- )))))))))))))))))))))))))
        private static void СозданиеЗадач()
        {
            var service = new OrganizationService(connection);
            var dataFromXmlx = new Program().ExcelOpenSpreadsheets(@"C:\Users\savchinvv\Desktop\Задачи.xlsx");

            for (int i = 2; i < dataFromXmlx.Tables[0].Rows.Count; i++)
            {
                var newTask = new SoftLine.Models.Task()
                {
                    Subject = dataFromXmlx.Tables[0].Rows[i][0].ToString(),
                    RegardingObjectId = ToSpravaEntity(dataFromXmlx.Tables[0].Rows[i][1].ToString()),
                    PriorityCode = ToOptionSetValue(dataFromXmlx.Tables[0].Rows[i][2].ToString()),
                    ScheduledEnd = FindDate(dataFromXmlx.Tables[0].Rows[i][3].ToString()),
                    ScheduledStart = FindDate(dataFromXmlx.Tables[0].Rows[i][4].ToString()),
                    ActualDurationMinutes = ToInt32(dataFromXmlx.Tables[0].Rows[i][5].ToString()),
                    Description = dataFromXmlx.Tables[0].Rows[i][6].ToString(),
                    PercentComplete = ToInt32(dataFromXmlx.Tables[0].Rows[i][7].ToString()),
                    ActualStart = FindDate(dataFromXmlx.Tables[0].Rows[i][9].ToString()),
                    ActualEnd = FindDate(dataFromXmlx.Tables[0].Rows[i][10].ToString())
                };
                var id = service.Create(newTask);
                Console.WriteLine("{0} - созданая Задача", dataFromXmlx.Tables[0].Rows[i][0].ToString());
                bool? status = false;
                if (dataFromXmlx.Tables[0].Rows[i][8].ToString() == "Завершено")
                {
                    status = ChangeStateCode(id);
                }
                Console.WriteLine("Задача = StatusChange->{0}", status ?? null);
            }
        }