<% Response.Buffer=false server.ScriptTimeout = 72000 v_BrandID = request("cbobrand") v_State = request("txtstate") ConString = "Provider=SQLOLEDB;Server=sql3.hostek.com;Database=popularglasses;UID=popularadmin;PWD=ochkee;" Set BrandRs = Server.CreateObject("ADODB.Recordset") Set DBConn = Server.CreateObject("ADODB.Connection") DBConn.Open Session("DSN") Set PopularCon = Server.CreateObject("ADODB.Connection") Set PopularRecordSet = Server.Createobject("ADODB.Recordset") PopularCon.Open ConString PopularCon.Execute "exec p_popular_count" PopularRecordSet.Open "select BrandName,CategoryName,Count,DecorBrandId from DMETempCounter",PopularCon %>
Popular Glasses Brand Counter
<% do until PopularRecordSet.eof=true %> <% PopularRecordSet.MoveNext Loop PopularRecordSet.close %>
<%=PopularRecordSet.Fields(0)%> <%=PopularRecordSet.Fields(1)%> <%=PopularRecordSet.Fields(2)%> <% 'Get count from DecorMyEyes.com DB If PopularRecordSet.Fields("DecorBrandID") > 0 then tSql = "p_color_count " & PopularRecordSet.Fields("DecorBrandID") BrandRs.Open tSql,DBConn Response.Write s Response.Write BrandRs.Fields(0) BrandRs.Close Else Response.Write "N/A" End if %>
Brand:
<% if v_State = 1 then Set objRS = Server.CreateObject("ADODB.Recordset") 'PopularCon.ConnectionString = ConString 'PopularCon.Mode = adModeReadWrite 'PopularCon.Open 'Run the process to move the products you dont have to the DecorMyEyesFeed table 'get only 1 brand SQL = "p_popular_feed_data_create " & v_BrandID PopularCon.Execute SQL 'Select from this table to get the data SQL = "exec p_popular_data_get" objRS.Open SQL,PopularCon Function TestNull(fieldvalue) If isnumeric(fieldvalue) Then If trim(fieldvalue) ="" Then TestNull = 0 Else TestNull = fieldvalue End if else TestNull = 0 end if End Function Public Function FileNameFromPath(strFullPath) if instr(strFullPath,"/") <> 0 then FileNameFromPath = replace(Right(strFullPath, Len(strFullPath) - InStrRev(strFullPath, "/")),".jpg","") else FileNameFromPath = strFullPath End if End Function Function DoesColorExist(BrandID,ProdName,ColorCode) Set RS = Server.CreateObject("ADODB.Recordset") SQL = "select * from products_colors where brand_id = " & BrandID SQL = SQL & " and product_n='" & objRS("ProductName") & "' and color_code_n='" & objRS.fields("ColorCode") & "'" RS.Open SQL,Session("DSN") if RS.BOF=true and RS.EOF=true then DoesColorExist = false else DoesColorExist = true end if End Function Function DoesProductExist(BrandID,ProdName) Set RS = Server.CreateObject("ADODB.Recordset") SQL = "select * from products where brand_id = " & BrandID SQL = SQL & " and product_n='" & objRS("ProductName") & "'" RS.Open SQL,Session("DSN") if RS.BOF=true and RS.EOF=true then DoesProductExist = false else DoesProductExist = true end if End Function Function GetNextProductID() Set Rs = Server.Createobject("ADODB.Recordset") 'Get the max productID from decormyeyes.com Rs.Open "select max(product_id) from products",Session("DSN") v_MaxID = rs.Fields(0) rs.Close Set Rs = nothing GetNextProductID = v_MaxID End Function Sub reNameFile(FileName,v_BrandID) 'on error resume next Dim fso Set fso = CreateObject("Scripting.FileSystemObject") oldFileName = "d:\home\hnt27a011\wwwroot" & replace(FileName,"/","\") newFileName = server.MapPath("Shades/ProductImages/" & v_BrandID & "/" & FileNameFromPath(FileName) & ".jpg") Response.Write "OLD_FILENAME:" & oldFileName & "
" Response.Write "NEW_FILENAME:" & newFileName & "

" 'Response.End fso.CopyFile oldFileName ,newFileName Set fso = Nothing End Sub Function GetProductID(BrandID,ProdName) Set RS = Server.CreateObject("ADODB.Recordset") SQL = "select product_id from products where brand_id = " & BrandID SQL = SQL & " and product_n='" & trim(objRS("ProductName")) & "'" RS.Open SQL,Session("DSN") GetProductID = RS("product_id") End Function %> <% counter=0 'Loop the Popular Database Do until objRS.EOF = true 'or cint(counter) = cint(v_LoopCounter) counter=counter+1 Response.Write "Processing Record #" & counter If DoesColorExist(objRS("DecorBrandID") ,objRS("ProductName"),objRS.fields("ColorCode")) = false then Response.Write "" If DoesProductExist(objRS("DecorBrandID") ,objRS("ProductName")) = false then If right(trim(objRS.fields("ProductName")),1) = "B" then v_Svarovsky = 1 else v_Svarovsky = 0 End if Response.Write "" Response.Write "" Response.Write "" else pic1= "" pic2= "" pic3= "" pic4= "" pic5= "" v_Done=false Response.Write "" Response.Write "" end if Response.Write "" End If objRS.movenext Loop Response.Write "End Processing" set BrandRs = nothing set objRS = nothing set PopularCon = nothing End if %>
MISSING PRODUCT: " & objRS.fields("ProductName") & "
COLOR: " & objRS.fields("ColorCode") & "
Adding the product that does not exist
" sqlInsert = "INSERT INTO products ( brand_id, product_n,counter_offer_price, show_i, eye, bridge, temple,offer_clicks,gender_i,rimless_i,swarovski_i,auto_add ) values (" sqlInsert = sqlInsert & objRS("DecorBrandID") & ",'" & trim(objRS.fields("ProductName")) & "'," & TestNull(objRS.fields("Price")) & ",1," & TestNull(objRS("Eye")) & "," & TestNull(objRS("Bridge")) & "," & TestNull(objRS("Temple")) & ",0,3,0," & v_Svarovsky & ",1)" Response.Write sqlInsert DBConn.Execute sqlInsert v_MaxProdID = GetNextProductID() v_Done=false Response.Write "
Adding the color that does not exist
" 'Update the Product Colors Table based on the amount of pics we have. pic1= FileNameFromPath(objRS.fields("LargeImageURL")) if isnull(objRS("pic2")) and v_Done=false then pic2= FileNameFromPath(objRS.fields("LargeImageURL")) pic3= FileNameFromPath(objRS.fields("LargeImageURL")) pic4= FileNameFromPath(objRS.fields("LargeImageURL")) pic5= FileNameFromPath(objRS.fields("LargeImageURL")) reNameFile objRS.fields("LargeImageURL"),objRS("DecorBrandID") v_Done=true end if if isnull(objRS("pic3")) and v_Done=false then pic2= FileNameFromPath(objRS.fields("LargeImageURL")) pic3= FileNameFromPath(objRS.fields("pic2")) pic4= FileNameFromPath(objRS.fields("LargeImageURL")) pic5= FileNameFromPath(objRS.fields("pic2")) Response.Write "3" reNameFile objRS.fields("LargeImageURL"),objRS("DecorBrandID") reNameFile objRS.fields("pic2"),objRS("DecorBrandID") v_Done=true end if if isnull(objRS("pic4")) and v_Done=false then pic2= FileNameFromPath(objRS.fields("pic2")) pic3= FileNameFromPath(objRS.fields("pic3")) pic4= FileNameFromPath(objRS.fields("pic2")) pic5= FileNameFromPath(objRS.fields("LargeImageURL")) Response.Write "4" reNameFile objRS.fields("LargeImageURL"),objRS("DecorBrandID") reNameFile objRS.fields("pic2"),objRS("DecorBrandID") reNameFile objRS.fields("pic3"),objRS("DecorBrandID") v_Done=true end if if isnull(objRS("pic5")) and v_Done=false then pic2= FileNameFromPath(objRS.fields("pic2")) pic3= FileNameFromPath(objRS.fields("pic3")) pic4= FileNameFromPath(objRS.fields("pic4")) pic5= FileNameFromPath(objRS.fields("pic2")) Response.Write "5" reNameFile objRS.fields("LargeImageURL"),objRS("DecorBrandID") reNameFile objRS.fields("pic2"),objRS("DecorBrandID") reNameFile objRS.fields("pic3"),objRS("DecorBrandID") reNameFile objRS.fields("pic4"),objRS("DecorBrandID") v_Done=true end if sqlUpdate = "INSERT into products_colors (brand_id, product_id, product_n, show_I, color_code_n, color_name,pic1,pic2,pic3,pic4,pic5,offer_clicks,most_popular_i,clearance_i,auto_add) values(" sqlUpdate = sqlUpdate & objRS("DecorBrandID") & "," & v_MaxProdID & ",'" & trim(ucase(objRS.fields("ProductName"))) & "',1,'" & ucase(trim(objRS.fields("ColorCode"))) & "','" & lcase(trim(objRS.fields("ColorName"))) & "','" & pic1 & "','" & pic2 & "','" & pic3 & "','" & pic4 & "','" & pic5 & "',0,0,0,1)" Response.Write sqlUpdate & "
" DBConn.Execute sqlUpdate Response.Write "
Adding the color that does not exist
" 'Update the Product Colors Table based on the amount of pics we have. pic1= FileNameFromPath(objRS.fields("LargeImageURL")) if isnull(objRS("pic2")) and v_Done=false then pic2= FileNameFromPath(objRS.fields("LargeImageURL")) pic3= FileNameFromPath(objRS.fields("LargeImageURL")) pic4= FileNameFromPath(objRS.fields("LargeImageURL")) pic5= FileNameFromPath(objRS.fields("LargeImageURL")) reNameFile objRS.fields("LargeImageURL"),objRS("DecorBrandID") v_Done=true end if if isnull(objRS("pic3")) and v_Done=false then pic2= FileNameFromPath(objRS.fields("LargeImageURL")) pic3= FileNameFromPath(objRS.fields("pic2")) pic4= FileNameFromPath(objRS.fields("LargeImageURL")) pic5= FileNameFromPath(objRS.fields("pic2")) Response.Write "3" reNameFile objRS.fields("LargeImageURL"),objRS("DecorBrandID") reNameFile objRS.fields("pic2"),objRS("DecorBrandID") v_Done=true end if if isnull(objRS("pic4")) and v_Done=false then pic2= FileNameFromPath(objRS.fields("pic2")) pic3= FileNameFromPath(objRS.fields("pic3")) pic4= FileNameFromPath(objRS.fields("pic2")) pic5= FileNameFromPath(objRS.fields("LargeImageURL")) Response.Write "4" reNameFile objRS.fields("LargeImageURL"),objRS("DecorBrandID") reNameFile objRS.fields("pic2"),objRS("DecorBrandID") reNameFile objRS.fields("pic3"),objRS("DecorBrandID") v_Done=true end if if isnull(objRS("pic5")) and v_Done=false then pic2= FileNameFromPath(objRS.fields("pic2")) pic3= FileNameFromPath(objRS.fields("pic3")) pic4= FileNameFromPath(objRS.fields("pic4")) pic5= FileNameFromPath(objRS.fields("pic2")) Response.Write "5" reNameFile objRS.fields("LargeImageURL"),objRS("DecorBrandID") reNameFile objRS.fields("pic2"),objRS("DecorBrandID") reNameFile objRS.fields("pic3"),objRS("DecorBrandID") reNameFile objRS.fields("pic4"),objRS("DecorBrandID") v_Done=true end if v_ProductIDForThisItem = GetProductID(objRS("DecorBrandID") ,objRS("ProductName")) sqlUpdate = "INSERT into products_colors (brand_id, product_id, product_n, show_I, color_code_n, color_name,pic1,pic2,pic3,pic4,pic5,offer_clicks,most_popular_i,clearance_i,auto_add) values(" sqlUpdate = sqlUpdate & objRS("DecorBrandID") & "," & v_ProductIDForThisItem & ",'" & trim(ucase(objRS.fields("ProductName"))) & "',1,'" & ucase(trim(objRS.fields("ColorCode"))) & "','" & lcase(trim(objRS.fields("ColorName"))) & "','" & pic1 & "','" & pic2 & "','" & pic3 & "','" & pic4 & "','" & pic5 & "',0,0,0,1)" Response.Write sqlUpdate & "
" DBConn.Execute sqlUpdate Response.Write "