//public InternaleEditResult GetInternalResult(DR_DeleteRequest request)
        //{
        //    InternaleEditResult result = new InternaleEditResult();



        //    var transactionresult = ConnectionManager.ExecuteTransactionalQueryItems(result.EditQueryResults.Select(x => x.QueryItem).ToList());
        //    if (transactionresult.Successful)
        //    {
        //        result.Result = Enum_DR_ResultType.SeccessfullyDone;
        //        actionActivityManager.DoAfterEditActionActivities(request.Requester, result);
        //    }
        //    else
        //    {
        //        result.Result = Enum_DR_ResultType.ExceptionThrown;
        //        foreach (var item in transactionresult.QueryItems)
        //        {
        //            result.EditQueryResults.First(x => x.QueryItem == item.QueryItem).DataUpdateMessage = item.Exception.Message;
        //            result.EditQueryResults.First(x => x.QueryItem == item.QueryItem).DataUpdateResult = Enum_DR_ResultType.ExceptionThrown;

        //        }
        //    }

        //    return result;
        //}


        public DR_DeleteInquiryResult Process(DR_DeleteInquiryRequest request)
        {
            DR_DeleteInquiryResult result = new DR_DeleteInquiryResult();

            foreach (var item in request.DataItems)
            {
                if (!result.Loop)
                {
                    DP_DataRepository rootDeleteITem = new DP_DataRepository(item.TargetEntityID, item.TargetEntityAlias);
                    rootDeleteITem.DataView = deleteQueryItemManager.GetDataView(item);
                    var treeResult = deleteQueryItemManager.GetTreeItems(request.Requester, rootDeleteITem, rootDeleteITem);
                    result.DataTreeItems.Add(rootDeleteITem);
                    if (treeResult)
                    {
                        result.Loop = true;
                        break;
                    }
                }
            }

            return(result);
        }
Example #2
0
        public DR_DeleteInquiryResult SendDeleteInquiryRequest(DR_DeleteInquiryRequest request)
        {
            EditRequestManager requestManager = new EditRequestManager();

            return(requestManager.Process(request as DR_DeleteInquiryRequest));
        }
        private void CommandManager_Clicked(object sender, EventArgs e)
        {
            //Enabled = false;
            dataList = new List <DP_DataRepository>();
            if (EditArea.AreaInitializer.DataMode == DataMode.One)
            {
                var data = EditArea.AreaInitializer.Datas.FirstOrDefault();
                if (data != null)
                {
                    dataList.Add(data);
                }
            }
            else if (EditArea.AreaInitializer.DataMode == DataMode.Multiple)
            {
                dataList = (EditArea as I_EditEntityAreaMultipleData).GetSelectedData();
            }
            if (dataList.Count != 0 && !dataList.Any(x => x.IsNewItem == true))
            {
                var requester = AgentUICoreMediator.GetAgentUICoreMediator.GetRequester();
                requester.SkipSecurity = true;
                DR_DeleteInquiryRequest request = new DR_DeleteInquiryRequest(requester);
                request.DataItems = dataList.Cast <DP_BaseData>().ToList();;
                var reuslt = AgentUICoreMediator.GetAgentUICoreMediator.requestRegistration.SendDeleteInquiryRequest(request);
                I_ViewDeleteInquiry view = AgentUICoreMediator.GetAgentUICoreMediator.UIManager.GetDeleteInquiryView();
                view.ButtonClicked += View_ButtonClicked;
                view.SetTreeItems(reuslt.DataTreeItems);
                if (reuslt.Loop == true)
                {
                    view.SetMessage("بعلت وجود حلقه وابستگی بین داده ها امکان حذف داده (داده های) انتخاب شده وجود ندارد");
                    view.SetUserConfirmMode(UserDialogMode.Ok);
                }
                else
                {
                    view.SetUserConfirmMode(UserDialogMode.YesNo);
                    if (reuslt.DataTreeItems.Any(x => x.ChildRelationshipInfos.Any(y => y.RelationshipDeleteOption == ModelEntites.RelationshipDeleteOption.DeleteCascade && y.RelatedData.Any())))
                    {
                        view.SetMessage("داده های وابسته نمایش داده شده نیز حذف خواهند شد. آیا مطمئن هستید؟");
                    }
                    else
                    {
                        view.SetMessage("داده های نمایش داده شده حذف خواهد شد. آیا مطمئن هستید؟");
                    }
                }
                AgentUICoreMediator.GetAgentUICoreMediator.UIManager.GetDialogWindow().ShowDialog(view, "تایید", Enum_WindowSize.Big);
                //////if (AgentUICoreMediator.GetAgentUICoreMediator.UIManager.ShowConfirm("تائید", "داده موجود به همراه تمامی اطلاعات وابسته حذف خواهند شد" +
                //////       Environment.NewLine + "آیا مطمئن هستید؟") == MyUILibrary.Temp.ConfirmResul.Yes)
                //////{

                //////    DR_DeleteRequest request = new DR_DeleteRequest();
                //////    request.EditPackages = dataList;

                //////    var reuslt = AgentUICoreMediator.GetAgentUICoreMediator.SendDeleteRequest(request);
                //////    if (reuslt.Result == Enum_DR_ResultType.SeccessfullyDone)
                //////    {
                //////        AgentUICoreMediator.GetAgentUICoreMediator.UIManager.ShowInfo(EditArea.SimpleEntity.Alias + " : " + "عملیات حذف با موفقیت انجام شد", "", MyUILibrary.Temp.InfoColor.Green);
                //////        if (EditArea.AreaInitializer.DataMode == DataMode.One)
                //////            EditArea.AreaInitializer.Datas.Remove(EditArea.AreaInitializer.Datas.First());
                //////        else if (EditArea.AreaInitializer.DataMode == DataMode.Multiple)
                //////        {
                //////            //foreach (var item in dataList)
                //////            //(EditArea as I_EditEntityAreaMultipleData).ClearData(item);
                //////            EditArea.AreaInitializer.Datas.Clear();
                //////        }


                //////    }
                //////}
            }
            //Enabled = true;
        }