Exemple #1
0
        public void UpdateOperatorRules(Converter.ExelConvertionRule[] rules)
        {
            if (rules != null && rules.Length > 0)
                using (var dc = exelconverterEntities2.New())
                {
                    //var dc = exelconverterEntities2.Default;

                    var rulesIds = rules.Select(i => i.Id).ToArray();
                    bool needSave = false;
                    foreach (var rule in rules)
                    {
                        var rl = dc.convertion_rules.Where(r => r.id == rule.Id).FirstOrDefault();
                        if (rl != null)
                        {
                            //ExelConvertionRule oldRule = GetRuleFromRow(rl);

                            //var serializedRule = string.Empty;
                            //if (!checkAfterUpdate || oldRule.Serialize().Trim() != (serializedRule = rule.Serialize()).Trim() && oldRule.SerializeXML().Trim() != rule.SerializeXML().Trim())
                            //{
                                needSave = true;
                                SetRuleToRow(rl, rule);
                            //}
                        }
                    }
                    if (needSave)
                        dc.SaveChanges();
                }
        }