コード例 #1
0
        /// <summary>
        ///   execute recompute
        /// </summary>
        /// <param name = "rec">the record on which the recompute is executed</param>
        internal void execute(Record rec)
        {
            int            i;
            Field          fld;
            CommandsTable  cmdsToServer = Task.getMGData().CmdsToServer;
            IClientCommand cmd;

            try
            {
                rec.setInRecompute(true);

                bool allowServerRecompute = _hasServerLinksRecomputes || (Task.getForm().AllowedSubformRecompute&& checkRefreshSubForms());
                // SERVER
                if (RcmpMode != RcmpBy.CLIENT && allowServerRecompute)
                {
                    bool inClient = _subFormsOnlyRecomp;
                    Task.ExecuteClientSubformRefresh = false;

                    // if the recompute is not only due to sub-forms go to server
                    if (inClient)
                    {
                        inClient = Task.prepareCache(true);
                        //if all sub-form are not update
                        if (inClient)
                        {
                            inClient = Task.testAndSet(true); //try to take dataviews from cache
                        }
                    }
                    if (!inClient)
                    {
                        ((FieldsTable)Task.DataView.GetFieldsTab()).setServerRcmp(true);
                        cmd = CommandFactory.CreateRecomputeCommand(Task.getTaskTag(), OwnerFld.getId(), !Task.getForm().AllowedSubformRecompute);
                        cmdsToServer.Add(cmd);
                        RemoteCommandsProcessor.GetInstance().Execute(CommandsProcessorBase.SendingInstruction.TASKS_AND_COMMANDS);
                    }

                    if (Task.ExecuteClientSubformRefresh)
                    {
                        RefreshSubforms();
                    }
                    else
                    {
                        if (recPrefixSubForms())
                        {
                            recSuffixSubForms();
                        }
                        Task.CleanDoSubformPrefixSuffix();
                    }
                }
                // CLIENT
                else
                {
                    try
                    {
                        FlowMonitorQueue.Instance.addRecompute(OwnerFld.getVarName());

                        // FORM PROPERTIES
                        if (_formProps != null)
                        {
                            _formProps.RefreshDisplay(false, false);
                        }

                        // CTRL PROPERTIES
                        if (_ctrlProps != null)
                        {
                            _ctrlProps.RefreshDisplay(false, false);
                        }

                        //re-cumpute client side fields and links
                        if (_rcmpOrder != null)
                        {
                            for (i = 0; i < _rcmpOrder.Count; i++)
                            {
                                if (_rcmpOrder[i] is Field)
                                {
                                    fld = (Field)_rcmpOrder[i];
                                    fldRcmp(fld, true);
                                }
                                else if (_rcmpOrder[i] is DataviewHeaderBase)
                                {
                                    var curLnk = (DataviewHeaderBase)_rcmpOrder[i];
                                    curLnk.getLinkedRecord(rec);

                                    //if we have recomputed a link we should also start the recompute process on all of its fields
                                    List <Field> linkFields =
                                        ((FieldsTable)Task.DataView.GetFieldsTab()).getLinkFields(curLnk.Id);
                                    rec.setInCompute(true);
                                    bool saveInForceUpdate = rec.InForceUpdate;
                                    rec.InForceUpdate = false;

                                    for (int j = 0; j < linkFields.Count; j++)
                                    {
                                        fldRcmp(linkFields[j], false);
                                        rec.clearFlag((linkFields[j]).getId(), Record.FLAG_UPDATED);
                                        rec.clearFlag((linkFields[j]).getId(), Record.FLAG_MODIFIED);
                                        rec.clearFlag((linkFields[j]).getId(), Record.FLAG_CRSR_MODIFIED);
                                        rec.clearHistoryFlag((linkFields[j]).getId());
                                    }
                                    rec.InForceUpdate = saveInForceUpdate;

                                    //start recompute process on the ret val of the link
                                    Field retFld = curLnk.ReturnField;
                                    if (retFld != null)
                                    {
                                        fldRcmp(retFld, false);
                                    }

                                    rec.setInCompute(false);
                                    rec.setForceSaveOrg(true);
                                }
                                else if (_rcmpOrder[i] is DCValuesRecompute)
                                {
                                    ((DCValuesRecompute)_rcmpOrder[i]).Recompute(Task, rec);
                                }
                            }
                        }

                        RefreshSubforms();
                    }
                    catch (Exception e)
                    {
                        Logger.Instance.WriteExceptionToLog("in Recompute.execute(): " + e.Message);
                    }
                } // END CLIENT BLOCK
            }
            finally
            {
                rec.buildLinksPosStr();
                rec.setInRecompute(false);
            }
        }