Esempio n. 1
0
 public static string GetOperationName(this int value)
 {
     return(OperationTools.GetOperationNameEnById(value));
 }
Esempio n. 2
0
        private void InitOperationAttributes(int operationId)
        {
            if (operationId == 0)
            {
                operationAttributes1.InitializeControl(null);
                return;
            }

            _viewShedulerStepModel.nameVis = cbOperation.Text;

            string fileName = OperationTools.GetOperationFileNameById(operationId);

            if (string.IsNullOrEmpty(fileName))
            {
                operationAttributes1.InitializeControl(null);
                return;
            }

            Type   attrType     = null;
            string operName     = OperationTools.GetOperationNameEnById(operationId);
            string operFileName = OperationTools.GetOperationFileNameById(operationId);
            string operFileMd5  = OperationTools.GetOperationFileMd5ById(operationId);

            if (!string.IsNullOrEmpty(operName) && !string.IsNullOrEmpty(operFileName) && !string.IsNullOrEmpty(operFileMd5))
            {
                attrType = PluginOperationAdapter.GetPluginOperationAttributesType(
                    operName
                    , operFileName
                    , operFileMd5);
            }

            if (attrType != null)
            {
                IOperationAttributes operationAttributesInstance = (IOperationAttributes)Activator.CreateInstance(attrType);

                //Ищем сохраненные атрибуты
                JObject savedModel = NewtonJson.GetModelFromJson(_viewShedulerStepModel.OperationAttributes) as JObject;
                JToken  token      = null;
                if (savedModel != null && savedModel.HasValues)
                {
                    foreach (var prop in operationAttributesInstance.GetType().GetProperties())
                    {
                        savedModel.TryGetValue(prop.Name, out token);
                        if (token != null)
                        {
                            object propValue = ExtTools.ConvertStringToType(token.ToString(), prop.PropertyType);
                            if (propValue != null)
                            {
                                prop.SetValue(operationAttributesInstance, propValue);
                            }
                        }
                    }
                }

                operationAttributes1.InitializeControl(operationAttributesInstance, operationId);
            }
            else
            {
                operationAttributes1.InitializeControl(null);
            }
        }
Esempio n. 3
0
        private ShedulerStepObj CheckStepResultNew(ShedulerStepObj step)
        {
            MLogger.Debug($"\"CheckStepResultNew\", StepId: {step.Id}, ThreadId: {Thread.CurrentThread.ManagedThreadId}, OperationId: {step.OperationID}");
            var operation = MQueryCommand.SelectOperationById(step.OperationID);

            if (operation != null)
            {
                //операция не прочитана
                if (!(operation.IsRead ?? false))
                {
                    MLogger.Debug($"\"CheckStepResultNew\" - operation not readed, StepId: {step.Id}, ThreadId: {Thread.CurrentThread.ManagedThreadId}, OperationId: {step.OperationID}");
                    var typeName = OperationTools.GetOperationNameEnById(operation.OperationType);
                    MQueryCommand.TryInsertShedulerHistory(Id, step.Id, step.ComputerId, false, $"Операция \"{typeName}\" для компьютера \"{operation.ComputerName}\" не прочитана. ID операции = {operation.ID}");
                    return(null);
                }

                //операция прочитана, но не выполена
                if ((operation.IsRead ?? false) && (!(operation.IsCompleted ?? false) || (operation.Is1CError == 1)))
                {
                    MLogger.Debug($"\"CheckStepResultNew\" - operation readed, bun not completed, StepId: {step.Id}, ThreadId: {Thread.CurrentThread.ManagedThreadId}, OperationId: {step.OperationID}");
                    if (step.RepeatCount > 0)
                    {
                        MLogger.Debug($"\"CheckStepResultNew\" - step.RepeatCount > 0) operation readed, bun not completed, StepId: {step.Id}, ThreadId: {Thread.CurrentThread.ManagedThreadId}, OperationId: {step.OperationID}");
                        MLogger.Debug($"\"CheckStepResultNew\" - step.RepeatCount ((до step.RepeatCount -= 1) = {step.RepeatCount}) operation readed, bun not completed, StepId: {step.Id}, ThreadId: {Thread.CurrentThread.ManagedThreadId}, OperationId: {step.OperationID}");
                        step.RepeatCount -= 1;
                        MLogger.Debug($"\"CheckStepResultNew\" - step.RepeatCount ((после step.RepeatCount -= 1) = {step.RepeatCount}) operation readed, bun not completed, StepId: {step.Id}, ThreadId: {Thread.CurrentThread.ManagedThreadId}, OperationId: {step.OperationID}");
                        Thread.Sleep(step.RepeatTimeout ?? 0);
                        MLogger.Debug($"\"CheckStepResultNew\" - step.RepeatCount (после step.RepeatCount -= 1), operation readed, bun not completed, return StepId: {step.Id}, ThreadId: {Thread.CurrentThread.ManagedThreadId}, OperationId: {step.OperationID}");
                        return(step);
                    }
                    else
                    {
                        var newStep = GetStep(step.OnOperationErrorStep);
                        if (newStep != null)
                        {
                            MLogger.Debug($"\"CheckStepResultNew\" - step.RepeatCount <= 0, operation readed, bun not completed, return StepId: {newStep.Id}, ThreadId: {Thread.CurrentThread.ManagedThreadId}, OperationId: {step.OperationID}");
                        }
                        else
                        {
                            MLogger.Debug($"\"CheckStepResultNew\" - step.RepeatCount <= 0, operation readed, bun not completed, return StepId: null, ThreadId: {Thread.CurrentThread.ManagedThreadId}");
                        }
                        return(newStep);
                    }
                }

                //операция прочитана и выполнена
                if ((operation.IsRead ?? false) && (operation.IsCompleted ?? false) && (operation.Is1CError == 0))
                {
                    var newStep = GetStep(step.OnOperationCompleteStep);
                    if (newStep != null)
                    {
                        MLogger.Debug($"\"CheckStepResultNew\" - operation readed, bun not completed, return StepId: {newStep.Id}, ThreadId: {Thread.CurrentThread.ManagedThreadId}, OperationId: {step.OperationID}");
                    }
                    else
                    {
                        MLogger.Debug($"\"CheckStepResultNew\" - operation readed, bun not completed, return StepId: null, ThreadId: {Thread.CurrentThread.ManagedThreadId}");
                    }
                    return(newStep);
                }
            }
            return(null);
        }