Exemple #1
0
        /// <summary>
        /// Клонировать объект.
        /// </summary>
        public virtual object Clone()
        {
            Condition clonedCondition = ScadaUtils.DeepClone(this);

            clonedCondition.SchemeView = SchemeView;
            return(clonedCondition);
        }
Exemple #2
0
        /// <summary>
        /// Клонировать объект
        /// </summary>
        public virtual Condition Clone()
        {
            Condition clonedCondition = (Condition)ScadaUtils.DeepClone(this);

            clonedCondition.SchemeDoc = SchemeDoc;
            return(clonedCondition);
        }
Exemple #3
0
        /// <summary>
        /// Клонировать объект.
        /// </summary>
        public override object Clone()
        {
            Condition clonedCondition = ScadaUtils.DeepClone(this, PlgUtils.SerializationBinder);

            clonedCondition.SchemeView = SchemeView;
            return(clonedCondition);
        }
Exemple #4
0
        /// <summary>
        /// Клонировать объект
        /// </summary>
        public virtual BaseComponent Clone()
        {
            BaseComponent clonedComponent = (BaseComponent)ScadaUtils.DeepClone(this, serBinder);

            clonedComponent.SchemeDoc    = SchemeDoc;
            clonedComponent.ItemChanged += ItemChanged;
            return(clonedComponent);
        }
Exemple #5
0
        /// <summary>
        /// Клонировать объект.
        /// </summary>
        public virtual BaseComponent Clone()
        {
            BaseComponent clonedComponent = ScadaUtils.DeepClone(this, serBinder);

            clonedComponent.schemeView   = SchemeView;
            clonedComponent.serBinder    = serBinder;
            clonedComponent.ItemChanged += ItemChanged;
            return(clonedComponent);
        }
Exemple #6
0
        /// <summary>
        /// Clones output channels.
        /// </summary>
        private bool CloneCtrlCnls(int srcStartNum, int srcEndNum, int destStartNum,
                                   int replaceObjNum, int replaceKpNum, bool updateFormulas)
        {
            try
            {
                BaseTable <CtrlCnl> ctrlCnlTable = configBase.CtrlCnlTable;
                int affectedRows = 0;

                if (srcStartNum <= srcEndNum)
                {
                    // create new channels
                    int            shiftNum  = destStartNum - srcStartNum;
                    List <CtrlCnl> cnlsToAdd = new List <CtrlCnl>(srcEndNum - srcStartNum + 1);

                    foreach (CtrlCnl ctrlCnl in ctrlCnlTable.Items.Values)
                    {
                        int ctrlCnlNum = ctrlCnl.CtrlCnlNum;

                        if (srcStartNum <= ctrlCnlNum && ctrlCnlNum <= srcEndNum)
                        {
                            int newCnlNum = ctrlCnlNum + shiftNum;

                            if (newCnlNum <= AdminUtils.MaxCnlNum && !ctrlCnlTable.PkExists(newCnlNum))
                            {
                                CtrlCnl newCtrlCnl = ScadaUtils.DeepClone(ctrlCnl);
                                newCtrlCnl.CtrlCnlNum = newCnlNum;

                                if (replaceObjNum >= 0)
                                {
                                    newCtrlCnl.ObjNum = replaceObjNum > 0 ? replaceObjNum : (int?)null;
                                }

                                if (replaceKpNum >= 0)
                                {
                                    newCtrlCnl.KPNum = replaceKpNum > 0 ? replaceKpNum : (int?)null;
                                }

                                if (updateFormulas)
                                {
                                    newCtrlCnl.Formula = UpdateFormula(newCtrlCnl.Formula, shiftNum);
                                }

                                cnlsToAdd.Add(newCtrlCnl);
                            }
                        }
                        else if (ctrlCnlNum > srcEndNum)
                        {
                            break;
                        }
                    }

                    // add the created channels
                    foreach (CtrlCnl ctrlCnl in cnlsToAdd)
                    {
                        ctrlCnlTable.AddItem(ctrlCnl);
                    }

                    affectedRows = cnlsToAdd.Count;
                }

                if (affectedRows > 0)
                {
                    ctrlCnlTable.Modified = true;
                }

                ScadaUiUtils.ShowInfo(string.Format(AppPhrases.CloneCnlsComplete, affectedRows));
                return(true);
            }
            catch (Exception ex)
            {
                appData.ProcError(ex, AppPhrases.CloneCtrlCnlsError);
                return(false);
            }
        }
Exemple #7
0
 /// <summary>
 /// Клонировать объект
 /// </summary>
 public Font Clone()
 {
     return((Font)ScadaUtils.DeepClone(this));
 }
Exemple #8
0
 /// <summary>
 /// Клонировать объект
 /// </summary>
 public override Condition Clone()
 {
     Condition clonedCondition = (Condition)ScadaUtils.DeepClone(this, PlgUtils.SerializationBinder);
     clonedCondition.SchemeDoc = SchemeDoc;
     return clonedCondition;
 }
 /// <summary>
 /// Clones the object.
 /// </summary>
 public ConnectionSettings Clone()
 {
     return(ScadaUtils.DeepClone(this));
 }
Exemple #10
0
        /// <summary>
        /// Clones channels with the specified parameters.
        /// </summary>
        private bool CloneChannels(int srcStartNum, int srcEndNum, int destStartNum,
                                   int replaceObjNum, int replaceDeviceNum, bool updateFormulas)
        {
            try
            {
                BaseTable <Cnl> cnlTable     = configDatabase.CnlTable;
                int             affectedRows = 0;

                if (srcStartNum <= srcEndNum)
                {
                    // create new channels
                    ExtensionUtils.NormalizeIdRange(ConfigDatabase.MinID, ConfigDatabase.MaxID,
                                                    ref srcStartNum, ref srcEndNum, destStartNum, out int numOffset);
                    List <Cnl> cnlsToAdd = new(srcEndNum - srcStartNum + 1);

                    foreach (Cnl cnl in cnlTable.EnumerateItems())
                    {
                        if (cnl.CnlNum < srcStartNum)
                        {
                            continue;
                        }
                        else if (cnl.CnlNum > srcEndNum)
                        {
                            break;
                        }
                        else if (!cnlTable.PkExists(cnl.CnlNum + numOffset))
                        {
                            Cnl newCnl = ScadaUtils.DeepClone(cnl);
                            newCnl.CnlNum = cnl.CnlNum + numOffset;

                            if (replaceObjNum >= 0)
                            {
                                newCnl.ObjNum = replaceObjNum > 0 ? replaceObjNum : null;
                            }

                            if (replaceDeviceNum >= 0)
                            {
                                newCnl.DeviceNum = replaceDeviceNum > 0 ? replaceDeviceNum : null;
                            }

                            if (updateFormulas)
                            {
                                newCnl.InFormula  = UpdateFormula(newCnl.InFormula, numOffset);
                                newCnl.OutFormula = UpdateFormula(newCnl.OutFormula, numOffset);
                            }

                            cnlsToAdd.Add(newCnl);
                        }
                    }

                    // add created channels
                    cnlsToAdd.ForEach(cnl => cnlTable.AddItem(cnl));
                    affectedRows = cnlsToAdd.Count;
                }

                if (affectedRows > 0)
                {
                    cnlTable.Modified = true;
                }

                ScadaUiUtils.ShowInfo(string.Format(ExtensionPhrases.CloneChannelsCompleted, affectedRows));
                return(true);
            }
            catch (Exception ex)
            {
                adminContext.ErrLog.HandleError(ex, ExtensionPhrases.CloneChannelsError);
                return(false);
            }
        }
Exemple #11
0
 /// <summary>
 /// Clones the module configuration.
 /// </summary>
 public ModConfig Clone()
 {
     return(ScadaUtils.DeepClone(this, new SerializationBinder(Assembly.GetExecutingAssembly())));
 }