Ejemplo n.º 1
0
        public void X(string Автор, string Произведение)
        {
            IQueryable <Me> mes = db.Mes.Where(t => t.idMeType == (int)MeTypeEnum.Realtones &&
                                               t.MePropValues.Count(
                                                   r => r.sVal == Произведение && r.idProp == (int)MePropertyEnum.song) > 0 &&
                                               t.MePropValues.Count(r => r.sVal == Автор) > 0);

            if (mes.Count() > 1)
            {
                throw new Exception("Больше одного совпадения МЭ!");
            }
            if (mes.Count() < 1)
            {
                throw new Exception("МЭ не найден!");
            }
            Debug.Assert(mes.Count() == 1);
            Me me = mes.First();
            // PriceCategory
            PriceCategory pc =
                db.PriceCategory_Configurations_sns.Where(t => t.sn == (string)Короткий_номер.SelectedItem).First().
                PriceCategory;

            if (pc == null)
            {
                throw new Exception("Не найдена ценовая категория!");
            }

            IEnumerable <Map> maps = CSS.sellSection.Maps.Where(t => t.idMe == me.id && t.idPriceCategory == pc.id);

            if (maps.Count() == 0)
            {
                // Генерируем код
                Console.WriteLine("Генерируем код");
                bool Занят;
                do
                {
                    Занят = db.Maps.Count(t => t.idPriceCategory == pc.id && t.code == СтартовыйКод.Text) > 0;
                    if (Занят)
                    {
                        Console.WriteLine("Код - " + СтартовыйКод.Text + " - занят");
                        code++;
                    }
                } while (Занят);
                db.Опубликовать(Короткий_номер.Text, СтартовыйКод.Text, me, (SellSectionEnum)CSS.sellSection.id);
            }
            else
            {
                Console.WriteLine(Автор + "\t" + Произведение + "\t" + maps.First().code);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Получение сгенерированного XML из базы данных
        /// </summary>
        /// <returns>XML в строке</returns>
        string LoadXML()
        {
            // Предварительно проверяем все параметры
            var report = new StringBuilder();

            using (var db = new DbDataContext()) {
                Raidb.Me me = db.Mes.SingleOrDefault(t => t.id == idMe);
                if (me.Maps.Count == 0)
                {
                    report.Append("Медиаэлемент idMe=" + idMe + " не опубликован, нажмите на кнопку опубликовать!\n");
                    foreach (Map m in me.Maps)
                    {
                        report.Append(" " + m.code + " SellSection = " + m.SellSection + " SellType =  " + m.SellType);
                    }
                    //   return report.ToString();
                }
                else
                {
                    Map map = me.Maps.FirstOrDefault(t => t.idSellSection == publishing1.IdSellSection);
                    if (map == null)
                    {
                        publishing1.IdSellSection = me.Maps.First().idSellSection;
                    }
                }
            }

            try {
                mng.Open();
                cmdXML.Parameters["@idMe"].Value          = idMe;
                cmdXML.Parameters["@idSellChannel"].Value = publishing1.IdSellChannel;
                cmdXML.Parameters["@idSellSection"].Value = publishing1.IdSellSection;

                object res = cmdXML.ExecuteScalar();
                if (res is string)
                {
                    return((string)res);
                }
                else
                {
                    return("Ошибка генерации XML " + cmdXML.CommandText + " " + idMe + " " + publishing1.IdSellChannel +
                           " " +
                           publishing1.IdSellSection +
                           "\n\n" + report);
                }
            } catch (Exception ex) {
                return("Ошибка генерации XML: " + ex);
            } finally {
                mng.Close();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Создание нового элемента с выбранным номером и кодом
        /// </summary>
        public void CreateNewSeries()
        {
            Assert.IsTrue(SN_Code.Code.Text.Length > 0);
            Assert.IsTrue(SN_Code.SN.Text.Length > 0);
            PriceCategory pc = db.PriceCategory_by_SN(SN_Code.SN.Text);
            var           me = new Me {
                idMeRetrieveWay = (int)MeRetrieveWayEnum.Файлы_не_хранятся,
                idMeType        = (int)MeTypeEnum.RandomText
            };

            db.Mes.InsertOnSubmit(me);
            map = new Map {
                idBasketCollection = (int)BasketCollectionEnum.main,
                Me = me,
                idPriceCategory = pc.id,
                code            = SN_Code.Code.Text
            };
            db.Maps.InsertOnSubmit(map);
        }
Ejemplo n.º 4
0
 public SMS_Series(Me me, string name)
 {
     this.me   = me;
     this.name = name;
 }
Ejemplo n.º 5
0
 public SMS_Series(Me me, string name) {
   this.me = me;
   this.name = name;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Создание нового элемента с выбранным номером и кодом
 /// </summary>
 public void CreateNewSeries() {
   Assert.IsTrue(SN_Code.Code.Text.Length > 0);
   Assert.IsTrue(SN_Code.SN.Text.Length > 0);
   PriceCategory pc = db.PriceCategory_by_SN(SN_Code.SN.Text);
   var me = new Me {
                     idMeRetrieveWay = (int) MeRetrieveWayEnum.Файлы_не_хранятся,
                     idMeType = (int) MeTypeEnum.RandomText
                   };
   db.Mes.InsertOnSubmit(me);
   map = new Map {
                   idBasketCollection = (int) BasketCollectionEnum.main,
                   Me = me,
                   idPriceCategory = pc.id,
                   code = SN_Code.Code.Text
                 };
   db.Maps.InsertOnSubmit(map);
 }