Exemple #1
0
 public static FeedbackRecipient[] GetFeedbackRecipients(string locale)
 {
     using( var dc = new DCFactory<CmsDataContext>() )
     {
         if (locale != "ru-RU")
         {
             //TODO получается как-то громоздко, но времени в обрез, а справочник этот небольшой, поэтому оставляем так (главное что работает)
             var recipients = from rpts in dc.DataContext.FeedbackRecipients
                              join
                                 locs in dc.DataContext.FeedbackRecipientsLocs on rpts.RecipientID equals locs.RecipientID
                              where locs.Localization == locale
                              select new
                              {
                                  RecipientID = rpts.RecipientID,
                                  RecipientEmail = rpts.RecipientEmail,
                                  RecipientVisible = rpts.RecipientVisible,
                                  RecipientName = locs.RecipientName
                              };
             var recipients_materialized = recipients.ToArray();
             return recipients_materialized.Select(r => new FeedbackRecipient
             {
                 RecipientID = r.RecipientID,
                 RecipientEmail = r.RecipientEmail,
                 RecipientVisible = r.RecipientVisible,
                 RecipientName = r.RecipientName
             }).ToArray();
         }
         else
         {
             return _getFeedbackRecipients(dc.DataContext).ToArray();
         }
     }
 }
Exemple #2
0
        protected void Page_PreRender( object sender, EventArgs e )
        {
            using( var dc = new DCFactory<CmsDataContext>() )
            {
                var groups = dc.DataContext.CatalogItems.GroupBy( c => c.ParentItemID ).ToDictionary( g => g.Key ?? 0 );

                if( groups.Count != 0 )
                {
                    var list = new List<object>();
                    var stack = new Stack<KeyValuePair<CatalogItem,int>>();

                    foreach( var item in groups[ 0 ].OrderByDescending( c=>c.CatalogItemPriority ) )
                        stack.Push( new KeyValuePair<CatalogItem, int>( item, 0 ) );

                    while( stack.Count != 0 )
                    {
                        var node = stack.Pop();
                        list.Add( new { CatalogItem = node.Key, Level = node.Value } );

                        if( groups.ContainsKey( node.Key.CatalogItemID ) )
                        {
                            foreach( var item in groups[ node.Key.CatalogItemID ].OrderByDescending( c => c.CatalogItemPriority ) )
                                stack.Push( new KeyValuePair<CatalogItem, int>( item, node.Value + 1 ) );
                        }
                    }

                    _repeater.DataSource = list;
                    _repeater.DataBind();
                }

            }
        }
 public static UserProfileEntry GetProfileByUsername(string username)
 {
     using (var dc = new DCFactory<StoreDataContext>())
     {
         return _getEntriesByUsername(dc.DataContext, username).SingleOrDefault();
     }
 }
 //public static UserProfileEntry GetProfileByUserId(int userId)
 //{
 //    using (var dc = new StoreDataContext())
 //    {
 //        return _getEntriesByUserId(dc, userId).SingleOrDefault();
 //    }
 //}
 public static ClientAlertConfig GetAlertConfigByClientId(string clientId)
 {
     using (var dc = new DCFactory<StoreDataContext>())
     {
         return _getAlertConfigByClientId(dc.DataContext, clientId).SingleOrDefault();
     }
 }
 public static SparePartGroup[] GetSparePartGroups()
 {
     using( var dc = new DCFactory<CmsDataContext>() )
     {
         return _getSparePartGroups( dc.DataContext ).ToArray();
     }
 }
 public IEnumerable<ShoppingCartItem> LoadItems()
 {
     using (var context = new DCFactory<StoreDataContext>())
     {
         return LoadItems(context.DataContext);
     }
 }
Exemple #7
0
 public static UserMaintEntry[] GetEntries(string username)
 {
     using (var dc = new DCFactory<StoreDataContext>())
     {
         return _getEntriesByUsername(dc.DataContext, username).ToArray();
     }
 }
Exemple #8
0
 /// <summary>
 /// Возвращает ID файла по его наименованию
 /// </summary>
 /// <param name="fileName">Имя файла</param>
 /// <returns>ID файла</returns>
 public static int GetFileIDByName(string fileName)
 {
     using (var dc = new DCFactory<CmsDataContext>())
     {
         return _getFileIDByFileName(dc.DataContext, fileName);
     }
 }
Exemple #9
0
        public static string GetFolderPath( int folderID )
        {
            using(var dc = new DCFactory<CmsDataContext>())
            {
                Folder folder = _getFolderById( dc.DataContext, folderID );

                if( folder != null )
                {
                    List<Folder> list = new List<Folder>();
                    for( Folder f = folder ; f != null ; f = f.Parent )
                    {
                        list.Add( f );
                    }

                    list.Reverse();

                    StringBuilder sb = new StringBuilder();
                    foreach( Folder f in list )
                    {
                        if( sb.Length != 0 ) sb.Append( " / " );
                        sb.Append( f.FolderName );
                    }
                    return sb.ToString();
                }
                else
                {
                    return null;
                }
            }
        }
        protected void Page_Load( object sender, EventArgs e )
        {
            using (var ctx = new DCFactory<StoreDataContext>())
            {
                this.Mfr = Request.QueryString.TryGet<string>( UrlKeys.StoreAndTecdoc.ManufacturerName, String.Empty );
                _pageTitleLiteral.Text = String.Format( "{0} / {1}", CmsContext.Current.CatalogItem.CatalogItemName, this.Mfr );

                var ids = StocksConfiguration.Current.SupplierIds;
                ctx.DataContext.Log = new RmsAuto.Common.Misc.DebuggerWriter();

                throw new NotImplementedException();

                //TODO: Возможно тут стоит переписать через SparePartsDac
                //var sps = ctx.DataContext.SpareParts.Where( sp => sp.Manufacturer == this.Mfr )
                //            .Where( sp => ids.Contains( sp.SupplierID ) )
                //            .OrderBy( sp => sp.PartDescription )
                //            .ThenBy( sp => sp.InitialPrice );

                //var pageSize = StocksConfiguration.Current.PageSize;

                //var pages = new int[ (int)Math.Ceiling( (decimal)sps.Count() / (decimal)pageSize ) ];
                //for( int j = 0 ; j < pages.Length ; j++ )
                //{
                //    pages[ j ] = j + 1;
                //}

                //rptPaging.DataSource = pages;
                //rptPaging.DataBind();

                //rptParts.DataSource = sps.Skip( ( this.PageNum - 1 ) * pageSize ).Take( pageSize ).ToList();
                //rptParts.DataBind();
            }
        }
 public void InsertMessage(int clientId, int userTo, string msgText)
 {
     using (var ctx = new DCFactory<StoreDataContext>())
     {
         ctx.DataContext.ExecuteCommand("insert into UserMessages (User_From, user_To, Text) values ({0},{1},{2})", clientId, userTo, msgText);
     }
 }
 public static TransferChangesLogEntry Load(int logEntryId)
 {
     using (var context = new DCFactory<StoreDataContext>())
     {
         return context.DataContext.TransferChangesLogEntries.Single(tcle => tcle.LogEntryID == logEntryId);
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Dictionary<byte, string> dNames = new Dictionary<byte, string>();

                using (var dc = new DCFactory<StoreDataContext>())
                {
                    //deas 30.03.2011 task3586
                    // добавлена сортировка и условие отображения
                    foreach ( var statusElement in dc.DataContext.OrderLineStatuses.OrderBy(t => t.ClientShowOrder))
                    {
                        var status = statusElement.OrderLineStatusID;
                        if (OrderLineStatusUtil.IsShow(status))
                        {
                            dNames.Add( status, OrderLineStatusUtil.DisplayName( status ) );
                        }
                    }
                }

                _listView.DataSource = dNames;
                _listView.DataBind();

                InitControls();
            }
        }
        protected void _btnChangeStatus_Click(object sender, EventArgs e)
        {
            int orderID = -1; int.TryParse(_txtOrderID.Text.Trim(), out orderID); if (orderID < 0) return;
            using (var dc = new DCFactory<StoreDataContext>())
            {
                for (int i = 0; i < _gvOrderLines.Rows.Count; i++)
                {
                    if (!((CheckBox)_gvOrderLines.Rows[i].Cells[0].Controls[0]).Checked) continue;
                    DataControlFieldCell cb = (DataControlFieldCell)_gvOrderLines.Rows[i].Cells[2];
                    int orderLineID; try { orderLineID = Convert.ToInt32(cb.Text); }
                    catch { continue; }
                    OrderLine line = dc.DataContext.OrderLines.FirstOrDefault(l => l.OrderLineID == orderLineID && l.OrderID == orderID);
                    if (line != null && line.CurrentStatus != OrderLineStatusUtil.StatusByte("Rejected"))
                    {
                        byte newStatus = 0;
                        byte.TryParse(_ddlStatuses.SelectedValue, out newStatus);
                        if (newStatus > 0)
                        {
                            //новая дата статуса
                            DateTime orderLineStatusDate;
                            try { orderLineStatusDate = DateTime.ParseExact(_txtStatusDate.Text, "dd.MM.yyyy", CultureInfo.InvariantCulture); }
                            catch { orderLineStatusDate = DateTime.Now; }
                            line.CurrentStatus = newStatus;
                            line.CurrentStatusDate = orderLineStatusDate;
                        }
                    }
                }
                dc.DataContext.SubmitChanges();
            }

            FillData();
        }
Exemple #15
0
 public static IEnumerable<VinRequest> GetRequests(string clientId)
 {
     using (var ctx = new DCFactory<StoreDataContext>())
     {
         return _getClientVinRequests(ctx.DataContext, clientId).ToList();
     }
 }
Exemple #16
0
        public static IEnumerable<BriefClientInfo> Search(
            string clientName, 
            string mainPhone,
            ClientSearchMatching matching)
        {
            using (var dc = new DCFactory<StoreDataContext>())
            {

                List<BriefClientInfo> ret = new List<BriefClientInfo>();
                if (!LightBO.IsLight())
                {
                    var rezSearch = dc.DataContext.spSelUsersByFields(clientName, "", mainPhone);

                    foreach (var oneRez in rezSearch)
                    {
                        ret.Add(new BriefClientInfo()
                        {
                            ClientID = oneRez.AcctgID,
                            ClientName = oneRez.ClientName,
                          //  MainPhone = oneRez.ContactPhone
                        });
                    }
                }
                else
                {
                    dc.DataContext.Log = new DebugTextWriter();
                    string query = @"select a.UserID as UserID,  AcctgID as ClientID,  ManagerId , ClientName as ClientName, ContactPhone as MainPhone, TradingVolume as TradingVolume, CreationTime, ISNULL(b.isAutoOrder, 0) as isAutoOrder,  isChecked from dbo.Users a LEFT JOIN dbo.UserSettings b ON a.UserID = b.UserID LEFT JOIN dbo.orders c ON a.UserId = b.Userid LEFT JOIN dbo.OrderLines d ON c.OrderId = d.OrderId where ClientName like {0} and ContactPhone like {1} and d.InternalFranchName = {2} AND UserRole = 0";

                    return dc.DataContext.ExecuteQuery<BriefClientInfo>(query, "%"+clientName+"%", "%"+mainPhone+"%", SiteContext.Current.InternalFranchName).ToList();
                }
                return ret;
            }
        }
 public void ClearItems()
 {
     using (var context = new DCFactory<StoreDataContext>())
     {
         ClearItems(context.DataContext);
     }
 }
Exemple #18
0
 public static HandyClientSetEntry GetDefaultHandySetEntry(int managerId)
 {
     using (var dc = new DCFactory<StoreDataContext>())
     {
         return _getHandySetEntries(dc.DataContext, managerId).SingleOrDefault(e => e.IsDefault);
     }
 }
        private void PopulateCatalogItems( DropDownList dropDownList )
        {
            using (var dc = new DCFactory<CmsDataContext>())
            {
                var groups = dc.DataContext.CatalogItems.GroupBy( c => c.ParentItemID ).ToDictionary( g => g.Key ?? 0 );

                if( groups.Count != 0 )
                {
                    var stack = new Stack<KeyValuePair<CatalogItem,int>>();

                    foreach( var item in groups[ 0 ].OrderByDescending( c=>c.CatalogItemPriority ) )
                        stack.Push( new KeyValuePair<CatalogItem, int>( item, 0 ) );

                    while( stack.Count != 0 )
                    {
                        var node = stack.Pop();
                        dropDownList.Items.Add(
                            new ListItem(
                                new string( '.', 3*node.Value ) + node.Key.CatalogItemName,
                                node.Key.CatalogItemID.ToString() )
                                );

                        if( groups.ContainsKey( node.Key.CatalogItemID ) )
                        {
                            foreach( var item in groups[ node.Key.CatalogItemID ].OrderByDescending( c => c.CatalogItemPriority ) )
                                stack.Push( new KeyValuePair<CatalogItem, int>( item, node.Value + 1 ) );
                        }
                    }

                }

            }
        }
Exemple #20
0
 public static HandyClientSetEntry[] GetHandySetEntries(int managerId)
 {
     using (var dc = new DCFactory<StoreDataContext>())
     {
         return _getHandySetEntries(dc.DataContext, managerId).ToArray();
     }
 }
Exemple #21
0
 public static UserMaintEntry GetEntry(Guid entryUid)
 {
     using (var dc = new DCFactory<StoreDataContext>())
     {
         return _getEntries(dc.DataContext, entryUid).SingleOrDefault();
     }
 }
 public static SeoShortLink GetSeoShortLink( int id )
 {
     using (var dc = new DCFactory<CmsDataContext>())
     {
         return _getSeoShortLink( dc.DataContext, id );
     }
 }
        public static void SaveClientAlertConfig(
			string clientId,
			int hourOfPeriod,
			string statusIds)
        {
            using (var dc = new DCFactory<StoreDataContext>())
            {
                var alertConfig = _getAlertConfigByClientId(dc.DataContext, clientId).SingleOrDefault();

                if (alertConfig != null)
                {
                    alertConfig.HourOfPeriod = hourOfPeriod;
                    alertConfig.StatusIDs = statusIds;
                }
                else
                {
                    alertConfig = new ClientAlertConfig
                    {
                        ClientID = clientId,
                        HourOfPeriod = hourOfPeriod,
                        StatusIDs = statusIds
                    };
                    dc.DataContext.ClientAlertConfigs.InsertOnSubmit(alertConfig);
                }
                dc.DataContext.SubmitChanges();
            }
        }
 public static int GetDiscountSparePartCount(string brand)
 {
     using (var dc = new DCFactory<StoreDataContext>())
     {
         return dc.DataContext.DiscountSpareParts.Where(d => d.Manufacturer == brand).Count();
     }
 }
 public static Reclamation GetReclamation( string clientId, int reclamationId )
 {
     using (var dc = new DCFactory<StoreDataContext>())
     {
         return dc.DataContext.Reclamations.Single( r => r.ClientID == clientId && r.ReclamationID == reclamationId );
     }
 }
 public static SeoTecDocTextTemplate[] GetTextTemplates()
 {
     using (var dc = new DCFactory<CmsDataContext>())
     {
         return _getSeoTecDocTextTemplates( dc.DataContext ).ToArray();
     }
 }
Exemple #27
0
 protected void _repeater_ItemCommand( object source, RepeaterCommandEventArgs e )
 {
     try
     {
         if( e.CommandName == "Delete" )
         {
             using (var dc = new DCFactory<CmsDataContext>())
             {
                 int id = Convert.ToInt32( e.CommandArgument );
                 CatalogItem item = dc.DataContext.CatalogItems.Where( c => c.CatalogItemID == id ).SingleOrDefault();
                 if( item != null )
                     dc.DataContext.CatalogItems.DeleteOnSubmit( item );
                 dc.DataContext.SubmitChanges();
                 Response.Redirect( table.ListActionPath, true );
             }
         }
     }
     catch( ThreadAbortException )
     {
         throw;
     }
     catch( Exception ex )
     {
         _errorLabel.Text = ex.Message;
     }
 }
Exemple #28
0
 public static VinRequest GetRequest(int requestId)
 {
     using (var ctx = new DCFactory<StoreDataContext>())
     {
         return _getVinRequest(ctx.DataContext, requestId).Single();
     }
 }
Exemple #29
0
        public static void SaveProfile(
            int userId,
            IDictionary<string, object> propValues,
            DateTime activityTime)
        {
            using (var dc = new DCFactory<StoreDataContext>())
            {
                var entry = _getEntriesByUserId(dc.DataContext, userId).SingleOrDefault();

                if (entry != null)
                {
                    entry.NameObjectMap = propValues;
                    entry.LastActivityTime = activityTime;
                    entry.LastUpdateTime = DateTime.Now;
                }
                else
                {
                    entry = new UserProfileEntry
                    {
                        UserID = userId,
                        NameObjectMap = propValues,
                        LastActivityTime = activityTime,
                        LastUpdateTime = DateTime.Now
                    };
                    dc.DataContext.UserProfileEntries.InsertOnSubmit(entry);
                }
                dc.DataContext.SubmitChanges();
            }
        }
Exemple #30
0
 public static FeedbackRecipient GetFeedbackRecipient(int id)
 {
     using(var dc = new  DCFactory<CmsDataContext>())
     {
      				return _getFeedbackRecipient(dc.DataContext, id);
     }
 }