Example #1
0
        internal override MSA.Expression/*!*/ TransformResult(AstGenerator/*!*/ gen, ResultOperation resultOperation) {
            Assert.NotNull(gen);

            if (HasExceptionHandling) {
                return TransformExceptionHandling(gen, resultOperation);
            } else {
                return gen.TransformStatements(_statements, resultOperation);
            }
        }
Example #2
0
        /// <summary>
        /// Transform and handle the result according to the specified result operation.
        /// </summary>
        internal virtual MSA.Expression/*!*/ TransformResult(AstGenerator/*!*/ gen, ResultOperation resultOperation) {
            MSA.Expression resultExpression = TransformRead(gen);
            MSA.Expression statement;

            if (resultOperation.Variable != null) {
                statement = Ast.Assign(resultOperation.Variable, Ast.Convert(resultExpression, resultOperation.Variable.Type));
            } else {
                statement = gen.Return(resultExpression);
            }

            return gen.AddDebugInfo(statement, Location);
        }
Example #3
0
        public ResultOperation ExceptionHandler(Exception exception)
        {
            this.RollbackTransaction();
            ResultOperation resultOperation = new ResultOperation();

            if (exception.InnerException == null && !string.IsNullOrWhiteSpace(exception.Message))
            {
                resultOperation.AddError(exception.Message);
            }
            else
            {
                resultOperation.AddError(exception.ToString());
            }
            return(resultOperation);
        }
        private void ButtonSave_Click(object sender, RoutedEventArgs e)
        {
            //Reset the error list
            errors.Clear();

            //Execute the validations
            if (ExecuteValidations())
            {
                //Password is not bound for safety issues, therefore we have to do it by code
                if (!string.IsNullOrEmpty(txtPassword.Password))
                {
                    Entity.ChangePassword = true;
                    Entity.Password       = txtPassword.Password;
                }

                //Although we work binding an object to the XAML, we did not want to give
                //to the view for edit the actual object being changed, so when we set
                //the Entity, the datacontext is loaded with a copy of the object
                //and when the user finally saves it, we set the properties
                //of our entity (that is the one shown in the grid) with the values from the
                //view (DataContext).
                User changedUser = (User)fieldsGrid.DataContext;

                Entity.Id         = changedUser.Id;
                Entity.IdUserType = changedUser.IdUserType;
                Entity.UserType   = changedUser.UserType;
                Entity.Name       = changedUser.Name;
                Entity.Username   = changedUser.Username;

                //It could be bound through the interface, but what I want to do is to
                //allow that the errors are shown here
                ResultOperation result = userModel.Save(Entity);

                if (result.Success)
                {
                    OnSave?.Invoke();
                }
                else
                {
                    errors.AddRange(result.Errors);
                }
            }

            if (errors.Any())
            {
                lblErrors.Content = UIHelper.GetStringFromList(errors);
            }
        }
        public ResultOperation Delete(Guid EntityDefId)
        {
            ResultOperation resultOperation = new ResultOperation();

            try
            {
                List <sysBpmsDocument> listDoc      = new DocumentService().GetList(null, EntityDefId, null, "", null, null, null);
                List <sysBpmsVariable> listVariable = new VariableService().GetList(null, null, null, "", EntityDefId, null);
                this.BeginTransaction();

                List <string> relatedEntity = this.GetList(EntityDefId);
                if (relatedEntity.Any())
                {
                    resultOperation.AddError($"This entity is related to {string.Join(",", relatedEntity)}");
                }

                if (listVariable.Count > 0)
                {
                    resultOperation.AddError(string.Format(LangUtility.Get("DeleteError.Text", nameof(sysBpmsEntityDef)), string.Join(" ,", listVariable.Select(d => d.Name))));
                }

                if (resultOperation.IsSuccess)
                {
                    DocumentService documentService = new DocumentService(base.UnitOfWork);
                    foreach (var item in listDoc)
                    {
                        if (resultOperation.IsSuccess)
                        {
                            resultOperation = documentService.Delete(item.GUID);
                        }
                    }

                    if (resultOperation.IsSuccess)
                    {
                        this.DropTable(this.GetInfo(EntityDefId));
                        this.UnitOfWork.Repository <IEntityDefRepository>().Delete(EntityDefId);
                        this.UnitOfWork.Save();
                    }
                    listDoc = null;
                }
            }
            catch (Exception ex)
            {
                return(base.ExceptionHandler(ex));
            }
            base.FinalizeService(resultOperation);
            return(resultOperation);
        }
Example #6
0
        public override ResultOperation Execute(MojBlogEntities entiteti)
        {
            IEnumerable <KomentarDto> komentari = from komentar in entiteti.komentars
                                                  select new KomentarDto
            {
                id              = komentar.id,
                datum           = komentar.datum,
                ime_korisnika   = komentar.AspNetUser.UserName,
                tekst_komentara = komentar.tekst_komentara,
                post_naziv      = komentar.post.naslov
            };
            ResultOperation result = new ResultOperation();

            result.items = komentari.ToArray();
            return(result);
        }
        public ResultOperation Update(sysBpmsDepartmentMember departmentMember)
        {
            ResultOperation resultOperation = new ResultOperation();

            if (this.GetList(departmentMember.DepartmentID, departmentMember.RoleLU, departmentMember.UserID).Any(c => c.ID != departmentMember.ID))
            {
                resultOperation.AddError(LangUtility.Get("SameUser.Error", nameof(sysBpmsDepartmentMember)));
            }

            if (resultOperation.IsSuccess)
            {
                this.UnitOfWork.Repository <IDepartmentMemberRepository>().Update(departmentMember);
                this.UnitOfWork.Save();
            }
            return(resultOperation);
        }
Example #8
0
        public ActionResult Create(KategorijaViewModel vm)
        {
            try
            {
                OpKategorijaInsert op = new OpKategorijaInsert();
                op.dto.naziv = vm.naziv;
                ResultOperation res = manager.ExecuteOperation(op);
                // TODO: Add insert logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Example #9
0
 public object GetActive(Guid ID)
 {
     using (ProcessService processService = new ProcessService())
     {
         sysBpmsProcess  process         = processService.GetInfo(ID);
         ResultOperation resultOperation = processService.Publish(ID);
         if (resultOperation.IsSuccess)
         {
             return(new PostMethodMessage(SharedLang.Get("Success.Text"), DisplayMessageType.success));
         }
         else
         {
             return(new PostMethodMessage(resultOperation.GetErrors(), DisplayMessageType.error));
         }
     }
 }
Example #10
0
        // GET: Admin/Contact/Delete/5


        // POST: Admin/Contact/Delete/5

        public ActionResult Delete(int id)
        {
            try
            {
                OpContactDelete op = new OpContactDelete();
                op.dto.id = id;
                ResultOperation res = manager.ExecuteOperation(op);
                // TODO: Add delete logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Example #11
0
        public ActionResult Create(
            [Bind(Include = "Id,IdProduct,Name,Qtd,Price,PriceAcquisition,DatePurchase")] InventoryProduct product)
        {
            if (ModelState.IsValid)
            {
                ResultOperation result = model.Save(product);

                if (result.Success)
                {
                    return(RedirectToAction("Index", new { success = "Item was successfully created" }));
                }

                ModelState.AddModelError("Name", result.Message);
            }
            return(View(product));
        }
        /// <summary>
        /// The pre-defined behavior is call the Delete method from the Model.
        /// This method is responsible for verifying the possibility of removal. It returns
        /// a ResultOperation that can be successiful or not, giving the reason for that through
        /// the Errors property.
        /// If the operation is executed, it adds to the top the success message, otherwise,
        /// it shows the errors returned by the model.
        /// </summary>
        /// <param name="item"></param>
        private void BaseGridViewer_OnDelete(object item)
        {
            GetTop().ClearMessage();
            ResultOperation result = GetModel().Delete((T)item);

            if (result.Success)
            {
                List.Remove((T)item);
                GetTop().AddSuccess();
            }
            else
            {
                ShowErrors(result.Errors);
                GetTop().AddError(UIHelper.GetStringFromList(result.Errors));
            }
        }
        public object PostAddEdit(PostAddEditEntityDefDTO postAddEdit)
        {
            using (EntityDefService entityDefService = new EntityDefService())
            {
                sysBpmsEntityDef entityDef = postAddEdit.EntityDefDTO.ID != Guid.Empty ? entityDefService.GetInfo(postAddEdit.EntityDefDTO.ID) : new sysBpmsEntityDef();

                if (postAddEdit.listProperties != null)
                {
                    foreach (var Item in postAddEdit.listProperties)
                    {
                        if (string.IsNullOrWhiteSpace(Item.ID))
                        {
                            Item.ID = Guid.NewGuid().ToString();
                        }
                        Item.IsActive = true;
                        postAddEdit.EntityDefDTO.Properties.Add(Item);
                    }
                }

                ResultOperation resultOperation = entityDef.Update(postAddEdit.EntityDefDTO.DisplayName, postAddEdit.EntityDefDTO.Name, postAddEdit.EntityDefDTO.DesignXML, true, postAddEdit.EntityDefDTO.Properties);
                if (resultOperation.IsSuccess)
                {
                    if (entityDef.ID != Guid.Empty)
                    {
                        resultOperation = entityDefService.Update(entityDef);
                    }
                    else
                    {
                        resultOperation = entityDefService.Add(entityDef);
                    }

                    if (resultOperation.IsSuccess)
                    {
                        return(new PostMethodMessage(SharedLang.Get("Success.Text"), DisplayMessageType.success, new { entityDef.ID, Name = (entityDef.Name + $"({entityDef.DisplayName})") }));
                    }
                    else
                    {
                        return(new PostMethodMessage(resultOperation.GetErrors(), DisplayMessageType.error));
                    }
                }
                else
                {
                    return(new PostMethodMessage(resultOperation.GetErrors(), DisplayMessageType.error));
                }
            }
        }
Example #14
0
        public ActionResult Edit(UlogaViewModel1 vm)
        {
            try
            {
                OpUlogaUpdate op = new OpUlogaUpdate();
                op.dto.id_uloga = vm.id;
                op.dto.naziv    = vm.naziv;
                ResultOperation res = manager.ExecuteOperation(op);
                // TODO: Add update logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Example #15
0
        public ActionResult Delete(int id)
        {
            try
            {
                OpKategorijaDelete op = new OpKategorijaDelete();
                op.dto.id = id;
                ResultOperation res = manager.ExecuteOperation(op);



                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Example #16
0
 public static void SetToErrorMessage(CodeResultModel result, ResultOperation resultOperation)
 {
     if (result != null)
     {
         if (!result.Result)
         {
             if (resultOperation != null)
             {
                 resultOperation.SetHasError();
                 if (!(result?.CodeBaseShared.MessageList?.Any() ?? false))
                 {
                     resultOperation.AddError(LangUtility.Get("Failed.Text", "Engine"));
                 }
             }
         }
     }
 }
Example #17
0
     public object GetDelete(string guid)
     {
         using (DocumentService documentService = new DocumentService())
         {
             ResultOperation resultOperation = documentService.InActive(StringCipher.DecryptFormValues(guid, base.ApiSessionId.ToString(), base.IsEncrypted).ToGuidObj());
             if (resultOperation.IsSuccess)
             {
                 return new { message = "حذف فایل موفقیت آمیز بود.", isSuccess = true }
             }
             ;
             else
             {
                 return new { message = "خطایی در حذف فایل رخ داده است.", isSuccess = false }
             };
         }
     }
 }
        public ResultOperation Delete(Guid SequenceFlowId)
        {
            ResultOperation resultOperation = null;

            try
            {
                resultOperation = new ResultOperation();
                if (resultOperation.IsSuccess)
                {
                    this.BeginTransaction();
                    sysBpmsSequenceFlow sysBpmsSequenceFlow = this.GetInfo(SequenceFlowId);
                    foreach (sysBpmsCondition Condition in new ConditionService(this.UnitOfWork).GetList(null, SequenceFlowId, null))
                    {
                        resultOperation = new ConditionService(this.UnitOfWork).Delete(Condition.ID);
                        if (!resultOperation.IsSuccess)
                        {
                            break;
                        }
                    }
                    //remove DefaultSequence
                    foreach (sysBpmsGateway gateway in new GatewayService(base.UnitOfWork).GetListByDefaultSequence(SequenceFlowId))
                    {
                        gateway.DefaultSequenceFlowID = null;
                        resultOperation = new GatewayService(base.UnitOfWork).Update(gateway);
                        if (!resultOperation.IsSuccess)
                        {
                            break;
                        }
                    }

                    if (resultOperation.IsSuccess)
                    {
                        this.UnitOfWork.Repository <ISequenceFlowRepository>().Delete(SequenceFlowId);
                        this.UnitOfWork.Save();
                        new ElementService(this.UnitOfWork).Delete(sysBpmsSequenceFlow.ElementID, sysBpmsSequenceFlow.ProcessID);
                    }
                }
            }
            catch (Exception ex)
            {
                return(base.ExceptionHandler(ex));
            }
            base.FinalizeService(resultOperation);

            return(resultOperation);
        }
Example #19
0
        public ResultOperation Login(string username, string password)
        {
            var result = new ResultOperation();

            try
            {
                //var path = KeysConfiguration.KeyFilePathUser;
                //var root = XElement.Load(path);
                //var usuario = (from u in root.Elements("usuario")
                //               where (u.Element("username")?.Value)?.ToLower() == username.ToLower()
                //               select new UsuarioDto
                //               {
                //                   Id = string.IsNullOrWhiteSpace(u.Attribute("id")?.Value) ? string.Empty : u.Attribute("id")?.Value,
                //                   KeyDepartamento = string.IsNullOrWhiteSpace(u.Attribute("keyCodeDepartamento")?.Value) ? string.Empty : u.Attribute("keyCodeDepartamento")?.Value,
                //                   EsRoot = string.IsNullOrWhiteSpace(u.Attribute("esRoot")?.Value) ? false : bool.Parse(u.Attribute("esRoot").Value),
                //                   Nombres = string.IsNullOrWhiteSpace(u.Element("nombres")?.Value) ? string.Empty : u.Element("nombres").Value,
                //                   Apellidos = string.IsNullOrWhiteSpace(u.Element("apellidos")?.Value) ? string.Empty : u.Element("apellidos").Value,
                //                   Username = string.IsNullOrWhiteSpace(u.Element("username")?.Value) ? string.Empty : u.Element("username").Value,
                //                   Password = string.IsNullOrWhiteSpace(u.Element("password")?.Value) ? string.Empty : u.Element("password").Value,
                //               }).ToList().FirstOrDefault();

                //if (usuario != null)
                //{
                //    var passHash = usuario.Password;
                //    var validPass = false;
                //    var cipher = IoC.Resolver<IPasswordCipher>();
                //    if (cipher != null)
                //    {
                //        validPass = cipher.ValidatePassword(password, passHash);
                //    }
                //    if (!validPass)
                //    {
                //        result.AddError(KeysConfiguration.ErrorAuthentication, LocalizedText.ErrorLogin);
                //        return result;
                //    }
                //}
            }
            catch (Exception ex)
            {
                var mensaje = ex.Message;
                result.AddError(KeysConfiguration.ErrorBusinessException, mensaje);
            }

            return(result);
        }
Example #20
0
        internal static MSA.Expression/*!*/ MakeUserMethodBody(AstGenerator gen, int lastLine,
            MSA.Expression/*!*/ blockParameter, MSA.Expression/*!*/ rfcVariable,
            MSA.ParameterExpression/*!*/ methodUnwinder, MSA.Expression/*!*/ bodyStatement, ResultOperation resultOperation, 
            int profileTickIndex, MSA.ParameterExpression stampVariable, MSA.LabelTarget returnLabel) {

            Assert.NotNull(blockParameter, rfcVariable, bodyStatement, methodUnwinder);
            Debug.Assert(!resultOperation.IsIgnore, "return value should not be ignored");
            Debug.Assert(returnLabel != null || resultOperation.Variable != null, "return label needed");

            MSA.Expression resultExpression = Ast.Field(methodUnwinder, MethodUnwinder.ReturnValueField);
            if (resultOperation.Variable != null) {
                resultExpression = Ast.Assign(resultOperation.Variable, resultExpression);
            } else {
                resultExpression = Ast.Return(returnLabel, resultExpression);
            }

            // TODO: move this to the caller:
            MSA.Expression profileStart, profileEnd;
            if (stampVariable != null) {
                profileStart = Ast.Assign(stampVariable, Methods.Stopwatch_GetTimestamp.OpCall());
                profileEnd = Methods.UpdateProfileTicks.OpCall(Ast.Constant(profileTickIndex), stampVariable);
            } else {
                profileStart = profileEnd = Ast.Empty();
            }

            return AstUtils.Try(
                // initialize frame (RFC):
                profileStart,
                Ast.Assign(rfcVariable, Methods.CreateRfcForMethod.OpCall(AstUtils.Convert(blockParameter, typeof(Proc)))),
                bodyStatement
            ).Filter(methodUnwinder, Ast.Equal(Ast.Field(methodUnwinder, MethodUnwinder.TargetFrameField), rfcVariable),

                // return unwinder.ReturnValue;
                resultExpression

            ).Finally(
                Ast.Assign(Ast.Field(rfcVariable, RuntimeFlowControl.IsActiveMethodField), Ast.Constant(false)),
                profileEnd,
                gen != null && gen.TraceEnabled ? Methods.TraceMethodReturn.OpCall(
                    gen.CurrentScopeVariable, 
                    Ast.Convert(Ast.Constant(gen.SourceUnit.Path), typeof(string)),
                    Ast.Constant(lastLine)
                ) : Ast.Empty()
            );
        }
Example #21
0
        public ResultOperation Delete(Guid ProcessGroupId)
        {
            ResultOperation resultOperation = new ResultOperation();

            if (resultOperation.IsSuccess)
            {
                if (new ProcessService(base.UnitOfWork).GetList(null, null, ProcessGroupId, null).Any())
                {
                    resultOperation.AddError(LangUtility.Get("DeleteError.Text", nameof(sysBpmsProcessGroup)));
                }
                if (resultOperation.IsSuccess)
                {
                    this.UnitOfWork.Repository <IProcessGroupRepository>().Delete(ProcessGroupId);
                    this.UnitOfWork.Save();
                }
            }
            return(resultOperation);
        }
        public object GetInActiveFolder(Guid id)
        {
            using (DocumentFolderService documentFolderService = new DocumentFolderService())
            {
                sysBpmsDocumentFolder sysBpmsDocumentFolder = documentFolderService.GetInfo(id);
                sysBpmsDocumentFolder.InActive();
                ResultOperation resultOperation = documentFolderService.Update(sysBpmsDocumentFolder);

                if (resultOperation.IsSuccess)
                {
                    return(new PostMethodMessage(SharedLang.Get("Success.Text"), DisplayMessageType.success));
                }
                else
                {
                    return(new PostMethodMessage(resultOperation.GetErrors(), DisplayMessageType.error));
                }
            }
        }
Example #23
0
        public ResultOperation Update(sysBpmsDynamicForm dynamicForm, string userName)
        {
            ResultOperation resultOperation = new ResultOperation();

            if (dynamicForm.ProcessId.HasValue && !new ProcessService(base.UnitOfWork).GetInfo(dynamicForm.ProcessId.Value).AllowEdit())
            {
                resultOperation.AddError(LangUtility.Get("NotAllowEdit.Text", nameof(sysBpmsProcess)));
            }

            if (resultOperation.IsSuccess)
            {
                dynamicForm.UpdatedBy   = userName;
                dynamicForm.UpdatedDate = DateTime.Now;
                this.UnitOfWork.Repository <IDynamicFormRepository>().Update(dynamicForm);
                this.UnitOfWork.Save();
            }
            return(resultOperation);
        }
        public object Delete(Guid ID)
        {
            using (DepartmentService departmentService = new DepartmentService())
            {
                sysBpmsDepartment department = departmentService.GetInfo(ID);
                department.IsActive = false;
                ResultOperation resultOperation = departmentService.Update(department, null);

                if (resultOperation.IsSuccess)
                {
                    return(new PostMethodMessage(SharedLang.Get("Success.Text"), DisplayMessageType.success));
                }
                else
                {
                    return(new PostMethodMessage(resultOperation.GetErrors(), DisplayMessageType.error));
                }
            }
        }
        public object GetInActiveDocumentDef(Guid id)
        {
            using (DocumentDefService documentDefService = new DocumentDefService())
            {
                sysBpmsDocumentDef documentDef = documentDefService.GetInfo(id);
                documentDef.IsActive = false;
                ResultOperation resultOperation = documentDefService.Update(documentDef);

                if (resultOperation.IsSuccess)
                {
                    return(new PostMethodMessage(SharedLang.Get("Success.Text"), DisplayMessageType.success));
                }
                else
                {
                    return(new PostMethodMessage(resultOperation.GetErrors(), DisplayMessageType.error));
                }
            }
        }
Example #26
0
        public ResultOperation Update(sysBpmsVariableDependency variableDependency)
        {
            ResultOperation resultOperation = new ResultOperation();

            if (string.IsNullOrWhiteSpace(variableDependency.ToPropertyName))
            {
                if (new VariableService(base.UnitOfWork).GetInfo(variableDependency.ToVariableID.Value).VarTypeLU == (int)sysBpmsVariable.e_VarTypeLU.Object)
                {
                    resultOperation.AddError(SharedLang.GetReuired(nameof(sysBpmsVariableDependency.ToPropertyName), nameof(sysBpmsVariableDependency)));
                }
            }
            if (resultOperation.IsSuccess)
            {
                this.UnitOfWork.Repository <IVariableDependencyRepository>().Update(variableDependency);
                this.UnitOfWork.Save();
            }
            return(resultOperation);
        }
Example #27
0
        internal override MSA.Expression /*!*/ TransformRead(AstGenerator /*!*/ gen)
        {
            Assert.NotNull(gen);

            if (HasExceptionHandling)
            {
                MSA.Expression resultVariable = gen.CurrentScope.DefineHiddenVariable("#block-result", typeof(object));

                return(Ast.Block(
                           TransformExceptionHandling(gen, ResultOperation.Store(resultVariable)),
                           resultVariable
                           ));
            }
            else
            {
                return(gen.TransformStatementsToExpression(_statements));
            }
        }
Example #28
0
        public object PostEditInfo(ProcessDTO processDTO)
        {
            using (ProcessService processService = new ProcessService())
            {
                sysBpmsProcess process = processService.GetInfo(processDTO.ID);
                process.Update(processDTO.Name, processDTO.Description, processDTO.ParallelCountPerUser, processDTO.TypeLU);

                ResultOperation resultOperation = processService.UpdateInfo(process);
                if (resultOperation.IsSuccess)
                {
                    return(new PostMethodMessage(SharedLang.Get("Success.Text"), DisplayMessageType.success));
                }
                else
                {
                    return(new PostMethodMessage(resultOperation.GetErrors(), DisplayMessageType.error));
                }
            }
        }
Example #29
0
        // GET: Admin/Uloga/Edit/5
        public ActionResult Edit(string id)
        {
            UlogaDto dto = new UlogaDto()
            {
                id_uloga = id
            };
            OpUlogaGetOne op = new OpUlogaGetOne();

            op.dto = dto;
            ResultOperation res   = manager.ExecuteOperation(op);
            UlogaDto        uloga = res.items[0] as UlogaDto;
            UlogaViewModel1 vm    = new UlogaViewModel1()
            {
                id    = uloga.id_uloga,
                naziv = uloga.naziv
            };

            return(View(vm));
        }
Example #30
0
        public object PostAddEditStyleSheet(PostAddEditStyleSheetDTO model)
        {
            using (DynamicFormService dynamicFormService = new DynamicFormService())
            {
                sysBpmsDynamicForm dynamicForm = dynamicFormService.GetInfo(model.DynamicFormId);

                DynamicFormConfigXmlModel configXmlModel = dynamicForm.ConfigXmlModel;
                configXmlModel.StyleSheetCode = model.StyleCode;
                dynamicForm.Update(configXmlModel);
                ResultOperation resultOperation = dynamicFormService.Update(dynamicForm, base.userName);

                if (!resultOperation.IsSuccess)
                {
                    return(new PostMethodMessage(resultOperation.GetErrors(), DisplayMessageType.error));
                }

                return(new PostMethodMessage(SharedLang.Get("Success.Text"), DisplayMessageType.success));
            }
        }
Example #31
0
        public ResultOperation IsExecuteStoreProcedure(string nameStoreProcedure, params OracleParameter[] parameters)
        {
            var result = new ResultOperation();

            try
            {
                if (!OpenConnection())
                {
                    result.Errors.Add(_errorOpenConection);
                    return(result);
                }
                var command = base.OracleConnection.CreateCommand();
                command.Parameters.Clear();
                command.BindByName  = true;
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = nameStoreProcedure;
                if (parameters != null)
                {
                    foreach (var p in parameters)
                    {
                        command.Parameters.Add(p);
                    }
                }
                var res = command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                var mensaje = ex.Message;
                result.Errors.Add(_codigoErrorException);
                result.Errors.Add(mensaje);
                if (Logger != null)
                {
                    var msj =
                        $"Error en {GetType().Name}.{System.Reflection.MethodBase.GetCurrentMethod().Name}: {mensaje}.";
                    Logger.Error(msj);
                }
            }
            finally
            {
                CloseConnection();
            }
            return(result);
        }
Example #32
0
        public void PerformResultOperation(Result result, ResultOperation operation)
        {
            CheckDisposed();

            if (result == null)
            {
                throw new ArgumentNullException(nameof(result));
            }

            CheckConnected();

            string tag = operation.ToString().ToLower() + "_result";

            XElement request = new XElement(tag,
                                            new XElement("project_url", result.ProjectUrl),
                                            new XElement("name", result.Name));

            CheckResponse(PerformRpc(request));
        }
Example #33
0
        public ResultOperation AddThreadEventMessage(sysBpmsEvent senderEvent, Guid?threadTaskId)
        {
            ResultOperation resultOperation = new ResultOperation();

            ThreadEventService threadEventService = new ThreadEventService(base.UnitOfWork);
            sysBpmsThreadEvent threadEvent        = new sysBpmsThreadEvent()
            {
                StartDate    = DateTime.Now,
                EventID      = senderEvent.ID,
                StatusLU     = (int)sysBpmsThreadEvent.e_StatusLU.InProgress,
                ThreadID     = base.EngineSharedModel.CurrentThreadID.Value,
                ThreadTaskID = threadTaskId,
                ExecuteDate  = DateTime.Now,//it eill be updated in SendMessage method.
            };

            threadEventService.Add(threadEvent);

            return(resultOperation);
        }
Example #34
0
        private string CalculateResult()
        {
            try
            {
                List<string> Datas = new List<string>();
                for (int check = 0; check <= options.NumberOfDataChecks; check++)
                {
                    switch (ChekerToRWEprom(new Packet(sending, DateTime.Now, null)))
                    {
                        case ResultOperation.Succes:

                            Datas.Add(proto.GetData(data));
                            data = CheckDatas(Datas);
                            if (data != string.Empty)
                            {
                                Datas.Clear();

                                lastOperation = ResultOperation.Succes;
                                return data;
                            }
                            break;

                        case ResultOperation.Timeout:

                            lastOperation = ResultOperation.Timeout;
                            return string.Empty;

                        case ResultOperation.MorePopit:

                            lastOperation = ResultOperation.MorePopit;
                            return string.Empty;
                    }
                }
                lastOperation = ResultOperation.Default;
                return string.Empty;
            }
            finally
            {
            }
        }
Example #35
0
        internal MSA.Expression/*!*/ TransformStatements(MSA.Expression prologue, Statements/*!*/ statements, MSA.Expression epilogue, 
            ResultOperation resultOperation) {

            Assert.NotNull(statements);

            int count = statements.Count + (prologue != null ? 1 : 0) + (epilogue != null ? 1 : 0);

            if (count == 0) {

                if (resultOperation.IsIgnore) {
                    return AstUtils.Empty();
                } else if (resultOperation.Variable != null) {
                    return Ast.Assign(resultOperation.Variable, AstUtils.Constant(null, resultOperation.Variable.Type));
                } else {
                    return Ast.Return(CurrentFrame.ReturnLabel, AstUtils.Constant(null));
                }

            } else if (count == 1) {
                if (prologue != null) {
                    return prologue;
                }

                if (epilogue != null) {
                    return epilogue;
                }

                if (resultOperation.IsIgnore) {
                    return statements.First.Transform(this);
                } else {
                    return statements.First.TransformResult(this, resultOperation);
                }

            } else {
                var result = new AstExpressions(count + 1);

                if (prologue != null) {
                    result.Add(prologue);
                }

                // transform all but the last statement if it is an expression stmt:
                foreach (var statement in statements.AllButLast) {
                    result.Add(statement.Transform(this));
                }

                if (statements.Count > 0) {
                    if (resultOperation.IsIgnore) {
                        result.Add(statements.Last.Transform(this));
                    } else {
                        result.Add(statements.Last.TransformResult(this, resultOperation));
                    }
                }

                if (epilogue != null) {
                    result.Add(epilogue);
                }

                result.Add(AstUtils.Empty());
                return Ast.Block(result);
            }
        }
Example #36
0
 internal MSA.Expression/*!*/ TransformStatements(MSA.Expression prologue, Statements/*!*/ statements, ResultOperation resultOperation) {
     return TransformStatements(prologue, statements, null, resultOperation);
 }
Example #37
0
        //
        // rescue stmts                     ... if (StandardError === $!) { stmts; }
        // rescue <types> stmts             ... temp1 = type1; ...; if (<temp1> === $! || ...) { stmts; }
        // rescue <types> => <lvalue> stmts ... temp1 = type1; ...; if (<temp1> === $! || ...) { <lvalue> = $!; stmts; }
        //
        /*!*/
        internal IfStatementTest Transform(AstGenerator/*!*/ gen, ResultOperation resultOperation)
        {
            Assert.NotNull(gen);

            MSA.Expression condition;
            if (_types.Length != 0) {
                var comparisonSiteStorage = Ast.Constant(new BinaryOpStorage(gen.Context));

                if (_types.Length == 1) {
                    condition = MakeCompareException(gen, comparisonSiteStorage, _types[0].TransformRead(gen), _types[0] is SplattedArgument);
                } else {
                    // forall{i}: <temps[i]> = evaluate type[i]
                    var temps = new MSA.Expression[_types.Length];
                    var exprs = new BlockBuilder();

                    for (int i = 0; i < _types.Length; i++) {
                        var t = _types[i].TransformRead(gen);
                        var tmp = gen.CurrentScope.DefineHiddenVariable("#type_" + i, t.Type);
                        temps[i] = tmp;
                        exprs.Add(Ast.Assign(tmp, t));
                    }

                    // CompareException(<temps[0]>) || ... CompareException(<temps[n]>) || CompareSplattedExceptions(<splatTypes>)
                    condition = MakeCompareException(gen, comparisonSiteStorage, temps[0], _types[0] is SplattedArgument);
                    for (int i = 1; i < _types.Length; i++) {
                        condition = Ast.OrElse(condition, MakeCompareException(gen, comparisonSiteStorage, temps[i], _types[i] is SplattedArgument));
                    }

                    // (temps[0] = type[0], ..., temps[n] == type[n], condition)
                    exprs.Add(condition);
                    condition = exprs;
                }
            } else {
                condition = Methods.CompareDefaultException.OpCall(gen.CurrentScopeVariable);
            }

            return AstUtils.IfCondition(condition,
                gen.TransformStatements(
                    // <lvalue> = e;
                    (_target != null) ? _target.TransformWrite(gen, Methods.GetCurrentException.OpCall(gen.CurrentScopeVariable)) : null,

                    // body:
                    _statements,

                    resultOperation
                )
            );
        }
Example #38
0
        private MSA.Expression/*!*/ TransformExceptionHandling(AstGenerator/*!*/ gen, ResultOperation resultOperation) {
            Assert.NotNull(gen);

            MSA.Expression exceptionThrownVariable = gen.CurrentScope.DefineHiddenVariable("#exception-thrown", typeof(bool));
            MSA.ParameterExpression exceptionVariable = gen.CurrentScope.DefineHiddenVariable("#exception", typeof(Exception));
            MSA.Expression exceptionRethrowVariable = gen.CurrentScope.DefineHiddenVariable("#exception-rethrow", typeof(bool));
            MSA.Expression retryingVariable = gen.CurrentScope.DefineHiddenVariable("#retrying", typeof(bool));
            MSA.ParameterExpression evalUnwinder = gen.CurrentScope.DefineHiddenVariable("#unwinder", typeof(EvalUnwinder));
            MSA.Expression oldExceptionVariable = gen.CurrentScope.DefineHiddenVariable("#old-exception", typeof(Exception));

            MSA.Expression transformedBody;
            MSA.Expression transformedEnsure;
            MSA.Expression transformedElse;

            if (_ensureStatements != null) {
                transformedEnsure = Ast.Block(
                    // ensure:
                    Ast.Assign(oldExceptionVariable, Methods.GetCurrentException.OpCall(gen.CurrentScopeVariable)),
                    gen.TransformStatements(_ensureStatements, ResultOperation.Ignore),
                    Methods.SetCurrentException.OpCall(gen.CurrentScopeVariable, oldExceptionVariable),

                    // rethrow:
                    AstUtils.IfThen(
                        Ast.AndAlso(
                            exceptionRethrowVariable,
                            Ast.NotEqual(oldExceptionVariable, AstUtils.Constant(null))
                        ),
                        Ast.Throw(oldExceptionVariable)
                    ),
                    AstUtils.Empty()
                );
            } else {
                // rethrow:
                transformedEnsure = AstUtils.IfThen(
                    Ast.AndAlso(
                        exceptionRethrowVariable,
                        Ast.NotEqual(
                            Ast.Assign(oldExceptionVariable, Methods.GetCurrentException.OpCall(gen.CurrentScopeVariable)),
                            AstUtils.Constant(null, typeof(Exception)))
                        ),
                    Ast.Throw(oldExceptionVariable)
                );
            }

            if (_elseStatements != null) {
                transformedElse = gen.TransformStatements(_elseStatements, resultOperation);
            } else {
                transformedElse = AstUtils.Empty();
            }

            // body should do return, but else-clause is present => we cannot do return from the guarded statements: 
            // (the value of the last expression in the body cannot be the last executed expression statement => we can ignore it):
            transformedBody = gen.TransformStatements(_statements, (_elseStatements != null) ? ResultOperation.Ignore : resultOperation);

            MSA.Expression setInRescueFlag = null, clearInRescueFlag = null;
            var breakLabel = Ast.Label();
            var continueLabel = Ast.Label();

            // make rescue clause:
            MSA.Expression transformedRescue;
            if (_rescueClauses != null) {
                // outer-most EH blocks sets and clears runtime flag RuntimeFlowControl.InTryRescue:
                if (gen.CurrentRescue == null) {
                    setInRescueFlag = Ast.Assign(Ast.Field(gen.CurrentRfcVariable, RuntimeFlowControl.InRescueField), AstUtils.Constant(true));
                    clearInRescueFlag = Ast.Assign(Ast.Field(gen.CurrentRfcVariable, RuntimeFlowControl.InRescueField), AstUtils.Constant(false));
                } else {
                    setInRescueFlag = clearInRescueFlag = AstUtils.Empty();
                }

                gen.EnterRescueClause(retryingVariable, breakLabel, continueLabel);

                var handlers = new IfStatementTest[_rescueClauses.Count];
                for (int i = 0; i < handlers.Length; i++) {
                    handlers[i] = _rescueClauses[i].Transform(gen, resultOperation);
                }

                transformedRescue = Ast.Block(
                    setInRescueFlag,
                    AstUtils.Try(
                        AstUtils.If(handlers, Ast.Assign(exceptionRethrowVariable, AstUtils.Constant(true)))
                    ).Filter(evalUnwinder, Ast.Equal(Ast.Field(evalUnwinder, EvalUnwinder.ReasonField), AstUtils.Constant(BlockReturnReason.Retry)),
                        Ast.Block(
                            Ast.Assign(retryingVariable, AstUtils.Constant(true)),
                            Ast.Continue(continueLabel),
                            AstUtils.Empty()
                        )
                    )
                );

                gen.LeaveRescueClause();

            } else {
                transformedRescue = Ast.Assign(exceptionRethrowVariable, AstUtils.Constant(true));
            }

            if (_elseStatements != null) {
                transformedElse = AstUtils.Unless(exceptionThrownVariable, transformedElse);
            }

            var result = AstFactory.Infinite(breakLabel, continueLabel,
                Ast.Assign(exceptionThrownVariable, AstUtils.Constant(false)),
                Ast.Assign(exceptionRethrowVariable, AstUtils.Constant(false)),
                Ast.Assign(retryingVariable, AstUtils.Constant(false)),

                AstUtils.Try(
                    // save exception (old_$! is not used unless there is a rescue clause):
                    Ast.Block(
                        (_rescueClauses == null) ? (MSA.Expression)AstUtils.Empty() :
                            Ast.Assign(oldExceptionVariable, Methods.GetCurrentException.OpCall(gen.CurrentScopeVariable)),

                        AstUtils.Try(
                            Ast.Block(transformedBody, AstUtils.Empty())
                        ).Filter(exceptionVariable, Methods.CanRescue.OpCall(gen.CurrentRfcVariable, exceptionVariable),
                            Ast.Assign(exceptionThrownVariable, AstUtils.Constant(true)),
                            Methods.SetCurrentExceptionAndStackTrace.OpCall(gen.CurrentScopeVariable, exceptionVariable),
                            transformedRescue,
                            AstUtils.Empty()
                        ).FinallyIf((_rescueClauses != null), 
                            // restore previous exception if the current one has been handled:
                            AstUtils.Unless(exceptionRethrowVariable,
                                Methods.SetCurrentException.OpCall(gen.CurrentScopeVariable, oldExceptionVariable)
                            ),
                            clearInRescueFlag
                        ),

                        // unless (exception_thrown) do <else-statements> end
                        transformedElse,
                        AstUtils.Empty()
                    )
                ).FilterIf((_rescueClauses != null || _elseStatements != null),
                    exceptionVariable, Methods.CanRescue.OpCall(gen.CurrentRfcVariable, exceptionVariable),
                    Ast.Block(
                        Methods.SetCurrentExceptionAndStackTrace.OpCall(gen.CurrentScopeVariable, exceptionVariable),
                        Ast.Assign(exceptionRethrowVariable, AstUtils.Constant(true)),
                        AstUtils.Empty()
                    )
                ).Finally(
                    AstUtils.Unless(retryingVariable, transformedEnsure)
                ),

                Ast.Break(breakLabel)
            );

            return result;
        }
Example #39
0
 internal override MSA.Expression TransformResult(AstGenerator/*!*/ gen, ResultOperation resultOperation) {
     // the code will jump, ignore the result variable:
     return Transform(gen);
 }
Example #40
0
        //
        // rescue stmts                     ... if (StandardError === $!) { stmts; } 
        // rescue <types> stmts             ... temp1 = type1; ...; if (<temp1> === $! || ...) { stmts; }
        // rescue <types> => <lvalue> stmts ... temp1 = type1; ...; if (<temp1> === $! || ...) { <lvalue> = $!; stmts; }
        // 
        internal IfStatementTest/*!*/ Transform(AstGenerator/*!*/ gen, ResultOperation resultOperation) {
            Assert.NotNull(gen);

            MSA.Expression condition;
            if (_types.Length != 0 || _splatType != null) {
                var comparisonSiteStorage = Ast.Constant(new BinaryOpStorage(gen.Context));

                if (_types.Length == 0) {
                    // splat only:
                    condition = MakeCompareSplattedExceptions(gen, comparisonSiteStorage, TransformSplatType(gen));
                } else if (_types.Length == 1 && _splatType == null) {
                    condition = MakeCompareException(gen, comparisonSiteStorage, _types[0].TransformRead(gen));
                } else {

                    // forall{i}: <temps[i]> = evaluate type[i]
                    var temps = new MSA.Expression[_types.Length + (_splatType != null ? 1 : 0)];
                    var exprs = new MSA.Expression[temps.Length  + 1];
                    
                    int i = 0;
                    while (i < _types.Length) {
                        var tmp = gen.CurrentScope.DefineHiddenVariable("#type_" + i, typeof(object));
                        temps[i] = tmp;
                        exprs[i] = Ast.Assign(tmp, _types[i].TransformRead(gen));
                        i++;
                    }

                    if (_splatType != null) {
                        var tmp = gen.CurrentScope.DefineHiddenVariable("#type_" + i, typeof(object));
                        temps[i] = tmp;
                        exprs[i] = Ast.Assign(tmp, TransformSplatType(gen));

                        i++;
                    }

                    Debug.Assert(i == temps.Length);

                    // CompareException(<temps[0]>) || ... CompareException(<temps[n]>) || CompareSplattedExceptions(<splatTypes>)
                    i = 0;
                    condition = MakeCompareException(gen, comparisonSiteStorage, temps[i++]);
                    while (i < _types.Length) {
                        condition = Ast.OrElse(condition, MakeCompareException(gen, comparisonSiteStorage, temps[i++]));
                    }

                    if (_splatType != null) {
                        condition = Ast.OrElse(condition, MakeCompareSplattedExceptions(gen, comparisonSiteStorage, temps[i++]));
                    }

                    Debug.Assert(i == temps.Length);

                    // (temps[0] = type[0], ..., temps[n] == type[n], condition)
                    exprs[exprs.Length - 1] = condition;
                    condition = AstFactory.Block(exprs);
                }

            } else {
                condition = Methods.CompareDefaultException.OpCall(gen.CurrentScopeVariable);
            }

            return AstUtils.IfCondition(condition,
                gen.TransformStatements(
                    // <lvalue> = e;
                    (_target != null) ? _target.TransformWrite(gen, Methods.GetCurrentException.OpCall(gen.CurrentScopeVariable)) : null,

                    // body:
                    _statements,

                    resultOperation
                )
            );
        }
Example #41
0
        internal MSA.Expression/*!*/ TransformStatements(MSA.Expression prologue, Statements/*!*/ statements, MSA.Expression epilogue, 
            ResultOperation resultOperation) {

            Assert.NotNull(statements);

            int count = statements.Count + (prologue != null ? 1 : 0) + (epilogue != null ? 1 : 0);

            if (count == 0) {

                if (resultOperation.IsIgnore) {
                    return AstUtils.Empty();
                } else if (resultOperation.Variable != null) {
                    return Ast.Assign(resultOperation.Variable, AstUtils.Constant(null, resultOperation.Variable.Type));
                } else {
                    return Ast.Return(CurrentFrame.ReturnLabel, AstUtils.Constant(null));
                }

            } else if (count == 1) {
                if (prologue != null) {
                    return prologue;
                }

                if (epilogue != null) {
                    return epilogue;
                }

                if (resultOperation.IsIgnore) {
                    return statements.First.Transform(this);
                } else {
                    return statements.First.TransformResult(this, resultOperation);
                }

            } else {
                var result = new MSA.Expression[count + 1];
                int resultIndex = 0;

                if (prologue != null) {
                    result[resultIndex++] = prologue;
                }

                // transform all but the last statement if it is an expression stmt:
                foreach (var statement in statements.AllButLast) {
                    result[resultIndex++] = statement.Transform(this);
                }

                if (statements.Count > 0) {
                    if (resultOperation.IsIgnore) {
                        result[resultIndex++] = statements.Last.Transform(this);
                    } else {
                        result[resultIndex++] = statements.Last.TransformResult(this, resultOperation);
                    }
                }

                if (epilogue != null) {
                    result[resultIndex++] = epilogue;
                }

                result[resultIndex++] = AstUtils.Empty();
                Debug.Assert(resultIndex == result.Length);

                return Ast.Block(new ReadOnlyCollection<MSA.Expression>(result));
            }
        }
Example #42
0
 /*!*/
 internal MSA.Expression TransformStatements(Statements/*!*/ statements, ResultOperation resultOperation)
 {
     return TransformStatements(null, statements, null, resultOperation);
 }